Logo Search packages:      
Sourcecode: kbiff version File versions

QString KBiffURL::searchPar ( const QString &  _parName  )  const

Returns the parameter value found in the search part of the URL

BNF description of the syntax (see RFC1738, HTTP syntax) ; HTTP

httpurl = "http://" hostport [ "/" hpath [ "?" search ]] hpath = hsegment *[ "/" hsegment ] hsegment = *[ uchar | ";" | ":" | "@" | "&" | "=" ] search = *[ uchar | ";" | ":" | "@" | "&" | "=" ]

Definition at line 41 of file kbiffurl.cpp.

References findPos().

Referenced by KBiffMonitor::setMailbox().

{
  const char *_searchPart, *_searchPos, *_parVal;
  int n;

  // Set some initial values
  n = 0;
  _parVal = NULL;

  // Get the search part of the URL, i.e. the stuff after "?"
  QString query_str(query());
  if (!query_str.isNull())
    query_str = query_str.remove(0,1);
  _searchPart = query_str.ascii();

  // Try to find the given parameter in the search part string
  if ((n = findPos( _searchPart, _parName )) < 0)
    return QString::null;

  /*
   * Now, we know that the parameter name is found
   */

  // If no value is assigned, an empty string is returned
  if (_searchPart[n] != '=')
    return QString::null;

  // Set the beginning of the parameter value string
  _parVal = &(_searchPart[n+1]);

  // Find the end of the assigned parameter value
  _searchPos = strpbrk( _parVal, ";:@&=" );

  // Return the assigned parameter value
  if (_searchPos == NULL)
    return QString( _parVal );
  else
    return QString( _parVal ).left(_searchPos - _parVal);
}


Generated by  Doxygen 1.6.0   Back to index