correct version now... i guess i'm just tired :)
3 * ======================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC and authors.
7 * ======================================================
9 * This software is provided 'as-is', without any express or implied warranty.
10 * In no event will the authors be held liable for any damages arising from
11 * the use of this software.
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, subject to the following restrictions:
17 * 1. The origin of this software must not be misrepresented; you must not
18 * claim that you wrote the original software. If you use this software in a
19 * product, an acknowledgment in the product documentation would be
20 * appreciated but is not required.
21 * 2. Altered source versions must be plainly marked as such, and must not be
22 * misrepresented as being the original software.
23 * 3. This notice may not be removed or altered from any source distribution.
28 #ifndef _INCLUDE_UTIL_H
29 #define _INCLUDE_UTIL_H
34 * @brief Utility functions
39 * @brief Returns true is string is not blank, false otherwise.
41 #define IS_STR_FILLED(var) (var != NULL && var[0] != '\0')
44 * @brief Returns a pointer to the extension in a file name.
46 const char *UTIL_GetExtension(const char *file);
49 * @brief Removes C-style comments from string.
51 void UTIL_TrimComments(char *buffer);
54 * @brief Removes whitespace characters from left side of string.
56 void UTIL_TrimLeft(char *buffer);
59 * @brief Removes whitespace characters from right side of string.
61 void UTIL_TrimRight(char *buffer);
64 * @brief Breaks a string at the first space until it reaches a non-space.
66 void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2);
69 * @brief Compares two file paths.
71 bool UTIL_PathCmp(const char *path1, const char *path2);
74 * @brief Same as snprintf except that it ensures the string buffer is null terminated.
76 size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
79 * @brief Same as vsnprintf except that it ensures the string buffer is null terminated.
81 size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list params);
84 * @brief Forms a relative path given two absolute paths.
86 * @param buffer Buffer to store relative path in.
87 * @param maxlength Maximum length of the output buffer.
88 * @param relTo Destination folder to use as a working directory.
89 * Final folder name should not be pathchar-terminated.
90 * @param relFrom Source file or folder to use as a target.
91 * @return True on success, false on failure.
93 bool UTIL_Relatize(char buffer[],
98 #endif //_INCLUDE_UTIL_H