From aa16b92db56d87cd074f16c3aa60c5b68feef17a Mon Sep 17 00:00:00 2001 From: Niels Elburg Date: Fri, 4 Nov 2005 17:08:35 +0000 Subject: [PATCH] Undoing change committed in r468 (junk in repository). git-svn-id: svn://code.dyne.org/veejay/trunk@469 eb8d1916-c9e9-0310-b8de-cf0c9472ead5 --- vevo-current/configure | 4 +- vevo-current/include/vevo.h | 5 +- vevo-current/src/vevo.c | 181 ++++++++++------------------------ vevo-current/test/Makefile.am | 4 +- 4 files changed, 58 insertions(+), 136 deletions(-) diff --git a/vevo-current/configure b/vevo-current/configure index 4a8b6302..a0a7316d 100755 --- a/vevo-current/configure +++ b/vevo-current/configure @@ -1620,8 +1620,8 @@ test -n "$target_alias" && LIBVEVO_MAJOR_VERSION=2 -LIBVEVO_MINOR_VERSION=2 -LIBVEVO_MICRO_VERSION=0 +LIBVEVO_MINOR_VERSION=1 +LIBVEVO_MICRO_VERSION=1 LIBVEVO_VERSION=$LIBVEVO_MAJOR_VERSION.$LIBVEVO_MINOR_VERSION.$LIBVEVO_MICRO_VERSION PACKAGE_VERSION=LIBVEVO_VERSION diff --git a/vevo-current/include/vevo.h b/vevo-current/include/vevo.h index f86588e9..2753256d 100644 --- a/vevo-current/include/vevo.h +++ b/vevo-current/include/vevo.h @@ -28,5 +28,8 @@ #endif #define HAVE_LIVIDO_PORT_T -typedef void livido_port_t; +typedef struct { + void *table; + void *index; +} livido_port_t; # endif diff --git a/vevo-current/src/vevo.c b/vevo-current/src/vevo.c index 15da97e9..454eed2b 100644 --- a/vevo-current/src/vevo.c +++ b/vevo-current/src/vevo.c @@ -1,31 +1,3 @@ -/* -Copyright (c) 2004-2005 N.Elburg - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. 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. -3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. -*/ - #define _GNU_SOURCE #include #include @@ -33,15 +5,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include - /** - libVeVo - Veejay's Video Objects Library - ----------------------------------------- - - This (shared) library attempts to provide a leightweight and efficient - framework for handling Livido plugins. - -*/ + VeVo's mediation layer and core livido functions implementation + using hashtable, see hash.h + */ #ifdef STRICT_CHECKING #include @@ -70,28 +37,14 @@ typedef struct { void *next; } port_index_t; -/* Now, define our port structure */ -typedef struct { - hash_t *table; - port_index_t *index; -} vevo_port_t; - static inline port_index_t *port_node_new(const char *key, int hash_key) { port_index_t *i = (port_index_t *) malloc(sizeof(port_index_t)); - -#ifdef STRICT_CHECKING - assert(i != NULL); - assert(key != NULL); - assert(hash_key != 0); -#endif - i->key = strdup(key); i->hash_code = hash_key; i->next = NULL; return i; } - static inline void port_node_free(port_index_t * node) { if (node) { @@ -101,18 +54,12 @@ static inline void port_node_free(port_index_t * node) } node = NULL; } -static inline void port_node_append(livido_port_t * p, const char *key, +static inline void port_node_append(livido_port_t * port, const char *key, int hash_key) { -#ifdef STRICT_CHECKING - assert(p != NULL); - assert(key != NULL); - assert(hash_key != 0); -#endif - vevo_port_t *port = (vevo_port_t *) p; port_index_t *node = port_node_new(key, hash_key); port_index_t *next; - port_index_t *list = port->index; + port_index_t *list = (port_index_t *) port->index; if (list == NULL) port->index = node; else { @@ -151,10 +98,8 @@ static inline int hash_key_code(const char *key) } return hash; } - -static int livido_property_finalize(livido_port_t * p, const char *key) +static int livido_property_finalize(livido_port_t * port, const char *key) { - vevo_port_t *port = (vevo_port_t *) p; hnode_t *node = NULL; int hash_key = hash_key_code(key); @@ -188,6 +133,7 @@ static int atom_get_value(livido_storage_t * t, int idx, void *dst) if (atom->size <= 0) return LIVIDO_NO_ERROR; + if (t->atom_type != LIVIDO_ATOM_TYPE_STRING) { memcpy(dst, atom->value, atom->size); } else { @@ -196,7 +142,6 @@ static int atom_get_value(livido_storage_t * t, int idx, void *dst) memcpy(p, atom->value, (atom->size - 1)); p[atom->size - 1] = '\0'; } - return LIVIDO_NO_ERROR; } @@ -245,7 +190,6 @@ static void livido_free_atom(atom_t * atom) #ifdef STRICT_CHECKING assert(atom != NULL); #endif - if (atom) { free(atom->value); free(atom); @@ -264,17 +208,14 @@ static atom_t *livido_put_atom(void *dst, int atom_type) if (atom_size > 0) memcpy(atom->value, *s, (atom_size - 1)); } else { - #ifdef STRICT_CHECKING assert(atom_size > 0); assert(dst != NULL); #endif atom = livido_new_atom(atom_type, atom_size); - #ifdef STRICT_CHECING assert(atom != NULL); #endif - memcpy(atom->value, dst, atom_size); } return atom; @@ -288,7 +229,6 @@ storage_put_atom_value(void *src, int n, livido_storage_t * d, int v) if (n > 0) assert((src != NULL)); #endif - if (d->num_elements >= 0) { if (d->num_elements >= 0 && d->num_elements <= 1) { if (d->elements.atom) @@ -356,6 +296,26 @@ static inline void livido_free_storage(livido_storage_t * t) } t = NULL; } +static inline int reversestrcmp(const char *key1, const char *key2) +{ + int k = strlen(key2); + int n = strlen(key1); + if (k < n) + n = k; + key1 += n - 1; + key2 += n - 1; + while (n-- > 0) { + if (*key1 != *key2) { + return 1; + } + key1--; + key2--; + } + if (n < 0) + return 0; + return 1; +} + static inline hash_val_t int_hash(const void *key) { @@ -367,14 +327,8 @@ static inline int key_compare(const void *key1, const void *key2) return ((int) key1 == (int) key2 ? 0 : 1); } -int livido_property_num_elements(livido_port_t * p, const char *key) +int livido_property_num_elements(livido_port_t * port, const char *key) { -#ifdef STRICT_CHECKING - assert(p != NULL); - assert(key != NULL); -#endif - - vevo_port_t *port = (vevo_port_t *) p; hnode_t *node = NULL; int hash_key = hash_key_code(key); @@ -386,14 +340,8 @@ int livido_property_num_elements(livido_port_t * p, const char *key) return -1; } -int livido_property_atom_type(livido_port_t * p, const char *key) +int livido_property_atom_type(livido_port_t * port, const char *key) { -#ifdef STRICT_CHECKING - assert(p != NULL); - assert(key != NULL); -#endif - - vevo_port_t *port = (vevo_port_t *) port; hnode_t *node = NULL; int hash_key = hash_key_code(key); if ((node = property_exists(port, hash_key)) != NULL) { @@ -405,21 +353,14 @@ int livido_property_atom_type(livido_port_t * p, const char *key) } size_t -livido_property_element_size(livido_port_t * p, const char *key, +livido_property_element_size(livido_port_t * port, const char *key, const int idx) { -#ifdef STRICT_CHECKING - assert(p != NULL); - assert(key != NULL); -#endif - - vevo_port_t *port = (vevo_port_t *) p; hnode_t *node = NULL; int hash_key = hash_key_code(key); if ((node = property_exists(port, hash_key)) != NULL) { livido_storage_t *stor = (livido_storage_t *) hnode_get(node); - #ifdef STRICT_CHECKING assert(stor != NULL); #endif @@ -427,7 +368,6 @@ livido_property_element_size(livido_port_t * p, const char *key, if (stor->num_elements == 1) { return stor->elements.atom->size; } else if (stor->num_elements > 1) { - #ifdef STRICT_CHECKING assert(idx >= 0); assert(idx < stor->num_elements); @@ -439,44 +379,45 @@ livido_property_element_size(livido_port_t * p, const char *key, return 0; } } - return -1; } livido_port_t *livido_port_new(int port_type) { - vevo_port_t *port = (vevo_port_t *) malloc(sizeof(vevo_port_t)); - + livido_port_t *port = (livido_port_t *) malloc(sizeof(livido_port_t)); #ifdef STRICT_CHECKING assert(port != NULL); #endif - port->index = NULL; - port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash); + int type = port_type; + port->table = + (void *) hash_create(HASHCOUNT_T_MAX, key_compare, int_hash); + port->index = NULL; #ifdef STRICT_CHECKING assert(port->table != NULL); #endif - - livido_property_set(port, "type", LIVIDO_ATOM_TYPE_INT, 1, &port_type); + livido_property_set(port, "type", LIVIDO_ATOM_TYPE_INT, 1, &type); #ifdef STRICT_CHECKING int hash_key = hash_key_code("type"); assert(property_exists(port, hash_key) != NULL); #endif - livido_property_finalize(port, "type"); #ifdef STRICT_CHECKING assert(livido_property_set - (port, "type", LIVIDO_ATOM_TYPE_INT, 1, &port_type) + (port, "type", LIVIDO_ATOM_TYPE_INT, 1, &type) != LIVIDO_PROPERTY_READONLY); #endif - return (livido_port_t *) port; + return port; } -void livido_port_free(livido_port_t * p) +void livido_port_free(livido_port_t * port) { - vevo_port_t *port = (vevo_port_t *) p; +#ifdef STRICT_CHECKING + assert(port != NULL); + assert(port->table != NULL); +#endif if (port) { #ifdef STRICT_CHECKING @@ -502,7 +443,7 @@ void livido_port_free(livido_port_t * p) } if (port->index) { - port_index_t *l = port->index; + port_index_t *l = (port_index_t *) port->index; port_index_t *n = NULL; while (l != NULL) { n = l->next; @@ -510,22 +451,19 @@ void livido_port_free(livido_port_t * p) l = n; } } - free(port); } port = NULL; } int -livido_property_set(livido_port_t * p, +livido_property_set(livido_port_t * port, const char *key, int atom_type, int num_elements, void *src) { #ifdef STRICT_CHECKING - assert(p != NULL); + assert(port != NULL); #endif - - vevo_port_t *port = (vevo_port_t *) p; hnode_t *old_node = NULL; int hash_key = hash_key_code(key); if ((old_node = property_exists(port, hash_key)) != NULL) { @@ -545,40 +483,31 @@ livido_property_set(livido_port_t * p, port_node_append(port, key, hash_key); } livido_storage_t *stor = livido_new_storage(num_elements); - #ifdef STRICT_CHECKING assert(stor != NULL); #endif - storage_put_atom_value(src, num_elements, stor, atom_type); hnode_t *node = hnode_create(stor); - #ifdef STRICT_CHECKING assert(node != NULL); assert(!hash_isfull((hash_t *) port->table)); assert(!property_exists(port, hash_key)); #endif - hash_insert((hash_t *) port->table, node, (const void *) hash_key); return LIVIDO_NO_ERROR; } int -livido_property_get(livido_port_t * p, const char *key, int idx, void *dst) +livido_property_get(livido_port_t * port, + const char *key, int idx, void *dst) { #ifdef STRICT_CHECKING - assert(p != NULL); -#endif - - vevo_port_t *port = (vevo_port_t *) p; - -#ifdef STRICT_CHECKING + assert(port != NULL); assert(port->table != NULL); assert(key != NULL); #endif - hnode_t *node = NULL; int hash_key = hash_key_code(key); if ((node = property_exists(port, hash_key)) != NULL) { @@ -586,41 +515,33 @@ livido_property_get(livido_port_t * p, const char *key, int idx, void *dst) return LIVIDO_NO_ERROR; else { livido_storage_t *stor = hnode_get(node); - #ifdef STRICT_CHECKING assert(stor != NULL); #endif return atom_get_value(stor, idx, dst); } } - return LIVIDO_ERROR_NOSUCH_PROPERTY; } -char **livido_list_properties(livido_port_t * p) +char **livido_list_properties(livido_port_t * port) { - vevo_port_t *port = (vevo_port_t *) p; - #ifdef STRICT_CHECKING assert(port != NULL); assert(port->table != NULL); assert(hash_isempty((hash_t *) port->table) == 0); #endif - char **list = NULL; - #ifdef STRICT_CHECKING int nn = hash_count((hash_t *) port->table); #endif - int n = 1; // null terminated list of keys int i = 0; - port_index_t *l = port->index; + port_index_t *l = (port_index_t *) port->index; while (l != NULL) { l = l->next; n++; } - #ifdef STRICT_CHECKING assert(nn == n); #endif diff --git a/vevo-current/test/Makefile.am b/vevo-current/test/Makefile.am index bedc0092..4b13cec0 100644 --- a/vevo-current/test/Makefile.am +++ b/vevo-current/test/Makefile.am @@ -6,7 +6,7 @@ LIBVEVO = $(top_builddir)/src/libvevo.la # ********************************************************************* # The tools themselves -EXAMPLES_BIN = vevotest vevobench vevoutils +EXAMPLES_BIN = vevotest vevobench bin_PROGRAMS = $(EXAMPLES_BIN) @@ -14,6 +14,4 @@ vevotest_SOURCES = vevotest.c vevotest_LDADD = $(LIBVEVO) -ldl vevobench_SOURCES = vevobenchmark.c vevobench_LDADD = $(LIBVEVO) -ldl -vevoutils_SOURCES = vevoutilstest.c -vevoutils_LDADD = $(LIBVEVO) -ldl