Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (44 sloc) 1.593 kb
c1a03f22 »
2012-09-14 o Needed convenient sub-second resolution time. Added CurrentTime()
1 // Copyright (C) 2012 Henner Zeller <h.zeller@acm.org>
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
15
a9d3e538 »
2012-09-15 o Found a project name: "Folve". Some renamings because of that.
16 #include "util.h"
17
8268c37e »
2012-09-15 o Bubble up error messages in status server.
18 #include <stdarg.h>
c1a03f22 »
2012-09-14 o Needed convenient sub-second resolution time. Added CurrentTime()
19 #include <stdio.h>
8268c37e »
2012-09-15 o Bubble up error messages in status server.
20 #include <sys/time.h>
c1a03f22 »
2012-09-14 o Needed convenient sub-second resolution time. Added CurrentTime()
21
a9d3e538 »
2012-09-15 o Found a project name: "Folve". Some renamings because of that.
22 double folve::CurrentTime() {
c1a03f22 »
2012-09-14 o Needed convenient sub-second resolution time. Added CurrentTime()
23 struct timeval tv;
24 gettimeofday(&tv, NULL);
25 return tv.tv_sec + tv.tv_usec / 1e6;
26 }
8268c37e »
2012-09-15 o Bubble up error messages in status server.
27
3e883b73 »
2012-09-18 o Match filters in sequence
28 static void vAppendf(std::string *str, const char *format, va_list ap) {
8268c37e »
2012-09-15 o Bubble up error messages in status server.
29 const size_t orig_len = str->length();
3e883b73 »
2012-09-18 o Match filters in sequence
30 const size_t space = 1024; // there should be better ways to do this...
8268c37e »
2012-09-15 o Bubble up error messages in status server.
31 str->resize(orig_len + space);
32 int written = vsnprintf((char*)str->data() + orig_len, space, format, ap);
33 str->resize(orig_len + written);
34 }
3e883b73 »
2012-09-18 o Match filters in sequence
35
36 void folve::Appendf(std::string *str, const char *format, ...) {
37 va_list ap;
38 va_start(ap, format);
39 vAppendf(str, format, ap);
40 va_end(ap);
41 }
42
43 std::string folve::StringPrintf(const char *format, ...) {
44 std::string result;
45 va_list ap;
46 va_start(ap, format);
47 vAppendf(&result, format, ap);
48 va_end(ap);
49 return result;
50 }
Something went wrong with that request. Please try again.