tcpflow  1.6.1
About: tcpflow is a TCP/IP packet demultiplexer that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis and debugging.
  Fossies Dox: tcpflow-1.6.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

utils.h
Go to the documentation of this file.
1 /****************************************************************
2  *** utils.h
3  ***
4  *** To use utils.c/utils.h, be sure this is in your configure.ac file:
5  m4_include([be13_api/be13_configure.m4])
6  ***
7  ****************************************************************/
8 
9 
10 
11 #ifndef UTILS_H
12 #define UTILS_H
13 
14 #include <sys/types.h>
15 #include <stdint.h>
16 #include <sys/time.h>
17 
18 #if defined(__cplusplus)
19 #include <string>
20 #include <vector>
21 bool ends_with(const std::string &buf,const std::string &with);
22 bool ends_with(const std::wstring &buf,const std::wstring &with);
23 std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
24 std::vector<std::string> split(const std::string &s, char delim);
25 #endif
26 
27 
28 
29 #ifndef __BEGIN_DECLS
30 #if defined(__cplusplus)
31 #define __BEGIN_DECLS extern "C" {
32 #define __END_DECLS }
33 #else
34 #define __BEGIN_DECLS
35 #define __END_DECLS
36 #endif
37 #endif
38 
40 
41 #ifdef HAVE_ERR_H
42 #include <err.h>
43 #else
44 [[noreturn]] void err(int eval,const char *fmt,...) __attribute__((format(printf, 2, 0)));
45 [[noreturn]] void errx(int eval,const char *fmt,...) __attribute__((format(printf, 2, 0)));
46 void warn(const char *fmt, ...) __attribute__((format(printf, 1, 0)));
47 void warnx(const char *fmt,...) __attribute__((format(printf, 1, 0)));
48 #endif
49 
50 #ifndef HAVE_LOCALTIME_R
51 #ifdef __MINGW32__
52 #undef localtime_r
53 #endif
54 void localtime_r(time_t *t,struct tm *tm);
55 #endif
56 
57 #ifndef HAVE_GMTIME_R
58 #ifdef __MINGW32__
59 #undef gmtime_r
60 #endif
61 void gmtime_r(time_t *t,struct tm *tm);
62 #endif
63 
64 int64_t get_filesize(int fd);
65 
66 #ifndef HAVE_ISHEXNUMBER
67 int ishexnumber(int c);
68 inline int ishexnumber(int c)
69 {
70  switch(c){
71  case '0': case '1': case '2': case '3': case '4':
72  case '5': case '6': case '7': case '8': case '9':
73  case 'A': case 'B': case 'C': case 'D': case 'E':
74  case 'F': case 'a': case 'b': case 'c': case 'd':
75  case 'e': case 'f':
76  return 1;
77  }
78  return 0;
79 }
80 #endif
82 
83 
84 #endif
int c
Definition: tcpdemux.cpp:366
bool ends_with(const std::string &buf, const std::string &with)
Definition: utils.cpp:114
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
Definition: utils.cpp:133
#define __END_DECLS
Definition: utils.h:35
void localtime_r(time_t *t, struct tm *tm)
Definition: utils.cpp:88
#define __BEGIN_DECLS
Definition: utils.h:34
void warnx(const char *fmt,...)
Definition: utils.cpp:70
void gmtime_r(time_t *t, struct tm *tm)
Definition: utils.cpp:98
int64_t get_filesize(int fd)
int ishexnumber(int c)
Definition: utils.h:68
void err(int eval, const char *fmt,...)
Definition: utils.cpp:33
void errx(int eval, const char *fmt,...)
Definition: utils.cpp:46
void warn(const char *fmt,...)
Definition: utils.cpp:59