FACT++  1.0
void service_info ( long *  tag,
int **  bufp,
int *  size,
int *  first_time 
)

Definition at line 2646 of file dis_old.c.

References append_service(), dis_hash_service_get_next(), dis_dns_ent::dis_n_services, serv::dnsp, Memory::free(), Memory::malloc(), MAX_NAME, and serv::registered.

2647 {
2648  register SERVICE *servp;
2649  int max_size, done = 0;
2650  static int curr_allocated_size = 0;
2651  static char *service_info_buffer;
2652  char *buff_ptr;
2653  DIS_DNS_CONN *dnsp = (DIS_DNS_CONN *)*tag;
2654  int hash_index;
2655 
2656  DISABLE_AST
2657  max_size = (dnsp->dis_n_services+10) * (MAX_NAME*2 + 4);
2658  if(!curr_allocated_size)
2659  {
2660  service_info_buffer = (char *)malloc(max_size);
2661  curr_allocated_size = max_size;
2662  }
2663  else if (max_size > curr_allocated_size)
2664  {
2665  free(service_info_buffer);
2666  service_info_buffer = (char *)malloc(max_size);
2667  curr_allocated_size = max_size;
2668  }
2669  service_info_buffer[0] = '\0';
2670  buff_ptr = service_info_buffer;
2671  servp = 0;
2672  hash_index = -1;
2673  if(*first_time)
2674  {
2675  while( (servp = dis_hash_service_get_next(&hash_index, servp, 0)) )
2676  {
2677  if(servp->dnsp != dnsp)
2678  continue;
2679  if(servp->registered)
2680  {
2681  servp->registered = 2;
2682  append_service(buff_ptr, servp);
2683  buff_ptr += strlen(buff_ptr);
2684  }
2685  }
2686  }
2687  else
2688  {
2689  while( (servp = dis_hash_service_get_next(&hash_index, servp, 0)) )
2690  {
2691  if(servp->dnsp != dnsp)
2692  continue;
2693  if(servp->registered == 1)
2694  {
2695  if(!done)
2696  {
2697  strcat(buff_ptr, "+");
2698  buff_ptr += strlen(buff_ptr);
2699  done = 1;
2700  }
2701  append_service(buff_ptr, servp);
2702  buff_ptr += strlen(buff_ptr);
2703  servp->registered = 2;
2704  }
2705  else if(servp->registered == 0)
2706  {
2707  strcat(buff_ptr, "-");
2708  buff_ptr += strlen(buff_ptr);
2709  append_service(buff_ptr, servp);
2710  buff_ptr += strlen(buff_ptr);
2711  }
2712  }
2713  }
2714  *bufp = (int *)service_info_buffer;
2715  *size = buff_ptr - service_info_buffer+1;
2716  ENABLE_AST
2717 }
#define MAX_NAME
Definition: dim.h:182
DIS_DNS_CONN * dnsp
Definition: dis.c:87
SERVICE * dis_hash_service_get_next(int *curr_index, SERVICE *prevp, int new_entries)
Definition: dis_old.c:2920
int registered
Definition: dis.c:81
void * malloc()
Definition: EventBuilder.cc:99
int dis_n_services
Definition: dis.c:43
void append_service(char *service_info_buffer, SERVICE *servp)
Definition: dis_old.c:2590
Definition: dis.c:69
int size
Definition: db_dim_server.c:17
void free(void *mem)

+ Here is the call graph for this function: