Example #1
0
int findChunkedDataLength( const char *inChunkPtr , size_t inChunkLen, char **  chunkedDataPtr, const char *inFormat, ... )
{
  char *dst = (char *)inChunkPtr + inChunkLen;
  char *src = (char *)inChunkPtr;
  size_t          len;
  va_list         args;
  
  // Find an empty line (separates the length and data).
  *chunkedDataPtr = dst;
  for( ;; )
  {
    while( ( src < *chunkedDataPtr ) && ( *src != '\r' ) ) ++src;
    if( src >= *chunkedDataPtr ) break;
    
    len = (size_t)( *chunkedDataPtr - src );

    if( ( len >= 2 ) && ( src[ 1 ] == '\n' ) ) // CRLF
    {
      if(*inChunkPtr == 0x30){ //last chunk
        *chunkedDataPtr = src + 2;
        va_start( args, inFormat );
        VSNScanF( "0", 1, "%llu", args);
        va_end( args );
        return true;
      }

      *chunkedDataPtr = src + 2;
      va_start( args, inFormat );
      VSNScanF( inChunkPtr, src - inChunkPtr, "%x", args);
      va_end( args );
      return true;
    }
    else if( len <= 1 )
    {
      break;
    }
    ++src;
  }
  return false;  
}
Example #2
0
int HTTPScanFHeaderValue( const char *inHeaderPtr, size_t inHeaderLen, const char *inName, const char *inFormat, ... )
{
    int                 n;
    const char *        valuePtr;
    size_t              valueLen;
    va_list             args;

    n = (int) HTTPGetHeaderField( inHeaderPtr, inHeaderLen, inName, NULL, NULL, &valuePtr, &valueLen, NULL );
    require_noerr_quiet( n, exit );

    va_start( args, inFormat );
    n = VSNScanF( valuePtr, valueLen, inFormat, args );
    va_end( args );

exit:
    return( n );
}