This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/launch/launch.h

274 lines
10 KiB
C
Raw Normal View History

2007-11-10 22:00:00 +01:00
//=======================================================================
// Copyright XashXT Group 2007 <20>
// launch.h - launch.dll main header
//=======================================================================
#ifndef LAUNCHER_H
#define LAUNCHER_H
#include <windows.h>
#include <stdio.h>
#include <io.h>
#include <winreg.h>
#include <fcntl.h>
#include <basetypes.h>
#include <ref_system.h>
enum
{
ERR_INVALID_ROOT,
ERR_CONSOLE_FAIL,
ERR_OSINFO_FAIL,
ERR_INVALID_VER,
ERR_WINDOWS_32S,
};
typedef struct system_s
{
char progname[MAX_QPATH];
int app_name;
bool debug;
bool developer;
bool log_active;
char log_path[MAX_SYSPATH];
bool hooked_out;
HINSTANCE hInstance;
LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
dll_info_t *linked_dll;
char caption[MAX_QPATH];
bool con_readonly;
bool con_showalways;
bool con_showcredits;
bool con_silentmode;
bool error;
2007-11-21 22:00:00 +01:00
bool crash;
2007-11-10 22:00:00 +01:00
byte *basepool;
byte *zonepool;
2007-11-11 22:00:00 +01:00
byte *imagepool;
2007-11-14 22:00:00 +01:00
byte *stringpool;
2007-11-10 22:00:00 +01:00
// simply profiling
double start, end;
void (*Con_Print)( const char *msg );
2007-11-11 22:00:00 +01:00
void ( *Init ) ( uint funcname, int argc, char **argv );
2007-11-10 22:00:00 +01:00
void ( *Main ) ( void ); // host frame
void ( *Free ) ( void ); // close host
} system_t;
2007-11-11 22:00:00 +01:00
extern system_t Sys;
2007-11-10 22:00:00 +01:00
extern gameinfo_t GI;
2007-11-11 22:00:00 +01:00
extern stdlib_api_t std;
2007-11-10 22:00:00 +01:00
//
// console.c
//
void Con_ShowConsole( bool show );
void Con_PrintA(const char *pMsg);
void Con_PrintW(const char *pMsg);
void Con_CreateConsole( void );
void Con_DestroyConsole( void );
char *Sys_Input( void );
void Con_RegisterHotkeys( void );
//
// system.c
//
void Sys_InitCPU( void );
gameinfo_t Sys_GameInfo( void );
uint Sys_SendKeyEvents( void );
void Sys_ParseCommandLine (LPSTR lpCmdLine);
void Sys_LookupInstance( void );
double Sys_DoubleTime( void );
char *Sys_GetClipboardData( void );
void Sys_Sleep( int msec );
void Sys_Init( void );
void Sys_Exit( void );
bool Sys_LoadLibrary ( dll_info_t *dll );
void* Sys_GetProcAddress ( dll_info_t *dll, const char* name );
bool Sys_FreeLibrary ( dll_info_t *dll );
void Sys_WaitForQuit( void );
void Sys_InitLog( void );
void Sys_CloseLog( void );
2007-11-14 22:00:00 +01:00
void Sys_Error(const char *error, ...);
2007-11-10 22:00:00 +01:00
void Sys_PrintLog( const char *pMsg );
void Sys_Print(const char *pMsg);
void Sys_Msg( const char *pMsg, ... );
void Sys_MsgWarn( const char *pMsg, ... );
void Sys_MsgDev( int level, const char *pMsg, ... );
int Sys_GetThreadWork( void );
void Sys_ThreadWorkerFunction (int threadnum);
void Sys_ThreadSetDefault (void);
void Sys_ThreadLock( void );
void Sys_ThreadUnlock( void );
int Sys_GetNumThreads( void );
void Sys_RunThreadsOnIndividual(int workcnt, bool showpacifier, void(*func)(int));
void Sys_RunThreadsOn (int workcnt, bool showpacifier, void(*func)(int));
#define Msg Sys_Msg
#define MsgDev Sys_MsgDev
#define MsgWarn Sys_MsgWarn
// registry common tools
bool REG_GetValue( HKEY hKey, const char *SubKey, const char *Value, char *pBuffer);
bool REG_SetValue( HKEY hKey, const char *SubKey, const char *Value, char *pBuffer);
//
// stdlib.c
//
void com_strnupr(const char *in, char *out, size_t size_out);
void com_strupr(const char *in, char *out);
void com_strnlwr(const char *in, char *out, size_t size_out);
void com_strlwr(const char *in, char *out);
int com_strlen( const char *string );
int com_cstrlen( const char *string );
char com_toupper(const char in );
char com_tolower(const char in );
size_t com_strncat(char *dst, const char *src, size_t siz);
size_t com_strcat(char *dst, const char *src );
size_t com_strncpy(char *dst, const char *src, size_t siz);
size_t com_strcpy(char *dst, const char *src );
2007-11-14 22:00:00 +01:00
char *com_stralloc(const char *s, const char *filename, int fileline);
2007-11-10 22:00:00 +01:00
int com_atoi(const char *str);
float com_atof(const char *str);
void com_atov( float *vec, const char *str, size_t siz );
char *com_strchr(const char *s, char c);
char *com_strrchr(const char *s, char c);
int com_strnicmp(const char *s1, const char *s2, int n);
int com_stricmp(const char *s1, const char *s2);
int com_strncmp (const char *s1, const char *s2, int n);
int com_strcmp (const char *s1, const char *s2);
const char* com_timestamp( int format );
char *com_stristr( const char *string, const char *string2 );
size_t com_strpack( byte *buffer, size_t pos, char *string, int n );
size_t com_strunpack( byte *buffer, size_t pos, char *string );
int com_vsnprintf(char *buffer, size_t buffersize, const char *format, va_list args);
int com_vsprintf(char *buffer, const char *format, va_list args);
int com_snprintf(char *buffer, size_t buffersize, const char *format, ...);
int com_sprintf(char *buffer, const char *format, ...);
2007-11-14 22:00:00 +01:00
char *com_pretifymem( float value, int digitsafterdecimal );
2007-11-10 22:00:00 +01:00
char *va(const char *format, ...);
//
// memlib.c
//
void Memory_Init( void );
void Memory_Shutdown( void );
void _mem_move(byte *poolptr, void **dest, void *src, size_t size, const char *filename, int fileline);
void *_mem_realloc(byte *poolptr, void *memptr, size_t size, const char *filename, int fileline);
void _mem_copy(void *dest, const void *src, size_t size, const char *filename, int fileline);
void _mem_set(void *dest, int set, size_t size, const char *filename, int fileline);
void *_mem_alloc(byte *poolptr, size_t size, const char *filename, int fileline);
byte *_mem_allocpool(const char *name, const char *filename, int fileline);
void _mem_freepool(byte **poolptr, const char *filename, int fileline);
void _mem_emptypool(byte *poolptr, const char *filename, int fileline);
void _mem_free(void *data, const char *filename, int fileline);
void _mem_check(const char *filename, int fileline);
#define Mem_Alloc(pool, size) _mem_alloc(pool, size, __FILE__, __LINE__)
#define Mem_Realloc(pool, ptr, size) _mem_realloc(pool, ptr, size, __FILE__, __LINE__)
#define Mem_Free(mem) _mem_free(mem, __FILE__, __LINE__)
#define Mem_AllocPool(name) _mem_allocpool(name, __FILE__, __LINE__)
#define Mem_FreePool(pool) _mem_freepool(pool, __FILE__, __LINE__)
#define Mem_EmptyPool(pool) _mem_emptypool(pool, __FILE__, __LINE__)
2007-11-11 22:00:00 +01:00
#define Mem_Move(pool, dest, src, size ) _mem_move(pool, dest, src, size, __FILE__, __LINE__)
2007-11-10 22:00:00 +01:00
#define Mem_Copy(dest, src, size ) _mem_copy(dest, src, size, __FILE__, __LINE__)
#define Mem_Set(dest, src, size ) _mem_set(dest, src, size, __FILE__, __LINE__)
#define Mem_Check() _mem_check(__FILE__, __LINE__)
2007-11-14 22:00:00 +01:00
#define Mem_Pretify( x ) com_pretifymem(x, 3)
#define Malloc( size ) Mem_Alloc( Sys.basepool, size )
2007-11-10 22:00:00 +01:00
//
// filesystem.c
//
void FS_Init( void );
void FS_Path( void );
void FS_Shutdown( void );
void FS_InitEditor( void );
void FS_InitRootDir( char *path );
void FS_ClearSearchPath (void);
void FS_AddGameHierarchy (const char *dir);
int FS_CheckParm (const char *parm);
void FS_LoadGameInfo( const char *filename );
void FS_FileBase (char *in, char *out);
const char *FS_FileExtension (const char *in);
void FS_DefaultExtension (char *path, const char *extension );
bool FS_GetParmFromCmdLine( char *parm, char *out );
2007-11-11 22:00:00 +01:00
void FS_ExtractFilePath(const char* const path, char* dest);
2007-11-10 22:00:00 +01:00
void FS_UpdateEnvironmentVariables( void );
2007-11-11 22:00:00 +01:00
const char *FS_FileWithoutPath (const char *in);
2007-11-10 22:00:00 +01:00
extern char sys_rootdir[];
extern char *fs_argv[];
extern int fs_argc;
// simply files managment interface
byte *FS_LoadFile (const char *path, fs_offset_t *filesizeptr );
bool FS_WriteFile (const char *filename, void *data, fs_offset_t len);
2007-11-11 22:00:00 +01:00
rgbdata_t *FS_LoadImage(const char *filename, char *data, int size );
void FS_SaveImage(const char *filename, rgbdata_t *buffer );
void FS_FreeImage( rgbdata_t *pack );
bool Image_Processing( const char *name, rgbdata_t **pix );
2007-11-10 22:00:00 +01:00
search_t *FS_Search(const char *pattern, int caseinsensitive );
search_t *FS_SearchDirs(const char *pattern, int caseinsensitive );
// files managment (like fopen, fread etc)
file_t *FS_Open (const char* filepath, const char* mode );
file_t* _FS_Open (const char* filepath, const char* mode, bool quiet, bool nonblocking);
fs_offset_t FS_Write (file_t* file, const void* data, size_t datasize);
fs_offset_t FS_Read (file_t* file, void* buffer, size_t buffersize);
int FS_VPrintf(file_t* file, const char* format, va_list ap);
int FS_Seek (file_t* file, fs_offset_t offset, int whence);
int FS_Gets (file_t* file, byte *string, size_t bufsize );
int FS_Printf(file_t* file, const char* format, ...);
fs_offset_t FS_FileSize (const char *filename);
int FS_Print(file_t* file, const char *msg);
bool FS_FileExists (const char *filename);
int FS_UnGetc (file_t* file, byte c);
void FS_StripExtension (char *path);
fs_offset_t FS_Tell (file_t* file);
void FS_Purge (file_t* file);
int FS_Close (file_t* file);
int FS_Getc (file_t* file);
bool FS_Eof( file_t* file);
// virtual files managment
2007-11-11 22:00:00 +01:00
vfile_t *VFS_Create(byte *buffer, size_t buffsize);
2007-11-18 22:00:00 +01:00
vfile_t *VFS_Open(file_t *handle, const char* mode);
2007-11-10 22:00:00 +01:00
fs_offset_t VFS_Write( vfile_t *file, const void *buf, size_t size );
fs_offset_t VFS_Read(vfile_t* file, void* buffer, size_t buffersize);
2007-11-18 22:00:00 +01:00
int VFS_Print(vfile_t* file, const char *msg);
int VFS_Printf(vfile_t* file, const char* format, ...);
2007-11-10 22:00:00 +01:00
int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence );
2007-11-21 22:00:00 +01:00
int VFS_Gets(vfile_t* file, byte *string, size_t bufsize );
2007-11-11 22:00:00 +01:00
bool VFS_Unpack( void* compbuf, size_t compsize, void **buf, size_t size );
2007-11-10 22:00:00 +01:00
fs_offset_t VFS_Tell (vfile_t* file);
2007-11-18 22:00:00 +01:00
file_t *VFS_Close( vfile_t *file );
2007-11-10 22:00:00 +01:00
//
// crclib.c
//
void CRC_Init(word *crcvalue);
word CRC_Block (byte *start, int count);
void CRC_ProcessByte(word *crcvalue, byte data);
byte CRC_BlockSequence(byte *base, int length, int sequence);
//
// parselib.c
//
bool SC_LoadScript( const char *filename, char *buf, int size );
2007-11-11 22:00:00 +01:00
bool SC_AddScript( const char *filename, char *buf, int size );
2007-11-10 22:00:00 +01:00
bool SC_FilterToken(char *filter, char *name, int casecmp);
char *SC_ParseToken(const char **data_p );
char *SC_ParseWord( const char **data_p );
bool SC_MatchToken( const char *match );
2007-11-11 22:00:00 +01:00
void SC_ResetScript( void );
2007-11-10 22:00:00 +01:00
void SC_SkipToken( void );
void SC_FreeToken( void );
bool SC_TryToken( void );
char *SC_GetToken( bool newline );
2007-11-11 22:00:00 +01:00
extern char token[];
2007-11-10 22:00:00 +01:00
#endif//LAUNCHER_H