Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

unix_main.c File Reference

#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <string.h>
#include <ctype.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <errno.h>
#include <dlfcn.h>
#include <termios.h>
#include "../game/q_shared.h"
#include "../qcommon/qcommon.h"
#include "../renderer/tr_public.h"
#include "linux_local.h"
#include "../client/client.h"

Include dependency graph for unix_main.c:

Include dependency graph

Go to the source code of this file.

Defines

#define MASK_QUED_EVENTS   ( MAX_QUED_EVENTS - 1 )
#define MAX_QUED_EVENTS   256
#define MEM_THRESHOLD   96*1024*1024
#define Q_RTLD   RTLD_NOW
#define TTY_HISTORY   32

Functions

void floating_point_exception_handler (int whatever)
char * FS_BuildOSPath (const char *base, const char *game, const char *qpath)
void Hist_Add (field_t *field)
field_tHist_Next ()
field_tHist_Prev ()
int main (int argc, char *argv[])
void Sys_AppActivate (void)
void Sys_BeginProfiling (void)
void Sys_BeginStreamedFile (fileHandle_t f, int readAhead)
qboolean Sys_CheckCD (void)
void Sys_ConfigureFPU ()
char * Sys_ConsoleInput (void)
void Sys_ConsoleInputInit ()
void Sys_ConsoleInputShutdown ()
void Sys_EndStreamedFile (fileHandle_t f)
void Sys_Error (const char *error,...)
void Sys_Exit (int ex)
int Sys_FileTime (char *path)
int Sys_FunctionCheckSum (void *f1)
int Sys_FunctionCmp (void *f1, void *f2)
char * Sys_GetClipboardData (void)
sysEvent_t Sys_GetEvent (void)
void Sys_In_Restart_f (void)
void Sys_Init (void)
void Sys_InitStreamThread (void)
void * Sys_LoadDll (const char *name, char *fqpath, int(**entryPoint)(int,...), int(*systemcalls)(int,...))
qboolean Sys_LowPhysicalMemory ()
int Sys_MonkeyShouldBeSpanked (void)
void Sys_ParseArgs (int argc, char *argv[])
void Sys_Print (const char *msg)
void Sys_PrintBinVersion (const char *name)
void Sys_QueEvent (int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr)
void Sys_Quit (void)
void Sys_ShutdownStreamThread (void)
int Sys_StreamedRead (void *buffer, int size, int count, fileHandle_t f)
void Sys_StreamSeek (fileHandle_t f, int offset, int origin)
void Sys_UnloadDll (void *dllHandle)
void Sys_Warn (char *warning,...)
void tty_Back ()
void tty_FlushIn ()
void tty_Hide ()
void tty_Show ()

Variables

clientStatic_t cls
int eventHead = 0
sysEvent_t eventQue [MAX_QUED_EVENTS]
int eventTail = 0
int hist_current = -1 hist_count = 0
refexport_t re
uid_t saved_euid
qboolean stdin_active = qtrue
unsigned sys_frame_time
byte sys_packetReceived [MAX_MSGLEN]
field_t tty_con
int tty_eof
int tty_erase
termios tty_tc
cvar_tttycon = NULL
int ttycon_hide = 0
qboolean ttycon_on = qfalse
field_t ttyEditLines [TTY_HISTORY]


Define Documentation

#define MASK_QUED_EVENTS   ( MAX_QUED_EVENTS - 1 )
 

Definition at line 1020 of file unix_main.c.

#define MAX_QUED_EVENTS   256
 

Definition at line 1019 of file unix_main.c.

#define MEM_THRESHOLD   96*1024*1024
 

Definition at line 100 of file unix_main.c.

#define Q_RTLD   RTLD_NOW
 

Referenced by Sys_LoadDll().

#define TTY_HISTORY   32
 

Definition at line 91 of file unix_main.c.

Referenced by Hist_Add(), Hist_Next(), and Hist_Prev().


Function Documentation

void floating_point_exception_handler int  whatever  ) 
 

Definition at line 457 of file unix_main.c.

References floating_point_exception_handler(), SIGFPE, and signal.

Referenced by floating_point_exception_handler().

00458 {
00459   signal(SIGFPE, floating_point_exception_handler);
00460 }

Here is the call graph for this function:

char* FS_BuildOSPath const char *  base,
const char *  game,
const char *  qpath
 

Definition at line 467 of file files.c.

00467                                                                               {
00468     char    temp[MAX_OSPATH];
00469     static char ospath[2][MAX_OSPATH];
00470     static int toggle;
00471     
00472     toggle ^= 1;        // flip-flop to allow two returns without clash
00473 
00474     if( !game || !game[0] ) {
00475         game = fs_gamedir;
00476     }
00477 
00478     Com_sprintf( temp, sizeof(temp), "/%s/%s", game, qpath );
00479     FS_ReplaceSeparators( temp );   
00480     Com_sprintf( ospath[toggle], sizeof( ospath[0] ), "%s%s", base, temp );
00481     
00482     return ospath[toggle];
00483 }

void Hist_Add field_t field  ) 
 

Definition at line 237 of file unix_main.c.

References assert, hist_current, i, TTY_HISTORY, and ttyEditLines.

Referenced by Sys_ConsoleInput().

00238 {
00239   int i;
00240   assert(hist_count <= TTY_HISTORY);
00241   assert(hist_count >= 0);
00242   assert(hist_current >= -1);
00243   assert(hist_current <= hist_count);
00244   // make some room
00245   for (i=TTY_HISTORY-1; i>0; i--)
00246   {
00247     ttyEditLines[i] = ttyEditLines[i-1];
00248   }
00249   ttyEditLines[0] = *field;
00250   if (hist_count<TTY_HISTORY)
00251   {
00252     hist_count++;
00253   }
00254   hist_current = -1; // re-init
00255 }

field_t* Hist_Next  ) 
 

Definition at line 273 of file unix_main.c.

References assert, hist_current, TTY_HISTORY, and ttyEditLines.

Referenced by Sys_ConsoleInput().

00274 {
00275   assert(hist_count <= TTY_HISTORY);
00276   assert(hist_count >= 0);
00277   assert(hist_current >= -1);
00278   assert(hist_current <= hist_count);
00279   if (hist_current >= 0)
00280   {
00281     hist_current--;
00282   }
00283   if (hist_current == -1)
00284   {
00285     return NULL;
00286   }
00287   return &(ttyEditLines[hist_current]);
00288 }

field_t* Hist_Prev  ) 
 

Definition at line 257 of file unix_main.c.

References assert, hist_current, TTY_HISTORY, and ttyEditLines.

Referenced by Sys_ConsoleInput().

00258 {
00259   int hist_prev;
00260   assert(hist_count <= TTY_HISTORY);
00261   assert(hist_count >= 0);
00262   assert(hist_current >= -1);
00263   assert(hist_current <= hist_count);
00264   hist_prev = hist_current + 1;
00265   if (hist_prev >= hist_count)
00266   {
00267     return NULL;
00268   }
00269   hist_current++;
00270   return &(ttyEditLines[hist_current]);
00271 }

main int  argc,
char *  argv[]
 

Definition at line 1223 of file unix_main.c.

01224 {
01225   // int    oldtime, newtime; // bk001204 - unused
01226   int   len, i;
01227   char  *cmdline;
01228   void Sys_SetDefaultCDPath(const char *path);
01229 
01230   // go back to real user for config loads
01231   saved_euid = geteuid();
01232   seteuid(getuid());
01233 
01234   Sys_ParseArgs( argc, argv );  // bk010104 - added this for support
01235 
01236   Sys_SetDefaultCDPath(argv[0]);
01237 
01238   // merge the command line, this is kinda silly
01239   for (len = 1, i = 1; i < argc; i++)
01240     len += strlen(argv[i]) + 1;
01241   cmdline = malloc(len);
01242   *cmdline = 0;
01243   for (i = 1; i < argc; i++)
01244   {
01245     if (i > 1)
01246       strcat(cmdline, " ");
01247     strcat(cmdline, argv[i]);
01248   }
01249 
01250   // bk000306 - clear queues
01251   memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); 
01252   memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );
01253 
01254   Com_Init(cmdline);
01255   NET_Init();
01256 
01257   Sys_ConsoleInputInit();
01258 
01259   fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
01260     
01261 #ifdef DEDICATED
01262     // init here for dedicated, as we don't have GLimp_Init
01263     InitSig();
01264 #endif
01265 
01266   while (1)
01267   {
01268 #ifdef __linux__
01269     Sys_ConfigureFPU();
01270 #endif
01271     Com_Frame ();
01272   }
01273 }

