source: trunk/tools/wrc/utils.h@ 6112

Last change on this file since 6112 was 6112, checked in by bird, 24 years ago

Added memory debugging stuff. EMX -> WIN32OS2. Note -Tm+ makes it *very* slow!! Delcared strcasecmp and getopt stuff for VAC.

File size: 2.0 KB
Line 
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__)
18void *_xmalloc(size_t, char*, int);
19void *_xrealloc(void *, size_t, char*, int);
20char *_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
25void *xmalloc(size_t);
26void *xrealloc(void *, size_t);
27char *xstrdup(const char *str);
28#endif
29
30int pperror(const char *s, ...) __attribute__((format (printf, 1, 2)));
31int ppwarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
32int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
33int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
34void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
35void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
36void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
37void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
38
39char *dup_basename(const char *name, const char *ext);
40char *dupwstr2cstr(const short *str);
41short *dupcstr2wstr(const char *str);
42int compare_name_id(name_id_t *n1, name_id_t *n2);
43string_t *convert_string(const string_t *str, enum str_e type);
44void set_language(unsigned short lang, unsigned short sublang);
45
46#if defined(__IBMC__) || defined(__IBMCPP__)
47int strcasecmp( char *p1, char *p2 );
48
49/* Borrowed from Apache NT Port and PHP */
50
51extern char *ap_php_optarg;
52extern int ap_php_optind;
53extern int ap_php_opterr;
54extern int ap_php_optopt;
55int 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
Note: See TracBrowser for help on using the repository browser.