port to tahoe by Nir peleg of CCI
[unix-history] / usr / src / usr.bin / mkstr / mkstr.1
CommitLineData
b763ca03
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
14140efb 5.\" @(#)mkstr.1 6.2 (Berkeley) %G%
b763ca03 6.\"
16c204ca 7.TH MKSTR 1 ""
b763ca03
KM
8.UC
9.SH NAME
10mkstr \- create an error message file by massaging C source
11.SH SYNOPSIS
12.B mkstr
13[
14.B \-
15]
16messagefile prefix file ...
17.SH DESCRIPTION
18.I Mkstr
19is used to create files of error messages.
20Its use can make programs with large numbers of error diagnostics much
21smaller, and reduce system overhead in running the program as the
22error messages do not have to be constantly swapped in and out.
23.PP
24.I Mkstr
25will process each of the specified
26.I files,
27placing a massaged version of the input file in a file whose name
28consists of the specified
29.I prefix
30and the original name.
31A typical usage of
32.I mkstr
33would be
34.DT
35.PP
36 mkstr pistrings xx *.c
37.PP
38This command would cause all the error messages from the C source
39files in the current directory to be placed in the file
40.I pistrings
41and processed copies of the source for these files to be placed in
42files whose names are prefixed with
43.I xx.
44.PP
45To process the error messages in the source to the message file
46.I mkstr
47keys on the string
48\%`error("'
49in the input stream.
50Each time it occurs, the C string starting at the `"' is placed
51in the message file followed by a null character and a new-line character;
52the null character terminates the message so it can be easily used
53when retrieved, the new-line character makes it possible to sensibly
54.I cat
55the error message file to see its contents.
56The massaged copy of the input file then contains a
57.I lseek
58pointer into the file which can be used to retrieve the message, i.e.:
59.IP
60.DT
61.nf
62\fBchar\fR efilname[] = "/usr/lib/pi_strings";
63\fBint\fR efil = -1;
64.sp
65error(a1, a2, a3, a4)
66{
67 \fBchar\fR buf[256];
68
69 \fBif\fR (efil < 0) {
70 efil = open(efilname, 0);
71 \fBif\fR (efil < 0) {
72oops:
73 perror(efilname);
74 exit(1);
75 }
76 }
77 \fBif\fR (lseek(efil, (long) a1, 0) |\|| read(efil, buf, 256) <= 0)
78 \fBgoto\fR oops;
79 printf(buf, a2, a3, a4);
80}
81.fi
82.PP
83The optional
84.B \-
85causes the error messages to be placed at the end of the specified
86message file for recompiling part of a large
87.IR mkstr \|ed
88program.
89.SH SEE\ ALSO
90lseek(2), xstr(1)