void Sys_AppActivate void   ) 
 

Definition at line 1144 of file unix_main.c.

01145 {
01146 }

void Sys_BeginProfiling void   ) 
 

Definition at line 141 of file unix_main.c.

00141                                 {
00142 }

void Sys_BeginStreamedFile fileHandle_t  f,
int  readAhead
 

Definition at line 820 of file unix_main.c.

00820                                                             {
00821 }

qboolean Sys_CheckCD void   ) 
 

Definition at line 1140 of file unix_main.c.

References qboolean.

01140                              {
01141   return qtrue;
01142 }

void Sys_ConfigureFPU  ) 
 

Definition at line 1167 of file unix_main.c.

References assert, and Com_Printf().

Referenced by main().

01167                            { // bk001213 - divide by zero
01168 #ifdef __linux__
01169 #ifdef __i386
01170 #ifndef NDEBUG
01171 
01172   // bk0101022 - enable FPE's in debug mode
01173   static int fpu_word = _FPU_DEFAULT & ~(_FPU_MASK_ZM | _FPU_MASK_IM);
01174   int current = 0;
01175   _FPU_GETCW(current);
01176   if ( current!=fpu_word)
01177   {
01178 #if 0
01179     Com_Printf("FPU Control 0x%x (was 0x%x)\n", fpu_word, current );
01180     _FPU_SETCW( fpu_word );
01181     _FPU_GETCW( current );
01182     assert(fpu_word==current);
01183 #endif
01184   }
01185 #else // NDEBUG
01186   static int fpu_word = _FPU_DEFAULT;
01187   _FPU_SETCW( fpu_word );
01188 #endif // NDEBUG
01189 #endif // __i386 
01190 #endif // __linux
01191 }

Here is the call graph for this function:

char* Sys_ConsoleInput void   ) 
 

Definition at line 514 of file unix_main.c.

