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