- add tar lib into sandbox_plugin.so
authorMiloš Mulač <mulac@civ.zcu.cz>
Mon, 11 Dec 2006 16:26:30 +0000 (16:26 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Mon, 11 Dec 2006 16:26:30 +0000 (16:26 +0000)
- read wrapper

org.glite.jp.primary/Makefile
org.glite.jp.primary/src/sandbox_plugin.c

index 48e93dd..d7427c1 100644 (file)
@@ -79,7 +79,7 @@ COMMONLIB:=-lglite_jp_common_${nothrflavour}
 BONESLIB:=-lglite_lb_server_bones
 GSOAPLIB:=-L${stagedir}/lib -lglite_security_gsoap_plugin_${dotless_soap_ver}_${nothrflavour} 
 TRIOLIB:=-lglite_jp_trio
-LIBTARLIB:=-L${libtar_prefix}/lib -llibtar
+LIBTARLIB:=-L${libtar_prefix}/lib -ltar
 
 ifneq (${mysql_prefix},/usr)
        ifeq ($(shell test -f ${mysql_prefix}/lib/libmysqlclient.a -o -f ${mysql_prefix}/lib/libmysqlclient.so && echo ok),ok)
@@ -198,7 +198,7 @@ simple_server.o soap_ops.o jpps-test.o: ${ps_prefix}H.h
 # 
 
 glite-jp-sandbox.la: sandbox_plugin.lo
-       ${SOLINK} -o $@ sandbox_plugin.lo ${LIBLIBTAR}
+       ${SOLINK} -o $@ sandbox_plugin.lo ${LIBTARLIB}
 
 glite-jp-tags.la: tags_plugin.lo
        ${SOLINK} -o $@ tags_plugin.lo
index 2bd63ef..6190457 100644 (file)
@@ -21,7 +21,13 @@ typedef struct _sb_handle {
        char            **file_names;
 } sb_handle;
 
-
+// Global data needed for read/write wrappers
+static struct {
+       void                    *bhandle;
+       glite_jp_context_t      ctx;
+       off_t                   offset;
+} global_data;
+               
 
 //static int sandbox_append(void *,void *,int,...);
 static int sandbox_open(void *,void *,const char *uri,void **);
@@ -39,8 +45,20 @@ static int my_close(int fd) {
         return 0;
 }
 
-static ssize_t my_read(int fd, void *buf, size_t count) {
-       // XXX: wrapper around glite_jppsbe_pread
+// wrapper around glite_jppsbe_pread
+static ssize_t my_read(int fd, void *buf, size_t count) 
+{
+       size_t                  r;
+
+       
+       if (glite_jppsbe_pread(global_data.ctx,global_data.bhandle,buf,count,global_data.offset,&r)) {
+               errno = global_data.ctx->error->code;
+               return -1;
+       }
+
+       global_data.offset += r;
+
+       return r;
 }
 
 
@@ -52,6 +70,7 @@ static ssize_t my_write(int fd, const void *buf, size_t count) {
 int init(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data)
 {
        data->fpctx = ctx;
+       global_data.ctx = ctx;
 
        data->uris = calloc(2,sizeof *data->uris);
        data->uris[0] = strdup(GLITE_JP_FILETYPE_ISB);
@@ -75,6 +94,8 @@ static int sandbox_open(void *fpctx,void *bhandle,const char *uri,void **handle)
        printf("sandbox_open() called\n");
 
        h->bhandle = bhandle;
+       global_data.bhandle = bhandle;
+       global_data.offset = 0;
 
        h->tt = malloc(sizeof(*h->tt));
        h->tt->openfunc = my_open;