00515 {
00516   // we use this when sending back commands
00517   static char text[256];
00518   int i;
00519   int avail;
00520   char key;
00521   field_t *history;
00522 
00523   if (ttycon && ttycon->value)
00524   {
00525     avail = read(0, &key, 1);
00526     if (avail != -1)
00527     {
00528       // we have something
00529       // backspace?
00530       // NOTE TTimo testing a lot of values .. seems it's the only way to get it to work everywhere
00531       if ((key == tty_erase) || (key == 127) || (key == 8))
00532       {
00533         if (tty_con.cursor > 0)
00534         {
00535           tty_con.cursor--;
00536           tty_con.buffer[tty_con.cursor] = '\0';
00537           tty_Back();
00538         }
00539         return NULL;
00540       }
00541       // check if this is a control char
00542       if ((key) && (key) < ' ')
00543       {
00544         if (key == '\n')
00545         {
00546           // push it in history
00547           Hist_Add(&tty_con);
00548           strcpy(text, tty_con.buffer);
00549           Field_Clear(&tty_con);
00550           key = '\n';
00551           write(1, &key, 1);
00552           return text;
00553         }
00554         if (key == '\t')
00555         {
00556           tty_Hide();
00557           Field_CompleteCommand( &tty_con );
00558           // Field_CompleteCommand does weird things to the string, do a cleanup
00559           //   it adds a '\' at the beginning of the string
00560           //   cursor doesn't reflect actual length of the string that's sent back
00561           tty_con.cursor = strlen(tty_con.buffer);
00562           if (tty_con.cursor>0)
00563           {
00564             if (tty_con.buffer[0] == '\\')
00565             {
00566               for (i=0; i<=tty_con.cursor; i++)
00567               {
00568                 tty_con.buffer[i] = tty_con.buffer[i+1];
00569               }
00570               tty_con.cursor--;
00571             }
00572           }
00573           tty_Show();
00574           return NULL;
00575         }
00576         avail = read(0, &key, 1);
00577         if (avail != -1)
00578         {
00579           // VT 100 keys
00580           if (key == '[' || key == 'O')
00581           {
00582             avail = read(0, &key, 1);
00583             if (avail != -1)
00584             {
00585               switch (key)
00586               {
00587               case 'A':
00588                 history = Hist_Prev();
00589                 if (history)
00590                 {
00591                   tty_Hide();
00592                   tty_con = *history;
00593                   tty_Show();
00594                 }
00595                 tty_FlushIn();
00596                 return NULL;
00597                 break;
00598               case 'B':
00599                 history = Hist_Next();
00600                 tty_Hide();
00601                 if (history)
00602                 {
00603                   tty_con = *history;
00604                 } else
00605                 {
00606                   Field_Clear(&tty_con);
00607                 }
00608                 tty_Show();
00609                 tty_FlushIn();
00610                 return NULL;
00611                 break;
00612               case 'C':
00613                 return NULL;
00614               case 'D':
00615                 return NULL;
00616               }
00617             }
00618           }
00619         }
00620         Com_DPrintf("droping ISCTL sequence: %d, tty_erase: %d\n", key, tty_erase);
00621         tty_FlushIn();
00622         return NULL;
00623       }
00624       // push regular character
00625       tty_con.buffer[tty_con.cursor] = key;
00626       tty_con.cursor++;
00627       // print the current line (this is differential)
00628       write(1, &key, 1);
00629     }
00630     return NULL;
00631   } else
00632   {
00633     int     len;
00634     fd_set  fdset;
00635     struct timeval timeout;
00636 
00637     if (!com_dedicated || !com_dedicated->value)
00638       return NULL;
00639 
00640     if (!stdin_active)
00641       return NULL;
00642 
00643     FD_ZERO(&fdset);
00644     FD_SET(0, &fdset); // stdin
00645     timeout.tv_sec = 0;
00646     timeout.tv_usec = 0;
00647     if (select (1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET(0, &fdset))
00648     {
00649       return NULL;
00650     }
00651 
00652     len = read (0, text, sizeof(text));
00653     if (len == 0)
00654     { // eof!
00655       stdin_active = qfalse;
00656       return NULL;
00657     }
00658 
00659     if (len < 1)
00660       return NULL;
00661     text[len-1] = 0;    // rip off the /n and terminate
00662 
00663     return text;
00664   }
00665 }

void Sys_ConsoleInputInit  ) 
 

Definition at line 463 of file unix_main.c.

References Com_Printf(), Cvar_Get(), Cvar_Set(), ECHO, Field_Clear(), SIG_IGN, signal, tty_con, tty_eof, tty_erase, tty_tc, ttycon, ttycon_on, and cvar_s::value.

Referenced by main().

00464 {
00465   struct termios tc;
00466 
00467   // TTimo 
00468   // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=390
00469   // ttycon 0 or 1, if the process is backgrounded (running non interactively)
00470   // then SIGTTIN or SIGTOU is emitted, if not catched, turns into a SIGSTP
00471   signal(SIGTTIN, SIG_IGN);
00472   signal(SIGTTOU, SIG_IGN);
00473 
00474   // FIXME TTimo initialize this in Sys_Init or something?
00475   ttycon = Cvar_Get("ttycon", "1", 0);
00476   if (ttycon && ttycon->value)
00477   {
00478     if (isatty(STDIN_FILENO)!=1)
00479     {
00480       Com_Printf("stdin is not a tty, tty console mode failed\n");
00481       Cvar_Set("ttycon", "0");
00482       ttycon_on = qfalse;
00483       return;
00484     }
00485     Com_Printf("Started tty console (use +set ttycon 0 to disable)\n");
00486     Field_Clear(&tty_con);
00487     tcgetattr (0, &tty_tc);
00488     tty_erase = tty_tc.c_cc[VERASE];
00489     tty_eof = tty_tc.c_cc[VEOF];
00490     tc = tty_tc;
00491     /*
00492      ECHO: don't echo input characters
00493      ICANON: enable canonical mode.  This  enables  the  special
00494               characters  EOF,  EOL,  EOL2, ERASE, KILL, REPRINT,
00495               STATUS, and WERASE, and buffers by lines.
00496      ISIG: when any of the characters  INTR,  QUIT,  SUSP,  or
00497               DSUSP are received, generate the corresponding sig­
00498               nal
00499     */              
00500     tc.c_lflag &= ~(ECHO | ICANON);
00501     /*
00502      ISTRIP strip off bit 8
00503      INPCK enable input parity checking
00504      */
00505     tc.c_iflag &= ~(ISTRIP | INPCK);
00506     tc.c_cc[VMIN] = 1;
00507     tc.c_cc[VTIME] = 0;
00508     tcsetattr (0, TCSADRAIN, &tc);    
00509     ttycon_on = qtrue;
00510   } else
00511     ttycon_on = qfalse;
00512 }

