]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/cmdlib.h
some updates to the Linux build system - obtained a core binary and all required...
[xonotic/netradiant.git] / libs / cmdlib.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 //\r
23 // start of shared cmdlib stuff\r
24 // \r
25 \r
26 #ifndef __CMDLIB__\r
27 #define __CMDLIB__\r
28 \r
29 #include <stdio.h>\r
30 #include <string.h>\r
31 #include <stdlib.h>\r
32 #include <errno.h>\r
33 #include <ctype.h>\r
34 #include <time.h>\r
35 #include <stdarg.h>\r
36 #include <limits.h>\r
37 #ifdef _WIN32\r
38   #define PATH_MAX 260\r
39 #endif\r
40 \r
41 // some easy portability crap\r
42 #ifdef _WIN32\r
43   #include <direct.h>\r
44   #define Q_mkdir(a,b) _mkdir(a)\r
45 #else\r
46   #include <sys/stat.h>\r
47   #define Q_mkdir(a,b) mkdir(a,b)\r
48 #endif\r
49 \r
50 #ifdef __cplusplus\r
51   typedef bool qboolean;\r
52 #endif\r
53 \r
54 // NOTE TTimo: is this worth anything?\r
55 #ifndef __BYTEBOOL__\r
56 #define __BYTEBOOL__\r
57 \r
58 #ifndef __cplusplus\r
59   typedef enum {false, true} boolean;\r
60 #else\r
61   typedef unsigned char boolean;\r
62 #endif\r
63 \r
64 typedef unsigned char byte;\r
65 \r
66 #endif // __BYTEBOOL__\r
67 \r
68 void    DefaultExtension( char *path, char *extension );\r
69 void    DefaultPath( char *path, char *basepath );\r
70 void    StripFilename( char *path );\r
71 void    StripExtension( char *path );\r
72 void    ExtractFilePath( const char *path, char *dest );\r
73 void    ExtractFileName( const char *path, char *dest );\r
74 void    ExtractFileBase( const char *path, char *dest );\r
75 void    ExtractFileExtension( const char *path, char *dest );\r
76 /*!\r
77 \brief create all directories leading to a file path. if you pass a directory, terminate it with a '/'\r
78 */  \r
79 void  CreateDirectoryPath (const char *path);\r
80   \r
81 short   BigShort (short l);\r
82 short   LittleShort (short l);\r
83 int             BigLong (int l);\r
84 int             LittleLong (int l);\r
85 float   BigFloat (float l);\r
86 float   LittleFloat (float l);\r
87 void *qmalloc (size_t size);\r
88 void* qblockmalloc(size_t nSize);\r
89 \r
90 void ConvertDOSToUnixName( char *dst, const char *src );\r
91 #ifdef __cplusplus\r
92   char* StrDup(char* pStr);\r
93 #endif\r
94 char* StrDup(const char* pStr);\r
95 \r
96 // TTimo started adding portability code:\r
97 // return true if spawning was successful, false otherwise\r
98 // on win32 we have a bCreateConsole flag to create a new console or run inside the current one\r
99 //boolean Q_Exec(const char* pCmd, boolean bCreateConsole);\r
100 // execute a system command:\r
101 //   cmd: the command to run\r
102 //   cmdline: the command line\r
103 // NOTE TTimo following are win32 specific:\r
104 //   execdir: the directory to execute in\r
105 //   bCreateConsole: spawn a new console or not\r
106 // return values;\r
107 //   if the spawn was fine\r
108 //   TODO TTimo add functionality to track the process until it dies\r
109 bool Q_Exec(const char *cmd, char *cmdline, const char *execdir, bool bCreateConsole);\r
110 \r
111 #endif\r