FACT++  1.0
void update_show_servers ( void *  tag,
unsigned long *  reason 
)

Definition at line 2464 of file did.c.

References app_context, item::busy, item::button_id, create_button(), Curr_matrix, Curr_view_opt, Curr_view_opt_par, Force_update, Memory::free(), get_something(), GREEN, i, Matrix_id, MAX_NODE_NAME, N_servers, N_services, DNS_SERVER_INFO::n_services, item::name, DNS_SERVICE_INFO::name, No_link_button_id, DNS_SERVER_INFO::node, put_label(), RED, remove_all_buttons(), remove_button(), item::server, Server_head, item::service_ptr, set_color(), sll_empty(), sll_get_next(), sll_remove(), and sll_remove_head().

Referenced by app_initialize(), and show_servers().

2465 {
2466 DNS_SERVER_INFO *server_ptr;
2467 DNS_SERVICE_INFO *service_ptr;
2468 int i, j, found, n_done = 0;
2469 Widget w, create_button();
2470 SERVER *servp, *prevp;
2471 static int old_n_services = 0;
2472 char node[MAX_NODE_NAME], par[MAX_NODE_NAME], *ptr;
2473 void remove_button();
2474 void remove_all_buttons();
2475 void put_label();
2476 
2477  DISABLE_AST
2478  if(tag){}
2479  if(reason){}
2480  if((N_services != old_n_services) || (Force_update))
2481  {
2482  if(!Matrix_id[Curr_matrix])
2483  {
2484  XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2485  ENABLE_AST
2486  return;
2487  }
2488  if(!N_servers)
2489  {
2491  if(! No_link_button_id)
2492  {
2493  No_link_button_id = create_button("DNS is down", 0);
2494  set_color(No_link_button_id, XmNbackground, RED);
2495  get_something(No_link_button_id,XmNuserData,&w);
2496  set_color(w, XmNbackground, RED);
2497  XtSetSensitive(No_link_button_id, False);
2498  }
2499  while(!sll_empty((SLL *)Server_head))
2500  {
2501  servp = (SERVER *)sll_remove_head((SLL *)Server_head);
2502  if(servp->service_ptr)
2503  free(servp->service_ptr);
2504  free(servp);
2505  }
2506  put_label();
2507  old_n_services = N_services;
2508  Force_update = 0;
2509  XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2510  ENABLE_AST
2511  return;
2512  }
2513  if(No_link_button_id)
2514  {
2515  XtDestroyWidget(No_link_button_id);
2516  /*
2517  XFlush(XtDisplay(No_link_button_id));
2518  */
2519  No_link_button_id = 0;
2520  }
2521  servp = Server_head;
2522  prevp = 0;
2523  while( (servp = (SERVER *)sll_get_next((SLL *)servp)) )
2524  {
2525  if(prevp)
2526  {
2527  free(prevp);
2528  prevp = 0;
2529  }
2530  if(n_done == 10)
2531  {
2532  if(!Force_update)
2533  put_label();
2534  XtAppAddTimeOut(app_context, 100, update_show_servers, 0);
2535  ENABLE_AST
2536  return;
2537  }
2538  server_ptr = &servp->server;
2539  if(servp->busy == 3)
2540  {
2541  remove_button(servp);
2542  servp->busy = 1;
2543  }
2544  if(servp->busy == 1)
2545  {
2546  if(!servp->button_id)
2547  {
2548  switch(Curr_view_opt)
2549  {
2550  case 1 :
2551  servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2552  n_done++;
2553  break;
2554  case 0 :
2555  strcpy(node, server_ptr->node);
2556  strcpy(par, Curr_view_opt_par);
2557  if(!isdigit(node[0]))
2558  {
2559  ptr = strchr(node, '.');
2560  if(ptr)
2561  *ptr = '\0';
2562  ptr = strchr(par,'.');
2563  if(ptr)
2564  *ptr = '\0';
2565  }
2566  ptr = node;
2567  for(i = 0; i < (int)strlen(ptr); i++)
2568  ptr[i] = (char)tolower((int)ptr[i]);
2569  ptr = par;
2570  for(i = 0; i < (int)strlen(ptr); i++)
2571  ptr[i] = (char)tolower((int)ptr[i]);
2572  if(!strcmp(/*server_ptr->*/node, /*Curr_view_opt_*/par))
2573  {
2574  servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2575  n_done++;
2576  }
2577  break;
2578  case 2 :
2579  found = 0;
2580  if(!(service_ptr = servp->service_ptr))
2581  break;
2582  for(j = 0; j < server_ptr->n_services; j++)
2583  {
2584  if(strstr(service_ptr->name, Curr_view_opt_par) > (char *)0)
2585  {
2586  found = 1;
2587  break;
2588  }
2589  service_ptr++;
2590  }
2591  if (found)
2592  {
2593  servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2594  n_done++;
2595  }
2596  break;
2597  case 3 :
2598  if(server_ptr->n_services == -1)
2599  {
2600  servp->button_id = create_button(/*server_ptr->task*/servp->name, servp);
2601  n_done++;
2602  }
2603  else
2604  {
2605  if(servp->button_id)
2606  remove_button(servp);
2607  }
2608  n_done++;
2609  break;
2610  }
2611  }
2612  servp->busy = 2;
2613  if(servp->button_id)
2614  {
2615  if(Curr_view_opt != -1)
2616  {
2617  if (server_ptr->n_services == -1)
2618  {
2619  set_color(servp->button_id, XmNbackground, RED);
2620  get_something(servp->button_id,XmNuserData,&w);
2621  set_color(w, XmNbackground, RED);
2622  }
2623  else
2624  {
2625  set_color(servp->button_id, XmNbackground, GREEN);
2626  get_something(servp->button_id,XmNuserData,&w);
2627  set_color(w, XmNbackground, GREEN);
2628  }
2629  }
2630  }
2631  }
2632  else if (servp->busy == -1)
2633  {
2634  remove_button(servp);
2635  sll_remove((SLL *)Server_head, (SLL *)servp);
2636  if(servp->service_ptr)
2637  {
2638  free(servp->service_ptr);
2639  servp->service_ptr = 0;
2640  }
2641  prevp = servp;
2642  n_done++;
2643  }
2644  }
2645  if(prevp)
2646  {
2647  free(prevp);
2648  prevp = 0;
2649  }
2650  put_label();
2651  old_n_services = N_services;
2652  Force_update = 0;
2653  }
2654  XtAppAddTimeOut(app_context, 1000, update_show_servers, 0);
2655  ENABLE_AST
2656 }
Definition: dns.c:26
int N_services
Definition: did.c:16
Widget Matrix_id[2]
Definition: did.h:57
int busy
Definition: did.h:52
void remove_button(SERVER *servp)
Definition: did.c:2759
Definition: did.h:42
int i
Definition: db_dim_client.c:21
Widget button_id
Definition: did.h:47
void set_color()
char node[MAX_NODE_NAME]
Definition: dim.h:338
void get_something()
void remove_all_buttons()
Definition: did.c:2743
XtAppContext app_context
Definition: did.h:38
int Force_update
Definition: did.c:36
Widget No_link_button_id
Definition: did.h:63
SERVER * Server_head
Definition: did.h:55
char name[132]
Definition: did.h:46
SLL * sll_get_next(SLL *item)
Definition: sll.c:50
Definition: dim.h:536
void put_label()
Definition: did.c:3183
SLL * sll_remove_head(SLL *head)
Definition: sll.c:94
char Curr_view_opt_par[80]
Definition: did.c:11
DNS_SERVICE_INFO * service_ptr
Definition: did.h:45
char name[MAX_NAME]
Definition: dim.h:331
int sll_remove(SLL *head, SLL *item)
Definition: sll.c:74
int Curr_view_opt
Definition: did.c:10
DNS_SERVER_INFO server
Definition: did.h:44
void free(void *mem)
#define MAX_NODE_NAME
Definition: dim.h:180
int Curr_matrix
Definition: did.h:58
int n_services
Definition: dim.h:341
void update_show_servers(void *tag, unsigned long *reason)
Definition: did.c:2464
int sll_empty(SLL *head)
Definition: sll.c:60
Definition: dui_colors.h:4
int N_servers
Definition: did.c:15
Widget create_button(char *name, SERVER *servp)
Definition: did.c:2658

+ Here is the call graph for this function:

+ Here is the caller graph for this function: