Added glite_renewal_core_init_ctx() and glite_renewal_core_destroy_ctx() calls.
authorDaniel Kouřil <kouril@ics.muni.cz>
Tue, 14 Mar 2006 13:55:55 +0000 (13:55 +0000)
committerDaniel Kouřil <kouril@ics.muni.cz>
Tue, 14 Mar 2006 13:55:55 +0000 (13:55 +0000)
Uglinesses moved to the implementation part.

org.glite.security.proxyrenewal/examples/renew_core.c
org.glite.security.proxyrenewal/interface/renewal_core.h
org.glite.security.proxyrenewal/src/renewal_core.c

index a527047..530a81c 100644 (file)
@@ -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;
-}
index 1e8dc68..f20ac8a 100644 (file)
@@ -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.
index 32e6ea8..7673b18 100644 (file)
@@ -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;