printf("%spbs_dest_host : %s\n", ind, stat.pbs_dest_host);
printf("%spbs_pid : %d\n", ind, stat.pbs_pid);
printf("%spbs_resource_usage : %s%s\n", ind,
- (stat.pbs_resource_usage) ? "\n" : "", stat.pbs_resource_usage);
+ (stat.pbs_resource_usage) ? "\n" : "", edg_wll_TagListToString(stat.pbs_resource_usage));
printf("%spbs_exit_status : %d\n", ind, stat.pbs_exit_status);
printf("%spbs_error_desc : %s%s\n", ind,
(stat.pbs_error_desc) ? "\n" : "", stat.pbs_error_desc);
NOTIFID_T, /**< NotifId value. */
FLOAT_T, /**< Float value. */
DOUBLE_T, /**< Double value. */
+ TAGLIST_T, /**< List of user tags (name = value pairs). */
};
Type type; /**< Type of the event as defined by Type. */
OLDSUBSTATE
NEWSTATE
NEWSUBSTATE
+ RESOURCES
/;
else glite_jobid_free(jobid);
}
+static void read_taglist(const edg_wll_Args* o, char* arg, char* par)
+{
+ edg_wll_TagValue *list = NULL;
+
+ if(edg_wll_TagListParse(par, &list) != 0) {
+ fprintf(stderr, "ERROR %s can't parse %s: %s\n", arg, par, strerror(errno));
+ exit(1);
+ }
+ if(o->value) *(edg_wll_TagValue **)o->value = list;
+ else /* FIXME: free it properly */ free(list);
+}
+
static void show_help(const edg_wll_Args* o, int prefix)
{
unsigned max = 0;
case EDG_WLL_ARGS_JOBID:
read_jobid(o, arg, par);
break;
+ case EDG_WLL_ARGS_TAGLIST:
+ read_taglist(o, arg, par);
+ break;
default:
printf("FIXME: unhandle option type %d\n", o->type);
break;
EDG_WLL_ARGS_SUBOPTIONS,
EDG_WLL_ARGS_SELECTSTRING,
EDG_WLL_ARGS_TIMEVAL,
+ EDG_WLL_ARGS_TAGLIST,
} edg_wll_ArgsCode;
typedef struct {
"edg_wll_NotifId", "EDG_WLL_ARGS_NOTIFID",
"edg_wll_Source", "EDG_WLL_ARGS_SOURCE",
"uint16_t", "EDG_WLL_ARGS_UINT16",
- "struct timeval", "EDG_WLL_ARGS_TIMEVAL"
+ "struct timeval", "EDG_WLL_ARGS_TIMEVAL",
+ "edg_wll_TagValue *", "EDG_WLL_ARGS_TAGLIST",
);
my %vars = ();
for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} }
#include <inttypes.h>
#include "glite/jobid/cjobid.h"
+#include "glite/lb/lb_types.h"
+
#ifdef BUILDING_LB_COMMON
#include "context.h"
/**
+ * Free allocated edg_wll_TagValue * list
+ * \param list IN: list to free
+ */
+extern void edg_wll_FreeTagList(
+ edg_wll_TagValue *list
+);
+
+
+/**
* \typedef edg_wll_KeyNameCode
* Predefined ULM key types
*/
edg_wll_Event * event
);
+
#ifdef __cplusplus
}
#endif
#include <sys/time.h>
#include "glite/jobid/cjobid.h"
+#include "glite/lb/lb_types.h"
#ifdef __cplusplus
extern "C" {
EDG_WLL_NUMBER_OF_STATCODES /**< Number of meaningful status codes */
} edg_wll_JobStatCode;
-/*!
- *
- * Pair tag = value.
- */
-typedef struct _edg_wll_TagValue {
- char * tag; /**< User-specified information tag */
- char * value; /**< Value assigned to user-specified information tag */
-} edg_wll_TagValue;
-
/*!
*
void edg_wll_add_logsrc_to_XMLBody(char **body, const edg_wll_Source toAdd, const char *tag, const edg_wll_Source null);
void edg_wll_add_intlist_to_XMLBody(char **body, const int *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to);
void edg_wll_add_strlist_to_XMLBody(char **body, char * const *toAdd, const char *tag, const char *subTag, const char *indent, const char *null);
-void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *indent, const char *subTag2, const char *null);
+void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const edg_wll_TagValue *null);
+void edg_wll_add_usertag_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *indent, const char *subTag2, const char *null);
void edg_wll_add_time_t_list_to_XMLBody(char **body, const time_t *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to);
void edg_wll_add_cclassad_to_XMLBody(char **body, void *toAdd, const char *tag, const char *null);
char *edg_wll_from_string_to_string(edg_wll_XML_ctx *XMLCtx);
"SysClStat",
};
+/* Free the tags and values from list */
+void edg_wll_FreeTagList(edg_wll_TagValue *list) {
+ edg_wll_TagValue *tag;
+
+ if(NULL == list) return;
+
+ for(tag = list; tag->tag; tag++) {
+ free(tag->tag);
+ if(tag->value) free(tag->value);
+ }
+}
+
+/* Deep copy the tag list */
+edg_wll_TagValue *edg_wll_CopyTagList(edg_wll_TagValue *src) {
+ edg_wll_TagValue *dst, *tag, *dtag;
+ int count;
+
+ if(NULL == src) return NULL;
+
+ for(tag = src, count = 0; tag->tag; tag++, count++);
+
+ dst = (edg_wll_TagValue*)calloc(count + 1, sizeof(edg_wll_TagValue));
+ for(tag = src, dtag = dst; tag->tag; tag++, dtag++) {
+ dtag->tag = strdup(tag->tag);
+ dtag->value = strdup(tag->value);
+ }
+
+ return dst;
+}
+
+
/**
* \fn edg_wll_EventCode edg_wll_StringToEvent(const char *name)
* \param name a string event name (e.g. "JobTransfer")
if ($ft eq 'notifid') {
gen $indent."\tif (event->$tl.$fn) edg_wll_NotifIdFree(event->$tl.$fn);\n"
}
+ if ($ft eq 'taglist') {
+ gen $intent."\tif (event->$tl.$fn) { edg_wll_FreeTagList(event->$tl.$fn); free(event->$tl.$fn); }\n"
+ }
}
gen $indent.$indent."break;\n"
}
/* -- Internal function prototype -- */
char *my_edg_wll_ULMGetValueAt( p_edg_wll_ULMFields, int );
+/* Function for parsing name=value tag lists */
+int edg_wll_TagListParse(const char *src, edg_wll_TagValue **list) {
+ int n = 0;
+ char *p;
+ edg_wll_TagValue *tag;
+
+ if(NULL == src)
+ return -1;
+
+ /* count tag=value pairs */
+ for(p = (char*)src; *p; p++) {
+ if(',' == *p) n++; /* counts empty tokens as well... */
+ }
+ /* one more for last empty struct */
+ n += 2;
+
+ *list = (edg_wll_TagValue*)malloc(n*sizeof(edg_wll_TagValue));
+ if(NULL == *list)
+ return -1;
+
+ for(p = strtok(src, ","), tag = *list; p; p = strtok(NULL, ","), tag++) {
+ char *s = strchr(p, '=');
+
+ if(NULL == s || '\0' == *(s+1))
+ continue;
+
+ *s = 0;
+ tag->tag = strdup(p);
+ *s = '=';
+ tag->value = strdup(s+1);
+ }
+ tag->tag = NULL;
+ tag->value = NULL;
+
+ return 0;
+}
+
+
+/* Function for stringifying name=value tag lists */
+char * edg_wll_TagListToString(edg_wll_TagValue *list) {
+ int len = 0;
+ edg_wll_TagValue *tag;
+ char *out, *p;
+
+ if(NULL == list) return NULL;
+
+ for(tag = list; tag->tag; tag++) {
+ len += strlen(tag->tag);
+ len += strlen(tag->value);
+ len++;
+ }
+
+ out = malloc(len*sizeof(char));
+ if(NULL == out) return NULL;
+
+ *out = '\0';
+ p = out;
+ for(tag = list; tag->tag; tag++) {
+ if(p != out) {
+ strcat(p++, ",");
+ }
+ strcat(p, tag->tag);
+ p += strlen(tag->tag);
+ strcat(p++, "=");
+ strcat(p, tag->value);
+ p += strlen(tag->value);
+ }
+
+ return out;
+}
+
+
/**
- * edg_wll_ParseEvent - parse ULM message to internal structures
+ * Edg_wll_ParseEvent - parse ULM message to internal structures
* Calls: calloc, free, sprintf, strdup
* edg_wll_ULMNewParseTable, edg_wll_ULMFreeParseTable, edg_wll_ULMProcessParseTable,
* edg_wll_ULMGetNameAt, my_edg_wll_ULMGetValueAt, edg_wll_ULMDateToTimeval (edg_wll_ULMDateToDouble),
gen "\t\t".toString $f "event->$tl.$fn", "$fn\_str"; gen "\n";
}
elsif ($ULMasString{$f->{type}}) {
- gen "\t\tchar \*$fn\_str = ".$f->getType()."ToString(event->$tl.$fn);\n";
+ #gen "\t\tchar \*$fn\_str = ".$f->getType()."ToString(event->$tl.$fn);\n";
+ gen "\t\t". $f->toString("event->$tl.$fn","char \*$fn\_str",)."\n";
$free .= "free($fn\_str); ";
}
}
static const struct timeval null_timeval = {0,0};
+extern void edg_wll_FreeTagList(edg_wll_TagValue *);
void edg_wll_FreeStatus(edg_wll_JobStat *stat)
{
}
if ($ft eq 'taglist') {
gen "\tif (stat->$_ != NULL ) {\n";
- gen "\t\tfor (i=0; stat->$_\[i].tag; i++) {\n";
- gen "\t\t\tfree(stat->$_\[i].tag);\n";
- gen "\t\t\tfree(stat->$_\[i].value);\n";
- gen "\t\t}\n";
+ #gen "\t\tfor (i=0; stat->$_\[i].tag; i++) {\n";
+ #gen "\t\t\tfree(stat->$_\[i].tag);\n";
+ #gen "\t\t\tfree(stat->$_\[i].value);\n";
+ #gen "\t\t}\n";
+ gen "\t\tedg_wll_FreeTagList(stat->$_);\n";
gen "\t\tfree(stat->$_);\n";
gen "\t}\n";
}
gen "\tdest->$_ = src->$_;\n";
}
if ($ft eq 'taglist') {
- gen qq{
-! if (src->$_ != NULL) \{
-! for (i=0; src->$_\[i].tag; i++);
-! dest->$_ = malloc(sizeof(*src->$_)*(i+1));
-! for (i=0; src->$_\[i].tag; i++) \{
-! dest->$_\[i].tag = strdup(src->$_\[i].tag);
-! dest->$_\[i].value = strdup(src->$_\[i].value);
-! \}
-! dest->$_\[i].tag = NULL;
-! \}
- };
+ gen "\tdest->$_ = edg_wll_CopyTagList(src->$_);\n";
}
}
@@@}
#include "jobstat.h"
+extern char *edg_wll_TagListToString(edg_wll_TagValue *);
static const struct timeval null_timeval = {0,0};
}
-void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *subTag2, const char *indent, const char *null)
+void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const edg_wll_TagValue *null)
+{
+ char *s_taglist;
+
+ s_taglist = edg_wll_TagListToString(toAdd);
+ edg_wll_add_string_to_XMLBody(body, s_taglist, tag, NULL);
+ free(s_taglist);
+}
+
+
+void edg_wll_add_usertag_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *subTag2, const char *indent, const char *null)
{
char *pomA, *pomB, *newBody;
char **list = NULL;
edg_wll_TagValue *edg_wll_from_string_to_taglist(edg_wll_XML_ctx *XMLCtx)
{
- // not done yet
- return(NULL);
+ char *s, *out = NULL;
+
+ s = glite_lbu_UnescapeXML((const char*) XMLCtx->char_buf);
+ if(s) {
+ edg_wll_TagListParse(s, &out);
+ }
+
+ return out;
}
/************************************************************************/
-include Makefile.inc
+globalprefix=glite
+lbprefix=lb
PM=StructField.pm MultiStruct.pm
T=events.T status.T types.T
SCRIPTS=at3 check_version.pl
+HDRS=lb_types.h
default: compile
done
install -m 755 ${top_srcdir}/at3.in ${DESTDIR}${PREFIX}${prefix}/sbin/glite-lb-at3
install -m 755 ${top_srcdir}/check_version.pl ${DESTDIR}${PREFIX}${prefix}/sbin/glite-lb-check_version.pl
+ (cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${DESTDIR}${PREFIX}${prefix}/include/${globalprefix}/${lbprefix})
clean:
rm -rvf log.xml rpmbuild/ RPMS/ tgz/ debian/
int usage Type of record
_code_ REQUESTED Requested value
_code_ USED Consumed quantity
- string resource Resource's name.
- double quantity Resources's quantity (how much).
- _optional_
- string unit Units (sec, kB, etc.).
+ taglist resources List of resources
@type PBSError Any error occured
string error_desc Error reason
--- /dev/null
+#ifndef GLITE_LB_TYPES_H
+#define GLITE_LB_TYPES_H
+
+/**
+ * \file lb_types.h
+ * \brief L&B API common types and related definitions
+ */
+
+
+#ident "$Header$"
+/*
+Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+See http://www.eu-egee.org/partners for details on the copyright holders.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ *
+ * Pair tag = value.
+ */
+typedef struct _edg_wll_TagValue {
+ char * tag; /**< User-specified information tag */
+ char * value; /**< Value assigned to user-specified information tag */
+} edg_wll_TagValue;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
string pbs_dest_host Hostname of node where job is running
int pbs_pid PID of running job
taglist pbs_resource_requested Resources requested
- _special_ XMLstructured
taglist pbs_resource_usage Resource usage
- _special_ XMLstructured
int pbs_exit_status Job exit status
string pbs_error_desc Glued error descriptions from error events
logsrc=>'qq{$dst = edg_wll_SourceToString($src);}',
cclassad=>'qq{$dst = NULL;}',
# strlist, intlist, stslist are used only in consumer API, they don't need toString method
+ taglist=>'qq{$dst = edg_wll_TagListToString($src);}',
}
);
%ULMasString = (
- logsrc=>1
+ logsrc=>1,
+ taglist=>1
);
%fromString = (
# level=>'qq{$dst = edg_wll_StringToLevel($src);}',
logsrc=>'qq{$dst = edg_wll_StringToSource($src);}',
# strlist, intlist, stslist are used only in consumer API, they don't need fromString method
+ taglist=>'qq{edg_wll_TagListParse($src, &$dst);}',
}
);
logsrc=>'"($a) == ($b)"',
timeval=>'"($a).tv_sec == ($b).tv_sec && ($a).tv_usec == ($b).tv_usec"',
cclassad=>'"($a == $b)"',
+ taglist=>'"($a == $b)"',
}
);
notifid=>'"%s"',
logsrc=>'"%s"',
timeval=>'"%s"',
+ taglist=>'"%s"',
}
);