Logo AND Algorithmique Numérique Distribuée

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