📄 format.c
字号:
/* * $Id: format.c,v 1.1 2002/12/05 22:20:38 telka Exp $ * * Copyright (C) 2001, 2002 ETC s.r.o. * * This program 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 * of the License, or (at your option) any later version. * * This program 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * Written by Marcel Telka <marcel@telka.sk>, 2001, 2002. * */#include <_windows.h>#include <stdarg.h>#include <nkintr.h>#include "format.h"static void OutputByte( BYTE c );static void OutputNumHex( unsigned long n, long depth );static void OutputNumDecimal( unsigned long n );static void OutputString( const char *s );voidEdbgOutputDebugString( const char *fmt, ... ){ char c; va_list vl; va_start( vl, fmt ); while (*fmt) { c = *fmt++; switch (c) { case '%': c = *fmt++; switch (c) { case 'x': OutputNumHex( va_arg( vl, unsigned long ), 0 ); break; case 'B': OutputNumHex( va_arg( vl, unsigned long ), 2 ); break; case 'H': OutputNumHex( va_arg( vl, unsigned long ), 4 ); break; case 'X': OutputNumHex( va_arg( vl, unsigned long ), 8 ); break; case 'd':{ long l; l = va_arg( vl, long ); if (l < 0) { OutputByte( '-' ); l = -l; } OutputNumDecimal( (unsigned long) l ); } break; case 'u': OutputNumDecimal( va_arg( vl, unsigned long ) ); break; case 's': OutputString( va_arg( vl, char * ) ); break; case '%': OutputByte( '%' ); break; case 'c': c = va_arg( vl, unsigned char ); OutputByte( c ); break; default: OutputByte( ' ' ); break; } break; case '\n': OutputByte( '\r' ); default: OutputByte( c ); } } va_end( vl );}static voidOutputByte( BYTE c ){ OEMWriteDebugByte( c );}static voidOutputNumHex( unsigned long n, long depth ){ if (depth) depth--; if ((n & ~0xF) || depth) { OutputNumHex( n >> 4, depth ); n &= 0xF; } if (n < 10) OutputByte( (BYTE) (n + '0') ); else OutputByte( (BYTE) (n - 10 + 'A') );}static voidOutputNumDecimal( unsigned long n ){ if (n >= 10) { OutputNumDecimal( n / 10 ); n %= 10; } OutputByte( (BYTE) (n + '0') );}static voidOutputString( const char *s ){ while (*s) { if (*s == '\n') OutputByte( '\r' ); OutputByte( *s++ ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -