X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1e32d1f72606b96bb1abd9af359f1590528ec843..88b195682c0062b55de5248962d736658f86de50:/include/gras/modules/base.h diff --git a/include/gras/modules/base.h b/include/gras/modules/base.h new file mode 100644 index 0000000000..0f300f590a --- /dev/null +++ b/include/gras/modules/base.h @@ -0,0 +1,90 @@ +/* $Id$ */ + +/* gras_addons - several addons to do specific stuff not in GRAS itself */ + +/* Authors: Martin Quinson */ +/* Copyright (C) 2003 the OURAGAN project. */ + +/* This program is free software; you can redistribute it and/or modify it + under the terms of the license (GNU LGPL) which comes with this package. */ + +#ifndef GRAS_ADDONS_H +#define GRAS_ADDONS_H + +#include + +#define HOSTNAME_LEN 256 +#define ERRMSG_LEN 50 + +/* **************************************************************************** + * The common types used as payload in the messages and their definitions + * ****************************************************************************/ + +/** + * msgHost_t: + * + * Description of an host + */ + +typedef struct { + char host[HOSTNAME_LEN]; + unsigned int port; +} msgHost_t; + +static const DataDescriptor msgHostDesc[] = + { SIMPLE_MEMBER(CHAR_TYPE,HOSTNAME_LEN,offsetof(msgHost_t,host)), + SIMPLE_MEMBER(UNSIGNED_INT_TYPE,1, offsetof(msgHost_t,port))}; +#define msgHostLen 2 + +/** + * msgError_t: + * + * how to indicate an eventual error + */ + +typedef struct { + char errmsg[ERRMSG_LEN]; + unsigned int errcode; +} msgError_t; + +static const DataDescriptor msgErrorDesc[] = + { SIMPLE_MEMBER(CHAR_TYPE, ERRMSG_LEN,offsetof(msgError_t,errmsg)), + SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(msgError_t,errcode))}; +#define msgErrorLen 2 + +/** + * msgResult_t: + * + * how to report the result of an experiment + */ + +typedef struct { + unsigned int timestamp; + double value; +} msgResult_t; + +static const DataDescriptor msgResultDesc[] = + { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(msgResult_t,timestamp)), + SIMPLE_MEMBER(DOUBLE_TYPE, 1, offsetof(msgResult_t,value))}; +#define msgResultLen 2 + +/** + * grasRepportError: + * + * Repports an error to the process listening on socket sock. + * + * The information will be embeeded in a message of type id, which must take a msgError_t as first + * sequence (and SeqCount sequences in total). Other sequences beside the error one will be of + * length 0. + * + * The message will be builded as sprintf would, using the given format and extra args. + * + * If the message cannot be builded and sent to recipient, the string severeError will be printed + * on localhost's stderr. + */ +void +grasRepportError (gras_socket_t *sock, int id, int SeqCount, + const char *severeError, + gras_error_t errcode, const char* format,...); + +#endif /* GRAS_ADDONS_H */