Changeset 1467 for trunk/src/win32k/misc/vprintf.c
- Timestamp:
- Oct 27, 1999, 4:03:01 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/misc/vprintf.c
r1271 r1467 1 /* $Id: vprintf.c,v 1. 1 1999-10-14 01:19:22bird Exp $1 /* $Id: vprintf.c,v 1.2 1999-10-27 02:03:00 bird Exp $ 2 2 * 3 3 * vprintf and printf … … 31 31 #include <stdarg.h> 32 32 33 #include "dev32.h" 34 #include "vprintf.h" 33 35 #ifdef RING0 34 #include "dev32.h" 35 #else 36 #define SSToDS(a) (a) 36 #include <builtin.h> 37 #include "options.h" 37 38 #endif 38 #include "vprintf.h" 39 39 40 41 /******************************************************************************* 42 * Global Variables * 43 *******************************************************************************/ 44 static char chNewLine = '\n'; 45 static char chReturn = '\r'; 40 46 41 47 /******************************************************************************* … … 44 50 static int _atoi_skip(const char **ppsz); 45 51 static unsigned _strnlen(const char *psz, unsigned cchMax); 46 _Inline void chout(int ch); 52 static void chout(int ch); 53 static char * strout(char *psz, signed cchMax); 47 54 48 55 … … 162 169 #if 0 163 170 else if (!(fFlags & NTSF_LEFT) && cchWidth > 0) 164 { /* not supported! */171 { /* not yet supported! */ 165 172 /* 166 173 for (j = i-1; j >= 0; j--) … … 207 214 int vprintf(const char *pszFormat, va_list args) 208 215 { 216 #ifdef RING0 217 if (options.fQuiet) 218 return 0; 219 #else 220 int cch = 0; 221 #endif 222 209 223 while (*pszFormat != '\0') 210 224 { 211 225 if (*pszFormat == '%') 212 226 { 227 #ifndef RING0 228 if (cch > 0) 229 { 230 strout((char*)(pszFormat - cch), cch); 231 cch = 0; 232 } 233 #endif 234 213 235 pszFormat++; /* skip '%' */ 214 236 if (*pszFormat == '%') /* '%%'-> '%' */ … … 306 328 case 's': /* string */ 307 329 { 308 int i;309 330 int cchStr; 310 331 char *pszStr = va_arg(args, char*); … … 316 337 while (--cchWidth >= cchStr) 317 338 chout(' '); 318 for (i = cchStr; i > 0; i--) 319 chout(*pszStr++);339 340 pszStr = strout(pszStr, cchStr); 320 341 321 342 while (--cchWidth >= cchStr) … … 352 373 } 353 374 else 354 chout(*pszFormat++); 355 } 375 { 376 #ifdef RING0 377 chout(*pszFormat++); 378 #else 379 cch++; 380 pszFormat++; 381 #endif 382 } 383 } 384 385 #ifndef RING0 386 if (cch > 0) 387 { 388 strout((char*)(pszFormat - cch), cch); 389 cch = 0; 390 } 391 #endif 356 392 357 393 return 0UL; … … 376 412 va_list arguments; 377 413 414 #ifdef RING0 415 if (options.fQuiet) 416 return 0; 417 #endif 418 378 419 va_start(arguments, pszFormat); 379 420 cch = vprintf(pszFormat, arguments); … … 390 431 va_list arguments; 391 432 433 #ifdef RING0 434 if (options.fQuiet) 435 return 0; 436 #endif 437 392 438 va_start(arguments, pszFormat); 393 439 cch = vprintf(pszFormat, arguments); … … 402 448 int cch; 403 449 va_list arguments; 450 451 #ifdef RING0 452 if (options.fQuiet) 453 return 0; 454 #endif 404 455 405 456 va_start(arguments, pszFormat); … … 419 470 * @author knut st. osmundsen 420 471 */ 421 _Inline void chout(int ch) 422 { 423 #ifdef RING0 424 425 #else 472 static void chout(int ch) 473 { 474 #ifndef RING0 426 475 ULONG ulWrote; 427 476 #endif … … 431 480 if (ch == '\n') 432 481 { 433 static char chReturn = '\r';434 482 #ifdef RING0 435 483 while (!(_inp(options.usCom + 5) & 0x20)); /* Waits for the port to be ready. */ 484 _outp(options.usCom, chReturn); /* Put the char. */ 436 485 #else 437 486 DosWrite(1, (void*)&chReturn, 1, &ulWrote); … … 439 488 } 440 489 #ifdef RING0 441 490 while (!(_inp(options.usCom + 5) & 0x20)); /* Waits for the port to be ready. */ 491 _outp(options.usCom, ch); /* Put the char. */ 442 492 #else 443 493 DosWrite(1, (void*)&ch, 1, &ulWrote); … … 446 496 } 447 497 498 499 /** 500 * Write a string to the output device. 501 * @returns pointer end of string. 502 * @param psz Pointer to the string to write. 503 * @param cchMax Max count of chars to write. (or until '\0') 504 * @status completely implemented. 505 * @author knut st. osmundsen 506 */ 507 static char *strout(char *psz, signed cchMax) 508 { 509 while (cchMax > 0 && *psz != '\0') 510 { 511 ULONG cch = 0; 512 ULONG ul; 513 514 while (cchMax - cch > 0 && psz[cch] != '\0' && psz[cch] != '\r' && psz[cch] != '\n') 515 cch++; 516 517 /* write string part */ 518 #ifdef RING0 519 for (ul = 0; ul < cch; ul++) 520 { 521 while (!(_inp(options.usCom + 5) & 0x20)); /* Waits for the port to be ready. */ 522 _outp(options.usCom, psz[ul]); /* Put the char. */ 523 } 524 #else 525 DosWrite(1, (void*)psz, cch, &ul); 526 #endif 527 528 /* cr and lf check + skip */ 529 if (psz[cch] == '\n' || psz[cch] == '\r') 530 { 531 if (psz[cch] == '\n') 532 { 533 #ifdef RING0 534 while (!(_inp(options.usCom + 5) & 0x20)); /* Waits for the port to be ready. */ 535 _outp(options.usCom, chReturn); /* Put the char. */ 536 while (!(_inp(options.usCom + 5) & 0x20)); /* Waits for the port to be ready. */ 537 _outp(options.usCom, chNewLine); /* Put the char. */ 538 #else 539 DosWrite(1, (void*)&chReturn, 1, &ul); 540 DosWrite(1, (void*)&chNewLine, 1, &ul); 541 #endif 542 543 } 544 545 while (cchMax - cch > 0 && (psz[cch] == '\r' || psz[cch] == '\n')) 546 cch++; 547 } 548 549 /* next */ 550 psz += cch; 551 cchMax -= cch; 552 } 553 return psz; 554 } 555
Note:
See TracChangeset
for help on using the changeset viewer.