Here is the call graph for this function:

void Sys_ConsoleInputShutdown  ) 
 

Definition at line 228 of file unix_main.c.

References Com_Printf(), and tty_tc.

Referenced by Sys_Exit().

00229 {
00230   if (ttycon_on)
00231   {
00232     Com_Printf("Shutdown tty console\n");
00233     tcsetattr (0, TCSADRAIN, &tty_tc);
00234   }
00235 }

Here is the call graph for this function:

void Sys_EndStreamedFile fileHandle_t  f  ) 
 

Definition at line 823 of file unix_main.c.

00823                                            {
00824 }

void Sys_Error const char *  error,
  ...
 

Definition at line 393 of file unix_main.c.

References CL_Shutdown(), error(), fprintf(), stderr, string(), Sys_Exit(), tty_Hide(), va_end, va_list, va_start, and vsprintf().

00394 { 
00395   va_list     argptr;
00396   char        string[1024];
00397 
00398   // change stdin to non blocking
00399   // NOTE TTimo not sure how well that goes with tty console mode
00400   fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
00401 
00402   // don't bother do a show on this one heh
00403   if (ttycon_on)
00404   {
00405     tty_Hide();
00406   }
00407 
00408   CL_Shutdown ();
00409 
00410   va_start (argptr,error);
00411   vsprintf (string,error,argptr);
00412   va_end (argptr);
00413   fprintf(stderr, "Sys_Error: %s\n", string);
00414 
00415   Sys_Exit( 1 ); // bk010104 - use single exit point.
00416 } 

Here is the call graph for this function:

void Sys_Exit int  ex  ) 
 

Definition at line 321 of file unix_main.c.

References assert, exit(), and Sys_ConsoleInputShutdown().

Referenced by signal_handler(), Sys_Error(), Sys_ParseArgs(), and Sys_Quit().

00321                         {
00322   Sys_ConsoleInputShutdown();
00323 
00324 #ifdef NDEBUG // regular behavior
00325 
00326   // We can't do this 
00327   //  as long as GL DLL's keep installing with atexit...
00328   //exit(ex);
00329   _exit(ex);
00330 #else
00331 
00332   // Give me a backtrace on error exits.
00333   assert( ex == 0 );
00334   exit(ex);
00335 #endif
00336 }

Here is the call graph for this function:

int Sys_FileTime char *  path  ) 
 

Definition at line 447 of file unix_main.c.

00448 {
00449   struct  stat  buf;
00450 
00451   if (stat (path,&buf) == -1)
00452     return -1;
00453 
00454   return buf.st_mtime;
00455 }

int Sys_FunctionCheckSum void *  f1  ) 
 

Definition at line 128 of file unix_main.c.

00128                                    {
00129   return 0;
00130 }

int Sys_FunctionCmp void *  f1,
void *  f2
 

Definition at line 119 of file unix_main.c.

00119                                         {
00120   return qtrue;
00121 }

char* Sys_GetClipboardData void   ) 
 

Definition at line 1148 of file unix_main.c.

01149 {
01150   return NULL;
01151 }

sysEvent_t Sys_GetEvent void   ) 
 

Definition at line 1075 of file unix_main.c.

