├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── run_bin.sh ├── src ├── bgame │ ├── bg_animation_mp.cpp │ ├── bg_jump.cpp │ ├── bg_mantle.cpp │ ├── bg_misc.cpp │ ├── bg_misctables.cpp │ ├── bg_pmove.cpp │ ├── bg_public.h │ ├── bg_slidemove.cpp │ ├── bg_weapons.cpp │ └── bg_weapons_load_obj.cpp ├── game │ ├── g_active_mp.cpp │ ├── g_client_fields_mp.cpp │ ├── g_client_mp.cpp │ ├── g_client_script_cmd_mp.cpp │ ├── g_cmds_mp.cpp │ ├── g_combat_mp.cpp │ ├── g_hudelem_mp.cpp │ ├── g_items_mp.cpp │ ├── g_load_utils.cpp │ ├── g_main_mp.cpp │ ├── g_misc_mp.cpp │ ├── g_missile_mp.cpp │ ├── g_mover_mp.cpp │ ├── g_scr_main_mp.cpp │ ├── g_scr_mover_mp.cpp │ ├── g_shared.h │ ├── g_spawn_mp.cpp │ ├── g_svcmds_mp.cpp │ ├── g_team_mp.cpp │ ├── g_trigger_mp.cpp │ ├── g_utils_mp.cpp │ ├── g_weapon_load_obj.cpp │ ├── g_weapon_mp.cpp │ ├── player_use_mp.cpp │ └── scr_const_mp.cpp ├── libcod │ ├── gsc.cpp │ ├── gsc.hpp │ ├── gsc_bots.cpp │ ├── gsc_bots.hpp │ ├── gsc_entity.cpp │ ├── gsc_entity.hpp │ ├── gsc_exec.cpp │ ├── gsc_exec.hpp │ ├── gsc_level.cpp │ ├── gsc_level.hpp │ ├── gsc_memory.cpp │ ├── gsc_memory.hpp │ ├── gsc_mysql.cpp │ ├── gsc_mysql.hpp │ ├── gsc_player.cpp │ ├── gsc_player.hpp │ ├── gsc_sqlite.cpp │ ├── gsc_sqlite.hpp │ ├── gsc_utils.cpp │ ├── gsc_utils.hpp │ ├── gsc_weapons.cpp │ ├── gsc_weapons.hpp │ ├── libcod.cpp │ ├── mysql │ │ └── include │ │ │ ├── big_endian.h │ │ │ ├── byte_order_generic.h │ │ │ ├── byte_order_generic_x86.h │ │ │ ├── decimal.h │ │ │ ├── errmsg.h │ │ │ ├── keycache.h │ │ │ ├── little_endian.h │ │ │ ├── m_ctype.h │ │ │ ├── m_string.h │ │ │ ├── my_alloc.h │ │ │ ├── my_byteorder.h │ │ │ ├── my_compiler.h │ │ │ ├── my_config.h │ │ │ ├── my_dbug.h │ │ │ ├── my_dir.h │ │ │ ├── my_getopt.h │ │ │ ├── my_global.h │ │ │ ├── my_list.h │ │ │ ├── my_pthread.h │ │ │ ├── my_sys.h │ │ │ ├── my_xml.h │ │ │ ├── mysql.h │ │ │ ├── mysql │ │ │ ├── client_authentication.h │ │ │ ├── client_plugin.h │ │ │ ├── client_plugin.h.pp │ │ │ ├── get_password.h │ │ │ ├── plugin_auth_common.h │ │ │ ├── plugin_trace.h │ │ │ ├── psi │ │ │ │ ├── mysql_file.h │ │ │ │ ├── mysql_idle.h │ │ │ │ ├── mysql_mdl.h │ │ │ │ ├── mysql_memory.h │ │ │ │ ├── mysql_ps.h │ │ │ │ ├── mysql_socket.h │ │ │ │ ├── mysql_sp.h │ │ │ │ ├── mysql_stage.h │ │ │ │ ├── mysql_statement.h │ │ │ │ ├── mysql_table.h │ │ │ │ ├── mysql_thread.h │ │ │ │ ├── mysql_transaction.h │ │ │ │ ├── psi.h │ │ │ │ ├── psi_base.h │ │ │ │ └── psi_memory.h │ │ │ ├── service_my_snprintf.h │ │ │ └── service_mysql_alloc.h │ │ │ ├── mysql_com.h │ │ │ ├── mysql_com_server.h │ │ │ ├── mysql_embed.h │ │ │ ├── mysql_time.h │ │ │ ├── mysql_version.h │ │ │ ├── mysqld_ername.h │ │ │ ├── mysqld_error.h │ │ │ ├── sql_common.h │ │ │ ├── sql_state.h │ │ │ ├── sslopt-case.h │ │ │ ├── sslopt-longopts.h │ │ │ ├── sslopt-vars.h │ │ │ └── typelib.h │ └── sqlite │ │ ├── sqlite3.c │ │ ├── sqlite3.h │ │ └── sqlite3ext.h ├── misc │ └── hexrays_defs.h ├── qcommon │ ├── cm_load.cpp │ ├── cm_load_obj.cpp │ ├── cm_local.h │ ├── cm_mesh.cpp │ ├── cm_public.h │ ├── cm_staticmodel.cpp │ ├── cm_staticmodel_load_obj.cpp │ ├── cm_test.cpp │ ├── cm_trace.cpp │ ├── cm_tracebox.cpp │ ├── cm_world.cpp │ ├── cmd.cpp │ ├── cmd.h │ ├── com_bsp_load_obj.cpp │ ├── common.cpp │ ├── dobj_management.cpp │ ├── huffman.cpp │ ├── md4.cpp │ ├── msg_mp.cpp │ ├── net_chan_mp.cpp │ ├── netchan.h │ ├── qcommon.h │ └── qvsnprintf.cpp ├── script │ ├── scr_animtree.cpp │ ├── scr_compiler.cpp │ ├── scr_evaluate.cpp │ ├── scr_main.cpp │ ├── scr_memorytree.cpp │ ├── scr_parser.cpp │ ├── scr_stringlist.cpp │ ├── scr_tempmemory.cpp │ ├── scr_variable.cpp │ ├── scr_vm.cpp │ ├── scr_yacc.cpp │ └── script_public.h ├── server │ ├── server.h │ ├── sv_ccmds_mp.cpp │ ├── sv_client_mp.cpp │ ├── sv_game_mp.cpp │ ├── sv_init_mp.cpp │ ├── sv_main_mp.cpp │ ├── sv_main_pc_mp.cpp │ ├── sv_net_chan_mp.cpp │ ├── sv_snapshot_mp.cpp │ ├── sv_voice_mp.cpp │ └── sv_world_mp.cpp ├── stringed │ ├── stringed_hooks.cpp │ └── stringed_public.h ├── ui │ └── keycodes.h ├── universal │ ├── assertive.cpp │ ├── com_files.cpp │ ├── com_files.h │ ├── com_math.cpp │ ├── com_math.h │ ├── com_memory.cpp │ ├── com_memory.h │ ├── dvar.cpp │ ├── dvar.h │ ├── dvar_cmds.cpp │ ├── q_parse.cpp │ ├── q_shared.cpp │ ├── q_shared.h │ ├── surfaceflags.cpp │ ├── surfaceflags.h │ └── universal_public.h ├── unix │ ├── linux_local.h │ ├── unix_main.cpp │ ├── unix_net.cpp │ ├── unix_shared.cpp │ └── unix_threads.cpp ├── win32 │ ├── cod2.ico │ ├── codlogo.bmp │ ├── resource.h │ ├── win_cod2.rc │ ├── win_input.cpp │ ├── win_local.h │ ├── win_main.cpp │ ├── win_net.cpp │ ├── win_shared.cpp │ ├── win_syscon.cpp │ ├── win_threads.cpp │ └── win_wndproc.cpp ├── xanim │ ├── dobj.cpp │ ├── dobj_utils.cpp │ ├── xanim.cpp │ ├── xanim_calc.cpp │ ├── xanim_load_obj.cpp │ ├── xanim_public.h │ ├── xmodel.cpp │ ├── xmodel_load_obj.cpp │ └── xmodel_utils.cpp └── zlib │ ├── adler32.c │ ├── crc32.c │ ├── crc32.h │ ├── crypt.h │ ├── deflate.c │ ├── deflate.h │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── ioapi.h │ ├── trees.c │ ├── trees.h │ ├── unzip.c │ ├── unzip.h │ ├── utils.c │ ├── zconf.h │ ├── zlib.h │ └── zutil.h └── test ├── database ├── cod2_lnxded_1_0.c ├── cod2_lnxded_1_0.c.original ├── funcs_offsets.txt ├── offset_database.txt ├── replace_offsets.pl └── sorted_database.txt ├── ida ├── cod2_lnxded.idb ├── generate_nasm.idc └── rename_offsets.idc └── linux ├── sys_libloader.cpp ├── sys_patch.cpp └── sys_patch.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # cod2rev 35 | *.bak 36 | *.iwd 37 | *.dm_1 38 | *.cfg 39 | 40 | bin/** 41 | main/** 42 | obj/** 43 | obj_test/** -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoD2rev_Server 2 | 3 | ## About 4 | 5 | This is a reverse-engenerred Call of Duty 2 dedicated server code. 6 | It fixes several bugs in the original binaries and allows developers to extend server functionality. 7 | 8 | ## Credits: 9 | 10 | id Software 11 | 12 | Activision / Infinity Ward 13 | 14 | CoD4x Server: https://github.com/callofduty4x/CoD4x_Server 15 | 16 | OpenBO2: https://github.com/builtbyxeno/OpenBO2 -------------------------------------------------------------------------------- /run_bin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BASEPATH="bin" 4 | HOMEPATH="bin/.callofduty2" 5 | PARAMS="+set fs_cdpath $BASEPATH +set fs_homepath $HOMEPATH +set fs_game test +set dedicated 2 +set net_port 28962 +set developer 1 +set developer_script 1 +set sv_maxclients 32 +set scr_testclients 4 +set scr_forcerespawn 0 +set g_gametype tdm +set sv_cheats 1 +set sv_cracked 1 +set g_password test +devmap mp_toujane" 6 | 7 | "bin/cod2rev_lnxded" "$PARAMS" 8 | -------------------------------------------------------------------------------- /src/game/g_team_mp.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | #include "g_shared.h" 3 | 4 | /* 5 | ============== 6 | OnSameTeam 7 | ============== 8 | */ 9 | qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ) 10 | { 11 | if ( !ent1->client || !ent2->client ) 12 | { 13 | return qfalse; 14 | } 15 | if ( ent1->client->sess.cs.team == TEAM_FREE ) 16 | { 17 | return qfalse; 18 | } 19 | 20 | if ( ent1->client->sess.cs.team == ent2->client->sess.cs.team ) 21 | { 22 | return qtrue; 23 | } 24 | 25 | return qfalse; 26 | } 27 | 28 | /* 29 | ================== 30 | TeamplayLocationsMessage 31 | 32 | Format: 33 | clientNum location health armor weapon powerups 34 | 35 | ================== 36 | */ 37 | void TeamplayInfoMessage( gentity_t *ent ) 38 | { 39 | trace_t trace; 40 | vec3_t vEnd; 41 | vec3_t vStart; 42 | vec3_t vForward; 43 | int num, health; 44 | 45 | if ( ent->client->sess.sessionState != SESS_STATE_PLAYING ) 46 | { 47 | G_GetPlayerViewOrigin(ent, vStart); 48 | G_GetPlayerViewDirection(ent, vForward, NULL, NULL); 49 | 50 | if ( ent->client->ps.viewHeightCurrent < DEAD_VIEWHEIGHT ) 51 | { 52 | vStart[2] += DEAD_VIEWHEIGHT - ent->client->ps.viewHeightCurrent; 53 | } 54 | 55 | VectorMA(vStart, 8192, vForward, vEnd); 56 | } 57 | else 58 | { 59 | if ( ent->client->sess.cs.team == TEAM_FREE ) 60 | { 61 | ent->client->ps.stats[STAT_IDENT_CLIENT_NUM] = -1; 62 | #if PROTOCOL_VERSION != 119 63 | ent->client->ps.stats[STAT_IDENT_CLIENT_HEALTH] = 0; 64 | #endif 65 | return; 66 | } 67 | 68 | G_GetPlayerViewOrigin(ent, vStart); 69 | G_GetPlayerViewDirection(ent, vForward, NULL, NULL); 70 | 71 | VectorMA(vStart, 8192, vForward, vEnd); 72 | } 73 | 74 | G_TraceCapsule(&trace, vStart, vec3_origin, vec3_origin, vEnd, ent->client->ps.clientNum, CONTENTS_SOLID | CONTENTS_BODY); 75 | num = trace.entityNum; 76 | 77 | if ( trace.entityNum < MAX_CLIENTS && g_entities[num].client && (!G_IsPlaying(ent) || g_entities[num].client->sess.cs.team == ent->client->sess.cs.team) ) 78 | { 79 | health = g_entities[num].health; 80 | } 81 | else 82 | { 83 | num = -1; 84 | health = 0; 85 | } 86 | 87 | ent->client->ps.stats[STAT_IDENT_CLIENT_NUM] = num; 88 | #if PROTOCOL_VERSION != 119 89 | ent->client->ps.stats[STAT_IDENT_CLIENT_HEALTH] = health; 90 | #endif 91 | } 92 | 93 | /* 94 | ============== 95 | CheckTeamStatus 96 | ============== 97 | */ 98 | void CheckTeamStatus() 99 | { 100 | gentity_t *ent; 101 | int i; 102 | 103 | if ( level.time - level.lastTeammateHealthTime <= 0 ) 104 | { 105 | return; 106 | } 107 | 108 | level.lastTeammateHealthTime = level.time; 109 | 110 | for ( i = 0; i < g_maxclients->current.integer; i++ ) 111 | { 112 | ent = &g_entities[i]; 113 | 114 | if ( !ent->r.inuse ) 115 | { 116 | continue; 117 | } 118 | 119 | if ( ent->client->ps.pm_flags & PMF_FOLLOW ) 120 | { 121 | continue; 122 | } 123 | 124 | TeamplayInfoMessage(ent); 125 | } 126 | } -------------------------------------------------------------------------------- /src/game/g_weapon_load_obj.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | #include "g_shared.h" 3 | 4 | const char *accuracyDirName[] = 5 | { 6 | "aivsai", 7 | "aivsplayer" 8 | }; 9 | 10 | /* 11 | ==================== 12 | G_ParseAIWeaponAccurayGraphFile 13 | ==================== 14 | */ 15 | static bool G_ParseAIWeaponAccurayGraphFile( const char *buffer, const char *fileName, float (*knots)[2], int *knotCount ) 16 | { 17 | int knotCountIndex; 18 | const char *token; 19 | 20 | assert(buffer); 21 | assert(fileName); 22 | assert(knots); 23 | assert(knotCount); 24 | 25 | Com_BeginParseSession(fileName); 26 | token = Com_Parse(&buffer); 27 | 28 | *knotCount = atoi(token); 29 | knotCountIndex = 0; 30 | 31 | while ( 1 ) 32 | { 33 | token = Com_Parse(&buffer); 34 | 35 | if ( !token[0] ) 36 | { 37 | break; 38 | } 39 | 40 | if ( *token == '}' ) 41 | { 42 | break; 43 | } 44 | 45 | (*knots)[2 * knotCountIndex] = atof(token); 46 | token = Com_Parse(&buffer); 47 | 48 | if ( !token[0] ) 49 | { 50 | break; 51 | } 52 | 53 | if ( *token == '}' ) 54 | { 55 | break; 56 | } 57 | 58 | (*knots)[2 * knotCountIndex + 1] = atof(token); 59 | knotCountIndex++; 60 | 61 | if ( knotCountIndex >= 16 ) 62 | { 63 | Com_Printf("^3WARNING: \"%s\" has too many graph knots\n", fileName); 64 | Com_EndParseSession(); 65 | return false; 66 | } 67 | 68 | } 69 | 70 | Com_EndParseSession(); 71 | 72 | if ( knotCountIndex != *knotCount ) 73 | { 74 | Com_Printf("^3WARNING: \"%s\" Error in parsing an ai weapon accuracy file\n", fileName); 75 | return false; 76 | } 77 | 78 | return true; 79 | } 80 | 81 | /* 82 | ==================== 83 | G_ParseWeaponAccurayGraphInternal 84 | ==================== 85 | */ 86 | static bool G_ParseWeaponAccurayGraphInternal( WeaponDef *weaponDef, const char *dirName, const char *graphName, float (*knots)[2], int *knotCount ) 87 | { 88 | int count, l; 89 | const char *last = "WEAPONACCUFILE"; 90 | char buffer[8192]; 91 | char string[MAX_QPATH]; 92 | fileHandle_t f; 93 | int len = strlen(last); 94 | 95 | assert(weaponDef); 96 | assert(graphName); 97 | assert(knots); 98 | assert(knotCount); 99 | assert(dirName); 100 | 101 | if ( weaponDef->weaponType && weaponDef->weaponType != WEAPTYPE_PROJECTILE ) 102 | { 103 | return true; 104 | } 105 | 106 | if ( !graphName[0] ) 107 | { 108 | return true; 109 | } 110 | 111 | sprintf(string, "accuracy/%s/%s", dirName, graphName); 112 | l = FS_FOpenFileByMode(string, &f, FS_READ); 113 | 114 | if ( l < 0 ) 115 | { 116 | Com_Printf("^3WARNING: Could not load ai weapon accuracy file '%s'\n", string); 117 | return false; 118 | } 119 | 120 | FS_Read(buffer, len, f); 121 | buffer[len] = 0; 122 | 123 | if ( strncmp( buffer, last, len ) ) 124 | { 125 | Com_Printf("^3WARNING: \"%s\" does not appear to be an ai weapon accuracy file\n", string); 126 | FS_FCloseFile(f); 127 | return false; 128 | } 129 | 130 | if ( l - len > sizeof(buffer) ) 131 | { 132 | Com_Printf("^3WARNING: \"%s\" Is too long of an ai weapon accuracy file to parse\n", string); 133 | FS_FCloseFile(f); 134 | return false; 135 | } 136 | 137 | memset(buffer, 0, sizeof(buffer)); 138 | 139 | FS_Read(buffer, l - len, f); 140 | buffer[l - len] = 0; 141 | FS_FCloseFile(f); 142 | 143 | count = 0; 144 | 145 | if ( !G_ParseAIWeaponAccurayGraphFile( buffer, string, knots, &count ) ) 146 | { 147 | return false; 148 | } 149 | 150 | *knotCount = count; 151 | return true; 152 | } 153 | 154 | /* 155 | ==================== 156 | G_ParseWeaponAccurayGraphs 157 | ==================== 158 | */ 159 | bool G_ParseWeaponAccurayGraphs( WeaponDef *weaponDef ) 160 | { 161 | int weaponType, accuracyGraphKnotCount; 162 | float accuracyGraphKnots[16][2]; 163 | 164 | for ( weaponType = 0; weaponType < 2; weaponType++ ) 165 | { 166 | memset(accuracyGraphKnots, 0, sizeof(accuracyGraphKnots)); 167 | accuracyGraphKnotCount = 0; 168 | 169 | if ( !G_ParseWeaponAccurayGraphInternal( weaponDef, accuracyDirName[weaponType], weaponDef->accuracyGraphName[weaponType], accuracyGraphKnots, &accuracyGraphKnotCount ) ) 170 | { 171 | return false; 172 | } 173 | 174 | if ( accuracyGraphKnotCount > 0 ) 175 | { 176 | weaponDef->accuracyGraphKnots[weaponType] = (float (*)[2])Hunk_AllocLowAlignInternal( sizeof( weaponDef->accuracyGraphKnots ) * accuracyGraphKnotCount, 4 ); 177 | memcpy(weaponDef->accuracyGraphKnots[weaponType], accuracyGraphKnots, sizeof( weaponDef->accuracyGraphKnots ) * accuracyGraphKnotCount); 178 | weaponDef->accuracyGraphKnotCount[weaponType] = accuracyGraphKnotCount; 179 | } 180 | } 181 | 182 | return true; 183 | } -------------------------------------------------------------------------------- /src/libcod/gsc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_HPP_ 2 | #define _GSC_HPP_ 3 | 4 | #include "../qcommon/qcommon.h" 5 | #include "../game/g_shared.h" 6 | 7 | #define COD2_MAX_STRINGLENGTH MAX_STRING_CHARS 8 | 9 | /* default stuff */ 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include // va_args 16 | #include //link, unlink, usleep 17 | #include // dir stuff 18 | #include // offsetof 19 | #include // fsize 20 | #include // getsystemtime 21 | #include // milliseconds 22 | #include // isdigit 23 | 24 | #if LIBCOD_COMPILE_BOTS == 1 25 | #include "gsc_bots.hpp" 26 | #endif 27 | 28 | #if LIBCOD_COMPILE_ENTITY == 1 29 | #include "gsc_entity.hpp" 30 | #endif 31 | 32 | #if LIBCOD_COMPILE_EXEC == 1 33 | #include "gsc_exec.hpp" 34 | #endif 35 | 36 | #if LIBCOD_COMPILE_LEVEL == 1 37 | #include "gsc_level.hpp" 38 | #endif 39 | 40 | #if LIBCOD_COMPILE_MEMORY == 1 41 | #include "gsc_memory.hpp" 42 | #endif 43 | 44 | #if LIBCOD_COMPILE_MYSQL == 1 45 | #include "gsc_mysql.hpp" 46 | #endif 47 | 48 | #if LIBCOD_COMPILE_PLAYER == 1 49 | #include "gsc_player.hpp" 50 | #endif 51 | 52 | #if LIBCOD_COMPILE_SQLITE == 1 53 | #include "gsc_sqlite.hpp" 54 | #endif 55 | 56 | #if LIBCOD_COMPILE_UTILS == 1 57 | #include "gsc_utils.hpp" 58 | #endif 59 | 60 | #if LIBCOD_COMPILE_WEAPONS == 1 61 | #include "gsc_weapons.hpp" 62 | #endif 63 | 64 | #ifdef EXTRA_INCLUDES_INC 65 | #include "extra/includes.hpp" 66 | #endif 67 | 68 | #define STACK_UNDEFINED 0 69 | #define STACK_OBJECT 1 70 | #define STACK_STRING 2 71 | #define STACK_LOCALIZED_STRING 3 72 | #define STACK_VECTOR 4 73 | #define STACK_FLOAT 5 74 | #define STACK_INT 6 75 | #define STACK_CODEPOS 7 76 | #define STACK_PRECODEPOS 8 77 | #define STACK_FUNCTION 9 78 | #define STACK_STACK 10 79 | #define STACK_ANIMATION 11 80 | #define STACK_DEVELOPER_CODEPOS 12 81 | #define STACK_INCLUDE_CODEPOS 13 82 | #define STACK_THREAD_LIST 14 83 | #define STACK_THREAD_1 15 84 | #define STACK_THREAD_2 16 85 | #define STACK_THREAD_3 17 86 | #define STACK_THREAD_4 18 87 | #define STACK_STRUCT 19 88 | #define STACK_REMOVED_ENTITY 20 89 | #define STACK_ENTITY 21 90 | #define STACK_ARRAY 22 91 | #define STACK_REMOVED_THREAD 23 92 | 93 | #define stackPushUndefined Scr_AddUndefined 94 | #define stackPushBool Scr_AddBool 95 | #define stackPushInt Scr_AddInt 96 | #define stackPushFloat Scr_AddFloat 97 | #define stackPushString Scr_AddString 98 | #define stackPushVector Scr_AddVector 99 | #define stackPushEntity Scr_AddEntity 100 | #define stackPushArray Scr_MakeArray 101 | #define stackPushArrayLast Scr_AddArray 102 | #define stackPushObject Scr_AddObject 103 | 104 | #ifndef Q_vsnprintf 105 | int Q_vsnprintf(char *s0, size_t size, const char *fmt, va_list args); 106 | #endif 107 | 108 | int stackGetParamType(int param); 109 | const char *stackGetParamTypeAsString(int param); 110 | 111 | int stackGetParams(const char *params, ...); 112 | void stackError(const char *format, ...); 113 | 114 | int stackGetParamInt(int param, int *value); 115 | int stackGetParamFunction(int param, int *value); 116 | int stackGetParamString(int param, const char **value); 117 | int stackGetParamConstString(int param, unsigned int *value); 118 | int stackGetParamVector(int param, vec3_t value); 119 | int stackGetParamFloat(int param, float *value); 120 | int stackGetParamObject(int param, unsigned int *value); 121 | 122 | xfunction_t Scr_GetCustomFunction(const char **fname, qboolean *fdev); 123 | xmethod_t Scr_GetCustomMethod(const char **fname, qboolean *fdev); 124 | 125 | uint64_t Sys_Milliseconds64(void); 126 | 127 | extern dvar_t *sv_master[MAX_MASTER_SERVERS]; 128 | extern dvar_t *fs_library; 129 | extern dvar_t *g_playerCollision; 130 | extern dvar_t *g_playerEject; 131 | extern dvar_t *sv_allowRcon; 132 | extern dvar_t *sv_downloadMessage; 133 | extern dvar_t *sv_fastDownload; 134 | extern dvar_t *sv_cracked; 135 | extern dvar_t *sv_kickbots; 136 | extern dvar_t *jump_bounceEnable; 137 | extern dvar_t *g_mantleBlockEnable; 138 | extern dvar_t *g_fixedWeaponSpreads; 139 | extern dvar_t *g_dropGrenadeOnDeath; 140 | 141 | void RegisterLibcodDvars(); 142 | int hook_findMap(const char *qpath, void **buffer); 143 | bool SV_IsBannedIp(netadr_t adr); 144 | void hook_ClientCommand(int clientNum); 145 | void InitLibcodCallbacks(); 146 | void SV_MasterHeartbeat_libcod(const char *hbname); 147 | void SV_ResetPureClient_libcod(client_t *cl); 148 | void SV_CalcPings_libcod( void ); 149 | void SV_CheckTimeouts_libcod( void ); 150 | void SV_BotUserMove_libcod(client_t *client); 151 | void SV_ClientThink_libcod(client_t *cl, usercmd_t *cmd); 152 | const char* NET_AdrToStringNoPort( netadr_t a ); 153 | 154 | void PM_ProjectVelocity(const float *velIn, const float *normal, float *velOut); 155 | void SV_AddLibcodCommands(); 156 | const char *SV_ModifyConfigstringIwdChkSum( client_t *client, int index ); 157 | VariableValue* Scr_GetValue(unsigned int param); 158 | 159 | #endif -------------------------------------------------------------------------------- /src/libcod/gsc_bots.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_BOTS_HPP_ 2 | #define _GSC_BOTS_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_bots_set_walkdir(scr_entref_t id); 8 | void gsc_bots_set_lean(scr_entref_t id); 9 | void gsc_bots_set_stance(scr_entref_t id); 10 | void gsc_bots_thrownade(scr_entref_t id); 11 | void gsc_bots_fireweapon(scr_entref_t id); 12 | void gsc_bots_meleeweapon(scr_entref_t id); 13 | void gsc_bots_reloadweapon(scr_entref_t id); 14 | void gsc_bots_adsaim(scr_entref_t id); 15 | void gsc_bots_switchtoweaponid(scr_entref_t id); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libcod/gsc_entity.cpp: -------------------------------------------------------------------------------- 1 | #include "gsc_entity.hpp" 2 | 3 | #if LIBCOD_COMPILE_ENTITY == 1 4 | 5 | void gsc_entity_setalive(scr_entref_t id) 6 | { 7 | int isAlive; 8 | 9 | if ( ! stackGetParams("i", &isAlive)) 10 | { 11 | stackError("gsc_entity_setalive() argument is undefined or has a wrong type"); 12 | stackPushUndefined(); 13 | return; 14 | } 15 | 16 | gentity_t *entity = &g_entities[id.entnum]; 17 | 18 | entity->takedamage = isAlive; 19 | stackPushBool(qtrue); 20 | } 21 | 22 | void gsc_entity_setbounds(scr_entref_t id) 23 | { 24 | float width, height; 25 | 26 | if ( ! stackGetParams("ff", &width, &height)) 27 | { 28 | stackError("gsc_entity_setbounds() one or more arguments is undefined or has a wrong type"); 29 | stackPushUndefined(); 30 | return; 31 | } 32 | 33 | gentity_t *entity = &g_entities[id.entnum]; 34 | 35 | vec3_t mins = {-height, -width, -width}; 36 | vec3_t maxs = {width, width, height}; 37 | 38 | VectorCopy(mins, entity->r.mins); 39 | VectorCopy(maxs, entity->r.maxs); 40 | 41 | stackPushBool(qtrue); 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/libcod/gsc_entity.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_ENTITY_HPP_ 2 | #define _GSC_ENTITY_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_entity_setalive(scr_entref_t id); 8 | void gsc_entity_setbounds(scr_entref_t id); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/libcod/gsc_exec.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_EXEC_HPP_ 2 | #define _GSC_EXEC_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_exec(); 8 | void gsc_exec_async_create(); 9 | void gsc_exec_async_create_nosave(); 10 | void gsc_exec_async_checkdone(); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/libcod/gsc_level.cpp: -------------------------------------------------------------------------------- 1 | #include "gsc_level.hpp" 2 | 3 | #if LIBCOD_COMPILE_LEVEL == 1 4 | 5 | void gsc_level_getnumberofstaticmodels() 6 | { 7 | stackPushInt(cm.numStaticModels); 8 | } 9 | 10 | void gsc_level_getstaticmodelname() 11 | { 12 | int index; 13 | 14 | if ( ! stackGetParams("i", &index)) 15 | { 16 | stackError("gsc_level_getstaticmodelname() argument is undefined or has a wrong type"); 17 | stackPushUndefined(); 18 | return; 19 | } 20 | 21 | if (index < 0 || index >= (int)cm.numStaticModels) 22 | { 23 | stackError("gsc_level_getstaticmodelname() index is out of range"); 24 | stackPushUndefined(); 25 | return; 26 | } 27 | 28 | stackPushString(cm.staticModelList[index].xmodel->name); 29 | } 30 | 31 | void gsc_level_getstaticmodelorigin() 32 | { 33 | int index; 34 | 35 | if ( ! stackGetParams("i", &index)) 36 | { 37 | stackError("gsc_level_getstaticmodelorigin() argument is undefined or has a wrong type"); 38 | stackPushUndefined(); 39 | return; 40 | } 41 | 42 | if (index < 0 || index >= (int)cm.numStaticModels) 43 | { 44 | stackError("gsc_level_getstaticmodelorigin() index is out of range"); 45 | stackPushUndefined(); 46 | return; 47 | } 48 | 49 | stackPushVector(cm.staticModelList[index].origin); 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/libcod/gsc_level.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_LEVEL_HPP_ 2 | #define _GSC_LEVEL_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_level_getnumberofstaticmodels(); 8 | void gsc_level_getstaticmodelname(); 9 | void gsc_level_getstaticmodelorigin(); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/libcod/gsc_memory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_MEMORY_HPP_ 2 | #define _GSC_MEMORY_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_memory_malloc(); 8 | void gsc_memory_free(); 9 | void gsc_memory_int_get(); 10 | void gsc_memory_int_set(); 11 | void gsc_memory_memset(); 12 | void gsc_binarybuffer_new(); 13 | void gsc_binarybuffer_free(); 14 | void gsc_binarybuffer_seek(); 15 | void gsc_binarybuffer_write(); 16 | void gsc_binarybuffer_read(); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/libcod/gsc_mysql.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_MYSQL_HPP_ 2 | #define _GSC_MYSQL_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_mysql_init(); 8 | void gsc_mysql_real_connect(); 9 | void gsc_mysql_close(); 10 | void gsc_mysql_query(); 11 | void gsc_mysql_errno(); 12 | void gsc_mysql_error(); 13 | void gsc_mysql_affected_rows(); 14 | void gsc_mysql_store_result(); 15 | void gsc_mysql_num_rows(); 16 | void gsc_mysql_num_fields(); 17 | void gsc_mysql_field_seek(); 18 | void gsc_mysql_fetch_field(); 19 | void gsc_mysql_fetch_row(); 20 | void gsc_mysql_free_result(); 21 | void gsc_mysql_real_escape_string(); 22 | void gsc_mysql_async_create_query(); 23 | void gsc_mysql_async_create_query_nosave(); 24 | void gsc_mysql_async_getdone_list(); 25 | void gsc_mysql_async_getresult_and_free(); 26 | void gsc_mysql_async_initializer(); 27 | void gsc_mysql_reuse_connection(); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/libcod/gsc_player.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_PLAYER_HPP_ 2 | #define _GSC_PLAYER_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_player_velocity_set(scr_entref_t id); 8 | void gsc_player_velocity_add(scr_entref_t id); 9 | void gsc_player_velocity_get(scr_entref_t id); 10 | void gsc_player_button_ads(scr_entref_t id); 11 | void gsc_player_button_left(scr_entref_t id); 12 | void gsc_player_button_right(scr_entref_t id); 13 | void gsc_player_button_forward(scr_entref_t id); 14 | void gsc_player_button_back(scr_entref_t id); 15 | void gsc_player_button_leanleft(scr_entref_t id); 16 | void gsc_player_button_leanright(scr_entref_t id); 17 | void gsc_player_button_jump(scr_entref_t id); 18 | void gsc_player_button_reload(scr_entref_t id); 19 | void gsc_player_button_frag(scr_entref_t id); 20 | void gsc_player_button_smoke(scr_entref_t id); 21 | void gsc_player_stance_get(scr_entref_t id); 22 | void gsc_player_stance_set(scr_entref_t id); 23 | void gsc_player_spectatorclient_get(scr_entref_t id); 24 | void gsc_player_get_userinfo(scr_entref_t id); 25 | void gsc_player_set_userinfo(scr_entref_t id); 26 | void gsc_player_getip(scr_entref_t id); 27 | void gsc_player_getping(scr_entref_t id); 28 | void gsc_player_clientuserinfochanged(scr_entref_t id); 29 | void gsc_player_clientcommand(scr_entref_t id); 30 | void gsc_player_getlastconnecttime(scr_entref_t id); 31 | void gsc_player_getlastmsg(scr_entref_t id); 32 | void gsc_player_getclientstate(scr_entref_t id); 33 | void gsc_player_addresstype(scr_entref_t id); 34 | void gsc_player_renameclient(scr_entref_t id); 35 | void gsc_player_outofbandprint(scr_entref_t id); 36 | void gsc_player_connectionlesspacket(scr_entref_t id); 37 | void gsc_player_resetnextreliabletime(scr_entref_t id); 38 | void gsc_player_ismantling(scr_entref_t id); 39 | void gsc_player_isonladder(scr_entref_t id); 40 | void gsc_player_isusingturret(scr_entref_t id); 41 | void gsc_player_getjumpslowdowntimer(scr_entref_t id); 42 | void gsc_player_clearjumpstate(scr_entref_t id); 43 | void gsc_player_setg_speed(scr_entref_t id); 44 | void gsc_player_setg_gravity(scr_entref_t id); 45 | void gsc_player_setweaponfiremeleedelay(scr_entref_t id); 46 | void gsc_player_set_anim(scr_entref_t id); 47 | void gsc_player_getcooktime(scr_entref_t id); 48 | void gsc_player_setguid(scr_entref_t id); 49 | void gsc_player_clienthasclientmuted(scr_entref_t id); 50 | void gsc_player_getlastgamestatesize(scr_entref_t id); 51 | void gsc_player_getfps(scr_entref_t id); 52 | void gsc_player_isbot(scr_entref_t id); 53 | void gsc_player_disableitempickup(scr_entref_t id); 54 | void gsc_player_enableitempickup(scr_entref_t id); 55 | void gsc_player_getcurrentoffhandslotammo(scr_entref_t id); 56 | void gsc_player_getprotocol(scr_entref_t id); 57 | void gsc_player_islocalclient(scr_entref_t id); 58 | 59 | // player functions without entity 60 | void gsc_kick_slot(); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/libcod/gsc_sqlite.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_SQLITE_HPP_ 2 | #define _GSC_SQLITE_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_sqlite_open(); 8 | void gsc_sqlite_query(); 9 | void gsc_sqlite_close(); 10 | void gsc_sqlite_escape_string(); 11 | void gsc_sqlite_databases_count(); 12 | void gsc_sqlite_tasks_count(); 13 | 14 | void gsc_async_sqlite_initialize(); 15 | void gsc_async_sqlite_create_query(); 16 | void gsc_async_sqlite_create_query_nosave(); 17 | void gsc_async_sqlite_checkdone(); 18 | 19 | void gsc_async_sqlite_create_entity_query(scr_entref_t entid); 20 | void gsc_async_sqlite_create_entity_query_nosave(scr_entref_t entid); 21 | 22 | void free_sqlite_db_stores_and_tasks(); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/libcod/gsc_utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_UTILS_HPP_ 2 | #define _GSC_UTILS_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_utils_printf(); 8 | void gsc_utils_outofbandprint(); 9 | void gsc_utils_getarraykeys(); 10 | void gsc_utils_getAscii(); 11 | void gsc_utils_toupper(); 12 | void gsc_utils_system(); 13 | void gsc_utils_exponent(); 14 | void gsc_utils_round(); 15 | void gsc_utils_file_link(); 16 | void gsc_utils_file_unlink(); 17 | void gsc_utils_file_exists(); 18 | void gsc_utils_FS_LoadDir(); 19 | void gsc_utils_getType(); 20 | void gsc_utils_float(); 21 | void gsc_utils_ExecuteString(); 22 | void gsc_utils_sendgameservercommand(); 23 | void gsc_utils_scandir(); 24 | void gsc_G_FindConfigstringIndex(); 25 | void gsc_G_FindConfigstringIndexOriginal(); 26 | void gsc_get_configstring(); 27 | void gsc_set_configstring(); 28 | void gsc_make_localized_string(); 29 | void gsc_utils_getlasttestclientnumber(); 30 | void gsc_utils_getmaxmsglen(); 31 | void gsc_utils_bullethiteffect(); 32 | void gsc_utils_fopen(); 33 | void gsc_utils_fread(); 34 | void gsc_utils_fwrite(); 35 | void gsc_utils_fclose(); 36 | void gsc_utils_fsize(); 37 | void gsc_utils_ftime(); 38 | void gsc_utils_sprintf(); 39 | void gsc_utils_getsystemtime(); 40 | void gsc_utils_getserverstarttime(); 41 | void gsc_utils_getlocaltime(); 42 | void gsc_utils_sqrt(); 43 | void gsc_utils_sqrtInv(); 44 | void gsc_utils_vectorscale(); 45 | void gsc_utils_remove_file(); 46 | void gsc_utils_putchar(); 47 | void gsc_utils_remotecommand(); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/libcod/gsc_weapons.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GSC_WEAPONS_HPP_ 2 | #define _GSC_WEAPONS_HPP_ 3 | 4 | /* gsc functions */ 5 | #include "gsc.hpp" 6 | 7 | void gsc_weapons_getweaponmaxammo(); 8 | void gsc_weapons_setweaponmaxammo(); 9 | void gsc_weapons_getweaponclipsize(); 10 | void gsc_weapons_setweaponclipsize(); 11 | void gsc_weapons_getweapondamage(); 12 | void gsc_weapons_setweapondamage(); 13 | void gsc_weapons_getweaponmeleedamage(); 14 | void gsc_weapons_setweaponmeleedamage(); 15 | void gsc_weapons_getweaponfiretime(); 16 | void gsc_weapons_setweaponfiretime(); 17 | void gsc_weapons_getweaponmeleetime(); 18 | void gsc_weapons_setweaponmeleetime(); 19 | void gsc_weapons_getweaponreloadtime(); 20 | void gsc_weapons_setweaponreloadtime(); 21 | void gsc_weapons_getweaponreloademptytime(); 22 | void gsc_weapons_setweaponreloademptytime(); 23 | void gsc_weapons_getweaponcookable(); 24 | void gsc_weapons_setweaponcookable(); 25 | void gsc_weapons_getweaponhitlocmultiplier(); 26 | void gsc_weapons_setweaponhitlocmultiplier(); 27 | void gsc_weapons_getloadedweapons(); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/big_endian.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #include 17 | 18 | /* 19 | Data in big-endian format. 20 | */ 21 | static inline void float4store(uchar *T, float A) 22 | { *(T)= ((uchar *) &A)[3]; 23 | *((T)+1)=(char) ((uchar *) &A)[2]; 24 | *((T)+2)=(char) ((uchar *) &A)[1]; 25 | *((T)+3)=(char) ((uchar *) &A)[0]; } 26 | 27 | static inline void float4get (float *V, const uchar *M) 28 | { float def_temp; 29 | ((uchar*) &def_temp)[0]=(M)[3]; 30 | ((uchar*) &def_temp)[1]=(M)[2]; 31 | ((uchar*) &def_temp)[2]=(M)[1]; 32 | ((uchar*) &def_temp)[3]=(M)[0]; 33 | (*V)=def_temp; } 34 | 35 | static inline void float8store(uchar *T, double V) 36 | { *(T)= ((uchar *) &V)[7]; 37 | *((T)+1)=(char) ((uchar *) &V)[6]; 38 | *((T)+2)=(char) ((uchar *) &V)[5]; 39 | *((T)+3)=(char) ((uchar *) &V)[4]; 40 | *((T)+4)=(char) ((uchar *) &V)[3]; 41 | *((T)+5)=(char) ((uchar *) &V)[2]; 42 | *((T)+6)=(char) ((uchar *) &V)[1]; 43 | *((T)+7)=(char) ((uchar *) &V)[0]; } 44 | 45 | static inline void float8get (double *V, const uchar *M) 46 | { double def_temp; 47 | ((uchar*) &def_temp)[0]=(M)[7]; 48 | ((uchar*) &def_temp)[1]=(M)[6]; 49 | ((uchar*) &def_temp)[2]=(M)[5]; 50 | ((uchar*) &def_temp)[3]=(M)[4]; 51 | ((uchar*) &def_temp)[4]=(M)[3]; 52 | ((uchar*) &def_temp)[5]=(M)[2]; 53 | ((uchar*) &def_temp)[6]=(M)[1]; 54 | ((uchar*) &def_temp)[7]=(M)[0]; 55 | (*V) = def_temp; } 56 | 57 | static inline void ushortget(uint16 *V, const uchar *pM) 58 | { *V = (uint16) (((uint16) ((uchar) (pM)[1]))+ 59 | ((uint16) ((uint16) (pM)[0]) << 8)); } 60 | static inline void shortget (int16 *V, const uchar *pM) 61 | { *V = (short) (((short) ((uchar) (pM)[1]))+ 62 | ((short) ((short) (pM)[0]) << 8)); } 63 | static inline void longget (int32 *V, const uchar *pM) 64 | { int32 def_temp; 65 | ((uchar*) &def_temp)[0]=(pM)[0]; 66 | ((uchar*) &def_temp)[1]=(pM)[1]; 67 | ((uchar*) &def_temp)[2]=(pM)[2]; 68 | ((uchar*) &def_temp)[3]=(pM)[3]; 69 | (*V)=def_temp; } 70 | static inline void ulongget (uint32 *V, const uchar *pM) 71 | { uint32 def_temp; 72 | ((uchar*) &def_temp)[0]=(pM)[0]; 73 | ((uchar*) &def_temp)[1]=(pM)[1]; 74 | ((uchar*) &def_temp)[2]=(pM)[2]; 75 | ((uchar*) &def_temp)[3]=(pM)[3]; 76 | (*V)=def_temp; } 77 | static inline void shortstore(uchar *T, int16 A) 78 | { uint def_temp=(uint) (A) ; 79 | *(((char*)T)+1)=(char)(def_temp); 80 | *(((char*)T)+0)=(char)(def_temp >> 8); } 81 | static inline void longstore (uchar *T, int32 A) 82 | { *(((char*)T)+3)=((A)); 83 | *(((char*)T)+2)=(((A) >> 8)); 84 | *(((char*)T)+1)=(((A) >> 16)); 85 | *(((char*)T)+0)=(((A) >> 24)); } 86 | 87 | static inline void floatget(float *V, const uchar *M) 88 | { 89 | memcpy(V, (M), sizeof(float)); 90 | } 91 | 92 | static inline void floatstore(uchar *T, float V) 93 | { 94 | memcpy((T), (&V), sizeof(float)); 95 | } 96 | 97 | static inline void doubleget(double *V, const uchar *M) 98 | { 99 | memcpy(V, (M), sizeof(double)); 100 | } 101 | 102 | static inline void doublestore(uchar *T, double V) 103 | { 104 | memcpy((T), &V, sizeof(double)); 105 | } 106 | 107 | static inline void longlongget(longlong *V, const uchar *M) 108 | { 109 | memcpy(V, (M), sizeof(ulonglong)); 110 | } 111 | static inline void longlongstore(uchar *T, longlong V) 112 | { 113 | memcpy((T), &V, sizeof(ulonglong)); 114 | } 115 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/byte_order_generic.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | Endianness-independent definitions for architectures other 18 | than the x86 architecture. 19 | */ 20 | static inline int16 sint2korr(const uchar *A) 21 | { 22 | return 23 | (int16) (((int16) (A[0])) + 24 | ((int16) (A[1]) << 8)) 25 | ; 26 | } 27 | 28 | static inline int32 sint4korr(const uchar *A) 29 | { 30 | return 31 | (int32) (((int32) (A[0])) + 32 | (((int32) (A[1]) << 8)) + 33 | (((int32) (A[2]) << 16)) + 34 | (((int32) (A[3]) << 24))) 35 | ; 36 | } 37 | 38 | static inline uint16 uint2korr(const uchar *A) 39 | { 40 | return 41 | (uint16) (((uint16) (A[0])) + 42 | ((uint16) (A[1]) << 8)) 43 | ; 44 | } 45 | 46 | static inline uint32 uint4korr(const uchar *A) 47 | { 48 | return 49 | (uint32) (((uint32) (A[0])) + 50 | (((uint32) (A[1])) << 8) + 51 | (((uint32) (A[2])) << 16) + 52 | (((uint32) (A[3])) << 24)) 53 | ; 54 | } 55 | 56 | static inline ulonglong uint8korr(const uchar *A) 57 | { 58 | return 59 | ((ulonglong)(((uint32) (A[0])) + 60 | (((uint32) (A[1])) << 8) + 61 | (((uint32) (A[2])) << 16) + 62 | (((uint32) (A[3])) << 24)) + 63 | (((ulonglong) (((uint32) (A[4])) + 64 | (((uint32) (A[5])) << 8) + 65 | (((uint32) (A[6])) << 16) + 66 | (((uint32) (A[7])) << 24))) << 67 | 32)) 68 | ; 69 | } 70 | 71 | static inline longlong sint8korr(const uchar *A) 72 | { 73 | return (longlong) uint8korr(A); 74 | } 75 | 76 | static inline void int2store(uchar *T, uint16 A) 77 | { 78 | uint def_temp= A ; 79 | *(T)= (uchar)(def_temp); 80 | *(T+1)= (uchar)(def_temp >> 8); 81 | } 82 | 83 | static inline void int4store(uchar *T, uint32 A) 84 | { 85 | *(T)= (uchar) (A); 86 | *(T+1)=(uchar) (A >> 8); 87 | *(T+2)=(uchar) (A >> 16); 88 | *(T+3)=(uchar) (A >> 24); 89 | } 90 | 91 | static inline void int8store(uchar *T, ulonglong A) 92 | { 93 | uint def_temp= (uint) A, 94 | def_temp2= (uint) (A >> 32); 95 | int4store(T, def_temp); 96 | int4store(T+4,def_temp2); 97 | } 98 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/byte_order_generic_x86.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | Optimized functions for the x86 architecture (_WIN32 included). 18 | */ 19 | static inline int16 sint2korr(const uchar *A) { return *((int16*) A); } 20 | 21 | static inline int32 sint4korr(const uchar *A) { return *((int32*) A); } 22 | 23 | static inline uint16 uint2korr(const uchar *A) { return *((uint16*) A); } 24 | 25 | static inline uint32 uint4korr(const uchar *A) { return *((uint32*) A); } 26 | 27 | static inline ulonglong uint8korr(const uchar *A) { return *((ulonglong*) A);} 28 | static inline longlong sint8korr(const uchar *A) { return *((longlong*) A); } 29 | 30 | static inline void int2store(uchar *T, uint16 A) 31 | { 32 | *((uint16*) T)= A; 33 | } 34 | 35 | static inline void int4store(uchar *T, uint32 A) 36 | { 37 | *((uint32*) T)= A; 38 | } 39 | 40 | static inline void int8store(uchar *T, ulonglong A) 41 | { 42 | *((ulonglong*) T)= A; 43 | } 44 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/errmsg.h: -------------------------------------------------------------------------------- 1 | #ifndef ERRMSG_INCLUDED 2 | #define ERRMSG_INCLUDED 3 | 4 | /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; version 2 of the License. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 18 | 19 | /* Error messages for MySQL clients */ 20 | /* (Error messages for the daemon are in sql/share/errmsg.txt) */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | void init_client_errs(void); 26 | void finish_client_errs(void); 27 | extern const char *client_errors[]; /* Error messages */ 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #define CR_MIN_ERROR 2000 /* For easier client code */ 33 | #define CR_MAX_ERROR 2999 34 | #if !defined(ER) 35 | #define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST)? \ 36 | client_errors[(X)-CR_ERROR_FIRST]: client_errors[CR_UNKNOWN_ERROR]) 37 | 38 | #endif 39 | #define CLIENT_ERRMAP 2 /* Errormap used by my_error() */ 40 | 41 | /* Do not add error numbers before CR_ERROR_FIRST. */ 42 | /* If necessary to add lower numbers, change CR_ERROR_FIRST accordingly. */ 43 | #define CR_ERROR_FIRST 2000 /*Copy first error nr.*/ 44 | #define CR_UNKNOWN_ERROR 2000 45 | #define CR_SOCKET_CREATE_ERROR 2001 46 | #define CR_CONNECTION_ERROR 2002 47 | #define CR_CONN_HOST_ERROR 2003 48 | #define CR_IPSOCK_ERROR 2004 49 | #define CR_UNKNOWN_HOST 2005 50 | #define CR_SERVER_GONE_ERROR 2006 51 | #define CR_VERSION_ERROR 2007 52 | #define CR_OUT_OF_MEMORY 2008 53 | #define CR_WRONG_HOST_INFO 2009 54 | #define CR_LOCALHOST_CONNECTION 2010 55 | #define CR_TCP_CONNECTION 2011 56 | #define CR_SERVER_HANDSHAKE_ERR 2012 57 | #define CR_SERVER_LOST 2013 58 | #define CR_COMMANDS_OUT_OF_SYNC 2014 59 | #define CR_NAMEDPIPE_CONNECTION 2015 60 | #define CR_NAMEDPIPEWAIT_ERROR 2016 61 | #define CR_NAMEDPIPEOPEN_ERROR 2017 62 | #define CR_NAMEDPIPESETSTATE_ERROR 2018 63 | #define CR_CANT_READ_CHARSET 2019 64 | #define CR_NET_PACKET_TOO_LARGE 2020 65 | #define CR_EMBEDDED_CONNECTION 2021 66 | #define CR_PROBE_SLAVE_STATUS 2022 67 | #define CR_PROBE_SLAVE_HOSTS 2023 68 | #define CR_PROBE_SLAVE_CONNECT 2024 69 | #define CR_PROBE_MASTER_CONNECT 2025 70 | #define CR_SSL_CONNECTION_ERROR 2026 71 | #define CR_MALFORMED_PACKET 2027 72 | #define CR_WRONG_LICENSE 2028 73 | 74 | /* new 4.1 error codes */ 75 | #define CR_NULL_POINTER 2029 76 | #define CR_NO_PREPARE_STMT 2030 77 | #define CR_PARAMS_NOT_BOUND 2031 78 | #define CR_DATA_TRUNCATED 2032 79 | #define CR_NO_PARAMETERS_EXISTS 2033 80 | #define CR_INVALID_PARAMETER_NO 2034 81 | #define CR_INVALID_BUFFER_USE 2035 82 | #define CR_UNSUPPORTED_PARAM_TYPE 2036 83 | 84 | #define CR_SHARED_MEMORY_CONNECTION 2037 85 | #define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038 86 | #define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039 87 | #define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040 88 | #define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041 89 | #define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042 90 | #define CR_SHARED_MEMORY_MAP_ERROR 2043 91 | #define CR_SHARED_MEMORY_EVENT_ERROR 2044 92 | #define CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR 2045 93 | #define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046 94 | #define CR_CONN_UNKNOW_PROTOCOL 2047 95 | #define CR_INVALID_CONN_HANDLE 2048 96 | #define CR_UNUSED_1 2049 97 | #define CR_FETCH_CANCELED 2050 98 | #define CR_NO_DATA 2051 99 | #define CR_NO_STMT_METADATA 2052 100 | #define CR_NO_RESULT_SET 2053 101 | #define CR_NOT_IMPLEMENTED 2054 102 | #define CR_SERVER_LOST_EXTENDED 2055 103 | #define CR_STMT_CLOSED 2056 104 | #define CR_NEW_STMT_METADATA 2057 105 | #define CR_ALREADY_CONNECTED 2058 106 | #define CR_AUTH_PLUGIN_CANNOT_LOAD 2059 107 | #define CR_DUPLICATE_CONNECTION_ATTR 2060 108 | #define CR_AUTH_PLUGIN_ERR 2061 109 | #define CR_ERROR_LAST /*Copy last error nr:*/ 2061 110 | /* Add error numbers before CR_ERROR_LAST and change it accordingly. */ 111 | 112 | #endif /* ERRMSG_INCLUDED */ 113 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/little_endian.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | Data in little-endian format. 18 | */ 19 | 20 | #include 21 | 22 | static inline void float4get (float *V, const uchar *M) 23 | { 24 | memcpy(V, (M), sizeof(float)); 25 | } 26 | 27 | static inline void float4store(uchar *V, float M) 28 | { 29 | memcpy(V, (&M), sizeof(float)); 30 | } 31 | 32 | static inline void float8get (double *V, const uchar *M) 33 | { 34 | memcpy(V, M, sizeof(double)); 35 | } 36 | 37 | static inline void float8store(uchar *V, double M) 38 | { 39 | memcpy(V, &M, sizeof(double)); 40 | } 41 | 42 | static inline void floatget (float *V, const uchar *M) { float4get(V, M); } 43 | static inline void floatstore (uchar *V, float M) { float4store(V, M); } 44 | 45 | /* Bi-endian hardware.... */ 46 | #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) 47 | static inline void doublestore(uchar *T, double V) 48 | { *(((char*)T)+0)=(char) ((uchar *) &V)[4]; 49 | *(((char*)T)+1)=(char) ((uchar *) &V)[5]; 50 | *(((char*)T)+2)=(char) ((uchar *) &V)[6]; 51 | *(((char*)T)+3)=(char) ((uchar *) &V)[7]; 52 | *(((char*)T)+4)=(char) ((uchar *) &V)[0]; 53 | *(((char*)T)+5)=(char) ((uchar *) &V)[1]; 54 | *(((char*)T)+6)=(char) ((uchar *) &V)[2]; 55 | *(((char*)T)+7)=(char) ((uchar *) &V)[3]; } 56 | static inline void doubleget(double *V, const uchar *M) 57 | { double def_temp; 58 | ((uchar*) &def_temp)[0]=(M)[4]; 59 | ((uchar*) &def_temp)[1]=(M)[5]; 60 | ((uchar*) &def_temp)[2]=(M)[6]; 61 | ((uchar*) &def_temp)[3]=(M)[7]; 62 | ((uchar*) &def_temp)[4]=(M)[0]; 63 | ((uchar*) &def_temp)[5]=(M)[1]; 64 | ((uchar*) &def_temp)[6]=(M)[2]; 65 | ((uchar*) &def_temp)[7]=(M)[3]; 66 | (*V) = def_temp; } 67 | 68 | #else /* Bi-endian hardware.... */ 69 | 70 | static inline void doublestore(uchar *T, double V) { memcpy(T, &V, sizeof(double)); } 71 | static inline void doubleget (double *V, const uchar *M) { memcpy(V, M, sizeof(double)); } 72 | 73 | #endif /* Bi-endian hardware.... */ 74 | 75 | static inline void ushortget(uint16 *V, const uchar *pM) { *V= uint2korr(pM); } 76 | static inline void shortget (int16 *V, const uchar *pM) { *V= sint2korr(pM); } 77 | static inline void longget (int32 *V, const uchar *pM) { *V= sint4korr(pM); } 78 | static inline void ulongget (uint32 *V, const uchar *pM) { *V= uint4korr(pM); } 79 | static inline void shortstore(uchar *T, int16 V) { int2store(T, V); } 80 | static inline void longstore (uchar *T, int32 V) { int4store(T, V); } 81 | 82 | static inline void longlongget(longlong *V, const uchar *M) 83 | { 84 | memcpy(V, (M), sizeof(ulonglong)); 85 | } 86 | static inline void longlongstore(uchar *T, longlong V) 87 | { 88 | memcpy((T), &V, sizeof(ulonglong)); 89 | } 90 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/my_alloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | Data structures for mysys/my_alloc.c (root memory allocator) 18 | */ 19 | 20 | #ifndef _my_alloc_h 21 | #define _my_alloc_h 22 | 23 | #define ALLOC_MAX_BLOCK_TO_DROP 4096 24 | #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 25 | 26 | /* PSI_memory_key */ 27 | #include "mysql/psi/psi_memory.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | typedef struct st_used_mem 34 | { /* struct for once_alloc (block) */ 35 | struct st_used_mem *next; /* Next block in use */ 36 | unsigned int left; /* memory left in block */ 37 | unsigned int size; /* size of block */ 38 | } USED_MEM; 39 | 40 | 41 | typedef struct st_mem_root 42 | { 43 | USED_MEM *free; /* blocks with free memory in it */ 44 | USED_MEM *used; /* blocks almost without free memory */ 45 | USED_MEM *pre_alloc; /* preallocated block */ 46 | /* if block have less memory it will be put in 'used' list */ 47 | size_t min_malloc; 48 | size_t block_size; /* initial block size */ 49 | unsigned int block_num; /* allocated blocks counter */ 50 | /* 51 | first free block in queue test counter (if it exceed 52 | MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) 53 | */ 54 | unsigned int first_block_usage; 55 | 56 | void (*error_handler)(void); 57 | 58 | PSI_memory_key m_psi_key; 59 | } MEM_ROOT; 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/my_dir.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef MY_DIR_H 17 | #define MY_DIR_H 18 | 19 | #include "my_global.h" 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Defines for my_dir and my_stat */ 28 | 29 | #ifdef _WIN32 30 | #define S_IROTH _S_IREAD 31 | #define S_IFIFO _S_IFIFO 32 | #endif 33 | 34 | #define MY_S_IFMT S_IFMT /* type of file */ 35 | #define MY_S_IFDIR S_IFDIR /* directory */ 36 | #define MY_S_IFCHR S_IFCHR /* character special */ 37 | #define MY_S_IFBLK S_IFBLK /* block special */ 38 | #define MY_S_IFREG S_IFREG /* regular */ 39 | #define MY_S_IFIFO S_IFIFO /* fifo */ 40 | #define MY_S_ISUID S_ISUID /* set user id on execution */ 41 | #define MY_S_ISGID S_ISGID /* set group id on execution */ 42 | #define MY_S_ISVTX S_ISVTX /* save swapped text even after use */ 43 | #define MY_S_IREAD S_IREAD /* read permission, owner */ 44 | #define MY_S_IWRITE S_IWRITE /* write permission, owner */ 45 | #define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */ 46 | 47 | #define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR) 48 | #define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR) 49 | #define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK) 50 | #define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG) 51 | #define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO) 52 | 53 | #define MY_DONT_SORT 512 /* my_lib; Don't sort files */ 54 | #define MY_WANT_STAT 1024 /* my_lib; stat files */ 55 | 56 | /* typedefs for my_dir & my_stat */ 57 | 58 | #if(_MSC_VER) 59 | #define MY_STAT struct _stati64 /* 64 bit file size */ 60 | #else 61 | #define MY_STAT struct stat /* Orginal struct have what we need */ 62 | #endif 63 | 64 | /* Struct describing one file returned from my_dir */ 65 | typedef struct fileinfo 66 | { 67 | char *name; 68 | MY_STAT *mystat; 69 | } FILEINFO; 70 | 71 | typedef struct st_my_dir /* Struct returned from my_dir */ 72 | { 73 | /* 74 | These members are just copies of parts of DYNAMIC_ARRAY structure, 75 | which is allocated right after the end of MY_DIR structure (MEM_ROOT 76 | for storing names is also resides there). We've left them here because 77 | we don't want to change code that uses my_dir. 78 | */ 79 | struct fileinfo *dir_entry; 80 | uint number_off_files; 81 | } MY_DIR; 82 | 83 | extern MY_DIR *my_dir(const char *path,myf MyFlags); 84 | extern void my_dirend(MY_DIR *buffer); 85 | extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags); 86 | extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags); 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* MY_DIR_H */ 93 | 94 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/my_list.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef _list_h_ 17 | #define _list_h_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct st_list { 24 | struct st_list *prev,*next; 25 | void *data; 26 | } LIST; 27 | 28 | typedef int (*list_walk_action)(void *,void *); 29 | 30 | extern LIST *list_add(LIST *root,LIST *element); 31 | extern LIST *list_delete(LIST *root,LIST *element); 32 | extern LIST *list_cons(void *data,LIST *root); 33 | extern LIST *list_reverse(LIST *root); 34 | extern void list_free(LIST *root,unsigned int free_data); 35 | extern unsigned int list_length(LIST *); 36 | extern int list_walk(LIST *,list_walk_action action,unsigned char * argument); 37 | 38 | #define list_rest(a) ((a)->next) 39 | #define list_push(a,b) (a)=list_cons((b),(a)) 40 | #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); } 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/my_xml.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 15 | 16 | 17 | #ifndef _my_xml_h 18 | #define _my_xml_h 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | 25 | #define MY_XML_OK 0 26 | #define MY_XML_ERROR 1 27 | 28 | /* 29 | A flag whether to use absolute tag names in call-back functions, 30 | like "a", "a.b" and "a.b.c" (used in character set file parser), 31 | or relative names like "a", "b" and "c". 32 | */ 33 | #define MY_XML_FLAG_RELATIVE_NAMES 1 34 | 35 | /* 36 | A flag whether to skip normilization of text values before calling 37 | call-back functions: i.e. skip leading/trailing spaces, 38 | \r, \n, \t characters. 39 | */ 40 | #define MY_XML_FLAG_SKIP_TEXT_NORMALIZATION 2 41 | 42 | enum my_xml_node_type 43 | { 44 | MY_XML_NODE_TAG, /* can have TAG, ATTR and TEXT children */ 45 | MY_XML_NODE_ATTR, /* can have TEXT children */ 46 | MY_XML_NODE_TEXT /* cannot have children */ 47 | }; 48 | 49 | typedef struct xml_stack_st 50 | { 51 | int flags; 52 | enum my_xml_node_type current_node_type; 53 | char errstr[128]; 54 | 55 | struct { 56 | char static_buffer[128]; 57 | char *buffer; 58 | size_t buffer_size; 59 | char *start; 60 | char *end; 61 | } attr; 62 | 63 | const char *beg; 64 | const char *cur; 65 | const char *end; 66 | void *user_data; 67 | int (*enter)(struct xml_stack_st *st,const char *val, size_t len); 68 | int (*value)(struct xml_stack_st *st,const char *val, size_t len); 69 | int (*leave_xml)(struct xml_stack_st *st,const char *val, size_t len); 70 | } MY_XML_PARSER; 71 | 72 | void my_xml_parser_create(MY_XML_PARSER *st); 73 | void my_xml_parser_free(MY_XML_PARSER *st); 74 | int my_xml_parse(MY_XML_PARSER *st,const char *str, size_t len); 75 | 76 | void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, 77 | const char *, 78 | size_t len)); 79 | void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, 80 | const char *, 81 | size_t len)); 82 | void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, 83 | const char *, 84 | size_t len)); 85 | void my_xml_set_user_data(MY_XML_PARSER *st, void *); 86 | 87 | size_t my_xml_error_pos(MY_XML_PARSER *st); 88 | uint my_xml_error_lineno(MY_XML_PARSER *st); 89 | 90 | const char *my_xml_error_string(MY_XML_PARSER *st); 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* _my_xml_h */ 97 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/client_authentication.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | #ifndef CLIENT_AUTHENTICATION_H 16 | #define CLIENT_AUTHENTICATION_H 17 | #include 18 | #include "mysql.h" 19 | #include "mysql/client_plugin.h" 20 | 21 | C_MODE_START 22 | int sha256_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); 23 | int sha256_password_init(char *, size_t, int, va_list); 24 | int sha256_password_deinit(void); 25 | C_MODE_END 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/client_plugin.h.pp: -------------------------------------------------------------------------------- 1 | struct st_mysql_client_plugin 2 | { 3 | int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(); int (*options)(const char *option, const void *); 4 | }; 5 | struct st_mysql; 6 | #include 7 | typedef struct st_plugin_vio_info 8 | { 9 | enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, 10 | MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol; 11 | int socket; 12 | } MYSQL_PLUGIN_VIO_INFO; 13 | typedef struct st_plugin_vio 14 | { 15 | int (*read_packet)(struct st_plugin_vio *vio, 16 | unsigned char **buf); 17 | int (*write_packet)(struct st_plugin_vio *vio, 18 | const unsigned char *packet, 19 | int packet_len); 20 | void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info); 21 | } MYSQL_PLUGIN_VIO; 22 | struct st_mysql_client_plugin_AUTHENTICATION 23 | { 24 | int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(); int (*options)(const char *option, const void *); 25 | int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql); 26 | }; 27 | struct st_mysql_client_plugin * 28 | mysql_load_plugin(struct st_mysql *mysql, const char *name, int type, 29 | int argc, ...); 30 | struct st_mysql_client_plugin * 31 | mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type, 32 | int argc, va_list args); 33 | struct st_mysql_client_plugin * 34 | mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type); 35 | struct st_mysql_client_plugin * 36 | mysql_client_register_plugin(struct st_mysql *mysql, 37 | struct st_mysql_client_plugin *plugin); 38 | int mysql_plugin_options(struct st_mysql_client_plugin *plugin, 39 | const char *option, const void *value); 40 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/get_password.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | ** Ask for a password from tty 18 | ** This is an own file to avoid conflicts with curses 19 | */ 20 | 21 | #ifndef MYSQL_GET_PASSWORD_H_INCLUDED 22 | #define MYSQL_GET_PASSWORD_H_INCLUDED 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef char *(* strdup_handler_t)(const char *, int); 29 | char *get_tty_password_ext(const char *opt_message, 30 | strdup_handler_t strdup_function); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* ! MYSQL_GET_PASSWORD_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/plugin_auth_common.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED 2 | /* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; version 2 of the License. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 16 | 17 | /** 18 | @file 19 | 20 | This file defines constants and data structures that are the same for 21 | both client- and server-side authentication plugins. 22 | */ 23 | #define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED 24 | 25 | /** the max allowed length for a user name */ 26 | #define MYSQL_USERNAME_LENGTH 48 27 | 28 | /** 29 | return values of the plugin authenticate_user() method. 30 | */ 31 | 32 | /** 33 | Authentication failed, plugin internal error. 34 | An error occurred in the authentication plugin itself. 35 | These errors are reported in table performance_schema.host_cache, 36 | column COUNT_AUTH_PLUGIN_ERRORS. 37 | */ 38 | #define CR_AUTH_PLUGIN_ERROR 3 39 | /** 40 | Authentication failed, client server handshake. 41 | An error occurred during the client server handshake. 42 | These errors are reported in table performance_schema.host_cache, 43 | column COUNT_HANDSHAKE_ERRORS. 44 | */ 45 | #define CR_AUTH_HANDSHAKE 2 46 | /** 47 | Authentication failed, user credentials. 48 | For example, wrong passwords. 49 | These errors are reported in table performance_schema.host_cache, 50 | column COUNT_AUTHENTICATION_ERRORS. 51 | */ 52 | #define CR_AUTH_USER_CREDENTIALS 1 53 | /** 54 | Authentication failed. Additionally, all other CR_xxx values 55 | (libmysql error code) can be used too. 56 | 57 | The client plugin may set the error code and the error message directly 58 | in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error 59 | code was returned, an error message in the MYSQL structure will be 60 | overwritten. If CR_ERROR is returned without setting the error in MYSQL, 61 | CR_UNKNOWN_ERROR will be user. 62 | */ 63 | #define CR_ERROR 0 64 | /** 65 | Authentication (client part) was successful. It does not mean that the 66 | authentication as a whole was successful, usually it only means 67 | that the client was able to send the user name and the password to the 68 | server. If CR_OK is returned, the libmysql reads the next packet expecting 69 | it to be one of OK, ERROR, or CHANGE_PLUGIN packets. 70 | */ 71 | #define CR_OK -1 72 | /** 73 | Authentication was successful. 74 | It means that the client has done its part successfully and also that 75 | a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN). 76 | In this case, libmysql will not read a packet from the server, 77 | but it will use the data at mysql->net.read_pos. 78 | 79 | A plugin may return this value if the number of roundtrips in the 80 | authentication protocol is not known in advance, and the client plugin 81 | needs to read one packet more to determine if the authentication is finished 82 | or not. 83 | */ 84 | #define CR_OK_HANDSHAKE_COMPLETE -2 85 | 86 | /* 87 | We need HANDLE definition if on Windows. Define WIN32_LEAN_AND_MEAN (if 88 | not already done) to minimize amount of imported declarations. 89 | */ 90 | #ifdef _WIN32 91 | #ifndef WIN32_LEAN_AND_MEAN 92 | #define WIN32_LEAN_AND_MEAN 93 | #endif 94 | #include 95 | #endif 96 | 97 | typedef struct st_plugin_vio_info 98 | { 99 | enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, 100 | MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol; 101 | int socket; /**< it's set, if the protocol is SOCKET or TCP */ 102 | #ifdef _WIN32 103 | HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */ 104 | #endif 105 | } MYSQL_PLUGIN_VIO_INFO; 106 | 107 | /** 108 | Provides plugin access to communication channel 109 | */ 110 | typedef struct st_plugin_vio 111 | { 112 | /** 113 | Plugin provides a pointer reference and this function sets it to the 114 | contents of any incoming packet. Returns the packet length, or -1 if 115 | the plugin should terminate. 116 | */ 117 | int (*read_packet)(struct st_plugin_vio *vio, 118 | unsigned char **buf); 119 | 120 | /** 121 | Plugin provides a buffer with data and the length and this 122 | function sends it as a packet. Returns 0 on success, 1 on failure. 123 | */ 124 | int (*write_packet)(struct st_plugin_vio *vio, 125 | const unsigned char *packet, 126 | int packet_len); 127 | 128 | /** 129 | Fills in a st_plugin_vio_info structure, providing the information 130 | about the connection. 131 | */ 132 | void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info); 133 | 134 | } MYSQL_PLUGIN_VIO; 135 | 136 | #endif 137 | 138 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/mysql_idle.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software Foundation, 14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 15 | 16 | #ifndef MYSQL_IDLE_H 17 | #define MYSQL_IDLE_H 18 | 19 | /** 20 | @file mysql/psi/mysql_idle.h 21 | Instrumentation helpers for idle waits. 22 | */ 23 | 24 | #include "mysql/psi/psi.h" 25 | 26 | #ifndef PSI_IDLE_CALL 27 | #define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M) 28 | #endif 29 | 30 | /** 31 | @defgroup Idle_instrumentation Idle Instrumentation 32 | @ingroup Instrumentation_interface 33 | @{ 34 | */ 35 | 36 | /** 37 | @def MYSQL_START_IDLE_WAIT 38 | Instrumentation helper for table io_waits. 39 | This instrumentation marks the start of a wait event. 40 | @param LOCKER the locker 41 | @param STATE the locker state 42 | @sa MYSQL_END_IDLE_WAIT. 43 | */ 44 | #ifdef HAVE_PSI_IDLE_INTERFACE 45 | #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \ 46 | LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__) 47 | #else 48 | #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \ 49 | do {} while (0) 50 | #endif 51 | 52 | /** 53 | @def MYSQL_END_IDLE_WAIT 54 | Instrumentation helper for idle waits. 55 | This instrumentation marks the end of a wait event. 56 | @param LOCKER the locker 57 | @sa MYSQL_START_IDLE_WAIT. 58 | */ 59 | #ifdef HAVE_PSI_IDLE_INTERFACE 60 | #define MYSQL_END_IDLE_WAIT(LOCKER) \ 61 | inline_mysql_end_idle_wait(LOCKER) 62 | #else 63 | #define MYSQL_END_IDLE_WAIT(LOCKER) \ 64 | do {} while (0) 65 | #endif 66 | 67 | #ifdef HAVE_PSI_IDLE_INTERFACE 68 | /** 69 | Instrumentation calls for MYSQL_START_IDLE_WAIT. 70 | @sa MYSQL_END_IDLE_WAIT. 71 | */ 72 | static inline struct PSI_idle_locker * 73 | inline_mysql_start_idle_wait(PSI_idle_locker_state *state, 74 | const char *src_file, int src_line) 75 | { 76 | struct PSI_idle_locker *locker; 77 | locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line); 78 | return locker; 79 | } 80 | 81 | /** 82 | Instrumentation calls for MYSQL_END_IDLE_WAIT. 83 | @sa MYSQL_START_IDLE_WAIT. 84 | */ 85 | static inline void 86 | inline_mysql_end_idle_wait(struct PSI_idle_locker *locker) 87 | { 88 | if (likely(locker != NULL)) 89 | PSI_IDLE_CALL(end_idle_wait)(locker); 90 | } 91 | #endif 92 | 93 | /** @} (end of group Idle_instrumentation) */ 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/mysql_mdl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software Foundation, 14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 15 | 16 | #ifndef MYSQL_MDL_H 17 | #define MYSQL_MDL_H 18 | 19 | /** 20 | @file mysql/psi/mysql_mdl.h 21 | Instrumentation helpers for metadata locks. 22 | */ 23 | 24 | #include "mysql/psi/psi.h" 25 | 26 | #ifndef PSI_METADATA_CALL 27 | #define PSI_METADATA_CALL(M) PSI_DYNAMIC_CALL(M) 28 | #endif 29 | 30 | /** 31 | @defgroup Thread_instrumentation Metadata Instrumentation 32 | @ingroup Instrumentation_interface 33 | @{ 34 | */ 35 | 36 | /** 37 | @def mysql_mdl_create(K, M, A) 38 | Instrumented metadata lock creation. 39 | @param I Metadata lock identity 40 | @param K Metadata key 41 | @param T Metadata lock type 42 | @param D Metadata lock duration 43 | @param S Metadata lock status 44 | @param F request source file 45 | @param L request source line 46 | */ 47 | 48 | #ifdef HAVE_PSI_METADATA_INTERFACE 49 | #define mysql_mdl_create(I, K, T, D, S, F, L) \ 50 | inline_mysql_mdl_create(I, K, T, D, S, F, L) 51 | #else 52 | #define mysql_mdl_create(I, K, T, D, S, F, L) NULL 53 | #endif 54 | 55 | #ifdef HAVE_PSI_METADATA_INTERFACE 56 | #define mysql_mdl_set_status(L, S) \ 57 | inline_mysql_mdl_set_status(L, S) 58 | #else 59 | #define mysql_mdl_set_status(L, S) \ 60 | do {} while (0) 61 | #endif 62 | 63 | 64 | /** 65 | @def mysql_mdl_destroy(M) 66 | Instrumented metadata lock destruction. 67 | @param M Metadata lock 68 | */ 69 | #ifdef HAVE_PSI_METADATA_INTERFACE 70 | #define mysql_mdl_destroy(M) \ 71 | inline_mysql_mdl_destroy(M, __FILE__, __LINE__) 72 | #else 73 | #define mysql_mdl_destroy(M) \ 74 | do {} while (0) 75 | #endif 76 | 77 | #ifdef HAVE_PSI_METADATA_INTERFACE 78 | 79 | static inline PSI_metadata_lock * 80 | inline_mysql_mdl_create(void *identity, 81 | const MDL_key *mdl_key, 82 | enum_mdl_type mdl_type, 83 | enum_mdl_duration mdl_duration, 84 | MDL_wait::enum_wait_status mdl_status, 85 | const char *src_file, uint src_line) 86 | { 87 | PSI_metadata_lock *result; 88 | 89 | /* static_cast: Fit a round C++ enum peg into a square C int hole ... */ 90 | result= PSI_METADATA_CALL(create_metadata_lock) 91 | (identity, 92 | mdl_key, 93 | static_cast (mdl_type), 94 | static_cast (mdl_duration), 95 | static_cast (mdl_status), 96 | src_file, src_line); 97 | 98 | return result; 99 | } 100 | 101 | static inline void inline_mysql_mdl_set_status( 102 | PSI_metadata_lock *psi, 103 | MDL_wait::enum_wait_status mdl_status) 104 | { 105 | if (psi != NULL) 106 | PSI_METADATA_CALL(set_metadata_lock_status)(psi, mdl_status); 107 | } 108 | 109 | static inline void inline_mysql_mdl_destroy( 110 | PSI_metadata_lock *psi, 111 | const char *src_file, uint src_line) 112 | { 113 | if (psi != NULL) 114 | PSI_METADATA_CALL(destroy_metadata_lock)(psi); 115 | } 116 | #endif /* HAVE_PSI_METADATA_INTERFACE */ 117 | 118 | /** @} (end of group Metadata_instrumentation) */ 119 | 120 | #endif 121 | 122 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/mysql_memory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software Foundation, 14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 15 | 16 | #ifndef MYSQL_MEMORY_H 17 | #define MYSQL_MEMORY_H 18 | 19 | /** 20 | @file mysql/psi/mysql_memory.h 21 | Instrumentation helpers for memory allocation. 22 | */ 23 | 24 | #include "mysql/psi/psi.h" 25 | 26 | #ifndef PSI_MEMORY_CALL 27 | #define PSI_MEMORY_CALL(M) PSI_DYNAMIC_CALL(M) 28 | #endif 29 | 30 | /** 31 | @defgroup Memory_instrumentation Memory Instrumentation 32 | @ingroup Instrumentation_interface 33 | @{ 34 | */ 35 | 36 | /** 37 | @def mysql_memory_register(P1, P2, P3) 38 | Memory registration. 39 | */ 40 | #define mysql_memory_register(P1, P2, P3) \ 41 | inline_mysql_memory_register(P1, P2, P3) 42 | 43 | static inline void inline_mysql_memory_register( 44 | #ifdef HAVE_PSI_MEMORY_INTERFACE 45 | const char *category, 46 | PSI_memory_info *info, 47 | int count) 48 | #else 49 | const char *category __attribute__((unused)), 50 | void *info __attribute__((unused)), 51 | int count __attribute__((unused))) 52 | #endif 53 | { 54 | #ifdef HAVE_PSI_MEMORY_INTERFACE 55 | PSI_MEMORY_CALL(register_memory)(category, info, count); 56 | #endif 57 | } 58 | 59 | /** @} (end of group Memory_instrumentation) */ 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/mysql_ps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef MYSQL_PS_H 17 | #define MYSQL_PS_H 18 | 19 | /** 20 | @file mysql/psi/mysql_ps.h 21 | Instrumentation helpers for prepared statements. 22 | */ 23 | 24 | #include "mysql/psi/psi.h" 25 | 26 | #ifndef PSI_PS_CALL 27 | #define PSI_PS_CALL(M) PSI_DYNAMIC_CALL(M) 28 | #endif 29 | 30 | #ifdef HAVE_PSI_PS_INTERFACE 31 | #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) \ 32 | inline_mysql_create_prepared_stmt(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) 33 | #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \ 34 | inline_mysql_execute_prepared_stmt(LOCKER, PREPARED_STMT) 35 | #define MYSQL_DESTROY_PS(PREPARED_STMT) \ 36 | inline_mysql_destroy_prepared_stmt(PREPARED_STMT) 37 | #define MYSQL_REPREPARE_PS(PREPARED_STMT) \ 38 | inline_mysql_reprepare_prepared_stmt(PREPARED_STMT) 39 | #else 40 | #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_LENGTH) \ 41 | NULL 42 | #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \ 43 | do {} while (0) 44 | #define MYSQL_DESTROY_PS(PREPARED_STMT) \ 45 | do {} while (0) 46 | #define MYSQL_REPREPARE_PS(PREPARED_STMT) \ 47 | do {} while (0) 48 | #endif 49 | 50 | #ifdef HAVE_PSI_PS_INTERFACE 51 | static inline struct PSI_prepared_stmt* 52 | inline_mysql_create_prepared_stmt(void *identity, uint stmt_id, 53 | PSI_statement_locker *locker, 54 | const char *stmt_name, size_t stmt_name_length, 55 | const char *sqltext, size_t sqltext_length) 56 | { 57 | if (locker == NULL) 58 | return NULL; 59 | return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id, 60 | locker, 61 | stmt_name, stmt_name_length, 62 | sqltext, sqltext_length); 63 | } 64 | 65 | static inline void 66 | inline_mysql_execute_prepared_stmt(PSI_statement_locker *locker, 67 | PSI_prepared_stmt* prepared_stmt) 68 | { 69 | if (prepared_stmt != NULL && locker != NULL) 70 | PSI_PS_CALL(execute_prepared_stmt)(locker, prepared_stmt); 71 | } 72 | 73 | static inline void 74 | inline_mysql_destroy_prepared_stmt(PSI_prepared_stmt *prepared_stmt) 75 | { 76 | if (prepared_stmt != NULL) 77 | PSI_PS_CALL(destroy_prepared_stmt)(prepared_stmt); 78 | } 79 | 80 | static inline void 81 | inline_mysql_reprepare_prepared_stmt(PSI_prepared_stmt *prepared_stmt) 82 | { 83 | if (prepared_stmt != NULL) 84 | PSI_PS_CALL(reprepare_prepared_stmt)(prepared_stmt); 85 | } 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/mysql_sp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef MYSQL_SP_H 17 | #define MYSQL_SP_H 18 | 19 | /** 20 | @file mysql/psi/mysql_sp.h 21 | Instrumentation helpers for stored programs. 22 | */ 23 | 24 | #include "mysql/psi/psi.h" 25 | 26 | #ifndef PSI_SP_CALL 27 | #define PSI_SP_CALL(M) PSI_DYNAMIC_CALL(M) 28 | #endif 29 | 30 | #ifdef HAVE_PSI_SP_INTERFACE 31 | #define MYSQL_START_SP(STATE, SP_SHARE) \ 32 | inline_mysql_start_sp(STATE, SP_SHARE) 33 | #else 34 | #define MYSQL_START_SP(STATE, SP_SHARE) \ 35 | NULL 36 | #endif 37 | 38 | 39 | #ifdef HAVE_PSI_SP_INTERFACE 40 | #define MYSQL_END_SP(LOCKER) \ 41 | inline_mysql_end_sp(LOCKER) 42 | #else 43 | #define MYSQL_END_SP(LOCKER) \ 44 | do {} while (0) 45 | #endif 46 | 47 | #ifdef HAVE_PSI_SP_INTERFACE 48 | #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \ 49 | inline_mysql_drop_sp(OT, SN, SNL, ON, ONL) 50 | #else 51 | #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \ 52 | do {} while (0) 53 | #endif 54 | 55 | #ifdef HAVE_PSI_SP_INTERFACE 56 | #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \ 57 | inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL) 58 | #else 59 | #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \ 60 | NULL 61 | #endif 62 | 63 | #ifdef HAVE_PSI_SP_INTERFACE 64 | static inline struct PSI_sp_locker* 65 | inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share) 66 | { 67 | return PSI_SP_CALL(start_sp)(state, sp_share); 68 | } 69 | 70 | static inline void inline_mysql_end_sp(PSI_sp_locker *locker) 71 | { 72 | if (likely(locker != NULL)) 73 | PSI_SP_CALL(end_sp)(locker); 74 | } 75 | 76 | static inline void 77 | inline_mysql_drop_sp(uint sp_type, 78 | const char* schema_name, uint shcema_name_length, 79 | const char* object_name, uint object_name_length) 80 | { 81 | PSI_SP_CALL(drop_sp)(sp_type, 82 | schema_name, shcema_name_length, 83 | object_name, object_name_length); 84 | } 85 | 86 | static inline PSI_sp_share* 87 | inline_mysql_get_sp_share(uint sp_type, 88 | const char* schema_name, uint shcema_name_length, 89 | const char* object_name, uint object_name_length) 90 | { 91 | return PSI_SP_CALL(get_sp_share)(sp_type, 92 | schema_name, shcema_name_length, 93 | object_name, object_name_length); 94 | } 95 | #endif 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/mysql_stage.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef MYSQL_STAGE_H 17 | #define MYSQL_STAGE_H 18 | 19 | /** 20 | @file mysql/psi/mysql_stage.h 21 | Instrumentation helpers for stages. 22 | */ 23 | 24 | #include "mysql/psi/psi.h" 25 | 26 | #ifndef PSI_STAGE_CALL 27 | #define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M) 28 | #endif 29 | 30 | /** 31 | @defgroup Stage_instrumentation Stage Instrumentation 32 | @ingroup Instrumentation_interface 33 | @{ 34 | */ 35 | 36 | /** 37 | @def mysql_stage_register(P1, P2, P3) 38 | Stage registration. 39 | */ 40 | #ifdef HAVE_PSI_STAGE_INTERFACE 41 | #define mysql_stage_register(P1, P2, P3) \ 42 | inline_mysql_stage_register(P1, P2, P3) 43 | #else 44 | #define mysql_stage_register(P1, P2, P3) \ 45 | do {} while (0) 46 | #endif 47 | 48 | /** 49 | @def MYSQL_SET_STAGE 50 | Set the current stage 51 | @param K the stage key 52 | @param F the source file name 53 | @param L the source file line 54 | @return the current stage progress 55 | */ 56 | #ifdef HAVE_PSI_STAGE_INTERFACE 57 | #define MYSQL_SET_STAGE(K, F, L) \ 58 | inline_mysql_set_stage(K, F, L) 59 | #else 60 | #define MYSQL_SET_STAGE(K, F, L) \ 61 | NULL 62 | #endif 63 | 64 | #ifdef HAVE_PSI_STAGE_INTERFACE 65 | static inline void inline_mysql_stage_register( 66 | const char *category, PSI_stage_info **info, int count) 67 | { 68 | PSI_STAGE_CALL(register_stage)(category, info, count); 69 | } 70 | #endif 71 | 72 | #ifdef HAVE_PSI_STAGE_INTERFACE 73 | static inline PSI_stage_progress* 74 | inline_mysql_set_stage(PSI_stage_key key, 75 | const char *src_file, int src_line) 76 | { 77 | return PSI_STAGE_CALL(start_stage)(key, src_file, src_line); 78 | } 79 | #endif 80 | 81 | #ifdef HAVE_PSI_STAGE_INTERFACE 82 | #define mysql_stage_set_work_completed(P1, P2) \ 83 | inline_mysql_stage_set_work_completed(P1, P2) 84 | #else 85 | #define mysql_stage_set_work_completed(P1, P2) \ 86 | do {} while (0) 87 | #endif 88 | 89 | #ifdef HAVE_PSI_STAGE_INTERFACE 90 | #define mysql_stage_inc_work_completed(P1, P2) \ 91 | inline_mysql_stage_inc_work_completed(P1, P2) 92 | #else 93 | #define mysql_stage_inc_work_completed(P1, P2) \ 94 | do {} while (0) 95 | #endif 96 | 97 | #ifdef HAVE_PSI_STAGE_INTERFACE 98 | #define mysql_stage_set_work_estimated(P1, P2) \ 99 | inline_mysql_stage_set_work_estimated(P1, P2) 100 | #else 101 | #define mysql_stage_set_work_estimated(P1, P2) \ 102 | do {} while (0) 103 | #endif 104 | 105 | #ifdef HAVE_PSI_STAGE_INTERFACE 106 | static inline void 107 | inline_mysql_stage_set_work_completed(PSI_stage_progress *progress, 108 | ulonglong val) 109 | { 110 | if (progress != NULL) 111 | progress->m_work_completed= val; 112 | } 113 | #endif 114 | 115 | #ifdef HAVE_PSI_STAGE_INTERFACE 116 | static inline void 117 | inline_mysql_stage_inc_work_completed(PSI_stage_progress *progress, 118 | ulonglong val) 119 | { 120 | if (progress != NULL) 121 | progress->m_work_completed+= val; 122 | } 123 | #endif 124 | 125 | #ifdef HAVE_PSI_STAGE_INTERFACE 126 | static inline void 127 | inline_mysql_stage_set_work_estimated(PSI_stage_progress *progress, 128 | ulonglong val) 129 | { 130 | if (progress != NULL) 131 | progress->m_work_estimated= val; 132 | } 133 | #endif 134 | 135 | /** @} (end of group Stage_instrumentation) */ 136 | 137 | #endif 138 | 139 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/mysql_table.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software Foundation, 14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 15 | 16 | #ifndef MYSQL_TABLE_H 17 | #define MYSQL_TABLE_H 18 | 19 | /** 20 | @file mysql/psi/mysql_table.h 21 | Instrumentation helpers for table io. 22 | */ 23 | 24 | #include "mysql/psi/psi.h" 25 | 26 | #ifndef PSI_TABLE_CALL 27 | #define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M) 28 | #endif 29 | 30 | /** 31 | @defgroup Table_instrumentation Table Instrumentation 32 | @ingroup Instrumentation_interface 33 | @{ 34 | */ 35 | 36 | /** 37 | @def MYSQL_TABLE_WAIT_VARIABLES 38 | Instrumentation helper for table waits. 39 | This instrumentation declares local variables. 40 | Do not use a ';' after this macro 41 | @param LOCKER the locker 42 | @param STATE the locker state 43 | @sa MYSQL_START_TABLE_IO_WAIT. 44 | @sa MYSQL_END_TABLE_IO_WAIT. 45 | @sa MYSQL_START_TABLE_LOCK_WAIT. 46 | @sa MYSQL_END_TABLE_LOCK_WAIT. 47 | */ 48 | #ifdef HAVE_PSI_TABLE_INTERFACE 49 | #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \ 50 | struct PSI_table_locker* LOCKER; \ 51 | PSI_table_locker_state STATE; 52 | #else 53 | #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) 54 | #endif 55 | 56 | /** 57 | @def MYSQL_START_TABLE_LOCK_WAIT 58 | Instrumentation helper for table lock waits. 59 | This instrumentation marks the start of a wait event. 60 | @param LOCKER the locker 61 | @param STATE the locker state 62 | @param PSI the instrumented table 63 | @param OP the table operation to be performed 64 | @param FLAGS per table operation flags. 65 | @sa MYSQL_END_TABLE_LOCK_WAIT. 66 | */ 67 | #ifdef HAVE_PSI_TABLE_INTERFACE 68 | #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \ 69 | LOCKER= inline_mysql_start_table_lock_wait(STATE, PSI, \ 70 | OP, FLAGS, __FILE__, __LINE__) 71 | #else 72 | #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \ 73 | do {} while (0) 74 | #endif 75 | 76 | /** 77 | @def MYSQL_END_TABLE_LOCK_WAIT 78 | Instrumentation helper for table lock waits. 79 | This instrumentation marks the end of a wait event. 80 | @param LOCKER the locker 81 | @sa MYSQL_START_TABLE_LOCK_WAIT. 82 | */ 83 | #ifdef HAVE_PSI_TABLE_INTERFACE 84 | #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \ 85 | inline_mysql_end_table_lock_wait(LOCKER) 86 | #else 87 | #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \ 88 | do {} while (0) 89 | #endif 90 | 91 | #ifdef HAVE_PSI_TABLE_INTERFACE 92 | #define MYSQL_UNLOCK_TABLE(T) \ 93 | inline_mysql_unlock_table(T) 94 | #else 95 | #define MYSQL_UNLOCK_TABLE(T) \ 96 | do {} while (0) 97 | #endif 98 | 99 | #ifdef HAVE_PSI_TABLE_INTERFACE 100 | /** 101 | Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT. 102 | @sa MYSQL_END_TABLE_LOCK_WAIT. 103 | */ 104 | static inline struct PSI_table_locker * 105 | inline_mysql_start_table_lock_wait(PSI_table_locker_state *state, 106 | struct PSI_table *psi, 107 | enum PSI_table_lock_operation op, 108 | ulong flags, const char *src_file, int src_line) 109 | { 110 | if (psi != NULL) 111 | { 112 | struct PSI_table_locker *locker; 113 | locker= PSI_TABLE_CALL(start_table_lock_wait) 114 | (state, psi, op, flags, src_file, src_line); 115 | return locker; 116 | } 117 | return NULL; 118 | } 119 | 120 | /** 121 | Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT. 122 | @sa MYSQL_START_TABLE_LOCK_WAIT. 123 | */ 124 | static inline void 125 | inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker) 126 | { 127 | if (locker != NULL) 128 | PSI_TABLE_CALL(end_table_lock_wait)(locker); 129 | } 130 | 131 | static inline void 132 | inline_mysql_unlock_table(struct PSI_table *table) 133 | { 134 | if (table != NULL) 135 | PSI_TABLE_CALL(unlock_table)(table); 136 | } 137 | #endif 138 | 139 | /** @} (end of group Table_instrumentation) */ 140 | 141 | #endif 142 | 143 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/psi_base.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software Foundation, 14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 15 | 16 | #ifndef MYSQL_PSI_BASE_H 17 | #define MYSQL_PSI_BASE_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /** 24 | @file mysql/psi/psi_base.h 25 | Performance schema instrumentation interface. 26 | 27 | @defgroup Instrumentation_interface Instrumentation Interface 28 | @ingroup Performance_schema 29 | @{ 30 | */ 31 | 32 | #define PSI_INSTRUMENT_ME 0 33 | 34 | #define PSI_NOT_INSTRUMENTED 0 35 | 36 | /** 37 | Global flag. 38 | This flag indicate that an instrumentation point is a global variable, 39 | or a singleton. 40 | */ 41 | #define PSI_FLAG_GLOBAL (1 << 0) 42 | 43 | /** 44 | Mutable flag. 45 | This flag indicate that an instrumentation point is a general placeholder, 46 | that can mutate into a more specific instrumentation point. 47 | */ 48 | #define PSI_FLAG_MUTABLE (1 << 1) 49 | 50 | #define PSI_FLAG_THREAD (1 << 2) 51 | 52 | /** 53 | Stage progress flag. 54 | This flag apply to the stage instruments only. 55 | It indicates the instrumentation provides progress data. 56 | */ 57 | #define PSI_FLAG_STAGE_PROGRESS (1 << 3) 58 | 59 | #ifdef HAVE_PSI_INTERFACE 60 | 61 | /** 62 | Shared Exclusive flag. 63 | Indicates that rwlock support the shared exclusive state. 64 | */ 65 | #define PSI_RWLOCK_FLAG_SX (1 << 4) 66 | 67 | /** 68 | @def PSI_VERSION_1 69 | Performance Schema Interface number for version 1. 70 | This version is supported. 71 | */ 72 | #define PSI_VERSION_1 1 73 | 74 | /** 75 | @def PSI_VERSION_2 76 | Performance Schema Interface number for version 2. 77 | This version is not implemented, it's a placeholder. 78 | */ 79 | #define PSI_VERSION_2 2 80 | 81 | /** 82 | @def PSI_CURRENT_VERSION 83 | Performance Schema Interface number for the most recent version. 84 | The most current version is @c PSI_VERSION_1 85 | */ 86 | #define PSI_CURRENT_VERSION 1 87 | 88 | /** 89 | @def USE_PSI_1 90 | Define USE_PSI_1 to use the interface version 1. 91 | */ 92 | 93 | /** 94 | @def USE_PSI_2 95 | Define USE_PSI_2 to use the interface version 2. 96 | */ 97 | 98 | /** 99 | @def HAVE_PSI_1 100 | Define HAVE_PSI_1 if the interface version 1 needs to be compiled in. 101 | */ 102 | 103 | /** 104 | @def HAVE_PSI_2 105 | Define HAVE_PSI_2 if the interface version 2 needs to be compiled in. 106 | */ 107 | 108 | #ifndef USE_PSI_2 109 | #ifndef USE_PSI_1 110 | #define USE_PSI_1 111 | #endif 112 | #endif 113 | 114 | #ifdef USE_PSI_1 115 | #define HAVE_PSI_1 116 | #endif 117 | 118 | #ifdef USE_PSI_2 119 | #define HAVE_PSI_2 120 | #endif 121 | 122 | /* 123 | Allow to override PSI_XXX_CALL at compile time 124 | with more efficient implementations, if available. 125 | If nothing better is available, 126 | make a dynamic call using the PSI_server function pointer. 127 | */ 128 | 129 | #define PSI_DYNAMIC_CALL(M) PSI_server->M 130 | 131 | #endif /* HAVE_PSI_INTERFACE */ 132 | 133 | /** @} */ 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /* MYSQL_PSI_BASE_H */ 140 | 141 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/psi/psi_memory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software Foundation, 14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 15 | 16 | #ifndef MYSQL_PSI_MEMORY_H 17 | #define MYSQL_PSI_MEMORY_H 18 | 19 | #include "psi_base.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | @file mysql/psi/psi_memory.h 27 | Performance schema instrumentation interface. 28 | 29 | @defgroup Instrumentation_interface Instrumentation Interface 30 | @ingroup Performance_schema 31 | @{ 32 | */ 33 | 34 | #ifdef HAVE_PSI_INTERFACE 35 | #ifndef DISABLE_ALL_PSI 36 | #ifndef DISABLE_PSI_MEMORY 37 | #define HAVE_PSI_MEMORY_INTERFACE 38 | #endif /* DISABLE_PSI_MEMORY */ 39 | #endif /* DISABLE_ALL_PSI */ 40 | #endif /* HAVE_PSI_INTERFACE */ 41 | 42 | /** 43 | Instrumented memory key. 44 | To instrument memory, a memory key must be obtained using @c register_memory. 45 | Using a zero key always disable the instrumentation. 46 | */ 47 | typedef unsigned int PSI_memory_key; 48 | 49 | #ifdef HAVE_PSI_1 50 | 51 | /** 52 | @defgroup Group_PSI_v1 Application Binary Interface, version 1 53 | @ingroup Instrumentation_interface 54 | @{ 55 | */ 56 | 57 | /** 58 | Memory instrument information. 59 | @since PSI_VERSION_1 60 | This structure is used to register instrumented memory. 61 | */ 62 | struct PSI_memory_info_v1 63 | { 64 | /** Pointer to the key assigned to the registered memory. */ 65 | PSI_memory_key *m_key; 66 | /** The name of the memory instrument to register. */ 67 | const char *m_name; 68 | /** 69 | The flags of the socket instrument to register. 70 | @sa PSI_FLAG_GLOBAL 71 | */ 72 | int m_flags; 73 | }; 74 | typedef struct PSI_memory_info_v1 PSI_memory_info_v1; 75 | 76 | /** 77 | Memory registration API. 78 | @param category a category name (typically a plugin name) 79 | @param info an array of memory info to register 80 | @param count the size of the info array 81 | */ 82 | typedef void (*register_memory_v1_t) 83 | (const char *category, struct PSI_memory_info_v1 *info, int count); 84 | 85 | /** 86 | Instrument memory allocation. 87 | @param key the memory instrument key 88 | @param size the size of memory allocated 89 | @return the effective memory instrument key 90 | */ 91 | typedef PSI_memory_key (*memory_alloc_v1_t) 92 | (PSI_memory_key key, size_t size); 93 | 94 | /** 95 | Instrument memory re allocation. 96 | @param key the memory instrument key 97 | @param old_size the size of memory previously allocated 98 | @param new_size the size of memory re allocated 99 | @return the effective memory instrument key 100 | */ 101 | typedef PSI_memory_key (*memory_realloc_v1_t) 102 | (PSI_memory_key key, size_t old_size, size_t new_size); 103 | 104 | /** 105 | Instrument memory free. 106 | @param key the memory instrument key 107 | @param size the size of memory allocated 108 | */ 109 | typedef void (*memory_free_v1_t) 110 | (PSI_memory_key key, size_t size); 111 | 112 | /** @} (end of group Group_PSI_v1) */ 113 | 114 | #endif /* HAVE_PSI_1 */ 115 | 116 | #ifdef HAVE_PSI_2 117 | struct PSI_memory_info_v2 118 | { 119 | int placeholder; 120 | }; 121 | 122 | #endif /* HAVE_PSI_2 */ 123 | 124 | #ifdef USE_PSI_1 125 | typedef struct PSI_memory_info_v1 PSI_memory_info; 126 | #endif 127 | 128 | #ifdef USE_PSI_2 129 | typedef struct PSI_memory_info_v2 PSI_memory_info; 130 | #endif 131 | 132 | /** @} (end of group Instrumentation_interface) */ 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif 137 | 138 | 139 | #endif /* MYSQL_PSI_MEMORY_H */ 140 | 141 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/service_my_snprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSQL_SERVICE_MY_SNPRINTF_INCLUDED 2 | /* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; version 2 of the License. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 16 | 17 | /** 18 | @file 19 | my_snprintf service 20 | 21 | Portable and limited vsnprintf() implementation. 22 | 23 | This is a portable, limited vsnprintf() implementation, with some 24 | extra features. "Portable" means that it'll produce identical result 25 | on all platforms (for example, on Windows and Linux system printf %e 26 | formats the exponent differently, on different systems %p either 27 | prints leading 0x or not, %s may accept null pointer or crash on 28 | it). "Limited" means that it does not support all the C89 features. 29 | But it supports few extensions, not in any standard. 30 | 31 | my_vsnprintf(to, n, fmt, ap) 32 | 33 | @param[out] to A buffer to store the result in 34 | @param[in] n Store up to n-1 characters, followed by an end 0 35 | @param[in] fmt printf-like format string 36 | @param[in] ap Arguments 37 | 38 | @return a number of bytes written to a buffer *excluding* terminating '\0' 39 | 40 | @post 41 | The syntax of a format string is generally the same: 42 | % 43 | where everithing but the format is optional. 44 | 45 | Three one-character flags are recognized: 46 | '0' has the standard zero-padding semantics; 47 | '-' is parsed, but silently ignored; 48 | '`' (backtick) is only supported for strings (%s) and means that the 49 | string will be quoted according to MySQL identifier quoting rules. 50 | 51 | Both and can be specified as numbers or '*'. 52 | If an asterisk is used, an argument of type int is consumed. 53 | 54 | can be 'l', 'll', or 'z'. 55 | 56 | Supported formats are 's' (null pointer is accepted, printed as 57 | "(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o', 58 | 'X', 'p' (works as 0x%x). 59 | 60 | Standard syntax for positional arguments $n is supported. 61 | 62 | Extensions: 63 | 64 | Flag '`' (backtick): see above. 65 | 66 | Format 'b': binary buffer, prints exactly bytes from the 67 | argument, without stopping at '\0'. 68 | */ 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | 74 | #ifndef MYSQL_ABI_CHECK 75 | #include 76 | #include 77 | #endif 78 | 79 | extern struct my_snprintf_service_st { 80 | size_t (*my_snprintf_type)(char*, size_t, const char*, ...); 81 | size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); 82 | } *my_snprintf_service; 83 | 84 | #ifdef MYSQL_DYNAMIC_PLUGIN 85 | 86 | #define my_vsnprintf my_snprintf_service->my_vsnprintf_type 87 | #define my_snprintf my_snprintf_service->my_snprintf_type 88 | 89 | #else 90 | 91 | size_t my_snprintf(char* to, size_t n, const char* fmt, ...); 92 | size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); 93 | 94 | #endif 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED 101 | #endif 102 | 103 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql/service_mysql_alloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED 17 | #define MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED 18 | 19 | #ifndef MYSQL_ABI_CHECK 20 | #include 21 | #endif 22 | 23 | /* PSI_memory_key */ 24 | #include "mysql/psi/psi_memory.h" 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* myf */ 31 | typedef int myf_t; 32 | 33 | typedef void * (*mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags); 34 | typedef void * (*mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size, myf_t flags); 35 | typedef void (*mysql_free_t)(void *ptr); 36 | typedef void * (*my_memdup_t)(PSI_memory_key key, const void *from, size_t length, myf_t flags); 37 | typedef char * (*my_strdup_t)(PSI_memory_key key, const char *from, myf_t flags); 38 | typedef char * (*my_strndup_t)(PSI_memory_key key, const char *from, size_t length, myf_t flags); 39 | 40 | struct mysql_malloc_service_st 41 | { 42 | mysql_malloc_t mysql_malloc; 43 | mysql_realloc_t mysql_realloc; 44 | mysql_free_t mysql_free; 45 | my_memdup_t my_memdup; 46 | my_strdup_t my_strdup; 47 | my_strndup_t my_strndup; 48 | }; 49 | 50 | extern struct mysql_malloc_service_st *mysql_malloc_service; 51 | 52 | #ifdef MYSQL_DYNAMIC_PLUGIN 53 | 54 | #define my_malloc mysql_malloc_service->mysql_malloc 55 | #define my_realloc mysql_malloc_service->mysql_realloc 56 | #define my_free mysql_malloc_service->mysql_free 57 | #define my_memdup mysql_malloc_service->my_memdup 58 | #define my_strdup mysql_malloc_service->my_strdup 59 | #define my_strndup mysql_malloc_service->my_strndup 60 | 61 | #else 62 | 63 | extern void * my_malloc(PSI_memory_key key, size_t size, myf_t flags); 64 | extern void * my_realloc(PSI_memory_key key, void *ptr, size_t size, myf_t flags); 65 | extern void my_free(void *ptr); 66 | extern void * my_memdup(PSI_memory_key key, const void *from, size_t length, myf_t flags); 67 | extern char * my_strdup(PSI_memory_key key, const char *from, myf_t flags); 68 | extern char * my_strndup(PSI_memory_key key, const char *from, size_t length, myf_t flags); 69 | 70 | #endif 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql_com_server.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | Definitions private to the server, 18 | used in the networking layer to notify specific events. 19 | */ 20 | 21 | #ifndef _mysql_com_server_h 22 | #define _mysql_com_server_h 23 | 24 | struct st_net_server; 25 | 26 | typedef void (*before_header_callback_fn) 27 | (struct st_net *net, void *user_data, size_t count); 28 | 29 | typedef void (*after_header_callback_fn) 30 | (struct st_net *net, void *user_data, size_t count, my_bool rc); 31 | 32 | struct st_net_server 33 | { 34 | before_header_callback_fn m_before_header; 35 | after_header_callback_fn m_after_header; 36 | void *m_user_data; 37 | }; 38 | 39 | typedef struct st_net_server NET_SERVER; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql_embed.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSQL_EMBED_INCLUDED 2 | #define MYSQL_EMBED_INCLUDED 3 | 4 | /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; version 2 of the License. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 18 | 19 | /* Defines that are unique to the embedded version of MySQL */ 20 | 21 | #ifdef EMBEDDED_LIBRARY 22 | 23 | /* Things we don't need in the embedded version of MySQL */ 24 | /* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */ 25 | 26 | #undef HAVE_DLOPEN /* No udf functions */ 27 | 28 | #endif /* EMBEDDED_LIBRARY */ 29 | #endif /* MYSQL_EMBED_INCLUDED */ 30 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql_time.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 15 | 16 | #ifndef _mysql_time_h_ 17 | #define _mysql_time_h_ 18 | 19 | /* 20 | Time declarations shared between the server and client API: 21 | you should not add anything to this header unless it's used 22 | (and hence should be visible) in mysql.h. 23 | If you're looking for a place to add new time-related declaration, 24 | it's most likely my_time.h. See also "C API Handling of Date 25 | and Time Values" chapter in documentation. 26 | */ 27 | 28 | enum enum_mysql_timestamp_type 29 | { 30 | MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, 31 | MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 32 | }; 33 | 34 | 35 | /* 36 | Structure which is used to represent datetime values inside MySQL. 37 | 38 | We assume that values in this structure are normalized, i.e. year <= 9999, 39 | month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions 40 | in server such as my_system_gmt_sec() or make_time() family of functions 41 | rely on this (actually now usage of make_*() family relies on a bit weaker 42 | restriction). Also functions that produce MYSQL_TIME as result ensure this. 43 | There is one exception to this rule though if this structure holds time 44 | value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold 45 | bigger values. 46 | */ 47 | typedef struct st_mysql_time 48 | { 49 | unsigned int year, month, day, hour, minute, second; 50 | unsigned long second_part; /**< microseconds */ 51 | my_bool neg; 52 | enum enum_mysql_timestamp_type time_type; 53 | } MYSQL_TIME; 54 | 55 | #endif /* _mysql_time_h_ */ 56 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/mysql_version.h: -------------------------------------------------------------------------------- 1 | /* Copyright Abandoned 1996,1999 TCX DataKonsult AB & Monty Program KB 2 | & Detron HB, 1996, 1999-2004, 2007 MySQL AB. 3 | This file is public domain and comes with NO WARRANTY of any kind 4 | */ 5 | 6 | /* Version numbers for protocol & mysqld */ 7 | 8 | #ifndef _mysql_version_h 9 | #define _mysql_version_h 10 | #ifdef _CUSTOMCONFIG_ 11 | #include 12 | #else 13 | #define MYSQL_PROTOCOL_VERSION 10 14 | #define MYSQL_SERVER_VERSION "5.7.6-m16" 15 | #define MYSQL_VERSION_ID 50706 16 | #define MYSQL_PORT 3306 17 | #define MYSQL_PORT_DEFAULT 0 18 | #define MYSQL_UNIX_ADDR "/tmp/mysql.sock" 19 | #define MYSQL_CONFIG_NAME "my" 20 | #define MYSQL_COMPILATION_COMMENT "MySQL Connector/C (GPL)" 21 | #define LIBMYSQL_VERSION "6.1.6" 22 | #define LIBMYSQL_VERSION_ID 60106 23 | 24 | /* mysqld compile time options */ 25 | #endif /* _CUSTOMCONFIG_ */ 26 | 27 | #ifndef LICENSE 28 | #define LICENSE GPL 29 | #endif /* LICENSE */ 30 | 31 | #endif /* _mysql_version_h */ 32 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/sslopt-case.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) 17 | #ifdef MYSQL_CLIENT 18 | case OPT_SSL_SSL: 19 | /* 20 | A client side --ssl option handling. 21 | --ssl=1 means enforce (use=1, enforce=1) 22 | --ssl=0 means can't enforce (use=0, enforce=0) 23 | no --ssl means default : no enforce (use=1), just try (enforce=1) 24 | */ 25 | opt_ssl_enforce= opt_use_ssl; 26 | break; 27 | #endif 28 | case OPT_SSL_KEY: 29 | case OPT_SSL_CERT: 30 | case OPT_SSL_CA: 31 | case OPT_SSL_CAPATH: 32 | case OPT_SSL_CIPHER: 33 | case OPT_SSL_CRL: 34 | case OPT_SSL_CRLPATH: 35 | /* 36 | Enable use of SSL if we are using any ssl option 37 | One can disable SSL later by using --skip-ssl or --ssl=0 38 | */ 39 | opt_use_ssl= TRUE; 40 | /* crl has no effect in yaSSL */ 41 | #ifdef HAVE_YASSL 42 | opt_ssl_crl= NULL; 43 | opt_ssl_crlpath= NULL; 44 | #endif 45 | break; 46 | #endif -------------------------------------------------------------------------------- /src/libcod/mysql/include/sslopt-longopts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) 17 | 18 | {"ssl", OPT_SSL_SSL, 19 | "If set to ON, this option enforces that SSL is established before client " 20 | "attempts to authenticate to the server. To disable client SSL capabilities " 21 | "use --ssl=OFF.", 22 | &opt_use_ssl, &opt_use_ssl, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, 23 | {"ssl-ca", OPT_SSL_CA, 24 | "CA file in PEM format.", 25 | &opt_ssl_ca, &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, 26 | 0, 0, 0, 0, 0, 0}, 27 | {"ssl-capath", OPT_SSL_CAPATH, 28 | "CA directory.", 29 | &opt_ssl_capath, &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, 30 | 0, 0, 0, 0, 0, 0}, 31 | {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format.", 32 | &opt_ssl_cert, &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, 33 | 0, 0, 0, 0, 0, 0}, 34 | {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use.", 35 | &opt_ssl_cipher, &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, 36 | 0, 0, 0, 0, 0, 0}, 37 | {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format.", 38 | &opt_ssl_key, &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, 39 | 0, 0, 0, 0, 0, 0}, 40 | {"ssl-crl", OPT_SSL_CRL, "Certificate revocation list.", 41 | &opt_ssl_crl, &opt_ssl_crl, 0, GET_STR, REQUIRED_ARG, 42 | 0, 0, 0, 0, 0, 0}, 43 | {"ssl-crlpath", OPT_SSL_CRLPATH, 44 | "Certificate revocation list path.", 45 | &opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG, 46 | 0, 0, 0, 0, 0, 0}, 47 | #ifdef MYSQL_CLIENT 48 | {"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT, 49 | "Verify server's \"Common Name\" in its cert against hostname used " 50 | "when connecting. This option is disabled by default.", 51 | &opt_ssl_verify_server_cert, &opt_ssl_verify_server_cert, 52 | 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, 53 | #endif 54 | #endif /* HAVE_OPENSSL */ -------------------------------------------------------------------------------- /src/libcod/mysql/include/sslopt-vars.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef SSLOPT_VARS_INCLUDED 17 | #define SSLOPT_VARS_INCLUDED 18 | 19 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) 20 | /* Always try to use SSL per default */ 21 | static my_bool opt_use_ssl = TRUE; 22 | /* Fall back on unencrypted connections per default */ 23 | static my_bool opt_ssl_enforce= FALSE; 24 | static char *opt_ssl_ca = 0; 25 | static char *opt_ssl_capath = 0; 26 | static char *opt_ssl_cert = 0; 27 | static char *opt_ssl_cipher = 0; 28 | static char *opt_ssl_key = 0; 29 | static char *opt_ssl_crl = 0; 30 | static char *opt_ssl_crlpath = 0; 31 | #ifndef MYSQL_CLIENT 32 | #error This header is supposed to be used only in the client 33 | #endif 34 | #define SSL_SET_OPTIONS(mysql) \ 35 | if (opt_use_ssl) \ 36 | { \ 37 | mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, \ 38 | opt_ssl_capath, opt_ssl_cipher); \ 39 | mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl); \ 40 | mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); \ 41 | mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &opt_ssl_enforce); \ 42 | } \ 43 | mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, \ 44 | (char*)&opt_ssl_verify_server_cert) 45 | 46 | static my_bool opt_ssl_verify_server_cert= 0; 47 | #else 48 | #define SSL_SET_OPTIONS(mysql) do { } while(0) 49 | #endif 50 | #endif /* SSLOPT_VARS_INCLUDED */ 51 | -------------------------------------------------------------------------------- /src/libcod/mysql/include/typelib.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 15 | 16 | 17 | #ifndef _typelib_h 18 | #define _typelib_h 19 | 20 | #include "my_alloc.h" 21 | 22 | typedef struct st_typelib { /* Different types saved here */ 23 | unsigned int count; /* How many types */ 24 | const char *name; /* Name of typelib */ 25 | const char **type_names; 26 | unsigned int *type_lengths; 27 | } TYPELIB; 28 | 29 | extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position); 30 | extern int find_type_or_exit(const char *x, TYPELIB *typelib, 31 | const char *option); 32 | #define FIND_TYPE_BASIC 0 33 | /** makes @c find_type() require the whole name, no prefix */ 34 | #define FIND_TYPE_NO_PREFIX (1 << 0) 35 | /** always implicitely on, so unused, but old code may pass it */ 36 | #define FIND_TYPE_NO_OVERWRITE (1 << 1) 37 | /** makes @c find_type() accept a number */ 38 | #define FIND_TYPE_ALLOW_NUMBER (1 << 2) 39 | /** makes @c find_type() treat ',' as terminator */ 40 | #define FIND_TYPE_COMMA_TERM (1 << 3) 41 | 42 | extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags); 43 | extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); 44 | extern const char *get_type(TYPELIB *typelib,unsigned int nr); 45 | extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from); 46 | 47 | extern TYPELIB sql_protocol_typelib; 48 | 49 | my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name, 50 | my_ulonglong cur_set, my_ulonglong default_set, 51 | const char *str, unsigned int length, 52 | char **err_pos, unsigned int *err_len); 53 | 54 | #endif /* _typelib_h */ 55 | -------------------------------------------------------------------------------- /src/qcommon/cm_load.cpp: -------------------------------------------------------------------------------- 1 | #include "qcommon.h" 2 | #include "cm_local.h" 3 | 4 | clipMap_t cm; 5 | 6 | /* 7 | ================== 8 | CM_LeafCluster 9 | ================== 10 | */ 11 | int CM_LeafCluster( int leafnum ) 12 | { 13 | if ( leafnum < 0 || leafnum >= cm.numLeafs ) 14 | { 15 | Com_Error( ERR_DROP, "CM_LeafCluster: bad number %i", leafnum ); 16 | } 17 | 18 | return cm.leafs[leafnum].cluster; 19 | } 20 | 21 | /* 22 | =================== 23 | CM_ModelBounds 24 | =================== 25 | */ 26 | void CM_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) 27 | { 28 | cmodel_t *cmod; 29 | 30 | cmod = CM_ClipHandleToModel( model ); 31 | 32 | VectorCopy( cmod->mins, mins ); 33 | VectorCopy( cmod->maxs, maxs ); 34 | } 35 | 36 | /* 37 | =================== 38 | CM_Hunk_Alloc 39 | =================== 40 | */ 41 | void* CM_Hunk_Alloc( int size ) 42 | { 43 | return Hunk_Alloc(size); 44 | } 45 | 46 | /* 47 | =================== 48 | CM_Hunk_CheckTempMemoryHighClear 49 | =================== 50 | */ 51 | void CM_Hunk_CheckTempMemoryHighClear() 52 | { 53 | ; 54 | } 55 | 56 | /* 57 | =================== 58 | CM_Hunk_ClearTempMemoryHigh 59 | =================== 60 | */ 61 | void CM_Hunk_ClearTempMemoryHigh() 62 | { 63 | Hunk_ClearTempMemoryHighInternal(); 64 | } 65 | 66 | /* 67 | =================== 68 | CM_Hunk_AllocateTempMemoryHigh 69 | =================== 70 | */ 71 | void* CM_Hunk_AllocateTempMemoryHigh( int size ) 72 | { 73 | return Hunk_AllocateTempMemoryHighInternal(size); 74 | } 75 | 76 | /* 77 | =================== 78 | CM_NumInlineModels 79 | =================== 80 | */ 81 | int CM_NumInlineModels( void ) 82 | { 83 | return cm.numSubModels; 84 | } 85 | 86 | /* 87 | =================== 88 | CM_EntityString 89 | =================== 90 | */ 91 | char *CM_EntityString() 92 | { 93 | return cm.entityString; 94 | } 95 | 96 | /* 97 | =================== 98 | CM_InitThreadData 99 | =================== 100 | */ 101 | void CM_InitThreadData( int threadContext ) 102 | { 103 | TraceThreadInfo *tti; 104 | 105 | tti = &g_traceThreadInfo[threadContext]; 106 | 107 | tti->checkcount = 0; 108 | 109 | tti->partitions = (uint16_t *)Hunk_Alloc( cm.partitionCount * sizeof( *tti->partitions ) ); 110 | tti->edges = (int32_t *)Hunk_Alloc( cm.edgeCount * sizeof( *tti->edges ) ); 111 | tti->verts = (int32_t *)Hunk_Alloc( cm.vertCount * sizeof( *tti->verts ) ); 112 | 113 | tti->box_brush = (cbrush_t *)Hunk_Alloc( sizeof( *tti->box_brush ) ); 114 | tti->box_brush = cm.box_brush; 115 | 116 | tti->box_model = (cmodel_t *)Hunk_Alloc( sizeof( *tti->box_model ) ); 117 | tti->box_model = &cm.box_model; 118 | } 119 | 120 | /* 121 | =================== 122 | CM_InitAllThreadData 123 | =================== 124 | */ 125 | void CM_InitAllThreadData() 126 | { 127 | CM_InitThreadData(THREAD_CONTEXT_MAIN); 128 | } 129 | 130 | /* 131 | =================== 132 | CM_LoadMapInternal 133 | =================== 134 | */ 135 | void CM_LoadMapInternal( const char *name ) 136 | { 137 | CM_LoadMapFromBsp(name, true); 138 | CM_LoadStaticModels(); 139 | } 140 | 141 | /* 142 | =================== 143 | CM_LoadMap 144 | =================== 145 | */ 146 | void CM_LoadMap( const char *name, int *checksum ) 147 | { 148 | if ( !name || !*name ) 149 | { 150 | Com_Error(ERR_DROP, "CM_LoadMap: NULL name"); 151 | } 152 | 153 | if ( !cm.name || strcasecmp(cm.name, name) ) 154 | { 155 | CM_LoadMapInternal(name); 156 | CM_InitAllThreadData(); 157 | } 158 | 159 | *checksum = cm.checksum; 160 | } 161 | 162 | /* 163 | =================== 164 | CM_Shutdown 165 | =================== 166 | */ 167 | void CM_Shutdown() 168 | { 169 | Com_Memset(&cm, 0, sizeof(cm)); 170 | } 171 | 172 | /* 173 | =================== 174 | CM_Cleanup 175 | =================== 176 | */ 177 | void CM_Cleanup( void ) 178 | { 179 | cm.header = NULL; 180 | } -------------------------------------------------------------------------------- /src/qcommon/cm_public.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "cm_local.h" 3 | 4 | extern clipMap_t cm; 5 | 6 | char *CM_EntityString(); 7 | void CM_LoadMapFromBsp(const char *name, bool usePvs); 8 | 9 | dheader_t* Com_GetBsp(int *fileSize, unsigned int *checksum); 10 | cmodel_t *CM_ClipHandleToModel( clipHandle_t handle ); 11 | void CM_SetAxialCullOnly(traceWork_t *tw); 12 | bool CM_CullBox(traceWork_t *tw, const float *origin, const float *halfSize); 13 | void CM_MeshTestInLeaf(traceWork_t *tw, cLeaf_s *leaf, trace_t *trace); 14 | int CM_TestInLeafBrushNode(traceWork_t *tw, cLeaf_s *leaf, trace_t *trace); 15 | void CM_TraceStaticModel(cStaticModel_s *sm, trace_t *results, const float *start, const float *end, int contentmask); 16 | int CM_TraceStaticModelComplete(cStaticModel_s *sm, const float *start, const float *end, int contentmask); 17 | int CM_PointTraceStaticModelsComplete(const float *start, const float *end, int contentmask); 18 | void CM_PointTraceStaticModels(trace_t *results, const float *start, const float *end, int contentmask); 19 | int CM_PointSightTraceToEntities(sightpointtrace_t *clip); 20 | int CM_ClipSightTraceToEntities(sightclip_t *clip); 21 | int CM_AreaEntities(const float *mins, const float *maxs, int *entityList, int maxcount, int contentmask); 22 | void CM_PointTraceToEntities(pointtrace_t *clip, trace_t *trace); 23 | void CM_TraceThroughAabbTree(traceWork_t *tw, CollisionAabbTree_s *aabbTree, trace_t *trace); 24 | void CM_TestInLeaf(traceWork_t *tw, cLeaf_s *leaf, trace_t *trace); 25 | void CM_ClipMoveToEntities(moveclip_t *clip, trace_t *trace); 26 | int CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles ); 27 | void CM_SightTraceThroughAabbTree(traceWork_t *tw, CollisionAabbTree_s *aabbTree, trace_t *trace); 28 | int CM_TransformedBoxSightTrace(int hitNum, const float *start, const float *end, const float *mins, const float *maxs, clipHandle_t model, int brushmask, const float *origin, const float *angles); 29 | int CM_BoxSightTrace( int oldHitNum, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask ); 30 | void CM_Trace(trace_t *results, const float *start, const float *end, const float *mins, const float *maxs, clipHandle_t model, int brushmask); 31 | void CM_BoxTrace(trace_t *results, const float *start, const float *end, const float *mins, const float *maxs, clipHandle_t model, int brushmask); 32 | void CM_TransformedBoxTrace(trace_t *results, const float *start, const float *end, const float *mins, const float *maxs, clipHandle_t model, int brushmask, const float *origin, const float *angles); 33 | void CM_TransformedBoxTraceExternal(trace_t *results, const float *start, const float *end, const float *mins, const float *maxs, clipHandle_t model, int brushmask, const float *origin, const float *angles); 34 | int CM_SightTraceThroughLeafBrushNode(traceWork_t *tw, cLeaf_s *leaf); 35 | bool CM_TraceThroughLeafBrushNode(traceWork_t *tw, cLeaf_s *leaf, trace_t *trace); 36 | cLeafBrushNode_s * CMod_PartionLeafBrushes_r(uint16_t *leafBrushes, int numLeafBrushes, const float *mins, const float *maxs); 37 | bool CM_RayTriangleIntersect( const vec3_t orig, const vec3_t dir, const vec3_t vert1, const vec3_t vert2, const vec3_t vert3, float *pt, float *pu, float *pv ); 38 | int CM_SightTraceThroughLeaf(traceWork_t *tw, cLeaf_s *leaf, trace_t *trace); 39 | void CM_TestCapsuleInCapsule(traceWork_t *tw, trace_t *trace); 40 | int CM_SightTraceCapsuleThroughCapsule(traceWork_t *tw, trace_t *trace); 41 | int CM_SightTraceThroughBrush(traceWork_t *tw, cbrush_t *brush); 42 | float CM_RadiusOfModel( clipHandle_t handle ); 43 | int CM_ContentsOfModel( clipHandle_t handle ); 44 | int CM_SightTraceThroughTree(traceWork_t *tw, int num, const float *p1_, const float *p2, trace_t *trace); 45 | void CM_TraceCapsuleThroughCapsule(traceWork_t *tw, trace_t *trace); 46 | void CM_TraceThroughLeaf(traceWork_t *tw, cLeaf_s *leaf, trace_t *trace); 47 | void CM_TraceThroughTree(traceWork_t *tw, int num, const float *p1_, const float *p2, trace_t *trace); 48 | int CM_TraceCylinderThroughCylinder(traceWork_t *tw, const float *vStationary, float fStationaryHalfHeight, float radius, trace_t *trace); 49 | int CM_TraceSphereThroughSphere(traceWork_t *tw, const float *vStart, const float *vEnd, const float *vStationary, float radius, trace_t *trace); 50 | void CM_PositionTestCapsuleInTriangle(traceWork_t *tw, CollisionTriangle_s *collTtris, trace_t *trace); 51 | void CM_TracePointThroughTriangle(traceWork_t *tw, CollisionTriangle_s *tri, trace_t *trace); 52 | void CM_TraceCapsuleThroughTriangle(traceWork_t *tw, CollisionTriangle_s *tri, float offsetZ, trace_t *trace); 53 | void CM_TraceCapsuleThroughBorder(traceWork_t *tw, CollisionBorder *border, trace_t *trace); 54 | void CM_TraceThroughBrush(traceWork_t *tw, cbrush_t *brush, trace_t *trace); 55 | void CM_PositionTest(traceWork_t *tw, trace_t *trace); 56 | int CM_PointContents( const vec3_t p, clipHandle_t model ); 57 | void CM_BoxLeafnums_r( leafList_t *ll, int nodenum ); 58 | void CM_StoreLeafs( leafList_t *ll, int nodenum ); 59 | void CM_LinkAllStaticModels(); 60 | void CM_LinkWorld(); 61 | 62 | qboolean CM_TraceBox(TraceExtents *extents, const float *mins, const float *maxs, float fraction); 63 | -------------------------------------------------------------------------------- /src/qcommon/cm_staticmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "qcommon.h" 2 | #include "cm_local.h" 3 | 4 | /* 5 | ================== 6 | CM_Hunk_AllocXModel 7 | ================== 8 | */ 9 | void* CM_Hunk_AllocXModel(int size) 10 | { 11 | return Hunk_Alloc(size); 12 | } 13 | 14 | /* 15 | ================== 16 | CM_Hunk_AllocXModelColl 17 | ================== 18 | */ 19 | void* CM_Hunk_AllocXModelColl(int size) 20 | { 21 | return Hunk_Alloc(size); 22 | } 23 | 24 | /* 25 | ================== 26 | CM_XModelPrecache 27 | ================== 28 | */ 29 | XModel* CM_XModelPrecache(const char *name) 30 | { 31 | return XModelPrecache(name, CM_Hunk_AllocXModel, CM_Hunk_AllocXModelColl); 32 | } 33 | 34 | /* 35 | ================== 36 | CM_TraceStaticModel 37 | ================== 38 | */ 39 | void CM_TraceStaticModel( cStaticModel_s *sm, trace_t *results, const vec3_t start, const vec3_t end, int contentmask ) 40 | { 41 | vec3_t normal; 42 | vec3_t delta; 43 | vec3_t localStart; 44 | vec3_t localEnd; 45 | DObjAnimMat *pose; 46 | 47 | VectorSubtract(start, sm->origin, delta); 48 | MatrixTransformVector(delta, sm->invScaledAxis, localStart); 49 | 50 | VectorSubtract(end, sm->origin, delta); 51 | MatrixTransformVector(delta, sm->invScaledAxis, localEnd); 52 | 53 | pose = XModelGetBasePose(sm->xmodel); 54 | 55 | if ( XModelTraceLine(sm->xmodel, results, pose, localStart, localEnd, contentmask) < 0 ) 56 | { 57 | return; 58 | } 59 | 60 | results->entityNum = ENTITYNUM_WORLD; 61 | MatrixTransposeTransformVector(results->normal, sm->invScaledAxis, normal); 62 | Vec3Normalize(normal); 63 | VectorCopy(normal, results->normal); 64 | } 65 | 66 | /* 67 | ================== 68 | CM_TraceStaticModel 69 | ================== 70 | */ 71 | qboolean CM_TraceStaticModelComplete( cStaticModel_s *sm, const vec3_t start, const vec3_t end, int contentmask ) 72 | { 73 | trace_t trace; 74 | vec3_t delta; 75 | vec3_t localStart; 76 | vec3_t localEnd; 77 | DObjAnimMat *pose; 78 | 79 | VectorSubtract(start, sm->origin, delta); 80 | MatrixTransformVector(delta, sm->invScaledAxis, localStart); 81 | 82 | VectorSubtract(end, sm->origin, delta); 83 | MatrixTransformVector(delta, sm->invScaledAxis, localEnd); 84 | 85 | trace.fraction = 1.0; 86 | 87 | pose = XModelGetBasePose(sm->xmodel); 88 | 89 | return XModelTraceLine(sm->xmodel, &trace, pose, localStart, localEnd, contentmask) < 0; 90 | } -------------------------------------------------------------------------------- /src/qcommon/cm_staticmodel_load_obj.cpp: -------------------------------------------------------------------------------- 1 | #include "qcommon.h" 2 | #include "cm_local.h" 3 | 4 | /* 5 | ================== 6 | CM_InitStaticModel 7 | ================== 8 | */ 9 | static void CM_InitStaticModel( cStaticModel_t *staticModel, const vec3_t origin, const vec3_t angles, const vec3_t scale ) 10 | { 11 | vec3_t axis[3]; 12 | 13 | VectorCopy(origin, staticModel->origin); 14 | AnglesToAxis(angles, axis); 15 | 16 | VectorScale(axis[0], scale[0], axis[0]); 17 | VectorScale(axis[1], scale[1], axis[1]); 18 | VectorScale(axis[2], scale[2], axis[2]); 19 | 20 | MatrixInverse(axis, staticModel->invScaledAxis); 21 | 22 | if ( XModelGetStaticBounds(staticModel->xmodel, axis, staticModel->absmin, staticModel->absmax) ) 23 | { 24 | VectorAdd(staticModel->absmin, origin, staticModel->absmin); 25 | VectorAdd(staticModel->absmax, origin, staticModel->absmax); 26 | } 27 | } 28 | 29 | /* 30 | ================== 31 | CM_InitStaticModel 32 | ================== 33 | */ 34 | static bool CM_CreateStaticModel( cStaticModel_t *staticModel, const char *name, const vec3_t origin, const vec3_t angles, const vec3_t scale ) 35 | { 36 | XModel *model; 37 | 38 | if ( !name || !name[0] ) 39 | Com_Error(ERR_DROP, "Invalid static model name"); 40 | 41 | if ( scale[0] == 0.0 ) 42 | Com_Error(ERR_DROP, "Static model [%s] has x scale of 0.0", name); 43 | 44 | if ( scale[1] == 0.0 ) 45 | Com_Error(ERR_DROP, "Static model [%s] has y scale of 0.0", name); 46 | 47 | if ( scale[2] == 0.0 ) 48 | Com_Error(ERR_DROP, "Static model [%s] has z scale of 0.0", name); 49 | 50 | model = CM_XModelPrecache(name); 51 | 52 | if ( !model ) 53 | { 54 | return false; 55 | } 56 | 57 | staticModel->xmodel = model; 58 | CM_InitStaticModel(staticModel, origin, angles, scale); 59 | 60 | return true; 61 | } 62 | 63 | /* 64 | ================== 65 | CM_LoadStaticModels 66 | ================== 67 | */ 68 | void CM_LoadStaticModels() 69 | { 70 | int count; 71 | qboolean bMiscModel; 72 | vec3_t scale; 73 | vec3_t angles; 74 | vec3_t origin; 75 | char value[MAX_QPATH]; 76 | char key[MAX_QPATH]; 77 | char modelName[MAX_QPATH]; 78 | const char *ptr; 79 | const char *token; 80 | 81 | ptr = cm.entityString; 82 | 83 | cm.numStaticModels = 0; 84 | cm.staticModelList = 0; 85 | 86 | while ( 1 ) 87 | { 88 | token = Com_Parse(&ptr); 89 | 90 | if ( !ptr || token[0] != '{' ) 91 | break; 92 | 93 | modelName[0] = 0; 94 | bMiscModel = 0; 95 | 96 | while ( 1 ) 97 | { 98 | token = Com_Parse(&ptr); 99 | 100 | if ( !ptr ) 101 | break; 102 | 103 | if ( token[0] == '}' ) 104 | break; 105 | 106 | strcpy(key, token); 107 | token = Com_Parse(&ptr); 108 | 109 | if ( !ptr ) 110 | break; 111 | 112 | strcpy(value, token); 113 | 114 | if ( !strcasecmp(key, "classname") ) 115 | { 116 | if ( !strcasecmp(value, "misc_model") ) 117 | bMiscModel = qtrue; 118 | } 119 | else if ( !strcasecmp(key, "model") ) 120 | { 121 | strcpy(modelName, value); 122 | } 123 | } 124 | 125 | if ( bMiscModel && Com_ValidXModelName(modelName) ) 126 | cm.numStaticModels++; 127 | } 128 | 129 | if ( !cm.numStaticModels ) 130 | return; 131 | 132 | cm.staticModelList = (cStaticModel_t *)CM_Hunk_Alloc( cm.numStaticModels * sizeof( *cm.staticModelList ) ); 133 | ptr = cm.entityString; 134 | count = 0; 135 | 136 | while ( 1 ) 137 | { 138 | token = Com_Parse(&ptr); 139 | 140 | if ( !ptr || token[0] != '{' ) 141 | break; 142 | 143 | modelName[0] = 0; 144 | 145 | memset(origin, 0, sizeof(origin)); 146 | memset(angles, 0, sizeof(angles)); 147 | 148 | scale[2] = 1.0; 149 | scale[1] = 1.0; 150 | scale[0] = 1.0; 151 | 152 | bMiscModel = 0; 153 | 154 | while ( 1 ) 155 | { 156 | token = Com_Parse(&ptr); 157 | 158 | if ( !ptr ) 159 | break; 160 | 161 | if ( token[0] == '}' ) 162 | break; 163 | 164 | strcpy(key, token); 165 | token = Com_Parse(&ptr); 166 | 167 | if ( !ptr ) 168 | break; 169 | 170 | strcpy(value, token); 171 | 172 | if ( !strcasecmp(key, "classname") ) 173 | { 174 | if ( !strcasecmp(value, "misc_model") ) 175 | bMiscModel = 1; 176 | } 177 | else if ( !strcasecmp(key, "model") ) 178 | { 179 | strcpy(modelName, value); 180 | } 181 | else if ( !strcasecmp(key, "origin") ) 182 | { 183 | sscanf(value, "%f %f %f", &origin[0], &origin[1], &origin[2]); 184 | } 185 | else if ( !strcasecmp(key, "angles") ) 186 | { 187 | sscanf(value, "%f %f %f", &angles[0], &angles[1], &angles[2]); 188 | } 189 | else if ( !strcasecmp(key, "modelscale_vec") ) 190 | { 191 | sscanf(value, "%f %f %f", &scale[0], &scale[1], &scale[2]); 192 | } 193 | else if ( !strcasecmp(key, "modelscale") ) 194 | { 195 | scale[2] = atof(value); 196 | scale[1] = scale[2]; 197 | scale[0] = scale[2]; 198 | } 199 | } 200 | 201 | if ( bMiscModel && Com_ValidXModelName(modelName) ) 202 | { 203 | if ( CM_CreateStaticModel(&cm.staticModelList[count], &modelName[7], origin, angles, scale) ) 204 | count++; 205 | else 206 | cm.numStaticModels--; 207 | } 208 | } 209 | } -------------------------------------------------------------------------------- /src/qcommon/cm_tracebox.cpp: -------------------------------------------------------------------------------- 1 | #include "qcommon.h" 2 | #include "cm_local.h" 3 | 4 | /* 5 | =================== 6 | CM_CalcTraceEntents 7 | =================== 8 | */ 9 | void CM_CalcTraceEntents( TraceExtents *extents ) 10 | { 11 | float delta; 12 | float diff; 13 | int i; 14 | 15 | for ( i = 0; i < 3; ++i ) 16 | { 17 | diff = extents->start[i] - extents->end[i]; 18 | 19 | if ( diff == 0.0 ) 20 | delta = 0.0; 21 | else 22 | delta = 1.0 / diff; 23 | 24 | extents->invDelta[i] = delta; 25 | } 26 | } 27 | 28 | /* 29 | =================== 30 | CM_TraceBox 31 | =================== 32 | */ 33 | qboolean CM_TraceBox( TraceExtents *extents, const vec3_t mins, const vec3_t maxs, float fraction ) 34 | { 35 | int i; 36 | float f; 37 | float t2; 38 | float t1; 39 | float s; 40 | float o; 41 | 42 | o = 0.0; 43 | s = -1.0; 44 | 45 | while ( 1 ) 46 | { 47 | for ( i = 0; i < 3; ++i ) 48 | { 49 | t1 = (extents->start[i] - mins[i]) * s; 50 | t2 = (extents->end[i] - mins[i]) * s; 51 | 52 | if ( t1 > 0.0 ) 53 | { 54 | if ( t2 > 0.0 ) 55 | { 56 | return qtrue; 57 | } 58 | 59 | f = t1 * extents->invDelta[i] * s; 60 | 61 | if ( f >= fraction ) 62 | { 63 | return qtrue; 64 | } 65 | 66 | o = I_fmax(o, f); 67 | } 68 | else 69 | { 70 | if ( t2 > 0.0 ) 71 | { 72 | f = t1 * extents->invDelta[i] * s; 73 | 74 | if ( o >= f ) 75 | { 76 | return qtrue; 77 | } 78 | 79 | fraction = I_fmin(fraction, f); 80 | } 81 | } 82 | } 83 | 84 | if ( s == 1.0 ) 85 | { 86 | break; 87 | } 88 | 89 | s = 1.0; 90 | mins = maxs; 91 | } 92 | 93 | return qfalse; 94 | } -------------------------------------------------------------------------------- /src/qcommon/cmd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "qcommon.h" 4 | 5 | // paramters for command buffer stuffing 6 | typedef enum 7 | { 8 | EXEC_NOW, // don't return until completed, a VM should NEVER use this, 9 | // because some commands might cause the VM to be unloaded... 10 | EXEC_INSERT, // insert at current position, but don't run yet 11 | EXEC_APPEND // add to end of the command buffer (normal case) 12 | } cbufExec_t; 13 | 14 | void Cbuf_Init (void); 15 | void Cmd_Init( void ); 16 | void Cmd_Shutdown(); 17 | int Cmd_Argc( void ); 18 | const char *Cmd_Argv( int arg ); 19 | char *Cmd_Args( int start ); 20 | void Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength ); 21 | void Cmd_ForEach( void(*callback)(const char *s) ); 22 | void Cbuf_Execute( void ); 23 | void Cbuf_ExecuteText( int exec_when, const char *text ); 24 | void Cbuf_AddText( const char *text ); 25 | void Cbuf_InsertText( const char *text ); 26 | void Cmd_TokenizeString( const char *text_in ); 27 | void Cmd_ExecuteString( const char *text ); 28 | void Cmd_SetAutoComplete(const char *cmdName, const char *dir, const char *ext); 29 | void Cmd_AddCommand( const char *cmd_name, xcommand_t function ); 30 | void Cmd_RemoveCommand( const char *cmd_name ); 31 | 32 | #define SV_Cmd_Argc Cmd_Argc 33 | #define SV_Cmd_Argv Cmd_Argv 34 | #define SV_Cmd_ArgvBuffer Cmd_ArgvBuffer 35 | #define SV_Cmd_ExecuteString Cmd_ExecuteString 36 | #define SV_Cmd_TokenizeString Cmd_TokenizeString 37 | -------------------------------------------------------------------------------- /src/qcommon/com_bsp_load_obj.cpp: -------------------------------------------------------------------------------- 1 | #include "qcommon.h" 2 | 3 | #define IBSP_VERSION 4 4 | 5 | struct lump_t 6 | { 7 | int filelen; 8 | int fileofs; 9 | }; 10 | 11 | struct dheader_t 12 | { 13 | int ident; 14 | int version; 15 | lump_t lumps[LUMP_COUNT]; 16 | }; 17 | 18 | typedef struct comBspGlob_s 19 | { 20 | dheader_t *header; 21 | int fileSize; 22 | unsigned int checksum; 23 | } comBspGlob_t; 24 | #if defined(__i386__) 25 | static_assert((sizeof(comBspGlob_t) == 0xC), "ERROR: comBspGlob_t size is invalid!"); 26 | #endif 27 | 28 | comBspGlob_t comBspGlob; 29 | 30 | qboolean Com_IsBspLoaded() 31 | { 32 | return comBspGlob.header != NULL; 33 | } 34 | 35 | const char *GetBspExtension() 36 | { 37 | const char *string = Dvar_GetString("gfx_driver"); 38 | 39 | if ( *string ) 40 | return va("%sbsp", string); 41 | 42 | return va("d3dbsp"); 43 | } 44 | 45 | void Com_UnloadBsp() 46 | { 47 | Z_Free(comBspGlob.header); 48 | comBspGlob.header = NULL; 49 | } 50 | 51 | void Com_CleanupBsp() 52 | { 53 | if ( Com_IsBspLoaded() ) 54 | Com_UnloadBsp(); 55 | } 56 | 57 | dheader_t* Com_GetBsp(int *fileSize, unsigned int *checksum) 58 | { 59 | if ( fileSize ) 60 | *fileSize = comBspGlob.fileSize; 61 | 62 | if ( checksum ) 63 | *checksum = comBspGlob.checksum; 64 | 65 | return comBspGlob.header; 66 | } 67 | 68 | byte* Com_ValidateBspLumpData(int type, int offset, int length, int elemSize, int *count) 69 | { 70 | if ( length ) 71 | { 72 | if ( type != LUMP_ENTITIES && length + offset > comBspGlob.fileSize ) 73 | { 74 | Com_Error(ERR_DROP, "CM_LoadMap: lump %i extends past end of file", type); 75 | } 76 | 77 | *count = length / elemSize; 78 | 79 | if ( elemSize * *count != length ) 80 | { 81 | Com_Error(ERR_DROP, "CM_LoadMap: lump %i has funny size", type); 82 | } 83 | 84 | return (byte*)comBspGlob.header + offset; 85 | } 86 | 87 | *count = 0; 88 | return NULL; 89 | } 90 | 91 | byte* Com_GetBspLump(int type, int elemSize, int *count) 92 | { 93 | return Com_ValidateBspLumpData(type, comBspGlob.header->lumps[type].fileofs, comBspGlob.header->lumps[type].filelen, elemSize, count); 94 | } 95 | 96 | bool Com_BspHasLump(int type) 97 | { 98 | int count; 99 | 100 | Com_GetBspLump(type, 1, &count); 101 | 102 | return count != 0; 103 | } 104 | 105 | void Com_LoadBsp(const char *filename) 106 | { 107 | fileHandle_t h; 108 | int bytesRead; 109 | int i; 110 | 111 | comBspGlob.fileSize = FS_FOpenFileRead(filename, &h, 0); 112 | 113 | if ( !h ) 114 | { 115 | Com_Error(ERR_DROP, "EXE_ERR_COULDNT_LOAD\x15%s", filename); 116 | } 117 | 118 | comBspGlob.header = (dheader_t *)Z_MallocGarbage(comBspGlob.fileSize); 119 | bytesRead = FS_Read(comBspGlob.header, comBspGlob.fileSize, h); 120 | FS_FCloseFile(h); 121 | 122 | if ( bytesRead != comBspGlob.fileSize || comBspGlob.fileSize < sizeof(*comBspGlob.header) ) 123 | { 124 | Z_Free(comBspGlob.header); 125 | Com_Error(ERR_DROP, "EXE_ERR_COULDNT_LOAD\x15%s", filename); 126 | } 127 | 128 | comBspGlob.checksum = Com_BlockChecksum(comBspGlob.header, comBspGlob.fileSize); 129 | 130 | comBspGlob.header->ident = LittleLong(comBspGlob.header->ident); 131 | comBspGlob.header->version = LittleLong(comBspGlob.header->version); 132 | 133 | if ( comBspGlob.header->ident != (uint32_t)'PSBI' || comBspGlob.header->version != IBSP_VERSION ) 134 | { 135 | Z_Free(comBspGlob.header); 136 | Com_Error(ERR_DROP, "EXE_ERR_WRONG_MAP_VERSION_NUM\x15%s", filename); 137 | } 138 | 139 | for ( i = 0; i != LUMP_COUNT; ++i ) 140 | { 141 | comBspGlob.header->lumps[i].filelen = LittleLong(comBspGlob.header->lumps[i].filelen); 142 | comBspGlob.header->lumps[i].fileofs = LittleLong(comBspGlob.header->lumps[i].fileofs); 143 | } 144 | } -------------------------------------------------------------------------------- /src/qcommon/netchan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_PACKETLEN 1400 4 | #define FRAGMENT_SIZE ( MAX_PACKETLEN - 100 ) 5 | 6 | struct netProfilePacket_t 7 | { 8 | int iTime; 9 | int iSize; 10 | int bFragment; 11 | }; 12 | 13 | #define MAX_PROFILE_PACKETS 60 14 | struct netProfileStream_t 15 | { 16 | netProfilePacket_t packets[MAX_PROFILE_PACKETS]; 17 | int iCurrPacket; 18 | int iBytesPerSecond; 19 | int iLastBPSCalcTime; 20 | int iCountedPackets; 21 | int iCountedFragments; 22 | int iFragmentPercentage; 23 | int iLargestPacket; 24 | int iSmallestPacket; 25 | }; 26 | 27 | typedef struct netProfileInfo_s 28 | { 29 | netProfileStream_t send; 30 | netProfileStream_t recieve; 31 | } netProfileInfo_t; 32 | #if defined(__i386__) 33 | static_assert((sizeof(netProfileInfo_t) == 0x5E0), "ERROR: netProfileInfo_t size is invalid!"); 34 | #endif 35 | 36 | typedef struct 37 | { 38 | int outgoingSequence; 39 | netsrc_t sock; 40 | int dropped; 41 | int incomingSequence; 42 | netadr_t remoteAddress; 43 | int qport; 44 | int fragmentSequence; 45 | int fragmentLength; 46 | byte fragmentBuffer[MAX_MSGLEN]; 47 | qboolean unsentFragments; 48 | int unsentFragmentStart; 49 | int unsentLength; 50 | byte unsentBuffer[MAX_MSGLEN]; 51 | netProfileInfo_t *pProf; 52 | #ifdef LIBCOD 53 | int protocol; 54 | #endif 55 | } netchan_t; 56 | /* 57 | #if defined(__i386__) 58 | static_assert((sizeof(netchan_t) == 0x8040), "ERROR: netchan_t size is invalid!"); 59 | #endif 60 | */ 61 | 62 | extern dvar_t* net_profile; 63 | extern dvar_t* net_lanauthorize; 64 | 65 | qboolean NET_GetLoopPacket(int sock, netadr_t *net_from, msg_t *net_message); 66 | const char* NET_AdrToString( netadr_t a ); 67 | qboolean NET_StringToAdr( const char *s, netadr_t *a ); 68 | qboolean NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t to ); 69 | qboolean NET_GetPacket(netadr_t *net_from, msg_t *net_message); 70 | void NetProf_PrepProfiling(netProfileInfo_t **prof); 71 | void NetProf_AddPacket(netProfileStream_t *pProfStream, int iSize, int bFragment); 72 | void NetProf_NewSendPacket(netchan_t *chan, int iSize, int bFragment); 73 | void NetProf_NewRecievePacket(netchan_t *chan, int iSize, int bFragment); 74 | void NetProf_UpdateStatistics(netProfileStream_t *pStream); 75 | void SV_Netchan_PrintProfileStats(int bPrintToConsole); 76 | qboolean NET_OutOfBandPrint(netsrc_t sock, netadr_t adr, const char *msg); 77 | void NET_OutOfBandVoiceData( netsrc_t sock, netadr_t adr, byte *data, int len ); 78 | void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport ); 79 | qboolean Netchan_TransmitNextFragment(netchan_t *chan); 80 | qboolean Netchan_Transmit(netchan_t *chan, int length, const byte *data); 81 | qboolean Netchan_Process(netchan_t *chan, msg_t *msg); 82 | qboolean NET_CompareBaseAdr(netadr_t a, netadr_t b); 83 | qboolean NET_CompareAdr(netadr_t a, netadr_t b); 84 | qboolean NET_IsLocalAddress( netadr_t adr ); 85 | void Netchan_Init(); -------------------------------------------------------------------------------- /src/script/scr_evaluate.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | #include "script_public.h" 3 | 4 | /* 5 | ============== 6 | Scr_InitEvaluate 7 | ============== 8 | */ 9 | void Scr_InitEvaluate() 10 | { 11 | scrVarPub.canonicalStrMark = Hunk_SetMark(); 12 | scrCompilePub.archivedCanonicalStringsBuf = (uint16_t *)Hunk_AllocInternal(0x20000); 13 | scrVarPub.canonicalStrCount = 0; 14 | } 15 | 16 | /* 17 | ============== 18 | Scr_EndLoadEvaluate 19 | ============== 20 | */ 21 | void Scr_EndLoadEvaluate() 22 | { 23 | scrCompilePub.archivedCanonicalStringsBuf = 0; 24 | Hunk_ClearHigh(scrVarPub.canonicalStrMark); 25 | } 26 | -------------------------------------------------------------------------------- /src/script/scr_tempmemory.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | #include "script_public.h" 3 | 4 | unsigned int currentPos; 5 | 6 | /* 7 | ============== 8 | Scr_Allign2 9 | ============== 10 | */ 11 | int Scr_Allign2( int pos ) 12 | { 13 | UNIMPLEMENTED(__FUNCTION__); 14 | return 0; 15 | } 16 | 17 | /* 18 | ============== 19 | Scr_Allign4 20 | ============== 21 | */ 22 | int Scr_Allign4( int pos ) 23 | { 24 | UNIMPLEMENTED(__FUNCTION__); 25 | return 0; 26 | } 27 | 28 | /* 29 | ============== 30 | Scr_Allign2Strict 31 | ============== 32 | */ 33 | int Scr_Allign2Strict( int pos ) 34 | { 35 | UNIMPLEMENTED(__FUNCTION__); 36 | return 0; 37 | } 38 | 39 | /* 40 | ============== 41 | Scr_Allign4Strict 42 | ============== 43 | */ 44 | int Scr_Allign4Strict( int pos ) 45 | { 46 | UNIMPLEMENTED(__FUNCTION__); 47 | return 0; 48 | } 49 | 50 | /* 51 | ============== 52 | TempMemoryReset 53 | ============== 54 | */ 55 | void TempMemoryReset() 56 | { 57 | currentPos = 0; 58 | } 59 | 60 | /* 61 | ============== 62 | TempMalloc 63 | ============== 64 | */ 65 | char* TempMalloc( int len ) 66 | { 67 | char *buf = (char *)Hunk_ReallocateTempMemoryInternal( currentPos + len ) + currentPos; 68 | currentPos += len; 69 | 70 | return buf; 71 | } 72 | 73 | /* 74 | ============== 75 | TempMemorySetPos 76 | ============== 77 | */ 78 | void TempMemorySetPos( char *pos ) 79 | { 80 | currentPos -= (char *)TempMalloc( 0 ) - pos; 81 | Hunk_ReallocateTempMemoryInternal( currentPos ); 82 | } 83 | 84 | /* 85 | ============== 86 | TempMallocAlignStrict 87 | ============== 88 | */ 89 | char* TempMallocAlignStrict( int len ) 90 | { 91 | return (char *)TempMalloc( len ); 92 | } 93 | 94 | /* 95 | ============== 96 | TempMallocAlign 97 | ============== 98 | */ 99 | char* TempMallocAlign( int len ) 100 | { 101 | return (char *)TempMalloc( len ); 102 | } 103 | -------------------------------------------------------------------------------- /src/server/sv_net_chan_mp.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | #include "../qcommon/netchan.h" 3 | 4 | /* 5 | ================== 6 | SV_Netchan_UpdateProfileStats 7 | ================== 8 | */ 9 | void SV_Netchan_UpdateProfileStats() 10 | { 11 | client_t *cl; 12 | int i; 13 | 14 | if ( !svs.clients ) 15 | return; 16 | 17 | if ( svs.pOOBProf ) 18 | { 19 | NetProf_UpdateStatistics(&svs.pOOBProf->send); 20 | NetProf_UpdateStatistics(&svs.pOOBProf->recieve); 21 | } 22 | 23 | for (i = 0, cl = svs.clients; i < sv_maxclients->current.integer; ++i, ++cl ) 24 | { 25 | if ( !cl->state ) 26 | continue; 27 | 28 | if ( !cl->netchan.pProf ) 29 | continue; 30 | 31 | NetProf_UpdateStatistics(&cl->netchan.pProf->send); 32 | NetProf_UpdateStatistics(&cl->netchan.pProf->recieve); 33 | } 34 | } 35 | 36 | /* 37 | ================== 38 | SV_Netchan_AddOOBProfilePacket 39 | ================== 40 | */ 41 | void SV_Netchan_AddOOBProfilePacket( int iLength ) 42 | { 43 | if ( net_profile->current.integer ) 44 | { 45 | NetProf_PrepProfiling(&svs.pOOBProf); 46 | NetProf_AddPacket(&svs.pOOBProf->send, iLength, 0); 47 | } 48 | } 49 | 50 | /* 51 | ================== 52 | SV_Netchan_TransmitNextFragment 53 | ================== 54 | */ 55 | bool SV_Netchan_TransmitNextFragment( netchan_t *chan ) 56 | { 57 | return Netchan_TransmitNextFragment(chan); 58 | } 59 | 60 | /* 61 | ================== 62 | SV_Netchan_Transmit 63 | ================== 64 | */ 65 | bool SV_Netchan_Transmit( client_t *client, byte *data, int length ) 66 | { 67 | SV_Netchan_Encode(client, data + SV_ENCODE_START, length - SV_ENCODE_START); 68 | return Netchan_Transmit(&client->netchan, length, data); 69 | } 70 | 71 | /* 72 | ================== 73 | SV_Netchan_PrintProfileStats 74 | ================== 75 | */ 76 | void SV_Netchan_PrintProfileStats( int bPrintToConsole ) 77 | { 78 | UNIMPLEMENTED(__FUNCTION__); 79 | } 80 | 81 | /* 82 | ================== 83 | SV_Netchan_SendOOBPacket 84 | ================== 85 | */ 86 | void SV_Netchan_SendOOBPacket( int iLength, const void *pData, netadr_t to ) 87 | { 88 | if ( *(int *)pData != -1 ) 89 | Com_Printf("SV_Netchan_SendOOBPacket used to send non-OOB packet.\n"); 90 | 91 | NetProf_PrepProfiling(&svs.pOOBProf); 92 | NET_SendPacket(NS_SERVER, iLength, pData, to); 93 | SV_Netchan_AddOOBProfilePacket(iLength); 94 | } 95 | 96 | /* 97 | ============== 98 | SV_Netchan_Encode 99 | 100 | // first four bytes of the data are always: 101 | long reliableAcknowledge; 102 | 103 | ============== 104 | */ 105 | void SV_Netchan_Encode( client_t *client, byte *data, int cursize ) 106 | { 107 | int i, index; 108 | byte key, *string; 109 | 110 | string = (byte *)client->lastClientCommandString; 111 | // xor the client challenge with the netchan sequence number 112 | key = client->challenge ^ client->netchan.outgoingSequence; 113 | 114 | for ( i = 0, index = 0; i < cursize; i++ ) 115 | { 116 | if ( !string[index] ) 117 | { 118 | index = 0; 119 | } 120 | 121 | // modify the key with the last sent and acknowledged server command 122 | key ^= string[index] << ( i & 1 ); 123 | data[i] ^= key; 124 | 125 | index++; 126 | } 127 | } 128 | 129 | /* 130 | ============== 131 | SV_Netchan_Decode 132 | 133 | // first 12 bytes of the data are always: 134 | long serverId; 135 | long messageAcknowledge; 136 | long reliableAcknowledge; 137 | 138 | ============== 139 | */ 140 | void SV_Netchan_Decode( client_t *client, byte *data, int remaining ) 141 | { 142 | int i, index; 143 | byte key, *string; 144 | 145 | string = (byte *)client->reliableCommandInfo[ client->reliableAcknowledge & ( MAX_RELIABLE_COMMANDS - 1 ) ].cmd; 146 | key = client->challenge ^ (byte)client->serverId ^ client->messageAcknowledge; 147 | 148 | for ( i = 0, index = 0; i < remaining; i++ ) 149 | { 150 | if ( !string[index] ) 151 | { 152 | index = 0; 153 | } 154 | 155 | // modify the key with the last sent and acknowledged server command 156 | key ^= string[index] << ( i & 1 ); 157 | data[i] ^= key; 158 | 159 | index++; 160 | } 161 | } -------------------------------------------------------------------------------- /src/server/sv_voice_mp.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | #include "../qcommon/netchan.h" 3 | 4 | /* 5 | ================== 6 | SV_QueueVoicePacket 7 | ================== 8 | */ 9 | void SV_QueueVoicePacket( int talkerNum, int clientNum, VoicePacket_t *voicePacket ) 10 | { 11 | client_t *client; 12 | 13 | assert(talkerNum >= 0 && talkerNum < MAX_CLIENTS); 14 | assert(clientNum >= 0 && clientNum < MAX_CLIENTS); 15 | 16 | client = &svs.clients[clientNum]; 17 | 18 | if ( client->voicePacketCount >= MAX_VOICE_PACKETS ) 19 | { 20 | return; 21 | } 22 | 23 | client->voicePackets[client->voicePacketCount].dataSize = voicePacket->dataSize; 24 | memcpy(client->voicePackets[client->voicePacketCount].data, voicePacket->data, voicePacket->dataSize); 25 | assert(talkerNum == static_cast(talkerNum)); 26 | client->voicePackets[client->voicePacketCount].talker = talkerNum; 27 | client->voicePacketCount++; 28 | } 29 | 30 | /* 31 | ================== 32 | SV_ClientHasClientMuted 33 | ================== 34 | */ 35 | bool SV_ClientHasClientMuted( int listener, int talker ) 36 | { 37 | assert(listener >= 0 && listener < MAX_CLIENTS); 38 | assert(talker >= 0 && talker < MAX_CLIENTS); 39 | return svs.clients[listener].muteList[talker]; 40 | } 41 | 42 | /* 43 | ================== 44 | SV_ClientWantsVoiceData 45 | ================== 46 | */ 47 | bool SV_ClientWantsVoiceData( int clientNum ) 48 | { 49 | assert(clientNum >= 0 && clientNum < MAX_CLIENTS); 50 | return svs.clients[clientNum].sendVoice; 51 | } 52 | 53 | /* 54 | ================== 55 | SV_PreGameUserVoice 56 | ================== 57 | */ 58 | void SV_PreGameUserVoice( client_t *cl, msg_t *msg ) 59 | { 60 | int talker; 61 | int listener; 62 | int packet; 63 | int packetCount; 64 | VoicePacket_t voicePacket; 65 | 66 | if ( !sv_voice->current.boolean ) 67 | { 68 | return; 69 | } 70 | 71 | talker = cl - svs.clients; 72 | assert(talker >= 0 && talker < MAX_CLIENTS); 73 | packetCount = MSG_ReadByte(msg); 74 | 75 | for ( packet = 0; packet < packetCount; packet++ ) 76 | { 77 | voicePacket.dataSize = MSG_ReadShort(msg); 78 | 79 | if ( voicePacket.dataSize <= 0 || voicePacket.dataSize > MAX_VOICE_PACKET_DATA ) 80 | { 81 | Com_Printf("Received invalid voice packet of size %i from %s\n", voicePacket.dataSize, cl->name); 82 | return; 83 | } 84 | 85 | assert(msg->data); 86 | assert(voicePacket.data); 87 | 88 | MSG_ReadData(msg, voicePacket.data, voicePacket.dataSize); 89 | 90 | for ( listener = 0; listener < MAX_CLIENTS; listener++ ) 91 | { 92 | if ( listener == talker ) 93 | continue; 94 | 95 | if ( svs.clients[listener].state < CS_CONNECTED ) 96 | continue; 97 | 98 | if ( SV_ClientHasClientMuted(listener, talker) ) 99 | continue; 100 | 101 | if ( !SV_ClientWantsVoiceData(listener) ) 102 | continue; 103 | 104 | SV_QueueVoicePacket(talker, listener, &voicePacket); 105 | } 106 | } 107 | } 108 | 109 | /* 110 | ================== 111 | SV_UserVoice 112 | ================== 113 | */ 114 | void SV_UserVoice( client_t *cl, msg_t *msg ) 115 | { 116 | int packet; 117 | int packetCount; 118 | VoicePacket_t voicePacket; 119 | 120 | if ( !sv_voice->current.boolean ) 121 | { 122 | return; 123 | } 124 | 125 | packetCount = MSG_ReadByte(msg); 126 | assert(cl->gentity); 127 | 128 | for ( packet = 0; packet < packetCount; packet++ ) 129 | { 130 | voicePacket.dataSize = MSG_ReadByte(msg); 131 | 132 | if ( voicePacket.dataSize <= 0 || voicePacket.dataSize > MAX_VOICE_PACKET_DATA ) 133 | { 134 | Com_Printf("Received invalid voice packet of size %i from %s\n", voicePacket.dataSize, cl->name); 135 | return; 136 | } 137 | 138 | assert(msg->data); 139 | assert(voicePacket.data); 140 | 141 | MSG_ReadData(msg, voicePacket.data, voicePacket.dataSize); 142 | G_BroadcastVoice(cl->gentity, &voicePacket); 143 | } 144 | } 145 | 146 | /* 147 | ================== 148 | SV_WriteClientVoiceData 149 | ================== 150 | */ 151 | void SV_WriteClientVoiceData( client_t *client, msg_t *msg ) 152 | { 153 | int i; 154 | 155 | MSG_WriteByte(msg, client->voicePacketCount); 156 | 157 | for ( i = 0; i < client->voicePacketCount; ++i ) 158 | { 159 | MSG_WriteByte(msg, client->voicePackets[i].talker); 160 | MSG_WriteByte(msg, client->voicePackets[i].dataSize); 161 | MSG_WriteData(msg, client->voicePackets[i].data, client->voicePackets[i].dataSize); 162 | } 163 | } 164 | 165 | /* 166 | ================== 167 | SV_SendClientVoiceData 168 | ================== 169 | */ 170 | void SV_SendClientVoiceData( client_t *client ) 171 | { 172 | byte msg_buf[MAX_VOICE_MSG_LEN]; 173 | msg_t msg; 174 | 175 | assert(client->voicePacketCount >= 0); 176 | 177 | if ( client->state != CS_ACTIVE ) 178 | return; 179 | 180 | if ( !client->voicePacketCount ) 181 | return; 182 | 183 | MSG_Init(&msg, msg_buf, sizeof(msg_buf)); 184 | assert(msg.cursize == 0); 185 | assert(msg.bit == 0); 186 | 187 | MSG_WriteString(&msg, "v"); 188 | SV_WriteClientVoiceData(client, &msg); 189 | 190 | if ( msg.overflowed ) 191 | { 192 | Com_Printf("WARNING: voice msg overflowed for %s\n", client->name); 193 | return; 194 | } 195 | 196 | NET_OutOfBandVoiceData(NS_SERVER, client->netchan.remoteAddress, msg.data, msg.cursize); 197 | client->voicePacketCount = 0; 198 | } -------------------------------------------------------------------------------- /src/stringed/stringed_hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | #include "stringed_public.h" 3 | 4 | dvar_t* loc_language; 5 | dvar_t* loc_forceEnglish; 6 | dvar_t* loc_translate; 7 | dvar_t* loc_warnings; 8 | dvar_t* loc_warningsAsErrors; 9 | 10 | languageInfo_t g_languages[MAX_LANGUAGES] = 11 | { 12 | { "english", 0 }, 13 | { "french", 0 }, 14 | { "german", 0 }, 15 | { "italian", 0 }, 16 | { "spanish", 0 }, 17 | { "british", 0 }, 18 | { "russian", 0 }, 19 | { "polish", 0 }, 20 | { "korean", 0 }, 21 | { "taiwanese", 0 }, 22 | { "japanese", 0 }, 23 | { "chinese", 0 }, 24 | { "thai", 0 }, 25 | { "leet", 0 } 26 | }; 27 | 28 | qboolean SEH_GetLanguageIndexForName(const char* language, int *langindex) 29 | { 30 | int i; 31 | 32 | for(i = 0; i < MAX_LANGUAGES; i++) 33 | { 34 | if(!I_stricmp(language, g_languages[i].pszName)) 35 | { 36 | *langindex = i; 37 | return qtrue; 38 | } 39 | } 40 | return qfalse; 41 | } 42 | 43 | const char *SEH_GetLanguageName(const int iLanguage) 44 | { 45 | if (iLanguage >= 0 && iLanguage < MAX_LANGUAGES) 46 | { 47 | return g_languages[iLanguage].pszName; 48 | } 49 | 50 | return g_languages[0].pszName; 51 | } 52 | 53 | int SEH_GetCurrentLanguage() 54 | { 55 | return loc_language->current.integer; 56 | } 57 | 58 | void SEH_UpdateCurrentLanguage(int langindex) 59 | { 60 | Dvar_SetInt(loc_language, langindex); 61 | } 62 | 63 | void SEH_InitLanguage() 64 | { 65 | loc_language = Dvar_RegisterInt("loc_language", 0, 0, MAX_LANGUAGES - 1, DVAR_ARCHIVE | DVAR_LATCH | DVAR_CHANGEABLE_RESET); 66 | loc_forceEnglish = Dvar_RegisterBool("loc_forceEnglish", false, DVAR_ARCHIVE | DVAR_LATCH | DVAR_CHANGEABLE_RESET); 67 | loc_translate = Dvar_RegisterBool("loc_translate", true, DVAR_LATCH | DVAR_CHANGEABLE_RESET); 68 | loc_warnings = Dvar_RegisterBool("loc_warnings", false, DVAR_CHANGEABLE_RESET); 69 | loc_warningsAsErrors = Dvar_RegisterBool("loc_warningsAsErrors", false, DVAR_CHANGEABLE_RESET); 70 | } -------------------------------------------------------------------------------- /src/stringed/stringed_public.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum msgLocErrType_t 6 | { 7 | LOCMSG_SAFE, 8 | LOCMSG_NOERR, 9 | }; 10 | 11 | enum 12 | { 13 | LANGUAGE_ENGLISH, 14 | LANGUAGE_FRENCH, 15 | LANGUAGE_GERMAN, 16 | LANGUAGE_ITALIAN, 17 | LANGUAGE_SPANISH, 18 | LANGUAGE_BRITISH, 19 | LANGUAGE_RUSSIAN, 20 | LANGUAGE_POLISH, 21 | LANGUAGE_KOREAN, 22 | LANGUAGE_TAIWANESE, 23 | LANGUAGE_JAPANESE, 24 | LANGUAGE_CHINESE, 25 | LANGUAGE_THAI, 26 | LANGUAGE_LEET, 27 | MAX_LANGUAGES, 28 | }; 29 | 30 | struct languageInfo_t 31 | { 32 | const char *pszName; 33 | int bPresent; 34 | }; 35 | 36 | extern dvar_t* loc_language; 37 | extern dvar_t* loc_forceEnglish; 38 | extern dvar_t* loc_translate; 39 | extern dvar_t* loc_warnings; 40 | extern dvar_t* loc_warningsAsErrors; 41 | 42 | qboolean SEH_GetLanguageIndexForName(const char* language, int *langindex); 43 | const char *SEH_GetLanguageName(const int iLanguage); 44 | int SEH_GetCurrentLanguage(); 45 | void SEH_UpdateCurrentLanguage(int langindex); 46 | void SEH_InitLanguage(); -------------------------------------------------------------------------------- /src/ui/keycodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | #ifndef __KEYCODES_H__ 24 | #define __KEYCODES_H__ 25 | 26 | // 27 | // these are the key numbers that should be passed to KeyEvent 28 | // 29 | 30 | // normal keys should be passed as lowercased ascii 31 | 32 | typedef enum { 33 | K_TAB = 9, 34 | K_ENTER = 13, 35 | K_ESCAPE = 27, 36 | K_SPACE = 32, 37 | 38 | K_BACKSPACE = 127, 39 | 40 | K_COMMAND = 128, 41 | K_CAPSLOCK, 42 | K_POWER, 43 | K_PAUSE, 44 | 45 | K_UPARROW, 46 | K_DOWNARROW, 47 | K_LEFTARROW, 48 | K_RIGHTARROW, 49 | 50 | K_ALT, 51 | K_CTRL, 52 | K_SHIFT, 53 | K_INS, 54 | K_DEL, 55 | K_PGDN, 56 | K_PGUP, 57 | K_HOME, 58 | K_END, 59 | 60 | K_F1, 61 | K_F2, 62 | K_F3, 63 | K_F4, 64 | K_F5, 65 | K_F6, 66 | K_F7, 67 | K_F8, 68 | K_F9, 69 | K_F10, 70 | K_F11, 71 | K_F12, 72 | K_F13, 73 | K_F14, 74 | K_F15, 75 | 76 | K_KP_HOME, 77 | K_KP_UPARROW, 78 | K_KP_PGUP, 79 | K_KP_LEFTARROW, 80 | K_KP_5, 81 | K_KP_RIGHTARROW, 82 | K_KP_END, 83 | K_KP_DOWNARROW, 84 | K_KP_PGDN, 85 | K_KP_ENTER, 86 | K_KP_INS, 87 | K_KP_DEL, 88 | K_KP_SLASH, 89 | K_KP_MINUS, 90 | K_KP_PLUS, 91 | K_KP_NUMLOCK, 92 | K_KP_STAR, 93 | K_KP_EQUALS, 94 | 95 | K_MOUSE1, 96 | K_MOUSE2, 97 | K_MOUSE3, 98 | K_MOUSE4, 99 | K_MOUSE5, 100 | 101 | K_MWHEELDOWN, 102 | K_MWHEELUP, 103 | 104 | K_JOY1, 105 | K_JOY2, 106 | K_JOY3, 107 | K_JOY4, 108 | K_JOY5, 109 | K_JOY6, 110 | K_JOY7, 111 | K_JOY8, 112 | K_JOY9, 113 | K_JOY10, 114 | K_JOY11, 115 | K_JOY12, 116 | K_JOY13, 117 | K_JOY14, 118 | K_JOY15, 119 | K_JOY16, 120 | K_JOY17, 121 | K_JOY18, 122 | K_JOY19, 123 | K_JOY20, 124 | K_JOY21, 125 | K_JOY22, 126 | K_JOY23, 127 | K_JOY24, 128 | K_JOY25, 129 | K_JOY26, 130 | K_JOY27, 131 | K_JOY28, 132 | K_JOY29, 133 | K_JOY30, 134 | K_JOY31, 135 | K_JOY32, 136 | 137 | K_AUX1, 138 | K_AUX2, 139 | K_AUX3, 140 | K_AUX4, 141 | K_AUX5, 142 | K_AUX6, 143 | K_AUX7, 144 | K_AUX8, 145 | K_AUX9, 146 | K_AUX10, 147 | K_AUX11, 148 | K_AUX12, 149 | K_AUX13, 150 | K_AUX14, 151 | K_AUX15, 152 | K_AUX16, 153 | 154 | K_LAST_KEY // this had better be <256! 155 | } keyNum_t; 156 | 157 | 158 | // The menu code needs to get both key and char events, but 159 | // to avoid duplicating the paths, the char events are just 160 | // distinguished by or'ing in K_CHAR_FLAG (ugly) 161 | #define K_CHAR_FLAG 1024 162 | 163 | #endif 164 | -------------------------------------------------------------------------------- /src/universal/assertive.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | 3 | static bool shouldQuitOnError = false; 4 | 5 | static void RefreshQuitOnErrorCondition() 6 | { 7 | if ( !Dvar_IsSystemActive() ) 8 | return; 9 | 10 | shouldQuitOnError = Dvar_GetBool("QuitOnError") || Dvar_GetInt("r_vc_compile") == 2; 11 | } 12 | 13 | bool QuitOnError() 14 | { 15 | RefreshQuitOnErrorCondition(); 16 | return shouldQuitOnError; 17 | } 18 | -------------------------------------------------------------------------------- /src/universal/com_files.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../zlib/unzip.h" 4 | 5 | #define MAX_IWDFILES 1024 6 | #define MAX_FILEHASH_SIZE 1024 7 | #define MAX_FILE_HANDLES 64 8 | #define MAX_ZPATH 256 9 | #define NUM_IW_IWDS 25 10 | 11 | #define BASEGAME "main" 12 | #define DEMOGAME "demomain" 13 | 14 | #define CONFIG_NAME "config_mp_server.cfg" 15 | #define DEFAULT_CONFIG "default_mp.cfg" 16 | 17 | enum FsThread 18 | { 19 | FS_THREAD_MAIN = 0x0, 20 | FS_THREAD_STREAM = 0x1, 21 | }; 22 | 23 | enum FsListBehavior 24 | { 25 | FS_LIST_PURE_ONLY = 0x0, 26 | FS_LIST_ALL = 0x1, 27 | }; 28 | 29 | enum fsMode_t 30 | { 31 | FS_READ, 32 | FS_WRITE, 33 | FS_APPEND, 34 | FS_APPEND_SYNC 35 | }; 36 | 37 | struct directory_t 38 | { 39 | char path[MAX_OSPATH]; 40 | char gamedir[MAX_OSPATH]; 41 | }; 42 | 43 | union qfile_gus 44 | { 45 | FILE* o; 46 | unzFile z; 47 | }; 48 | 49 | struct qfile_us 50 | { 51 | qfile_gus file; 52 | qboolean unique; 53 | }; 54 | 55 | struct fileInIwd_t 56 | { 57 | unsigned long pos; 58 | char *name; 59 | fileInIwd_t *next; 60 | }; 61 | 62 | struct iwd_t 63 | { 64 | char iwdFilename[MAX_OSPATH]; 65 | char iwdBasename[MAX_OSPATH]; 66 | char iwdGamename[MAX_OSPATH]; 67 | unzFile handle; 68 | int checksum; 69 | int pure_checksum; 70 | int numFiles; 71 | int referenced; 72 | int hashSize; 73 | fileInIwd_t **hashTable; 74 | fileInIwd_t *buildBuffer; 75 | }; 76 | #if defined(__i386__) 77 | static_assert((sizeof(iwd_t) == 800), "ERROR: iwd_t size is invalid!"); 78 | #endif 79 | 80 | struct fileHandleData_t 81 | { 82 | qfile_us handleFiles; 83 | qboolean handleSync; 84 | int fileSize; 85 | int zipFilePos; 86 | qboolean zipFile; 87 | qboolean streamed; 88 | char name[MAX_ZPATH]; 89 | }; 90 | #if defined(__i386__) 91 | static_assert((sizeof(fileHandleData_t) == 284), "ERROR: fileHandleData_t size is invalid!"); 92 | #endif 93 | 94 | struct searchpath_t 95 | { 96 | searchpath_t *next; 97 | iwd_t *iwd; 98 | directory_t *dir; 99 | qboolean localized; 100 | int language; 101 | }; 102 | #if defined(__i386__) 103 | static_assert((sizeof(searchpath_t) == 20), "ERROR: searchpath_t size is invalid!"); 104 | #endif 105 | 106 | /* 107 | ============== 108 | FileWrapper_Open 109 | ============== 110 | */ 111 | inline FILE *FileWrapper_Open(const char *ospath, const char *mode) 112 | { 113 | FILE* file; 114 | 115 | file = fopen(ospath, mode); 116 | 117 | if (file != (FILE*)-1) 118 | { 119 | return file; 120 | } 121 | 122 | return 0; 123 | } 124 | 125 | /* 126 | ============== 127 | FileWrapper_Seek 128 | ============== 129 | */ 130 | inline int FileWrapper_Seek(FILE *h, int offset, int origin) 131 | { 132 | switch (origin) 133 | { 134 | case SEEK_SET: 135 | return fseek(h, offset, SEEK_SET); 136 | case SEEK_CUR: 137 | return fseek(h, offset, SEEK_CUR); 138 | case SEEK_END: 139 | return fseek(h, offset, SEEK_END); 140 | } 141 | 142 | return 0; 143 | } 144 | 145 | /* 146 | ============== 147 | FileWrapper_GetFileSize 148 | ============== 149 | */ 150 | inline int FileWrapper_GetFileSize(FILE *h) 151 | { 152 | int startPos; 153 | int fileSize; 154 | 155 | startPos = ftell(h); 156 | fseek(h, 0, SEEK_END); 157 | 158 | fileSize = ftell(h); 159 | fseek(h, startPos, SEEK_SET); 160 | 161 | return fileSize; 162 | } 163 | 164 | extern dvar_t* fs_ignoreLocalized; 165 | extern int fs_numServerIwds; 166 | 167 | bool FS_Initialized(); 168 | long FS_HashFileName( const char *fname, int hashSize ); 169 | int FS_Seek(int f, int offset, int origin); 170 | int FS_Read(void *buffer, int len, fileHandle_t h); 171 | int FS_ReadFile(const char* qpath, void** buffer); 172 | void FS_FreeFile(void* buffer); 173 | fileHandle_t FS_FOpenFileWrite(const char *filename); 174 | fileHandle_t FS_FOpenTextFileWrite(const char* filename); 175 | fileHandle_t FS_FOpenFileAppend(const char *filename); 176 | int FS_FOpenFileByMode(const char *qpath, fileHandle_t *f, fsMode_t mode); 177 | void FS_Printf( fileHandle_t h, const char *fmt, ... ); 178 | void FS_Flush(fileHandle_t f); 179 | int FS_Write(const void *buffer, int len, fileHandle_t h); 180 | void FS_FCloseFile( fileHandle_t f ); 181 | void FS_Shutdown(); 182 | void FS_InitFilesystem(); 183 | int FS_LoadStack(); 184 | void FS_ShutdownServerIwdNames(); 185 | void FS_ShutdownServerReferencedIwds(); 186 | void FS_PureServerSetLoadedIwds(const char *paksums, const char *paknames); 187 | int FS_FOpenFileRead(const char *filename, fileHandle_t *file, qboolean uniqueFILE); 188 | int FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ); 189 | int FS_SV_FOpenFileWrite( const char *filename ); 190 | void FS_AddIwdFilesForGameDirectory(const char *path, const char *dir); 191 | int FS_GetFileList(const char *path, const char *extension, FsListBehavior behavior, char *listbuf, int bufsize); 192 | char** FS_ListFiles(const char* path, const char* extension, FsListBehavior behavior, int* numfiles); 193 | void FS_FreeFileList( char **list ); 194 | void FS_ConvertPath(char *s); 195 | int FS_WriteFile(const char* filename, const void* buffer, int size); 196 | qboolean FS_iwIwd(char *iwd, const char *base); 197 | const char *FS_LoadedIwdNames(); 198 | const char *FS_ReferencedIwdNames(); 199 | const char *FS_ReferencedIwdChecksums(); 200 | const char *FS_LoadedIwdChecksums(); 201 | const char *FS_LoadedIwdPureChecksums(); 202 | qboolean FS_VerifyIwd( const char *iwd ); 203 | char *FS_GetMapBaseName(const char *mapname); 204 | void FS_ClearIwdReferences(); 205 | void FS_Restart(int checksumFeed); 206 | void FS_ResetFiles(); -------------------------------------------------------------------------------- /src/universal/com_memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../qcommon/qcommon.h" 4 | #include "../xanim/xanim_public.h" 5 | 6 | #define PAD(base, alignment) (((base)+(alignment)-1) & ~((alignment)-1)) 7 | #define PADP(base, alignment) ((void *) PAD((intptr_t) (base), (alignment))) 8 | 9 | #define Com_Memset memset 10 | #define Com_Memcpy memcpy 11 | #define Com_Memcmp memcmp 12 | 13 | #define HUNK_MAGIC 0x89537892 14 | #define HUNK_FREE_MAGIC 0x89537893 15 | 16 | #define FILEDATA_HASH_SIZE 1024 17 | 18 | typedef struct 19 | { 20 | int permanent; 21 | int temp; 22 | } hunkUsed_t; 23 | 24 | struct hunkHeader_t 25 | { 26 | unsigned int magic; 27 | int size; 28 | const char *name; 29 | int dummy; 30 | }; 31 | 32 | #pragma pack(push) 33 | #pragma pack(1) 34 | typedef struct fileData_s 35 | { 36 | void *data; 37 | fileData_s *next; 38 | unsigned char type; 39 | char name[1]; 40 | } fileData_t; 41 | #pragma pack(pop) 42 | 43 | enum filedata_type_t 44 | { 45 | FILEDATA_AITYPE, 46 | FILEDATA_XMODELPIECES, 47 | FILEDATA_XMODELSURFS, 48 | FILEDATA_XMODELPARTS, 49 | FILEDATA_XMODEL, 50 | FILEDATA_XANIM, 51 | FILEDATA_XANIMLIST, 52 | FILEDATA_STRINGTABLE, 53 | FILEDATA_VEHICLEDEF 54 | }; 55 | 56 | void *Z_TryMallocInternal( int size ); 57 | void *Z_MallocInternal( int size ); 58 | void *Z_MallocGarbageInternal( int size ); 59 | void Z_FreeInternal( void *ptr ); 60 | char* CopyStringInternal(const char *in); 61 | void* Hunk_FindDataForFile(int type, const char *name); 62 | void Hunk_OverrideDataForFile(int type, const char *name, void *data); 63 | void Hunk_AddData(unsigned char type, void *data, void *(*alloc)(int)); 64 | const char* Hunk_SetDataForFile(int type, const char *name, void *data, void *(*alloc)(int)); 65 | qboolean Hunk_DataOnHunk(void *data); 66 | void FreeStringInternal(char *str); 67 | void* Hunk_AllocAlignInternal(int size, int aligment); 68 | void *Hunk_AllocInternal( int size ); 69 | void* Hunk_AllocateTempMemoryInternal(int size); 70 | void* Hunk_AllocateTempMemoryHighInternal(int size); 71 | void* Hunk_AllocLowAlignInternal(int size, int aligment); 72 | void* Hunk_AllocLowInternal(int n); 73 | void Hunk_ConvertTempToPermLowInternal(); 74 | void* Hunk_ReallocateTempMemoryInternal(int size); 75 | void Hunk_FreeTempMemory(void* buf); 76 | void Hunk_ClearData(); 77 | void DB_EnumXAssets(XAssetType type, void (*func)(struct XAssetHeader, void *), void *inData, bool includeOverride); 78 | void Hunk_ClearTempMemoryInternal(); 79 | void Hunk_ClearTempMemoryHighInternal(); 80 | void Hunk_ClearHigh(int memory); 81 | void Hunk_ClearLow(int memory); 82 | void Hunk_Clear(); 83 | int Hunk_SetMark(); 84 | void Hunk_ClearTempMemoryHigh(); 85 | void Hunk_Shutdown(); 86 | char* TempMalloc(int size); 87 | char* TempMallocAlign(int size); 88 | char* TempMallocAlignStrict(int size); 89 | void TempMemorySetPos(char *pos); 90 | void TempMemoryReset(); 91 | int Hunk_HideTempMemory(); 92 | void Hunk_ShowTempMemory(int memory); 93 | void Com_InitHunkMemory( void ); 94 | 95 | #define Z_Malloc Z_MallocInternal 96 | #define S_Malloc Z_MallocInternal 97 | #define Z_MallocGarbage Z_MallocGarbageInternal 98 | #define Z_Free Z_FreeInternal 99 | 100 | #define Hunk_Alloc Hunk_AllocInternal 101 | #define Hunk_AllocateTempMemory Hunk_AllocateTempMemoryInternal 102 | 103 | #define CopyString CopyStringInternal 104 | #define FreeString FreeStringInternal 105 | -------------------------------------------------------------------------------- /src/universal/surfaceflags.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define SURF_START_BIT 20 4 | #define SURF_TYPEINDEX( x ) ( ( x >> ( SURF_START_BIT ) ) & 0x1f ) 5 | #define SURF_INVALID -1 6 | 7 | enum 8 | { 9 | SURF_TYPE_NONE, 10 | SURF_TYPE_BARK, 11 | SURF_TYPE_BRICK, 12 | SURF_TYPE_CARPET, 13 | SURF_TYPE_CLOTH, 14 | SURF_TYPE_CONCRETE, 15 | SURF_TYPE_DIRT, 16 | SURF_TYPE_FLESH, 17 | SURF_TYPE_FOLIAGE, 18 | SURF_TYPE_GLASS, 19 | SURF_TYPE_GRASS, 20 | SURF_TYPE_GRAVEL, 21 | SURF_TYPE_ICE, 22 | SURF_TYPE_METAL, 23 | SURF_TYPE_MUD, 24 | SURF_TYPE_PAPER, 25 | SURF_TYPE_PLASTER, 26 | SURF_TYPE_ROCK, 27 | SURF_TYPE_SAND, 28 | SURF_TYPE_SNOW, 29 | SURF_TYPE_WATER, 30 | SURF_TYPE_WOOD, 31 | SURF_TYPE_ASPHALT, 32 | SURF_TYPECOUNT 33 | }; 34 | 35 | #define SURF_NODAMAGE 0x00000001 36 | #define SURF_SLICK 0x00000002 37 | #define SURF_SKY 0x00000004 38 | #define SURF_LADDER 0x00000008 39 | #define SURF_NOIMPACT 0x00000010 40 | #define SURF_NOMARKS 0x00000020 41 | #define SURF_NODRAW 0x00000080 42 | #define SURF_HINT 0x00000100 43 | #define SURF_SKIP 0x00000200 44 | #define SURF_NOLIGHTMAP 0x00000400 45 | #define SURF_POINTLIGHT 0x00000800 46 | #define SURF_NOSTEPS 0x00002000 47 | #define SURF_NONSOLID 0x00004000 48 | #define SURF_ALPHASHADOW 0x00010000 49 | #define SURF_NODLIGHT 0x00020000 50 | #define SURF_NOCASTSHADOW 0x00040000 51 | #define SURF_BARK 0x00100000 52 | #define SURF_BRICK 0x00200000 53 | #define SURF_CARPET 0x00300000 54 | #define SURF_CLOTH 0x00400000 55 | #define SURF_CONCRETE 0x00500000 56 | #define SURF_DIRT 0x00600000 57 | #define SURF_FLESH 0x00700000 58 | #define SURF_FOLIAGE 0x00800000 59 | #define SURF_GLASS 0x00900000 60 | #define SURF_GRASS 0x00A00000 61 | #define SURF_GRAVEL 0x00B00000 62 | #define SURF_ICE 0x00C00000 63 | #define SURF_METAL 0x00D00000 64 | #define SURF_MUD 0x00E00000 65 | #define SURF_PAPER 0x00F00000 66 | #define SURF_PLASTER 0x01000000 67 | #define SURF_ROCK 0x01100000 68 | #define SURF_SAND 0x01200000 69 | #define SURF_SNOW 0x01300000 70 | #define SURF_WATER 0x01400000 71 | #define SURF_WOOD 0x01500000 72 | #define SURF_ASPHALT 0x01600000 73 | #define SURF_MANTLEON 0x02000000 74 | #define SURF_MANTLEOVER 0x04000000 75 | #define SURF_PORTAL 0x80000000 76 | 77 | #define SURF_OPAQUEGLASS SURF_GLASS 78 | 79 | #define CONTENTS_NONE 0x00000000 80 | #define CONTENTS_SOLID 0x00000001 81 | #define CONTENTS_FOILAGE 0x00000002 82 | #define CONTENTS_NONCOLLIDING 0x00000004 83 | #define CONTENTS_LAVA 0x00000008 84 | #define CONTENTS_GLASS 0x00000010 85 | #define CONTENTS_WATER 0x00000020 86 | #define CONTENTS_CANSHOTCLIP 0x00000040 87 | #define CONTENTS_MISSILECLIP 0x00000080 88 | #define CONTENTS_UNKNOWNCLIP 0x00000100 89 | #define CONTENTS_VEHICLECLIP 0x00000200 90 | #define CONTENTS_ITEMCLIP 0x00000400 91 | #define CONTENTS_SKY 0x00000800 92 | #define CONTENTS_AI_NOSIGHT 0x00001000 93 | #define CONTENTS_CLIPSHOT 0x00002000 94 | #define CONTENTS_MOVER 0x00004000 95 | #define CONTENTS_AREAPORTAL 0x00008000 96 | #define CONTENTS_PLAYERCLIP 0x00010000 97 | #define CONTENTS_MONSTERCLIP 0x00020000 98 | #define CONTENTS_TELEPORTER 0x00040000 99 | #define CONTENTS_JUMPPAD 0x00080000 100 | #define CONTENTS_CLUSTERPORTAL 0x00100000 101 | #define CONTENTS_DONOTENTER 0x00200000 102 | #define CONTENTS_DONOTENTER_LARGE 0x00400000 103 | #define CONTENTS_UNKNOWN 0x00800000 104 | #define CONTENTS_MANTLE 0x01000000 105 | #define CONTENTS_BODY 0x02000000 106 | #define CONTENTS_CORPSE 0x04000000 107 | #define CONTENTS_DETAIL 0x08000000 108 | #define CONTENTS_STRUCTURAL 0x10000000 109 | #define CONTENTS_TRANSLUCENT 0x20000000 110 | #define CONTENTS_TRIGGER 0x40000000 111 | #define CONTENTS_NODROP 0x80000000 112 | 113 | #define TOOL_OCCLUDER 0x00000001 114 | #define TOOL_DRAWTOGGLE 0x00000002 115 | #define TOOL_ORIGIN 0x00000004 116 | #define TOOL_RADIALNORMALS 0x00000008 117 | 118 | #define MASK_ALL ( -1 ) 119 | #define MASK_SOLID ( CONTENTS_SOLID | CONTENTS_GLASS | CONTENTS_SKY ) 120 | #define MASK_PLAYERSOLID ( CONTENTS_SOLID | CONTENTS_GLASS | CONTENTS_PLAYERCLIP | CONTENTS_UNKNOWN | CONTENTS_BODY ) 121 | 122 | #define MASK_SHOT ( CONTENTS_SOLID | CONTENTS_GLASS | CONTENTS_WATER | CONTENTS_SKY | CONTENTS_CLIPSHOT | CONTENTS_UNKNOWN | CONTENTS_BODY ) 123 | #define MASK_MISSILESHOT ( MASK_SHOT | CONTENTS_MISSILECLIP ) 124 | -------------------------------------------------------------------------------- /src/universal/universal_public.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "q_shared.h" 4 | #include "dvar.h" 5 | #include "com_files.h" 6 | #include "com_math.h" 7 | #include "com_memory.h" 8 | #include "surfaceflags.h" 9 | 10 | // Assertive 11 | bool QuitOnError(); -------------------------------------------------------------------------------- /src/unix/linux_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // linux_local.h: Linux-specific Quake3 header file 23 | 24 | void Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr ); 25 | qboolean Sys_GetPacket ( netadr_t *net_from, msg_t *net_message ); 26 | void Sys_SendKeyEvents (void); 27 | 28 | // Input subsystem 29 | 30 | void IN_Init (void); 31 | void IN_Frame (void); 32 | void IN_Shutdown (void); 33 | 34 | 35 | void IN_JoyMove( void ); 36 | void IN_StartupJoystick( void ); 37 | 38 | // GL subsystem 39 | qboolean QGL_Init( const char *dllname ); 40 | void QGL_EnableLogging( qboolean enable ); 41 | void QGL_Shutdown( void ); 42 | 43 | // bk001130 - win32 44 | // void IN_JoystickCommands (void); 45 | 46 | char *strlwr (char *s); 47 | 48 | // signals.c 49 | void InitSig(void); 50 | -------------------------------------------------------------------------------- /src/unix/unix_main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voron00/CoD2rev_Server/2cb7c9878cfef610920f96c20c35cc61a2e460cb/src/unix/unix_main.cpp -------------------------------------------------------------------------------- /src/unix/unix_threads.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "../qcommon/qcommon.h" 24 | #include "linux_local.h" 25 | #include 26 | #include 27 | 28 | threadid_t mainthread; 29 | void *g_threadValues[THREAD_VALUE_COUNT]; 30 | 31 | /* 32 | ================ 33 | Sys_InitializeCriticalSections 34 | ================ 35 | */ 36 | static pthread_mutex_t crit_sections[CRITSECT_COUNT]; 37 | static void Sys_InitializeCriticalSections( void ) 38 | { 39 | int i; 40 | pthread_mutexattr_t muxattr; 41 | 42 | pthread_mutexattr_init(&muxattr); 43 | pthread_mutexattr_settype(&muxattr, PTHREAD_MUTEX_RECURSIVE); 44 | 45 | for (i = 0; i < CRITSECT_COUNT; i++) 46 | { 47 | pthread_mutex_init( &crit_sections[i], &muxattr ); 48 | 49 | } 50 | 51 | pthread_mutexattr_destroy(&muxattr); 52 | } 53 | 54 | /* 55 | ================ 56 | Sys_InitMainThread 57 | ================ 58 | */ 59 | void Sys_InitMainThread() 60 | { 61 | Sys_InitializeCriticalSections(); 62 | mainthread = pthread_self(); 63 | Com_InitThreadData(THREAD_CONTEXT_MAIN); 64 | } 65 | 66 | /* 67 | ================ 68 | Sys_IsMainThread 69 | ================ 70 | */ 71 | qboolean Sys_IsMainThread( void ) 72 | { 73 | return mainthread == pthread_self(); 74 | } 75 | 76 | /* 77 | ================ 78 | Sys_SetValue 79 | ================ 80 | */ 81 | void Sys_SetValue( int valueIndex, void *data ) 82 | { 83 | g_threadValues[valueIndex] = data; 84 | } 85 | 86 | /* 87 | ================ 88 | Sys_GetValue 89 | ================ 90 | */ 91 | void* Sys_GetValue( int valueIndex ) 92 | { 93 | return g_threadValues[valueIndex]; 94 | } 95 | 96 | /* 97 | ================ 98 | Sys_CreateNewThread 99 | ================ 100 | */ 101 | #define MIN_STACKSIZE 256*1024 102 | qboolean Sys_CreateNewThread(void* (*ThreadMain)(void*), threadid_t *tid, void* arg) 103 | { 104 | int err; 105 | pthread_attr_t tattr; 106 | 107 | err = pthread_attr_init(&tattr); 108 | if(err != 0) 109 | { 110 | Com_Printf("pthread_attr_init(): Thread creation failed with the following error: %s\n", strerror(errno)); 111 | return qfalse; 112 | } 113 | 114 | err = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); 115 | if(err != 0) 116 | { 117 | pthread_attr_destroy(&tattr); 118 | Com_Printf("pthread_attr_setdetachstate(): Thread creation failed with the following error: %s\n", strerror(errno)); 119 | return qfalse; 120 | } 121 | 122 | err = pthread_attr_setstacksize(&tattr, MIN_STACKSIZE); 123 | if(err != 0) 124 | { 125 | pthread_attr_destroy(&tattr); 126 | Com_Printf("pthread_attr_setstacksize(): Thread creation failed with the following error: %s\n", strerror(errno)); 127 | return qfalse; 128 | } 129 | 130 | err = pthread_create(tid, &tattr, ThreadMain, arg); 131 | if(err != 0) 132 | { 133 | pthread_attr_destroy(&tattr); 134 | Com_Printf("pthread_create(): Thread creation failed with the following error: %s\n", strerror(errno)); 135 | return qfalse; 136 | } 137 | pthread_attr_destroy(&tattr); 138 | return qtrue; 139 | } 140 | 141 | /* 142 | ================ 143 | Sys_ExitThread 144 | ================ 145 | */ 146 | void Sys_ExitThread(int code) 147 | { 148 | pthread_exit(&code); 149 | } 150 | 151 | /* 152 | ================ 153 | Sys_SleepMSec 154 | ================ 155 | */ 156 | void Sys_SleepMSec(int msec) 157 | { 158 | struct timespec ts; 159 | ts.tv_sec = msec / 1000; 160 | ts.tv_nsec = (msec % 1000) * 1000000; 161 | nanosleep(&ts, NULL); 162 | } 163 | 164 | /* 165 | ================ 166 | Sys_EnterCriticalSection 167 | ================ 168 | */ 169 | void Sys_EnterCriticalSection(int section) 170 | { 171 | pthread_mutex_lock(&crit_sections[section]); 172 | } 173 | 174 | /* 175 | ================ 176 | Sys_TryEnterCriticalSection 177 | ================ 178 | */ 179 | int Sys_TryEnterCriticalSection(int section) 180 | { 181 | return pthread_mutex_trylock(&crit_sections[section]); 182 | } 183 | 184 | /* 185 | ================ 186 | Sys_LeaveCriticalSection 187 | ================ 188 | */ 189 | void Sys_LeaveCriticalSection(int section) 190 | { 191 | pthread_mutex_unlock(&crit_sections[section]); 192 | } 193 | -------------------------------------------------------------------------------- /src/win32/cod2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voron00/CoD2rev_Server/2cb7c9878cfef610920f96c20c35cc61a2e460cb/src/win32/cod2.ico -------------------------------------------------------------------------------- /src/win32/codlogo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voron00/CoD2rev_Server/2cb7c9878cfef610920f96c20c35cc61a2e460cb/src/win32/codlogo.bmp -------------------------------------------------------------------------------- /src/win32/resource.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | //{{NO_DEPENDENCIES}} 23 | // Microsoft Developer Studio generated include file. 24 | // Used by winquake.rc 25 | // 26 | #define IDS_STRING1 1 27 | #define IDI_ICON1 1 28 | #define IDB_BITMAP1 1 29 | #define IDB_BITMAP2 128 30 | #define IDC_CURSOR1 129 31 | #define IDC_CURSOR2 130 32 | #define IDC_CURSOR3 131 33 | 34 | // Next default values for new objects 35 | // 36 | #ifdef APSTUDIO_INVOKED 37 | #ifndef APSTUDIO_READONLY_SYMBOLS 38 | #define _APS_NO_MFC 1 39 | #define _APS_NEXT_RESOURCE_VALUE 132 40 | #define _APS_NEXT_COMMAND_VALUE 40001 41 | #define _APS_NEXT_CONTROL_VALUE 1005 42 | #define _APS_NEXT_SYMED_VALUE 101 43 | #endif 44 | #endif 45 | -------------------------------------------------------------------------------- /src/win32/win_cod2.rc: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Icon 4 | // 5 | 6 | #define IDS_STRING1 1 7 | #define IDI_ICON1 1 8 | #define IDB_BITMAP1 1 9 | 10 | // Icon with lowest ID value placed first to ensure application icon 11 | // remains consistent on all systems. 12 | IDI_ICON1 ICON DISCARDABLE "cod2.ico" 13 | IDI_ICON1 BITMAP DISCARDABLE "codlogo.bmp" 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // 17 | // String Table 18 | // 19 | 20 | STRINGTABLE DISCARDABLE 21 | BEGIN 22 | IDS_STRING1 "Call of Duty" 23 | END -------------------------------------------------------------------------------- /src/win32/win_input.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // win_input.c -- win32 mouse and joystick code 23 | // 02/21/97 JCB Added extended DirectInput code to support external controllers. 24 | 25 | #include "win_local.h" 26 | #include "../ui/keycodes.h" 27 | 28 | dvar_t *in_mouse; 29 | 30 | /* 31 | =========== 32 | IN_Startup 33 | =========== 34 | */ 35 | void IN_Startup( void ) 36 | { 37 | } 38 | 39 | /* 40 | =========== 41 | IN_Shutdown 42 | =========== 43 | */ 44 | void IN_Shutdown( void ) 45 | { 46 | } 47 | 48 | 49 | /* 50 | =========== 51 | IN_Init 52 | =========== 53 | */ 54 | void IN_Init( void ) 55 | { 56 | in_mouse = Dvar_RegisterBool("in_mouse", 1, DVAR_ARCHIVE | DVAR_LATCH | DVAR_CHANGEABLE_RESET); 57 | 58 | if ( !in_mouse->current.boolean ) 59 | { 60 | Com_Printf("Mouse control not active.\n"); 61 | } 62 | 63 | Dvar_ClearModified(in_mouse); 64 | } 65 | 66 | /* 67 | =========== 68 | IN_MouseEvent 69 | =========== 70 | */ 71 | void IN_MouseEvent (int mstate) 72 | { 73 | } 74 | 75 | 76 | /* 77 | =========== 78 | IN_Activate 79 | 80 | Called when the main window gains or loses focus. 81 | The window may have been destroyed and recreated 82 | between a deactivate and an activate. 83 | =========== 84 | */ 85 | void IN_Activate (qboolean active) 86 | { 87 | } 88 | 89 | 90 | /* 91 | ================== 92 | IN_Frame 93 | 94 | Called every frame, even if not generating commands 95 | ================== 96 | */ 97 | void IN_Frame (void) 98 | { 99 | } 100 | 101 | 102 | /* 103 | =================== 104 | IN_ClearStates 105 | =================== 106 | */ 107 | void IN_ClearStates (void) 108 | { 109 | } 110 | -------------------------------------------------------------------------------- /src/win32/win_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // win_local.h: Win32-specific Quake3 header file 23 | 24 | #include "../qcommon/qcommon.h" 25 | 26 | #if defined (_MSC_VER) && (_MSC_VER >= 1200) 27 | #pragma warning(disable : 4201) 28 | #pragma warning( push ) 29 | #endif 30 | #include 31 | #if defined (_MSC_VER) && (_MSC_VER >= 1200) 32 | #pragma warning( pop ) 33 | #endif 34 | 35 | #define DIRECTSOUND_VERSION 0x0300 36 | #define DIRECTINPUT_VERSION 0x0300 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | void IN_MouseEvent (int mstate); 44 | 45 | void Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr ); 46 | 47 | void Sys_CreateConsole( void ); 48 | void Sys_DestroyConsole( void ); 49 | 50 | char *Sys_ConsoleInput (void); 51 | 52 | qboolean Sys_GetPacket ( netadr_t *net_from, msg_t *net_message ); 53 | 54 | // Input subsystem 55 | 56 | void IN_Init (void); 57 | void IN_Shutdown (void); 58 | void IN_JoystickCommands (void); 59 | 60 | void IN_Move (usercmd_t *cmd); 61 | // add additional non keyboard / non mouse movement on top of the keyboard move cmd 62 | 63 | void IN_DeactivateWin32Mouse( void); 64 | 65 | void IN_Activate (qboolean active); 66 | void IN_Frame (void); 67 | 68 | // window procedure 69 | LONG WINAPI MainWndProc ( 70 | HWND hWnd, 71 | UINT uMsg, 72 | WPARAM wParam, 73 | LPARAM lParam); 74 | 75 | void Conbuf_AppendText( const char *msg ); 76 | 77 | void SNDDMA_Activate( void ); 78 | int SNDDMA_InitDS (); 79 | 80 | typedef struct 81 | { 82 | 83 | HINSTANCE reflib_library; // Handle to refresh DLL 84 | qboolean reflib_active; 85 | 86 | HWND hWnd; 87 | HINSTANCE hInstance; 88 | qboolean activeApp; 89 | qboolean isMinimized; 90 | OSVERSIONINFO osversion; 91 | 92 | // when we get a windows message, we store the time off so keyboard processing 93 | // can know the exact time of an event 94 | unsigned sysMsgTime; 95 | } WinVars_t; 96 | 97 | extern WinVars_t g_wv; 98 | -------------------------------------------------------------------------------- /src/win32/win_shared.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "../qcommon/qcommon.h" 24 | #include "win_local.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /* 36 | ================ 37 | Sys_Milliseconds 38 | ================ 39 | */ 40 | int sys_timeBase; 41 | int Sys_Milliseconds (void) 42 | { 43 | int sys_curtime; 44 | static qboolean initialized = qfalse; 45 | 46 | if (!initialized) { 47 | sys_timeBase = timeGetTime(); 48 | initialized = qtrue; 49 | } 50 | sys_curtime = timeGetTime() - sys_timeBase; 51 | 52 | return sys_curtime; 53 | } 54 | 55 | int Sys_GetProcessorId( void ) 56 | { 57 | return CPUID_GENERIC; 58 | } 59 | 60 | const char *Sys_GetCurrentUser( void ) 61 | { 62 | static char s_userName[1024]; 63 | unsigned long size = sizeof( s_userName ); 64 | 65 | 66 | if ( !GetUserName( s_userName, &size ) ) 67 | strcpy( s_userName, "player" ); 68 | 69 | if ( !s_userName[0] ) 70 | { 71 | strcpy( s_userName, "player" ); 72 | } 73 | 74 | return s_userName; 75 | } 76 | 77 | const char *Sys_DefaultHomePath(void) { 78 | return NULL; 79 | } 80 | 81 | char *Sys_DefaultInstallPath(void) 82 | { 83 | return Sys_Cwd(); 84 | } 85 | 86 | void Sys_SnapVector(vec3_t v) 87 | { 88 | v[0] = rint(v[0]); 89 | v[1] = rint(v[1]); 90 | v[2] = rint(v[2]); 91 | } 92 | 93 | qboolean Sys_DirectoryHasContents(const char *dir) 94 | { 95 | DIR *hdir; 96 | struct dirent *hfiles; 97 | 98 | hdir = opendir(dir); 99 | 100 | if ( hdir ) 101 | { 102 | hfiles = readdir(hdir); 103 | while ( hfiles ) 104 | { 105 | if ( hfiles->d_reclen != 4 || hfiles->d_name[0] != '.' ) 106 | { 107 | closedir(hdir); 108 | return qtrue; 109 | } 110 | hfiles = readdir(hdir); 111 | } 112 | closedir(hdir); 113 | } 114 | 115 | return qfalse; 116 | } 117 | 118 | -------------------------------------------------------------------------------- /src/win32/win_threads.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, 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 Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "../qcommon/qcommon.h" 24 | #include "win_local.h" 25 | #include 26 | 27 | threadid_t mainthread; 28 | void *g_threadValues[THREAD_VALUE_COUNT]; 29 | 30 | /* 31 | ================ 32 | Sys_InitializeCriticalSections 33 | ================ 34 | */ 35 | static CRITICAL_SECTION crit_sections[CRITSECT_COUNT]; 36 | static void Sys_InitializeCriticalSections( void ) 37 | { 38 | int i; 39 | 40 | for (i = 0; i < CRITSECT_COUNT; i++) 41 | { 42 | InitializeCriticalSection( &crit_sections[i] ); 43 | } 44 | } 45 | 46 | /* 47 | ================ 48 | Sys_InitMainThread 49 | ================ 50 | */ 51 | void Sys_InitMainThread() 52 | { 53 | Sys_InitializeCriticalSections(); 54 | mainthread = GetCurrentThreadId(); 55 | Com_InitThreadData(THREAD_CONTEXT_MAIN); 56 | } 57 | 58 | /* 59 | ================ 60 | Sys_IsMainThread 61 | ================ 62 | */ 63 | qboolean Sys_IsMainThread( void ) 64 | { 65 | return mainthread == GetCurrentThreadId(); 66 | } 67 | 68 | /* 69 | ================ 70 | Sys_SetValue 71 | ================ 72 | */ 73 | void Sys_SetValue( int valueIndex, void *data ) 74 | { 75 | g_threadValues[valueIndex] = data; 76 | } 77 | 78 | /* 79 | ================ 80 | Sys_GetValue 81 | ================ 82 | */ 83 | void* Sys_GetValue( int valueIndex ) 84 | { 85 | return g_threadValues[valueIndex]; 86 | } 87 | 88 | HANDLE Sys_CreateThreadWithHandle(void* (*ThreadMain)(void*), threadid_t *tid, void* arg) 89 | { 90 | char errMessageBuf[512]; 91 | DWORD lastError; 92 | 93 | 94 | HANDLE thid = CreateThread( NULL, // LPSECURITY_ATTRIBUTES lpsa, 95 | 0, // DWORD cbStack, 96 | (LPTHREAD_START_ROUTINE)ThreadMain, // LPTHREAD_START_ROUTINE lpStartAddr, 97 | arg, // LPVOID lpvThreadParm, 98 | 0, // DWORD fdwCreate, 99 | tid ); 100 | 101 | if(thid == NULL) 102 | { 103 | lastError = GetLastError(); 104 | 105 | if(lastError != 0) 106 | { 107 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, lastError, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPSTR)errMessageBuf, sizeof(errMessageBuf) -1, NULL); 108 | Com_Printf("Failed to start thread with error: %s\n", errMessageBuf); 109 | 110 | } 111 | else 112 | { 113 | Com_Printf("Failed to start thread!\n"); 114 | } 115 | return NULL; 116 | } 117 | return thid; 118 | } 119 | 120 | /* 121 | ================ 122 | Sys_CreateNewThread 123 | ================ 124 | */ 125 | qboolean Sys_CreateNewThread(void* (*ThreadMain)(void*), threadid_t *tid, void* arg) 126 | { 127 | HANDLE thid = Sys_CreateThreadWithHandle(ThreadMain, tid, arg); 128 | 129 | if(thid == NULL) 130 | { 131 | return qfalse; 132 | } 133 | 134 | CloseHandle(thid); 135 | return qtrue; 136 | } 137 | 138 | /* 139 | ================ 140 | Sys_ExitThread 141 | ================ 142 | */ 143 | void Sys_ExitThread(int code) 144 | { 145 | ExitThread( code ); 146 | } 147 | 148 | /* 149 | ================ 150 | Sys_SleepMSec 151 | ================ 152 | */ 153 | void Sys_SleepMSec(int msec) 154 | { 155 | Sleep(msec); 156 | } 157 | 158 | /* 159 | ================ 160 | Sys_EnterCriticalSection 161 | ================ 162 | */ 163 | void Sys_EnterCriticalSection(int section) 164 | { 165 | EnterCriticalSection(&crit_sections[section]); 166 | } 167 | 168 | /* 169 | ================ 170 | Sys_TryEnterCriticalSection 171 | ================ 172 | */ 173 | int Sys_TryEnterCriticalSection(int section) 174 | { 175 | return TryEnterCriticalSection(&crit_sections[section]) == 0; 176 | } 177 | 178 | /* 179 | ================ 180 | Sys_LeaveCriticalSection 181 | ================ 182 | */ 183 | void Sys_LeaveCriticalSection(int section) 184 | { 185 | LeaveCriticalSection(&crit_sections[section]); 186 | } 187 | -------------------------------------------------------------------------------- /src/xanim/xmodel_utils.cpp: -------------------------------------------------------------------------------- 1 | #include "../qcommon/qcommon.h" 2 | 3 | unsigned short* XModelBoneNames(XModel *model) 4 | { 5 | return model->parts->hierarchy->names; 6 | } 7 | 8 | int XModelGetBoneIndex(const XModel *model, unsigned int name) 9 | { 10 | int i; 11 | 12 | for ( i = model->parts->numBones - 1; i >= 0 && name != model->parts->hierarchy->names[i]; --i ) 13 | ; 14 | 15 | return i; 16 | } 17 | 18 | int XModelGetContents(const XModel *model) 19 | { 20 | return model->contents; 21 | } 22 | 23 | int XModelGetNumLods(const XModel *model) 24 | { 25 | return model->numLods; 26 | } 27 | 28 | int XModelGetFlags(const XModel *model) 29 | { 30 | return model->flags; 31 | } 32 | 33 | const char* XModelGetName(const XModel *model) 34 | { 35 | return model->name; 36 | } 37 | 38 | DObjAnimMat* XModelGetBasePose(const XModel *model) 39 | { 40 | return &model->parts->skel.Mat; 41 | } 42 | 43 | int XModelNumBones(const XModel *model) 44 | { 45 | return model->parts->numBones; 46 | } -------------------------------------------------------------------------------- /src/zlib/crypt.h: -------------------------------------------------------------------------------- 1 | /* crypt.h -- base code for crypt/uncrypt ZIPfile 2 | 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | 8 | This code is a modified version of crypting code in Infozip distribution 9 | 10 | The encryption/decryption parts of this source code (as opposed to the 11 | non-echoing password parts) were originally written in Europe. The 12 | whole source package can be freely distributed, including from the USA. 13 | (Prior to January 2000, re-export from the US was a violation of US law.) 14 | 15 | This encryption code is a direct transcription of the algorithm from 16 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This 17 | file (appnote.txt) is distributed with the PKZIP program (even in the 18 | version without encryption capabilities). 19 | 20 | If you don't need crypting in your application, just define symbols 21 | NOCRYPT and NOUNCRYPT. 22 | 23 | This code support the "Traditional PKWARE Encryption". 24 | 25 | The new AES encryption added on Zip format by Winzip (see the page 26 | http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong 27 | Encryption is not supported. 28 | */ 29 | 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) 31 | 32 | /*********************************************************************** 33 | * Return the next byte in the pseudo-random sequence 34 | */ 35 | static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) 36 | { 37 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an 38 | * unpredictable manner on 16-bit systems; not a problem 39 | * with any known compiler so far, though */ 40 | 41 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; 42 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); 43 | } 44 | 45 | /*********************************************************************** 46 | * Update the encryption keys with the next byte of plain text 47 | */ 48 | static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) 49 | { 50 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); 51 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; 52 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; 53 | { 54 | register int keyshift = (int)((*(pkeys+1)) >> 24); 55 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); 56 | } 57 | return c; 58 | } 59 | 60 | 61 | /*********************************************************************** 62 | * Initialize the encryption keys and the random header according to 63 | * the given password. 64 | */ 65 | static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) 66 | { 67 | *(pkeys+0) = 305419896L; 68 | *(pkeys+1) = 591751049L; 69 | *(pkeys+2) = 878082192L; 70 | while (*passwd != '\0') { 71 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); 72 | passwd++; 73 | } 74 | } 75 | 76 | #define zdecode(pkeys,pcrc_32_tab,c) \ 77 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) 78 | 79 | #define zencode(pkeys,pcrc_32_tab,c,t) \ 80 | (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) 81 | 82 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED 83 | 84 | #define RAND_HEAD_LEN 12 85 | /* "last resort" source for second part of crypt seed pattern */ 86 | # ifndef ZCR_SEED2 87 | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ 88 | # endif 89 | 90 | static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) 91 | const char *passwd; /* password string */ 92 | unsigned char *buf; /* where to write header */ 93 | int bufSize; 94 | unsigned long* pkeys; 95 | const unsigned long* pcrc_32_tab; 96 | unsigned long crcForCrypting; 97 | { 98 | int n; /* index in random header */ 99 | int t; /* temporary */ 100 | int c; /* random byte */ 101 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ 102 | static unsigned calls = 0; /* ensure different random header each time */ 103 | 104 | if (bufSize> 7) & 0xff; 119 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); 120 | } 121 | /* Encrypt random header (last two bytes is high word of crc) */ 122 | init_keys(passwd, pkeys, pcrc_32_tab); 123 | for (n = 0; n < RAND_HEAD_LEN-2; n++) 124 | { 125 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); 126 | } 127 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); 128 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); 129 | return n; 130 | } 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /src/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /src/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /src/zlib/ioapi.h: -------------------------------------------------------------------------------- 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | */ 8 | 9 | #ifndef _ZLIBIOAPI_H 10 | #define _ZLIBIOAPI_H 11 | 12 | 13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 14 | #define ZLIB_FILEFUNC_SEEK_END (2) 15 | #define ZLIB_FILEFUNC_SEEK_SET (0) 16 | 17 | #define ZLIB_FILEFUNC_MODE_READ (1) 18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 20 | 21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 23 | 24 | 25 | #ifndef ZCALLBACK 26 | 27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 28 | #define ZCALLBACK CALLBACK 29 | #else 30 | #define ZCALLBACK 31 | #endif 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 45 | 46 | typedef struct zlib_filefunc_def_s 47 | { 48 | open_file_func zopen_file; 49 | read_file_func zread_file; 50 | write_file_func zwrite_file; 51 | tell_file_func ztell_file; 52 | seek_file_func zseek_file; 53 | close_file_func zclose_file; 54 | testerror_file_func zerror_file; 55 | voidpf opaque; 56 | } zlib_filefunc_def; 57 | 58 | 59 | 60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 61 | 62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /test/database/replace_offsets.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | my $offset_file = 'offset_database.txt'; 7 | my $sorted_file = 'sorted_database.txt'; 8 | my $original_pseudocode = 'cod2_lnxded_1_0.c.original'; 9 | my $created_pseudocode = 'cod2_lnxded_1_0.c'; 10 | 11 | print "Opening files...\n"; 12 | open(OFFSET_FILE, '<' . $offset_file) or die("Error: Cannot open offset file.\n"); 13 | open(SORTED_FILE, '>' . $sorted_file) or die("Error: Cannot create sorted file.\n"); 14 | open(ORIGINAL_PSEUDOCODE, '<' . $original_pseudocode) or die("Error: Cannot open original pseudocode file.\n"); 15 | open(CREATED_PSEUDOCODE, '>' . $created_pseudocode) or die("Error: Cannot create new pseudocode file.\n"); 16 | 17 | my %offsets; 18 | my %sorted_functions; 19 | my %sorted_variables; 20 | my @keys; 21 | my $line; 22 | my $key; 23 | my $file; 24 | 25 | print "Parsing offset file...\n"; 26 | while (defined($line = )) { 27 | if ($line =~ /0[xX]0([0-9a-fA-F]+)/) { 28 | next if ($line =~ /^s?+\/\//); 29 | my $offset = $1; 30 | 31 | if ($line =~ /\(DWORD\)(\w+\.?\w+)/) { 32 | my $variable = $1; 33 | 34 | if (defined($offsets{$offset})) { die("Error: Duplicate offset found: $offset Aborting.\n"); } 35 | 36 | foreach $key (keys %offsets) { 37 | if ($variable eq $offsets{$key}) { die("Error: Duplicate variable found: $variable\n"); } 38 | } 39 | 40 | $offsets{$offset} = $variable; 41 | 42 | if ($line =~ /^SetJump/) { 43 | $sorted_functions{$offset} = $variable; 44 | } 45 | elsif ($line =~ /^SetDword/) { 46 | $sorted_variables{$offset} = $variable; 47 | } 48 | } 49 | } 50 | } 51 | 52 | print "Parsing original pseudocode file...\n"; 53 | $file = ''; 54 | while (defined($line = )) { 55 | $file = $file . $line; 56 | } 57 | 58 | print "Replacing offsets in pseudocode file...\n"; 59 | foreach $key (keys %offsets) { 60 | $file =~ s/(byte_|dword_|sub_|unk_)$key/$offsets{$key}/g; 61 | } 62 | 63 | print "Writing new pseudocode file...\n"; 64 | print CREATED_PSEUDOCODE $file; 65 | 66 | print "Writing sorted offset file...\n"; 67 | printf SORTED_FILE "// This file was autogenerated by replace_offsets.pl"; 68 | @keys = sort { $a cmp $b } keys %sorted_functions; 69 | printf SORTED_FILE "\n\n// =================================== Functions ===================================\n\n"; 70 | foreach $key ( @keys ) { 71 | printf SORTED_FILE "SetJump(0x0$key, (DWORD)$sorted_functions{$key});\n"; 72 | } 73 | @keys = sort { $a cmp $b } keys %sorted_variables; 74 | printf SORTED_FILE "\n\n// =================================== Variables ===================================\n\n"; 75 | foreach $key ( @keys ) { 76 | printf SORTED_FILE "SetJump(0x0$key, (DWORD)$sorted_variables{$key});\n"; 77 | } 78 | 79 | print "Closing files...\n"; 80 | close OFFSET_FILE; 81 | close ORIGINAL_PSEUDOCODE; 82 | close CREATED_PSEUDOCODE; 83 | 84 | die "Done!\n"; 85 | -------------------------------------------------------------------------------- /test/ida/cod2_lnxded.idb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voron00/CoD2rev_Server/2cb7c9878cfef610920f96c20c35cc61a2e460cb/test/ida/cod2_lnxded.idb -------------------------------------------------------------------------------- /test/ida/rename_offsets.idc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static main() 4 | { 5 | auto fp; 6 | auto lineContents; 7 | auto subString; 8 | auto offset; 9 | auto function; 10 | auto variable; 11 | auto count = 0; 12 | 13 | fp = fopen("offset_database.txt", "r"); 14 | 15 | if (!fp) 16 | { 17 | Message("Cannot open offset list file."); 18 | return; 19 | } 20 | 21 | while (1) 22 | { 23 | lineContents = readstr(fp); 24 | 25 | if (lineContents == -1) 26 | break; 27 | 28 | if (strlen(lineContents) < 2) 29 | continue; 30 | 31 | // Functions 32 | subString = substr(lineContents, 8, 11); 33 | 34 | if (subString == "0x0") 35 | { 36 | subString = substr(lineContents, 0, 7); 37 | 38 | if (subString == "SetJump") 39 | { 40 | offset = substr(lineContents, 8, 18); 41 | function = substr(lineContents, 27, strlen(lineContents) - 3); 42 | 43 | if (MakeName(offset, function)) 44 | count++; 45 | else 46 | Message("Failed to rename offset '%s' function '%s'\n", offset, function); 47 | } 48 | } 49 | 50 | // Variables 51 | subString = substr(lineContents, 9, 12); 52 | 53 | if (subString == "0x0") 54 | { 55 | subString = substr(lineContents, 0, 8); 56 | 57 | if (subString == "SetDword") 58 | { 59 | offset = substr(lineContents, 9, 19); 60 | variable = substr(lineContents, 28, strlen(lineContents) - 3); 61 | 62 | if (MakeName(offset, variable)) 63 | count++; 64 | else 65 | Message("Failed to rename offset '%s' variable '%s'\n", offset, variable); 66 | } 67 | } 68 | } 69 | 70 | Message("Success! Renamed total of %i offsets.\n", count); 71 | } -------------------------------------------------------------------------------- /test/linux/sys_patch.cpp: -------------------------------------------------------------------------------- 1 | #include "sys_patch.h" 2 | 3 | DWORD SetCall(DWORD addr, DWORD destination) 4 | { 5 | DWORD restore = *(DWORD *)addr; 6 | 7 | DWORD relative = destination - (addr + 5); // +5 is the position of next opcode 8 | memcpy((void *)(addr + 1), &relative, 4); // set relative address with endian 9 | 10 | return restore; 11 | } 12 | 13 | DWORD SetJump(DWORD addr, DWORD destination) 14 | { 15 | DWORD restore = *(DWORD *)addr; 16 | 17 | DWORD relative = destination - (addr + 5); // +5 is the position of next opcode 18 | memset((void *)addr, 0xE9, 1); // JMP-OPCODE 19 | memcpy((void *)(addr + 1), &relative, 4); // set relative address with endian 20 | 21 | return restore; 22 | } 23 | 24 | DWORD SetDword(DWORD addr, DWORD replacement) 25 | { 26 | DWORD restore = *(DWORD *)addr; 27 | *(DWORD *)addr = replacement; 28 | 29 | return restore; 30 | } 31 | -------------------------------------------------------------------------------- /test/linux/sys_patch.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYS_PATCH_H__ 2 | #define __SYS_PATCH_H__ 3 | 4 | #include 5 | 6 | #include "../../src/qcommon/qcommon.h" 7 | 8 | DWORD SetCall(DWORD addr, DWORD destination); 9 | DWORD SetJump(DWORD addr, DWORD destination); 10 | DWORD SetDword(DWORD addr, DWORD replacement); 11 | 12 | #endif 13 | --------------------------------------------------------------------------------