Added more interface for IRI
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 18:46:43 +0000 (15:46 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 18:46:43 +0000 (15:46 -0300)
You can set scheme and host part of IRIs now. You can also get it as a
string, which should be revised, because of the needed separators. You
can also make a copy of a IRI.

include/atompub/iri.h
iri/iri.c

index 0135916..94de6e3 100644 (file)
@@ -26,7 +26,13 @@ typedef struct _iri IRI;
 
 IRI * iri_new (void);
 void iri_delete (IRI *);
 
 IRI * iri_new (void);
 void iri_delete (IRI *);
+IRI * iri_copy (IRI *);
+char *iri_get_scheme (IRI *);
+void iri_set_scheme (IRI *, char *);
+char * iri_get_host (IRI *);
+void iri_set_host (IRI *, char *);
 char * iri_get_path (IRI *);
 void iri_set_path (IRI *, char *);
 char * iri_get_path (IRI *);
 void iri_set_path (IRI *, char *);
+char * iri_get_string (IRI *);
 
 #endif
 
 #endif
index 47b79ac..dd82a6a 100644 (file)
--- a/iri/iri.c
+++ b/iri/iri.c
@@ -51,6 +51,45 @@ iri_delete (IRI *iri)
   g_slice_free (IRI, iri);
 }
 
   g_slice_free (IRI, iri);
 }
 
+IRI *
+iri_copy (IRI *iri)
+{
+  IRI *niri;
+  niri = g_slice_new (IRI);
+  niri->scheme = g_strdup (iri->scheme);
+  niri->host = g_strdup (iri->host);
+  niri->path = g_strdup (iri->path);
+  return niri;
+}
+
+char *
+iri_get_scheme (IRI *iri)
+{
+  return iri->scheme;
+}
+
+void
+iri_set_scheme (IRI *iri, char *scheme)
+{
+  if (iri->scheme)
+    g_free (iri->scheme);
+  iri->scheme = g_strdup (iri->scheme);
+}
+
+char *
+iri_get_host (IRI *iri)
+{
+  return iri->host;
+}
+
+void
+iri_set_host (IRI *iri, char *host)
+{
+  if (iri->host)
+    g_free (iri->host);
+  iri->host = g_strdup (host);
+}
+
 char *
 iri_get_path (IRI *iri)
 {
 char *
 iri_get_path (IRI *iri)
 {
@@ -64,3 +103,11 @@ iri_set_path (IRI *iri, char *path)
     g_free (iri->path);
   iri->path = g_strdup (path);
 }
     g_free (iri->path);
   iri->path = g_strdup (path);
 }
+
+char *
+iri_get_string (IRI *iri)
+{
+  if (iri->scheme == NULL || iri->host == NULL || iri->path == NULL)
+    return NULL;
+  return g_strconcat (iri->scheme, iri->host, iri->path, NULL);
+}