References b, msg_t::cursize, msg_t::data, eventHead, eventQue, eventTail, sysEvent_t::evTime, IN_Frame(), memcpy(), memset(), MSG_Init(), s, SE_CONSOLE, SE_PACKET, strcpy(), strlen(), Sys_ConsoleInput(), Sys_GetPacket(), Sys_Milliseconds(), sys_packetReceived, Sys_QueEvent(), Sys_SendKeyEvents(), and Z_Malloc().

01075                                 {
01076   sysEvent_t  ev;
01077   char    *s;
01078   msg_t   netmsg;
01079   netadr_t  adr;
01080 
01081   // return if we have data
01082   if ( eventHead > eventTail )
01083   {
01084     eventTail++;
01085     return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];
01086   }
01087 
01088   // pump the message loop
01089   // in vga this calls KBD_Update, under X, it calls GetEvent
01090   Sys_SendKeyEvents ();
01091 
01092   // check for console commands
01093   s = Sys_ConsoleInput();
01094   if ( s )
01095   {
01096     char  *b;
01097     int   len;
01098 
01099     len = strlen( s ) + 1;
01100     b = Z_Malloc( len );
01101     strcpy( b, s );
01102     Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
01103   }
01104 
01105   // check for other input devices
01106   IN_Frame();
01107 
01108   // check for network packets
01109   MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );
01110   if ( Sys_GetPacket ( &adr, &netmsg ) )
01111   {
01112     netadr_t    *buf;
01113     int       len;
01114 
01115     // copy out to a seperate buffer for qeueing
01116     len = sizeof( netadr_t ) + netmsg.cursize;
01117     buf = Z_Malloc( len );
01118     *buf = adr;
01119     memcpy( buf+1, netmsg.data, netmsg.cursize );
01120     Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
01121   }
01122 
01123   // return if we have data
01124   if ( eventHead > eventTail )
01125   {
01126     eventTail++;
01127     return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];
01128   }
01129 
01130   // create an empty event to return
01131 
01132   memset( &ev, 0, sizeof( ev ) );
01133   ev.evTime = Sys_Milliseconds();
01134 
01135   return ev;
01136 }

Here is the call graph for this function:

void Sys_In_Restart_f void   ) 
 

Definition at line 151 of file unix_main.c.

References IN_Init(), and IN_Shutdown().

Referenced by Sys_Init().

00152 {
00153   IN_Shutdown();
00154   IN_Init();
00155 }

Here is the call graph for this function:

void Sys_Init void   ) 
 

Definition at line 345 of file unix_main.c.

References Cmd_AddCommand(), Cvar_Set(), IN_Init(), Sys_GetCurrentUser(), and Sys_In_Restart_f().

00346 {
00347   Cmd_AddCommand ("in_restart", Sys_In_Restart_f);
00348 
00349 #if defined __linux__
00350 #if defined __i386__
00351   Cvar_Set( "arch", "linux i386" );
00352 #elif defined __alpha__
00353   Cvar_Set( "arch", "linux alpha" );
00354 #elif defined __sparc__
00355   Cvar_Set( "arch", "linux sparc" );
00356 #elif defined __FreeBSD__
00357 
00358 #if defined __i386__ // FreeBSD
00359   Cvar_Set( "arch", "freebsd i386" );
00360 #elif defined __alpha__
00361   Cvar_Set( "arch", "freebsd alpha" );
00362 #else
00363   Cvar_Set( "arch", "freebsd unknown" );
00364 #endif // FreeBSD
00365 
00366 #else
00367   Cvar_Set( "arch", "linux unknown" );
00368 #endif
00369 #elif defined __sun__
00370 #if defined __i386__
00371   Cvar_Set( "arch", "solaris x86" );
00372 #elif defined __sparc__
00373   Cvar_Set( "arch", "solaris sparc" );
00374 #else
00375   Cvar_Set( "arch", "solaris unknown" );
00376 #endif
00377 #elif defined __sgi__
00378 #if defined __mips__
00379   Cvar_Set( "arch", "sgi mips" );
00380 #else
00381   Cvar_Set( "arch", "sgi unknown" );
00382 #endif
00383 #else
00384   Cvar_Set( "arch", "unknown" );
00385 #endif
00386 
00387   Cvar_Set( "username", Sys_GetCurrentUser() );
00388 
00389   IN_Init();
00390 
00391 }

