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

Definition at line 240 of file webServer.c.

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

Referenced by check_browser_changes(), find_services(), recv_service_info(), sendFile(), update_command_data(), and update_service_data().

241 {
242  static char date_buffer[128];
243  static char snd_buffer[BUFSIZE+1]; /* static so zero filled */
244  static char snd_data_buffer[BUFSIZE+1]; /* static so zero filled */
245  char *ptr = 0;
246  char node[128], server[256], service[256];
247  int pid, ret, req, browser, force;
248  extern char *update_services();
249  extern char *update_service_data();
250  extern char *getJSONHeader();
251  extern char *getJSONBuffer();
252  char datatype[128];
253  char *conv_buffer;
254 
255  conv_buffer = buffer;
256  strcpy(datatype,"application/json");
257  if(type == 0)
258  {
259  ptr = getJSONHeader(0);
260  }
261  else if(type == 1)
262  {
263  ret = getNodeParameters(conv_buffer, node, &browser);
264  ptr = getJSONBuffer(node, browser);
265  }
266  else if(type == 2)
267  {
268  ret = getServerParameters(conv_buffer, node, server, &pid, &browser);
269  if(!ret)
270  {
271  strcpy(snd_data_buffer,"{}");
272  ptr = snd_data_buffer;
273  }
274  else
275  {
276  ptr = update_services(node, server, pid, browser);
277  }
278  }
279  else if(type == 3)
280  {
281  ret = getServiceParameters(conv_buffer, service, &req, &browser, &force);
282  if(!ret)
283  {
284  strcpy(snd_data_buffer,"{}");
285  ptr = snd_data_buffer;
286  }
287  else
288  {
289  update_service_data(service, conn_id, 0, req, browser, force);
290  return;
291  }
292  }
293  else if(type == 4)
294  {
295  ptr = conv_buffer;
296 if(WebDID_Debug)
297  printf("%s\n",ptr);
298  strcpy(datatype,"text/html");
299  }
300  else if(type == 5)
301  {
302  ret = getServiceParameters(conv_buffer, service, &req, &browser, &force);
303  if(!ret)
304  {
305  strcpy(snd_data_buffer,"{}");
306  ptr = snd_data_buffer;
307  }
308  else
309  {
310  check_browser_changes(service, conn_id, 0, req, browser, force);
311  return;
312  }
313  }
314  else if(type == 6)
315  {
316  ret = getServiceParameters(conv_buffer, service, &req, &browser, &force);
317  if(!ret)
318  {
319  strcpy(snd_data_buffer,"{}");
320  ptr = snd_data_buffer;
321  }
322  else
323  {
324  find_services(service, conn_id, browser, force);
325  if(force == -1)
326  strcpy(snd_data_buffer,"");
327  else
328  strcpy(snd_data_buffer,"load");
329  ptr = snd_data_buffer;
330  }
331  }
332  getTime(date_buffer);
333  (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",
334  date_buffer, (int)strlen(ptr), datatype);
335  (void)web_write(conn_id,snd_buffer,(int)strlen(snd_buffer));
336 if(WebDID_Debug)
337  printf("SENDING DATA to conn %d:\n%s\n",conn_id, snd_buffer);
338  (void)web_write(conn_id,ptr,(int)strlen(ptr));
339 if(WebDID_Debug == 2)
340  printf("SENDING DATA to conn %d:\n%s\n",conn_id, ptr);
341 }
void getTime(char *buffer)
Definition: webServer.c:45
Definition: dns.c:26
#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: