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.
22 #include "avaliacao.h"
29 regex_eval (const GMatchInfo *info, GString *result, gpointer data)
36 match = g_match_info_fetch (info, 1);
37 smap = vlcurval (db, &slen);
38 map = cbmapload (smap, slen);
39 val = cbmapget (map, match + 1, -1, NULL);
40 g_string_append (result, val);
48 regex_create_message ()
53 message = g_regex_replace_eval (regex, regex_str, regex_len,
54 0, 0, regex_eval, NULL, &error);
66 channel = g_io_channel_new_file ("message", "r", &error);
69 g_critical ("Could not open file: %s", error->message);
73 st = g_io_channel_read_to_end (channel, ®ex_str, ®ex_len, &error);
74 if (st != G_IO_STATUS_NORMAL)
76 g_critical ("Could not read file: %s", error->message);
80 g_io_channel_close (channel);
81 regex = g_regex_new ("(?<!\\\\)(\\\\[[:alpha:]][[:alnum:]]*)", 0, 0, &error);
84 g_critical ("Error creating regex: %s", error->message);