1 /* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO C Standard: 4.10 GENERAL UTILITIES <stdlib.h>
28 /* Get size_t, wchar_t and NULL from <stddef.h>. */
30 #define __need_wchar_t
36 /* Returned by `div'. */
39 int quot
; /* Quotient. */
40 int rem
; /* Remainder. */
43 /* Returned by `ldiv'. */
46 long int quot
; /* Quotient. */
47 long int rem
; /* Remainder. */
51 /* Returned by `lldiv'. */
54 long long int quot
; /* Quotient. */
55 long long int rem
; /* Remainder. */
60 /* The largest number rand will return (same as INT_MAX). */
61 #define RAND_MAX 2147483647
64 /* We define these the same for all machines.
65 Changes from this to the outside world should be done in `_exit'. */
66 #define EXIT_FAILURE 1 /* Failing exit status. */
67 #define EXIT_SUCCESS 0 /* Successful exit status. */
70 /* Maximum length of a multibyte character in the current locale. */
71 #define MB_CUR_MAX (__ctype_get_mb_cur_max ())
72 extern int __ctype_get_mb_cur_max
__P ((void));
75 /* Convert a string to a floating-point number. */
76 extern double atof
__P ((__const
char *__nptr
));
77 /* Convert a string to an integer. */
78 extern int atoi
__P ((__const
char *__nptr
));
79 /* Convert a string to a long integer. */
80 extern long int atol
__P ((__const
char *__nptr
));
82 #if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
83 /* These functions will part of the standard C library in ISO C 9X. */
84 extern long long int atoll
__P ((__const
char *__nptr
));
87 /* Convert a string to a floating-point number. */
88 extern double strtod
__P ((__const
char *__restrict __nptr
,
89 char **__restrict __endptr
));
92 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
93 extern float strtof
__P ((__const
char *__restrict __nptr
,
94 char **__restrict __endptr
));
96 extern __long_double_t strtold
__P ((__const
char *__restrict __nptr
,
97 char **__restrict __endptr
));
100 /* Convert a string to a long integer. */
101 extern long int strtol
__P ((__const
char *__restrict __nptr
,
102 char **__restrict __endptr
, int __base
));
103 /* Convert a string to an unsigned long integer. */
104 extern unsigned long int strtoul
__P ((__const
char *__restrict __nptr
,
105 char **__restrict __endptr
,
108 #if defined __GNUC__ && defined __USE_BSD
109 /* Convert a string to a quadword integer. */
110 extern long long int strtoq
__P ((__const
char *__restrict __nptr
,
111 char **__restrict __endptr
, int __base
));
112 /* Convert a string to an unsigned quadword integer. */
113 extern unsigned long long int strtouq
__P ((__const
char *__restrict __nptr
,
114 char **__restrict __endptr
,
116 #endif /* GCC and use BSD. */
118 #if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
119 /* These functions will part of the standard C library in ISO C 9X. */
121 /* Convert a string to a quadword integer. */
122 extern long long int strtoll
__P ((__const
char *__restrict __nptr
,
123 char **__restrict __endptr
, int __base
));
124 /* Convert a string to an unsigned quadword integer. */
125 extern unsigned long long int strtoull
__P ((__const
char *__restrict __nptr
,
126 char **__restrict __endptr
,
128 #endif /* ISO C 9X or GCC and use MISC. */
132 /* The concept of one static locale per category is not very well
133 thought out. Many applications will need to process its data using
134 information from several different locales. Another application is
135 the implementation of the internationalization handling in the
136 upcoming ISO C++ standard library. To support this another set of
137 the functions using locale data exist which have an additional
140 Attention: all these functions are *not* standardized in any form.
141 This is a proof-of-concept implementation. */
143 /* Structure for reentrant locale using functions. This is an
144 (almost) opaque type for the user level programs. */
145 # include <xlocale.h>
147 /* Special versions of the functions above which take the locale to
148 use as an additional parameter. */
149 extern long int __strtol_l
__P ((__const
char *__restrict __nptr
,
150 char **__restrict __endptr
, int __base
,
153 extern unsigned long int __strtoul_l
__P ((__const
char *__restrict __nptr
,
154 char **__restrict __endptr
,
155 int __base
, __locale_t __loc
));
157 extern long long int __strtoll_l
__P ((__const
char *__restrict __nptr
,
158 char **__restrict __endptr
, int __base
,
161 extern unsigned long long int __strtoull_l
__P ((__const
char *__restrict
163 char **__restrict __endptr
,
167 extern double __strtod_l
__P ((__const
char *__restrict __nptr
,
168 char **__restrict __endptr
, __locale_t __loc
));
170 extern float __strtof_l
__P ((__const
char *__restrict __nptr
,
171 char **__restrict __endptr
, __locale_t __loc
));
173 extern __long_double_t __strtold_l
__P ((__const
char *__restrict __nptr
,
174 char **__restrict __endptr
,
179 /* The internal entry points for `strtoX' take an extra flag argument
180 saying whether or not to parse locale-dependent number grouping. */
182 extern double __strtod_internal
__P ((__const
char *__restrict __nptr
,
183 char **__restrict __endptr
,
185 extern float __strtof_internal
__P ((__const
char *__restrict __nptr
,
186 char **__restrict __endptr
, int __group
));
187 extern __long_double_t __strtold_internal
__P ((__const
char *
189 char **__restrict __endptr
,
191 #ifndef __strtol_internal_defined
192 extern long int __strtol_internal
__P ((__const
char *__restrict __nptr
,
193 char **__restrict __endptr
,
194 int __base
, int __group
));
195 # define __strtol_internal_defined 1
197 #ifndef __strtoul_internal_defined
198 extern unsigned long int __strtoul_internal
__P ((__const
char *
200 char **__restrict __endptr
,
201 int __base
, int __group
));
202 # define __strtoul_internal_defined 1
204 #if defined __GNUC__ || defined __USE_ISOC9X
205 # ifndef __strtoll_internal_defined
206 extern long long int __strtoll_internal
__P ((__const
char *__restrict __nptr
,
207 char **__restrict __endptr
,
208 int __base
, int __group
));
209 # define __strtoll_internal_defined 1
211 # ifndef __strtoull_internal_defined
212 extern unsigned long long int __strtoull_internal
__P ((__const
char *
218 # define __strtoull_internal_defined 1
222 #if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
223 && defined __USE_EXTERN_INLINES
224 /* Define inline functions which call the internal entry points. */
226 extern __inline
double
227 strtod (__const
char *__restrict __nptr
, char **__restrict __endptr
)
229 return __strtod_internal (__nptr
, __endptr
, 0);
231 extern __inline
long int
232 strtol (__const
char *__restrict __nptr
, char **__restrict __endptr
,
235 return __strtol_internal (__nptr
, __endptr
, __base
, 0);
237 extern __inline
unsigned long int
238 strtoul (__const
char *__restrict __nptr
, char **__restrict __endptr
,
241 return __strtoul_internal (__nptr
, __endptr
, __base
, 0);
245 extern __inline
float
246 strtof (__const
char *__restrict __nptr
, char **__restrict __endptr
)
248 return __strtof_internal (__nptr
, __endptr
, 0);
250 extern __inline __long_double_t
251 strtold (__const
char *__restrict __nptr
, char **__restrict __endptr
)
253 return __strtold_internal (__nptr
, __endptr
, 0);
258 extern __inline
long long int
259 strtoq (__const
char *__restrict __nptr
, char **__restrict __endptr
,
262 return __strtoll_internal (__nptr
, __endptr
, __base
, 0);
264 extern __inline
unsigned long long int
265 strtouq (__const
char *__restrict __nptr
, char **__restrict __endptr
,
268 return __strtoull_internal (__nptr
, __endptr
, __base
, 0);
272 # if defined __USE_MISC || defined __USE_ISOC9X
273 extern __inline
long long int
274 strtoll (__const
char *__restrict __nptr
, char **__restrict __endptr
,
277 return __strtoll_internal (__nptr
, __endptr
, __base
, 0);
279 extern __inline
unsigned long long int
280 strtoull (__const
char * __restrict __nptr
, char **__restrict __endptr
,
283 return __strtoull_internal (__nptr
, __endptr
, __base
, 0);
287 extern __inline
double
288 atof (__const
char *__nptr
)
290 return strtod (__nptr
, (char **) NULL
);
293 atoi (__const
char *__nptr
)
295 return (int) strtol (__nptr
, (char **) NULL
, 10);
297 extern __inline
long int
298 atol (__const
char *__nptr
)
300 return strtol (__nptr
, (char **) NULL
, 10);
303 # if defined __USE_MISC || defined __USE_ISOC9X
304 extern __inline
long long int
305 atoll (__const
char *__nptr
)
307 return strtoll (__nptr
, (char **) NULL
, 10);
310 #endif /* Optimizing and Inlining. */
313 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
314 /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
315 digit first. Returns a pointer to static storage overwritten by the
317 extern char *l64a
__P ((long int __n
));
319 /* Read a number from a string S in base 64 as above. */
320 extern long int a64l
__P ((__const
char *__s
));
323 # include <sys/types.h> /* we need int32_t... */
325 /* These are the functions that actually do things. The `random', `srandom',
326 `initstate' and `setstate' functions are those from BSD Unices.
327 The `rand' and `srand' functions are required by the ANSI standard.
328 We provide both interfaces to the same random number generator. */
329 /* Return a random long integer between 0 and RAND_MAX inclusive. */
330 extern int32_t random
__P ((void));
332 /* Seed the random number generator with the given number. */
333 extern void srandom
__P ((unsigned int __seed
));
335 /* Initialize the random number generator to use state buffer STATEBUF,
336 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
337 32, 64, 128 and 256, the bigger the better; values less than 8 will
338 cause an error and values greater than 256 will be rounded down. */
339 extern __ptr_t initstate
__P ((unsigned int __seed
, __ptr_t __statebuf
,
342 /* Switch the random number generator to state buffer STATEBUF,
343 which should have been previously initialized by `initstate'. */
344 extern __ptr_t setstate
__P ((__ptr_t __statebuf
));
348 /* Reentrant versions of the `random' family of functions.
349 These functions all use the following data structure to contain
350 state, rather than global state variables. */
354 int32_t *fptr
; /* Front pointer. */
355 int32_t *rptr
; /* Rear pointer. */
356 int32_t *state
; /* Array of state values. */
357 int rand_type
; /* Type of random number generator. */
358 int rand_deg
; /* Degree of random number generator. */
359 int rand_sep
; /* Distance between front and rear. */
360 int32_t *end_ptr
; /* Pointer behind state table. */
363 extern int random_r
__P ((struct random_data
*__buf
, int32_t *__result
));
365 extern int srandom_r
__P ((unsigned int __seed
, struct random_data
*__buf
));
367 extern int initstate_r
__P ((unsigned int __seed
, __ptr_t __statebuf
,
368 size_t __statelen
, struct random_data
*__buf
));
370 extern int setstate_r
__P ((__ptr_t __statebuf
, struct random_data
*__buf
));
371 # endif /* Use misc. */
372 #endif /* Use SVID || extended X/Open. */
375 /* Return a random integer between 0 and RAND_MAX inclusive. */
376 extern int rand
__P ((void));
377 /* Seed the random number generator with the given number. */
378 extern void srand
__P ((unsigned int __seed
));
381 /* Reentrant interface according to POSIX.1. */
382 extern int rand_r
__P ((unsigned int *__seed
));
386 #if defined __USE_SVID || defined __USE_XOPEN
387 /* System V style 48-bit random number generator functions. */
389 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
390 extern double drand48
__P ((void));
391 extern double erand48
__P ((unsigned short int __xsubi
[3]));
393 /* Return non-negative, long integer in [0,2^31). */
394 extern long int lrand48
__P ((void));
395 extern long int nrand48
__P ((unsigned short int __xsubi
[3]));
397 /* Return signed, long integers in [-2^31,2^31). */
398 extern long int mrand48
__P ((void));
399 extern long int jrand48
__P ((unsigned short int __xsubi
[3]));
401 /* Seed random number generator. */
402 extern void srand48
__P ((long int __seedval
));
403 extern unsigned short int *seed48
__P ((unsigned short int __seed16v
[3]));
404 extern void lcong48
__P ((unsigned short int __param
[7]));
406 /* Data structure for communication with thread safe versions. */
409 unsigned short int x
[3]; /* Current state. */
410 unsigned short int a
[3]; /* Factor in congruential formula. */
411 unsigned short int c
; /* Additive const. in congruential formula. */
412 unsigned short int old_x
[3]; /* Old state. */
413 int init
; /* Flag for initializing. */
417 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
418 extern int drand48_r
__P ((struct drand48_data
*__buffer
, double *__result
));
419 extern int erand48_r
__P ((unsigned short int __xsubi
[3],
420 struct drand48_data
*__buffer
, double *__result
));
422 /* Return non-negative, long integer in [0,2^31). */
423 extern int lrand48_r
__P ((struct drand48_data
*__buffer
, long int *__result
));
424 extern int nrand48_r
__P ((unsigned short int __xsubi
[3],
425 struct drand48_data
*__buffer
, long int *__result
));
427 /* Return signed, long integers in [-2^31,2^31). */
428 extern int mrand48_r
__P ((struct drand48_data
*__buffer
, long int *__result
));
429 extern int jrand48_r
__P ((unsigned short int __xsubi
[3],
430 struct drand48_data
*__buffer
, long int *__result
));
432 /* Seed random number generator. */
433 extern int srand48_r
__P ((long int __seedval
, struct drand48_data
*__buffer
));
435 extern int seed48_r
__P ((unsigned short int __seed16v
[3],
436 struct drand48_data
*__buffer
));
438 extern int lcong48_r
__P ((unsigned short int __param
[7],
439 struct drand48_data
*__buffer
));
440 # endif /* Use misc. */
441 #endif /* Use SVID or X/Open. */
444 /* Allocate SIZE bytes of memory. */
445 extern __ptr_t malloc
__P ((size_t __size
));
446 /* Re-allocate the previously allocated block
447 in __ptr_t, making the new block SIZE bytes long. */
448 extern __ptr_t realloc
__P ((__ptr_t __ptr
, size_t __size
));
449 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
450 extern __ptr_t calloc
__P ((size_t __nmemb
, size_t __size
));
451 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
452 extern void free
__P ((__ptr_t __ptr
));
455 /* Free a block. An alias for `free'. (Sun Unices). */
456 extern void cfree
__P ((__ptr_t __ptr
));
457 #endif /* Use misc. */
459 #if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
461 #endif /* Use GNU, BSD, or misc. */
463 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
464 /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
465 extern __ptr_t valloc
__P ((size_t __size
));
469 /* Abort execution and generate a core-dump. */
470 extern void abort
__P ((void)) __attribute__ ((__noreturn__
));
473 /* Register a function to be called when `exit' is called. */
474 extern int atexit
__P ((void (*__func
) (void)));
477 /* Register a function to be called with the status
478 given to `exit' and the given argument. */
479 extern int __on_exit
__P ((void (*__func
) (int __status
, __ptr_t __arg
),
481 extern int on_exit
__P ((void (*__func
) (int __status
, __ptr_t __arg
),
485 /* Call all functions registered with `atexit' and `on_exit',
486 in the reverse of the order in which they were registered
487 perform stdio cleanup, and terminate program execution with STATUS. */
488 extern void exit
__P ((int __status
)) __attribute__ ((__noreturn__
));
491 /* Return the value of envariable NAME, or NULL if it doesn't exist. */
492 extern char *getenv
__P ((__const
char *__name
));
494 /* This function is similar to the above but returns NULL if the
495 programs is running with SUID or SGID enabled. */
496 extern char *__secure_getenv
__P ((__const
char *__name
));
498 #if defined __USE_SVID || defined __USE_XOPEN
499 /* The SVID says this is in <stdio.h>, but this seems a better place. */
500 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
501 If there is no `=', remove NAME from the environment. */
502 extern int putenv
__P ((__const
char *__string
));
506 /* Set NAME to VALUE in the environment.
507 If REPLACE is nonzero, overwrite an existing value. */
508 extern int setenv
__P ((__const
char *__name
, __const
char *__value
,
511 /* Remove the variable NAME from the environment. */
512 extern void unsetenv
__P ((__const
char *__name
));
516 /* The `clearenv' was planned to be added to POSIX.1 but probably
517 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
518 for Fortran 77) requires this function. */
519 extern int clearenv
__P ((void));
523 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
524 /* Generate a unique temporary file name from TEMPLATE.
525 The last six characters of TEMPLATE must be "XXXXXX";
526 they are replaced with a string that makes the file name unique.
527 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
528 extern char *mktemp
__P ((char *__template
));
530 /* Generate a unique temporary file name from TEMPLATE.
531 The last six characters of TEMPLATE must be "XXXXXX";
532 they are replaced with a string that makes the filename unique.
533 Returns a file descriptor open on the file for reading and writing,
534 or -1 if it cannot create a uniquely-named file. */
535 extern int mkstemp
__P ((char *__template
));
539 /* Execute the given line as a shell command. */
540 extern int system
__P ((__const
char *__command
));
544 /* Return a malloc'd string containing the canonical absolute name of the
545 named file. The last file name component need not exist, and may be a
546 symlink to a nonexistent file. */
547 extern char *canonicalize_file_name
__P ((__const
char *__name
));
550 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
551 /* Return the canonical absolute name of file NAME. The last file name
552 component need not exist, and may be a symlink to a nonexistent file.
553 If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
554 name is PATH_MAX chars or more, returns null with `errno' set to
555 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
557 extern char *realpath
__P ((__const
char *__name
, char *__resolved
));
561 /* Shorthand for type of comparison functions. */
562 #ifndef __COMPAR_FN_T
563 # define __COMPAR_FN_T
564 typedef int (*__compar_fn_t
) __PMT ((__const __ptr_t
, __const __ptr_t
));
567 typedef __compar_fn_t comparison_fn_t
;
571 /* Do a binary search for KEY in BASE, which consists of NMEMB elements
572 of SIZE bytes each, using COMPAR to perform the comparisons. */
573 extern __ptr_t bsearch
__PMT ((__const __ptr_t __key
, __const __ptr_t __base
,
574 size_t __nmemb
, size_t __size
,
575 __compar_fn_t __compar
));
577 /* Sort NMEMB elements of BASE, of SIZE bytes each,
578 using COMPAR to perform the comparisons. */
579 extern void qsort
__PMT ((__ptr_t __base
, size_t __nmemb
, size_t __size
,
580 __compar_fn_t __compar
));
583 /* Return the absolute value of X. */
584 extern int abs
__P ((int __x
)) __attribute__ ((__const__
));
585 extern long int labs
__P ((long int __x
)) __attribute__ ((__const__
));
587 extern long long int llabs
__P ((long long int __x
))
588 __attribute__ ((__const__
));
592 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
593 of the value of NUMER over DENOM. */
594 /* GCC may have built-ins for these someday. */
595 extern div_t div
__P ((int __numer
, int __denom
)) __attribute__ ((__const__
));
596 extern ldiv_t ldiv
__P ((long int __numer
, long int __denom
))
597 __attribute__ ((__const__
));
599 extern lldiv_t lldiv
__P ((long long int __numer
, long long int __denom
))
600 __attribute__ ((__const__
));
604 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
605 /* Convert floating point numbers to strings. The returned values are
606 valid only until another call to the same function. */
608 /* Convert VALUE to a string with NDIGIT digits and return a pointer to
609 this. Set *DECPT with the position of the decimal character and *SIGN
610 with the sign of the number. */
611 extern char *ecvt
__P ((double __value
, int __ndigit
, int *__decpt
,
614 /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
615 with the position of the decimal character and *SIGN with the sign of
617 extern char *fcvt
__P ((double __value
, int __ndigit
, int *__decpt
,
620 /* If possible convert VALUE to a string with NDIGIT significant digits.
621 Otherwise use exponential representation. The resulting string will
622 be written to BUF. */
623 extern char *gcvt
__P ((double __value
, int __ndigit
, char *__buf
));
625 /* Long double versions of above functions. */
626 extern char *qecvt
__P ((__long_double_t __value
, int __ndigit
, int *__decpt
,
628 extern char *qfcvt
__P ((__long_double_t __value
, int __ndigit
, int *__decpt
,
630 extern char *qgcvt
__P ((__long_double_t __value
, int __ndigit
, char *__buf
));
634 /* Reentrant version of the functions above which provide their own
636 extern int ecvt_r
__P ((double __value
, int __ndigit
, int *__decpt
,
637 int *__sign
, char *__buf
, size_t __len
));
638 extern int fcvt_r
__P ((double __value
, int __ndigit
, int *__decpt
,
639 int *__sign
, char *__buf
, size_t __len
));
641 extern int qecvt_r
__P ((__long_double_t __value
, int __ndigit
, int *__decpt
,
642 int *__sign
, char *__buf
, size_t __len
));
643 extern int qfcvt_r
__P ((__long_double_t __value
, int __ndigit
, int *__decpt
,
644 int *__sign
, char *__buf
, size_t __len
));
646 #endif /* use MISC || use X/Open Unix */
649 /* Return the length of the multibyte character
650 in S, which is no longer than N. */
651 extern int mblen
__P ((__const
char *__s
, size_t __n
));
652 /* Return the length of the given multibyte character,
653 putting its `wchar_t' representation in *PWC. */
654 extern int mbtowc
__P ((wchar_t *__restrict __pwc
,
655 __const
char *__restrict __s
, size_t __n
));
656 /* Put the multibyte character represented
657 by WCHAR in S, returning its length. */
658 extern int wctomb
__P ((char *__s
, wchar_t __wchar
));
661 /* Convert a multibyte string to a wide char string. */
662 extern size_t mbstowcs
__P ((wchar_t *__restrict __pwcs
,
663 __const
char *__restrict __s
, size_t __n
));
664 /* Convert a wide char string to multibyte string. */
665 extern size_t wcstombs
__P ((char *__restrict __s
,
666 __const
wchar_t *__restrict __pwcs
, size_t __n
));
670 /* Determine whether the string value of RESPONSE matches the affirmation
671 or negative response expression as specified by the LC_MESSAGES category
672 in the program's current locale. Returns 1 if affirmative, 0 if
673 negative, and -1 if not matching. */
674 extern int rpmatch
__P ((__const
char *__response
));
678 #ifdef __USE_XOPEN_EXTENDED
679 /* Parse comma separated suboption from *OPTIONP and match against
680 strings in TOKENS. If found return index and set *VALUEP to
681 optional value introduced by an equal sign. If the suboption is
682 not part of TOKENS return in *VALUEP beginning of unknown
683 suboption. On exit *OPTIONP is set to the beginning of the next
684 token or at the terminating NUL character. */
685 extern int getsubopt
__P ((char **__optionp
, __const
char *__const
*__tokens
,
692 /* Setup DES tables according KEY. */
693 extern void setkey
__P ((__const
char *__key
));
695 /* X/Open pseudo terminal handling. */
697 /* The next four functions all take a master pseudo-tty fd and
698 perform an operation on the associated slave: */
700 /* Chown the slave to the calling user. */
701 extern int grantpt
__P ((int __fd
));
703 /* Release an internal lock so the slave can be opened.
704 Call after grantpt(). */
705 extern int unlockpt
__P ((int __fd
));
707 /* Return the pathname of the pseudo terminal slave assoicated with
708 the master FD is open on, or NULL on errors.
709 The returned storage is good until the next call to this function. */
710 extern char *ptsname
__P ((int __fd
));
714 /* Store at most BUFLEN characters of the pathname of the slave pseudo
715 terminal associated with the master FD is open on in BUF.
716 Return 0 on success, otherwise an error number. */
717 extern int ptsname_r
__P ((int __fd
, char *__buf
, size_t __buflen
));
719 /* Open a master pseudo terminal and return its file descriptor. */
720 extern int getpt
__P ((void));
725 #endif /* stdlib.h */