Wrapper around strtol.c to compile as strtoll_l.
[glibc/history.git] / stdlib / stdlib.h
blob40c24eb8f0c81da6daa1e598aa5b8ed09ba761e4
1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 #define _STDLIB_H 1
26 #include <features.h>
28 /* Get size_t, wchar_t and NULL from <stddef.h>. */
29 #define __need_size_t
30 #define __need_wchar_t
31 #define __need_NULL
32 #include <stddef.h>
34 __BEGIN_DECLS
36 /* Returned by `div'. */
37 typedef struct
39 int quot; /* Quotient. */
40 int rem; /* Remainder. */
41 } div_t;
43 /* Returned by `ldiv'. */
44 typedef struct
46 long int quot; /* Quotient. */
47 long int rem; /* Remainder. */
48 } ldiv_t;
50 #ifdef __USE_ISOC9X
51 /* Returned by `lldiv'. */
52 typedef struct
54 long long int quot; /* Quotient. */
55 long long int rem; /* Remainder. */
56 } lldiv_t;
57 #endif
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));
85 #endif
87 /* Convert a string to a floating-point number. */
88 extern double strtod __P ((__const char *__restrict __nptr,
89 char **__restrict __endptr));
91 #ifdef __USE_GNU
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));
98 #endif
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,
106 int __base));
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,
115 int __base));
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,
127 int __base));
128 #endif /* ISO C 9X or GCC and use MISC. */
131 #ifdef __USE_GNU
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
138 argument.
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,
151 __locale_t __loc));
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,
159 __locale_t __loc));
161 extern unsigned long long int __strtoull_l __P ((__const char *__restrict
162 __nptr,
163 char **__restrict __endptr,
164 int __base,
165 __locale_t __loc));
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,
175 __locale_t __loc));
176 #endif /* GNU */
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,
184 int __group));
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 *
188 __restrict __nptr,
189 char **__restrict __endptr,
190 int __group));
191 extern long int __strtol_internal __P ((__const char *__restrict __nptr,
192 char **__restrict __endptr,
193 int __base, int __group));
194 extern unsigned long int __strtoul_internal __P ((__const char *
195 __restrict __nptr,
196 char **__restrict __endptr,
197 int __base, int __group));
198 #ifdef __GNUC__
199 extern long long int __strtoll_internal __P ((__const char *__restrict __nptr,
200 char **__restrict __endptr,
201 int __base, int __group));
202 extern unsigned long long int __strtoull_internal __P ((__const char *
203 __restrict __nptr,
204 char **
205 __restrict __endptr,
206 int __base,
207 int __group));
208 #endif /* GCC */
210 #if defined __OPTIMIZE__ && __GNUC__ >= 2
211 /* Define inline functions which call the internal entry points. */
213 extern __inline double strtod (__const char *__restrict __nptr,
214 char **__restrict __endptr)
215 { return __strtod_internal (__nptr, __endptr, 0); }
216 extern __inline long int strtol (__const char *__restrict __nptr,
217 char **__restrict __endptr, int __base)
218 { return __strtol_internal (__nptr, __endptr, __base, 0); }
219 extern __inline unsigned long int strtoul (__const char *__restrict __nptr,
220 char **__restrict __endptr,
221 int __base)
222 { return __strtoul_internal (__nptr, __endptr, __base, 0); }
224 #ifdef __USE_GNU
225 extern __inline float strtof (__const char *__restrict __nptr,
226 char **__restrict __endptr)
227 { return __strtof_internal (__nptr, __endptr, 0); }
228 extern __inline __long_double_t strtold (__const char *__restrict __nptr,
229 char **__restrict __endptr)
230 { return __strtold_internal (__nptr, __endptr, 0); }
231 #endif
233 #ifdef __USE_BSD
234 extern __inline long long int strtoq (__const char *__restrict __nptr,
235 char **__restrict __endptr, int __base)
236 { return __strtoll_internal (__nptr, __endptr, __base, 0); }
237 extern __inline unsigned long long int strtouq (__const char *__restrict __nptr,
238 char **__restrict __endptr,
239 int __base)
240 { return __strtoull_internal (__nptr, __endptr, __base, 0); }
241 #endif
243 #if defined __USE_MISC || defined __USE_ISOC9X
244 extern __inline long long int strtoll (__const char *__restrict __nptr,
245 char **__restrict __endptr, int __base)
246 { return __strtoll_internal (__nptr, __endptr, __base, 0); }
247 extern __inline unsigned long long int strtoull (__const char *
248 __restrict __nptr,
249 char **__restrict __endptr,
250 int __base)
251 { return __strtoull_internal (__nptr, __endptr, __base, 0); }
252 #endif
254 extern __inline double atof (__const char *__nptr)
255 { return strtod (__nptr, (char **) NULL); }
256 extern __inline int atoi (__const char *__nptr)
257 { return (int) strtol (__nptr, (char **) NULL, 10); }
258 extern __inline long int atol (__const char *__nptr)
259 { return strtol (__nptr, (char **) NULL, 10); }
261 #if defined __USE_MISC || defined __USE_ISOC9X
262 extern __inline long long int atoll (__const char *__nptr)
263 { return strtoll (__nptr, (char **) NULL, 10); }
264 #endif
265 #endif /* Optimizing GCC >=2. */
268 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
269 /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
270 digit first. Returns a pointer to static storage overwritten by the
271 next call. */
272 extern char *l64a __P ((long int __n));
274 /* Read a number from a string S in base 64 as above. */
275 extern long int a64l __P ((__const char *__s));
278 #include <sys/types.h> /* we need int32_t... */
280 /* These are the functions that actually do things. The `random', `srandom',
281 `initstate' and `setstate' functions are those from BSD Unices.
282 The `rand' and `srand' functions are required by the ANSI standard.
283 We provide both interfaces to the same random number generator. */
284 /* Return a random long integer between 0 and RAND_MAX inclusive. */
285 extern int32_t __random __P ((void));
286 extern int32_t random __P ((void));
288 /* Seed the random number generator with the given number. */
289 extern void __srandom __P ((unsigned int __seed));
290 extern void srandom __P ((unsigned int __seed));
292 /* Initialize the random number generator to use state buffer STATEBUF,
293 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
294 32, 64, 128 and 256, the bigger the better; values less than 8 will
295 cause an error and values greater than 256 will be rounded down. */
296 extern __ptr_t __initstate __P ((unsigned int __seed, __ptr_t __statebuf,
297 size_t __statelen));
298 extern __ptr_t initstate __P ((unsigned int __seed, __ptr_t __statebuf,
299 size_t __statelen));
301 /* Switch the random number generator to state buffer STATEBUF,
302 which should have been previously initialized by `initstate'. */
303 extern __ptr_t __setstate __P ((__ptr_t __statebuf));
304 extern __ptr_t setstate __P ((__ptr_t __statebuf));
307 #ifdef __USE_MISC
308 /* Reentrant versions of the `random' family of functions.
309 These functions all use the following data structure to contain
310 state, rather than global state variables. */
312 struct random_data
314 int32_t *fptr; /* Front pointer. */
315 int32_t *rptr; /* Rear pointer. */
316 int32_t *state; /* Array of state values. */
317 int rand_type; /* Type of random number generator. */
318 int rand_deg; /* Degree of random number generator. */
319 int rand_sep; /* Distance between front and rear. */
320 int32_t *end_ptr; /* Pointer behind state table. */
323 extern int __random_r __P ((struct random_data *__buf, int32_t *__result));
324 extern int random_r __P ((struct random_data *__buf, int32_t *__result));
326 extern int __srandom_r __P ((unsigned int __seed, struct random_data *__buf));
327 extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf));
329 extern int __initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
330 size_t __statelen, struct random_data *__buf));
331 extern int initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
332 size_t __statelen, struct random_data *__buf));
334 extern int __setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
335 extern int setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
336 #endif /* Use misc. */
337 #endif /* Use SVID || extended X/Open. */
340 /* Return a random integer between 0 and RAND_MAX inclusive. */
341 extern int rand __P ((void));
342 /* Seed the random number generator with the given number. */
343 extern void srand __P ((unsigned int __seed));
345 #ifdef __USE_MISC
346 /* Reentrant interface according to POSIX.1. */
347 extern int __rand_r __P ((unsigned int *__seed));
348 extern int rand_r __P ((unsigned int *__seed));
349 #endif
352 #if defined __USE_SVID || defined __USE_XOPEN
353 /* System V style 48-bit random number generator functions. */
355 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
356 extern double drand48 __P ((void));
357 extern double erand48 __P ((unsigned short int __xsubi[3]));
359 /* Return non-negative, long integer in [0,2^31). */
360 extern long int lrand48 __P ((void));
361 extern long int nrand48 __P ((unsigned short int __xsubi[3]));
363 /* Return signed, long integers in [-2^31,2^31). */
364 extern long int mrand48 __P ((void));
365 extern long int jrand48 __P ((unsigned short int __xsubi[3]));
367 /* Seed random number generator. */
368 extern void srand48 __P ((long int __seedval));
369 extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
370 extern void lcong48 __P ((unsigned short int __param[7]));
372 /* Data structure for communication with thread safe versions. */
373 struct drand48_data
375 unsigned short int X[3]; /* Current state. */
376 unsigned short int a[3]; /* Factor in congruential formula. */
377 unsigned short int c; /* Additive const. in congruential formula. */
378 unsigned short int old_X[3]; /* Old state. */
379 int init; /* Flag for initializing. */
382 #ifdef __USE_MISC
383 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
384 extern int drand48_r __P ((struct drand48_data *__buffer, double *__result));
385 extern int __erand48_r __P ((unsigned short int __xsubi[3],
386 struct drand48_data *__buffer, double *__result));
387 extern int erand48_r __P ((unsigned short int __xsubi[3],
388 struct drand48_data *__buffer, double *__result));
390 /* Return non-negative, long integer in [0,2^31). */
391 extern int lrand48_r __P ((struct drand48_data *__buffer, long int *__result));
392 extern int __nrand48_r __P ((unsigned short int __xsubi[3],
393 struct drand48_data *__buffer,
394 long int *__result));
395 extern int nrand48_r __P ((unsigned short int __xsubi[3],
396 struct drand48_data *__buffer, long int *__result));
398 /* Return signed, long integers in [-2^31,2^31). */
399 extern int mrand48_r __P ((struct drand48_data *__buffer, long int *__result));
400 extern int __jrand48_r __P ((unsigned short int __xsubi[3],
401 struct drand48_data *__buffer,
402 long int *__result));
403 extern int jrand48_r __P ((unsigned short int __xsubi[3],
404 struct drand48_data *__buffer, long int *__result));
406 /* Seed random number generator. */
407 extern int __srand48_r __P ((long int __seedval,
408 struct drand48_data *__buffer));
409 extern int srand48_r __P ((long int __seedval, struct drand48_data *__buffer));
411 extern int __seed48_r __P ((unsigned short int __seed16v[3],
412 struct drand48_data *__buffer));
413 extern int seed48_r __P ((unsigned short int __seed16v[3],
414 struct drand48_data *__buffer));
416 extern int __lcong48_r __P ((unsigned short int __param[7],
417 struct drand48_data *__buffer));
418 extern int lcong48_r __P ((unsigned short int __param[7],
419 struct drand48_data *__buffer));
420 #endif /* Use misc. */
422 /* Internal function to compute next state of the generator. */
423 extern int __drand48_iterate __P ((unsigned short int __xsubi[3],
424 struct drand48_data *__buffer));
425 #endif /* Use SVID or X/Open. */
428 /* Allocate SIZE bytes of memory. */
429 extern __ptr_t malloc __P ((size_t __size));
430 /* Re-allocate the previously allocated block
431 in __ptr_t, making the new block SIZE bytes long. */
432 extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size));
433 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
434 extern __ptr_t calloc __P ((size_t __nmemb, size_t __size));
435 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
436 extern void free __P ((__ptr_t __ptr));
438 #ifdef __USE_MISC
439 /* Free a block. An alias for `free'. (Sun Unices). */
440 extern void cfree __P ((__ptr_t __ptr));
441 #endif /* Use misc. */
443 #if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
444 #include <alloca.h>
445 #endif /* Use GNU, BSD, or misc. */
447 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
448 /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
449 extern __ptr_t valloc __P ((size_t __size));
450 #endif
453 /* Abort execution and generate a core-dump. */
454 extern void abort __P ((void)) __attribute__ ((__noreturn__));
457 /* Register a function to be called when `exit' is called. */
458 extern int atexit __P ((void (*__func) (void)));
460 #ifdef __USE_MISC
461 /* Register a function to be called with the status
462 given to `exit' and the given argument. */
463 extern int __on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
464 __ptr_t __arg));
465 extern int on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
466 __ptr_t __arg));
467 #endif
469 /* Call all functions registered with `atexit' and `on_exit',
470 in the reverse of the order in which they were registered
471 perform stdio cleanup, and terminate program execution with STATUS. */
472 extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
475 /* Return the value of envariable NAME, or NULL if it doesn't exist. */
476 extern char *getenv __P ((__const char *__name));
478 /* This function is similar to the above but returns NULL if the
479 programs is running with SUID or SGID enabled. */
480 extern char *__secure_getenv __P ((__const char *__name));
482 #if defined __USE_SVID || defined __USE_XOPEN
483 /* The SVID says this is in <stdio.h>, but this seems a better place. */
484 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
485 If there is no `=', remove NAME from the environment. */
486 extern int putenv __P ((__const char *__string));
487 #endif
489 #ifdef __USE_BSD
490 /* Set NAME to VALUE in the environment.
491 If REPLACE is nonzero, overwrite an existing value. */
492 extern int setenv __P ((__const char *__name, __const char *__value,
493 int __replace));
495 /* Remove the variable NAME from the environment. */
496 extern void unsetenv __P ((__const char *__name));
497 #endif
499 #ifdef __USE_MISC
500 /* The `clearenv' was planned to be added to POSIX.1 but probably
501 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
502 for Fortran 77) requires this function. */
503 extern int __clearenv __P ((void));
504 extern int clearenv __P ((void));
505 #endif
508 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
509 /* Generate a unique temporary file name from TEMPLATE.
510 The last six characters of TEMPLATE must be "XXXXXX";
511 they are replaced with a string that makes the file name unique.
512 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
513 extern char *mktemp __P ((char *__template));
515 /* Generate a unique temporary file name from TEMPLATE.
516 The last six characters of TEMPLATE must be "XXXXXX";
517 they are replaced with a string that makes the filename unique.
518 Returns a file descriptor open on the file for reading and writing,
519 or -1 if it cannot create a uniquely-named file. */
520 extern int mkstemp __P ((char *__template));
521 #endif
524 /* Execute the given line as a shell command. */
525 extern int system __P ((__const char *__command));
528 #ifdef __USE_GNU
529 /* Return a malloc'd string containing the canonical absolute name of the
530 named file. The last file name component need not exist, and may be a
531 symlink to a nonexistent file. */
532 extern char *canonicalize_file_name __P ((__const char *__name));
533 #endif
535 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
536 /* Return the canonical absolute name of file NAME. The last file name
537 component need not exist, and may be a symlink to a nonexistent file.
538 If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
539 name is PATH_MAX chars or more, returns null with `errno' set to
540 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
541 name in RESOLVED. */
542 extern char *realpath __P ((__const char *__name, char *__resolved));
543 #endif
546 /* Shorthand for type of comparison functions. */
547 #ifndef __COMPAR_FN_T
548 #define __COMPAR_FN_T
549 typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
550 #endif
552 #ifdef __USE_GNU
553 typedef __compar_fn_t comparison_fn_t;
554 #endif
556 /* Do a binary search for KEY in BASE, which consists of NMEMB elements
557 of SIZE bytes each, using COMPAR to perform the comparisons. */
558 extern __ptr_t bsearch __P ((__const __ptr_t __key, __const __ptr_t __base,
559 size_t __nmemb, size_t __size,
560 __compar_fn_t __compar));
562 /* Sort NMEMB elements of BASE, of SIZE bytes each,
563 using COMPAR to perform the comparisons. */
564 extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
565 __compar_fn_t __compar));
568 /* Return the absolute value of X. */
569 extern int abs __P ((int __x)) __attribute__ ((__const__));
570 extern long int labs __P ((long int __x)) __attribute__ ((__const__));
571 #if defined __USE_ISOC9X
572 extern long long int llabs __P ((long long int __x))
573 __attribute__ ((__const__));
574 #endif
577 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
578 of the value of NUMER over DENOM. */
579 /* GCC may have built-ins for these someday. */
580 extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
581 extern ldiv_t ldiv __P ((long int __numer, long int __denom))
582 __attribute__ ((__const__));
583 #ifdef __USE_ISOC9X
584 extern lldiv_t lldiv __P ((long long int __numer, long long int __denom))
585 __attribute__ ((__const__));
586 #endif
589 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
590 /* Convert floating point numbers to strings. The returned values are
591 valid only until another call to the same function. */
593 /* Convert VALUE to a string with NDIGIT digits and return a pointer to
594 this. Set *DECPT with the position of the decimal character and *SIGN
595 with the sign of the number. */
596 extern char *ecvt __P ((double __value, int __ndigit, int *__decpt,
597 int *__sign));
599 /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
600 with the position of the decimal character and *SIGN with the sign of
601 the number. */
602 extern char *fcvt __P ((double __value, int __ndigit, int *__decpt,
603 int *__sign));
605 /* If possible convert VALUE to a string with NDIGIT significant digits.
606 Otherwise use exponential representation. The resulting string will
607 be written to BUF. */
608 extern char *gcvt __P ((double __value, int __ndigit, char *__buf));
610 /* Long double versions of above functions. */
611 extern char *qecvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
612 int *__sign));
613 extern char *qfcvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
614 int *__sign));
615 extern char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf));
618 #ifdef __USE_MISC
619 /* Reentrant version of the functions above which provide their own
620 buffers. */
621 extern int ecvt_r __P ((double __value, int __ndigit, int *__decpt,
622 int *__sign, char *__buf, size_t __len));
623 extern int fcvt_r __P ((double __value, int __ndigit, int *__decpt,
624 int *__sign, char *__buf, size_t __len));
626 extern int qecvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
627 int *__sign, char *__buf, size_t __len));
628 extern int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
629 int *__sign, char *__buf, size_t __len));
630 #endif /* misc */
631 #endif /* use MISC || use X/Open Unix */
634 /* Return the length of the multibyte character
635 in S, which is no longer than N. */
636 extern int mblen __P ((__const char *__s, size_t __n));
637 /* Return the length of the given multibyte character,
638 putting its `wchar_t' representation in *PWC. */
639 extern int mbtowc __P ((wchar_t *__restrict __pwc,
640 __const char *__restrict __s, size_t __n));
641 /* Put the multibyte character represented
642 by WCHAR in S, returning its length. */
643 extern int wctomb __P ((char *__s, wchar_t __wchar));
645 #if defined __OPTIMIZE__ && __GNUC__ >= 2
646 extern __inline int mblen (__const char *__s, size_t __n)
647 { return mbtowc ((wchar_t *) NULL, __s, __n); }
648 #endif /* Optimizing GCC >=2. */
651 /* Convert a multibyte string to a wide char string. */
652 extern size_t mbstowcs __P ((wchar_t *__restrict __pwcs,
653 __const char *__restrict __s, size_t __n));
654 /* Convert a wide char string to multibyte string. */
655 extern size_t wcstombs __P ((char *__restrict __s,
656 __const wchar_t *__restrict __pwcs, size_t __n));
659 #ifdef __USE_SVID
660 /* Determine whether the string value of RESPONSE matches the affirmation
661 or negative response expression as specified by the LC_MESSAGES category
662 in the program's current locale. Returns 1 if affirmative, 0 if
663 negative, and -1 if not matching. */
664 extern int rpmatch __P ((__const char *__response));
665 #endif
668 #ifdef __USE_XOPEN_EXTENDED
669 /* Parse comma separated suboption from *OPTIONP and match against
670 strings in TOKENS. If found return index and set *VALUEP to
671 optional value introduced by an equal sign. If the suboption is
672 not part of TOKENS return in *VALUEP beginning of unknown
673 suboption. On exit *OPTIONP is set to the beginning of the next
674 otken or at the terminating NUL character. */
675 extern int getsubopt __P ((char **__optionp, __const char *__const *__tokens,
676 char **__valuep));
677 #endif
680 #ifdef __USE_XOPEN
682 /* Setup DES tables according KEY. */
683 extern void setkey __P ((__const char *__key));
684 #endif
687 __END_DECLS
689 #endif /* stdlib.h */