[882] | 1 | /*
|
---|
| 2 | * Utility routines' prototypes etc.
|
---|
| 3 | *
|
---|
| 4 | * Copyright 1998 Bertho A. Stultiens (BS)
|
---|
| 5 | *
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef __WRC_UTILS_H
|
---|
| 9 | #define __WRC_UTILS_H
|
---|
| 10 |
|
---|
| 11 | #ifndef __WRC_WRCTYPES_H
|
---|
| 12 | #include "wrctypes.h"
|
---|
| 13 | #endif
|
---|
| 14 |
|
---|
[6112] | 15 | #include <stddef.h> /* size_t */
|
---|
[882] | 16 |
|
---|
[6112] | 17 | #if defined(__DEBUG_ALLOC__) && defined(__IBMC__)
|
---|
| 18 | void *_xmalloc(size_t, char*, int);
|
---|
| 19 | void *_xrealloc(void *, size_t, char*, int);
|
---|
| 20 | char *_xstrdup(const char *, char*, int);
|
---|
| 21 | #define xmalloc(a) _xmalloc(a, __FILE__, __LINE__)
|
---|
| 22 | #define xrealloc(a, b) _xrealloc(a, b, __FILE__, __LINE__)
|
---|
| 23 | #define xstrdup(a) _xstrdup(a, __FILE__, __LINE__)
|
---|
| 24 | #else
|
---|
[882] | 25 | void *xmalloc(size_t);
|
---|
| 26 | void *xrealloc(void *, size_t);
|
---|
| 27 | char *xstrdup(const char *str);
|
---|
[21929] | 28 | char *xtempnam(const char *dir, const char *prefix);
|
---|
[6112] | 29 | #endif
|
---|
[882] | 30 |
|
---|
[5523] | 31 | int pperror(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
---|
| 32 | int ppwarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
---|
| 33 | int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
---|
| 34 | int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
---|
| 35 | void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
|
---|
| 36 | void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
---|
| 37 | void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
---|
| 38 | void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
---|
[882] | 39 |
|
---|
| 40 | char *dup_basename(const char *name, const char *ext);
|
---|
| 41 | char *dupwstr2cstr(const short *str);
|
---|
| 42 | short *dupcstr2wstr(const char *str);
|
---|
[5523] | 43 | int compare_name_id(name_id_t *n1, name_id_t *n2);
|
---|
| 44 | string_t *convert_string(const string_t *str, enum str_e type);
|
---|
| 45 | void set_language(unsigned short lang, unsigned short sublang);
|
---|
[882] | 46 |
|
---|
[6112] | 47 | #if defined(__IBMC__) || defined(__IBMCPP__)
|
---|
[8596] | 48 | #undef strcasecmp
|
---|
| 49 | INT WINAPI strcasecmp(LPCSTR p1, LPCSTR p2);
|
---|
[6112] | 50 |
|
---|
| 51 | /* Borrowed from Apache NT Port and PHP */
|
---|
| 52 |
|
---|
| 53 | extern char *ap_php_optarg;
|
---|
| 54 | extern int ap_php_optind;
|
---|
| 55 | extern int ap_php_opterr;
|
---|
| 56 | extern int ap_php_optopt;
|
---|
| 57 | int ap_php_getopt(int argc, char* const *argv, const char *optstr);
|
---|
| 58 |
|
---|
| 59 | #define getopt ap_php_getopt
|
---|
| 60 | #define optarg ap_php_optarg
|
---|
| 61 | #define optind ap_php_optind
|
---|
| 62 | #define opterr ap_php_opterr
|
---|
| 63 | #define optopt ap_php_optopt
|
---|
| 64 |
|
---|
[882] | 65 | #endif
|
---|
[6112] | 66 |
|
---|
| 67 | #endif
|
---|