亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cmdline.c

?? ATMEL的AVR單片機庫文件
?? C
字號:
/*! \file cmdline.c \brief Command-Line Interface Library. */
//*****************************************************************************
//
// File Name	: 'cmdline.c'
// Title		: Command-Line Interface Library
// Author		: Pascal Stang - Copyright (C) 2003
// Created		: 2003.07.16
// Revised		: 2003.07.23
// Version		: 0.1
// Target MCU	: Atmel AVR Series
// Editor Tabs	: 4
//
// NOTE: This code is currently below version 1.0, and therefore is considered
// to be lacking in some functionality or documentation, or may not be fully
// tested.  Nonetheless, you can expect most functions to work.
//
// This code is distributed under the GNU Public License
//		which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************

//----- Include Files ---------------------------------------------------------
#include <avr/io.h>			// include I/O definitions (port names, pin names, etc)
#include <avr/signal.h>		// include "signal" names (interrupt names)
#include <avr/interrupt.h>	// include interrupt support
#include <avr/pgmspace.h>	// include AVR program memory support
#include <string.h>			// include standard C string functions
#include <stdlib.h>			// include stdlib for string conversion functions

#include "global.h"		// include our global settings
#include "cmdline.h"

// include project-specific configuration
#include "cmdlineconf.h"

// defines
#define ASCII_BEL				0x07
#define ASCII_BS				0x08
#define ASCII_CR				0x0D
#define ASCII_LF				0x0A
#define ASCII_ESC				0x1B
#define ASCII_DEL				0x7F

#define VT100_ARROWUP			'A'
#define VT100_ARROWDOWN			'B'
#define VT100_ARROWRIGHT		'C'
#define VT100_ARROWLEFT			'D'

#define CMDLINE_HISTORY_SAVE	0
#define CMDLINE_HISTORY_PREV	1
#define CMDLINE_HISTORY_NEXT	2


// Global variables

// strings
u08 PROGMEM CmdlinePrompt[] = "cmd>";
u08 PROGMEM CmdlineNotice[] = "cmdline: ";
u08 PROGMEM CmdlineCmdNotFound[] = "command not found";

// command list
// -commands are null-terminated strings
static char CmdlineCommandList[CMDLINE_MAX_COMMANDS][CMDLINE_MAX_CMD_LENGTH];
// command function pointer list
static CmdlineFuncPtrType CmdlineFunctionList[CMDLINE_MAX_COMMANDS];
// number of commands currently registered
u08 CmdlineNumCommands;

u08 CmdlineBuffer[CMDLINE_BUFFERSIZE];
u08 CmdlineBufferLength;
u08 CmdlineBufferEditPos;
u08 CmdlineInputVT100State;
u08 CmdlineHistory[CMDLINE_HISTORYSIZE][CMDLINE_BUFFERSIZE];
CmdlineFuncPtrType CmdlineExecFunction;

// Functions

// function pointer to single character output routine
static void (*cmdlineOutputFunc)(unsigned char c);

void cmdlineInit(void)
{
	// reset vt100 processing state
	CmdlineInputVT100State = 0;
	// initialize input buffer
	CmdlineBufferLength = 0;
	CmdlineBufferEditPos = 0;
	// initialize executing function
	CmdlineExecFunction = 0;
	// initialize command list
	CmdlineNumCommands = 0;
}

void cmdlineAddCommand(u08* newCmdString, CmdlineFuncPtrType newCmdFuncPtr)
{
	// add command string to end of command list
	strcpy(CmdlineCommandList[CmdlineNumCommands], newCmdString);
	// add command function ptr to end of function list
	CmdlineFunctionList[CmdlineNumCommands] = newCmdFuncPtr;
	// increment number of registered commands
	CmdlineNumCommands++;
}

void cmdlineSetOutputFunc(void (*output_func)(unsigned char c))
{
	// set new output function
	cmdlineOutputFunc = output_func;
	
	// should we really do this?
	// print a prompt 
	//cmdlinePrintPrompt();
}

