| 10 | |
| 11 | This could be performed from a system call in an app. A better approach is to use the curl library. |
| 12 | |
| 13 | {{{ |
| 14 | |
| 15 | #include "cardinal825.h" |
| 16 | #include <curl/curl.h> |
| 17 | |
| 18 | |
| 19 | size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) |
| 20 | { |
| 21 | size_t written = fwrite(ptr, size, nmemb, stream); |
| 22 | return written; |
| 23 | } |
| 24 | |
| 25 | void CaptureImage(int tktNum, const char* code) |
| 26 | { |
| 27 | char imgfilepath[120]; |
| 28 | CURL *curl; |
| 29 | FILE *fp; |
| 30 | CURLcode res; |
| 31 | |
| 32 | DEBUG_MSG("%s tktNum %d code [%s]\n", __FUNCTION__, tktNum, code); |
| 33 | |
| 34 | curl = curl_easy_init(); |
| 35 | if(curl) { |
| 36 | sprintf_s(imgfilepath, _imgfilefmt, tktNum, code); |
| 37 | fp = fopen(imgfilepath, "wb"); |
| 38 | curl_easy_setopt(curl, CURLOPT_URL, /*CAMERA_SNAP_URL*/ _cameraSnapURL); |
| 39 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); |
| 40 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); |
| 41 | res = curl_easy_perform(curl); |
| 42 | if(res != CURLE_OK) { |
| 43 | DEBUG_MSG("curl_easy_perform error %d\n", res); |
| 44 | } |
| 45 | |
| 46 | curl_easy_cleanup(curl); |
| 47 | fclose(fp); |
| 48 | |
| 49 | } else { |
| 50 | DEBUG_MSG("curl_easy_init returned NULL\n"); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | }}} |