FACT++  1.0
void sendSmiData ( int  conn_id,
char *  buffer,
int  type 
)

Definition at line 344 of file webServer.c.

References buffer, BUFSIZE, check_browser_changes(), conv_buffer, find_services(), getJSONBuffer(), getJSONHeader(), getJSONSmiBuffer(), getNodeParameters(), getServerParameters(), getServiceParameters(), getTime(), sprintf(), update_service_data(), update_services(), update_smi_objects(), web_write(), and WebDID_Debug.

Referenced by sendFile().

345 {
346  static char date_buffer[128];
347  static char snd_buffer[BUFSIZE+1]; /* static so zero filled */
348  static char snd_data_buffer[BUFSIZE+1]; /* static so zero filled */
349  char *ptr = 0;
350  char node[128], server[256], service[256];
351  int pid, ret, req, browser, force;
352  extern char *update_services(), *update_smi_objects();
353  extern char *update_service_data();
354  extern char *getJSONHeader();
355  extern char *getJSONBuffer(), *getJSONSmiBuffer();
356  char datatype[128];
357  char *conv_buffer;
358 
359  conv_buffer = buffer;
360  strcpy(datatype,"application/json");
361  if(type == 0)
362  {
363  ptr = getJSONHeader(1);
364  }
365  else if(type == 1)
366  {
367  ret = getNodeParameters(conv_buffer, node, &browser);
368  ptr = getJSONSmiBuffer(node, browser);
369  }
370  else if(type == 2)
371  {
372  ret = getServerParameters(conv_buffer, node, server, &pid, &browser);
373  if(!ret)
374  {
375  strcpy(snd_data_buffer,"{}");
376  ptr = snd_data_buffer;
377  }
378  else
379  {
380  ptr = update_smi_objects(node, server, pid, browser);
381  }
382  }
383  else if(type == 3)
384  {
385  ret = getServiceParameters(conv_buffer, service, &req, &browser, &force);
386  if(!ret)
387  {
388  strcpy(snd_data_buffer,"{}");
389  ptr = snd_data_buffer;
390  }
391  else
392  {
393  update_service_data(service, conn_id, 0, req, browser, force);
394  return;
395  }
396  }
397  else if(type == 4)
398  {
399  ptr = conv_buffer;
400 if(WebDID_Debug)
401  printf("%s\n",ptr);
402  strcpy(datatype,"text/html");
403  }
404  else if(type == 5)
405  {
406  ret = getServiceParameters(conv_buffer, service, &req, &browser, &force);
407  if(!ret)
408  {
409  strcpy(snd_data_buffer,"{}");
410  ptr = snd_data_buffer;
411  }
412  else
413  {
414  check_browser_changes(service, conn_id, 0, req, browser, force);
415  return;
416  }
417  }
418  else if(type == 6)
419  {
420  ret = getServiceParameters(conv_buffer, service, &req, &browser, &force);
421  if(!ret)
422  {
423  strcpy(snd_data_buffer,"{}");
424  ptr = snd_data_buffer;
425  }
426  else
427  {
428  find_services(service, conn_id, browser, force);
429  if(force == -1)
430  strcpy(snd_data_buffer,"");
431  else
432  strcpy(snd_data_buffer,"load");
433  ptr = snd_data_buffer;
434  }
435  }
436  getTime(date_buffer);
437  (void)sprintf(snd_buffer,"HTTP/1.1 200 OK\r\nDate: %s\r\nServer: DID/19.7\r\nContent-Length: %d\r\nContent-Type: %s\r\nConnection: close\r\n\r\n",
438  date_buffer, (int)strlen(ptr), datatype);
439  (void)web_write(conn_id,snd_buffer,(int)strlen(snd_buffer));
440 if(WebDID_Debug)
441  printf("SENDING DATA to conn %d:\n%s\n",conn_id, snd_buffer);
442  (void)web_write(conn_id,ptr,(int)strlen(ptr));
443 if(WebDID_Debug == 2)
444  printf("SENDING DATA to conn %d:\n%s\n",conn_id, ptr);
445 }
void getTime(char *buffer)
Definition: webServer.c:45
Definition: dns.c:26
char * getJSONSmiBuffer(char *node, int browser)
Definition: webDid.c:1436
char * update_smi_objects(char *node, char *server, int pid, int browser)
Definition: webDid.c:487
#define BUFSIZE
Definition: webServer.c:9
void web_write()
int getNodeParameters(char *buffer, char *node, int *browser)
Definition: webServer.c:129
void update_services()
int getServiceParameters(char *buffer, char *service, int *req, int *browser, int *force)
Definition: webServer.c:172
int type
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
int getServerParameters(char *buffer, char *node, char *server, int *pid, int *browser)
Definition: webServer.c:149
static char * conv_buffer
Definition: webServer.c:199
char * getJSONBuffer(char *node, int browser)
Definition: webDid.c:1413
int check_browser_changes()
int WebDID_Debug
Definition: webServer.c:7
sprintf(name1,"NewService%d", i)
char * getJSONHeader(int isSMI)
Definition: webDid.c:1465
int update_service_data(char *service, int conn_id, int subscribe, int req, int browser, int force)
Definition: webDid.c:718
int find_services()

+ Here is the call graph for this function:

+ Here is the caller graph for this function: