1 | /*************************************************************************** |
2 | * _ _ ____ _ |
3 | * Project ___| | | | _ \| | |
4 | * / __| | | | |_) | | |
5 | * | (__| |_| | _ <| |___ |
6 | * \___|\___/|_| \_\_____| |
7 | * |
8 | * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. |
9 | * |
10 | * This software is licensed as described in the file COPYING, which |
11 | * you should have received as part of this distribution. The terms |
12 | * are also available at https://curl.haxx.se/docs/copyright.html. |
13 | * |
14 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
15 | * copies of the Software, and permit persons to whom the Software is |
16 | * furnished to do so, under the terms of the COPYING file. |
17 | * |
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
19 | * KIND, either express or implied. |
20 | * |
21 | ***************************************************************************/ |
22 | |
23 | #include "curl_setup.h" |
24 | |
25 | #ifndef CURL_DISABLE_FTP |
26 | |
27 | #include "wildcard.h" |
28 | #include "llist.h" |
29 | #include "fileinfo.h" |
30 | /* The last 3 #include files should be in this order */ |
31 | #include "curl_printf.h" |
32 | #include "curl_memory.h" |
33 | #include "memdebug.h" |
34 | |
35 | static void fileinfo_dtor(void *user, void *element) |
36 | { |
37 | (void)user; |
38 | Curl_fileinfo_cleanup(element); |
39 | } |
40 | |
41 | CURLcode Curl_wildcard_init(struct WildcardData *wc) |
42 | { |
43 | Curl_llist_init(&wc->filelist, fileinfo_dtor); |
44 | wc->state = CURLWC_INIT; |
45 | |
46 | return CURLE_OK; |
47 | } |
48 | |
49 | void Curl_wildcard_dtor(struct WildcardData *wc) |
50 | { |
51 | if(!wc) |
52 | return; |
53 | |
54 | if(wc->dtor) { |
55 | wc->dtor(wc->protdata); |
56 | wc->dtor = ZERO_NULL; |
57 | wc->protdata = NULL; |
58 | } |
59 | DEBUGASSERT(wc->protdata == NULL); |
60 | |
61 | Curl_llist_destroy(&wc->filelist, NULL); |
62 | |
63 | |
64 | free(wc->path); |
65 | wc->path = NULL; |
66 | free(wc->pattern); |
67 | wc->pattern = NULL; |
68 | |
69 | wc->customptr = NULL; |
70 | wc->state = CURLWC_INIT; |
71 | } |
72 | |
73 | #endif /* if disabled */ |
74 | |