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

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

?? printf_p.c

?? 遙控電子玩具飛機用的控制前進后退的程序包
?? C
字號:
// Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist nicht von der Lizenz f黵 den MikroKopter-Teil unterstellt

/* 
Copyright (C) 1993 Free Software Foundation

This file is part of the GNU IO Library.  This library is free
software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this library; see the file COPYING.  If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

As a special exception, if you link this library with files
compiled with a GNU compiler to produce an executable, this does not cause
the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */

/*
 * Copyright (c) 1990 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. [rescinded 22 July 1999]
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/******************************************************************************
 This file is a patched version of printf called _printf_P
 It is made to work with avr-gcc for Atmel AVR MCUs.
 There are some differences from standard printf:
 	1. There is no floating point support (with fp the code is about 8K!)
 	2. Return type is void
 	3. Format string must be in program memory (by using macro printf this is
 	   done automaticaly)
 	4. %n is not implemented (just remove the comment around it if you need it)
 	5. If LIGHTPRINTF is defined, the code is about 550 bytes smaller and the
 	   folowing specifiers are disabled :
 		space # * . - + p s o O
	6. A function void uart_sendchar(char c) is used for output. The UART must
		be initialized before using printf.

 Alexander Popov
 sasho@vip.orbitel.bg
******************************************************************************/

/*
 * Actual printf innards.
 *
 * This code is large and complicated...
 */

#include <string.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif

#include "main.h"


//#define LIGHTPRINTF
char PrintZiel;


char Putchar(char zeichen)
{
 if(PrintZiel == OUT_LCD) { DisplayBuff[DispPtr++] = zeichen; return(1);}
 else                       return(uart_putchar(zeichen));
}


void PRINT(const char * ptr, unsigned int len) 
{
 for(;len;len--) Putchar(*ptr++);
}
  
void PRINTP(const char * ptr, unsigned int len) 
{
 for(;len;len--) Putchar(pgm_read_byte(ptr++));
}

void PAD_SP(signed char howmany) 
{
	for(;howmany>0;howmany--) Putchar(' ');
}

void PAD_0(signed char howmany) 
{
	for(;howmany>0;howmany--) Putchar('0');
}

#define	BUF		40

/*
 * Macros for converting digits to letters and vice versa
 */
#define	to_digit(c)	((c) - '0')
#define  is_digit(c)	((c)<='9' && (c)>='0')
#define	to_char(n)	((n) + '0')

/*
 * Flags used during conversion.
 */
#define	LONGINT		0x01		/* long integer */
#define	LONGDBL		0x02		/* long double; unimplemented */
#define	SHORTINT		0x04		/* short integer */
#define	ALT			0x08		/* alternate form */
#define	LADJUST		0x10		/* left adjustment */
#define	ZEROPAD		0x20		/* zero (as opposed to blank) pad */
#define	HEXPREFIX	0x40		/* add 0x or 0X prefix */

