example (not yet really functional) implementation of tags plugin
authorAleš Křenek <ljocha@ics.muni.cz>
Mon, 11 Apr 2005 15:11:58 +0000 (15:11 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Mon, 11 Apr 2005 15:11:58 +0000 (15:11 +0000)
org.glite.jp.primary/Makefile
org.glite.jp.primary/interface/file_plugin.h
org.glite.jp.primary/src/backend.h
org.glite.jp.primary/src/bones_server.c
org.glite.jp.primary/src/file_plugin.c
org.glite.jp.primary/src/ftp_backend.c

index e1ab3ed..1d8b8b6 100644 (file)
@@ -37,15 +37,18 @@ CFLAGS:=${DEBUG} -I. -I${top_srcdir}/interface -I${top_srcdir}/src -I${gsoap_pre
 LDFLAGS:=-L${stagedir}/lib
 
 LINK:=libtool --mode=link ${CC} ${LDFLAGS} 
+LTCOMPILE:=libtool --mode=compile ${CC} ${CFLAGS}
+SOLINK:=libtool --mode=link ${CC} -module ${LDFLAGS} -rpath ${stagedir}/lib
 LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} 
 INSTALL:=libtool --mode=install install
 
-
 daemon:=glite-jp-primarystoraged
 example:=jpps-test
 ps_prefix:=jpps_
 is_prefix:=jpis_
 
+plugins:=glite-jp-tags.la
+
 gsoap_version=`${gsoap_prefix}/bin/soapcpp2 -version 2>&1 | cut -d' ' -f4 | perl -F\\\\. -nae '$$F[2] =~ s/\D*$$//; print $$F[2]+100*$$F[1]+10000*$$F[0]'`
 
 CFLAGS+=-DGSOAP_VERSION=${gsoap_version}
@@ -72,7 +75,7 @@ GSOAPLIB:=-lglite_security_gsoap_plugin_${nothrflavour} -lglite_security_gss_${n
 
 default all: compile
 
-compile: ${daemon} ${example}
+compile: ${daemon} ${example} ${plugins}
 
 ${daemon}: ${OBJS}
        ${LINK} -o $@ ${OBJS} ${BONESLIB} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} 
@@ -150,3 +153,9 @@ stdsoap2.o: ${gsoap_prefix}/devel/stdsoap2.c
        @echo 'The following warning "time_t (de)serialization is not MT safe on this platform" is harmless'
        ${CC} -o $@ -c -DWITH_NONAMESPACES -DHAVE_CONFIG_H ${CFLAGS} ${gsoap_prefix}/devel/stdsoap2.c
 
+
+glite-jp-tags.la: tags_plugin.lo
+       ${SOLINK} -o $@ tags_plugin.lo
+
+%.lo: %.c
+       ${LTCOMPILE} -o $@ -c $<
index ab566f4..18ef3a1 100644 (file)
@@ -60,12 +60,11 @@ typedef int (*glite_jpps_fplug_init_t)(
 );
 
 
-/** Lookup file plugin according to given file-type.
-\param[in] ctx         JPPS context
-\param[in] uri         Requested file-type.
-\param[out] data       Context of the plugin
-*/
 
+
+/* XXX: not really public interface follows */
+
+int glite_jpps_fplug_load(glite_jp_context_t ctx,int argc,char **argv);
 int glite_jpps_fplug_lookup(glite_jp_context_t ctx,const char *uri, glite_jpps_fplug_data_t **plugin_data);
 
 #endif
index 54c152d..cf901fb 100644 (file)
@@ -6,7 +6,7 @@
 
 int glite_jppsbe_init(
        glite_jp_context_t ctx,
-       int *argc,
+       int argc,
        char *argv[]
 );
 
index 921dbca..1a8cef3 100644 (file)
@@ -12,6 +12,8 @@
 #include <stdsoap2.h>
 #include "glite/security/glite_gsplugin.h"
 
+#include "backend.h"
+#include "file_plugin.h"
 
 
 #include "jpps_H.h"
@@ -40,9 +42,11 @@ static int debug = 1;
 
 static glite_jp_context_t      ctx;
 
+static int call_opts(glite_jp_context_t,char *,char *,int (*)(glite_jp_context_t,int,char **));
+
 int main(int argc, char *argv[])
 {
-       int     one = 1;
+       int     one = 1,opt,bend = 0;
        edg_wll_GssStatus       gss_code;
        struct sockaddr_in      a;
 
@@ -50,16 +54,26 @@ int main(int argc, char *argv[])
 
        glite_jp_init_context(&ctx);
 
-       if (glite_jppsbe_init(ctx, &argc, argv)) {
-               /* XXX log */
-               fputs(glite_jp_error_chain(ctx), stderr);
-               exit(1);
+       while ((opt = getopt(argc,argv,"B:P:")) != EOF) switch (opt) {
+               case 'B':
+                       if (call_opts(ctx,optarg,"backend",glite_jppsbe_init)) {
+                               /* XXX log */
+                               fputs(glite_jp_error_chain(ctx), stderr);
+                               exit(1);
+                       }
+                       bend = 1;
+                       break;
+               case 'P':
+                       if (call_opts(ctx,optarg,"plugins",glite_jpps_fplug_load)) {
+                               /* XXX log */
+                               fputs(glite_jp_error_chain(ctx), stderr);
+                               exit(1);
+                       }
        }
 
-       if (glite_jpps_fplug_load(ctx, &argc, argv)) {
-               /* XXX log */
-               fputs(glite_jp_error_chain(ctx), stderr);
-               exit(1);
+       if (!bend) {
+               fputs("-B required\n",stderr);
+               exit (1);
        }
 
        srand48(time(NULL)); /* feed id generation */
@@ -89,7 +103,7 @@ int main(int argc, char *argv[])
        }
 
        if (!server_cert || !server_key)
-               fprintf(stderr, "%s: WARNING: key or certificate file not specified,"
+               fprintf(stderr, "%s: WARNING: key or certificate file not specified, "
                                "can't watch them for changes\n",
                                argv[0]);
 
@@ -252,6 +266,27 @@ static int disconn(int conn,struct timeval *to,void *data)
        return 0;
 }
 
+#define WSPACE "\t\n "
+
+static int call_opts(glite_jp_context_t ctx,char *opt,char *name,int (*f)(glite_jp_context_t,int,char **))
+{
+       int     ac = 1,ret,my_optind; 
+       char    **av = malloc(sizeof *av),*ap;
+
+       *av = name;
+       for (ap = strtok(opt,WSPACE); ap; ap = strtok(NULL,WSPACE)) {
+               av = realloc(av,(ac+1) * sizeof *av);
+               av[ac++] = ap;
+       }
+
+       my_optind = optind;
+       optind = 0;
+       ret = f(ctx,ac,av);
+       optind = my_optind;
+       free(av);
+       return ret;
+}
+
 
 /* XXX: we don't use it */
 SOAP_NMAC struct Namespace namespaces[] = { {NULL,NULL} };
index d703eec..25687ef 100644 (file)
@@ -57,23 +57,16 @@ static int loadit(glite_jp_context_t ctx,const char *so)
        return 0;
 }
 
-int glite_jpps_fplug_load(glite_jp_context_t ctx,int *argc,char **argv)
+int glite_jpps_fplug_load(glite_jp_context_t ctx,int argc,char **argv)
 {
-       int     opt,ret;
-
-       while ((opt = getopt_long(*argc,argv,"p:",opts,NULL)) != EOF) switch (opt) {
-               case 'p':
-                       glite_jp_clear_error(ctx);
-
-                       if (loadit(ctx,optarg)) {
-                               glite_jp_error_t        err;
-                               err.source = __FUNCTION__;
-                               err.code = EINVAL;
-                               err.desc = optarg;
-                               return glite_jp_stack_error(ctx,&err);
-                       }
-                       break;
-               default: break;
+       int     i;
+
+       for (i=1; i<argc; i++) if (loadit(ctx,argv[i])) {
+               glite_jp_error_t        err;
+               err.source = __FUNCTION__;
+               err.code = EINVAL;
+               err.desc = argv[i];
+               return glite_jp_stack_error(ctx,&err);
        }
 
        return 0;
index dc4ed60..8bf523b 100644 (file)
@@ -165,7 +165,7 @@ static long regtime_ceil(long tv_sec)
 /********************************************************************************/
 int glite_jppsbe_init(
        glite_jp_context_t ctx,
-       int *argc,
+       int argc,
        char *argv[]
 )
 {
@@ -184,7 +184,7 @@ int glite_jppsbe_init(
 
        config->logname = getlogin();
 
-       while ((opt = getopt_long(*argc, argv, "I:E:G:", ftpbe_opts, NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "I:E:G:", ftpbe_opts, NULL)) != EOF) {
                switch (opt) {
                        case 'I': config->internal_path = optarg; break;
                        case 'E': config->external_path = optarg; break;