Here is the call graph for this function:

void Sys_InitStreamThread void   ) 
 

Definition at line 814 of file unix_main.c.

Referenced by WinMain().

00814                                   {
00815 }

void* Sys_LoadDll const char *  name,
char *  fqpath,
int(**)(int,...)  entryPoint,
int(*)(int,...)  systemcalls
 

Definition at line 704 of file unix_main.c.

References assert, basepath(), Com_Error(), Com_Printf(), Cvar_VariableString(), dllEntry(), err(), ERR_FATAL, FS_BuildOSPath(), gamedir, int(), MAX_QPATH, name, Q_RTLD, Q_strncpyz(), Sys_Cwd(), and void().

00707 {
00708   void *libHandle;
00709   void  (*dllEntry)( int (*syscallptr)(int, ...) );
00710   char  curpath[MAX_OSPATH];
00711   char  fname[MAX_OSPATH];
00712   char  *basepath;
00713   char  *homepath;
00714   char  *pwdpath;
00715   char  *gamedir;
00716   char  *fn;
00717   const char*  err = NULL;
00718     
00719     *fqpath = 0;
00720 
00721   // bk001206 - let's have some paranoia
00722   assert( name );
00723 
00724   getcwd(curpath, sizeof(curpath));
00725 #if defined __i386__
00726   snprintf (fname, sizeof(fname), "%si386.so", name);
00727 #elif defined __powerpc__   //rcg010207 - PPC support.
00728   snprintf (fname, sizeof(fname), "%sppc.so", name);
00729 #elif defined __axp__
00730   snprintf (fname, sizeof(fname), "%saxp.so", name);
00731 #elif defined __mips__
00732   snprintf (fname, sizeof(fname), "%smips.so", name);
00733 #else
00734 #error Unknown arch
00735 #endif
00736 
00737 // bk001129 - was RTLD_LAZY 
00738 #define Q_RTLD    RTLD_NOW
00739 
00740   pwdpath = Sys_Cwd();
00741   basepath = Cvar_VariableString( "fs_basepath" );
00742   homepath = Cvar_VariableString( "fs_homepath" );
00743   gamedir = Cvar_VariableString( "fs_game" );
00744 
00745   // pwdpath
00746   fn = FS_BuildOSPath( pwdpath, gamedir, fname );
00747   Com_Printf( "Sys_LoadDll(%s)... \n", fn );
00748   libHandle = dlopen( fn, Q_RTLD );
00749 
00750   if ( !libHandle )
00751   {
00752     Com_Printf( "Sys_LoadDll(%s) failed:\n\"%s\"\n", fn, dlerror() );
00753     // fs_homepath
00754     fn = FS_BuildOSPath( homepath, gamedir, fname );
00755     Com_Printf( "Sys_LoadDll(%s)... \n", fn );
00756     libHandle = dlopen( fn, Q_RTLD );
00757 
00758     if ( !libHandle )
00759     {
00760       Com_Printf( "Sys_LoadDll(%s) failed:\n\"%s\"\n", fn, dlerror() );
00761       // fs_basepath
00762       fn = FS_BuildOSPath( basepath, gamedir, fname );
00763       Com_Printf( "Sys_LoadDll(%s)... \n", fn );
00764       libHandle = dlopen( fn, Q_RTLD );
00765 
00766       if ( !libHandle )
00767       {
00768 #ifndef NDEBUG // bk001206 - in debug abort on failure
00769         Com_Error ( ERR_FATAL, "Sys_LoadDll(%s) failed dlopen() completely!\n", name  );
00770 #else
00771         Com_Printf ( "Sys_LoadDll(%s) failed dlopen() completely!\n", name );
00772 #endif
00773         return NULL;
00774       } else
00775         Com_Printf ( "Sys_LoadDll(%s): succeeded ...\n", fn );
00776     } else
00777       Com_Printf ( "Sys_LoadDll(%s): succeeded ...\n", fn );
00778   } else
00779     Com_Printf ( "Sys_LoadDll(%s): succeeded ...\n", fn ); 
00780 
00781   dllEntry = dlsym( libHandle, "dllEntry" ); 
00782   *entryPoint = dlsym( libHandle, "vmMain" );
00783   if ( !*entryPoint || !dllEntry )
00784   {
00785     err = dlerror();
00786 #ifndef NDEBUG // bk001206 - in debug abort on failure
00787     Com_Error ( ERR_FATAL, "Sys_LoadDll(%s) failed dlsym(vmMain):\n\"%s\" !\n", name, err );
00788 #else
00789     Com_Printf ( "Sys_LoadDll(%s) failed dlsym(vmMain):\n\"%s\" !\n", name, err );
00790 #endif
00791     dlclose( libHandle );
00792     err = dlerror();
00793     if ( err != NULL )
00794       Com_Printf ( "Sys_LoadDll(%s) failed dlcose:\n\"%s\"\n", name, err );
00795     return NULL;
00796   }
00797   Com_Printf ( "Sys_LoadDll(%s) found **vmMain** at  %p  \n", name, *entryPoint ); // bk001212
00798   dllEntry( systemcalls );
00799   Com_Printf ( "Sys_LoadDll(%s) succeeded!\n", name );
00800   if ( libHandle ) Q_strncpyz ( fqpath , fn , MAX_QPATH ) ;     // added 7/20/02 by T.Ray
00801   return libHandle;
00802 }

