Undoing change committed in r468 (junk in repository).

git-svn-id: svn://code.dyne.org/veejay/trunk@469 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
Niels Elburg
2005-11-04 17:08:35 +00:00
parent 317562a2c1
commit aa16b92db5
4 changed files with 58 additions and 136 deletions

View File

@@ -1620,8 +1620,8 @@ test -n "$target_alias" &&
LIBVEVO_MAJOR_VERSION=2 LIBVEVO_MAJOR_VERSION=2
LIBVEVO_MINOR_VERSION=2 LIBVEVO_MINOR_VERSION=1
LIBVEVO_MICRO_VERSION=0 LIBVEVO_MICRO_VERSION=1
LIBVEVO_VERSION=$LIBVEVO_MAJOR_VERSION.$LIBVEVO_MINOR_VERSION.$LIBVEVO_MICRO_VERSION LIBVEVO_VERSION=$LIBVEVO_MAJOR_VERSION.$LIBVEVO_MINOR_VERSION.$LIBVEVO_MICRO_VERSION
PACKAGE_VERSION=LIBVEVO_VERSION PACKAGE_VERSION=LIBVEVO_VERSION

View File

@@ -28,5 +28,8 @@
#endif #endif
#define HAVE_LIVIDO_PORT_T #define HAVE_LIVIDO_PORT_T
typedef void livido_port_t; typedef struct {
void *table;
void *index;
} livido_port_t;
# endif # endif

View File

