From e91151f57dae182c52763d8b0a00ef9a5c32aff9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kou=C5=99il?= Date: Tue, 14 Mar 2006 13:55:55 +0000 Subject: [PATCH] Added glite_renewal_core_init_ctx() and glite_renewal_core_destroy_ctx() calls. Uglinesses moved to the implementation part. --- .../examples/renew_core.c | 22 ++++++--------- .../interface/renewal_core.h | 15 ++++++++-- org.glite.security.proxyrenewal/src/renewal_core.c | 32 ++++++++++++++++++++++ 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/org.glite.security.proxyrenewal/examples/renew_core.c b/org.glite.security.proxyrenewal/examples/renew_core.c index a527047..530a81c 100644 --- a/org.glite.security.proxyrenewal/examples/renew_core.c +++ b/org.glite.security.proxyrenewal/examples/renew_core.c @@ -12,12 +12,6 @@ static struct option const long_options[] = { static char short_options[] = "s:p:h"; -/* Two ugly hacks, will be removed once the context is introduced */ -char *vomsconf = NULL; - -void -edg_wlpr_Log(int dbg_level, const char *format, ...); - int main(int argc, char *argv[]) { @@ -29,8 +23,6 @@ main(int argc, char *argv[]) glite_renewal_core_context_data ctx; int ret; - memset(&ctx, 0, sizeof(ctx)); - while ((arg = getopt_long(argc, argv, short_options, long_options, NULL)) != EOF) { switch(arg) { case 's': @@ -48,19 +40,21 @@ main(int argc, char *argv[]) exit(1); } + ret = glite_renewal_core_init_ctx(&ctx); + if (ret) { + fprintf(stderr, "glite_renewal_core_init_ctx() failed\n"); + exit(1); + } + ret = glite_renewal_core_renew(&ctx, server, 0, proxy, &new_proxy); if (ret) { fprintf(stderr, "glite_renewal_core_renew() failed: %d\n", ret); exit(1); } + ret = glite_renewal_core_destroy_ctx(ctx); + printf("%s\n", new_proxy); return 0; } - -void -edg_wlpr_Log(int dbg_level, const char *format, ...) -{ - return; -} diff --git a/org.glite.security.proxyrenewal/interface/renewal_core.h b/org.glite.security.proxyrenewal/interface/renewal_core.h index 1e8dc68..f20ac8a 100644 --- a/org.glite.security.proxyrenewal/interface/renewal_core.h +++ b/org.glite.security.proxyrenewal/interface/renewal_core.h @@ -9,15 +9,24 @@ extern "C" { typedef struct glite_renewal_core_context_data { int dbg_level; - char *cert; - char *key; - char *cadir; int voms_enabled; } glite_renewal_core_context_data; typedef struct glite_renewal_core_context_data *glite_renewal_core_context; /** + * This cal initializes the context and sets default values + */ +int +glite_renewal_core_init_ctx(glite_renewal_core_context *context); + +/** + * This call frees the context and all memory used by the context + */ +int +glite_renewal_core_destroy_ctx(glite_renewal_core_context context); + +/** * This call tries to renew the proxy certificate using the MyProxy * repository. If VOMS attributes are present in the proxy they are renewed * as well. diff --git a/org.glite.security.proxyrenewal/src/renewal_core.c b/org.glite.security.proxyrenewal/src/renewal_core.c index 32e6ea8..7673b18 100644 --- a/org.glite.security.proxyrenewal/src/renewal_core.c +++ b/org.glite.security.proxyrenewal/src/renewal_core.c @@ -214,3 +214,35 @@ end: return ret; } + +int +glite_renewal_core_init_ctx(glite_renewal_core_context *context) +{ + glite_renewal_core_context p = NULL; + + *context = NULL; + + p = calloc(1, sizeof(*p)); + if (p == NULL) + return ENOMEM; + + *context = p; + return 0; +} + +int +glite_renewal_core_destroy_ctx(glite_renewal_core_context context) +{ + free(context); + return 0; +} + +/* XXX remove these ugly things: */ + +void +edg_wlpr_Log(int dbg_level, const char *format, ...) +{ + return; +} + +char *vomsconf = NULL; -- 1.8.2.3