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