void cmdlineInputFunc(unsigned char c)
{
	u08 i;
	// process the received character

	// VT100 handling
	// are we processing a VT100 command?
	if(CmdlineInputVT100State == 2)
	{
		// we have already received ESC and [
		// now process the vt100 code
		switch(c)
		{
		case VT100_ARROWUP:
			cmdlineDoHistory(CMDLINE_HISTORY_PREV);
			break;
		case VT100_ARROWDOWN:
			cmdlineDoHistory(CMDLINE_HISTORY_NEXT);
			break;
		case VT100_ARROWRIGHT:
			// if the edit position less than current string length
			if(CmdlineBufferEditPos < CmdlineBufferLength)
			{
				// increment the edit position
				CmdlineBufferEditPos++;
				// move cursor forward one space (no erase)
				cmdlineOutputFunc(ASCII_ESC);
				cmdlineOutputFunc('[');
				cmdlineOutputFunc(VT100_ARROWRIGHT);
			}
			else
			{
				// else, ring the bell
				cmdlineOutputFunc(ASCII_BEL);
			}
			break;
		case VT100_ARROWLEFT:
			// if the edit position is non-zero
			if(CmdlineBufferEditPos)
			{
				// decrement the edit position
				CmdlineBufferEditPos--;
				// move cursor back one space (no erase)
				cmdlineOutputFunc(ASCII_BS);
			}
			else
			{
				// else, ring the bell
				cmdlineOutputFunc(ASCII_BEL);
			}
			break;
		default:
			break;
		}
		// done, reset state
		CmdlineInputVT100State = 0;
		return;
	}
	else if(CmdlineInputVT100State == 1)
	{
		// we last received [ESC]
		if(c == '[')
		{
			CmdlineInputVT100State = 2;
			return;
		}
		else
			CmdlineInputVT100State = 0;
	}
	else
	{
		// anything else, reset state
		CmdlineInputVT100State = 0;
	}

	// Regular handling
	if( (c >= 0x20) && (c < 0x7F) )
	{
		// character is printable
		// is this a simple append
		if(CmdlineBufferEditPos == CmdlineBufferLength)
		{
			// echo character to the output
			cmdlineOutputFunc(c);
			// add it to the command line buffer
			CmdlineBuffer[CmdlineBufferEditPos++] = c;
			// update buffer length
			CmdlineBufferLength++;
		}
		else
		{
			// edit/cursor position != end of buffer
			// we're inserting characters at a mid-line edit position
			// make room at the insert point
			CmdlineBufferLength++;
			for(i=CmdlineBufferLength; i>CmdlineBufferEditPos; i--)
				CmdlineBuffer[i] = CmdlineBuffer[i-1];
			// insert character
			CmdlineBuffer[CmdlineBufferEditPos++] = c;
			// repaint
			cmdlineRepaint();
			// reposition cursor
			for(i=CmdlineBufferEditPos; i<CmdlineBufferLength; i++)
				cmdlineOutputFunc(ASCII_BS);
		}
	}
	// handle special characters
	else if(c == ASCII_CR)
	{
		// user pressed [ENTER]
		// echo CR and LF to terminal
		cmdlineOutputFunc(ASCII_CR);
		cmdlineOutputFunc(ASCII_LF);
		// add null termination to command
		CmdlineBuffer[CmdlineBufferLength++] = 0;
		CmdlineBufferEditPos++;
		// command is complete, process it
		cmdlineProcessInputString();
		// reset buffer
		CmdlineBufferLength = 0;
		CmdlineBufferEditPos = 0;
	}
	else if(c == ASCII_BS)
	{
		if(CmdlineBufferEditPos)
		{
			// is this a simple delete (off the end of the line)
			if(CmdlineBufferEditPos == CmdlineBufferLength)
			{
				// destructive backspace
				// echo backspace-space-backspace
				cmdlineOutputFunc(ASCII_BS);
				cmdlineOutputFunc(' ');
				cmdlineOutputFunc(ASCII_BS);
				// decrement our buffer length and edit position
				CmdlineBufferLength--;
				CmdlineBufferEditPos--;
			}
			else
			{
				// edit/cursor position != end of buffer
				// we're deleting characters at a mid-line edit position
				// shift characters down, effectively deleting
				CmdlineBufferLength--;
				CmdlineBufferEditPos--;
				for(i=CmdlineBufferEditPos; i<CmdlineBufferLength; i++)
					CmdlineBuffer[i] = CmdlineBuffer[i+1];
				// repaint
				cmdlineRepaint();
				// add space to clear leftover characters
				cmdlineOutputFunc(' ');
				// reposition cursor
				for(i=CmdlineBufferEditPos; i<(CmdlineBufferLength+1); i++)
					cmdlineOutputFunc(ASCII_BS);
			}
		}
		else
		{
			// else, ring the bell
			cmdlineOutputFunc(ASCII_BEL);
		}
	}
	else if(c == ASCII_DEL)
	{
		// not yet handled
	}
	else if(c == ASCII_ESC)
	{
		CmdlineInputVT100State = 1;
	}
}