void _printf_P (char ziel,char const *fmt0, ...)      /* Works with string from FLASH */
{
 	va_list ap;
	register const char *fmt; /* format string */
	register char ch;	/* character from fmt */
	register int n;		/* handy integer (short term usage) */
	register char *cp;	/* handy char pointer (short term usage) */
	const char *fmark;	/* for remembering a place in fmt */
	register unsigned char flags;	/* flags as above */
	signed char width;		/* width from format (%8d), or 0 */
	signed char prec;		/* precision from format (%.3d), or -1 */
	char sign;				/* sign prefix (' ', '+', '-', or \0) */
	unsigned long _ulong=0;	/* integer arguments %[diouxX] */
#define OCT 8
#define DEC 10
#define HEX 16
	unsigned char base;		/* base for [diouxX] conversion */
	signed char dprec;		/* a copy of prec if [diouxX], 0 otherwise */
	signed char dpad;			/* extra 0 padding needed for integers */
	signed char fieldsz;		/* field size expanded by sign, dpad etc */
	/* The initialization of 'size' is to suppress a warning that
	   'size' might be used unitialized.  It seems gcc can't
	   quite grok this spaghetti code ... */
	signed char size = 0;		/* size of converted field or string */
	char buf[BUF];		/* space for %c, %[diouxX], %[eEfgG] */
	char ox[2];			/* space for 0x hex-prefix */

    PrintZiel = ziel;  // bestimmt, LCD oder UART
	va_start(ap, fmt0);
	
	fmt = fmt0;

	/*
	 * Scan the format for conversions (`%' character).
	 */
	for (;;) {
		for (fmark = fmt; (ch = pgm_read_byte(fmt)) != '\0' && ch != '%'; fmt++)
			/* void */;
		if ((n = fmt - fmark) != 0) {
			PRINTP(fmark, n);
		}
		if (ch == '\0')
			goto done;
		fmt++;		/* skip over '%' */

		flags = 0;
		dprec = 0;
		width = 0;
		prec = -1;
		sign = '\0';

rflag:		ch = PRG_RDB(fmt++);
reswitch:
#ifdef LIGHTPRINTF
	if (ch=='o' || ch=='u' || (ch|0x20)=='x') {
#else
	if (ch=='u' || (ch|0x20)=='x') {
#endif
		if (flags&LONGINT) {
		 	_ulong=va_arg(ap, unsigned long);
		} else {
			register unsigned int _d;
			_d=va_arg(ap, unsigned int);
			_ulong = flags&SHORTINT ? (unsigned long)(unsigned short)_d : (unsigned long)_d;
		}
	}
 	
#ifndef LIGHTPRINTF
		if(ch==' ') {
			/*
			 * ``If the space and + flags both appear, the space
			 * flag will be ignored.''
			 *	-- ANSI X3J11
			 */
			if (!sign)
				sign = ' ';
			goto rflag;
		} else if (ch=='#') {
			flags |= ALT;
			goto rflag;
		} else if (ch=='*'||ch=='-') {
			if (ch=='*') {
				/*
				 * ``A negative field width argument is taken as a
				 * - flag followed by a positive field width.''
				 *	-- ANSI X3J11
				 * They don't exclude field widths read from args.
				 */
				if ((width = va_arg(ap, int)) >= 0)
					goto rflag;
				width = -width;
			}
			flags |= LADJUST;
			flags &= ~ZEROPAD; /* '-' disables '0' */
			goto rflag;
		} else if (ch=='+') {
			sign = '+';
			goto rflag;
		} else if (ch=='.') {
			if ((ch = PRG_RDB(fmt++)) == '*') {
				n = va_arg(ap, int);
				prec = n < 0 ? -1 : n;
				goto rflag;
			}
			n = 0;
			while (is_digit(ch)) {
				n = n*10 + to_digit(ch);
				ch = PRG_RDB(fmt++);
			}
			prec = n < 0 ? -1 : n;
			goto reswitch;
		} else
#endif /* LIGHTPRINTF */
		if (ch=='0') {
			/*
			 * ``Note that 0 is taken as a flag, not as the
			 * beginning of a field width.''
			 *	-- ANSI X3J11
			 */
			if (!(flags & LADJUST))
			    flags |= ZEROPAD; /* '-' disables '0' */
			goto rflag;
		} else if (ch>='1' && ch<='9') {
			n = 0;
			do {
				n = 10 * n + to_digit(ch);
				ch = PRG_RDB(fmt++);
			} while (is_digit(ch));
			width = n;
			goto reswitch;
		} else if (ch=='h') {
			flags |= SHORTINT;
			goto rflag;
		} else if (ch=='l') {
			flags |= LONGINT;
			goto rflag;
		} else if (ch=='c') {
			*(cp = buf) = va_arg(ap, int);
			size = 1;
			sign = '\0';
		} else if (ch=='D'||ch=='d'||ch=='i') {
			if(ch=='D')
				flags |= LONGINT;
			if (flags&LONGINT) {
			 	_ulong=va_arg(ap, long);
			} else {
				register int _d;
				_d=va_arg(ap, int);
				_ulong = flags&SHORTINT ? (long)(short)_d : (long)_d;
			}
    			
			if ((long)_ulong < 0) {
				_ulong = -_ulong;
				sign = '-';
			}
			base = DEC;
			goto number;
		} else
/*		
		if (ch=='n') {
			if (flags & LONGINT)
				*va_arg(ap, long *) = ret;
			else if (flags & SHORTINT)
				*va_arg(ap, short *) = ret;
			else
				*va_arg(ap, int *) = ret;
			continue;	// no output 
		} else
*/
#ifndef LIGHTPRINTF			
		if (ch=='O'||ch=='o') {
			if (ch=='O')
				flags |= LONGINT;
			base = OCT;
			goto nosign;
		} else if (ch=='p') {
			/*
			 * ``The argument shall be a pointer to void.  The
			 * value of the pointer is converted to a sequence
			 * of printable characters, in an implementation-
			 * defined manner.''
			 *	-- ANSI X3J11
			 */
			/* NOSTRICT */
			_ulong = (unsigned int)va_arg(ap, void *);
			base = HEX;
			flags |= HEXPREFIX;
			ch = 'x';
			goto nosign;
		} else if (ch=='s') {  // print a string from RAM
			if ((cp = va_arg(ap, char *)) == NULL) {
				cp=buf;
				cp[0] = '(';
				cp[1] = 'n';
				cp[2] = 'u';
				cp[4] = cp[3] = 'l';
				cp[5] = ')';
				cp[6] = '\0';
			}
			if (prec >= 0) {
				/*
				 * can't use strlen; can only look for the
				 * NUL in the first `prec' characters, and
				 * strlen() will go further.
				 */
				char *p = (char*)memchr(cp, 0, prec);

				if (p != NULL) {
					size = p - cp;
					if (size > prec)
						size = prec;
				} else
					size = prec;
			} else
				size = strlen(cp);
			sign = '\0';
		} else
#endif /* LIGHTPRINTF */			
		if(ch=='U'||ch=='u') {
			if (ch=='U')
				flags |= LONGINT;
			base = DEC;
			goto nosign;
		} else if (ch=='X'||ch=='x') {
			base = HEX;
			/* leading 0x/X only if non-zero */
			if (flags & ALT && _ulong != 0)
				flags |= HEXPREFIX;

			/* unsigned conversions */
nosign:			sign = '\0';
			/*
			 * ``... diouXx conversions ... if a precision is
			 * specified, the 0 flag will be ignored.''
			 *	-- ANSI X3J11
			 */
number:	if ((dprec = prec) >= 0)
				flags &= ~ZEROPAD;

			/*
			 * ``The result of converting a zero value with an
			 * explicit precision of zero is no characters.''
			 *	-- ANSI X3J11
			 */
			cp = buf + BUF;
			if (_ulong != 0 || prec != 0) {
				register unsigned char _d,notlastdigit;
				do {
					notlastdigit=(_ulong>=base);
					_d = _ulong % base;

					if (_d<10) {
						_d+='0';
					} else {
						_d+='a'-10;
						if (ch=='X') _d&=~0x20;
					}
					*--cp=_d;
					_ulong /= base;
				} while (notlastdigit);
#ifndef LIGHTPRINTF
				// handle octal leading 0 
				if (base==OCT && flags & ALT && *cp != '0')
					*--cp = '0';
#endif
			}

			size = buf + BUF - cp;
	} else {  //default
		/* "%?" prints ?, unless ? is NUL */
			if (ch == '\0')
				goto done;
			/* pretend it was %c with argument ch */
			cp = buf;
			*cp = ch;
			size = 1;
			sign = '\0';
		}

		/*
		 * All reasonable formats wind up here.  At this point,
		 * `cp' points to a string which (if not flags&LADJUST)
		 * should be padded out to `width' places.  If
		 * flags&ZEROPAD, it should first be prefixed by any
		 * sign or other prefix; otherwise, it should be blank
		 * padded before the prefix is emitted.  After any
		 * left-hand padding and prefixing, emit zeroes
		 * required by a decimal [diouxX] precision, then print
		 * the string proper, then emit zeroes required by any
		 * leftover floating precision; finally, if LADJUST,
		 * pad with blanks.
		 */

		/*
		 * compute actual size, so we know how much to pad.
		 */
		fieldsz = size;

		dpad = dprec - size;
		if (dpad < 0)
		    dpad = 0;

		if (sign)
			fieldsz++;
		else if (flags & HEXPREFIX)
			fieldsz += 2;
		fieldsz += dpad;

		/* right-adjusting blank padding */
		if ((flags & (LADJUST|ZEROPAD)) == 0)
			PAD_SP(width - fieldsz);

		/* prefix */
		if (sign) {
			PRINT(&sign, 1);
		} else if (flags & HEXPREFIX) {
			ox[0] = '0';
			ox[1] = ch;
			PRINT(ox, 2);
		}

		/* right-adjusting zero padding */
		if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
			PAD_0(width - fieldsz);

		/* leading zeroes from decimal precision */
		PAD_0(dpad);

		/* the string or number proper */
		PRINT(cp, size);

		/* left-adjusting padding (always blank) */
		if (flags & LADJUST)
			PAD_SP(width - fieldsz);
	}
done:
	va_end(ap);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品亚洲乱码伦伦中文| 这里只有精品视频在线观看| 黑人巨大精品欧美一区| 夜夜精品视频一区二区| 亚洲一区在线观看视频| 亚洲综合999| 午夜精品久久久久久久| 天天做天天摸天天爽国产一区| 午夜精品一区在线观看| 人禽交欧美网站| 久久99精品久久久久久国产越南 | 日韩欧美在线不卡| 在线成人免费观看| 日韩精品在线一区| 国产三级欧美三级| 亚洲欧美日韩国产一区二区三区| 亚洲老妇xxxxxx| 天天爽夜夜爽夜夜爽精品视频| 婷婷成人综合网| 韩国三级中文字幕hd久久精品| 成人a免费在线看| 一本色道**综合亚洲精品蜜桃冫| 在线视频你懂得一区| 欧美一区二区三区在线观看视频| 久久亚洲免费视频| 亚洲美女一区二区三区| 日精品一区二区三区| 国产福利视频一区二区三区| 91老司机福利 在线| 欧美一区二区三区四区五区| 欧美国产一区二区在线观看| 亚洲最大色网站| 激情久久五月天| 欧美亚洲国产一区在线观看网站| 精品99久久久久久| 亚洲精品久久久久久国产精华液| 久久国产综合精品| 91成人在线观看喷潮| 精品国产伦一区二区三区观看体验 | 午夜影视日本亚洲欧洲精品| 麻豆成人av在线| 色偷偷88欧美精品久久久| 欧美成人一区二区三区| 一区二区三区精品久久久| 国产一区二区在线观看免费| 在线观看区一区二| 国产欧美日本一区视频| 日本欧美大码aⅴ在线播放| av一区二区不卡| 久久天堂av综合合色蜜桃网| 亚洲成人动漫在线免费观看| av不卡在线播放| 久久精品在线免费观看| 日韩黄色免费网站| 日本精品视频一区二区| 中文字幕第一页久久| 另类小说欧美激情| 91精品国产色综合久久不卡蜜臀| 综合av第一页| 97se亚洲国产综合自在线不卡 | 亚洲一区二区三区美女| 成人深夜福利app| 久久色.com| 久久超碰97中文字幕| 4438x成人网最大色成网站| 亚洲激情在线激情| 色综合久久综合网| 成人免费在线视频| 成人午夜免费av| 中文字幕二三区不卡| 成人免费毛片片v| 国产精品理论片在线观看| 国产福利一区在线观看| 国产欧美精品一区二区色综合朱莉| 麻豆91在线观看| 久久夜色精品国产噜噜av| 激情图区综合网| 久久中文娱乐网| 国产精品一区二区你懂的| 国产亚洲精品aa午夜观看| 丰满放荡岳乱妇91ww| 国产精品久久久久影院色老大| 国产精品1区2区| 欧美激情一区三区| 94色蜜桃网一区二区三区| 亚洲色图欧美在线| 欧美日韩激情一区| 免费不卡在线视频| 久久婷婷久久一区二区三区| 轻轻草成人在线| 日韩欧美电影一区| 成人午夜av电影| 一区二区欧美国产| 这里是久久伊人| 国产成人免费av在线| 亚洲女子a中天字幕| 欧美日韩国产a| 国产一区二区免费在线| 中文字幕视频一区| 欧美日韩精品免费观看视频| 麻豆国产精品视频| 亚洲色欲色欲www| 在线播放欧美女士性生活| 狠狠色丁香久久婷婷综合丁香| 国产精品水嫩水嫩| 欧美精品在线一区二区三区| 国模套图日韩精品一区二区| 中文字幕欧美三区| 欧美疯狂性受xxxxx喷水图片| 国产在线精品免费| 一区二区三区欧美激情| 欧美草草影院在线视频| 99国产精品久久久久| 伦理电影国产精品| 亚洲靠逼com| 日本一区二区三区视频视频| 欧美色网站导航| 国产麻豆精品95视频| 亚洲动漫第一页| 国产精品无遮挡| 欧美精品一区二区三区久久久 | 日本午夜一本久久久综合| 久久精品人人爽人人爽| 制服丝袜av成人在线看| eeuss国产一区二区三区| 六月丁香综合在线视频| 亚洲成人一区二区| 亚洲精品乱码久久久久久| 国产女人水真多18毛片18精品视频| 欧美日韩亚州综合| 99精品在线免费| 国产黄色精品网站| 麻豆精品一区二区综合av| 亚洲一区二区精品3399| 欧美国产日韩一二三区| 精品电影一区二区三区| 欧美一区午夜视频在线观看| 色偷偷88欧美精品久久久| 成人美女视频在线观看18| 国产精品一区二区在线看| 日本成人在线电影网| 日韩av一区二区在线影视| 亚洲成人免费在线观看| 亚洲第一综合色| 日韩国产在线一| 亚洲色欲色欲www在线观看| 国产精品色哟哟| 国产精品水嫩水嫩| 国产精品国产a| 国产精品国产三级国产有无不卡 | 亚洲欧洲日韩在线| 国产精品美女久久久久久久久 | 精品一区二区日韩| 美腿丝袜亚洲一区| 久久国产精品露脸对白| 免费成人美女在线观看| 精品一区二区三区久久| 国产精品一级片在线观看| 国产高清精品久久久久| 成人免费va视频| 色老汉一区二区三区| 在线观看视频欧美| 欧美日本免费一区二区三区| 欧美一区二区三区在线电影| 日韩欧美国产午夜精品| 久久久精品欧美丰满| 国产精品美女久久久久高潮| 亚洲美女精品一区| 日日夜夜精品视频天天综合网| 免费在线成人网| 成人性生交大片| 在线视频观看一区| 日韩欧美国产电影| 国产精品美女www爽爽爽| 亚洲欧美视频在线观看| 婷婷夜色潮精品综合在线| 国产乱人伦精品一区二区在线观看| 成人一级片网址| 欧美亚洲国产一卡| 欧美大片顶级少妇| 亚洲欧美另类图片小说| 日韩电影免费一区| 国产精品18久久久久| 欧美亚洲动漫制服丝袜| 26uuu精品一区二区| 一区二区三区在线视频免费| 美女尤物国产一区| 成人黄页毛片网站| 91麻豆精品国产91久久久使用方法| 国产欧美一区二区三区网站| 性欧美大战久久久久久久久| 国产精品18久久久久久vr| 欧美视频在线播放| 国产精品理论片| 久久精品国产精品亚洲红杏| 91黄色激情网站| 久久久www成人免费毛片麻豆| 亚洲成人动漫精品| 99re这里只有精品6| 久久理论电影网|