DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * "$Id: flstring.h 7913 2010-11-29 18:18:27Z greg.ercolano $" |
| 3 | * |
| 4 | * Common string header file for the Fast Light Tool Kit (FLTK). |
| 5 | * |
| 6 | * Copyright 1998-2010 by Bill Spitzak and others. |
| 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Library General Public |
| 10 | * License as published by the Free Software Foundation; either |
| 11 | * version 2 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Library General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Library General Public |
| 19 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 21 | * USA. |
| 22 | * |
| 23 | * Please report all bugs and problems on the following page: |
| 24 | * |
| 25 | * http://www.fltk.org/str.php |
| 26 | */ |
| 27 | |
| 28 | #ifndef flstring_h |
| 29 | # define flstring_h |
| 30 | |
| 31 | # include <FL/Fl_Export.H> |
| 32 | # include <config.h> |
| 33 | # include <stdio.h> |
| 34 | # include <stdarg.h> |
| 35 | # include <string.h> |
| 36 | # ifdef HAVE_STRINGS_H |
| 37 | # include <strings.h> |
| 38 | # endif /* HAVE_STRINGS_H */ |
| 39 | # include <ctype.h> |
| 40 | |
| 41 | /* |
| 42 | * Apparently Unixware defines "index" to strchr (!) rather than |
| 43 | * providing a proper entry point or not providing the (obsolete) |
| 44 | * BSD function. Make sure index is not defined... |
| 45 | */ |
| 46 | |
| 47 | # ifdef index |
| 48 | # undef index |
| 49 | # endif /* index */ |
| 50 | |
| 51 | # if defined(WIN32) && !defined(__CYGWIN__) |
| 52 | # define strcasecmp(s,t) _stricmp((s), (t)) |
| 53 | # define strncasecmp(s,t,n) _strnicmp((s), (t), (n)) |
| 54 | /* Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs |
| 55 | * on Windows, which is supposed to be POSIX compliant... Some of these |
| 56 | * functions are also defined in ISO C99... |
| 57 | */ |
| 58 | # ifndef __WATCOMC__ |
| 59 | # define strdup _strdup |
| 60 | # define unlink _unlink |
| 61 | # endif /* !__WATCOMC__ */ |
| 62 | # elif defined(__EMX__) |
| 63 | # define strcasecmp(s,t) stricmp((s), (t)) |
| 64 | # define strncasecmp(s,t,n) strnicmp((s), (t), (n)) |
| 65 | # endif /* WIN32 */ |
| 66 | |
| 67 | # ifdef __cplusplus |
| 68 | extern "C" { |
| 69 | # endif /* __cplusplus */ |
| 70 | |
| 71 | FL_EXPORT extern int fl_snprintf(char *, size_t, const char *, ...); |
| 72 | # if !HAVE_SNPRINTF |
| 73 | # define snprintf fl_snprintf |
| 74 | # endif /* !HAVE_SNPRINTF */ |
| 75 | |
| 76 | FL_EXPORT extern int fl_vsnprintf(char *, size_t, const char *, va_list ap); |
| 77 | # if !HAVE_VSNPRINTF |
| 78 | # define vsnprintf fl_vsnprintf |
| 79 | # endif /* !HAVE_VSNPRINTF */ |
| 80 | |
| 81 | /* |
| 82 | * strlcpy() and strlcat() are some really useful BSD string functions |
| 83 | * that work the way strncpy() and strncat() *should* have worked. |
| 84 | */ |
| 85 | |
| 86 | FL_EXPORT extern size_t fl_strlcat(char *, const char *, size_t); |
| 87 | # if !HAVE_STRLCAT |
| 88 | # define strlcat fl_strlcat |
| 89 | # endif /* !HAVE_STRLCAT */ |
| 90 | |
| 91 | FL_EXPORT extern size_t fl_strlcpy(char *, const char *, size_t); |
| 92 | # if !HAVE_STRLCPY |
| 93 | # define strlcpy fl_strlcpy |
| 94 | # endif /* !HAVE_STRLCPY */ |
| 95 | |
| 96 | # ifdef __cplusplus |
| 97 | } |
| 98 | # endif /* __cplusplus */ |
| 99 | #endif /* !flstring_h */ |
| 100 | |
| 101 | |
| 102 | /* |
| 103 | * End of "$Id: flstring.h 7913 2010-11-29 18:18:27Z greg.ercolano $". |
| 104 | */ |