(_IO_seekoff): Only remove pushback buffer if mode!=0.
[glibc/history.git] / stdlib / stdlib.h
blobe577fb7245aca455e54902de5b25445f7a6ee22f
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>
23 #ifndef _STDLIB_H
25 #include <features.h>
27 /* Get size_t, wchar_t and NULL from <stddef.h>. */
28 #define __need_size_t
29 #ifndef __need_malloc_and_calloc
30 # define __need_wchar_t
31 # define __need_NULL
32 #endif
33 #include <stddef.h>
35 __BEGIN_DECLS
37 #ifndef __need_malloc_and_calloc
38 #define _STDLIB_H 1
40 /* Returned by `div'. */
41 typedef struct
43 int quot; /* Quotient. */
44 int rem; /* Remainder. */
45 } div_t;
47 /* Returned by `ldiv'. */
48 typedef struct
50 long int quot; /* Quotient. */
51 long int rem; /* Remainder. */
52 } ldiv_t;
54 #ifdef __USE_ISOC9X
55 /* Returned by `lldiv'. */
56 typedef struct
58 long long int quot; /* Quotient. */
59 long long int rem; /* Remainder. */
60 } lldiv_t;
61 #endif
64 /* The largest number rand will return (same as INT_MAX). */
65 #define RAND_MAX 2147483647
68 /* We define these the same for all machines.
69 Changes from this to the outside world should be done in `_exit'. */
70 #define EXIT_FAILURE 1 /* Failing exit status. */
71 #define EXIT_SUCCESS 0 /* Successful exit status. */
74 /* Maximum length of a multibyte character in the current locale. */
75 #define MB_CUR_MAX (__ctype_get_mb_cur_max ())
76 extern int __ctype_get_mb_cur_max __P ((void));
79 /* Convert a string to a floating-point number. */
80 extern double atof __P ((__const char *__nptr));
81 /* Convert a string to an integer. */
82 extern int atoi __P ((__const char *__nptr));
83 /* Convert a string to a long integer. */
84 extern long int atol __P ((__const char *__nptr));
86 #if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
87 /* These functions will part of the standard C library in ISO C 9X. */
88 extern long long int atoll __P ((__const char *__nptr));
89 #endif
91 /* Convert a string to a floating-point number. */
92 extern double strtod __P ((__const char *__restrict __nptr,
93 char **__restrict __endptr));
95 #ifdef __USE_ISOC9X
96 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
97 extern float strtof __P ((__const char *__restrict __nptr,
98 char **__restrict __endptr));
100 extern __long_double_t strtold __P ((__const char *__restrict __nptr,
101 char **__restrict __endptr));
102 #endif
104 /* Convert a string to a long integer. */
105 extern long int strtol __P ((__const char *__restrict __nptr,
106 char **__restrict __endptr, int __base));
107 /* Convert a string to an unsigned long integer. */
108 extern unsigned long int strtoul __P ((__const char *__restrict __nptr,
109 char **__restrict __endptr,
110 int __base));
112 #if defined __GNUC__ && defined __USE_BSD
113 /* Convert a string to a quadword integer. */
114 extern long long int strtoq __P ((__const char *__restrict __nptr,
115 char **__restrict __endptr, int __base));
116 /* Convert a string to an unsigned quadword integer. */
117 extern unsigned long long int strtouq __P ((__const char *__restrict __nptr,
118 char **__restrict __endptr,
119 int __base));
120 #endif /* GCC and use BSD. */
122 #if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
123 /* These functions will part of the standard C library in ISO C 9X. */
125 /* Convert a string to a quadword integer. */
126 extern long long int strtoll __P ((__const char *__restrict __nptr,
127 char **__restrict __endptr, int __base));
128 /* Convert a string to an unsigned quadword integer. */
129 extern unsigned long long int strtoull __P ((__const char *__restrict __nptr,
130 char **__restrict __endptr,
131 int __base));
132 #endif /* ISO C 9X or GCC and use MISC. */
135 #ifdef __USE_GNU
136 /* The concept of one static locale per category is not very well
137 thought out. Many applications will need to process its data using
138 information from several different locales. Another application is
139 the implementation of the internationalization handling in the
140 upcoming ISO C++ standard library. To support this another set of
141 the functions using locale data exist which have an additional
142 argument.
144 Attention: all these functions are *not* standardized in any form.
145 This is a proof-of-concept implementation. */
147 /* Structure for reentrant locale using functions. This is an
148 (almost) opaque type for the user level programs. */
149 # include <xlocale.h>
151 /* Special versions of the functions above which take the locale to
152 use as an additional parameter. */
153 extern long int __strtol_l __P ((__const char *__restrict __nptr,
154 char **__restrict __endptr, int __base,
155 __locale_t __loc));
157 extern unsigned long int __strtoul_l __P ((__const char *__restrict __nptr,
158 char **__restrict __endptr,
159 int __base, __locale_t __loc));
161 extern long long int __strtoll_l __P ((__const char *__restrict __nptr,
162 char **__restrict __endptr, int __base,
163 __locale_t __loc));
165 extern unsigned long long int __strtoull_l __P ((__const char *__restrict
166 __nptr,
167 char **__restrict __endptr,
168 int __base,
169 __locale_t __loc));
171 extern double __strtod_l __P ((__const char *__restrict __nptr,
172 char **__restrict __endptr, __locale_t __loc));
174 extern float __strtof_l __P ((__const char *__restrict __nptr,
175 char **__restrict __endptr, __locale_t __loc));
177 extern __long_double_t __strtold_l __P ((__const char *__restrict __nptr,
178 char **__restrict __endptr,
179 __locale_t __loc));
180 #endif /* GNU */
183 /* The internal entry points for `strtoX' take an extra flag argument
184 saying whether or not to parse locale-dependent number grouping. */
186 extern double __strtod_internal __P ((__const char *__restrict __nptr,
187 char **__restrict __endptr,
188 int __group));
189 extern float __strtof_internal __P ((__const char *__restrict __nptr,
190 char **__restrict __endptr, int __group));
191 extern __long_double_t __strtold_internal __P ((__const char *
192 __restrict __nptr,
193 char **__restrict __endptr,
194 int __group));
195 #ifndef __strtol_internal_defined
196 extern long int __strtol_internal __P ((__const char *__restrict __nptr,
197 char **__restrict __endptr,
198 int __base, int __group));
199 # define __strtol_internal_defined 1
200 #endif
201 #ifndef __strtoul_internal_defined
202 extern unsigned long int __strtoul_internal __P ((__const char *
203 __restrict __nptr,
204 char **__restrict __endptr,
205 int __base, int __group));
206 # define __strtoul_internal_defined 1
207 #endif
208 #if defined __GNUC__ || defined __USE_ISOC9X
209 # ifndef __strtoll_internal_defined
210 extern long long int __strtoll_internal __P ((__const char *__restrict __nptr,
211 char **__restrict __endptr,
212 int __base, int __group));
213 # define __strtoll_internal_defined 1
214 # endif
215 # ifndef __strtoull_internal_defined
216 extern unsigned long long int __strtoull_internal __P ((__const char *
217 __restrict __nptr,
218 char **
219 __restrict __endptr,
220 int __base,
221 int __group));
222 # define __strtoull_internal_defined 1
223 # endif
224 #endif /* GCC */
226 #if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
227 && defined __USE_EXTERN_INLINES
228 /* Define inline functions which call the internal entry points. */
230 extern __inline double
231 strtod (__const char *__restrict __nptr, char **__restrict __endptr)
233 return __strtod_internal (__nptr, __endptr, 0);
235 extern __inline long int
236 strtol (__const char *__restrict __nptr, char **__restrict __endptr,
237 int __base)
239 return __strtol_internal (__nptr, __endptr, __base, 0);
241 extern __inline unsigned long int
242 strtoul (__const char *__restrict __nptr, char **__restrict __endptr,
243 int __base)
245 return __strtoul_internal (__nptr, __endptr, __base, 0);
248 # ifdef __USE_ISOC9X
249 extern __inline float
250 strtof (__const char *__restrict __nptr, char **__restrict __endptr)
252 return __strtof_internal (__nptr, __endptr, 0);
254 extern __inline __long_double_t
255 strtold (__const char *__restrict __nptr, char **__restrict __endptr)
257 return __strtold_internal (__nptr, __endptr, 0);
259 # endif
261 # ifdef __USE_BSD
262 extern __inline long long int
263 strtoq (__const char *__restrict __nptr, char **__restrict __endptr,
264 int __base)
266 return __strtoll_internal (__nptr, __endptr, __base, 0);
268 extern __inline unsigned long long int
269 strtouq (__const char *__restrict __nptr, char **__restrict __endptr,
270 int __base)
272 return __strtoull_internal (__nptr, __endptr, __base, 0);
274 # endif
276 # if defined __USE_MISC || defined __USE_ISOC9X
277 extern __inline long long int
278 strtoll (__const char *__restrict __nptr, char **__restrict __endptr,
279 int __base)
281 return __strtoll_internal (__nptr, __endptr, __base, 0);
283 extern __inline unsigned long long int
284 strtoull (__const char * __restrict __nptr, char **__restrict __endptr,
285 int __base)
287 return __strtoull_internal (__nptr, __endptr, __base, 0);
289 # endif
291 extern __inline double
292 atof (__const char *__nptr)
294 return strtod (__nptr, (char **) NULL);
296 extern __inline int
297 atoi (__const char *__nptr)
299 return (int) strtol (__nptr, (char **) NULL, 10);
301 extern __inline long int
302 atol (__const char *__nptr)
304 return strtol (__nptr, (char **) NULL, 10);
307 # if defined __USE_MISC || defined __USE_ISOC9X
308 extern __inline long long int
309 atoll (__const char *__nptr)
311 return strtoll (__nptr, (char **) NULL, 10);
313 # endif
314 #endif /* Optimizing and Inlining. */
317 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
318 /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
319 digit first. Returns a pointer to static storage overwritten by the
320 next call. */
321 extern char *l64a __P ((long int __n));
323 /* Read a number from a string S in base 64 as above. */
324 extern long int a64l __P ((__const char *__s));
327 # include <sys/types.h> /* we need int32_t... */
329 /* These are the functions that actually do things. The `random', `srandom',
330 `initstate' and `setstate' functions are those from BSD Unices.
331 The `rand' and `srand' functions are required by the ANSI standard.
332 We provide both interfaces to the same random number generator. */
333 /* Return a random long integer between 0 and RAND_MAX inclusive. */
334 extern int32_t random __P ((void));
336 /* Seed the random number generator with the given number. */
337 extern void srandom __P ((unsigned int __seed));
339 /* Initialize the random number generator to use state buffer STATEBUF,
340 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
341 32, 64, 128 and 256, the bigger the better; values less than 8 will
342 cause an error and values greater than 256 will be rounded down. */
343 extern __ptr_t initstate __P ((unsigned int __seed, __ptr_t __statebuf,
344 size_t __statelen));
346 /* Switch the random number generator to state buffer STATEBUF,
347 which should have been previously initialized by `initstate'. */
348 extern __ptr_t setstate __P ((__ptr_t __statebuf));
351 # ifdef __USE_MISC
352 /* Reentrant versions of the `random' family of functions.
353 These functions all use the following data structure to contain
354 state, rather than global state variables. */
356 struct random_data
358 int32_t *fptr; /* Front pointer. */
359 int32_t *rptr; /* Rear pointer. */
360 int32_t *state; /* Array of state values. */
361 int rand_type; /* Type of random number generator. */
362 int rand_deg; /* Degree of random number generator. */
363 int rand_sep; /* Distance between front and rear. */
364 int32_t *end_ptr; /* Pointer behind state table. */
367 extern int random_r __P ((struct random_data *__buf, int32_t *__result));
369 extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf));
371 extern int initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
372 size_t __statelen, struct random_data *__buf));
374 extern int setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
375 # endif /* Use misc. */
376 #endif /* Use SVID || extended X/Open. */
379 /* Return a random integer between 0 and RAND_MAX inclusive. */
380 extern int rand __P ((void));
381 /* Seed the random number generator with the given number. */
382 extern void srand __P ((unsigned int __seed));
384 #ifdef __USE_POSIX
385 /* Reentrant interface according to POSIX.1. */
386 extern int rand_r __P ((unsigned int *__seed));
387 #endif
390 #if defined __USE_SVID || defined __USE_XOPEN
391 /* System V style 48-bit random number generator functions. */
393 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
394 extern double drand48 __P ((void));
395 extern double erand48 __P ((unsigned short int __xsubi[3]));
397 /* Return non-negative, long integer in [0,2^31). */
398 extern long int lrand48 __P ((void));
399 extern long int nrand48 __P ((unsigned short int __xsubi[3]));
401 /* Return signed, long integers in [-2^31,2^31). */
402 extern long int mrand48 __P ((void));
403 extern long int jrand48 __P ((unsigned short int __xsubi[3]));
405 /* Seed random number generator. */
406 extern void srand48 __P ((long int __seedval));
407 extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
408 extern void lcong48 __P ((unsigned short int __param[7]));
410 /* Data structure for communication with thread safe versions. */
411 struct drand48_data
413 unsigned short int x[3]; /* Current state. */
414 unsigned short int a[3]; /* Factor in congruential formula. */
415 unsigned short int c; /* Additive const. in congruential formula. */
416 unsigned short int old_x[3]; /* Old state. */
417 int init; /* Flag for initializing. */
420 # ifdef __USE_MISC
421 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
422 extern int drand48_r __P ((struct drand48_data *__buffer, double *__result));
423 extern int erand48_r __P ((unsigned short int __xsubi[3],
424 struct drand48_data *__buffer, double *__result));
426 /* Return non-negative, long integer in [0,2^31). */
427 extern int lrand48_r __P ((struct drand48_data *__buffer, long int *__result));
428 extern int nrand48_r __P ((unsigned short int __xsubi[3],
429 struct drand48_data *__buffer, long int *__result));
431 /* Return signed, long integers in [-2^31,2^31). */
432 extern int mrand48_r __P ((struct drand48_data *__buffer, long int *__result));
433 extern int jrand48_r __P ((unsigned short int __xsubi[3],
434 struct drand48_data *__buffer, long int *__result));
436 /* Seed random number generator. */
437 extern int srand48_r __P ((long int __seedval, struct drand48_data *__buffer));
439 extern int seed48_r __P ((unsigned short int __seed16v[3],
440 struct drand48_data *__buffer));
442 extern int lcong48_r __P ((unsigned short int __param[7],
443 struct drand48_data *__buffer));
444 # endif /* Use misc. */
445 #endif /* Use SVID or X/Open. */
447 #endif /* don't just need malloc and calloc */
449 #ifndef __malloc_and_calloc_defined
450 #define __malloc_and_calloc_defined
451 /* Allocate SIZE bytes of memory. */
452 extern __ptr_t malloc __P ((size_t __size));
453 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
454 extern __ptr_t calloc __P ((size_t __nmemb, size_t __size));
455 #endif
457 #ifndef __need_malloc_and_calloc
458 /* Re-allocate the previously allocated block
459 in __ptr_t, making the new block SIZE bytes long. */
460 extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size));
461 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
462 extern void free __P ((__ptr_t __ptr));
464 #ifdef __USE_MISC
465 /* Free a block. An alias for `free'. (Sun Unices). */
466 extern void cfree __P ((__ptr_t __ptr));
467 #endif /* Use misc. */
469 #if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
470 # include <alloca.h>
471 #endif /* Use GNU, BSD, or misc. */
473 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
474 /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
475 extern __ptr_t valloc __P ((size_t __size));
476 #endif
479 /* Abort execution and generate a core-dump. */
480 extern void abort __P ((void)) __attribute__ ((__noreturn__));
483 /* Register a function to be called when `exit' is called. */
484 extern int atexit __P ((void (*__func) (void)));
486 #ifdef __USE_MISC
487 /* Register a function to be called with the status
488 given to `exit' and the given argument. */
489 extern int __on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
490 __ptr_t __arg));
491 extern int on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
492 __ptr_t __arg));
493 #endif
495 /* Call all functions registered with `atexit' and `on_exit',
496 in the reverse of the order in which they were registered
497 perform stdio cleanup, and terminate program execution with STATUS. */
498 extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
501 /* Return the value of envariable NAME, or NULL if it doesn't exist. */
502 extern char *getenv __P ((__const char *__name));
504 /* This function is similar to the above but returns NULL if the
505 programs is running with SUID or SGID enabled. */
506 extern char *__secure_getenv __P ((__const char *__name));
508 #if defined __USE_SVID || defined __USE_XOPEN
509 /* The SVID says this is in <stdio.h>, but this seems a better place. */
510 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
511 If there is no `=', remove NAME from the environment. */
512 extern int putenv __P ((__const char *__string));
513 #endif
515 #ifdef __USE_BSD
516 /* Set NAME to VALUE in the environment.
517 If REPLACE is nonzero, overwrite an existing value. */
518 extern int setenv __P ((__const char *__name, __const char *__value,
519 int __replace));
521 /* Remove the variable NAME from the environment. */
522 extern void unsetenv __P ((__const char *__name));
523 #endif
525 #ifdef __USE_MISC
526 /* The `clearenv' was planned to be added to POSIX.1 but probably
527 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
528 for Fortran 77) requires this function. */
529 extern int clearenv __P ((void));
530 #endif
533 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
534 /* Generate a unique temporary file name from TEMPLATE.
535 The last six characters of TEMPLATE must be "XXXXXX";
536 they are replaced with a string that makes the file name unique.
537 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
538 extern char *mktemp __P ((char *__template));
540 /* Generate a unique temporary file name from TEMPLATE.
541 The last six characters of TEMPLATE must be "XXXXXX";
542 they are replaced with a string that makes the filename unique.
543 Returns a file descriptor open on the file for reading and writing,
544 or -1 if it cannot create a uniquely-named file. */
545 extern int mkstemp __P ((char *__template));
546 #endif
549 /* Execute the given line as a shell command. */
550 extern int system __P ((__const char *__command));
553 #ifdef __USE_GNU
554 /* Return a malloc'd string containing the canonical absolute name of the
555 named file. The last file name component need not exist, and may be a
556 symlink to a nonexistent file. */
557 extern char *canonicalize_file_name __P ((__const char *__name));
558 #endif
560 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
561 /* Return the canonical absolute name of file NAME. The last file name
562 component need not exist, and may be a symlink to a nonexistent file.
563 If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
564 name is PATH_MAX chars or more, returns null with `errno' set to
565 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
566 name in RESOLVED. */
567 extern char *realpath __P ((__const char *__name, char *__resolved));
568 #endif
571 /* Shorthand for type of comparison functions. */
572 #ifndef __COMPAR_FN_T
573 # define __COMPAR_FN_T
574 typedef int (*__compar_fn_t) __PMT ((__const __ptr_t, __const __ptr_t));
576 # ifdef __USE_GNU
577 typedef __compar_fn_t comparison_fn_t;
578 # endif
579 #endif
581 /* Do a binary search for KEY in BASE, which consists of NMEMB elements
582 of SIZE bytes each, using COMPAR to perform the comparisons. */
583 extern __ptr_t bsearch __PMT ((__const __ptr_t __key, __const __ptr_t __base,
584 size_t __nmemb, size_t __size,
585 __compar_fn_t __compar));
587 /* Sort NMEMB elements of BASE, of SIZE bytes each,
588 using COMPAR to perform the comparisons. */
589 extern void qsort __PMT ((__ptr_t __base, size_t __nmemb, size_t __size,
590 __compar_fn_t __compar));
593 /* Return the absolute value of X. */
594 extern int abs __P ((int __x)) __attribute__ ((__const__));
595 extern long int labs __P ((long int __x)) __attribute__ ((__const__));
596 #ifdef __USE_ISOC9X
597 extern long long int llabs __P ((long long int __x))
598 __attribute__ ((__const__));
599 #endif
602 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
603 of the value of NUMER over DENOM. */
604 /* GCC may have built-ins for these someday. */
605 extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
606 extern ldiv_t ldiv __P ((long int __numer, long int __denom))
607 __attribute__ ((__const__));
608 #ifdef __USE_ISOC9X
609 extern lldiv_t lldiv __P ((long long int __numer, long long int __denom))
610 __attribute__ ((__const__));
611 #endif
614 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
615 /* Convert floating point numbers to strings. The returned values are
616 valid only until another call to the same function. */
618 /* Convert VALUE to a string with NDIGIT digits and return a pointer to
619 this. Set *DECPT with the position of the decimal character and *SIGN
620 with the sign of the number. */
621 extern char *ecvt __P ((double __value, int __ndigit, int *__decpt,
622 int *__sign));
624 /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
625 with the position of the decimal character and *SIGN with the sign of
626 the number. */
627 extern char *fcvt __P ((double __value, int __ndigit, int *__decpt,
628 int *__sign));
630 /* If possible convert VALUE to a string with NDIGIT significant digits.
631 Otherwise use exponential representation. The resulting string will
632 be written to BUF. */
633 extern char *gcvt __P ((double __value, int __ndigit, char *__buf));
635 /* Long double versions of above functions. */
636 extern char *qecvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
637 int *__sign));
638 extern char *qfcvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
639 int *__sign));
640 extern char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf));
643 # ifdef __USE_MISC
644 /* Reentrant version of the functions above which provide their own
645 buffers. */
646 extern int ecvt_r __P ((double __value, int __ndigit, int *__decpt,
647 int *__sign, char *__buf, size_t __len));
648 extern int fcvt_r __P ((double __value, int __ndigit, int *__decpt,
649 int *__sign, char *__buf, size_t __len));
651 extern int qecvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
652 int *__sign, char *__buf, size_t __len));
653 extern int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
654 int *__sign, char *__buf, size_t __len));
655 # endif /* misc */
656 #endif /* use MISC || use X/Open Unix */
659 /* Return the length of the multibyte character
660 in S, which is no longer than N. */
661 extern int mblen __P ((__const char *__s, size_t __n));
662 /* Return the length of the given multibyte character,
663 putting its `wchar_t' representation in *PWC. */
664 extern int mbtowc __P ((wchar_t *__restrict __pwc,
665 __const char *__restrict __s, size_t __n));
666 /* Put the multibyte character represented
667 by WCHAR in S, returning its length. */
668 extern int wctomb __P ((char *__s, wchar_t __wchar));
671 /* Convert a multibyte string to a wide char string. */
672 extern size_t mbstowcs __P ((wchar_t *__restrict __pwcs,
673 __const char *__restrict __s, size_t __n));
674 /* Convert a wide char string to multibyte string. */
675 extern size_t wcstombs __P ((char *__restrict __s,
676 __const wchar_t *__restrict __pwcs, size_t __n));
679 #ifdef __USE_SVID
680 /* Determine whether the string value of RESPONSE matches the affirmation
681 or negative response expression as specified by the LC_MESSAGES category
682 in the program's current locale. Returns 1 if affirmative, 0 if
683 negative, and -1 if not matching. */
684 extern int rpmatch __P ((__const char *__response));
685 #endif
688 #ifdef __USE_XOPEN_EXTENDED
689 /* Parse comma separated suboption from *OPTIONP and match against
690 strings in TOKENS. If found return index and set *VALUEP to
691 optional value introduced by an equal sign. If the suboption is
692 not part of TOKENS return in *VALUEP beginning of unknown
693 suboption. On exit *OPTIONP is set to the beginning of the next
694 token or at the terminating NUL character. */
695 extern int getsubopt __P ((char **__optionp, __const char *__const *__tokens,
696 char **__valuep));
697 #endif
700 #ifdef __USE_XOPEN
702 /* Setup DES tables according KEY. */
703 extern void setkey __P ((__const char *__key));
705 /* X/Open pseudo terminal handling. */
707 /* The next four functions all take a master pseudo-tty fd and
708 perform an operation on the associated slave: */
710 /* Chown the slave to the calling user. */
711 extern int grantpt __P ((int __fd));
713 /* Release an internal lock so the slave can be opened.
714 Call after grantpt(). */
715 extern int unlockpt __P ((int __fd));
717 /* Return the pathname of the pseudo terminal slave assoicated with
718 the master FD is open on, or NULL on errors.
719 The returned storage is good until the next call to this function. */
720 extern char *ptsname __P ((int __fd));
721 #endif
723 #ifdef __USE_GNU
724 /* Store at most BUFLEN characters of the pathname of the slave pseudo
725 terminal associated with the master FD is open on in BUF.
726 Return 0 on success, otherwise an error number. */
727 extern int ptsname_r __P ((int __fd, char *__buf, size_t __buflen));
729 /* Open a master pseudo terminal and return its file descriptor. */
730 extern int getpt __P ((void));
731 #endif
733 #endif /* don't just need malloc and calloc */
734 #undef __need_malloc_and_calloc
736 __END_DECLS
738 #endif /* stdlib.h */