diff options
Diffstat (limited to 'src/common/strlib.h')
-rw-r--r-- | src/common/strlib.h | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/common/strlib.h b/src/common/strlib.h index 10844d257..7f84d2893 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -2,27 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_STRLIB_H_ -#define _COMMON_STRLIB_H_ +#ifndef COMMON_STRLIB_H +#define COMMON_STRLIB_H -#include "../common/cbasetypes.h" #include <stdarg.h> +#include <string.h> -#ifndef __USE_GNU - #define __USE_GNU // required to enable strnlen on some platforms - #include <string.h> - #undef __USE_GNU -#else - #include <string.h> -#endif +#include "../common/cbasetypes.h" #ifdef WIN32 #define HAVE_STRTOK_R - #define strtok_r(s,delim,save_ptr) _strtok_r((s),(delim),(save_ptr)) - char *_strtok_r(char* s1, const char* s2, char** lasts); + #define strtok_r(s,delim,save_ptr) strtok_r_((s),(delim),(save_ptr)) + char *strtok_r_(char* s1, const char* s2, char** lasts); #endif -/// Bitfield determining the behaviour of sv_parse and sv_split. +/// Bitfield determining the behavior of sv_parse and sv_split. typedef enum e_svopt { // default: no escapes and no line terminator SV_NOESCAPE_NOTERMINATE = 0, @@ -79,14 +73,14 @@ struct strlib_interface { int (*e_mail_check) (char* email); int (*config_switch) (const char* str); - /// strncpy that always nul-terminates the string + /// strncpy that always null-terminates the string char *(*safestrncpy) (char* dst, const char* src, size_t n); /// doesn't crash on null pointer size_t (*safestrnlen) (const char* string, size_t maxlen); - /// Works like snprintf, but always nul-terminates the buffer. - /// Returns the size of the string (without nul-terminator) + /// Works like snprintf, but always null-terminates the buffer. + /// Returns the size of the string (without null-terminator) /// or -1 if the buffer is too small. int (*safesnprintf) (char* buf, size_t sz, const char* fmt, ...); @@ -137,7 +131,7 @@ struct sv_interface { /// WARNING: this function modifies the input string /// Starts splitting at startoff and fills the out_fields array. /// out_fields[0] is the start of the next line. - /// Other entries are the start of fields (nul-teminated). + /// Other entries are the start of fields (null-terminated). /// Returns the number of fields found or -1 if an error occurs. int (*split) (char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt); @@ -165,7 +159,7 @@ struct sv_interface *sv; void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef STRLIB_C +#ifndef H_STRLIB_C #define jstrescape(pt) (strlib->jstrescape(pt)) #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) @@ -189,6 +183,6 @@ void strlib_defaults(void); #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) -#endif /* STRLIB_C */ +#endif /* H_STRLIB_C */ -#endif /* _COMMON_STRLIB_H_ */ +#endif /* COMMON_STRLIB_H */ |