UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
infostring.h File Reference

Info string handling. More...

#include <stddef.h>
#include "ufotypes.h"

Go to the source code of this file.

Macros

#define MAX_INFO_KEY   64
 
#define MAX_INFO_VALUE   64
 
#define MAX_INFO_STRING   512
 

Functions

const char * Info_ValueForKey (const char *s, const char *key)
 Searches the string for the given key and returns the associated value, or an empty string. More...
 
const char * Info_BoolForKey (const char *s, const char *key)
 
int Info_IntegerForKey (const char *s, const char *key)
 
void Info_RemoveKey (char *s, const char *key)
 Searches through s for key and remove is. More...
 
void Info_SetValueForKey (char *s, const size_t size, const char *key, const char *value)
 Adds a new entry into string with given value. More...
 
void Info_SetValueForKeyAsInteger (char *s, const size_t size, const char *key, const int value)
 
void Info_Print (const char *s)
 Prints info strings (like userinfo or serverinfo - CVAR_USERINFO, CVAR_SERVERINFO) More...
 
bool Info_Validate (const char *s)
 Some characters are illegal in info strings because they can mess up the server's parsing. More...
 

Detailed Description

Info string handling.

Definition in file infostring.h.

Macro Definition Documentation

#define MAX_INFO_KEY   64

Definition at line 34 of file infostring.h.

Referenced by Info_SetValueForKey().

#define MAX_INFO_VALUE   64

Definition at line 35 of file infostring.h.

Referenced by Info_SetValueForKey().

Function Documentation

const char* Info_BoolForKey ( const char *  s,
const char *  key 
)

Definition at line 76 of file infostring.cpp.

References Info_ValueForKey(), and Q_streq.

Referenced by GAME_MP_ParseServerInfoMessage().

int Info_IntegerForKey ( const char *  s,
const char *  key 
)
void Info_Print ( const char *  s)

Prints info strings (like userinfo or serverinfo - CVAR_USERINFO, CVAR_SERVERINFO)

Definition at line 209 of file infostring.cpp.

References Com_Printf(), and key.

Referenced by CL_UserInfo_f(), SV_Serverinfo_f(), SV_ShowServerinfo_f(), and SV_UserInfo_f().

void Info_RemoveKey ( char *  s,
const char *  key 
)

Searches through s for key and remove is.

Parameters
[in]sString to search key in
[in]keyString to search for in s
See also
Info_SetValueForKey

Definition at line 95 of file infostring.cpp.

Referenced by Info_SetValueForKey(), and TEST_F().

void Info_SetValueForKey ( char *  s,
const size_t  size,
const char *  key,
const char *  value 
)

Adds a new entry into string with given value.

Note
Removed any old version of the key
Parameters
[in,out]sThe target info string
[in]sizeThe size of s
[in]keyThe key to set
[in]valueThe value to set for the given key
See also
Info_RemoveKey
Info_SetValueForKeyAsInteger

Definition at line 169 of file infostring.cpp.

References Com_Printf(), Com_sprintf(), DOUBLEQUOTE, Info_RemoveKey(), MAX_INFO_KEY, MAX_INFO_STRING, MAX_INFO_VALUE, Q_strncpyz(), and Q_strnull().

Referenced by Cvar_BitInfo(), G_ClientConnect(), Info_SetValueForKeyAsInteger(), SVC_DirectConnect(), SVC_Info(), SVC_TeamInfo(), and TEST_F().

void Info_SetValueForKeyAsInteger ( char *  s,
const size_t  size,
const char *  key,
const int  value 
)
See also
Info_SetValueForKey

Definition at line 154 of file infostring.cpp.

References Info_SetValueForKey(), and va().

Referenced by G_SetTeamForPlayer(), SVC_Info(), and SVC_TeamInfo().

bool Info_Validate ( const char *  s)

Some characters are illegal in info strings because they can mess up the server's parsing.

Definition at line 142 of file infostring.cpp.

Referenced by G_ClientUserinfoChanged().

const char* Info_ValueForKey ( const char *  s,
const char *  key 
)

Searches the string for the given key and returns the associated value, or an empty string.

Parameters
[in]sThe string you want to extract the keyvalue from
[in]keyThe key you want to extract the value for
See also
Info_SetValueForKey
Returns
The value or empty string - never nullptr
Todo:
Not thread safe

Definition at line 39 of file infostring.cpp.

References Q_strcasecmp.

Referenced by G_ClientConnect(), G_ClientUserinfoChanged(), GAME_MP_ParseServerInfoMessage(), GAME_MP_ParseTeamInfoMessage(), GAME_MP_ProcessPingReply(), Info_BoolForKey(), Info_IntegerForKey(), SV_UserinfoChanged(), SVC_DirectConnect(), and TEST_F().