#include <errno.h>
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
Go to the source code of this file.
Defines | |
#define | MAX_VAR 64 |
#define | __attribute__(x) |
#define | UFO_DEPRECATED |
#define | EXPORT |
#define | IMPORT |
#define | inline |
#define | STRINGIFY(x) #x |
#define | DOUBLEQUOTE(x) STRINGIFY(x) |
#define | lengthof(x) (sizeof(x) / sizeof(*(x))) |
#define | CASSERT(x) extern int ASSERT_COMPILE[((x) != 0) * 2 - 1] |
#define | Q_strcasecmp(a, b) strcasecmp((a), (b)) |
Functions | |
const char * | Com_SkipPath (const char *pathname) |
Returns just the filename from a given path. | |
void | Com_ReplaceFilename (const char *fileName, const char *name, char *path, size_t size) |
Replaces the filename from one path with another one. | |
void | Com_StripExtension (const char *in, char *out, size_t size) |
Removes the file extension from a filename. | |
void | Com_FilePath (const char *in, char *out) |
Returns the path up to, but not including the last /. | |
const char * | Com_GetExtension (const char *path) |
void | Com_DefaultExtension (char *path, size_t len, const char *extension) |
Sets a default extension if there is none. | |
int | Com_Filter (const char *pattern, const char *text) |
Match the pattern PATTERN against the string TEXT;. | |
char * | Com_Trim (char *s) |
char * | va (const char *format,...) __attribute__((format(printf |
char int | Q_FloatSort (const void *float1, const void *float2) |
Compare two floats. | |
int | Q_StringSort (const void *string1, const void *string2) __attribute__((nonnull)) |
Compare two strings. | |
qboolean | Com_sprintf (char *dest, size_t size, const char *fmt,...) __attribute__((format(printf |
int | Q_strncasecmp (const char *s1, const char *s2, size_t n) __attribute__((nonnull)) |
void | Q_strncpyz (char *dest, const char *src, size_t destsize) __attribute__((nonnull)) |
Safe strncpy that ensures a trailing zero. | |
int | Q_vsnprintf (char *str, size_t size, const char *format, va_list ap) |
Safe (null terminating) vsnprintf implementation. | |
void | Q_strcat (char *dest, const char *src, size_t size) __attribute__((nonnull)) |
Safely (without overflowing the destination buffer) concatenates two strings. | |
char * | Q_strlwr (char *str) __attribute__((nonnull)) |
const char * | Q_stristr (const char *str, const char *substr) __attribute__((nonnull)) |
void | Com_Printf (const char *fmt,...) __attribute__((format(printf |
void void | Com_DPrintf (int level, const char *msg,...) __attribute__((format(printf |
void void void | Com_Error (int code, const char *fmt,...) __attribute__((noreturn |
void void void | format (printf, 2, 3))) |
Definition in file shared.h.
#define CASSERT | ( | x | ) | extern int ASSERT_COMPILE[((x) != 0) * 2 - 1] |
#define DOUBLEQUOTE | ( | x | ) | STRINGIFY(x) |
Definition at line 87 of file shared.h.
Referenced by CL_Connect_f(), CL_PingServers_f(), CL_Rcon_f(), CL_ServerInfo_f(), Qcommon_Init(), R_InitPrograms(), SV_Init(), SV_InitGame(), and SVC_Info().
#define lengthof | ( | x | ) | (sizeof(x) / sizeof(*(x))) |
returns the amount of elements - not the amount of bytes
Definition at line 99 of file shared.h.
Referenced by AII_UpdateOneInstallationDelay(), AIR_NewAircraft(), AIR_Refuel(), B_ManageAntimatter(), B_SellOrAddItems(), B_SetBaseTitle_f(), B_UpdateBaseData(), BDEF_AddSlotToSlotList(), CL_ActorAddToTeamList(), CL_ActorDie(), CL_ActorRevitalised(), CL_DisplayPopupAircraft(), CL_ParseMapDefinition(), CL_ParticleRunTimed(), CL_ParticleSpawnTimed(), CL_UpdateActorAircraftVar(), Com_AllocateCustomSkin(), CP_LoadMissionsXML(), G_ClientMove(), G_UpdateCharacterBodycount(), GAME_GetCharacter(), GAME_GetCharacterArraySize(), GAME_InitializeBattlescape(), GAME_MP_Results(), GAME_SK_Results(), HUD_ActorSelectionChangeListener(), HUD_MapDebugCursor(), HUD_PopupFiremodeReservation(), HUD_UpdateActorCvar(), HUD_UpdateActorFireMode(), HUD_UpdateActorMove(), HUD_UpdateAllActors(), I_EquipActor(), IN_JoystickMove(), INS_SetInstallationTitle(), INS_UpdateInstallationData(), MAP_DrawMap(), MP_LoadTeamMultiplayerInfo(), MP_UpdateMenuParameters_f(), NET_ReadDir(), NET_WriteDir(), PR_ProductionIncrease_f(), R_CreateFramebuffer(), R_CullBox(), R_CullMeshModel(), R_CullSphere(), R_FillArrayData(), R_ImageClearMaterials(), R_InitConvolveProgram(), R_ModReloadSurfacesArrays(), R_StageColor(), R_TextureAlphaMode(), R_TextureMode(), R_TextureSolidMode(), RS_GetTechForItem(), SV_CreateWorldSector(), SV_GetServerDataForEdict(), Sys_TTYConsoleHistoryAdd(), Sys_TTYConsoleHistoryPrevious(), TR_CargoList(), UI_CheckActionTokenTypeSanity(), UI_GetActionTokenType(), UR_DialogFillNations(), UR_DialogInitStore_f(), UR_DialogStartStore_f(), and VID_GetModeNums().
#define MAX_VAR 64 |
Definition at line 33 of file shared.h.
Referenced by actorL_tostring(), AIL_InitActor(), B_LoadXML(), B_SetBaseTitle_f(), BDEF_AddBattery_f(), BDEF_BaseDefenceMenuUpdate_f(), BDEF_RemoveBattery_f(), BS_BuyType(), CHRSH_CharGetBody(), CHRSH_CharGetHead(), CL_Connect_f(), CL_DisplayHomebasePopup(), CL_DownloadUMPMap(), CL_EventAddMail_f(), CL_LanguageInit(), CL_ParseMapParticle(), CL_ParsePtlCmds(), CL_ParticleAppear(), CL_ParticleSpawnEvent(), CL_QueryMasterServerThread(), CL_ServerListDiscoveryCallback(), CM_LoadMap(), Cmd_GetCommandDesc(), Com_ParseGameTypes(), Com_ParseValue(), Com_SetValue(), Com_ValueToStr(), E_CreateEmployeeAtIndex(), ED_ParseEdict(), FS_NextScriptHeader(), G_MatchSendResults(), G_SpawnAIPlayer(), GAME_CP_CharacterCvars(), GAME_MP_StartServer_f(), GAME_SK_Start_f(), HUD_DisplayFiremodeEntry(), HUD_PopupFiremodeReservation(), INS_DestroyInstallation_f(), INS_ParseInstallations(), INS_SetInstallationTitle(), Irc_Client_CmdJoin(), Irc_Client_CmdKick(), Irc_Client_CmdKill(), Irc_Client_CmdMode(), Irc_Client_CmdNick(), Irc_Client_CmdPart(), Irc_Client_CmdPrivmsg(), Irc_Client_CmdQuit(), Irc_Client_CmdRplNamreply(), Irc_Client_Names_f(), Irc_Logic_AddChannelName(), MP_GetEquipment(), MS_LoadXML(), MSO_ParseCategories(), pos3L_tostring(), PR_ProductionList_f(), R_ModBeginLoading(), Rimp_Init(), S_Init(), SAV_GameSave_f(), SEQ_FindEnt(), SV_ParseMapcycle(), SVC_Info(), Sys_GetCurrentUser(), UFO_CampaignCheckEvents(), UI_BarNodeCapturedMouseMove(), UI_BaseInventoryNodeDrawTooltip(), UI_BuildRadarImageList(), UI_ContainerNodeDrawTooltip(), UI_DrawModelNode(), UI_DrawModelNodeWithUIModel(), UI_GenInjectedString(), UI_GetPath(), UI_GetUIModel(), UI_MaterialEditorUpdate(), UI_ModelNodeDraw(), UI_ParseProperty(), UI_ReadNodePath(), UI_StringNodeDrawTooltip(), UI_TextNodeDrawText(), UI_Tooltip(), UI_Translate_f(), UP_SetMailHeader(), UR_DialogInit_f(), and UR_DialogInitStore_f().
#define Q_strcasecmp | ( | a, | |||
b | ) | strcasecmp((a), (b)) |
Definition at line 120 of file shared.h.
Referenced by CheckNeedPass(), CL_QueueHTTPDownload(), CL_StartNextHTTPDownload(), Cmd_CompleteCommandParameters(), Cmd_ExecuteString(), Cmd_RemoveCommand(), Com_ParseFire(), Com_ParseInventory(), Com_ParseItem(), Cvar_Delete(), ED_ParseField(), FS_OpenFileSingle(), G_ClientCommand(), G_Find(), G_ServerCommand(), Info_ValueForKey(), Key_StringToKeynum(), LoadModel(), ModelWorker(), R_BeginFrame(), R_FontRegister(), R_ModForName(), R_ScreenShot(), R_TextureAlphaMode(), R_TextureMode(), R_TextureSolidMode(), R_VerifyDriver(), RS_GetTechByID(), RS_GetTechByProvided(), RS_GetTechIdxByName(), SV_LoadModelMinsMaxs(), Sys_ListFilteredFiles(), UI_FindPropertyByName(), UI_ParseNode(), and UI_ParseValueExpression().
#define STRINGIFY | ( | x | ) | #x |
Definition at line 86 of file shared.h.
Referenced by Info_SetValueForKey().
void Com_DefaultExtension | ( | char * | path, | |
size_t | len, | |||
const char * | extension | |||
) |
Sets a default extension if there is none.
Definition at line 252 of file shared.c.
References Com_sprintf(), MAX_OSPATH, and Q_strncpyz().
Referenced by Com_WriteConfig_f(), Key_WriteBindings_f(), main(), R_ModLoadMDX(), and RT_WriteCSVFiles().
void void Com_DPrintf | ( | int | level, | |
const char * | msg, | |||
... | ||||
) |
void void void Com_Error | ( | int | code, | |
const char * | fmt, | |||
... | ||||
) |
void Com_FilePath | ( | const char * | in, | |
char * | out | |||
) |
Returns the path up to, but not including the last /.
Definition at line 275 of file shared.c.
References Q_strncpyz().
Referenced by ExportLightmaps(), FS_BuildFileList(), and Sys_FindFirst().
int Com_Filter | ( | const char * | pattern, | |
const char * | text | |||
) |
Match the pattern PATTERN against the string TEXT;.
Definition at line 100 of file shared.c.
References Com_FilterAfterStar(), and match().
Referenced by Com_FilterAfterStar(), Sys_FindFirst(), Sys_FindNext(), and Sys_ListFilteredFiles().
const char* Com_GetExtension | ( | const char * | path | ) |
path | The path resp. filename to extract the extension from |
NULL
if the given path name does not contain an extension Definition at line 237 of file shared.c.
Referenced by CL_CheckAndQueueDownload(), CL_FinishHTTPDownload(), CL_QueueHTTPDownload(), CL_StartHTTPDownload(), FS_LoadPackFile(), MD2Check(), and MD2SkinFix().
void Com_Printf | ( | const char * | fmt, | |
... | ||||
) |
void Com_ReplaceFilename | ( | const char * | fileName, | |
const char * | name, | |||
char * | path, | |||
size_t | size | |||
) |
Replaces the filename from one path with another one.
[in] | fileName | The full path to a filename |
[in] | name | The filename to insert into the given full path |
[out] | path | The target buffer |
[in] | size | The size of the target buffer |
Definition at line 194 of file shared.c.
References Q_strncpyz().
Referenced by R_AliasModelGetSkin().
const char* Com_SkipPath | ( | const char * | pathname | ) |
Returns just the filename from a given path.
Definition at line 35 of file shared.c.
Referenced by _AddToListBlock(), ExportLightmaps(), FS_GetMaps(), GenerateMaterialFile(), M_RandomTrack_f(), MD2SkinFix(), and R_LoadMaterials().
qboolean Com_sprintf | ( | char * | dest, | |
size_t | size, | |||
const char * | fmt, | |||
... | ||||
) |
void Com_StripExtension | ( | const char * | in, | |
char * | out, | |||
const size_t | size | |||
) |
Removes the file extension from a filename.
[in] | in | The incoming filename |
[in] | out | The stripped filename |
[in] | size | The size of the output buffer |
Definition at line 214 of file shared.c.
References i.
Referenced by ASE_KeyMAP_DIFFUSE(), CIN_PlayCinematic(), ExportLightmaps(), FS_GetMaps(), GenerateFootstepList(), GenerateMaterialFile(), M_Start(), main(), MD2SkinFix(), PrecalcNormalsAndTangents(), R_FindImage(), R_LoadImage(), R_LoadObjSkin(), R_ModLoadLevelOfDetailData(), R_ModLoadMDX(), and S_LoadSample().
char* Com_Trim | ( | char * | s | ) |
Definition at line 41 of file shared.c.
Referenced by MP_AddChatMessage(), and R_LoadObjModel_().
void void void format | ( | printf | , | |
2 | , | |||
3 | ||||
) |
char int Q_FloatSort | ( | const void * | float1, | |
const void * | float2 | |||
) |
Compare two floats.
[in] | float1 | The first float |
[in] | float2 | The second float |
Definition at line 293 of file shared.c.
Referenced by AIR_GetAircraftWeaponRanges().
void Q_strcat | ( | char * | dest, | |
const char * | src, | |||
size_t | destsize | |||
) |
Safely (without overflowing the destination buffer) concatenates two strings.
[in] | dest | the destination string. |
[in] | src | the source string. |
[in] | destsize | the total size of the destination buffer. |
Definition at line 420 of file shared.c.
References Q_strncpyz(), and Sys_Error().
Referenced by AIM_AircraftEquipMenuUpdate(), AIR_AircraftSelect(), B_AssembleMap(), B_DrawBuilding(), BaseSummary_Init(), Cbuf_AddLateCommands(), CL_DisplayPopupAircraft(), CL_LanguageTest(), CL_PingServerCallback(), CL_StatsUpdate_f(), Cmd_Alias_f(), CMod_LoadEntityString(), Com_ConsoleCompleteCommand(), Com_GetCharacterValues(), Com_MD5File(), Com_vPrintf(), CP_InitMissionResults(), G_Players_f(), G_Say_f(), GAME_MP_MapInfo(), Info_SetValueForKey(), INS_ParseInstallations(), INV_ItemDescription(), Irc_AppendToBuffer(), Key_Bind_f(), MAP_DrawMapMarkers(), MAP_GetAircraftText(), MAP_GetUFOText(), MAP_MultiSelectListAddItem(), PR_AircraftInfo(), PR_DisassemblyInfo(), PR_ItemProductionInfo(), PrecalcNormalsAndTangents(), Rimp_Init(), SV_AssembleMap(), SVC_RemoteCommand(), Sys_GetHomeDirectory(), TR_TransferBaseSelect(), UI_BaseInventoryNodeDrawTooltip(), UI_ContainerNodeDrawTooltip(), UI_GetItemTooltip(), UI_GetPath(), UI_MaterialEditorStagesToName(), UI_StringNodeDrawTooltip(), UI_TodoNodeDrawTooltip(), UnparseEntities(), UP_AircraftDescription(), UP_AircraftItemDescription(), UP_BuildingDescription(), and UP_OpenMail_f().
int Q_StringSort | ( | const void * | string1, | |
const void * | string2 | |||
) |
Compare two strings.
[in] | string1 | The first string |
[in] | string2 | The second string |
Definition at line 306 of file shared.c.
Referenced by Com_MapDefSort(), FS_AddGameDirectory(), FS_ListFiles(), FS_LoadPackFile(), FS_MapDefSort(), and Irc_Client_Names_f().
const char* Q_stristr | ( | const char * | str, | |
const char * | substr | |||
) |
Definition at line 499 of file shared.c.
References Q_strncasecmp().
Referenced by R_SearchForVendor().
char* Q_strlwr | ( | char * | str | ) |
Definition at line 355 of file shared.c.
Referenced by FS_ListFiles(), and FS_LoadPackFile().
int Q_strncasecmp | ( | const char * | s1, | |
const char * | s2, | |||
size_t | n | |||
) |
Definition at line 366 of file shared.c.
Referenced by HTTP_Header(), Q_stristr(), and UI_ParseValueExpression().
void Q_strncpyz | ( | char * | dest, | |
const char * | src, | |||
size_t | destsize | |||
) |
Safe strncpy that ensures a trailing zero.
dest | Destination pointer | |
src | Source pointer | |
destsize | Size of destination buffer (this should be a sizeof size due to portability) |
Definition at line 398 of file shared.c.
References Sys_Error(), and UTF8_strncpyz().
Referenced by _Mem_CreatePool(), AIL_InitActor(), AIM_AircraftEquipMenuUpdate(), AIR_ChangeAircraftName_f(), AIR_LoadAircraftXML(), AIR_NewAircraft(), AIR_ParseAircraft(), B_BuildBase_f(), B_ChangeBaseName_f(), B_LoadXML(), B_SetBaseTitle_f(), BDEF_AddBattery_f(), BDEF_BaseDefenceMenuUpdate_f(), BDEF_RemoveBattery_f(), Check_SetNodraw(), CheckMixedFaceContents(), CheckTexturesBasedOnFlags(), CIN_ROQ_PlayCinematic(), CIN_RunCinematic(), CL_AddMapParticle(), CL_CheckOrDownloadFile(), CL_Connect_f(), CL_DownloadUMPMap(), CL_HTTP_Progress(), CL_Init(), CL_LanguageInit(), CL_LanguageTest(), CL_LoadCharacterXML(), CL_ParseAlienTeam(), CL_ParseCampaign(), CL_ParseClientinfo(), CL_ParseComponents(), CL_ParseMapParticle(), CL_ParseParticle(), CL_ParsePtlCmds(), CL_ParseRanks(), CL_ParseSequence(), CL_ParseServerInfoMessage(), CL_ParticleGetArt(), CL_ParticleSpawnTimed(), CL_ProcessPingReply(), CL_QueryMasterServerThread(), CL_QueueHTTPDownload(), CL_SetHTTPServer(), CM_AddMapTile(), CM_LoadMap(), Cmd_Alias_f(), Cmd_GenericCompleteFunction(), Cmd_GetCommandDesc(), Cmd_TokenizeString(), CMod_LoadEntityString(), CMod_LoadSurfaces(), Com_ConsoleCompleteCommand(), Com_DefaultExtension(), Com_FilePath(), Com_GetCharacterValues(), Com_MacroExpandString(), Com_ParseCharacterTemplate(), Com_ParseDamageTypes(), Com_ParseEquipment(), Com_ParseGameTypes(), Com_ParseInventory(), Com_ParseItem(), Com_ParseTeam(), Com_ParseValue(), Com_RegisterConstInt(), Com_ReplaceFilename(), Com_SetValue(), Com_ValueToStr(), Com_WriteConfig_f(), Con_DrawInput(), Con_LoadConsoleHistory(), CP_CreateCivilianTeam(), CP_LoadMissionsXML(), E_ChangeName_f(), E_CreateEmployeeAtIndex(), ED_ParseEdict(), FindMiptex(), FS_AddGameDirectory(), FS_BuildFileList(), FS_CreatePath(), FS_GetCwd(), FS_GetFileData(), FS_GetMaps(), FS_ListFiles(), FS_LoadPackFile(), FS_NextScriptHeader(), FS_OpenFileSingle(), G_ClientUserinfoChanged(), G_SpawnAIPlayer(), G_SpawnEntities(), HOS_UpdateMenu(), HTTP_GetURL(), HTTP_Header(), HUD_UpdateActorFireMode(), Info_SetValueForKey(), INS_BuildInstallation_f(), INS_ChangeInstallationName_f(), INS_LoadXML(), Irc_Client_CmdPrivmsg(), Irc_Client_CmdRplNamreply(), Irc_Client_CmdRplWhowasuser(), Irc_Client_Names_f(), Irc_Client_Topic_f(), Irc_ParseName(), Irc_Proto_Join(), Irc_Proto_ProcessServerMsg(), Key_Console(), Key_WriteBindings_f(), LE_GetAnim(), LM_AddModel(), LoadModel(), M_Start(), main(), MP_AddChatMessage(), MP_SaveTeamMultiplayer(), MS_AddNewMessageSound(), MS_LoadXML(), NET_SockaddrToStrings(), NET_StreamPeerToName(), ParseBrush(), ParseFromMemory(), Q_strcat(), R_FontFindTruncFit(), R_FontGenerateTexture(), R_FontMakeChunks(), R_FontSetTruncationMarker(), R_InitExtensions(), R_LoadAnimImages(), R_LoadImageData(), R_LoadObjSkin(), R_LoadProgram(), R_LoadShader(), R_ModBeginLoading(), R_ModForName(), R_ModLoadAliasDPMModel(), R_ModLoadAliasMD2MeshIndexed(), R_ModLoadAliasMD2MeshUnindexed(), R_ModLoadAliasMD2Model(), R_ModLoadAliasMD3Model(), R_ModLoadAnims(), R_PrintInfo(), R_ProgramVariable(), S_Init(), SAV_GameLoad(), SAV_GameSave(), SAV_GameSave_f(), SEQ_Execute2Dobj(), SEQ_ExecuteModel(), SP_misc_model(), SP_worldspawn(), SV_AssembleMap(), SV_CompleteMapCommand(), SV_Map(), SV_Map_f(), SV_NextMapcycle(), SV_ParseAssembly(), SV_ParseMapcycle(), SV_ParseMapTile(), SV_ParseMapTileSet(), SV_ParseUMP(), SV_SetConfigString(), SVC_DirectConnect(), Sys_ConsoleInput(), Sys_FindFirst(), Sys_GetCurrentUser(), Sys_GetHomeDirectory(), testStringCopiers(), TexinfoForBrushTexture(), UFO_CampaignCheckEvents(), UI_AllocNodeWithoutNew(), UI_AllocStaticIcon(), UI_BarNodeCapturedMouseMove(), UI_BaseMapNodeDraw(), UI_BuildRadarImageList(), UI_CloneNode(), UI_DisplayNotice(), UI_DrawModelNode(), UI_InitOption(), UI_ModelNodeDraw(), UI_ParseProperty(), UI_ReadNodePath(), UI_TextEntryFocusGained(), UI_TextEntryNodeEdit(), UI_TextNodeDrawText(), UI_TextNodeGenerateLineSplit(), UM_Parameter(), UnparseEntities(), UP_SetMailHeader(), UR_DialogInit_f(), US_LoadXML(), and US_StoreUFO().
int Q_vsnprintf | ( | char * | str, | |
size_t | size, | |||
const char * | format, | |||
va_list | ap | |||
) |
Safe (null terminating) vsnprintf implementation.
Definition at line 477 of file shared.c.
References Com_Printf(), len, and UFO_SIZE_T.
Referenced by Check_Printf(), Com_DPrintf(), Com_Error(), Com_Printf(), Com_sprintf(), Com_vPrintf(), FS_CheckFile(), FS_Printf(), Irc_AppendToBuffer(), NET_OOB_Printf(), NET_VPrintf(), SV_BroadcastPrintf(), SV_Configstring(), SV_error(), SV_PlayerPrintf(), Sys_Error(), TEST_Printf(), UI_ExecuteConfunc(), va(), and Verb_Printf().
char* va | ( | const char * | format, | |
... | ||||
) |