用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语言]fopen()函数的参数说明
2007年06月05日 星期二 23:55
格式:文件指针名=fopen(文件名,使用文件方式)
参数:
文件名 意义
"C:/temp/temp.txt" 文件 C:\temp\temp.txt
文件使用方式 意 义
“rt” 只读打开一个文本文件,只允许读数据
“wt” 只写 ......
typedef struct _RTP_header {
/* byte 0 */
#if (BYTE_ORDER == LITTLE_ENDIAN)
unsigned char csrc_len:4; /* expect 0 */
&nb ......
该程序很简单,就是用C从ORACLE,把当前日期显示出来就OK,作为一个简单的DEMO
(一)写PRO*C
/*===========================================================================
* pro*c编译方法:
* 预编译 proc test.pc
* 编译 gcc -o test test.c $ORACLE_HOME/lib/libclntsh.so
* 作者 f ......
---- 在数据库的应用开发中,常常会遇到性能和代价的之间矛盾。以作者在开发股市行
情查询和交易系统中遇到的问题为例,要在实时记录1000多只股票每分钟更新一次的行
情数据的同时,响应大量并发用户的数据查询请求。考虑到性价比和易维护性,系统又
要求在基于PC服务器,Windows NT平台的软硬件环境下实现。开 ......