?? test.c
字號:
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char name[20];
char val[20];
} entry;
void getword(char *word, char *line, char stop);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
main(int argc, char *argv[])
{
entry entries[5];
register int x,m=0;
char *cl;
printf("Content-type: text/html%c%c",10,10);
if(strcmp(getenv("REQUEST_METHOD"),"GET"))
{
printf("This script should be referenced with a METHOD of GET.\n");
exit(1);
}
cl = getenv("QUERY_STRING");
if(cl == NULL)
{
printf("No query information to decode.\n");
exit(1);
}
for(x=0;cl[0] != '\0';x++)
{
m=x;
getword(entries[x].val,cl,'&');
plustospace(entries[x].val);
unescape_url(entries[x].val);
getword(entries[x].name,entries[x].val,'=');
}
printf("<H1>CGI 測試</H1>");
printf("您 輸 入 的 信 息 如 下 ∶ <p>%c",10);
printf("<ul>%c",10);
for(x=0; x <= m; x++)
{
printf("<li> <code>%s = %s</code>%c",entries[x].name,entries[x].val,10);
printf("</ul>%c",10);
}
}
void getword(char *word, char *line, char stop)
{
int x = 0,y;
for(x=0;((line[x]) && (line[x] != stop));x++)
word[x] = line[x];
word[x] = '\0';
if(line[x]) ++x;
y=0;
while(line[y++] = line[x++]);
}
char x2c(char *what)
{
register char digit;
digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
digit *= 16;
digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
return(digit);
}
void unescape_url(char *url)
{
register int x,y;
for(x=0,y=0;url[y];++x,++y)
{
if((url[x] = url[y]) == '%')
{
url[x] = x2c(&url[y+1]);
y+=2;
}
}
url[x] = '\0';
}
void plustospace(char *str)
{
register int x;
for(x=0;str[x];x++)
if(str[x] == '+')
{
str[x] = ' ';
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -