[cvs-annodex] commit (/annodex): libannodex/trunk/src/libannodex/anx_element.c libannodex/trunk/src/libannodex/anx_read.c +libannodex/trunk/src/libannodex/anx_element.h

conrad nobody at lists.annodex.net
Tue Jan 25 20:43:06 EST 2005


Update of /annodex (new revision 731)

Added files:
   libannodex/trunk/src/libannodex/anx_element.h

Modified files:
   libannodex/trunk/src/libannodex/anx_element.c
   libannodex/trunk/src/libannodex/anx_read.c

Log Message:
move anx_head_from_xtag(), anx_clip_from_xtag() into anx_element.c for re-use


Modified: libannodex/trunk/src/libannodex/anx_element.c
===================================================================
--- libannodex/trunk/src/libannodex/anx_element.c	2005-01-25 09:31:03 UTC (rev 730)
+++ libannodex/trunk/src/libannodex/anx_element.c	2005-01-25 09:43:04 UTC (rev 731)
@@ -39,6 +39,8 @@
 
 #include "anx_snprint.h"
 
+#include "xtag.h"
+
 AnxMetaElement *
 anx_meta_element_clone (AnxMetaElement * meta)
 {
@@ -121,6 +123,50 @@
   return NULL;
 }
 
+AnxHead *
+anx_head_from_xtag (XTag * tag)
+{
+  AnxHead * head;
+  AnxMetaElement * meta;
+  XTag * child;
+
+  if (tag == NULL) return NULL;
+
+  head = anx_malloc (sizeof(AnxHead));
+
+  head->head_id = xtag_get_attribute (tag, "id");
+  head->lang = xtag_get_attribute (tag, "lang");
+  head->dir = xtag_get_attribute (tag, "dir");
+  head->profile = xtag_get_attribute (tag, "profile");
+
+  child = xtag_first_child (tag, "title");
+  head->title = xtag_get_pcdata (child);
+  head->title_id = xtag_get_attribute (child, "id");
+  head->title_lang = xtag_get_attribute (child, "lang");
+  head->title_dir = xtag_get_attribute (child, "dir");
+
+  child = xtag_first_child (tag, "base");
+  head->base_id = xtag_get_attribute (child, "id");
+  head->base_href = xtag_get_attribute (child, "href");
+
+  head->meta = anx_list_new ();
+
+  for (child = xtag_first_child (tag, "meta"); child;
+       child = xtag_next_child (tag, "meta")) {
+    meta = anx_malloc (sizeof (AnxMetaElement));
+    meta->id = xtag_get_attribute (child, "id");
+    meta->lang = xtag_get_attribute (child, "lang");
+    meta->dir = xtag_get_attribute (child, "dir");
+    meta->name = xtag_get_attribute (child, "name");
+    meta->content = xtag_get_attribute (child, "content");
+    meta->scheme = xtag_get_attribute (child, "scheme");
+
+    head->meta = anx_list_append (head->meta, meta);
+  }
+
+  return head;
+}
+
 AnxClip *
 anx_clip_clone (AnxClip * clip)
 {
@@ -188,3 +234,56 @@
 
   return NULL;
 }
+
+AnxClip *
+anx_clip_from_xtag (XTag * tag)
+{
+  AnxClip * clip;
+  AnxMetaElement * meta;
+  XTag * child;
+
+  clip = anx_malloc (sizeof(AnxClip));
+
+  clip->clip_id = xtag_get_attribute (tag, "id");
+  clip->lang = xtag_get_attribute (tag, "lang");
+  clip->dir = xtag_get_attribute (tag, "dir");
+  clip->track = xtag_get_attribute (tag, "track");
+
+  child = xtag_first_child (tag, "a");
+  clip->anchor_id = xtag_get_attribute (child, "id");
+  clip->anchor_lang = xtag_get_attribute (child, "lang");
+  clip->anchor_dir = xtag_get_attribute (child, "dir");
+  clip->anchor_class = xtag_get_attribute (child, "class");
+  clip->anchor_href = xtag_get_attribute (child, "href");
+  clip->anchor_text = xtag_get_pcdata (child);
+
+  child = xtag_first_child (tag, "img");
+  clip->img_id = xtag_get_attribute (child, "id");
+  clip->img_lang = xtag_get_attribute (child, "lang");
+  clip->img_dir = xtag_get_attribute (child, "dir");
+  clip->img_src = xtag_get_attribute (child, "src");
+  clip->img_alt = xtag_get_attribute (child, "alt");
+
+  clip->meta = anx_list_new ();
+
+  for (child = xtag_first_child (tag, "meta"); child;
+       child = xtag_next_child (tag, "meta")) {
+    meta = anx_malloc (sizeof (AnxMetaElement));
+    meta->id = xtag_get_attribute (child, "id");
+    meta->lang = xtag_get_attribute (child, "lang");
+    meta->dir = xtag_get_attribute (child, "dir");
+    meta->name = xtag_get_attribute (child, "name");
+    meta->content = xtag_get_attribute (child, "content");
+    meta->scheme = xtag_get_attribute (child, "scheme");
+
+    clip->meta = anx_list_append (clip->meta, meta);
+  }
+
+  child = xtag_first_child (tag, "desc");
+  clip->desc_id = xtag_get_attribute (child, "id");
+  clip->desc_lang = xtag_get_attribute (child, "lang");
+  clip->desc_dir = xtag_get_attribute (child, "dir");
+  clip->desc_text = xtag_get_pcdata (child);
+
+  return clip;
+}

