1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
20 long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains);
22 long chunk_end(void *ptr);
25 long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains)
27 chunk_data_t *ch_d = ptr;
28 ch_d->remains = remains;
30 printf("=============================================================\n");
31 printf("Remains: %d\n", remains);
32 printf("Filename: %s\n", finfo->filename);
33 if(finfo->strings.perm) {
34 printf("Permissions: %s", finfo->strings.perm);
35 if(finfo->flags & CURLFINFOFLAG_KNOWN_PERM)
36 printf(" (parsed => %o)", finfo->perm);
39 printf("Size: %ldB\n", (long)finfo->size);
40 if(finfo->strings.user)
41 printf("User: %s\n", finfo->strings.user);
42 if(finfo->strings.group)
43 printf("Group: %s\n", finfo->strings.group);
44 if(finfo->strings.time)
45 printf("Time: %s\n", finfo->strings.time);
47 switch(finfo->filetype) {
48 case CURLFILETYPE_FILE:
49 printf("regular file\n");
51 case CURLFILETYPE_DIRECTORY:
52 printf("directory\n");
54 case CURLFILETYPE_SYMLINK:
56 printf("Target: %s\n", finfo->strings.target);
59 printf("other type\n");
62 if(finfo->filetype == CURLFILETYPE_FILE) {
63 ch_d->print_content = 1;
64 printf("Content:\n-------------------------------------------------------------\n");
66 if(strcmp(finfo->filename, "someothertext.txt") == 0) {
67 printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n");
68 return CURL_CHUNK_BGN_FUNC_SKIP;
70 return CURL_CHUNK_BGN_FUNC_OK;
74 long chunk_end(void *ptr)
76 chunk_data_t *ch_d = ptr;
77 if(ch_d->print_content) {
78 ch_d->print_content = 0;
79 printf("-------------------------------------------------------------\n");
81 if(ch_d->remains == 1)
82 printf("=============================================================\n");
83 return CURL_CHUNK_END_FUNC_OK;
89 CURLcode res = CURLE_OK;
90 chunk_data_t chunk_data = {0,0};
91 curl_global_init(CURL_GLOBAL_ALL);
92 handle = curl_easy_init();
94 res = CURLE_OUT_OF_MEMORY;
98 test_setopt(handle, CURLOPT_URL, URL);
99 test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
100 test_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, chunk_bgn);
101 test_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, chunk_end);
102 test_setopt(handle, CURLOPT_CHUNK_DATA, &chunk_data);
104 res = curl_easy_perform(handle);
108 curl_easy_cleanup(handle);
109 curl_global_cleanup();