summaryrefslogtreecommitdiffstats
path: root/src/extract-uri.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2006-01-16 02:36:01 +0000
committermental <mental@users.sourceforge.net>2006-01-16 02:36:01 +0000
commit179fa413b047bede6e32109e2ce82437c5fb8d34 (patch)
treea5a6ac2c1708bd02288fbd8edb2ff500ff2e0916 /src/extract-uri.cpp
downloadinkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.tar.gz
inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.zip
moving trunk for module inkscape
(bzr r1)
Diffstat (limited to 'src/extract-uri.cpp')
-rw-r--r--src/extract-uri.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/extract-uri.cpp b/src/extract-uri.cpp
new file mode 100644
index 000000000..dd6549c8f
--- /dev/null
+++ b/src/extract-uri.cpp
@@ -0,0 +1,40 @@
+#include <string.h>
+#include <glib.h>
+
+// FIXME: kill this ugliness when we have a proper CSS parser
+gchar *extract_uri(gchar const *s)
+{
+ gchar const *sb = s;
+ g_assert( strncmp(sb, "url", 3) == 0 );
+ sb += 3;
+
+ while ( ( *sb == ' ' ) ||
+ ( *sb == '(' ) )
+ {
+ sb++;
+ }
+
+ gchar const *se = sb + strlen(sb);
+ while ( ( se[-1] == ' ' ) ||
+ ( se[-1] == ')' ) )
+ {
+ se--;
+ }
+
+ if ( sb < se ) {
+ return g_strndup(sb, se - sb);
+ } else {
+ return NULL;
+ }
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :