implemented http get method
[strongswan.git] / src / libstrongswan / utils / fetcher.h
1 /**
2 * @file fetcher.h
3 *
4 * @brief Interface of fetcher_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Andreas Steffen
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <fetcher://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef FETCHER_H_
24 #define FETCHER_H_
25
26 typedef struct fetcher_t fetcher_t;
27
28 #include <chunk.h>
29
30 #define FETCHER_TIMEOUT 10 /* seconds */
31
32 /**
33 * @brief Fetches information from an URI (http, file, ftp, etc.)
34 *
35 * @ingroup utils
36 */
37 struct fetcher_t {
38
39 /**
40 * @brief Get information via a get request.
41 *
42 * @param this calling object
43 * @param uri uri specifying the information source
44 * @return chunk_t containing the information
45 */
46 chunk_t (*get) (fetcher_t *this);
47
48 /**
49 * @brief Get information via a get request.
50 *
51 * @param this calling object
52 * @param uri uri specifying the information source
53 * @param type content type of http post request
54 * @param request binary data for http post request
55 * @return chunk_t containing the information
56 */
57 chunk_t (*post) (fetcher_t *this, const char *type, chunk_t request);
58
59 /**
60 * @brief Destroys the fetcher_t object.
61 *
62 * @param this fetcher_t to destroy
63 */
64 void (*destroy) (fetcher_t *this);
65
66 };
67
68 /**
69 * @brief Create a fetcher_t object.
70 *
71 * @return created fetcher_t object
72 *
73 * @ingroup utils
74 */
75 fetcher_t* fetcher_create(const char *uri);
76
77 /**
78 * @brief Initializes the fetcher_t class
79 *
80 * call this function only once in the main program
81 *
82 * @ingroup utils
83 */
84 void fetcher_initialize(void);
85
86 /**
87 * @brief Finalizes the fetcher_t class
88 *
89 * call this function only once befor exiting the main program
90 *
91 * @ingroup utils
92 */
93 void fetcher_finalize(void);
94
95 #endif /*FETCHER_H_*/