tron@2186: /* $Id$ */ tron@2186: tron@1317: #ifndef STRING_H tron@1317: #define STRING_H tron@1317: tron@1317: /* tron@1317: * dst: destination buffer tron@1317: * src: string to copy/concatenate tron@1317: * size: size of the destination buffer tron@1317: * usage: ttd_strlcpy(dst, src, lengthof(dst)); tron@1317: */ tron@1317: void ttd_strlcat(char *dst, const char *src, size_t size); tron@1317: void ttd_strlcpy(char *dst, const char *src, size_t size); tron@1317: tron@1317: /* tron@1317: * dst: destination buffer tron@1317: * src: string to copy tron@1317: * last: pointer to the last element in the dst array tron@1317: * if NULL no boundary check is performed tron@1317: * returns a pointer to the terminating \0 in the destination buffer tron@1317: * usage: strecpy(dst, src, lastof(dst)); tron@1317: */ tron@1317: char* strecat(char* dst, const char* src, const char* last); tron@1317: char* strecpy(char* dst, const char* src, const char* last); tron@1317: tron@2234: char* CDECL str_fmt(const char* str, ...); tron@2234: Darkvater@2775: /** Scans the string for valid characters and if it finds invalid ones, Darkvater@2775: * replaces them with a question mark '?' */ Darkvater@2775: void str_validate(char *str); Darkvater@2775: truelight@4300: /** truelight@4300: * Valid filter types for IsValidAsciiChar. truelight@4300: */ truelight@4300: typedef enum CharSetFilter { truelight@4300: CS_ALPHANUMERAL, //! Both numeric and alphabetic and spaces and stuff truelight@4300: CS_NUMERAL, //! Only numeric ones truelight@4300: CS_ALPHA, //! Only alphabetic values truelight@4300: } CharSetFilter; truelight@4300: truelight@4300: /** truelight@4300: * Only allow certain keys. You can define the filter to be used. This makes truelight@4300: * sure no invalid keys can get into an editbox, like BELL. truelight@4300: * @param key character to be checked truelight@4300: * @param afilter the filter to use truelight@4300: * @return true or false depending if the character is printable/valid or not truelight@4300: */ truelight@4300: bool IsValidAsciiChar(byte key, CharSetFilter afilter); truelight@4300: Darkvater@4200: /** Convert the given string to lowercase */ Darkvater@4200: void strtolower(char *str); Darkvater@4200: Darkvater@2436: #endif /* STRING_H */