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

Definition at line 1923 of file webDid.c.

References addJSONChildEnd(), addJSONChildStart(), addJSONEnd(), addJSONNodeEnd(), addJSONNodeStart(), addJSONStart(), findSmiServices(), Memory::free(), i, JSONSmiServices, JSONSmiServicesSize, Memory::malloc(), objstate::mode_index, 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, bitem::smidomainp, sprintf(), DNS_SERVICE_INFO::status, and str.

Referenced by update_smi_objects().

1924 {
1925  DNS_SERVICE_INFO *servicep;
1926  char *ptr;
1927  int n_services, i;
1928  char str[512], type_str[512];
1929  int selective = 0;
1930  int n_found = 0, n, mode_index;
1931  char aux[512], *sptr, state[512], *stptr;
1932  OBJSTATE *smidomainp;
1933  int findSmiServices();
1934 
1935 printf("prepareJSONSmiObjectList name %s\n", servp->name);
1936  servicep = servp->service_ptr;
1937  n_services = servp->server.n_services;
1938  if(JSONSmiServicesSize == 0)
1939  {
1940  JSONSmiServicesSize = n_services*512;
1942  }
1943  else if (JSONSmiServicesSize < n_services*512)
1944  {
1946  JSONSmiServicesSize = n_services*512;
1948  }
1949  if(browserp)
1950  {
1951  if(browserp->pattern[0] != '\0')
1952  selective = 1;
1953  }
1954  n_found = n_services;
1955  /*
1956  if(selective)
1957  {
1958  n_found = find_server_service_pattern(servp, browserp->pattern);
1959  }
1960  */
1961 
1962  n_found = findSmiServices(browserp, servp);
1963  smidomainp = browserp->smidomainp;
1964 
1965 printf("prepareJSONSmiObjectList1 name %s\n", servp->name);
1966 
1967 
1968  ptr = JSONSmiServices;
1969  *ptr = '\0';
1970  ptr = addJSONStart(ptr);
1971  ptr = addJSONNodeStart(ptr,"children");
1972  /*
1973  if(selective)
1974  sprintf(str,"name: \"%s (%d/%d services, pid %d)\"",servp->name, n_found, n_services, servp->server.pid);
1975  else
1976  sprintf(str,"name: \"%s (%d services, pid %d)\"",servp->name, n_services, servp->server.pid);
1977  */
1978  sprintf(str,"name: \"%s (%d objects, pid %d)\"",servp->name, n_found, servp->server.pid);
1979  ptr = addJSONChildStart(ptr,str,1);
1980  ptr = addJSONNodeStart(ptr,"children");
1981  servicep = servp->service_ptr;
1982  n = 0;
1983  for(i = 0; i < n_services; i++)
1984  {
1985 /*
1986 printf("Service type = %d\n",servicep->type);
1987 */
1988 printf("prepareJSONSmiObjectList2 obj name %s\n", servicep->name);
1989  if((!selective) || (strstr(servicep->name, browserp->pattern)))
1990  {
1991 /*
1992  if(servicep->type == 1)
1993  {
1994  sprintf(type_str,"%d@%s|%s|CMD", pid, node, servicep->name);
1995  sprintf(str,"name: \"%s\", id: \"%s\", leaf: true, icon: \"leaf_cmd.gif\"",servicep->name, type_str);
1996  }
1997  else
1998  {
1999  sprintf(type_str,"%d@%s|%s", pid, node, servicep->name);
2000  sprintf(str,"name: \"%s\", state: \"RUNNING\", id: \"%s\", leaf: true",servicep->name, type_str);
2001  }
2002 */
2003  if(servicep->status == 2)
2004  {
2005  sprintf(type_str,"%d@%s|%s", pid, node, servicep->name);
2006  strcpy(aux, servicep->name);
2007  sptr = strchr(aux,'/');
2008  if(sptr)
2009  {
2010  sptr++;
2011  sptr = strchr(sptr,'/');
2012  if(sptr)
2013  sptr++;
2014  }
2015  strcpy(state, smidomainp[i].state);
2016  stptr = strchr(state,'/');
2017  if(stptr)
2018  {
2019  *stptr = '\0';
2020  }
2021  mode_index = smidomainp[i].mode_index;
2022 // sprintf(str,"name: \"%s\", state: \"%s\", id: \"%s\", leaf: true, fname: \"%s\"",sptr, state, type_str, servicep->name);
2023  sprintf(str,"name: \"%s\", state: \"%s\", mode: \"%s\",id: \"%s\", leaf: true, fname: \"%s\"",
2024  sptr, state, smidomainp[mode_index].state, type_str, servicep->name);
2025 
2026  ptr = addJSONChildStart(ptr,str,0);
2027  n++;
2028  if(n < n_found)
2029  ptr = addJSONChildEnd(ptr,1);
2030  else
2031  ptr = addJSONChildEnd(ptr,0);
2032  }
2033  }
2034  servicep++;
2035  }
2036  ptr = addJSONNodeEnd(ptr);
2037  ptr = addJSONChildEnd(ptr,0);
2038  ptr = addJSONNodeEnd(ptr);
2039  ptr = addJSONEnd(ptr);
2040 printf("%s\n",JSONSmiServices);
2041  return JSONSmiServices;
2042 }
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
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 mode_index
Definition: webDid.c:52
char * JSONSmiServices
Definition: webDid.c:1920
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
int JSONSmiServicesSize
Definition: webDid.c:1921
int status
Definition: dim.h:333
void free(void *mem)
char * addJSONStart(char *ptr)
Definition: webDid.c:1353
int n_services
Definition: dim.h:341
sprintf(name1,"NewService%d", i)
OBJSTATE * smidomainp
Definition: webDid.c:86
char pattern[256]
Definition: webDid.c:78
int findSmiServices(BROWSER *browserp, SERVER *servp)
Definition: webDid.c:2061

+ Here is the call graph for this function:

+ Here is the caller graph for this function: