popt 1.13
|
00001 00005 #ifdef HAVE_CONFIG_H 00006 #include "config.h" 00007 #endif 00008 00009 #if defined (__GLIBC__) && defined(__LCLINT__) 00010 /*@-declundef@*/ 00011 /*@unchecked@*/ 00012 extern __const __int32_t *__ctype_tolower; 00013 /*@unchecked@*/ 00014 extern __const __int32_t *__ctype_toupper; 00015 /*@=declundef@*/ 00016 #endif 00017 00018 #include <ctype.h> 00019 00020 /* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */ 00021 #define _isspaceptr(_chp) isspace((int)(*(unsigned char *)(_chp))) 00022 00023 #include <errno.h> 00024 #include <fcntl.h> 00025 #include <limits.h> 00026 00027 #ifdef HAVE_MCHECK_H 00028 #include <mcheck.h> 00029 #endif 00030 00031 #include <stdio.h> 00032 #include <stdlib.h> 00033 #include <string.h> 00034 00035 #ifdef HAVE_UNISTD_H 00036 #include <unistd.h> 00037 #endif 00038 00039 #ifdef __NeXT 00040 /* access macros are not declared in non posix mode in unistd.h - 00041 don't try to use posix on NeXTstep 3.3 ! */ 00042 #include <libc.h> 00043 #endif 00044 00045 /*@-incondefs@*/ 00046 /*@mayexit@*/ /*@only@*/ /*@out@*/ /*@unused@*/ 00047 void * xmalloc (size_t size) 00048 /*@globals errno @*/ 00049 /*@ensures maxSet(result) == (size - 1) @*/ 00050 /*@modifies errno @*/; 00051 00052 /*@mayexit@*/ /*@only@*/ /*@unused@*/ 00053 void * xcalloc (size_t nmemb, size_t size) 00054 /*@ensures maxSet(result) == (nmemb - 1) @*/ 00055 /*@*/; 00056 00057 /*@mayexit@*/ /*@only@*/ /*@unused@*/ 00058 void * xrealloc (/*@null@*/ /*@only@*/ void * ptr, size_t size) 00059 /*@ensures maxSet(result) == (size - 1) @*/ 00060 /*@modifies *ptr @*/; 00061 00062 /*@mayexit@*/ /*@only@*/ /*@unused@*/ 00063 char * xstrdup (const char *str) 00064 /*@*/; 00065 /*@=incondefs@*/ 00066 00067 /* Memory allocation via macro defs to get meaningful locations from mtrace() */ 00068 #if defined(HAVE_MCHECK_H) && defined(__GNUC__) 00069 #define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL) 00070 #define xmalloc(_size) (malloc(_size) ? : vmefail()) 00071 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail()) 00072 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail()) 00073 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str))) 00074 #else 00075 #define xmalloc(_size) malloc(_size) 00076 #define xcalloc(_nmemb, _size) calloc((_nmemb), (_size)) 00077 #define xrealloc(_ptr, _size) realloc((_ptr), (_size)) 00078 #define xstrdup(_str) strdup(_str) 00079 #endif /* defined(HAVE_MCHECK_H) && defined(__GNUC__) */ 00080 00081 #if defined(HAVE___SECURE_GETENV) && !defined(__LCLINT__) 00082 #define getenv(_s) __secure_getenv(_s) 00083 #endif 00084 00085 #include "popt.h"