summaryrefslogtreecommitdiff
path: root/src/s/s_Print.cpp
blob: 3a94b0cc915d9eeb1080bcb30112bfcc1b7cea29 (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
#include "s/s_Print.h"

#include "rvl/OS/OSError.h"

#include <cstdarg>
#include <cstdio>
#include <stdio.h>

namespace sLib {

typedef int (*vprintf_sig)(const char *format, va_list args);

static vprintf_sig sPrintfFunc = &std::vprintf;

static vprintf_sig getVprintfFunc() {
    return sPrintfFunc;
}

static void my_vprintf(const char *format, va_list args) {
    (getVprintfFunc())(format, args);
}

void printf(const char *msg, ...) {
    va_list l;
    va_start(l, msg);
    vprintf(msg, l);
    va_end(l);
}

} // namespace sLib

// Overriding the weakly linked OS functions...
void OSReport(const char *msg, ...) {
    va_list l;
    va_start(l, msg);
    OSVReport(msg, l);
    va_end(l);
}

void OSVReport(const char *msg, va_list args) {
    sLib::my_vprintf(msg, args);
}