BSD 1 development
[unix-history] / man6 / mkstr.6
CommitLineData
c7adcd0b
BJ
1.th MKSTR VI 8/22/77
2.sh NAME
3mkstr \- create an error message file by massaging C source
4.sh SYNOPSIS
5.bd mkstr
6[
7.bd \-
8]
9message-file prefix file ...
10.sh DESCRIPTION
11.it 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.s3
17.it Mkstr
18will process each of the specified
19.it files,
20placing a massaged version of the input file in a file whose name
21consists of the specified
22.it prefix
23and the original name.
24A typical usage of
25.it mkstr
26would be
27.dt
28.s3
29 mkstr pi_strings temp/ *.c
30.s3
31This command would cause all the error messages from the C source
32files in the current directory to be placed in the file
33.it pi_strings
34and processed copies of the source for these files to be placed in
35the (existing) directory
36.it temp.
37.s3
38To process the error messages in the source to the message file
39.it 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.it cat
48the error message file to see its contents.
49The massaged copy of the input file then contains a
50.it seek
51pointer into the file which can be used to retrieve the message, i.e.:
52.s3
53 \fBchar\fR efilname[] "/usr/lib/pi_strings";
54 \fBint\fR efil -1;
55
56 error(a1, a2, a3, a4)
57 {
58 char buf[256];
59
60 \fBif\fR (efil < 0) {
61 efil = open(efilname, 0);
62 \fBif\fR (efil < 0) {
63.br
64oops:
65 perror(efilname);
66 exit(1);
67 }
68 }
69 \fBif\fR (seek(efil, a1, 0))
70 \fBgoto\fR oops;
71 \fBif\fR (read(efil, buf, 256) <= 0)
72 \fBgoto\fR oops;
73 printf(buf, a2, a3, a4);
74 }
75.s3
76The optional
77.bd \-
78causes the error messages to be placed at the end of the specified
79message file for recompiling part of a large
80\fImkstr\fR\|ed
81program.
82.sh SEE\ ALSO
83seek (II)
84.sh AUTHORS
85William Joy and Charles Haley
86.sh BUGS