Rev 2377 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2377 | Rev 2435 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | /* |
|
- | 2 | * Copyright (c) 1987,1997, Prentice Hall |
|
- | 3 | * All rights reserved. |
|
- | 4 | * |
|
- | 5 | * Redistribution and use of the MINIX operating system in source and |
|
- | 6 | * binary forms, with or without modification, are permitted provided |
|
1 | /* Functions for printing on console. */ |
7 | * that the following conditions are met: |
2 | 8 | ||
- | 9 | * - Redistributions of source code must retain the above copyright |
|
- | 10 | * notice, this list of conditions and the following disclaimer. |
|
3 | 11 | ||
- | 12 | * - Redistributions in binary form must reproduce the above |
|
- | 13 | * copyright notice, this list of conditions and the following |
|
- | 14 | * disclaimer in the documentation and/or other materials provided |
|
4 | /* Methods: |
15 | * with the distribution. |
- | 16 | ||
5 | * init_printing: connects to SERVICE_CONSOLE and initializes used data structures |
17 | * - Neither the name of Prentice Hall nor the names of the software |
6 | * print_console: prints char* on console |
18 | * authors or contributors may be used to endorse or promote |
7 | * print_console_int: prints int argument with specified conversion inside input string |
19 | * products derived from this software without specific prior |
- | 20 | * written permission. |
|
- | 21 | ||
- | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND |
|
- | 23 | * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
- | 24 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
- | 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
- | 26 | * IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE |
|
- | 27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
- | 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
- | 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
|
- | 30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
- | 31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
|
- | 32 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
- | 33 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
- | 34 | */ |
|
- | 35 | ||
- | 36 | /** @addtogroup FileSystemImpl |
|
- | 37 | * @{ |
|
- | 38 | */ |
|
- | 39 | ||
- | 40 | /** |
|
- | 41 | * @file printing.c |
|
- | 42 | * @brief Functions for printing on console. |
|
8 | */ |
43 | */ |
9 | 44 | ||
10 | 45 | ||
11 | #include <string.h> |
46 | #include <string.h> |
12 | #include <ipc/ipc.h> |
47 | #include <ipc/ipc.h> |
Line 17... | Line 52... | ||
17 | 52 | ||
18 | #define TOTAL_CONVERSIONS 5 |
53 | #define TOTAL_CONVERSIONS 5 |
19 | #define BUFF_SIZE 10 |
54 | #define BUFF_SIZE 10 |
20 | 55 | ||
21 | 56 | ||
- | 57 | /** |
|
22 | /* Table of printing conversions for: d, i, u, c, %. */ |
58 | * Table of printing conversions for: d, i, u, c, %. |
- | 59 | */ |
|
23 | char conversions[TOTAL_CONVERSIONS]; |
60 | char conversions[TOTAL_CONVERSIONS]; |
24 | char format_string[3] = "%"; |
61 | char format_string[3] = "%"; |
25 | 62 | ||
26 | static int validate_string(char conv); |
63 | static int validate_string(char conv); |
27 | 64 | ||
- | 65 | /** |
|
- | 66 | * Connects to SERVICE_CONSOLE and initializes used data structures |
|
- | 67 | */ |
|
28 | int init_printing() |
68 | int init_printing() |
29 | { |
69 | { |
30 | 70 | ||
31 | /* Attempt to connect to SERVICE_CONSOLE fail. */ |
71 | /* Attempt to connect to SERVICE_CONSOLE fail. */ |
32 | if (!connect_to_con(&con_phone, CON_CONN_ATTEMPTS)) |
72 | if (!connect_to_con(&con_phone, CON_CONN_ATTEMPTS)) |
Line 38... | Line 78... | ||
38 | conversions[3] = 'c'; |
78 | conversions[3] = 'c'; |
39 | conversions[4] = '%'; |
79 | conversions[4] = '%'; |
40 | 80 | ||
41 | } |
81 | } |
42 | 82 | ||
- | 83 | /** |
|
- | 84 | * Check whether the conversion character matches the conversions table |
|
- | 85 | */ |
|
43 | int validate_string(char conv) |
86 | int validate_string(char conv) |
44 | { |
87 | { |
45 | 88 | ||
46 | int i; |
89 | int i; |
47 | 90 | ||
Line 53... | Line 96... | ||
53 | } |
96 | } |
54 | 97 | ||
55 | return FALSE; |
98 | return FALSE; |
56 | } |
99 | } |
57 | 100 | ||
- | 101 | /** |
|
- | 102 | * Prints char* on console |
|
- | 103 | */ |
|
58 | int print_console(char *str) |
104 | int print_console(char *str) |
59 | { |
105 | { |
60 | 106 | ||
61 | int i, len; |
107 | int i, len; |
62 | char c; |
108 | char c; |
Line 75... | Line 121... | ||
75 | } |
121 | } |
76 | 122 | ||
77 | return TRUE; |
123 | return TRUE; |
78 | } |
124 | } |
79 | 125 | ||
- | 126 | /** |
|
- | 127 | * Prints int argument with specified conversion inside input string |
|
- | 128 | */ |
|
80 | int print_console_int(char *str, int arg) |
129 | int print_console_int(char *str, int arg) |
81 | { |
130 | { |
82 | 131 | ||
83 | int i, retval, len, front_side, offset; |
132 | int i, retval, len, front_side, offset; |
84 | char conversion; |
133 | char conversion; |
Line 145... | Line 194... | ||
145 | print_console(buffer); |
194 | print_console(buffer); |
146 | print_console(back); |
195 | print_console(back); |
147 | 196 | ||
148 | return TRUE; |
197 | return TRUE; |
149 | } |
198 | } |
- | 199 | ||
- | 200 | /** |
|
- | 201 | * } |
|
- | 202 | */ |
|
- | 203 |