@@ -1,31 +1,3 @@
/*
Copyright (c) 2004-2005 N.Elburg <nelburg@looze.net>
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 #define _GNU_SOURCE
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@@ -33,15 +5,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <include/vevo.h> #include <include/vevo.h>
#include <include/livido.h> #include <include/livido.h>
#include <include/hash.h> #include <include/hash.h>
/** /**
libVeVo - Veejay's Video Objects Library VeVo's mediation layer and core livido functions implementation
----------------------------------------- using hashtable, see hash.h
*/
This (shared) library attempts to provide a leightweight and efficient
framework for handling Livido plugins.
*/
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
#include <assert.h> #include <assert.h>
@@ -70,28 +37,14 @@ typedef struct {
void *next; void *next;
} port_index_t; } 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) 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)); 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->key = strdup(key);
i->hash_code = hash_key; i->hash_code = hash_key;
i->next = NULL; i->next = NULL;
return i; return i;
} }
static inline void port_node_free(port_index_t * node) static inline void port_node_free(port_index_t * node)
{ {
if (node) { if (node) {
@@ -101,18 +54,12 @@ static inline void port_node_free(port_index_t * node)
} }
node = NULL; 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) 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 *node = port_node_new(key, hash_key);
port_index_t *next; port_index_t *next;
port_index_t *list = port->index; port_index_t *list = (port_index_t *) port->index;
if (list == NULL) if (list == NULL)
port->index = node; port->index = node;
else { else {
@@ -151,10 +98,8 @@ static inline int hash_key_code(const char *key)
} }
return hash; return hash;
} }
static int livido_property_finalize(livido_port_t * port, const char *key)
static int livido_property_finalize(livido_port_t * p, const char *key)
{ {
vevo_port_t *port = (vevo_port_t *) p;
hnode_t *node = NULL; hnode_t *node = NULL;
int hash_key = hash_key_code(key); 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) if (atom->size <= 0)
return LIVIDO_NO_ERROR; return LIVIDO_NO_ERROR;
if (t->atom_type != LIVIDO_ATOM_TYPE_STRING) { if (t->atom_type != LIVIDO_ATOM_TYPE_STRING) {
memcpy(dst, atom->value, atom->size); memcpy(dst, atom->value, atom->size);
} else { } 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)); memcpy(p, atom->value, (atom->size - 1));
p[atom->size - 1] = '\0'; p[atom->size - 1] = '\0';
} }
return LIVIDO_NO_ERROR; return LIVIDO_NO_ERROR;
} }
@@ -245,7 +190,6 @@ static void livido_free_atom(atom_t * atom)
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(atom != NULL); assert(atom != NULL);
#endif #endif
if (atom) { if (atom) {
free(atom->value); free(atom->value);
free(atom); free(atom);
@@ -264,17 +208,14 @@ static atom_t *livido_put_atom(void *dst, int atom_type)
if (atom_size > 0) if (atom_size > 0)
memcpy(atom->value, *s, (atom_size - 1)); memcpy(atom->value, *s, (atom_size - 1));
} else { } else {
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(atom_size > 0); assert(atom_size > 0);
assert(dst != NULL); assert(dst != NULL);
#endif #endif
atom = livido_new_atom(atom_type, atom_size); atom = livido_new_atom(atom_type, atom_size);
#ifdef STRICT_CHECING #ifdef STRICT_CHECING
assert(atom != NULL); assert(atom != NULL);
#endif #endif
memcpy(atom->value, dst, atom_size); memcpy(atom->value, dst, atom_size);
} }
return atom; return atom;
@@ -288,7 +229,6 @@ storage_put_atom_value(void *src, int n, livido_storage_t * d, int v)
if (n > 0) if (n > 0)
assert((src != NULL)); assert((src != NULL));
#endif #endif
if (d->num_elements >= 0) { if (d->num_elements >= 0) {
if (d->num_elements >= 0 && d->num_elements <= 1) { if (d->num_elements >= 0 && d->num_elements <= 1) {
if (d->elements.atom) if (d->elements.atom)
@@ -356,6 +296,26 @@ static inline void livido_free_storage(livido_storage_t * t)
} }
t = NULL; 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) 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); 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; hnode_t *node = NULL;
int hash_key = hash_key_code(key); 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; 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; hnode_t *node = NULL;
int hash_key = hash_key_code(key); int hash_key = hash_key_code(key);
if ((node = property_exists(port, hash_key)) != NULL) { 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 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) 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; hnode_t *node = NULL;
int hash_key = hash_key_code(key); int hash_key = hash_key_code(key);
if ((node = property_exists(port, hash_key)) != NULL) { if ((node = property_exists(port, hash_key)) != NULL) {
livido_storage_t *stor = (livido_storage_t *) hnode_get(node); livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(stor != NULL); assert(stor != NULL);
#endif #endif
@@ -427,7 +368,6 @@ livido_property_element_size(livido_port_t * p, const char *key,
if (stor->num_elements == 1) { if (stor->num_elements == 1) {
return stor->elements.atom->size; return stor->elements.atom->size;
} else if (stor->num_elements > 1) { } else if (stor->num_elements > 1) {
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(idx >= 0); assert(idx >= 0);
assert(idx < stor->num_elements); assert(idx < stor->num_elements);
@@ -439,44 +379,45 @@ livido_property_element_size(livido_port_t * p, const char *key,
return 0; return 0;
} }
} }
return -1; return -1;
} }
livido_port_t *livido_port_new(int port_type) 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 #ifdef STRICT_CHECKING
assert(port != NULL); assert(port != NULL);
#endif #endif
port->index = NULL; int type = port_type;
port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash);
port->table =
(void *) hash_create(HASHCOUNT_T_MAX, key_compare, int_hash);
port->index = NULL;
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(port->table != NULL); assert(port->table != NULL);
#endif #endif
livido_property_set(port, "type", LIVIDO_ATOM_TYPE_INT, 1, &type);
livido_property_set(port, "type", LIVIDO_ATOM_TYPE_INT, 1, &port_type);
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
int hash_key = hash_key_code("type"); int hash_key = hash_key_code("type");
assert(property_exists(port, hash_key) != NULL); assert(property_exists(port, hash_key) != NULL);
#endif #endif
livido_property_finalize(port, "type"); livido_property_finalize(port, "type");
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(livido_property_set assert(livido_property_set
(port, "type", LIVIDO_ATOM_TYPE_INT, 1, &port_type) (port, "type", LIVIDO_ATOM_TYPE_INT, 1, &type)
!= LIVIDO_PROPERTY_READONLY); != LIVIDO_PROPERTY_READONLY);
#endif #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) { if (port) {
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
@@ -502,7 +443,7 @@ void livido_port_free(livido_port_t * p)
} }
if (port->index) { if (port->index) {
port_index_t *l = port->index; port_index_t *l = (port_index_t *) port->index;
port_index_t *n = NULL; port_index_t *n = NULL;
while (l != NULL) { while (l != NULL) {
n = l->next; n = l->next;
@@ -510,22 +451,19 @@ void livido_port_free(livido_port_t * p)
l = n; l = n;
} }
} }
free(port); free(port);
} }
port = NULL; port = NULL;
} }
int int
livido_property_set(livido_port_t * p, livido_property_set(livido_port_t * port,
const char *key, const char *key,
int atom_type, int num_elements, void *src) int atom_type, int num_elements, void *src)
{ {
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(p != NULL); assert(port != NULL);
#endif #endif
vevo_port_t *port = (vevo_port_t *) p;
hnode_t *old_node = NULL; hnode_t *old_node = NULL;
int hash_key = hash_key_code(key); int hash_key = hash_key_code(key);
if ((old_node = property_exists(port, hash_key)) != NULL) { 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); port_node_append(port, key, hash_key);
} }
livido_storage_t *stor = livido_new_storage(num_elements); livido_storage_t *stor = livido_new_storage(num_elements);
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(stor != NULL); assert(stor != NULL);
#endif #endif
storage_put_atom_value(src, num_elements, stor, atom_type); storage_put_atom_value(src, num_elements, stor, atom_type);
hnode_t *node = hnode_create(stor); hnode_t *node = hnode_create(stor);
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(node != NULL); assert(node != NULL);
assert(!hash_isfull((hash_t *) port->table)); assert(!hash_isfull((hash_t *) port->table));
assert(!property_exists(port, hash_key)); assert(!property_exists(port, hash_key));
#endif #endif
hash_insert((hash_t *) port->table, node, (const void *) hash_key); hash_insert((hash_t *) port->table, node, (const void *) hash_key);
return LIVIDO_NO_ERROR; return LIVIDO_NO_ERROR;
} }
int 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 #ifdef STRICT_CHECKING
assert(p != NULL); assert(port != NULL);
#endif
vevo_port_t *port = (vevo_port_t *) p;
#ifdef STRICT_CHECKING
assert(port->table != NULL); assert(port->table != NULL);
assert(key != NULL); assert(key != NULL);
#endif #endif
hnode_t *node = NULL; hnode_t *node = NULL;
int hash_key = hash_key_code(key); int hash_key = hash_key_code(key);
if ((node = property_exists(port, hash_key)) != NULL) { 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; return LIVIDO_NO_ERROR;
else { else {
livido_storage_t *stor = hnode_get(node); livido_storage_t *stor = hnode_get(node);
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(stor != NULL); assert(stor != NULL);
#endif #endif
return atom_get_value(stor, idx, dst); return atom_get_value(stor, idx, dst);
} }
} }
return LIVIDO_ERROR_NOSUCH_PROPERTY; 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 #ifdef STRICT_CHECKING
assert(port != NULL); assert(port != NULL);
assert(port->table != NULL); assert(port->table != NULL);
assert(hash_isempty((hash_t *) port->table) == 0); assert(hash_isempty((hash_t *) port->table) == 0);
#endif #endif
char **list = NULL; char **list = NULL;
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
int nn = hash_count((hash_t *) port->table); int nn = hash_count((hash_t *) port->table);
#endif #endif
int n = 1; // null terminated list of keys int n = 1; // null terminated list of keys
int i = 0; int i = 0;
port_index_t *l = port->index; port_index_t *l = (port_index_t *) port->index;
while (l != NULL) { while (l != NULL) {
l = l->next; l = l->next;
n++; n++;
} }
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert(nn == n); assert(nn == n);
#endif #endif

View File

@@ -6,7 +6,7 @@ LIBVEVO = $(top_builddir)/src/libvevo.la
# ********************************************************************* # *********************************************************************
# The tools themselves # The tools themselves
EXAMPLES_BIN = vevotest vevobench vevoutils EXAMPLES_BIN = vevotest vevobench
bin_PROGRAMS = $(EXAMPLES_BIN) bin_PROGRAMS = $(EXAMPLES_BIN)
@@ -14,6 +14,4 @@ vevotest_SOURCES = vevotest.c
vevotest_LDADD = $(LIBVEVO) -ldl vevotest_LDADD = $(LIBVEVO) -ldl
vevobench_SOURCES = vevobenchmark.c vevobench_SOURCES = vevobenchmark.c
vevobench_LDADD = $(LIBVEVO) -ldl vevobench_LDADD = $(LIBVEVO) -ldl
vevoutils_SOURCES = vevoutilstest.c
vevoutils_LDADD = $(LIBVEVO) -ldl