unit-tests: Add a simple thread_cancel() test
[strongswan.git] / src / libstrongswan / fetcher / fetcher.c
1 /*
2 * Copyright (C) 2011 Martin Willi
3 * Copyright (C) 2011 revosec AG
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
16 #include "fetcher.h"
17
18 /**
19 * See header.
20 */
21 bool fetcher_default_callback(void *userdata, chunk_t chunk)
22 {
23 chunk_t *accu = userdata;
24
25 accu->ptr = realloc(accu->ptr, accu->len + chunk.len);
26 if (accu->ptr)
27 {
28 memcpy(&accu->ptr[accu->len], chunk.ptr, chunk.len);
29 accu->len += chunk.len;
30 return TRUE;
31 }
32 return FALSE;
33 }