Commit | Line | Data |
---|---|---|
1611f8fd BJ |
1 | .TH MKSTR 1 2/24/79 |
2 | .UC | |
3 | .SH NAME | |
4 | mkstr \- create an error message file by massaging C source | |
5 | .SH SYNOPSIS | |
6 | .B mkstr | |
7 | [ | |
8 | .B \- | |
9 | ] | |
10 | messagefile prefix file ... | |
11 | .SH DESCRIPTION | |
12 | .I Mkstr | |
13 | is used to create files of error messages. | |
14 | Its use can make programs with large numbers of error diagnostics much | |
15 | smaller, and reduce system overhead in running the program as the | |
16 | error messages do not have to be constantly swapped in and out. | |
17 | .PP | |
18 | .I Mkstr | |
19 | will process each of the specified | |
20 | .I files, | |
21 | placing a massaged version of the input file in a file whose name | |
22 | consists of the specified | |
23 | .I prefix | |
24 | and the original name. | |
25 | A typical usage of | |
26 | .I mkstr | |
27 | would be | |
28 | .DT | |
29 | .PP | |
30 | mkstr pistrings xx *.c | |
31 | .PP | |
32 | This command would cause all the error messages from the C source | |
33 | files in the current directory to be placed in the file | |
34 | .I pistrings | |
35 | and processed copies of the source for these files to be placed in | |
36 | files whose names are prefixed with | |
37 | .I xx. | |
38 | .PP | |
39 | To process the error messages in the source to the message file | |
40 | .I mkstr | |
41 | keys on the string | |
42 | \%`error("' | |
43 | in the input stream. | |
44 | Each time it occurs, the C string starting at the `"' is placed | |
45 | in the message file followed by a null character and a new-line character; | |
46 | the null character terminates the message so it can be easily used | |
47 | when retrieved, the new-line character makes it possible to sensibly | |
48 | .I cat | |
49 | the error message file to see its contents. | |
50 | The massaged copy of the input file then contains a | |
51 | .I lseek | |
52 | pointer 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 | |
59 | error(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) { | |
66 | oops: | |
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 | |
77 | The optional | |
78 | .B \- | |
79 | causes the error messages to be placed at the end of the specified | |
80 | message file for recompiling part of a large | |
81 | .IR mkstr \|ed | |
82 | program. | |
83 | .SH SEE\ ALSO | |
84 | lseek(2), xstr(1) | |
85 | .SH AUTHORS | |
86 | William Joy and Charles Haley | |
87 | ...SH BUGS | |
88 | ...All the arguments except the name of the file to be processed could be made unnecessary. |