wangzhengquan
2020-08-06 203df24a403a8c0cd8e93d0f33eaf10de2788969
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * Our own header, to be included before all standard system headers.
 */
 
#ifndef __USG_COMMON_H__
#define __USG_COMMON_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <setjmp.h>
#include <signal.h>
#include <dirent.h>
#include <time.h>
#include <sched.h>
 
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/file.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <errno.h>
#include <math.h>
#include <pthread.h>
#include <semaphore.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <libgen.h>
/*
 * define int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t
*/
#include <stdint.h>
#include <assert.h>
 
#ifdef __cplusplus
}
#endif
 
 
 
//c++ header
#ifdef __cplusplus
 
 
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
 
#include <cstdlib>
#include <atomic>
#include <algorithm>
#include <iomanip>
#include <limits>
 
#include <initializer_list>
#include <vector>
#include <map>
#include <set>
 
#include <thread>
 
#endif
 
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Our own error-handling functions */
 
void err_exit(int error, const char *fmt, ...);
void err_msg(int error, const char *fmt, ...);
 
char *ltrim(char *str, const char *seps);
char *rtrim(char *str, const char *seps);
char *trim(char *str, const char *seps);
 
static inline int 
itoa(int num, char *str) 
{
    return sprintf(str, "%d", num); 
 
}
 
static inline int 
ftoa(float num, char *str) 
{
     return sprintf(str, "%f", num); 
 
}
 
 
 
#ifdef __cplusplus
}
#endif
 
 
 
#ifdef __cplusplus
 
// static inline std::string& ltrim(std::string& str, const std::string& chars = "\t\n\v\f\r ")
// {
//     str.erase(0, str.find_first_not_of(chars));
//     return str;
// }
 
// static inline std::string& rtrim(std::string& str, const std::string& chars = "\t\n\v\f\r ")
// {
//     str.erase(str.find_last_not_of(chars) + 1);
//     return str;
// }
 
// static inline std::string& trim(std::string& str, const std::string& chars = "\t\n\v\f\r ")
// {
//     return ltrim(rtrim(str, chars), chars);
// }
 
 
#endif
 
#endif