-
Notifications
You must be signed in to change notification settings - Fork 4
/
utils.cc
39 lines (30 loc) · 833 Bytes
/
utils.cc
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
/*
Ghost File System, or simply GhostFS
Copyright (C) 2016 Raphael S. Carvalho
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
*/
#include "utils.h"
#include <sstream>
#include <stdarg.h>
std::vector<std::string> &split(const std::string &s, char delim,
std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
}
std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}
int log(const char *format, ...) {
va_list args;
va_start(args, format);
int ret = vprintf(format, args);
va_end(args);
return ret;
}