[tracker/direct-access: 45/121] libtracker-sparql: Added utils file for escaping mostly
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access: 45/121] libtracker-sparql: Added utils file for escaping mostly
- Date: Thu, 22 Jul 2010 14:47:38 +0000 (UTC)
commit be9275bb5680f8e038b5fe958623e0224da9ceae
Author: Martyn Russell <martyn lanedo com>
Date: Tue Jul 13 17:35:40 2010 +0100
libtracker-sparql: Added utils file for escaping mostly
src/libtracker-sparql/Makefile.am | 3 +-
src/libtracker-sparql/tracker-utils.vala | 59 ++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-sparql/Makefile.am b/src/libtracker-sparql/Makefile.am
index 591d6ef..17a992d 100644
--- a/src/libtracker-sparql/Makefile.am
+++ b/src/libtracker-sparql/Makefile.am
@@ -14,11 +14,12 @@ lib_LTLIBRARIES = libtracker-sparql- TRACKER_API_VERSION@.la
libtracker_sparqlincludedir = $(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-sparql
libtracker_sparql_la_VALASOURCES = \
+ tracker-builder.vala \
tracker-connection.vala \
tracker-cursor.vala \
tracker-plugin-loader.vala \
tracker-query.vala \
- tracker-builder.vala
+ tracker-utils.vala
libtracker_sparql_ TRACKER_API_VERSION@_la_SOURCES = \
libtracker-sparql.vala.stamp \
diff --git a/src/libtracker-sparql/tracker-utils.vala b/src/libtracker-sparql/tracker-utils.vala
new file mode 100644
index 0000000..198a3c5
--- /dev/null
+++ b/src/libtracker-sparql/tracker-utils.vala
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+public unowned string tracker_sparql_escape_string (string literal) {
+ StringBuilder str = new StringBuilder ();
+ char *p = literal;
+
+ while (*p != '\0') {
+ size_t len = Posix.strcspn ((string) p, "\t\n\r\"\\");
+ str.append_len ((string) p, (long) len);
+ p += len;
+
+ switch (*p) {
+ case '\t':
+ str.append ("\\t");
+ break;
+ case '\n':
+ str.append ("\\n");
+ break;
+ case '\r':
+ str.append ("\\r");
+ break;
+ case '\b':
+ str.append ("\\b");
+ break;
+ case '\f':
+ str.append ("\\f");
+ break;
+ case '"':
+ str.append ("\\\"");
+ break;
+ case '\\':
+ str.append ("\\\\");
+ break;
+ default:
+ continue;
+ }
+
+ p++;
+ }
+
+ return str.str;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]