2010-01-07 03:45:19 +00:00
|
|
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
|
|
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
2009-07-28 21:44:22 +00:00
|
|
|
*
|
2009-07-20 15:21:33 +00:00
|
|
|
* Conky, a system monitor, based on torsmo
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
2010-01-01 23:46:17 +00:00
|
|
|
* Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
|
2009-07-20 15:21:33 +00:00
|
|
|
* (see AUTHORS)
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CURL_THREAD_H_
|
|
|
|
#define _CURL_THREAD_H_
|
|
|
|
|
2010-01-04 04:50:02 +00:00
|
|
|
#include <list>
|
2010-01-13 18:52:35 +00:00
|
|
|
#include "timed-thread.h"
|
2009-07-20 15:42:17 +00:00
|
|
|
|
2009-07-20 18:02:53 +00:00
|
|
|
/* curl thread lib exports begin */
|
|
|
|
|
2010-01-04 04:50:02 +00:00
|
|
|
struct ccurl_location_t {
|
|
|
|
ccurl_location_t() : uri(0), result(0) {}
|
2009-07-20 18:02:53 +00:00
|
|
|
/* uri of location */
|
|
|
|
char *uri;
|
|
|
|
/* a pointer to some arbitrary data, will be freed by ccurl_free_info() if
|
|
|
|
* non-null */
|
2010-01-04 04:50:02 +00:00
|
|
|
char *result;
|
2009-07-20 18:02:53 +00:00
|
|
|
/* internal thread pointer, destroyed by timed_thread.c */
|
2010-01-04 04:50:02 +00:00
|
|
|
timed_thread_ptr p_timed_thread;
|
2009-07-20 18:02:53 +00:00
|
|
|
/* function to call when data is ready to be processed, the first argument
|
|
|
|
* will be the result pointer, and the second argument is an internal
|
|
|
|
* buffer that shouldn't be mangled */
|
2010-02-24 19:10:26 +00:00
|
|
|
std::function<void(char *, const char *)> process_function;
|
2010-01-04 04:50:02 +00:00
|
|
|
};
|
|
|
|
|
2010-02-24 19:10:26 +00:00
|
|
|
typedef std::shared_ptr<ccurl_location_t> ccurl_location_ptr;
|
|
|
|
typedef std::list<ccurl_location_ptr> ccurl_location_list;
|
2009-07-20 15:21:33 +00:00
|
|
|
|
|
|
|
/* find an existing location for the uri specified */
|
2010-01-07 18:50:00 +00:00
|
|
|
ccurl_location_ptr ccurl_find_location(ccurl_location_list &locations, char *uri);
|
2009-07-20 15:21:33 +00:00
|
|
|
/* free all locations (as well as location->uri and location->result if
|
|
|
|
* non-null) */
|
2010-01-04 04:50:02 +00:00
|
|
|
void ccurl_free_locations(ccurl_location_list &locations);
|
2009-07-20 18:02:53 +00:00
|
|
|
/* initiates a curl thread at the location specified using the interval in
|
|
|
|
* seconds */
|
2010-01-04 04:50:02 +00:00
|
|
|
void ccurl_init_thread(ccurl_location_ptr curloc, int interval);
|
2009-07-20 15:21:33 +00:00
|
|
|
|
2009-07-20 18:02:53 +00:00
|
|
|
/* curl thread lib exports end */
|
|
|
|
|
|
|
|
|
|
|
|
/* $curl exports begin */
|
|
|
|
|
2009-07-20 15:21:33 +00:00
|
|
|
/* for $curl, free internal list pointer */
|
|
|
|
void ccurl_free_info(void);
|
|
|
|
/* runs instance of $curl */
|
|
|
|
void ccurl_process_info(char *p, int p_max_size, char *uri, int interval);
|
|
|
|
|
2009-10-04 19:06:52 +00:00
|
|
|
void curl_parse_arg(struct text_object *, const char *);
|
|
|
|
void curl_print(struct text_object *, char *, int);
|
2009-10-04 19:17:43 +00:00
|
|
|
void curl_obj_free(struct text_object *);
|
2009-10-04 19:06:52 +00:00
|
|
|
|
2009-07-20 18:02:53 +00:00
|
|
|
/* $curl exports end */
|
|
|
|
|
2009-07-20 15:21:33 +00:00
|
|
|
#endif /* _CURL_THREAD_H_ */
|
|
|
|
|