shared.h

Go to the documentation of this file.
00001 
00005 /*
00006 All original material Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 Copyright (C) 1997-2001 Id Software, Inc.
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 
00019 See the GNU General Public License for more details.
00020 
00021 You should have received a copy of the GNU General Public License
00022 along with this program; if not, write to the Free Software
00023 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00024 */
00025 
00026 #ifndef SHARED_H
00027 #define SHARED_H
00028 
00029 #ifdef HAVE_CONFIG_H
00030 # include "../../config.h"
00031 #endif
00032 
00033 #define MAX_VAR     64
00034 
00035 #include <errno.h>
00036 #include <assert.h>
00037 #include <math.h>
00038 #include <stdio.h>
00039 #include <stdarg.h>
00040 #include <string.h>
00041 #include <stdlib.h>
00042 #include <time.h>
00043 #include <ctype.h>
00044 #include <limits.h>
00045 #include <stddef.h>
00046 
00047 /* to support the gnuc __attribute__ command */
00048 #if defined __ICC || !defined __GNUC__
00049 #  define __attribute__(x)  /*NOTHING*/
00050 #endif
00051 
00052 #if defined(__GNUC__)
00053 #define UFO_DEPRECATED __attribute__ ((deprecated))
00054 #else
00055 #define UFO_DEPRECATED
00056 #endif
00057 
00058 #ifndef NULL
00059 #define NULL ((void *)0)
00060 #endif
00061 
00062 #ifdef _WIN32
00063 # ifndef snprintf
00064 #  define snprintf _snprintf
00065 # endif
00066 # define EXPORT __cdecl
00067 # define IMPORT __cdecl
00068 #else
00069 # define EXPORT
00070 # define IMPORT
00071 #endif
00072 
00073 #if !defined __STDC_VERSION__
00074 #  define inline
00075 #elif __STDC_VERSION__ < 199901L
00076 /* if we are using ansi - the compiler doesn't know about inline */
00077 #  if defined __GNUC__
00078 #    define inline __inline__
00079 #  elif defined _MSVC
00080 #    define inline __inline
00081 #  else
00082 #    define inline
00083 #  endif
00084 #endif
00085 
00086 #define STRINGIFY(x) #x
00087 #define DOUBLEQUOTE(x) STRINGIFY(x)
00088 
00089 const char *Com_SkipPath(const char *pathname);
00090 void Com_ReplaceFilename(const char *fileName, const char *name, char *path, size_t size);
00091 void Com_StripExtension(const char *in, char *out, size_t size);
00092 void Com_FilePath(const char *in, char *out);
00093 const char *Com_GetExtension(const char *path);
00094 void Com_DefaultExtension(char *path, size_t len, const char *extension);
00095 int Com_Filter(const char *pattern, const char *text);
00096 char *Com_Trim(char *s);
00097 
00099 #define lengthof(x) (sizeof(x) / sizeof(*(x)))
00100 #define CASSERT(x) extern int ASSERT_COMPILE[((x) != 0) * 2 - 1]
00101 
00102 char *va(const char *format, ...) __attribute__((format(printf, 1, 2)));
00103 int Q_FloatSort(const void *float1, const void *float2);
00104 int Q_StringSort(const void *string1, const void *string2) __attribute__((nonnull));
00105 
00106 qboolean Com_sprintf(char *dest, size_t size, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
00107 
00108 #if defined(__MINGW32_VERSION) && defined(__STRICT_ANSI__)
00109 /* function exists but are not defined */
00110 _CRTIMP char* __cdecl   strdup (const char*) __MINGW_ATTRIB_MALLOC;
00111 _CRTIMP int __cdecl _stricmp (const char*, const char*);
00112 _CRTIMP int __cdecl _strnicmp (const char*, const char*, size_t);
00113 #define strncasecmp _strnicmp
00114 #endif
00115 
00116 /* portable case sensitive compare */
00117 #if defined(_WIN32)
00118 #   define Q_strcasecmp(a, b) _stricmp((a), (b))
00119 #else
00120 #   define Q_strcasecmp(a, b) strcasecmp((a), (b))
00121 #endif
00122 
00123 #ifdef HAVE_STRNCASECMP
00124 # define Q_strncasecmp(s1, s2, n) strncasecmp(s1, s2, n)
00125 #else
00126 int Q_strncasecmp(const char *s1, const char *s2, size_t n) __attribute__((nonnull));
00127 #endif
00128 
00129 #ifndef DEBUG
00130 void Q_strncpyz(char *dest, const char *src, size_t destsize) __attribute__((nonnull));
00131 #else
00132 #define Q_strncpyz(string1,string2,length) Q_strncpyzDebug( string1, string2, length, __FILE__, __LINE__ )
00133 void Q_strncpyzDebug(char *dest, const char *src, size_t destsize, const char *file, int line) __attribute__((nonnull));
00134 #endif
00135 
00136 int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap);
00137 void Q_strcat(char *dest, const char *src, size_t size) __attribute__((nonnull));
00138 char *Q_strlwr(char *str) __attribute__((nonnull));
00139 const char *Q_stristr(const char *str, const char *substr) __attribute__((nonnull));
00140 
00141 void Com_Printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
00142 void Com_DPrintf(int level, const char *msg, ...) __attribute__((format(printf, 2, 3)));
00143 void Com_Error(int code, const char *fmt, ...) __attribute__((noreturn, format(printf, 2, 3)));
00144 
00145 #endif

Generated by  doxygen 1.6.2