Debian Codegraph @

code/game/bg_lib.h

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 // bg_lib.h -- standard C library replacement routines used by code
23 // compiled for the virtual machine
24
25 // This file is NOT included on native builds
26 #if !defined( BG_LIB_H ) && defined( Q3_VM )
27 #define BG_LIB_H
28
29 #ifndef NULL
30 #define NULL ((void *)0)
31 #endif
32
33 typedef unsigned int size_t;
34
35 typedef char * va_list;
36 #define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
37 #define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )
38 #define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
39 #define va_end(ap) ( ap = (va_list)0 )
40
41 #define CHAR_BIT 8 /* number of bits in a char */
42 #define SCHAR_MAX 0x7f /* maximum signed char value */
43 #define SCHAR_MIN (-SCHAR_MAX - 1) /* minimum signed char value */
44 #define UCHAR_MAX 0xff /* maximum unsigned char value */
45
46 #define SHRT_MAX 0x7fff /* maximum (signed) short value */
47 #define SHRT_MIN (-SHRT_MAX - 1) /* minimum (signed) short value */
48 #define USHRT_MAX 0xffff /* maximum unsigned short value */
49 #define INT_MAX 0x7fffffff /* maximum (signed) int value */
50 #define INT_MIN (-INT_MAX - 1) /* minimum (signed) int value */
51 #define UINT_MAX 0xffffffff /* maximum unsigned int value */
52 #define LONG_MAX 0x7fffffffL /* maximum (signed) long value */
53 #define LONG_MIN (-LONG_MAX - 1) /* minimum (signed) long value */
54 #define ULONG_MAX 0xffffffffUL /* maximum unsigned long value */
55
56 #define isalnum(c) (isalpha(c) || isdigit(c))
57 #define isalpha(c) (isupper(c) || islower(c))
58 #define isascii(c) ((c) > 0 && (c) <= 0x7f)
59 #define iscntrl(c) (((c) >= 0) && (((c) <= 0x1f) || ((c) == 0x7f)))
60 #define isdigit(c) ((c) >= '0' && (c) <= '9')
61 #define isgraph(c) ((c) != ' ' && isprint(c))
62 #define islower(c) ((c) >= 'a' && (c) <= 'z')
63 #define isprint(c) ((c) >= ' ' && (c) <= '~')
64 #define ispunct(c) (((c) > ' ' && (c) <= '~') && !isalnum(c))
65 #define isspace(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || (c) == '\r' || \
66 (c) == '\t' || (c) == '\v')
67 #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
68 #define isxdigit(c) (isxupper(c) || isxlower(c))
69 #define isxlower(c) (isdigit(c) || (c >= 'a' && c <= 'f'))
70 #define isxupper(c) (isdigit(c) || (c >= 'A' && c <= 'F'))
71
72 // Misc functions
73 typedef int cmp_t(const void *, const void *);
74 void qsort(void *a, size_t n, size_t es, cmp_t *cmp);
75 void srand( unsigned seed );
76 int rand( void );
77
78 // String functions
79 size_t strlen( const char *string );
80 char *strcat( char *strDestination, const char *strSource );
81 char *strcpy( char *strDestination, const char *strSource );
82 int strcmp( const char *string1, const char *string2 );
83 char *strchr( const char *string, int c );
84 char *strrchr(const char *string, int c);
85 char *strstr( const char *string, const char *strCharSet );
86 char *strncpy( char *strDest, const char *strSource, size_t count );
87 int tolower( int c );
88 int toupper( int c );
89
90 double atof( const char *string );
91 double _atof( const char **stringPtr );
92 double strtod( const char *nptr, char **endptr );
93 int atoi( const char *string );
94 int _atoi( const char **stringPtr );
95 long strtol( const char *nptr, char **endptr, int base );
96
97 int Q_vsnprintf( char *buffer, size_t length, const char *fmt, va_list argptr ) Q_PRINTF_FUNC(3, 0);
98
99 int sscanf( const char *buffer, const char *fmt, ... ) Q_SCANF_FUNC(2, 3);
100
101 // Memory functions
102 void *memmove( void *dest, const void *src, size_t count );
103 void *memset( void *dest, int c, size_t count );
104 void *memcpy( void *dest, const void *src, size_t count );
105
106 // Math functions
107 double ceil( double x );
108 double floor( double x );
109 double sqrt( double x );
110 double sin( double x );
111 double cos( double x );
112 double atan2( double y, double x );
113 double tan( double x );
114 int abs( int n );
115 double fabs( double x );
116 double acos( double x );
117
118 #endif // BG_LIB_H