0d0cbf06a4867db73ac367681263c5724cc18f69
[monky] / src / ccurl_thread.h
1 /*
2  * Conky, a system monitor, based on torsmo
3  *
4  * Please see COPYING for details
5  *
6  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
7  *      (see AUTHORS)
8  * All rights reserved.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #ifndef _CURL_THREAD_H_
25 #define _CURL_THREAD_H_
26
27 #include "timed_thread.h"
28
29
30 /* curl thread lib exports begin */
31
32 typedef struct _ccurl_location_t {
33         /* uri of location */
34         char *uri;
35         /* a pointer to some arbitrary data, will be freed by ccurl_free_info() if
36          * non-null */
37         void *result;
38         /* internal thread pointer, destroyed by timed_thread.c */
39         timed_thread *p_timed_thread;
40         /* function to call when data is ready to be processed, the first argument
41          * will be the result pointer, and the second argument is an internal
42          * buffer that shouldn't be mangled */
43         void (*process_function)(void *, const char *);
44         /* internal list pointer, don't mess with this unless you don't know any
45          * better */
46         struct _ccurl_location_t *next;
47 } ccurl_location_t;
48
49 /* find an existing location for the uri specified */
50 ccurl_location_t *ccurl_find_location(ccurl_location_t **locations_head, char *uri);
51 /* free all locations (as well as location->uri and location->result if
52  * non-null) */
53 void ccurl_free_locations(ccurl_location_t **locations_head);
54 /* initiates a curl thread at the location specified using the interval in
55  * seconds */
56 void ccurl_init_thread(ccurl_location_t *curloc, int interval);
57
58 /* curl thread lib exports end */
59
60
61 /* $curl exports begin */
62
63 /* for $curl, free internal list pointer */
64 void ccurl_free_info(void);
65 /* runs instance of $curl */
66 void ccurl_process_info(char *p, int p_max_size, char *uri, int interval);
67
68 /* $curl exports end */
69
70 #endif /* _CURL_THREAD_H_ */
71