[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 3

mkstr Command


Creates an error message file.


mkstr [ - ] MessageFile Prefix File ...


The mkstr command creates a file of error messages that can be removed from a single C source file or from multiple source files. Its use can reduce the size of programs that contain many error diagnostics and reduce system overhead in running such programs, since error messages are then not constantly swapped in and out of the source file(s).

The mkstr command processes each file specified by the File parameter, placing a massaged version of the file in a file having the name specified by the Prefix parameter followed by the original name.

To process the error messages in the source to the file specified by the MessageFile parameter, the mkstr command keys on the string `error("' in the input stream. The string, starting at the '"' (two double quotation marks), is placed in the message file and followed by a null character and a new-line character. The null character terminates the message so it can be easily used when retrieved. The new-line character makes it possible to see the contents of the error message file by using the cat command.

The massaged copy of the input file then contains an lseek pointer into the file, which can be used to retrieve the message to its appropriate source file, as shown in the following example:

char efilname[] = "/usr/lib/pistrings";
int    efil = -1;
error(a1, a2, a3, a4)
    char buf[256];
    if (efil < 0) {
        efil = open(efilname, 0);
        if (efil < 0) {
    if (lseek(efil,(long) a1,0) <0|| 
         read(efil,buf, 256) <= 0)
        goto oops;
    printf(buf, a2, a3, a4);


- The optional - (minus sign) causes the error messages to be placed at the end of the MessageFile for recompiling part of a large mkstr program.


  1. To put the error messages from the current directory C source files into the file pistrings and to put processed copies of the source for these files into file names prefixed by xx, enter:
    mkstr pistrings xx *.c
  2. To append the error messages from an additional source file into the file pistrings, enter:
    mkstr - pistrings xx newfile.c


/usr/ccs/bin/mkstr Contains the mkstr command.

Related Information

The cat command, xstr command.

The lseek subroutine.

[ Previous | Next | Contents | Glossary | Home | Search ]