]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/console.c
boot-80.1.tar.gz
[apple/boot.git] / i386 / libsaio / console.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 * Mach Operating System
26 * Copyright (c) 1990 Carnegie-Mellon University
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * All rights reserved. The CMU software License Agreement specifies
29 * the terms and conditions for use and redistribution.
30 */
31
32 /*
33 * INTEL CORPORATION PROPRIETARY INFORMATION
34 *
35 * This software is supplied under the terms of a license agreement or
36 * nondisclosure agreement with Intel Corporation and may not be copied
37 * nor disclosed except in accordance with the terms of that agreement.
38 *
39 * Copyright 1988, 1989 Intel Corporation
40 */
41
42 /*
43 * Copyright 1993 NeXT, Inc.
44 * All rights reserved.
45 */
46
47 #include "libsaio.h"
48
49 BOOL verbose_mode;
50 BOOL errors;
51
52 /*
53 * write one character to console
54 */
55 void putchar(int c)
56 {
57 if ( c == '\t' )
58 {
59 for (c = 0; c < 8; c++) putc(' ');
60 return;
61 }
62
63 if ( c == '\n' )
64 {
65 putc('\r');
66 }
67
68 putc(c);
69 }
70
71 int getc()
72 {
73 int c = bgetc();
74
75 if ((c & 0xff) == 0)
76 return c;
77 else
78 return (c & 0xff);
79 }
80
81 // Read and echo a character from console. This doesn't echo backspace
82 // since that screws up higher level handling
83
84 int getchar()
85 {
86 register int c = getc();
87
88 if ( c == '\r' ) c = '\n';
89
90 if ( c >= ' ' && c < 0x7f) putchar(c);
91
92 return (c);
93 }
94
95 int printf(const char * fmt, ...)
96 {
97 va_list ap;
98 va_start(ap, fmt);
99 prf(fmt, ap, putchar, 0);
100 va_end(ap);
101 return 0;
102 }
103
104 int verbose(const char * fmt, ...)
105 {
106 va_list ap;
107
108 if (verbose_mode)
109 {
110 va_start(ap, fmt);
111 prf(fmt, ap, putchar, 0);
112 va_end(ap);
113 }
114 return(0);
115 }
116
117 int error(const char * fmt, ...)
118 {
119 va_list ap;
120 errors = YES;
121 va_start(ap, fmt);
122 prf(fmt, ap, putchar, 0);
123 va_end(ap);
124 return(0);
125 }