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 size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list params);
62 * @brief Forms a relative path given two absolute paths.
64 * @param buffer Buffer to store relative path in.
65 * @param maxlength Maximum length of the output buffer.
66 * @param relTo Destination folder to use as a working directory.
67 * Final folder name should not be pathchar-terminated.
68 * @param relFrom Source file or folder to use as a target.
69 * @return True on success, false on failure.
71 bool UTIL_Relatize(char buffer[],
76 #endif //_INCLUDE_UTIL_H