1 /* ======== SourceMM ========
2 * Copyright (C) 2004-2007 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): David "BAILOPAN" Anderson
8 * ============================
11 #ifndef _INCLUDE_UTIL_H
12 #define _INCLUDE_UTIL_H
17 * @brief Utility functions
22 * @brief Returns a pointer to the extension in a file name.
24 const char *UTIL_GetExtension(const char *file);
27 * @brief Removes C-style comments from string.
29 void UTIL_TrimComments(char *buffer);
32 * @brief Removes whitespace characters from left side of string.
34 void UTIL_TrimLeft(char *buffer);
37 * @brief Removes whitespace characters from right side of string.
39 void UTIL_TrimRight(char *buffer);
42 * @brief Breaks a string at the first space until it reaches a non-space.
44 void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2);
47 * @brief Compares two file paths.
49 bool UTIL_PathCmp(const char *path1, const char *path2);
52 * @brief Same as snprintf except that it ensures the string buffer is null terminated.
54 size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
57 * @brief Same as vsnprintf except that it ensures the string buffer is null terminated.
59 inline size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list params)
61 size_t len = vsnprintf(buffer, maxlength, fmt, params);
72 #endif //_INCLUDE_UTIL_H