6 #define _FILE_OFFSET_BITS 64
9 #ifndef __STDC_FORMAT_MACROS
10 #define __STDC_FORMAT_MACROS
33 void err(
int eval,
const char *fmt,...)
37 vfprintf(stderr,fmt,ap);
39 fprintf(stderr,
": %s\n",strerror(errno));
46 void errx(
int eval,
const char *fmt,...)
50 vfprintf(stderr,fmt,ap);
51 fprintf(stderr,
"%s\n",strerror(errno));
59 void warn(
const char *fmt, ...)
63 vfprintf(stderr,fmt, args);
64 fprintf(stderr,
": %s\n",strerror(errno));
74 vfprintf(stderr,fmt,ap);
85 #ifndef HAVE_LOCALTIME_R
102 struct tm *tmret = gmtime(t);
106 memset(tm,0,
sizeof(*tm));
114 bool ends_with(
const std::string &buf,
const std::string &with)
116 size_t buflen = buf.size();
117 size_t withlen = with.size();
118 return buflen>withlen && buf.substr(buflen-withlen,withlen)==with;
121 bool ends_with(
const std::wstring &buf,
const std::wstring &with)
123 size_t buflen = buf.size();
124 size_t withlen = with.size();
125 return buflen>withlen && buf.substr(buflen-withlen,withlen)==with;
133 std::vector<std::string> &
split(
const std::string &s,
char delim, std::vector<std::string> &elems)
135 std::stringstream ss(s);
137 while(std::getline(ss, item, delim)) {
138 elems.push_back(item);
143 std::vector<std::string>
split(
const std::string &s,
char delim)
145 std::vector<std::string> elems;
146 return split(s, delim, elems);
bool ends_with(const std::string &buf, const std::string &with)
void localtime_r(time_t *t, struct tm *tm)
void warnx(const char *fmt,...)
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
void gmtime_r(time_t *t, struct tm *tm)
void err(int eval, const char *fmt,...)
void errx(int eval, const char *fmt,...)
void warn(const char *fmt,...)