MKSTR(1) HP-UX 5.0 MKSTR(1) NAME mkstr - extract error messages from C source into a file SYNOPSIS mkstr [ - ] messagefile prefix file ... HP-UX COMPATIBILITY Level: HP-UX/DEVELOPMENT Origin: UCB DESCRIPTION Mkstr examines a C program and creates a file containing error message strings used by the program. Programs with many error diagnostics can be made much smaller by referring to places in the file, and reduce system overhead in running the program. Mkstr processes each of the specified files, placing a revised version of each in a file whose name consists of the specified prefix concatenated to the original name. A typical usage of mkstr would be mkstr mystrings xx *.c This command would cause all the error messages from the C source files in the current directory to be placed in the file mystrings and revised copies of the source for these files to be placed in files whose names are prefixed with xx. To process the error messages in the source to the message file mkstr keys on the string error(" in the input file. Each time it is encountered, the C string starting after the `"' is placed in the message file followed by a null character and a new-line character; the null character terminates the message so it can be easily used when retrieved, and the new-line character makes it possible to sensibly cat the error message file to see its contents. The new copy of the input file is the same as the original, except that each occurrence of a string that is in the error message file is replaced by an offset pointer usable by lseek to retrieve the message. The optional - on the command line causes the error messages to be placed at the end of the specified message file instead of overwriting it. When many source files constitute a large mkstred program, this can be used to avoid reprocessing all the files. All functions used by the original program whose names end in "error" and that can take a constant string as their first argument should be rewritten so that they search for the string in the error message file. For example: #include #include #include char errfile[] = "mystrings"; error(offset, a2, a3, a4) int offset, a1, a2, a3; { char msg[256]; static int fd = -1; if (fd < 0) { fd = open(errfile, O_RDONLY); if (fd < 0) { perror(errfile); exit(1); } } if (lseek(fd, (off_t) offset, 0) || read(fd, msg, 256) <= 0) { printf("? Can't find error message in %s:\n", errfile); perror(errfile); exit(1); } printf(msg, a1, a2, a3); } SEE ALSO lseek(2), perror(3C), xstr(1) BUGS Strings in calls to functions whose names end in 'error', notably perror(3C), may be replaced with offsets. Calls to error functions whose first argument is not a string constant are left unmodified without warning.