FACT++  1.0
int find_services ( char *  wild_name)

Definition at line 1718 of file dns.c.

References count, Curr_n_services, dll_get_next(), i, Memory::malloc(), MAX_HASH_ENTRIES, MAX_NAME, red_serv::serv_name, service_exists(), node::servp, serv::state, and red_serv::state.

Referenced by set_rpc_info().

1719 {
1720 
1721  int i;
1722  RED_DNS_SERVICE *servp;
1723  DNS_SERVICE *servp1;
1724  char tmp[MAX_NAME], *ptr, *ptr1, *dptr, *dptr1;
1725  int match, count = 0;
1726 
1728  malloc((size_t)(Curr_n_services*(int)sizeof(DNS_SERVICE *)));
1729 
1730  if(!strchr(wild_name, '*'))
1731  {
1732  servp1 = service_exists(wild_name);
1733  if(servp1)
1734  {
1735  if(servp1->state == 1)
1736  {
1737  Service_info_list[count] = (DNS_SERVICE *)servp1;
1738  count++;
1739  return 1;
1740  }
1741  }
1742  return 0;
1743  }
1744  for( i = 0; i < MAX_HASH_ENTRIES; i++ )
1745  {
1746  servp = Service_hash_table[i];
1747  while( (servp = (RED_DNS_SERVICE *) dll_get_next(
1748  (DLL *) Service_hash_table[i],
1749  (DLL *) servp)) )
1750  {
1751  ptr = wild_name;
1752  dptr = servp->serv_name;
1753  match = 1;
1754 
1755  while( (ptr1 = strchr(ptr,'*')) )
1756  {
1757  if(ptr1 == ptr)
1758  {
1759  ptr++;
1760  if(!*ptr)
1761  {
1762  dptr = ptr;
1763  break;
1764  }
1765  strcpy(tmp,ptr);
1766  if( (ptr1 = strchr(ptr,'*')) )
1767  {
1768  tmp[ptr1-ptr] = '\0';
1769  }
1770  if( (dptr1 = strstr(dptr, tmp)) )
1771  {
1772  if(!ptr1)
1773  {
1774  dptr = dptr1;
1775  break;
1776  }
1777  dptr1 += (int)strlen(tmp);
1778  ptr = ptr1;
1779  dptr = dptr1;
1780  }
1781  else
1782  {
1783  match = 0;
1784  break;
1785  }
1786  }
1787  else
1788  {
1789  strcpy(tmp,ptr);
1790  tmp[ptr1-ptr] = '\0';
1791  if(!strncmp(dptr, tmp, strlen(tmp)))
1792  {
1793  dptr += (int)strlen(tmp);
1794  ptr = ptr1;
1795  }
1796  else
1797  {
1798  match = 0;
1799  break;
1800  }
1801  }
1802  }
1803  if(strcmp(dptr, ptr))
1804  {
1805  strcpy(tmp,ptr);
1806  strcat(tmp,"/RpcIn");
1807  if(strcmp(dptr, tmp))
1808  match = 0;
1809  }
1810  if(match)
1811  {
1812  if(servp->state == 1)
1813  {
1814  ptr = (char *)servp - (2 * sizeof(void *));
1816  count++;
1817  }
1818  }
1819  }
1820  }
1821  return(count);
1822 }
#define MAX_NAME
Definition: dim.h:182
int i
Definition: db_dim_client.c:21
Definition: dns.c:58
void * malloc()
Definition: EventBuilder.cc:99
int state
Definition: dns.c:63
char serv_name[MAX_NAME]
Definition: dns.c:61
#define MAX_HASH_ENTRIES
Definition: dns.c:23
Definition: dim.h:530
Definition: dis.c:69
int state
Definition: dns.c:51
DNS_SERVICE * service_exists(char *name)
Definition: dns.c:1649
int count
Definition: db_dim_server.c:18
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
static RED_DNS_SERVICE * Service_hash_table[MAX_HASH_ENTRIES]
Definition: dns.c:71
static DNS_SERVICE ** Service_info_list
Definition: dns.c:70
static int Curr_n_services
Definition: dns.c:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function: