Added more interface for IRI
[cascardo/atompub.git] / iri / iri.c
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);
 }
 
+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)
 {
@@ -64,3 +103,11 @@ iri_set_path (IRI *iri, char *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);
+}