From c9dd4c3b66499aae364beb996d7e739167854c37 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Mon, 7 Apr 2008 15:14:54 +0000 Subject: [PATCH] utils and interfaces moved to common --- org.glite.jp.primary/Makefile | 10 +-- org.glite.jp.primary/interface/file_plugin.h | 86 ------------------ org.glite.jp.primary/src/attrs.c | 8 +- org.glite.jp.primary/src/bones_server.c | 4 +- org.glite.jp.primary/src/classad_plugin.c | 6 +- org.glite.jp.primary/src/feed.c | 5 +- org.glite.jp.primary/src/new_ftp_backend.c | 2 +- org.glite.jp.primary/src/sandbox_plugin.c | 6 +- org.glite.jp.primary/src/tags.c | 7 +- org.glite.jp.primary/src/utils.c | 127 --------------------------- org.glite.jp.primary/src/utils.h | 27 ------ 11 files changed, 23 insertions(+), 265 deletions(-) delete mode 100644 org.glite.jp.primary/interface/file_plugin.h delete mode 100644 org.glite.jp.primary/src/utils.c delete mode 100644 org.glite.jp.primary/src/utils.h diff --git a/org.glite.jp.primary/Makefile b/org.glite.jp.primary/Makefile index 0e8fa45..7696978 100644 --- a/org.glite.jp.primary/Makefile +++ b/org.glite.jp.primary/Makefile @@ -46,7 +46,7 @@ GLOBUS_CFLAGS:=-I${globus_prefix}/include/${nothrflavour} DEBUG:=-g -O0 -DDEBUG -CFLAGS:=${DEBUG} -I. -I${top_srcdir}/interface -I${top_srcdir}/src -I${gsoap_prefix}/include -I${gsoap_prefix} -I${stagedir}/include -I${classads_prefix}/include -I${libtar_prefix}/include ${GLOBUS_CFLAGS} +CFLAGS:=${DEBUG} -I. -I${top_srcdir}/src -I${gsoap_prefix}/include -I${gsoap_prefix} -I${stagedir}/include -I${classads_prefix}/include -I${libtar_prefix}/include ${GLOBUS_CFLAGS} # 3.1 CFLAGS:=${DEBUG} -I. -I${top_srcdir}/interface -I${top_srcdir}/src -I${gsoap_prefix}/include -I${gsoap_prefix} -I${stagedir}/include ${GLOBUS_CFLAGS} -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql -I${classads_prefix}/include -I${libtar_prefix}/include LDFLAGS:=-L${stagedir}/lib @@ -65,9 +65,6 @@ sample_jobs:=sample_job_aborted sample_job_cleared sample_job_tagged_done sam plugins:=glite-jp-ftpdauth.la glite-jp-classad.la glite-jp-sandbox.la -HDRS_I=file_plugin.h -HDRS_S=builtin_plugins.h backend.h feed.h utils.h - SRCS:= bones_server.c soap_ops.c \ new_ftp_backend.c file_plugin.c utils.c\ feed.c authz.c attrs.c \ @@ -162,11 +159,6 @@ install: ${INSTALL} -m 755 ${daemon} ${PREFIX}/bin ${INSTALL} -m 755 jpps-test ${PREFIX}/examples/glite-jp-primary-test ${INSTALL} -m 755 ${top_srcdir}/examples/getjobattr.pl ${PREFIX}/examples/glite-jpps-getjobattr.pl - if [ x${DOSTAGE} = xyes ]; then \ - mkdir -p ${PREFIX}/include/${globalprefix}/${jpprefix} ; \ - (cd ${top_srcdir}/interface && install -m 644 ${HDRS_I} ${PREFIX}/include/${globalprefix}/${jpprefix}) ; \ - (cd ${top_srcdir}/src && install -m 644 ${HDRS_S} ${PREFIX}/include/${globalprefix}/${jpprefix}) ; \ - fi for plugin in ${plugins}; do \ ${INSTALL} -m 755 $$plugin ${PREFIX}/lib; \ done diff --git a/org.glite.jp.primary/interface/file_plugin.h b/org.glite.jp.primary/interface/file_plugin.h deleted file mode 100644 index eea7d05..0000000 --- a/org.glite.jp.primary/interface/file_plugin.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef GLITE_JP_FILEPLUGIN_H -#define GLITE_JP_FILEPLUGIN_H - -/** Methods of the file plugin. */ - -typedef struct _glite_jpps_fplug_op_t { - -/** Open a file. -\param[in] fpctx Context of the plugin, returned by its init. -\param[in] bhandle Handle of the file via JPPS backend. -\param[in] uri URI (type) of the opened file. -\param[out] handle Handle to the opened file structure, to be passed to other plugin functions. -*/ - int (*open)(void *fpctx,void *bhandle,const char *uri,void **handle); -/** Open from a string. -\param[in] fpctx Context of the plugin, returned by its init. -\param[in] str The string to use. -\param[in] uri URI (type) of the string -\param[in] ns namespace to handle -\param[out] handle Handle to the opened file structure, to be passed to other plugin functions. -*/ - - int (*open_str)(void *fpctx,const char *str,const char *uri,const char *ns,void **handle); - -/** Close the file. Free data associated to a handle */ - int (*close)(void *fpctx,void *handle); - -/** "Preprocess" the file -- this function is called once after the file is commited */ - int (*filecom)(void *fpctx,void *handle); - -/** Retrieve value(s) of an attribute. -\param[in] fpctx Plugin context. -\param[in] handle Handle of the opened file. -\param[in] ns Namespace of queried attribute. -\param[in] attr Queried attribute. -\param[out] attrval GLITE_JP_ATTR_UNDEF-terminated list of value(s) of the attribute. - If there are more and there is an interpretation of their order - they must be sorted, eg. current value of tag is the last one. -\retval 0 success -\retval ENOSYS this attribute is not defined by this type of file -\retval ENOENT no value is present -*/ - int (*attr)(void *fpctx,void *handle, const char *attr,glite_jp_attrval_t **attrval); - -/** File type specific operation. -\param[in] fpctx Plugin context. -\param[in] handle Handle of the opened file. -\param[in] oper Code of the operation, specific for a concrete plugin. -*/ - int (*generic)(void *fpctx,void *handle,int oper,...); - -} glite_jpps_fplug_op_t; - -/** Data describing a plugin. */ -typedef struct _glite_jpps_fplug_data_t { - void *fpctx; /**< Context passed to plugin operations. */ - char **uris; /**< NULL-terminated list of file types (URIs) - handled by the plugin. */ - char **classes; /**< The same as uris but filesystem-friendly - (can be used to construct file names).*/ - char **namespaces; /**< Which attribute namespaces this plugin handles. */ - - glite_jpps_fplug_op_t ops; /**< Plugin operations. */ -} glite_jpps_fplug_data_t; - -/** Initialisation function of the plugin. - Called after dlopen(), must be named "init". -\param[in] ctx JPPS context -\param[out] data filled-in plugin data -*/ - -typedef int (*glite_jpps_fplug_init_t)( - glite_jp_context_t ctx, - glite_jpps_fplug_data_t *plugin_data -); - - - - -/* 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); -int glite_jpps_fplug_lookup_byclass(glite_jp_context_t, const char *class,glite_jpps_fplug_data_t ***plugin_data); - -#endif /* GLITE_JP_FILEPLUGIN_H */ diff --git a/org.glite.jp.primary/src/attrs.c b/org.glite.jp.primary/src/attrs.c index b4415c9..f6655ee 100644 --- a/org.glite.jp.primary/src/attrs.c +++ b/org.glite.jp.primary/src/attrs.c @@ -3,16 +3,16 @@ #include #include #include +#include #include "glite/lbu/trio.h" #include "glite/jp/types.h" #include "glite/jp/attr.h" +#include "glite/jp/backend.h" +#include "glite/jp/file_plugin.h" #include "feed.h" -#include "backend.h" #include "attrs.h" -#include "utils.h" -#include "file_plugin.h" #include "builtin_plugins.h" static struct { @@ -92,7 +92,7 @@ static int merge_attrvals(glite_jp_attrval_t **out,int nout,const glite_jp_attrv return nout+nin; } -void process_files(glite_jp_context_t ctx, const char *job, glite_jp_attrval_t** out, int* nout, const char* attr, const glite_jpps_fplug_data_t* plugin, const char* class, const char* uri, const char **opened_class, const char **opened_file, void **op_handle, void **of_handle){ +static void process_files(glite_jp_context_t ctx, const char *job, glite_jp_attrval_t** out, int* nout, const char* attr, const glite_jpps_fplug_data_t* plugin, const char* class, const char* uri, char **opened_class, char **opened_file, void **op_handle, void **of_handle){ void *ph, *beh; char** names = NULL; int nnames; diff --git a/org.glite.jp.primary/src/bones_server.c b/org.glite.jp.primary/src/bones_server.c index 891d751..be568c7 100644 --- a/org.glite.jp.primary/src/bones_server.c +++ b/org.glite.jp.primary/src/bones_server.c @@ -6,6 +6,7 @@ #include "glite/jp/types.h" #include "glite/jp/context.h" +#include "glite/jp/file_plugin.h" #include "glite/lbu/srvbones.h" #include "glite/security/glite_gss.h" @@ -14,8 +15,7 @@ #include "glite/security/glite_gsplugin.h" #include "feed.h" -#include "backend.h" -#include "file_plugin.h" +#include "backend_private.h" #include "soap_version.h" #include "jpps_H.h" diff --git a/org.glite.jp.primary/src/classad_plugin.c b/org.glite.jp.primary/src/classad_plugin.c index 1d7b6ec..1858b67 100644 --- a/org.glite.jp.primary/src/classad_plugin.c +++ b/org.glite.jp.primary/src/classad_plugin.c @@ -5,6 +5,7 @@ #include #include #include +#include /* #include "glite/lb/context.h" @@ -18,9 +19,10 @@ #include "glite/jp/attr.h" #include "glite/jp/known_attr.h" -#include "file_plugin.h" +#include "glite/jp/file_plugin.h" +#include "glite/jp/backend.h" + #include "builtin_plugins.h" -#include "backend.h" //#define INITIAL_NUMBER_EVENTS 100 //#define INITIAL_NUMBER_STATES EDG_WLL_NUMBER_OF_STATCODES diff --git a/org.glite.jp.primary/src/feed.c b/org.glite.jp.primary/src/feed.c index b461403..1f3904c 100644 --- a/org.glite.jp.primary/src/feed.c +++ b/org.glite.jp.primary/src/feed.c @@ -11,11 +11,12 @@ #include "glite/jp/context.h" #include "glite/jp/strmd5.h" #include "glite/jp/known_attr.h" +#include "glite/jp/file_plugin.h" + #include "feed.h" -#include "file_plugin.h" #include "builtin_plugins.h" #include "is_client.h" -#include "backend.h" +#include "backend_private.h" extern pid_t master; diff --git a/org.glite.jp.primary/src/new_ftp_backend.c b/org.glite.jp.primary/src/new_ftp_backend.c index 84de773..901441a 100644 --- a/org.glite.jp.primary/src/new_ftp_backend.c +++ b/org.glite.jp.primary/src/new_ftp_backend.c @@ -25,7 +25,7 @@ #include "feed.h" #include "tags.h" -#include "backend.h" +#include "backend_private.h" #include "jpps_H.h" /* XXX: SOAP_TYPE___jpsrv__GetJob */ diff --git a/org.glite.jp.primary/src/sandbox_plugin.c b/org.glite.jp.primary/src/sandbox_plugin.c index 680e277..0d59c3b 100644 --- a/org.glite.jp.primary/src/sandbox_plugin.c +++ b/org.glite.jp.primary/src/sandbox_plugin.c @@ -1,19 +1,21 @@ #include +#include #include #include #include #include #include +#include #include #include #include #include +#include "glite/jp/backend.h" -#include "file_plugin.h" +#include "glite/jp/file_plugin.h" #include "builtin_plugins.h" -#include "backend.h" #define ALLOC_CHUNK 3 diff --git a/org.glite.jp.primary/src/tags.c b/org.glite.jp.primary/src/tags.c index 851c671..98be56e 100644 --- a/org.glite.jp.primary/src/tags.c +++ b/org.glite.jp.primary/src/tags.c @@ -6,11 +6,12 @@ #include #include #include +#include #include #include +#include "glite/jp/backend.h" #include "tags.h" -#include "backend.h" /* magic name_len value_len binary sequence timestamp */ #define HEADER "JP#TAG# %05u %012lu %c %05u %012lu#" @@ -245,7 +246,7 @@ int tag_append(void *fpctx,void *bhandle,glite_jp_attrval_t * tag) char *hdr,*rec; glite_jp_context_t ctx = fpctx; uint32_t magic,hlen,rlen,rlen_n; - size_t r; + ssize_t r; glite_jp_error_t err; memset(&err,0,sizeof err); @@ -359,7 +360,7 @@ static int tagsread(void *fpctx,struct tags_handle *h) glite_jp_context_t ctx = fpctx; uint32_t magic,rlen; glite_jp_error_t err; - int r; + ssize_t r; size_t off = sizeof rlen; glite_jp_attrval_t *tp; char *rp; diff --git a/org.glite.jp.primary/src/utils.c b/org.glite.jp.primary/src/utils.c deleted file mode 100644 index 911f762..0000000 --- a/org.glite.jp.primary/src/utils.c +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glite/jp/types.h" -#include "glite/jp/context.h" -#include "glite/jp/strmd5.h" -#include "glite/jp/known_attr.h" -#include "glite/jp/attr.h" - -#include "feed.h" -#include "tags.h" - -#include "utils.h" -#include "backend.h" - -/* - * realloc the line to double size if needed - * - * \return 0 if failed, did nothing - * \return 1 if success - */ -int check_realloc_line(char **line, size_t *maxlen, size_t len) { - void *tmp; - - if (len > *maxlen) { - *maxlen <<= 1; - tmp = realloc(*line, *maxlen); - if (!tmp) return 0; - *line = tmp; - } - - return 1; -} - -/* - * read next line from stream - * - * \return error code - */ -int glite_jppsbe_readline( - glite_jp_context_t ctx, - void *handle, - rl_buffer_t *buffer, - char **line -) -{ - size_t maxlen, len, i; - ssize_t nbytes; - int retval, z, end; - - maxlen = BUFSIZ; - i = 0; - len = 0; - *line = malloc(maxlen); - end = 0; - - do { - /* read next portion */ - if (buffer->pos >= buffer->size) { - buffer->pos = 0; - buffer->size = 0; - if ((retval = glite_jppsbe_pread(ctx, handle, buffer->buf, BUFSIZ, buffer->offset, &nbytes)) == 0) { - if (nbytes < 0) { - retval = EINVAL; - goto fail; - } else { - if (nbytes) { - buffer->size = (size_t)nbytes; - buffer->offset += nbytes; - } else end = 1; - } - } else goto fail; - } - - /* we have buffer->size - buffer->pos bytes */ - i = buffer->pos; - do { - if (i >= buffer->size) z = '\0'; - else { - z = buffer->buf[i]; - if (z == '\n') z = '\0'; - } - len++; - - if (!check_realloc_line(line, &maxlen, len)) { - retval = ENOMEM; - goto fail; - } - (*line)[len - 1] = z; - i++; - } while (z && i < buffer->size); - buffer->pos = i; - } while (len && (*line)[len - 1] != '\0'); - - if ((!len || !(*line)[0]) && end) { - free(*line); - *line = NULL; - } - - return 0; - -fail: - free(*line); - *line = NULL; - return retval; -} - -char* glite_jpps_get_namespace(const char* attr){ - char* namespace = strdup(attr); - char* colon = strrchr(namespace, ':'); - if (colon) - namespace[strrchr(namespace, ':') - namespace] = 0; - else - namespace[0] = 0; - return namespace; -} - diff --git a/org.glite.jp.primary/src/utils.h b/org.glite.jp.primary/src/utils.h deleted file mode 100644 index 742098a..0000000 --- a/org.glite.jp.primary/src/utils.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef GLITE_JP_UTILS_H -#define GLITE_JP_UTILS_H - -#include -#include -#include - -#include "feed.h" - -typedef struct _rl_buffer_t { - char *buf; - size_t pos, size; - off_t offset; -} rl_buffer_t; - -int glite_jppsbe_readline( - glite_jp_context_t ctx, - void *handle, - rl_buffer_t *buffer, - char **line -); - -char* glite_jpps_get_namespace( - const char* attr -); - -#endif /* GLITE_JP_UTILS_H */ -- 1.8.2.3