Update for hl2sdk-l4d changes.
3 * ======================================================
5 * Copyright (C) 2004-2008 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 whitespace characters from left side of string.
51 void UTIL_TrimLeft(char *buffer);
54 * @brief Removes whitespace characters from right side of string.
56 void UTIL_TrimRight(char *buffer);
59 * @brief Compares two file paths.
61 bool UTIL_PathCmp(const char *path1, const char *path2);
64 * @brief Same as snprintf except that it ensures the string buffer is null terminated.
66 size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
69 * @brief Same as vsnprintf except that it ensures the string buffer is null terminated.
71 size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list params);
74 * @brief Forms a relative path given two absolute paths.
76 * @param buffer Buffer to store relative path in.
77 * @param maxlength Maximum length of the output buffer.
78 * @param relTo Destination folder to use as a working directory.
79 * Final folder name should not be pathchar-terminated.
80 * @param relFrom Source file or folder to use as a target.
81 * @return True on success, false on failure.
83 bool UTIL_Relatize(char buffer[],
89 * @brief Compares memory address against a signature.
91 * @param addr Memory address to check.
92 * @param sig Signature used to check against memory address. Accept 0x2A as wildcard.
93 * @param len Length of signature.
94 * @return True if signature was verified, false otherwise.
96 bool UTIL_VerifySignature(const void *addr, const char *sig, size_t len);
98 #endif //_INCLUDE_UTIL_H