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

Definition at line 2956 of file dis.c.

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

2957 {
2958  register SERVICE *servp;
2959  int max_size, done = 0;
2960  static int curr_allocated_size = 0;
2961  static char *service_info_buffer;
2962  char *buff_ptr;
2963  DIS_DNS_CONN *dnsp = (DIS_DNS_CONN *)*tag;
2964  int hash_index;
2965 
2966  DISABLE_AST
2967  max_size = (dnsp->dis_n_services+10) * (MAX_NAME*2 + 4);
2968  if(!curr_allocated_size)
2969  {
2970  service_info_buffer = (char *)malloc((size_t)max_size);
2971  curr_allocated_size = max_size;
2972  }
2973  else if (max_size > curr_allocated_size)
2974  {
2975  free(service_info_buffer);
2976  service_info_buffer = (char *)malloc((size_t)max_size);
2977  curr_allocated_size = max_size;
2978  }
2979  service_info_buffer[0] = '\0';
2980  buff_ptr = service_info_buffer;
2981  servp = 0;
2982  hash_index = -1;
2983  if(*first_time)
2984  {
2985  while( (servp = dis_hash_service_get_next(&hash_index, servp, 0)) )
2986  {
2987  if(servp->dnsp != dnsp)
2988  continue;
2989  if(servp->registered)
2990  {
2991 /*
2992  servp->registered = 2;
2993 */
2994  if((dnsp->updating_service_list) && (Last_n_clients > 1) &&
2995  (servp->registered == 1))
2996  continue;
2997  servp->registered = Last_n_clients+1;
2998  append_service(buff_ptr, servp);
2999  buff_ptr += (int)strlen(buff_ptr);
3000  }
3001  }
3002  }
3003  else
3004  {
3005  while( (servp = dis_hash_service_get_next(&hash_index, servp, 0)) )
3006  {
3007  if(servp->dnsp != dnsp)
3008  continue;
3009 /*
3010  if(servp->registered == 1)
3011 */
3012  if(servp->registered == 0)
3013  {
3014  strcat(buff_ptr, "-");
3015  buff_ptr += (int)strlen(buff_ptr);
3016  append_service(buff_ptr, servp);
3017  buff_ptr += (int)strlen(buff_ptr);
3018  }
3019  else if(servp->registered < (Last_n_clients+1))
3020  {
3021  if(!done)
3022  {
3023  strcat(buff_ptr, "+");
3024  buff_ptr += (int)strlen(buff_ptr);
3025  done = 1;
3026  }
3027  append_service(buff_ptr, servp);
3028  buff_ptr += (int)strlen(buff_ptr);
3029 /*
3030  servp->registered = 2;
3031 */
3032  servp->registered++;
3033  }
3034  }
3035  }
3036  *bufp = (int *)service_info_buffer;
3037  *size = (int)(buff_ptr - service_info_buffer+1);
3038  if(*size == 1)
3039  *size = -1;
3040  ENABLE_AST
3041 }
#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.c:3315
int registered
Definition: dis.c:81
void * malloc()
Definition: EventBuilder.cc:99
int dis_n_services
Definition: dis.c:43
int updating_service_list
Definition: dis.c:49
void append_service(char *service_info_buffer, SERVICE *servp)
Definition: dis.c:2900
Definition: dis.c:69
int size
Definition: db_dim_server.c:17
void free(void *mem)
static int Last_n_clients
Definition: dis.c:150

+ Here is the call graph for this function: