diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-07-29 14:01:37 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-07-29 14:01:37 +0000 |
commit | 5051244c80bd93e1599c5c39aeeefebaeef40d61 (patch) | |
tree | 5b64b237d5af7a25f2e75b150fbb3396a360820e /src/sensor/gnunet-sensor.c | |
parent | 764a37c57035bb131d4cf265bf24396c1e422efb (diff) | |
download | gnunet-5051244c80bd93e1599c5c39aeeefebaeef40d61.tar.gz gnunet-5051244c80bd93e1599c5c39aeeefebaeef40d61.zip |
sensor, sensordashboard: doxygen fixes + indentation
Diffstat (limited to 'src/sensor/gnunet-sensor.c')
-rw-r--r-- | src/sensor/gnunet-sensor.c | 95 |
1 files changed, 41 insertions, 54 deletions
diff --git a/src/sensor/gnunet-sensor.c b/src/sensor/gnunet-sensor.c index fa7930832..ffd61f8b4 100644 --- a/src/sensor/gnunet-sensor.c +++ b/src/sensor/gnunet-sensor.c | |||
@@ -51,16 +51,16 @@ static struct GNUNET_SENSOR_Handle *sensor_handle; | |||
51 | * @param tc scheduler context | 51 | * @param tc scheduler context |
52 | */ | 52 | */ |
53 | static void | 53 | static void |
54 | shutdown_task (void *cls, | 54 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
55 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
56 | { | 55 | { |
57 | if(NULL != sensor_handle) | 56 | if (NULL != sensor_handle) |
58 | { | 57 | { |
59 | GNUNET_SENSOR_disconnect(sensor_handle); | 58 | GNUNET_SENSOR_disconnect (sensor_handle); |
60 | sensor_handle = NULL; | 59 | sensor_handle = NULL; |
61 | } | 60 | } |
62 | } | 61 | } |
63 | 62 | ||
63 | |||
64 | /** | 64 | /** |
65 | * Callback for getting sensor info from service | 65 | * Callback for getting sensor info from service |
66 | * | 66 | * |
@@ -68,27 +68,26 @@ shutdown_task (void *cls, | |||
68 | * @param sensor brief information about sensor (NULL means end of transmission) | 68 | * @param sensor brief information about sensor (NULL means end of transmission) |
69 | * @param err_msg contains error string if any | 69 | * @param err_msg contains error string if any |
70 | */ | 70 | */ |
71 | void print_sensor_info(void *cls, | 71 | void |
72 | const struct SensorInfoShort *sensor, | 72 | print_sensor_info (void *cls, const struct SensorInfoShort *sensor, |
73 | const char *err_msg) | 73 | const char *err_msg) |
74 | { | 74 | { |
75 | if(NULL != err_msg) | 75 | if (NULL != err_msg) |
76 | { | 76 | { |
77 | printf("Error: %s\n", err_msg); | 77 | printf ("Error: %s\n", err_msg); |
78 | GNUNET_SCHEDULER_shutdown(); | 78 | GNUNET_SCHEDULER_shutdown (); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | if(NULL == sensor) /* no more sensors from service */ | 81 | if (NULL == sensor) /* no more sensors from service */ |
82 | return; | 82 | return; |
83 | printf("Name: %s\nVersion: %d.%d\n", | 83 | printf ("Name: %s\nVersion: %d.%d\n", sensor->name, sensor->version_major, |
84 | sensor->name, | 84 | sensor->version_minor); |
85 | sensor->version_major, | 85 | if (NULL != sensor->description) |
86 | sensor->version_minor); | 86 | printf ("Description: %s\n", sensor->description); |
87 | if(NULL != sensor->description) | 87 | printf ("\n"); |
88 | printf("Description: %s\n", sensor->description); | ||
89 | printf("\n"); | ||
90 | } | 88 | } |
91 | 89 | ||
90 | |||
92 | /** | 91 | /** |
93 | * Main function that will be run by the scheduler. | 92 | * Main function that will be run by the scheduler. |
94 | * | 93 | * |
@@ -98,41 +97,31 @@ void print_sensor_info(void *cls, | |||
98 | * @param cfg configuration | 97 | * @param cfg configuration |
99 | */ | 98 | */ |
100 | static void | 99 | static void |
101 | run (void *cls, | 100 | run (void *cls, char *const *args, const char *cfgfile, |
102 | char *const *args, | ||
103 | const char *cfgfile, | ||
104 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 101 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
105 | { | 102 | { |
106 | |||
107 | sensor_handle = NULL; | 103 | sensor_handle = NULL; |
108 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 104 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
109 | &shutdown_task, | 105 | NULL); |
110 | NULL); | 106 | sensor_handle = GNUNET_SENSOR_connect (cfg); |
111 | sensor_handle = GNUNET_SENSOR_connect(cfg); | 107 | GNUNET_assert (NULL != sensor_handle); |
112 | GNUNET_assert(NULL != sensor_handle); | 108 | if (GNUNET_YES == get_all) |
113 | if(GNUNET_YES == get_all) | ||
114 | { | 109 | { |
115 | GNUNET_SENSOR_iterate_sensors(sensor_handle, | 110 | GNUNET_SENSOR_iterate_sensors (sensor_handle, GNUNET_TIME_UNIT_FOREVER_REL, |
116 | GNUNET_TIME_UNIT_FOREVER_REL, | 111 | NULL, 0, &print_sensor_info, NULL); |
117 | NULL, | ||
118 | 0, | ||
119 | &print_sensor_info, | ||
120 | NULL); | ||
121 | } | 112 | } |
122 | else if(NULL != get_sensor) | 113 | else if (NULL != get_sensor) |
123 | { | 114 | { |
124 | GNUNET_SENSOR_iterate_sensors(sensor_handle, | 115 | GNUNET_SENSOR_iterate_sensors (sensor_handle, GNUNET_TIME_UNIT_FOREVER_REL, |
125 | GNUNET_TIME_UNIT_FOREVER_REL, | 116 | get_sensor, strlen (get_sensor), |
126 | get_sensor, | 117 | &print_sensor_info, NULL); |
127 | strlen(get_sensor), | ||
128 | &print_sensor_info, | ||
129 | NULL); | ||
130 | } | 118 | } |
131 | 119 | ||
132 | GNUNET_SCHEDULER_shutdown(); | 120 | GNUNET_SCHEDULER_shutdown (); |
133 | ret = 0; | 121 | ret = 0; |
134 | } | 122 | } |
135 | 123 | ||
124 | |||
136 | /** | 125 | /** |
137 | * The main function to sensor. | 126 | * The main function to sensor. |
138 | * | 127 | * |
@@ -144,21 +133,19 @@ int | |||
144 | main (int argc, char *const *argv) | 133 | main (int argc, char *const *argv) |
145 | { | 134 | { |
146 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 135 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
147 | {'a', "all", NULL, | 136 | {'a', "all", NULL, |
148 | gettext_noop("Retrieve information about all defined sensors"), | 137 | gettext_noop ("Retrieve information about all defined sensors"), |
149 | 0, &GNUNET_GETOPT_set_one, &get_all}, | 138 | 0, &GNUNET_GETOPT_set_one, &get_all}, |
150 | {'g', "get-sensor", NULL, | 139 | {'g', "get-sensor", NULL, |
151 | gettext_noop("Retrieve information about a single sensor"), | 140 | gettext_noop ("Retrieve information about a single sensor"), |
152 | 1, &GNUNET_GETOPT_set_string, &get_sensor}, | 141 | 1, &GNUNET_GETOPT_set_string, &get_sensor}, |
153 | GNUNET_GETOPT_OPTION_END | 142 | GNUNET_GETOPT_OPTION_END |
154 | }; | 143 | }; |
144 | |||
155 | return (GNUNET_OK == | 145 | return (GNUNET_OK == |
156 | GNUNET_PROGRAM_run (argc, | 146 | GNUNET_PROGRAM_run (argc, argv, "gnunet-sensor [options [value]]", |
157 | argv, | 147 | gettext_noop ("sensor"), options, &run, |
158 | "gnunet-sensor [options [value]]", | 148 | NULL)) ? ret : 1; |
159 | gettext_noop | ||
160 | ("sensor"), | ||
161 | options, &run, NULL)) ? ret : 1; | ||
162 | } | 149 | } |
163 | 150 | ||
164 | /* end of gnunet-sensor.c */ | 151 | /* end of gnunet-sensor.c */ |