1 |
/* |
2 |
* fptools.c, some helper functions for getcgi.c and uu(en|de)view |
3 |
* |
4 |
* Distributed under the terms of the GNU General Public License. |
5 |
* Use and be happy. |
6 |
*/ |
7 |
|
8 |
/* |
9 |
* Some handy, nonstandard functions. Note that the original may |
10 |
* be both faster and better. ``better'', if your compiler allows |
11 |
* cleaner use of such functions by proper use of ``const''. |
12 |
* |
13 |
* $Id$ |
14 |
*/ |
15 |
|
16 |
#ifndef FPTOOLS_H__ |
17 |
#define FPTOOLS_H__ |
18 |
|
19 |
#include <string.h> |
20 |
|
21 |
typedef signed char schar; |
22 |
typedef unsigned char uchar; |
23 |
|
24 |
#include "ecb.h" |
25 |
|
26 |
#ifndef TOOLEXPORT |
27 |
#define TOOLEXPORT |
28 |
#endif |
29 |
|
30 |
#ifdef __cplusplus |
31 |
extern "C" { |
32 |
#endif |
33 |
|
34 |
#if HAVE_GETC_UNLOCKED |
35 |
# define FP_getc(s) getc_unlocked (s) |
36 |
#else |
37 |
# define FP_getc(s) getc (s) |
38 |
#endif |
39 |
|
40 |
#if HAVE_FEOF_UNLOCKED |
41 |
# define FP_feof(s) feof_unlocked (s) |
42 |
#else |
43 |
# define FP_feof(s) feof (s) |
44 |
#endif |
45 |
|
46 |
#if HAVE_FERROR_UNLOCKED |
47 |
# define FP_ferror(s) ferror_unlocked (s) |
48 |
#else |
49 |
# define FP_ferror(s) ferror (s) |
50 |
#endif |
51 |
|
52 |
#define FP_strstr(a,b) strstr (a, b) |
53 |
|
54 |
void TOOLEXPORT FP_free (void *); |
55 |
char * TOOLEXPORT FP_strdup (char *); |
56 |
char * TOOLEXPORT FP_strncpy (char *, char *, int); |
57 |
void * TOOLEXPORT FP_memdup (const void *, int); |
58 |
int TOOLEXPORT FP_stricmp (const char *, const char *); |
59 |
int TOOLEXPORT FP_strnicmp (const char *, const char *, int); |
60 |
char * TOOLEXPORT FP_strrstr (char *, char *); |
61 |
char * TOOLEXPORT FP_stoupper (char *); |
62 |
char * TOOLEXPORT FP_stolower (char *); |
63 |
int TOOLEXPORT FP_strmatch (char *, char *); |
64 |
char * TOOLEXPORT FP_stristr (char *, char *); |
65 |
char * TOOLEXPORT FP_strirstr (char *, char *); |
66 |
char * TOOLEXPORT FP_strrchr (const char *, int); |
67 |
char * TOOLEXPORT FP_fgets (char *, int, FILE *); |
68 |
char * TOOLEXPORT FP_strpbrk (char *, char *); |
69 |
char * TOOLEXPORT FP_strtok (char *, char *); |
70 |
char * TOOLEXPORT FP_cutdir (char *); |
71 |
char * TOOLEXPORT FP_strerror (int); |
72 |
#ifndef HAVE_MKSTEMP |
73 |
char * TOOLEXPORT FP_tempnam (char *, char *); |
74 |
#endif /* HAVE_MKSTEMP */ |
75 |
|
76 |
/* like stgricmp, but only works when one of the strings is printable ascii */ |
77 |
/* not containing any of these characters: @`[\]^:_{|}~ */ |
78 |
int TOOLEXPORT FP_strnicmp_fast (const char *, const char *, int); |
79 |
|
80 |
#if 0 /* API differs too much between systems to make those replacements */ |
81 |
#if HAVE_STRCASECMP |
82 |
# define FP_stricmp(a,b) strcasecmp (a, b) |
83 |
#endif |
84 |
|
85 |
#if HAVE_STRNCASECMP |
86 |
# define FP_strnicmp(a,b,l) strncasecmp (a, b, l) |
87 |
#endif |
88 |
|
89 |
#if HAVE_STRCASESTR |
90 |
# define FP_stristr(a,b) strcasestr (a, b) |
91 |
#endif |
92 |
#endif |
93 |
|
94 |
#ifdef __cplusplus |
95 |
} |
96 |
#endif |
97 |
#endif |
98 |
|