/* This file contains stubs of all (I think) ANSI C library functions. * This is intended to serve as a reference; there's no point in compiling it. * The idea is that you put this file in an accessible but out-of-the-way * location, and run ctags on it. Then you set the TAGPATH environment * variable to include this file's directory. From that point on, you can * use the normal tag searching functions to see the declaration for any * of these functions. In particular, the "ref" program distributed with * elvis is handy for this. */ /* */ #define NULL 0 /* */ typedef struct _filestruct *FILE; FILE *stdin, *stdout, *stderr; /* time/date breakdown */ struct tm { int tm_sec; /* second, 0-59 */ int tm_min; /* minute, 0-59 */ int tm_hour; /* hour, 0-23 */ int tm_mday; /* day of month, 1-31 */ int tm_mon; /* month, 0-11 */ int tm_year; /* year, 1970-2038 */ int tm_wday; /* day of week, 0=sunday - 6=saturday */ int tm_yday; /* day of year, 0-364 (365 on leap years) */ int tm_isdst; /* daylight savings time flag */ }; /* formats of numbers and money */ struct lconv { /* NUMERIC */ char *decimal_point; /* Decimal point character */ char *thousands_sep; /* Thousands separator */ char *grouping; /* one-byte ints giving groups, end with 0 to repeat or CHAR_MAX to stop grouping */ /* MONETARY */ char *int_curr_symbol; /* 3-byte ISO-4217 synbol, 1-byte separator */ char *currency_symbol; /* Local currency symbol */ char *mon_decimal_point;/* Decimal point character */ char *mon_thousands_sep;/* Thousands separator. */ char *mon_grouping; /* Like `grouping' element (above). */ char *positive_sign; /* Sign for positive values. */ char *negative_sign; /* Sign for negative values. */ char int_frac_digits; /* Int'l fractional digits. */ char frac_digits; /* Local fractional digits. */ char p_cs_precedes; /* currency_symbol preceeds positive amount? */ char p_sep_by_space; /* space between currency_symbol & positive? */ char n_cs_precedes; /* currency_symbol preceeds negative amount? */ char n_sep_by_space; /* space between currency_symbol & negative? */ char p_sign_posn; /* 0=parentheses, 1=before both, 2=after both,*/ char n_sign_posn; /* 3=before cuurency_symbol, 4=after it */ }; /* Returned by div() */ typedef struct { int quot; /* Quotient */ int rem; /* Remainder */ } div_t; /* Returned by ldiv() */ typedef struct { long quot; /* Quotient */ long rem; /* Remainder */ } ldiv_t; /* wide characters, typically `unsigned short' */ typedef OPAQUE wchar_t; /* type returned by sizeof operator, traditionally `int' */ typedef OPAQUE size_t; /* type returned by clock(), typically `long int' */ typedef OPAQUE clock_t; /* type returned by time(), traditionally `long int' */ typedef OPAQUE time_t; /* type returned by fgetpos(), typically `long int' */ typedef OPAQUE fpos_t; /* type returned by ftell(), traditionally `long int'. Apparently * ANSI continues to use `long int' instead of `off_t', but `off_t' is still * preferred because 32-bit offsets aren't big enough anymore. `off_t' may be * a larger data type than `long int'. This doesn't necessarily mean that * your libraries and OS support the larger offsets, of course. */ typedef OPAQUE off_t; /* Cause a core dump */ void abort(void) { } /* Return the absolute value of an int */ int abs(int num) { } /* Return the angle whose cosine is cosvalue */ double acos(double cosvalue) { } /* Return a date/time string, e.g., "Wed Jun 30 21:49:08 1993\n" */ char *asctime(const struct tm *currtime) { } /* Return the angle whose sine is sinvalue */ double asin(double sinvalue) { } /* If expression is false, abort */ void assert(int expression) { } /* Return the angle whose tangent is tanvalue */ double atan(double tanvalue) { } /* Return the angle from (0,0) to (x,y) */ double atan2(double y, double x) { } /* Arrange for func() to be called when the program exits */ int atexit(void(*func)(void)) { } /* Convert a string to a double */ double atof(const char *string) { } /* Convert a string to an int */ int atoi(const char *string) { } /* Convert a string to a long */ long int atol(const char *string) { } /* Seach through an array for a given item. There are five * arguments: the item to find, the array to find it in, the number of * items in the array, the size of each item, and a pointer to a comparison * function. It returns a pointer to the found item, or NULL if it isn't * found. */ void *bsearch(const void *itemx, const void *array, size_t nitems, size_t itemsize, int (*compare) (const void *itemi, const void *itemj)) { } /* Allocate an array, and initialize it to 0 */ void *calloc(size_t num, size_t length) { } /* Round upwards to the next integer value (might not fit in "int") */ double ceil(double upwards) { } /* Clear the error flag on a FILE */ void clearerr(FILE *fp) { } /* Return the approximate CPU time used by this process, in time * slices. To get seconds, divide by CLOCKS_PER_SEC. */ clock_t clock(void) { } /* Return the cosine for a given angle */ double cos(double angle) { } /* Return the hyperbolic cosine of an angle */ double cosh(double angle) { } /* Return a date/time string, e.g., "Wed Jun 30 21:49:08 1993\n" */ char *ctime(const time_t *timeval) { } /* Compute the time difference, in seconds, between two times */ double difftime(time_t end, time_t begin) { } /* Compute the quotient and remainder of integer division */ div_t div(int number, int divider) { } /* Terminate this process */ void exit(int exit_code) { } /* Return e^num */ double exp(double num) { } /* Return the absolute value of num */ double fabs(double num) { } /* Close a FILE */ int fclose(FILE *fp) { } /* Return a true (non-zero) value if a previous attempt to read * from fp resulted in an end-of-file condition; else return false (0). * Note that this function doesn't "look ahead" -- you must try to read * past the EOF before this function will know you've hit it. */ int feof(FILE *fp) { } /* Return a true (non-zero) value if a previos I/O operation on fp * failed for any reason. */ int ferror(FILE *fp) { } /* Flush any data written to fp, by writing it to the operating * system. Note that this does not necessarily guarantee that the data has * been written to disk. */ int fflush(FILE *fp) { } /* Read a character or EOF from fp. */ int fgetc(FILE *fp) { } /* Store fp's current record number into the position argument */ int fgetpos(FILE *fp, fpos_t *position) { } /* Read a string from fp. Returns NULL at end of file. */ char *fgets(char *string, int width, FILE *fp) { } /* Round a double to the next lower integer (might not fit an "int") */ double floor(double lower) { } /* Return the remainder of integer division, performed on doubles */ double fmod(double first, double second) { } /* Open a file. */ FILE *fopen(const char *file_name, const char *mode) { } /* Print formatted text out to fp. */ int fprintf(FILE *fp, const char *format, ...) { } /* Write a single character to fp */ int fputc(int ch, FILE *fp) { } /* Write a string to fp, without adding a newline. */ int fputs(const char *string, FILE *fp) { } /* Read an array of items from fp. "width" is the size of each * item, and "count" is the number of items requested. It returns the * number of items actually read. */ size_t fread(void *buffer, size_t width, size_t count, FILE *fp) { } /* Release memory allocated by malloc(), calloc(), or realloc() */ void free(void *memory_ptr) { } /* Force an existing fp to use a different file and/or mode */ FILE *freopen(const char *new_file, const char *mode, FILE *fp) { } /* Break a double into its exponent and (normalized) mantissa. */ double frexp(double num, int *exp) { } /* Scan a formatted text string from fp */ int fscanf(FILE *fp, const char *format, ...) { } /* Change fp's I/O offset */ int fseek(FILE *fp, long int offset, int whence) { } /* Restore fp's current record number to a position from a previous * fgetpos(). Note that the file must remain open between those two calls. */ int fsetpos(FILE *fp, const fpos_t *position) { } /* Write an array of items to fp. "width" is the size of each * item, and "count" is the number of items to be written. Returns the * number of items actually written. */ size_t fwrite(const void *buffer, size_t width, size_t count, FILE *fp) { } /* Get a single character from fp */ int getc(FILE *fp) { } /* Get a single character from stdin */ int getchar(void) { } /* Return the value (as a '\0'-terminated string) of an environment * variable. */ char *getenv(const char *name) { } /* Read a line from stdin, and strip off the terminating '\n'. * Return NULL if * the end of the file was encountered. THIS FUNCTION IS A * SECURITY HOLE! Use the fgets() function instead, and strip off the '\n' * from that function's returned value if necessary. */ char *gets(char *string) { } /* Return the I/O offset of fp */ long int ftell(FILE *fp) { } /* Return the absolute value of a long */ long int labs(long int num) { } /* Convert string to a long int. This is more versatile than * atol(), because it works with various bases (2 through 64, instead of * just base 10). Also, it has the side-effect of setting "end" to point * to the character after the number's last digit. */ long int strtol(const char *start, char **end, int base) { } /* True for letters and digits */ int isalnum(int ch) { } /* True for letters */ int isalpha(int ch) { } /* True for ASCII control characters */ int iscntrl(int ch) { } /* True for digits */ int isdigit(int ch) { } /* True for printable characters other than whitespace */ int isgraph(int ch) { } /* True for lowercase letters */ int islower(int ch) { } /* True for printable characters including whitespace */ int isprint(int ch) { } /* True for punctuation characters */ int ispunct(int ch) { } /* True for any whitespace character */ int isspace(int ch) { } /* True for uppercase letters */ int isupper(int ch) { } /* True for hexadecimal digits -- 0-9, a-f, A-F */ int isxdigit(int ch) { } /* Fetch the locale-specific information for numeric conversions */ struct lconv *localeconv(void) { } /* Return num * (2 ^ exp) -- i.e., add exp the num's exponent */ double ldexp(double num, int exp) { } /* Return the quotient and remainder of two longs */ ldiv_t ldiv(long int num, long int divisor) { } /* Return the natural logarithm of num */ double log(double num) { } /* Return the base-10 logarithm of num */ double log10(double num) { } /* Convert a string to an unsigned long int, using a given base */ unsigned long int strtoul(const char *start, char **end, int base) { } /* Jump to a location set by setjmp(). Note that the function * which called setjmp() must not have returned yet. */ void longjmp(jmp_buf jmpenv, int value) { } /* The entry point of a C program */ int main(void) or (int argc, char *argv[]) { } /* Allocate memory. The returned memory is NOT initialized */ void *malloc(size_t amount) { } /* Seach for ch in the first count bytes of string. String is * permitted to contain '\0' bytes. */ void *memchr(const void *string, int ch, size_t count) { } /* Compare two chunks of memory */ int memcmp(const void *area1, const void *area2, size_t width) { } /* Copy one chunk of memory into another (non-overlapping) chunk of * memory. If the regions might overlap, you should use memmove() instead. */ void *memcpy(void *to, const void *from, size_t width) { } /* Copy one chunk of memory into another. They are permitted to * overlap. */ void *memmove(void *to, const void *from, size_t width) { } /* Set every byte in a chunk of memory to "ch" */ void *memset(void *buffer, int ch, size_t count) { } /* Convert "local" into a time_t value */ time_t mktime(struct tm *local) { } /* Return the modulo (remainder of integer division)) of two doubles */ double modf(double num, *double whole) { } /* Print an error message to stderr. The string should identify * what caused the error (e.g., the name of a file that couldn't be opened). * The error's description is produced by examining the "errno" global * variable. */ void perror(const char *string) { } /* Return base^exp */ double pow(double base, double exp) { } /* Print a formatted string to stdout */ int printf(const char *format, ...) { } /* Write a single character to fp */ int putc(int ch, FILE *fp) { } /* write a single character to stdout */ int putchar(int ch) { } /* Write a string to stdout, and then write a '\n' character */ int puts(const char *string) { } /* Sort an array. There are four arguments: the array to sort, * the number of items in the array, the size of each item, and a pointer * to a comparison function. */ void qsort(void *array, size_t nitems, size_t itemsize, int (*compare)(const void *itemi, const void *itemj)) { } /* Send a single to yourself, like "kill(getpid(), signo)" */ int raise(int signo) { } /* Return a random number between 0 and RAND_MAX */ int rand(void) { } /* Change the size of a previously allocated chunk of memory. * If possible, leave it in the same location. If the surrounding memory * isn't free, then allocate a totally new chunk of memory, copy the old * data into it, and then free the old memory. Either way, return a * pointer to the reallocated chunk. */ void *realloc(void *mem, size_t new_size) { } /* Delete a file */ int remove(const char *filename) { } /* Rename a file */ int rename(const char *oldname, const char *newname) { } /* Reset fp to read from the beginning of a file */ void rewind(FILE *fp) { } /* Scan formatted text from stdin */ int scanf(const char *format , ...) { } /* Force fp to use a given buffer */ void setbuf(FILE *fp, char buffer[BUFSIZ]) { } /* Define the destination for a later longjmp() call. When * called initially, setjmp() returns 0. When longjmp() is called later, * setjmp() will appear to return again, this time with the value that was * passed into longjmp(). */ int setjmp(jmp_buf jmpenv) { } /* Set the locale */ char *setlocale(int type, const char *locale) { } /* "mode" is one _IONBF for unbuffered, _IOLBF for line buffered, * or _IOFBF for fully buffered. This function must be called before the * first I/O operation on the FILE. */ int setvbuf(FILE *fp, char *buffer, int mode, size_t width) { } /* This one looks trickier than it is. There are two arguments: * a signal number, and a function to call when that signal is received. * signal() returns the previous function pointer for that signal. The * catcher functions should accept a signal number argument, and return void. */ void (*signal (int signo, void (*fn)(int signo)))(int signo) { } /* Return the sine of an angle */ double sin(double angle) { } /* Return the hyperbolic sine of an angle */ double sinh(double angle) { } /* Write formatted text into a buffer. */ int sprintf(char *buffer, const char *format, ...) { } /* Return the square root of num */ double sqrt(double num) { } /* Set the seed for the random number generator, rand() */ void srand(unsigned int seed) { } /* Scan formatted text from a buffer */ int sscanf(const char *buffer, const char *format, ...) { } /* Append rear onto the end of the front string. It is assumed * that the front string's buffer is large enough to hold the combined string. */ char *strcat(char *front, const char *rear) { } /* Return a pointer to the first instance of ch in string. If it * doesn't appear there, then return NULL. */ char *strchr(const char *string, int ch) { } /* Compare two strings, without using the locale */ int strcmp(const char *first, const char *second) { } /* Compare two strings using the locale */ int strcoll(const char *first, const char *second) { } /* Copy a string */ char *strcpy(char *dest, const char *source) { } /* Count the initial chars in `string' which DON'T which appear in * the `chars' string. */ size_t strcspn(const char *string, const char *chars) { } /* Return the string describing an error */ char *strerror(int error_num) { } /* Convert a time from struct tm to a string, using a given format */ size_t strftime(char *date_time, size_t maxsize,const char *format, const struct tm *currtime) { } /* Return the length of a string */ size_t strlen(const char *string) { } /* Append the rear string onto the end of the front string, up * to an overall length limit. */ char *strncat(char *front, const char *rear, size_t length) { } /* Compare first "length" characters of two strings */ int strncmp(const char *first, const char *second, size_t length) { } /* Copy the first "length" characters of "from" into "to" */ char *strncpy(char *to, const char *from, size_t length) { } /* Locate the first instance of in string, of any character in * chars, and return a pointer to it. If no such character can be found, * return NULL. */ char *strpbrk(const char *string, const char *chars) { } /* Return a pointer to the last instance of ch in string, * or NULL if none. */ char *strrchr(const char *string, int ch) { } /* Count the initial chars in `string' which appear in `chars' */ size_t strspn(const char *string, const char *chars) { } /* Return a pointer to the first instance of `target' in `string', or NULL if * `target' doesn't appear anywhere in `string' */ char *strstr(const char *string, const char *target) { } /* Convert a string to a double. Also set *end to point to * character after the last digit of the number. */ double strtod(const char *start, char **end) { } /* Return a token from buf. On the first call, buf should be * the start of a buffer; on subsequent calls, it should be NULL. The * delim argument is used as a list of delimiter characters. Each call * will return sequential tokens from buf, until they've all been returned * at which point it switches to NULL. Note that buf is modified as this * progresses. */ char* strtok(char *buf, const char *delim) { } /* Transform a string into a form which can be used for * locale-dependent comparisons efficiently. */ size_t strxfrm(char *first, const char *second, size_t length) { } /* Run a program, and wait for it to complete. Return the exit * status of that program. */ int system(const char *command) { } /* Return the tangent of an angle */ double tan(double angle) { } /* Return the hyperbolic tangent of an angle */ double tanh(double angle) { } /* Return the current system time. If "tptr" is not NULL, then also * copy the current system time into the variable that it points to. */ time_t time(time_t *tptr) { } /* Decompose a time_t value, for the Universal Time zone */ struct tm *gmtime(const time_t *tptr) { } /* Decompose a time_t value, for the local time zone */ struct tm *localtime(const time_t *tptr) { } /* Create a temporary file */ FILE *tmpfile(void) { } /* Create a name for a temporary file. If buf is null, then it * uses a static variable to store the name. Note that some other process * may create a file with the same name before yours does, so this function * is not 100% reliable. */ char *tmpnam(char *buf) { } /* Convert ch to lowercase */ int tolower(int ch) { } /* Convert ch to uppercase */ int toupper(int ch) { } /* Stuff ch back into the input stream for fp */ int ungetc(int ch, FILE *fp) { } /* Return the next varargs value, for a given type */ type va_arg(va_list arg_ptr, type) { } /* End the varargs processing */ void va_end(va_list arg_ptr) { } /* Start the varargs processing. The variable portion of the * arguments start immediately after last_fixed_arg. Note that this is a * macro, and its second parameter is simply the identifier of an argument, * NOT A REFERENCE TO IT. */ void va_start(va_list first_arg, last_fixed_arg) { } /* and Print varargs out to fp */ int vfprintf(FILE *fp, const char *format, va_list arg_ptr) { } /* and Print varargs out to stdout */ int vprintf(const char *format, va_list arg_ptr) { } /* and Print varargs into a buffer */ int vsprintf(char *buffer, const char *format, va_list arg_ptr) { } /* Convert a string of multibyte characters into a string of wide * characters. Return the number of wide characters. If pwcs is NULL, then * still returns the count but does not store the converted text. */ mbstowcs(wchar_t *pwcs, const char *m_byte, size_t length) { } /* Convert a single wide character into a multibyte character * string, and return the number of bytes required for the multibyte text * (including a terminating NUL byte, if appropriate). Note that there is * no way to predict how large the m_byte buffer must be, but you're * responsible for making it large enough anyway. * * If m_byte is NULL then it resets its internal shift state and returns 1 * if that state was complex, or 0 if trivial. */ int wctomb(char* m_byte, wchar_t wide_char) { }