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