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