Logo Search packages:      
Sourcecode: fence-agents version File versions  Download package

static int return_port ( char *  port_s ) [static]

Return port inserted in string. Fuction tests, if port is integer, and than return integer value of string. Otherwise, it will use /etc/services. On fail, it returns port -1.

Parameters:
port_sInput port or service name
Returns:
port number (converted with ntohs) on success, otherwise -1.

Definition at line 42 of file fence_nss_wrapper.c.

Referenced by main().

                                     {
  char *end_c;
  int res;
  struct servent *serv;

  res=strtol(port_s,&end_c,10);

  if (*end_c=='\0') return res;

  /*It's not number, so try service name*/
  serv=getservbyname(port_s,NULL);

  if (serv==NULL) return -1;

  return ntohs(serv->s_port);
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index