diff options
author | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2010-02-23 10:34:14 +0000 |
---|---|---|
committer | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2010-02-23 10:34:14 +0000 |
commit | ed7d79f96177044949744da10f4431c1d6242241 (patch) | |
tree | 3aabaa55ed3b5291daef891cfee9befb5235e2b8 /src/libstrongswan/database | |
parent | 7410d3c6d6a9a1cd7aa55083c938946af6ff9498 (diff) | |
download | vyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.tar.gz vyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.zip |
[svn-upgrade] Integrating new upstream version, strongswan (4.3.6)
Diffstat (limited to 'src/libstrongswan/database')
-rw-r--r-- | src/libstrongswan/database/database.h | 58 | ||||
-rw-r--r-- | src/libstrongswan/database/database_factory.c | 14 | ||||
-rw-r--r-- | src/libstrongswan/database/database_factory.h | 12 |
3 files changed, 42 insertions, 42 deletions
diff --git a/src/libstrongswan/database/database.h b/src/libstrongswan/database/database.h index 16472d869..8df1c6f7f 100644 --- a/src/libstrongswan/database/database.h +++ b/src/libstrongswan/database/database.h @@ -59,41 +59,41 @@ enum db_driver_t { * Interface for a database implementation. * * @code - int affected, rowid, aint; - char *atext; - database_t *db; - enumerator_t *enumerator; - - db = lib->database->create("mysql://user:pass@host/database"); - affected = db->execute(db, &rowid, "INSERT INTO table VALUES (?, ?)", - DB_INT, 77, DB_TEXT, "a text"); - printf("inserted %d row, new row ID: %d\n", affected, rowid); - - enumerator = db->query(db, "SELECT aint, atext FROM table WHERE aint > ?", - DB_INT, 10, // 1 argument to SQL string - DB_INT, DB_TEXT); // 2 enumerated types in query - if (enumerator) - { - while (enumerator->enumerate(enumerator, &aint, &atext)) - { - printf("%d: %s\n", aint, atext); - } - enumerator->destroy(enumerator); - } + int affected, rowid, aint; + char *atext; + database_t *db; + enumerator_t *enumerator; + + db = lib->database->create("mysql://user:pass@host/database"); + affected = db->execute(db, &rowid, "INSERT INTO table VALUES (?, ?)", + DB_INT, 77, DB_TEXT, "a text"); + printf("inserted %d row, new row ID: %d\n", affected, rowid); + + enumerator = db->query(db, "SELECT aint, atext FROM table WHERE aint > ?", + DB_INT, 10, // 1 argument to SQL string + DB_INT, DB_TEXT); // 2 enumerated types in query + if (enumerator) + { + while (enumerator->enumerate(enumerator, &aint, &atext)) + { + printf("%d: %s\n", aint, atext); + } + enumerator->destroy(enumerator); + } @endcode */ struct database_t { - + /** * Run a query which returns rows, such as a SELECT. * * @param sql sql query string, containing '?' placeholders * @param ... list of sql placeholder db_type_t followed by its value, - * followed by enumerators arguments as db_type_t's + * followed by enumerators arguments as db_type_t's * @return enumerator as defined with arguments, NULL on failure */ enumerator_t* (*query)(database_t *this, char *sql, ...); - + /** * Execute a query which dows not return rows, such as INSERT. * @@ -103,7 +103,7 @@ struct database_t { * @return number of affected rows, < 0 on failure */ int (*execute)(database_t *this, int *rowid, char *sql, ...); - + /** * Get the database implementation type. * @@ -113,11 +113,11 @@ struct database_t { * @return database implementation type */ db_driver_t (*get_driver)(database_t *this); - + /** - * Destroy a database connection. - */ - void (*destroy)(database_t *this); + * Destroy a database connection. + */ + void (*destroy)(database_t *this); }; #endif /** DATABASE_H_ @}*/ diff --git a/src/libstrongswan/database/database_factory.c b/src/libstrongswan/database/database_factory.c index ef6927874..3936565a1 100644 --- a/src/libstrongswan/database/database_factory.c +++ b/src/libstrongswan/database/database_factory.c @@ -16,7 +16,7 @@ #include "database_factory.h" #include <utils/linked_list.h> -#include <utils/mutex.h> +#include <threading/mutex.h> typedef struct private_database_factory_t private_database_factory_t; @@ -29,12 +29,12 @@ struct private_database_factory_t { * public functions */ database_factory_t public; - + /** * list of registered database_t implementations */ linked_list_t *databases; - + /** * mutex to lock access to databases */ @@ -49,7 +49,7 @@ static database_t* create(private_database_factory_t *this, char *uri) enumerator_t *enumerator; database_t *database = NULL; database_constructor_t create; - + this->mutex->lock(this->mutex); enumerator = this->databases->create_enumerator(this->databases); while (enumerator->enumerate(enumerator, &create)) @@ -103,15 +103,15 @@ static void destroy(private_database_factory_t *this) database_factory_t *database_factory_create() { private_database_factory_t *this = malloc_thing(private_database_factory_t); - + this->public.create = (database_t*(*)(database_factory_t*, char *url))create; this->public.add_database = (void(*)(database_factory_t*, database_constructor_t))add_database; this->public.remove_database = (void(*)(database_factory_t*, database_constructor_t))remove_database; this->public.destroy = (void(*)(database_factory_t*))destroy; - + this->databases = linked_list_create(); this->mutex = mutex_create(MUTEX_TYPE_DEFAULT); - + return &this->public; } diff --git a/src/libstrongswan/database/database_factory.h b/src/libstrongswan/database/database_factory.h index 8875adad7..3213e1a08 100644 --- a/src/libstrongswan/database/database_factory.h +++ b/src/libstrongswan/database/database_factory.h @@ -44,25 +44,25 @@ struct database_factory_t { * @return database_t instance, NULL if not supported/failed */ database_t* (*create)(database_factory_t *this, char *uri); - + /** * Register a database constructor. * * @param create database constructor to register */ void (*add_database)(database_factory_t *this, database_constructor_t create); - + /** * Unregister a previously registered database constructor. * * @param create database constructor to unregister */ void (*remove_database)(database_factory_t *this, database_constructor_t create); - + /** - * Destroy a database_factory instance. - */ - void (*destroy)(database_factory_t *this); + * Destroy a database_factory instance. + */ + void (*destroy)(database_factory_t *this); }; /** |