doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sys_stub.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 #include "../../idlib/precompiled.h"
29 #pragma hdrstop
30 
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <errno.h>
34 #include <stdio.h>
35 #include <dirent.h>
36 #include <unistd.h>
37 #include <sys/mman.h>
38 #include <sys/time.h>
39 #include <pwd.h>
40 
41 #define MAX_OSPATH 256
42 
43 static int frameNum;
44 
45 int Sys_Milliseconds( void ) {
46  return frameNum * 16;
47 }
48 
49 double Sys_GetClockTicks( void ) {
50  return frameNum * 16.0;
51 }
52 
53 double Sys_ClockTicksPerSecond( void ) {
54  return 1000.0;
55 }
56 
57 void Sys_Sleep( int msec ) {
58 }
59 
60 void Sys_CreateThread( xthread_t function, void *parms, xthreadPriority priority, xthreadInfo& info ) {
61 }
62 
64 }
65 
66 void Sys_FlushCacheMemory( void *base, int bytes ) {
67 }
68 
69 void Sys_Error( const char *error, ... ) {
70  va_list argptr;
71  char text[4096];
72 
73  va_start (argptr, error);
74  vprintf (error, argptr);
75  va_end (argptr);
76  printf( "\n" );
77 
78  exit( 1 );
79 }
80 
81 void Sys_Quit( void ) {
82  exit( 0 );
83 }
84 
85 char *Sys_GetClipboardData( void ) {
86  return NULL;
87 }
88 
89 void Sys_GenerateEvents( void ) {
90 }
91 
92 void Sys_Init( void ) {
93 }
94 
95 //==========================================================
96 
98 
99 void Sys_InitNetworking( void ) {
100 }
101 
102 bool idPort::GetPacket( netadr_t &net_from, void *data int &size, int maxSize ) {
103  return false;
104 }
105 void idPort::SendPacket( const netadr_t to, const void *data, int size ) {
106 }
107 
108 //==========================================================
109 
110 double idTimer::base;
111 
112 void idTimer::InitBaseClockTicks( void ) const {
113 }
114 
115 //==========================================================
116 
118 }
119 
120 
121 void Sys_InitInput( void ) {
122 }
123 
124 void Sys_ShutdownInput( void ) {
125 }
126 
128  sysEvent_t ev;
129 
130  memset( &ev, 0, sizeof( ev ) );
131  ev.evType = SE_NONE;
132  ev.evTime = Sys_Milliseconds();
133  return ev;
134 }
135 
136 void Sys_Mkdir( const char *path ) {
137 }
138 
139 const char *Sys_DefaultCDPath(void) {
140  return "";
141 }
142 
143 const char *Sys_DefaultBasePath(void) {
144  return "";
145 }
146 
147 int Sys_ListFiles( const char *directory, const char *extension, idStrList &list )
148 {
149  struct dirent *d;
150  DIR *fdir;
151  bool dironly = false;
152  char search[MAX_OSPATH];
153  int i;
154  struct stat st;
155 
156  list.Clear();
157 
158  if ( !extension)
159  extension = "";
160 
161  if ( extension[0] == '/' && extension[1] == 0 ) {
162  extension = "";
163  dironly = true;
164  }
165 
166  // search
167  if ((fdir = opendir(directory)) == NULL) {
168  return 0;
169  }
170 
171  while ((d = readdir(fdir)) != NULL) {
172  idStr::snprintf( search, sizeof(search), "%s/%s", directory, d->d_name );
173  if (stat(search, &st) == -1)
174  continue;
175  if (!dironly) {
176  idStr look(search);
177  idStr ext;
178  look.ExtractFileExtension( ext );
179  if ( extension && extension[0] && ext.Icmp( &extension[1] ) != 0 ) {
180  continue;
181  }
182  }
183  if ((dironly && !(st.st_mode & S_IFDIR)) ||
184  (!dironly && (st.st_mode & S_IFDIR)))
185  continue;
186 
187  list.Append( d->d_name );
188  }
189 
190  closedir(fdir);
191 
192  return list.Num();
193 }
194 
195 void Sys_GrabMouseCursor( bool grabIt ) {
196 }
197 
198 bool Sys_StringToNetAdr( const char *s, netadr_t *a ) {
199  return false;
200 }
201 
202 const char *Sys_NetAdrToString( const netadr_t a ) {
203  static char s[64];
204 
205  if ( a.type == NA_LOOPBACK ) {
206  idStr::snPrintf( s, sizeof(s), "localhost" );
207  } else if ( a.type == NA_IP ) {
208  idStr::snPrintf( s, sizeof(s), "%i.%i.%i.%i:%i",
209  a.ip[0], a.ip[1], a.ip[2], a.ip[3], BigShort(a.port) );
210  }
211  return s;
212 }
213 
214 void Sys_DoPreferences( void ) {
215 }
216 
217 int main( int argc, char **argv ) {
218  // combine the args into a windows-style command line
219  char cmdline[4096];
220  cmdline[0] = 0;
221  for ( int i = 1 ; i < argc ; i++ ) {
222  strcat( cmdline, argv[i] );
223  if ( i < argc - 1 ) {
224  strcat( cmdline, " " );
225  }
226  }
227  common->Init( cmdline );
228 
229  while( 1 ) {
230  common->Async();
231  common->Frame();
232  frameNum++;
233  }
234 }
GLenum
Definition: qgl.h:120
void Sys_DoPreferences(void)
Definition: sys_stub.cpp:214
static int snPrintf(char *dest, int size, const char *fmt,...) id_attribute((format(printf
Definition: Str.cpp:1465
void InitBaseClockTicks(void) const
Definition: Timer.cpp:40
GLsizei
Definition: qgl.h:120
void Sys_DestroyThread(xthreadInfo &info)
Definition: sys_stub.cpp:63
unsigned char ip[4]
Definition: sys_public.h:406
static double base
Definition: Timer.h:58
netadrtype_t type
Definition: sys_public.h:405
GLenum GLsizei GLenum format
Definition: glext.h:2846
xthreadPriority
Definition: sys_public.h:482
int Sys_ListFiles(const char *directory, const char *extension, idStrList &list)
Definition: sys_stub.cpp:147
void Sys_Quit(void)
Definition: sys_stub.cpp:81
int Sys_Milliseconds(void)
Definition: sys_stub.cpp:45
unsigned short port
Definition: sys_public.h:407
void Sys_FlushCacheMemory(void *base, int bytes)
Definition: sys_stub.cpp:66
GLint
Definition: qgl.h:120
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
GLdouble s
Definition: glext.h:2935
int i
Definition: process.py:33
idPort clientPort
Definition: sys_stub.cpp:97
virtual void Async(void)=0
void Sys_GenerateEvents(void)
Definition: sys_stub.cpp:89
int Icmp(const char *text) const
Definition: Str.h:667
virtual void Frame(void)=0
bool GetPacket(netadr_t &from, void *data, int &size, int maxSize)
Definition: posix_net.cpp:487
char * Sys_GetClipboardData(void)
Definition: sys_stub.cpp:85
const char * Sys_DefaultCDPath(void)
Definition: sys_stub.cpp:139
int main(int argc, char **argv)
Definition: sys_stub.cpp:217
idPort serverPort
Definition: sys_stub.cpp:97
void SendPacket(const netadr_t to, const void *data, int size)
Definition: posix_net.cpp:572
void Sys_ShutdownInput(void)
Definition: sys_stub.cpp:124
idCommon * common
Definition: Common.cpp:206
#define NULL
Definition: Lib.h:88
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:2853
const char * Sys_DefaultBasePath(void)
Definition: sys_stub.cpp:143
void Sys_Mkdir(const char *path)
Definition: sys_stub.cpp:136
const char * path
Definition: sws.c:117
GLenum GLsizei width
Definition: glext.h:2846
unsigned int(* xthread_t)(void *)
Definition: sys_public.h:480
GLubyte GLubyte GLubyte a
Definition: glext.h:4662
void Sys_Error(const char *error,...)
Definition: sys_stub.cpp:69
sysEventType_t evType
Definition: sys_public.h:216
GLenum GLsizei GLsizei height
Definition: glext.h:2856
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: glext.h:2878
int Append(const type &obj)
Definition: List.h:646
const char * Sys_NetAdrToString(const netadr_t a)
Definition: sys_stub.cpp:202
void Sys_Init(void)
Definition: sys_stub.cpp:92
int Num(void) const
Definition: List.h:265
#define snprintf
Definition: Str.h:70
void Sys_CreateThread(xthread_t function, void *parms, xthreadPriority priority, xthreadInfo &info)
Definition: sys_stub.cpp:60
GLsizeiptr size
Definition: glext.h:3112
void Sys_Sleep(int msec)
Definition: sys_stub.cpp:57
Definition: Str.h:116
GLenum internalformat
Definition: glext.h:2846
sysEvent_t Sys_GetEvent(void)
Definition: sys_stub.cpp:127
void Sys_InitInput(void)
Definition: sys_stub.cpp:121
void Sys_InitNetworking(void)
Definition: sys_stub.cpp:99
#define MAX_OSPATH
Definition: sys_stub.cpp:41
short BigShort(short l)
Definition: Lib.cpp:278
GLint level
Definition: glext.h:2878
void ExtractFileExtension(idStr &dest) const
Definition: Str.cpp:965
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: glext.h:2878
void _glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
Definition: sys_stub.cpp:117
bool Sys_StringToNetAdr(const char *s, netadr_t *a)
Definition: sys_stub.cpp:198
virtual void Init(int argc, const char **argv, const char *cmdline)=0
double Sys_GetClockTicks(void)
Definition: sys_stub.cpp:49
double Sys_ClockTicksPerSecond(void)
Definition: sys_stub.cpp:53
void Clear(void)
Definition: List.h:184
void Sys_GrabMouseCursor(bool grabIt)
Definition: sys_stub.cpp:195