4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * PROPRIETARY/CONFIDENTIAL
10 * This software is the confidential and proprietary information of SAMSUNG ELECTRONICS ("Confidential Information").
11 * You shall not disclose such Confidential Information and shall
12 * use it only in accordance with the terms of the license agreement you entered into with SAMSUNG ELECTRONICS.
13 * SAMSUNG make no representations or warranties about the suitability
14 * of the software, either express or implied, including but not
15 * limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.
16 * SAMSUNG shall not be liable for any damages suffered by licensee as
17 * a result of using, modifying or distributing this software or its derivatives.
23 #define TABLE_NAME "mcc_mnc_oper_list"
24 #define TABLE_SCHEMA "create table " TABLE_NAME " (id integer primary key, country char(3), mcc integer, mnc char(3), oper char(45));"
26 #define dbg(fmt,args...) fprintf(stderr, fmt, ##args);
28 int main(int argc, char *argv[])
42 printf("%s filename.csv\n", argv[0]);
46 fp_in = fopen(argv[1], "r");
52 printf("%s\n", TABLE_SCHEMA);
56 fgets (buf, 255, fp_in);
63 buf[strlen(buf)-1] = '\0';
67 pos1 = strchr (buf, ',');
68 memset (country, 0, 10);
69 memcpy(country, buf, pos1-buf);
71 dbg("country=[%s]\n", country);
73 sscanf (pos1+1, "%d", &mcc);
74 dbg("mcc=[%d]\n", mcc);
77 pos1 = strchr (pos1+1, ',');
78 pos2 = strchr (pos1+1, ',');
80 dbg("mnc=[%s]\n", pos1+1);
83 strncpy (mnc, pos1+1, pos2-pos1-1);
87 pos2 = strchr (pos1+1, ',');
89 dbg("brand=[%s]\n", pos1+1);
91 memset (brand, 0, 255);
92 strncpy (brand, pos1+1, pos2-pos1-1);
96 pos2 = strchr (pos1+1, ',');
98 dbg("oper=[%s]\n", pos1+1);
100 memset (oper, 0, 255);
101 strcpy (oper, pos1+1);
104 if (strlen(brand) == 0)
107 if (oper_select[0] == '\"') {
109 snprintf(buf, strlen(oper_select)-2, "%s", oper_select+1);
110 snprintf(oper_select, 255, "%s", buf);
113 snprintf(buf, 255, "insert into %s "
114 " (country, mcc, mnc, oper) "
115 " values (\"%s\", %d, \"%s\", \"%s\");",
116 TABLE_NAME, country, mcc, mnc, oper_select);