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