FACT++  1.0
char* dic_get_server_services ( int  conn_id)

Definition at line 2238 of file dic.c.

References Dic_conns, dll_get_next(), Memory::free(), Memory::malloc(), MAX_NAME, dic_serv::serv_name, and DIC_CONNECTION::service_head.

Referenced by dic_get_error_services(), DimClient::getServerServices(), and Java_dim_Client_getServices().

2239 {
2240  DIC_SERVICE *servp;
2241  DIC_CONNECTION *dic_connp;
2242  int n_services = 0;
2243  int max_size;
2244  static int curr_allocated_size = 0;
2245  static char *service_info_buffer;
2246  char *buff_ptr;
2247 
2248 
2249  if(!conn_id)
2250  return((char *)0);
2251  dic_connp = &Dic_conns[conn_id];
2252  if( (servp = (DIC_SERVICE *) dic_connp->service_head) )
2253  {
2254  while( (servp = (DIC_SERVICE *) dll_get_next(
2255  (DLL *) dic_connp->service_head,
2256  (DLL *) servp)) )
2257  {
2258  n_services++;
2259  }
2260  if(!n_services)
2261  return((char *)0);
2262  max_size = n_services * MAX_NAME;
2263  if(!curr_allocated_size)
2264  {
2265  service_info_buffer = (char *)malloc((size_t)max_size);
2266  curr_allocated_size = max_size;
2267  }
2268  else if (max_size > curr_allocated_size)
2269  {
2270  free(service_info_buffer);
2271  service_info_buffer = (char *)malloc((size_t)max_size);
2272  curr_allocated_size = max_size;
2273  }
2274  service_info_buffer[0] = '\0';
2275  buff_ptr = service_info_buffer;
2276 
2277  servp = (DIC_SERVICE *) dic_connp->service_head;
2278  while( (servp = (DIC_SERVICE *) dll_get_next(
2279  (DLL *) dic_connp->service_head,
2280  (DLL *) servp)) )
2281  {
2282  strcat(buff_ptr, servp->serv_name);
2283  strcat(buff_ptr, "\n");
2284  buff_ptr += (int)strlen(buff_ptr);
2285  }
2286  }
2287  else
2288  {
2289  return((char *)0);
2290  }
2291 /*
2292  dim_print_date_time();
2293  printf("Server %s@%s provides services:\n",
2294  dic_connp->task_name, dic_connp->node_name);
2295  printf("%s\n",service_info_buffer);
2296 */
2297  return(service_info_buffer);
2298 }
#define MAX_NAME
Definition: dim.h:182
DIM_NOSHARE DIC_CONNECTION * Dic_conns
Definition: conn_handler.c:30
char * service_head
Definition: dim.h:424
void * malloc()
Definition: EventBuilder.cc:99
Definition: dim.h:530
Definition: dim.h:457
void free(void *mem)
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
char serv_name[MAX_NAME]
Definition: dim.h:460

+ Here is the call graph for this function:

+ Here is the caller graph for this function: