| 1 | .th MKSTR VI 8/22/77 |
| 2 | .sh NAME |
| 3 | mkstr \- create an error message file by massaging C source |
| 4 | .sh SYNOPSIS |
| 5 | .bd mkstr |
| 6 | [ |
| 7 | .bd \- |
| 8 | ] |
| 9 | message-file prefix file ... |
| 10 | .sh DESCRIPTION |
| 11 | .it 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 | .s3 |
| 17 | .it Mkstr |
| 18 | will process each of the specified |
| 19 | .it files, |
| 20 | placing a massaged version of the input file in a file whose name |
| 21 | consists of the specified |
| 22 | .it prefix |
| 23 | and the original name. |
| 24 | A typical usage of |
| 25 | .it mkstr |
| 26 | would be |
| 27 | .dt |
| 28 | .s3 |
| 29 | mkstr pi_strings temp/ *.c |
| 30 | .s3 |
| 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 | .it pi_strings |
| 34 | and processed copies of the source for these files to be placed in |
| 35 | the (existing) directory |
| 36 | .it temp. |
| 37 | .s3 |
| 38 | To process the error messages in the source to the message file |
| 39 | .it 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 | .it cat |
| 48 | the error message file to see its contents. |
| 49 | The massaged copy of the input file then contains a |
| 50 | .it seek |
| 51 | pointer 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 |
| 64 | oops: |
| 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 |
| 76 | The optional |
| 77 | .bd \- |
| 78 | causes the error messages to be placed at the end of the specified |
| 79 | message file for recompiling part of a large |
| 80 | \fImkstr\fR\|ed |
| 81 | program. |
| 82 | .sh SEE\ ALSO |
| 83 | seek (II) |
| 84 | .sh AUTHORS |
| 85 | William Joy and Charles Haley |
| 86 | .sh BUGS |