Added: libannodex/trunk/src/libannodex/anx_element.h
===================================================================
--- libannodex/trunk/src/libannodex/anx_element.h	2005-01-25 09:31:03 UTC (rev 730)
+++ libannodex/trunk/src/libannodex/anx_element.h	2005-01-25 09:43:04 UTC (rev 731)
@@ -0,0 +1,42 @@
+/*
+   Copyright (C) 2005 Commonwealth Scientific and Industrial Research
+   Organisation (CSIRO) Australia
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   - Neither the name of CSIRO Australia nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+   PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __ANX_ELEMENT_H__
+#define __ANX_ELEMENT_H__
+
+#include <config.h>
+#include "xtag.h"
+
+AnxHead * anx_head_from_xtag (XTag * tag);
+AnxClip * anx_clip_from_xtag (XTag * tag);
+
+#endif /* __ANX_ELEMENT_H__ */

Modified: libannodex/trunk/src/libannodex/anx_read.c
===================================================================
--- libannodex/trunk/src/libannodex/anx_read.c	2005-01-25 09:31:03 UTC (rev 730)
+++ libannodex/trunk/src/libannodex/anx_read.c	2005-01-25 09:43:04 UTC (rev 731)
@@ -44,9 +44,8 @@
 #include <time.h>
 
 #include "anx_private.h"
+#include "anx_element.h"
 
-#include "xtag.h"
-
 /*#define DEBUG*/
 
 #define CHUNKSIZE 8500
@@ -467,103 +466,7 @@
   return cb_ret;
 }
 
-static AnxHead *
-anx_head_from_xtag (XTag * tag)
-{
-  AnxHead * head;
-  AnxMetaElement * meta;
-  XTag * child;
 
-  if (tag == NULL) return NULL;
-
-  head = anx_malloc (sizeof(AnxHead));
-
-  head->head_id = xtag_get_attribute (tag, "id");
-  head->lang = xtag_get_attribute (tag, "lang");
-  head->dir = xtag_get_attribute (tag, "dir");
-  head->profile = xtag_get_attribute (tag, "profile");
-
-  child = xtag_first_child (tag, "title");
-  head->title = xtag_get_pcdata (child);
-  head->title_id = xtag_get_attribute (child, "id");
-  head->title_lang = xtag_get_attribute (child, "lang");
-  head->title_dir = xtag_get_attribute (child, "dir");
-
-  child = xtag_first_child (tag, "base");
-  head->base_id = xtag_get_attribute (child, "id");
-  head->base_href = xtag_get_attribute (child, "href");
-
-  head->meta = anx_list_new ();
-
-  for (child = xtag_first_child (tag, "meta"); child;
-       child = xtag_next_child (tag, "meta")) {
-    meta = anx_malloc (sizeof (AnxMetaElement));
-    meta->id = xtag_get_attribute (child, "id");
-    meta->lang = xtag_get_attribute (child, "lang");
-    meta->dir = xtag_get_attribute (child, "dir");
-    meta->name = xtag_get_attribute (child, "name");
-    meta->content = xtag_get_attribute (child, "content");
-    meta->scheme = xtag_get_attribute (child, "scheme");
-
-    head->meta = anx_list_append (head->meta, meta);
-  }
-
-  return head;
-}
-
-static AnxClip *
-anx_clip_from_xtag (XTag * tag)
-{
-  AnxClip * clip;
-  AnxMetaElement * meta;
-  XTag * child;
-
-  clip = anx_malloc (sizeof(AnxClip));
-
-  clip->clip_id = xtag_get_attribute (tag, "id");
-  clip->lang = xtag_get_attribute (tag, "lang");
-  clip->dir = xtag_get_attribute (tag, "dir");
-  clip->track = xtag_get_attribute (tag, "track");
-
-  child = xtag_first_child (tag, "a");
-  clip->anchor_id = xtag_get_attribute (child, "id");
-  clip->anchor_lang = xtag_get_attribute (child, "lang");
-  clip->anchor_dir = xtag_get_attribute (child, "dir");
-  clip->anchor_class = xtag_get_attribute (child, "class");
-  clip->anchor_href = xtag_get_attribute (child, "href");
-  clip->anchor_text = xtag_get_pcdata (child);
-
-  child = xtag_first_child (tag, "img");
-  clip->img_id = xtag_get_attribute (child, "id");
-  clip->img_lang = xtag_get_attribute (child, "lang");
-  clip->img_dir = xtag_get_attribute (child, "dir");
-  clip->img_src = xtag_get_attribute (child, "src");
-  clip->img_alt = xtag_get_attribute (child, "alt");
-
-  clip->meta = anx_list_new ();
-
-  for (child = xtag_first_child (tag, "meta"); child;
-       child = xtag_next_child (tag, "meta")) {
-    meta = anx_malloc (sizeof (AnxMetaElement));
-    meta->id = xtag_get_attribute (child, "id");
-    meta->lang = xtag_get_attribute (child, "lang");
-    meta->dir = xtag_get_attribute (child, "dir");
-    meta->name = xtag_get_attribute (child, "name");
-    meta->content = xtag_get_attribute (child, "content");
-    meta->scheme = xtag_get_attribute (child, "scheme");
-
-    clip->meta = anx_list_append (clip->meta, meta);
-  }
-
-  child = xtag_first_child (tag, "desc");
-  clip->desc_id = xtag_get_attribute (child, "id");
-  clip->desc_lang = xtag_get_attribute (child, "lang");
-  clip->desc_dir = xtag_get_attribute (child, "dir");
-  clip->desc_text = xtag_get_pcdata (child);
-
-  return clip;
-}
-
 static int
 anx_read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
 {


-- 
conrad



More information about the cvs-annodex mailing list