void main() { char *query = (char *)malloc(sizeof(char)*200); gets(query); queryParser(query); getche(); }
void QueryParamList::BulidList( StrPtrLen* querySPL ) { // parse the string and build the name/value list from the tokens. // the string is a 'form' encoded query string ( see rfc - 1808 ) StringParser queryParser( querySPL ); while ( queryParser.GetDataRemaining() > 0 ) { StrPtrLen theCGIParamName; StrPtrLen theCGIParamValue; queryParser.ConsumeUntil(&theCGIParamName, '='); // leaves "=..." in cgiParser, puts item keywd in theCGIParamName if ( queryParser.GetDataRemaining() > 1 ) { queryParser.ConsumeLength(&theCGIParamValue, 1 ); // the '=' queryParser.ConsumeUntil(&theCGIParamValue, '&'); // our value will end by here... AddNameValuePairToList( theCGIParamName.GetAsCString(), theCGIParamValue.GetAsCString() ); queryParser.ConsumeLength(&theCGIParamValue, 1 ); // the '=' } } }
void QueryParamList::BulidList( StrPtrLen* querySPL ) { // parse the string and build the name/value list from the tokens. // the string is a 'form' encoded query string ( see rfc - 1808 ) StringParser queryParser( querySPL ); char *stopCharPtr = NULL; while ( queryParser.GetDataRemaining() > 0 ) { StrPtrLen theCGIParamName; StrPtrLen theCGIParamValue; queryParser.ConsumeUntil(&theCGIParamName, '='); // leaves "=..." in cgiParser, puts item keywd in theCGIParamName if ( queryParser.GetDataRemaining() > 1 ) { queryParser.ConsumeLength(&theCGIParamValue, 1 ); // the '=' stopCharPtr = queryParser.GetCurrentPosition(); if (*stopCharPtr == '"') // if quote read to next quote { queryParser.ConsumeLength(NULL, 1); queryParser.ConsumeUntil(&theCGIParamValue, '"'); queryParser.ConsumeLength(NULL, 1); queryParser.ConsumeUntil(NULL, '&'); // our value will end by here... } else queryParser.ConsumeUntil(&theCGIParamValue, '&'); // our value will end by here... AddNameValuePairToList( theCGIParamName.GetAsCString(), theCGIParamValue.GetAsCString() ); queryParser.ConsumeLength(&theCGIParamValue, 1 ); // the '=' } } }