CUBRID Engine  latest
broker_log_time.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * broker_log_time.c -
22  */
23 
24 #ident "$Id$"
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <errno.h>
29 
30 #include "cas_common.h"
31 #include "broker_log_time.h"
32 
33 #if defined (ENABLE_UNUSED_FUNCTION)
34 int
35 log_time_make (char *str, T_LOG_TIME * ltm)
36 {
37  int hour, min, sec, msec;
38 
39  if (sscanf (str, "%*d%*c%*d%*c%d%*c%d%*c%d%*c%d", &hour, &min, &sec, &msec) < 4)
40  {
41  fprintf (stderr, "time format error[%s]\n", str);
42  return -1;
43  }
44 
45  ltm->hour = hour;
46  ltm->min = min;
47  ltm->sec = sec;
48  ltm->msec = msec;
49 
50  return 0;
51 }
52 
53 int
54 log_time_diff (T_LOG_TIME * t1, T_LOG_TIME * t2)
55 {
56  int diff;
57 
58  diff = (t2->hour - t1->hour) * 3600;
59  diff += (t2->min - t1->min) * 60;
60  diff += (t2->sec - t1->sec);
61  diff *= 1000;
62  diff += (t2->msec - t1->msec);
63  return diff;
64 }
65 #endif /* ENABLE_UNUSED_FUNCTION */
#define diff
Definition: mprec.h:352
#define min(a, b)