Here is the call graph for this function:

qboolean Sys_LowPhysicalMemory  ) 
 

Definition at line 107 of file unix_main.c.

References qboolean.

00107                                  {
00108   //MEMORYSTATUS stat;
00109   //GlobalMemoryStatus (&stat);
00110   //return (stat.dwTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
00111   return qfalse; // bk001207 - FIXME
00112 }

int Sys_MonkeyShouldBeSpanked void   ) 
 

Definition at line 137 of file unix_main.c.

00137                                       {
00138   return 0;
00139 }

void Sys_ParseArgs int  argc,
char *  argv[]
 

Definition at line 1207 of file unix_main.c.

References argc, argv, strcmp(), Sys_Exit(), and Sys_PrintBinVersion().

Referenced by main().

01207                                              {
01208 
01209   if ( argc==2 )
01210   {
01211     if ( (!strcmp( argv[1], "--version" ))
01212          || ( !strcmp( argv[1], "-v" )) )
01213     {
01214       Sys_PrintBinVersion( argv[0] );
01215       Sys_Exit(0);
01216     }
01217   }
01218 }

Here is the call graph for this function:

void Sys_Print const char *  msg  ) 
 

Definition at line 1153 of file unix_main.c.

References fputs(), stderr, tty_Hide(), and tty_Show().

01154 {
01155   if (ttycon_on)
01156   {
01157     tty_Hide();
01158   }
01159   fputs(msg, stderr);
01160   if (ttycon_on)
01161   {
01162     tty_Show();
01163   }
01164 }

Here is the call graph for this function:

void Sys_PrintBinVersion const char *  name  ) 
 

Definition at line 1193 of file unix_main.c.

References fprintf(), name, stdout, and time().

Referenced by Sys_ParseArgs().

01193                                              {
01194   char* date = __DATE__;
01195   char* time = __TIME__;
01196   char* sep = "==============================================================";
01197   fprintf( stdout, "\n\n%s\n", sep );
01198 #ifdef DEDICATED
01199   fprintf( stdout, "Linux Quake3 Dedicated Server [%s %s]\n", date, time );  
01200 #else
01201   fprintf( stdout, "Linux Quake3 Full Executable  [%s %s]\n", date, time );  
01202 #endif
01203   fprintf( stdout, " local install: %s\n", name );
01204   fprintf( stdout, "%s\n\n", sep );
01205 }

Here is the call graph for this function:

void Sys_QueEvent int  time,
sysEventType_t  type,
int  value,
int  value2,
int  ptrLength,
void *  ptr
 

Definition at line 1037 of file unix_main.c.

References Com_Printf(), eventHead,