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

Definition at line 1296 of file dns.c.

References Curr_N_Conns, Dns_conns, Memory::free(), i, Last_conn_id, DNS_CONNECTION::long_task_name, Memory::malloc(), MAX_NAME, MAX_TASK_NAME, DNS_CONNECTION::n_services, DNS_CONNECTION::node_name, DNS_CONNECTION::pid, sprintf(), and SRC_DIS.

Referenced by main().

1297 {
1298  static int curr_allocated_size = 0;
1299  static char *info_buffer;
1300  static int *pid_buffer, pid_size;
1301  int pid_index = 0;
1302  DNS_CONNECTION *connp;
1303  int i, max_size, max_pid_size/*, j, n*/;
1304  int n_server = 0;
1305  char /*aux[MAX_NAME], *ptr, */ server[MAX_NAME], *info_buffer_ptr;
1306 /*
1307  DNS_SERVICE *servp;
1308  int find_services();
1309 */
1310 
1311  DISABLE_AST
1312  if(tag){}
1313  for( i = 0; i< Curr_N_Conns; i++ )
1314  {
1315  if( Dns_conns[i].src_type == SRC_DIS )
1316  {
1317  n_server++;
1318  }
1319  }
1320  max_size = ((int)sizeof(DNS_SERVER_INFO) + MAX_TASK_NAME) * n_server;
1321  max_pid_size = (int)sizeof(int) * n_server;
1322  if(!curr_allocated_size)
1323  {
1324  info_buffer = (char *)malloc((size_t)max_size);
1325  curr_allocated_size = max_size;
1326  pid_buffer = (int *)malloc((size_t)max_pid_size);
1327  }
1328  else if (max_size > curr_allocated_size)
1329  {
1330  free(info_buffer);
1331  info_buffer = (char *)malloc((size_t)max_size);
1332  curr_allocated_size = max_size;
1333  free(pid_buffer);
1334  pid_buffer = (int *)malloc((size_t)max_pid_size);
1335  }
1336  info_buffer[0] = '\0';
1337  pid_buffer[0] = 0;
1338 
1339  info_buffer_ptr = info_buffer;
1340  if(*first_time)
1341  {
1342  for( i = 0; i< Curr_N_Conns; i++ )
1343  {
1344  if( Dns_conns[i].src_type == SRC_DIS )
1345  {
1346  connp = &Dns_conns[i];
1347 /*
1348  if((int)strlen(connp->task_name) == MAX_TASK_NAME-4-1)
1349  {
1350  strcpy(aux,connp->task_name);
1351  strcat(aux,"--CLIENT_LIST");
1352  n = find_services(aux);
1353  for(j = 0; j < n; j++)
1354  {
1355  servp = Service_info_list[j];
1356  if(i == servp->conn_id)
1357  {
1358  strcpy(aux,servp->serv_name);
1359  ptr = strstr(aux,"/CLIENT_LIST");
1360  if(ptr)
1361  *ptr = '\0';
1362  break;
1363  }
1364  }
1365  free(Service_info_list);
1366  strcpy(server, aux);
1367  }
1368  else
1369  {
1370 */
1371  strcpy(server, connp->long_task_name);
1372 /*
1373  }
1374 */
1375  strcat(server,"@");
1376  strcat(server, connp->node_name);
1377  strcat(server,"|");
1378  strcpy(info_buffer_ptr, server);
1379  info_buffer_ptr += (int)strlen(server);
1380  pid_buffer[pid_index] = connp->pid;
1381  pid_index++;
1382  }
1383  }
1384  }
1385  else
1386  {
1387  connp = &Dns_conns[Last_conn_id];
1388  if(connp->n_services > 0)
1389  strcat(info_buffer, "+");
1390  else if(connp->n_services == -1)
1391  strcat(info_buffer, "!");
1392  else
1393  strcat(info_buffer, "-");
1394  strcat(info_buffer, connp->long_task_name);
1395  strcat(info_buffer,"@");
1396  strcat(info_buffer, connp->node_name);
1397  strcat(info_buffer,"|");
1398  pid_buffer[pid_index] = connp->pid;
1399  pid_index++;
1400  }
1401  info_buffer[(int)strlen(info_buffer) - 1] = '\0';
1402  info_buffer_ptr = &info_buffer[(int)strlen(info_buffer)+1];
1403  pid_size = 0;
1404  for(i = 0; i < pid_index; i++)
1405  {
1406  if(i != (pid_index -1))
1407  sprintf(server, "%d|",pid_buffer[i]);
1408  else
1409  sprintf(server, "%d",pid_buffer[i]);
1410  strcpy(info_buffer_ptr, server);
1411  info_buffer_ptr += (int)strlen(server);
1412  pid_size += (int)strlen(server);
1413  }
1414  *bufp = (int *)info_buffer;
1415  *size = (int)strlen(info_buffer)+1+pid_size+1;
1416  ENABLE_AST
1417 }
char node_name[MAX_NODE_NAME]
Definition: dim.h:431
#define MAX_NAME
Definition: dim.h:182
DllExp DIM_NOSHARE int Curr_N_Conns
Definition: conn_handler.c:33
DllExp DIM_NOSHARE DNS_CONNECTION * Dns_conns
Definition: conn_handler.c:29
int i
Definition: db_dim_client.c:21
void * malloc()
Definition: EventBuilder.cc:99
int pid
Definition: dim.h:434
static int Last_conn_id
Definition: dns.c:74
#define MAX_TASK_NAME
Definition: dim.h:181
int n_services
Definition: dim.h:440
int size
Definition: db_dim_server.c:17
void free(void *mem)
char long_task_name[MAX_NAME]
Definition: dim.h:444
sprintf(name1,"NewService%d", i)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: