Migrated initiate_mediation_job_t to INIT/METHOD macros.
authorTobias Brunner <tobias@strongswan.org>
Mon, 3 Oct 2011 16:53:14 +0000 (18:53 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 3 Oct 2011 16:53:14 +0000 (18:53 +0200)
src/libcharon/processing/jobs/initiate_mediation_job.c

index 183484a..e52f3c6 100644 (file)
@@ -41,10 +41,8 @@ struct private_initiate_mediation_job_t {
        ike_sa_id_t *mediation_sa_id;
 };
 
-/**
- * Implements job_t.destroy.
- */
-static void destroy(private_initiate_mediation_job_t *this)
+METHOD(job_t, destroy, void,
+       private_initiate_mediation_job_t *this)
 {
        DESTROY_IF(this->mediation_sa_id);
        DESTROY_IF(this->mediated_sa_id);
@@ -66,10 +64,8 @@ static bool initiate_callback(private_initiate_mediation_job_t *this,
        return TRUE;
 }
 
-/**
- * Implementation of job_t.execute.
- */
-static void initiate(private_initiate_mediation_job_t *this)
+METHOD(job_t, initiate, void,
+       private_initiate_mediation_job_t *this)
 {
        ike_sa_t *mediated_sa, *mediation_sa;
        peer_cfg_t *mediated_cfg, *mediation_cfg;
@@ -172,10 +168,8 @@ static void initiate(private_initiate_mediation_job_t *this)
        destroy(this);
 }
 
-/**
- * Implementation of job_t.execute.
- */
-static void reinitiate(private_initiate_mediation_job_t *this)
+METHOD(job_t, reinitiate, void,
+       private_initiate_mediation_job_t *this)
 {
        ike_sa_t *mediated_sa, *mediation_sa;
        peer_cfg_t *mediated_cfg;
@@ -223,10 +217,8 @@ static void reinitiate(private_initiate_mediation_job_t *this)
        destroy(this);
 }
 
-/**
- * Implementation of job_t.get_priority.
- */
-static job_priority_t get_priority(private_initiate_mediation_job_t *this)
+METHOD(job_t, get_priority, job_priority_t,
+       private_initiate_mediation_job_t *this)
 {
        return JOB_PRIO_MEDIUM;
 }
@@ -236,16 +228,15 @@ static job_priority_t get_priority(private_initiate_mediation_job_t *this)
  */
 static private_initiate_mediation_job_t *initiate_mediation_job_create_empty()
 {
-       private_initiate_mediation_job_t *this = malloc_thing(private_initiate_mediation_job_t);
-
-       /* interface functions */
-       this->public.job_interface.get_priority = (job_priority_t (*) (job_t *)) get_priority;
-       this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-
-       /* private variables */
-       this->mediation_sa_id = NULL;
-       this->mediated_sa_id = NULL;
-
+       private_initiate_mediation_job_t *this;
+       INIT(this,
+               .public = {
+                       .job_interface = {
+                               .get_priority = _get_priority,
+                               .destroy = _destroy,
+                       },
+               },
+       );
        return this;
 }
 
@@ -256,8 +247,7 @@ initiate_mediation_job_t *initiate_mediation_job_create(ike_sa_id_t *ike_sa_id)
 {
        private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
 
-       this->public.job_interface.execute = (void (*) (job_t *)) initiate;
-
+       this->public.job_interface.execute = _initiate;
        this->mediated_sa_id = ike_sa_id->clone(ike_sa_id);
 
        return &this->public;
@@ -271,8 +261,7 @@ initiate_mediation_job_t *reinitiate_mediation_job_create(ike_sa_id_t *mediation
 {
        private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
 
-       this->public.job_interface.execute = (void (*) (job_t *)) reinitiate;
-
+       this->public.job_interface.execute = _reinitiate;
        this->mediation_sa_id = mediation_sa_id->clone(mediation_sa_id);
        this->mediated_sa_id = mediated_sa_id->clone(mediated_sa_id);