17 #include "regex_win32.h" 20 #ifndef WIN32_LEAN_AND_MEAN 21 #define WIN32_LEAN_AND_MEAN 24 #include "getline_win32.h" 26 #define cis_getpid _getpid 27 #define sleep(tsec) Sleep(1000*tsec) 28 #define usleep(usec) Sleep(usec/1000) 30 #include "regex_posix.h" 33 #define cis_getpid getpid 38 #define CIS_MSG_MAX 2048 40 #define CIS_MSG_MAX 1048576 43 #define CIS_MSG_EOF "EOF!!!" 45 #define CIS_MSG_BUF 2048 47 #define CIS_SLEEP_TIME 250000 50 #define PSI_MSG_MAX CIS_MSG_MAX 51 #define PSI_MSG_BUF CIS_MSG_BUF 52 #define PSI_MSG_EOF CIS_MSG_EOF 54 #define CIS_DEBUG PSI_DEBUG 56 static int _cis_error_flag = 0;
65 unsigned long ptr2seed(
void *ptr) {
66 uint64_t v = (uint64_t)ptr;
67 unsigned long seed = (
unsigned long)(v & 0xFFFFFFFFLL);
96 void cisLog(
const char* prefix,
const char* fmt, va_list ap) {
97 fprintf(stdout,
"%s: %d: ", prefix, cis_getpid());
98 vfprintf(stdout, fmt, ap);
99 fprintf(stdout,
"\n");
111 void cisInfo(
const char* fmt, ...) {
114 cisLog(
"INFO", fmt, ap);
126 void cisDebug(
const char* fmt, ...) {
129 cisLog(
"DEBUG", fmt, ap);
141 void cisError(
const char* fmt, ...) {
144 cisLog(
"ERROR", fmt, ap);
151 #define cislog_error cisError 152 #define cislog_info cisInfo 153 #define cislog_debug cisDebug 154 #elif CIS_DEBUG <= 20 155 #define cislog_error cisError 156 #define cislog_info cisInfo 157 #define cislog_debug while (0) cisDebug 158 #elif CIS_DEBUG <= 40 159 #define cislog_error cisError 160 #define cislog_info while (0) cisInfo 161 #define cislog_debug while (0) cisDebug 163 #define cislog_error while (0) cisError 164 #define cislog_info while (0) cisInfo 165 #define cislog_debug while (0) cisDebug 168 #define cislog_error cisError 169 #define cislog_info while (0) cisInfo 170 #define cislog_debug while (0) cisDebug 180 int not_empty_match(
const char *pattern,
const char *buf) {
185 if (strcmp(buf, pattern) == 0) {
198 int is_eof(
const char *buf) {
199 return not_empty_match(CIS_MSG_EOF, buf);
208 int is_recv(
const char *buf) {
209 return not_empty_match(
"recv", buf);
218 int is_send(
const char *buf) {
219 return not_empty_match(
"send", buf);