FTEQW
Documentation of the FTE engine source tree.
cmdlib.h
Go to the documentation of this file.
1// cmdlib.h
2
3#ifndef __CMDLIB__
4#define __CMDLIB__
5
6#include "progsint.h"
7
8/*#include <stdio.h>
9#include <string.h>
10#include <stdlib.h>
11#include <errno.h>
12#include <ctype.h>
13#include <sys/types.h>
14#include <sys/stat.h>
15#include <fcntl.h>
16#include <stdarg.h>
17#include <setjmp.h>
18#include <io.h>
19
20#ifdef NeXT
21#include <libc.h>
22#endif
23*/
24
25// the dec offsetof macro doesn't work very well...
26#define myoffsetof(type,identifier) ((size_t)&((type *)NULL)->identifier)
27
28
29// set these before calling CheckParm
30extern int myargc;
31extern const char **myargv;
32
33//char *strupr (char *in);
34//char *strlower (char *in);
36int QCC_tell (int handle);
37
38#if 0//def __GNUC__
39 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
40#else
41 #define WARN_UNUSED_RESULT
42#endif
43
44int QC_strcasecmp (const char *s1, const char *s2);
45int QC_strncasecmp(const char *s1, const char *s2, int n);
46
47pbool QC_strlcat(char *dest, const char *src, size_t destsize) WARN_UNUSED_RESULT;
48pbool QC_strlcpy(char *dest, const char *src, size_t destsize) WARN_UNUSED_RESULT;
49pbool QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize) WARN_UNUSED_RESULT;
50char *QC_strcasestr(const char *haystack, const char *needle);
51
52#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
53 #define FTE_DEPRECATED __attribute__((__deprecated__)) //no idea about the actual gcc version
54 #if defined(_WIN32)
55 #include <stdio.h>
56 #ifdef __MINGW_PRINTF_FORMAT
57 #define LIKEPRINTF(x) __attribute__((format(__MINGW_PRINTF_FORMAT,x,x+1)))
58 #else
59 #define LIKEPRINTF(x) __attribute__((format(ms_printf,x,x+1)))
60 #endif
61 #else
62 #define LIKEPRINTF(x) __attribute__((format(printf,x,x+1)))
63 #endif
64#endif
65#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
66 #define NORETURN __attribute__((noreturn))
67#endif
68#ifndef NORETURN
69 #define NORETURN
70#endif
71#ifndef LIKEPRINTF
72 #define LIKEPRINTF(x)
73#endif
74
75#ifdef _MSC_VER
76#define QC_vsnprintf _vsnprintf
77static void VARGS QC_snprintfz (char *dest, size_t size, const char *fmt, ...) LIKEPRINTF(3)
78{
79 va_list args;
80 va_start (args, fmt);
81 _vsnprintf (dest, size-1, fmt, args);
82 va_end (args);
83 //make sure its terminated.
84 dest[size-1] = 0;
85}
86#define snprintf QC_snprintfz
87#else
88 #define QC_vsnprintf vsnprintf
89 #define QC_snprintfz snprintf
90#endif
91
92double I_FloatTime (void);
93
94void VARGS QCC_Error (int errortype, const char *error, ...) LIKEPRINTF(2);
95int QCC_CheckParm (const char *check);
96const char *QCC_ReadParm (const char *check);
97
98
99int SafeOpenWrite (char *filename, int maxsize);
101void SafeRead (int handle, void *buffer, long count);
102void SafeWrite (int handle, const void *buffer, long count);
103pbool SafeClose(int hand);
104int SafeSeek(int hand, int ofs, int mode);
105void *SafeMalloc (long size);
106
107
108long QCC_LoadFile (char *filename, void **bufferptr);
109void QCC_SaveFile (char *filename, void *buffer, long count);
110
111void DefaultExtension (char *path, char *extension);
112void DefaultPath (char *path, char *basepath);
113void StripFilename (char *path);
114void StripExtension (char *path);
115
116void ExtractFilePath (char *path, char *dest);
117void ExtractFileBase (char *path, char *dest);
118void ExtractFileExtension (char *path, char *dest);
119
120long ParseNum (char *str);
121
122unsigned short *QCC_makeutf16(char *mem, size_t len, int *outlen, pbool *errors);
123char *QCC_SanitizeCharSet(char *mem, size_t *len, pbool *freeresult, int *origfmt);
124
125
126char *QCC_COM_Parse (const char *data);
127char *QCC_COM_Parse2 (char *data);
128
129unsigned int utf8_check(const void *in, unsigned int *value);
130
131extern char qcc_token[1024];
132
133
134#define qcc_iswhite(c) ((c) == ' ' || (c) == '\r' || (c) == '\n' || (c) == '\t' || (c) == '\v')
135#define qcc_iswhitesameline(c) ((c) == ' ' || (c) == '\t')
136#define qcc_islineending(c,n) ((c) == '\n' || ((c) == '\r' && (n) != '\n')) //to try to handle mac line endings, especially if they're in the middle of a line
137
138
139enum
140{
148};
149
150#endif
enum @13::coninfomode_e mode
Definition: com_phys_ode.c:695
int QCC_CheckParm(const char *check)
Definition: qcc_cmdlib.c:597
pbool QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize) WARN_UNUSED_RESULT
Definition: qcc_cmdlib.c:179
void ExtractFileExtension(char *path, char *dest)
Definition: qcc_cmdlib.c:773
void DefaultExtension(char *path, char *extension)
Definition: qcc_cmdlib.c:691
void ExtractFileBase(char *path, char *dest)
Definition: qcc_cmdlib.c:754
unsigned short * QCC_makeutf16(char *mem, size_t len, int *outlen, pbool *errors)
Definition: qcc_cmdlib.c:1106
int QC_strncasecmp(const char *s1, const char *s2, int n)
Definition: comprout.c:236
long QCC_LoadFile(char *filename, void **bufferptr)
Definition: qcc_cmdlib.c:1240
pbool QC_strlcpy(char *dest, const char *src, size_t destsize) WARN_UNUSED_RESULT
Definition: qcc_cmdlib.c:169
void StripExtension(char *path)
Definition: qcc_cmdlib.c:1338
void * SafeMalloc(long size)
int myargc
Definition: qcc_cmdlib.c:16
@ UTF16BE
Definition: cmdlib.h:145
@ UTF16LE
Definition: cmdlib.h:144
@ UTF32BE
Definition: cmdlib.h:147
@ UTF8_RAW
Definition: cmdlib.h:141
@ UTF32LE
Definition: cmdlib.h:146
@ UTF8_BOM
Definition: cmdlib.h:142
@ UTF_ANSI
Definition: cmdlib.h:143
int SafeSeek(int hand, int ofs, int mode)
Definition: qcc_cmdlib.c:911
char * QC_strcasestr(const char *haystack, const char *needle)
Definition: qcc_cmdlib.c:190
void StripFilename(char *path)
Definition: qcc_cmdlib.c:723
int QCC_filelength(int handle)
void SafeWrite(int handle, const void *buffer, long count)
Definition: qcc_cmdlib.c:894
char * QCC_SanitizeCharSet(char *mem, size_t *len, pbool *freeresult, int *origfmt)
Definition: qcc_cmdlib.c:1165
unsigned int utf8_check(const void *in, unsigned int *value)
Definition: qcc_cmdlib.c:948
char qcc_token[1024]
Definition: qcc_cmdlib.c:19
void VARGS QCC_Error(int errortype, const char *error,...) LIKEPRINTF(2)
Definition: qcc_cmdlib.c:561
pbool SafeClose(int hand)
Definition: qcc_cmdlib.c:927
char * QCC_COM_Parse2(char *data)
Definition: qcc_cmdlib.c:411
const char ** myargv
Definition: qcc_cmdlib.c:17
void ExtractFilePath(char *path, char *dest)
Definition: qcc_cmdlib.c:738
const char * QCC_ReadParm(const char *check)
Definition: qcc_cmdlib.c:610
int SafeOpenRead(char *filename)
char * QCC_COM_Parse(const char *data)
Definition: qcc_cmdlib.c:290
int SafeOpenWrite(char *filename, int maxsize)
Definition: qcc_cmdlib.c:852
int QCC_tell(int handle)
void DefaultPath(char *path, char *basepath)
Definition: qcc_cmdlib.c:711
void SafeRead(int handle, void *buffer, long count)
long ParseNum(char *str)
Definition: qcc_cmdlib.c:825
double I_FloatTime(void)
pbool QC_strlcat(char *dest, const char *src, size_t destsize) WARN_UNUSED_RESULT
Definition: qcc_cmdlib.c:158
int QC_strcasecmp(const char *s1, const char *s2)
Definition: qcc_cmdlib.c:273
void QCC_SaveFile(char *filename, void *buffer, long count)
const char * extension
Definition: fs.c:251
char filename[64]
Definition: generatebuiltin.c:8
int error
Definition: gl_vidlinuxglx.c:447
static GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: gl_vidnt.c:848
GLsizei count
Definition: glquake.h:149
GLint size
Definition: glquake.h:157
GLsizei GLboolean const GLfloat * value
Definition: glquake.h:164
GLenum GLsizei len
Definition: glsupp.h:502
void * handle
Definition: image.c:4553
char ** data
Definition: p_script.c:63
unsigned int pbool
Definition: progtype.h:62
int ofs
Definition: qcc_cmdlib.c:849
int outlen
Definition: qccgui.c:6543
uploadfmt_t fmt
Definition: r_2d.c:48
static ALC_API ALCvoid * buffer
Definition: snd_al.c:259
static AL_API ALsizei n
Definition: snd_al.c:161
static spx_int16_t * in
Definition: snd_dma.c:488