~rozzin/foxtrotgps/bing-maps

« back to all changes in this revision

Viewing changes to src/util.c

  • Committer: Joshua Judson Rosen
  • Date: 2012-06-01 02:01:33 UTC
  • mfrom: (201.1.2 foxtrot-revert2)
  • Revision ID: rozzin@geekspace.com-20120601020133-pgchkyqpv96o2jpk
Make route-finding work again, by interacting directly with the routing servers
rather than proxying through tangogps.org (which appears to be dead).

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        return size;
63
63
}
64
64
 
 
65
postreply_t*
 
66
mycurl__do_http_post_XML (char *url, char *xmlString, char *useragent)
 
67
{
 
68
        GSList *list;
 
69
        postreply_t *postreply;
 
70
        
 
71
        CURL *curl_handle;
 
72
        
 
73
        struct curl_httppost *lastptr  = NULL;
 
74
                
 
75
        mem_struct_t chunk;
 
76
        long int status_code;
 
77
        
 
78
        chunk.memory = NULL;
 
79
        chunk.size   = 0;
 
80
        
 
81
        curl_global_init(CURL_GLOBAL_ALL);
 
82
        
 
83
        curl_handle = curl_easy_init();
 
84
        
 
85
        curl_easy_setopt(curl_handle, CURLOPT_URL, url);
 
86
        curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
 
87
        curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, xmlString);
 
88
        curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, mycurl_write_to_mem_cb);
 
89
        curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
65
90
 
 
91
        curl_easy_perform(curl_handle);
 
92
        curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &status_code);
 
93
        
 
94
        curl_easy_cleanup(curl_handle);
 
95
        
 
96
        postreply = g_new0(postreply_t, 1);
 
97
        postreply->status_code = status_code;
 
98
        if(chunk.memory)
 
99
                postreply->size = strlen(chunk.memory);
 
100
        else
 
101
                postreply->size = 0;
 
102
        postreply->data = g_strdup(chunk.memory);
 
103
        
 
104
        if(chunk.memory)
 
105
                g_free(chunk.memory);
 
106
        
 
107
        curl_global_cleanup();
 
108
        
 
109
        return postreply;
 
110
}
66
111
 
67
112
postreply_t*
68
113
mycurl__do_http_post (char *url, GSList *post_data_list, char *useragent)