Blame


1 78e51a8c 2005-01-14 devnull <head>
2 78e51a8c 2005-01-14 devnull <title>print(3) - Plan 9 from User Space</title>
3 78e51a8c 2005-01-14 devnull <meta content="text/html; charset=utf-8" http-equiv=Content-Type>
4 78e51a8c 2005-01-14 devnull </head>
5 78e51a8c 2005-01-14 devnull <body bgcolor=#ffffff>
6 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0 width=100%>
7 78e51a8c 2005-01-14 devnull <tr height=10><td>
8 78e51a8c 2005-01-14 devnull <tr><td width=20><td>
9 78e51a8c 2005-01-14 devnull <tr><td width=20><td><b>PRINT(3)</b><td align=right><b>PRINT(3)</b>
10 78e51a8c 2005-01-14 devnull <tr><td width=20><td colspan=2>
11 78e51a8c 2005-01-14 devnull <br>
12 78e51a8c 2005-01-14 devnull <p><font size=+1><b>NAME </b></font><br>
13 78e51a8c 2005-01-14 devnull
14 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
15 78e51a8c 2005-01-14 devnull
16 78e51a8c 2005-01-14 devnull print, fprint, sprint, snprint, seprint, smprint, runesprint,
17 78e51a8c 2005-01-14 devnull runesnprint, runeseprint, runesmprint, vfprint, vsnprint, vseprint,
18 78e51a8c 2005-01-14 devnull vsmprint, runevsnprint, runevseprint, runevsmprint &ndash; print formatted
19 78e51a8c 2005-01-14 devnull output<br>
20 78e51a8c 2005-01-14 devnull
21 78e51a8c 2005-01-14 devnull </table>
22 78e51a8c 2005-01-14 devnull <p><font size=+1><b>SYNOPSIS </b></font><br>
23 78e51a8c 2005-01-14 devnull
24 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
25 78e51a8c 2005-01-14 devnull
26 78e51a8c 2005-01-14 devnull <tt><font size=+1>#include &lt;u.h&gt;
27 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
28 78e51a8c 2005-01-14 devnull </font></tt>
29 78e51a8c 2005-01-14 devnull <tt><font size=+1>#include &lt;libc.h&gt;
30 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
31 78e51a8c 2005-01-14 devnull </font></tt>
32 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;print(char *format, ...)
33 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
34 78e51a8c 2005-01-14 devnull </font></tt>
35 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;fprint(int fd, char *format, ...)
36 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
37 78e51a8c 2005-01-14 devnull </font></tt>
38 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;sprint(char *s, char *format, ...)
39 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
40 78e51a8c 2005-01-14 devnull </font></tt>
41 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;snprint(char *s, int len, char *format, ...)
42 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
43 78e51a8c 2005-01-14 devnull </font></tt>
44 78e51a8c 2005-01-14 devnull <tt><font size=+1>char* seprint(char *s, char *e, char *format, ...)
45 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
46 78e51a8c 2005-01-14 devnull </font></tt>
47 78e51a8c 2005-01-14 devnull <tt><font size=+1>char* smprint(char *format, ...)
48 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
49 78e51a8c 2005-01-14 devnull </font></tt>
50 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;runesprint(Rune *s, char *format, ...)
51 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
52 78e51a8c 2005-01-14 devnull </font></tt>
53 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;runesnprint(Rune *s, int len, char *format, ...)
54 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
55 78e51a8c 2005-01-14 devnull </font></tt>
56 78e51a8c 2005-01-14 devnull <tt><font size=+1>Rune* runeseprint(Rune *s, Rune *e, char *format, ...)
57 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
58 78e51a8c 2005-01-14 devnull </font></tt>
59 78e51a8c 2005-01-14 devnull <tt><font size=+1>Rune* runesmprint(char *format, ...)
60 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
61 78e51a8c 2005-01-14 devnull </font></tt>
62 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;vfprint(int fd, char *format, va_list v)
63 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
64 78e51a8c 2005-01-14 devnull </font></tt>
65 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;vsnprint(char *s, int len, char *format, va_list v)
66 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
67 78e51a8c 2005-01-14 devnull </font></tt>
68 78e51a8c 2005-01-14 devnull <tt><font size=+1>char* vseprint(char *s, char *e, char *format, va_list v)
69 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
70 78e51a8c 2005-01-14 devnull </font></tt>
71 78e51a8c 2005-01-14 devnull <tt><font size=+1>char* vsmprint(char *format, va_list v)
72 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
73 78e51a8c 2005-01-14 devnull </font></tt>
74 78e51a8c 2005-01-14 devnull <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;runevsnprint(Rune *s, int len, char *format, va_list v)
75 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
76 78e51a8c 2005-01-14 devnull </font></tt>
77 78e51a8c 2005-01-14 devnull <tt><font size=+1>Rune* runevseprint(Rune *s, Rune *e, char *format, va_list v)
78 78e51a8c 2005-01-14 devnull
79 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
80 78e51a8c 2005-01-14 devnull </font></tt>
81 78e51a8c 2005-01-14 devnull <tt><font size=+1>Rune* runevsmprint(Rune *format, va_list v)
82 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
83 78e51a8c 2005-01-14 devnull </font></tt>
84 78e51a8c 2005-01-14 devnull
85 78e51a8c 2005-01-14 devnull </table>
86 78e51a8c 2005-01-14 devnull <p><font size=+1><b>DESCRIPTION </b></font><br>
87 78e51a8c 2005-01-14 devnull
88 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
89 78e51a8c 2005-01-14 devnull
90 78e51a8c 2005-01-14 devnull <i>Print</i> writes text to the standard output. <i>Fprint</i> writes to the
91 78e51a8c 2005-01-14 devnull named output file descriptor: a buffered form is described in
92 78e51a8c 2005-01-14 devnull <a href="../man3/bio.html"><i>bio</i>(3)</a>. <i>Sprint</i> places text followed by the NUL character (<tt><font size=+1>\0</font></tt>)
93 78e51a8c 2005-01-14 devnull in consecutive bytes starting at <i>s</i>; it is the user&#8217;s responsibility
94 78e51a8c 2005-01-14 devnull to ensure that enough storage is available. Each function returns
95 78e51a8c 2005-01-14 devnull the
96 78e51a8c 2005-01-14 devnull number of bytes transmitted (not including the NUL in the case
97 78e51a8c 2005-01-14 devnull of <i>sprint</i>), or a negative value if an output error was encountered.
98 78e51a8c 2005-01-14 devnull
99 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
100 78e51a8c 2005-01-14 devnull
101 78e51a8c 2005-01-14 devnull <i>Snprint</i> is like <i>sprint</i>, but will not place more than <i>len</i> bytes
102 78e51a8c 2005-01-14 devnull in <i>s</i>. Its result is always NUL-terminated and holds the maximal
103 78e51a8c 2005-01-14 devnull number of complete UTF-8 characters that can fit. <i>Seprint</i> is like
104 78e51a8c 2005-01-14 devnull <i>snprint</i>, except that the end is indicated by a pointer <i>e</i> rather
105 78e51a8c 2005-01-14 devnull than a count and the return value points to the terminating NUL
106 78e51a8c 2005-01-14 devnull of
107 78e51a8c 2005-01-14 devnull the resulting string. <i>Smprint</i> is like <i>sprint</i>, except that it prints
108 78e51a8c 2005-01-14 devnull into and returns a string of the required length, which is allocated
109 78e51a8c 2005-01-14 devnull by <a href="../man3/malloc.html"><i>malloc</i>(3)</a>.
110 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
111 78e51a8c 2005-01-14 devnull
112 78e51a8c 2005-01-14 devnull The routines <i>runesprint</i>, <i>runesnprint</i>, <i>runeseprint</i>, and <i>runesmprint</i>
113 78e51a8c 2005-01-14 devnull are the same as <i>sprint</i>, <i>snprint</i>, <i>seprint</i> and <i>smprint</i> except that
114 78e51a8c 2005-01-14 devnull their output is rune strings instead of byte strings.
115 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
116 78e51a8c 2005-01-14 devnull
117 78e51a8c 2005-01-14 devnull Finally, the routines <i>vfprint</i>, <i>vsnprint</i>, <i>vseprint</i>, <i>vsmprint</i>, <i>runevsnprint</i>,
118 78e51a8c 2005-01-14 devnull <i>runevseprint</i>, and <i>runevsmprint</i> are like their <tt><font size=+1>v&#8722;less</font></tt> relatives
119 78e51a8c 2005-01-14 devnull except they take as arguments a <tt><font size=+1>va_list</font></tt> parameter, so they can
120 78e51a8c 2005-01-14 devnull be called within a variadic function. The Example section shows
121 78e51a8c 2005-01-14 devnull a representative usage.
122 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
123 78e51a8c 2005-01-14 devnull
124 78e51a8c 2005-01-14 devnull Each of these functions converts, formats, and prints its trailing
125 78e51a8c 2005-01-14 devnull arguments under control of a <i>format</i> string. The format contains
126 78e51a8c 2005-01-14 devnull two types of objects: plain characters, which are simply copied
127 78e51a8c 2005-01-14 devnull to the output stream, and conversion specifications, each of which
128 78e51a8c 2005-01-14 devnull results in fetching of zero or more arguments. The results
129 78e51a8c 2005-01-14 devnull are undefined if there are arguments of the wrong type or too
130 78e51a8c 2005-01-14 devnull few arguments for the format. If the format is exhausted while
131 78e51a8c 2005-01-14 devnull arguments remain, the excess is ignored.
132 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
133 78e51a8c 2005-01-14 devnull
134 78e51a8c 2005-01-14 devnull Each conversion specification has the following format:<br>
135 78e51a8c 2005-01-14 devnull
136 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
137 78e51a8c 2005-01-14 devnull
138 78e51a8c 2005-01-14 devnull <tt><font size=+1>% [flags] verb
139 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
140 78e51a8c 2005-01-14 devnull </font></tt>
141 78e51a8c 2005-01-14 devnull
142 78e51a8c 2005-01-14 devnull </table>
143 78e51a8c 2005-01-14 devnull The verb is a single character and each flag is a single character
144 78e51a8c 2005-01-14 devnull or a (decimal) numeric string. Up to two numeric strings may be
145 78e51a8c 2005-01-14 devnull used; the first is called <i>width</i>, the second <i>precision</i>. A period
146 78e51a8c 2005-01-14 devnull can be used to separate them, and if the period is present then
147 78e51a8c 2005-01-14 devnull <i>width</i> and <i>precision</i> are taken to be zero if missing, otherwise
148 78e51a8c 2005-01-14 devnull they are &#8216;omitted&#8217;. Either or both of the numbers may be replaced
149 78e51a8c 2005-01-14 devnull with the character <tt><font size=+1>*</font></tt>, meaning that the actual number will be obtained
150 78e51a8c 2005-01-14 devnull from the argument list as an integer. The flags and numbers are
151 78e51a8c 2005-01-14 devnull arguments to the <i>verb</i> described below.
152 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
153 78e51a8c 2005-01-14 devnull
154 78e51a8c 2005-01-14 devnull The numeric verbs <tt><font size=+1>d</font></tt>, <tt><font size=+1>o</font></tt>, <tt><font size=+1>b</font></tt>, <tt><font size=+1>x</font></tt>, and <tt><font size=+1>X</font></tt> format their arguments in
155 78e51a8c 2005-01-14 devnull decimal, octal, binary, hexadecimal, and upper case hexadecimal.
156 78e51a8c 2005-01-14 devnull Each interprets the flags <tt><font size=+1>0</font></tt>, <tt><font size=+1>h</font></tt>, <tt><font size=+1>hh</font></tt>, <tt><font size=+1>l</font></tt>, <tt><font size=+1>u</font></tt>, <tt><font size=+1>+</font></tt>, <tt><font size=+1>&#8722;</font></tt>, <tt><font size=+1>,</font></tt>, and <tt><font size=+1>#</font></tt> to mean
157 78e51a8c 2005-01-14 devnull pad with zeros, short, byte, long, unsigned, always print a sign,
158 78e51a8c 2005-01-14 devnull left justified, commas every three digits, and alternate format.
159 78e51a8c 2005-01-14 devnull Also, a space character in the flag position is like <tt><font size=+1>+</font></tt>, but prints
160 78e51a8c 2005-01-14 devnull a space instead of a plus sign for non-negative values. If neither
161 78e51a8c 2005-01-14 devnull short nor long is specified, then the argument is an <tt><font size=+1>int</font></tt>. If unsigned
162 78e51a8c 2005-01-14 devnull is specified, then the argument is interpreted as a positive number
163 78e51a8c 2005-01-14 devnull and no sign is output. If two <tt><font size=+1>l</font></tt> flags are given, then
164 78e51a8c 2005-01-14 devnull the argument is interpreted as a <tt><font size=+1>vlong</font></tt> (usually an 8-byte, sometimes
165 78e51a8c 2005-01-14 devnull a 4-byte integer). If <i>precision</i> is not omitted, the number is
166 78e51a8c 2005-01-14 devnull padded on the left with zeros until at least <i>precision</i> digits
167 78e51a8c 2005-01-14 devnull appear. If <i>precision</i> is explicitly 0, and the number is 0, no
168 78e51a8c 2005-01-14 devnull digits are generated, and alternate formatting does not apply.
169 78e51a8c 2005-01-14 devnull Then,
170 78e51a8c 2005-01-14 devnull if alternate format is specified, for <tt><font size=+1>o</font></tt> conversion, the number
171 78e51a8c 2005-01-14 devnull is preceded by a <tt><font size=+1>0</font></tt> if it doesn&#8217;t already begin with one; for <tt><font size=+1>x</font></tt>
172 78e51a8c 2005-01-14 devnull conversion, the number is preceded by <tt><font size=+1>0x</font></tt>; for <tt><font size=+1>X</font></tt> conversion, the
173 78e51a8c 2005-01-14 devnull number is preceded by <tt><font size=+1>0X</font></tt>. Finally, if <i>width</i> is not omitted, the
174 78e51a8c 2005-01-14 devnull number is padded on the left (or right, if left justification
175 78e51a8c 2005-01-14 devnull is specified)
176 78e51a8c 2005-01-14 devnull with enough blanks to make the field at least <i>width</i> characters
177 78e51a8c 2005-01-14 devnull long.
178 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
179 78e51a8c 2005-01-14 devnull
180 78e51a8c 2005-01-14 devnull The floating point verbs <tt><font size=+1>f</font></tt>, <tt><font size=+1>e</font></tt>, <tt><font size=+1>E</font></tt>, <tt><font size=+1>g</font></tt>, and <tt><font size=+1>G</font></tt> take a <tt><font size=+1>double</font></tt> argument.
181 78e51a8c 2005-01-14 devnull Each interprets the flags <tt><font size=+1>0</font></tt>, <tt><font size=+1>L +</font></tt>, <tt><font size=+1>&#8722;</font></tt>, and <tt><font size=+1>#</font></tt> to mean pad with zeros,
182 78e51a8c 2005-01-14 devnull long double argument, always print a sign, left justified, and
183 78e51a8c 2005-01-14 devnull alternate format. <i>Width</i> is the minimum field width and, if the
184 78e51a8c 2005-01-14 devnull converted value takes up less than <i>width</i> characters, it is
185 78e51a8c 2005-01-14 devnull padded on the left (or right, if &#8216;left justified&#8217;) with spaces.
186 78e51a8c 2005-01-14 devnull <i>Precision</i> is the number of digits that are converted after the
187 78e51a8c 2005-01-14 devnull decimal place for <tt><font size=+1>e</font></tt>, <tt><font size=+1>E</font></tt>, and <tt><font size=+1>f</font></tt> conversions, and <i>precision</i> is the
188 78e51a8c 2005-01-14 devnull maximum number of significant digits for <tt><font size=+1>g</font></tt> and <tt><font size=+1>G</font></tt> conversions.
189 78e51a8c 2005-01-14 devnull The <tt><font size=+1>f</font></tt> verb produces output of the form [<tt><font size=+1>&#8722;</font></tt>]<tt><font size=+1>digits</font></tt>[<tt><font size=+1>.digits</font></tt>]. <tt><font size=+1>E
190 78e51a8c 2005-01-14 devnull </font></tt>conversion appends an exponent <tt><font size=+1>E</font></tt>[<tt><font size=+1>&#8722;</font></tt>]<tt><font size=+1>digits</font></tt>, and <tt><font size=+1>e</font></tt> conversion appends
191 78e51a8c 2005-01-14 devnull an exponent <tt><font size=+1>e</font></tt>[<tt><font size=+1>&#8722;</font></tt>]<tt><font size=+1>digits</font></tt>. The <tt><font size=+1>g</font></tt> verb will output the argument in
192 78e51a8c 2005-01-14 devnull either <tt><font size=+1>e</font></tt> or <tt><font size=+1>f</font></tt> with the goal of producing the smallest output.
193 78e51a8c 2005-01-14 devnull Also, trailing zeros are omitted from the fraction part of the
194 78e51a8c 2005-01-14 devnull output, and a trailing decimal point appears only if it is
195 78e51a8c 2005-01-14 devnull followed by a digit. The <tt><font size=+1>G</font></tt> verb is similar, but uses <tt><font size=+1>E</font></tt> format
196 78e51a8c 2005-01-14 devnull instead of <tt><font size=+1>e</font></tt>. When alternate format is specified, the result will
197 78e51a8c 2005-01-14 devnull always contain a decimal point, and for <tt><font size=+1>g</font></tt> and <tt><font size=+1>G</font></tt> conversions, trailing
198 78e51a8c 2005-01-14 devnull zeros are not removed.
199 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
200 78e51a8c 2005-01-14 devnull
201 78e51a8c 2005-01-14 devnull The <tt><font size=+1>s</font></tt> verb copies a NUL-terminated string (pointer to <tt><font size=+1>char</font></tt>) to
202 78e51a8c 2005-01-14 devnull the output. The number of characters copied (<i>n</i>) is the minimum
203 78e51a8c 2005-01-14 devnull of the size of the string and <i>precision</i>. These <i>n</i> characters are
204 78e51a8c 2005-01-14 devnull justified within a field of <i>width</i> characters as described above.
205 78e51a8c 2005-01-14 devnull If a <i>precision</i> is given, it is safe for the string not to be nul-
206 78e51a8c 2005-01-14 devnull terminated as long as it is at least <i>precision</i> characters (not
207 78e51a8c 2005-01-14 devnull bytes!) long. The <tt><font size=+1>S</font></tt> verb is similar, but it interprets its pointer
208 78e51a8c 2005-01-14 devnull as an array of runes (see <a href="../man7/utf.html"><i>utf</i>(7)</a>); the runes are converted to
209 78e51a8c 2005-01-14 devnull UTF before output.
210 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
211 78e51a8c 2005-01-14 devnull
212 78e51a8c 2005-01-14 devnull The <tt><font size=+1>c</font></tt> verb copies a single <tt><font size=+1>char</font></tt> (promoted to <tt><font size=+1>int</font></tt>) justified within
213 78e51a8c 2005-01-14 devnull a field of <i>width</i> characters as described above. The <tt><font size=+1>C</font></tt> verb is
214 78e51a8c 2005-01-14 devnull similar, but works on runes.
215 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
216 78e51a8c 2005-01-14 devnull
217 78e51a8c 2005-01-14 devnull The <tt><font size=+1>p</font></tt> verb formats a pointer value. At the moment, it is a synonym
218 78e51a8c 2005-01-14 devnull for <tt><font size=+1>x</font></tt>, but that will change if pointers and integers are different
219 78e51a8c 2005-01-14 devnull sizes.
220 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
221 78e51a8c 2005-01-14 devnull
222 78e51a8c 2005-01-14 devnull The <tt><font size=+1>r</font></tt> verb takes no arguments; it copies the error string returned
223 78e51a8c 2005-01-14 devnull by a call to <a href="../man3/errstr.html"><i>errstr</i>(3)</a>.
224 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
225 78e51a8c 2005-01-14 devnull
226 78e51a8c 2005-01-14 devnull Custom verbs may be installed using <a href="../man3/fmtinstall.html"><i>fmtinstall</i>(3)</a>.<br>
227 78e51a8c 2005-01-14 devnull
228 78e51a8c 2005-01-14 devnull </table>
229 78e51a8c 2005-01-14 devnull <p><font size=+1><b>EXAMPLE </b></font><br>
230 78e51a8c 2005-01-14 devnull
231 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
232 78e51a8c 2005-01-14 devnull
233 78e51a8c 2005-01-14 devnull This function prints an error message with a variable number of
234 78e51a8c 2005-01-14 devnull arguments and then quits.<br>
235 78e51a8c 2005-01-14 devnull
236 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
237 78e51a8c 2005-01-14 devnull
238 78e51a8c 2005-01-14 devnull <tt><font size=+1>void fatal(char *msg, ...)<br>
239 78e51a8c 2005-01-14 devnull {<br>
240 78e51a8c 2005-01-14 devnull
241 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
242 78e51a8c 2005-01-14 devnull
243 78e51a8c 2005-01-14 devnull char buf[1024], *out;<br>
244 78e51a8c 2005-01-14 devnull va_list arg;<br>
245 78e51a8c 2005-01-14 devnull out = seprint(buf, buf+sizeof buf, &quot;Fatal error: &quot;);<br>
246 78e51a8c 2005-01-14 devnull va_start(arg, msg);<br>
247 78e51a8c 2005-01-14 devnull out = vseprint(out, buf+sizeof buf, msg, arg);<br>
248 78e51a8c 2005-01-14 devnull va_end(arg);<br>
249 78e51a8c 2005-01-14 devnull write(2, buf, out&#8722;buf);<br>
250 78e51a8c 2005-01-14 devnull exits(&quot;fatal error&quot;);<br>
251 78e51a8c 2005-01-14 devnull
252 78e51a8c 2005-01-14 devnull </table>
253 78e51a8c 2005-01-14 devnull }<br>
254 78e51a8c 2005-01-14 devnull </font></tt>
255 78e51a8c 2005-01-14 devnull </table>
256 78e51a8c 2005-01-14 devnull
257 78e51a8c 2005-01-14 devnull </table>
258 78e51a8c 2005-01-14 devnull <p><font size=+1><b>SOURCE </b></font><br>
259 78e51a8c 2005-01-14 devnull
260 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
261 78e51a8c 2005-01-14 devnull
262 78e51a8c 2005-01-14 devnull <tt><font size=+1>/usr/local/plan9/src/lib9/libfmt<br>
263 78e51a8c 2005-01-14 devnull </font></tt>
264 78e51a8c 2005-01-14 devnull </table>
265 78e51a8c 2005-01-14 devnull <p><font size=+1><b>SEE ALSO </b></font><br>
266 78e51a8c 2005-01-14 devnull
267 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
268 78e51a8c 2005-01-14 devnull
269 78e51a8c 2005-01-14 devnull <a href="../man3/fmtinstall.html"><i>fmtinstall</i>(3)</a>, <a href="../man3/fprintf.html"><i>fprintf</i>(3)</a>, <a href="../man7/utf.html"><i>utf</i>(7)</a><br>
270 78e51a8c 2005-01-14 devnull
271 78e51a8c 2005-01-14 devnull </table>
272 78e51a8c 2005-01-14 devnull <p><font size=+1><b>DIAGNOSTICS </b></font><br>
273 78e51a8c 2005-01-14 devnull
274 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
275 78e51a8c 2005-01-14 devnull
276 78e51a8c 2005-01-14 devnull Routines that write to a file descriptor or call <i>malloc</i> set <i>errstr</i>.<br>
277 78e51a8c 2005-01-14 devnull
278 78e51a8c 2005-01-14 devnull </table>
279 78e51a8c 2005-01-14 devnull <p><font size=+1><b>BUGS </b></font><br>
280 78e51a8c 2005-01-14 devnull
281 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
282 78e51a8c 2005-01-14 devnull
283 78e51a8c 2005-01-14 devnull The formatting is close to that specified for ANSI <a href="../man3/fprintf.html"><i>fprintf</i>(3)</a>;
284 78e51a8c 2005-01-14 devnull the main difference is that <tt><font size=+1>b</font></tt> and <tt><font size=+1>r</font></tt> are not in ANSI and <tt><font size=+1>u</font></tt> is a
285 78e51a8c 2005-01-14 devnull flag here instead of a verb. Also, and distinctly not a bug, <i>print</i>
286 78e51a8c 2005-01-14 devnull and friends generate UTF rather than ASCII.
287 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
288 78e51a8c 2005-01-14 devnull
289 78e51a8c 2005-01-14 devnull There is no <i>runeprint</i>, <i>runefprint</i>, etc. because runes are byte-order
290 78e51a8c 2005-01-14 devnull dependent and should not be written directly to a file; use the
291 78e51a8c 2005-01-14 devnull UTF output of <i>print</i> or <i>fprint</i> instead. Also, <i>sprint</i> is deprecated
292 78e51a8c 2005-01-14 devnull for safety reasons; use <i>snprint</i>, <i>seprint</i>, or <i>smprint</i> instead.
293 78e51a8c 2005-01-14 devnull Safety also precludes the existence of <i>runesprint</i>.
294 78e51a8c 2005-01-14 devnull
295 78e51a8c 2005-01-14 devnull </table>
296 78e51a8c 2005-01-14 devnull
297 78e51a8c 2005-01-14 devnull <td width=20>
298 78e51a8c 2005-01-14 devnull <tr height=20><td>
299 78e51a8c 2005-01-14 devnull </table>
300 78e51a8c 2005-01-14 devnull <!-- TRAILER -->
301 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0 width=100%>
302 78e51a8c 2005-01-14 devnull <tr height=15><td width=10><td><td width=10>
303 78e51a8c 2005-01-14 devnull <tr><td><td>
304 78e51a8c 2005-01-14 devnull <center>
305 78e51a8c 2005-01-14 devnull <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
306 78e51a8c 2005-01-14 devnull </center>
307 78e51a8c 2005-01-14 devnull </table>
308 78e51a8c 2005-01-14 devnull <!-- TRAILER -->
309 78e51a8c 2005-01-14 devnull </body></html>