31 #include <sys/timeb.h> 51 for (s = str; *s !=
'\0' && (*s ==
' ' || *s ==
'\t' || *s ==
'\n' || *s ==
'\r'); s++)
60 for (p = s; *p !=
'\0'; p++)
62 for (p--; *p ==
' ' || *p ==
'\t' || *p ==
'\n' || *p ==
'\r'; p--)
67 memmove (str, s,
strlen (s) + 1);
80 for (p = str; *
p; p++)
82 if (*p >=
'A' && *p <=
'Z')
87 #if defined(BROKER_LOG_RUNNER) 104 if (strncmp (buf,
"B ", 1) != 0)
109 type = atoi (buf + 2);
110 if ((type != CCI_U_TYPE_CHAR) && (type != CCI_U_TYPE_STRING) && (type != CCI_U_TYPE_NCHAR)
111 && (type != CCI_U_TYPE_VARNCHAR) && (type != CCI_U_TYPE_BIT) && (type != CCI_U_TYPE_VARBIT)
112 && (type != CCI_U_TYPE_ENUM) && (type != CCI_U_TYPE_JSON))
117 p = strchr (buf + 2,
' ');
120 goto error_on_val_size;
124 p = strchr (p + 1,
' ');
127 goto error_on_val_size;
132 *info_size = (
char *) (p + 1) - (
char *) buf;
137 case CCI_U_TYPE_CHAR:
138 case CCI_U_TYPE_STRING:
139 case CCI_U_TYPE_NCHAR:
140 case CCI_U_TYPE_VARNCHAR:
152 *tot_val_size = len + 1;
159 *tot_val_size = size;
179 char size[256] = { 0, };
196 if (strncmp (msg,
"bind ", 5) != 0)
201 p = strchr (msg,
':');
208 if ((strncmp (p,
"CHAR", 4) != 0) && (strncmp (p,
"VARCHAR", 7) != 0) && (strncmp (p,
"NCHAR", 5) != 0)
209 && (strncmp (p,
"VARNCHAR", 8) != 0) && (strncmp (p,
"BIT", 3) != 0) && (strncmp (p,
"VARBIT", 6) != 0))
224 size_begin = strstr (value_p,
"(");
225 if (size_begin ==
NULL)
227 goto error_on_val_size;
230 size_end = strstr (value_p,
")");
231 if (size_end ==
NULL)
233 goto error_on_val_size;
236 info_end = size_end + 1;
240 *info_size = (
char *) info_end - (
char *) buf;
243 if ((strncmp (p,
"CHAR", 4) != 0) || (strncmp (p,
"VARCHAR", 7) != 0) || (strncmp (p,
"NCHAR", 5) != 0)
244 || (strncmp (p,
"VARNCHAR", 8) != 0))
246 *tot_val_size =
strlen (info_end);
248 else if (tot_val_size)
250 len = size_end - size_begin;
251 if (len > (
int)
sizeof (size))
253 goto error_on_val_size;
257 memcpy (size, size_begin, len);
260 *tot_val_size = atoi (size);
261 if (*tot_val_size < 0)
263 goto error_on_val_size;
287 bool is_first, bind_with_size =
false;
288 int tot_val_size = 0, info_size = 0;
296 memset (buf, 0,
sizeof (buf));
297 position = ftell (fp);
298 if (fgets (buf,
sizeof (buf), fp) ==
NULL)
301 if (strncmp (buf + 19,
"(debug)", 7) == 0)
308 if (tot_val_size < 0 || info_size < 0 || (tot_val_size + info_size + 1) < 0)
310 fprintf (stderr,
"log error\n");
321 value = (
char *)
MALLOC (info_size + tot_val_size + 1);
324 fprintf (stderr,
"memory allocation error.\n");
327 fseek (fp, position, SEEK_SET);
328 rlen = fread ((
void *) value,
sizeof (
char), info_size + tot_val_size, fp);
329 if (
t_bind_string_add (t_str, value, info_size + tot_val_size, tot_val_size) < 0)
331 fprintf (stderr,
"memory allocation error.\n");
342 fprintf (stderr,
"memory allocation error.\n");
345 if (buf[
sizeof (buf) - 2] ==
'\0' || buf[
sizeof (buf) - 2] ==
'\n')
354 *lineno = *lineno + 1;
366 if (str[2] ==
'-' && str[5] ==
'-' && str[8] ==
' ' && str[11] ==
':' && str[14] ==
':' && str[21] ==
' ')
370 else if (str[2] ==
'/' && str[5] ==
' ' && str[8] ==
':' && str[11] ==
':' && str[18] ==
' ')
392 tmp_ptr = strchr (tmp_ptr,
' ');
403 #define DATE_VALUE_COUNT 7 444 sprintf (date_format_str,
"%02d-%02d-%02d %02d:%02d:%02d.%03d", date_val[0], date_val[1], date_val[2], date_val[3],
445 date_val[4], date_val[5], date_val[6]);
455 if (strncmp (msg_p,
"execute ", 8) == 0)
461 else if (strncmp (msg_p,
"execute_call ", 13) == 0)
463 *prepare_flag = 0x40;
465 return (msg_p += 13);
467 else if (strncmp (msg_p,
"execute_all ", 12) == 0)
471 return (msg_p += 12);
501 sec = (end->tv_sec - begin->tv_sec);
502 usec = (double) (end->tv_usec - begin->tv_usec) / 1000000;
#define CAS_LOG_BEGIN_WITH_YEAR
int t_string_add(T_STRING *t_str, char *str, int str_len)
char * get_msg_start_ptr(char *linebuf)
static void begin(char *test_name)
int t_string_len(T_STRING *t_str)
#define CAS_LOG_BEGIN_WITH_MONTH
char * t_string_str(T_STRING *t_str)
int is_cas_log(char *str)
int str_to_int32(int *ret_p, char **end_p, const char *str_p, int base)
int ut_check_log_valid_time(const char *log_date, const char *from_date, const char *to_date)
static void error(const char *msg)
double ut_diff_time(struct timeval *begin, struct timeval *end)
static char from_date[128]
void ut_tolower(char *str)
char * ut_get_execute_type(char *msg_p, int *prepare_flag, int *execute_flag)
static bool is_bind_with_size(char *buf, int *tot_val_size, int *info_size)
char * ut_trim(char *str)
int t_bind_string_add(T_STRING *t_str, char *str, int str_len, int bind_len)
void t_string_clear(T_STRING *t_str)
int ut_get_line(FILE *fp, T_STRING *t_str, char **out_str, int *lineno)
#define CAS_LOG_MSG_INDEX
int str_to_log_date_format(char *str, char *date_format_str)