(xdrproc_t) xdr_domainname, &domain,
(xdrproc_t) xdr_domainname, (caddr_t) &domain,
__yp_bind (const char *domain, dom_binding ** ypdb){  struct sockaddr_in clnt_saddr;  struct ypbind_resp ypbr;  dom_binding *ysd;  int clnt_sock;  CLIENT *client;  int is_new = 0;  int try;  if (ypdb != NULL)    *ypdb = NULL;  if ((domain == NULL) || (strlen (domain) == 0))    return YPERR_BADARGS;  ysd = __ypbindlist;  while (ysd != NULL)    {      if (strcmp (domain, ysd->dom_domain) == 0)        break;      ysd = ysd->dom_pnext;    }  if (ysd == NULL)    {      is_new = 1;      ysd = (dom_binding *) malloc (sizeof *ysd);      memset (ysd, '\0', sizeof *ysd);      ysd->dom_socket = -1;      ysd->dom_vers = -1;    }  try = 0;  do    {      try++;      if (try > MAXTRIES)        {          if (is_new)            free (ysd);          return YPERR_YPBIND;        }      if (ysd->dom_vers == -1)        {          if(ysd->dom_client)            {              clnt_destroy(ysd->dom_client);              ysd->dom_client = NULL;              ysd->dom_socket = -1;            }          memset (&clnt_saddr, '\0', sizeof clnt_saddr);          clnt_saddr.sin_family = AF_INET;          clnt_saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);          clnt_sock = RPC_ANYSOCK;          client = clnttcp_create (&clnt_saddr, YPBINDPROG, YPBINDVERS,                                   &clnt_sock, 0, 0);          if (client == NULL)            {              if (is_new)                free (ysd);              return YPERR_YPBIND;            }          /*          ** Check the port number -- should be < IPPORT_RESERVED.          ** If not, it's possible someone has registered a bogus          ** ypbind with the portmapper and is trying to trick us.          */          if (ntohs(clnt_saddr.sin_port) >= IPPORT_RESERVED)            {              clnt_destroy(client);              if (is_new)                free(ysd);              return(YPERR_YPBIND);            }          if (clnt_call (client, YPBINDPROC_DOMAIN,                         (xdrproc_t) xdr_domainname, &domain,                         (xdrproc_t) xdr_ypbind_resp,                         &ypbr, TIMEOUT) != RPC_SUCCESS)            {              clnt_destroy (client);              if (is_new)                free (ysd);              return YPERR_YPBIND;            }          clnt_destroy (client);          if (ypbr.ypbind_status != YPBIND_SUCC_VAL)            {              switch (ypbr.ypbind_resp_u.ypbind_error)                {                case YPBIND_ERR_ERR:                  fputs (_("YPBINDPROC_DOMAIN: Internal error\n"), stderr);                  break;                case YPBIND_ERR_NOSERV:                  fprintf (stderr,                           _("YPBINDPROC_DOMAIN: No server for domain %s\n"),                           domain);                  break;                case YPBIND_ERR_RESC:                  fputs (_("YPBINDPROC_DOMAIN: Resource allocation failure\n"),                         stderr);                  break;                default:                  fputs (_("YPBINDPROC_DOMAIN: Unknown error\n"), stderr);                  break;                }              if (is_new)                free (ysd);              return YPERR_DOMAIN;            }          memset (&ysd->dom_server_addr, '\0', sizeof ysd->dom_server_addr);          ysd->dom_server_addr.sin_family = AF_INET;          memcpy (&ysd->dom_server_addr.sin_port,                  ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port,                  sizeof (ysd->dom_server_addr.sin_port));          memcpy (&ysd->dom_server_addr.sin_addr.s_addr,                  ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,                  sizeof (ysd->dom_server_addr.sin_addr.s_addr));          ysd->dom_vers = YPVERS;          strncpy (ysd->dom_domain, domain, YPMAXDOMAIN);	  ysd->dom_domain[YPMAXDOMAIN] = '\0';        }      if (ysd->dom_client)        clnt_destroy (ysd->dom_client);      ysd->dom_socket = RPC_ANYSOCK;      ysd->dom_client = clntudp_create (&ysd->dom_server_addr, YPPROG, YPVERS,                                        TIMEOUT, &ysd->dom_socket);      if (ysd->dom_client == NULL)        ysd->dom_vers = -1;    }  while (ysd->dom_client == NULL);  /* If the program exists, close the socket */  if (fcntl (ysd->dom_socket, F_SETFD, 1) == -1)    perror (_("fcntl: F_SETFD"));  if (is_new)    {      ysd->dom_pnext = __ypbindlist;      __ypbindlist = ysd;    }  if (NULL != ypdb)    *ypdb = ysd;  return YPERR_SUCCESS;}