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 |
#if HAVE_FLOCKFILE |
53 |
# define FP_flockfile(s) flockfile (s) |
54 |
#else |
55 |
# define FP_flockfile(s) ((void *)0) |
56 |
#endif |
57 |
|
58 |
#define FP_strstr(a,b) strstr (a, b) |
59 |
#define FP_strerror(a) strerror (a) |
60 |
|
61 |
void TOOLEXPORT FP_free (void *); |
62 |
char * TOOLEXPORT FP_strdup (char *); |
63 |
char * TOOLEXPORT FP_strncpy (char *, char *, int); |
64 |
void * TOOLEXPORT FP_memdup (const void *, int); |
65 |
int TOOLEXPORT FP_stricmp (const char *, const char *); |
66 |
int TOOLEXPORT FP_strnicmp (const char *, const char *, int); |
67 |
char * TOOLEXPORT FP_strrstr (const char *, const char *); |
68 |
char * TOOLEXPORT FP_stoupper (char *); |
69 |
char * TOOLEXPORT FP_stolower (char *); |
70 |
int TOOLEXPORT FP_strmatch (char *, char *); |
71 |
char * TOOLEXPORT FP_stristr (char *, char *); |
72 |
char * TOOLEXPORT FP_strirstr (char *, char *); |
73 |
char * TOOLEXPORT FP_strrchr (const char *, int); |
74 |
char * TOOLEXPORT FP_fgets (char *, int, FILE *); |
75 |
char * TOOLEXPORT FP_strpbrk (char *, char *); |
76 |
char * TOOLEXPORT FP_strtok (char *, char *); |
77 |
char * TOOLEXPORT FP_cutdir (char *); |
78 |
|
79 |
/* like stgricmp, but only works when one of the strings is printable ascii */ |
80 |
/* not containing any of these characters: @`[\]^:_{|}~ */ |
81 |
int TOOLEXPORT FP_strnicmp_fast (const char *, const char *, int); |
82 |
|
83 |
#if 0 /* API differs too much between systems to make those replacements */ |
84 |
#if HAVE_STRCASECMP |
85 |
# define FP_stricmp(a,b) strcasecmp (a, b) |
86 |
#endif |
87 |
|
88 |
#if HAVE_STRNCASECMP |
89 |
# define FP_strnicmp(a,b,l) strncasecmp (a, b, l) |
90 |
#endif |
91 |
|
92 |
#if HAVE_STRCASESTR |
93 |
# define FP_stristr(a,b) strcasestr (a, b) |
94 |
#endif |
95 |
#endif |
96 |
|
97 |
#ifdef __cplusplus |
98 |
} |
99 |
#endif |
100 |
#endif |
101 |
|