Simple example using the glite_renewal_core_renew() call
authorDaniel Kouřil <kouril@ics.muni.cz>
Tue, 14 Mar 2006 12:35:44 +0000 (12:35 +0000)
committerDaniel Kouřil <kouril@ics.muni.cz>
Tue, 14 Mar 2006 12:35:44 +0000 (12:35 +0000)
org.glite.security.proxyrenewal/examples/renew_core.c [new file with mode: 0644]

diff --git a/org.glite.security.proxyrenewal/examples/renew_core.c b/org.glite.security.proxyrenewal/examples/renew_core.c
new file mode 100644 (file)
index 0000000..f150f75
--- /dev/null
@@ -0,0 +1,63 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <glite/security/proxyrenewal/renewal_core.h>
+
+static struct option const long_options[] = {
+   { "server",   required_argument, 0, 's' },
+   { "proxy",    required_argument, 0, 'p' },
+   { NULL, 0, NULL, 0}
+};
+
+static char short_options[] = "s:p:";
+
+/* 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[])
+{
+   char *server = NULL;
+   char *proxy = NULL;
+   char *new_proxy = NULL;
+   extern int optind;
+   char arg;
+   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':
+          server = optarg; break;
+       case 'p':
+          proxy = optarg; break;
+       case 'h':
+          fprintf(stdout, "Usage: %s --server <myproxy server> --proxy <filename>\n", argv[0]);
+          exit(1);
+      }
+   }
+
+   if (server == NULL || proxy == NULL) {
+      fprintf(stderr, "both server and proxy parameters must be given\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);
+   }
+
+   return 0;
+}
+
+void
+edg_wlpr_Log(int dbg_level, const char *format, ...)
+{
+   return;
+}