2 * Copyright (C) 2007 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 int main (int argc, char **argv)
36 g_critical ("No input file.");
40 channel = g_io_channel_new_file (argv[1], "r", &error);
43 g_critical ("Could not open file: %s", error->message);
47 db = dpopen ("palestras", DP_OWRITER | DP_OCREAT, 0);
50 g_critical ("Could not create database.");
54 for (st = g_io_channel_read_line (channel, &str, &len, NULL, &error);
55 st == G_IO_STATUS_NORMAL;
56 st = g_io_channel_read_line (channel, &str, &len, NULL, &error))
60 fields = g_strsplit (g_strchomp (str), ";", 0);
61 if (fields != NULL || fields[0] != NULL)
63 for (i = 1; fields[i] != NULL; i+=3)
65 if (fields[i+2] != NULL)
71 cbmapput (map, "id", -1, fields[0], -1, 0);
72 cbmapput (map, "palestra", -1, fields[i], -1, 0);
73 cbmapput (map, "palestrantes", -1, fields[i+1], -1, 0);
74 cbmapput (map, "email", -1, fields[i+2], -1, 0);
75 val = cbmapdump (map, &vlen);
77 dpput (db, (char *) &(records), sizeof records, val, vlen, DP_DOVER);
86 g_io_channel_close (channel);