| 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 |  | 
|---|
| 15 | #include <stddef.h> /* size_t */ | 
|---|
| 16 |  | 
|---|
| 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 | 
|---|
| 25 | void *xmalloc(size_t); | 
|---|
| 26 | void *xrealloc(void *, size_t); | 
|---|
| 27 | char *xstrdup(const char *str); | 
|---|
| 28 | #endif | 
|---|
| 29 |  | 
|---|
| 30 | int pperror(const char *s, ...) __attribute__((format (printf, 1, 2))); | 
|---|
| 31 | int ppwarning(const char *s, ...) __attribute__((format (printf, 1, 2))); | 
|---|
| 32 | int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2))); | 
|---|
| 33 | int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2))); | 
|---|
| 34 | void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4))); | 
|---|
| 35 | void error(const char *s, ...) __attribute__((format (printf, 1, 2))); | 
|---|
| 36 | void warning(const char *s, ...) __attribute__((format (printf, 1, 2))); | 
|---|
| 37 | void chat(const char *s, ...) __attribute__((format (printf, 1, 2))); | 
|---|
| 38 |  | 
|---|
| 39 | char *dup_basename(const char *name, const char *ext); | 
|---|
| 40 | char *dupwstr2cstr(const short *str); | 
|---|
| 41 | short *dupcstr2wstr(const char *str); | 
|---|
| 42 | int compare_name_id(name_id_t *n1, name_id_t *n2); | 
|---|
| 43 | string_t *convert_string(const string_t *str, enum str_e type); | 
|---|
| 44 | void set_language(unsigned short lang, unsigned short sublang); | 
|---|
| 45 |  | 
|---|
| 46 | #if defined(__IBMC__) || defined(__IBMCPP__) | 
|---|
| 47 | int strcasecmp( char *p1, char *p2 ); | 
|---|
| 48 |  | 
|---|
| 49 | /* Borrowed from Apache NT Port and PHP */ | 
|---|
| 50 |  | 
|---|
| 51 | extern char *ap_php_optarg; | 
|---|
| 52 | extern int   ap_php_optind; | 
|---|
| 53 | extern int   ap_php_opterr; | 
|---|
| 54 | extern int   ap_php_optopt; | 
|---|
| 55 | int ap_php_getopt(int argc, char* const *argv, const char *optstr); | 
|---|
| 56 |  | 
|---|
| 57 | #define getopt  ap_php_getopt | 
|---|
| 58 | #define optarg  ap_php_optarg | 
|---|
| 59 | #define optind  ap_php_optind | 
|---|
| 60 | #define opterr  ap_php_opterr | 
|---|
| 61 | #define optopt  ap_php_optopt | 
|---|
| 62 |  | 
|---|
| 63 | #endif | 
|---|
| 64 |  | 
|---|
| 65 | #endif | 
|---|