📄 webpages.c
字号:
/*
*
* webpages.c
*
* Part of the Myson Century CS620X demo program.
*
* Authors: LY Lin, WM Wang, IJ Chen, WH Lee
*
* webpages.c contains contains entries for all the web pages for the embedded
* web server.
*
* This program was developed using the Keil 8051 C uVision 2 system.
* The Keil compiler MUST be used if working with Myson Century supplied
* firmware.
*
*
* This program must be linked with the 620xlib.LIB library
* supplied by Myson Century in object module form.
*
*/
#include <stdio.h>
#include <string.h>
#include "hpserver.h"
#include "timer.h"
#include "ether.h"
#include "netutil.h"
#include "net.h"
#include "ip.h"
#include "tcp.h"
#include "config.h"
#include "http.h"
/*Web pages(store in code memory) head files*/
#include "index.h"
#include "bgm.h"
#include "century.h"
#include "cs00.h"
#include "tm00.h"
#include "cs6209.h"
#include "demokit.h"
#include "desc.h"
#include "grem.h"
#include "ioset.h"
#include "purm.h"
#include "redm.h"
#include "status.h"
#include "yello.h"
#include "ioset.h"
#include "time.h"
/*Buffer for system FAT*/
RAM_WEB_PAGE web_page_table [MAX_HTTP_FILES];
/*Buffer for file name in EEPROM */
unsigned char http_name_buff[MAX_HTTP_FILES*MAX_HTTP_FILE_NAME_L];
/*
RAM_WEB_PAGE web_page_table_incode []
This table is the place to store the web page information.
For each web page, you need to specify an entry in this table.
The first field is the name of the web page. The second field
is the name of the data arry to store the web page data.
The third field is the size of the web page array you specified
in the second field.
The first field, the name of the web page, is used to search
for this table when an HTTP GET request comes in from the browser.
The HTTP GET request will specify the name of the web page. When
the CS620X web server parses this request, the server uses the name
of the web page to search this table. If an entry matching the web
page name is found, the web page data and length will be read from the
second and third fields in the entry.
The second field is the name of the data array to store the web page
data. You can hand code this data array, or a better way is to use the
utility ewsh2c.exe to convert a web page file into the C data array
for you.
The third field for each entry is the size of the web page data array.
You can also use the ewsh2c.exe to generate this number for you.
For an example, if you have a web page in the html format called
index.htm. After you use the ewsh2c.exe utility with index.htm,
two files are generated: index.c and index.h. In index.c, the web
page data is converted to a data array with the name index_htm[] in
index.c, and the size of the array, INDEX_SIZE, is specified in
index.h.
You then include index.h at the start of this file. Also you make
an entry of the web page in the web page table as shown in the
following.
If your web page includes any graphics file, you carry out the
same procedure. For an example, if one of the graphics file is
called cs00.jpg, which is a jpeg graphics file. You run the
ewsh2c.exe utility through this file. The cs00.c and cs00.h files
are generated. The cs00.c file contains the data array cs00_jpg, and
the cs00.h file has the data array size CS00_SIZE.
For each web page file, you have to go through the following steps:
1) Use the ewsh2c.exe utility to generate the .c and .h file.
2) In this file, you include the .h file at the beginning.
3) Make an entry in the web_page_table below.
4) In your firmware build environment, you have to include the
.c file as part of the total project source files.
5) If the web page needs processing after it is requested by the
browser, you write a CGI program to do it. You specify the
web page and CGI function association by modifying the
register_cgi_functions () in HTTP.C.
After the above is done for each web page file, you build
the firmware load the firmware into the board for execution.
*/
RAM_WEB_PAGE web_page_table_incode [] =
{
// index.htm has to be the first one.
{"index.htm", index_htm, INDEX_SIZE},
{"ioset.cgi", ioset_cgi, IOSET_SIZE},
{"bgm.jpg", bgm_jpg, BGM_SIZE},
{"century.htm", century_htm, CENTURY_SIZE},
{"cs00.jpg", cs00_jpg, CS00_SIZE},
{"tm00.jpg", tm00_jpg, TM00_SIZE},
{"cs6209.htm", cs6209_htm, CS6209_SIZE},
{"demokit.htm", demokit_htm, DEMOKIT_SIZE},
{"desc.htm", desc_htm, DESC_SIZE},
{"grem.jpg", grem_jpg, GREM_SIZE},
{"purm.jpg", purm_jpg, PURM_SIZE},
{"redm.jpg", redm_jpg, REDM_SIZE},
{"status.cgi", status_cgi, STATUS_SIZE},
{"yello.htm", yello_jpg, YELLO_SIZE},
{"time.cgi",time_cgi,TIME_SIZE},
{NULL, NULL, NULL}
};
/* EGI function definitions */
extern void ioset_resp(TSOCK xdata *ts, char xdata *str);
extern void status_resp(TSOCK xdata *ts, char xdata *str);
extern void time_resp(TSOCK xdata *ts,char xdata *str);
code EGI_FUNC egifuncs[] = {
{ioset_resp, "ioset"},
{status_resp, "status"},
{time_resp,"time"},
{0}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -