sourcemm/util.h
branchsourcemm-1.6.0
changeset 347 e82968c21606
child 348 716af2e7be78
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sourcemm/util.h	Tue Sep 18 20:03:47 2007 +0000
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* ======== SourceMM ========
     1.5 + * Copyright (C) 2004-2007 Metamod:Source Development Team
     1.6 + * No warranties of any kind
     1.7 + *
     1.8 + * License: zlib/libpng
     1.9 + *
    1.10 + * Author(s): David "BAILOPAN" Anderson
    1.11 + * ============================
    1.12 + */
    1.13 +
    1.14 +#ifndef _INCLUDE_UTIL_H
    1.15 +#define _INCLUDE_UTIL_H
    1.16 +
    1.17 +#include <stdarg.h>
    1.18 +
    1.19 +/**
    1.20 + * @brief Utility functions
    1.21 + * @file util.h
    1.22 + */
    1.23 +
    1.24 +/**
    1.25 + * @brief Returns a pointer to the extension in a file name.
    1.26 + */
    1.27 +const char *UTIL_GetExtension(const char *file);
    1.28 +
    1.29 +/**
    1.30 + * @brief Removes C-style comments from string.
    1.31 + */
    1.32 +void UTIL_TrimComments(char *buffer);
    1.33 +
    1.34 +/**
    1.35 + * @brief Removes whitespace characters from left side of string.
    1.36 + */
    1.37 +void UTIL_TrimLeft(char *buffer);
    1.38 +
    1.39 +/**
    1.40 + * @brief Removes whitespace characters from right side of string.
    1.41 + */
    1.42 +void UTIL_TrimRight(char *buffer);
    1.43 +
    1.44 +/**
    1.45 + * @brief Breaks a string at the first space until it reaches a non-space.
    1.46 + */
    1.47 +void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2);
    1.48 +
    1.49 +/**
    1.50 + * @brief Compares two file paths.
    1.51 + */
    1.52 +bool UTIL_PathCmp(const char *path1, const char *path2);
    1.53 +
    1.54 +/**
    1.55 + * @brief Same as snprintf except that it ensures the string buffer is null terminated.
    1.56 + */
    1.57 +size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
    1.58 +
    1.59 +/**
    1.60 + * @brief Same as vsnprintf except that it ensures the string buffer is null terminated.
    1.61 + */
    1.62 +size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list params);
    1.63 +
    1.64 +/**
    1.65 + * @brief Forms a relative path given two absolute paths.
    1.66 + *
    1.67 + * @param buffer		Buffer to store relative path in.
    1.68 + * @param maxlength		Maximum length of the output buffer.
    1.69 + * @param relTo			Destination folder to use as a working directory.
    1.70 + *						Final folder name should not be pathchar-terminated.
    1.71 + * @param relFrom		Source file or folder to use as a target.
    1.72 + * @return				True on success, false on failure.
    1.73 + */
    1.74 +bool UTIL_Relatize(char buffer[],
    1.75 +				   size_t maxlength,
    1.76 +				   const char *relTo,
    1.77 +				   const char *relFrom);
    1.78 +
    1.79 +#endif //_INCLUDE_UTIL_H