]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Migrated storage_t to INIT/METHOD macros.
authorTobias Brunner <tobias@strongswan.org>
Tue, 4 Oct 2011 09:22:41 +0000 (11:22 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 4 Oct 2011 09:22:41 +0000 (11:22 +0200)
src/manager/storage.c

index f7635ea7175e7daecf7a83a139ec08c5d3fc5627..5461a4288d4159cff05465a75f87d1855905b527 100644 (file)
@@ -37,10 +37,8 @@ struct private_storage_t {
        database_t *db;
 };
 
-/**
- * Implementation of storage_t.login.
- */
-static int login(private_storage_t *this, char *username, char *password)
+METHOD(storage_t, login, int,
+       private_storage_t *this, char *username, char *password)
 {
        hasher_t *hasher;
        chunk_t hash, data, hex_str;
@@ -77,10 +75,8 @@ static int login(private_storage_t *this, char *username, char *password)
        return uid;
 }
 
-/**
- * Implementation of storage_t.create_gateway_enumerator.
- */
-static enumerator_t* create_gateway_enumerator(private_storage_t *this, int user)
+METHOD(storage_t, create_gateway_enumerator, enumerator_t*,
+       private_storage_t *this, int user)
 {
        enumerator_t *enumerator;
 
@@ -96,10 +92,8 @@ static enumerator_t* create_gateway_enumerator(private_storage_t *this, int user
        return enumerator;
 }
 
-/**
- * Implementation of storage_t.destroy
- */
-static void destroy(private_storage_t *this)
+METHOD(storage_t, destroy, void,
+       private_storage_t *this)
 {
        this->db->destroy(this->db);
        free(this);
@@ -110,13 +104,16 @@ static void destroy(private_storage_t *this)
  */
 storage_t *storage_create(char *uri)
 {
-       private_storage_t *this = malloc_thing(private_storage_t);
-
-       this->public.login = (int(*)(storage_t*, char *username, char *password))login;
-       this->public.create_gateway_enumerator = (enumerator_t*(*)(storage_t*,int))create_gateway_enumerator;
-       this->public.destroy = (void(*)(storage_t*))destroy;
-
-       this->db = lib->db->create(lib->db, uri);
+       private_storage_t *this;
+
+       INIT(this,
+               .public = {
+                       .login = _login,
+                       .create_gateway_enumerator = _create_gateway_enumerator,
+                       .destroy = _destroy,
+               },
+               .db = lib->db->create(lib->db, uri),
+       );
        if (this->db == NULL)
        {
                free(this);