updated Doxyfile
[strongswan.git] / src / libstrongswan / plugins / curl / curl_plugin.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * $Id$
16 */
17
18 #include "curl_plugin.h"
19
20 #include <library.h>
21 #include <debug.h>
22 #include "curl_fetcher.h"
23
24 #include <curl/curl.h>
25
26 typedef struct private_curl_plugin_t private_curl_plugin_t;
27
28 /**
29 * private data of curl_plugin
30 */
31 struct private_curl_plugin_t {
32
33 /**
34 * public functions
35 */
36 curl_plugin_t public;
37 };
38
39 /**
40 * Implementation of curl_plugin_t.curltroy
41 */
42 static void destroy(private_curl_plugin_t *this)
43 {
44 lib->fetcher->remove_fetcher(lib->fetcher,
45 (fetcher_constructor_t)curl_fetcher_create);
46 curl_global_cleanup();
47 free(this);
48 }
49
50 /*
51 * see header file
52 */
53 plugin_t *plugin_create()
54 {
55 CURLcode res;
56 private_curl_plugin_t *this = malloc_thing(private_curl_plugin_t);
57
58 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
59
60 res = curl_global_init(CURL_GLOBAL_NOTHING);
61 if (res == CURLE_OK)
62 {
63 lib->fetcher->add_fetcher(lib->fetcher,
64 (fetcher_constructor_t)curl_fetcher_create, "file://");
65 lib->fetcher->add_fetcher(lib->fetcher,
66 (fetcher_constructor_t)curl_fetcher_create, "http://");
67 lib->fetcher->add_fetcher(lib->fetcher,
68 (fetcher_constructor_t)curl_fetcher_create, "https://");
69 lib->fetcher->add_fetcher(lib->fetcher,
70 (fetcher_constructor_t)curl_fetcher_create, "ftp://");
71 }
72 else
73 {
74 DBG1("global libcurl initializing failed: %s, curl disabled",
75 curl_easy_strerror(res));
76 }
77 return &this->public.plugin;
78 }
79