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