public/mms_sample_ext/stub_util.cpp
author Asher Baker <asherkin@gmail.com>
Tue Aug 07 18:04:10 2012 +0100 (2012-08-07)
changeset 3600 8b38b6996600
parent 1990 de135d1f05b1
permissions -rw-r--r--
Changed TFWeaponSlot enum description (r=me).
ds@1990
     1
/**
ds@1990
     2
 * vim: set ts=4 :
ds@1990
     3
 * ======================================================
ds@1990
     4
 * Metamod:Source Stub Plugin
ds@1990
     5
 * Written by AlliedModders LLC.
ds@1990
     6
 * ======================================================
ds@1990
     7
 *
ds@1990
     8
 * This software is provided 'as-is', without any express or implied warranty.
ds@1990
     9
 * In no event will the authors be held liable for any damages arising from 
ds@1990
    10
 * the use of this software.
ds@1990
    11
 *
ds@1990
    12
 * This stub plugin is public domain.
ds@1990
    13
 *
ds@1990
    14
 * Version: $Id$
ds@1990
    15
 */
ds@1990
    16
ds@1990
    17
#include <stdio.h>
ds@1990
    18
#include <stdarg.h>
ds@1990
    19
#include "stub_util.h"
ds@1990
    20
ds@1990
    21
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
ds@1990
    22
{
ds@1990
    23
	va_list ap;
ds@1990
    24
ds@1990
    25
	va_start(ap, fmt);
ds@1990
    26
	size_t len = vsnprintf(buffer, maxlength, fmt, ap);
ds@1990
    27
	va_end(ap);
ds@1990
    28
ds@1990
    29
	if (len >= maxlength)
ds@1990
    30
	{
ds@1990
    31
		len = maxlength - 1;
ds@1990
    32
		buffer[len] = '\0';
ds@1990
    33
	}
ds@1990
    34
ds@1990
    35
	return len;
ds@1990
    36
}
ds@1990
    37
ds@1990
    38