xref: /freebsd/usr.bin/mkstr/mkstr.1 (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
19b50d902SRodney W. Grimes.\" Copyright (c) 1980, 1990, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
59b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
69b50d902SRodney W. Grimes.\" are met:
79b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
89b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
99b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
109b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
119b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12*fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
139b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
149b50d902SRodney W. Grimes.\"    without specific prior written permission.
159b50d902SRodney W. Grimes.\"
169b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
179b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
189b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
209b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
219b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
229b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
239b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
249b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
259b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
269b50d902SRodney W. Grimes.\" SUCH DAMAGE.
279b50d902SRodney W. Grimes.\"
2847d53ed2SBaptiste Daroussin.Dd June 6, 2015
299b50d902SRodney W. Grimes.Dt MKSTR 1
309b50d902SRodney W. Grimes.Os
319b50d902SRodney W. Grimes.Sh NAME
329b50d902SRodney W. Grimes.Nm mkstr
339b50d902SRodney W. Grimes.Nd create an error message file by massaging C source
349b50d902SRodney W. Grimes.Sh SYNOPSIS
352487a449SPhilippe Charnier.Nm
369b50d902SRodney W. Grimes.Op Fl
3758f5d5b0SRuslan Ermilov.Ar mesgfile
3847dec781SRuslan Ermilov.Ar prefix Ar
399b50d902SRodney W. Grimes.Sh DESCRIPTION
40e8937ba0SPhilippe CharnierThe
41e8937ba0SPhilippe Charnier.Nm
4258f5d5b0SRuslan Ermilovutility creates a file containing error messages extracted from C source,
439b50d902SRodney W. Grimesand restructures the same C source, to utilize the created error message
449b50d902SRodney W. Grimesfile.
459b50d902SRodney W. GrimesThe intent of
462487a449SPhilippe Charnier.Nm
479b50d902SRodney W. Grimeswas to reduce the size of large programs and
489b50d902SRodney W. Grimesreduce swapping (see
499b50d902SRodney W. Grimes.Sx BUGS
509b50d902SRodney W. Grimessection below).
519b50d902SRodney W. Grimes.Pp
52e8937ba0SPhilippe CharnierThe
53e8937ba0SPhilippe Charnier.Nm
5458f5d5b0SRuslan Ermilovutility processes each of the specified files,
559b50d902SRodney W. Grimesplacing a restructured version of the input in a file whose name
569b50d902SRodney W. Grimesconsists of the specified
579b50d902SRodney W. Grimes.Ar prefix
589b50d902SRodney W. Grimesand the original name.
599b50d902SRodney W. GrimesA typical usage of
602487a449SPhilippe Charnier.Nm
619b50d902SRodney W. Grimesis
6231d30658SRuslan Ermilov.Pp
6331d30658SRuslan Ermilov.Dl "mkstr pistrings xx *.c"
649b50d902SRodney W. Grimes.Pp
659b50d902SRodney W. GrimesThis command causes all the error messages from the C source
669b50d902SRodney W. Grimesfiles in the current directory to be placed in the file
6731d30658SRuslan Ermilov.Pa pistrings
689b50d902SRodney W. Grimesand restructured copies of the sources to be placed in
699b50d902SRodney W. Grimesfiles whose names are prefixed with
7058f5d5b0SRuslan Ermilov.Dq Li xx .
719b50d902SRodney W. Grimes.Pp
729b50d902SRodney W. GrimesOptions:
739b50d902SRodney W. Grimes.Bl -tag -width indent
749b50d902SRodney W. Grimes.It Fl
759b50d902SRodney W. GrimesError messages are placed at the end of the specified
769b50d902SRodney W. Grimesmessage file for recompiling part of a large
77e8937ba0SPhilippe Charnier.Nm Ns ed
789b50d902SRodney W. Grimesprogram.
799b50d902SRodney W. Grimes.El
809b50d902SRodney W. Grimes.Pp
81e8937ba0SPhilippe CharnierThe
82e8937ba0SPhilippe Charnier.Nm
83e8937ba0SPhilippe Charnierutility finds error messages in the source by
849b50d902SRodney W. Grimessearching for the string
8558f5d5b0SRuslan Ermilov.Sq Li error("
869b50d902SRodney W. Grimesin the input stream.
879b50d902SRodney W. GrimesEach time it occurs, the C string starting at the
8858f5d5b0SRuslan Ermilov.Ql \&"
899b50d902SRodney W. Grimesis stored
909b50d902SRodney W. Grimesin the message file followed by a null character and a new-line character;
919b50d902SRodney W. GrimesThe new source is restructured with
929b50d902SRodney W. Grimes.Xr lseek 2
939b50d902SRodney W. Grimespointers into the error message file for retrieval.
949b50d902SRodney W. Grimes.Bd -literal -offset indent
959b50d902SRodney W. Grimeschar efilname = "/usr/lib/pi_strings";
969b50d902SRodney W. Grimesint efil = -1;
979b50d902SRodney W. Grimes
989b50d902SRodney W. Grimeserror(a1, a2, a3, a4)
9931d30658SRuslan Ermilov{
1009b50d902SRodney W. Grimes	char buf[256];
1019b50d902SRodney W. Grimes
1029b50d902SRodney W. Grimes	if (efil < 0) {
1039b50d902SRodney W. Grimes		efil = open(efilname, 0);
1044b952f84SPhilippe Charnier		if (efil < 0)
1054b952f84SPhilippe Charnier			err(1, "%s", efilname);
1069b50d902SRodney W. Grimes	}
1074b952f84SPhilippe Charnier	if (lseek(efil, (off_t)a1, SEEK_SET) < 0 ||
1084b952f84SPhilippe Charnier	    read(efil, buf, 256) <= 0)
1094b952f84SPhilippe Charnier		err(1, "%s", efilname);
1109b50d902SRodney W. Grimes	printf(buf, a2, a3, a4);
1119b50d902SRodney W. Grimes}
1129b50d902SRodney W. Grimes.Ed
1139b50d902SRodney W. Grimes.Sh SEE ALSO
11485da09e8SDiomidis Spinellis.Xr gencat 1 ,
115da1ff3cbSWolfram Schneider.Xr xstr 1 ,
116da1ff3cbSWolfram Schneider.Xr lseek 2
1179b50d902SRodney W. Grimes.Sh HISTORY
11847d53ed2SBaptiste DaroussinThe
119e8937ba0SPhilippe Charnier.Nm
12047d53ed2SBaptiste Daroussinutility first appeared in
12147d53ed2SBaptiste Daroussin.Bx 1 .
12247d53ed2SBaptiste Daroussin.Sh AUTHORS
12347d53ed2SBaptiste Daroussin.An -nosplit
12447d53ed2SBaptiste Daroussin.An Bill Joy
12547d53ed2SBaptiste Daroussinand
12647d53ed2SBaptiste Daroussin.An Chuck Haley ,
12747d53ed2SBaptiste Daroussin1977.
1289b50d902SRodney W. Grimes.Sh BUGS
129e8937ba0SPhilippe CharnierThe
130e8937ba0SPhilippe Charnier.Nm
131e8937ba0SPhilippe Charnierutility was intended for the limited architecture of the PDP 11 family.
13287faa07bSSheldon HearnVery few programs actually use it.
13385da09e8SDiomidis SpinellisThe memory savings are negligible in modern computers.
134