📄 cgiparse.c
字号:
//--------------------------------------------------------------------------
// IP Stack CGI Demonstration Program
//--------------------------------------------------------------------------
// cgiparse.c
//
// Basic CGI Functions
//
// Author: Michael A. Denio
// Adam K. Keys
//
// Copyright 2001 by Texas Instruments Inc.
//-------------------------------------------------------------------------
#include "netmain.h"
//
// cgiParseVars()
//
// Reads input from a CGI post operation in pointed to by PostIn and
// returns in sequence a pointer the name and then the value of each
// post entry. This function modifies the data in PostIn. It also
// returns the current parsing position in the variable pParseIndex.
// The parse index must be set to 0 on initial call.
//
char *cgiParseVars(char PostIn[], int *pParseIndex )
{
int out;
int in;
char hexch;
char hexval[3];
int start;
char ch;
// Get the current parse index. On the first call, it
// must be zero.
in = *pParseIndex;
hexval[2] = '\0';
if( in == 0 )
out = 0;
else if( in == -1 )
return NULL;
else
out = ++in;
start = in;
while (((ch = PostIn[in]) != '=') && (ch != '&') && (ch != '\0'))
{
if (ch == '+')
PostIn[out++] = ' ';
else if (ch == '%')
{
hexval[0] = PostIn[++in];
hexval[1] = PostIn[++in];
hexch = (char) strtol(hexval, NULL, 16);
PostIn[out++] = hexch;
}
else
PostIn[out++] = ch;
in++;
}
// If we got to the end of the string, set the parse index to -1
if( ch == '\0' )
in = -1;
// Null terminate the result string
PostIn[out++] = '\0';
// Save the value of the current parse index
*pParseIndex = in;
// Return a pointer to the start of the result string
return (&PostIn[start]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -