4ef2885e65d7f22b9eda4c7fa2c4a4b752a7e461
[oweals/gnunet.git] / src / include / gnunet_sensor_service.h
1 /*
2       This file is part of GNUnet
3       (C) 
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 3, or (at your
8       option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file include/gnunet_sensor_service.h
23  * @brief API to the sensor service
24  * @author Omar Tarabai
25  */
26 #ifndef GNUNET_SENSOR_SERVICE_H
27 #define GNUNET_SENSOR_SERVICE_H
28
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0                           /* keep Emacsens' auto-indent happy */
36 }
37 #endif
38 #endif
39
40
41 /**
42  * Handle to the sensor service.
43  */
44 struct GNUNET_SENSOR_Handle;
45
46 /**
47  * Structure containing brief info about sensor
48  */
49 struct SensorInfoShort
50 {
51
52   /*
53    * Sensor name
54    */
55   char *name;
56
57   /*
58    * First part of version number
59    */
60   uint16_t version_major;
61
62   /*
63    * Second part of version number
64    */
65   uint16_t version_minor;
66
67   /*
68    * Sensor description
69    */
70   char *description;
71
72 };
73
74 /**
75  * Type of an iterator over sensor definitions.
76  *
77  * @param cls closure
78  * @param hello hello message for the peer (can be NULL)
79  * @param error message
80  */
81 typedef void (*GNUNET_SENSOR_SensorIteratorCB) (void *cls,
82                                                 const struct SensorInfoShort *
83                                                 sensor, const char *err_msg);
84
85
86 /**
87  * Continuation called with a status result.
88  *
89  * @param cls closure
90  * @param emsg error message, NULL on success
91  */
92 typedef void (*GNUNET_SENSOR_Continuation) (void *cls, const char *emsg);
93
94
95 /**
96  * Connect to the sensor service.
97  *
98  * @return NULL on error
99  */
100 struct GNUNET_SENSOR_Handle *
101 GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
102
103
104 /**
105  * Disconnect from the sensor service
106  *
107  * @param h handle to disconnect
108  */
109 void
110 GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h);
111
112
113 /**
114  * Client asking to iterate all available sensors
115  *
116  * @param h Handle to SENSOR service
117  * @param timeout how long to wait until timing out
118  * @param sensorname information on one sensor only, can be NULL to get all
119  * @param sensorname_len length of the sensorname parameter
120  * @param callback the method to call for each sensor
121  * @param callback_cls closure for callback
122  * @return iterator context
123  */
124 struct GNUNET_SENSOR_SensorIteratorContext *
125 GNUNET_SENSOR_iterate_sensors (struct GNUNET_SENSOR_Handle *h,
126                                struct GNUNET_TIME_Relative timeout,
127                                const char *sensorname, size_t sensorname_len,
128                                GNUNET_SENSOR_SensorIteratorCB callback,
129                                void *callback_cls);
130
131 #if 0                           /* keep Emacsens' auto-indent happy */
132 {
133 #endif
134 #ifdef __cplusplus
135 }
136 #endif
137
138 #endif