1 /*
2  * "$Id: flstring.h 4660 2005-11-27 14:45:48Z mike $"
3  *
4  * Common string header file for the Fast Light Tool Kit (FLTK).
5  * versions < 1.3.x
6  *
7  * Copyright 1998-2005 by Bill Spitzak and others.
8  *
9  // This file is part of FLAMP.
10  //
11  // This is free software; you can redistribute it and/or modify
12  // it under the terms of the GNU General Public License as published by
13  // the Free Software Foundation; either version 3 of the License, or
14  // (at your option) any later version.
15  //
16  // This software is distributed in the hope that it will be useful,
17  // but WITHOUT ANY WARRANTY; without even the implied warranty of
18  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  // GNU General Public License for more details.
20  //
21  // You should have received a copy of the GNU General Public License
22  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  //
24  *
25  * Please report all bugs and problems on the following page:
26  *
27  *     http://www.fltk.org/str.php
28  */
29 
30 #ifndef flstring_h
31 #  define flstring_h
32 
33 #include <config.h>
34 
35 // versions of FLTK < 1.3.2 do not contain fl_string
36 #if (FLAMP_FLTK_API_MAJOR == 1 && FLAMP_FLTK_API_MINOR == 3 && FLAMP_FLTK_API_PATCH < 1)
37 
38 #  include <FL/Fl_Export.H>
39 #  include <config.h>
40 #  include <stdio.h>
41 #  include <stdarg.h>
42 #  include <string.h>
43 
44 #  ifdef HAVE_STRINGS_H
45 #    include <strings.h>
46 #  endif /* HAVE_STRINGS_H */
47 
48 #  include <ctype.h>
49 
50 /*
51  * Apparently Unixware defines "index" to strchr (!) rather than
52  * providing a proper entry point or not providing the (obsolete)
53  * BSD function.  Make sure index is not defined...
54  */
55 
56 #  ifdef index
57 #    undef index
58 #  endif /* index */
59 
60 #  if defined(WIN32) && !defined(__CYGWIN__)
61 #    define strcasecmp(s,t)	_stricmp((s), (t))
62 #    define strncasecmp(s,t,n)	_strnicmp((s), (t), (n))
63 // Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs
64 // on Windows, which is supposed to be POSIX compliant...  Some of these functions
65 // are also defined in ISO C99...
66 #  define strdup _strdup
67 #  define unlink _unlink
68 #  elif defined(__EMX__)
69 #    define strcasecmp(s,t)	stricmp((s), (t))
70 #    define strncasecmp(s,t,n)	strnicmp((s), (t), (n))
71 #  endif /* WIN32 */
72 
73 #  ifdef __cplusplus
74 extern "C" {
75 #  endif /* __cplusplus */
76 
77 /*
78  * MetroWerks' CodeWarrior put thes "non-standard" functions in
79  * <extras.h> which unfortunatly does not play well otherwise
80  * when included - to be resolved...
81  */
82 
83 #  if defined(__APPLE__) && defined(__MWERKS__) && defined(_MSL_USING_MW_C_HEADERS)
84 int strcasecmp(const char*,const char*);
85 int strncasecmp(const char*,const char*,int);
86 char *strdup(const char*);
87 #  endif
88 
89 FL_EXPORT extern int fl_snprintf(char *, size_t, const char *, ...);
90 #  if !HAVE_SNPRINTF
91 #    define snprintf fl_snprintf
92 #  endif /* !HAVE_SNPRINTF */
93 
94 FL_EXPORT extern int fl_vsnprintf(char *, size_t, const char *, va_list ap);
95 #  if !HAVE_VSNPRINTF
96 #    define vsnprintf fl_vsnprintf
97 #  endif /* !HAVE_VSNPRINTF */
98 
99 /*
100  * strlcpy() and strlcat() are some really useful BSD string functions
101  * that work the way strncpy() and strncat() *should* have worked.
102  */
103 
104 FL_EXPORT extern size_t fl_strlcat(char *, const char *, size_t);
105 #  if !HAVE_STRLCAT
106 #    define strlcat fl_strlcat
107 #  endif /* !HAVE_STRLCAT */
108 
109 FL_EXPORT extern size_t fl_strlcpy(char *, const char *, size_t);
110 #  if !HAVE_STRLCPY
111 #    define strlcpy fl_strlcpy
112 #  endif /* !HAVE_STRLCPY */
113 
114 #  ifdef __cplusplus
115 }
116 #  endif /* __cplusplus */
117 
118 #endif /* < FLTK < 1.3.0 */
119 
120 #endif /* !flstring_h */
121 
122