FACT++  1.0
void update_servers ( int *  tag,
DNS_DID buffer,
int *  size 
)

Definition at line 2285 of file didMarkus.c.

References item::busy, item::button_id, find_server(), First_time, Force_update, Memory::free(), Memory::malloc(), MAX_NAME, MAX_TASK_NAME, DNS_SERVICE_INFO::n_clients, N_servers, N_services, DNS_SERVER_INFO::n_services, item::name, DNS_SERVICE_INFO::name, item::next, DNS_SERVER_INFO::node, DNS_SERVER_INFO::pid, item::pop_widget_id, item::server, DNS_DID::server, Server_head, item::service_ptr, DNS_DID::services, sll_init(), sll_insert_queue(), DNS_SERVICE_INFO::status, str, switch_matrix(), DNS_SERVER_INFO::task, and DNS_SERVICE_INFO::type.

Referenced by app_initialize().

2286 {
2287 int n_services, service_size;
2288 SERVER *servp;
2289 int j;
2290 char str[MAX_NAME], sname[MAX_NAME], *ptr;
2291 
2292  if(tag){}
2293  if(!Server_head)
2294  {
2295  Server_head = (SERVER *)malloc(sizeof(SERVER));
2296  sll_init((SLL *)Server_head);
2297  }
2298  if(First_time)
2299  {
2300  switch_matrix();
2301  First_time = 0;
2302  }
2303 
2304  if(!*size)
2305  return;
2306  if(*(char *)buffer == -1)
2307  {
2308  N_servers = 0;
2309  N_services = 0;
2310  return;
2311  }
2312  buffer->server.n_services = vtohl(buffer->server.n_services);
2313  buffer->server.pid = vtohl(buffer->server.pid);
2314  n_services = buffer->server.n_services;
2315 
2316  if(n_services == 1)
2317  return;
2318  strcpy(sname, buffer->server.task);
2319  if(n_services > 1)
2320  {
2321  for(j = 0; j < n_services; j++)
2322  {
2323  buffer->services[j].type = vtohl(
2324  buffer->services[j].type);
2325  buffer->services[j].status = vtohl(
2326  buffer->services[j].status);
2327  buffer->services[j].n_clients = vtohl(
2328  buffer->services[j].n_clients);
2329  if(strlen(sname) == MAX_TASK_NAME-4-1)
2330  {
2331  strcpy(str,buffer->services[j].name);
2332  if( (ptr = strstr(str,"/CLIENT_LIST")) )
2333  {
2334  *ptr = '\0';
2335  strcpy(sname,str);
2336  }
2337  }
2338  }
2339  }
2340  if (!(servp = find_server(buffer->server.node,buffer->server.pid)))
2341  /*
2342  if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2343  (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2344  */
2345  {
2346  if(n_services)
2347  {
2348  servp = (SERVER *)malloc(sizeof(SERVER));
2349  strcpy(servp->name,sname);
2350  servp->next = 0;
2351  servp->button_id = 0;
2352  servp->pop_widget_id[0] = 0;
2353  servp->pop_widget_id[1] = 0;
2354  servp->busy = 0;
2355  servp->server.n_services = 0;
2356  servp->service_ptr = 0;
2357  sll_insert_queue((SLL *)Server_head,(SLL *)servp);
2358  }
2359  }
2360  if(n_services != 0)
2361  {
2362  if(n_services == servp->server.n_services)
2363  {
2364  return;
2365  }
2366  if(servp->server.n_services == 0)
2367  N_servers++;
2368  if(servp->server.n_services != -1)
2369  N_services -= servp->server.n_services;
2370  memcpy(&servp->server,&buffer->server,sizeof(DNS_SERVER_INFO));
2371  if(servp->service_ptr)
2372  {
2373  free(servp->service_ptr);
2374  servp->service_ptr = 0;
2375  }
2376  if(n_services != -1)
2377  {
2378  service_size = n_services*sizeof(DNS_SERVICE_INFO);
2379  servp->service_ptr = (DNS_SERVICE_INFO *)malloc(service_size);
2380  memcpy(servp->service_ptr, buffer->services, service_size);
2381  N_services += n_services;
2382  }
2383  servp->busy = 1;
2384  }
2385  else
2386  {
2387  if(servp)
2388  {
2389  N_servers--;
2390  if(servp->server.n_services != -1)
2391  {
2392  N_services -= servp->server.n_services;
2393  }
2394  else
2395  Force_update = 1;
2396  servp->server.n_services = 0;
2397  servp->busy = -1;
2398  }
2399  }
2400 }
#define MAX_NAME
Definition: dim.h:182
int busy
Definition: did.h:52
Definition: did.h:42
Widget button_id
Definition: did.h:47
char str[80]
Definition: test_client.c:7
char node[MAX_NODE_NAME]
Definition: dim.h:338
int N_services
Definition: didMarkus.c:16
int n_clients
Definition: dim.h:334
void * malloc()
Definition: EventBuilder.cc:99
char task[MAX_TASK_NAME]
Definition: dim.h:339
int N_servers
Definition: didMarkus.c:15
SERVER * Server_head
Definition: did.h:55
char name[132]
Definition: did.h:46
DNS_SERVER_INFO server
Definition: dim.h:345
Definition: dim.h:536
Widget pop_widget_id[2]
Definition: did.h:48
int First_time
Definition: didMarkus.c:9
void sll_init(SLL *head)
Definition: sll.c:14
int sll_insert_queue(SLL *head, SLL *item)
Definition: sll.c:20
DNS_SERVICE_INFO * service_ptr
Definition: did.h:45
char name[MAX_NAME]
Definition: dim.h:331
#define MAX_TASK_NAME
Definition: dim.h:181
struct item * next
Definition: did.h:43
void switch_matrix()
Definition: didMarkus.c:2241
DNS_SERVER_INFO server
Definition: did.h:44
int status
Definition: dim.h:333
SERVER * find_server(char *node, int pid)
Definition: didMarkus.c:2263
int size
Definition: db_dim_server.c:17
void free(void *mem)
int Force_update
Definition: didMarkus.c:36
int n_services
Definition: dim.h:341
DNS_SERVICE_INFO services[1]
Definition: dim.h:346

+ Here is the call graph for this function:

+ Here is the caller graph for this function: