Project

General

Profile

Revision 5305e5e7

ID5305e5e7383f036c5fe98fdc215ddf420a54fe1c
Parent 06dedf83
Child 36f3b65f

Added by Thomas Mullins about 11 years ago

query.c has optional debug output for /add_card_event

View differences:

mainbox/query.c
6 6
#include <string.h>
7 7
#include <curl/curl.h>
8 8

  
9
/* Outputs the response to /add_card_event to debug.html */
10
//#define DEBUG_EVENT_RESPONSE
11

  
9 12
const char *server;
10 13
char *tooltron_password;
11 14

  
......
121 124
  struct tm *timeinfo;
122 125
  long response = 0;
123 126

  
127
#ifdef DEBUG_EVENT_RESPONSE
128
  FILE *fdebug;
129
  fdebug = fopen("debug.html", "w");
130
#endif
131

  
124 132
  handle = curl_easy_init();
125 133
  if (handle == NULL)
126 134
    return 1;
......
171 179
  error_code = curl_easy_setopt(handle, CURLOPT_URL, buf);
172 180
  if (error_code) goto error;
173 181

  
182
  /* TODO disabling host and peer verification should theoretically be removed
183
   * eventually */
174 184
  error_code = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L);
175 185
  if (error_code) goto error;
176 186

  
177
  /* TODO TEMPORARY */
178
  FILE *tmp = fopen("temp.html", "w");
179
  error_code = curl_easy_setopt(handle, CURLOPT_WRITEDATA, tmp);
187
  error_code = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
180 188
  if (error_code) goto error;
181 189

  
182
  /*
190
#ifdef DEBUG_EVENT_RESPONSE
191
  error_code = curl_easy_setopt(handle, CURLOPT_WRITEDATA, fdebug);
192
#else
183 193
  error_code = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_ignore);
194
#endif
184 195
  if (error_code) goto error;
185
  */
186 196

  
187 197
  error_code = curl_easy_setopt(handle, CURLOPT_HTTPPOST, formpost);
188 198
  if (error_code) goto error;
......
199 209

  
200 210
  curl_easy_cleanup(handle);
201 211
  curl_formfree(formpost);
202
  fclose(tmp);
212
#ifdef DEBUG_EVENT_RESPONSE
213
  fclose(fdebug);
214
#endif
203 215
  return response >= 300;
204 216

  
205 217
error:
206 218
  fprintf(stderr, "curl: %s\n", curl_easy_strerror(error_code));
207 219
  curl_easy_cleanup(handle);
208 220
  curl_formfree(formpost);
221
#ifdef DEBUG_EVENT_RESPONSE
222
  fclose(fdebug);
223
#endif
209 224
  return 1;
210 225
}

Also available in: Unified diff