From: cvs2svn Date: Fri, 10 Dec 2004 12:42:33 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create tag 'glite-lb- X-Git-Tag: glite-lb-common_R_0_3_0 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=23f076202323e5dafa48f5c97de15cec659dbf78;p=jra1mw.git This commit was manufactured by cvs2svn to create tag 'glite-lb- common_R_0_3_0'. Sprout from glite-lb-common_branch_1_1_0 2004-12-10 12:42:32 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch 'glite-lb-' Cherrypick from master 2004-11-24 04:58:40 UTC Master Builder 'Incremented build number [GLBUILDER]': org.glite.lb.common/interface/context-int.h org.glite.lb.common/interface/lb_plain_io.h org.glite.lb.common/interface/xml_conversions.h org.glite.lb.common/project/version.properties org.glite.lb.common/src/context.c org.glite.lb.common/src/lb_plain_io.c org.glite.lb.common/src/mini_http.c org.glite.lb.common/src/param.c org.glite.lb.common/src/ulm_parse.c org.glite.lb.common/src/xml_conversions.c org.glite.lb.common/src/xml_parse.c.T org.glite.lb.common/test/test_gss.cpp Cherrypick from master 2004-11-25 09:55:24 UTC Aleš Křenek 'Avoid adding -L/usr/lib': org.glite.lb.common/Makefile --- diff --git a/org.glite.lb.common/Makefile b/org.glite.lb.common/Makefile index d4424be..95a574e 100644 --- a/org.glite.lb.common/Makefile +++ b/org.glite.lb.common/Makefile @@ -38,7 +38,6 @@ CFLAGS:=${DEBUG} -I${top_srcdir}/src -I${top_srcdir}/interface \ -I${expat_prefix}/include \ -I${ares_prefix}/include \ ${COVERAGE_FLAGS} \ - -D_GNU_SOURCE \ -DDATAGRID_EXTENSION # We must follow major version changes of org.glite.lb.client-interface due to @@ -46,7 +45,7 @@ CFLAGS:=${DEBUG} -I${top_srcdir}/src -I${top_srcdir}/interface \ # major version more frequently. This variable specifies how many steps ahead # we are. -VERSION_AHEAD=1 +VERSION_AHEAD=0 GLOBUS_LIBS:=-L${globus_prefix}/lib \ -lglobus_common_${nothrflavour} \ diff --git a/org.glite.lb.common/interface/context-int.h b/org.glite.lb.common/interface/context-int.h index c9f6acf..c8125cb 100644 --- a/org.glite.lb.common/interface/context-int.h +++ b/org.glite.lb.common/interface/context-int.h @@ -5,7 +5,7 @@ #include "glite/lb/consumer.h" #include "lb_gss.h" -#include "lb_plain_io.h" +//#include "lb_plain_io.h" #include "authz.h" #ifdef __cplusplus @@ -18,13 +18,13 @@ typedef struct _edg_wll_SeqCode { -/* non-gsi one-element analogy of connPool for L&B Proxy server */ -typedef struct _edg_wll_ConnProxy { - edg_wll_PlainConnection conn; - char *buf; - size_t bufSize; - size_t bufUse; -} edg_wll_ConnProxy; +/* non-gsi one-element analogy of connPool */ +typedef struct _edg_wll_Connection { + int sock; + char *buf; + size_t bufSize; + size_t bufUse; +} edg_wll_Connection; @@ -36,6 +36,7 @@ typedef struct _edg_wll_ConnPool { /* http(s) stream */ gss_cred_id_t gsiCred; edg_wll_GssConnection gss; + edg_wll_Connection conn; /* for plain (non-gss) connections - i.e. lbproxy */ char *buf; int bufUse,bufSize; @@ -55,7 +56,7 @@ struct _edg_wll_Context { void *mysql; edg_wll_ConnPool *connPool; edg_wll_ConnPool *connPoolNotif; /* hold _one_ connection from notif-interlogger */ - edg_wll_ConnProxy *connProxy; /* holds one plain connection */ + edg_wll_Connection *connPlain; /* holds one plain connection */ int semaphores,semset; edg_wll_QueryRec **job_index; @@ -132,7 +133,6 @@ struct _edg_wll_Context { /* producer part */ edg_wlc_JobId p_jobid; edg_wll_SeqCode p_seqcode; - int count_statistics; }; /* to be used internally: set, update and and clear the error information in diff --git a/org.glite.lb.common/interface/lb_plain_io.h b/org.glite.lb.common/interface/lb_plain_io.h index d423bbc..29c5032 100644 --- a/org.glite.lb.common/interface/lb_plain_io.h +++ b/org.glite.lb.common/interface/lb_plain_io.h @@ -2,39 +2,32 @@ #define __EDG_WORKLOAD_LOGGING_COMMON_LB_PLAIN_IO_H__ +#include "context-int.h" + #ifdef __cplusplus extern "C" { #endif -typedef struct _edg_wll_PlainConnection { - int sock; - char *buf; - size_t bufSize; - size_t bufUse; -} edg_wll_PlainConnection; int edg_wll_plain_accept( int sock, - edg_wll_PlainConnection *conn); - -int edg_wll_plain_close( - edg_wll_PlainConnection *conn); + edg_wll_Connection *conn); int edg_wll_plain_read( - edg_wll_PlainConnection *conn, + edg_wll_Connection *conn, void *outbuf, size_t outbufsz, struct timeval *timeout); int edg_wll_plain_read_full( - edg_wll_PlainConnection *conn, + edg_wll_Connection *conn, void *outbuf, size_t outbufsz, struct timeval *timeout); int edg_wll_plain_write_full( - edg_wll_PlainConnection *conn, + edg_wll_Connection *conn, const void *buf, size_t bufsz, struct timeval *timeout); diff --git a/org.glite.lb.common/interface/xml_conversions.h b/org.glite.lb.common/interface/xml_conversions.h index a5361b3..7d289ab 100644 --- a/org.glite.lb.common/interface/xml_conversions.h +++ b/org.glite.lb.common/interface/xml_conversions.h @@ -67,13 +67,6 @@ typedef struct _edg_wll_XML_ctx { edg_wll_NotifId notifId; edg_wll_NotifChangeOp notifChangeOp; time_t notifValidity; - char *statsFunction; - edg_wll_QueryRec **statsConditions; - edg_wll_JobStatCode statsMajor; - int statsMinor; - time_t statsFrom, statsTo; - float statsRate, statsDuration; - int statsResFrom, statsResTo; edg_wlc_JobId jobId; char *source; char *seqCode; @@ -99,7 +92,6 @@ void edg_wll_freeBuf(edg_wll_XML_ctx *c); void edg_wll_add_string_to_XMLBody(char **body, const char *toAdd, const char *tag, const char *null); void edg_wll_add_tagged_string_to_XMLBody(char **body, const char *toAdd, const char *tag, const char *name, const char *tag2, const char *null); void edg_wll_add_int_to_XMLBody(char **body, const int toAdd, const char *tag, const int null); -void edg_wll_add_float_to_XMLBody(char **body, const float toAdd, const char *tag, const float null); void edg_wll_add_timeval_to_XMLBody(char **body, struct timeval toAdd, const char *tag, const struct timeval null); void edg_wll_add_jobid_to_XMLBody(char **body, edg_wlc_JobId toAdd, const char *tag, const void *null); void edg_wll_add_notifid_to_XMLBody(char **body, edg_wll_NotifId toAdd, const char *tag, const void *null); @@ -118,7 +110,6 @@ edg_wlc_JobId edg_wll_from_string_to_jobid(edg_wll_XML_ctx *XMLCtx); edg_wll_NotifId edg_wll_from_string_to_notifid(edg_wll_XML_ctx *XMLCtx); edg_wll_JobStatCode edg_wll_from_string_to_edg_wll_JobStatCode(edg_wll_XML_ctx *XMLCtx); int edg_wll_from_string_to_int(edg_wll_XML_ctx *XMLCtx); -float edg_wll_from_string_to_float(edg_wll_XML_ctx *XMLCtx); long edg_wll_from_string_to_long(edg_wll_XML_ctx *XMLCtx); uint16_t edg_wll_from_string_to_uint16_t(edg_wll_XML_ctx *XMLCtx); struct timeval edg_wll_from_string_to_timeval(edg_wll_XML_ctx *XMLCtx); diff --git a/org.glite.lb.common/project/version.properties b/org.glite.lb.common/project/version.properties index aa6fcbe..cf759c3 100644 --- a/org.glite.lb.common/project/version.properties +++ b/org.glite.lb.common/project/version.properties @@ -1,4 +1,4 @@ -#Fri Dec 10 13:22:02 CET 2004 -module.version=1.0.0 -module.build=111 +#Wed Nov 24 05:47:54 CET 2004 +module.version=0.3.0 +module.build=93 module.age=2 diff --git a/org.glite.lb.common/src/context.c b/org.glite.lb.common/src/context.c index 33cb50c..504022d 100644 --- a/org.glite.lb.common/src/context.c +++ b/org.glite.lb.common/src/context.c @@ -32,8 +32,7 @@ int edg_wll_InitContext(edg_wll_Context *ctx) out->connPool = (edg_wll_ConnPool *) calloc(out->poolSize, sizeof(edg_wll_ConnPool)); out->connPoolNotif = (edg_wll_ConnPool *) calloc(1, sizeof(edg_wll_ConnPool)); - out->connProxy = (edg_wll_ConnPool *) calloc(1, sizeof(edg_wll_ConnProxy)); - out->connProxy->conn.sock = -1; + out->connPlain = (edg_wll_Connection *) calloc(1, sizeof(edg_wll_Connection)); *ctx = out; return 0; @@ -52,6 +51,10 @@ void edg_wll_FreeContext(edg_wll_Context ctx) for (i=0; ipoolSize; i++) { if (ctx->connPool[i].peerName) free(ctx->connPool[i].peerName); + + close(ctx->connPool[i].conn.sock); + if (ctx->connPool[i].conn.buf) free(ctx->connPool[i].conn.buf); + edg_wll_gss_close(&ctx->connPool[i].gss,&close_timeout); if (ctx->connPool[i].gsiCred) gss_release_cred(&min_stat, &ctx->connPool[i].gsiCred); @@ -59,18 +62,9 @@ void edg_wll_FreeContext(edg_wll_Context ctx) } free(ctx->connPool); } - if (ctx->connPoolNotif) { - if (ctx->connPoolNotif[0].peerName) free(ctx->connPoolNotif[0].peerName); - edg_wll_gss_close(&ctx->connPoolNotif[0].gss,&close_timeout); - if (ctx->connPoolNotif[0].gsiCred) - gss_release_cred(&min_stat, &ctx->connPoolNotif[0].gsiCred); - if (ctx->connPoolNotif[0].buf) free(ctx->connPoolNotif[0].buf); - free(ctx->connPoolNotif); - } - if ( ctx->connProxy ) { - if ( ctx->connProxy->buf ) free(ctx->connProxy->buf); - edg_wll_plain_close(&ctx->connProxy->conn); - free(ctx->connProxy); + if (ctx->connPlain) { + if (ctx->connPlain->buf) free(ctx->connPlain->buf); + free(ctx->connPlain); } if (ctx->notifSock >=0) close(ctx->notifSock); if (ctx->srvName) free(ctx->srvName); diff --git a/org.glite.lb.common/src/lb_plain_io.c b/org.glite.lb.common/src/lb_plain_io.c index f197c9b..dba91c6 100644 --- a/org.glite.lb.common/src/lb_plain_io.c +++ b/org.glite.lb.common/src/lb_plain_io.c @@ -29,38 +29,33 @@ } int edg_wll_plain_connect( - char const *hostname, - int port, - struct timeval *to, - edg_wll_PlainConnection *conn) + char const *hostname, + int port, + struct timeval *to, + edg_wll_Connection *conn) { return 0; } int edg_wll_plain_accept( - int sock, - edg_wll_PlainConnection *conn) + int sock, + edg_wll_Connection *conn) { + struct sockaddr_in a; + int alen = sizeof(a); + /* Do not free the buffer here - just reuse the memmory */ conn->bufUse = 0; - conn->sock = sock; + /* + if ( (conn->sock = accept(sock, (struct sockaddr *)&a, &alen)) ) + return -1; + */ return 0; } -int edg_wll_plain_close(edg_wll_PlainConnection *conn) -{ - errno = 0; - if ( conn->buf ) free(conn->buf); - if ( conn->sock > -1 ) close(conn->sock); - memset(conn, 0, sizeof(*conn)); - conn->sock = -1; - - return errno? -1: 0; -} - int edg_wll_plain_read( - edg_wll_PlainConnection *conn, + edg_wll_Connection *conn, void *outbuf, size_t outbufsz, struct timeval *to) @@ -138,10 +133,10 @@ cleanup: int edg_wll_plain_read_full( - edg_wll_PlainConnection *conn, - void *outbuf, - size_t outbufsz, - struct timeval *to) + edg_wll_Connection *conn, + void *outbuf, + size_t outbufsz, + struct timeval *to) { size_t total = 0; @@ -164,10 +159,10 @@ int edg_wll_plain_read_full( } int edg_wll_plain_write_full( - edg_wll_PlainConnection *conn, - const void *buf, - size_t bufsz, - struct timeval *to) + edg_wll_Connection *conn, + const void *buf, + size_t bufsz, + struct timeval *to) { size_t written = 0; int ct = -1; diff --git a/org.glite.lb.common/src/mini_http.c b/org.glite.lb.common/src/mini_http.c index 7e86628..2ac714e 100644 --- a/org.glite.lb.common/src/mini_http.c +++ b/org.glite.lb.common/src/mini_http.c @@ -143,8 +143,6 @@ error: } return edg_wll_Error(ctx,NULL,NULL); - -#undef bshift } edg_wll_ErrorCode edg_wll_http_recv_proxy(edg_wll_Context ctx,char **firstOut,char ***hdrOut,char **bodyOut) @@ -154,50 +152,46 @@ edg_wll_ErrorCode edg_wll_http_recv_proxy(edg_wll_Context ctx,char **firstOut,ch int len, nhdr = 0,rdmore = 0,clen = 0,blen = 0; #define bshift(shift) {\ - memmove(ctx->connProxy->buf,\ - ctx->connProxy->buf+(shift),\ - ctx->connProxy->bufUse-(shift));\ - ctx->connProxy->bufUse -= (shift);\ + memmove(ctx->connPlain->buf,\ + ctx->connPlain->buf+(shift),\ + ctx->connPlain->bufUse-(shift));\ + ctx->connPlain->bufUse -= (shift);\ } edg_wll_ResetError(ctx); - if ( !ctx->connProxy->buf ) { - ctx->connProxy->bufSize = BUFSIZ; - ctx->connProxy->bufUse = 0; - ctx->connProxy->buf = malloc(BUFSIZ); + if ( !ctx->connPlain->buf ) { + ctx->connPlain->bufSize = BUFSIZ; + ctx->connPlain->buf = malloc(BUFSIZ); } do { - len = edg_wll_plain_read(&ctx->connProxy->conn, - ctx->connProxy->buf+ctx->connProxy->bufUse, - ctx->connProxy->bufSize-ctx->connProxy->bufUse, + len = edg_wll_plain_read(&ctx->connPlain->sock, + ctx->connPlain->buf+ctx->connPlain->bufUse, + ctx->connPlain->bufSize-ctx->connPlain->bufUse, &ctx->p_tmp_timeout); - if ( len < 0 ) { - edg_wll_SetError(ctx, errno, "edg_wll_plain_read()"); - goto error; - } + if ( len < 0 ) goto error; - ctx->connProxy->bufUse += len; + ctx->connPlain->bufUse += len; rdmore = 0; while (!rdmore && pstat != DONE) switch (pstat) { char *cr; case FIRST: - if ((cr = memchr(ctx->connProxy->buf,'\r',ctx->connProxy->bufUse)) && - ctx->connProxy->bufUse >= cr-ctx->connProxy->buf+2 && cr[1] == '\n') + if ((cr = memchr(ctx->connPlain->buf,'\r',ctx->connPlain->bufUse)) && + ctx->connPlain->bufUse >= cr-ctx->connPlain->buf+2 && cr[1] == '\n') { *cr = 0; - first = strdup(ctx->connProxy->buf); - bshift(cr-ctx->connProxy->buf+2); + first = strdup(ctx->connPlain->buf); + bshift(cr-ctx->connPlain->buf+2); pstat = HEAD; } else rdmore = 1; break; case HEAD: - if ((cr = memchr(ctx->connProxy->buf,'\r',ctx->connProxy->bufUse)) && - ctx->connProxy->bufUse >= cr-ctx->connProxy->buf+2 && cr[1] == '\n') + if ((cr = memchr(ctx->connPlain->buf,'\r',ctx->connPlain->bufUse)) && + ctx->connPlain->bufUse >= cr-ctx->connPlain->buf+2 && cr[1] == '\n') { - if (cr == ctx->connProxy->buf) { + if (cr == ctx->connPlain->buf) { bshift(2); pstat = clen ? BODY : DONE; if (clen) body = malloc(clen+1); @@ -206,19 +200,19 @@ edg_wll_ErrorCode edg_wll_http_recv_proxy(edg_wll_Context ctx,char **firstOut,ch *cr = 0; hdr = realloc(hdr,(nhdr+2) * sizeof(*hdr)); - hdr[nhdr] = strdup(ctx->connProxy->buf); + hdr[nhdr] = strdup(ctx->connPlain->buf); hdr[++nhdr] = NULL; - if (!strncasecmp(ctx->connProxy->buf,CONTENT_LENGTH,sizeof(CONTENT_LENGTH)-1)) - clen = atoi(ctx->connProxy->buf+sizeof(CONTENT_LENGTH)-1); + if (!strncasecmp(ctx->connPlain->buf,CONTENT_LENGTH,sizeof(CONTENT_LENGTH)-1)) + clen = atoi(ctx->connPlain->buf+sizeof(CONTENT_LENGTH)-1); - bshift(cr-ctx->connProxy->buf+2); + bshift(cr-ctx->connPlain->buf+2); } else rdmore = 1; break; case BODY: - if (ctx->connProxy->bufUse) { - int m = min(ctx->connProxy->bufUse,clen-blen); - memcpy(body+blen,ctx->connProxy->buf,m); + if (ctx->connPlain->bufUse) { + int m = min(ctx->connPlain->bufUse,clen-blen); + memcpy(body+blen,ctx->connPlain->buf,m); blen += m; bshift(m); } @@ -254,13 +248,11 @@ error: } return edg_wll_Error(ctx,NULL,NULL); - -#undef bshift } static int real_write(edg_wll_Context ctx, edg_wll_GssConnection *con,const char *data,int len) { - size_t total = 0; + int total = 0; struct sigaction sa,osa; edg_wll_GssStatus gss_code; int ret; @@ -339,16 +331,16 @@ edg_wll_ErrorCode edg_wll_http_send_proxy(edg_wll_Context ctx, const char *first edg_wll_ResetError(ctx); - if ( edg_wll_plain_write_full(&ctx->connProxy->conn, + if ( edg_wll_plain_write_full(&ctx->connPlain->sock, first, strlen(first), &ctx->p_tmp_timeout) < 0 - || edg_wll_plain_write_full(&ctx->connProxy->conn, + || edg_wll_plain_write_full(&ctx->connPlain->sock, "\r\n", 2, &ctx->p_tmp_timeout) < 0 ) return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); if ( head ) for ( h = head; *h; h++ ) - if ( edg_wll_plain_write_full(&ctx->connProxy->conn, + if ( edg_wll_plain_write_full(&ctx->connPlain->sock, *h, strlen(*h), &ctx->p_tmp_timeout) < 0 - || edg_wll_plain_write_full(&ctx->connProxy->conn, + || edg_wll_plain_write_full(&ctx->connPlain->sock, "\r\n", 2, &ctx->p_tmp_timeout) < 0 ) return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); @@ -357,15 +349,15 @@ edg_wll_ErrorCode edg_wll_http_send_proxy(edg_wll_Context ctx, const char *first len = strlen(body); blen = sprintf(buf, CONTENT_LENGTH " %d\r\n",len); - if (edg_wll_plain_write_full(&ctx->connProxy->conn, + if (edg_wll_plain_write_full(&ctx->connPlain->sock, buf, blen, &ctx->p_tmp_timeout) < 0) return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); } - if ( edg_wll_plain_write_full(&ctx->connProxy->conn, + if ( edg_wll_plain_write_full(&ctx->connPlain->sock, "\r\n", 2, &ctx->p_tmp_timeout) < 0) return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); - if ( body && edg_wll_plain_write_full(&ctx->connProxy->conn, + if ( body && edg_wll_plain_write_full(&ctx->connPlain->sock, body, len, &ctx->p_tmp_timeout) < 0) return edg_wll_SetError(ctx, errno, "edg_wll_http_send()"); diff --git a/org.glite.lb.common/src/param.c b/org.glite.lb.common/src/param.c index f4a6df0..2efd560 100644 --- a/org.glite.lb.common/src/param.c +++ b/org.glite.lb.common/src/param.c @@ -118,6 +118,10 @@ int edg_wll_SetParamString(edg_wll_Context ctx,edg_wll_ContextParam param,const free(ctx->p_destination); ctx->p_destination = val ? strdup(val) : extract_host(param,EDG_WLL_LOG_HOST_DEFAULT); break; + case EDG_WLL_PARAM_LBPROXY_USER: + free(ctx->p_user_lbproxy); + ctx->p_user_lbproxy = val ? strdup(val) : NULL; + break; case EDG_WLL_PARAM_QUERY_SERVER: free(ctx->p_query_server); ctx->p_query_server = val ? strdup(val) : extract_host(param,NULL); @@ -151,10 +155,6 @@ int edg_wll_SetParamString(edg_wll_Context ctx,edg_wll_ContextParam param,const free(ctx->p_lbproxy_serve_sock); ctx->p_lbproxy_serve_sock = val ? strdup(val): NULL; break; - case EDG_WLL_PARAM_LBPROXY_USER: - free(ctx->p_user_lbproxy); - ctx->p_user_lbproxy = val ? strdup(val) : NULL; - break; default: return edg_wll_SetError(ctx,EINVAL,"unknown parameter"); } @@ -285,6 +285,7 @@ int edg_wll_SetParam(edg_wll_Context ctx,edg_wll_ContextParam param,...) case EDG_WLL_PARAM_HOST: case EDG_WLL_PARAM_INSTANCE: case EDG_WLL_PARAM_DESTINATION: + case EDG_WLL_PARAM_LBPROXY_USER: case EDG_WLL_PARAM_QUERY_SERVER: case EDG_WLL_PARAM_NOTIF_SERVER: case EDG_WLL_PARAM_QUERY_SERVER_OVERRIDE: @@ -293,7 +294,6 @@ int edg_wll_SetParam(edg_wll_Context ctx,edg_wll_ContextParam param,...) case EDG_WLL_PARAM_X509_CERT: case EDG_WLL_PARAM_LBPROXY_STORE_SOCK: case EDG_WLL_PARAM_LBPROXY_SERVE_SOCK: - case EDG_WLL_PARAM_LBPROXY_USER: return edg_wll_SetParamString(ctx,param,va_arg(ap,char *)); case EDG_WLL_PARAM_LOG_TIMEOUT: case EDG_WLL_PARAM_LOG_SYNC_TIMEOUT: @@ -367,6 +367,10 @@ int edg_wll_GetParam(edg_wll_Context ctx,edg_wll_ContextParam param,...) p_string = va_arg(ap, char **); *p_string = estrdup(ctx->p_destination); break; + case EDG_WLL_PARAM_LBPROXY_USER: + p_string = va_arg(ap, char **); + *p_string = estrdup(ctx->p_user_lbproxy); + break; case EDG_WLL_PARAM_QUERY_SERVER: p_string = va_arg(ap, char **); *p_string = estrdup(ctx->p_query_server); @@ -399,10 +403,7 @@ int edg_wll_GetParam(edg_wll_Context ctx,edg_wll_ContextParam param,...) p_string = va_arg(ap, char **); *p_string = estrdup(ctx->p_lbproxy_serve_sock); break; - case EDG_WLL_PARAM_LBPROXY_USER: - p_string = va_arg(ap, char **); - *p_string = estrdup(ctx->p_user_lbproxy); - break; + case EDG_WLL_PARAM_LOG_TIMEOUT: p_tv = va_arg(ap,struct timeval *); *p_tv = ctx->p_log_timeout; diff --git a/org.glite.lb.common/src/ulm_parse.c b/org.glite.lb.common/src/ulm_parse.c index 2525a3e..1a40d57 100644 --- a/org.glite.lb.common/src/ulm_parse.c +++ b/org.glite.lb.common/src/ulm_parse.c @@ -163,8 +163,8 @@ int edg_wll_ULMProcessParseTable(p_edg_wll_ULMFields this) else qmCnt--; } if ((qmCnt == 0) && (!isspace(this->raw[i+1]) && (this->raw[i+1] != '\0'))) { - fprintf(stderr,"%s: PARSE ERROR: Disallowed character ('%c') after ending '%c'at i=%d size=%lu char=%d.\n", - func,this->raw[i+1],ULM_QM,i,(unsigned long)size,this->raw[i+1]); + fprintf(stderr,"%s: PARSE ERROR: Disallowed character ('%c') after ending '%c'at i=%d size=%d char=%d.\n", + func,this->raw[i+1],ULM_QM,i,size,this->raw[i+1]); for (j=0; j<=i; j++) fputc(this->raw[j],stderr); fputc(ULM_LF,stderr); return ULM_PARSE_ERROR; diff --git a/org.glite.lb.common/src/xml_conversions.c b/org.glite.lb.common/src/xml_conversions.c index d914cce..515a6d6 100644 --- a/org.glite.lb.common/src/xml_conversions.c +++ b/org.glite.lb.common/src/xml_conversions.c @@ -1,7 +1,6 @@ #ident "$Header$" #include -#include #include #include "trio.h" @@ -65,16 +64,6 @@ void edg_wll_initXMLCtx(edg_wll_XML_ctx *c) { c->attrsGlobal = NULL; c->errCode = 0; c->bound = 0; - c->statsFunction = NULL; - c->statsConditions = NULL; - c->statsMajor = EDG_WLL_JOB_UNDEF; - c->statsMinor = 0; - c->statsRate = 0; - c->statsDuration = 0; - c->statsFrom = 0; - c->statsTo = 0; - c->statsResFrom = 0; - c->statsResTo = 0; c->errDesc = NULL; c->stat_begin = 0; c->jobQueryRec_begin = 0; @@ -147,22 +136,6 @@ void edg_wll_add_int_to_XMLBody(char **body, const int toAdd, const char *tag, c } -/* edg_wll_add_float_to_XMLBody(&body, rate, "rate", 0) */ - -void edg_wll_add_float_to_XMLBody(char **body, const float toAdd, const char *tag, const float null) -{ - if (toAdd != null) { - char *newBody; - - trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xf\r\n", *body, tag, toAdd, tag); - - free(*body); - *body = newBody; - } -} - - - /* edg_wll_add_timeval_to_XMLBody(&body, eventsOut[i].any.tv, "timestamp", -1) */ void edg_wll_add_timeval_to_XMLBody(char **body, struct timeval toAdd, const char *tag, const struct timeval null) @@ -570,21 +543,6 @@ int edg_wll_from_string_to_int(edg_wll_XML_ctx *XMLCtx) } - -/* XMLCtx->eventsOutGlobal[XMLCtx->position].jobClear.clearReason = - edg_wll_from_string_to_int(XMLCtx); */ -float edg_wll_from_string_to_float(edg_wll_XML_ctx *XMLCtx) -{ - float out; - - out = strtof(XMLCtx->char_buf, (char **) NULL); - edg_wll_freeBuf(XMLCtx); - - return(out); -} - - - long edg_wll_from_string_to_long(edg_wll_XML_ctx *XMLCtx) { long out; diff --git a/org.glite.lb.common/src/xml_parse.c.T b/org.glite.lb.common/src/xml_parse.c.T index 4b2e2bd..0b7464f 100644 --- a/org.glite.lb.common/src/xml_parse.c.T +++ b/org.glite.lb.common/src/xml_parse.c.T @@ -45,8 +45,6 @@ #define INDEXED_ATTRS_REQUEST_END "\r\n" #define NOTIF_REQUEST_BEGIN "\r\n" -#define STATS_REQUEST_BEGIN "\r\n" #define QUERY_SEQUENCE_CODE_REQUEST_BEGIN "\r\n" #define QUERY_SEQUENCE_CODE_REQUEST_END "\r\n" @@ -692,37 +690,6 @@ static void startQuerySequenceCodeResult(void *data, const char *el, const char -static void startStatsResult(void *data, const char *el, const char **attr) -{ - edg_wll_XML_ctx *XMLCtx = data; - int i; - - - strcpy(XMLCtx->element, el); - - switch (XMLCtx->level) { - case 0: if (strcasecmp(el,"edg_wll_StatsResult")) { unexpError() break;} - for ( i = 0; attr[i] && attr[i+1]; i += 2 ) { - if (!strcmp(attr[i],"code")) - XMLCtx->errCode = atoi(attr[i+1]); - else if (!strcmp(attr[i],"desc")) - XMLCtx->errDesc = strdup(attr[i+1]); - else { unexpError() } - } - break; - case 1: if (strcasecmp(el,"from") && strcasecmp(el,"to") && - strcasecmp(el,"rate") && strcasecmp(el,"duration") && - strcasecmp(el,"res_from") && strcasecmp(el,"res_to")) - unexpWarning() - break; - default: unexpWarning() - break; - } - XMLCtx->level++; -} - - - static void char_handler(void *data, const char *s, int len) { edg_wll_XML_ctx *XMLCtx = data; @@ -1281,34 +1248,6 @@ static void endQuerySequenceCodeResult(void *data, const char *el UNUSED_VAR) - -static void endStatsResult(void *data, const char *el UNUSED_VAR) -{ - edg_wll_XML_ctx *XMLCtx = data; - - - if (XMLCtx->level == 2) { - if (!strcmp(XMLCtx->element,"from")) - XMLCtx->statsFrom = edg_wll_from_string_to_time_t(XMLCtx); - else if (!strcmp(XMLCtx->element,"to")) - XMLCtx->statsTo = edg_wll_from_string_to_time_t(XMLCtx); - else if (!strcmp(XMLCtx->element,"rate")) - XMLCtx->statsRate = edg_wll_from_string_to_float(XMLCtx); - else if (!strcmp(XMLCtx->element,"duration")) - XMLCtx->statsDuration = edg_wll_from_string_to_float(XMLCtx); - else if (!strcmp(XMLCtx->element,"res_from")) - XMLCtx->statsResFrom = edg_wll_from_string_to_int(XMLCtx); - else if (!strcmp(XMLCtx->element,"res_to")) - XMLCtx->statsResTo = edg_wll_from_string_to_int(XMLCtx); - } - - XMLCtx->char_buf = NULL; - XMLCtx->char_buf_len = 0; - XMLCtx->level--; -} - - - #undef unexpError #undef unexpWarning @@ -2335,76 +2274,6 @@ edg_wll_ErrorCode edg_wll_ParseQuerySequenceCodeResult(edg_wll_Context ctx, char -/* parse statistics result from client */ -edg_wll_ErrorCode edg_wll_ParseStatsResult(edg_wll_Context ctx, char *messageBody, time_t *from, time_t *to, float *rate, float *duration, int *res_from, int *res_to) -{ - edg_wll_XML_ctx XMLCtx; - edg_wll_ErrorCode errorCode; - XML_Char *encoding = "ISO-8859-1"; - - errno = 0; - edg_wll_ResetError(ctx); - edg_wll_initXMLCtx(&XMLCtx); - XMLCtx.ctx = ctx; - - - /* initialize parser */ - XMLCtx.p = XML_ParserCreate(encoding); - XML_SetElementHandler(XMLCtx.p, startStatsResult, endStatsResult); - XML_SetCharacterDataHandler(XMLCtx.p, char_handler); - XML_SetUserData(XMLCtx.p, (void *) &XMLCtx); - - - if (! XML_Parse(XMLCtx.p, messageBody, strlen(messageBody), 1)) { - char *errorMessage; - - asprintf(&errorMessage, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(XMLCtx.p), - XML_ErrorString(XML_GetErrorCode(XMLCtx.p))); - - edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, errorMessage); - free(errorMessage); - } else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt); - - - if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) { - *from = -1; - *to = -1; - *rate = 0; - *duration = 0; - *res_from = -1; - *res_to = -1; - } else { - *from = XMLCtx.statsFrom; - *to = XMLCtx.statsTo; - *rate = XMLCtx.statsRate; - *duration = XMLCtx.statsDuration; - *res_from = XMLCtx.statsResFrom; - *res_to = XMLCtx.statsResTo; - } - - if (XMLCtx.errDesc || XMLCtx.errCode) { - ctx->errDesc = XMLCtx.errDesc; - ctx->errCode = XMLCtx.errCode; - } - - /* print all warning if corresponding env variable is set */ - if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) { - fprintf(stderr,"----------------------------------------------------\n"); - fprintf(stderr,"%s\n\n",XMLCtx.warntxt); - fprintf(stderr,"%s\n",messageBody); - fprintf(stderr,"----------------------------------------------------\n"); - } - - /* free parser */ - XML_ParserFree(XMLCtx.p); - - edg_wll_freeXMLCtx(&XMLCtx); - return errorCode; -} - - - /* construct Message-Body of Request-Line for edg_wll_QueryJobs */ int edg_wll_JobQueryRecToXML( @@ -2875,52 +2744,3 @@ int edg_wll_QuerySequenceCodeToXML( return 0; } - - -/* construct Message-Body of Request-Line for edg_wll_StateRate function */ -int edg_wll_StatsRequestToXML( - edg_wll_Context ctx, - const char *function, - const edg_wll_QueryRec *cond, - edg_wll_JobStatCode major, - int minor, - time_t *from, - time_t *to, - char **message) -{ - char *pomA=NULL, *pomB=NULL, *pomC=NULL; - edg_wll_QueryRec **conditions; - - - conditions = (edg_wll_QueryRec **) malloc(2 * sizeof(edg_wll_QueryRec *)); - conditions[1] = NULL; - - conditions[0] = cond; - conditions[1] = NULL; - - pomA = strdup(""); - - edg_wll_add_edg_wll_JobStatCode_to_XMLBody(&pomA, major, "major", EDG_WLL_JOB_UNDEF); - edg_wll_add_int_to_XMLBody(&pomA, minor, "minor", -1); - edg_wll_add_time_t_to_XMLBody(&pomA, *from, "from", 0); - edg_wll_add_time_t_to_XMLBody(&pomA, *to, "to", 0); - - if (conditions && conditions[0] && conditions[0][0].attr != EDG_WLL_QUERY_ATTR_UNDEF) - edg_wll_JobQueryRecToXML(ctx, (edg_wll_QueryRec const * const *) conditions, &pomB); - - - if (pomB) - trio_asprintf(&pomC,"%s function=\"%s\">\r\n%s\t\r\n%s\t\r\n%s", - STATS_REQUEST_BEGIN,function,pomA,pomB,STATS_REQUEST_END); - else - trio_asprintf(&pomC,"%s function=\"%s\">\r\n%s%s", - STATS_REQUEST_BEGIN,function,pomA,STATS_REQUEST_END); - - - free(pomA); - free(pomB); - free(conditions); - *message = pomC; - - return 0; -} diff --git a/org.glite.lb.common/test/test_gss.cpp b/org.glite.lb.common/test/test_gss.cpp index d6df484..97688c3 100644 --- a/org.glite.lb.common/test/test_gss.cpp +++ b/org.glite.lb.common/test/test_gss.cpp @@ -116,7 +116,7 @@ void GSSTest::echo() err = edg_wll_gss_read_full(&conn, buf2, strlen(buf)+1, &timeout, &total, &stat); CPPUNIT_ASSERT_MESSAGE("edg_wll_gss_read_full()", !err); - CPPUNIT_ASSERT(strlen(buf)+1 == total && !strcmp(buf,buf2) ); + CPPUNIT_ASSERT(strlen(buf)+1 == (int) total && !strcmp(buf,buf2) ); edg_wll_gss_close(&conn, &timeout);