librnr/uri.c
char *UriParseHostNew(const char *sHost, char **pHostName, int *pPortNum)
{
  char   *s;    // working host string head pointer
  char   *t;    // working host string tail pointer
  size_t  n;    // size of host string component

  *pHostName  = NULL;
  *pPortNum   = URI_PORT_NONE;

  if( sHost == NULL )
  {
    return NULL;
  }

  if( ((t = strstr(sHost, URI_SEP_PATH)) == NULL) && 
      ((t = strstr(sHost, URI_SEP_QUERY)) == NULL) )
  {
    t = (char *)sHost + strlen(sHost);
  }

  if( (s = strstr(sHost, URI_SEP_PORT)) == NULL )
  {
    s = t;
  }

  n = (size_t)(s - sHost);

  if( n > 0 )
  {
    *pHostName = new_strndup(sHost, n);
  }

  if( s+1 < t )
  {
    *pPortNum = (int)strtol(s+1, NULL, 10);
  }
  
  return t;
}
/*!
 * \brief Parse the host string.
 *
 * If no hostname is specified, NULL is set. If no port number is specified,
 * URI_PORT_NONE is set.
 *
 * \par Format:
 * hostname:port...
 *
 * \param sHost             Host string.
 * \param [out] pHostName   Pointer to the allocated parsed host name string.
 * \param [out] pPortNum    Pointer to the parsed port number.
 *
 * \return
 * Returns pointer to the first character after the host substring. If sHost
 * is NULL, NULL is return. If now URI components follow the host string,
 * will point to the end terminator of sHost.
 */
\brief Parse the host string.
If no hostname is specified, NULL is set. If no port number is specified,
URI_PORT_NONE is set.

\par Format:
hostname:port

\param sHost             Host string.
\param [out] pHostName   Pointer to the allocated parsed host name string.
\param [out] pPortNum    Pointer to the parsed port number.

\return
Returns pointer to the first character after the host substring. If sHost
is NULL, NULL is return. If now URI components follow the host string,
will point to the end terminator of sHost.
\ brief Parse the host string . If no hostname is specified NULL is set . If no port number is specified URI_PORT_NONE is set . \ par Format : hostname : port \ param sHost Host string . \ param [ out ] pHostName Pointer to the allocated parsed host name string . \ param [ out ] pPortNum Pointer to the parsed port number . \ return Returns pointer to the first character after the host substring . If sHost is NULL NULL is return . If now URI components follow the host string will point to the end terminator of sHost .
char *UriParseHostNew(const char *sHost, char **pHostName, int *pPortNum)
{
  char   *s;    
  char   *t;    
  size_t  n;    
  *pHostName  = NULL;
  *pPortNum   = URI_PORT_NONE;
  if( sHost == NULL )
  {
    return NULL;
  }
  if( ((t = strstr(sHost, URI_SEP_PATH)) == NULL) && 
      ((t = strstr(sHost, URI_SEP_QUERY)) == NULL) )
  {
    t = (char *)sHost + strlen(sHost);
  }
  if( (s = strstr(sHost, URI_SEP_PORT)) == NULL )
  {
    s = t;
  }
  n = (size_t)(s - sHost);
  if( n > 0 )
  {
    *pHostName = new_strndup(sHost, n);
  }
  if( s+1 < t )
  {
    *pPortNum = (int)strtol(s+1, NULL, 10);
  }
  return t;
}
char * UriParseHostNew ( const char * sHost , char * * pHostName , int * pPortNum ) { char * s ; char * t ; size_t n ; * pHostName = NULL ; * pPortNum = URI_PORT_NONE ; if ( sHost == NULL ) { return NULL ; } if ( ( ( t = strstr ( sHost , URI_SEP_PATH ) ) == NULL ) && ( ( t = strstr ( sHost , URI_SEP_QUERY ) ) == NULL ) ) { t = ( char * ) sHost + strlen ( sHost ) ; } if ( ( s = strstr ( sHost , URI_SEP_PORT ) ) == NULL ) { s = t ; } n = ( size_t ) ( s - sHost ) ; if ( n > 0 ) { * pHostName = new_strndup ( sHost , n ) ; } if ( s + 1 < t ) { * pPortNum = ( int ) strtol ( s + 1 , NULL , 10 ) ; } return t ; }
\brief Parse the host string.
\ brief Parse the host string .
// working host string head pointer // working host string tail pointer // size of host string component