📄 utils.txt
字号:
const char * Util_Separate(const char **data, char delim); Somewhat along the lines of strtok, but implemented differently. Searches for delim in *data. If not found, simply returns NULL, otherwise copies everything up to delim into an internal buffer, assigns *data to the next character after delim, and returns a pointer to the internal buffer.void Util_SepTo(char *buffer, int len, const char **data, char delim); This is like Util_Separate, but it doesn't use an internal buffer. Searches for delim in *data. Util_Copy's everything up to that point into buffer, reassigns *data to the next character after delim, or NULL if delim wasn't found. I think this was implemented better than Util_Separate.void Util_Explode(const char *data, char delim, const char **ptr, int len); Inspired by the explode efun from MudOS. ptr is an array of length len. Copies data to an internal buffer, splits it around every occurance of delim (up to len-1), and places pointers to each substring in the ptr array.int Util_Count(const char *data, char delim); Returns the number of occurances of delim in data.void Util_Copy(char *, const char *, unsigned int size); This is basically strlcpy from some OSs. At some point I'll probably rename it to that, and use it only when the OS doesn't provide it.TF Util_Isalnum(const char *); Returns TRUE if every character in a string is alphanumeric.void Util_Cat(char *, const char *, unsigned int size); This is basically strlcat.char Util_hex2dec(char val); Convert a hexadecimal digit to a 4-bit decimal value. Returns -1 if val is not a hexadecimal digit.char Util_dec2hex(char val); Convert a 4-bit decimal value to a hexadecimal digit. Returns a nul character if val is out of range (val>>4 != 0).void Util_Strip(char *, unsigned int size, TF flag); Strips non-alphanumeric characters out of a string. If flag is TRUE, also changes capital letters to lowercase.void Util_Eputs(const char *); Print an error message. This calls fputs on stderr and, if present, options.errlogvoid Util_Eprintf(const char *, ...); Print a formatted error message. This calls fprintf on stderr and, if present, options.errlogchar * Util_FormatA(const char *, ...); Like vasprintf, but returns the formatted string or NULL if allocation failed. Don't forget to free the buffer when you're done with it.const char * Util_Format(const char *, ...); Like vsnprintf, but uses an internal buffer to store the result, and returns a pointer to this buffer. Note that this used to require 4 arguments, and some code still reflects this.const char * Util_FormatD(const char *, const char *, const char *, const char *); Similar to Util_Format. Use this if one of the variables you're formatting into the string may be the internal buffer from utils.c, it checks for this condition and handles it safely. This should probably be considered deprecated. Util_FormatA is a cleaner solution, if just a tad more inconvenient.const char * Util_CTCPFmt(const char *, const char *); This encodes a string with a CTCP command. The second string is the arguments to the command, or NULL if there are no arguments.const char * Util_CTCPFmtD(const char *, const char *); Similar to Util_CTCPFmt, but like Util_FormatD above, deals with the condition of one of the args being the same internal buffer we write to. (This is generally the case if Util_Separate was used to separate the command from its arguments.)@(#) $Id: utils.txt,v 1.1.1.1 2004/01/16 07:28:15 lachesis Exp $
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -