ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/fptools.h
(Generate patch)

Comparing Convert-UUlib/uulib/fptools.h (file contents):
Revision 1.3.2.5 by root, Sun Apr 18 19:55:46 2004 UTC vs.
Revision 1.17 by root, Sat Sep 24 06:25:44 2022 UTC

7 7
8/* 8/*
9 * Some handy, nonstandard functions. Note that the original may 9 * Some handy, nonstandard functions. Note that the original may
10 * be both faster and better. ``better'', if your compiler allows 10 * be both faster and better. ``better'', if your compiler allows
11 * cleaner use of such functions by proper use of ``const''. 11 * cleaner use of such functions by proper use of ``const''.
12 *
13 * $Id: fptools.h,v 1.3.2.5 2004/04/18 19:55:46 root Exp $
14 */ 12 */
15 13
16#ifndef __FPTOOLS_H__ 14#ifndef FPTOOLS_H__
17#define __FPTOOLS_H__ 15#define FPTOOLS_H__
18 16
19#ifndef _ANSI_ARGS_ 17#include <string.h>
20#ifdef PROTOTYPES 18#include <stdint.h>
21#define _ANSI_ARGS_(c) c 19
22#else 20typedef signed char schar;
23#define _ANSI_ARGS_(c) () 21typedef unsigned char uchar;
24#endif 22
25#endif 23#include "ecb.h"
26 24
27#ifndef TOOLEXPORT 25#ifndef TOOLEXPORT
28#define TOOLEXPORT 26#define TOOLEXPORT
29#endif 27#endif
30 28
31#ifdef __cplusplus 29#ifdef __cplusplus
32extern "C" { 30extern "C" {
33#endif 31#endif
34 32
33#if HAVE_GETC_UNLOCKED
34# define FP_getc(s) getc_unlocked (s)
35#else
36# define FP_getc(s) getc (s)
37#endif
38
39#if HAVE_FEOF_UNLOCKED
40# define FP_feof(s) feof_unlocked (s)
41#else
42# define FP_feof(s) feof (s)
43#endif
44
45#if HAVE_FERROR_UNLOCKED
46# define FP_ferror(s) ferror_unlocked (s)
47#else
48# define FP_ferror(s) ferror (s)
49#endif
50
51#if HAVE_FLOCKFILE
52# define FP_flockfile(s) flockfile (s)
53#else
54# define FP_flockfile(s) ((void *)0)
55#endif
56
57#define FP_strstr(a,b) strstr (a, b)
58#define FP_strerror(a) strerror (a)
59
35void TOOLEXPORT _FP_free _ANSI_ARGS_((void *)); 60void TOOLEXPORT FP_free (void *);
36char * TOOLEXPORT _FP_strdup _ANSI_ARGS_((char *)); 61char * TOOLEXPORT FP_strdup (char *);
37char * TOOLEXPORT _FP_strncpy _ANSI_ARGS_((char *, char *, int)); 62char * TOOLEXPORT FP_strncpy (char *, char *, int);
38void * TOOLEXPORT _FP_memdup _ANSI_ARGS_((void *, int)); 63void * TOOLEXPORT FP_memdup (const void *, int);
39int TOOLEXPORT _FP_stricmp _ANSI_ARGS_((char *, char *)); 64int TOOLEXPORT FP_stricmp (const char *, const char *);
40int TOOLEXPORT _FP_strnicmp _ANSI_ARGS_((char *, char *, int)); 65int TOOLEXPORT FP_strnicmp (const char *, const char *, int);
41char * TOOLEXPORT _FP_strrstr _ANSI_ARGS_((char *, char *)); 66char * TOOLEXPORT FP_strrstr (const char *, const char *);
42char * TOOLEXPORT _FP_stoupper _ANSI_ARGS_((char *)); 67char * TOOLEXPORT FP_stoupper (char *);
43char * TOOLEXPORT _FP_stolower _ANSI_ARGS_((char *)); 68char * TOOLEXPORT FP_stolower (char *);
44int TOOLEXPORT _FP_strmatch _ANSI_ARGS_((char *, char *)); 69int TOOLEXPORT FP_strmatch (char *, char *);
45char * TOOLEXPORT _FP_strstr _ANSI_ARGS_((char *, char *));
46char * TOOLEXPORT _FP_stristr _ANSI_ARGS_((char *, char *)); 70char * TOOLEXPORT FP_stristr (char *, char *);
47char * TOOLEXPORT _FP_strirstr _ANSI_ARGS_((char *, char *)); 71char * TOOLEXPORT FP_strirstr (char *, char *);
48char * TOOLEXPORT _FP_strrchr _ANSI_ARGS_((char *, int)); 72char * TOOLEXPORT FP_strrchr (const char *, int);
49char * TOOLEXPORT _FP_fgets _ANSI_ARGS_((char *, int, FILE *)); 73char * TOOLEXPORT FP_fgets (char *, int, FILE *);
50char * TOOLEXPORT _FP_strpbrk _ANSI_ARGS_((char *, char *)); 74char * TOOLEXPORT FP_strpbrk (char *, char *);
51char * TOOLEXPORT _FP_strtok _ANSI_ARGS_((char *, char *)); 75char * TOOLEXPORT FP_strtok (char *, char *);
52char * TOOLEXPORT _FP_cutdir _ANSI_ARGS_((char *)); 76char * TOOLEXPORT FP_cutdir (char *);
53char * TOOLEXPORT _FP_strerror _ANSI_ARGS_((int)); 77
54char * TOOLEXPORT _FP_tempnam _ANSI_ARGS_((char *, char *)); 78/* like stgricmp, but only works when one of the strings is printable ascii */
79/* not containing any of these characters: @`[\]^:_{|}~ */
80int TOOLEXPORT FP_strnicmp_fast (const char *, const char *, int);
81
82#if 0 /* API differs too much between systems to make those replacements */
83#if HAVE_STRCASECMP
84# define FP_stricmp(a,b) strcasecmp (a, b)
85#endif
86
87#if HAVE_STRNCASECMP
88# define FP_strnicmp(a,b,l) strncasecmp (a, b, l)
89#endif
90
91#if HAVE_STRCASESTR
92# define FP_stristr(a,b) strcasestr (a, b)
93#endif
94#endif
95
96/* this hashes in the final 0 octet to avoid a branch - might or might not be worth it */
97/* this also means that this function distinguishes between NULL and "" */
98static uint32_t
99fnv1a (const char *str)
100{
101 uint32_t hash = 0x811C9DC5, c;
102
103 if (str)
104 for (;;)
105 {
106 c = *str++;
107 hash = (hash ^ c) * 16777619;
108 if (!c)
109 break;
110 }
111
112 return hash;
113}
55 114
56#ifdef __cplusplus 115#ifdef __cplusplus
57} 116}
58#endif 117#endif
59#endif 118#endif
119

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines