[cvs-annodex] commit (/annodex): libannodex/trunk/include/annodex/anx_general.h libannodex/trunk/src/libannodex/annodex.c

conrad nobody at lists.annodex.net
Thu Apr 14 21:54:46 EST 2005


Update of /annodex (new revision 1250)

Modified files:
   libannodex/trunk/include/annodex/anx_general.h
   libannodex/trunk/src/libannodex/annodex.c

Log Message:
libannodex: add anx_get_mode() function, for ticket:98
Also clean up flag setting functions, and ensure only ANX_READ or ANX_WRITE
is stored.


Modified: libannodex/trunk/include/annodex/anx_general.h
===================================================================
--- libannodex/trunk/include/annodex/anx_general.h	2005-04-14 11:52:26 UTC (rev 1249)
+++ libannodex/trunk/include/annodex/anx_general.h	2005-04-14 11:54:45 UTC (rev 1250)
@@ -62,28 +62,37 @@
 const char * anx_strerror (ANNODEX * annodex);
 
 /**
+ * Get the mode of an Annodex
+ * \param annodex an ANNODEX* handle
+ * \retval ANX_READ \a annodex is a reader
+ * \retval ANX_WRITE \a annodex is a writer
+ * \retval ANX_ERR_INVALID \a annodex is invalid
+ */
+int anx_get_mode (ANNODEX * annodex);
+
+/**
  * Open a file containing Annodex media
  * \param filename path to the file
- * \param flags ANX_READ or ANX_WRITE
+ * \param mode ANX_READ or ANX_WRITE
  * \returns an ANNODEX* handle
  */
-ANNODEX * anx_open (char * filename, int flags);
+ANNODEX * anx_open (char * filename, int mode);
 
 /**
  * Attach to an existing file descriptor
  * \param fd an open file descriptor
- * \param flags ANX_READ or ANX_WRITE
+ * \param mode ANX_READ or ANX_WRITE
  * \returns an ANNODEX* handle
  */
-ANNODEX * anx_open_stdio (FILE * file, int flags);
+ANNODEX * anx_open_stdio (FILE * file, int mode);
 
 /**
  * Create a managed Annodex handle
  * This is an alternative interface for non-file annodexes
- * \param flags ANX_READ or ANX_WRITE
+ * \param mode ANX_READ or ANX_WRITE
  * \returns an ANNODEX* handle
  */
-ANNODEX * anx_new (int flags);
+ANNODEX * anx_new (int mode);
 
 /**
  * Flush any unwritten data associated with an annodex

Modified: libannodex/trunk/src/libannodex/annodex.c
===================================================================
--- libannodex/trunk/src/libannodex/annodex.c	2005-04-14 11:52:26 UTC (rev 1249)
+++ libannodex/trunk/src/libannodex/annodex.c	2005-04-14 11:54:45 UTC (rev 1250)
@@ -45,15 +45,17 @@
 /*#define DEBUG*/
 
 static int
-anx_flags_disabled (int flags)
+anx_flags_check (int flags)
 {
  if (flags & ANX_WRITE) {
    if (!ANX_CONFIG_WRITE) return ANX_ERR_DISABLED;
+   flags = ANX_WRITE;
  } else {
    if (!ANX_CONFIG_READ) return ANX_ERR_DISABLED;
+   flags = ANX_READ;
  }
 
- return 0;
+ return flags;
 }
 
 static ANNODEX *
@@ -108,7 +110,8 @@
   OGGZ * oggz = NULL;
   int oggz_flags;
 
-  if (anx_flags_disabled (flags)) return NULL;
+  if ((flags = anx_flags_check (flags)) == ANX_ERR_DISABLED)
+    return NULL;
 
   if (flags & ANX_WRITE) {
     oggz_flags = OGGZ_WRITE;
@@ -127,7 +130,8 @@
   OGGZ * oggz = NULL;
   int oggz_flags;
 
-  if (anx_flags_disabled (flags)) return NULL;
+  if ((flags = anx_flags_check (flags)) == ANX_ERR_DISABLED)
+    return NULL;
 
   if (flags & ANX_WRITE) {
     oggz_flags = OGGZ_WRITE;
@@ -148,7 +152,8 @@
   int oggz_flags;
   int fd;
 
-  if (anx_flags_disabled (flags)) return NULL;
+  if ((flags = anx_flags_check (flags)) == ANX_ERR_DISABLED)
+    return NULL;
 
   if (flags & ANX_WRITE) {
     oggz_flags = OGGZ_WRITE;
@@ -203,6 +208,20 @@
   return NULL;
 }
 
+int
+anx_get_mode (ANNODEX * annodex)
+{
+  if (annodex == NULL) return ANX_ERR_INVALID;
+
+  if (annodex->flags & ANX_WRITE) {
+    return ANX_WRITE;
+  } else if (annodex->flags & ANX_READ) {
+    return ANX_READ;
+  }
+
+  return ANX_ERR_INVALID;
+}
+
 AnxHead *
 anx_set_head (ANNODEX * annodex, AnxHead * head)
 {


-- 
conrad



More information about the cvs-annodex mailing list