
#ifndef __CONSOLE_H__
#define	__CONSOLE_H__

#include "config.h"

//---------------------------------------------------------------------------------------------

#ifndef MAX_CMD_LINE
#define	MAX_CMD_LINE	50
#endif

#ifdef _IN_CONSOLE_C

int g_netDebugInfo = 0;	// = 0, 不使用网口输出， = 1, 输出信息到网口

#else

extern int g_netDebugInfo;

#endif

//---------------------------------------------------------------------------------------------

#define	MAX_DEBUG_INFO_LEN	127

#define	DEBUG_INFO(...)		do\
{\
	if (g_netDebugInfo != 0)\
	{\
		char str[MAX_DEBUG_INFO_LEN+1];	\
		sprintf(str, __VA_ARGS__);	\
		str[MAX_DEBUG_INFO_LEN] = 0;	\
		SendDebugInfo(str);	\
	} \
	printf(__VA_ARGS__);	\
}while(0)

//---------------------------------------------------------------------------------------------


void InitConsole(void);

void ConsoleCmdScan(void);

void OutNewCmdLine(void);

int IsConsoleCancel(void);

int PutChar(int ch);
int GetChar(void);

void SetConsoleOutType(int type);
int IsNewCommand(void);
int LockExecAndGetCmdStr(char*pBuf);
void UnlockExec(void);
void SetPauseStatus(int sta);

int GetHistoryCmd(int hisIdx, char * pch);
int GetHistoryNum(void);
int GetHistoryMaxNum(void);
int GetHistoryIdx(void);

//---------------------------------------------------------------------------------------------

#endif