void cmdlineRepaint(void)
{
	u08* ptr;
	u08 i;

	// carriage return
	cmdlineOutputFunc(ASCII_CR);
	// print fresh prompt
	cmdlinePrintPrompt();
	// print the new command line buffer
	i = CmdlineBufferLength;
	ptr = CmdlineBuffer;
	while(i--) cmdlineOutputFunc(*ptr++);
}

void cmdlineDoHistory(u08 action)
{
	switch(action)
	{
	case CMDLINE_HISTORY_SAVE:
		// copy CmdlineBuffer to history if not null string
		if( strlen(CmdlineBuffer) )
			strcpy(CmdlineHistory[0], CmdlineBuffer);
		break;
	case CMDLINE_HISTORY_PREV:
		// copy history to current buffer
		strcpy(CmdlineBuffer, CmdlineHistory[0]);
		// set the buffer position to the end of the line
		CmdlineBufferLength = strlen(CmdlineBuffer);
		CmdlineBufferEditPos = CmdlineBufferLength;
		// "re-paint" line
		cmdlineRepaint();
		break;
	case CMDLINE_HISTORY_NEXT:
		break;
	}
}

void cmdlineProcessInputString(void)
{
	u08 cmdIndex;
	u08 i=0;

	// save command in history
	cmdlineDoHistory(CMDLINE_HISTORY_SAVE);

	// find the end of the command (excluding arguments)
	// find first whitespace character in CmdlineBuffer
	while( !((CmdlineBuffer[i] == ' ') || (CmdlineBuffer[i] == 0)) ) i++;

	if(!i)
	{
		// command was null or empty
		// output a new prompt
		cmdlinePrintPrompt();
		// we're done
		return;
	}

	// search command list for match with entered command
	for(cmdIndex=0; cmdIndex<CmdlineNumCommands; cmdIndex++)
	{
		if( !strncmp(CmdlineCommandList[cmdIndex], CmdlineBuffer, i) )
		{
			// user-entered command matched a command in the list (database)
			// run the corresponding function
			CmdlineExecFunction = CmdlineFunctionList[cmdIndex];
			// new prompt will be output after user function runs
			// and we're done
			return;
		}
	}

	// if we did not get a match
	// output an error message
	cmdlinePrintError();
	// output a new prompt
	cmdlinePrintPrompt();
}

void cmdlineMainLoop(void)
{
	// do we have a command/function to be executed
	if(CmdlineExecFunction)
	{
		// run it
		CmdlineExecFunction();
		// reset
		CmdlineExecFunction = 0;
		// output new prompt
		cmdlinePrintPrompt();
	}
}

void cmdlinePrintPrompt(void)
{
	// print a new command prompt
	u08* ptr = CmdlinePrompt;
	while(PRG_RDB(ptr)) cmdlineOutputFunc( PRG_RDB(ptr++) );
}

void cmdlinePrintError(void)
{
	u08 * ptr;

	// print a notice header
	// (u08*) cast used to avoid compiler warning
	ptr = (u08*)CmdlineNotice;
	while(PRG_RDB(ptr)) cmdlineOutputFunc( PRG_RDB(ptr++) );
	
	// print the offending command
	ptr = CmdlineBuffer;
	while((*ptr) && (*ptr != ' ')) cmdlineOutputFunc(*ptr++);

	cmdlineOutputFunc(':');
	cmdlineOutputFunc(' ');

	// print the not-found message
	// (u08*) cast used to avoid compiler warning
	ptr = (u08*)CmdlineCmdNotFound;
	while(PRG_RDB(ptr)) cmdlineOutputFunc( PRG_RDB(ptr++) );

	cmdlineOutputFunc('\r');
	cmdlineOutputFunc('\n');
}

