用C/C++写CGI程序
用C/C++写CGI程序
使用CGIC库的简要:
库的函数说明: http://www.boutell.com/cgic/#cgiFormStringNoNewlines
1. 打印CGI标准输出头部:
cgiHeaderContentType("text/plain");
或者:
fprintf( stdout, "Content-type:text/plain\n\n");红色部分不能写出“Contenttype”,否则浏览器显示网页会不正常。
2. 处理Request Method:
//deal with "GET"/"POST" method
if (strncmp(cgiRequestMethod, "post",4) == 0)
{
handlePostRequest();
}
else //"GET"
{
handleGetRequest();
}
3. 获取QueryString中的各个字段值:
cgiFormStringNoNewlines("query1", cmdstr, sizeof(cmdstr));
if (strcmp(cmdStr, "ip_address") == 0)
{
...
}
else
...
4. CGI输出:fprintf(cgiOut, "%s\n", cgi_Output);
以下是一些细节:
一、 C/C++编写CGI程序之form处理
1. GET
2. POST
3. 结束
我们有一张web
test.html
<html>
<head>
<title>form test</title>
</head>
<body>
<form method="get" name="test-get" action="./cgi-bin/test-get.cgi">
<input name="name"><input name="pswd"><input type=submit value="get">
</form>
<br><br>
<form method="post" name="test-post" action="./cgi-bin/t
相关文档:
C语言的标准库函数包括一系列日期和时间处理函数,它们都在头文件中说明。下面列出了这些函数。在头文件中定义了三种类型:time_t,struct tm和clock_t。
在中说明的C语言时间函数 & ......
先用贝尔的一道笔试题简要的说明一下吧:
【题】说明以下程序。
#include
int main(void)
{
unsigned int a[3] = {0x01020304, 0x05060708, 0x090a0b0c};
unsigned int *p = (unsigned int *)((int)a +1);①
printf("%x\n", *p);
return 0;
}
【题目解析】
这段程序的输出结果应 ......
很奇怪,以前一直以为C++是兼容C的,但是,今天用lex&yacc生成的C代码可用通过GCC的编译,
但是怎么都通不过G++的编译,而其错误很多,有可能是lex&yacc生成的C代码太老了,,,
我是这样解决的
把lex&yacc生成的代码 用 GCC -c 编译成 lex.o 的目标文件。然后 g++ main.cpp lex.o ,就OK了
记得: 在 main. ......
该程序很简单,就是用C从ORACLE,把当前日期显示出来就OK,作为一个简单的DEMO
(一)写PRO*C
/*===========================================================================
* pro*c编译方法:
* 预编译 proc test.pc
* 编译 gcc -o test test.c $ORACLE_HOME/lib/libclntsh.so
* 作者 f ......