towards PEERSTORE file plugin
[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 *sensor,
83                                              const char *err_msg);
84
85 /**
86  * Continuation called with a status result.
87  *
88  * @param cls closure
89  * @param emsg error message, NULL on success
90  */
91 typedef void (*GNUNET_SENSOR_Continuation)(void *cls,
92                const char *emsg);
93
94 /**
95  * Connect to the sensor service.
96  *
97  * @return NULL on error
98  */
99 struct GNUNET_SENSOR_Handle *
100 GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
101
102 /**
103  * Disconnect from the sensor service
104  *
105  * @param h handle to disconnect
106  */
107 void
108 GNUNET_SENSOR_disconnect(struct GNUNET_SENSOR_Handle *h);
109
110 /**
111  * Client asking to iterate all available sensors
112  *
113  * @param h Handle to SENSOR service
114  * @param timeout how long to wait until timing out
115  * @param sensorname information on one sensor only, can be NULL to get all
116  * @param sensorname_len length of the sensorname parameter
117  * @param callback the method to call for each sensor
118  * @param callback_cls closure for callback
119  * @return iterator context
120  */
121 struct GNUNET_SENSOR_SensorIteratorContext *
122 GNUNET_SENSOR_iterate_sensors (struct GNUNET_SENSOR_Handle *h,
123     struct GNUNET_TIME_Relative timeout,
124     const char* sensorname, size_t sensorname_len,
125     GNUNET_SENSOR_SensorIteratorCB callback, void *callback_cls);
126
127 #if 0                           /* keep Emacsens' auto-indent happy */
128 {
129 #endif
130 #ifdef __cplusplus
131 }
132 #endif
133
134 #endif