Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make a proper gras/ directory in the include one, and stop fooling with recursive...
[simgrid.git] / include / modules / base.h
1 /* $Id$ */
2
3 /* gras_addons - several addons to do specific stuff not in GRAS itself     */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003 the OURAGAN project.                                  */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #ifndef GRAS_ADDONS_H
12 #define GRAS_ADDONS_H
13
14 #include <gras.h>
15
16 #define HOSTNAME_LEN 256
17 #define ERRMSG_LEN  50
18
19 /* ****************************************************************************
20  * The common types used as payload in the messages and their definitions
21  * ****************************************************************************/
22
23 /**
24  * msgHost_t:
25  * 
26  * Description of an host
27  */
28
29 typedef struct {
30   char host[HOSTNAME_LEN];
31   unsigned int port;
32 } msgHost_t;
33
34 static const DataDescriptor msgHostDesc[] = 
35  { SIMPLE_MEMBER(CHAR_TYPE,HOSTNAME_LEN,offsetof(msgHost_t,host)),
36    SIMPLE_MEMBER(UNSIGNED_INT_TYPE,1,   offsetof(msgHost_t,port))};
37 #define msgHostLen 2
38
39 /**
40  * msgError_t:
41  *
42  * how to indicate an eventual error
43  */
44
45 typedef struct {
46   char errmsg[ERRMSG_LEN];
47   unsigned int errcode;
48 } msgError_t;
49
50 static const DataDescriptor msgErrorDesc[] = 
51  { SIMPLE_MEMBER(CHAR_TYPE,         ERRMSG_LEN,offsetof(msgError_t,errmsg)),
52    SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1,         offsetof(msgError_t,errcode))};
53 #define msgErrorLen 2
54
55 /**
56  * msgResult_t:
57  *
58  * how to report the result of an experiment
59  */
60
61 typedef struct {
62   unsigned int timestamp;
63   double value;
64 } msgResult_t;
65
66 static const DataDescriptor msgResultDesc[] = 
67  { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(msgResult_t,timestamp)),
68    SIMPLE_MEMBER(DOUBLE_TYPE,       1, offsetof(msgResult_t,value))};
69 #define msgResultLen 2
70
71 /**
72  * grasRepportError:
73  *
74  * Repports an error to the process listening on socket sock. 
75  *
76  * The information will be embeeded in a message of type id, which must take a msgError_t as first
77  * sequence (and SeqCount sequences in total). Other sequences beside the error one will be of
78  * length 0.
79  *
80  * The message will be builded as sprintf would, using the given format and extra args.
81  *
82  * If the message cannot be builded and sent to recipient, the string severeError will be printed
83  * on localhost's stderr.
84  */
85 void
86 grasRepportError (gras_socket_t *sock, int id, int SeqCount,
87                   const char *severeError,
88                   gras_error_t errcode, const char* format,...);
89
90 #endif /* GRAS_ADDONS_H */