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

📄 msgprint.c

📁 基于嵌入式linux的命令行接口
💻 C
字号:
/*******************************************************************************
文件名:msgprint.c

版权所有:武汉易捷通信有限公司

版本:V1.0

作者:吴友山

描述:打印提示。

日期:
*******************************************************************************/
#include <stdio.h>

#include "msgprint.h"

#define MSG_LIST 72

BOOL printfEnable = ENABLE;/*如果要定时更新vlan,就必须为ENABLE*/

INT8  * const  commonMsg[MSG_LIST] = 
 {
/*1*/ {"enable"},
/*2*/ {"disable"},
/*3*/ {"Corporation name :  Edgin Technologies Co. Ltd"},/*系统信息*/
/*4*/ {"Product name     :  eSoon ES2024"},
/*5*/ {"Version          :  "},
/*6*/ {"Product date     :  2005-08-17"},
/*7*/ {"Lanswitch name   :  "},
/*8*/ {"Lanswitch MAC    :  "},
/*9*/ {"MAC aging time   :  "},
/*10*/{"Logout time      :  "},
/*11*/{"PVID range       :  "},
/*12*/{"Egmp status      :  "},
/*13*/{"Broadcast filter :  "},
/*函数提示*/
/*14*/{"Pvid save."},
/*15*/{"Pvid restore OK."},
/*16*/{"Save OK."},
/*17*/{"Parameter ERROR."},
/*18*/{"PVID is not in range."},
/*19*/{"Unknown command."},
/*20*/{"Select the choice:"},
/*21*/{"Set ports duplex status OK."},
/*22*/{"This command will delete all vlan, 'y' to confirm, others key to quit."},
/*23*/{"Num  Port        MAC         Status"},
/*24*/{"Press any key to continue, or Ctrl-C to quit.........................."},
/*25*/{"Default vlan can't be deleted!"},
/*26*/{"Manage vlan can't be deleted!"},
/*27*/{"Can't delete ports from default or manager vlan!"},
/*28*/{"Enter password:"},
/*29*/{"Password again:"},
/*30*/{"The password must be the same!"},
/*31*/{"No such vlan!"},
/*32*/{"Fail to read vlan map!"},
/*33*/{"Fail to write vlan map!"},
/*34*/{"Vlan num is more than 128."},
/*35*/{"Can't set speed of fiber port 24."},
/*36*/{"Can't set duplex of fiber port 24."},
/*37*/{"Can't set auto-negotiation of fiber port 24."},
/*38*/{"No ports' pvid have been set."},
/*39*/{"Port status:\n"},
/*40*/{"Port  Link  SpeedSet   TrueSpeed  Pvid  Type     Status   FlowCtrl"},
/*41*/{"Length of word in command should be less than 30!"},
/*42*/{"Can't malloc!"},
/*43*/{"eSoon ES2024"},
/*44*/{"Command is too long!"},
/*45*/{"Enter name:"},
/*46*/{"Rec Cmd save"},
/*47*/{"Rec Cmd reboot"},
/*48*/{"Rec Cmd port inquire"},
/*49*/{"Rec Cmd port set"},
/*50*/{"Rec Cmd creat vlan"},
/*51*/{"Rec Cmd del vlan"},
/*52*/{"Rec Cmd add port"},
/*53*/{"Rec Cmd del port"},
/*54*/{"Rec Cmd sh vlan"},
/*55*/{"Rec Cmd vlan num inquire"},
/*56*/{"Rec Cmd change SW name"},
/*57*/{"Rec Cmd show all vlan"},
/*58*/{"Rec Cmd port isolate"},
/*59*/{"Rec Cmd Glb pvid"},
/*60*/{"Enter choice:"},
/*61*/{"Length of password should be less than 8!"},
/*62*/{"Length of username should be less than 8!"},
/*63*/{"Reset is in process...."},
/*64*/{"Deleting mac is in process...."},
/*65*/{"Product name     :  eSoon ES2016"},
/*66*/{"eSoon ES2016"},
/*67*/{"Rec Cmd del all vlan"},
/*68*/{"V100R001B001D001P001"},/*eSoon ES2024 版本*/
/*69*/{"V100R002B001D001P001"},/*eSoon ES2016 版本*/
/*70*/{"Product name     :  eSoon ES2008"},
/*71*/{"eSoon ES2008"},
/*72*/{"V100R003B001D001P001"},/*eSoon ES2008 版本*/
};

/*******************************************************************************
函数:charPrint
功能:连续times次打印字符outChar。
参数:
    输入--times:打印字符的次数。
	           outChar:要打印的字符。
    输出--
返回:
描述:
*******************************************************************************/
void charPrint( BYTE times, BYTE outChar )
{
    	UINT32 loop;

    	for ( loop = times; loop >0; loop-- )/*for ( loop = 0; loop < times; loop++ )*/
    	{
        	putchar(outChar );
    	}
}

/*******************************************************************************
函数:pvidPrint
功能:打印pvid范围。
参数:
    输入--pvid:端口vid号。
    输出--
返回:
描述:pvid是由全局pvid号(pvid[11:8])和每个端口的pvid号(pvid[7:0])组成。
*******************************************************************************/
void pvidPrint(UINT16 pvid)
{
    	UINT16 pvidBegin, pvidEnd;

    	//PVID起始
    	pvidBegin = pvid & 0xf00;
    	if (pvidBegin == 0)
    	{
        	pvidBegin = 1;
    	}
    	//PVID结束
    	pvidEnd = pvidBegin |0xff;
    	if (pvidEnd == 4095)
    	{
        	pvidEnd = 4094;
    	}
    	printf("%d - %d",pvidBegin, pvidEnd);
}

/*******************************************************************************
函数:commonMsgPrint
功能:常用信息的打印
参数:
    输入--msgType:要打印的信息类型,即(数组的索引+1)。
                  enterReq:=TRUE:在打印前先增加打印回车符。
    输出--
返回:
描述:
*******************************************************************************/
void commonMsgPrint(BYTE msgType, BOOL enterReq)
{
    	INT8 *printfMsg;
    	BYTE msgNum;

    	if (printfEnable==DISABLE)
    	{
        	return;
    	}
    
    	//如果打印的信息超出范围,返回
    	if (msgType > MSG_LIST)
    	{
        	return;
    	}

    	//传进来的参数要减1
    	msgNum = msgType -1;
    	printfMsg = commonMsg[msgNum];

    	//是否打印回车符
    	if (enterReq == TRUE)
    	{
        	printf("\n");
    	}

    	printf("%s", printfMsg);
}

⌨️ 快捷键说明

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