CUBRID Engine  latest
generate_timezone.cpp
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  * generate_timezone.cpp - internal executable to generate timezones.c file required for cubrid_timezones library
21  */
22 
23 #include "error_manager.h"
24 #include "tz_compile.h"
25 
26 #include <cstring>
27 #include <iostream>
28 
29 void
30 usage (void)
31 {
32  std::cerr << "gen_timezones incorrect usages; requires two arguments:" << std::endl;
33  std::cerr << "\t1. path to input tzdata file" << std::endl;
34  std::cerr << "\t2. path to output timezones.c file" << std::endl;
35 }
36 
37 int
38 main (int argc, char **argv)
39 {
40  // check args
41  if (argc != 3)
42  {
43  usage ();
44  return EXIT_FAILURE;
45  }
46 
47  const char *tzdata_input_path = argv[1];
48  const char *timezones_dot_c_output_path = argv[2];
49  char checksum_str[TZ_CHECKSUM_SIZE + 1];
50 
51  std::memset (checksum_str, 0, sizeof (checksum_str));
52  if (timezone_compile_data (tzdata_input_path, TZ_GEN_TYPE_NEW, NULL, timezones_dot_c_output_path, checksum_str)
53  != NO_ERROR)
54  {
55  assert (false);
56  return EXIT_FAILURE;
57  }
58  else
59  {
60  return EXIT_SUCCESS;
61  }
62 }
#define NO_ERROR
Definition: error_code.h:46
int argc
Definition: dynamic_load.c:951
#define TZ_CHECKSUM_SIZE
#define assert(x)
#define NULL
Definition: freelistheap.h:34
int main(int argc, char **argv)
const char ** argv
Definition: dynamic_load.c:952
void usage(void)