From 8de026fb8fef2aab897998b1a21eeb5ef368265e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20=C5=A0kr=C3=A1bal?= Date: Mon, 19 Sep 2005 15:07:27 +0000 Subject: [PATCH] - JP importer lib - first shot --- org.glite.jp.client/Makefile | 22 +++++-- org.glite.jp.client/interface/jpimp-ctx-int.h | 23 ++++++++ org.glite.jp.client/interface/jpimporter.h | 37 ++++++++++++ org.glite.jp.client/src/jpimp_ctx.c | 82 +++++++++++++++++++++++++++ org.glite.jp.client/src/jpimp_lib.c | 22 +++++++ 5 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 org.glite.jp.client/interface/jpimp-ctx-int.h create mode 100644 org.glite.jp.client/interface/jpimporter.h create mode 100644 org.glite.jp.client/src/jpimp_ctx.c create mode 100644 org.glite.jp.client/src/jpimp_lib.c diff --git a/org.glite.jp.client/Makefile b/org.glite.jp.client/Makefile index b065ce7..7b9388e 100644 --- a/org.glite.jp.client/Makefile +++ b/org.glite.jp.client/Makefile @@ -23,7 +23,7 @@ CC=gcc -include Makefile.inc -VPATH=${top_srcdir}/src:${top_srcdir}/examples:${top_srcdir}/project:${stagedir}/interface +VPATH=${top_srcdir}/src:${top_srcdir}/examples:${top_srcdir}/project:${stagedir}/interface:${top_srcdir}/build GLOBUS_LIBS:=-L${globus_prefix}/lib \ -lglobus_common_${nothrflavour} \ @@ -43,6 +43,16 @@ LTCOMPILE:=libtool --mode=compile ${CC} ${CFLAGS} LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} INSTALL:=libtool --mode=install install +HDRS:=jpimporter.h + +LIBOBJS:=jpimp_ctx.o jpimp_lib.o + +LIBTHROBJS:=${LIBOBJS:.o=.thr.o} +LIBLOBJS:=${LIBOBJS:.o=.lo} + +LIB:=libglite_jp_importer_${nothrflavour}.la +THRLIB:=libglite_jp_importer_${thrflavour}.la + daemon:=glite-jp-importer wsprefix:=jpps_ @@ -56,17 +66,21 @@ EXA_SRCS:= OBJS:=${SRCS:.c=.o} EXA_OBJS:=${EXA_SRCS:.c=.o} -COMMONLIB:=-lglite_jp_common GSOAPLIB:=-lglite_security_gsoap_plugin_${nothrflavour} -lglite_security_gss_${nothrflavour} \ -L${gsoap_prefix}/lib -lgsoap${GSOAP_DEBUG} -L${ares_prefix}/lib -lares LBMAILDIRLIB:=-lglite_lb_maildir +version_info=-version-info `echo ${version} | cut -d. -f1,2 | tr . :` + default all: compile -compile: ${daemon} +compile: ${daemon} ${LIB} + +${LIB}: ${LIBOBJS} + ${LINK} ${version_info} -o $@ ${LIBLOBJS} -rpath ${glite_location}/lib ${LBMAILDIRLIB} ${daemon}: ${OBJS} - ${LINK} -o $@ ${OBJS} ${LBMAILDIRLIB} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} + ${LINK} -o $@ ${OBJS} ${LBMAILDIRLIB} ${GSOAPLIB} ${GLOBUS_LIBS} JobProvenancePS.xh: %.xh: %.wsdl JobProvenanceTypes.wsdl typemap.dat diff --git a/org.glite.jp.client/interface/jpimp-ctx-int.h b/org.glite.jp.client/interface/jpimp-ctx-int.h new file mode 100644 index 0000000..3412e39 --- /dev/null +++ b/org.glite.jp.client/interface/jpimp-ctx-int.h @@ -0,0 +1,23 @@ +#ifndef __GLITE_JPIMPORTER_CONTEXT_INT +#define __GLITE_JPIMPORTER_CONTEXT_INT + +#ifdef __cplusplus +extern "C" { +#endif + +struct _glite_jpimp_context_t { + int errCode; + char *errDesc; + + char *jpps; + char *lbmd_dir; +}; + +extern int glite_jpimp_SetError(glite_jpimp_context_t, int, const char *); +extern int glite_jpimp_ResetError(glite_jpimp_context_t); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/org.glite.jp.client/interface/jpimporter.h b/org.glite.jp.client/interface/jpimporter.h new file mode 100644 index 0000000..7258bc6 --- /dev/null +++ b/org.glite.jp.client/interface/jpimporter.h @@ -0,0 +1,37 @@ +#ifndef __GLITE_JPIMPORTER +#define __GLITE_JPIMPORTER + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _glite_jpimp_context_t *glite_jpimp_context_t; + +typedef enum _glite_jpimp_ctx_param_t { + GLITE_JPIMP_PARAM_JPPS, + GLITE_JPIMP_PARAM_LBMAILDIR +} glite_jpimp_ctx_param_t; + +extern int glite_jpimp_InitContext(glite_jpimp_context_t *); +extern void glite_jpimp_FreeContext(glite_jpimp_context_t); + +extern int glite_jpimp_SetParam( + glite_jpimp_context_t ctx, + int param, ... ); + +extern int glite_jpimp_Error( + glite_jpimp_context_t ctx, + char **errt, + char **errd); + +extern int glite_jpimporter_upload_files( + glite_jpimp_context_t ctx, + char *jobid, + char *files, + char *user); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/org.glite.jp.client/src/jpimp_ctx.c b/org.glite.jp.client/src/jpimp_ctx.c new file mode 100644 index 0000000..ef030a9 --- /dev/null +++ b/org.glite.jp.client/src/jpimp_ctx.c @@ -0,0 +1,82 @@ +#include +#include +#include +#include +#include + +#include "jpimporter.h" +#include "jpimp-ctx-int.h" + + +int glite_jpimp_InitContext(glite_jpimp_context_t *ctx) +{ + glite_jpimp_context_t out = (glite_jpimp_context_t) malloc(sizeof(*out)); + if (!out) return ENOMEM; + memset(out, 0, sizeof(*out)); + assert(out->errDesc == NULL); + + *ctx = out; + return 0; +} + +void glite_jpimp_FreeContext(glite_jpimp_context_t ctx) +{ + free(ctx->jpps); + free(ctx->lbmd_dir); +} + +int glite_jpimp_SetParam(glite_jpimp_context_t ctx, int param, ...) +{ + va_list ap; + + va_start(ap, param); + switch ( param ) { + case GLITE_JPIMP_PARAM_JPPS: + if ( ctx->jpps ) free(ctx->jpps); + ctx->jpps = va_arg(ap, char *); + ctx->jpps = strdup(ctx->jpps); + break; + case GLITE_JPIMP_PARAM_LBMAILDIR: + if ( ctx->lbmd_dir ) free(ctx->lbmd_dir); + ctx->lbmd_dir = strdup(va_arg(ap, char *)); + break; + default: + return glite_jpimp_SetError(ctx, EINVAL, "unknown parameter"); + } + + return 0; +} + +int glite_jpimp_Error( + glite_jpimp_context_t ctx, + char **errt, + char **errd) +{ + if ( errt ) *errt = strdup(strerror(ctx->errCode)); + if ( errd ) *errd = (ctx->errDesc)? strdup(ctx->errDesc): NULL; + return ctx->errCode; +} + +int glite_jpimp_SetError( + glite_jpimp_context_t ctx, + int code, + const char *desc) +{ + glite_jpimp_ResetError(ctx); + if ( code ) { + ctx->errCode = code; + if ( desc ) ctx->errDesc = (char *) strdup(desc); + } + + return ctx->errCode; +} + +int glite_jpimp_ResetError( + glite_jpimp_context_t ctx) +{ + if ( ctx->errDesc ) free(ctx->errDesc); + ctx->errDesc = NULL; + ctx->errCode = 0; + + return ctx->errCode; +} diff --git a/org.glite.jp.client/src/jpimp_lib.c b/org.glite.jp.client/src/jpimp_lib.c new file mode 100644 index 0000000..999b470 --- /dev/null +++ b/org.glite.jp.client/src/jpimp_lib.c @@ -0,0 +1,22 @@ +#include "lb_maildir" +#include "jpimporter.h" +#include "jpimp-ctx-int.h" + +int glite_jpimporter_upload_files( + glite_jpimp_context_t ctx, + char *jobid, + char *files, + char *userdn) +{ + if ( edg_wll_MaildirInit(ctx->lbmd_dir) ) { + char *aux; + asprintf(aux, "Can't initialize maildir structure - %s", lbm_errdesc); + glite_jpimp_SetError(ctx, errno, aux); + free(aux); + return -1; + } + + edg_wll_MaildirStoreMsg(const char *, const char *, const char *); + + return 0; +} -- 1.8.2.3