13 #include "regex_win32.h" 16 #ifndef WIN32_LEAN_AND_MEAN 17 #define WIN32_LEAN_AND_MEAN 20 #include "getline_win32.h" 22 #define cis_getpid _getpid 23 #define sleep(tsec) Sleep(1000*tsec) 24 #define usleep(usec) Sleep(usec/1000) 26 #include "regex_posix.h" 29 #define cis_getpid getpid 34 #define CIS_MSG_MAX 2048 36 #define CIS_MSG_MAX 1048576 39 #define CIS_MSG_EOF "EOF!!!" 41 #define CIS_MSG_BUF 2048 43 #define CIS_SLEEP_TIME 250000 46 #define PSI_MSG_MAX CIS_MSG_MAX 47 #define PSI_MSG_BUF CIS_MSG_BUF 48 #define PSI_MSG_EOF CIS_MSG_EOF 50 #define CIS_DEBUG PSI_DEBUG 52 static int _cis_error_flag = 0;
61 unsigned long ptr2seed(
void *ptr) {
62 uint64_t v = (uint64_t)ptr;
63 unsigned long seed = (
unsigned long)(v & 0xFFFFFFFFLL);
92 void cisLog(
const char* prefix,
const char* fmt, va_list ap) {
93 fprintf(stdout,
"%s: %d: ", prefix, cis_getpid());
94 vfprintf(stdout, fmt, ap);
95 fprintf(stdout,
"\n");
107 void cisInfo(
const char* fmt, ...) {
110 cisLog(
"INFO", fmt, ap);
122 void cisDebug(
const char* fmt, ...) {
125 cisLog(
"DEBUG", fmt, ap);
137 void cisError(
const char* fmt, ...) {
140 cisLog(
"ERROR", fmt, ap);
147 #define cislog_error cisError 148 #define cislog_info cisInfo 149 #define cislog_debug cisDebug 150 #elif CIS_DEBUG <= 20 151 #define cislog_error cisError 152 #define cislog_info cisInfo 153 #define cislog_debug while (0) cisDebug 154 #elif CIS_DEBUG <= 40 155 #define cislog_error cisError 156 #define cislog_info while (0) cisInfo 157 #define cislog_debug while (0) cisDebug 159 #define cislog_error while (0) cisError 160 #define cislog_info while (0) cisInfo 161 #define cislog_debug while (0) cisDebug 164 #define cislog_error cisError 165 #define cislog_info while (0) cisInfo 166 #define cislog_debug while (0) cisDebug 176 int not_empty_match(
const char *pattern,
const char *buf) {
181 if (strcmp(buf, pattern) == 0) {
194 int is_eof(
const char *buf) {
195 return not_empty_match(CIS_MSG_EOF, buf);
204 int is_recv(
const char *buf) {
205 return not_empty_match(
"recv", buf);
214 int is_send(
const char *buf) {
215 return not_empty_match(
"send", buf);