// argument retrieval commands

// return string pointer to argument [argnum]
u08* cmdlineGetArgStr(u08 argnum)
{
	// find the offset of argument number [argnum]
	u08 idx=0;
	u08 arg;
	
	// find the first non-whitespace character
	while( (CmdlineBuffer[idx] != 0) && (CmdlineBuffer[idx] == ' ')) idx++;
	
	// we are at the first argument
	for(arg=0; arg<argnum; arg++)
	{
		// find the next whitespace character
		while( (CmdlineBuffer[idx] != 0) && (CmdlineBuffer[idx] != ' ')) idx++;
		// find the first non-whitespace character
		while( (CmdlineBuffer[idx] != 0) && (CmdlineBuffer[idx] == ' ')) idx++;
	}
	// we are at the requested argument or the end of the buffer
	return &CmdlineBuffer[idx];
}

// return argument [argnum] interpreted as a decimal integer
long cmdlineGetArgInt(u08 argnum)
{
	char* endptr;
	return strtol(cmdlineGetArgStr(argnum), &endptr, 10);
}

// return argument [argnum] interpreted as a hex integer
long cmdlineGetArgHex(u08 argnum)
{
	char* endptr;
	return strtol(cmdlineGetArgStr(argnum), &endptr, 16);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
视频一区在线视频| 蜜臀av性久久久久蜜臀aⅴ流畅 | 久久一留热品黄| 91网上在线视频| 国产一区二区精品久久99| 亚洲午夜精品一区二区三区他趣| 久久久亚洲精品一区二区三区| 欧美色综合久久| 成熟亚洲日本毛茸茸凸凹| 麻豆视频观看网址久久| 亚洲美女偷拍久久| 国产精品女同一区二区三区| 日韩欧美一区二区免费| 欧美网站一区二区| 91久久国产综合久久| 懂色中文一区二区在线播放| 久久99国产精品免费网站| 一区二区免费在线| 亚洲欧美视频在线观看| 中文字幕不卡三区| 久久亚洲一区二区三区四区| 日韩区在线观看| 91麻豆精品国产91久久久使用方法| 色婷婷综合久久久久中文一区二区 | 免费黄网站欧美| 午夜精品久久久久久久| 亚洲一区二区四区蜜桃| 尤物av一区二区| 亚洲精品国久久99热| 亚洲色图一区二区| 国产精品国产自产拍在线| 国产精品毛片高清在线完整版| 久久久夜色精品亚洲| 久久看人人爽人人| 久久精品一二三| 国产色一区二区| 国产欧美视频一区二区| 欧美激情综合五月色丁香小说| 国产人妖乱国产精品人妖| 国产欧美一区二区精品性色超碰 | 制服.丝袜.亚洲.另类.中文| 欧美日韩大陆一区二区| 欧美日韩成人在线| 欧美老肥妇做.爰bbww视频| 欧美理论电影在线| 亚洲视频在线一区观看| 亚洲色图欧洲色图| 亚洲成人tv网| 伦理电影国产精品| 国模无码大尺度一区二区三区| 国产在线国偷精品产拍免费yy | 国产精品资源在线看| 国产成人在线影院| 99久久久免费精品国产一区二区| 91网站在线观看视频| 91搞黄在线观看| 91精品在线免费观看| 欧美电视剧在线观看完整版| 久久久精品国产99久久精品芒果| 国产精品网曝门| 亚洲综合色噜噜狠狠| 视频在线观看一区| 国产精品影视网| 91美女精品福利| 在线播放一区二区三区| 亚洲精品一线二线三线无人区| 国产精品沙发午睡系列990531| 亚洲乱码国产乱码精品精98午夜 | 欧美极品aⅴ影院| 国内精品自线一区二区三区视频| 国产麻豆精品久久一二三| 99re视频这里只有精品| 91精品国产综合久久蜜臀| 亚洲国产精品成人综合| 亚洲大片免费看| 国模一区二区三区白浆| 欧洲视频一区二区| 欧美tickling网站挠脚心| 国产精品天干天干在线综合| 五月婷婷欧美视频| 丁香桃色午夜亚洲一区二区三区| 色噜噜狠狠色综合中国| 精品国产乱码久久久久久影片| 中文字幕一区在线| 久久精品国产久精国产| 91天堂素人约啪| 精品国产青草久久久久福利| 亚洲欧美激情视频在线观看一区二区三区 | 国产成人在线观看免费网站| 欧洲一区在线电影| 国产欧美精品一区二区三区四区 | 久久久久久久久久久久久女国产乱 | 热久久一区二区| 99久久婷婷国产| 久久综合久久99| 视频在线观看国产精品| 91天堂素人约啪| 久久精品夜夜夜夜久久| 免费成人av在线播放| 91国偷自产一区二区开放时间| 精品免费视频一区二区| 亚洲国产wwwccc36天堂| 99视频一区二区三区| 精品国产乱码久久久久久老虎 | 欧美精品黑人性xxxx| 综合自拍亚洲综合图不卡区| 国产精品资源站在线| 日韩精品中文字幕一区二区三区 | 久久久久99精品一区| 日本特黄久久久高潮| 在线观看日产精品| 亚洲日本va午夜在线影院| 欧美亚洲动漫另类| 中文字幕不卡在线| 国产成人精品免费视频网站| 日韩欧美一级在线播放| 日韩av一级电影| 欧美久久久久久蜜桃| 一区二区三区四区在线| 99在线热播精品免费| 国产精品嫩草影院av蜜臀| 国产精品1024久久| 久久精品人人爽人人爽| 国产在线视频精品一区| 精品成人一区二区三区| 开心九九激情九九欧美日韩精美视频电影 | 欧美在线你懂得| 夜夜揉揉日日人人青青一国产精品| 国产69精品久久99不卡| 国产视频不卡一区| 国产91露脸合集magnet| 国产精品五月天| 成人午夜电影久久影院| 中文字幕乱码一区二区免费| 成人午夜碰碰视频| 国产精品久久久久9999吃药| 大桥未久av一区二区三区中文| 国产精品免费人成网站| 国产高清无密码一区二区三区| 亚洲一区二区三区四区在线| 在线观看网站黄不卡| 亚洲成在人线在线播放| 制服丝袜激情欧洲亚洲| 美日韩黄色大片| 久久久久久久综合狠狠综合| 国产91丝袜在线播放| 亚洲色欲色欲www| 欧美三级一区二区| 日本视频中文字幕一区二区三区 | 亚洲一区二区三区在线看| 欧美日韩在线精品一区二区三区激情| 亚洲不卡一区二区三区| 欧美mv日韩mv| www.av亚洲| 丝袜诱惑亚洲看片| 精品国产成人系列| 99久久综合99久久综合网站| 一区二区三区免费观看| 51精品国自产在线| 精品在线视频一区| 国产精品国产三级国产aⅴ中文| 色老综合老女人久久久| 蜜臀91精品一区二区三区| 国产欧美日韩一区二区三区在线观看 | 狠狠色丁香九九婷婷综合五月| 中文字幕第一区| 欧美肥大bbwbbw高潮| 国产伦精品一区二区三区在线观看| 中文字幕中文在线不卡住| 欧美在线短视频| 色婷婷国产精品| 精久久久久久久久久久| 亚洲美女少妇撒尿| 欧美大黄免费观看| 91网址在线看| 久久99精品国产麻豆婷婷| 亚洲精品免费一二三区| 日韩精品一区二区三区四区| 99视频一区二区三区| 麻豆国产欧美一区二区三区| 中文字幕亚洲欧美在线不卡| 91.成人天堂一区| 9i看片成人免费高清| 久久国产剧场电影| 亚洲理论在线观看| 久久色在线观看| 在线观看欧美精品| 国产成人免费视频一区| 日韩主播视频在线| 中文字幕一区在线观看| 精品少妇一区二区三区在线视频| 色av成人天堂桃色av| 国产精品自拍毛片| 日产精品久久久久久久性色| 亚洲色大成网站www久久九九| 久久品道一品道久久精品| 精品视频一区三区九区| 91亚洲国产成人精品一区二区三| 激情小说欧美图片| 免费欧美在线视频|