FACT++  1.0
char* prepareJSONServiceList ( SERVER servp,
char *  node,
int  pid,
BROWSER browserp 
)

Definition at line 1843 of file webDid.c.

References addJSONChildEnd(), addJSONChildStart(), addJSONEnd(), addJSONNodeEnd(), addJSONNodeStart(), addJSONStart(), find_server_service_pattern(), Memory::free(), i, JSONServices, JSONServicesSize, Memory::malloc(), bitem::n_services, DNS_SERVER_INFO::n_services, item::name, DNS_SERVICE_INFO::name, bitem::pattern, DNS_SERVER_INFO::pid, item::server, item::service_ptr, bitem::servicep, sprintf(), str, and DNS_SERVICE_INFO::type.

Referenced by update_services().

1844 {
1845  DNS_SERVICE_INFO *servicep;
1846  char *ptr;
1847  int n_services, i;
1848  char str[256], type_str[256];
1849  int selective = 0;
1850  int n_found = 0, n;
1851 
1852  servicep = servp->service_ptr;
1853  n_services = servp->server.n_services;
1854  if(JSONServicesSize == 0)
1855  {
1856  JSONServicesSize = n_services*256;
1858  }
1859  else if (JSONServicesSize < n_services*256)
1860  {
1861  free(JSONServices);
1862  JSONServicesSize = n_services*256;
1864  }
1865  if(browserp)
1866  {
1867  if(browserp->pattern[0] != '\0')
1868  selective = 1;
1869  }
1870  n_found = n_services;
1871  if(selective)
1872  {
1873  n_found = find_server_service_pattern(servp, browserp->pattern);
1874  }
1875  ptr = JSONServices;
1876  *ptr = '\0';
1877  ptr = addJSONStart(ptr);
1878  ptr = addJSONNodeStart(ptr,"children");
1879  if(selective)
1880  sprintf(str,"text: \"%s (%d/%d services, pid %d)\"",servp->name, n_found, n_services, servp->server.pid);
1881  else
1882  sprintf(str,"text: \"%s (%d services, pid %d)\"",servp->name, n_services, servp->server.pid);
1883  ptr = addJSONChildStart(ptr,str,1);
1884  ptr = addJSONNodeStart(ptr,"children");
1885  servicep = servp->service_ptr;
1886  n = 0;
1887  for(i = 0; i < n_services; i++)
1888  {
1889 /*
1890 printf("Service type = %d\n",servicep->type);
1891 */
1892  if((!selective) || (strstr(servicep->name, browserp->pattern)))
1893  {
1894  if(servicep->type == 1)
1895  {
1896  sprintf(type_str,"%d@%s|%s|CMD", pid, node, servicep->name);
1897  sprintf(str,"text: \"%s\", id: \"%s\", leaf: true, icon: \"leaf_cmd.gif\"",servicep->name, type_str);
1898  }
1899  else
1900  {
1901  sprintf(type_str,"%d@%s|%s", pid, node, servicep->name);
1902  sprintf(str,"text: \"%s\", id: \"%s\", leaf: true",servicep->name, type_str);
1903  }
1904  ptr = addJSONChildStart(ptr,str,0);
1905  n++;
1906  if(n < n_found)
1907  ptr = addJSONChildEnd(ptr,1);
1908  else
1909  ptr = addJSONChildEnd(ptr,0);
1910  }
1911  servicep++;
1912  }
1913  ptr = addJSONNodeEnd(ptr);
1914  ptr = addJSONChildEnd(ptr,0);
1915  ptr = addJSONNodeEnd(ptr);
1916  ptr = addJSONEnd(ptr);
1917  return JSONServices;
1918 }
char * addJSONNodeEnd(char *ptr)
Definition: webDid.c:1380
Definition: dns.c:26
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
char * JSONServices
Definition: webDid.c:1841
void * malloc()
Definition: EventBuilder.cc:99
char * addJSONChildEnd(char *ptr, int sep)
Definition: webDid.c:1401
char name[132]
Definition: did.h:46
char * addJSONChildStart(char *ptr, char *child, int sep)
Definition: webDid.c:1389
int JSONServicesSize
Definition: webDid.c:1842
DNS_SERVICE_INFO * service_ptr
Definition: did.h:45
char * addJSONEnd(char *ptr)
Definition: webDid.c:1362
char name[MAX_NAME]
Definition: dim.h:331
char * addJSONNodeStart(char *ptr, char *node)
Definition: webDid.c:1371
DNS_SERVER_INFO server
Definition: did.h:44
void free(void *mem)
char * addJSONStart(char *ptr)
Definition: webDid.c:1353
int n_services
Definition: dim.h:341
int find_server_service_pattern(SERVER *servp, char *pattern)
Definition: webDid.c:189
sprintf(name1,"NewService%d", i)
char pattern[256]
Definition: webDid.c:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function: