TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
httpget.cpp File Reference
#include "httpget.h"
+ Include dependency graph for httpget.cpp:

Functions

static int http_get_init (struct soap *soap, struct http_get_data *data, int(*handler)(struct soap *))
 
static void http_get_delete (struct soap *soap, struct soap_plugin *p)
 
static int http_get_parse (struct soap *soap)
 
int http_get (struct soap *soap, struct soap_plugin *p, void *arg)
 
int soap_get_connect (struct soap *soap, const char *endpoint, const char *action)
 
char * query (struct soap *soap)
 
char * query_key (struct soap *soap, char **s)
 
char * query_val (struct soap *soap, char **s)
 
int soap_encode_string (const char *s, char *t, size_t len)
 
const char * soap_decode_string (char *buf, size_t len, const char *val)
 

Variables

const char http_get_id [13] = HTTP_GET_ID
 

Function Documentation

int http_get ( struct soap soap,
struct soap_plugin p,
void *  arg 
)
155 { p->id = http_get_id;
156  p->data = (void*)malloc(sizeof(struct http_get_data));
157  /* p->fcopy = http_get_copy; obsolete, see note with http_get_copy() */
159  if (p->data)
160  if (http_get_init(soap, (struct http_get_data*)p->data, (int (*)(struct soap*))arg))
161  { free(p->data); /* error: could not init */
162  return SOAP_EOM; /* return error */
163  }
164  return SOAP_OK;
165 }
Definition: httpget.h:63
static void http_get_delete(struct soap *soap, struct soap_plugin *p)
Definition: httpget.cpp:187
const char * id
Definition: stdsoap2.h:2252
static int http_get_init(struct soap *soap, struct http_get_data *data, int(*handler)(struct soap *))
Definition: httpget.cpp:167
const char http_get_id[13]
Definition: httpget.cpp:148
internal::NamedArg< char > arg(StringRef name, const T &arg)
Definition: format.h:3248
#define SOAP_OK
Definition: stdsoap2.h:1245
void * data
Definition: stdsoap2.h:2253
void(* fdelete)(struct soap *soap, struct soap_plugin *p)
Definition: stdsoap2.h:2255
#define SOAP_EOM
Definition: stdsoap2.h:1265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void http_get_delete ( struct soap soap,
struct soap_plugin p 
)
static
188 { free(p->data); /* free allocated plugin data (this function is not called for shared plugin data, but only when the final soap_done() is invoked on the original soap struct) */
189 }
void * data
Definition: stdsoap2.h:2253

+ Here is the caller graph for this function:

static int http_get_init ( struct soap soap,
struct http_get_data data,
int(*)(struct soap *)  handler 
)
static
168 { data->fparse = soap->fparse; /* save old HTTP header parser callback */
169  data->fget = handler;
170  data->stat_get = 0;
171  data->stat_post = 0;
172  data->stat_fail = 0;
173  memset(data->min, 0, sizeof(data->min));
174  memset(data->hour, 0, sizeof(data->hour));
175  memset(data->day, 0, sizeof(data->day));
176  soap->fparse = http_get_parse; /* replace HTTP header parser callback with ours */
177  return SOAP_OK;
178 }
size_t stat_post
Definition: httpget.h:67
int(* fget)(struct soap *)
Definition: httpget.h:65
size_t day[366]
Definition: httpget.h:71
size_t stat_fail
Definition: httpget.h:68
size_t min[60]
Definition: httpget.h:69
#define SOAP_OK
Definition: stdsoap2.h:1245
int(* fparse)(struct soap *)
Definition: httpget.h:64
static int http_get_parse(struct soap *soap)
Definition: httpget.cpp:191
size_t hour[24]
Definition: httpget.h:70
int(* fparse)(struct soap *)
Definition: stdsoap2.h:1991
size_t stat_get
Definition: httpget.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int http_get_parse ( struct soap soap)
static
192 {
193 #ifndef WITH_LEAN
194  time_t t;
195  struct tm T, *pT;
196 #endif
197  struct http_get_data *data = (struct http_get_data*)soap_lookup_plugin(soap, http_get_id);
198  if (!data)
199  return SOAP_PLUGIN_ERROR;
200 #ifndef WITH_LEAN
201  time(&t);
202 #ifdef HAVE_LOCALTIME_R
203  pT = localtime_r(&t, &T);
204 #else
205  pT = localtime(&t);
206 #endif
207  /* updates should be in mutex, but we don't mind some inaccuracy in the count to preserve performance */
208  data->day[pT->tm_yday]++;
209  data->day[(pT->tm_yday + 1) % 365] = 0;
210  data->hour[pT->tm_hour]++;
211  data->hour[(pT->tm_hour + 1) % 24] = 0;
212  data->min[pT->tm_min]++;
213  data->min[(pT->tm_min + 1) % 60] = 0;
214 #endif
215  soap->error = data->fparse(soap); /* parse HTTP header */
216  if (soap->error == SOAP_OK)
217  { /* update should be in mutex, but we don't mind some inaccuracy in the count */
218  data->stat_post++;
219  }
220  else if (soap->error == SOAP_GET_METHOD && data->fget)
221  { soap->error = SOAP_OK;
222  if ((soap->error = data->fget(soap))) /* call user-defined HTTP GET handler */
223  { /* update should be in mutex, but we don't mind some inaccuracy in the count */
224  data->stat_fail++;
225  return soap->error;
226  }
227  /* update should be in mutex, but we don't mind some inaccuracy in the count */
228  data->stat_get++;
229  return SOAP_STOP; /* stop processing the request and do not return SOAP Fault */
230  }
231  else
232  { /* update should be in mutex, but we don't mind some inaccuracy in the count */
233  data->stat_fail++;
234  }
235  return soap->error;
236 }
size_t stat_post
Definition: httpget.h:67
int error
Definition: stdsoap2.h:2112
Definition: httpget.h:63
int(* fget)(struct soap *)
Definition: httpget.h:65
SOAP_FMAC1 void *SOAP_FMAC2 soap_lookup_plugin(struct soap *soap, const char *id)
Definition: stdsoap2.cpp:16947
#define SOAP_PLUGIN_ERROR
Definition: stdsoap2.h:1285
#define SOAP_STOP
Definition: stdsoap2.h:1308
const char http_get_id[13]
Definition: httpget.cpp:148
size_t day[366]
Definition: httpget.h:71
size_t stat_fail
Definition: httpget.h:68
size_t min[60]
Definition: httpget.h:69
TC_COMMON_API struct tm * localtime_r(const time_t *time, struct tm *result)
#define SOAP_OK
Definition: stdsoap2.h:1245
int(* fparse)(struct soap *)
Definition: httpget.h:64
size_t hour[24]
Definition: httpget.h:70
#define SOAP_GET_METHOD
Definition: stdsoap2.h:1260
size_t stat_get
Definition: httpget.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* query ( struct soap soap)
245 { return strchr(soap->path, '?');
246 }
char path[SOAP_TAGLEN]
Definition: stdsoap2.h:2093

+ Here is the caller graph for this function:

char* query_key ( struct soap soap,
char **  s 
)
249 { char *t = *s;
250  if (t && *t)
251  { *s = (char*)soap_decode_string(t, strlen(t), t + 1);
252  return t;
253  }
254  return *s = NULL;
255 }
const char * soap_decode_string(char *buf, size_t len, const char *val)
Definition: httpget.cpp:294
arena_t NULL
Definition: jemalloc_internal.h:624

+ Here is the call graph for this function:

char* query_val ( struct soap soap,
char **  s 
)
258 { char *t = *s;
259  if (t && *t == '=')
260  { *s = (char*)soap_decode_string(t, strlen(t), t + 1);
261  return t;
262  }
263  return NULL;
264 }
const char * soap_decode_string(char *buf, size_t len, const char *val)
Definition: httpget.cpp:294
arena_t NULL
Definition: jemalloc_internal.h:624

+ Here is the call graph for this function:

const char* soap_decode_string ( char *  buf,
size_t  len,
const char *  val 
)
295 { const char *s;
296  char *t;
297  for (s = val; *s; s++)
298  if (*s != ' ' && *s != '=')
299  break;
300  if (*s == '"')
301  { t = buf;
302  s++;
303  while (*s && *s != '"' && --len)
304  *t++ = *s++;
305  *t = '\0';
306  do s++;
307  while (*s && *s != '&' && *s != '=');
308  }
309  else
310  { t = buf;
311  while (*s && *s != '&' && *s != '=' && --len)
312  { switch (*s)
313  { case '+':
314  *t++ = ' ';
315  case ' ':
316  s++;
317  break;
318  case '%':
319  *t++ = ((s[1] >= 'A' ? (s[1]&0x7) + 9 : s[1] - '0') << 4) + (s[2] >= 'A' ? (s[2]&0x7) + 9 : s[2] - '0');
320  s += 3;
321  break;
322  default:
323  *t++ = *s++;
324  }
325  }
326  *t = '\0';
327  }
328  return s;
329 }

+ Here is the caller graph for this function:

int soap_encode_string ( const char *  s,
char *  t,
size_t  len 
)
267 { register int c;
268  register size_t n = len;
269  while ((c = *s++) && n-- > 1)
270  { if (c == ' ')
271  *t++ = '+';
272  else if (c == '!'
273  || c == '$'
274  || (c >= '(' && c <= '.')
275  || (c >= '0' && c <= '9')
276  || (c >= 'A' && c <= 'Z')
277  || c == '_'
278  || (c >= 'a' && c <= 'z'))
279  *t++ = (char)c;
280  else if (n > 2)
281  { *t++ = '%';
282  *t++ = (char)((c >> 4) + (c > 159 ? '7' : '0'));
283  c &= 0xF;
284  *t++ = (char)(c + (c > 9 ? '7' : '0'));
285  n -= 2;
286  }
287  else
288  break;
289  }
290  *t = '\0';
291  return len - n;
292 }
int soap_get_connect ( struct soap soap,
const char *  endpoint,
const char *  action 
)
241 { return soap_connect_command(soap, SOAP_GET, endpoint, action);
242 }
#define SOAP_GET
Definition: stdsoap2.h:1317
SOAP_FMAC1 int SOAP_FMAC2 soap_connect_command(struct soap *soap, int http_command, const char *endpoints, const char *action)
Definition: stdsoap2.cpp:15698

+ Here is the call graph for this function:

Variable Documentation

const char http_get_id[13] = HTTP_GET_ID