一、参考网址
二、网页是采用文件读写方式,还是转换为数组方式?
1)其通过宏定义“WEBS_PAGE_ROM”来区分,我是在websPageReadData()(page.c)函数源码发现的
int websPageReadData(webs_t wp, char *buf, int nBytes) { #ifdef WEBS_PAGE_ROM a_assert(websValid(wp)); return websRomPageReadData(wp, buf, nBytes); #else a_assert(websValid(wp)); return read(wp->docfd, buf, nBytes); #endif }
2) 其保存网页的数组定义:websRomPageIndexType websRomPageIndex[], 其内部有个Page成员指向网页数组数据:
/* * Compiled Rom Page Index */ typedef struct { char_t *path; /* Web page URL path */ unsigned char *page; /* Web page data */ int size; /* Size of web page in bytes */ int pos; /* Current read position */ } websRomPageIndexType;
3) websRomPageIndex[]数组初始化过程
websRomOpen()
symEnter(romTab, name, valueInteger((int) wip), 0); //填充到sym[romTab]中
4) 从数组中读出网页的过程:
websDefaultHandler 注册了写事件处理
websDefaultWriteEvent
websPageReadData
websRomPageReadData
2、输入URL时,其默认网页定义
在initwebs()函数中有UrlHandlerDefine(T("/"), NULL, 0, websHomePageHandler, 0);
其websHomePageHandler()定义如下:
static int websHomePageHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg, char_t *url, char_t *path, char_t *query) { /* * If the empty or "/" URL is invoked, redirect default URLs to the home page */ if (*url == '