New upstream version 2.3.4
This commit is contained in:
		
							parent
							
								
									e7bdd1c6c6
								
							
						
					
					
						commit
						de72f6f588
					
				
					 556 changed files with 90432 additions and 53391 deletions
				
			
		| 
						 | 
					@ -20,7 +20,7 @@ Using the DLPI support on SysV systems to get the host MAC address in check_dhcp
 | 
				
			||||||
Stenberg, Daniel
 | 
					Stenberg, Daniel
 | 
				
			||||||
Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se>
 | 
					Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se>
 | 
				
			||||||
http://curl.haxx.se/
 | 
					http://curl.haxx.se/
 | 
				
			||||||
Use of duplication of macros in m4/np_curl.m4 (slighly adapted for m4/uriparser.m4 too)
 | 
					Use of duplication of macros in m4/np_curl.m4 (slightly adapted for m4/uriparser.m4 too)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Coreutils team
 | 
					Coreutils team
 | 
				
			||||||
Copyright (C) 91, 1995-2004 Free Software Foundation, Inc.
 | 
					Copyright (C) 91, 1995-2004 Free Software Foundation, Inc.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								INSTALL
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								INSTALL
									
										
									
									
									
								
							| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
Installation Instructions
 | 
					Installation Instructions
 | 
				
			||||||
*************************
 | 
					*************************
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
 | 
					   Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
 | 
				
			||||||
Software Foundation, Inc.
 | 
					Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copying and distribution of this file, with or without modification,
 | 
					   Copying and distribution of this file, with or without modification,
 | 
				
			||||||
are permitted in any medium without royalty provided the copyright
 | 
					are permitted in any medium without royalty provided the copyright
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1124
									
								
								Makefile.in
									
										
									
									
									
								
							
							
						
						
									
										1124
									
								
								Makefile.in
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										64
									
								
								NEWS
									
										
									
									
									
								
							
							
						
						
									
										64
									
								
								NEWS
									
										
									
									
									
								
							| 
						 | 
					@ -1,5 +1,39 @@
 | 
				
			||||||
This file documents the major additions and syntax changes between releases.
 | 
					This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2.3.4 18th Oct 2023
 | 
				
			||||||
 | 
						ENHANCEMENTS
 | 
				
			||||||
 | 
						* check_curl: added --cookie-jar and doing proper cleanup of libcurl
 | 
				
			||||||
 | 
						* check_curl: Include all IPs from getaddrinfo() in curl DNS cache
 | 
				
			||||||
 | 
						* check_dhcp: Add dhcp rogue detection
 | 
				
			||||||
 | 
						* check_disk: add ignore-missing option to return OK for missing fs
 | 
				
			||||||
 | 
						* check_disk_smb: allow checking 0-sized resource (ex. IPC$)
 | 
				
			||||||
 | 
						* check_disk: The options to include or exclude specific file systems now allow the usage of regex(7)
 | 
				
			||||||
 | 
						* check_icmp: Add support to Jitter, MOS and Score
 | 
				
			||||||
 | 
						* check_mysql: Detect running mysqldump and handle it more gracefully
 | 
				
			||||||
 | 
						* check_procs: Implement --exclude-process to exclude specific processes
 | 
				
			||||||
 | 
						* check_smtp: add new longoption --tls
 | 
				
			||||||
 | 
						* check_smtp: Add option to prefix PROXY header
 | 
				
			||||||
 | 
						* check_smtp: Add support for SMTP over TLS
 | 
				
			||||||
 | 
						* check_smtp: Add support for SNI
 | 
				
			||||||
 | 
						* check_snmp: Implement option to ignore mib file parsing errors
 | 
				
			||||||
 | 
						* check_users: prefer systemd-logind over utmp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						FIXES
 | 
				
			||||||
 | 
						* check_disk: Display SI units correctly
 | 
				
			||||||
 | 
						* check_ircd: use pack_sockaddr_in rather than hand-rolled
 | 
				
			||||||
 | 
						* check_log/check_oracle/check_sensors: fixed the outputs of the help functionality
 | 
				
			||||||
 | 
						* check_mysql: Add mysql_close to avoid spamming the server logs
 | 
				
			||||||
 | 
						* check_smtp: add missing -r option in usage
 | 
				
			||||||
 | 
						* check_snmp: disable multiplier when unused
 | 
				
			||||||
 | 
						* check_wave: Use compile time determined path to snmpget
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						GENERAL
 | 
				
			||||||
 | 
						* Sync with the Gnulib code 668c0b8ffa
 | 
				
			||||||
 | 
						* Set autoconf prerequisite version to 2.64
 | 
				
			||||||
 | 
						* Remove sha1 and use sha256 in some parts of the plugin structure
 | 
				
			||||||
 | 
						* A lot of compiler warnings were fixed
 | 
				
			||||||
 | 
						* Some code was refactored a little bit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.3.3 2nd Feb 2023
 | 
					2.3.3 2nd Feb 2023
 | 
				
			||||||
        ENHANCEMENTS
 | 
					        ENHANCEMENTS
 | 
				
			||||||
	using PRId64 and PRIu64 instead of %ld directly
 | 
						using PRId64 and PRIu64 instead of %ld directly
 | 
				
			||||||
| 
						 | 
					@ -9,12 +43,12 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	check_http/check_curl: add chunked encoding test
 | 
						check_http/check_curl: add chunked encoding test
 | 
				
			||||||
	check_log: Added --exclude to exclude patterns
 | 
						check_log: Added --exclude to exclude patterns
 | 
				
			||||||
	check_log: Add tests
 | 
						check_log: Add tests
 | 
				
			||||||
	check_disk: Clarify usage possibilites
 | 
						check_disk: Clarify usage possibilities
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	FIXES
 | 
						FIXES
 | 
				
			||||||
	fixed two PRId64 to PRIu64 in perfdata_uint64
 | 
						fixed two PRId64 to PRIu64 in perfdata_uint64
 | 
				
			||||||
	check_pgsql: Removing is_pg_dbname alltogether,using postgres API.
 | 
						check_pgsql: Removing is_pg_dbname altogether,using postgres API.
 | 
				
			||||||
	check_http: Remove superflous CRLF in HTTP-Requests
 | 
						check_http: Remove superfluous CRLF in HTTP-Requests
 | 
				
			||||||
	check_curl: detect ipv6
 | 
						check_curl: detect ipv6
 | 
				
			||||||
	check_icmp: fix parsing help/version long options
 | 
						check_icmp: fix parsing help/version long options
 | 
				
			||||||
	check_http: fix test plan
 | 
						check_http: fix test plan
 | 
				
			||||||
| 
						 | 
					@ -40,7 +74,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.3.2 20th Oct 2022
 | 
					2.3.2 20th Oct 2022
 | 
				
			||||||
	GENERAL
 | 
						GENERAL
 | 
				
			||||||
	Use netcat-openbsd for debian explicitely (by @RincewindsHat #1704)
 | 
						Use netcat-openbsd for debian explicitly (by @RincewindsHat #1704)
 | 
				
			||||||
	Replace egrep with grep -E (by @RincewindsHat #1791)
 | 
						Replace egrep with grep -E (by @RincewindsHat #1791)
 | 
				
			||||||
	Use silent automake by default (by @RincewindsHat #1747)
 | 
						Use silent automake by default (by @RincewindsHat #1747)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,7 +157,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	check_log: Modernize check log (by @RincewindsHat #1692)
 | 
						check_log: Modernize check log (by @RincewindsHat #1692)
 | 
				
			||||||
	check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755)
 | 
						check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755)
 | 
				
			||||||
	check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781)
 | 
						check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781)
 | 
				
			||||||
	check_pgsql: Using snprintf which honors the buffers size and guarantees null temination. (Closes: #1601) (by @waja #1663)
 | 
						check_pgsql: Using snprintf which honors the buffers size and guarantees null termination. (Closes: #1601) (by @waja #1663)
 | 
				
			||||||
	check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743)
 | 
						check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743)
 | 
				
			||||||
	check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679)
 | 
						check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679)
 | 
				
			||||||
	check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676)
 | 
						check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676)
 | 
				
			||||||
| 
						 | 
					@ -165,7 +199,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	check_apt: adding packages-warning option
 | 
						check_apt: adding packages-warning option
 | 
				
			||||||
	check_load: Adding top consuming processes option
 | 
						check_load: Adding top consuming processes option
 | 
				
			||||||
	check_http: Adding Proxy-Authorization and extra headers
 | 
						check_http: Adding Proxy-Authorization and extra headers
 | 
				
			||||||
	check_snmp: make calcualtion of timeout value in help output more clear
 | 
						check_snmp: make calculation of timeout value in help output more clear
 | 
				
			||||||
	check_uptime: new plugin for checking uptime to see how long the system is running
 | 
						check_uptime: new plugin for checking uptime to see how long the system is running
 | 
				
			||||||
	check_curl: check_http replacement based on libcurl
 | 
						check_curl: check_http replacement based on libcurl
 | 
				
			||||||
	check_http: Allow user to specify HTTP method after proxy CONNECT
 | 
						check_http: Allow user to specify HTTP method after proxy CONNECT
 | 
				
			||||||
| 
						 | 
					@ -195,7 +229,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	check_procs: improve command examples for 'at least' processes
 | 
						check_procs: improve command examples for 'at least' processes
 | 
				
			||||||
	check_swap: repaired "-n" behaviour
 | 
						check_swap: repaired "-n" behaviour
 | 
				
			||||||
	check_disk: include -P switch in help
 | 
						check_disk: include -P switch in help
 | 
				
			||||||
	check_mailq: restore accidentially removed options
 | 
						check_mailq: restore accidentally removed options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.2 29th November 2016
 | 
					2.2 29th November 2016
 | 
				
			||||||
	ENHANCEMENTS
 | 
						ENHANCEMENTS
 | 
				
			||||||
| 
						 | 
					@ -236,7 +270,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	check_ssh now returns CRITICAL for protocol/version errors
 | 
						check_ssh now returns CRITICAL for protocol/version errors
 | 
				
			||||||
	If a plugin is invoked with -h/--help or -V/--version, the exit status
 | 
						If a plugin is invoked with -h/--help or -V/--version, the exit status
 | 
				
			||||||
	  is now UNKNOWN
 | 
						  is now UNKNOWN
 | 
				
			||||||
	The superseeded check_ntp.pl was removed, please use check_ntp_peer or
 | 
						The superseded check_ntp.pl was removed, please use check_ntp_peer or
 | 
				
			||||||
	  check_ntp_time instead
 | 
						  check_ntp_time instead
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.1.2 16th October 2015
 | 
					2.1.2 16th October 2015
 | 
				
			||||||
| 
						 | 
					@ -263,7 +297,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	New check_mysql -n option to ignore authentication failures
 | 
						New check_mysql -n option to ignore authentication failures
 | 
				
			||||||
	Added IP and port or socket name to error messages
 | 
						Added IP and port or socket name to error messages
 | 
				
			||||||
	New check_ntp_time -o option to add expected offset
 | 
						New check_ntp_time -o option to add expected offset
 | 
				
			||||||
	check_disk shows now troubled partions in verbose mode
 | 
						check_disk shows now troubled partitions in verbose mode
 | 
				
			||||||
	check_dig has now support for drill and dig
 | 
						check_dig has now support for drill and dig
 | 
				
			||||||
	check_dig has now support for -6 option
 | 
						check_dig has now support for -6 option
 | 
				
			||||||
	Add performance data to check_file_age
 | 
						Add performance data to check_file_age
 | 
				
			||||||
| 
						 | 
					@ -357,10 +391,10 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	New check_procs -k option to ignore kernel threads (on Linux)
 | 
						New check_procs -k option to ignore kernel threads (on Linux)
 | 
				
			||||||
	Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified
 | 
						Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified
 | 
				
			||||||
	Let check_mysql support SSL
 | 
						Let check_mysql support SSL
 | 
				
			||||||
	Let check_mysql add perfromance metrics for all checks
 | 
						Let check_mysql add performance metrics for all checks
 | 
				
			||||||
	New check_mysql -f option to specify a client options file
 | 
						New check_mysql -f option to specify a client options file
 | 
				
			||||||
	New check_mysql -g option to specify a client options group
 | 
						New check_mysql -g option to specify a client options group
 | 
				
			||||||
	New check_snmp --offset option to allow for adding/substracting an offset value to sensor data
 | 
						New check_snmp --offset option to allow for adding/subtracting an offset value to sensor data
 | 
				
			||||||
	Let check_snmp support an arbitrary number of OIDs
 | 
						Let check_snmp support an arbitrary number of OIDs
 | 
				
			||||||
	Let check_ide_smart support NetBSD
 | 
						Let check_ide_smart support NetBSD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -375,7 +409,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	Fix deprecated imports of check_nmap.py
 | 
						Fix deprecated imports of check_nmap.py
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	WARNINGS
 | 
						WARNINGS
 | 
				
			||||||
	check_http behaviour of -k/--header changed since it does not seperate multiple headers by semicolons anymore. Use multiple -k switches instead.
 | 
						check_http behaviour of -k/--header changed since it does not separate multiple headers by semicolons anymore. Use multiple -k switches instead.
 | 
				
			||||||
	check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way)
 | 
						check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way)
 | 
				
			||||||
	The contrib directory has been removed from this distribution
 | 
						The contrib directory has been removed from this distribution
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -526,7 +560,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help
 | 
						check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help
 | 
				
			||||||
	check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers)
 | 
						check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers)
 | 
				
			||||||
	check_mysql and check_radius now try clearing password in processlist just like check_mysql_query
 | 
						check_mysql and check_radius now try clearing password in processlist just like check_mysql_query
 | 
				
			||||||
	check_mysql and check_mysql_query now support sockets explicitely (-s, --socket)
 | 
						check_mysql and check_mysql_query now support sockets explicitly (-s, --socket)
 | 
				
			||||||
	negate now has the ability to replace the status text as well (-s, --substitute)
 | 
						negate now has the ability to replace the status text as well (-s, --substitute)
 | 
				
			||||||
	Added performance data to check_ping
 | 
						Added performance data to check_ping
 | 
				
			||||||
	Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
 | 
						Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
 | 
				
			||||||
| 
						 | 
					@ -566,7 +600,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
 | 
						New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
 | 
				
			||||||
	  Thus accessibility of remote filesystems can be checked without any threshold comparison.
 | 
						  Thus accessibility of remote filesystems can be checked without any threshold comparison.
 | 
				
			||||||
	Check_disk's --help now prints some examples for the new features introduced in 1.4.8
 | 
						Check_disk's --help now prints some examples for the new features introduced in 1.4.8
 | 
				
			||||||
	New check_disk -i/-I option to ignore pathes/partitions based on regular expressions
 | 
						New check_disk -i/-I option to ignore paths/partitions based on regular expressions
 | 
				
			||||||
	New check_disk -A option to select all filesystems explicitly
 | 
						New check_disk -A option to select all filesystems explicitly
 | 
				
			||||||
	WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
 | 
						WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
 | 
				
			||||||
	  Passing -E after -p or -r results in UNKNOWN state, now
 | 
						  Passing -E after -p or -r results in UNKNOWN state, now
 | 
				
			||||||
| 
						 | 
					@ -615,7 +649,7 @@ This file documents the major additions and syntax changes between releases.
 | 
				
			||||||
	Fixed MKINSTALLDIRS problem in po/
 | 
						Fixed MKINSTALLDIRS problem in po/
 | 
				
			||||||
	./configure now detects if possible to compile check_mysql
 | 
						./configure now detects if possible to compile check_mysql
 | 
				
			||||||
	Fixed broken HELO in check_smtp
 | 
						Fixed broken HELO in check_smtp
 | 
				
			||||||
	check_icmp now allows to set a minimum number of hosts required for successs (-m)
 | 
						check_icmp now allows to set a minimum number of hosts required for success (-m)
 | 
				
			||||||
	check_icmp fix for *BSD when running for long time
 | 
						check_icmp fix for *BSD when running for long time
 | 
				
			||||||
	check_ping times out 1 second quicker if host is unreachable
 | 
						check_ping times out 1 second quicker if host is unreachable
 | 
				
			||||||
	Root plugins installed with world executable
 | 
						Root plugins installed with world executable
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@
 | 
				
			||||||
SRC_ROOT=`dirname $0`
 | 
					SRC_ROOT=`dirname $0`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NPVF=NP-VERSION-FILE
 | 
					NPVF=NP-VERSION-FILE
 | 
				
			||||||
DEF_VER=2.3.3
 | 
					DEF_VER=2.3.4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LF='
 | 
					LF='
 | 
				
			||||||
'
 | 
					'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -151,14 +151,14 @@ of testing against a set of desired exit status values.
 | 
				
			||||||
=item *
 | 
					=item *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Firstly, if C<$desiredExitStatus> is a reference to an array of exit
 | 
					Firstly, if C<$desiredExitStatus> is a reference to an array of exit
 | 
				
			||||||
stati, if the actual exit status of the command is present in the
 | 
					statuses, if the actual exit status of the command is present in the
 | 
				
			||||||
array, it is used in the call to C<Test::ok(...)> when testing the
 | 
					array, it is used in the call to C<Test::ok(...)> when testing the
 | 
				
			||||||
exit status.
 | 
					exit status.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=item *
 | 
					=item *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Alternatively, if C<$desiredExitStatus> is a reference to a hash of
 | 
					Alternatively, if C<$desiredExitStatus> is a reference to a hash of
 | 
				
			||||||
exit stati (mapped to the strings "continue" or "skip"), similar
 | 
					exit  statuses(mapped to the strings "continue" or "skip"), similar
 | 
				
			||||||
processing to the above occurs with the side affect of determining if
 | 
					processing to the above occurs with the side affect of determining if
 | 
				
			||||||
any generated output testing should proceed. Note: only the string
 | 
					any generated output testing should proceed. Note: only the string
 | 
				
			||||||
"skip" will result in generated output testing being skipped.
 | 
					"skip" will result in generated output testing being skipped.
 | 
				
			||||||
| 
						 | 
					@ -207,7 +207,7 @@ under the same terms as the Monitoring Plugins release.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my( %CACHE ) = ();
 | 
					my( %CACHE ) = ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# I'm not really sure wether to house a site-specific cache inside
 | 
					# I'm not really sure whether to house a site-specific cache inside
 | 
				
			||||||
# or outside of the extracted source / build tree - lets default to outside
 | 
					# or outside of the extracted source / build tree - lets default to outside
 | 
				
			||||||
my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} )
 | 
					my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} )
 | 
				
			||||||
                       ? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd";
 | 
					                       ? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										34
									
								
								THANKS
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								THANKS
									
										
									
									
									
								
							| 
						 | 
					@ -2,22 +2,25 @@ This software is brought to you by the Monitoring Plugins Development Team. Howe
 | 
				
			||||||
there have been many contributors to this project. Everyone below has helped in 
 | 
					there have been many contributors to this project. Everyone below has helped in 
 | 
				
			||||||
raising bug reports, creating patches or contributing new plugins.
 | 
					raising bug reports, creating patches or contributing new plugins.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Elan Ruusamäe
 | 
					Thoralf Rickert-Wendt
 | 
				
			||||||
Randy O'Meara
 | 
					 | 
				
			||||||
Wolfgang Karall-Ahlborn
 | 
					 | 
				
			||||||
Nicolai Søborg
 | 
					 | 
				
			||||||
dag rob?le
 | 
					 | 
				
			||||||
Diego Elio Pettenò
 | 
					 | 
				
			||||||
Matthias Hähnel
 | 
					Matthias Hähnel
 | 
				
			||||||
 | 
					Randy O'Meara
 | 
				
			||||||
 | 
					dag rob?le
 | 
				
			||||||
Marc Sánchez
 | 
					Marc Sánchez
 | 
				
			||||||
 | 
					Arkadiusz Miśkiewicz
 | 
				
			||||||
Aksel Sjögren
 | 
					Aksel Sjögren
 | 
				
			||||||
fabiodds
 | 
					fabiodds
 | 
				
			||||||
 | 
					Diego Elio Pettenò
 | 
				
			||||||
 | 
					Nicolai Søborg
 | 
				
			||||||
 | 
					Elan Ruusamäe
 | 
				
			||||||
 | 
					Matthias Döhler
 | 
				
			||||||
 | 
					Wolfgang Karall-Ahlborn
 | 
				
			||||||
Oskar Ahner
 | 
					Oskar Ahner
 | 
				
			||||||
Lance Albertson
 | 
					Lance Albertson
 | 
				
			||||||
David Alden
 | 
					David Alden
 | 
				
			||||||
Patrick Allen
 | 
					Patrick Allen
 | 
				
			||||||
Rodger Allen
 | 
					 | 
				
			||||||
Paul Allen
 | 
					Paul Allen
 | 
				
			||||||
 | 
					Rodger Allen
 | 
				
			||||||
Felipe Gustavo de Almeida
 | 
					Felipe Gustavo de Almeida
 | 
				
			||||||
Michael Almond
 | 
					Michael Almond
 | 
				
			||||||
Michael Anthon
 | 
					Michael Anthon
 | 
				
			||||||
| 
						 | 
					@ -44,6 +47,7 @@ Hilko Bengen
 | 
				
			||||||
Jason Benguerel
 | 
					Jason Benguerel
 | 
				
			||||||
Allan Bennett
 | 
					Allan Bennett
 | 
				
			||||||
Booker C. Bense
 | 
					Booker C. Bense
 | 
				
			||||||
 | 
					Björn Berg
 | 
				
			||||||
Guy Van Den Bergh
 | 
					Guy Van Den Bergh
 | 
				
			||||||
Andrew Berglund
 | 
					Andrew Berglund
 | 
				
			||||||
Jimmy Bergman
 | 
					Jimmy Bergman
 | 
				
			||||||
| 
						 | 
					@ -75,6 +79,7 @@ Jethro Carr
 | 
				
			||||||
Jim Carroll
 | 
					Jim Carroll
 | 
				
			||||||
Ian Cass
 | 
					Ian Cass
 | 
				
			||||||
Arnold Cavazos
 | 
					Arnold Cavazos
 | 
				
			||||||
 | 
					Patrick Cervicek
 | 
				
			||||||
Alex Chaffee
 | 
					Alex Chaffee
 | 
				
			||||||
Yannick Charton
 | 
					Yannick Charton
 | 
				
			||||||
Stephane Chazelas
 | 
					Stephane Chazelas
 | 
				
			||||||
| 
						 | 
					@ -125,13 +130,13 @@ Reuben Farrelly
 | 
				
			||||||
Mark Favas
 | 
					Mark Favas
 | 
				
			||||||
Duncan Ferguson
 | 
					Duncan Ferguson
 | 
				
			||||||
Juan Carlos Fernandez
 | 
					Juan Carlos Fernandez
 | 
				
			||||||
Paulo Afonso Graner Fessel
 | 
					 | 
				
			||||||
Paulo Fessel
 | 
					Paulo Fessel
 | 
				
			||||||
 | 
					Paulo Afonso Graner Fessel
 | 
				
			||||||
James Fidell
 | 
					James Fidell
 | 
				
			||||||
Tobias Fiebig
 | 
					Tobias Fiebig
 | 
				
			||||||
Roman Fiedler
 | 
					Roman Fiedler
 | 
				
			||||||
Johan Fischer
 | 
					 | 
				
			||||||
Bernhard Fischer
 | 
					Bernhard Fischer
 | 
				
			||||||
 | 
					Johan Fischer
 | 
				
			||||||
Matthias Flacke
 | 
					Matthias Flacke
 | 
				
			||||||
Martin Foster
 | 
					Martin Foster
 | 
				
			||||||
Felix Frank
 | 
					Felix Frank
 | 
				
			||||||
| 
						 | 
					@ -161,12 +166,13 @@ Sebastien Guay
 | 
				
			||||||
Linda Guo
 | 
					Linda Guo
 | 
				
			||||||
Jon Hallett
 | 
					Jon Hallett
 | 
				
			||||||
Steve Hanselman
 | 
					Steve Hanselman
 | 
				
			||||||
Ask Bjoern Hansen
 | 
					 | 
				
			||||||
Jacob Hansen
 | 
					Jacob Hansen
 | 
				
			||||||
 | 
					Ask Bjoern Hansen
 | 
				
			||||||
Sebastian Harl
 | 
					Sebastian Harl
 | 
				
			||||||
Michael Haro
 | 
					Michael Haro
 | 
				
			||||||
Olli Hauer
 | 
					Olli Hauer
 | 
				
			||||||
Gunnar Hellekson
 | 
					Gunnar Hellekson
 | 
				
			||||||
 | 
					Stuart Henderson
 | 
				
			||||||
Geert Hendrickx
 | 
					Geert Hendrickx
 | 
				
			||||||
Sebastian Herbszt
 | 
					Sebastian Herbszt
 | 
				
			||||||
Johannes Herlitz
 | 
					Johannes Herlitz
 | 
				
			||||||
| 
						 | 
					@ -209,6 +215,7 @@ Frederic Krueger
 | 
				
			||||||
Claudio Kuenzler
 | 
					Claudio Kuenzler
 | 
				
			||||||
Marcel Kuiper
 | 
					Marcel Kuiper
 | 
				
			||||||
Christian Kujau
 | 
					Christian Kujau
 | 
				
			||||||
 | 
					Thorsten Kukuk
 | 
				
			||||||
Alexander Kulak
 | 
					Alexander Kulak
 | 
				
			||||||
Bill Kunkel
 | 
					Bill Kunkel
 | 
				
			||||||
Thomas Kurschel
 | 
					Thomas Kurschel
 | 
				
			||||||
| 
						 | 
					@ -236,6 +243,7 @@ Jason Lunn
 | 
				
			||||||
Davide Madrisan
 | 
					Davide Madrisan
 | 
				
			||||||
Guenther Mair
 | 
					Guenther Mair
 | 
				
			||||||
Pawel Malachowski
 | 
					Pawel Malachowski
 | 
				
			||||||
 | 
					Gerardo Malazdrewicz
 | 
				
			||||||
Ricardo Maraschini
 | 
					Ricardo Maraschini
 | 
				
			||||||
Michael Markstaller
 | 
					Michael Markstaller
 | 
				
			||||||
John Marquart
 | 
					John Marquart
 | 
				
			||||||
| 
						 | 
					@ -261,6 +269,7 @@ Jonathan Milby
 | 
				
			||||||
Russell Miller
 | 
					Russell Miller
 | 
				
			||||||
Eric J. Mislivec
 | 
					Eric J. Mislivec
 | 
				
			||||||
Janos Mohacsi
 | 
					Janos Mohacsi
 | 
				
			||||||
 | 
					John Morrissey
 | 
				
			||||||
Andreas Motl
 | 
					Andreas Motl
 | 
				
			||||||
Tomas Mozes
 | 
					Tomas Mozes
 | 
				
			||||||
Gerd Mueller
 | 
					Gerd Mueller
 | 
				
			||||||
| 
						 | 
					@ -297,6 +306,7 @@ Matt Pounsett
 | 
				
			||||||
Peter Pramberger
 | 
					Peter Pramberger
 | 
				
			||||||
Joe Presbrey
 | 
					Joe Presbrey
 | 
				
			||||||
Will Preston
 | 
					Will Preston
 | 
				
			||||||
 | 
					Platon Pronko
 | 
				
			||||||
Arnaud Quette
 | 
					Arnaud Quette
 | 
				
			||||||
Darian Rackham
 | 
					Darian Rackham
 | 
				
			||||||
Peter Radcliffe
 | 
					Peter Radcliffe
 | 
				
			||||||
| 
						 | 
					@ -337,6 +347,8 @@ Cove Schneider
 | 
				
			||||||
Enrico Scholz
 | 
					Enrico Scholz
 | 
				
			||||||
Sebastian Schubert
 | 
					Sebastian Schubert
 | 
				
			||||||
Christopher Schultz
 | 
					Christopher Schultz
 | 
				
			||||||
 | 
					Kristian Schuster
 | 
				
			||||||
 | 
					Franz Schwartau
 | 
				
			||||||
Russell Scibetti
 | 
					Russell Scibetti
 | 
				
			||||||
Noel Sebastien
 | 
					Noel Sebastien
 | 
				
			||||||
Andreas Seemueller
 | 
					Andreas Seemueller
 | 
				
			||||||
| 
						 | 
					@ -359,6 +371,7 @@ David Sullivan
 | 
				
			||||||
Kjell Sundtjonn
 | 
					Kjell Sundtjonn
 | 
				
			||||||
Ziya Suzen
 | 
					Ziya Suzen
 | 
				
			||||||
Christian Tacke
 | 
					Christian Tacke
 | 
				
			||||||
 | 
					Stefan Taferner
 | 
				
			||||||
Danijel Tasov
 | 
					Danijel Tasov
 | 
				
			||||||
Michael Tiernan
 | 
					Michael Tiernan
 | 
				
			||||||
Ben Timby
 | 
					Ben Timby
 | 
				
			||||||
| 
						 | 
					@ -369,6 +382,7 @@ Gabriele Tozzi
 | 
				
			||||||
Kyle Tucker
 | 
					Kyle Tucker
 | 
				
			||||||
Jerome Tytgat
 | 
					Jerome Tytgat
 | 
				
			||||||
Daniel Uhlmann
 | 
					Daniel Uhlmann
 | 
				
			||||||
 | 
					Patrick Uiterwijk
 | 
				
			||||||
Stéphane Urbanovski
 | 
					Stéphane Urbanovski
 | 
				
			||||||
Matthias Urlichs
 | 
					Matthias Urlichs
 | 
				
			||||||
Matteo HCE Valsasna
 | 
					Matteo HCE Valsasna
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										3465
									
								
								aclocal.m4
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3465
									
								
								aclocal.m4
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
					@ -1,348 +0,0 @@
 | 
				
			||||||
#! /bin/sh
 | 
					 | 
				
			||||||
# Wrapper for compilers which do not understand '-c -o'.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
scriptversion=2018-03-07.03; # UTC
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 | 
					 | 
				
			||||||
# Written by Tom Tromey <tromey@cygnus.com>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
# the Free Software Foundation; either version 2, or (at your option)
 | 
					 | 
				
			||||||
# any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
# GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# As a special exception to the GNU General Public License, if you
 | 
					 | 
				
			||||||
# distribute this file as part of a program that contains a
 | 
					 | 
				
			||||||
# configuration script generated by Autoconf, you may include it under
 | 
					 | 
				
			||||||
# the same distribution terms that you use for the rest of that program.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This file is maintained in Automake, please report
 | 
					 | 
				
			||||||
# bugs to <bug-automake@gnu.org> or send patches to
 | 
					 | 
				
			||||||
# <automake-patches@gnu.org>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
nl='
 | 
					 | 
				
			||||||
'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# We need space, tab and new line, in precisely that order.  Quoting is
 | 
					 | 
				
			||||||
# there to prevent tools from complaining about whitespace usage.
 | 
					 | 
				
			||||||
IFS=" ""	$nl"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
file_conv=
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# func_file_conv build_file lazy
 | 
					 | 
				
			||||||
# Convert a $build file to $host form and store it in $file
 | 
					 | 
				
			||||||
# Currently only supports Windows hosts. If the determined conversion
 | 
					 | 
				
			||||||
# type is listed in (the comma separated) LAZY, no conversion will
 | 
					 | 
				
			||||||
# take place.
 | 
					 | 
				
			||||||
func_file_conv ()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  file=$1
 | 
					 | 
				
			||||||
  case $file in
 | 
					 | 
				
			||||||
    / | /[!/]*) # absolute file, and not a UNC file
 | 
					 | 
				
			||||||
      if test -z "$file_conv"; then
 | 
					 | 
				
			||||||
	# lazily determine how to convert abs files
 | 
					 | 
				
			||||||
	case `uname -s` in
 | 
					 | 
				
			||||||
	  MINGW*)
 | 
					 | 
				
			||||||
	    file_conv=mingw
 | 
					 | 
				
			||||||
	    ;;
 | 
					 | 
				
			||||||
	  CYGWIN* | MSYS*)
 | 
					 | 
				
			||||||
	    file_conv=cygwin
 | 
					 | 
				
			||||||
	    ;;
 | 
					 | 
				
			||||||
	  *)
 | 
					 | 
				
			||||||
	    file_conv=wine
 | 
					 | 
				
			||||||
	    ;;
 | 
					 | 
				
			||||||
	esac
 | 
					 | 
				
			||||||
      fi
 | 
					 | 
				
			||||||
      case $file_conv/,$2, in
 | 
					 | 
				
			||||||
	*,$file_conv,*)
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	mingw/*)
 | 
					 | 
				
			||||||
	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	cygwin/* | msys/*)
 | 
					 | 
				
			||||||
	  file=`cygpath -m "$file" || echo "$file"`
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	wine/*)
 | 
					 | 
				
			||||||
	  file=`winepath -w "$file" || echo "$file"`
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
      esac
 | 
					 | 
				
			||||||
      ;;
 | 
					 | 
				
			||||||
  esac
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# func_cl_dashL linkdir
 | 
					 | 
				
			||||||
# Make cl look for libraries in LINKDIR
 | 
					 | 
				
			||||||
func_cl_dashL ()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  func_file_conv "$1"
 | 
					 | 
				
			||||||
  if test -z "$lib_path"; then
 | 
					 | 
				
			||||||
    lib_path=$file
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    lib_path="$lib_path;$file"
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
  linker_opts="$linker_opts -LIBPATH:$file"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# func_cl_dashl library
 | 
					 | 
				
			||||||
# Do a library search-path lookup for cl
 | 
					 | 
				
			||||||
func_cl_dashl ()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  lib=$1
 | 
					 | 
				
			||||||
  found=no
 | 
					 | 
				
			||||||
  save_IFS=$IFS
 | 
					 | 
				
			||||||
  IFS=';'
 | 
					 | 
				
			||||||
  for dir in $lib_path $LIB
 | 
					 | 
				
			||||||
  do
 | 
					 | 
				
			||||||
    IFS=$save_IFS
 | 
					 | 
				
			||||||
    if $shared && test -f "$dir/$lib.dll.lib"; then
 | 
					 | 
				
			||||||
      found=yes
 | 
					 | 
				
			||||||
      lib=$dir/$lib.dll.lib
 | 
					 | 
				
			||||||
      break
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    if test -f "$dir/$lib.lib"; then
 | 
					 | 
				
			||||||
      found=yes
 | 
					 | 
				
			||||||
      lib=$dir/$lib.lib
 | 
					 | 
				
			||||||
      break
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    if test -f "$dir/lib$lib.a"; then
 | 
					 | 
				
			||||||
      found=yes
 | 
					 | 
				
			||||||
      lib=$dir/lib$lib.a
 | 
					 | 
				
			||||||
      break
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
  done
 | 
					 | 
				
			||||||
  IFS=$save_IFS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if test "$found" != yes; then
 | 
					 | 
				
			||||||
    lib=$lib.lib
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# func_cl_wrapper cl arg...
 | 
					 | 
				
			||||||
# Adjust compile command to suit cl
 | 
					 | 
				
			||||||
func_cl_wrapper ()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  # Assume a capable shell
 | 
					 | 
				
			||||||
  lib_path=
 | 
					 | 
				
			||||||
  shared=:
 | 
					 | 
				
			||||||
  linker_opts=
 | 
					 | 
				
			||||||
  for arg
 | 
					 | 
				
			||||||
  do
 | 
					 | 
				
			||||||
    if test -n "$eat"; then
 | 
					 | 
				
			||||||
      eat=
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      case $1 in
 | 
					 | 
				
			||||||
	-o)
 | 
					 | 
				
			||||||
	  # configure might choose to run compile as 'compile cc -o foo foo.c'.
 | 
					 | 
				
			||||||
	  eat=1
 | 
					 | 
				
			||||||
	  case $2 in
 | 
					 | 
				
			||||||
	    *.o | *.[oO][bB][jJ])
 | 
					 | 
				
			||||||
	      func_file_conv "$2"
 | 
					 | 
				
			||||||
	      set x "$@" -Fo"$file"
 | 
					 | 
				
			||||||
	      shift
 | 
					 | 
				
			||||||
	      ;;
 | 
					 | 
				
			||||||
	    *)
 | 
					 | 
				
			||||||
	      func_file_conv "$2"
 | 
					 | 
				
			||||||
	      set x "$@" -Fe"$file"
 | 
					 | 
				
			||||||
	      shift
 | 
					 | 
				
			||||||
	      ;;
 | 
					 | 
				
			||||||
	  esac
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-I)
 | 
					 | 
				
			||||||
	  eat=1
 | 
					 | 
				
			||||||
	  func_file_conv "$2" mingw
 | 
					 | 
				
			||||||
	  set x "$@" -I"$file"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-I*)
 | 
					 | 
				
			||||||
	  func_file_conv "${1#-I}" mingw
 | 
					 | 
				
			||||||
	  set x "$@" -I"$file"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-l)
 | 
					 | 
				
			||||||
	  eat=1
 | 
					 | 
				
			||||||
	  func_cl_dashl "$2"
 | 
					 | 
				
			||||||
	  set x "$@" "$lib"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-l*)
 | 
					 | 
				
			||||||
	  func_cl_dashl "${1#-l}"
 | 
					 | 
				
			||||||
	  set x "$@" "$lib"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-L)
 | 
					 | 
				
			||||||
	  eat=1
 | 
					 | 
				
			||||||
	  func_cl_dashL "$2"
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-L*)
 | 
					 | 
				
			||||||
	  func_cl_dashL "${1#-L}"
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-static)
 | 
					 | 
				
			||||||
	  shared=false
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-Wl,*)
 | 
					 | 
				
			||||||
	  arg=${1#-Wl,}
 | 
					 | 
				
			||||||
	  save_ifs="$IFS"; IFS=','
 | 
					 | 
				
			||||||
	  for flag in $arg; do
 | 
					 | 
				
			||||||
	    IFS="$save_ifs"
 | 
					 | 
				
			||||||
	    linker_opts="$linker_opts $flag"
 | 
					 | 
				
			||||||
	  done
 | 
					 | 
				
			||||||
	  IFS="$save_ifs"
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-Xlinker)
 | 
					 | 
				
			||||||
	  eat=1
 | 
					 | 
				
			||||||
	  linker_opts="$linker_opts $2"
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	-*)
 | 
					 | 
				
			||||||
	  set x "$@" "$1"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
 | 
					 | 
				
			||||||
	  func_file_conv "$1"
 | 
					 | 
				
			||||||
	  set x "$@" -Tp"$file"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
 | 
					 | 
				
			||||||
	  func_file_conv "$1" mingw
 | 
					 | 
				
			||||||
	  set x "$@" "$file"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
	*)
 | 
					 | 
				
			||||||
	  set x "$@" "$1"
 | 
					 | 
				
			||||||
	  shift
 | 
					 | 
				
			||||||
	  ;;
 | 
					 | 
				
			||||||
      esac
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    shift
 | 
					 | 
				
			||||||
  done
 | 
					 | 
				
			||||||
  if test -n "$linker_opts"; then
 | 
					 | 
				
			||||||
    linker_opts="-link$linker_opts"
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
  exec "$@" $linker_opts
 | 
					 | 
				
			||||||
  exit 1
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
eat=
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
case $1 in
 | 
					 | 
				
			||||||
  '')
 | 
					 | 
				
			||||||
     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
 | 
					 | 
				
			||||||
     exit 1;
 | 
					 | 
				
			||||||
     ;;
 | 
					 | 
				
			||||||
  -h | --h*)
 | 
					 | 
				
			||||||
    cat <<\EOF
 | 
					 | 
				
			||||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Wrapper for compilers which do not understand '-c -o'.
 | 
					 | 
				
			||||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
 | 
					 | 
				
			||||||
arguments, and rename the output as expected.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If you are trying to build a whole package this is not the
 | 
					 | 
				
			||||||
right script to run: please start by reading the file 'INSTALL'.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Report bugs to <bug-automake@gnu.org>.
 | 
					 | 
				
			||||||
EOF
 | 
					 | 
				
			||||||
    exit $?
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  -v | --v*)
 | 
					 | 
				
			||||||
    echo "compile $scriptversion"
 | 
					 | 
				
			||||||
    exit $?
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
 | 
					 | 
				
			||||||
  icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
 | 
					 | 
				
			||||||
    func_cl_wrapper "$@"      # Doesn't return...
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
esac
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ofile=
 | 
					 | 
				
			||||||
cfile=
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
for arg
 | 
					 | 
				
			||||||
do
 | 
					 | 
				
			||||||
  if test -n "$eat"; then
 | 
					 | 
				
			||||||
    eat=
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    case $1 in
 | 
					 | 
				
			||||||
      -o)
 | 
					 | 
				
			||||||
	# configure might choose to run compile as 'compile cc -o foo foo.c'.
 | 
					 | 
				
			||||||
	# So we strip '-o arg' only if arg is an object.
 | 
					 | 
				
			||||||
	eat=1
 | 
					 | 
				
			||||||
	case $2 in
 | 
					 | 
				
			||||||
	  *.o | *.obj)
 | 
					 | 
				
			||||||
	    ofile=$2
 | 
					 | 
				
			||||||
	    ;;
 | 
					 | 
				
			||||||
	  *)
 | 
					 | 
				
			||||||
	    set x "$@" -o "$2"
 | 
					 | 
				
			||||||
	    shift
 | 
					 | 
				
			||||||
	    ;;
 | 
					 | 
				
			||||||
	esac
 | 
					 | 
				
			||||||
	;;
 | 
					 | 
				
			||||||
      *.c)
 | 
					 | 
				
			||||||
	cfile=$1
 | 
					 | 
				
			||||||
	set x "$@" "$1"
 | 
					 | 
				
			||||||
	shift
 | 
					 | 
				
			||||||
	;;
 | 
					 | 
				
			||||||
      *)
 | 
					 | 
				
			||||||
	set x "$@" "$1"
 | 
					 | 
				
			||||||
	shift
 | 
					 | 
				
			||||||
	;;
 | 
					 | 
				
			||||||
    esac
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
  shift
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if test -z "$ofile" || test -z "$cfile"; then
 | 
					 | 
				
			||||||
  # If no '-o' option was seen then we might have been invoked from a
 | 
					 | 
				
			||||||
  # pattern rule where we don't need one.  That is ok -- this is a
 | 
					 | 
				
			||||||
  # normal compilation that the losing compiler can handle.  If no
 | 
					 | 
				
			||||||
  # '.c' file was seen then we are probably linking.  That is also
 | 
					 | 
				
			||||||
  # ok.
 | 
					 | 
				
			||||||
  exec "$@"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Name of file we expect compiler to create.
 | 
					 | 
				
			||||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Create the lock directory.
 | 
					 | 
				
			||||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
 | 
					 | 
				
			||||||
# that we are using for the .o file.  Also, base the name on the expected
 | 
					 | 
				
			||||||
# object file name, since that is what matters with a parallel build.
 | 
					 | 
				
			||||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
 | 
					 | 
				
			||||||
while true; do
 | 
					 | 
				
			||||||
  if mkdir "$lockdir" >/dev/null 2>&1; then
 | 
					 | 
				
			||||||
    break
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
  sleep 1
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
# FIXME: race condition here if user kills between mkdir and trap.
 | 
					 | 
				
			||||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Run the compile.
 | 
					 | 
				
			||||||
"$@"
 | 
					 | 
				
			||||||
ret=$?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if test -f "$cofile"; then
 | 
					 | 
				
			||||||
  test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
 | 
					 | 
				
			||||||
elif test -f "${cofile}bj"; then
 | 
					 | 
				
			||||||
  test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
rmdir "$lockdir"
 | 
					 | 
				
			||||||
exit $ret
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Local Variables:
 | 
					 | 
				
			||||||
# mode: shell-script
 | 
					 | 
				
			||||||
# sh-indentation: 2
 | 
					 | 
				
			||||||
# eval: (add-hook 'before-save-hook 'time-stamp)
 | 
					 | 
				
			||||||
# time-stamp-start: "scriptversion="
 | 
					 | 
				
			||||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
 | 
					 | 
				
			||||||
# time-stamp-time-zone: "UTC0"
 | 
					 | 
				
			||||||
# time-stamp-end: "; # UTC"
 | 
					 | 
				
			||||||
# End:
 | 
					 | 
				
			||||||
							
								
								
									
										1452
									
								
								build-aux/config.guess
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1452
									
								
								build-aux/config.guess
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
					@ -2,7 +2,7 @@
 | 
				
			||||||
# Output a system dependent set of variables, describing how to set the
 | 
					# Output a system dependent set of variables, describing how to set the
 | 
				
			||||||
# run time search path of shared libraries in an executable.
 | 
					# run time search path of shared libraries in an executable.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#   Copyright 1996-2013 Free Software Foundation, Inc.
 | 
					#   Copyright 1996-2023 Free Software Foundation, Inc.
 | 
				
			||||||
#   Taken from GNU libtool, 2001
 | 
					#   Taken from GNU libtool, 2001
 | 
				
			||||||
#   Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
 | 
					#   Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
| 
						 | 
					@ -367,15 +367,11 @@ else
 | 
				
			||||||
    dgux*)
 | 
					    dgux*)
 | 
				
			||||||
      hardcode_libdir_flag_spec='-L$libdir'
 | 
					      hardcode_libdir_flag_spec='-L$libdir'
 | 
				
			||||||
      ;;
 | 
					      ;;
 | 
				
			||||||
    freebsd2.2*)
 | 
					    freebsd2.[01]*)
 | 
				
			||||||
      hardcode_libdir_flag_spec='-R$libdir'
 | 
					 | 
				
			||||||
      hardcode_direct=yes
 | 
					 | 
				
			||||||
      ;;
 | 
					 | 
				
			||||||
    freebsd2*)
 | 
					 | 
				
			||||||
      hardcode_direct=yes
 | 
					      hardcode_direct=yes
 | 
				
			||||||
      hardcode_minus_L=yes
 | 
					      hardcode_minus_L=yes
 | 
				
			||||||
      ;;
 | 
					      ;;
 | 
				
			||||||
    freebsd* | dragonfly*)
 | 
					    freebsd* | dragonfly* | midnightbsd*)
 | 
				
			||||||
      hardcode_libdir_flag_spec='-R$libdir'
 | 
					      hardcode_libdir_flag_spec='-R$libdir'
 | 
				
			||||||
      hardcode_direct=yes
 | 
					      hardcode_direct=yes
 | 
				
			||||||
      ;;
 | 
					      ;;
 | 
				
			||||||
| 
						 | 
					@ -548,13 +544,11 @@ case "$host_os" in
 | 
				
			||||||
  dgux*)
 | 
					  dgux*)
 | 
				
			||||||
    library_names_spec='$libname$shrext'
 | 
					    library_names_spec='$libname$shrext'
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  freebsd* | dragonfly*)
 | 
					  freebsd[23].*)
 | 
				
			||||||
    case "$host_os" in
 | 
					    library_names_spec='$libname$shrext$versuffix'
 | 
				
			||||||
      freebsd[123]*)
 | 
					    ;;
 | 
				
			||||||
        library_names_spec='$libname$shrext$versuffix' ;;
 | 
					  freebsd* | dragonfly* | midnightbsd*)
 | 
				
			||||||
      *)
 | 
					    library_names_spec='$libname$shrext'
 | 
				
			||||||
        library_names_spec='$libname$shrext' ;;
 | 
					 | 
				
			||||||
    esac
 | 
					 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  gnu*)
 | 
					  gnu*)
 | 
				
			||||||
    library_names_spec='$libname$shrext'
 | 
					    library_names_spec='$libname$shrext'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2839
									
								
								build-aux/config.sub
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2839
									
								
								build-aux/config.sub
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
scriptversion=2018-03-07.03; # UTC
 | 
					scriptversion=2018-03-07.03; # UTC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
 | 
					# Copyright (C) 1999-2020 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This program is free software; you can redistribute it and/or modify
 | 
					# This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					# it under the terms of the GNU General Public License as published by
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -189,7 +189,7 @@ func_basename ()
 | 
				
			||||||
#             to NONDIR_REPLACEMENT.
 | 
					#             to NONDIR_REPLACEMENT.
 | 
				
			||||||
#             value returned in "$func_dirname_result"
 | 
					#             value returned in "$func_dirname_result"
 | 
				
			||||||
#   basename: Compute filename of FILE.
 | 
					#   basename: Compute filename of FILE.
 | 
				
			||||||
#             value retuned in "$func_basename_result"
 | 
					#             value returned in "$func_basename_result"
 | 
				
			||||||
# Implementation must be kept synchronized with func_dirname
 | 
					# Implementation must be kept synchronized with func_dirname
 | 
				
			||||||
# and func_basename. For efficiency, we do not delegate to
 | 
					# and func_basename. For efficiency, we do not delegate to
 | 
				
			||||||
# those functions but instead duplicate the functionality here.
 | 
					# those functions but instead duplicate the functionality here.
 | 
				
			||||||
| 
						 | 
					@ -4394,7 +4394,7 @@ EOF
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
 | 
					          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
 | 
				
			||||||
             namespace, but it is not one of the ones we know about and
 | 
					             namespace, but it is not one of the ones we know about and
 | 
				
			||||||
             have already dealt with, above (inluding dump-script), then
 | 
					             have already dealt with, above (including dump-script), then
 | 
				
			||||||
             report an error. Otherwise, targets might begin to believe
 | 
					             report an error. Otherwise, targets might begin to believe
 | 
				
			||||||
             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
 | 
					             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
 | 
				
			||||||
             namespace. The first time any user complains about this, we'll
 | 
					             namespace. The first time any user complains about this, we'll
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
scriptversion=2018-03-07.03; # UTC
 | 
					scriptversion=2018-03-07.03; # UTC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
 | 
					# Copyright (C) 1996-2020 Free Software Foundation, Inc.
 | 
				
			||||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 | 
					# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This program is free software; you can redistribute it and/or modify
 | 
					# This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +0,0 @@
 | 
				
			||||||
#if !defined _Noreturn && __STDC_VERSION__ < 201112
 | 
					 | 
				
			||||||
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
 | 
					 | 
				
			||||||
      || 0x5110 <= __SUNPRO_C)
 | 
					 | 
				
			||||||
#  define _Noreturn __attribute__ ((__noreturn__))
 | 
					 | 
				
			||||||
# elif 1200 <= _MSC_VER
 | 
					 | 
				
			||||||
#  define _Noreturn __declspec (noreturn)
 | 
					 | 
				
			||||||
# else
 | 
					 | 
				
			||||||
#  define _Noreturn
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,109 +0,0 @@
 | 
				
			||||||
/* A C macro for emitting warnings if a function is used.
 | 
					 | 
				
			||||||
   Copyright (C) 2010-2013 Free Software Foundation, Inc.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify it
 | 
					 | 
				
			||||||
   under the terms of the GNU General Public License as published
 | 
					 | 
				
			||||||
   by the Free Software Foundation; either version 3 of the License, or
 | 
					 | 
				
			||||||
   (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					 | 
				
			||||||
   General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
 | 
					 | 
				
			||||||
   for FUNCTION which will then trigger a compiler warning containing
 | 
					 | 
				
			||||||
   the text of "literal string" anywhere that function is called, if
 | 
					 | 
				
			||||||
   supported by the compiler.  If the compiler does not support this
 | 
					 | 
				
			||||||
   feature, the macro expands to an unused extern declaration.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This macro is useful for marking a function as a potential
 | 
					 | 
				
			||||||
   portability trap, with the intent that "literal string" include
 | 
					 | 
				
			||||||
   instructions on the replacement function that should be used
 | 
					 | 
				
			||||||
   instead.  However, one of the reasons that a function is a
 | 
					 | 
				
			||||||
   portability trap is if it has the wrong signature.  Declaring
 | 
					 | 
				
			||||||
   FUNCTION with a different signature in C is a compilation error, so
 | 
					 | 
				
			||||||
   this macro must use the same type as any existing declaration so
 | 
					 | 
				
			||||||
   that programs that avoid the problematic FUNCTION do not fail to
 | 
					 | 
				
			||||||
   compile merely because they included a header that poisoned the
 | 
					 | 
				
			||||||
   function.  But this implies that _GL_WARN_ON_USE is only safe to
 | 
					 | 
				
			||||||
   use if FUNCTION is known to already have a declaration.  Use of
 | 
					 | 
				
			||||||
   this macro implies that there must not be any other macro hiding
 | 
					 | 
				
			||||||
   the declaration of FUNCTION; but undefining FUNCTION first is part
 | 
					 | 
				
			||||||
   of the poisoning process anyway (although for symbols that are
 | 
					 | 
				
			||||||
   provided only via a macro, the result is a compilation error rather
 | 
					 | 
				
			||||||
   than a warning containing "literal string").  Also note that in
 | 
					 | 
				
			||||||
   C++, it is only safe to use if FUNCTION has no overloads.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   For an example, it is possible to poison 'getline' by:
 | 
					 | 
				
			||||||
   - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
 | 
					 | 
				
			||||||
     [getline]) in configure.ac, which potentially defines
 | 
					 | 
				
			||||||
     HAVE_RAW_DECL_GETLINE
 | 
					 | 
				
			||||||
   - adding this code to a header that wraps the system <stdio.h>:
 | 
					 | 
				
			||||||
     #undef getline
 | 
					 | 
				
			||||||
     #if HAVE_RAW_DECL_GETLINE
 | 
					 | 
				
			||||||
     _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
 | 
					 | 
				
			||||||
       "not universally present; use the gnulib module getline");
 | 
					 | 
				
			||||||
     #endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   It is not possible to directly poison global variables.  But it is
 | 
					 | 
				
			||||||
   possible to write a wrapper accessor function, and poison that
 | 
					 | 
				
			||||||
   (less common usage, like &environ, will cause a compilation error
 | 
					 | 
				
			||||||
   rather than issue the nice warning, but the end result of informing
 | 
					 | 
				
			||||||
   the developer about their portability problem is still achieved):
 | 
					 | 
				
			||||||
   #if HAVE_RAW_DECL_ENVIRON
 | 
					 | 
				
			||||||
   static char ***rpl_environ (void) { return &environ; }
 | 
					 | 
				
			||||||
   _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
 | 
					 | 
				
			||||||
   # undef environ
 | 
					 | 
				
			||||||
   # define environ (*rpl_environ ())
 | 
					 | 
				
			||||||
   #endif
 | 
					 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
#ifndef _GL_WARN_ON_USE
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
 | 
					 | 
				
			||||||
/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
 | 
					 | 
				
			||||||
#  define _GL_WARN_ON_USE(function, message) \
 | 
					 | 
				
			||||||
extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
 | 
					 | 
				
			||||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
 | 
					 | 
				
			||||||
/* Verify the existence of the function.  */
 | 
					 | 
				
			||||||
#  define _GL_WARN_ON_USE(function, message) \
 | 
					 | 
				
			||||||
extern __typeof__ (function) function
 | 
					 | 
				
			||||||
# else /* Unsupported.  */
 | 
					 | 
				
			||||||
#  define _GL_WARN_ON_USE(function, message) \
 | 
					 | 
				
			||||||
_GL_WARN_EXTERN_C int _gl_warn_on_use
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
 | 
					 | 
				
			||||||
   is like _GL_WARN_ON_USE (function, "string"), except that the function is
 | 
					 | 
				
			||||||
   declared with the given prototype, consisting of return type, parameters,
 | 
					 | 
				
			||||||
   and attributes.
 | 
					 | 
				
			||||||
   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
 | 
					 | 
				
			||||||
   not work in this case.  */
 | 
					 | 
				
			||||||
#ifndef _GL_WARN_ON_USE_CXX
 | 
					 | 
				
			||||||
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
 | 
					 | 
				
			||||||
#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
 | 
					 | 
				
			||||||
extern rettype function parameters_and_attributes \
 | 
					 | 
				
			||||||
     __attribute__ ((__warning__ (msg)))
 | 
					 | 
				
			||||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
 | 
					 | 
				
			||||||
/* Verify the existence of the function.  */
 | 
					 | 
				
			||||||
#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
 | 
					 | 
				
			||||||
extern rettype function parameters_and_attributes
 | 
					 | 
				
			||||||
# else /* Unsupported.  */
 | 
					 | 
				
			||||||
#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
 | 
					 | 
				
			||||||
_GL_WARN_EXTERN_C int _gl_warn_on_use
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* _GL_WARN_EXTERN_C declaration;
 | 
					 | 
				
			||||||
   performs the declaration with C linkage.  */
 | 
					 | 
				
			||||||
#ifndef _GL_WARN_EXTERN_C
 | 
					 | 
				
			||||||
# if defined __cplusplus
 | 
					 | 
				
			||||||
#  define _GL_WARN_EXTERN_C extern "C"
 | 
					 | 
				
			||||||
# else
 | 
					 | 
				
			||||||
#  define _GL_WARN_EXTERN_C extern
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
scriptversion=2018-03-07.03; # UTC
 | 
					scriptversion=2018-03-07.03; # UTC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
 | 
					# Copyright (C) 2011-2020 Free Software Foundation, Inc.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# This program is free software; you can redistribute it and/or modify
 | 
					# This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
# it under the terms of the GNU General Public License as published by
 | 
					# it under the terms of the GNU General Public License as published by
 | 
				
			||||||
| 
						 | 
					@ -105,11 +105,8 @@ trap "st=130; $do_exit" 2
 | 
				
			||||||
trap "st=141; $do_exit" 13
 | 
					trap "st=141; $do_exit" 13
 | 
				
			||||||
trap "st=143; $do_exit" 15
 | 
					trap "st=143; $do_exit" 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Test script is run here. We create the file first, then append to it,
 | 
					# Test script is run here.
 | 
				
			||||||
# to ameliorate tests themselves also writing to the log file. Our tests
 | 
					"$@" >$log_file 2>&1
 | 
				
			||||||
# don't, but others can (automake bug#35762).
 | 
					 | 
				
			||||||
: >"$log_file"
 | 
					 | 
				
			||||||
"$@" >>"$log_file" 2>&1
 | 
					 | 
				
			||||||
estatus=$?
 | 
					estatus=$?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if test $enable_hard_errors = no && test $estatus -eq 99; then
 | 
					if test $enable_hard_errors = no && test $estatus -eq 99; then
 | 
				
			||||||
| 
						 | 
					@ -131,7 +128,7 @@ esac
 | 
				
			||||||
# know whether the test passed or failed simply by looking at the '.log'
 | 
					# know whether the test passed or failed simply by looking at the '.log'
 | 
				
			||||||
# file, without the need of also peaking into the corresponding '.trs'
 | 
					# file, without the need of also peaking into the corresponding '.trs'
 | 
				
			||||||
# file (automake bug#11814).
 | 
					# file (automake bug#11814).
 | 
				
			||||||
echo "$res $test_name (exit status: $estatus)" >>"$log_file"
 | 
					echo "$res $test_name (exit status: $estatus)" >>$log_file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Report outcome to console.
 | 
					# Report outcome to console.
 | 
				
			||||||
echo "${col}${res}${std}: $test_name"
 | 
					echo "${col}${res}${std}: $test_name"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2426
									
								
								config.h.in
									
										
									
									
									
								
							
							
						
						
									
										2426
									
								
								config.h.in
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
					@ -30,7 +30,7 @@ int main(){
 | 
				
			||||||
            /* pipefd[1] is for writing to the pipe. We want the output
 | 
					            /* pipefd[1] is for writing to the pipe. We want the output
 | 
				
			||||||
             * that used to go to the standard output (file descriptor 1)
 | 
					             * that used to go to the standard output (file descriptor 1)
 | 
				
			||||||
             * to be written to the pipe. The following command does this,
 | 
					             * to be written to the pipe. The following command does this,
 | 
				
			||||||
             * creating a new file descripter 1 (the lowest available) 
 | 
					             * creating a new file descriptor 1 (the lowest available) 
 | 
				
			||||||
             * that writes where pipefd[1] goes. */
 | 
					             * that writes where pipefd[1] goes. */
 | 
				
			||||||
            dup (pipefd[1]); /* points pipefd at file descriptor */
 | 
					            dup (pipefd[1]); /* points pipefd at file descriptor */
 | 
				
			||||||
            /* the child isn't going to read from the pipe, so
 | 
					            /* the child isn't going to read from the pipe, so
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										50
									
								
								configure.ac
									
										
									
									
									
								
							
							
						
						
									
										50
									
								
								configure.ac
									
										
									
									
									
								
							| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
dnl Process this file with autoconf to produce a configure script.
 | 
					dnl Process this file with autoconf to produce a configure script.
 | 
				
			||||||
AC_PREREQ(2.59)
 | 
					AC_PREREQ(2.64)
 | 
				
			||||||
AC_INIT(monitoring-plugins,2.3.3)
 | 
					AC_INIT(monitoring-plugins,2.3.4)
 | 
				
			||||||
AC_CONFIG_SRCDIR(NPTest.pm)
 | 
					AC_CONFIG_SRCDIR(NPTest.pm)
 | 
				
			||||||
AC_CONFIG_FILES([gl/Makefile])
 | 
					AC_CONFIG_FILES([gl/Makefile])
 | 
				
			||||||
AC_CONFIG_AUX_DIR(build-aux)
 | 
					AC_CONFIG_AUX_DIR(build-aux)
 | 
				
			||||||
| 
						 | 
					@ -328,6 +328,25 @@ AS_IF([test "x$with_ldap" != "xno"], [
 | 
				
			||||||
  LIBS="$_SAVEDLIBS"
 | 
					  LIBS="$_SAVEDLIBS"
 | 
				
			||||||
])
 | 
					])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AC_ARG_WITH([systemd], [AS_HELP_STRING([--without-systemd], [Skips systemd support])])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dnl Check for libsystemd
 | 
				
			||||||
 | 
					AS_IF([test "x$with_systemd" != "xno"], [
 | 
				
			||||||
 | 
					  _SAVEDLIBS="$LIBS"
 | 
				
			||||||
 | 
					  AC_CHECK_LIB(systemd,sd_get_sessions,,,-lsystemd)
 | 
				
			||||||
 | 
					  if test "$ac_cv_lib_systemd_sd_get_sessions" = "yes"; then
 | 
				
			||||||
 | 
					    SYSTEMDLIBS="-lsystemd"
 | 
				
			||||||
 | 
					    SYSTEMDINCLUDE=""
 | 
				
			||||||
 | 
					    AC_SUBST(SYSTEMDLIBS)
 | 
				
			||||||
 | 
					    AC_SUBST(SYSTEMDINCLUDE)
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    AC_MSG_WARN([Skipping systemd support])
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  LIBS="$_SAVEDLIBS"
 | 
				
			||||||
 | 
					])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dnl Check for headers used by check_ide_smart
 | 
					dnl Check for headers used by check_ide_smart
 | 
				
			||||||
case $host in
 | 
					case $host in
 | 
				
			||||||
  *linux*)
 | 
					  *linux*)
 | 
				
			||||||
| 
						 | 
					@ -602,7 +621,6 @@ AC_C_CONST
 | 
				
			||||||
AC_STRUCT_TM
 | 
					AC_STRUCT_TM
 | 
				
			||||||
AC_TYPE_PID_T
 | 
					AC_TYPE_PID_T
 | 
				
			||||||
AC_TYPE_SIZE_T
 | 
					AC_TYPE_SIZE_T
 | 
				
			||||||
AC_TYPE_SIGNAL
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
 | 
					AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
 | 
				
			||||||
AC_TRY_LINK([#include <stdarg.h>
 | 
					AC_TRY_LINK([#include <stdarg.h>
 | 
				
			||||||
| 
						 | 
					@ -626,12 +644,16 @@ AC_TRY_COMPILE([#include <sys/time.h>],
 | 
				
			||||||
               [struct timeval *tv;
 | 
					               [struct timeval *tv;
 | 
				
			||||||
                struct timezone *tz;],
 | 
					                struct timezone *tz;],
 | 
				
			||||||
               AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
 | 
					               AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
 | 
				
			||||||
 | 
								   FOUND_STRUCT_TIMEVAL="yes")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if test x"$FOUND_STRUCT_TIMEVAL" = x"yes"; then
 | 
				
			||||||
	AC_TRY_COMPILE([#include <sys/time.h>],
 | 
						AC_TRY_COMPILE([#include <sys/time.h>],
 | 
				
			||||||
			  [struct timeval *tv;
 | 
								  [struct timeval *tv;
 | 
				
			||||||
			   struct timezone *tz;
 | 
								   struct timezone *tz;
 | 
				
			||||||
			   gettimeofday(tv, tz);],
 | 
								   gettimeofday(tv, tz);],
 | 
				
			||||||
			  AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
 | 
								  AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
 | 
				
			||||||
                              AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
 | 
								  AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed]))
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dnl Checks for library functions.
 | 
					dnl Checks for library functions.
 | 
				
			||||||
AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
 | 
					AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
 | 
				
			||||||
| 
						 | 
					@ -932,7 +954,7 @@ elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
	ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
 | 
						ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
 | 
				
			||||||
	ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
 | 
						ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
 | 
				
			||||||
	# There must be no space between the %s and %n due to a wierd problem in sscanf where
 | 
						# There must be no space between the %s and %n due to a weird problem in sscanf where
 | 
				
			||||||
	# it will return %n as longer than the line length
 | 
						# it will return %n as longer than the line length
 | 
				
			||||||
	ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
 | 
						ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
 | 
				
			||||||
	ac_cv_ps_cols=9
 | 
						ac_cv_ps_cols=9
 | 
				
			||||||
| 
						 | 
					@ -1552,7 +1574,7 @@ if test -n "$PATH_TO_SUDO"
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
	AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
 | 
						AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
	AC_MSG_WARN([Could not find sudo or eqivalent])
 | 
						AC_MSG_WARN([Could not find sudo or equivalent])
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AC_PATH_PROG(PATH_TO_MAILQ,mailq)
 | 
					AC_PATH_PROG(PATH_TO_MAILQ,mailq)
 | 
				
			||||||
| 
						 | 
					@ -1563,7 +1585,7 @@ if test -n "$PATH_TO_MAILQ"
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
	AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
 | 
						AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
	AC_MSG_WARN([Could not find mailq or eqivalent])
 | 
						AC_MSG_WARN([Could not find mailq or equivalent])
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
 | 
					AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
 | 
				
			||||||
| 
						 | 
					@ -1574,7 +1596,7 @@ if test -n "$PATH_TO_QMAIL_QSTAT"
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
	AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
 | 
						AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
	AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
 | 
						AC_MSG_WARN([Could not find qmail-qstat or equivalent])
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dnl SWAP info required is amount allocated/available and amount free
 | 
					dnl SWAP info required is amount allocated/available and amount free
 | 
				
			||||||
| 
						 | 
					@ -1592,13 +1614,13 @@ then
 | 
				
			||||||
		grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
 | 
							grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
 | 
				
			||||||
		>/dev/null]
 | 
							>/dev/null]
 | 
				
			||||||
	then
 | 
						then
 | 
				
			||||||
		ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
 | 
							ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %lu %lu"]
 | 
				
			||||||
		ac_cv_swap_conv=2048
 | 
							ac_cv_swap_conv=2048
 | 
				
			||||||
		AC_MSG_RESULT([using IRIX format swap])
 | 
							AC_MSG_RESULT([using IRIX format swap])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
 | 
						elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
 | 
				
			||||||
	then
 | 
						then
 | 
				
			||||||
		ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
 | 
							ac_cv_swap_format=["%*s %*[0-9,-] %*d %lu %lu"]
 | 
				
			||||||
		ac_cv_swap_conv=2048
 | 
							ac_cv_swap_conv=2048
 | 
				
			||||||
		AC_MSG_RESULT([using Unixware format swap])
 | 
							AC_MSG_RESULT([using Unixware format swap])
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -1622,7 +1644,7 @@ then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
 | 
						if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
 | 
				
			||||||
	then
 | 
						then
 | 
				
			||||||
		ac_cv_swap_format=["%*s %f %*d %f"]
 | 
							ac_cv_swap_format=["%*s %lu %*d %lu"]
 | 
				
			||||||
		ac_cv_swap_conv=1024
 | 
							ac_cv_swap_conv=1024
 | 
				
			||||||
		AC_MSG_RESULT([using FreeBSD format swapinfo])
 | 
							AC_MSG_RESULT([using FreeBSD format swapinfo])
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
| 
						 | 
					@ -1631,7 +1653,7 @@ elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE"
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
	ac_cv_have_swap=yes
 | 
						ac_cv_have_swap=yes
 | 
				
			||||||
	ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
 | 
						ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
 | 
				
			||||||
	ac_cv_swap_format=["%*s %f %*d %f"]
 | 
						ac_cv_swap_format=["%*s %lu %*d %lu"]
 | 
				
			||||||
	ac_cv_swap_conv=1024
 | 
						ac_cv_swap_conv=1024
 | 
				
			||||||
	AC_MSG_RESULT([using HP-UX format swapinfo])
 | 
						AC_MSG_RESULT([using HP-UX format swapinfo])
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -1646,7 +1668,7 @@ if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
	ac_cv_have_swap=yes
 | 
						ac_cv_have_swap=yes
 | 
				
			||||||
	ac_cv_swap_command="$PATH_TO_LSPS -a"
 | 
						ac_cv_swap_command="$PATH_TO_LSPS -a"
 | 
				
			||||||
	ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
 | 
						ac_cv_swap_format=["%*s %*s %*s %lu%*s %lu %*s"]
 | 
				
			||||||
	ac_cv_swap_conv=1
 | 
						ac_cv_swap_conv=1
 | 
				
			||||||
	AC_MSG_RESULT([using AIX lsps])
 | 
						AC_MSG_RESULT([using AIX lsps])
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -1832,7 +1854,7 @@ AM_GNU_GETTEXT([external], [need-ngettext])
 | 
				
			||||||
AM_GNU_GETTEXT_VERSION(0.15)
 | 
					AM_GNU_GETTEXT_VERSION(0.15)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dnl Check for Redhat spopen problem
 | 
					dnl Check for Redhat spopen problem
 | 
				
			||||||
dnl Wierd problem where ECHILD is returned from a wait call in error
 | 
					dnl Weird problem where ECHILD is returned from a wait call in error
 | 
				
			||||||
dnl Only appears to affect nslookup and dig calls. Only affects redhat around
 | 
					dnl Only appears to affect nslookup and dig calls. Only affects redhat around
 | 
				
			||||||
dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
 | 
					dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
 | 
				
			||||||
dnl We patch plugins/popen.c
 | 
					dnl We patch plugins/popen.c
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2398
									
								
								gl/Makefile.am
									
										
									
									
									
								
							
							
						
						
									
										2398
									
								
								gl/Makefile.am
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										5543
									
								
								gl/Makefile.in
									
										
									
									
									
								
							
							
						
						
									
										5543
									
								
								gl/Makefile.in
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										50
									
								
								gl/_Noreturn.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								gl/_Noreturn.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,50 @@
 | 
				
			||||||
 | 
					/* A C macro for declaring that a function does not return.
 | 
				
			||||||
 | 
					   Copyright (C) 2011-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This program is free software: you can redistribute it and/or modify it
 | 
				
			||||||
 | 
					   under the terms of the GNU Lesser General Public License as published
 | 
				
			||||||
 | 
					   by the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					   (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _Noreturn
 | 
				
			||||||
 | 
					# if (defined __cplusplus \
 | 
				
			||||||
 | 
					      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
 | 
				
			||||||
 | 
					          || (defined _MSC_VER && 1900 <= _MSC_VER)) \
 | 
				
			||||||
 | 
					      && 0)
 | 
				
			||||||
 | 
					    /* [[noreturn]] is not practically usable, because with it the syntax
 | 
				
			||||||
 | 
					         extern _Noreturn void func (...);
 | 
				
			||||||
 | 
					       would not be valid; such a declaration would only be valid with 'extern'
 | 
				
			||||||
 | 
					       and '_Noreturn' swapped, or without the 'extern' keyword.  However, some
 | 
				
			||||||
 | 
					       AIX system header files and several gnulib header files use precisely
 | 
				
			||||||
 | 
					       this syntax with 'extern'.  */
 | 
				
			||||||
 | 
					#  define _Noreturn [[noreturn]]
 | 
				
			||||||
 | 
					# elif (defined __clang__ && __clang_major__ < 16 \
 | 
				
			||||||
 | 
					        && defined _GL_WORK_AROUND_LLVM_BUG_59792)
 | 
				
			||||||
 | 
					   /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
 | 
				
			||||||
 | 
					      that rare LLVM bug, though you may get many false-alarm warnings.  */
 | 
				
			||||||
 | 
					#  define _Noreturn
 | 
				
			||||||
 | 
					# elif ((!defined __cplusplus || defined __clang__) \
 | 
				
			||||||
 | 
					        && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
 | 
				
			||||||
 | 
					            || (!defined __STRICT_ANSI__ \
 | 
				
			||||||
 | 
					                && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
 | 
				
			||||||
 | 
					                    || (defined __apple_build_version__ \
 | 
				
			||||||
 | 
					                        ? 6000000 <= __apple_build_version__ \
 | 
				
			||||||
 | 
					                        : 3 < __clang_major__ + (5 <= __clang_minor__))))))
 | 
				
			||||||
 | 
					   /* _Noreturn works as-is.  */
 | 
				
			||||||
 | 
					# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
 | 
				
			||||||
 | 
					        || 0x5110 <= __SUNPRO_C)
 | 
				
			||||||
 | 
					#  define _Noreturn __attribute__ ((__noreturn__))
 | 
				
			||||||
 | 
					# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
 | 
				
			||||||
 | 
					#  define _Noreturn __declspec (noreturn)
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define _Noreturn
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										213
									
								
								gl/af_alg.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										213
									
								
								gl/af_alg.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,213 @@
 | 
				
			||||||
 | 
					/* af_alg.c - Compute message digests from file streams and buffers.
 | 
				
			||||||
 | 
					   Copyright (C) 2018-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Matteo Croce <mcroce@redhat.com>, 2018.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "af_alg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if USE_LINUX_CRYPTO_API
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <linux/if_alg.h>
 | 
				
			||||||
 | 
					#include <sys/stat.h>
 | 
				
			||||||
 | 
					#include <sys/sendfile.h>
 | 
				
			||||||
 | 
					#include <sys/socket.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "sys-limits.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define BLOCKSIZE 32768
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return a newly created socket for ALG.
 | 
				
			||||||
 | 
					   On error, return a negative error number.  */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					alg_socket (char const *alg)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  struct sockaddr_alg salg = {
 | 
				
			||||||
 | 
					    .salg_family = AF_ALG,
 | 
				
			||||||
 | 
					    .salg_type = "hash",
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					  /* Copy alg into salg.salg_name, without calling strcpy nor strlen.  */
 | 
				
			||||||
 | 
					  for (size_t i = 0; (salg.salg_name[i] = alg[i]) != '\0'; i++)
 | 
				
			||||||
 | 
					    if (i == sizeof salg.salg_name - 1)
 | 
				
			||||||
 | 
					      /* alg is too long.  */
 | 
				
			||||||
 | 
					      return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int cfd = socket (AF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
 | 
				
			||||||
 | 
					  if (cfd < 0)
 | 
				
			||||||
 | 
					    return -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					  int ofd = (bind (cfd, (struct sockaddr *) &salg, sizeof salg) == 0
 | 
				
			||||||
 | 
					             ? accept4 (cfd, NULL, 0, SOCK_CLOEXEC)
 | 
				
			||||||
 | 
					             : -1);
 | 
				
			||||||
 | 
					  close (cfd);
 | 
				
			||||||
 | 
					  return ofd < 0 ? -EAFNOSUPPORT : ofd;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					afalg_buffer (const char *buffer, size_t len, const char *alg,
 | 
				
			||||||
 | 
					              void *resblock, ssize_t hashlen)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
 | 
				
			||||||
 | 
					     See <https://patchwork.kernel.org/patch/9308641/>.
 | 
				
			||||||
 | 
					     This was not fixed properly until November 2016,
 | 
				
			||||||
 | 
					     see <https://patchwork.kernel.org/patch/9434741/>.  */
 | 
				
			||||||
 | 
					  if (len == 0)
 | 
				
			||||||
 | 
					    return -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int ofd = alg_socket (alg);
 | 
				
			||||||
 | 
					  if (ofd < 0)
 | 
				
			||||||
 | 
					    return ofd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (;;)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      ssize_t size = (len > BLOCKSIZE ? BLOCKSIZE : len);
 | 
				
			||||||
 | 
					      if (send (ofd, buffer, size, MSG_MORE) != size)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          result = -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      buffer += size;
 | 
				
			||||||
 | 
					      len -= size;
 | 
				
			||||||
 | 
					      if (len == 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          result = read (ofd, resblock, hashlen) == hashlen ? 0 : -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  close (ofd);
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					afalg_stream (FILE *stream, const char *alg,
 | 
				
			||||||
 | 
					              void *resblock, ssize_t hashlen)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int ofd = alg_socket (alg);
 | 
				
			||||||
 | 
					  if (ofd < 0)
 | 
				
			||||||
 | 
					    return ofd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* If STREAM's size is known and nonzero and not too large, attempt
 | 
				
			||||||
 | 
					     sendfile to pipe the data.  The nonzero restriction avoids issues
 | 
				
			||||||
 | 
					     with /proc files that pretend to be empty, and lets the classic
 | 
				
			||||||
 | 
					     read-write loop work around an empty-input bug noted below.  */
 | 
				
			||||||
 | 
					  int fd = fileno (stream);
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					  struct stat st;
 | 
				
			||||||
 | 
					  off_t off = ftello (stream);
 | 
				
			||||||
 | 
					  if (0 <= off && fstat (fd, &st) == 0
 | 
				
			||||||
 | 
					      && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
 | 
				
			||||||
 | 
					      && off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* Make sure the offset of fileno (stream) reflects how many bytes
 | 
				
			||||||
 | 
					         have been read from stream before this function got invoked.
 | 
				
			||||||
 | 
					         Note: fflush on an input stream after ungetc does not work as expected
 | 
				
			||||||
 | 
					         on some platforms.  Therefore this situation is not supported here.  */
 | 
				
			||||||
 | 
					      if (fflush (stream))
 | 
				
			||||||
 | 
					        result = -EIO;
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          off_t nbytes = st.st_size - off;
 | 
				
			||||||
 | 
					          if (sendfile (ofd, fd, &off, nbytes) == nbytes)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              if (read (ofd, resblock, hashlen) == hashlen)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                  /* The input buffers of stream are no longer valid.  */
 | 
				
			||||||
 | 
					                  if (lseek (fd, off, SEEK_SET) != (off_t)-1)
 | 
				
			||||||
 | 
					                    result = 0;
 | 
				
			||||||
 | 
					                  else
 | 
				
			||||||
 | 
					                    /* The file position of fd has not changed.  */
 | 
				
			||||||
 | 
					                    result = -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					              else
 | 
				
			||||||
 | 
					                /* The file position of fd has not changed.  */
 | 
				
			||||||
 | 
					                result = -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            /* The file position of fd has not changed.  */
 | 
				
			||||||
 | 
					            result = -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* sendfile not possible, do a classic read-write loop.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* Number of bytes to seek (backwards) in case of error.  */
 | 
				
			||||||
 | 
					      off_t nseek = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      for (;;)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          char buf[BLOCKSIZE];
 | 
				
			||||||
 | 
					          /* When the stream is not seekable, start with a single-byte block,
 | 
				
			||||||
 | 
					             so that we can use ungetc() in the case that send() fails.  */
 | 
				
			||||||
 | 
					          size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
 | 
				
			||||||
 | 
					          ssize_t size = fread (buf, 1, blocksize, stream);
 | 
				
			||||||
 | 
					          if (size == 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              /* On Linux < 4.9, the value for an empty stream is wrong (all 0).
 | 
				
			||||||
 | 
					                 See <https://patchwork.kernel.org/patch/9308641/>.
 | 
				
			||||||
 | 
					                 This was not fixed properly until November 2016,
 | 
				
			||||||
 | 
					                 see <https://patchwork.kernel.org/patch/9434741/>.  */
 | 
				
			||||||
 | 
					              result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
 | 
				
			||||||
 | 
					              break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          nseek -= size;
 | 
				
			||||||
 | 
					          if (send (ofd, buf, size, MSG_MORE) != size)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              if (nseek == -1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                  /* 1 byte of pushback buffer is guaranteed on stream, even
 | 
				
			||||||
 | 
					                     if stream is not seekable.  */
 | 
				
			||||||
 | 
					                  ungetc ((unsigned char) buf[0], stream);
 | 
				
			||||||
 | 
					                  result = -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					              else if (fseeko (stream, nseek, SEEK_CUR) == 0)
 | 
				
			||||||
 | 
					                /* The position of stream has been restored.  */
 | 
				
			||||||
 | 
					                result = -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					              else
 | 
				
			||||||
 | 
					                result = -EIO;
 | 
				
			||||||
 | 
					              break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          /* Don't assume that EOF is sticky. See:
 | 
				
			||||||
 | 
					             <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>.  */
 | 
				
			||||||
 | 
					          if (feof (stream))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              result = 0;
 | 
				
			||||||
 | 
					              break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
 | 
				
			||||||
 | 
					            /* The position of stream has been restored.  */
 | 
				
			||||||
 | 
					            result = -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            result = -EIO;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  close (ofd);
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										115
									
								
								gl/af_alg.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								gl/af_alg.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,115 @@
 | 
				
			||||||
 | 
					/* af_alg.h - Compute message digests from file streams and buffers.
 | 
				
			||||||
 | 
					   Copyright (C) 2018-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Matteo Croce <mcroce@redhat.com>, 2018.
 | 
				
			||||||
 | 
					   Documentation by Bruno Haible <bruno@clisp.org>, 2018.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Declare specific functions for computing message digests
 | 
				
			||||||
 | 
					   using the Linux kernel crypto API, if available.  This kernel API gives
 | 
				
			||||||
 | 
					   access to specialized crypto instructions (that would also be available
 | 
				
			||||||
 | 
					   in user space) or to crypto devices (not directly available in user space).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   For a more complete set of facilities that use the Linux kernel crypto API,
 | 
				
			||||||
 | 
					   look at libkcapi.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef AF_ALG_H
 | 
				
			||||||
 | 
					# define AF_ALG_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# include <stdio.h>
 | 
				
			||||||
 | 
					# include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if USE_LINUX_CRYPTO_API
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Compute a message digest of a memory region.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The memory region starts at BUFFER and is LEN bytes long.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   ALG is the message digest algorithm; see the file /proc/crypto.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   RESBLOCK points to a block of HASHLEN bytes, for the result.
 | 
				
			||||||
 | 
					   HASHLEN must be the length of the message digest, in bytes, in particular:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      alg    | hashlen
 | 
				
			||||||
 | 
					      -------+--------
 | 
				
			||||||
 | 
					      md5    | 16
 | 
				
			||||||
 | 
					      sha1   | 20
 | 
				
			||||||
 | 
					      sha224 | 28
 | 
				
			||||||
 | 
					      sha256 | 32
 | 
				
			||||||
 | 
					      sha384 | 48
 | 
				
			||||||
 | 
					      sha512 | 64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   If successful, fill RESBLOCK and return 0.
 | 
				
			||||||
 | 
					   Upon failure, return a negated error number.  */
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					afalg_buffer (const char *buffer, size_t len, const char *alg,
 | 
				
			||||||
 | 
					              void *resblock, ssize_t hashlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Compute a message digest of data read from STREAM.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   STREAM is an open file stream.  The last operation on STREAM should
 | 
				
			||||||
 | 
					   not be 'ungetc', and if STREAM is also open for writing it should
 | 
				
			||||||
 | 
					   have been fflushed since its last write.  Read from the current
 | 
				
			||||||
 | 
					   position to the end of STREAM.  Handle regular files efficiently.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   ALG is the message digest algorithm; see the file /proc/crypto.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   RESBLOCK points to a block of HASHLEN bytes, for the result.
 | 
				
			||||||
 | 
					   HASHLEN must be the length of the message digest, in bytes, in particular:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      alg    | hashlen
 | 
				
			||||||
 | 
					      -------+--------
 | 
				
			||||||
 | 
					      md5    | 16
 | 
				
			||||||
 | 
					      sha1   | 20
 | 
				
			||||||
 | 
					      sha224 | 28
 | 
				
			||||||
 | 
					      sha256 | 32
 | 
				
			||||||
 | 
					      sha384 | 48
 | 
				
			||||||
 | 
					      sha512 | 64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   If successful, fill RESBLOCK and return 0.
 | 
				
			||||||
 | 
					   Upon failure, return a negated error number.
 | 
				
			||||||
 | 
					   Unless returning 0 or -EIO, restore STREAM's file position so that
 | 
				
			||||||
 | 
					   the caller can fall back on some other method.  */
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					afalg_stream (FILE *stream, const char *alg,
 | 
				
			||||||
 | 
					              void *resblock, ssize_t hashlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline int
 | 
				
			||||||
 | 
					afalg_buffer (const char *buffer, size_t len, const char *alg,
 | 
				
			||||||
 | 
					              void *resblock, ssize_t hashlen)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline int
 | 
				
			||||||
 | 
					afalg_stream (FILE *stream, const char *alg,
 | 
				
			||||||
 | 
					              void *resblock, ssize_t hashlen)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return -EAFNOSUPPORT;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* AF_ALG_H */
 | 
				
			||||||
| 
						 | 
					@ -1,22 +1,20 @@
 | 
				
			||||||
/* Memory allocation on the stack.
 | 
					/* Memory allocation on the stack.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation,
 | 
					   Copyright (C) 1995, 1999, 2001-2004, 2006-2023 Free Software Foundation,
 | 
				
			||||||
   Inc.
 | 
					   Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify it
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   under the terms of the GNU General Public License as published
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   by the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   License along with this program; if not, see
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
   <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
 | 
					/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
 | 
				
			||||||
   means there is a real alloca function.  */
 | 
					   means there is a real alloca function.  */
 | 
				
			||||||
| 
						 | 
					@ -35,7 +33,16 @@
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef alloca
 | 
					#ifndef alloca
 | 
				
			||||||
# ifdef __GNUC__
 | 
					  /* Some version of mingw have an <alloca.h> that causes trouble when
 | 
				
			||||||
 | 
					     included after 'alloca' gets defined as a macro.  As a workaround,
 | 
				
			||||||
 | 
					     include this <alloca.h> first and define 'alloca' as a macro afterwards
 | 
				
			||||||
 | 
					     if needed.  */
 | 
				
			||||||
 | 
					# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
 | 
				
			||||||
 | 
					#  include_next <alloca.h>
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef alloca
 | 
				
			||||||
 | 
					# if defined __GNUC__ || (__clang_major__ >= 4)
 | 
				
			||||||
#  define alloca __builtin_alloca
 | 
					#  define alloca __builtin_alloca
 | 
				
			||||||
# elif defined _AIX
 | 
					# elif defined _AIX
 | 
				
			||||||
#  define alloca __alloca
 | 
					#  define alloca __alloca
 | 
				
			||||||
| 
						 | 
					@ -51,6 +58,8 @@ extern "C"
 | 
				
			||||||
void *_alloca (unsigned short);
 | 
					void *_alloca (unsigned short);
 | 
				
			||||||
#  pragma intrinsic (_alloca)
 | 
					#  pragma intrinsic (_alloca)
 | 
				
			||||||
#  define alloca _alloca
 | 
					#  define alloca _alloca
 | 
				
			||||||
 | 
					# elif defined __MVS__
 | 
				
			||||||
 | 
					#  include <stdlib.h>
 | 
				
			||||||
# else
 | 
					# else
 | 
				
			||||||
#  include <stddef.h>
 | 
					#  include <stddef.h>
 | 
				
			||||||
#  ifdef  __cplusplus
 | 
					#  ifdef  __cplusplus
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,24 +1,24 @@
 | 
				
			||||||
/* A C macro for declaring that specific arguments must not be NULL.
 | 
					/* A C macro for declaring that specific arguments must not be NULL.
 | 
				
			||||||
   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify it
 | 
					   This program is free software: you can redistribute it and/or modify it
 | 
				
			||||||
   under the terms of the GNU General Public License as published
 | 
					   under the terms of the GNU Lesser General Public License as published
 | 
				
			||||||
   by the Free Software Foundation; either version 3 of the License, or
 | 
					   by the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
   (at your option) any later version.
 | 
					   (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This program is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
   General Public License for more details.
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
 | 
					/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
 | 
				
			||||||
   that the values passed as arguments n, ..., m must be non-NULL pointers.
 | 
					   that the values passed as arguments n, ..., m must be non-NULL pointers.
 | 
				
			||||||
   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
 | 
					   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
 | 
				
			||||||
#ifndef _GL_ARG_NONNULL
 | 
					#ifndef _GL_ARG_NONNULL
 | 
				
			||||||
# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
 | 
					# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
 | 
				
			||||||
#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
 | 
					#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
 | 
				
			||||||
# else
 | 
					# else
 | 
				
			||||||
#  define _GL_ARG_NONNULL(params)
 | 
					#  define _GL_ARG_NONNULL(params)
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* A GNU-like <arpa/inet.h>.
 | 
					/* A GNU-like <arpa/inet.h>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _@GUARD_PREFIX@_ARPA_INET_H
 | 
					#ifndef _@GUARD_PREFIX@_ARPA_INET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,12 @@
 | 
				
			||||||
#ifndef _@GUARD_PREFIX@_ARPA_INET_H
 | 
					#ifndef _@GUARD_PREFIX@_ARPA_INET_H
 | 
				
			||||||
#define _@GUARD_PREFIX@_ARPA_INET_H
 | 
					#define _@GUARD_PREFIX@_ARPA_INET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get all possible declarations of inet_ntop() and inet_pton().  */
 | 
				
			||||||
 | 
					#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
 | 
				
			||||||
 | 
					    && @HAVE_WS2TCPIP_H@
 | 
				
			||||||
 | 
					# include <ws2tcpip.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 | 
					/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The definition of _GL_ARG_NONNULL is copied here.  */
 | 
					/* The definition of _GL_ARG_NONNULL is copied here.  */
 | 
				
			||||||
| 
						 | 
					@ -70,8 +76,8 @@
 | 
				
			||||||
   the return value is NULL and errno is set to ENOSPC.  A good value
 | 
					   the return value is NULL and errno is set to ENOSPC.  A good value
 | 
				
			||||||
   for CNT is 46.
 | 
					   for CNT is 46.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   For more details, see the POSIX:2001 specification
 | 
					   For more details, see the POSIX:2008 specification
 | 
				
			||||||
   <http://www.opengroup.org/susv3xsh/inet_ntop.html>.  */
 | 
					   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>.  */
 | 
				
			||||||
# if @REPLACE_INET_NTOP@
 | 
					# if @REPLACE_INET_NTOP@
 | 
				
			||||||
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
#   undef inet_ntop
 | 
					#   undef inet_ntop
 | 
				
			||||||
| 
						 | 
					@ -97,7 +103,9 @@ _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
 | 
				
			||||||
                       (int af, const void *restrict src,
 | 
					                       (int af, const void *restrict src,
 | 
				
			||||||
                        char *restrict dst, socklen_t cnt));
 | 
					                        char *restrict dst, socklen_t cnt));
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					# if __GLIBC__ >= 2
 | 
				
			||||||
_GL_CXXALIASWARN (inet_ntop);
 | 
					_GL_CXXALIASWARN (inet_ntop);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
#elif defined GNULIB_POSIXCHECK
 | 
					#elif defined GNULIB_POSIXCHECK
 | 
				
			||||||
# undef inet_ntop
 | 
					# undef inet_ntop
 | 
				
			||||||
# if HAVE_RAW_DECL_INET_NTOP
 | 
					# if HAVE_RAW_DECL_INET_NTOP
 | 
				
			||||||
| 
						 | 
					@ -126,7 +134,9 @@ _GL_FUNCDECL_SYS (inet_pton, int,
 | 
				
			||||||
_GL_CXXALIAS_SYS (inet_pton, int,
 | 
					_GL_CXXALIAS_SYS (inet_pton, int,
 | 
				
			||||||
                  (int af, const char *restrict src, void *restrict dst));
 | 
					                  (int af, const char *restrict src, void *restrict dst));
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					# if __GLIBC__ >= 2
 | 
				
			||||||
_GL_CXXALIASWARN (inet_pton);
 | 
					_GL_CXXALIASWARN (inet_pton);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
#elif defined GNULIB_POSIXCHECK
 | 
					#elif defined GNULIB_POSIXCHECK
 | 
				
			||||||
# undef inet_pton
 | 
					# undef inet_pton
 | 
				
			||||||
# if HAVE_RAW_DECL_INET_PTON
 | 
					# if HAVE_RAW_DECL_INET_PTON
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,18 +1,18 @@
 | 
				
			||||||
/* Formatted output to strings.
 | 
					/* Formatted output to strings.
 | 
				
			||||||
   Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 1999, 2002, 2006, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License along
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Formatted output to strings.
 | 
					/* Formatted output to strings.
 | 
				
			||||||
   Copyright (C) 1999, 2002, 2006-2007, 2009-2013 Free Software Foundation,
 | 
					   Copyright (C) 1999, 2002, 2006-2007, 2009-2023 Free Software Foundation,
 | 
				
			||||||
   Inc.
 | 
					   Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License along
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										27
									
								
								gl/assert.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								gl/assert.in.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					/* Substitute for and wrapper around <assert.h>
 | 
				
			||||||
 | 
					   Copyright (C) 2011-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Do not guard the include, since <assert.h> is supposed to define
 | 
				
			||||||
 | 
					   the assert macro each time it is included.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __GNUC__ >= 3
 | 
				
			||||||
 | 
					@PRAGMA_SYSTEM_HEADER@
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					@PRAGMA_COLUMNS@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#@INCLUDE_NEXT@ @NEXT_ASSERT_H@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The definition of static_assert is copied here.  */
 | 
				
			||||||
							
								
								
									
										226
									
								
								gl/attribute.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								gl/attribute.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,226 @@
 | 
				
			||||||
 | 
					/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright 2020-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Paul Eggert.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
 | 
				
			||||||
 | 
					   macros used within Gnulib.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* These attributes can be placed in two ways:
 | 
				
			||||||
 | 
					     - At the start of a declaration (i.e. even before storage-class
 | 
				
			||||||
 | 
					       specifiers!); then they apply to all entities that are declared
 | 
				
			||||||
 | 
					       by the declaration.
 | 
				
			||||||
 | 
					     - Immediately after the name of an entity being declared by the
 | 
				
			||||||
 | 
					       declaration; then they apply to that entity only.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GL_ATTRIBUTE_H
 | 
				
			||||||
 | 
					#define _GL_ATTRIBUTE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This file defines two types of attributes:
 | 
				
			||||||
 | 
					   * C23 standard attributes.  These have macro names that do not begin with
 | 
				
			||||||
 | 
					     'ATTRIBUTE_'.
 | 
				
			||||||
 | 
					   * Selected GCC attributes; see:
 | 
				
			||||||
 | 
					     https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
 | 
				
			||||||
 | 
					     https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
 | 
				
			||||||
 | 
					     https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html
 | 
				
			||||||
 | 
					     These names begin with 'ATTRIBUTE_' to avoid name clashes.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* =============== Attributes for specific kinds of functions =============== */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Attributes for functions that should not be used.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Warn if the entity is used.  */
 | 
				
			||||||
 | 
					/* Applies to:
 | 
				
			||||||
 | 
					     - function, variable,
 | 
				
			||||||
 | 
					     - struct, union, struct/union member,
 | 
				
			||||||
 | 
					     - enumeration, enumeration item,
 | 
				
			||||||
 | 
					     - typedef,
 | 
				
			||||||
 | 
					   in C++ also: namespace, class, template specialization.  */
 | 
				
			||||||
 | 
					#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If a function call is not optimized way, warn with MSG.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If a function call is not optimized way, report an error with MSG.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Attributes for memory-allocating functions.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The function returns a pointer to freshly allocated memory.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function
 | 
				
			||||||
 | 
					   is the size of the returned memory block.
 | 
				
			||||||
 | 
					   ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
 | 
				
			||||||
 | 
					   to determine the size of the returned memory block.  */
 | 
				
			||||||
 | 
					/* Applies to: function, pointer to function, function types.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
 | 
				
			||||||
 | 
					   that can be freed by passing them as the Ith argument to the
 | 
				
			||||||
 | 
					   function F.
 | 
				
			||||||
 | 
					   ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
 | 
				
			||||||
 | 
					   can be freed via 'free'; it can be used only after declaring 'free'.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  Cannot be used on inline functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i)
 | 
				
			||||||
 | 
					#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Attributes for variadic functions.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The variadic function expects a trailing NULL argument.
 | 
				
			||||||
 | 
					   ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
 | 
				
			||||||
 | 
					   ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ================== Attributes for compiler diagnostics ================== */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Attributes that help the compiler diagnose programmer mistakes.
 | 
				
			||||||
 | 
					   Some of them may also help for some compiler optimizations.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) -
 | 
				
			||||||
 | 
					   The STRING-INDEXth function argument is a format string of style
 | 
				
			||||||
 | 
					   ARCHETYPE, which is one of:
 | 
				
			||||||
 | 
					     printf, gnu_printf
 | 
				
			||||||
 | 
					     scanf, gnu_scanf,
 | 
				
			||||||
 | 
					     strftime, gnu_strftime,
 | 
				
			||||||
 | 
					     strfmon,
 | 
				
			||||||
 | 
					   or the same thing prefixed and suffixed with '__'.
 | 
				
			||||||
 | 
					   If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
 | 
				
			||||||
 | 
					   are suitable for the format string.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL.
 | 
				
			||||||
 | 
					   ATTRIBUTE_NONNULL () - All pointer arguments must not be null.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The function's return value is a non-NULL pointer.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Warn if the caller does not use the return value,
 | 
				
			||||||
 | 
					   unless the caller uses something like ignore_value.  */
 | 
				
			||||||
 | 
					/* Applies to: function, enumeration, class.  */
 | 
				
			||||||
 | 
					#define NODISCARD _GL_ATTRIBUTE_NODISCARD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Attributes that disable false alarms when the compiler diagnoses
 | 
				
			||||||
 | 
					   programmer "mistakes".  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Do not warn if the entity is not used.  */
 | 
				
			||||||
 | 
					/* Applies to:
 | 
				
			||||||
 | 
					     - function, variable,
 | 
				
			||||||
 | 
					     - struct, union, struct/union member,
 | 
				
			||||||
 | 
					     - enumeration, enumeration item,
 | 
				
			||||||
 | 
					     - typedef,
 | 
				
			||||||
 | 
					   in C++ also: class.  */
 | 
				
			||||||
 | 
					#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The contents of a character array is not meant to be NUL-terminated.  */
 | 
				
			||||||
 | 
					/* Applies to: struct/union members and variables that are arrays of element
 | 
				
			||||||
 | 
					   type '[[un]signed] char'.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Do not warn if control flow falls through to the immediately
 | 
				
			||||||
 | 
					   following 'case' or 'default' label.  */
 | 
				
			||||||
 | 
					/* Applies to: Empty statement (;), inside a 'switch' statement.  */
 | 
				
			||||||
 | 
					#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ================== Attributes for debugging information ================== */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Attributes regarding debugging information emitted by the compiler.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Omit the function from stack traces when debugging.  */
 | 
				
			||||||
 | 
					/* Applies to: function.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Make the entity visible to debuggers etc., even with '-fwhole-program'.  */
 | 
				
			||||||
 | 
					/* Applies to: functions, variables.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ========== Attributes that mainly direct compiler optimizations ========== */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The function does not throw exceptions.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Do not inline the function.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Always inline the function, and report an error if the compiler
 | 
				
			||||||
 | 
					   cannot inline.  */
 | 
				
			||||||
 | 
					/* Applies to: function.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* It is OK for a compiler to omit duplicate calls with the same arguments.
 | 
				
			||||||
 | 
					   This attribute is safe for a function that neither depends on
 | 
				
			||||||
 | 
					   nor affects observable state, and always returns exactly once -
 | 
				
			||||||
 | 
					   e.g., does not loop forever, and does not call longjmp.
 | 
				
			||||||
 | 
					   (This attribute is stricter than ATTRIBUTE_PURE.)  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* It is OK for a compiler to omit duplicate calls with the same
 | 
				
			||||||
 | 
					   arguments if observable state is not changed between calls.
 | 
				
			||||||
 | 
					   This attribute is safe for a function that does not affect
 | 
				
			||||||
 | 
					   observable state, and always returns exactly once.
 | 
				
			||||||
 | 
					   (This attribute is looser than ATTRIBUTE_CONST.)  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The function is rarely executed.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If called from some other compilation unit, the function executes
 | 
				
			||||||
 | 
					   code from that unit only by return or by exception handling,
 | 
				
			||||||
 | 
					   letting the compiler optimize that unit more aggressively.  */
 | 
				
			||||||
 | 
					/* Applies to: functions.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* For struct members: The member has the smallest possible alignment.
 | 
				
			||||||
 | 
					   For struct, union, class: All members have the smallest possible alignment,
 | 
				
			||||||
 | 
					   minimizing the memory required.  */
 | 
				
			||||||
 | 
					/* Applies to: struct members, struct, union,
 | 
				
			||||||
 | 
					   in C++ also: class.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ================ Attributes that make invalid code valid ================ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Attributes that prevent fatal compiler optimizations for code that is not
 | 
				
			||||||
 | 
					   fully ISO C compliant.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Pointers to the type may point to the same storage as pointers to
 | 
				
			||||||
 | 
					   other types, thus disabling strict aliasing optimization.  */
 | 
				
			||||||
 | 
					/* Applies to: types.  */
 | 
				
			||||||
 | 
					#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GL_ATTRIBUTE_H */
 | 
				
			||||||
							
								
								
									
										126
									
								
								gl/base64.c
									
										
									
									
									
								
							
							
						
						
									
										126
									
								
								gl/base64.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,24 +1,24 @@
 | 
				
			||||||
/* base64.c -- Encode binary data using printable characters.
 | 
					/* base64.c -- Encode binary data using printable characters.
 | 
				
			||||||
   Copyright (C) 1999-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 1999-2001, 2004-2006, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Written by Simon Josefsson.  Partially adapted from GNU MailUtils
 | 
					/* Written by Simon Josefsson.  Partially adapted from GNU MailUtils
 | 
				
			||||||
 * (mailbox/filter_trans.c, as of 2004-11-28).  Improved by review
 | 
					 * (mailbox/filter_trans.c, as of 2004-11-28).  Improved by review
 | 
				
			||||||
 * from Paul Eggert, Bruno Haible, and Stepan Kasal.
 | 
					 * from Paul Eggert, Bruno Haible, and Stepan Kasal.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * See also RFC 4648 <http://www.ietf.org/rfc/rfc4648.txt>.
 | 
					 * See also RFC 4648 <https://www.ietf.org/rfc/rfc4648.txt>.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Be careful with error checking.  Here is how you would typically
 | 
					 * Be careful with error checking.  Here is how you would typically
 | 
				
			||||||
 * use these functions:
 | 
					 * use these functions:
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,7 @@
 | 
				
			||||||
 *   FAIL: memory allocation error
 | 
					 *   FAIL: memory allocation error
 | 
				
			||||||
 * OK: data in OUT/OUTLEN
 | 
					 * OK: data in OUT/OUTLEN
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * size_t outlen = base64_encode_alloc (in, inlen, &out);
 | 
					 * idx_t outlen = base64_encode_alloc (in, inlen, &out);
 | 
				
			||||||
 * if (out == NULL && outlen == 0 && inlen != 0)
 | 
					 * if (out == NULL && outlen == 0 && inlen != 0)
 | 
				
			||||||
 *   FAIL: input too long
 | 
					 *   FAIL: input too long
 | 
				
			||||||
 * if (out == NULL)
 | 
					 * if (out == NULL)
 | 
				
			||||||
| 
						 | 
					@ -44,51 +44,84 @@
 | 
				
			||||||
/* Get prototype. */
 | 
					/* Get prototype. */
 | 
				
			||||||
#include "base64.h"
 | 
					#include "base64.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Get malloc. */
 | 
					/* Get imalloc. */
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <ialloc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <intprops.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Get UCHAR_MAX. */
 | 
					/* Get UCHAR_MAX. */
 | 
				
			||||||
#include <limits.h>
 | 
					#include <limits.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* C89 compliant way to cast 'char' to 'unsigned char'. */
 | 
					/* Convert 'char' to 'unsigned char' without casting.  */
 | 
				
			||||||
static unsigned char
 | 
					static unsigned char
 | 
				
			||||||
to_uchar (char ch)
 | 
					to_uchar (char ch)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return ch;
 | 
					  return ch;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char b64c[64] =
 | 
				
			||||||
 | 
					  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Base64 encode IN array of size INLEN into OUT array. OUT needs
 | 
				
			||||||
 | 
					   to be of length >= BASE64_LENGTH(INLEN), and INLEN needs to be
 | 
				
			||||||
 | 
					   a multiple of 3.  */
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					base64_encode_fast (const char *restrict in, idx_t inlen, char *restrict out)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  while (inlen)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      *out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
 | 
				
			||||||
 | 
					      *out++ = b64c[((to_uchar (in[0]) << 4) + (to_uchar (in[1]) >> 4)) & 0x3f];
 | 
				
			||||||
 | 
					      *out++ = b64c[((to_uchar (in[1]) << 2) + (to_uchar (in[2]) >> 6)) & 0x3f];
 | 
				
			||||||
 | 
					      *out++ = b64c[to_uchar (in[2]) & 0x3f];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      inlen -= 3;
 | 
				
			||||||
 | 
					      in += 3;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
 | 
					/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
 | 
				
			||||||
   If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
 | 
					   If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
 | 
				
			||||||
   possible.  If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
 | 
					   possible.  If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
 | 
				
			||||||
   terminate the output buffer. */
 | 
					   terminate the output buffer. */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
base64_encode (const char *restrict in, size_t inlen,
 | 
					base64_encode (const char *restrict in, idx_t inlen,
 | 
				
			||||||
               char *restrict out, size_t outlen)
 | 
					               char *restrict out, idx_t outlen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  static const char b64str[64] =
 | 
					  /* Note this outlen constraint can be enforced at compile time.
 | 
				
			||||||
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 | 
					     I.E. that the output buffer is exactly large enough to hold
 | 
				
			||||||
 | 
					     the encoded inlen bytes.  The inlen constraints (of corresponding
 | 
				
			||||||
 | 
					     to outlen, and being a multiple of 3) can change at runtime
 | 
				
			||||||
 | 
					     at the end of input.  However the common case when reading
 | 
				
			||||||
 | 
					     large inputs is to have both constraints satisfied, so we depend
 | 
				
			||||||
 | 
					     on both in base_encode_fast().  */
 | 
				
			||||||
 | 
					  if (outlen % 4 == 0 && inlen == (outlen >> 2) * 3)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      base64_encode_fast (in, inlen, out);
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (inlen && outlen)
 | 
					  while (inlen && outlen)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f];
 | 
					      *out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
 | 
				
			||||||
      if (!--outlen)
 | 
					      if (!--outlen)
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      *out++ = b64str[((to_uchar (in[0]) << 4)
 | 
					      *out++ = b64c[((to_uchar (in[0]) << 4)
 | 
				
			||||||
                       + (--inlen ? to_uchar (in[1]) >> 4 : 0))
 | 
					                       + (--inlen ? to_uchar (in[1]) >> 4 : 0))
 | 
				
			||||||
                      & 0x3f];
 | 
					                      & 0x3f];
 | 
				
			||||||
      if (!--outlen)
 | 
					      if (!--outlen)
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      *out++ =
 | 
					      *out++ =
 | 
				
			||||||
        (inlen
 | 
					        (inlen
 | 
				
			||||||
         ? b64str[((to_uchar (in[1]) << 2)
 | 
					         ? b64c[((to_uchar (in[1]) << 2)
 | 
				
			||||||
                   + (--inlen ? to_uchar (in[2]) >> 6 : 0))
 | 
					                   + (--inlen ? to_uchar (in[2]) >> 6 : 0))
 | 
				
			||||||
                  & 0x3f]
 | 
					                  & 0x3f]
 | 
				
			||||||
         : '=');
 | 
					         : '=');
 | 
				
			||||||
      if (!--outlen)
 | 
					      if (!--outlen)
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      *out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '=';
 | 
					      *out++ = inlen ? b64c[to_uchar (in[2]) & 0x3f] : '=';
 | 
				
			||||||
      if (!--outlen)
 | 
					      if (!--outlen)
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      if (inlen)
 | 
					      if (inlen)
 | 
				
			||||||
| 
						 | 
					@ -110,30 +143,21 @@ base64_encode (const char *restrict in, size_t inlen,
 | 
				
			||||||
   memory allocation failed, OUT is set to NULL, and the return value
 | 
					   memory allocation failed, OUT is set to NULL, and the return value
 | 
				
			||||||
   indicates length of the requested memory block, i.e.,
 | 
					   indicates length of the requested memory block, i.e.,
 | 
				
			||||||
   BASE64_LENGTH(inlen) + 1. */
 | 
					   BASE64_LENGTH(inlen) + 1. */
 | 
				
			||||||
size_t
 | 
					idx_t
 | 
				
			||||||
base64_encode_alloc (const char *in, size_t inlen, char **out)
 | 
					base64_encode_alloc (const char *in, idx_t inlen, char **out)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  size_t outlen = 1 + BASE64_LENGTH (inlen);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /* Check for overflow in outlen computation.
 | 
					  /* Check for overflow in outlen computation.
 | 
				
			||||||
   *
 | 
					     Treat negative INLEN as overflow, for better compatibility with
 | 
				
			||||||
   * If there is no overflow, outlen >= inlen.
 | 
					     pre-2021-08-27 API, which used size_t.  */
 | 
				
			||||||
   *
 | 
					  idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen;
 | 
				
			||||||
   * If the operation (inlen + 2) overflows then it yields at most +1, so
 | 
					  if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen) || inlen < 0)
 | 
				
			||||||
   * outlen is 0.
 | 
					 | 
				
			||||||
   *
 | 
					 | 
				
			||||||
   * If the multiplication overflows, we lose at least half of the
 | 
					 | 
				
			||||||
   * correct value, so the result is < ((inlen + 2) / 3) * 2, which is
 | 
					 | 
				
			||||||
   * less than (inlen + 2) * 0.66667, which is less than inlen as soon as
 | 
					 | 
				
			||||||
   * (inlen > 4).
 | 
					 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
  if (inlen > outlen)
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      *out = NULL;
 | 
					      *out = NULL;
 | 
				
			||||||
      return 0;
 | 
					      return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  outlen++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  *out = malloc (outlen);
 | 
					  *out = imalloc (outlen);
 | 
				
			||||||
  if (!*out)
 | 
					  if (!*out)
 | 
				
			||||||
    return outlen;
 | 
					    return outlen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -317,7 +341,7 @@ base64_decode_ctx_init (struct base64_decode_context *ctx)
 | 
				
			||||||
static char *
 | 
					static char *
 | 
				
			||||||
get_4 (struct base64_decode_context *ctx,
 | 
					get_4 (struct base64_decode_context *ctx,
 | 
				
			||||||
       char const *restrict *in, char const *restrict in_end,
 | 
					       char const *restrict *in, char const *restrict in_end,
 | 
				
			||||||
       size_t *n_non_newline)
 | 
					       idx_t *n_non_newline)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (ctx->i == 4)
 | 
					  if (ctx->i == 4)
 | 
				
			||||||
    ctx->i = 0;
 | 
					    ctx->i = 0;
 | 
				
			||||||
| 
						 | 
					@ -369,8 +393,8 @@ get_4 (struct base64_decode_context *ctx,
 | 
				
			||||||
   *OUT to point to the byte after the last one written, and decrement
 | 
					   *OUT to point to the byte after the last one written, and decrement
 | 
				
			||||||
   *OUTLEN to reflect the number of bytes remaining in *OUT.  */
 | 
					   *OUTLEN to reflect the number of bytes remaining in *OUT.  */
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
decode_4 (char const *restrict in, size_t inlen,
 | 
					decode_4 (char const *restrict in, idx_t inlen,
 | 
				
			||||||
          char *restrict *outp, size_t *outleft)
 | 
					          char *restrict *outp, idx_t *outleft)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  char *out = *outp;
 | 
					  char *out = *outp;
 | 
				
			||||||
  if (inlen < 2)
 | 
					  if (inlen < 2)
 | 
				
			||||||
| 
						 | 
					@ -455,10 +479,10 @@ decode_4 (char const *restrict in, size_t inlen,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool
 | 
					bool
 | 
				
			||||||
base64_decode_ctx (struct base64_decode_context *ctx,
 | 
					base64_decode_ctx (struct base64_decode_context *ctx,
 | 
				
			||||||
                   const char *restrict in, size_t inlen,
 | 
					                   const char *restrict in, idx_t inlen,
 | 
				
			||||||
                   char *restrict out, size_t *outlen)
 | 
					                   char *restrict out, idx_t *outlen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  size_t outleft = *outlen;
 | 
					  idx_t outleft = *outlen;
 | 
				
			||||||
  bool ignore_newlines = ctx != NULL;
 | 
					  bool ignore_newlines = ctx != NULL;
 | 
				
			||||||
  bool flush_ctx = false;
 | 
					  bool flush_ctx = false;
 | 
				
			||||||
  unsigned int ctx_i = 0;
 | 
					  unsigned int ctx_i = 0;
 | 
				
			||||||
| 
						 | 
					@ -472,7 +496,7 @@ base64_decode_ctx (struct base64_decode_context *ctx,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (true)
 | 
					  while (true)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      size_t outleft_save = outleft;
 | 
					      idx_t outleft_save = outleft;
 | 
				
			||||||
      if (ctx_i == 0 && !flush_ctx)
 | 
					      if (ctx_i == 0 && !flush_ctx)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          while (true)
 | 
					          while (true)
 | 
				
			||||||
| 
						 | 
					@ -546,17 +570,17 @@ base64_decode_ctx (struct base64_decode_context *ctx,
 | 
				
			||||||
   undefined. */
 | 
					   undefined. */
 | 
				
			||||||
bool
 | 
					bool
 | 
				
			||||||
base64_decode_alloc_ctx (struct base64_decode_context *ctx,
 | 
					base64_decode_alloc_ctx (struct base64_decode_context *ctx,
 | 
				
			||||||
                         const char *in, size_t inlen, char **out,
 | 
					                         const char *in, idx_t inlen, char **out,
 | 
				
			||||||
                         size_t *outlen)
 | 
					                         idx_t *outlen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  /* This may allocate a few bytes too many, depending on input,
 | 
					  /* This may allocate a few bytes too many, depending on input,
 | 
				
			||||||
     but it's not worth the extra CPU time to compute the exact size.
 | 
					     but it's not worth the extra CPU time to compute the exact size.
 | 
				
			||||||
     The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
 | 
					     The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
 | 
				
			||||||
     input ends with "=" and minus another 1 if the input ends with "==".
 | 
					     input ends with "=" and minus another 1 if the input ends with "==".
 | 
				
			||||||
     Dividing before multiplying avoids the possibility of overflow.  */
 | 
					     Shifting before multiplying avoids the possibility of overflow.  */
 | 
				
			||||||
  size_t needlen = 3 * (inlen / 4) + 3;
 | 
					  idx_t needlen = 3 * ((inlen >> 2) + 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  *out = malloc (needlen);
 | 
					  *out = imalloc (needlen);
 | 
				
			||||||
  if (!*out)
 | 
					  if (!*out)
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										41
									
								
								gl/base64.h
									
										
									
									
									
								
							
							
						
						
									
										41
									
								
								gl/base64.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,28 +1,25 @@
 | 
				
			||||||
/* base64.h -- Encode binary data using printable characters.
 | 
					/* base64.h -- Encode binary data using printable characters.
 | 
				
			||||||
   Copyright (C) 2004-2006, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2004-2006, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Written by Simon Josefsson.
 | 
					   Written by Simon Josefsson.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef BASE64_H
 | 
					#ifndef BASE64_H
 | 
				
			||||||
# define BASE64_H
 | 
					# define BASE64_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Get size_t. */
 | 
					/* Get idx_t.  */
 | 
				
			||||||
# include <stddef.h>
 | 
					# include <idx.h>
 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Get bool. */
 | 
					 | 
				
			||||||
# include <stdbool.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ifdef __cplusplus
 | 
					# ifdef __cplusplus
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
| 
						 | 
					@ -34,26 +31,26 @@ extern "C" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct base64_decode_context
 | 
					struct base64_decode_context
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned int i;
 | 
					  int i;
 | 
				
			||||||
  char buf[4];
 | 
					  char buf[4];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
 | 
					extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void base64_encode (const char *restrict in, size_t inlen,
 | 
					extern void base64_encode (const char *restrict in, idx_t inlen,
 | 
				
			||||||
                           char *restrict out, size_t outlen);
 | 
					                           char *restrict out, idx_t outlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
 | 
					extern idx_t base64_encode_alloc (const char *in, idx_t inlen, char **out);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
 | 
					extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern bool base64_decode_ctx (struct base64_decode_context *ctx,
 | 
					extern bool base64_decode_ctx (struct base64_decode_context *ctx,
 | 
				
			||||||
                               const char *restrict in, size_t inlen,
 | 
					                               const char *restrict in, idx_t inlen,
 | 
				
			||||||
                               char *restrict out, size_t *outlen);
 | 
					                               char *restrict out, idx_t *outlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
 | 
					extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
 | 
				
			||||||
                                     const char *in, size_t inlen,
 | 
					                                     const char *in, idx_t inlen,
 | 
				
			||||||
                                     char **out, size_t *outlen);
 | 
					                                     char **out, idx_t *outlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define base64_decode(in, inlen, out, outlen) \
 | 
					#define base64_decode(in, inlen, out, outlen) \
 | 
				
			||||||
        base64_decode_ctx (NULL, in, inlen, out, outlen)
 | 
					        base64_decode_ctx (NULL, in, inlen, out, outlen)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,37 +1,36 @@
 | 
				
			||||||
/* basename.c -- return the last element in a file name
 | 
					/* basename.c -- return the last element in a file name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
 | 
					   Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dirname.h"
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include "basename-lgpl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Return the address of the last file name component of NAME.  If
 | 
					#include "filename.h"
 | 
				
			||||||
   NAME has no relative file name components because it is a file
 | 
					 | 
				
			||||||
   system root, return the empty string.  */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *
 | 
					char *
 | 
				
			||||||
last_component (char const *name)
 | 
					last_component (char const *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
 | 
					  char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
 | 
				
			||||||
  char const *p;
 | 
					  char const *p;
 | 
				
			||||||
  bool saw_slash = false;
 | 
					  bool last_was_slash = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (ISSLASH (*base))
 | 
					  while (ISSLASH (*base))
 | 
				
			||||||
    base++;
 | 
					    base++;
 | 
				
			||||||
| 
						 | 
					@ -39,21 +38,17 @@ last_component (char const *name)
 | 
				
			||||||
  for (p = base; *p; p++)
 | 
					  for (p = base; *p; p++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      if (ISSLASH (*p))
 | 
					      if (ISSLASH (*p))
 | 
				
			||||||
        saw_slash = true;
 | 
					        last_was_slash = true;
 | 
				
			||||||
      else if (saw_slash)
 | 
					      else if (last_was_slash)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          base = p;
 | 
					          base = p;
 | 
				
			||||||
          saw_slash = false;
 | 
					          last_was_slash = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (char *) base;
 | 
					  return (char *) base;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Return the length of the basename NAME.  Typically NAME is the
 | 
					 | 
				
			||||||
   value returned by base_name or last_component.  Act like strlen
 | 
					 | 
				
			||||||
   (NAME), except omit all trailing slashes.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
base_len (char const *name)
 | 
					base_len (char const *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										78
									
								
								gl/basename-lgpl.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								gl/basename-lgpl.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,78 @@
 | 
				
			||||||
 | 
					/* Extract the last component (base name) of a file name.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
 | 
				
			||||||
 | 
					   Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _BASENAME_LGPL_H
 | 
				
			||||||
 | 
					#define _BASENAME_LGPL_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stddef.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
 | 
				
			||||||
 | 
					# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return the address of the last file name component of FILENAME.
 | 
				
			||||||
 | 
					   If FILENAME has some trailing slash(es), they are considered to be
 | 
				
			||||||
 | 
					   part of the last component.
 | 
				
			||||||
 | 
					   If FILENAME has no relative file name components because it is a file
 | 
				
			||||||
 | 
					   system root, return the empty string.
 | 
				
			||||||
 | 
					   Examples:
 | 
				
			||||||
 | 
					              FILENAME      RESULT
 | 
				
			||||||
 | 
					              "foo.c"       "foo.c"
 | 
				
			||||||
 | 
					              "foo/bar.c"   "bar.c"
 | 
				
			||||||
 | 
					              "/foo/bar.c"  "bar.c"
 | 
				
			||||||
 | 
					              "foo/bar/"    "bar/"
 | 
				
			||||||
 | 
					              "foo/bar//"   "bar//"
 | 
				
			||||||
 | 
					              "/"           ""
 | 
				
			||||||
 | 
					              "//"          ""
 | 
				
			||||||
 | 
					              ""            ""
 | 
				
			||||||
 | 
					   The return value is a tail of the given FILENAME; do NOT free() it!  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This function was traditionally called 'basename', but we avoid this
 | 
				
			||||||
 | 
					   function name because
 | 
				
			||||||
 | 
					     * Various platforms have different functions in their libc.
 | 
				
			||||||
 | 
					       In particular, the glibc basename(), defined in <string.h>, does
 | 
				
			||||||
 | 
					       not consider trailing slashes to be part of the component:
 | 
				
			||||||
 | 
					              FILENAME      RESULT
 | 
				
			||||||
 | 
					              "foo/bar/"    ""
 | 
				
			||||||
 | 
					              "foo/bar//"   ""
 | 
				
			||||||
 | 
					     * The 'basename' command eliminates trailing slashes and for a root
 | 
				
			||||||
 | 
					       produces a non-empty result:
 | 
				
			||||||
 | 
					              FILENAME      RESULT
 | 
				
			||||||
 | 
					              "foo/bar/"    "bar"
 | 
				
			||||||
 | 
					              "foo/bar//"   "bar"
 | 
				
			||||||
 | 
					              "/"           "/"
 | 
				
			||||||
 | 
					              "//"          "/"
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					extern char *last_component (char const *filename) _GL_ATTRIBUTE_PURE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return the length of the basename FILENAME.
 | 
				
			||||||
 | 
					   Typically FILENAME is the value returned by base_name or last_component.
 | 
				
			||||||
 | 
					   Act like strlen (FILENAME), except omit all trailing slashes.  */
 | 
				
			||||||
 | 
					extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					} /* extern "C" */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _BASENAME_LGPL_H */
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,11 @@
 | 
				
			||||||
/* basename.c -- return the last element in a file name
 | 
					/* basename.c -- return the last element in a file name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
 | 
					   Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU General Public License as published by
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   the Free Software Foundation, either version 3 of the License, or
 | 
				
			||||||
   (at your option) any later version.
 | 
					   (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This program is distributed in the hope that it will be useful,
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,37 +22,43 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include "xalloc.h"
 | 
					#include "xalloc.h"
 | 
				
			||||||
#include "xstrndup.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *
 | 
					char *
 | 
				
			||||||
base_name (char const *name)
 | 
					base_name (char const *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  char const *base = last_component (name);
 | 
					  char const *base = last_component (name);
 | 
				
			||||||
  size_t length;
 | 
					  idx_t length;
 | 
				
			||||||
 | 
					  int dotslash_len;
 | 
				
			||||||
  /* If there is no last component, then name is a file system root or the
 | 
					  if (*base)
 | 
				
			||||||
     empty string.  */
 | 
					    {
 | 
				
			||||||
  if (! *base)
 | 
					      length = base_len (base);
 | 
				
			||||||
    return xstrndup (name, base_len (name));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /* Collapse a sequence of trailing slashes into one.  */
 | 
					      /* Collapse a sequence of trailing slashes into one.  */
 | 
				
			||||||
  length = base_len (base);
 | 
					      length += ISSLASH (base[length]);
 | 
				
			||||||
  if (ISSLASH (base[length]))
 | 
					 | 
				
			||||||
    length++;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /* On systems with drive letters, "a/b:c" must return "./b:c" rather
 | 
					      /* On systems with drive letters, "a/b:c" must return "./b:c" rather
 | 
				
			||||||
         than "b:c" to avoid confusion with a drive letter.  On systems
 | 
					         than "b:c" to avoid confusion with a drive letter.  On systems
 | 
				
			||||||
         with pure POSIX semantics, this is not an issue.  */
 | 
					         with pure POSIX semantics, this is not an issue.  */
 | 
				
			||||||
  if (FILE_SYSTEM_PREFIX_LEN (base))
 | 
					      dotslash_len = FILE_SYSTEM_PREFIX_LEN (base) != 0 ? 2 : 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* There is no last component, so NAME is a file system root or
 | 
				
			||||||
 | 
					         the empty string.  */
 | 
				
			||||||
 | 
					      base = name;
 | 
				
			||||||
 | 
					      length = base_len (base);
 | 
				
			||||||
 | 
					      dotslash_len = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  char *p = ximalloc (dotslash_len + length + 1);
 | 
				
			||||||
 | 
					  if (dotslash_len)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      char *p = xmalloc (length + 3);
 | 
					 | 
				
			||||||
      p[0] = '.';
 | 
					      p[0] = '.';
 | 
				
			||||||
      p[1] = '/';
 | 
					      p[1] = '/';
 | 
				
			||||||
      memcpy (p + 2, base, length);
 | 
					 | 
				
			||||||
      p[length + 2] = '\0';
 | 
					 | 
				
			||||||
      return p;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Finally, copy the basename.  */
 | 
					  /* Finally, copy the basename.  */
 | 
				
			||||||
  return xstrndup (base, length);
 | 
					  memcpy (p + dotslash_len, base, length);
 | 
				
			||||||
 | 
					  p[dotslash_len + length] = '\0';
 | 
				
			||||||
 | 
					  return p;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								gl/btowc.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								gl/btowc.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Convert unibyte character to wide character.
 | 
					/* Convert unibyte character to wide character.
 | 
				
			||||||
   Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Written by Bruno Haible <bruno@clisp.org>, 2008.
 | 
					   Written by Bruno Haible <bruno@clisp.org>, 2008.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										44
									
								
								gl/byteswap.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								gl/byteswap.in.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,44 @@
 | 
				
			||||||
 | 
					/* byteswap.h - Byte swapping
 | 
				
			||||||
 | 
					   Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GL_BYTESWAP_H
 | 
				
			||||||
 | 
					#define _GL_BYTESWAP_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Given an unsigned 16-bit argument X, return the value corresponding to
 | 
				
			||||||
 | 
					   X with reversed byte order.  */
 | 
				
			||||||
 | 
					#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
 | 
				
			||||||
 | 
					                     (((x) & 0xFF00) >> 8))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Given an unsigned 32-bit argument X, return the value corresponding to
 | 
				
			||||||
 | 
					   X with reversed byte order.  */
 | 
				
			||||||
 | 
					#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x0000FF00) << 8) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x00FF0000) >> 8) | \
 | 
				
			||||||
 | 
					                     (((x) & 0xFF000000) >> 24))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Given an unsigned 64-bit argument X, return the value corresponding to
 | 
				
			||||||
 | 
					   X with reversed byte order.  */
 | 
				
			||||||
 | 
					#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x000000000000FF00ULL) << 40) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x0000000000FF0000ULL) << 24) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x00000000FF000000ULL) << 8) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x000000FF00000000ULL) >> 8) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x0000FF0000000000ULL) >> 24) | \
 | 
				
			||||||
 | 
					                     (((x) & 0x00FF000000000000ULL) >> 40) | \
 | 
				
			||||||
 | 
					                     (((x) & 0xFF00000000000000ULL) >> 56))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GL_BYTESWAP_H */
 | 
				
			||||||
| 
						 | 
					@ -1,22 +1,31 @@
 | 
				
			||||||
/* C++ compatible function declaration macros.
 | 
					/* C++ compatible function declaration macros.
 | 
				
			||||||
   Copyright (C) 2010-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2010-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify it
 | 
					   This program is free software: you can redistribute it and/or modify it
 | 
				
			||||||
   under the terms of the GNU General Public License as published
 | 
					   under the terms of the GNU Lesser General Public License as published
 | 
				
			||||||
   by the Free Software Foundation; either version 3 of the License, or
 | 
					   by the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
   (at your option) any later version.
 | 
					   (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This program is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
   General Public License for more details.
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _GL_CXXDEFS_H
 | 
					#ifndef _GL_CXXDEFS_H
 | 
				
			||||||
#define _GL_CXXDEFS_H
 | 
					#define _GL_CXXDEFS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Begin/end the GNULIB_NAMESPACE namespace.  */
 | 
				
			||||||
 | 
					#if defined __cplusplus && defined GNULIB_NAMESPACE
 | 
				
			||||||
 | 
					# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
 | 
				
			||||||
 | 
					# define _GL_END_NAMESPACE }
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define _GL_BEGIN_NAMESPACE
 | 
				
			||||||
 | 
					# define _GL_END_NAMESPACE
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The three most frequent use cases of these macros are:
 | 
					/* The three most frequent use cases of these macros are:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   * For providing a substitute for a function that is missing on some
 | 
					   * For providing a substitute for a function that is missing on some
 | 
				
			||||||
| 
						 | 
					@ -111,14 +120,25 @@
 | 
				
			||||||
   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
 | 
					   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
 | 
				
			||||||
   Example:
 | 
					   Example:
 | 
				
			||||||
     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
 | 
					     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 */
 | 
					
 | 
				
			||||||
 | 
					   Wrapping rpl_func in an object with an inline conversion operator
 | 
				
			||||||
 | 
					   avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
 | 
				
			||||||
 | 
					   actually used in the program.  */
 | 
				
			||||||
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
 | 
					#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
 | 
				
			||||||
  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
 | 
					  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
 | 
				
			||||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
 | 
					#if defined __cplusplus && defined GNULIB_NAMESPACE
 | 
				
			||||||
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
 | 
					# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
 | 
				
			||||||
    namespace GNULIB_NAMESPACE                                \
 | 
					    namespace GNULIB_NAMESPACE                                \
 | 
				
			||||||
    {                                                         \
 | 
					    {                                                         \
 | 
				
			||||||
      rettype (*const func) parameters = ::rpl_func;          \
 | 
					      static const struct _gl_ ## func ## _wrapper            \
 | 
				
			||||||
 | 
					      {                                                       \
 | 
				
			||||||
 | 
					        typedef rettype (*type) parameters;                   \
 | 
				
			||||||
 | 
					                                                              \
 | 
				
			||||||
 | 
					        inline operator type () const                         \
 | 
				
			||||||
 | 
					        {                                                     \
 | 
				
			||||||
 | 
					          return ::rpl_func;                                  \
 | 
				
			||||||
 | 
					        }                                                     \
 | 
				
			||||||
 | 
					      } func = {};                                            \
 | 
				
			||||||
    }                                                         \
 | 
					    }                                                         \
 | 
				
			||||||
    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -126,6 +146,16 @@
 | 
				
			||||||
    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* _GL_CXXALIAS_MDA (func, rettype, parameters);
 | 
				
			||||||
 | 
					   is to be used when func is a Microsoft deprecated alias, on native Windows.
 | 
				
			||||||
 | 
					   It declares a C++ alias called GNULIB_NAMESPACE::func
 | 
				
			||||||
 | 
					   that redirects to _func, if GNULIB_NAMESPACE is defined.
 | 
				
			||||||
 | 
					   Example:
 | 
				
			||||||
 | 
					     _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
 | 
				
			||||||
 | 
					  _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
 | 
					/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
 | 
				
			||||||
   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
 | 
					   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
 | 
				
			||||||
   except that the C function rpl_func may have a slightly different
 | 
					   except that the C function rpl_func may have a slightly different
 | 
				
			||||||
| 
						 | 
					@ -135,8 +165,15 @@
 | 
				
			||||||
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
 | 
					# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
 | 
				
			||||||
    namespace GNULIB_NAMESPACE                                     \
 | 
					    namespace GNULIB_NAMESPACE                                     \
 | 
				
			||||||
    {                                                              \
 | 
					    {                                                              \
 | 
				
			||||||
      rettype (*const func) parameters =                           \
 | 
					      static const struct _gl_ ## func ## _wrapper                 \
 | 
				
			||||||
        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
 | 
					      {                                                            \
 | 
				
			||||||
 | 
					        typedef rettype (*type) parameters;                        \
 | 
				
			||||||
 | 
					                                                                   \
 | 
				
			||||||
 | 
					        inline operator type () const                              \
 | 
				
			||||||
 | 
					        {                                                          \
 | 
				
			||||||
 | 
					          return reinterpret_cast<type>(::rpl_func);               \
 | 
				
			||||||
 | 
					        }                                                          \
 | 
				
			||||||
 | 
					      } func = {};                                                 \
 | 
				
			||||||
    }                                                              \
 | 
					    }                                                              \
 | 
				
			||||||
    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -144,24 +181,37 @@
 | 
				
			||||||
    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
 | 
				
			||||||
 | 
					   is like  _GL_CXXALIAS_MDA (func, rettype, parameters);
 | 
				
			||||||
 | 
					   except that the C function func may have a slightly different declaration.
 | 
				
			||||||
 | 
					   A cast is used to silence the "invalid conversion" error that would
 | 
				
			||||||
 | 
					   otherwise occur.  */
 | 
				
			||||||
 | 
					#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
 | 
				
			||||||
 | 
					  _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
 | 
					/* _GL_CXXALIAS_SYS (func, rettype, parameters);
 | 
				
			||||||
   declares a C++ alias called GNULIB_NAMESPACE::func
 | 
					   declares a C++ alias called GNULIB_NAMESPACE::func
 | 
				
			||||||
   that redirects to the system provided function func, if GNULIB_NAMESPACE
 | 
					   that redirects to the system provided function func, if GNULIB_NAMESPACE
 | 
				
			||||||
   is defined.
 | 
					   is defined.
 | 
				
			||||||
   Example:
 | 
					   Example:
 | 
				
			||||||
     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
 | 
					     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 */
 | 
					
 | 
				
			||||||
 | 
					   Wrapping func in an object with an inline conversion operator
 | 
				
			||||||
 | 
					   avoids a reference to func unless GNULIB_NAMESPACE::func is
 | 
				
			||||||
 | 
					   actually used in the program.  */
 | 
				
			||||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
 | 
					#if defined __cplusplus && defined GNULIB_NAMESPACE
 | 
				
			||||||
  /* If we were to write
 | 
					 | 
				
			||||||
       rettype (*const func) parameters = ::func;
 | 
					 | 
				
			||||||
     like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
 | 
					 | 
				
			||||||
     better (remove an indirection through a 'static' pointer variable),
 | 
					 | 
				
			||||||
     but then the _GL_CXXALIASWARN macro below would cause a warning not only
 | 
					 | 
				
			||||||
     for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
 | 
					 | 
				
			||||||
# define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
 | 
					# define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
 | 
				
			||||||
    namespace GNULIB_NAMESPACE                                \
 | 
					    namespace GNULIB_NAMESPACE                                \
 | 
				
			||||||
    {                                                         \
 | 
					    {                                                         \
 | 
				
			||||||
      static rettype (*func) parameters = ::func;  \
 | 
					      static const struct _gl_ ## func ## _wrapper            \
 | 
				
			||||||
 | 
					      {                                                       \
 | 
				
			||||||
 | 
					        typedef rettype (*type) parameters;                   \
 | 
				
			||||||
 | 
					                                                              \
 | 
				
			||||||
 | 
					        inline operator type () const                         \
 | 
				
			||||||
 | 
					        {                                                     \
 | 
				
			||||||
 | 
					          return ::func;                                      \
 | 
				
			||||||
 | 
					        }                                                     \
 | 
				
			||||||
 | 
					      } func = {};                                            \
 | 
				
			||||||
    }                                                         \
 | 
					    }                                                         \
 | 
				
			||||||
    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -178,8 +228,15 @@
 | 
				
			||||||
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
 | 
					# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
 | 
				
			||||||
    namespace GNULIB_NAMESPACE                          \
 | 
					    namespace GNULIB_NAMESPACE                          \
 | 
				
			||||||
    {                                                   \
 | 
					    {                                                   \
 | 
				
			||||||
      static rettype (*func) parameters =               \
 | 
					      static const struct _gl_ ## func ## _wrapper      \
 | 
				
			||||||
        reinterpret_cast<rettype(*)parameters>(::func); \
 | 
					      {                                                 \
 | 
				
			||||||
 | 
					        typedef rettype (*type) parameters;             \
 | 
				
			||||||
 | 
					                                                        \
 | 
				
			||||||
 | 
					        inline operator type () const                   \
 | 
				
			||||||
 | 
					        {                                               \
 | 
				
			||||||
 | 
					          return reinterpret_cast<type>(::func);        \
 | 
				
			||||||
 | 
					        }                                               \
 | 
				
			||||||
 | 
					      } func = {};                                      \
 | 
				
			||||||
    }                                                   \
 | 
					    }                                                   \
 | 
				
			||||||
    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -202,9 +259,15 @@
 | 
				
			||||||
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
 | 
					# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
 | 
				
			||||||
    namespace GNULIB_NAMESPACE                                                \
 | 
					    namespace GNULIB_NAMESPACE                                                \
 | 
				
			||||||
    {                                                                         \
 | 
					    {                                                                         \
 | 
				
			||||||
      static rettype (*func) parameters =                                     \
 | 
					      static const struct _gl_ ## func ## _wrapper                            \
 | 
				
			||||||
        reinterpret_cast<rettype(*)parameters>(                               \
 | 
					      {                                                                       \
 | 
				
			||||||
          (rettype2(*)parameters2)(::func));                                  \
 | 
					        typedef rettype (*type) parameters;                                   \
 | 
				
			||||||
 | 
					                                                                              \
 | 
				
			||||||
 | 
					        inline operator type () const                                         \
 | 
				
			||||||
 | 
					        {                                                                     \
 | 
				
			||||||
 | 
					          return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
 | 
				
			||||||
 | 
					        }                                                                     \
 | 
				
			||||||
 | 
					      } func = {};                                                            \
 | 
				
			||||||
    }                                                                         \
 | 
					    }                                                                         \
 | 
				
			||||||
    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					    _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -221,9 +284,9 @@
 | 
				
			||||||
   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
 | 
					   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
 | 
				
			||||||
# define _GL_CXXALIASWARN_1(func,namespace) \
 | 
					# define _GL_CXXALIASWARN_1(func,namespace) \
 | 
				
			||||||
   _GL_CXXALIASWARN_2 (func, namespace)
 | 
					   _GL_CXXALIASWARN_2 (func, namespace)
 | 
				
			||||||
/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
 | 
					/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
 | 
				
			||||||
   we enable the warning only when not optimizing.  */
 | 
					   we enable the warning only when not optimizing.  */
 | 
				
			||||||
# if !__OPTIMIZE__
 | 
					# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
 | 
				
			||||||
#  define _GL_CXXALIASWARN_2(func,namespace) \
 | 
					#  define _GL_CXXALIASWARN_2(func,namespace) \
 | 
				
			||||||
    _GL_WARN_ON_USE (func, \
 | 
					    _GL_WARN_ON_USE (func, \
 | 
				
			||||||
                     "The symbol ::" #func " refers to the system function. " \
 | 
					                     "The symbol ::" #func " refers to the system function. " \
 | 
				
			||||||
| 
						 | 
					@ -249,16 +312,13 @@
 | 
				
			||||||
                        GNULIB_NAMESPACE)
 | 
					                        GNULIB_NAMESPACE)
 | 
				
			||||||
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
 | 
					# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
 | 
				
			||||||
   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
 | 
					   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
 | 
				
			||||||
/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
 | 
					/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
 | 
				
			||||||
   we enable the warning only when not optimizing.  */
 | 
					   we enable the warning only when not optimizing.  */
 | 
				
			||||||
# if !__OPTIMIZE__
 | 
					# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
 | 
				
			||||||
#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
 | 
					#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
 | 
				
			||||||
    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
 | 
					    _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
 | 
				
			||||||
                         "The symbol ::" #func " refers to the system function. " \
 | 
					                         "The symbol ::" #func " refers to the system function. " \
 | 
				
			||||||
                         "Use " #namespace "::" #func " instead.")
 | 
					                         "Use " #namespace "::" #func " instead.")
 | 
				
			||||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
 | 
					 | 
				
			||||||
#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
 | 
					 | 
				
			||||||
     extern __typeof__ (func) func
 | 
					 | 
				
			||||||
# else
 | 
					# else
 | 
				
			||||||
#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
 | 
					#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
 | 
				
			||||||
     _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
					     _GL_EXTERN_C int _gl_cxxalias_dummy
 | 
				
			||||||
							
								
								
									
										55
									
								
								gl/calloc.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								gl/calloc.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,55 @@
 | 
				
			||||||
 | 
					/* calloc() function that is glibc compatible.
 | 
				
			||||||
 | 
					   This wrapper function is required at least on Tru64 UNIX 5.1 and mingw.
 | 
				
			||||||
 | 
					   Copyright (C) 2004-2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* written by Jim Meyering and Bruno Haible */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "xalloc-oversized.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Call the system's calloc below.  */
 | 
				
			||||||
 | 
					#undef calloc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Allocate and zero-fill an NxS-byte block of memory from the heap,
 | 
				
			||||||
 | 
					   even if N or S is zero.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void *
 | 
				
			||||||
 | 
					rpl_calloc (size_t n, size_t s)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (n == 0 || s == 0)
 | 
				
			||||||
 | 
					    n = s = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (xalloc_oversized (n, s))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = ENOMEM;
 | 
				
			||||||
 | 
					      return NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void *result = calloc (n, s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if !HAVE_MALLOC_POSIX
 | 
				
			||||||
 | 
					  if (result == NULL)
 | 
				
			||||||
 | 
					    errno = ENOMEM;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										707
									
								
								gl/cdefs.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										707
									
								
								gl/cdefs.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,707 @@
 | 
				
			||||||
 | 
					/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   Copyright The GNU Toolchain Authors.
 | 
				
			||||||
 | 
					   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef	_SYS_CDEFS_H
 | 
				
			||||||
 | 
					#define	_SYS_CDEFS_H	1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* We are almost always included from features.h. */
 | 
				
			||||||
 | 
					#ifndef _FEATURES_H
 | 
				
			||||||
 | 
					# include <features.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The GNU libc does not support any K&R compilers or the traditional mode
 | 
				
			||||||
 | 
					   of ISO C compilers anymore.  Check for some of the combinations not
 | 
				
			||||||
 | 
					   supported anymore.  */
 | 
				
			||||||
 | 
					#if defined __GNUC__ && !defined __STDC__
 | 
				
			||||||
 | 
					# error "You need a ISO C conforming compiler to use the glibc headers"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Some user header file might have defined this before.  */
 | 
				
			||||||
 | 
					#undef	__P
 | 
				
			||||||
 | 
					#undef	__PMT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Compilers that lack __has_attribute may object to
 | 
				
			||||||
 | 
					       #if defined __has_attribute && __has_attribute (...)
 | 
				
			||||||
 | 
					   even though they do not need to evaluate the right-hand side of the &&.
 | 
				
			||||||
 | 
					   Similarly for __has_builtin, etc.  */
 | 
				
			||||||
 | 
					#if (defined __has_attribute \
 | 
				
			||||||
 | 
					     && (!defined __clang_minor__ \
 | 
				
			||||||
 | 
					         || (defined __apple_build_version__ \
 | 
				
			||||||
 | 
					             ? 6000000 <= __apple_build_version__ \
 | 
				
			||||||
 | 
					             : 3 < __clang_major__ + (5 <= __clang_minor__))))
 | 
				
			||||||
 | 
					# define __glibc_has_attribute(attr) __has_attribute (attr)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __glibc_has_attribute(attr) 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef __has_builtin
 | 
				
			||||||
 | 
					# define __glibc_has_builtin(name) __has_builtin (name)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __glibc_has_builtin(name) 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef __has_extension
 | 
				
			||||||
 | 
					# define __glibc_has_extension(ext) __has_extension (ext)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __glibc_has_extension(ext) 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined __GNUC__ || defined __clang__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* All functions, except those with callbacks or those that
 | 
				
			||||||
 | 
					   synchronize memory, are leaf functions.  */
 | 
				
			||||||
 | 
					# if __GNUC_PREREQ (4, 6) && !defined _LIBC
 | 
				
			||||||
 | 
					#  define __LEAF , __leaf__
 | 
				
			||||||
 | 
					#  define __LEAF_ATTR __attribute__ ((__leaf__))
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __LEAF
 | 
				
			||||||
 | 
					#  define __LEAF_ATTR
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* GCC can always grok prototypes.  For C++ programs we add throw()
 | 
				
			||||||
 | 
					   to help it optimize the function calls.  But this only works with
 | 
				
			||||||
 | 
					   gcc 2.8.x and egcs.  For gcc 3.4 and up we even mark C functions
 | 
				
			||||||
 | 
					   as non-throwing using a function attribute since programs can use
 | 
				
			||||||
 | 
					   the -fexceptions options for C code as well.  */
 | 
				
			||||||
 | 
					# if !defined __cplusplus \
 | 
				
			||||||
 | 
					     && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
 | 
				
			||||||
 | 
					#  define __THROW	__attribute__ ((__nothrow__ __LEAF))
 | 
				
			||||||
 | 
					#  define __THROWNL	__attribute__ ((__nothrow__))
 | 
				
			||||||
 | 
					#  define __NTH(fct)	__attribute__ ((__nothrow__ __LEAF)) fct
 | 
				
			||||||
 | 
					#  define __NTHNL(fct)  __attribute__ ((__nothrow__)) fct
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
 | 
				
			||||||
 | 
					#   if __cplusplus >= 201103L
 | 
				
			||||||
 | 
					#    define __THROW	noexcept (true)
 | 
				
			||||||
 | 
					#   else
 | 
				
			||||||
 | 
					#    define __THROW	throw ()
 | 
				
			||||||
 | 
					#   endif
 | 
				
			||||||
 | 
					#   define __THROWNL	__THROW
 | 
				
			||||||
 | 
					#   define __NTH(fct)	__LEAF_ATTR fct __THROW
 | 
				
			||||||
 | 
					#   define __NTHNL(fct) fct __THROW
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					#   define __THROW
 | 
				
			||||||
 | 
					#   define __THROWNL
 | 
				
			||||||
 | 
					#   define __NTH(fct)	fct
 | 
				
			||||||
 | 
					#   define __NTHNL(fct) fct
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else	/* Not GCC or clang.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if (defined __cplusplus						\
 | 
				
			||||||
 | 
					      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
 | 
				
			||||||
 | 
					#  define __inline	inline
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __inline		/* No inline functions.  */
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# define __THROW
 | 
				
			||||||
 | 
					# define __THROWNL
 | 
				
			||||||
 | 
					# define __NTH(fct)	fct
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif	/* GCC || clang.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* These two macros are not used in glibc anymore.  They are kept here
 | 
				
			||||||
 | 
					   only because some other projects expect the macros to be defined.  */
 | 
				
			||||||
 | 
					#define __P(args)	args
 | 
				
			||||||
 | 
					#define __PMT(args)	args
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* For these things, GCC behaves the ANSI way normally,
 | 
				
			||||||
 | 
					   and the non-ANSI way under -traditional.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define __CONCAT(x,y)	x ## y
 | 
				
			||||||
 | 
					#define __STRING(x)	#x
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This is not a typedef so `const __ptr_t' does the right thing.  */
 | 
				
			||||||
 | 
					#define __ptr_t void *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* C++ needs to know that types and declarations are C, not C++.  */
 | 
				
			||||||
 | 
					#ifdef	__cplusplus
 | 
				
			||||||
 | 
					# define __BEGIN_DECLS	extern "C" {
 | 
				
			||||||
 | 
					# define __END_DECLS	}
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __BEGIN_DECLS
 | 
				
			||||||
 | 
					# define __END_DECLS
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fortify support.  */
 | 
				
			||||||
 | 
					#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
 | 
				
			||||||
 | 
					#define __bos0(ptr) __builtin_object_size (ptr, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available.  */
 | 
				
			||||||
 | 
					#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0)		      \
 | 
				
			||||||
 | 
									 || __GNUC_PREREQ (12, 0))
 | 
				
			||||||
 | 
					# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
 | 
				
			||||||
 | 
					# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __glibc_objsize0(__o) __bos0 (__o)
 | 
				
			||||||
 | 
					# define __glibc_objsize(__o) __bos (__o)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Compile time conditions to choose between the regular, _chk and _chk_warn
 | 
				
			||||||
 | 
					   variants.  These conditions should get evaluated to constant and optimized
 | 
				
			||||||
 | 
					   away.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
 | 
				
			||||||
 | 
					#define __glibc_unsigned_or_positive(__l) \
 | 
				
			||||||
 | 
					  ((__typeof (__l)) 0 < (__typeof (__l)) -1				      \
 | 
				
			||||||
 | 
					   || (__builtin_constant_p (__l) && (__l) > 0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
 | 
				
			||||||
 | 
					   condition can be folded to a constant and if it is true, or unknown (-1) */
 | 
				
			||||||
 | 
					#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
 | 
				
			||||||
 | 
					  ((__osz) == (__SIZE_TYPE__) -1					      \
 | 
				
			||||||
 | 
					   || (__glibc_unsigned_or_positive (__l)				      \
 | 
				
			||||||
 | 
					       && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
 | 
				
			||||||
 | 
											       (__s), (__osz)))	      \
 | 
				
			||||||
 | 
					       && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Conversely, we know at compile time that the length is unsafe if the
 | 
				
			||||||
 | 
					   __L * __S <= __OBJSZ condition can be folded to a constant and if it is
 | 
				
			||||||
 | 
					   false.  */
 | 
				
			||||||
 | 
					#define __glibc_unsafe_len(__l, __s, __osz) \
 | 
				
			||||||
 | 
					  (__glibc_unsigned_or_positive (__l)					      \
 | 
				
			||||||
 | 
					   && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l),     \
 | 
				
			||||||
 | 
											   __s, __osz))		      \
 | 
				
			||||||
 | 
					   && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fortify function f.  __f_alias, __f_chk and __f_chk_warn must be
 | 
				
			||||||
 | 
					   declared.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define __glibc_fortify(f, __l, __s, __osz, ...) \
 | 
				
			||||||
 | 
					  (__glibc_safe_or_unknown_len (__l, __s, __osz)			      \
 | 
				
			||||||
 | 
					   ? __ ## f ## _alias (__VA_ARGS__)					      \
 | 
				
			||||||
 | 
					   : (__glibc_unsafe_len (__l, __s, __osz)				      \
 | 
				
			||||||
 | 
					      ? __ ## f ## _chk_warn (__VA_ARGS__, __osz)			      \
 | 
				
			||||||
 | 
					      : __ ## f ## _chk (__VA_ARGS__, __osz)))			      \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fortify function f, where object size argument passed to f is the number of
 | 
				
			||||||
 | 
					   elements and not total size.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
 | 
				
			||||||
 | 
					  (__glibc_safe_or_unknown_len (__l, __s, __osz)			      \
 | 
				
			||||||
 | 
					   ? __ ## f ## _alias (__VA_ARGS__)					      \
 | 
				
			||||||
 | 
					   : (__glibc_unsafe_len (__l, __s, __osz)				      \
 | 
				
			||||||
 | 
					      ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s))		      \
 | 
				
			||||||
 | 
					      : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))		      \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4,3)
 | 
				
			||||||
 | 
					# define __warnattr(msg) __attribute__((__warning__ (msg)))
 | 
				
			||||||
 | 
					# define __errordecl(name, msg) \
 | 
				
			||||||
 | 
					  extern void name (void) __attribute__((__error__ (msg)))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __warnattr(msg)
 | 
				
			||||||
 | 
					# define __errordecl(name, msg) extern void name (void)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Support for flexible arrays.
 | 
				
			||||||
 | 
					   Headers that should use flexible arrays only if they're "real"
 | 
				
			||||||
 | 
					   (e.g. only if they won't affect sizeof()) should test
 | 
				
			||||||
 | 
					   #if __glibc_c99_flexarr_available.  */
 | 
				
			||||||
 | 
					#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
 | 
				
			||||||
 | 
					# define __flexarr	[]
 | 
				
			||||||
 | 
					# define __glibc_c99_flexarr_available 1
 | 
				
			||||||
 | 
					#elif __GNUC_PREREQ (2,97) || defined __clang__
 | 
				
			||||||
 | 
					/* GCC 2.97 and clang support C99 flexible array members as an extension,
 | 
				
			||||||
 | 
					   even when in C89 mode or compiling C++ (any version).  */
 | 
				
			||||||
 | 
					# define __flexarr	[]
 | 
				
			||||||
 | 
					# define __glibc_c99_flexarr_available 1
 | 
				
			||||||
 | 
					#elif defined __GNUC__
 | 
				
			||||||
 | 
					/* Pre-2.97 GCC did not support C99 flexible arrays but did have
 | 
				
			||||||
 | 
					   an equivalent extension with slightly different notation.  */
 | 
				
			||||||
 | 
					# define __flexarr	[0]
 | 
				
			||||||
 | 
					# define __glibc_c99_flexarr_available 1
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					/* Some other non-C99 compiler.  Approximate with [1].  */
 | 
				
			||||||
 | 
					# define __flexarr	[1]
 | 
				
			||||||
 | 
					# define __glibc_c99_flexarr_available 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* __asm__ ("xyz") is used throughout the headers to rename functions
 | 
				
			||||||
 | 
					   at the assembly language level.  This is wrapped by the __REDIRECT
 | 
				
			||||||
 | 
					   macro, in order to support compilers that can do this some other
 | 
				
			||||||
 | 
					   way.  When compilers don't support asm-names at all, we have to do
 | 
				
			||||||
 | 
					   preprocessor tricks instead (which don't have exactly the right
 | 
				
			||||||
 | 
					   semantics, but it's the best we can do).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Example:
 | 
				
			||||||
 | 
					   int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
 | 
				
			||||||
 | 
					# ifdef __cplusplus
 | 
				
			||||||
 | 
					#  define __REDIRECT_NTH(name, proto, alias) \
 | 
				
			||||||
 | 
					     name proto __THROW __asm__ (__ASMNAME (#alias))
 | 
				
			||||||
 | 
					#  define __REDIRECT_NTHNL(name, proto, alias) \
 | 
				
			||||||
 | 
					     name proto __THROWNL __asm__ (__ASMNAME (#alias))
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __REDIRECT_NTH(name, proto, alias) \
 | 
				
			||||||
 | 
					     name proto __asm__ (__ASMNAME (#alias)) __THROW
 | 
				
			||||||
 | 
					#  define __REDIRECT_NTHNL(name, proto, alias) \
 | 
				
			||||||
 | 
					     name proto __asm__ (__ASMNAME (#alias)) __THROWNL
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
 | 
				
			||||||
 | 
					# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					#elif __SOME_OTHER_COMPILER__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# define __REDIRECT(name, proto, alias) name proto; \
 | 
				
			||||||
 | 
						_Pragma("let " #name " = " #alias)
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* GCC and clang have various useful declarations that can be made with
 | 
				
			||||||
 | 
					   the '__attribute__' syntax.  All of the ways we use this do fine if
 | 
				
			||||||
 | 
					   they are omitted for compilers that don't understand it.  */
 | 
				
			||||||
 | 
					#if !(defined __GNUC__ || defined __clang__)
 | 
				
			||||||
 | 
					# define __attribute__(xyz)	/* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* At some point during the gcc 2.96 development the `malloc' attribute
 | 
				
			||||||
 | 
					   for functions was introduced.  We don't want to use it unconditionally
 | 
				
			||||||
 | 
					   (although this would be possible) since it generates warnings.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
 | 
				
			||||||
 | 
					# define __attribute_malloc__ __attribute__ ((__malloc__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_malloc__ /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Tell the compiler which arguments to an allocation function
 | 
				
			||||||
 | 
					   indicate the size of the allocation.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4, 3)
 | 
				
			||||||
 | 
					# define __attribute_alloc_size__(params) \
 | 
				
			||||||
 | 
					  __attribute__ ((__alloc_size__ params))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_alloc_size__(params) /* Ignore.  */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Tell the compiler which argument to an allocation function
 | 
				
			||||||
 | 
					   indicates the alignment of the allocation.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
 | 
				
			||||||
 | 
					# define __attribute_alloc_align__(param) \
 | 
				
			||||||
 | 
					  __attribute__ ((__alloc_align__ param))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_alloc_align__(param) /* Ignore.  */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* At some point during the gcc 2.96 development the `pure' attribute
 | 
				
			||||||
 | 
					   for functions was introduced.  We don't want to use it unconditionally
 | 
				
			||||||
 | 
					   (although this would be possible) since it generates warnings.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
 | 
				
			||||||
 | 
					# define __attribute_pure__ __attribute__ ((__pure__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_pure__ /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This declaration tells the compiler that the value is constant.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
 | 
				
			||||||
 | 
					# define __attribute_const__ __attribute__ ((__const__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_const__ /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
 | 
				
			||||||
 | 
					# define __attribute_maybe_unused__ __attribute__ ((__unused__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_maybe_unused__ /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* At some point during the gcc 3.1 development the `used' attribute
 | 
				
			||||||
 | 
					   for functions was introduced.  We don't want to use it unconditionally
 | 
				
			||||||
 | 
					   (although this would be possible) since it generates warnings.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
 | 
				
			||||||
 | 
					# define __attribute_used__ __attribute__ ((__used__))
 | 
				
			||||||
 | 
					# define __attribute_noinline__ __attribute__ ((__noinline__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_used__ __attribute__ ((__unused__))
 | 
				
			||||||
 | 
					# define __attribute_noinline__ /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Since version 3.2, gcc allows marking deprecated functions.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
 | 
				
			||||||
 | 
					# define __attribute_deprecated__ __attribute__ ((__deprecated__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_deprecated__ /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Since version 4.5, gcc also allows one to specify the message printed
 | 
				
			||||||
 | 
					   when a deprecated function is used.  clang claims to be gcc 4.2, but
 | 
				
			||||||
 | 
					   may also support this feature.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4,5) \
 | 
				
			||||||
 | 
					    || __glibc_has_extension (__attribute_deprecated_with_message__)
 | 
				
			||||||
 | 
					# define __attribute_deprecated_msg__(msg) \
 | 
				
			||||||
 | 
						 __attribute__ ((__deprecated__ (msg)))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* At some point during the gcc 2.8 development the `format_arg' attribute
 | 
				
			||||||
 | 
					   for functions was introduced.  We don't want to use it unconditionally
 | 
				
			||||||
 | 
					   (although this would be possible) since it generates warnings.
 | 
				
			||||||
 | 
					   If several `format_arg' attributes are given for the same function, in
 | 
				
			||||||
 | 
					   gcc-3.0 and older, all but the last one are ignored.  In newer gccs,
 | 
				
			||||||
 | 
					   all designated arguments are considered.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
 | 
				
			||||||
 | 
					# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_format_arg__(x) /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* At some point during the gcc 2.97 development the `strfmon' format
 | 
				
			||||||
 | 
					   attribute for functions was introduced.  We don't want to use it
 | 
				
			||||||
 | 
					   unconditionally (although this would be possible) since it
 | 
				
			||||||
 | 
					   generates warnings.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
 | 
				
			||||||
 | 
					# define __attribute_format_strfmon__(a,b) \
 | 
				
			||||||
 | 
					  __attribute__ ((__format__ (__strfmon__, a, b)))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_format_strfmon__(a,b) /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The nonnull function attribute marks pointer parameters that
 | 
				
			||||||
 | 
					   must not be NULL.  This has the name __nonnull in glibc,
 | 
				
			||||||
 | 
					   and __attribute_nonnull__ in files shared with Gnulib to avoid
 | 
				
			||||||
 | 
					   collision with a different __nonnull in DragonFlyBSD 5.9.  */
 | 
				
			||||||
 | 
					#ifndef __attribute_nonnull__
 | 
				
			||||||
 | 
					# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
 | 
				
			||||||
 | 
					#  define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __attribute_nonnull__(params)
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef __nonnull
 | 
				
			||||||
 | 
					# define __nonnull(params) __attribute_nonnull__ (params)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The returns_nonnull function attribute marks the return type of the function
 | 
				
			||||||
 | 
					   as always being non-null.  */
 | 
				
			||||||
 | 
					#ifndef __returns_nonnull
 | 
				
			||||||
 | 
					# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
 | 
				
			||||||
 | 
					# define __returns_nonnull __attribute__ ((__returns_nonnull__))
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					# define __returns_nonnull
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If fortification mode, we warn about unused results of certain
 | 
				
			||||||
 | 
					   function calls which can lead to problems.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
 | 
				
			||||||
 | 
					# define __attribute_warn_unused_result__ \
 | 
				
			||||||
 | 
					   __attribute__ ((__warn_unused_result__))
 | 
				
			||||||
 | 
					# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
 | 
				
			||||||
 | 
					#  define __wur __attribute_warn_unused_result__
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_warn_unused_result__ /* empty */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef __wur
 | 
				
			||||||
 | 
					# define __wur /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Forces a function to be always inlined.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
 | 
				
			||||||
 | 
					/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
 | 
				
			||||||
 | 
					   it conflicts with this definition.  Therefore undefine it first to
 | 
				
			||||||
 | 
					   allow either header to be included first.  */
 | 
				
			||||||
 | 
					# undef __always_inline
 | 
				
			||||||
 | 
					# define __always_inline __inline __attribute__ ((__always_inline__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# undef __always_inline
 | 
				
			||||||
 | 
					# define __always_inline __inline
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Associate error messages with the source location of the call site rather
 | 
				
			||||||
 | 
					   than with the source location inside the function.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
 | 
				
			||||||
 | 
					# define __attribute_artificial__ __attribute__ ((__artificial__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_artificial__ /* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
 | 
				
			||||||
 | 
					   inline semantics, unless -fgnu89-inline is used.  Using __GNUC_STDC_INLINE__
 | 
				
			||||||
 | 
					   or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
 | 
				
			||||||
 | 
					   older than 4.3 may define these macros and still not guarantee GNU inlining
 | 
				
			||||||
 | 
					   semantics.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   clang++ identifies itself as gcc-4.2, but has support for GNU inlining
 | 
				
			||||||
 | 
					   semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
 | 
				
			||||||
 | 
					   __GNUC_GNU_INLINE__ macro definitions.  */
 | 
				
			||||||
 | 
					#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
 | 
				
			||||||
 | 
					     || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
 | 
				
			||||||
 | 
								       || defined __GNUC_GNU_INLINE__)))
 | 
				
			||||||
 | 
					# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
 | 
				
			||||||
 | 
					#  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
 | 
				
			||||||
 | 
					#  define __extern_always_inline \
 | 
				
			||||||
 | 
					  extern __always_inline __attribute__ ((__gnu_inline__))
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __extern_inline extern __inline
 | 
				
			||||||
 | 
					#  define __extern_always_inline extern __always_inline
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __extern_always_inline
 | 
				
			||||||
 | 
					# define __fortify_function __extern_always_inline __attribute_artificial__
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* GCC 4.3 and above allow passing all anonymous arguments of an
 | 
				
			||||||
 | 
					   __extern_always_inline function to some other vararg function.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4,3)
 | 
				
			||||||
 | 
					# define __va_arg_pack() __builtin_va_arg_pack ()
 | 
				
			||||||
 | 
					# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* It is possible to compile containing GCC extensions even if GCC is
 | 
				
			||||||
 | 
					   run in pedantic mode if the uses are carefully marked using the
 | 
				
			||||||
 | 
					   `__extension__' keyword.  But this is not generally available before
 | 
				
			||||||
 | 
					   version 2.8.  */
 | 
				
			||||||
 | 
					#if !(__GNUC_PREREQ (2,8) || defined __clang__)
 | 
				
			||||||
 | 
					# define __extension__		/* Ignore */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* __restrict is known in EGCS 1.2 and above, and in clang.
 | 
				
			||||||
 | 
					   It works also in C++ mode (outside of arrays), but only when spelled
 | 
				
			||||||
 | 
					   as '__restrict', not 'restrict'.  */
 | 
				
			||||||
 | 
					#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
 | 
				
			||||||
 | 
					# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
 | 
				
			||||||
 | 
					#  define __restrict	restrict
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __restrict	/* Ignore */
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is
 | 
				
			||||||
 | 
					     array_name[restrict]
 | 
				
			||||||
 | 
					   GCC 3.1 and clang support this.
 | 
				
			||||||
 | 
					   This syntax is not usable in C++ mode.  */
 | 
				
			||||||
 | 
					#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
 | 
				
			||||||
 | 
					# define __restrict_arr	__restrict
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# ifdef __GNUC__
 | 
				
			||||||
 | 
					#  define __restrict_arr	/* Not supported in old GCC.  */
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
 | 
				
			||||||
 | 
					#   define __restrict_arr	restrict
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					/* Some other non-C99 compiler.  */
 | 
				
			||||||
 | 
					#   define __restrict_arr	/* Not supported.  */
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
 | 
				
			||||||
 | 
					# define __glibc_unlikely(cond)	__builtin_expect ((cond), 0)
 | 
				
			||||||
 | 
					# define __glibc_likely(cond)	__builtin_expect ((cond), 1)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __glibc_unlikely(cond)	(cond)
 | 
				
			||||||
 | 
					# define __glibc_likely(cond)	(cond)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (!defined _Noreturn \
 | 
				
			||||||
 | 
					     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
 | 
				
			||||||
 | 
					     &&  !(__GNUC_PREREQ (4,7) \
 | 
				
			||||||
 | 
					           || (3 < __clang_major__ + (5 <= __clang_minor__))))
 | 
				
			||||||
 | 
					# if __GNUC_PREREQ (2,8)
 | 
				
			||||||
 | 
					#  define _Noreturn __attribute__ ((__noreturn__))
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define _Noreturn
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (8, 0)
 | 
				
			||||||
 | 
					/* Describes a char array whose address can safely be passed as the first
 | 
				
			||||||
 | 
					   argument to strncpy and strncat, as the char array is not necessarily
 | 
				
			||||||
 | 
					   a NUL-terminated string.  */
 | 
				
			||||||
 | 
					# define __attribute_nonstring__ __attribute__ ((__nonstring__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_nonstring__
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Undefine (also defined in libc-symbols.h).  */
 | 
				
			||||||
 | 
					#undef __attribute_copy__
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (9, 0)
 | 
				
			||||||
 | 
					/* Copies attributes from the declaration or type referenced by
 | 
				
			||||||
 | 
					   the argument.  */
 | 
				
			||||||
 | 
					# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_copy__(arg)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (!defined _Static_assert && !defined __cplusplus \
 | 
				
			||||||
 | 
					     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
 | 
				
			||||||
 | 
					     && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
 | 
				
			||||||
 | 
					         || defined __STRICT_ANSI__))
 | 
				
			||||||
 | 
					# define _Static_assert(expr, diagnostic) \
 | 
				
			||||||
 | 
					    extern int (*__Static_assert_function (void)) \
 | 
				
			||||||
 | 
					      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Gnulib avoids including these, as they don't work on non-glibc or
 | 
				
			||||||
 | 
					   older glibc platforms.  */
 | 
				
			||||||
 | 
					#ifndef __GNULIB_CDEFS
 | 
				
			||||||
 | 
					# include <bits/wordsize.h>
 | 
				
			||||||
 | 
					# include <bits/long-double.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
 | 
				
			||||||
 | 
					# ifdef __REDIRECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Alias name defined automatically.  */
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR_DECL(name) \
 | 
				
			||||||
 | 
					  extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Alias name defined automatically, with leading underscores.  */
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR2_DECL(name) \
 | 
				
			||||||
 | 
					  extern __typeof (__##name) __##name \
 | 
				
			||||||
 | 
					    __asm (__ASMNAME ("__" #name "ieee128"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Alias name defined manually.  */
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR1_DECL(name, alias) \
 | 
				
			||||||
 | 
					  extern __typeof (name) name __asm (__ASMNAME (#alias));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR1_NTH(name, proto, alias) \
 | 
				
			||||||
 | 
					  __REDIRECT_NTH (name, proto, alias)
 | 
				
			||||||
 | 
					#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
 | 
				
			||||||
 | 
					  __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Unused.  */
 | 
				
			||||||
 | 
					#  define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
 | 
				
			||||||
 | 
					# define __LDBL_COMPAT 1
 | 
				
			||||||
 | 
					# ifdef __REDIRECT
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR(name, proto) \
 | 
				
			||||||
 | 
					  __LDBL_REDIR1 (name, proto, __nldbl_##name)
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR_NTH(name, proto) \
 | 
				
			||||||
 | 
					  __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR2_DECL(name) \
 | 
				
			||||||
 | 
					  extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR1_DECL(name, alias) \
 | 
				
			||||||
 | 
					  extern __typeof (name) name __asm (__ASMNAME (#alias));
 | 
				
			||||||
 | 
					#  define __LDBL_REDIR_DECL(name) \
 | 
				
			||||||
 | 
					  extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
 | 
				
			||||||
 | 
					#  define __REDIRECT_LDBL(name, proto, alias) \
 | 
				
			||||||
 | 
					  __LDBL_REDIR1 (name, proto, __nldbl_##alias)
 | 
				
			||||||
 | 
					#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
 | 
				
			||||||
 | 
					  __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
 | 
				
			||||||
 | 
					    || !defined __REDIRECT
 | 
				
			||||||
 | 
					# define __LDBL_REDIR1(name, proto, alias) name proto
 | 
				
			||||||
 | 
					# define __LDBL_REDIR(name, proto) name proto
 | 
				
			||||||
 | 
					# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
 | 
				
			||||||
 | 
					# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
 | 
				
			||||||
 | 
					# define __LDBL_REDIR2_DECL(name)
 | 
				
			||||||
 | 
					# define __LDBL_REDIR_DECL(name)
 | 
				
			||||||
 | 
					# ifdef __REDIRECT
 | 
				
			||||||
 | 
					#  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
 | 
				
			||||||
 | 
					#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
 | 
				
			||||||
 | 
					  __REDIRECT_NTH (name, proto, alias)
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE.  This is
 | 
				
			||||||
 | 
					   intended for use in preprocessor macros.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Note: MESSAGE must be a _single_ string; concatenation of string
 | 
				
			||||||
 | 
					   literals is not supported.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
 | 
				
			||||||
 | 
					# define __glibc_macro_warning1(message) _Pragma (#message)
 | 
				
			||||||
 | 
					# define __glibc_macro_warning(message) \
 | 
				
			||||||
 | 
					  __glibc_macro_warning1 (GCC warning message)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __glibc_macro_warning(msg)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Generic selection (ISO C11) is a C-only feature, available in GCC
 | 
				
			||||||
 | 
					   since version 4.9.  Previous versions do not provide generic
 | 
				
			||||||
 | 
					   selection, even though they might set __STDC_VERSION__ to 201112L,
 | 
				
			||||||
 | 
					   when in -std=c11 mode.  Thus, we must check for !defined __GNUC__
 | 
				
			||||||
 | 
					   when testing __STDC_VERSION__ for generic selection support.
 | 
				
			||||||
 | 
					   On the other hand, Clang also defines __GNUC__, so a clang-specific
 | 
				
			||||||
 | 
					   check is required to enable the use of generic selection.  */
 | 
				
			||||||
 | 
					#if !defined __cplusplus \
 | 
				
			||||||
 | 
					    && (__GNUC_PREREQ (4, 9) \
 | 
				
			||||||
 | 
						|| __glibc_has_extension (c_generic_selections) \
 | 
				
			||||||
 | 
						|| (!defined __GNUC__ && defined __STDC_VERSION__ \
 | 
				
			||||||
 | 
						    && __STDC_VERSION__ >= 201112L))
 | 
				
			||||||
 | 
					# define __HAVE_GENERIC_SELECTION 1
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __HAVE_GENERIC_SELECTION 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (10, 0)
 | 
				
			||||||
 | 
					/* Designates a 1-based positional argument ref-index of pointer type
 | 
				
			||||||
 | 
					   that can be used to access size-index elements of the pointed-to
 | 
				
			||||||
 | 
					   array according to access mode, or at least one element when
 | 
				
			||||||
 | 
					   size-index is not provided:
 | 
				
			||||||
 | 
					     access (access-mode, <ref-index> [, <size-index>])  */
 | 
				
			||||||
 | 
					#  define __attr_access(x) __attribute__ ((__access__ x))
 | 
				
			||||||
 | 
					/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
 | 
				
			||||||
 | 
					   use the access attribute to get object sizes from function definition
 | 
				
			||||||
 | 
					   arguments, so we can't use them on functions we fortify.  Drop the object
 | 
				
			||||||
 | 
					   size hints for such functions.  */
 | 
				
			||||||
 | 
					#  if __USE_FORTIFY_LEVEL == 3
 | 
				
			||||||
 | 
					#    define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					#    define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					#  if __GNUC_PREREQ (11, 0)
 | 
				
			||||||
 | 
					#    define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					#    define __attr_access_none(argno)
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#  define __fortified_attr_access(a, o, s)
 | 
				
			||||||
 | 
					#  define __attr_access(x)
 | 
				
			||||||
 | 
					#  define __attr_access_none(argno)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (11, 0)
 | 
				
			||||||
 | 
					/* Designates dealloc as a function to call to deallocate objects
 | 
				
			||||||
 | 
					   allocated by the declared function.  */
 | 
				
			||||||
 | 
					# define __attr_dealloc(dealloc, argno) \
 | 
				
			||||||
 | 
					    __attribute__ ((__malloc__ (dealloc, argno)))
 | 
				
			||||||
 | 
					# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attr_dealloc(dealloc, argno)
 | 
				
			||||||
 | 
					# define __attr_dealloc_free
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specify that a function such as setjmp or vfork may return
 | 
				
			||||||
 | 
					   twice.  */
 | 
				
			||||||
 | 
					#if __GNUC_PREREQ (4, 1)
 | 
				
			||||||
 | 
					# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __attribute_returns_twice__ /* Ignore.  */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif	 /* sys/cdefs.h */
 | 
				
			||||||
							
								
								
									
										83
									
								
								gl/cloexec.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								gl/cloexec.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,83 @@
 | 
				
			||||||
 | 
					/* cloexec.c - set or clear the close-on-exec descriptor flag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 1991, 2004-2006, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The code is taken from glibc/manual/llio.texi  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cloexec.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
 | 
				
			||||||
 | 
					   or clear the flag if VALUE is false.
 | 
				
			||||||
 | 
					   Return 0 on success, or -1 on error with 'errno' set.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Note that on MingW, this function does NOT protect DESC from being
 | 
				
			||||||
 | 
					   inherited into spawned children.  Instead, either use dup_cloexec
 | 
				
			||||||
 | 
					   followed by closing the original DESC, or use interfaces such as
 | 
				
			||||||
 | 
					   open or pipe2 that accept flags like O_CLOEXEC to create DESC
 | 
				
			||||||
 | 
					   non-inheritable in the first place.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					set_cloexec_flag (int desc, bool value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef F_SETFD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int flags = fcntl (desc, F_GETFD, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (0 <= flags)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (flags == newflags
 | 
				
			||||||
 | 
					          || fcntl (desc, F_SETFD, newflags) != -1)
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else /* !F_SETFD */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Use dup2 to reject invalid file descriptors; the cloexec flag
 | 
				
			||||||
 | 
					     will be unaffected.  */
 | 
				
			||||||
 | 
					  if (desc < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = EBADF;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  if (dup2 (desc, desc) < 0)
 | 
				
			||||||
 | 
					    /* errno is EBADF here.  */
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* There is nothing we can do on this kind of platform.  Punt.  */
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					#endif /* !F_SETFD */
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Duplicates a file handle FD, while marking the copy to be closed
 | 
				
			||||||
 | 
					   prior to exec or spawn.  Returns -1 and sets errno if FD could not
 | 
				
			||||||
 | 
					   be duplicated.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					dup_cloexec (int fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return fcntl (fd, F_DUPFD_CLOEXEC, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										34
									
								
								gl/cloexec.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								gl/cloexec.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					/* cloexec.c - set or clear the close-on-exec descriptor flag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 2004, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
 | 
				
			||||||
 | 
					   or clear the flag if VALUE is false.
 | 
				
			||||||
 | 
					   Return 0 on success, or -1 on error with 'errno' set.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Note that on MingW, this function does NOT protect DESC from being
 | 
				
			||||||
 | 
					   inherited into spawned children.  Instead, either use dup_cloexec
 | 
				
			||||||
 | 
					   followed by closing the original DESC, or use interfaces such as
 | 
				
			||||||
 | 
					   open or pipe2 that accept flags like O_CLOEXEC to create DESC
 | 
				
			||||||
 | 
					   non-inheritable in the first place.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int set_cloexec_flag (int desc, bool value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Duplicates a file handle FD, while marking the copy to be closed
 | 
				
			||||||
 | 
					   prior to exec or spawn.  Returns -1 and sets errno if FD could not
 | 
				
			||||||
 | 
					   be duplicated.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int dup_cloexec (int fd);
 | 
				
			||||||
							
								
								
									
										75
									
								
								gl/close.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								gl/close.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,75 @@
 | 
				
			||||||
 | 
					/* close replacement.
 | 
				
			||||||
 | 
					   Copyright (C) 2008-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "fd-hook.h"
 | 
				
			||||||
 | 
					#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 | 
				
			||||||
 | 
					# include "msvc-inval.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#undef close
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _WIN32 && !defined __CYGWIN__
 | 
				
			||||||
 | 
					# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					close_nothrow (int fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TRY_MSVC_INVAL
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      result = _close (fd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  CATCH_MSVC_INVAL
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      result = -1;
 | 
				
			||||||
 | 
					      errno = EBADF;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  DONE_MSVC_INVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define close_nothrow _close
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define close_nothrow close
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Override close() to call into other gnulib modules.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					rpl_close (int fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if WINDOWS_SOCKETS
 | 
				
			||||||
 | 
					  int retval = execute_all_close_hooks (close_nothrow, fd);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  int retval = close_nothrow (fd);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if REPLACE_FCHDIR
 | 
				
			||||||
 | 
					  if (retval >= 0)
 | 
				
			||||||
 | 
					    _gl_unregister_fd (fd);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return retval;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,684 +0,0 @@
 | 
				
			||||||
#! /bin/sh
 | 
					 | 
				
			||||||
# Output a system dependent table of character encoding aliases.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#   Copyright (C) 2000-2004, 2006-2013 Free Software Foundation, Inc.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#   This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
#   it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
#   the Free Software Foundation; either version 3, or (at your option)
 | 
					 | 
				
			||||||
#   any later version.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#   This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
#   GNU General Public License for more details.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#   You should have received a copy of the GNU General Public License along
 | 
					 | 
				
			||||||
#   with this program; if not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# The table consists of lines of the form
 | 
					 | 
				
			||||||
#    ALIAS  CANONICAL
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
 | 
					 | 
				
			||||||
# ALIAS is compared in a case sensitive way.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# CANONICAL is the GNU canonical name for this character encoding.
 | 
					 | 
				
			||||||
# It must be an encoding supported by libiconv. Support by GNU libc is
 | 
					 | 
				
			||||||
# also desirable. CANONICAL is case insensitive. Usually an upper case
 | 
					 | 
				
			||||||
# MIME charset name is preferred.
 | 
					 | 
				
			||||||
# The current list of GNU canonical charset names is as follows.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#       name              MIME?             used by which systems
 | 
					 | 
				
			||||||
#                                    (darwin = Mac OS X, woe32 = native Windows)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#   ASCII, ANSI_X3.4-1968       glibc solaris freebsd netbsd darwin cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-3              Y   glibc solaris cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-4              Y   osf solaris freebsd netbsd openbsd darwin
 | 
					 | 
				
			||||||
#   ISO-8859-5              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-6              Y   glibc aix hpux solaris cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-7              Y   glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-8              Y   glibc aix hpux osf solaris cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-9              Y   glibc aix hpux irix osf solaris darwin cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-13                 glibc netbsd openbsd darwin cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-14                 glibc cygwin
 | 
					 | 
				
			||||||
#   ISO-8859-15                 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
 | 
					 | 
				
			||||||
#   KOI8-R                  Y   glibc solaris freebsd netbsd openbsd darwin
 | 
					 | 
				
			||||||
#   KOI8-U                  Y   glibc freebsd netbsd openbsd darwin cygwin
 | 
					 | 
				
			||||||
#   KOI8-T                      glibc
 | 
					 | 
				
			||||||
#   CP437                       dos
 | 
					 | 
				
			||||||
#   CP775                       dos
 | 
					 | 
				
			||||||
#   CP850                       aix osf dos
 | 
					 | 
				
			||||||
#   CP852                       dos
 | 
					 | 
				
			||||||
#   CP855                       dos
 | 
					 | 
				
			||||||
#   CP856                       aix
 | 
					 | 
				
			||||||
#   CP857                       dos
 | 
					 | 
				
			||||||
#   CP861                       dos
 | 
					 | 
				
			||||||
#   CP862                       dos
 | 
					 | 
				
			||||||
#   CP864                       dos
 | 
					 | 
				
			||||||
#   CP865                       dos
 | 
					 | 
				
			||||||
#   CP866                       freebsd netbsd openbsd darwin dos
 | 
					 | 
				
			||||||
#   CP869                       dos
 | 
					 | 
				
			||||||
#   CP874                       woe32 dos
 | 
					 | 
				
			||||||
#   CP922                       aix
 | 
					 | 
				
			||||||
#   CP932                       aix cygwin woe32 dos
 | 
					 | 
				
			||||||
#   CP943                       aix
 | 
					 | 
				
			||||||
#   CP949                       osf darwin woe32 dos
 | 
					 | 
				
			||||||
#   CP950                       woe32 dos
 | 
					 | 
				
			||||||
#   CP1046                      aix
 | 
					 | 
				
			||||||
#   CP1124                      aix
 | 
					 | 
				
			||||||
#   CP1125                      dos
 | 
					 | 
				
			||||||
#   CP1129                      aix
 | 
					 | 
				
			||||||
#   CP1131                      darwin
 | 
					 | 
				
			||||||
#   CP1250                      woe32
 | 
					 | 
				
			||||||
#   CP1251                      glibc solaris netbsd openbsd darwin cygwin woe32
 | 
					 | 
				
			||||||
#   CP1252                      aix woe32
 | 
					 | 
				
			||||||
#   CP1253                      woe32
 | 
					 | 
				
			||||||
#   CP1254                      woe32
 | 
					 | 
				
			||||||
#   CP1255                      glibc woe32
 | 
					 | 
				
			||||||
#   CP1256                      woe32
 | 
					 | 
				
			||||||
#   CP1257                      woe32
 | 
					 | 
				
			||||||
#   GB2312                  Y   glibc aix hpux irix solaris freebsd netbsd darwin
 | 
					 | 
				
			||||||
#   EUC-JP                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
 | 
					 | 
				
			||||||
#   EUC-KR                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
 | 
					 | 
				
			||||||
#   EUC-TW                      glibc aix hpux irix osf solaris netbsd
 | 
					 | 
				
			||||||
#   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin cygwin
 | 
					 | 
				
			||||||
#   BIG5-HKSCS                  glibc solaris darwin
 | 
					 | 
				
			||||||
#   GBK                         glibc aix osf solaris darwin cygwin woe32 dos
 | 
					 | 
				
			||||||
#   GB18030                     glibc solaris netbsd darwin
 | 
					 | 
				
			||||||
#   SHIFT_JIS               Y   hpux osf solaris freebsd netbsd darwin
 | 
					 | 
				
			||||||
#   JOHAB                       glibc solaris woe32
 | 
					 | 
				
			||||||
#   TIS-620                     glibc aix hpux osf solaris cygwin
 | 
					 | 
				
			||||||
#   VISCII                  Y   glibc
 | 
					 | 
				
			||||||
#   TCVN5712-1                  glibc
 | 
					 | 
				
			||||||
#   ARMSCII-8                   glibc darwin
 | 
					 | 
				
			||||||
#   GEORGIAN-PS                 glibc cygwin
 | 
					 | 
				
			||||||
#   PT154                       glibc
 | 
					 | 
				
			||||||
#   HP-ROMAN8                   hpux
 | 
					 | 
				
			||||||
#   HP-ARABIC8                  hpux
 | 
					 | 
				
			||||||
#   HP-GREEK8                   hpux
 | 
					 | 
				
			||||||
#   HP-HEBREW8                  hpux
 | 
					 | 
				
			||||||
#   HP-TURKISH8                 hpux
 | 
					 | 
				
			||||||
#   HP-KANA8                    hpux
 | 
					 | 
				
			||||||
#   DEC-KANJI                   osf
 | 
					 | 
				
			||||||
#   DEC-HANYU                   osf
 | 
					 | 
				
			||||||
#   UTF-8                   Y   glibc aix hpux osf solaris netbsd darwin cygwin
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Note: Names which are not marked as being a MIME name should not be used in
 | 
					 | 
				
			||||||
# Internet protocols for information interchange (mail, news, etc.).
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
 | 
					 | 
				
			||||||
# must understand both names and treat them as equivalent.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# The first argument passed to this file is the canonical host specification,
 | 
					 | 
				
			||||||
#    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
 | 
					 | 
				
			||||||
# or
 | 
					 | 
				
			||||||
#    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
host="$1"
 | 
					 | 
				
			||||||
os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
 | 
					 | 
				
			||||||
echo "# This file contains a table of character encoding aliases,"
 | 
					 | 
				
			||||||
echo "# suitable for operating system '${os}'."
 | 
					 | 
				
			||||||
echo "# It was automatically generated from config.charset."
 | 
					 | 
				
			||||||
# List of references, updated during installation:
 | 
					 | 
				
			||||||
echo "# Packages using this file: "
 | 
					 | 
				
			||||||
case "$os" in
 | 
					 | 
				
			||||||
  linux-gnulibc1*)
 | 
					 | 
				
			||||||
    # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
 | 
					 | 
				
			||||||
    # localcharset.c falls back to using the full locale name
 | 
					 | 
				
			||||||
    # from the environment variables.
 | 
					 | 
				
			||||||
    echo "C ASCII"
 | 
					 | 
				
			||||||
    echo "POSIX ASCII"
 | 
					 | 
				
			||||||
    for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
 | 
					 | 
				
			||||||
             en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
 | 
					 | 
				
			||||||
             en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
 | 
					 | 
				
			||||||
             es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
 | 
					 | 
				
			||||||
             et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
 | 
					 | 
				
			||||||
             fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
 | 
					 | 
				
			||||||
             it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
 | 
					 | 
				
			||||||
             sv_FI sv_SE; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-1"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-15@euro ISO-8859-15"
 | 
					 | 
				
			||||||
      echo "$l@euro ISO-8859-15"
 | 
					 | 
				
			||||||
      echo "$l.cp-437 CP437"
 | 
					 | 
				
			||||||
      echo "$l.cp-850 CP850"
 | 
					 | 
				
			||||||
      echo "$l.cp-1252 CP1252"
 | 
					 | 
				
			||||||
      echo "$l.cp-1252@euro CP1252"
 | 
					 | 
				
			||||||
      #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
      echo "$l.utf-8@euro UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
 | 
					 | 
				
			||||||
             sl_SI sr sr_CS sr_YU; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-2"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
      echo "$l.cp-852 CP852"
 | 
					 | 
				
			||||||
      echo "$l.cp-1250 CP1250"
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in mk mk_MK ru ru_RU; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-5"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
      echo "$l.koi8-r KOI8-R"
 | 
					 | 
				
			||||||
      echo "$l.cp-866 CP866"
 | 
					 | 
				
			||||||
      echo "$l.cp-1251 CP1251"
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in ar ar_SA; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-6"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-6 ISO-8859-6"
 | 
					 | 
				
			||||||
      echo "$l.cp-864 CP864"
 | 
					 | 
				
			||||||
      #echo "$l.cp-868 CP868" # not a commonly used encoding
 | 
					 | 
				
			||||||
      echo "$l.cp-1256 CP1256"
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in el el_GR gr gr_GR; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-7"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
      echo "$l.cp-869 CP869"
 | 
					 | 
				
			||||||
      echo "$l.cp-1253 CP1253"
 | 
					 | 
				
			||||||
      echo "$l.cp-1253@euro CP1253"
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
      echo "$l.utf-8@euro UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in he he_IL iw iw_IL; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-8"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-8 ISO-8859-8"
 | 
					 | 
				
			||||||
      echo "$l.cp-862 CP862"
 | 
					 | 
				
			||||||
      echo "$l.cp-1255 CP1255"
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in tr tr_TR; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-9"
 | 
					 | 
				
			||||||
      echo "$l.iso-8859-9 ISO-8859-9"
 | 
					 | 
				
			||||||
      echo "$l.cp-857 CP857"
 | 
					 | 
				
			||||||
      echo "$l.cp-1254 CP1254"
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in lt lt_LT lv lv_LV; do
 | 
					 | 
				
			||||||
      #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-13"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in ru_UA uk uk_UA; do
 | 
					 | 
				
			||||||
      echo "$l KOI8-U"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in zh zh_CN; do
 | 
					 | 
				
			||||||
      #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
 | 
					 | 
				
			||||||
      echo "$l GB2312"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in ja ja_JP ja_JP.EUC; do
 | 
					 | 
				
			||||||
      echo "$l EUC-JP"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in ko ko_KR; do
 | 
					 | 
				
			||||||
      echo "$l EUC-KR"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in th th_TH; do
 | 
					 | 
				
			||||||
      echo "$l TIS-620"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in fa fa_IR; do
 | 
					 | 
				
			||||||
      #echo "$l ISIRI-3342" # a broken encoding
 | 
					 | 
				
			||||||
      echo "$l.utf-8 UTF-8"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  linux* | *-gnu*)
 | 
					 | 
				
			||||||
    # With glibc-2.1 or newer, we don't need any canonicalization,
 | 
					 | 
				
			||||||
    # because glibc has iconv and both glibc and libiconv support all
 | 
					 | 
				
			||||||
    # GNU canonical names directly. Therefore, the Makefile does not
 | 
					 | 
				
			||||||
    # need to install the alias file at all.
 | 
					 | 
				
			||||||
    # The following applies only to glibc-2.0.x and older libcs.
 | 
					 | 
				
			||||||
    echo "ISO_646.IRV:1983 ASCII"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  aix*)
 | 
					 | 
				
			||||||
    echo "ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "ISO8859-6 ISO-8859-6"
 | 
					 | 
				
			||||||
    echo "ISO8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "ISO8859-8 ISO-8859-8"
 | 
					 | 
				
			||||||
    echo "ISO8859-9 ISO-8859-9"
 | 
					 | 
				
			||||||
    echo "ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    echo "IBM-850 CP850"
 | 
					 | 
				
			||||||
    echo "IBM-856 CP856"
 | 
					 | 
				
			||||||
    echo "IBM-921 ISO-8859-13"
 | 
					 | 
				
			||||||
    echo "IBM-922 CP922"
 | 
					 | 
				
			||||||
    echo "IBM-932 CP932"
 | 
					 | 
				
			||||||
    echo "IBM-943 CP943"
 | 
					 | 
				
			||||||
    echo "IBM-1046 CP1046"
 | 
					 | 
				
			||||||
    echo "IBM-1124 CP1124"
 | 
					 | 
				
			||||||
    echo "IBM-1129 CP1129"
 | 
					 | 
				
			||||||
    echo "IBM-1252 CP1252"
 | 
					 | 
				
			||||||
    echo "IBM-eucCN GB2312"
 | 
					 | 
				
			||||||
    echo "IBM-eucJP EUC-JP"
 | 
					 | 
				
			||||||
    echo "IBM-eucKR EUC-KR"
 | 
					 | 
				
			||||||
    echo "IBM-eucTW EUC-TW"
 | 
					 | 
				
			||||||
    echo "big5 BIG5"
 | 
					 | 
				
			||||||
    echo "GBK GBK"
 | 
					 | 
				
			||||||
    echo "TIS-620 TIS-620"
 | 
					 | 
				
			||||||
    echo "UTF-8 UTF-8"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  hpux*)
 | 
					 | 
				
			||||||
    echo "iso88591 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "iso88592 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "iso88595 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "iso88596 ISO-8859-6"
 | 
					 | 
				
			||||||
    echo "iso88597 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "iso88598 ISO-8859-8"
 | 
					 | 
				
			||||||
    echo "iso88599 ISO-8859-9"
 | 
					 | 
				
			||||||
    echo "iso885915 ISO-8859-15"
 | 
					 | 
				
			||||||
    echo "roman8 HP-ROMAN8"
 | 
					 | 
				
			||||||
    echo "arabic8 HP-ARABIC8"
 | 
					 | 
				
			||||||
    echo "greek8 HP-GREEK8"
 | 
					 | 
				
			||||||
    echo "hebrew8 HP-HEBREW8"
 | 
					 | 
				
			||||||
    echo "turkish8 HP-TURKISH8"
 | 
					 | 
				
			||||||
    echo "kana8 HP-KANA8"
 | 
					 | 
				
			||||||
    echo "tis620 TIS-620"
 | 
					 | 
				
			||||||
    echo "big5 BIG5"
 | 
					 | 
				
			||||||
    echo "eucJP EUC-JP"
 | 
					 | 
				
			||||||
    echo "eucKR EUC-KR"
 | 
					 | 
				
			||||||
    echo "eucTW EUC-TW"
 | 
					 | 
				
			||||||
    echo "hp15CN GB2312"
 | 
					 | 
				
			||||||
    #echo "ccdc ?" # what is this?
 | 
					 | 
				
			||||||
    echo "SJIS SHIFT_JIS"
 | 
					 | 
				
			||||||
    echo "utf8 UTF-8"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  irix*)
 | 
					 | 
				
			||||||
    echo "ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "ISO8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "ISO8859-9 ISO-8859-9"
 | 
					 | 
				
			||||||
    echo "eucCN GB2312"
 | 
					 | 
				
			||||||
    echo "eucJP EUC-JP"
 | 
					 | 
				
			||||||
    echo "eucKR EUC-KR"
 | 
					 | 
				
			||||||
    echo "eucTW EUC-TW"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  osf*)
 | 
					 | 
				
			||||||
    echo "ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "ISO8859-4 ISO-8859-4"
 | 
					 | 
				
			||||||
    echo "ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "ISO8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "ISO8859-8 ISO-8859-8"
 | 
					 | 
				
			||||||
    echo "ISO8859-9 ISO-8859-9"
 | 
					 | 
				
			||||||
    echo "ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    echo "cp850 CP850"
 | 
					 | 
				
			||||||
    echo "big5 BIG5"
 | 
					 | 
				
			||||||
    echo "dechanyu DEC-HANYU"
 | 
					 | 
				
			||||||
    echo "dechanzi GB2312"
 | 
					 | 
				
			||||||
    echo "deckanji DEC-KANJI"
 | 
					 | 
				
			||||||
    echo "deckorean EUC-KR"
 | 
					 | 
				
			||||||
    echo "eucJP EUC-JP"
 | 
					 | 
				
			||||||
    echo "eucKR EUC-KR"
 | 
					 | 
				
			||||||
    echo "eucTW EUC-TW"
 | 
					 | 
				
			||||||
    echo "GBK GBK"
 | 
					 | 
				
			||||||
    echo "KSC5601 CP949"
 | 
					 | 
				
			||||||
    echo "sdeckanji EUC-JP"
 | 
					 | 
				
			||||||
    echo "SJIS SHIFT_JIS"
 | 
					 | 
				
			||||||
    echo "TACTIS TIS-620"
 | 
					 | 
				
			||||||
    echo "UTF-8 UTF-8"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  solaris*)
 | 
					 | 
				
			||||||
    echo "646 ASCII"
 | 
					 | 
				
			||||||
    echo "ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "ISO8859-3 ISO-8859-3"
 | 
					 | 
				
			||||||
    echo "ISO8859-4 ISO-8859-4"
 | 
					 | 
				
			||||||
    echo "ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "ISO8859-6 ISO-8859-6"
 | 
					 | 
				
			||||||
    echo "ISO8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "ISO8859-8 ISO-8859-8"
 | 
					 | 
				
			||||||
    echo "ISO8859-9 ISO-8859-9"
 | 
					 | 
				
			||||||
    echo "ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    echo "koi8-r KOI8-R"
 | 
					 | 
				
			||||||
    echo "ansi-1251 CP1251"
 | 
					 | 
				
			||||||
    echo "BIG5 BIG5"
 | 
					 | 
				
			||||||
    echo "Big5-HKSCS BIG5-HKSCS"
 | 
					 | 
				
			||||||
    echo "gb2312 GB2312"
 | 
					 | 
				
			||||||
    echo "GBK GBK"
 | 
					 | 
				
			||||||
    echo "GB18030 GB18030"
 | 
					 | 
				
			||||||
    echo "cns11643 EUC-TW"
 | 
					 | 
				
			||||||
    echo "5601 EUC-KR"
 | 
					 | 
				
			||||||
    echo "ko_KR.johap92 JOHAB"
 | 
					 | 
				
			||||||
    echo "eucJP EUC-JP"
 | 
					 | 
				
			||||||
    echo "PCK SHIFT_JIS"
 | 
					 | 
				
			||||||
    echo "TIS620.2533 TIS-620"
 | 
					 | 
				
			||||||
    #echo "sun_eu_greek ?" # what is this?
 | 
					 | 
				
			||||||
    echo "UTF-8 UTF-8"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  freebsd* | os2*)
 | 
					 | 
				
			||||||
    # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
 | 
					 | 
				
			||||||
    # localcharset.c falls back to using the full locale name
 | 
					 | 
				
			||||||
    # from the environment variables.
 | 
					 | 
				
			||||||
    # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
 | 
					 | 
				
			||||||
    # reuse FreeBSD's locale data for OS/2.
 | 
					 | 
				
			||||||
    echo "C ASCII"
 | 
					 | 
				
			||||||
    echo "US-ASCII ASCII"
 | 
					 | 
				
			||||||
    for l in la_LN lt_LN; do
 | 
					 | 
				
			||||||
      echo "$l.ASCII ASCII"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
 | 
					 | 
				
			||||||
             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
 | 
					 | 
				
			||||||
             lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
 | 
					 | 
				
			||||||
      echo "$l.ISO_8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
      echo "$l.DIS_8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
 | 
					 | 
				
			||||||
      echo "$l.ISO_8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in la_LN lt_LT; do
 | 
					 | 
				
			||||||
      echo "$l.ISO_8859-4 ISO-8859-4"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in ru_RU ru_SU; do
 | 
					 | 
				
			||||||
      echo "$l.KOI8-R KOI8-R"
 | 
					 | 
				
			||||||
      echo "$l.ISO_8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
      echo "$l.CP866 CP866"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    echo "uk_UA.KOI8-U KOI8-U"
 | 
					 | 
				
			||||||
    echo "zh_TW.BIG5 BIG5"
 | 
					 | 
				
			||||||
    echo "zh_TW.Big5 BIG5"
 | 
					 | 
				
			||||||
    echo "zh_CN.EUC GB2312"
 | 
					 | 
				
			||||||
    echo "ja_JP.EUC EUC-JP"
 | 
					 | 
				
			||||||
    echo "ja_JP.SJIS SHIFT_JIS"
 | 
					 | 
				
			||||||
    echo "ja_JP.Shift_JIS SHIFT_JIS"
 | 
					 | 
				
			||||||
    echo "ko_KR.EUC EUC-KR"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  netbsd*)
 | 
					 | 
				
			||||||
    echo "646 ASCII"
 | 
					 | 
				
			||||||
    echo "ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "ISO8859-4 ISO-8859-4"
 | 
					 | 
				
			||||||
    echo "ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "ISO8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "ISO8859-13 ISO-8859-13"
 | 
					 | 
				
			||||||
    echo "ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    echo "eucCN GB2312"
 | 
					 | 
				
			||||||
    echo "eucJP EUC-JP"
 | 
					 | 
				
			||||||
    echo "eucKR EUC-KR"
 | 
					 | 
				
			||||||
    echo "eucTW EUC-TW"
 | 
					 | 
				
			||||||
    echo "BIG5 BIG5"
 | 
					 | 
				
			||||||
    echo "SJIS SHIFT_JIS"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  openbsd*)
 | 
					 | 
				
			||||||
    echo "646 ASCII"
 | 
					 | 
				
			||||||
    echo "ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "ISO8859-4 ISO-8859-4"
 | 
					 | 
				
			||||||
    echo "ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "ISO8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "ISO8859-13 ISO-8859-13"
 | 
					 | 
				
			||||||
    echo "ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  darwin[56]*)
 | 
					 | 
				
			||||||
    # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
 | 
					 | 
				
			||||||
    # localcharset.c falls back to using the full locale name
 | 
					 | 
				
			||||||
    # from the environment variables.
 | 
					 | 
				
			||||||
    echo "C ASCII"
 | 
					 | 
				
			||||||
    for l in en_AU en_CA en_GB en_US la_LN; do
 | 
					 | 
				
			||||||
      echo "$l.US-ASCII ASCII"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
 | 
					 | 
				
			||||||
             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
 | 
					 | 
				
			||||||
             nl_NL no_NO pt_PT sv_SE; do
 | 
					 | 
				
			||||||
      echo "$l ISO-8859-1"
 | 
					 | 
				
			||||||
      echo "$l.ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
      echo "$l.ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in la_LN; do
 | 
					 | 
				
			||||||
      echo "$l.ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
      echo "$l.ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
 | 
					 | 
				
			||||||
      echo "$l.ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in la_LN lt_LT; do
 | 
					 | 
				
			||||||
      echo "$l.ISO8859-4 ISO-8859-4"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in ru_RU; do
 | 
					 | 
				
			||||||
      echo "$l.KOI8-R KOI8-R"
 | 
					 | 
				
			||||||
      echo "$l.ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
      echo "$l.CP866 CP866"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    for l in bg_BG; do
 | 
					 | 
				
			||||||
      echo "$l.CP1251 CP1251"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
    echo "uk_UA.KOI8-U KOI8-U"
 | 
					 | 
				
			||||||
    echo "zh_TW.BIG5 BIG5"
 | 
					 | 
				
			||||||
    echo "zh_TW.Big5 BIG5"
 | 
					 | 
				
			||||||
    echo "zh_CN.EUC GB2312"
 | 
					 | 
				
			||||||
    echo "ja_JP.EUC EUC-JP"
 | 
					 | 
				
			||||||
    echo "ja_JP.SJIS SHIFT_JIS"
 | 
					 | 
				
			||||||
    echo "ko_KR.EUC EUC-KR"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  darwin*)
 | 
					 | 
				
			||||||
    # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
 | 
					 | 
				
			||||||
    # useless:
 | 
					 | 
				
			||||||
    # - It returns the empty string when LANG is set to a locale of the
 | 
					 | 
				
			||||||
    #   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
 | 
					 | 
				
			||||||
    #   LC_CTYPE file.
 | 
					 | 
				
			||||||
    # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
 | 
					 | 
				
			||||||
    #   the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
 | 
					 | 
				
			||||||
    # - The documentation says:
 | 
					 | 
				
			||||||
    #     "... all code that calls BSD system routines should ensure
 | 
					 | 
				
			||||||
    #      that the const *char parameters of these routines are in UTF-8
 | 
					 | 
				
			||||||
    #      encoding. All BSD system functions expect their string
 | 
					 | 
				
			||||||
    #      parameters to be in UTF-8 encoding and nothing else."
 | 
					 | 
				
			||||||
    #   It also says
 | 
					 | 
				
			||||||
    #     "An additional caveat is that string parameters for files,
 | 
					 | 
				
			||||||
    #      paths, and other file-system entities must be in canonical
 | 
					 | 
				
			||||||
    #      UTF-8. In a canonical UTF-8 Unicode string, all decomposable
 | 
					 | 
				
			||||||
    #      characters are decomposed ..."
 | 
					 | 
				
			||||||
    #   but this is not true: You can pass non-decomposed UTF-8 strings
 | 
					 | 
				
			||||||
    #   to file system functions, and it is the OS which will convert
 | 
					 | 
				
			||||||
    #   them to decomposed UTF-8 before accessing the file system.
 | 
					 | 
				
			||||||
    # - The Apple Terminal application displays UTF-8 by default.
 | 
					 | 
				
			||||||
    # - However, other applications are free to use different encodings:
 | 
					 | 
				
			||||||
    #   - xterm uses ISO-8859-1 by default.
 | 
					 | 
				
			||||||
    #   - TextEdit uses MacRoman by default.
 | 
					 | 
				
			||||||
    # We prefer UTF-8 over decomposed UTF-8-MAC because one should
 | 
					 | 
				
			||||||
    # minimize the use of decomposed Unicode. Unfortunately, through the
 | 
					 | 
				
			||||||
    # Darwin file system, decomposed UTF-8 strings are leaked into user
 | 
					 | 
				
			||||||
    # space nevertheless.
 | 
					 | 
				
			||||||
    # Then there are also the locales with encodings other than US-ASCII
 | 
					 | 
				
			||||||
    # and UTF-8. These locales can be occasionally useful to users (e.g.
 | 
					 | 
				
			||||||
    # when grepping through ISO-8859-1 encoded text files), when all their
 | 
					 | 
				
			||||||
    # file names are in US-ASCII.
 | 
					 | 
				
			||||||
    echo "ISO8859-1 ISO-8859-1"
 | 
					 | 
				
			||||||
    echo "ISO8859-2 ISO-8859-2"
 | 
					 | 
				
			||||||
    echo "ISO8859-4 ISO-8859-4"
 | 
					 | 
				
			||||||
    echo "ISO8859-5 ISO-8859-5"
 | 
					 | 
				
			||||||
    echo "ISO8859-7 ISO-8859-7"
 | 
					 | 
				
			||||||
    echo "ISO8859-9 ISO-8859-9"
 | 
					 | 
				
			||||||
    echo "ISO8859-13 ISO-8859-13"
 | 
					 | 
				
			||||||
    echo "ISO8859-15 ISO-8859-15"
 | 
					 | 
				
			||||||
    echo "KOI8-R KOI8-R"
 | 
					 | 
				
			||||||
    echo "KOI8-U KOI8-U"
 | 
					 | 
				
			||||||
    echo "CP866 CP866"
 | 
					 | 
				
			||||||
    echo "CP949 CP949"
 | 
					 | 
				
			||||||
    echo "CP1131 CP1131"
 | 
					 | 
				
			||||||
    echo "CP1251 CP1251"
 | 
					 | 
				
			||||||
    echo "eucCN GB2312"
 | 
					 | 
				
			||||||
    echo "GB2312 GB2312"
 | 
					 | 
				
			||||||
    echo "eucJP EUC-JP"
 | 
					 | 
				
			||||||
    echo "eucKR EUC-KR"
 | 
					 | 
				
			||||||
    echo "Big5 BIG5"
 | 
					 | 
				
			||||||
    echo "Big5HKSCS BIG5-HKSCS"
 | 
					 | 
				
			||||||
    echo "GBK GBK"
 | 
					 | 
				
			||||||
    echo "GB18030 GB18030"
 | 
					 | 
				
			||||||
    echo "SJIS SHIFT_JIS"
 | 
					 | 
				
			||||||
    echo "ARMSCII-8 ARMSCII-8"
 | 
					 | 
				
			||||||
    echo "PT154 PT154"
 | 
					 | 
				
			||||||
    #echo "ISCII-DEV ?"
 | 
					 | 
				
			||||||
    echo "* UTF-8"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  beos* | haiku*)
 | 
					 | 
				
			||||||
    # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
 | 
					 | 
				
			||||||
    echo "* UTF-8"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
  msdosdjgpp*)
 | 
					 | 
				
			||||||
    # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
 | 
					 | 
				
			||||||
    # localcharset.c falls back to using the full locale name
 | 
					 | 
				
			||||||
    # from the environment variables.
 | 
					 | 
				
			||||||
    echo "#"
 | 
					 | 
				
			||||||
    echo "# The encodings given here may not all be correct."
 | 
					 | 
				
			||||||
    echo "# If you find that the encoding given for your language and"
 | 
					 | 
				
			||||||
    echo "# country is not the one your DOS machine actually uses, just"
 | 
					 | 
				
			||||||
    echo "# correct it in this file, and send a mail to"
 | 
					 | 
				
			||||||
    echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
 | 
					 | 
				
			||||||
    echo "# and Bruno Haible <bruno@clisp.org>."
 | 
					 | 
				
			||||||
    echo "#"
 | 
					 | 
				
			||||||
    echo "C ASCII"
 | 
					 | 
				
			||||||
    # ISO-8859-1 languages
 | 
					 | 
				
			||||||
    echo "ca CP850"
 | 
					 | 
				
			||||||
    echo "ca_ES CP850"
 | 
					 | 
				
			||||||
    echo "da CP865"    # not CP850 ??
 | 
					 | 
				
			||||||
    echo "da_DK CP865" # not CP850 ??
 | 
					 | 
				
			||||||
    echo "de CP850"
 | 
					 | 
				
			||||||
    echo "de_AT CP850"
 | 
					 | 
				
			||||||
    echo "de_CH CP850"
 | 
					 | 
				
			||||||
    echo "de_DE CP850"
 | 
					 | 
				
			||||||
    echo "en CP850"
 | 
					 | 
				
			||||||
    echo "en_AU CP850" # not CP437 ??
 | 
					 | 
				
			||||||
    echo "en_CA CP850"
 | 
					 | 
				
			||||||
    echo "en_GB CP850"
 | 
					 | 
				
			||||||
    echo "en_NZ CP437"
 | 
					 | 
				
			||||||
    echo "en_US CP437"
 | 
					 | 
				
			||||||
    echo "en_ZA CP850" # not CP437 ??
 | 
					 | 
				
			||||||
    echo "es CP850"
 | 
					 | 
				
			||||||
    echo "es_AR CP850"
 | 
					 | 
				
			||||||
    echo "es_BO CP850"
 | 
					 | 
				
			||||||
    echo "es_CL CP850"
 | 
					 | 
				
			||||||
    echo "es_CO CP850"
 | 
					 | 
				
			||||||
    echo "es_CR CP850"
 | 
					 | 
				
			||||||
    echo "es_CU CP850"
 | 
					 | 
				
			||||||
    echo "es_DO CP850"
 | 
					 | 
				
			||||||
    echo "es_EC CP850"
 | 
					 | 
				
			||||||
    echo "es_ES CP850"
 | 
					 | 
				
			||||||
    echo "es_GT CP850"
 | 
					 | 
				
			||||||
    echo "es_HN CP850"
 | 
					 | 
				
			||||||
    echo "es_MX CP850"
 | 
					 | 
				
			||||||
    echo "es_NI CP850"
 | 
					 | 
				
			||||||
    echo "es_PA CP850"
 | 
					 | 
				
			||||||
    echo "es_PY CP850"
 | 
					 | 
				
			||||||
    echo "es_PE CP850"
 | 
					 | 
				
			||||||
    echo "es_SV CP850"
 | 
					 | 
				
			||||||
    echo "es_UY CP850"
 | 
					 | 
				
			||||||
    echo "es_VE CP850"
 | 
					 | 
				
			||||||
    echo "et CP850"
 | 
					 | 
				
			||||||
    echo "et_EE CP850"
 | 
					 | 
				
			||||||
    echo "eu CP850"
 | 
					 | 
				
			||||||
    echo "eu_ES CP850"
 | 
					 | 
				
			||||||
    echo "fi CP850"
 | 
					 | 
				
			||||||
    echo "fi_FI CP850"
 | 
					 | 
				
			||||||
    echo "fr CP850"
 | 
					 | 
				
			||||||
    echo "fr_BE CP850"
 | 
					 | 
				
			||||||
    echo "fr_CA CP850"
 | 
					 | 
				
			||||||
    echo "fr_CH CP850"
 | 
					 | 
				
			||||||
    echo "fr_FR CP850"
 | 
					 | 
				
			||||||
    echo "ga CP850"
 | 
					 | 
				
			||||||
    echo "ga_IE CP850"
 | 
					 | 
				
			||||||
    echo "gd CP850"
 | 
					 | 
				
			||||||
    echo "gd_GB CP850"
 | 
					 | 
				
			||||||
    echo "gl CP850"
 | 
					 | 
				
			||||||
    echo "gl_ES CP850"
 | 
					 | 
				
			||||||
    echo "id CP850"    # not CP437 ??
 | 
					 | 
				
			||||||
    echo "id_ID CP850" # not CP437 ??
 | 
					 | 
				
			||||||
    echo "is CP861"    # not CP850 ??
 | 
					 | 
				
			||||||
    echo "is_IS CP861" # not CP850 ??
 | 
					 | 
				
			||||||
    echo "it CP850"
 | 
					 | 
				
			||||||
    echo "it_CH CP850"
 | 
					 | 
				
			||||||
    echo "it_IT CP850"
 | 
					 | 
				
			||||||
    echo "lt CP775"
 | 
					 | 
				
			||||||
    echo "lt_LT CP775"
 | 
					 | 
				
			||||||
    echo "lv CP775"
 | 
					 | 
				
			||||||
    echo "lv_LV CP775"
 | 
					 | 
				
			||||||
    echo "nb CP865"    # not CP850 ??
 | 
					 | 
				
			||||||
    echo "nb_NO CP865" # not CP850 ??
 | 
					 | 
				
			||||||
    echo "nl CP850"
 | 
					 | 
				
			||||||
    echo "nl_BE CP850"
 | 
					 | 
				
			||||||
    echo "nl_NL CP850"
 | 
					 | 
				
			||||||
    echo "nn CP865"    # not CP850 ??
 | 
					 | 
				
			||||||
    echo "nn_NO CP865" # not CP850 ??
 | 
					 | 
				
			||||||
    echo "no CP865"    # not CP850 ??
 | 
					 | 
				
			||||||
    echo "no_NO CP865" # not CP850 ??
 | 
					 | 
				
			||||||
    echo "pt CP850"
 | 
					 | 
				
			||||||
    echo "pt_BR CP850"
 | 
					 | 
				
			||||||
    echo "pt_PT CP850"
 | 
					 | 
				
			||||||
    echo "sv CP850"
 | 
					 | 
				
			||||||
    echo "sv_SE CP850"
 | 
					 | 
				
			||||||
    # ISO-8859-2 languages
 | 
					 | 
				
			||||||
    echo "cs CP852"
 | 
					 | 
				
			||||||
    echo "cs_CZ CP852"
 | 
					 | 
				
			||||||
    echo "hr CP852"
 | 
					 | 
				
			||||||
    echo "hr_HR CP852"
 | 
					 | 
				
			||||||
    echo "hu CP852"
 | 
					 | 
				
			||||||
    echo "hu_HU CP852"
 | 
					 | 
				
			||||||
    echo "pl CP852"
 | 
					 | 
				
			||||||
    echo "pl_PL CP852"
 | 
					 | 
				
			||||||
    echo "ro CP852"
 | 
					 | 
				
			||||||
    echo "ro_RO CP852"
 | 
					 | 
				
			||||||
    echo "sk CP852"
 | 
					 | 
				
			||||||
    echo "sk_SK CP852"
 | 
					 | 
				
			||||||
    echo "sl CP852"
 | 
					 | 
				
			||||||
    echo "sl_SI CP852"
 | 
					 | 
				
			||||||
    echo "sq CP852"
 | 
					 | 
				
			||||||
    echo "sq_AL CP852"
 | 
					 | 
				
			||||||
    echo "sr CP852"    # CP852 or CP866 or CP855 ??
 | 
					 | 
				
			||||||
    echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
 | 
					 | 
				
			||||||
    echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
 | 
					 | 
				
			||||||
    # ISO-8859-3 languages
 | 
					 | 
				
			||||||
    echo "mt CP850"
 | 
					 | 
				
			||||||
    echo "mt_MT CP850"
 | 
					 | 
				
			||||||
    # ISO-8859-5 languages
 | 
					 | 
				
			||||||
    echo "be CP866"
 | 
					 | 
				
			||||||
    echo "be_BE CP866"
 | 
					 | 
				
			||||||
    echo "bg CP866"    # not CP855 ??
 | 
					 | 
				
			||||||
    echo "bg_BG CP866" # not CP855 ??
 | 
					 | 
				
			||||||
    echo "mk CP866"    # not CP855 ??
 | 
					 | 
				
			||||||
    echo "mk_MK CP866" # not CP855 ??
 | 
					 | 
				
			||||||
    echo "ru CP866"
 | 
					 | 
				
			||||||
    echo "ru_RU CP866"
 | 
					 | 
				
			||||||
    echo "uk CP1125"
 | 
					 | 
				
			||||||
    echo "uk_UA CP1125"
 | 
					 | 
				
			||||||
    # ISO-8859-6 languages
 | 
					 | 
				
			||||||
    echo "ar CP864"
 | 
					 | 
				
			||||||
    echo "ar_AE CP864"
 | 
					 | 
				
			||||||
    echo "ar_DZ CP864"
 | 
					 | 
				
			||||||
    echo "ar_EG CP864"
 | 
					 | 
				
			||||||
    echo "ar_IQ CP864"
 | 
					 | 
				
			||||||
    echo "ar_IR CP864"
 | 
					 | 
				
			||||||
    echo "ar_JO CP864"
 | 
					 | 
				
			||||||
    echo "ar_KW CP864"
 | 
					 | 
				
			||||||
    echo "ar_MA CP864"
 | 
					 | 
				
			||||||
    echo "ar_OM CP864"
 | 
					 | 
				
			||||||
    echo "ar_QA CP864"
 | 
					 | 
				
			||||||
    echo "ar_SA CP864"
 | 
					 | 
				
			||||||
    echo "ar_SY CP864"
 | 
					 | 
				
			||||||
    # ISO-8859-7 languages
 | 
					 | 
				
			||||||
    echo "el CP869"
 | 
					 | 
				
			||||||
    echo "el_GR CP869"
 | 
					 | 
				
			||||||
    # ISO-8859-8 languages
 | 
					 | 
				
			||||||
    echo "he CP862"
 | 
					 | 
				
			||||||
    echo "he_IL CP862"
 | 
					 | 
				
			||||||
    # ISO-8859-9 languages
 | 
					 | 
				
			||||||
    echo "tr CP857"
 | 
					 | 
				
			||||||
    echo "tr_TR CP857"
 | 
					 | 
				
			||||||
    # Japanese
 | 
					 | 
				
			||||||
    echo "ja CP932"
 | 
					 | 
				
			||||||
    echo "ja_JP CP932"
 | 
					 | 
				
			||||||
    # Chinese
 | 
					 | 
				
			||||||
    echo "zh_CN GBK"
 | 
					 | 
				
			||||||
    echo "zh_TW CP950" # not CP938 ??
 | 
					 | 
				
			||||||
    # Korean
 | 
					 | 
				
			||||||
    echo "kr CP949"    # not CP934 ??
 | 
					 | 
				
			||||||
    echo "kr_KR CP949" # not CP934 ??
 | 
					 | 
				
			||||||
    # Thai
 | 
					 | 
				
			||||||
    echo "th CP874"
 | 
					 | 
				
			||||||
    echo "th_TH CP874"
 | 
					 | 
				
			||||||
    # Other
 | 
					 | 
				
			||||||
    echo "eo CP850"
 | 
					 | 
				
			||||||
    echo "eo_EO CP850"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
esac
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,20 +1,20 @@
 | 
				
			||||||
/* dirname.c -- return all but the last element in a file name
 | 
					/* dirname.c -- return all but the last element in a file name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
 | 
					   Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,11 @@
 | 
				
			||||||
/* dirname.c -- return all but the last element in a file name
 | 
					/* dirname.c -- return all but the last element in a file name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
 | 
					   Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU General Public License as published by
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   the Free Software Foundation, either version 3 of the License, or
 | 
				
			||||||
   (at your option) any later version.
 | 
					   (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This program is distributed in the hope that it will be useful,
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										45
									
								
								gl/dirname.h
									
										
									
									
									
								
							
							
						
						
									
										45
									
								
								gl/dirname.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,46 +1,53 @@
 | 
				
			||||||
/* Take file names apart into directory and base names.
 | 
					/* Take file names apart into directory and base names.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation,
 | 
					   Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
 | 
				
			||||||
   Inc.
 | 
					   Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
    it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
    the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
    (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
    GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef DIRNAME_H_
 | 
					#ifndef DIRNAME_H_
 | 
				
			||||||
# define DIRNAME_H_ 1
 | 
					# define DIRNAME_H_ 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# include <stdbool.h>
 | 
					# include <stdlib.h>
 | 
				
			||||||
# include <stddef.h>
 | 
					# include "filename.h"
 | 
				
			||||||
# include "dosname.h"
 | 
					# include "basename-lgpl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ifndef DIRECTORY_SEPARATOR
 | 
					# ifndef DIRECTORY_SEPARATOR
 | 
				
			||||||
#  define DIRECTORY_SEPARATOR '/'
 | 
					#  define DIRECTORY_SEPARATOR '/'
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
 | 
					#ifdef __cplusplus
 | 
				
			||||||
#  define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if GNULIB_DIRNAME
 | 
					# if GNULIB_DIRNAME
 | 
				
			||||||
char *base_name (char const *file);
 | 
					char *base_name (char const *file)
 | 
				
			||||||
char *dir_name (char const *file);
 | 
					  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
 | 
				
			||||||
 | 
					  _GL_ATTRIBUTE_RETURNS_NONNULL;
 | 
				
			||||||
 | 
					char *dir_name (char const *file)
 | 
				
			||||||
 | 
					  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
 | 
				
			||||||
 | 
					  _GL_ATTRIBUTE_RETURNS_NONNULL;
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *mdir_name (char const *file);
 | 
					char *mdir_name (char const *file)
 | 
				
			||||||
size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
 | 
					  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
 | 
				
			||||||
size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
 | 
					size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
 | 
				
			||||||
char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool strip_trailing_slashes (char *file);
 | 
					bool strip_trailing_slashes (char *file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					} /* extern "C" */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* not DIRNAME_H_ */
 | 
					#endif /* not DIRNAME_H_ */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										53
									
								
								gl/dosname.h
									
										
									
									
									
								
							
							
						
						
									
										53
									
								
								gl/dosname.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,53 +0,0 @@
 | 
				
			||||||
/* File names on MS-DOS/Windows systems.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					 | 
				
			||||||
   (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
   GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   From Paul Eggert and Jim Meyering.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef _DOSNAME_H
 | 
					 | 
				
			||||||
#define _DOSNAME_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if (defined _WIN32 || defined __WIN32__ ||     \
 | 
					 | 
				
			||||||
     defined __MSDOS__ || defined __CYGWIN__ || \
 | 
					 | 
				
			||||||
     defined __EMX__ || defined __DJGPP__)
 | 
					 | 
				
			||||||
   /* This internal macro assumes ASCII, but all hosts that support drive
 | 
					 | 
				
			||||||
      letters use ASCII.  */
 | 
					 | 
				
			||||||
# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a'  \
 | 
					 | 
				
			||||||
                              <= 'z' - 'a')
 | 
					 | 
				
			||||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
 | 
					 | 
				
			||||||
          (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
 | 
					 | 
				
			||||||
# ifndef __CYGWIN__
 | 
					 | 
				
			||||||
#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
 | 
					 | 
				
			||||||
# define ISSLASH(C) ((C) == '/')
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
 | 
					 | 
				
			||||||
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
 | 
					 | 
				
			||||||
#  define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
 | 
					 | 
				
			||||||
# else
 | 
					 | 
				
			||||||
#  define IS_ABSOLUTE_FILE_NAME(F)                              \
 | 
					 | 
				
			||||||
     (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* DOSNAME_H_ */
 | 
					 | 
				
			||||||
							
								
								
									
										189
									
								
								gl/dup2.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										189
									
								
								gl/dup2.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,189 @@
 | 
				
			||||||
 | 
					/* Duplicate an open file descriptor to a specified file descriptor.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 1999, 2004-2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* written by Paul Eggert */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#undef dup2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get declarations of the native Windows API functions.  */
 | 
				
			||||||
 | 
					# define WIN32_LEAN_AND_MEAN
 | 
				
			||||||
 | 
					# include <windows.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 | 
				
			||||||
 | 
					#  include "msvc-inval.h"
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get _get_osfhandle.  */
 | 
				
			||||||
 | 
					# if GNULIB_MSVC_NOTHROW
 | 
				
			||||||
 | 
					#  include "msvc-nothrow.h"
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  include <io.h>
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					dup2_nothrow (int fd, int desired_fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TRY_MSVC_INVAL
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      result = _dup2 (fd, desired_fd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  CATCH_MSVC_INVAL
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = EBADF;
 | 
				
			||||||
 | 
					      result = -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  DONE_MSVC_INVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define dup2_nothrow _dup2
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					ms_windows_dup2 (int fd, int desired_fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* If fd is closed, mingw hangs on dup2 (fd, fd).  If fd is open,
 | 
				
			||||||
 | 
					     dup2 (fd, fd) returns 0, but all further attempts to use fd in
 | 
				
			||||||
 | 
					     future dup2 calls will hang.  */
 | 
				
			||||||
 | 
					  if (fd == desired_fd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          errno = EBADF;
 | 
				
			||||||
 | 
					          return -1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      return fd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
 | 
				
			||||||
 | 
					     https://bugs.winehq.org/show_bug.cgi?id=21289 */
 | 
				
			||||||
 | 
					  if (desired_fd < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = EBADF;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  result = dup2_nothrow (fd, desired_fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (result == 0)
 | 
				
			||||||
 | 
					    result = desired_fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# define dup2 ms_windows_dup2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#elif defined __KLIBC__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# include <InnoTekLIBC/backend.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					klibc_dup2dirfd (int fd, int desired_fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int tempfd;
 | 
				
			||||||
 | 
					  int dupfd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  tempfd = open ("NUL", O_RDONLY);
 | 
				
			||||||
 | 
					  if (tempfd == -1)
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (tempfd == desired_fd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      close (tempfd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      char path[_MAX_PATH];
 | 
				
			||||||
 | 
					      if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      return open(path, O_RDONLY);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  dupfd = klibc_dup2dirfd (fd, desired_fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  close (tempfd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return dupfd;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					klibc_dup2 (int fd, int desired_fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int dupfd;
 | 
				
			||||||
 | 
					  struct stat sbuf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  dupfd = dup2 (fd, desired_fd);
 | 
				
			||||||
 | 
					  if (dupfd == -1 && errno == ENOTSUP \
 | 
				
			||||||
 | 
					      && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      close (desired_fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      return klibc_dup2dirfd (fd, desired_fd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return dupfd;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# define dup2 klibc_dup2
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					rpl_dup2 (int fd, int desired_fd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef F_GETFL
 | 
				
			||||||
 | 
					  /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
 | 
				
			||||||
 | 
					     On Cygwin 1.5.x, dup2 (1, 1) returns 0.
 | 
				
			||||||
 | 
					     On Cygwin 1.7.17, dup2 (1, -1) dumps core.
 | 
				
			||||||
 | 
					     On Cygwin 1.7.25, dup2 (1, 256) can dump core.
 | 
				
			||||||
 | 
					     On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC.  */
 | 
				
			||||||
 | 
					# if HAVE_SETDTABLESIZE
 | 
				
			||||||
 | 
					  setdtablesize (desired_fd + 1);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					  if (desired_fd < 0)
 | 
				
			||||||
 | 
					    fd = desired_fd;
 | 
				
			||||||
 | 
					  if (fd == desired_fd)
 | 
				
			||||||
 | 
					    return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  result = dup2 (fd, desired_fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x.  */
 | 
				
			||||||
 | 
					  if (result == -1 && errno == EMFILE)
 | 
				
			||||||
 | 
					    errno = EBADF;
 | 
				
			||||||
 | 
					#if REPLACE_FCHDIR
 | 
				
			||||||
 | 
					  if (fd != desired_fd && result != -1)
 | 
				
			||||||
 | 
					    result = _gl_register_dup (fd, result);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										284
									
								
								gl/dynarray.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										284
									
								
								gl/dynarray.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,284 @@
 | 
				
			||||||
 | 
					/* Type-safe arrays which grow dynamically.
 | 
				
			||||||
 | 
					   Copyright 2021-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Paul Eggert and Bruno Haible, 2021.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GL_DYNARRAY_H
 | 
				
			||||||
 | 
					#define _GL_DYNARRAY_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Before including this file, you need to define:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   DYNARRAY_STRUCT
 | 
				
			||||||
 | 
					      The struct tag of dynamic array to be defined.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   DYNARRAY_ELEMENT
 | 
				
			||||||
 | 
					      The type name of the element type.  Elements are copied
 | 
				
			||||||
 | 
					      as if by memcpy, and can change address as the dynamic
 | 
				
			||||||
 | 
					      array grows.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   DYNARRAY_PREFIX
 | 
				
			||||||
 | 
					      The prefix of the functions which are defined.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The following parameters are optional:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   DYNARRAY_ELEMENT_FREE
 | 
				
			||||||
 | 
					      DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
 | 
				
			||||||
 | 
					      contents of elements. E is of type  DYNARRAY_ELEMENT *.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   DYNARRAY_ELEMENT_INIT
 | 
				
			||||||
 | 
					      DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
 | 
				
			||||||
 | 
					      element.  E is of type  DYNARRAY_ELEMENT *.
 | 
				
			||||||
 | 
					      If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
 | 
				
			||||||
 | 
					      defined, new elements are automatically zero-initialized.
 | 
				
			||||||
 | 
					      Otherwise, new elements have undefined contents.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   DYNARRAY_INITIAL_SIZE
 | 
				
			||||||
 | 
					      The size of the statically allocated array (default:
 | 
				
			||||||
 | 
					      at least 2, more elements if they fit into 128 bytes).
 | 
				
			||||||
 | 
					      Must be a preprocessor constant.  If DYNARRAY_INITIAL_SIZE is 0,
 | 
				
			||||||
 | 
					      there is no statically allocated array at, and all non-empty
 | 
				
			||||||
 | 
					      arrays are heap-allocated.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   DYNARRAY_FINAL_TYPE
 | 
				
			||||||
 | 
					      The name of the type which holds the final array.  If not
 | 
				
			||||||
 | 
					      defined, is PREFIX##finalize not provided.  DYNARRAY_FINAL_TYPE
 | 
				
			||||||
 | 
					      must be a struct type, with members of type DYNARRAY_ELEMENT and
 | 
				
			||||||
 | 
					      size_t at the start (in this order).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   These macros are undefined after this header file has been
 | 
				
			||||||
 | 
					   included.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The following types are provided (their members are private to the
 | 
				
			||||||
 | 
					   dynarray implementation):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     struct DYNARRAY_STRUCT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The following functions are provided:
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Initialize a dynamic array object.  This must be called before any
 | 
				
			||||||
 | 
					   use of the object.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Deallocate the dynamic array and its elements.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return true if the dynamic array is in an error state.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static bool
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Mark the dynamic array as failed.  All elements are deallocated as
 | 
				
			||||||
 | 
					   a side effect.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return the number of elements which have been added to the dynamic
 | 
				
			||||||
 | 
					   array.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static size_t
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return a pointer to the first array element, if any.  For a
 | 
				
			||||||
 | 
					   zero-length array, the pointer can be NULL even though the dynamic
 | 
				
			||||||
 | 
					   array has not entered the failure state.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static DYNARRAY_ELEMENT *
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return a pointer one element past the last array element.  For a
 | 
				
			||||||
 | 
					   zero-length array, the pointer can be NULL even though the dynamic
 | 
				
			||||||
 | 
					   array has not entered the failure state.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static DYNARRAY_ELEMENT *
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return a pointer to the array element at INDEX.  Terminate the
 | 
				
			||||||
 | 
					   process if INDEX is out of bounds.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static DYNARRAY_ELEMENT *
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *list, size_t index);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Add ITEM at the end of the array, enlarging it by one element.
 | 
				
			||||||
 | 
					   Mark *LIST as failed if the dynamic array allocation size cannot be
 | 
				
			||||||
 | 
					   increased.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *list,
 | 
				
			||||||
 | 
					                             DYNARRAY_ELEMENT item);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Allocate a place for a new element in *LIST and return a pointer to
 | 
				
			||||||
 | 
					   it.  The pointer can be NULL if the dynamic array cannot be
 | 
				
			||||||
 | 
					   enlarged due to a memory allocation failure.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static DYNARRAY_ELEMENT *
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Change the size of *LIST to SIZE.  If SIZE is larger than the
 | 
				
			||||||
 | 
					   existing size, new elements are added (which can be initialized).
 | 
				
			||||||
 | 
					   Otherwise, the list is truncated, and elements are freed.  Return
 | 
				
			||||||
 | 
					   false on memory allocation failure (and mark *LIST as failed).  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static bool
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *list, size_t size);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Remove the last element of LIST if it is present.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Remove all elements from the list.  The elements are freed, but the
 | 
				
			||||||
 | 
					   list itself is not.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *list);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined DYNARRAY_FINAL_TYPE
 | 
				
			||||||
 | 
					/* Transfer the dynamic array to a permanent location at *RESULT.
 | 
				
			||||||
 | 
					   Returns true on success on false on allocation failure.  In either
 | 
				
			||||||
 | 
					   case, *LIST is re-initialized and can be reused.  A NULL pointer is
 | 
				
			||||||
 | 
					   stored in *RESULT if LIST refers to an empty list.  On success, the
 | 
				
			||||||
 | 
					   pointer in *RESULT is heap-allocated and must be deallocated using
 | 
				
			||||||
 | 
					   free.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static bool
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
 | 
				
			||||||
 | 
					                                  DYNARRAY_FINAL_TYPE *result);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#else /* !defined DYNARRAY_FINAL_TYPE */
 | 
				
			||||||
 | 
					/* Transfer the dynamic array to a heap-allocated array and return a
 | 
				
			||||||
 | 
					   pointer to it.  The pointer is NULL if memory allocation fails, or
 | 
				
			||||||
 | 
					   if the array is empty, so this function should be used only for
 | 
				
			||||||
 | 
					   arrays which are known not be empty (usually because they always
 | 
				
			||||||
 | 
					   have a sentinel at the end).  If LENGTHP is not NULL, the array
 | 
				
			||||||
 | 
					   length is written to *LENGTHP.  *LIST is re-initialized and can be
 | 
				
			||||||
 | 
					   reused.  */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static DYNARRAY_ELEMENT *
 | 
				
			||||||
 | 
					       DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
 | 
				
			||||||
 | 
					                                  size_t *lengthp);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* A minimal example which provides a growing list of integers can be
 | 
				
			||||||
 | 
					   defined like this:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     struct int_array
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       // Pointer to result array followed by its length,
 | 
				
			||||||
 | 
					       // as required by DYNARRAY_FINAL_TYPE.
 | 
				
			||||||
 | 
					       int *array;
 | 
				
			||||||
 | 
					       size_t length;
 | 
				
			||||||
 | 
					     };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     #define DYNARRAY_STRUCT dynarray_int
 | 
				
			||||||
 | 
					     #define DYNARRAY_ELEMENT int
 | 
				
			||||||
 | 
					     #define DYNARRAY_PREFIX dynarray_int_
 | 
				
			||||||
 | 
					     #define DYNARRAY_FINAL_TYPE struct int_array
 | 
				
			||||||
 | 
					     #include <malloc/dynarray-skeleton.c>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   To create a three-element array with elements 1, 2, 3, use this
 | 
				
			||||||
 | 
					   code:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     struct dynarray_int dyn;
 | 
				
			||||||
 | 
					     dynarray_int_init (&dyn);
 | 
				
			||||||
 | 
					     for (int i = 1; i <= 3; ++i)
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					         int *place = dynarray_int_emplace (&dyn);
 | 
				
			||||||
 | 
					         assert (place != NULL);
 | 
				
			||||||
 | 
					         *place = i;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					     struct int_array result;
 | 
				
			||||||
 | 
					     bool ok = dynarray_int_finalize (&dyn, &result);
 | 
				
			||||||
 | 
					     assert (ok);
 | 
				
			||||||
 | 
					     assert (result.length == 3);
 | 
				
			||||||
 | 
					     assert (result.array[0] == 1);
 | 
				
			||||||
 | 
					     assert (result.array[1] == 2);
 | 
				
			||||||
 | 
					     assert (result.array[2] == 3);
 | 
				
			||||||
 | 
					     free (result.array);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   If the elements contain resources which must be freed, define
 | 
				
			||||||
 | 
					   DYNARRAY_ELEMENT_FREE appropriately, like this:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     struct str_array
 | 
				
			||||||
 | 
					     {
 | 
				
			||||||
 | 
					       char **array;
 | 
				
			||||||
 | 
					       size_t length;
 | 
				
			||||||
 | 
					     };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     #define DYNARRAY_STRUCT dynarray_str
 | 
				
			||||||
 | 
					     #define DYNARRAY_ELEMENT char *
 | 
				
			||||||
 | 
					     #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
 | 
				
			||||||
 | 
					     #define DYNARRAY_PREFIX dynarray_str_
 | 
				
			||||||
 | 
					     #define DYNARRAY_FINAL_TYPE struct str_array
 | 
				
			||||||
 | 
					     #include <malloc/dynarray-skeleton.c>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The implementation is imported from glibc.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Avoid possible conflicts with symbols exported by the GNU libc.  */
 | 
				
			||||||
 | 
					#define __libc_dynarray_at_failure gl_dynarray_at_failure
 | 
				
			||||||
 | 
					#define __libc_dynarray_emplace_enlarge gl_dynarray_emplace_enlarge
 | 
				
			||||||
 | 
					#define __libc_dynarray_finalize gl_dynarray_finalize
 | 
				
			||||||
 | 
					#define __libc_dynarray_resize_clear gl_dynarray_resize_clear
 | 
				
			||||||
 | 
					#define __libc_dynarray_resize gl_dynarray_resize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifndef _GL_LIKELY
 | 
				
			||||||
 | 
					/* Rely on __builtin_expect, as provided by the module 'builtin-expect'.  */
 | 
				
			||||||
 | 
					#  define _GL_LIKELY(cond) __builtin_expect ((cond), 1)
 | 
				
			||||||
 | 
					#  define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0)
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define auxiliary structs and declare auxiliary functions, common to all
 | 
				
			||||||
 | 
					   instantiations of dynarray.  */
 | 
				
			||||||
 | 
					# include <malloc/dynarray.gl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define the instantiation, specified through
 | 
				
			||||||
 | 
					     DYNARRAY_STRUCT
 | 
				
			||||||
 | 
					     DYNARRAY_ELEMENT
 | 
				
			||||||
 | 
					     DYNARRAY_PREFIX
 | 
				
			||||||
 | 
					   etc.  */
 | 
				
			||||||
 | 
					# include <malloc/dynarray-skeleton.gl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This file is being included from one of the malloc/dynarray_*.c files.  */
 | 
				
			||||||
 | 
					# include <malloc/dynarray.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GL_DYNARRAY_H */
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* A POSIX-like <errno.h>.
 | 
					/* A POSIX-like <errno.h>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2008-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _@GUARD_PREFIX@_ERRNO_H
 | 
					#ifndef _@GUARD_PREFIX@_ERRNO_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* On native Windows platforms, many macros are not defined.  */
 | 
					/* On native Windows platforms, many macros are not defined.  */
 | 
				
			||||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 | 
					# if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* These are the same values as defined by MSVC 10, for interoperability.  */
 | 
					/* These are the same values as defined by MSVC 10, for interoperability.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -248,7 +248,7 @@
 | 
				
			||||||
       interoperability.  */
 | 
					       interoperability.  */
 | 
				
			||||||
#   define EOWNERDEAD      58
 | 
					#   define EOWNERDEAD      58
 | 
				
			||||||
#   define ENOTRECOVERABLE 59
 | 
					#   define ENOTRECOVERABLE 59
 | 
				
			||||||
#  elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 | 
					#  elif defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
    /* We have a conflict here: pthreads-win32 defines these values
 | 
					    /* We have a conflict here: pthreads-win32 defines these values
 | 
				
			||||||
       differently than MSVC 10.  It's hairy to decide which one to use.  */
 | 
					       differently than MSVC 10.  It's hairy to decide which one to use.  */
 | 
				
			||||||
#   if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
 | 
					#   if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										72
									
								
								gl/error.c
									
										
									
									
									
								
							
							
						
						
									
										72
									
								
								gl/error.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Error handler for noninteractive utilities
 | 
					/* Error handler for noninteractive utilities
 | 
				
			||||||
   Copyright (C) 1990-1998, 2000-2007, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 1990-1998, 2000-2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   This file is part of the GNU C Library.
 | 
					   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */
 | 
					/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,11 @@
 | 
				
			||||||
# include <stdint.h>
 | 
					# include <stdint.h>
 | 
				
			||||||
# include <wchar.h>
 | 
					# include <wchar.h>
 | 
				
			||||||
# define mbsrtowcs __mbsrtowcs
 | 
					# define mbsrtowcs __mbsrtowcs
 | 
				
			||||||
 | 
					# define USE_UNLOCKED_IO 0
 | 
				
			||||||
 | 
					# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b)
 | 
				
			||||||
 | 
					# define _GL_ARG_NONNULL(a)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# include "getprogname.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_UNLOCKED_IO
 | 
					#if USE_UNLOCKED_IO
 | 
				
			||||||
| 
						 | 
					@ -72,14 +77,14 @@ extern void __error (int status, int errnum, const char *message, ...)
 | 
				
			||||||
extern void __error_at_line (int status, int errnum, const char *file_name,
 | 
					extern void __error_at_line (int status, int errnum, const char *file_name,
 | 
				
			||||||
                             unsigned int line_number, const char *message,
 | 
					                             unsigned int line_number, const char *message,
 | 
				
			||||||
                             ...)
 | 
					                             ...)
 | 
				
			||||||
     __attribute__ ((__format__ (__printf__, 5, 6)));;
 | 
					     __attribute__ ((__format__ (__printf__, 5, 6)));
 | 
				
			||||||
# define error __error
 | 
					# define error __error
 | 
				
			||||||
# define error_at_line __error_at_line
 | 
					# define error_at_line __error_at_line
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# include <libio/iolibio.h>
 | 
					# include <libio/iolibio.h>
 | 
				
			||||||
# define fflush(s) INTUSE(_IO_fflush) (s)
 | 
					# define fflush(s) _IO_fflush (s)
 | 
				
			||||||
# undef putc
 | 
					# undef putc
 | 
				
			||||||
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
 | 
					# define putc(c, fp) _IO_putc (c, fp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# include <bits/libc-lock.h>
 | 
					# include <bits/libc-lock.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -88,35 +93,37 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
 | 
				
			||||||
# include <fcntl.h>
 | 
					# include <fcntl.h>
 | 
				
			||||||
# include <unistd.h>
 | 
					# include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 | 
					# if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
/* Get declarations of the native Windows API functions.  */
 | 
					/* Get declarations of the native Windows API functions.  */
 | 
				
			||||||
#  define WIN32_LEAN_AND_MEAN
 | 
					#  define WIN32_LEAN_AND_MEAN
 | 
				
			||||||
#  include <windows.h>
 | 
					#  include <windows.h>
 | 
				
			||||||
/* Get _get_osfhandle.  */
 | 
					/* Get _get_osfhandle.  */
 | 
				
			||||||
 | 
					#  if GNULIB_MSVC_NOTHROW
 | 
				
			||||||
#   include "msvc-nothrow.h"
 | 
					#   include "msvc-nothrow.h"
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					#   include <io.h>
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The gnulib override of fcntl is not needed in this file.  */
 | 
					/* The gnulib override of fcntl is not needed in this file.  */
 | 
				
			||||||
# undef fcntl
 | 
					# undef fcntl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if !HAVE_DECL_STRERROR_R
 | 
					# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
 | 
				
			||||||
#  ifndef HAVE_DECL_STRERROR_R
 | 
					#  ifndef HAVE_DECL_STRERROR_R
 | 
				
			||||||
"this configure-time declaration test was not run"
 | 
					"this configure-time declaration test was not run"
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
#  if STRERROR_R_CHAR_P
 | 
					#  if STRERROR_R_CHAR_P
 | 
				
			||||||
char *strerror_r ();
 | 
					char *strerror_r (int errnum, char *buf, size_t buflen);
 | 
				
			||||||
#  else
 | 
					#  else
 | 
				
			||||||
int strerror_r ();
 | 
					int strerror_r (int errnum, char *buf, size_t buflen);
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The calling program should define program_name and set it to the
 | 
					# define program_name getprogname ()
 | 
				
			||||||
   name of the executing program.  */
 | 
					 | 
				
			||||||
extern char *program_name;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if HAVE_STRERROR_R || defined strerror_r
 | 
					# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
 | 
				
			||||||
#  define __strerror_r strerror_r
 | 
					#  define __strerror_r strerror_r
 | 
				
			||||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
 | 
					# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
 | 
				
			||||||
#endif  /* not _LIBC */
 | 
					#endif  /* not _LIBC */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !_LIBC
 | 
					#if !_LIBC
 | 
				
			||||||
| 
						 | 
					@ -124,7 +131,7 @@ extern char *program_name;
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
is_open (int fd)
 | 
					is_open (int fd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 | 
					# if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
  /* On native Windows: The initial state of unassigned standard file
 | 
					  /* On native Windows: The initial state of unassigned standard file
 | 
				
			||||||
     descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
 | 
					     descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
 | 
				
			||||||
     There is no fcntl, and the gnulib replacement fcntl does not support
 | 
					     There is no fcntl, and the gnulib replacement fcntl does not support
 | 
				
			||||||
| 
						 | 
					@ -169,9 +176,9 @@ print_errno_message (int errnum)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  char const *s;
 | 
					  char const *s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined HAVE_STRERROR_R || _LIBC
 | 
					#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
 | 
				
			||||||
  char errbuf[1024];
 | 
					  char errbuf[1024];
 | 
				
			||||||
# if STRERROR_R_CHAR_P || _LIBC
 | 
					# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
 | 
				
			||||||
  s = __strerror_r (errnum, errbuf, sizeof errbuf);
 | 
					  s = __strerror_r (errnum, errbuf, sizeof errbuf);
 | 
				
			||||||
# else
 | 
					# else
 | 
				
			||||||
  if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
 | 
					  if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
 | 
				
			||||||
| 
						 | 
					@ -195,13 +202,12 @@ print_errno_message (int errnum)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))
 | 
				
			||||||
error_tail (int status, int errnum, const char *message, va_list args)
 | 
					error_tail (int status, int errnum, const char *message, va_list args)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#if _LIBC
 | 
					#if _LIBC
 | 
				
			||||||
  if (_IO_fwide (stderr, 0) > 0)
 | 
					  if (_IO_fwide (stderr, 0) > 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
# define ALLOCA_LIMIT 2000
 | 
					 | 
				
			||||||
      size_t len = strlen (message) + 1;
 | 
					      size_t len = strlen (message) + 1;
 | 
				
			||||||
      wchar_t *wmessage = NULL;
 | 
					      wchar_t *wmessage = NULL;
 | 
				
			||||||
      mbstate_t st;
 | 
					      mbstate_t st;
 | 
				
			||||||
| 
						 | 
					@ -237,7 +243,7 @@ error_tail (int status, int errnum, const char *message, va_list args)
 | 
				
			||||||
          if (res != len)
 | 
					          if (res != len)
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (__builtin_expect (len >= SIZE_MAX / 2, 0))
 | 
					          if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              /* This really should not happen if everything is fine.  */
 | 
					              /* This really should not happen if everything is fine.  */
 | 
				
			||||||
              res = (size_t) -1;
 | 
					              res = (size_t) -1;
 | 
				
			||||||
| 
						 | 
					@ -266,7 +272,6 @@ error_tail (int status, int errnum, const char *message, va_list args)
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    vfprintf (stderr, message, args);
 | 
					    vfprintf (stderr, message, args);
 | 
				
			||||||
  va_end (args);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ++error_message_count;
 | 
					  ++error_message_count;
 | 
				
			||||||
  if (errnum)
 | 
					  if (errnum)
 | 
				
			||||||
| 
						 | 
					@ -316,6 +321,7 @@ error (int status, int errnum, const char *message, ...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  va_start (args, message);
 | 
					  va_start (args, message);
 | 
				
			||||||
  error_tail (status, errnum, message, args);
 | 
					  error_tail (status, errnum, message, args);
 | 
				
			||||||
 | 
					  va_end (args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _LIBC
 | 
					#ifdef _LIBC
 | 
				
			||||||
  _IO_funlockfile (stderr);
 | 
					  _IO_funlockfile (stderr);
 | 
				
			||||||
| 
						 | 
					@ -342,7 +348,10 @@ error_at_line (int status, int errnum, const char *file_name,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (old_line_number == line_number
 | 
					      if (old_line_number == line_number
 | 
				
			||||||
          && (file_name == old_file_name
 | 
					          && (file_name == old_file_name
 | 
				
			||||||
              || strcmp (old_file_name, file_name) == 0))
 | 
					              || (old_file_name != NULL
 | 
				
			||||||
 | 
					                  && file_name != NULL
 | 
				
			||||||
 | 
					                  && strcmp (old_file_name, file_name) == 0)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Simply return and print nothing.  */
 | 
					        /* Simply return and print nothing.  */
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -374,15 +383,16 @@ error_at_line (int status, int errnum, const char *file_name,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if _LIBC
 | 
					#if _LIBC
 | 
				
			||||||
  __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
 | 
					  __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
 | 
				
			||||||
              file_name, line_number);
 | 
					              file_name, line_number);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
  fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
 | 
					  fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
 | 
				
			||||||
           file_name, line_number);
 | 
					           file_name, line_number);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  va_start (args, message);
 | 
					  va_start (args, message);
 | 
				
			||||||
  error_tail (status, errnum, message, args);
 | 
					  error_tail (status, errnum, message, args);
 | 
				
			||||||
 | 
					  va_end (args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _LIBC
 | 
					#ifdef _LIBC
 | 
				
			||||||
  _IO_funlockfile (stderr);
 | 
					  _IO_funlockfile (stderr);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										45
									
								
								gl/error.h
									
										
									
									
									
								
							
							
						
						
									
										45
									
								
								gl/error.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,35 +1,26 @@
 | 
				
			||||||
/* Declaration for error-reporting function
 | 
					/* Declaration for error-reporting function
 | 
				
			||||||
   Copyright (C) 1995-1997, 2003, 2006, 2008-2013 Free Software Foundation,
 | 
					   Copyright (C) 1995-1997, 2003, 2006, 2008-2023 Free Software Foundation,
 | 
				
			||||||
   Inc.
 | 
					   Inc.
 | 
				
			||||||
   This file is part of the GNU C Library.
 | 
					   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _ERROR_H
 | 
					#ifndef _ERROR_H
 | 
				
			||||||
#define _ERROR_H 1
 | 
					#define _ERROR_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The __attribute__ feature is available in gcc versions 2.5 and later.
 | 
					/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM.  */
 | 
				
			||||||
   The __-protected variants of the attributes 'format' and 'printf' are
 | 
					#include <stdio.h>
 | 
				
			||||||
   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
 | 
					 | 
				
			||||||
   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
 | 
					 | 
				
			||||||
   gnulib and libintl do '#define printf __printf__' when they override
 | 
					 | 
				
			||||||
   the 'printf' function.  */
 | 
					 | 
				
			||||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
 | 
					 | 
				
			||||||
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
| 
						 | 
					@ -40,11 +31,21 @@ extern "C" {
 | 
				
			||||||
   If STATUS is nonzero, terminate the program with 'exit (STATUS)'.  */
 | 
					   If STATUS is nonzero, terminate the program with 'exit (STATUS)'.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void error (int __status, int __errnum, const char *__format, ...)
 | 
					extern void error (int __status, int __errnum, const char *__format, ...)
 | 
				
			||||||
     _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
 | 
					#if GNULIB_VFPRINTF_POSIX
 | 
				
			||||||
 | 
					     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 3, 4))
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					     ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void error_at_line (int __status, int __errnum, const char *__fname,
 | 
					extern void error_at_line (int __status, int __errnum, const char *__fname,
 | 
				
			||||||
                           unsigned int __lineno, const char *__format, ...)
 | 
					                           unsigned int __lineno, const char *__format, ...)
 | 
				
			||||||
     _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6));
 | 
					#if GNULIB_VFPRINTF_POSIX
 | 
				
			||||||
 | 
					     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 6))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 5, 6))
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					     ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* If NULL, error will flush stdout, then print on stderr the program
 | 
					/* If NULL, error will flush stdout, then print on stderr the program
 | 
				
			||||||
   name, a colon and a space.  Otherwise, error will call this
 | 
					   name, a colon and a space.  Otherwise, error will call this
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Failure exit status
 | 
					/* Failure exit status
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,18 +1,18 @@
 | 
				
			||||||
/* Failure exit status
 | 
					/* Failure exit status
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2002, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int volatile exit_failure;
 | 
					extern int volatile exit_failure;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										629
									
								
								gl/fcntl.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										629
									
								
								gl/fcntl.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,629 @@
 | 
				
			||||||
 | 
					/* Provide file descriptor control.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Eric Blake <ebb9@byu.net>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <limits.h>
 | 
				
			||||||
 | 
					#include <stdarg.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __KLIBC__
 | 
				
			||||||
 | 
					# define INCL_DOS
 | 
				
			||||||
 | 
					# include <os2.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					/* Get declarations of the native Windows API functions.  */
 | 
				
			||||||
 | 
					# define WIN32_LEAN_AND_MEAN
 | 
				
			||||||
 | 
					# include <windows.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get _get_osfhandle.  */
 | 
				
			||||||
 | 
					# if GNULIB_MSVC_NOTHROW
 | 
				
			||||||
 | 
					#  include "msvc-nothrow.h"
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  include <io.h>
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Upper bound on getdtablesize().  See lib/getdtablesize.c.  */
 | 
				
			||||||
 | 
					# define OPEN_MAX_MAX 0x10000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Duplicate OLDFD into the first available slot of at least NEWFD,
 | 
				
			||||||
 | 
					   which must be positive, with FLAGS determining whether the duplicate
 | 
				
			||||||
 | 
					   will be inheritable.  */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					dupfd (int oldfd, int newfd, int flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /* Mingw has no way to create an arbitrary fd.  Iterate until all
 | 
				
			||||||
 | 
					     file descriptors less than newfd are filled up.  */
 | 
				
			||||||
 | 
					  HANDLE curr_process = GetCurrentProcess ();
 | 
				
			||||||
 | 
					  HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
 | 
				
			||||||
 | 
					  unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
 | 
				
			||||||
 | 
					  unsigned int fds_to_close_bound = 0;
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					  BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
 | 
				
			||||||
 | 
					  int mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (newfd < 0 || getdtablesize () <= newfd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = EINVAL;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  if (old_handle == INVALID_HANDLE_VALUE
 | 
				
			||||||
 | 
					      || (mode = _setmode (oldfd, O_BINARY)) == -1)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* oldfd is not open, or is an unassigned standard file
 | 
				
			||||||
 | 
					         descriptor.  */
 | 
				
			||||||
 | 
					      errno = EBADF;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  _setmode (oldfd, mode);
 | 
				
			||||||
 | 
					  flags |= mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (;;)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      HANDLE new_handle;
 | 
				
			||||||
 | 
					      int duplicated_fd;
 | 
				
			||||||
 | 
					      unsigned int index;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (!DuplicateHandle (curr_process,           /* SourceProcessHandle */
 | 
				
			||||||
 | 
					                            old_handle,             /* SourceHandle */
 | 
				
			||||||
 | 
					                            curr_process,           /* TargetProcessHandle */
 | 
				
			||||||
 | 
					                            (PHANDLE) &new_handle,  /* TargetHandle */
 | 
				
			||||||
 | 
					                            (DWORD) 0,              /* DesiredAccess */
 | 
				
			||||||
 | 
					                            inherit,                /* InheritHandle */
 | 
				
			||||||
 | 
					                            DUPLICATE_SAME_ACCESS)) /* Options */
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          switch (GetLastError ())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              case ERROR_TOO_MANY_OPEN_FILES:
 | 
				
			||||||
 | 
					                errno = EMFILE;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					              case ERROR_INVALID_HANDLE:
 | 
				
			||||||
 | 
					              case ERROR_INVALID_TARGET_HANDLE:
 | 
				
			||||||
 | 
					              case ERROR_DIRECT_ACCESS_HANDLE:
 | 
				
			||||||
 | 
					                errno = EBADF;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					              case ERROR_INVALID_PARAMETER:
 | 
				
			||||||
 | 
					              case ERROR_INVALID_FUNCTION:
 | 
				
			||||||
 | 
					              case ERROR_INVALID_ACCESS:
 | 
				
			||||||
 | 
					                errno = EINVAL;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					              default:
 | 
				
			||||||
 | 
					                errno = EACCES;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          result = -1;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
 | 
				
			||||||
 | 
					      if (duplicated_fd < 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          CloseHandle (new_handle);
 | 
				
			||||||
 | 
					          result = -1;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      if (newfd <= duplicated_fd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          result = duplicated_fd;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* Set the bit duplicated_fd in fds_to_close[].  */
 | 
				
			||||||
 | 
					      index = (unsigned int) duplicated_fd / CHAR_BIT;
 | 
				
			||||||
 | 
					      if (fds_to_close_bound <= index)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          if (sizeof fds_to_close <= index)
 | 
				
			||||||
 | 
					            /* Need to increase OPEN_MAX_MAX.  */
 | 
				
			||||||
 | 
					            abort ();
 | 
				
			||||||
 | 
					          memset (fds_to_close + fds_to_close_bound, '\0',
 | 
				
			||||||
 | 
					                  index + 1 - fds_to_close_bound);
 | 
				
			||||||
 | 
					          fds_to_close_bound = index + 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Close the previous fds that turned out to be too small.  */
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    int saved_errno = errno;
 | 
				
			||||||
 | 
					    unsigned int duplicated_fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (duplicated_fd = 0;
 | 
				
			||||||
 | 
					         duplicated_fd < fds_to_close_bound * CHAR_BIT;
 | 
				
			||||||
 | 
					         duplicated_fd++)
 | 
				
			||||||
 | 
					      if ((fds_to_close[duplicated_fd / CHAR_BIT]
 | 
				
			||||||
 | 
					           >> (duplicated_fd % CHAR_BIT))
 | 
				
			||||||
 | 
					          & 1)
 | 
				
			||||||
 | 
					        close (duplicated_fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    errno = saved_errno;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if REPLACE_FCHDIR
 | 
				
			||||||
 | 
					  if (0 <= result)
 | 
				
			||||||
 | 
					    result = _gl_register_dup (oldfd, result);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif /* W32 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Forward declarations, because we '#undef fcntl' in the middle of this
 | 
				
			||||||
 | 
					   compilation unit.  */
 | 
				
			||||||
 | 
					/* Our implementation of fcntl (fd, F_DUPFD, target).  */
 | 
				
			||||||
 | 
					static int rpl_fcntl_DUPFD (int fd, int target);
 | 
				
			||||||
 | 
					/* Our implementation of fcntl (fd, F_DUPFD_CLOEXEC, target).  */
 | 
				
			||||||
 | 
					static int rpl_fcntl_DUPFD_CLOEXEC (int fd, int target);
 | 
				
			||||||
 | 
					#ifdef __KLIBC__
 | 
				
			||||||
 | 
					/* Adds support for fcntl on directories.  */
 | 
				
			||||||
 | 
					static int klibc_fcntl (int fd, int action, /* arg */...);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Perform the specified ACTION on the file descriptor FD, possibly
 | 
				
			||||||
 | 
					   using the argument ARG further described below.  This replacement
 | 
				
			||||||
 | 
					   handles the following actions, and forwards all others on to the
 | 
				
			||||||
 | 
					   native fcntl.  An unrecognized ACTION returns -1 with errno set to
 | 
				
			||||||
 | 
					   EINVAL.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
 | 
				
			||||||
 | 
					   If successful, return the duplicate, which will be inheritable;
 | 
				
			||||||
 | 
					   otherwise return -1 and set errno.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
 | 
				
			||||||
 | 
					   target fd.  If successful, return the duplicate, which will not be
 | 
				
			||||||
 | 
					   inheritable; otherwise return -1 and set errno.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   F_GETFD - ARG need not be present.  If successful, return a
 | 
				
			||||||
 | 
					   non-negative value containing the descriptor flags of FD (only
 | 
				
			||||||
 | 
					   FD_CLOEXEC is portable, but other flags may be present); otherwise
 | 
				
			||||||
 | 
					   return -1 and set errno.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					fcntl (int fd, int action, /* arg */...)
 | 
				
			||||||
 | 
					#undef fcntl
 | 
				
			||||||
 | 
					#ifdef __KLIBC__
 | 
				
			||||||
 | 
					# define fcntl klibc_fcntl
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  va_list arg;
 | 
				
			||||||
 | 
					  int result = -1;
 | 
				
			||||||
 | 
					  va_start (arg, action);
 | 
				
			||||||
 | 
					  switch (action)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    case F_DUPFD:
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        int target = va_arg (arg, int);
 | 
				
			||||||
 | 
					        result = rpl_fcntl_DUPFD (fd, target);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case F_DUPFD_CLOEXEC:
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        int target = va_arg (arg, int);
 | 
				
			||||||
 | 
					        result = rpl_fcntl_DUPFD_CLOEXEC (fd, target);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if !HAVE_FCNTL
 | 
				
			||||||
 | 
					    case F_GETFD:
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					# if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					        HANDLE handle = (HANDLE) _get_osfhandle (fd);
 | 
				
			||||||
 | 
					        DWORD flags;
 | 
				
			||||||
 | 
					        if (handle == INVALID_HANDLE_VALUE
 | 
				
			||||||
 | 
					            || GetHandleInformation (handle, &flags) == 0)
 | 
				
			||||||
 | 
					          errno = EBADF;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
 | 
				
			||||||
 | 
					# else /* !W32 */
 | 
				
			||||||
 | 
					        /* Use dup2 to reject invalid file descriptors.  No way to
 | 
				
			||||||
 | 
					           access this information, so punt.  */
 | 
				
			||||||
 | 
					        if (0 <= dup2 (fd, fd))
 | 
				
			||||||
 | 
					          result = 0;
 | 
				
			||||||
 | 
					# endif /* !W32 */
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      } /* F_GETFD */
 | 
				
			||||||
 | 
					#endif /* !HAVE_FCNTL */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* Implementing F_SETFD on mingw is not trivial - there is no
 | 
				
			||||||
 | 
					         API for changing the O_NOINHERIT bit on an fd, and merely
 | 
				
			||||||
 | 
					         changing the HANDLE_FLAG_INHERIT bit on the underlying handle
 | 
				
			||||||
 | 
					         can lead to odd state.  It may be possible by duplicating the
 | 
				
			||||||
 | 
					         handle, using _open_osfhandle with the right flags, then
 | 
				
			||||||
 | 
					         using dup2 to move the duplicate onto the original, but that
 | 
				
			||||||
 | 
					         is not supported for now.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					#if HAVE_FCNTL
 | 
				
			||||||
 | 
					        switch (action)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					          #ifdef F_BARRIERFSYNC                  /* macOS */
 | 
				
			||||||
 | 
					          case F_BARRIERFSYNC:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_CHKCLEAN                      /* macOS */
 | 
				
			||||||
 | 
					          case F_CHKCLEAN:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_CLOSEM                        /* NetBSD, HP-UX */
 | 
				
			||||||
 | 
					          case F_CLOSEM:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_FLUSH_DATA                    /* macOS */
 | 
				
			||||||
 | 
					          case F_FLUSH_DATA:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_FREEZE_FS                     /* macOS */
 | 
				
			||||||
 | 
					          case F_FREEZE_FS:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_FULLFSYNC                     /* macOS */
 | 
				
			||||||
 | 
					          case F_FULLFSYNC:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETCONFINED                   /* macOS */
 | 
				
			||||||
 | 
					          case F_GETCONFINED:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETDEFAULTPROTLEVEL           /* macOS */
 | 
				
			||||||
 | 
					          case F_GETDEFAULTPROTLEVEL:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETFD                         /* POSIX */
 | 
				
			||||||
 | 
					          case F_GETFD:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETFL                         /* POSIX */
 | 
				
			||||||
 | 
					          case F_GETFL:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETLEASE                      /* Linux */
 | 
				
			||||||
 | 
					          case F_GETLEASE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETNOSIGPIPE                  /* macOS */
 | 
				
			||||||
 | 
					          case F_GETNOSIGPIPE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETOWN                        /* POSIX */
 | 
				
			||||||
 | 
					          case F_GETOWN:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETPIPE_SZ                    /* Linux */
 | 
				
			||||||
 | 
					          case F_GETPIPE_SZ:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETPROTECTIONCLASS            /* macOS */
 | 
				
			||||||
 | 
					          case F_GETPROTECTIONCLASS:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETPROTECTIONLEVEL            /* macOS */
 | 
				
			||||||
 | 
					          case F_GETPROTECTIONLEVEL:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GET_SEALS                     /* Linux */
 | 
				
			||||||
 | 
					          case F_GET_SEALS:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETSIG                        /* Linux */
 | 
				
			||||||
 | 
					          case F_GETSIG:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_MAXFD                         /* NetBSD */
 | 
				
			||||||
 | 
					          case F_MAXFD:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_RECYCLE                       /* macOS */
 | 
				
			||||||
 | 
					          case F_RECYCLE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETFIFOENH                    /* HP-UX */
 | 
				
			||||||
 | 
					          case F_SETFIFOENH:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_THAW_FS                       /* macOS */
 | 
				
			||||||
 | 
					          case F_THAW_FS:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					            /* These actions take no argument.  */
 | 
				
			||||||
 | 
					            result = fcntl (fd, action);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          #ifdef F_ADD_SEALS                     /* Linux */
 | 
				
			||||||
 | 
					          case F_ADD_SEALS:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_BADFD                         /* Solaris */
 | 
				
			||||||
 | 
					          case F_BADFD:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_CHECK_OPENEVT                 /* macOS */
 | 
				
			||||||
 | 
					          case F_CHECK_OPENEVT:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_DUP2FD                        /* FreeBSD, AIX, Solaris */
 | 
				
			||||||
 | 
					          case F_DUP2FD:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_DUP2FD_CLOEXEC                /* FreeBSD, Solaris */
 | 
				
			||||||
 | 
					          case F_DUP2FD_CLOEXEC:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_DUP2FD_CLOFORK                /* Solaris */
 | 
				
			||||||
 | 
					          case F_DUP2FD_CLOFORK:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_DUPFD                         /* POSIX */
 | 
				
			||||||
 | 
					          case F_DUPFD:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_DUPFD_CLOEXEC                 /* POSIX */
 | 
				
			||||||
 | 
					          case F_DUPFD_CLOEXEC:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_DUPFD_CLOFORK                 /* Solaris */
 | 
				
			||||||
 | 
					          case F_DUPFD_CLOFORK:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GETXFL                        /* Solaris */
 | 
				
			||||||
 | 
					          case F_GETXFL:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_GLOBAL_NOCACHE                /* macOS */
 | 
				
			||||||
 | 
					          case F_GLOBAL_NOCACHE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_MAKECOMPRESSED                /* macOS */
 | 
				
			||||||
 | 
					          case F_MAKECOMPRESSED:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_MOVEDATAEXTENTS               /* macOS */
 | 
				
			||||||
 | 
					          case F_MOVEDATAEXTENTS:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_NOCACHE                       /* macOS */
 | 
				
			||||||
 | 
					          case F_NOCACHE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_NODIRECT                      /* macOS */
 | 
				
			||||||
 | 
					          case F_NODIRECT:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_NOTIFY                        /* Linux */
 | 
				
			||||||
 | 
					          case F_NOTIFY:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_OPLKACK                       /* IRIX */
 | 
				
			||||||
 | 
					          case F_OPLKACK:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_OPLKREG                       /* IRIX */
 | 
				
			||||||
 | 
					          case F_OPLKREG:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_RDAHEAD                       /* macOS */
 | 
				
			||||||
 | 
					          case F_RDAHEAD:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETBACKINGSTORE               /* macOS */
 | 
				
			||||||
 | 
					          case F_SETBACKINGSTORE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETCONFINED                   /* macOS */
 | 
				
			||||||
 | 
					          case F_SETCONFINED:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETFD                         /* POSIX */
 | 
				
			||||||
 | 
					          case F_SETFD:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETFL                         /* POSIX */
 | 
				
			||||||
 | 
					          case F_SETFL:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETLEASE                      /* Linux */
 | 
				
			||||||
 | 
					          case F_SETLEASE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETNOSIGPIPE                  /* macOS */
 | 
				
			||||||
 | 
					          case F_SETNOSIGPIPE:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETOWN                        /* POSIX */
 | 
				
			||||||
 | 
					          case F_SETOWN:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETPIPE_SZ                    /* Linux */
 | 
				
			||||||
 | 
					          case F_SETPIPE_SZ:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETPROTECTIONCLASS            /* macOS */
 | 
				
			||||||
 | 
					          case F_SETPROTECTIONCLASS:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SETSIG                        /* Linux */
 | 
				
			||||||
 | 
					          case F_SETSIG:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #ifdef F_SINGLE_WRITER                 /* macOS */
 | 
				
			||||||
 | 
					          case F_SINGLE_WRITER:
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					            /* These actions take an 'int' argument.  */
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              int x = va_arg (arg, int);
 | 
				
			||||||
 | 
					              result = fcntl (fd, action, x);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          default:
 | 
				
			||||||
 | 
					            /* Other actions take a pointer argument.  */
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              void *p = va_arg (arg, void *);
 | 
				
			||||||
 | 
					              result = fcntl (fd, action, p);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					        errno = EINVAL;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  va_end (arg);
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					rpl_fcntl_DUPFD (int fd, int target)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					#if !HAVE_FCNTL
 | 
				
			||||||
 | 
					  result = dupfd (fd, target, 0);
 | 
				
			||||||
 | 
					#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
 | 
				
			||||||
 | 
					  /* Detect invalid target; needed for cygwin 1.5.x.  */
 | 
				
			||||||
 | 
					  if (target < 0 || getdtablesize () <= target)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      result = -1;
 | 
				
			||||||
 | 
					      errno = EINVAL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* Haiku alpha 2 loses fd flags on original.  */
 | 
				
			||||||
 | 
					      int flags = fcntl (fd, F_GETFD);
 | 
				
			||||||
 | 
					      if (flags < 0)
 | 
				
			||||||
 | 
					        result = -1;
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          result = fcntl (fd, F_DUPFD, target);
 | 
				
			||||||
 | 
					          if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              int saved_errno = errno;
 | 
				
			||||||
 | 
					              close (result);
 | 
				
			||||||
 | 
					              result = -1;
 | 
				
			||||||
 | 
					              errno = saved_errno;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					# if REPLACE_FCHDIR
 | 
				
			||||||
 | 
					          if (0 <= result)
 | 
				
			||||||
 | 
					            result = _gl_register_dup (fd, result);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  result = fcntl (fd, F_DUPFD, target);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					#if !HAVE_FCNTL
 | 
				
			||||||
 | 
					  result = dupfd (fd, target, O_CLOEXEC);
 | 
				
			||||||
 | 
					#else /* HAVE_FCNTL */
 | 
				
			||||||
 | 
					# if defined __NetBSD__ || defined __HAIKU__
 | 
				
			||||||
 | 
					  /* On NetBSD 9.0, the system fcntl (fd, F_DUPFD_CLOEXEC, target)
 | 
				
			||||||
 | 
					     has only the same effect as fcntl (fd, F_DUPFD, target).  */
 | 
				
			||||||
 | 
					  /* On Haiku, the system fcntl (fd, F_DUPFD_CLOEXEC, target) sets
 | 
				
			||||||
 | 
					     the FD_CLOEXEC flag on fd, not on target.  Therefore avoid the
 | 
				
			||||||
 | 
					     system fcntl in this case.  */
 | 
				
			||||||
 | 
					#  define have_dupfd_cloexec -1
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					  /* Try the system call first, if the headers claim it exists
 | 
				
			||||||
 | 
					     (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
 | 
				
			||||||
 | 
					     may be running with a glibc that has the macro but with an
 | 
				
			||||||
 | 
					     older kernel that does not support it.  Cache the
 | 
				
			||||||
 | 
					     information on whether the system call really works, but
 | 
				
			||||||
 | 
					     avoid caching failure if the corresponding F_DUPFD fails
 | 
				
			||||||
 | 
					     for any reason.  0 = unknown, 1 = yes, -1 = no.  */
 | 
				
			||||||
 | 
					  static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
 | 
				
			||||||
 | 
					  if (0 <= have_dupfd_cloexec)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      result = fcntl (fd, F_DUPFD_CLOEXEC, target);
 | 
				
			||||||
 | 
					      if (0 <= result || errno != EINVAL)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          have_dupfd_cloexec = 1;
 | 
				
			||||||
 | 
					#  if REPLACE_FCHDIR
 | 
				
			||||||
 | 
					          if (0 <= result)
 | 
				
			||||||
 | 
					            result = _gl_register_dup (fd, result);
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          result = rpl_fcntl_DUPFD (fd, target);
 | 
				
			||||||
 | 
					          if (result >= 0)
 | 
				
			||||||
 | 
					            have_dupfd_cloexec = -1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					    result = rpl_fcntl_DUPFD (fd, target);
 | 
				
			||||||
 | 
					  if (0 <= result && have_dupfd_cloexec == -1)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      int flags = fcntl (result, F_GETFD);
 | 
				
			||||||
 | 
					      if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          int saved_errno = errno;
 | 
				
			||||||
 | 
					          close (result);
 | 
				
			||||||
 | 
					          errno = saved_errno;
 | 
				
			||||||
 | 
					          result = -1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif /* HAVE_FCNTL */
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#undef fcntl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __KLIBC__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					klibc_fcntl (int fd, int action, /* arg */...)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  va_list arg_ptr;
 | 
				
			||||||
 | 
					  int arg;
 | 
				
			||||||
 | 
					  struct stat sbuf;
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  va_start (arg_ptr, action);
 | 
				
			||||||
 | 
					  arg = va_arg (arg_ptr, int);
 | 
				
			||||||
 | 
					  result = fcntl (fd, action, arg);
 | 
				
			||||||
 | 
					  /* EPERM for F_DUPFD, ENOTSUP for others */
 | 
				
			||||||
 | 
					  if (result == -1 && (errno == EPERM || errno == ENOTSUP)
 | 
				
			||||||
 | 
					      && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      ULONG ulMode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      switch (action)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        case F_DUPFD:
 | 
				
			||||||
 | 
					          /* Find available fd */
 | 
				
			||||||
 | 
					          while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
 | 
				
			||||||
 | 
					            arg++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          result = dup2 (fd, arg);
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* Using underlying APIs is right ? */
 | 
				
			||||||
 | 
					        case F_GETFD:
 | 
				
			||||||
 | 
					          if (DosQueryFHState (fd, &ulMode))
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case F_SETFD:
 | 
				
			||||||
 | 
					          if (arg & ~FD_CLOEXEC)
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          if (DosQueryFHState (fd, &ulMode))
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          if (arg & FD_CLOEXEC)
 | 
				
			||||||
 | 
					            ulMode |= OPEN_FLAGS_NOINHERIT;
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            ulMode &= ~OPEN_FLAGS_NOINHERIT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          /* Filter supported flags.  */
 | 
				
			||||||
 | 
					          ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
 | 
				
			||||||
 | 
					                     | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          if (DosSetFHState (fd, ulMode))
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          result = 0;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case F_GETFL:
 | 
				
			||||||
 | 
					          result = 0;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case F_SETFL:
 | 
				
			||||||
 | 
					          if (arg != 0)
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          result = 0;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					          errno = EINVAL;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  va_end (arg_ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										445
									
								
								gl/fcntl.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										445
									
								
								gl/fcntl.in.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,445 @@
 | 
				
			||||||
 | 
					/* Like <fcntl.h>, but with non-working flags defined to 0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 2006-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* written by Paul Eggert */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __GNUC__ >= 3
 | 
				
			||||||
 | 
					@PRAGMA_SYSTEM_HEADER@
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					@PRAGMA_COLUMNS@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined __need_system_fcntl_h
 | 
				
			||||||
 | 
					/* Special invocation convention.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Needed before <sys/stat.h>.
 | 
				
			||||||
 | 
					   May also define off_t to a 64-bit type on native Windows.  */
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
 | 
				
			||||||
 | 
					   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
 | 
				
			||||||
 | 
					   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
 | 
				
			||||||
 | 
					   extern "C" { ... } block, which leads to errors in C++ mode with the
 | 
				
			||||||
 | 
					   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
 | 
				
			||||||
 | 
					   with g++ version >= 4.3.  */
 | 
				
			||||||
 | 
					#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
 | 
				
			||||||
 | 
					# include <sys/stat.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Native Windows platforms declare open(), creat() in <io.h>.  */
 | 
				
			||||||
 | 
					#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
 | 
				
			||||||
 | 
					    && (defined _WIN32 && ! defined __CYGWIN__)
 | 
				
			||||||
 | 
					# include <io.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					/* Normal invocation convention.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _@GUARD_PREFIX@_FCNTL_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Needed before <sys/stat.h>.
 | 
				
			||||||
 | 
					   May also define off_t to a 64-bit type on native Windows.  */
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
 | 
				
			||||||
 | 
					   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
 | 
				
			||||||
 | 
					   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
 | 
				
			||||||
 | 
					   extern "C" { ... } block, which leads to errors in C++ mode with the
 | 
				
			||||||
 | 
					   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
 | 
				
			||||||
 | 
					   with g++ version >= 4.3.  */
 | 
				
			||||||
 | 
					#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
 | 
				
			||||||
 | 
					# include <sys/stat.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					/* The include_next requires a split double-inclusion guard.  */
 | 
				
			||||||
 | 
					#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Native Windows platforms declare open(), creat() in <io.h>.  */
 | 
				
			||||||
 | 
					#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
 | 
				
			||||||
 | 
					    && (defined _WIN32 && ! defined __CYGWIN__)
 | 
				
			||||||
 | 
					# include <io.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _@GUARD_PREFIX@_FCNTL_H
 | 
				
			||||||
 | 
					#define _@GUARD_PREFIX@_FCNTL_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
 | 
				
			||||||
 | 
					# include <unistd.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The definition of _GL_ARG_NONNULL is copied here.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The definition of _GL_WARN_ON_USE is copied here.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Declare overridden functions.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if @GNULIB_CREAT@
 | 
				
			||||||
 | 
					# if @REPLACE_CREAT@
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef creat
 | 
				
			||||||
 | 
					#   define creat rpl_creat
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
 | 
				
			||||||
 | 
					                             _GL_ARG_NONNULL ((1)));
 | 
				
			||||||
 | 
					_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
 | 
				
			||||||
 | 
					# elif defined _WIN32 && !defined __CYGWIN__
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef creat
 | 
				
			||||||
 | 
					#   define creat _creat
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode));
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					_GL_CXXALIASWARN (creat);
 | 
				
			||||||
 | 
					#elif defined GNULIB_POSIXCHECK
 | 
				
			||||||
 | 
					# undef creat
 | 
				
			||||||
 | 
					/* Assume creat is always declared.  */
 | 
				
			||||||
 | 
					_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
 | 
				
			||||||
 | 
					                 "use gnulib module creat for portability");
 | 
				
			||||||
 | 
					#elif @GNULIB_MDA_CREAT@
 | 
				
			||||||
 | 
					/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
 | 
				
			||||||
 | 
					   required.  In C++ with GNULIB_NAMESPACE, avoid differences between
 | 
				
			||||||
 | 
					   platforms by defining GNULIB_NAMESPACE::creat always.  */
 | 
				
			||||||
 | 
					# if defined _WIN32 && !defined __CYGWIN__
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef creat
 | 
				
			||||||
 | 
					#   define creat _creat
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					/* Need to cast, because in mingw the last argument is 'int mode'.  */
 | 
				
			||||||
 | 
					_GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode));
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					_GL_CXXALIASWARN (creat);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if @GNULIB_FCNTL@
 | 
				
			||||||
 | 
					# if @REPLACE_FCNTL@
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef fcntl
 | 
				
			||||||
 | 
					#   define fcntl rpl_fcntl
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
 | 
				
			||||||
 | 
					_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
 | 
				
			||||||
 | 
					#  if !GNULIB_defined_rpl_fcntl
 | 
				
			||||||
 | 
					#   define GNULIB_defined_rpl_fcntl 1
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  if !@HAVE_FCNTL@
 | 
				
			||||||
 | 
					_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
 | 
				
			||||||
 | 
					#   if !GNULIB_defined_fcntl
 | 
				
			||||||
 | 
					#    define GNULIB_defined_fcntl 1
 | 
				
			||||||
 | 
					#   endif
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					_GL_CXXALIASWARN (fcntl);
 | 
				
			||||||
 | 
					#elif defined GNULIB_POSIXCHECK
 | 
				
			||||||
 | 
					# undef fcntl
 | 
				
			||||||
 | 
					# if HAVE_RAW_DECL_FCNTL
 | 
				
			||||||
 | 
					_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
 | 
				
			||||||
 | 
					                 "use gnulib module fcntl for portability");
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if @GNULIB_OPEN@
 | 
				
			||||||
 | 
					# if @REPLACE_OPEN@
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef open
 | 
				
			||||||
 | 
					#   define open rpl_open
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
 | 
				
			||||||
 | 
					                             _GL_ARG_NONNULL ((1)));
 | 
				
			||||||
 | 
					_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 | 
					# elif defined _WIN32 && !defined __CYGWIN__
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef open
 | 
				
			||||||
 | 
					#   define open _open
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
 | 
				
			||||||
 | 
					   default argument.  _GL_CXXALIASWARN does not work in this case.  */
 | 
				
			||||||
 | 
					# if !defined __hpux
 | 
				
			||||||
 | 
					_GL_CXXALIASWARN (open);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#elif defined GNULIB_POSIXCHECK
 | 
				
			||||||
 | 
					# undef open
 | 
				
			||||||
 | 
					/* Assume open is always declared.  */
 | 
				
			||||||
 | 
					_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
 | 
				
			||||||
 | 
					                 "use gnulib module open for portability");
 | 
				
			||||||
 | 
					#elif @GNULIB_MDA_OPEN@
 | 
				
			||||||
 | 
					/* On native Windows, map 'open' to '_open', so that -loldnames is not
 | 
				
			||||||
 | 
					   required.  In C++ with GNULIB_NAMESPACE, avoid differences between
 | 
				
			||||||
 | 
					   platforms by defining GNULIB_NAMESPACE::open always.  */
 | 
				
			||||||
 | 
					# if defined _WIN32 && !defined __CYGWIN__
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef open
 | 
				
			||||||
 | 
					#   define open _open
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# if !defined __hpux
 | 
				
			||||||
 | 
					_GL_CXXALIASWARN (open);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if @GNULIB_OPENAT@
 | 
				
			||||||
 | 
					# if @REPLACE_OPENAT@
 | 
				
			||||||
 | 
					#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 | 
				
			||||||
 | 
					#   undef openat
 | 
				
			||||||
 | 
					#   define openat rpl_openat
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_FUNCDECL_RPL (openat, int,
 | 
				
			||||||
 | 
					                  (int fd, char const *file, int flags, /* mode_t mode */ ...)
 | 
				
			||||||
 | 
					                  _GL_ARG_NONNULL ((2)));
 | 
				
			||||||
 | 
					_GL_CXXALIAS_RPL (openat, int,
 | 
				
			||||||
 | 
					                  (int fd, char const *file, int flags, /* mode_t mode */ ...));
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  if !@HAVE_OPENAT@
 | 
				
			||||||
 | 
					_GL_FUNCDECL_SYS (openat, int,
 | 
				
			||||||
 | 
					                  (int fd, char const *file, int flags, /* mode_t mode */ ...)
 | 
				
			||||||
 | 
					                  _GL_ARG_NONNULL ((2)));
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					_GL_CXXALIAS_SYS (openat, int,
 | 
				
			||||||
 | 
					                  (int fd, char const *file, int flags, /* mode_t mode */ ...));
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					_GL_CXXALIASWARN (openat);
 | 
				
			||||||
 | 
					#elif defined GNULIB_POSIXCHECK
 | 
				
			||||||
 | 
					# undef openat
 | 
				
			||||||
 | 
					# if HAVE_RAW_DECL_OPENAT
 | 
				
			||||||
 | 
					_GL_WARN_ON_USE (openat, "openat is not portable - "
 | 
				
			||||||
 | 
					                 "use gnulib module openat for portability");
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fix up the FD_* macros, only known to be missing on mingw.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef FD_CLOEXEC
 | 
				
			||||||
 | 
					# define FD_CLOEXEC 1
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fix up the supported F_* macros.  Intentionally leave other F_*
 | 
				
			||||||
 | 
					   macros undefined.  Only known to be missing on mingw.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef F_DUPFD_CLOEXEC
 | 
				
			||||||
 | 
					# define F_DUPFD_CLOEXEC 0x40000000
 | 
				
			||||||
 | 
					/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise.  */
 | 
				
			||||||
 | 
					# define GNULIB_defined_F_DUPFD_CLOEXEC 1
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define GNULIB_defined_F_DUPFD_CLOEXEC 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef F_DUPFD
 | 
				
			||||||
 | 
					# define F_DUPFD 1
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef F_GETFD
 | 
				
			||||||
 | 
					# define F_GETFD 2
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fix up the O_* macros.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
 | 
				
			||||||
 | 
					   to values outside 'int' range, so omit these misdefinitions.
 | 
				
			||||||
 | 
					   But avoid namespace pollution on non-AIX systems.  */
 | 
				
			||||||
 | 
					#ifdef _AIX
 | 
				
			||||||
 | 
					# include <limits.h>
 | 
				
			||||||
 | 
					# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
 | 
				
			||||||
 | 
					#  undef O_CLOEXEC
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
 | 
				
			||||||
 | 
					#  undef O_NOFOLLOW
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
 | 
				
			||||||
 | 
					#  undef O_TTY_INIT
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if !defined O_DIRECT && defined O_DIRECTIO
 | 
				
			||||||
 | 
					/* Tru64 spells it 'O_DIRECTIO'.  */
 | 
				
			||||||
 | 
					# define O_DIRECT O_DIRECTIO
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if !defined O_CLOEXEC && defined O_NOINHERIT
 | 
				
			||||||
 | 
					/* Mingw spells it 'O_NOINHERIT'.  */
 | 
				
			||||||
 | 
					# define O_CLOEXEC O_NOINHERIT
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_CLOEXEC
 | 
				
			||||||
 | 
					# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags.  */
 | 
				
			||||||
 | 
					# define GNULIB_defined_O_CLOEXEC 1
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define GNULIB_defined_O_CLOEXEC 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_DIRECT
 | 
				
			||||||
 | 
					# define O_DIRECT 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_DIRECTORY
 | 
				
			||||||
 | 
					# define O_DIRECTORY 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_DSYNC
 | 
				
			||||||
 | 
					# define O_DSYNC 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_EXEC
 | 
				
			||||||
 | 
					# define O_EXEC O_RDONLY /* This is often close enough in older systems.  */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_IGNORE_CTTY
 | 
				
			||||||
 | 
					# define O_IGNORE_CTTY 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NDELAY
 | 
				
			||||||
 | 
					# define O_NDELAY 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NOATIME
 | 
				
			||||||
 | 
					# define O_NOATIME 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NONBLOCK
 | 
				
			||||||
 | 
					# define O_NONBLOCK O_NDELAY
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
 | 
				
			||||||
 | 
					   value of O_NONBLOCK.  Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
 | 
				
			||||||
 | 
					   or to 0 as fallback.  */
 | 
				
			||||||
 | 
					#if @GNULIB_NONBLOCKING@
 | 
				
			||||||
 | 
					# if O_NONBLOCK
 | 
				
			||||||
 | 
					#  define GNULIB_defined_O_NONBLOCK 0
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define GNULIB_defined_O_NONBLOCK 1
 | 
				
			||||||
 | 
					#  undef O_NONBLOCK
 | 
				
			||||||
 | 
					#  define O_NONBLOCK 0x40000000
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NOCTTY
 | 
				
			||||||
 | 
					# define O_NOCTTY 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NOFOLLOW
 | 
				
			||||||
 | 
					# define O_NOFOLLOW 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NOLINK
 | 
				
			||||||
 | 
					# define O_NOLINK 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NOLINKS
 | 
				
			||||||
 | 
					# define O_NOLINKS 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NOTRANS
 | 
				
			||||||
 | 
					# define O_NOTRANS 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_RSYNC
 | 
				
			||||||
 | 
					# define O_RSYNC 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_SEARCH
 | 
				
			||||||
 | 
					# define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_SYNC
 | 
				
			||||||
 | 
					# define O_SYNC 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_TTY_INIT
 | 
				
			||||||
 | 
					# define O_TTY_INIT 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
 | 
				
			||||||
 | 
					# undef O_ACCMODE
 | 
				
			||||||
 | 
					# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* For systems that distinguish between text and binary I/O.
 | 
				
			||||||
 | 
					   O_BINARY is usually declared in fcntl.h  */
 | 
				
			||||||
 | 
					#if !defined O_BINARY && defined _O_BINARY
 | 
				
			||||||
 | 
					  /* For MSC-compatible compilers.  */
 | 
				
			||||||
 | 
					# define O_BINARY _O_BINARY
 | 
				
			||||||
 | 
					# define O_TEXT _O_TEXT
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined __BEOS__ || defined __HAIKU__
 | 
				
			||||||
 | 
					  /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect.  */
 | 
				
			||||||
 | 
					# undef O_BINARY
 | 
				
			||||||
 | 
					# undef O_TEXT
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_BINARY
 | 
				
			||||||
 | 
					# define O_BINARY 0
 | 
				
			||||||
 | 
					# define O_TEXT 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fix up the AT_* macros.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.  Its
 | 
				
			||||||
 | 
					   value exceeds INT_MAX, so its use as an int doesn't conform to the
 | 
				
			||||||
 | 
					   C standard, and GCC and Sun C complain in some cases.  If the bug
 | 
				
			||||||
 | 
					   is present, undef AT_FDCWD here, so it can be redefined below.  */
 | 
				
			||||||
 | 
					#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
 | 
				
			||||||
 | 
					# undef AT_FDCWD
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Use the same bit pattern as Solaris 9, but with the proper
 | 
				
			||||||
 | 
					   signedness.  The bit pattern is important, in case this actually is
 | 
				
			||||||
 | 
					   Solaris with the above workaround.  */
 | 
				
			||||||
 | 
					#ifndef AT_FDCWD
 | 
				
			||||||
 | 
					# define AT_FDCWD (-3041965)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Use the same values as Solaris 9.  This shouldn't matter, but
 | 
				
			||||||
 | 
					   there's no real reason to differ.  */
 | 
				
			||||||
 | 
					#ifndef AT_SYMLINK_NOFOLLOW
 | 
				
			||||||
 | 
					# define AT_SYMLINK_NOFOLLOW 4096
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef AT_REMOVEDIR
 | 
				
			||||||
 | 
					# define AT_REMOVEDIR 1
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Solaris 9 lacks these two, so just pick unique values.  */
 | 
				
			||||||
 | 
					#ifndef AT_SYMLINK_FOLLOW
 | 
				
			||||||
 | 
					# define AT_SYMLINK_FOLLOW 2
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef AT_EACCESS
 | 
				
			||||||
 | 
					# define AT_EACCESS 4
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Ignore this flag if not supported.  */
 | 
				
			||||||
 | 
					#ifndef AT_NO_AUTOMOUNT
 | 
				
			||||||
 | 
					# define AT_NO_AUTOMOUNT 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _@GUARD_PREFIX@_FCNTL_H */
 | 
				
			||||||
 | 
					#endif /* _@GUARD_PREFIX@_FCNTL_H */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										22
									
								
								gl/fd-hook.c
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								gl/fd-hook.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Hook for making making file descriptor functions close(), ioctl() extensible.
 | 
					/* Hook for making file descriptor functions close(), ioctl() extensible.
 | 
				
			||||||
   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Written by Bruno Haible <bruno@clisp.org>, 2009.
 | 
					   Written by Bruno Haible <bruno@clisp.org>, 2009.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify it
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   under the terms of the GNU General Public License as published
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   by the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										22
									
								
								gl/fd-hook.h
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								gl/fd-hook.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,18 +1,18 @@
 | 
				
			||||||
/* Hook for making making file descriptor functions close(), ioctl() extensible.
 | 
					/* Hook for making file descriptor functions close(), ioctl() extensible.
 | 
				
			||||||
   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify it
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   under the terms of the GNU General Public License as published
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   by the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef FD_HOOK_H
 | 
					#ifndef FD_HOOK_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										233
									
								
								gl/fflush.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										233
									
								
								gl/fflush.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,233 @@
 | 
				
			||||||
 | 
					/* fflush.c -- allow flushing input streams
 | 
				
			||||||
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Eric Blake. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "freading.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "stdio-impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#undef fflush
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
 | 
				
			||||||
 | 
					/* GNU libc, BeOS, Haiku, Linux libc5 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					clear_ungetc_buffer_preserving_position (FILE *fp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (fp->_flags & _IO_IN_BACKUP)
 | 
				
			||||||
 | 
					    /* _IO_free_backup_area is a bit complicated.  Simply call fseek.  */
 | 
				
			||||||
 | 
					    fseeko (fp, 0, SEEK_CUR);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Clear the stream's ungetc buffer.  May modify the value of ftello (fp).  */
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					clear_ungetc_buffer (FILE *fp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					  if (HASUB (fp))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      fp_->_p += fp_->_r;
 | 
				
			||||||
 | 
					      fp_->_r = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					# elif defined __EMX__              /* emx+gcc */
 | 
				
			||||||
 | 
					  if (fp->_ungetc_count > 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      fp->_ungetc_count = 0;
 | 
				
			||||||
 | 
					      fp->_rcount = - fp->_rcount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					# elif defined _IOERR               /* Minix, AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
 | 
				
			||||||
 | 
					  /* Nothing to do.  */
 | 
				
			||||||
 | 
					# else                              /* other implementations */
 | 
				
			||||||
 | 
					  fseeko (fp, 0, SEEK_CUR);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ! (defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1)
 | 
				
			||||||
 | 
					/* GNU libc, BeOS, Haiku, Linux libc5 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
 | 
				
			||||||
 | 
					/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					disable_seek_optimization (FILE *fp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int saved_flags = fp_->_flags & (__SOPT | __SNPT);
 | 
				
			||||||
 | 
					  fp_->_flags = (fp_->_flags & ~__SOPT) | __SNPT;
 | 
				
			||||||
 | 
					  return saved_flags;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					restore_seek_optimization (FILE *fp, int saved_flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  fp_->_flags = (fp_->_flags & ~(__SOPT | __SNPT)) | saved_flags;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
 | 
				
			||||||
 | 
					                   _GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#  if defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					#   if defined __CYGWIN__ || defined __ANDROID__
 | 
				
			||||||
 | 
					  /* fp_->_offset is typed as an integer.  */
 | 
				
			||||||
 | 
					  fp_->_offset = pos;
 | 
				
			||||||
 | 
					#   else
 | 
				
			||||||
 | 
					  /* fp_->_offset is an fpos_t.  */
 | 
				
			||||||
 | 
					  /* Use a union, since on NetBSD, the compilation flags determine
 | 
				
			||||||
 | 
					     whether fpos_t is typedef'd to off_t or a struct containing a
 | 
				
			||||||
 | 
					     single off_t member.  */
 | 
				
			||||||
 | 
					  union
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      fpos_t f;
 | 
				
			||||||
 | 
					      off_t o;
 | 
				
			||||||
 | 
					    } u;
 | 
				
			||||||
 | 
					  u.o = pos;
 | 
				
			||||||
 | 
					  fp_->_offset = u.f;
 | 
				
			||||||
 | 
					#   endif
 | 
				
			||||||
 | 
					  fp_->_flags |= __SOFF;
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Flush all pending data on STREAM according to POSIX rules.  Both
 | 
				
			||||||
 | 
					   output and seekable input streams are supported.  */
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					rpl_fflush (FILE *stream)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /* When stream is NULL, POSIX and C99 only require flushing of "output
 | 
				
			||||||
 | 
					     streams and update streams in which the most recent operation was not
 | 
				
			||||||
 | 
					     input", and all implementations do this.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     When stream is "an output stream or an update stream in which the most
 | 
				
			||||||
 | 
					     recent operation was not input", POSIX and C99 requires that fflush
 | 
				
			||||||
 | 
					     writes out any buffered data, and all implementations do this.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     When stream is, however, an input stream or an update stream in
 | 
				
			||||||
 | 
					     which the most recent operation was input, C99 specifies nothing,
 | 
				
			||||||
 | 
					     and POSIX only specifies behavior if the stream is seekable.
 | 
				
			||||||
 | 
					     mingw, in particular, drops the input buffer, leaving the file
 | 
				
			||||||
 | 
					     descriptor positioned at the end of the input buffer. I.e. ftell
 | 
				
			||||||
 | 
					     (stream) is lost.  We don't want to call the implementation's
 | 
				
			||||||
 | 
					     fflush in this case.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     We test ! freading (stream) here, rather than fwriting (stream), because
 | 
				
			||||||
 | 
					     what we need to know is whether the stream holds a "read buffer", and on
 | 
				
			||||||
 | 
					     mingw this is indicated by _IOREAD, regardless of _IOWRT.  */
 | 
				
			||||||
 | 
					  if (stream == NULL || ! freading (stream))
 | 
				
			||||||
 | 
					    return fflush (stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
 | 
				
			||||||
 | 
					  /* GNU libc, BeOS, Haiku, Linux libc5 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  clear_ungetc_buffer_preserving_position (stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return fflush (stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    /* What POSIX says:
 | 
				
			||||||
 | 
					       1) About the file-position indicator (-> fseeko, ftello):
 | 
				
			||||||
 | 
					          The file position indicator is incremented by fgetc() and decremented
 | 
				
			||||||
 | 
					          by ungetc():
 | 
				
			||||||
 | 
					          <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fgetc.html>
 | 
				
			||||||
 | 
					            "... the fgetc() function shall ... advance the associated file
 | 
				
			||||||
 | 
					             position indicator for the stream ..."
 | 
				
			||||||
 | 
					          <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ungetc.html>
 | 
				
			||||||
 | 
					            "The file-position indicator is decremented by each successful
 | 
				
			||||||
 | 
					             call to ungetc()..."
 | 
				
			||||||
 | 
					       2) fflush discards bytes pushed back by ungetc:
 | 
				
			||||||
 | 
					          <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
 | 
				
			||||||
 | 
					            "...any characters pushed back onto the stream by ungetc()
 | 
				
			||||||
 | 
					             or ungetwc() that have not subsequently been read from the
 | 
				
			||||||
 | 
					             stream shall be discarded..."
 | 
				
			||||||
 | 
					          This implies implicitly: fflush does not change the file position
 | 
				
			||||||
 | 
					          indicator.
 | 
				
			||||||
 | 
					       3) Effects on the file descriptor, if the file descriptor is capable of
 | 
				
			||||||
 | 
					          seeking:
 | 
				
			||||||
 | 
					          <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
 | 
				
			||||||
 | 
					            "...the file offset of the underlying open file description shall
 | 
				
			||||||
 | 
					             be set to the file position of the stream..."  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* POSIX does not specify fflush behavior for non-seekable input
 | 
				
			||||||
 | 
					       streams.  Some implementations purge unread data, some return
 | 
				
			||||||
 | 
					       EBADF, some do nothing.  */
 | 
				
			||||||
 | 
					    off_t pos = ftello (stream);
 | 
				
			||||||
 | 
					    if (pos == -1)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        errno = EBADF;
 | 
				
			||||||
 | 
					        return EOF;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Clear the ungetc buffer.  */
 | 
				
			||||||
 | 
					    clear_ungetc_buffer (stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* To get here, we must be flushing a seekable input stream, so the
 | 
				
			||||||
 | 
					       semantics of fpurge are now appropriate to clear the buffer.  To
 | 
				
			||||||
 | 
					       avoid losing data, the lseek is also necessary.  */
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      int result = fpurge (stream);
 | 
				
			||||||
 | 
					      if (result != 0)
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
 | 
				
			||||||
 | 
					    /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* Disable seek optimization for the next fseeko call.  This tells the
 | 
				
			||||||
 | 
					         following fseeko call to seek to the desired position directly, rather
 | 
				
			||||||
 | 
					         than to seek to a block-aligned boundary.  */
 | 
				
			||||||
 | 
					      int saved_flags = disable_seek_optimization (stream);
 | 
				
			||||||
 | 
					      int result = fseeko (stream, pos, SEEK_SET);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      restore_seek_optimization (stream, saved_flags);
 | 
				
			||||||
 | 
					      return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pos = lseek (fileno (stream), pos, SEEK_SET);
 | 
				
			||||||
 | 
					    if (pos == -1)
 | 
				
			||||||
 | 
					      return EOF;
 | 
				
			||||||
 | 
					    /* After a successful lseek, update the file descriptor's position cache
 | 
				
			||||||
 | 
					       in the stream.  */
 | 
				
			||||||
 | 
					    update_fpos_cache (stream, pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										112
									
								
								gl/filename.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								gl/filename.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,112 @@
 | 
				
			||||||
 | 
					/* Basic filename support macros.
 | 
				
			||||||
 | 
					   Copyright (C) 2001-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   This file is part of the GNU C Library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* From Paul Eggert and Jim Meyering.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _FILENAME_H
 | 
				
			||||||
 | 
					#define _FILENAME_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Filename support.
 | 
				
			||||||
 | 
					   ISSLASH(C)                  tests whether C is a directory separator
 | 
				
			||||||
 | 
					                               character.
 | 
				
			||||||
 | 
					   HAS_DEVICE(Filename)        tests whether Filename contains a device
 | 
				
			||||||
 | 
					                               specification.
 | 
				
			||||||
 | 
					   FILE_SYSTEM_PREFIX_LEN(Filename)  length of the device specification
 | 
				
			||||||
 | 
					                                     at the beginning of Filename,
 | 
				
			||||||
 | 
					                                     index of the part consisting of
 | 
				
			||||||
 | 
					                                     alternating components and slashes.
 | 
				
			||||||
 | 
					   FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
 | 
				
			||||||
 | 
					                               1 when a non-empty device specification
 | 
				
			||||||
 | 
					                               can be followed by an empty or relative
 | 
				
			||||||
 | 
					                               part,
 | 
				
			||||||
 | 
					                               0 when a non-empty device specification
 | 
				
			||||||
 | 
					                               must be followed by a slash,
 | 
				
			||||||
 | 
					                               0 when device specification don't exist.
 | 
				
			||||||
 | 
					   IS_ABSOLUTE_FILE_NAME(Filename)
 | 
				
			||||||
 | 
					                               tests whether Filename is independent of
 | 
				
			||||||
 | 
					                               any notion of "current directory".
 | 
				
			||||||
 | 
					   IS_RELATIVE_FILE_NAME(Filename)
 | 
				
			||||||
 | 
					                               tests whether Filename may be concatenated
 | 
				
			||||||
 | 
					                               to a directory filename.
 | 
				
			||||||
 | 
					   Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
 | 
				
			||||||
 | 
					   relative file name!
 | 
				
			||||||
 | 
					   IS_FILE_NAME_WITH_DIR(Filename)  tests whether Filename contains a device
 | 
				
			||||||
 | 
					                                    or directory specification.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#if defined _WIN32 || defined __CYGWIN__ \
 | 
				
			||||||
 | 
					    || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
 | 
				
			||||||
 | 
					  /* Native Windows, Cygwin, OS/2, DOS */
 | 
				
			||||||
 | 
					# define ISSLASH(C) ((C) == '/' || (C) == '\\')
 | 
				
			||||||
 | 
					  /* Internal macro: Tests whether a character is a drive letter.  */
 | 
				
			||||||
 | 
					# define _IS_DRIVE_LETTER(C) \
 | 
				
			||||||
 | 
					    (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
 | 
				
			||||||
 | 
					  /* Help the compiler optimizing it.  This assumes ASCII.  */
 | 
				
			||||||
 | 
					# undef _IS_DRIVE_LETTER
 | 
				
			||||||
 | 
					# define _IS_DRIVE_LETTER(C) \
 | 
				
			||||||
 | 
					    (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
 | 
				
			||||||
 | 
					# define HAS_DEVICE(Filename) \
 | 
				
			||||||
 | 
					    (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
 | 
				
			||||||
 | 
					# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
 | 
				
			||||||
 | 
					# ifdef __CYGWIN__
 | 
				
			||||||
 | 
					#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					   /* On native Windows, OS/2, DOS, the system has the notion of a
 | 
				
			||||||
 | 
					      "current directory" on each drive.  */
 | 
				
			||||||
 | 
					#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
 | 
				
			||||||
 | 
					#  define IS_ABSOLUTE_FILE_NAME(Filename) \
 | 
				
			||||||
 | 
					     ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define IS_ABSOLUTE_FILE_NAME(Filename) \
 | 
				
			||||||
 | 
					     (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# define IS_RELATIVE_FILE_NAME(Filename) \
 | 
				
			||||||
 | 
					    (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
 | 
				
			||||||
 | 
					# define IS_FILE_NAME_WITH_DIR(Filename) \
 | 
				
			||||||
 | 
					    (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
 | 
				
			||||||
 | 
					     || HAS_DEVICE (Filename))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  /* Unix */
 | 
				
			||||||
 | 
					# define ISSLASH(C) ((C) == '/')
 | 
				
			||||||
 | 
					# define HAS_DEVICE(Filename) ((void) (Filename), 0)
 | 
				
			||||||
 | 
					# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
 | 
				
			||||||
 | 
					# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
 | 
				
			||||||
 | 
					# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
 | 
				
			||||||
 | 
					# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
 | 
				
			||||||
 | 
					# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Deprecated macros.  For backward compatibility with old users of the
 | 
				
			||||||
 | 
					   'filename' module.  */
 | 
				
			||||||
 | 
					#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
 | 
				
			||||||
 | 
					#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _FILENAME_H */
 | 
				
			||||||
							
								
								
									
										18
									
								
								gl/float+.h
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								gl/float+.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Supplemental information about the floating-point formats.
 | 
					/* Supplemental information about the floating-point formats.
 | 
				
			||||||
   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Written by Bruno Haible <bruno@clisp.org>, 2007.
 | 
					   Written by Bruno Haible <bruno@clisp.org>, 2007.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _FLOATPLUS_H
 | 
					#ifndef _FLOATPLUS_H
 | 
				
			||||||
#define _FLOATPLUS_H
 | 
					#define _FLOATPLUS_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								gl/float.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								gl/float.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Auxiliary definitions for <float.h>.
 | 
					/* Auxiliary definitions for <float.h>.
 | 
				
			||||||
   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2011-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Written by Bruno Haible <bruno@clisp.org>, 2011.
 | 
					   Written by Bruno Haible <bruno@clisp.org>, 2011.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* A correct <float.h>.
 | 
					/* A correct <float.h>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _@GUARD_PREFIX@_FLOAT_H
 | 
					#ifndef _@GUARD_PREFIX@_FLOAT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,8 +62,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
 | 
					/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
 | 
				
			||||||
   precision in the compiler but 64 bits of precision at runtime.  See
 | 
					   precision in the compiler but 64 bits of precision at runtime.  See
 | 
				
			||||||
   <http://lists.gnu.org/archive/html/bug-gnulib/2008-07/msg00063.html>.  */
 | 
					   <https://lists.gnu.org/r/bug-gnulib/2008-07/msg00063.html>.  */
 | 
				
			||||||
#if defined __i386__ && defined __FreeBSD__
 | 
					#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
 | 
				
			||||||
/* Number of mantissa units, in base FLT_RADIX.  */
 | 
					/* Number of mantissa units, in base FLT_RADIX.  */
 | 
				
			||||||
# undef LDBL_MANT_DIG
 | 
					# undef LDBL_MANT_DIG
 | 
				
			||||||
# define LDBL_MANT_DIG   64
 | 
					# define LDBL_MANT_DIG   64
 | 
				
			||||||
| 
						 | 
					@ -81,7 +81,7 @@
 | 
				
			||||||
# define LDBL_MAX_EXP    16384
 | 
					# define LDBL_MAX_EXP    16384
 | 
				
			||||||
/* Minimum positive normalized number.  */
 | 
					/* Minimum positive normalized number.  */
 | 
				
			||||||
# undef LDBL_MIN
 | 
					# undef LDBL_MIN
 | 
				
			||||||
# define LDBL_MIN        3.3621031431120935E-4932L /* = 0x1p-16382L */
 | 
					# define LDBL_MIN        3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */
 | 
				
			||||||
/* Maximum representable finite number.  */
 | 
					/* Maximum representable finite number.  */
 | 
				
			||||||
# undef LDBL_MAX
 | 
					# undef LDBL_MAX
 | 
				
			||||||
/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
 | 
					/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
 | 
				
			||||||
| 
						 | 
					@ -93,11 +93,14 @@
 | 
				
			||||||
     extern const long double LDBL_MAX;
 | 
					     extern const long double LDBL_MAX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Unfortunately, this is not a constant expression.  */
 | 
					   Unfortunately, this is not a constant expression.  */
 | 
				
			||||||
 | 
					# if !GNULIB_defined_long_double_union
 | 
				
			||||||
union gl_long_double_union
 | 
					union gl_long_double_union
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
 | 
					    struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
 | 
				
			||||||
    long double ld;
 | 
					    long double ld;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					#  define GNULIB_defined_long_double_union 1
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
extern const union gl_long_double_union gl_LDBL_MAX;
 | 
					extern const union gl_long_double_union gl_LDBL_MAX;
 | 
				
			||||||
# define LDBL_MAX (gl_LDBL_MAX.ld)
 | 
					# define LDBL_MAX (gl_LDBL_MAX.ld)
 | 
				
			||||||
/* Minimum e such that 10^e is in the range of normalized numbers.  */
 | 
					/* Minimum e such that 10^e is in the range of normalized numbers.  */
 | 
				
			||||||
| 
						 | 
					@ -146,11 +149,14 @@ extern const union gl_long_double_union gl_LDBL_MAX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Unfortunately, this is not a constant expression, and the latter expression
 | 
					   Unfortunately, this is not a constant expression, and the latter expression
 | 
				
			||||||
   does not work well when GCC is optimizing..  */
 | 
					   does not work well when GCC is optimizing..  */
 | 
				
			||||||
 | 
					# if !GNULIB_defined_long_double_union
 | 
				
			||||||
union gl_long_double_union
 | 
					union gl_long_double_union
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    struct { double hi; double lo; } dd;
 | 
					    struct { double hi; double lo; } dd;
 | 
				
			||||||
    long double ld;
 | 
					    long double ld;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					#  define GNULIB_defined_long_double_union 1
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
extern const union gl_long_double_union gl_LDBL_MAX;
 | 
					extern const union gl_long_double_union gl_LDBL_MAX;
 | 
				
			||||||
# define LDBL_MAX (gl_LDBL_MAX.ld)
 | 
					# define LDBL_MAX (gl_LDBL_MAX.ld)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										20
									
								
								gl/floor.c
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								gl/floor.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,18 +1,18 @@
 | 
				
			||||||
/* Round towards negative infinity.
 | 
					/* Round towards negative infinity.
 | 
				
			||||||
   Copyright (C) 2007, 2010-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2007, 2010-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation, either version 3 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 | 
					/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,7 +44,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* MSVC with option -fp:strict refuses to compile constant initializers that
 | 
					/* MSVC with option -fp:strict refuses to compile constant initializers that
 | 
				
			||||||
   contain floating-point operations.  Pacify this compiler.  */
 | 
					   contain floating-point operations.  Pacify this compiler.  */
 | 
				
			||||||
#ifdef _MSC_VER
 | 
					#if defined _MSC_VER && !defined __clang__
 | 
				
			||||||
# pragma fenv_access (off)
 | 
					# pragma fenv_access (off)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								gl/floorf.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								gl/floorf.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,18 +1,18 @@
 | 
				
			||||||
/* Round towards negative infinity.
 | 
					/* Round towards negative infinity.
 | 
				
			||||||
   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation, either version 3 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 | 
					/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										229
									
								
								gl/fopen.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										229
									
								
								gl/fopen.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,229 @@
 | 
				
			||||||
 | 
					/* Open a stream to a file.
 | 
				
			||||||
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If the user's config.h happens to include <stdio.h>, let it include only
 | 
				
			||||||
 | 
					   the system's <stdio.h> here, so that orig_fopen doesn't recurse to
 | 
				
			||||||
 | 
					   rpl_fopen.  */
 | 
				
			||||||
 | 
					#define _GL_ALREADY_INCLUDING_STDIO_H
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get the original definition of fopen.  It might be defined as a macro.  */
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#undef _GL_ALREADY_INCLUDING_STDIO_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static FILE *
 | 
				
			||||||
 | 
					orig_fopen (const char *filename, const char *mode)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return fopen (filename, mode);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					/* Write "stdio.h" here, not <stdio.h>, otherwise OSF/1 5.1 DTK cc eliminates
 | 
				
			||||||
 | 
					   this include because of the preliminary #include <stdio.h> above.  */
 | 
				
			||||||
 | 
					#include "stdio.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <sys/stat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FILE *
 | 
				
			||||||
 | 
					rpl_fopen (const char *filename, const char *mode)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int open_direction;
 | 
				
			||||||
 | 
					  int open_flags;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					  bool open_flags_gnu;
 | 
				
			||||||
 | 
					# define BUF_SIZE 80
 | 
				
			||||||
 | 
					  char fdopen_mode_buf[BUF_SIZE + 1];
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					  if (strcmp (filename, "/dev/null") == 0)
 | 
				
			||||||
 | 
					    filename = "NUL";
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Parse the mode.  */
 | 
				
			||||||
 | 
					  open_direction = 0;
 | 
				
			||||||
 | 
					  open_flags = 0;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					  open_flags_gnu = false;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const char *p = mode;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					    char *q = fdopen_mode_buf;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (; *p != '\0'; p++)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        switch (*p)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					          case 'r':
 | 
				
			||||||
 | 
					            open_direction = O_RDONLY;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					            if (q < fdopen_mode_buf + BUF_SIZE)
 | 
				
			||||||
 | 
					              *q++ = *p;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					          case 'w':
 | 
				
			||||||
 | 
					            open_direction = O_WRONLY;
 | 
				
			||||||
 | 
					            open_flags |= O_CREAT | O_TRUNC;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					            if (q < fdopen_mode_buf + BUF_SIZE)
 | 
				
			||||||
 | 
					              *q++ = *p;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					          case 'a':
 | 
				
			||||||
 | 
					            open_direction = O_WRONLY;
 | 
				
			||||||
 | 
					            open_flags |= O_CREAT | O_APPEND;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					            if (q < fdopen_mode_buf + BUF_SIZE)
 | 
				
			||||||
 | 
					              *q++ = *p;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					          case 'b':
 | 
				
			||||||
 | 
					            /* While it is non-standard, O_BINARY is guaranteed by
 | 
				
			||||||
 | 
					               gnulib <fcntl.h>.  We can also assume that orig_fopen
 | 
				
			||||||
 | 
					               supports the 'b' flag.  */
 | 
				
			||||||
 | 
					            open_flags |= O_BINARY;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					            if (q < fdopen_mode_buf + BUF_SIZE)
 | 
				
			||||||
 | 
					              *q++ = *p;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					          case '+':
 | 
				
			||||||
 | 
					            open_direction = O_RDWR;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					            if (q < fdopen_mode_buf + BUF_SIZE)
 | 
				
			||||||
 | 
					              *q++ = *p;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					          case 'x':
 | 
				
			||||||
 | 
					            open_flags |= O_EXCL;
 | 
				
			||||||
 | 
					            open_flags_gnu = true;
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					          case 'e':
 | 
				
			||||||
 | 
					            open_flags |= O_CLOEXEC;
 | 
				
			||||||
 | 
					            open_flags_gnu = true;
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					          default:
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					        /* The rest of the mode string can be a platform-dependent extension.
 | 
				
			||||||
 | 
					           Copy it unmodified.  */
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          size_t len = strlen (p);
 | 
				
			||||||
 | 
					          if (len > fdopen_mode_buf + BUF_SIZE - q)
 | 
				
			||||||
 | 
					            len = fdopen_mode_buf + BUF_SIZE - q;
 | 
				
			||||||
 | 
					          memcpy (q, p, len);
 | 
				
			||||||
 | 
					          q += len;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					    *q = '\0';
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if FOPEN_TRAILING_SLASH_BUG
 | 
				
			||||||
 | 
					  /* Fail if the mode requires write access and the filename ends in a slash,
 | 
				
			||||||
 | 
					     as POSIX says such a filename must name a directory
 | 
				
			||||||
 | 
					     <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
 | 
				
			||||||
 | 
					       "A pathname that contains at least one non-<slash> character and that
 | 
				
			||||||
 | 
					        ends with one or more trailing <slash> characters shall not be resolved
 | 
				
			||||||
 | 
					        successfully unless the last pathname component before the trailing
 | 
				
			||||||
 | 
					        <slash> characters names an existing directory"
 | 
				
			||||||
 | 
					     If the named file already exists as a directory, then if a mode that
 | 
				
			||||||
 | 
					     requires write access is specified, fopen() must fail because POSIX
 | 
				
			||||||
 | 
					     <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html>
 | 
				
			||||||
 | 
					     says that it fails with errno = EISDIR in this case.
 | 
				
			||||||
 | 
					     If the named file does not exist or does not name a directory, then
 | 
				
			||||||
 | 
					     fopen() must fail since the file does not contain a '.' directory.  */
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    size_t len = strlen (filename);
 | 
				
			||||||
 | 
					    if (len > 0 && filename[len - 1] == '/')
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        int fd;
 | 
				
			||||||
 | 
					        struct stat statbuf;
 | 
				
			||||||
 | 
					        FILE *fp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (open_direction != O_RDONLY)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            errno = EISDIR;
 | 
				
			||||||
 | 
					            return NULL;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        fd = open (filename, open_direction | open_flags,
 | 
				
			||||||
 | 
					                   S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 | 
				
			||||||
 | 
					        if (fd < 0)
 | 
				
			||||||
 | 
					          return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            close (fd);
 | 
				
			||||||
 | 
					            errno = ENOTDIR;
 | 
				
			||||||
 | 
					            return NULL;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					        fp = fdopen (fd, fdopen_mode_buf);
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					        fp = fdopen (fd, mode);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					        if (fp == NULL)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            int saved_errno = errno;
 | 
				
			||||||
 | 
					            close (fd);
 | 
				
			||||||
 | 
					            errno = saved_errno;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        return fp;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if GNULIB_FOPEN_GNU
 | 
				
			||||||
 | 
					  if (open_flags_gnu)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      int fd;
 | 
				
			||||||
 | 
					      FILE *fp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      fd = open (filename, open_direction | open_flags,
 | 
				
			||||||
 | 
					                 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 | 
				
			||||||
 | 
					      if (fd < 0)
 | 
				
			||||||
 | 
					        return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      fp = fdopen (fd, fdopen_mode_buf);
 | 
				
			||||||
 | 
					      if (fp == NULL)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          int saved_errno = errno;
 | 
				
			||||||
 | 
					          close (fd);
 | 
				
			||||||
 | 
					          errno = saved_errno;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      return fp;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return orig_fopen (filename, mode);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										150
									
								
								gl/fpurge.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								gl/fpurge.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,150 @@
 | 
				
			||||||
 | 
					/* Flushing buffers of a FILE stream.
 | 
				
			||||||
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
 | 
				
			||||||
 | 
					# if HAVE_STDIO_EXT_H
 | 
				
			||||||
 | 
					#  include <stdio_ext.h>
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "stdio-impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					fpurge (FILE *fp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  __fpurge (fp);
 | 
				
			||||||
 | 
					  /* The __fpurge function does not have a return value.  */
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#elif HAVE_FPURGE                   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Call the system's fpurge function.  */
 | 
				
			||||||
 | 
					# undef fpurge
 | 
				
			||||||
 | 
					# if !HAVE_DECL_FPURGE
 | 
				
			||||||
 | 
					  extern int fpurge (FILE *);
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					  int result = fpurge (fp);
 | 
				
			||||||
 | 
					# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					  if (result == 0)
 | 
				
			||||||
 | 
					    /* Correct the invariants that fpurge broke.
 | 
				
			||||||
 | 
					       <stdio.h> on BSD systems says:
 | 
				
			||||||
 | 
					         "The following always hold: if _flags & __SRD, _w is 0."
 | 
				
			||||||
 | 
					       If this invariant is not fulfilled and the stream is read-write but
 | 
				
			||||||
 | 
					       currently reading, subsequent putc or fputc calls will write directly
 | 
				
			||||||
 | 
					       into the buffer, although they shouldn't be allowed to.  */
 | 
				
			||||||
 | 
					    if ((fp_->_flags & __SRD) != 0)
 | 
				
			||||||
 | 
					      fp_->_w = 0;
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Most systems provide FILE as a struct and the necessary bitmask in
 | 
				
			||||||
 | 
					     <stdio.h>, because they need it for implementing getc() and putc() as
 | 
				
			||||||
 | 
					     fast macros.  */
 | 
				
			||||||
 | 
					# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
 | 
				
			||||||
 | 
					  /* GNU libc, BeOS, Haiku, Linux libc5 */
 | 
				
			||||||
 | 
					  fp->_IO_read_end = fp->_IO_read_ptr;
 | 
				
			||||||
 | 
					  fp->_IO_write_ptr = fp->_IO_write_base;
 | 
				
			||||||
 | 
					  /* Avoid memory leak when there is an active ungetc buffer.  */
 | 
				
			||||||
 | 
					  if (fp->_IO_save_base != NULL)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      free (fp->_IO_save_base);
 | 
				
			||||||
 | 
					      fp->_IO_save_base = NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					  fp_->_p = fp_->_bf._base;
 | 
				
			||||||
 | 
					  fp_->_r = 0;
 | 
				
			||||||
 | 
					  fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
 | 
				
			||||||
 | 
					             ? fp_->_bf._size
 | 
				
			||||||
 | 
					             : 0);
 | 
				
			||||||
 | 
					  /* Avoid memory leak when there is an active ungetc buffer.  */
 | 
				
			||||||
 | 
					  if (fp_ub._base != NULL)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      if (fp_ub._base != fp_->_ubuf)
 | 
				
			||||||
 | 
					        free (fp_ub._base);
 | 
				
			||||||
 | 
					      fp_ub._base = NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined __EMX__              /* emx+gcc */
 | 
				
			||||||
 | 
					  fp->_ptr = fp->_buffer;
 | 
				
			||||||
 | 
					  fp->_rcount = 0;
 | 
				
			||||||
 | 
					  fp->_wcount = 0;
 | 
				
			||||||
 | 
					  fp->_ungetc_count = 0;
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined __minix              /* Minix */
 | 
				
			||||||
 | 
					  fp->_ptr = fp->_buf;
 | 
				
			||||||
 | 
					  if (fp->_ptr != NULL)
 | 
				
			||||||
 | 
					    fp->_count = 0;
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined _IOERR               /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
 | 
				
			||||||
 | 
					  fp_->_ptr = fp_->_base;
 | 
				
			||||||
 | 
					  if (fp_->_ptr != NULL)
 | 
				
			||||||
 | 
					    fp_->_cnt = 0;
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined __UCLIBC__           /* uClibc */
 | 
				
			||||||
 | 
					#  ifdef __STDIO_BUFFERS
 | 
				
			||||||
 | 
					  if (fp->__modeflags & __FLAG_WRITING)
 | 
				
			||||||
 | 
					    fp->__bufpos = fp->__bufstart;
 | 
				
			||||||
 | 
					  else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
 | 
				
			||||||
 | 
					    fp->__bufpos = fp->__bufread;
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined __QNX__              /* QNX */
 | 
				
			||||||
 | 
					  fp->_Rback = fp->_Back + sizeof (fp->_Back);
 | 
				
			||||||
 | 
					  fp->_Rsave = NULL;
 | 
				
			||||||
 | 
					  if (fp->_Mode & 0x2000 /* _MWRITE */)
 | 
				
			||||||
 | 
					    /* fp->_Buf <= fp->_Next <= fp->_Wend */
 | 
				
			||||||
 | 
					    fp->_Next = fp->_Buf;
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    /* fp->_Buf <= fp->_Next <= fp->_Rend */
 | 
				
			||||||
 | 
					    fp->_Rend = fp->_Next;
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined __MINT__             /* Atari FreeMiNT */
 | 
				
			||||||
 | 
					  if (fp->__pushed_back)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      fp->__bufp = fp->__pushback_bufp;
 | 
				
			||||||
 | 
					      fp->__pushed_back = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  /* Preserve the current file position.  */
 | 
				
			||||||
 | 
					  if (fp->__target != -1)
 | 
				
			||||||
 | 
					    fp->__target += fp->__bufp - fp->__buffer;
 | 
				
			||||||
 | 
					  fp->__bufp = fp->__buffer;
 | 
				
			||||||
 | 
					  /* Nothing in the buffer, next getc is nontrivial.  */
 | 
				
			||||||
 | 
					  fp->__get_limit = fp->__bufp;
 | 
				
			||||||
 | 
					  /* Nothing in the buffer, next putc is nontrivial.  */
 | 
				
			||||||
 | 
					  fp->__put_limit = fp->__buffer;
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# elif defined EPLAN9               /* Plan9 */
 | 
				
			||||||
 | 
					  fp->rp = fp->wp = fp->lp = fp->buf;
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										76
									
								
								gl/freading.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								gl/freading.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,76 @@
 | 
				
			||||||
 | 
					/* Retrieve information about a FILE stream.
 | 
				
			||||||
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include "freading.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "stdio-impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Don't use glibc's __freading function in glibc < 2.7, see
 | 
				
			||||||
 | 
					   <https://sourceware.org/bugzilla/show_bug.cgi?id=4359>  */
 | 
				
			||||||
 | 
					#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool
 | 
				
			||||||
 | 
					freading (FILE *fp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /* Most systems provide FILE as a struct and the necessary bitmask in
 | 
				
			||||||
 | 
					     <stdio.h>, because they need it for implementing getc() and putc() as
 | 
				
			||||||
 | 
					     fast macros.  */
 | 
				
			||||||
 | 
					# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
 | 
				
			||||||
 | 
					  /* GNU libc, BeOS, Haiku, Linux libc5 */
 | 
				
			||||||
 | 
					  return ((fp->_flags & _IO_NO_WRITES) != 0
 | 
				
			||||||
 | 
					          || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
 | 
				
			||||||
 | 
					              && fp->_IO_read_base != NULL));
 | 
				
			||||||
 | 
					# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
 | 
				
			||||||
 | 
					  return (fp_->_flags & __SRD) != 0;
 | 
				
			||||||
 | 
					# elif defined __EMX__               /* emx+gcc */
 | 
				
			||||||
 | 
					  return (fp->_flags & _IOREAD) != 0;
 | 
				
			||||||
 | 
					# elif defined __minix               /* Minix */
 | 
				
			||||||
 | 
					  return (fp->_flags & _IOREADING) != 0;
 | 
				
			||||||
 | 
					# elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
 | 
				
			||||||
 | 
					#  if defined __sun                  /* Solaris */
 | 
				
			||||||
 | 
					  return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					  return (fp_->_flag & _IOREAD) != 0;
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					# elif defined __UCLIBC__            /* uClibc */
 | 
				
			||||||
 | 
					  return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
 | 
				
			||||||
 | 
					# elif defined __QNX__               /* QNX */
 | 
				
			||||||
 | 
					  return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
 | 
				
			||||||
 | 
					          || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
 | 
				
			||||||
 | 
					# elif defined __MINT__              /* Atari FreeMiNT */
 | 
				
			||||||
 | 
					  if (!fp->__mode.__write)
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					  if (!fp->__mode.__read)
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					#  ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
 | 
				
			||||||
 | 
					  return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					  return (fp->__buffer < fp->__get_limit /*|| fp->__bufp == fp->__put_limit ??*/);
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
 | 
					# elif defined EPLAN9                /* Plan9 */
 | 
				
			||||||
 | 
					  if (fp->state == 0 /* CLOSED */ || fp->state == 4 /* WR */)
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					  return (fp->state == 3 /* RD */ && (fp->bufl == 0 || fp->rp < fp->wp));
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  error "Please port gnulib freading.c to your platform!"
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										54
									
								
								gl/freading.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								gl/freading.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,54 @@
 | 
				
			||||||
 | 
					/* Retrieve information about a FILE stream.
 | 
				
			||||||
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return true if the stream STREAM is opened read-only, or if the
 | 
				
			||||||
 | 
					   last operation on the stream was a read operation.  Return false if
 | 
				
			||||||
 | 
					   the stream is opened write-only or append-only, or if it supports
 | 
				
			||||||
 | 
					   writing and there is no current read operation (such as fgetc).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   freading and fwriting will never both be true.  If STREAM supports
 | 
				
			||||||
 | 
					   both reads and writes, then:
 | 
				
			||||||
 | 
					     - both freading and fwriting might be false when the stream is first
 | 
				
			||||||
 | 
					       opened, after read encounters EOF, or after fflush,
 | 
				
			||||||
 | 
					     - freading might be false or true and fwriting might be false
 | 
				
			||||||
 | 
					       after repositioning (such as fseek, fsetpos, or rewind),
 | 
				
			||||||
 | 
					   depending on the underlying implementation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   STREAM must not be wide-character oriented.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
 | 
				
			||||||
 | 
					/* Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34, Android API >= 29, not glibc >= 2.2, but glibc >= 2.7, or musl libc  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if HAVE_STDIO_EXT_H
 | 
				
			||||||
 | 
					#  include <stdio_ext.h>
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# define freading(stream) (__freading (stream) != 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern bool freading (FILE *stream) _GL_ATTRIBUTE_PURE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										53
									
								
								gl/free.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								gl/free.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,53 @@
 | 
				
			||||||
 | 
					/* Make free() preserve errno.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 2003, 2006, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* written by Paul Eggert */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* A function definition is only needed if HAVE_FREE_POSIX is not defined.  */
 | 
				
			||||||
 | 
					#if !HAVE_FREE_POSIX
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					rpl_free (void *p)
 | 
				
			||||||
 | 
					# undef free
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					# if defined __GNUC__ && !defined __clang__
 | 
				
			||||||
 | 
					  /* An invalid GCC optimization
 | 
				
			||||||
 | 
					     <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396>
 | 
				
			||||||
 | 
					     would optimize away the assignments in the code below, when link-time
 | 
				
			||||||
 | 
					     optimization (LTO) is enabled.  Make the code more complicated, so that
 | 
				
			||||||
 | 
					     GCC does not grok how to optimize it.  */
 | 
				
			||||||
 | 
					  int err[2];
 | 
				
			||||||
 | 
					  err[0] = errno;
 | 
				
			||||||
 | 
					  err[1] = errno;
 | 
				
			||||||
 | 
					  errno = 0;
 | 
				
			||||||
 | 
					  free (p);
 | 
				
			||||||
 | 
					  errno = err[errno == 0];
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					  int err = errno;
 | 
				
			||||||
 | 
					  free (p);
 | 
				
			||||||
 | 
					  errno = err;
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										30
									
								
								gl/fseek.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								gl/fseek.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,30 @@
 | 
				
			||||||
 | 
					/* An fseek() function that, together with fflush(), is POSIX compliant.
 | 
				
			||||||
 | 
					   Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get off_t.  */
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					fseek (FILE *fp, long offset, int whence)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /* Use the replacement fseeko function with all its workarounds.  */
 | 
				
			||||||
 | 
					  return fseeko (fp, (off_t)offset, whence);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										164
									
								
								gl/fseeko.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								gl/fseeko.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,164 @@
 | 
				
			||||||
 | 
					/* An fseeko() function that, together with fflush(), is POSIX compliant.
 | 
				
			||||||
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get off_t, lseek, _POSIX_VERSION.  */
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "stdio-impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					fseeko (FILE *fp, off_t offset, int whence)
 | 
				
			||||||
 | 
					#undef fseeko
 | 
				
			||||||
 | 
					#if !HAVE_FSEEKO
 | 
				
			||||||
 | 
					# undef fseek
 | 
				
			||||||
 | 
					# define fseeko fseek
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if _GL_WINDOWS_64_BIT_OFF_T
 | 
				
			||||||
 | 
					# undef fseeko
 | 
				
			||||||
 | 
					# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
 | 
				
			||||||
 | 
					#  define fseeko _fseeki64
 | 
				
			||||||
 | 
					# else /* mingw before msvcrt8.0 */
 | 
				
			||||||
 | 
					#  define fseeko fseeko64
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if LSEEK_PIPE_BROKEN
 | 
				
			||||||
 | 
					  /* mingw gives bogus answers rather than failure on non-seekable files.  */
 | 
				
			||||||
 | 
					  if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
 | 
				
			||||||
 | 
					    return EOF;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* These tests are based on fpurge.c.  */
 | 
				
			||||||
 | 
					#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
 | 
				
			||||||
 | 
					  /* GNU libc, BeOS, Haiku, Linux libc5 */
 | 
				
			||||||
 | 
					  if (fp->_IO_read_end == fp->_IO_read_ptr
 | 
				
			||||||
 | 
					      && fp->_IO_write_ptr == fp->_IO_write_base
 | 
				
			||||||
 | 
					      && fp->_IO_save_base == NULL)
 | 
				
			||||||
 | 
					#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					# if defined __SL64 && defined __SCLE /* Cygwin */
 | 
				
			||||||
 | 
					  if ((fp->_flags & __SL64) == 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
 | 
				
			||||||
 | 
					         mode; but has an fseeko that requires 64-bit mode.  */
 | 
				
			||||||
 | 
					      FILE *tmp = fopen ("/dev/null", "r");
 | 
				
			||||||
 | 
					      if (!tmp)
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					      fp->_flags |= __SL64;
 | 
				
			||||||
 | 
					      fp->_seek64 = tmp->_seek64;
 | 
				
			||||||
 | 
					      fclose (tmp);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					  if (fp_->_p == fp_->_bf._base
 | 
				
			||||||
 | 
					      && fp_->_r == 0
 | 
				
			||||||
 | 
					      && fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
 | 
				
			||||||
 | 
					                     ? fp_->_bf._size
 | 
				
			||||||
 | 
					                     : 0)
 | 
				
			||||||
 | 
					      && fp_ub._base == NULL)
 | 
				
			||||||
 | 
					#elif defined __EMX__               /* emx+gcc */
 | 
				
			||||||
 | 
					  if (fp->_ptr == fp->_buffer
 | 
				
			||||||
 | 
					      && fp->_rcount == 0
 | 
				
			||||||
 | 
					      && fp->_wcount == 0
 | 
				
			||||||
 | 
					      && fp->_ungetc_count == 0)
 | 
				
			||||||
 | 
					#elif defined __minix               /* Minix */
 | 
				
			||||||
 | 
					  if (fp_->_ptr == fp_->_buf
 | 
				
			||||||
 | 
					      && (fp_->_ptr == NULL || fp_->_count == 0))
 | 
				
			||||||
 | 
					#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
 | 
				
			||||||
 | 
					  if (fp_->_ptr == fp_->_base
 | 
				
			||||||
 | 
					      && (fp_->_ptr == NULL || fp_->_cnt == 0))
 | 
				
			||||||
 | 
					#elif defined __UCLIBC__            /* uClibc */
 | 
				
			||||||
 | 
					  if (((fp->__modeflags & __FLAG_WRITING) == 0
 | 
				
			||||||
 | 
					       || fp->__bufpos == fp->__bufstart)
 | 
				
			||||||
 | 
					      && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
 | 
				
			||||||
 | 
					          || fp->__bufpos == fp->__bufread))
 | 
				
			||||||
 | 
					#elif defined __QNX__               /* QNX */
 | 
				
			||||||
 | 
					  if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
 | 
				
			||||||
 | 
					      && fp->_Rback == fp->_Back + sizeof (fp->_Back)
 | 
				
			||||||
 | 
					      && fp->_Rsave == NULL)
 | 
				
			||||||
 | 
					#elif defined __MINT__              /* Atari FreeMiNT */
 | 
				
			||||||
 | 
					  if (fp->__bufp == fp->__buffer
 | 
				
			||||||
 | 
					      && fp->__get_limit == fp->__bufp
 | 
				
			||||||
 | 
					      && fp->__put_limit == fp->__bufp
 | 
				
			||||||
 | 
					      && !fp->__pushed_back)
 | 
				
			||||||
 | 
					#elif defined EPLAN9                /* Plan9 */
 | 
				
			||||||
 | 
					  if (fp->rp == fp->buf
 | 
				
			||||||
 | 
					      && fp->wp == fp->buf)
 | 
				
			||||||
 | 
					#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
 | 
				
			||||||
 | 
					  /* Cross-compiling to some other system advertising conformance to
 | 
				
			||||||
 | 
					     POSIX.1-2008 or later.  Assume fseeko and fflush work as advertised.
 | 
				
			||||||
 | 
					     If this assumption is incorrect, please report the bug to
 | 
				
			||||||
 | 
					     bug-gnulib.  */
 | 
				
			||||||
 | 
					  if (0)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* We get here when an fflush() call immediately preceded this one (or
 | 
				
			||||||
 | 
					         if ftell() has created buffers but no I/O has occurred on a
 | 
				
			||||||
 | 
					         newly-opened stream).  We know there are no buffers.  */
 | 
				
			||||||
 | 
					      off_t pos = lseek (fileno (fp), offset, whence);
 | 
				
			||||||
 | 
					      if (pos == -1)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					          /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					          fp_->_flags &= ~__SOFF;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					          return -1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
 | 
				
			||||||
 | 
					      /* GNU libc, BeOS, Haiku, Linux libc5 */
 | 
				
			||||||
 | 
					      fp->_flags &= ~_IO_EOF_SEEN;
 | 
				
			||||||
 | 
					      fp->_offset = pos;
 | 
				
			||||||
 | 
					#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
 | 
				
			||||||
 | 
					      /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 | 
				
			||||||
 | 
					# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
 | 
				
			||||||
 | 
					      /* fp_->_offset is typed as an integer.  */
 | 
				
			||||||
 | 
					      fp_->_offset = pos;
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					      /* fp_->_offset is an fpos_t.  */
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        /* Use a union, since on NetBSD, the compilation flags
 | 
				
			||||||
 | 
					           determine whether fpos_t is typedef'd to off_t or a struct
 | 
				
			||||||
 | 
					           containing a single off_t member.  */
 | 
				
			||||||
 | 
					        union
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            fpos_t f;
 | 
				
			||||||
 | 
					            off_t o;
 | 
				
			||||||
 | 
					          } u;
 | 
				
			||||||
 | 
					        u.o = pos;
 | 
				
			||||||
 | 
					        fp_->_offset = u.f;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					      fp_->_flags |= __SOFF;
 | 
				
			||||||
 | 
					      fp_->_flags &= ~__SEOF;
 | 
				
			||||||
 | 
					#elif defined __EMX__               /* emx+gcc */
 | 
				
			||||||
 | 
					      fp->_flags &= ~_IOEOF;
 | 
				
			||||||
 | 
					#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
 | 
				
			||||||
 | 
					      fp_->_flag &= ~_IOEOF;
 | 
				
			||||||
 | 
					#elif defined __MINT__              /* Atari FreeMiNT */
 | 
				
			||||||
 | 
					      fp->__offset = pos;
 | 
				
			||||||
 | 
					      fp->__eof = 0;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					      return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  return fseeko (fp, offset, whence);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										94
									
								
								gl/fstat.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								gl/fstat.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,94 @@
 | 
				
			||||||
 | 
					/* fstat() replacement.
 | 
				
			||||||
 | 
					   Copyright (C) 2011-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If the user's config.h happens to include <sys/stat.h>, let it include only
 | 
				
			||||||
 | 
					   the system's <sys/stat.h> here, so that orig_fstat doesn't recurse to
 | 
				
			||||||
 | 
					   rpl_fstat.  */
 | 
				
			||||||
 | 
					#define __need_system_sys_stat_h
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get the original definition of fstat.  It might be defined as a macro.  */
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <sys/stat.h>
 | 
				
			||||||
 | 
					#undef __need_system_sys_stat_h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					# define WINDOWS_NATIVE
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if !defined WINDOWS_NATIVE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					orig_fstat (int fd, struct stat *buf)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return fstat (fd, buf);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#ifdef __osf__
 | 
				
			||||||
 | 
					/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
 | 
				
			||||||
 | 
					   eliminates this include because of the preliminary #include <sys/stat.h>
 | 
				
			||||||
 | 
					   above.  */
 | 
				
			||||||
 | 
					# include "sys/stat.h"
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# include <sys/stat.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "stat-time.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#ifdef WINDOWS_NATIVE
 | 
				
			||||||
 | 
					# define WIN32_LEAN_AND_MEAN
 | 
				
			||||||
 | 
					# include <windows.h>
 | 
				
			||||||
 | 
					# if GNULIB_MSVC_NOTHROW
 | 
				
			||||||
 | 
					#  include "msvc-nothrow.h"
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  include <io.h>
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# include "stat-w32.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					rpl_fstat (int fd, struct stat *buf)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY
 | 
				
			||||||
 | 
					  /* Handle the case when rpl_open() used a dummy file descriptor to work
 | 
				
			||||||
 | 
					     around an open() that can't normally visit directories.  */
 | 
				
			||||||
 | 
					  const char *name = _gl_directory_name (fd);
 | 
				
			||||||
 | 
					  if (name != NULL)
 | 
				
			||||||
 | 
					    return stat (name, buf);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef WINDOWS_NATIVE
 | 
				
			||||||
 | 
					  /* Fill the fields ourselves, because the original fstat function returns
 | 
				
			||||||
 | 
					     values for st_atime, st_mtime, st_ctime that depend on the current time
 | 
				
			||||||
 | 
					     zone.  See
 | 
				
			||||||
 | 
					     <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html>  */
 | 
				
			||||||
 | 
					  HANDLE h = (HANDLE) _get_osfhandle (fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (h == INVALID_HANDLE_VALUE)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = EBADF;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  return _gl_fstat_by_handle (h, NULL, buf);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  return stat_time_normalize (orig_fstat (fd, buf), buf);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										123
									
								
								gl/fsusage.c
									
										
									
									
									
								
							
							
						
						
									
										123
									
								
								gl/fsusage.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,20 +1,20 @@
 | 
				
			||||||
/* fsusage.c -- return space usage of mounted file systems
 | 
					/* fsusage.c -- return space usage of mounted file systems
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2013 Free Software
 | 
					   Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation, either version 3 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,22 +43,10 @@
 | 
				
			||||||
# if HAVE_SYS_FS_S5PARAM_H      /* Fujitsu UXP/V */
 | 
					# if HAVE_SYS_FS_S5PARAM_H      /* Fujitsu UXP/V */
 | 
				
			||||||
#  include <sys/fs/s5param.h>
 | 
					#  include <sys/fs/s5param.h>
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
# if defined HAVE_SYS_FILSYS_H && !defined _CRAY
 | 
					 | 
				
			||||||
#  include <sys/filsys.h>       /* SVR2 */
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
# if HAVE_SYS_STATFS_H
 | 
					# if HAVE_SYS_STATFS_H
 | 
				
			||||||
#  include <sys/statfs.h>
 | 
					#  include <sys/statfs.h>
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
# if HAVE_DUSTAT_H              /* AIX PS/2 */
 | 
					 | 
				
			||||||
#  include <sys/dustat.h>
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
# include "full-read.h"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* The results of open() in this file are not used with fchdir,
 | 
					 | 
				
			||||||
   therefore save some unnecessary work in fchdir.c.  */
 | 
					 | 
				
			||||||
#undef open
 | 
					 | 
				
			||||||
#undef close
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Many space usage primitives use all 1 bits to denote a value that is
 | 
					/* Many space usage primitives use all 1 bits to denote a value that is
 | 
				
			||||||
   not applicable or unknown.  Propagate this information by returning
 | 
					   not applicable or unknown.  Propagate this information by returning
 | 
				
			||||||
| 
						 | 
					@ -143,7 +131,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
 | 
				
			||||||
      fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (vfsd.f_bavail) != 0;
 | 
					      fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (vfsd.f_bavail) != 0;
 | 
				
			||||||
      fsp->fsu_files = PROPAGATE_ALL_ONES (vfsd.f_files);
 | 
					      fsp->fsu_files = PROPAGATE_ALL_ONES (vfsd.f_files);
 | 
				
			||||||
      fsp->fsu_ffree = PROPAGATE_ALL_ONES (vfsd.f_ffree);
 | 
					      fsp->fsu_ffree = PROPAGATE_ALL_ONES (vfsd.f_ffree);
 | 
				
			||||||
      fsp->fsu_favail = PROPAGATE_ALL_ONES (vfsd.f_favail);
 | 
					 | 
				
			||||||
      return 0;
 | 
					      return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -161,58 +148,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
 | 
				
			||||||
                        ? PROPAGATE_ALL_ONES (fsd.f_frsize)
 | 
					                        ? PROPAGATE_ALL_ONES (fsd.f_frsize)
 | 
				
			||||||
                        : PROPAGATE_ALL_ONES (fsd.f_bsize));
 | 
					                        : PROPAGATE_ALL_ONES (fsd.f_bsize));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#elif defined STAT_STATFS2_FS_DATA      /* Ultrix */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  struct fs_data fsd;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (statfs (file, &fsd) != 1)
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  fsp->fsu_blocksize = 1024;
 | 
					 | 
				
			||||||
  fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.fd_req.btot);
 | 
					 | 
				
			||||||
  fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.fd_req.bfree);
 | 
					 | 
				
			||||||
  fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.fd_req.bfreen);
 | 
					 | 
				
			||||||
  fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0;
 | 
					 | 
				
			||||||
  fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
 | 
					 | 
				
			||||||
  fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
 | 
					 | 
				
			||||||
  fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#elif defined STAT_READ_FILSYS          /* SVR2 */
 | 
					 | 
				
			||||||
# ifndef SUPERBOFF
 | 
					 | 
				
			||||||
#  define SUPERBOFF (SUPERB * 512)
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  struct filsys fsd;
 | 
					 | 
				
			||||||
  int fd;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (! disk)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      errno = 0;
 | 
					 | 
				
			||||||
      return -1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  fd = open (disk, O_RDONLY);
 | 
					 | 
				
			||||||
  if (fd < 0)
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
  lseek (fd, (off_t) SUPERBOFF, 0);
 | 
					 | 
				
			||||||
  if (full_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      close (fd);
 | 
					 | 
				
			||||||
      return -1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  close (fd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  fsp->fsu_blocksize = (fsd.s_type == Fs2b ? 1024 : 512);
 | 
					 | 
				
			||||||
  fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.s_fsize);
 | 
					 | 
				
			||||||
  fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.s_tfree);
 | 
					 | 
				
			||||||
  fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree);
 | 
					 | 
				
			||||||
  fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0;
 | 
					 | 
				
			||||||
  fsp->fsu_files = (fsd.s_isize == -1
 | 
					 | 
				
			||||||
                    ? UINTMAX_MAX
 | 
					 | 
				
			||||||
                    : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
 | 
					 | 
				
			||||||
  fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
 | 
					 | 
				
			||||||
  fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.s_tinode);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#elif defined STAT_STATFS3_OSF1         /* OSF/1 */
 | 
					#elif defined STAT_STATFS3_OSF1         /* OSF/1 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  struct statfs fsd;
 | 
					  struct statfs fsd;
 | 
				
			||||||
| 
						 | 
					@ -266,12 +201,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
 | 
					  fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#elif defined STAT_STATFS4              /* SVR3, Dynix, old Irix, old AIX, \
 | 
					#elif defined STAT_STATFS4              /* SVR3, old Irix */
 | 
				
			||||||
                                           Dolphin */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN
 | 
					 | 
				
			||||||
#  define f_bavail f_bfree
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  struct statfs fsd;
 | 
					  struct statfs fsd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -281,11 +211,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
 | 
				
			||||||
  /* Empirically, the block counts on most SVR3 and SVR3-derived
 | 
					  /* Empirically, the block counts on most SVR3 and SVR3-derived
 | 
				
			||||||
     systems seem to always be in terms of 512-byte blocks,
 | 
					     systems seem to always be in terms of 512-byte blocks,
 | 
				
			||||||
     no matter what value f_bsize has.  */
 | 
					     no matter what value f_bsize has.  */
 | 
				
			||||||
# if _AIX || defined _CRAY
 | 
					 | 
				
			||||||
   fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
 | 
					 | 
				
			||||||
# else
 | 
					 | 
				
			||||||
   fsp->fsu_blocksize = 512;
 | 
					   fsp->fsu_blocksize = 512;
 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -299,38 +225,9 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
 | 
				
			||||||
  fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0;
 | 
					  fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0;
 | 
				
			||||||
  fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files);
 | 
					  fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files);
 | 
				
			||||||
  fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
 | 
					  fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
 | 
				
			||||||
  fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.f_ffree);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  (void) disk;  /* avoid argument-unused warning */
 | 
					  (void) disk;  /* avoid argument-unused warning */
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined _AIX && defined _I386
 | 
					 | 
				
			||||||
/* AIX PS/2 does not supply statfs.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
statfs (char *file, struct statfs *fsb)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  struct stat stats;
 | 
					 | 
				
			||||||
  struct dustat fsd;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (stat (file, &stats) != 0)
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
  if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
  fsb->f_type   = 0;
 | 
					 | 
				
			||||||
  fsb->f_bsize  = fsd.du_bsize;
 | 
					 | 
				
			||||||
  fsb->f_blocks = fsd.du_fsize - fsd.du_isize;
 | 
					 | 
				
			||||||
  fsb->f_bfree  = fsd.du_tfree;
 | 
					 | 
				
			||||||
  fsb->f_bavail = fsd.du_tfree;
 | 
					 | 
				
			||||||
  fsb->f_files  = (fsd.du_isize - 2) * fsd.du_inopb;
 | 
					 | 
				
			||||||
  fsb->f_ffree  = fsd.du_tinode;
 | 
					 | 
				
			||||||
  fsb->f_favail  = fsd.du_tinode;
 | 
					 | 
				
			||||||
  fsb->f_fsid.val[0] = fsd.du_site;
 | 
					 | 
				
			||||||
  fsb->f_fsid.val[1] = fsd.du_pckno;
 | 
					 | 
				
			||||||
  return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* _AIX && _I386 */
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										22
									
								
								gl/fsusage.h
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								gl/fsusage.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,20 +1,20 @@
 | 
				
			||||||
/* fsusage.h -- declarations for file system space usage info
 | 
					/* fsusage.h -- declarations for file system space usage info
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2013 Free Software
 | 
					   Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation, either version 3 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Space usage statistics for a file system.  Blocks are 512-byte. */
 | 
					/* Space usage statistics for a file system.  Blocks are 512-byte. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,6 @@
 | 
				
			||||||
# define FSUSAGE_H_
 | 
					# define FSUSAGE_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# include <stdint.h>
 | 
					# include <stdint.h>
 | 
				
			||||||
# include <stdbool.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct fs_usage
 | 
					struct fs_usage
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -32,8 +31,7 @@ struct fs_usage
 | 
				
			||||||
  uintmax_t fsu_bavail;         /* Free blocks available to non-superuser. */
 | 
					  uintmax_t fsu_bavail;         /* Free blocks available to non-superuser. */
 | 
				
			||||||
  bool fsu_bavail_top_bit_set;  /* 1 if fsu_bavail represents a value < 0.  */
 | 
					  bool fsu_bavail_top_bit_set;  /* 1 if fsu_bavail represents a value < 0.  */
 | 
				
			||||||
  uintmax_t fsu_files;          /* Total file nodes. */
 | 
					  uintmax_t fsu_files;          /* Total file nodes. */
 | 
				
			||||||
  uintmax_t fsu_ffree;          /* Free file nodes to superuser. */
 | 
					  uintmax_t fsu_ffree;          /* Free file nodes. */
 | 
				
			||||||
  uintmax_t fsu_favail;         /* Free file nodes to non-superuser. */
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp);
 | 
					int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										37
									
								
								gl/ftell.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								gl/ftell.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,37 @@
 | 
				
			||||||
 | 
					/* An ftell() function that works around platform bugs.
 | 
				
			||||||
 | 
					   Copyright (C) 2007-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <limits.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					long
 | 
				
			||||||
 | 
					ftell (FILE *fp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /* Use the replacement ftello function with all its workarounds.  */
 | 
				
			||||||
 | 
					  off_t offset = ftello (fp);
 | 
				
			||||||
 | 
					  if (LONG_MIN <= offset && offset <= LONG_MAX)
 | 
				
			||||||
 | 
					    return /* (long) */ offset;
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = EOVERFLOW;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										157
									
								
								gl/ftello.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										157
									
								
								gl/ftello.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,157 @@
 | 
				
			||||||
 | 
					/* An ftello() function that works around platform bugs.
 | 
				
			||||||
 | 
					   Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include "intprops.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get lseek.  */
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "stdio-impl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					off_t
 | 
				
			||||||
 | 
					ftello (FILE *fp)
 | 
				
			||||||
 | 
					#undef ftello
 | 
				
			||||||
 | 
					#if !HAVE_FTELLO
 | 
				
			||||||
 | 
					# undef ftell
 | 
				
			||||||
 | 
					# define ftello ftell
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if _GL_WINDOWS_64_BIT_OFF_T
 | 
				
			||||||
 | 
					# undef ftello
 | 
				
			||||||
 | 
					# if HAVE__FTELLI64 /* msvc, mingw64 */
 | 
				
			||||||
 | 
					#  define ftello _ftelli64
 | 
				
			||||||
 | 
					# else /* mingw */
 | 
				
			||||||
 | 
					#  define ftello ftello64
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if FTELLO_BROKEN_AFTER_UNGETC /* macOS >= 10.15 */
 | 
				
			||||||
 | 
					  /* The system's ftello() is completely broken, because it calls __sflush,
 | 
				
			||||||
 | 
					     which makes side effects on the stream.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Handle non-seekable files first.  */
 | 
				
			||||||
 | 
					  if (fp->_file < 0 || fp->_seek == NULL)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = ESPIPE;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Determine the current offset, ignoring buffered and pushed-back bytes.  */
 | 
				
			||||||
 | 
					  off_t pos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (fp->_flags & __SOFF)
 | 
				
			||||||
 | 
					    pos = fp->_offset;
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      pos = fp->_seek (fp->_cookie, 0, SEEK_CUR);
 | 
				
			||||||
 | 
					      if (pos < 0)
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					      if (fp->_flags & __SOPT)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          fp->_offset = pos;
 | 
				
			||||||
 | 
					          fp->_flags |= __SOFF;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (fp->_flags & __SRD)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* Now consider buffered and pushed-back bytes from ungetc.  */
 | 
				
			||||||
 | 
					      if (fp->_ub._base != NULL)
 | 
				
			||||||
 | 
					        /* Considering the buffered bytes, we are at position
 | 
				
			||||||
 | 
					             pos - fp->_ur.
 | 
				
			||||||
 | 
					           Considering also the pushed-back bytes, we are at position
 | 
				
			||||||
 | 
					             pos - fp->_ur - fp->_r.  */
 | 
				
			||||||
 | 
					        pos = pos - fp->_ur - fp->_r;
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        /* Considering the buffered bytes, we are at position
 | 
				
			||||||
 | 
					             pos - fp->_r.  */
 | 
				
			||||||
 | 
					        pos = pos - fp->_r;
 | 
				
			||||||
 | 
					      if (pos < 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          errno = EIO;
 | 
				
			||||||
 | 
					          return -1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else if ((fp->_flags & __SWR) && fp->_p != NULL)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* Consider the buffered bytes.  */
 | 
				
			||||||
 | 
					      off_t buffered = fp->_p - fp->_bf._base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* Compute pos + buffered, with overflow check.  */
 | 
				
			||||||
 | 
					      off_t sum;
 | 
				
			||||||
 | 
					      if (! INT_ADD_OK (pos, buffered, &sum))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          errno = EOVERFLOW;
 | 
				
			||||||
 | 
					          return -1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      pos = sum;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return pos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if LSEEK_PIPE_BROKEN
 | 
				
			||||||
 | 
					  /* mingw gives bogus answers rather than failure on non-seekable files.  */
 | 
				
			||||||
 | 
					  if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */
 | 
				
			||||||
 | 
					  /* The Solaris stdio leaves the _IOREAD flag set after reading from a file
 | 
				
			||||||
 | 
					     reaches EOF and the program then starts writing to the file.  ftello
 | 
				
			||||||
 | 
					     gets confused by this.  */
 | 
				
			||||||
 | 
					  if (fp_->_flag & _IOWRT)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      off_t pos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* Call ftello nevertheless, for the side effects that it does on fp.  */
 | 
				
			||||||
 | 
					      ftello (fp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* Compute the file position ourselves.  */
 | 
				
			||||||
 | 
					      pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
 | 
				
			||||||
 | 
					      if (pos >= 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
 | 
				
			||||||
 | 
					            pos += fp_->_ptr - fp_->_base;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      return pos;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if defined __SL64 && defined __SCLE /* Cygwin */
 | 
				
			||||||
 | 
					  if ((fp->_flags & __SL64) == 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
 | 
				
			||||||
 | 
					         mode; but has an ftello that requires 64-bit mode.  */
 | 
				
			||||||
 | 
					      FILE *tmp = fopen ("/dev/null", "r");
 | 
				
			||||||
 | 
					      if (!tmp)
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					      fp->_flags |= __SL64;
 | 
				
			||||||
 | 
					      fp->_seek64 = tmp->_seek64;
 | 
				
			||||||
 | 
					      fclose (tmp);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return ftello (fp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,18 +0,0 @@
 | 
				
			||||||
/* An interface to read that retries after partial reads and interrupts.
 | 
					 | 
				
			||||||
   Copyright (C) 2002-2003, 2009-2013 Free Software Foundation, Inc.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					 | 
				
			||||||
   (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
   GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define FULL_READ
 | 
					 | 
				
			||||||
#include "full-write.c"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,24 +0,0 @@
 | 
				
			||||||
/* An interface to read() that reads all it is asked to read.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					 | 
				
			||||||
   (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
   GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
   along with this program; if not, read to the Free Software Foundation,
 | 
					 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stddef.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Read COUNT bytes at BUF to descriptor FD, retrying if interrupted
 | 
					 | 
				
			||||||
   or if partial reads occur.  Return the number of bytes successfully
 | 
					 | 
				
			||||||
   read, setting errno if that is less than COUNT.  errno = 0 means EOF.  */
 | 
					 | 
				
			||||||
extern size_t full_read (int fd, void *buf, size_t count);
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,79 +0,0 @@
 | 
				
			||||||
/* An interface to read and write that retries (if necessary) until complete.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   Copyright (C) 1993-1994, 1997-2006, 2009-2013 Free Software Foundation, Inc.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					 | 
				
			||||||
   (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
   GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <config.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Specification.  */
 | 
					 | 
				
			||||||
#ifdef FULL_READ
 | 
					 | 
				
			||||||
# include "full-read.h"
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
# include "full-write.h"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef FULL_READ
 | 
					 | 
				
			||||||
# include "safe-read.h"
 | 
					 | 
				
			||||||
# define safe_rw safe_read
 | 
					 | 
				
			||||||
# define full_rw full_read
 | 
					 | 
				
			||||||
# undef const
 | 
					 | 
				
			||||||
# define const /* empty */
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
# include "safe-write.h"
 | 
					 | 
				
			||||||
# define safe_rw safe_write
 | 
					 | 
				
			||||||
# define full_rw full_write
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef FULL_READ
 | 
					 | 
				
			||||||
/* Set errno to zero upon EOF.  */
 | 
					 | 
				
			||||||
# define ZERO_BYTE_TRANSFER_ERRNO 0
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
/* Some buggy drivers return 0 when one tries to write beyond
 | 
					 | 
				
			||||||
   a device's end.  (Example: Linux 1.2.13 on /dev/fd0.)
 | 
					 | 
				
			||||||
   Set errno to ENOSPC so they get a sensible diagnostic.  */
 | 
					 | 
				
			||||||
# define ZERO_BYTE_TRANSFER_ERRNO ENOSPC
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if
 | 
					 | 
				
			||||||
   interrupted or if a partial write(read) occurs.  Return the number
 | 
					 | 
				
			||||||
   of bytes transferred.
 | 
					 | 
				
			||||||
   When writing, set errno if fewer than COUNT bytes are written.
 | 
					 | 
				
			||||||
   When reading, if fewer than COUNT bytes are read, you must examine
 | 
					 | 
				
			||||||
   errno to distinguish failure from EOF (errno == 0).  */
 | 
					 | 
				
			||||||
size_t
 | 
					 | 
				
			||||||
full_rw (int fd, const void *buf, size_t count)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  size_t total = 0;
 | 
					 | 
				
			||||||
  const char *ptr = (const char *) buf;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  while (count > 0)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      size_t n_rw = safe_rw (fd, ptr, count);
 | 
					 | 
				
			||||||
      if (n_rw == (size_t) -1)
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      if (n_rw == 0)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
          errno = ZERO_BYTE_TRANSFER_ERRNO;
 | 
					 | 
				
			||||||
          break;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      total += n_rw;
 | 
					 | 
				
			||||||
      ptr += n_rw;
 | 
					 | 
				
			||||||
      count -= n_rw;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return total;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,20 +1,20 @@
 | 
				
			||||||
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2013 Free Software
 | 
					/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
   This file is part of the GNU C Library.
 | 
					   This file is part of the GNU C Library.
 | 
				
			||||||
   Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
 | 
					   Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _LIBC
 | 
					#ifndef _LIBC
 | 
				
			||||||
# include <config.h>
 | 
					# include <config.h>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
/* Get address information (partial implementation).
 | 
					/* Get address information (partial implementation).
 | 
				
			||||||
   Copyright (C) 1997, 2001-2002, 2004-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 1997, 2001-2002, 2004-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Contributed by Simon Josefsson <simon@josefsson.org>.
 | 
					   Contributed by Simon Josefsson <simon@josefsson.org>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software; you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3, or (at your option)
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
 | 
					/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
 | 
				
			||||||
   optimizes away the sa == NULL test below.  */
 | 
					   optimizes away the sa == NULL test below.  */
 | 
				
			||||||
| 
						 | 
					@ -39,8 +39,6 @@
 | 
				
			||||||
/* Get snprintf. */
 | 
					/* Get snprintf. */
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdbool.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "gettext.h"
 | 
					#include "gettext.h"
 | 
				
			||||||
#define _(String) gettext (String)
 | 
					#define _(String) gettext (String)
 | 
				
			||||||
#define N_(String) String
 | 
					#define N_(String) String
 | 
				
			||||||
| 
						 | 
					@ -54,7 +52,30 @@
 | 
				
			||||||
# define PF_UNSPEC 0
 | 
					# define PF_UNSPEC 0
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined _WIN32 || defined __WIN32__
 | 
					#if HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Override with cdecl calling convention.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					getaddrinfo (const char *restrict nodename,
 | 
				
			||||||
 | 
					             const char *restrict servname,
 | 
				
			||||||
 | 
					             const struct addrinfo *restrict hints,
 | 
				
			||||||
 | 
					             struct addrinfo **restrict res)
 | 
				
			||||||
 | 
					# undef getaddrinfo
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return getaddrinfo (nodename, servname, hints, res);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					freeaddrinfo (struct addrinfo *ai)
 | 
				
			||||||
 | 
					# undef freeaddrinfo
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  freeaddrinfo (ai);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if defined _WIN32 && !defined __CYGWIN__
 | 
				
			||||||
#  define WINDOWS_NATIVE
 | 
					#  define WINDOWS_NATIVE
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +83,17 @@
 | 
				
			||||||
# include "sockets.h"
 | 
					# include "sockets.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ifdef WINDOWS_NATIVE
 | 
					# ifdef WINDOWS_NATIVE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Don't assume that UNICODE is not defined.  */
 | 
				
			||||||
 | 
					#  undef GetModuleHandle
 | 
				
			||||||
 | 
					#  define GetModuleHandle GetModuleHandleA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#  if !(_WIN32_WINNT >= _WIN32_WINNT_WINXP)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Avoid warnings from gcc -Wcast-function-type.  */
 | 
				
			||||||
 | 
					#   define GetProcAddress \
 | 
				
			||||||
 | 
					     (void *) GetProcAddress
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
 | 
					typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
 | 
				
			||||||
                                        const struct addrinfo*,
 | 
					                                        const struct addrinfo*,
 | 
				
			||||||
                                        struct addrinfo**);
 | 
					                                        struct addrinfo**);
 | 
				
			||||||
| 
						 | 
					@ -107,6 +139,29 @@ use_win32_p (void)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return 1;
 | 
					  return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#  else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					use_win32_p (void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  static int done = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!done)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      done = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      gl_sockets_startup (SOCKETS_1_1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#   define getaddrinfo_ptr getaddrinfo
 | 
				
			||||||
 | 
					#   define freeaddrinfo_ptr freeaddrinfo
 | 
				
			||||||
 | 
					#   define getnameinfo_ptr getnameinfo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#  endif
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
| 
						 | 
					@ -133,6 +188,7 @@ getaddrinfo (const char *restrict nodename,
 | 
				
			||||||
             const char *restrict servname,
 | 
					             const char *restrict servname,
 | 
				
			||||||
             const struct addrinfo *restrict hints,
 | 
					             const struct addrinfo *restrict hints,
 | 
				
			||||||
             struct addrinfo **restrict res)
 | 
					             struct addrinfo **restrict res)
 | 
				
			||||||
 | 
					#undef getaddrinfo
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  struct addrinfo *tmp;
 | 
					  struct addrinfo *tmp;
 | 
				
			||||||
  int port = 0;
 | 
					  int port = 0;
 | 
				
			||||||
| 
						 | 
					@ -334,6 +390,7 @@ getaddrinfo (const char *restrict nodename,
 | 
				
			||||||
/* Free 'addrinfo' structure AI including associated storage.  */
 | 
					/* Free 'addrinfo' structure AI including associated storage.  */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
freeaddrinfo (struct addrinfo *ai)
 | 
					freeaddrinfo (struct addrinfo *ai)
 | 
				
			||||||
 | 
					#undef freeaddrinfo
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
# ifdef WINDOWS_NATIVE
 | 
					# ifdef WINDOWS_NATIVE
 | 
				
			||||||
  if (use_win32_p ())
 | 
					  if (use_win32_p ())
 | 
				
			||||||
| 
						 | 
					@ -360,6 +417,7 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
 | 
				
			||||||
             char *restrict node, socklen_t nodelen,
 | 
					             char *restrict node, socklen_t nodelen,
 | 
				
			||||||
             char *restrict service, socklen_t servicelen,
 | 
					             char *restrict service, socklen_t servicelen,
 | 
				
			||||||
             int flags)
 | 
					             int flags)
 | 
				
			||||||
 | 
					#undef getnameinfo
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
# ifdef WINDOWS_NATIVE
 | 
					# ifdef WINDOWS_NATIVE
 | 
				
			||||||
  if (use_win32_p ())
 | 
					  if (use_win32_p ())
 | 
				
			||||||
| 
						 | 
					@ -441,3 +499,5 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										147
									
								
								gl/getdelim.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								gl/getdelim.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,147 @@
 | 
				
			||||||
 | 
					/* getdelim.c --- Implementation of replacement getdelim function.
 | 
				
			||||||
 | 
					   Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2023 Free Software
 | 
				
			||||||
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Ported from glibc by Simon Josefsson. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
 | 
				
			||||||
 | 
					   optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below.  */
 | 
				
			||||||
 | 
					#define _GL_ARG_NONNULL(params)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <limits.h>
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef SSIZE_MAX
 | 
				
			||||||
 | 
					# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if USE_UNLOCKED_IO
 | 
				
			||||||
 | 
					# include "unlocked-io.h"
 | 
				
			||||||
 | 
					# define getc_maybe_unlocked(fp)        getc(fp)
 | 
				
			||||||
 | 
					#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
 | 
				
			||||||
 | 
					# undef flockfile
 | 
				
			||||||
 | 
					# undef funlockfile
 | 
				
			||||||
 | 
					# define flockfile(x) ((void) 0)
 | 
				
			||||||
 | 
					# define funlockfile(x) ((void) 0)
 | 
				
			||||||
 | 
					# define getc_maybe_unlocked(fp)        getc(fp)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define getc_maybe_unlocked(fp)        getc_unlocked(fp)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					alloc_failed (void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					  /* Avoid errno problem without using the realloc module; see:
 | 
				
			||||||
 | 
					     https://lists.gnu.org/r/bug-gnulib/2016-08/msg00025.html  */
 | 
				
			||||||
 | 
					  errno = ENOMEM;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
 | 
				
			||||||
 | 
					   NUL-terminate it).  *LINEPTR is a pointer returned from malloc (or
 | 
				
			||||||
 | 
					   NULL), pointing to *N characters of space.  It is realloc'ed as
 | 
				
			||||||
 | 
					   necessary.  Returns the number of characters read (not including
 | 
				
			||||||
 | 
					   the null terminator), or -1 on error or EOF.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ssize_t
 | 
				
			||||||
 | 
					getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  ssize_t result;
 | 
				
			||||||
 | 
					  size_t cur_len = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (lineptr == NULL || n == NULL || fp == NULL)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = EINVAL;
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  flockfile (fp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (*lineptr == NULL || *n == 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      char *new_lineptr;
 | 
				
			||||||
 | 
					      *n = 120;
 | 
				
			||||||
 | 
					      new_lineptr = (char *) realloc (*lineptr, *n);
 | 
				
			||||||
 | 
					      if (new_lineptr == NULL)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          alloc_failed ();
 | 
				
			||||||
 | 
					          result = -1;
 | 
				
			||||||
 | 
					          goto unlock_return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      *lineptr = new_lineptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (;;)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      i = getc_maybe_unlocked (fp);
 | 
				
			||||||
 | 
					      if (i == EOF)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          result = -1;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /* Make enough space for len+1 (for final NUL) bytes.  */
 | 
				
			||||||
 | 
					      if (cur_len + 1 >= *n)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          size_t needed_max =
 | 
				
			||||||
 | 
					            SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
 | 
				
			||||||
 | 
					          size_t needed = 2 * *n + 1;   /* Be generous. */
 | 
				
			||||||
 | 
					          char *new_lineptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          if (needed_max < needed)
 | 
				
			||||||
 | 
					            needed = needed_max;
 | 
				
			||||||
 | 
					          if (cur_len + 1 >= needed)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              result = -1;
 | 
				
			||||||
 | 
					              errno = EOVERFLOW;
 | 
				
			||||||
 | 
					              goto unlock_return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          new_lineptr = (char *) realloc (*lineptr, needed);
 | 
				
			||||||
 | 
					          if (new_lineptr == NULL)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              alloc_failed ();
 | 
				
			||||||
 | 
					              result = -1;
 | 
				
			||||||
 | 
					              goto unlock_return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          *lineptr = new_lineptr;
 | 
				
			||||||
 | 
					          *n = needed;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      (*lineptr)[cur_len] = i;
 | 
				
			||||||
 | 
					      cur_len++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (i == delimiter)
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  (*lineptr)[cur_len] = '\0';
 | 
				
			||||||
 | 
					  result = cur_len ? cur_len : result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 unlock_return:
 | 
				
			||||||
 | 
					  funlockfile (fp); /* doesn't set errno */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										124
									
								
								gl/getdtablesize.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								gl/getdtablesize.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,124 @@
 | 
				
			||||||
 | 
					/* getdtablesize() function: Return maximum possible file descriptor value + 1.
 | 
				
			||||||
 | 
					   Copyright (C) 2008-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   Written by Bruno Haible <bruno@clisp.org>, 2008.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Specification.  */
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined _WIN32 && ! defined __CYGWIN__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 | 
				
			||||||
 | 
					#  include "msvc-inval.h"
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					_setmaxstdio_nothrow (int newmax)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TRY_MSVC_INVAL
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      result = _setmaxstdio (newmax);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  CATCH_MSVC_INVAL
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      result = -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  DONE_MSVC_INVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define _setmaxstdio_nothrow _setmaxstdio
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Cache for the previous getdtablesize () result.  Safe to cache because
 | 
				
			||||||
 | 
					   Windows also lacks setrlimit.  */
 | 
				
			||||||
 | 
					static int dtablesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					getdtablesize (void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (dtablesize == 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      /* We are looking for the number N such that the valid file descriptors
 | 
				
			||||||
 | 
					         are 0..N-1.  It can be obtained through a loop as follows:
 | 
				
			||||||
 | 
					           {
 | 
				
			||||||
 | 
					             int fd;
 | 
				
			||||||
 | 
					             for (fd = 3; fd < 65536; fd++)
 | 
				
			||||||
 | 
					               if (dup2 (0, fd) == -1)
 | 
				
			||||||
 | 
					                 break;
 | 
				
			||||||
 | 
					             return fd;
 | 
				
			||||||
 | 
					           }
 | 
				
			||||||
 | 
					         On Windows XP, the result is 2048.
 | 
				
			||||||
 | 
					         The drawback of this loop is that it allocates memory for a libc
 | 
				
			||||||
 | 
					         internal array that is never freed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         The number N can also be obtained as the upper bound for
 | 
				
			||||||
 | 
					         _getmaxstdio ().  _getmaxstdio () returns the maximum number of open
 | 
				
			||||||
 | 
					         FILE objects.  The sanity check in _setmaxstdio reveals the maximum
 | 
				
			||||||
 | 
					         number of file descriptors.  This too allocates memory, but it is
 | 
				
			||||||
 | 
					         freed when we call _setmaxstdio with the original value.  */
 | 
				
			||||||
 | 
					      int orig_max_stdio = _getmaxstdio ();
 | 
				
			||||||
 | 
					      unsigned int bound;
 | 
				
			||||||
 | 
					      for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
 | 
				
			||||||
 | 
					        ;
 | 
				
			||||||
 | 
					      _setmaxstdio_nothrow (orig_max_stdio);
 | 
				
			||||||
 | 
					      dtablesize = bound;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  return dtablesize;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# include <limits.h>
 | 
				
			||||||
 | 
					# include <sys/resource.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifndef RLIM_SAVED_CUR
 | 
				
			||||||
 | 
					#  define RLIM_SAVED_CUR RLIM_INFINITY
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# ifndef RLIM_SAVED_MAX
 | 
				
			||||||
 | 
					#  define RLIM_SAVED_MAX RLIM_INFINITY
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifdef __CYGWIN__
 | 
				
			||||||
 | 
					  /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it
 | 
				
			||||||
 | 
					     hits the compile-time constant hard limit of 3200.  We might as
 | 
				
			||||||
 | 
					     well just report the hard limit.  */
 | 
				
			||||||
 | 
					#  define rlim_cur rlim_max
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					getdtablesize (void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  struct rlimit lim;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (getrlimit (RLIMIT_NOFILE, &lim) == 0
 | 
				
			||||||
 | 
					      && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX
 | 
				
			||||||
 | 
					      && lim.rlim_cur != RLIM_INFINITY
 | 
				
			||||||
 | 
					      && lim.rlim_cur != RLIM_SAVED_CUR
 | 
				
			||||||
 | 
					      && lim.rlim_cur != RLIM_SAVED_MAX)
 | 
				
			||||||
 | 
					    return lim.rlim_cur;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return INT_MAX;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -1,26 +1,26 @@
 | 
				
			||||||
/* gethostname emulation for SysV and POSIX.1.
 | 
					/* gethostname emulation for SysV and POSIX.1.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1992, 2003, 2006, 2008-2013 Free Software Foundation, Inc.
 | 
					   Copyright (C) 1992, 2003, 2006, 2008-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* David MacKenzie <djm@gnu.ai.mit.edu>
 | 
					/* David MacKenzie <djm@gnu.ai.mit.edu>
 | 
				
			||||||
   Windows port by Simon Josefsson <simon@josefsson.org> */
 | 
					   Windows port by Simon Josefsson <simon@josefsson.org> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
 | 
					#if !(defined _WIN32 && !defined __CYGWIN__)
 | 
				
			||||||
/* Unix API.  */
 | 
					/* Unix API.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Specification.  */
 | 
					/* Specification.  */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										27
									
								
								gl/getline.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								gl/getline.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					/* getline.c --- Implementation of replacement getline function.
 | 
				
			||||||
 | 
					   Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Written by Simon Josefsson. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ssize_t
 | 
				
			||||||
 | 
					getline (char **lineptr, size_t *n, FILE *stream)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return getdelim (lineptr, n, '\n', stream);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										171
									
								
								gl/getloadavg.c
									
										
									
									
									
								
							
							
						
						
									
										171
									
								
								gl/getloadavg.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
/* Get the system load averages.
 | 
					/* Get the system load averages.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2013 Free Software
 | 
					   Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2023 Free Software
 | 
				
			||||||
   Foundation, Inc.
 | 
					   Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   NOTE: The canonical source of this file is maintained with gnulib.
 | 
					   NOTE: The canonical source of this file is maintained with gnulib.
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU General Public License as published by
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   the Free Software Foundation, either version 3 of the License, or
 | 
				
			||||||
   (at your option) any later version.
 | 
					   (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This program is distributed in the hope that it will be useful,
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Compile-time symbols that this file uses:
 | 
					/* Compile-time symbols that this file uses:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,29 +47,25 @@
 | 
				
			||||||
   N_NAME_POINTER               The nlist n_name element is a pointer,
 | 
					   N_NAME_POINTER               The nlist n_name element is a pointer,
 | 
				
			||||||
                                not an array.
 | 
					                                not an array.
 | 
				
			||||||
   HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
 | 
					   HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
 | 
				
			||||||
   LINUX_LDAV_FILE              [__linux__, __CYGWIN__]: File containing
 | 
					   LINUX_LDAV_FILE              [__linux__, __ANDROID__, __CYGWIN__]: File
 | 
				
			||||||
                                load averages.
 | 
					                                containing load averages.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Specific system predefines this file uses, aside from setting
 | 
					   Specific system predefines this file uses, aside from setting
 | 
				
			||||||
   default values if not emacs:
 | 
					   default values if not emacs:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   apollo
 | 
					   apollo
 | 
				
			||||||
   BSD                          Real BSD, not just BSD-like.
 | 
					   BSD                          Real BSD, not just BSD-like.
 | 
				
			||||||
   convex
 | 
					 | 
				
			||||||
   DGUX
 | 
					   DGUX
 | 
				
			||||||
   eunice                       UNIX emulator under VMS.
 | 
					   eunice                       UNIX emulator under VMS.
 | 
				
			||||||
   hpux
 | 
					   hpux
 | 
				
			||||||
   __MSDOS__                    No-op for MSDOS.
 | 
					   __MSDOS__                    No-op for MSDOS.
 | 
				
			||||||
   NeXT
 | 
					   NeXT
 | 
				
			||||||
   sgi
 | 
					   sgi
 | 
				
			||||||
   sequent                      Sequent Dynix 3.x.x (BSD)
 | 
					 | 
				
			||||||
   _SEQUENT_                    Sequent DYNIX/ptx 1.x.x (SYSV)
 | 
					 | 
				
			||||||
   sony_news                    NEWS-OS (works at least for 4.1C)
 | 
					 | 
				
			||||||
   UMAX
 | 
					   UMAX
 | 
				
			||||||
   UMAX4_3
 | 
					   UMAX4_3
 | 
				
			||||||
   VMS
 | 
					   VMS
 | 
				
			||||||
   WINDOWS32                    No-op for Windows95/NT.
 | 
					   _WIN32                       Native Windows (possibly also defined on Cygwin)
 | 
				
			||||||
   __linux__                    Linux: assumes /proc file system mounted.
 | 
					   __linux__, __ANDROID__       Linux: assumes /proc file system mounted.
 | 
				
			||||||
                                Support from Michael K. Johnson.
 | 
					                                Support from Michael K. Johnson.
 | 
				
			||||||
   __CYGWIN__                   Cygwin emulates linux /proc/loadavg.
 | 
					   __CYGWIN__                   Cygwin emulates linux /proc/loadavg.
 | 
				
			||||||
   __NetBSD__                   NetBSD: assumes /kern file system mounted.
 | 
					   __NetBSD__                   NetBSD: assumes /kern file system mounted.
 | 
				
			||||||
| 
						 | 
					@ -86,7 +82,6 @@
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <stdbool.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# include <sys/types.h>
 | 
					# include <sys/types.h>
 | 
				
			||||||
| 
						 | 
					@ -97,9 +92,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# include "intprops.h"
 | 
					# include "intprops.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if !defined (BSD) && defined (ultrix)
 | 
					# if defined _WIN32 && ! defined __CYGWIN__ && ! defined WINDOWS32
 | 
				
			||||||
/* Ultrix behaves like BSD on Vaxen.  */
 | 
					#  define WINDOWS32
 | 
				
			||||||
#  define BSD
 | 
					 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ifdef NeXT
 | 
					# ifdef NeXT
 | 
				
			||||||
| 
						 | 
					@ -141,10 +135,6 @@
 | 
				
			||||||
#  define MORE_BSD
 | 
					#  define MORE_BSD
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if defined (ultrix) && defined (mips)
 | 
					 | 
				
			||||||
#  define decstation
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# if defined (__SVR4) && !defined (SVR4)
 | 
					# if defined (__SVR4) && !defined (SVR4)
 | 
				
			||||||
#  define SVR4
 | 
					#  define SVR4
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
| 
						 | 
					@ -168,13 +158,6 @@
 | 
				
			||||||
#  include <sys/table.h>
 | 
					#  include <sys/table.h>
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* UTek's /bin/cc on the 4300 has no architecture specific cpp define by
 | 
					 | 
				
			||||||
   default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>.  Combine
 | 
					 | 
				
			||||||
   that with a couple of other things and we'll have a unique match.  */
 | 
					 | 
				
			||||||
# if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
 | 
					 | 
				
			||||||
#  define tek4300                       /* Define by emacs, but not by other users.  */
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars.  */
 | 
					/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars.  */
 | 
				
			||||||
# ifndef LOAD_AVE_TYPE
 | 
					# ifndef LOAD_AVE_TYPE
 | 
				
			||||||
| 
						 | 
					@ -187,14 +170,6 @@
 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					#   define LOAD_AVE_TYPE long
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  ifdef decstation
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  ifdef _SEQUENT_
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  ifdef sgi
 | 
					#  ifdef sgi
 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					#   define LOAD_AVE_TYPE long
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
| 
						 | 
					@ -203,41 +178,14 @@
 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					#   define LOAD_AVE_TYPE long
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  ifdef sony_news
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  ifdef sequent
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  ifdef OSF_ALPHA
 | 
					#  ifdef OSF_ALPHA
 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					#   define LOAD_AVE_TYPE long
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  if defined (ardent) && defined (titan)
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  ifdef tek4300
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  if defined (alliant) && defined (i860) /* Alliant FX/2800 */
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  if defined _AIX && ! defined HAVE_LIBPERFSTAT
 | 
					#  if defined _AIX && ! defined HAVE_LIBPERFSTAT
 | 
				
			||||||
#   define LOAD_AVE_TYPE long
 | 
					#   define LOAD_AVE_TYPE long
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  ifdef convex
 | 
					 | 
				
			||||||
#   define LOAD_AVE_TYPE double
 | 
					 | 
				
			||||||
#   ifndef LDAV_CVT
 | 
					 | 
				
			||||||
#    define LDAV_CVT(n) (n)
 | 
					 | 
				
			||||||
#   endif
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# endif /* No LOAD_AVE_TYPE.  */
 | 
					# endif /* No LOAD_AVE_TYPE.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ifdef OSF_ALPHA
 | 
					# ifdef OSF_ALPHA
 | 
				
			||||||
| 
						 | 
					@ -247,13 +195,6 @@
 | 
				
			||||||
#  define FSCALE 1024.0
 | 
					#  define FSCALE 1024.0
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
 | 
					 | 
				
			||||||
/* <sys/param.h> defines an incorrect value for FSCALE on an
 | 
					 | 
				
			||||||
   Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu.  */
 | 
					 | 
				
			||||||
#  undef FSCALE
 | 
					 | 
				
			||||||
#  define FSCALE 100.0
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ifndef FSCALE
 | 
					# ifndef FSCALE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -263,25 +204,17 @@
 | 
				
			||||||
#   define FSCALE 2048.0
 | 
					#   define FSCALE 2048.0
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  if defined (MIPS) || defined (SVR4) || defined (decstation)
 | 
					#  if defined (MIPS) || defined (SVR4)
 | 
				
			||||||
#   define FSCALE 256
 | 
					#   define FSCALE 256
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  if defined (sgi) || defined (sequent)
 | 
					#  if defined (sgi)
 | 
				
			||||||
/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
 | 
					/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
 | 
				
			||||||
   above under #ifdef MIPS.  But we want the sgi value.  */
 | 
					   above under #ifdef MIPS.  But we want the sgi value.  */
 | 
				
			||||||
#   undef FSCALE
 | 
					#   undef FSCALE
 | 
				
			||||||
#   define FSCALE 1000.0
 | 
					#   define FSCALE 1000.0
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  if defined (ardent) && defined (titan)
 | 
					 | 
				
			||||||
#   define FSCALE 65536.0
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  ifdef tek4300
 | 
					 | 
				
			||||||
#   define FSCALE 100.0
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  if defined _AIX && !defined HAVE_LIBPERFSTAT
 | 
					#  if defined _AIX && !defined HAVE_LIBPERFSTAT
 | 
				
			||||||
#   define FSCALE 65536.0
 | 
					#   define FSCALE 65536.0
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
| 
						 | 
					@ -303,28 +236,22 @@
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if !defined (KERNEL_FILE) && defined (sequent)
 | 
					 | 
				
			||||||
#  define KERNEL_FILE "/dynix"
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# if !defined (KERNEL_FILE) && defined (hpux)
 | 
					# if !defined (KERNEL_FILE) && defined (hpux)
 | 
				
			||||||
#  define KERNEL_FILE "/hp-ux"
 | 
					#  define KERNEL_FILE "/hp-ux"
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if !defined (KERNEL_FILE) && (defined (_SEQUENT_) || defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)))
 | 
					# if !defined (KERNEL_FILE) && (defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi))
 | 
				
			||||||
#  define KERNEL_FILE "/unix"
 | 
					#  define KERNEL_FILE "/unix"
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if !defined (LDAV_SYMBOL) && defined (alliant)
 | 
					# if !defined (LDAV_SYMBOL) && (defined (hpux) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
 | 
				
			||||||
#  define LDAV_SYMBOL "_Loadavg"
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# if !defined (LDAV_SYMBOL) && ((defined (hpux) && !defined (hp9000s300)) || defined (_SEQUENT_) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
 | 
					 | 
				
			||||||
#  define LDAV_SYMBOL "avenrun"
 | 
					#  define LDAV_SYMBOL "avenrun"
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ifdef HAVE_UNISTD_H
 | 
				
			||||||
#  include <unistd.h>
 | 
					#  include <unistd.h>
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* LOAD_AVE_TYPE should only get defined if we're going to use the
 | 
					/* LOAD_AVE_TYPE should only get defined if we're going to use the
 | 
				
			||||||
   nlist method.  */
 | 
					   nlist method.  */
 | 
				
			||||||
| 
						 | 
					@ -335,7 +262,7 @@
 | 
				
			||||||
# ifdef LOAD_AVE_TYPE
 | 
					# ifdef LOAD_AVE_TYPE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  ifndef __VMS
 | 
					#  ifndef __VMS
 | 
				
			||||||
#   ifndef __linux__
 | 
					#   if !(defined __linux__ || defined __ANDROID__)
 | 
				
			||||||
#    ifndef NLIST_STRUCT
 | 
					#    ifndef NLIST_STRUCT
 | 
				
			||||||
#     include <a.out.h>
 | 
					#     include <a.out.h>
 | 
				
			||||||
#    else /* NLIST_STRUCT */
 | 
					#    else /* NLIST_STRUCT */
 | 
				
			||||||
| 
						 | 
					@ -358,7 +285,7 @@
 | 
				
			||||||
#    ifndef LDAV_SYMBOL
 | 
					#    ifndef LDAV_SYMBOL
 | 
				
			||||||
#     define LDAV_SYMBOL "_avenrun"
 | 
					#     define LDAV_SYMBOL "_avenrun"
 | 
				
			||||||
#    endif /* LDAV_SYMBOL */
 | 
					#    endif /* LDAV_SYMBOL */
 | 
				
			||||||
#   endif /* __linux__ */
 | 
					#   endif /* __linux__ || __ANDROID__ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  else /* __VMS */
 | 
					#  else /* __VMS */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -431,7 +358,8 @@
 | 
				
			||||||
#  include <sys/dg_sys_info.h>
 | 
					#  include <sys/dg_sys_info.h>
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5        \
 | 
					# if (defined __linux__ || defined __ANDROID__ \
 | 
				
			||||||
 | 
					      || defined __CYGWIN__ || defined SUNOS_5 \
 | 
				
			||||||
      || (defined LOAD_AVE_TYPE && ! defined __VMS))
 | 
					      || (defined LOAD_AVE_TYPE && ! defined __VMS))
 | 
				
			||||||
#  include <fcntl.h>
 | 
					#  include <fcntl.h>
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
| 
						 | 
					@ -460,7 +388,7 @@ static bool getloadavg_initialized;
 | 
				
			||||||
/* Offset in kmem to seek to read load average, or 0 means invalid.  */
 | 
					/* Offset in kmem to seek to read load average, or 0 means invalid.  */
 | 
				
			||||||
static long offset;
 | 
					static long offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  if ! defined __VMS && ! defined sgi && ! defined __linux__
 | 
					#  if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined __ANDROID__)
 | 
				
			||||||
static struct nlist name_list[2];
 | 
					static struct nlist name_list[2];
 | 
				
			||||||
#  endif
 | 
					#  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -495,17 +423,17 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
  int saved_errno;
 | 
					  int saved_errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  kc = kstat_open ();
 | 
					  kc = kstat_open ();
 | 
				
			||||||
  if (kc == 0)
 | 
					  if (kc == NULL)
 | 
				
			||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
  ksp = kstat_lookup (kc, "unix", 0, "system_misc");
 | 
					  ksp = kstat_lookup (kc, "unix", 0, "system_misc");
 | 
				
			||||||
  if (ksp == 0)
 | 
					  if (ksp == NULL)
 | 
				
			||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
  if (kstat_read (kc, ksp, 0) == -1)
 | 
					  if (kstat_read (kc, ksp, 0) == -1)
 | 
				
			||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  kn = kstat_data_lookup (ksp, "avenrun_1min");
 | 
					  kn = kstat_data_lookup (ksp, "avenrun_1min");
 | 
				
			||||||
  if (kn == 0)
 | 
					  if (kn == NULL)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      /* Return -1 if no load average information is available.  */
 | 
					      /* Return -1 if no load average information is available.  */
 | 
				
			||||||
      nelem = 0;
 | 
					      nelem = 0;
 | 
				
			||||||
| 
						 | 
					@ -518,14 +446,14 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
  if (nelem >= 2)
 | 
					  if (nelem >= 2)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      kn = kstat_data_lookup (ksp, "avenrun_5min");
 | 
					      kn = kstat_data_lookup (ksp, "avenrun_5min");
 | 
				
			||||||
      if (kn != 0)
 | 
					      if (kn != NULL)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          loadavg[elem++] = (double) kn->value.ul / FSCALE;
 | 
					          loadavg[elem++] = (double) kn->value.ul / FSCALE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (nelem >= 3)
 | 
					          if (nelem >= 3)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              kn = kstat_data_lookup (ksp, "avenrun_15min");
 | 
					              kn = kstat_data_lookup (ksp, "avenrun_15min");
 | 
				
			||||||
              if (kn != 0)
 | 
					              if (kn != NULL)
 | 
				
			||||||
                loadavg[elem++] = (double) kn->value.ul / FSCALE;
 | 
					                loadavg[elem++] = (double) kn->value.ul / FSCALE;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -570,8 +498,8 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__))
 | 
					# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__)
 | 
				
			||||||
                                              /* Linux without glibc, Cygwin */
 | 
					                                      /* Linux without glibc, Android, Cygwin */
 | 
				
			||||||
#  define LDAV_DONE
 | 
					#  define LDAV_DONE
 | 
				
			||||||
#  undef LOAD_AVE_TYPE
 | 
					#  undef LOAD_AVE_TYPE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -583,7 +511,7 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
  char const *ptr = ldavgbuf;
 | 
					  char const *ptr = ldavgbuf;
 | 
				
			||||||
  int fd, count, saved_errno;
 | 
					  int fd, count, saved_errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  fd = open (LINUX_LDAV_FILE, O_RDONLY);
 | 
					  fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC);
 | 
				
			||||||
  if (fd == -1)
 | 
					  if (fd == -1)
 | 
				
			||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
  count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
 | 
					  count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
 | 
				
			||||||
| 
						 | 
					@ -621,12 +549,12 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
        for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
 | 
					        for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
 | 
				
			||||||
          numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
 | 
					          numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      loadavg[elem++] = numerator / denominator;
 | 
					      loadavg[elem] = numerator / denominator;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return elem;
 | 
					  return elem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# endif /* __linux__ || __CYGWIN__ */
 | 
					# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if !defined (LDAV_DONE) && defined (__NetBSD__)          /* NetBSD < 0.9 */
 | 
					# if !defined (LDAV_DONE) && defined (__NetBSD__)          /* NetBSD < 0.9 */
 | 
				
			||||||
#  define LDAV_DONE
 | 
					#  define LDAV_DONE
 | 
				
			||||||
| 
						 | 
					@ -638,15 +566,22 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  unsigned long int load_ave[3], scale;
 | 
					  unsigned long int load_ave[3], scale;
 | 
				
			||||||
  int count;
 | 
					  int count;
 | 
				
			||||||
  FILE *fp;
 | 
					  char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
 | 
				
			||||||
 | 
					  int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC);
 | 
				
			||||||
  fp = fopen (NETBSD_LDAV_FILE, "r");
 | 
					  if (fd < 0)
 | 
				
			||||||
  if (fp == NULL)
 | 
					    return fd;
 | 
				
			||||||
 | 
					  int nread = read (fd, readbuf, sizeof readbuf - 1);
 | 
				
			||||||
 | 
					  int err = errno;
 | 
				
			||||||
 | 
					  close (fd);
 | 
				
			||||||
 | 
					  if (nread < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      errno = err;
 | 
				
			||||||
      return -1;
 | 
					      return -1;
 | 
				
			||||||
  count = fscanf (fp, "%lu %lu %lu %lu\n",
 | 
					    }
 | 
				
			||||||
 | 
					  readbuf[nread] = '\0';
 | 
				
			||||||
 | 
					  count = sscanf (readbuf, "%lu %lu %lu %lu\n",
 | 
				
			||||||
                  &load_ave[0], &load_ave[1], &load_ave[2],
 | 
					                  &load_ave[0], &load_ave[1], &load_ave[2],
 | 
				
			||||||
                  &scale);
 | 
					                  &scale);
 | 
				
			||||||
  (void) fclose (fp);
 | 
					 | 
				
			||||||
  if (count != 4)
 | 
					  if (count != 4)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      errno = ENOTSUP;
 | 
					      errno = ENOTSUP;
 | 
				
			||||||
| 
						 | 
					@ -915,7 +850,7 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#   ifndef SUNOS_5
 | 
					#   ifndef SUNOS_5
 | 
				
			||||||
      if (
 | 
					      if (
 | 
				
			||||||
#    if !(defined (_AIX) && !defined (ps2))
 | 
					#    if !defined (_AIX)
 | 
				
			||||||
          nlist (KERNEL_FILE, name_list)
 | 
					          nlist (KERNEL_FILE, name_list)
 | 
				
			||||||
#    else  /* _AIX */
 | 
					#    else  /* _AIX */
 | 
				
			||||||
          knlist (name_list, 1, sizeof (name_list[0]))
 | 
					          knlist (name_list, 1, sizeof (name_list[0]))
 | 
				
			||||||
| 
						 | 
					@ -940,33 +875,17 @@ getloadavg (double loadavg[], int nelem)
 | 
				
			||||||
  if (!getloadavg_initialized)
 | 
					  if (!getloadavg_initialized)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
#  ifndef SUNOS_5
 | 
					#  ifndef SUNOS_5
 | 
				
			||||||
      /* Set the channel to close on exec, so it does not
 | 
					 | 
				
			||||||
         litter any child's descriptor table.  */
 | 
					 | 
				
			||||||
#   ifndef O_CLOEXEC
 | 
					 | 
				
			||||||
#    define O_CLOEXEC 0
 | 
					 | 
				
			||||||
#   endif
 | 
					 | 
				
			||||||
      int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
 | 
					      int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
 | 
				
			||||||
      if (0 <= fd)
 | 
					      if (0 <= fd)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
#   if F_DUPFD_CLOEXEC
 | 
					 | 
				
			||||||
          if (fd <= STDERR_FILENO)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
 | 
					 | 
				
			||||||
              close (fd);
 | 
					 | 
				
			||||||
              fd = fd1;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
#   endif
 | 
					 | 
				
			||||||
          if (0 <= fd)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
          channel = fd;
 | 
					          channel = fd;
 | 
				
			||||||
          getloadavg_initialized = true;
 | 
					          getloadavg_initialized = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#  else /* SUNOS_5 */
 | 
					#  else /* SUNOS_5 */
 | 
				
			||||||
      /* We pass 0 for the kernel, corefile, and swapfile names
 | 
					      /* We pass 0 for the kernel, corefile, and swapfile names
 | 
				
			||||||
         to use the currently running kernel.  */
 | 
					         to use the currently running kernel.  */
 | 
				
			||||||
      kd = kvm_open (0, 0, 0, O_RDONLY, 0);
 | 
					      kd = kvm_open (0, 0, 0, O_RDONLY, 0);
 | 
				
			||||||
      if (kd != 0)
 | 
					      if (kd != NULL)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          /* nlist the currently running kernel.  */
 | 
					          /* nlist the currently running kernel.  */
 | 
				
			||||||
          kvm_nlist (kd, name_list);
 | 
					          kvm_nlist (kd, name_list);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										66
									
								
								gl/getopt-cdefs.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								gl/getopt-cdefs.in.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,66 @@
 | 
				
			||||||
 | 
					/* getopt-on-non-glibc compatibility macros.
 | 
				
			||||||
 | 
					   Copyright (C) 1989-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   This file is part of gnulib.
 | 
				
			||||||
 | 
					   Unlike most of the getopt implementation, it is NOT shared
 | 
				
			||||||
 | 
					   with the GNU C Library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GETOPT_CDEFS_H
 | 
				
			||||||
 | 
					#define _GETOPT_CDEFS_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This header should not be used directly; include getopt.h or
 | 
				
			||||||
 | 
					   unistd.h instead.  It does not have a protective #error, because
 | 
				
			||||||
 | 
					   the guard macro for getopt.h in gnulib is not fixed.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
 | 
				
			||||||
 | 
					   a number of the internal macros supplied to GNU libc's headers by
 | 
				
			||||||
 | 
					   sys/cdefs.h.  Provide fallback definitions for all of them.  */
 | 
				
			||||||
 | 
					#if @HAVE_SYS_CDEFS_H@
 | 
				
			||||||
 | 
					# include <sys/cdefs.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __BEGIN_DECLS
 | 
				
			||||||
 | 
					# ifdef __cplusplus
 | 
				
			||||||
 | 
					#  define __BEGIN_DECLS extern "C" {
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __BEGIN_DECLS /* nothing */
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef __END_DECLS
 | 
				
			||||||
 | 
					# ifdef __cplusplus
 | 
				
			||||||
 | 
					#  define __END_DECLS }
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __END_DECLS /* nothing */
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __GNUC_PREREQ
 | 
				
			||||||
 | 
					# if defined __GNUC__ && defined __GNUC_VERSION__
 | 
				
			||||||
 | 
					# define __GNUC_PREREQ(maj, min) \
 | 
				
			||||||
 | 
					        ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __GNUC_PREREQ(maj, min) 0
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __THROW
 | 
				
			||||||
 | 
					# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
 | 
				
			||||||
 | 
					#  define __THROW       throw ()
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __THROW
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GETOPT_CDEFS_H */
 | 
				
			||||||
							
								
								
									
										96
									
								
								gl/getopt-core.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								gl/getopt-core.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,96 @@
 | 
				
			||||||
 | 
					/* Declarations for getopt (basic, portable features only).
 | 
				
			||||||
 | 
					   Copyright (C) 1989-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   This file is part of the GNU C Library and is also part of gnulib.
 | 
				
			||||||
 | 
					   Patches to this file should be submitted to both projects.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GETOPT_CORE_H
 | 
				
			||||||
 | 
					#define _GETOPT_CORE_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This header should not be used directly; include getopt.h or
 | 
				
			||||||
 | 
					   unistd.h instead.  Unlike most bits headers, it does not have
 | 
				
			||||||
 | 
					   a protective #error, because the guard macro for getopt.h in
 | 
				
			||||||
 | 
					   gnulib is not fixed.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* For communication from 'getopt' to the caller.
 | 
				
			||||||
 | 
					   When 'getopt' finds an option that takes an argument,
 | 
				
			||||||
 | 
					   the argument value is returned here.
 | 
				
			||||||
 | 
					   Also, when 'ordering' is RETURN_IN_ORDER,
 | 
				
			||||||
 | 
					   each non-option ARGV-element is returned here.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern char *optarg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Index in ARGV of the next element to be scanned.
 | 
				
			||||||
 | 
					   This is used for communication to and from the caller
 | 
				
			||||||
 | 
					   and for communication between successive calls to 'getopt'.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   On entry to 'getopt', zero means this is the first call; initialize.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   When 'getopt' returns -1, this is the index of the first of the
 | 
				
			||||||
 | 
					   non-option elements that the caller should itself scan.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Otherwise, 'optind' communicates from one call to the next
 | 
				
			||||||
 | 
					   how much of ARGV has been scanned so far.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern int optind;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Callers store zero here to inhibit the error message 'getopt' prints
 | 
				
			||||||
 | 
					   for unrecognized options.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern int opterr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Set to an option character which was unrecognized.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern int optopt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Get definitions and prototypes for functions to process the
 | 
				
			||||||
 | 
					   arguments in ARGV (ARGC of them, minus the program name) for
 | 
				
			||||||
 | 
					   options given in OPTS.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Return the option character from OPTS just read.  Return -1 when
 | 
				
			||||||
 | 
					   there are no more options.  For unrecognized options, or options
 | 
				
			||||||
 | 
					   missing arguments, 'optopt' is set to the option letter, and '?' is
 | 
				
			||||||
 | 
					   returned.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The OPTS string is a list of characters which are recognized option
 | 
				
			||||||
 | 
					   letters, optionally followed by colons, specifying that that letter
 | 
				
			||||||
 | 
					   takes an argument, to be placed in 'optarg'.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   If a letter in OPTS is followed by two colons, its argument is
 | 
				
			||||||
 | 
					   optional.  This behavior is specific to the GNU 'getopt'.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The argument '--' causes premature termination of argument
 | 
				
			||||||
 | 
					   scanning, explicitly telling 'getopt' that there are no more
 | 
				
			||||||
 | 
					   options.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   If OPTS begins with '-', then non-option arguments are treated as
 | 
				
			||||||
 | 
					   arguments to the option '\1'.  This behavior is specific to the GNU
 | 
				
			||||||
 | 
					   'getopt'.  If OPTS begins with '+', or POSIXLY_CORRECT is set in
 | 
				
			||||||
 | 
					   the environment, then do not permute arguments.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   For standards compliance, the 'argv' argument has the type
 | 
				
			||||||
 | 
					   char *const *, but this is inaccurate; if argument permutation is
 | 
				
			||||||
 | 
					   enabled, the argv array (not the strings it points to) must be
 | 
				
			||||||
 | 
					   writable.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
 | 
				
			||||||
 | 
					       __THROW _GL_ARG_NONNULL ((2, 3));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GETOPT_CORE_H */
 | 
				
			||||||
							
								
								
									
										77
									
								
								gl/getopt-ext.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								gl/getopt-ext.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,77 @@
 | 
				
			||||||
 | 
					/* Declarations for getopt (GNU extensions).
 | 
				
			||||||
 | 
					   Copyright (C) 1989-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   This file is part of the GNU C Library and is also part of gnulib.
 | 
				
			||||||
 | 
					   Patches to this file should be submitted to both projects.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License as published by the Free Software Foundation; either
 | 
				
			||||||
 | 
					   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GETOPT_EXT_H
 | 
				
			||||||
 | 
					#define _GETOPT_EXT_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This header should not be used directly; include getopt.h instead.
 | 
				
			||||||
 | 
					   Unlike most bits headers, it does not have a protective #error,
 | 
				
			||||||
 | 
					   because the guard macro for getopt.h in gnulib is not fixed.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Describe the long-named options requested by the application.
 | 
				
			||||||
 | 
					   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
 | 
				
			||||||
 | 
					   of 'struct option' terminated by an element containing a name which is
 | 
				
			||||||
 | 
					   zero.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   The field 'has_arg' is:
 | 
				
			||||||
 | 
					   no_argument		(or 0) if the option does not take an argument,
 | 
				
			||||||
 | 
					   required_argument	(or 1) if the option requires an argument,
 | 
				
			||||||
 | 
					   optional_argument 	(or 2) if the option takes an optional argument.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   If the field 'flag' is not NULL, it points to a variable that is set
 | 
				
			||||||
 | 
					   to the value given in the field 'val' when the option is found, but
 | 
				
			||||||
 | 
					   left unchanged if the option is not found.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   To have a long-named option do something other than set an 'int' to
 | 
				
			||||||
 | 
					   a compiled-in constant, such as set a value from 'optarg', set the
 | 
				
			||||||
 | 
					   option's 'flag' field to zero and its 'val' field to a nonzero
 | 
				
			||||||
 | 
					   value (the equivalent single-letter option character, if there is
 | 
				
			||||||
 | 
					   one).  For long options that have a zero 'flag' field, 'getopt'
 | 
				
			||||||
 | 
					   returns the contents of the 'val' field.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct option
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const char *name;
 | 
				
			||||||
 | 
					  /* has_arg can't be an enum because some compilers complain about
 | 
				
			||||||
 | 
					     type mismatches in all the code that assumes it is an int.  */
 | 
				
			||||||
 | 
					  int has_arg;
 | 
				
			||||||
 | 
					  int *flag;
 | 
				
			||||||
 | 
					  int val;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Names for the values of the 'has_arg' field of 'struct option'.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define no_argument		0
 | 
				
			||||||
 | 
					#define required_argument	1
 | 
				
			||||||
 | 
					#define optional_argument	2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
 | 
				
			||||||
 | 
								const char *__shortopts,
 | 
				
			||||||
 | 
							        const struct option *__longopts, int *__longind)
 | 
				
			||||||
 | 
					       __THROW _GL_ARG_NONNULL ((2, 3));
 | 
				
			||||||
 | 
					extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
 | 
				
			||||||
 | 
								     const char *__shortopts,
 | 
				
			||||||
 | 
							             const struct option *__longopts, int *__longind)
 | 
				
			||||||
 | 
					       __THROW _GL_ARG_NONNULL ((2, 3));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GETOPT_EXT_H */
 | 
				
			||||||
							
								
								
									
										66
									
								
								gl/getopt-pfx-core.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								gl/getopt-pfx-core.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,66 @@
 | 
				
			||||||
 | 
					/* getopt (basic, portable features) gnulib wrapper header.
 | 
				
			||||||
 | 
					   Copyright (C) 1989-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   This file is part of gnulib.
 | 
				
			||||||
 | 
					   Unlike most of the getopt implementation, it is NOT shared
 | 
				
			||||||
 | 
					   with the GNU C Library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GETOPT_PFX_CORE_H
 | 
				
			||||||
 | 
					#define _GETOPT_PFX_CORE_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This header should not be used directly; include getopt.h or
 | 
				
			||||||
 | 
					   unistd.h instead.  It does not have a protective #error, because
 | 
				
			||||||
 | 
					   the guard macro for getopt.h in gnulib is not fixed.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Standalone applications should #define __GETOPT_PREFIX to an
 | 
				
			||||||
 | 
					   identifier that prefixes the external functions and variables
 | 
				
			||||||
 | 
					   defined in getopt-core.h and getopt-ext.h.  Systematically
 | 
				
			||||||
 | 
					   rename identifiers so that they do not collide with the system
 | 
				
			||||||
 | 
					   functions and variables.  Renaming avoids problems with some
 | 
				
			||||||
 | 
					   compilers and linkers.  */
 | 
				
			||||||
 | 
					#ifdef __GETOPT_PREFIX
 | 
				
			||||||
 | 
					# ifndef __GETOPT_ID
 | 
				
			||||||
 | 
					#  define __GETOPT_CONCAT(x, y) x ## y
 | 
				
			||||||
 | 
					#  define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
 | 
				
			||||||
 | 
					#  define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# undef getopt
 | 
				
			||||||
 | 
					# undef optarg
 | 
				
			||||||
 | 
					# undef opterr
 | 
				
			||||||
 | 
					# undef optind
 | 
				
			||||||
 | 
					# undef optopt
 | 
				
			||||||
 | 
					# define getopt __GETOPT_ID (getopt)
 | 
				
			||||||
 | 
					# define optarg __GETOPT_ID (optarg)
 | 
				
			||||||
 | 
					# define opterr __GETOPT_ID (opterr)
 | 
				
			||||||
 | 
					# define optind __GETOPT_ID (optind)
 | 
				
			||||||
 | 
					# define optopt __GETOPT_ID (optopt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Work around a a problem on macOS, which declares getopt with a
 | 
				
			||||||
 | 
					   trailing __DARWIN_ALIAS(getopt) that would expand to something like
 | 
				
			||||||
 | 
					   __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
 | 
				
			||||||
 | 
					   hack to suppress the macOS declaration <https://bugs.gnu.org/40205>.  */
 | 
				
			||||||
 | 
					# ifdef __APPLE__
 | 
				
			||||||
 | 
					#  define _GETOPT
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The system's getopt.h may have already included getopt-core.h to
 | 
				
			||||||
 | 
					   declare the unprefixed identifiers.  Undef _GETOPT_CORE_H so that
 | 
				
			||||||
 | 
					   getopt-core.h declares them with prefixes.  */
 | 
				
			||||||
 | 
					# undef _GETOPT_CORE_H
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <getopt-core.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GETOPT_PFX_CORE_H */
 | 
				
			||||||
							
								
								
									
										70
									
								
								gl/getopt-pfx-ext.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								gl/getopt-pfx-ext.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,70 @@
 | 
				
			||||||
 | 
					/* getopt (GNU extensions) gnulib wrapper header.
 | 
				
			||||||
 | 
					   Copyright (C) 1989-2023 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					   This file is part of gnulib.
 | 
				
			||||||
 | 
					   Unlike most of the getopt implementation, it is NOT shared
 | 
				
			||||||
 | 
					   with the GNU C Library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _GETOPT_PFX_EXT_H
 | 
				
			||||||
 | 
					#define _GETOPT_PFX_EXT_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This header should not be used directly; include getopt.h instead.
 | 
				
			||||||
 | 
					   It does not have a protective #error, because the guard macro for
 | 
				
			||||||
 | 
					   getopt.h in gnulib is not fixed.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Standalone applications should #define __GETOPT_PREFIX to an
 | 
				
			||||||
 | 
					   identifier that prefixes the external functions and variables
 | 
				
			||||||
 | 
					   defined in getopt-core.h and getopt-ext.h.  Systematically
 | 
				
			||||||
 | 
					   rename identifiers so that they do not collide with the system
 | 
				
			||||||
 | 
					   functions and variables.  Renaming avoids problems with some
 | 
				
			||||||
 | 
					   compilers and linkers.  */
 | 
				
			||||||
 | 
					#ifdef __GETOPT_PREFIX
 | 
				
			||||||
 | 
					# ifndef __GETOPT_ID
 | 
				
			||||||
 | 
					#  define __GETOPT_CONCAT(x, y) x ## y
 | 
				
			||||||
 | 
					#  define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
 | 
				
			||||||
 | 
					#  define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					# undef getopt_long
 | 
				
			||||||
 | 
					# undef getopt_long_only
 | 
				
			||||||
 | 
					# undef option
 | 
				
			||||||
 | 
					# undef _getopt_internal
 | 
				
			||||||
 | 
					# define getopt_long __GETOPT_ID (getopt_long)
 | 
				
			||||||
 | 
					# define getopt_long_only __GETOPT_ID (getopt_long_only)
 | 
				
			||||||
 | 
					# define option __GETOPT_ID (option)
 | 
				
			||||||
 | 
					# define _getopt_internal __GETOPT_ID (getopt_internal)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* The system's getopt.h may have already included getopt-ext.h to
 | 
				
			||||||
 | 
					   declare the unprefixed identifiers.  Undef _GETOPT_EXT_H so that
 | 
				
			||||||
 | 
					   getopt-ext.h declares them with prefixes.  */
 | 
				
			||||||
 | 
					# undef _GETOPT_EXT_H
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Standalone applications get correct prototypes for getopt_long and
 | 
				
			||||||
 | 
					   getopt_long_only; they declare "char **argv".  For backward
 | 
				
			||||||
 | 
					   compatibility with old applications, if __GETOPT_PREFIX is not
 | 
				
			||||||
 | 
					   defined, we supply GNU-libc-compatible, but incorrect, prototypes
 | 
				
			||||||
 | 
					   using "char *const *argv".  (GNU libc is stuck with the incorrect
 | 
				
			||||||
 | 
					   prototypes, as they are baked into older versions of LSB.)  */
 | 
				
			||||||
 | 
					#ifndef __getopt_argv_const
 | 
				
			||||||
 | 
					# if defined __GETOPT_PREFIX
 | 
				
			||||||
 | 
					#  define __getopt_argv_const /* empty */
 | 
				
			||||||
 | 
					# else
 | 
				
			||||||
 | 
					#  define __getopt_argv_const const
 | 
				
			||||||
 | 
					# endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <getopt-ext.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _GETOPT_PFX_EXT_H */
 | 
				
			||||||
							
								
								
									
										1062
									
								
								gl/getopt.c
									
										
									
									
									
								
							
							
						
						
									
										1062
									
								
								gl/getopt.c
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										236
									
								
								gl/getopt.in.h
									
										
									
									
									
								
							
							
						
						
									
										236
									
								
								gl/getopt.in.h
									
										
									
									
									
								
							| 
						 | 
					@ -1,20 +1,22 @@
 | 
				
			||||||
/* Declarations for getopt.
 | 
					/* Declarations for getopt.
 | 
				
			||||||
   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software
 | 
					   Copyright (C) 1989-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Foundation, Inc.
 | 
					   This file is part of gnulib.
 | 
				
			||||||
   This file is part of the GNU C Library.
 | 
					   Unlike most of the getopt implementation, it is NOT shared
 | 
				
			||||||
 | 
					   with the GNU C Library, which supplies a different version of
 | 
				
			||||||
 | 
					   this file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   This file is free software: you can redistribute it and/or modify
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   it under the terms of the GNU Lesser General Public License as
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   published by the Free Software Foundation; either version 2.1 of the
 | 
				
			||||||
   (at your option) any later version.
 | 
					   License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   This file is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   GNU Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public License
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _@GUARD_PREFIX@_GETOPT_H
 | 
					#ifndef _@GUARD_PREFIX@_GETOPT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,22 +34,15 @@
 | 
				
			||||||
# undef _GL_SYSTEM_GETOPT
 | 
					# undef _GL_SYSTEM_GETOPT
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _@GUARD_PREFIX@_GETOPT_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef __need_getopt
 | 
					 | 
				
			||||||
#define _@GUARD_PREFIX@_GETOPT_H 1
 | 
					#define _@GUARD_PREFIX@_GETOPT_H 1
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Standalone applications should #define __GETOPT_PREFIX to an
 | 
					/* Standalone applications should #define __GETOPT_PREFIX to an
 | 
				
			||||||
   identifier that prefixes the external functions and variables
 | 
					   identifier that prefixes the external functions and variables
 | 
				
			||||||
   defined in this header.  When this happens, include the
 | 
					   defined in getopt-core.h and getopt-ext.h.  When this happens,
 | 
				
			||||||
   headers that might declare getopt so that they will not cause
 | 
					   include the headers that might declare getopt so that they will not
 | 
				
			||||||
   confusion if included after this file (if the system had <getopt.h>,
 | 
					   cause confusion if included after this file (if the system had
 | 
				
			||||||
   we have already included it).  Then systematically rename
 | 
					   <getopt.h>, we have already included it).  */
 | 
				
			||||||
   identifiers so that they do not collide with the system functions
 | 
					#if defined __GETOPT_PREFIX
 | 
				
			||||||
   and variables.  Renaming avoids problems with some compilers and
 | 
					 | 
				
			||||||
   linkers.  */
 | 
					 | 
				
			||||||
#if defined __GETOPT_PREFIX && !defined __need_getopt
 | 
					 | 
				
			||||||
# if !@HAVE_GETOPT_H@
 | 
					# if !@HAVE_GETOPT_H@
 | 
				
			||||||
#  define __need_system_stdlib_h
 | 
					#  define __need_system_stdlib_h
 | 
				
			||||||
#  include <stdlib.h>
 | 
					#  include <stdlib.h>
 | 
				
			||||||
| 
						 | 
					@ -55,201 +50,12 @@
 | 
				
			||||||
#  include <stdio.h>
 | 
					#  include <stdio.h>
 | 
				
			||||||
#  include <unistd.h>
 | 
					#  include <unistd.h>
 | 
				
			||||||
# endif
 | 
					# endif
 | 
				
			||||||
# undef __need_getopt
 | 
					 | 
				
			||||||
# undef getopt
 | 
					 | 
				
			||||||
# undef getopt_long
 | 
					 | 
				
			||||||
# undef getopt_long_only
 | 
					 | 
				
			||||||
# undef optarg
 | 
					 | 
				
			||||||
# undef opterr
 | 
					 | 
				
			||||||
# undef optind
 | 
					 | 
				
			||||||
# undef optopt
 | 
					 | 
				
			||||||
# undef option
 | 
					 | 
				
			||||||
# define __GETOPT_CONCAT(x, y) x ## y
 | 
					 | 
				
			||||||
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
 | 
					 | 
				
			||||||
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
 | 
					 | 
				
			||||||
# define getopt __GETOPT_ID (getopt)
 | 
					 | 
				
			||||||
# define getopt_long __GETOPT_ID (getopt_long)
 | 
					 | 
				
			||||||
# define getopt_long_only __GETOPT_ID (getopt_long_only)
 | 
					 | 
				
			||||||
# define optarg __GETOPT_ID (optarg)
 | 
					 | 
				
			||||||
# define opterr __GETOPT_ID (opterr)
 | 
					 | 
				
			||||||
# define optind __GETOPT_ID (optind)
 | 
					 | 
				
			||||||
# define optopt __GETOPT_ID (optopt)
 | 
					 | 
				
			||||||
# define option __GETOPT_ID (option)
 | 
					 | 
				
			||||||
# define _getopt_internal __GETOPT_ID (getopt_internal)
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Standalone applications get correct prototypes for getopt_long and
 | 
					 | 
				
			||||||
   getopt_long_only; they declare "char **argv".  libc uses prototypes
 | 
					 | 
				
			||||||
   with "char *const *argv" that are incorrect because getopt_long and
 | 
					 | 
				
			||||||
   getopt_long_only can permute argv; this is required for backward
 | 
					 | 
				
			||||||
   compatibility (e.g., for LSB 2.0.1).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt',
 | 
					 | 
				
			||||||
   but it caused redefinition warnings if both unistd.h and getopt.h were
 | 
					 | 
				
			||||||
   included, since unistd.h includes getopt.h having previously defined
 | 
					 | 
				
			||||||
   __need_getopt.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   The only place where __getopt_argv_const is used is in definitions
 | 
					 | 
				
			||||||
   of getopt_long and getopt_long_only below, but these are visible
 | 
					 | 
				
			||||||
   only if __need_getopt is not defined, so it is quite safe to rewrite
 | 
					 | 
				
			||||||
   the conditional as follows:
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#if !defined __need_getopt
 | 
					 | 
				
			||||||
# if defined __GETOPT_PREFIX
 | 
					 | 
				
			||||||
#  define __getopt_argv_const /* empty */
 | 
					 | 
				
			||||||
# else
 | 
					 | 
				
			||||||
#  define __getopt_argv_const const
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
 | 
					 | 
				
			||||||
   standalone, or this is the first header included in the source file.
 | 
					 | 
				
			||||||
   If we are being used with glibc, we need to include <features.h>, but
 | 
					 | 
				
			||||||
   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
 | 
					 | 
				
			||||||
   not defined, include <ctype.h>, which will pull in <features.h> for us
 | 
					 | 
				
			||||||
   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
 | 
					 | 
				
			||||||
   doesn't flood the namespace with stuff the way some other headers do.)  */
 | 
					 | 
				
			||||||
#if !defined __GNU_LIBRARY__
 | 
					 | 
				
			||||||
# include <ctype.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef __THROW
 | 
					 | 
				
			||||||
# ifndef __GNUC_PREREQ
 | 
					 | 
				
			||||||
#  define __GNUC_PREREQ(maj, min) (0)
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
 | 
					 | 
				
			||||||
#  define __THROW       throw ()
 | 
					 | 
				
			||||||
# else
 | 
					 | 
				
			||||||
#  define __THROW
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The definition of _GL_ARG_NONNULL is copied here.  */
 | 
					/* The definition of _GL_ARG_NONNULL is copied here.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#include <getopt-cdefs.h>
 | 
				
			||||||
extern "C" {
 | 
					#include <getopt-pfx-core.h>
 | 
				
			||||||
#endif
 | 
					#include <getopt-pfx-ext.h>
 | 
				
			||||||
 | 
					 | 
				
			||||||
/* For communication from 'getopt' to the caller.
 | 
					 | 
				
			||||||
   When 'getopt' finds an option that takes an argument,
 | 
					 | 
				
			||||||
   the argument value is returned here.
 | 
					 | 
				
			||||||
   Also, when 'ordering' is RETURN_IN_ORDER,
 | 
					 | 
				
			||||||
   each non-option ARGV-element is returned here.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern char *optarg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Index in ARGV of the next element to be scanned.
 | 
					 | 
				
			||||||
   This is used for communication to and from the caller
 | 
					 | 
				
			||||||
   and for communication between successive calls to 'getopt'.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   On entry to 'getopt', zero means this is the first call; initialize.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   When 'getopt' returns -1, this is the index of the first of the
 | 
					 | 
				
			||||||
   non-option elements that the caller should itself scan.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   Otherwise, 'optind' communicates from one call to the next
 | 
					 | 
				
			||||||
   how much of ARGV has been scanned so far.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int optind;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Callers store zero here to inhibit the error message 'getopt' prints
 | 
					 | 
				
			||||||
   for unrecognized options.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int opterr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Set to an option character which was unrecognized.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int optopt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef __need_getopt
 | 
					 | 
				
			||||||
/* Describe the long-named options requested by the application.
 | 
					 | 
				
			||||||
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
 | 
					 | 
				
			||||||
   of 'struct option' terminated by an element containing a name which is
 | 
					 | 
				
			||||||
   zero.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   The field 'has_arg' is:
 | 
					 | 
				
			||||||
   no_argument          (or 0) if the option does not take an argument,
 | 
					 | 
				
			||||||
   required_argument    (or 1) if the option requires an argument,
 | 
					 | 
				
			||||||
   optional_argument    (or 2) if the option takes an optional argument.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   If the field 'flag' is not NULL, it points to a variable that is set
 | 
					 | 
				
			||||||
   to the value given in the field 'val' when the option is found, but
 | 
					 | 
				
			||||||
   left unchanged if the option is not found.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   To have a long-named option do something other than set an 'int' to
 | 
					 | 
				
			||||||
   a compiled-in constant, such as set a value from 'optarg', set the
 | 
					 | 
				
			||||||
   option's 'flag' field to zero and its 'val' field to a nonzero
 | 
					 | 
				
			||||||
   value (the equivalent single-letter option character, if there is
 | 
					 | 
				
			||||||
   one).  For long options that have a zero 'flag' field, 'getopt'
 | 
					 | 
				
			||||||
   returns the contents of the 'val' field.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# if !GNULIB_defined_struct_option
 | 
					 | 
				
			||||||
struct option
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  const char *name;
 | 
					 | 
				
			||||||
  /* has_arg can't be an enum because some compilers complain about
 | 
					 | 
				
			||||||
     type mismatches in all the code that assumes it is an int.  */
 | 
					 | 
				
			||||||
  int has_arg;
 | 
					 | 
				
			||||||
  int *flag;
 | 
					 | 
				
			||||||
  int val;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
#  define GNULIB_defined_struct_option 1
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Names for the values of the 'has_arg' field of 'struct option'.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# define no_argument            0
 | 
					 | 
				
			||||||
# define required_argument      1
 | 
					 | 
				
			||||||
# define optional_argument      2
 | 
					 | 
				
			||||||
#endif  /* need getopt */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Get definitions and prototypes for functions to process the
 | 
					 | 
				
			||||||
   arguments in ARGV (ARGC of them, minus the program name) for
 | 
					 | 
				
			||||||
   options given in OPTS.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   Return the option character from OPTS just read.  Return -1 when
 | 
					 | 
				
			||||||
   there are no more options.  For unrecognized options, or options
 | 
					 | 
				
			||||||
   missing arguments, 'optopt' is set to the option letter, and '?' is
 | 
					 | 
				
			||||||
   returned.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   The OPTS string is a list of characters which are recognized option
 | 
					 | 
				
			||||||
   letters, optionally followed by colons, specifying that that letter
 | 
					 | 
				
			||||||
   takes an argument, to be placed in 'optarg'.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   If a letter in OPTS is followed by two colons, its argument is
 | 
					 | 
				
			||||||
   optional.  This behavior is specific to the GNU 'getopt'.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   The argument '--' causes premature termination of argument
 | 
					 | 
				
			||||||
   scanning, explicitly telling 'getopt' that there are no more
 | 
					 | 
				
			||||||
   options.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   If OPTS begins with '-', then non-option arguments are treated as
 | 
					 | 
				
			||||||
   arguments to the option '\1'.  This behavior is specific to the GNU
 | 
					 | 
				
			||||||
   'getopt'.  If OPTS begins with '+', or POSIXLY_CORRECT is set in
 | 
					 | 
				
			||||||
   the environment, then do not permute arguments.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
 | 
					 | 
				
			||||||
       __THROW _GL_ARG_NONNULL ((2, 3));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef __need_getopt
 | 
					 | 
				
			||||||
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
 | 
					 | 
				
			||||||
                        const char *__shortopts,
 | 
					 | 
				
			||||||
                        const struct option *__longopts, int *__longind)
 | 
					 | 
				
			||||||
       __THROW _GL_ARG_NONNULL ((2, 3));
 | 
					 | 
				
			||||||
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
 | 
					 | 
				
			||||||
                             const char *__shortopts,
 | 
					 | 
				
			||||||
                             const struct option *__longopts, int *__longind)
 | 
					 | 
				
			||||||
       __THROW _GL_ARG_NONNULL ((2, 3));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Make sure we later can get all the definitions and declarations.  */
 | 
					 | 
				
			||||||
#undef __need_getopt
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* _@GUARD_PREFIX@_GETOPT_H */
 | 
					#endif /* _@GUARD_PREFIX@_GETOPT_H */
 | 
				
			||||||
#endif /* _@GUARD_PREFIX@_GETOPT_H */
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										45
									
								
								gl/getopt1.c
									
										
									
									
									
								
							
							
						
						
									
										45
									
								
								gl/getopt1.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,41 +1,29 @@
 | 
				
			||||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
 | 
					/* getopt_long and getopt_long_only entry points for GNU getopt.
 | 
				
			||||||
   Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software
 | 
					   Copyright (C) 1987-2023 Free Software Foundation, Inc.
 | 
				
			||||||
   Foundation, Inc.
 | 
					   This file is part of the GNU C Library and is also part of gnulib.
 | 
				
			||||||
   This file is part of the GNU C Library.
 | 
					   Patches to this file should be submitted to both projects.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is free software: you can redistribute it and/or modify
 | 
					   The GNU C Library is free software; you can redistribute it and/or
 | 
				
			||||||
   it under the terms of the GNU General Public License as published by
 | 
					   modify it under the terms of the GNU Lesser General Public
 | 
				
			||||||
   the Free Software Foundation; either version 3 of the License, or
 | 
					   License as published by the Free Software Foundation; either
 | 
				
			||||||
   (at your option) any later version.
 | 
					   version 2.1 of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This program is distributed in the hope that it will be useful,
 | 
					   The GNU C Library is distributed in the hope that it will be useful,
 | 
				
			||||||
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
   GNU General Public License for more details.
 | 
					   Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   You should have received a copy of the GNU General Public License
 | 
					   You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | 
					   License along with the GNU C Library; if not, see
 | 
				
			||||||
 | 
					   <https://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _LIBC
 | 
					#ifndef _LIBC
 | 
				
			||||||
# include <getopt.h>
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
# include <config.h>
 | 
					# include <config.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "getopt.h"
 | 
					#include "getopt.h"
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#include "getopt_int.h"
 | 
					#include "getopt_int.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* This needs to come after some library #include
 | 
					 | 
				
			||||||
   to get __GNU_LIBRARY__ defined.  */
 | 
					 | 
				
			||||||
#ifdef __GNU_LIBRARY__
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NULL
 | 
					 | 
				
			||||||
#define NULL 0
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
 | 
					getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
 | 
				
			||||||
	     const struct option *long_options, int *opt_index)
 | 
						     const struct option *long_options, int *opt_index)
 | 
				
			||||||
| 
						 | 
					@ -80,6 +68,7 @@ _getopt_long_only_r (int argc, char **argv, const char *options,
 | 
				
			||||||
#ifdef TEST
 | 
					#ifdef TEST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
main (int argc, char **argv)
 | 
					main (int argc, char **argv)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue