⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htmlmanager.c

📁 vxworks下或者任何一个操作系统下http任务的cgi层的实现例子
💻 C
📖 第 1 页 / 共 5 页
字号:
#include <vxworks.h>

#include "stdio.h"
#include "string.h"
 
#include "include/sysdef.h"
#include "maintain/message.h"
#include "maintain/lpt.h" 
#include "database/dbdefine.h"  
#include "cmdTree/cmdLib.h"

#include "maintain/sysParameter.h"
#include "database/dbdescription.h"
#include "database/databaseApi.h"

#include "html.h"
#include "htmllib.h"
#include "htmlManager.h"

#define web_gk 1
#define web_gw 1
#define web_sys 1
#define web_new 1     
#define Gwweb_new 1
#define Gkweb_new 1

extern UINT8 * intToString(UINT32 intVal,UINT8* buf,UINT8 len) ;
extern STATUS addSelectN(void * pCheck, UINT8 * fileNameStr, UINT32 selected);
extern STATUS getHtmlParams(char * dataBuf, long bufLen);

//全局变量
//2004.12.7 sxf
static UINT8 submitErrorBuf[10000];//暂时认为只能有100条错误报告
static UINT8 submitErrorFlag;
static UINT8 LinkPath[50];
static UINT16 MaxNum;
//gw
static UINT16 MaxPortnum=MAX_PORT;
static UINT16 MaxGwnum=28;
static UINT16 MaxSTrunknum=MAX_PORT;
static UINT16 MaxGwSRnum=20;
static UINT16 MaxCoUsernum=MAX_PORT;
//gk
static UINT16 MaxLoGwnum=20;
static UINT16 MaxGknum=20;
static UINT16 MaxGwgroupnum=MAX_GW_GROUP;//10
static UINT16 MaxGkSRnum=20;

static UINT8 productType[][10] = {"","DSL_VIP","KVP_6010","KVP_6011","KVP_6014","KVP_6015","KVP_6016","KVP_6017",
	"KVP_6033","KVP_6020","KVP_6016A"};

#define isValidStr(pParam) ((pParam != NULL) && (strlen(pParam)!=0))
/*
STATUS isValidStr(UINT8 *p_str)
{
    if(p_str==NULL) return ERROR;
    if(strlen(p_str)==0) return FALSE;
    return TRUE;
}*/

void submitErrorPrint(UINT8 *errorBuf,UINT16 errLen)
{
    UINT16 len;
    
    if(errorBuf==NULL)
    {
        lpt(PT_WARN,"errorBuf is NULL\n");
        return ;
    }

    len = strlen(submitErrorBuf);
    if((len+errLen)>=sizeof(submitErrorBuf))
    {
        return;
    }

    strcat(submitErrorBuf,errorBuf);

    submitErrorFlag = TRUE;
}


#ifdef web_new
int buildWebPage(char * fileBuf, long bufLen)
{
     UINT8 * pPage;
     
     pPage = buildFrame("web.htm", fileBuf, bufLen);
     addTitle("VoIP 数据配置!", 0, pPage);
   
    return TRUE;
}

int buildSingleButton(UINT8 * pPage)
{
	
       B_L("left",pPage) 
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <TD class=hline><IMG height=1 src=\"bmp/empty.gif\"  width=1></TD>", pPage));
       E_L(pPage)
       B_L("left",pPage) 
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <TD class=tail height=30> &nbsp;<INPUT class=button id=save type=submit value=\"提交\" name=Submit>&nbsp; ", pPage));
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <INPUT class=button id=Refresh onclick=\"window.location.reload();\" type=button value=\"刷 新\" name=Refresh>&nbsp; </TD></TR>\n", pPage));
                  
        return 1;
}
int buildSubmitButton(UINT8 * pPage)
{
       B_L("left",pPage) 
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <TD class=hline><IMG height=1 src=\"bmp/empty.gif\"  width=1></TD>", pPage));
       E_L(pPage)
       B_L("left",pPage) 
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <TD class=tail height=30> &nbsp; \n", pPage));
           if(MaxNum>8)
           {
               ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <INPUT class=button type=button disabled onclick=doPrev(); value=\"上一页\" name=PrevPage>&nbsp; \n", pPage));
               ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <INPUT class=button type=button onclick=doNext(); value=\"下一页\" name=NextPage>&nbsp; \n", pPage));
           }
           if(MaxNum<=8) 
           {}
           //ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <INPUT class=button onclick=doClear(); type=button value=\"清 空\" name=Clear>&nbsp; \n", pPage));
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <INPUT class=button type=submit value=\"提 交\" name=Submit>&nbsp; \n", pPage));
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <INPUT class=button id=Refresh onclick=\"window.location.reload();\" type=button value=\"刷 新\" name=Refresh>&nbsp; </TD>\n</TR>\n", pPage));

       //E_L(pPage)
	return 1;
}

int EndPage(UINT8 * pPage)
{
                   B_L("left",pPage) 
                       ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <TD class=hline><IMG height=1 src=\"bmp/empty.gif\"  width=1></TD>", pPage));
                   E_L(pPage)
            E_T(pPage)
            ASSERT_BUILD_PAGE_SUCCESS(addLanguage("</TD>", pPage));
            
        E_L(pPage)
    E_T(pPage)
	return 1;
}
int EditPage(int width,UINT8 * pPage)
{
	UINT8  tmp[100];  
	memset(tmp, 0, sizeof(tmp));
	//新增记录的编辑区
	sprintf(tmp,"<TABLE width=%d",width);
	//addLanguage("<TABLE width=420 align=center border=0>", pPage);
	addLanguage(tmp, pPage);
	addLanguage(" align=center border=0><TBODY>", pPage);
	     B_L("center",pPage) 
	            B_D(pPage)
	     	        addLanguage("<span id=\"newTR\" title=\"新增数据提交之后才有效\"></span>", pPage);
	     	  E_D(pPage)
	     E_L(pPage)
	E_T(pPage)
#if 0
		     addLanguage("<span id=\"newTR\" title=\"提交之后才有效\"></span>", pPage);
		     B_T2(width, "", "false", "TbEditSel", "TbEditSel", pPage)
			   B_L("left", pPage)
				B_D(pPage)
					addLanguage("新增记录<input type=\"checkbox\" name=\"checkadd\" onClick=\"AddParaChk()\">", pPage);
		     		E_D(pPage)
		     	   E_L(pPage)
		     E_T(pPage)
		     addLanguage("<span id=\"EditPara\"></span>", pPage);
#endif
return 1;
}
int AddFlag(INPUT_INFO inputInfo, UINT16 i, UINT8 * pPage)
{
	    sprintf(inputInfo.name, "%s%d", "DelFlag",i);  
           strcpy(inputInfo.type,"hidden");
           strcpy(inputInfo.value,"0");
           addInputN((void *)&inputInfo, pPage);

	    sprintf(inputInfo.name, "%s%d", "ModFlag",i);  
           strcpy(inputInfo.type,"hidden");
           strcpy(inputInfo.value,"0");
           addInputN((void *)&inputInfo, pPage);

	    sprintf(inputInfo.name, "%s%d", "AddFlag",i);  
           strcpy(inputInfo.type,"hidden");
           strcpy(inputInfo.value,"0");
           addInputN((void *)&inputInfo, pPage);

           sprintf(inputInfo.id,"%s%d","recycle",i);
           inputInfo.width=23;
           strcpy(inputInfo.type,"span");
           addInputN((void *)&inputInfo, pPage);
	return 1;
}
int buildErrorPage(char * fileBuf, long bufLen)
{
    UINT8 * pPage;
    HOT_LINK_INFO change;
//    UINT8 tmpBuf[2048];

    pPage = buildHtmlFile("SubmitError.htm", fileBuf, bufLen);
    //标题
    addTitle("设置结果!", 0, pPage);
    //换行
    addEnter(pPage);
    addEnter(pPage);
    addEnter(pPage);
    addEnter(pPage);
    addEnter(pPage);
    
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<p align=\"center\">", pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<body bgcolor=#ffffff>", pPage));   
    //debugPrintf(1,"submitErrorFlag %d\n",submitErrorFlag);
    if(submitErrorFlag == FALSE)
    {   
    	ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<FONT color=\"#FF0000\" size=\"+2\">配置成功!</FONT>", pPage));
    }
    else 
    {  	
    	ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<FONT color=\"#FF0000\" size=\"+2\">配置错误!下面是错误内容提示:</FONT>", pPage));
       ASSERT_BUILD_PAGE_SUCCESS(addEnter(pPage));
       strcat(submitErrorBuf,"</font><br><br></p>");
       addLanguage(submitErrorBuf, pPage);
    }
    ASSERT_BUILD_PAGE_SUCCESS(addEnter(pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addEnter(pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addEnter(pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addEnter(pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addEnter(pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<p align=\"center\">", pPage));    
    //strcpy(change.path, "main.htm");
    strcpy(change.path, LinkPath);
    strcpy(change.content, "返  回");
    addhotLink((void *)&change, pPage);   
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("</p>", pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("</body", pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("</p>", pPage));

    
    return TRUE;
    
}

int buildRuninfoPage(char * fileBuf, long bufLen)
{
    UINT8 * pPage;
    UINT8 configbuf[4096*6];
    
    stackCheck();
    
    memset(configbuf,0,sizeof(configbuf));

    pPage=buildHtmlFile("NetRuninfo.htm", fileBuf, bufLen);
    addTitle("网络参数当前配置", 0, pPage);
    
   //script cookies
   addLanguage("<script language=\"javascript\" src=\"ChkLogin.Js\" type=\"text/javascript\"></script>", pPage);
   addLanguage("<script language=\"javascript\" src=\"protect.Js\" type=\"text/javascript\"></script>", pPage);
     //style
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<LINK href=\"style.css\" type=text/css rel=stylesheet>", pPage));
    ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<CENTER>", pPage));
    //begin of action
    ASSERT_BUILD_PAGE_SUCCESS(addBeginActionObject("/NetRuninfo.htm", pPage));
    //界面
    //B_T1(502, pPage)
    B_T1(502, pPage)
        B_L("left",pPage) 
            ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<TD class=title width=7><IMG height=24 src=\"bmp/arc.gif\"  width=7></TD>", pPage));
            ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<TD class=title vAlign=center align=left width=495>当前配置</TD>", pPage));
        E_L(pPage)
        B_L("left",pPage) 
        
            ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<TD colSpan=2>", pPage));
            B_T1(502, pPage)
	            B_L("left",pPage) 
                   ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<TD class=vline rowSpan=15><BR></TD><TD width=500>", pPage));
                   B_T2(420, "space", "true","Tbhead","Tbhead", pPage)
                       B_L("left",pPage) 
		         	  ASSERT_BUILD_PAGE_SUCCESS(addLanguage("<TD>当前网络配置:反映网络部分的所有设置内容。</TD>", pPage));
		         E_L(pPage)
		     E_T(pPage)
                   //table1 start
                   B_T2(420, "space", "false", "TbData","TbData",pPage)
		         B_L("left",pPage)
		         	  //B_DL(pPage)
				//	addLanguage("运行状态", pPage);
		         	 // E_D(pPage)
		         E_L(pPage)
		         B_L("left",pPage)
		         	  B_D(pPage)
		         	       onNetQuery(configbuf,sizeof(configbuf));
		         	  	//strcat(tempbuf,buf);
					addLanguage(configbuf, pPage);
		         	  E_D(pPage)
		         E_L(pPage)
		     E_T(pPage)
		     //table1 end
                   ASSERT_BUILD_PAGE_SUCCESS(addLanguage("</TD><TD class=vline rowSpan=15><BR></TD>", pPage));
                   E_L(pPage)
                   //下面是表的结束部分:提交按钮
       B_L("left",pPage) 
           ASSERT_BUILD_PAGE_SUCCESS(addLanguage(" <TD class=hline><IMG height=1 src=\"bmp/empty.gif\"  width=1></TD>", pPage));
       E_L(pPage)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -