Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ods.cpp « overlay - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0e869f600f5a5406aff923cebaea1afc14897033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2005-2016 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include <stdio.h>
#include <ctype.h>
#include <windows.h>
#include "ods.h"

void __cdecl _ods_out(const char *format, va_list *args) {
	char buf[4096], *p = buf + 2;

	buf[0] = 'M'; // Add a prefix
	buf[1] = ':';

	// Format but be aware of space taken by prefix
	int len = _vsnprintf_s(p, sizeof(buf) - 3, _TRUNCATE, format, *args);


	if (len <= 0)
		return;

	p += len;

	// Truncate trailing spaces
	while (p > (buf + 2) && isspace(p[-1]))
		*--p = '\0';

	// Add custom termination
	if (p > (buf + sizeof(buf) - 3)) { // Make sure there's space
		p = buf + sizeof(buf) - 3;
	}
	*p++ = '\r';
	*p++ = '\n';
	*p   = '\0';

	OutputDebugStringA(buf);
}

void __cdecl fods(const char *format, ...) {
	va_list args;

	va_start(args, format);
	_ods_out(format, &args);
	va_end(args);
}