目标: 回显输入的asp页面中的字符串
1. 在相应的根目录中创建hello.asp,如果是刚下载的话就是源码下面的那个www目录,里面有个home.html
<% hello("hello"); %>
<% hello("jack"); %>
<% hello("rose "); %>
2. 在相应平台的目录中编辑main.c, 本文针对Linux,所以是源码目录下面的:LINUX/main.c
A. 首先关联asp页面中的hello函数到C中一个函数,如:hello
websAspDefine(T("hello"), hello);
B. 接下来实现对hello函数的定义,在goahead中函数头有特定的格式
static int hello(int eid, webs_t wp, int argc, char_t **argv)
{
char_t *hello; /*这里只能是指针不能是数组,刚刚用数组显示乱码,不知道是什么情况*/
if (ejArgs(argc, argv, T("%s"), &hello) < 1) {
websError(wp, 400, T("Insufficeinet args/n");
return -1;
}
return websWrite(wp, T("%s "), hello);
}
C. 上面这样还不行,还要在调用hello之前实现对它的声明
static int hello(int eid, webs_t wp, int argc, char_t **argv);
PS: 这里使用的是goahead 2.5, 简单功能就是这个样子了,以前认为吧可能不需要看这个程序的源码的,其实我错了,不看源码不行的。
哦,当你实践完之后是不是有种被骗的感觉,这不是helloworld, 这是echo..呵呵。
2011-05-04 10:07:57