FACT++  1.0
char* dis_get_client_services ( int  conn_id)

Definition at line 2229 of file dis_old.c.

References dll_get_next(), find_client(), Memory::free(), Memory::malloc(), MAX_NAME, serv::name, reqp_ent::reqp, cli_ent::requestp_head, and req_ent::service_ptr.

Referenced by dis_get_error_services().

2230 {
2231  register REQUEST_PTR *reqpp;
2232  register CLIENT *clip;
2233  register REQUEST *reqp;
2234  register SERVICE *servp;
2235 
2236  int n_services = 0;
2237  int max_size;
2238  static int curr_allocated_size = 0;
2239  static char *service_info_buffer;
2240  char *buff_ptr;
2241 
2242 
2243  if(!conn_id)
2244  return((char *)0);
2245  {
2246  DISABLE_AST;
2247  clip = find_client(conn_id);
2248  if(clip)
2249  {
2250  reqpp = clip->requestp_head;
2251  while( (reqpp = (REQUEST_PTR *) dll_get_next((DLL *)clip->requestp_head,
2252  (DLL *) reqpp)))
2253  {
2254  n_services++;
2255  }
2256  if(!n_services)
2257  {
2258  ENABLE_AST
2259  return((char *)0);
2260  }
2261  max_size = n_services * MAX_NAME;
2262  if(!curr_allocated_size)
2263  {
2264  service_info_buffer = (char *)malloc(max_size);
2265  curr_allocated_size = max_size;
2266  }
2267  else if (max_size > curr_allocated_size)
2268  {
2269  free(service_info_buffer);
2270  service_info_buffer = (char *)malloc(max_size);
2271  curr_allocated_size = max_size;
2272  }
2273  service_info_buffer[0] = '\0';
2274  buff_ptr = service_info_buffer;
2275  reqpp = clip->requestp_head;
2276  while( (reqpp = (REQUEST_PTR *) dll_get_next((DLL *)clip->requestp_head,
2277  (DLL *) reqpp)) )
2278  {
2279  reqp = (REQUEST *) reqpp->reqp;
2280  servp = reqp->service_ptr;
2281  strcat(buff_ptr, servp->name);
2282  strcat(buff_ptr, "\n");
2283  buff_ptr += strlen(buff_ptr);
2284  }
2285  }
2286  else
2287  {
2288  ENABLE_AST
2289  return((char *)0);
2290  }
2291  ENABLE_AST;
2292  }
2293 /*
2294  dim_print_date_time();
2295  dna_get_node_task(conn_id, node, task);
2296  printf("Client %s@%s uses services: \n", task, node);
2297  printf("%s\n",service_info_buffer);
2298 */
2299  return(service_info_buffer);
2300 }
#define MAX_NAME
Definition: dim.h:182
Definition: dis.c:98
char name[MAX_NAME]
Definition: dis.c:72
void * malloc()
Definition: EventBuilder.cc:99
Definition: dim.h:530
Definition: dis.c:69
REQUEST_PTR * requestp_head
Definition: dis.c:102
CLIENT * find_client(int conn_id)
Definition: dis_old.c:2148
struct serv * service_ptr
Definition: dis.c:59
void free(void *mem)
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
Definition: dis.c:92
REQUEST * reqp
Definition: dis.c:95
Definition: dis.c:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function: