1 #include <string.h>
2 #include <glib.h>
4 // FIXME: kill this ugliness when we have a proper CSS parser
5 gchar *extract_uri(gchar const *s)
6 {
7 gchar const *sb = s;
8 g_assert( strncmp(sb, "url", 3) == 0 );
9 sb += 3;
11 while ( ( *sb == ' ' ) ||
12 ( *sb == '(' ) )
13 {
14 sb++;
15 }
17 gchar const *se = sb + strlen(sb);
18 while ( ( se[-1] == ' ' ) ||
19 ( se[-1] == ')' ) )
20 {
21 se--;
22 }
24 if ( sb < se ) {
25 return g_strndup(sb, se - sb);
26 } else {
27 return NULL;
28 }
29 }
31 /*
32 Local Variables:
33 mode:c++
34 c-file-style:"stroustrup"
35 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
36 indent-tabs-mode:nil
37 fill-column:99
38 End:
39 */
40 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :