forked from fte/fteqw
1
0
Fork 0
fteqw/engine/server/sv_sql.h

103 lines
3.6 KiB
C
Raw Normal View History

#ifndef SV_SQL_H
#define SV_SQL_H
#ifdef USE_MYSQL
#ifdef _WIN32
#include <windows.h>
#endif
#include <mysql/mysql.h>
#endif
#define SQL_CONNECT_STRUCTPARAMS 2
#define SQL_CONNECT_PARAMS 4
typedef enum
{
SQLDRV_MYSQL,
SQLDRV_SQLITE, /* NOT IN YET */
SQLDRV_INVALID
} sqldrv_t;
typedef struct queryrequest_s
{
int num; /* query number reference */
qboolean persistant; /* persistant query */
struct queryrequest_s *next; /* next request in queue */
int callback; /* callback function reference */
int selfent; /* self entity on call */
float selfid; /* self entity id on call */
int otherent; /* other entity on call */
float otherid; /* other entity id on call */
char query[1]; /* query to run */
} queryrequest_t;
typedef struct queryresult_s
{
struct queryrequest_s *request; /* corresponding request */
struct queryresult_s *next; /* next result in queue */
int rows; /* rows contained in single result set */
int firstrow; /* 0 on first result block */
int columns; /* fields */
qboolean eof; /* end of query reached */
void *result; /* result set from mysql */
#if 0
char **resultset; /* stored result set from partial fetch */
#endif
char error[1]; /* error string, "" if none */
} queryresult_t;
typedef struct sqlserver_s
{
void *thread; /* worker thread for server */
sqldrv_t driver; /* driver type */
#ifdef USE_MYSQL
MYSQL *mysql; /* mysql server */
#endif
#ifdef USE_SQLITE
struct sqlite3 *sqlite;
#endif
volatile qboolean active; /* set to false to kill thread */
volatile qboolean terminated; /* set by the worker to say that it won't block (for long) and can be joined */
void *requestcondv; /* lock and conditional variable for queue read/write */
void *resultlock; /* mutex for queue read/write */
int querynum; /* next reference number for queries */
queryrequest_t *requests; /* query requests queue */
queryrequest_t *requestslast; /* query requests queue last link */
queryresult_t *results; /* query results queue */
queryresult_t *resultslast; /* query results queue last link */
queryresult_t *currentresult; /* current called result */
queryresult_t *persistresults; /* list of persistant results */
queryresult_t *serverresult; /* server error results */
char **connectparams; /* connect parameters (0 = host, 1 = user, 2 = pass, 3 = defaultdb) */
} sqlserver_t;
/* prototypes */
void SQL_Init(void);
void SQL_KillServers(void);
void SQL_DeInit(void);
sqlserver_t *SQL_GetServer (int serveridx, qboolean inactives);
queryresult_t *SQL_GetQueryResult (sqlserver_t *server, int queryidx);
//void SQL_DeallocResult(sqlserver_t *server, queryresult_t *qres);
void SQL_ClosePersistantResult(sqlserver_t *server, queryresult_t *qres);
void SQL_CloseResult(sqlserver_t *server, queryresult_t *qres);
void SQL_CloseAllResults(sqlserver_t *server);
char *SQL_ReadField (sqlserver_t *server, queryresult_t *qres, int row, int col, qboolean fields);
int SQL_NewServer(char *driver, char **paramstr);
int SQL_NewQuery(sqlserver_t *server, int callfunc, int type, int self, float selfid, int other, float otherid, char *str);
void SQL_Disconnect(sqlserver_t *server);
void SQL_Escape(sqlserver_t *server, char *src, char *dst, int dstlen);
const char *SQL_Info(sqlserver_t *server);
qboolean SQL_Available(void);
------------------------------------------------------------------------ r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines removed MAX_VISEDICTS limit. PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default. TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW. added android multitouch emulation for windows/rawinput (in_simulatemultitouch). split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature. now using utf-8 for windows consoles. qcc warnings/errors now give clickable console links for quick+easy editing. disabled menutint when the currently active item changes contrast or gamma (for OneManClan). Added support for drawfont/drawfontscale. tweaked the qcvm a little to reduce the number of pointers. .doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up. windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings. fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen. editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts. Added support for .framegroups files for psk(psa) and iqm formats. True support for ezquake's colour codes. Mutually exclusive with background colours. path command output slightly more readable. added support for digest_hex (MD4, SHA1, CRC16). skingroups now colourmap correctly. Fix terrain colour hints, and litdata from the wrong bsp. fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported). remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother. fix v *= v.x and similar opcodes. fteqcc: fixed support for áéíóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported. fteqcc: fixed '#if 1 == 3 && 4' parsing. fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable. fteqcc: copyright message now includes compile date instead. fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile. fteqccgui: the output window is now focused and scrolls down as compilation progresses. pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue. rewrote prespawn/modelist/soundlist code. server tracks progress now. ------------------------------------------------------------------------ git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
void SQL_ServerCycle (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
extern cvar_t sql_driver;
extern cvar_t sql_host;
extern cvar_t sql_username;
extern cvar_t sql_password;
extern cvar_t sql_defaultdb;
#define SQLCVAROPTIONS "SQL Defaults"
#endif