blob: af45c79bd3c0ba889685314fd947eaf6b29a3828 [file] [log] [blame]
Lucas Eckels9bd90e62012-08-06 15:07:02 -07001/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
Elliott Hughes82be86d2017-09-20 17:00:17 -07008 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
Lucas Eckels9bd90e62012-08-06 15:07:02 -07009 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
Alex Deymo8f1a2142016-06-28 14:49:26 -070012 * are also available at https://curl.haxx.se/docs/copyright.html.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070013 *
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
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070023#include "curl_setup.h"
24
Lucas Eckels9bd90e62012-08-06 15:07:02 -070025#include "wildcard.h"
26#include "llist.h"
27#include "fileinfo.h"
Alex Deymo8f1a2142016-06-28 14:49:26 -070028/* The last 3 #include files should be in this order */
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070029#include "curl_printf.h"
Lucas Eckels9bd90e62012-08-06 15:07:02 -070030#include "curl_memory.h"
Lucas Eckels9bd90e62012-08-06 15:07:02 -070031#include "memdebug.h"
32
33CURLcode Curl_wildcard_init(struct WildcardData *wc)
34{
Elliott Hughes82be86d2017-09-20 17:00:17 -070035 Curl_llist_init(&wc->filelist, Curl_fileinfo_dtor);
36 wc->state = CURLWC_INIT;
37
Lucas Eckels9bd90e62012-08-06 15:07:02 -070038 return CURLE_OK;
39}
40
41void Curl_wildcard_dtor(struct WildcardData *wc)
42{
43 if(!wc)
44 return;
45
46 if(wc->tmp_dtor) {
47 wc->tmp_dtor(wc->tmp);
48 wc->tmp_dtor = ZERO_NULL;
49 wc->tmp = NULL;
50 }
51 DEBUGASSERT(wc->tmp == NULL);
52
Elliott Hughes82be86d2017-09-20 17:00:17 -070053 Curl_llist_destroy(&wc->filelist, NULL);
54
Lucas Eckels9bd90e62012-08-06 15:07:02 -070055
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070056 free(wc->path);
57 wc->path = NULL;
58 free(wc->pattern);
59 wc->pattern = NULL;
Lucas Eckels9bd90e62012-08-06 15:07:02 -070060
61 wc->customptr = NULL;
62 wc->state = CURLWC_INIT;
63}