*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> mkstr (1)              
Title
Content
Arch
Section
 

Contents


 mkstr(1)                                                           mkstr(1)




 NAME    [Toc]    [Back]
      mkstr - extract error messages from C source into a file

 SYNOPSIS    [Toc]    [Back]
      mkstr [-] messagefile prefix file ...

 DESCRIPTION    [Toc]    [Back]
      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 in front of 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.

      When processing the error messages in the source for transfer to the
      message file, mkstr searches for the string error( in the input file.
      Each time it is encountered, the C string starting after the leading
      quote is placed in the message file, followed by a null character and
      a new-line character.  The null character terminates the message so
      that it can be easily used when retrieved, and the new-line character
      makes it possible to conveniently list the error message file (using
      cat, more, etc. - see cat(1) and more(1)) to review its contents.

      The modified copy of the input file is identical to the original,
      except that each occurrence of any string that was moved to the error
      message file is replaced by an offset pointer usable by lseek to
      retrieve the message.

      If the command line includes the optional -, extracted error messages
      are placed at the end of the specified message file (append) instead
      of overwriting it.  This enables you to process individual files that
      are part of larger programs that have been previously processed by
      mkstr without reprocessing all the files.

      All functions used by the original program whose names end in "error"
      that also 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, a program based on the previous example usage would
      resemble the following:



 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 mkstr(1)                                                           mkstr(1)




           #include <stdio.h>
           #include <sys/types.h>
           #include <fcntl.h>

           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);
           }

 EXTERNAL INFLUENCES    [Toc]    [Back]
    Environment Variables
      LC_CTYPE determines the interpretation of comments and string literals
      as single- and/or multi-byte characters.

      If LC_CTYPE is not specified in the environment or is set to the empty
      string, the value of LANG is used as a default for each unspecified or
      empty variable.  If LANG is not specified or is set to the empty
      string, a default of "C" (see lang(5)) is used instead of LANG.  If
      any internationalization variable contains an invalid setting, mkstr
      behaves as if all internationalization variables are set to "C".  See
      environ(5).

    International Code Set Support    [Toc]    [Back]
      Single- and multi-byte character code sets are supported within file
      names, comments, and string literals.

 SEE ALSO    [Toc]    [Back]
      lseek(2), perror(3C), xstr(1).

 BUGS    [Toc]    [Back]
      Strings in calls to functions whose names end in error, notably



 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003






 mkstr(1)                                                           mkstr(1)




      perror(), may be replaced with offsets by mkstr.

      Calls to error functions whose first argument is not a string constant
      are left unmodified without warning.


 Hewlett-Packard Company            - 3 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
mkstr FreeBSD create an error message file by massaging C source
mkstr IRIX create an error message file by massaging C source
mkstr OpenBSD create an error message file by massaging C source
mkstr NetBSD create an error message file by massaging C source
exstr IRIX extract strings from source files
perror OpenBSD write error messages to standard error
perror NetBSD write error messages to standard error
vwarnx FreeBSD formatted error messages
err FreeBSD formatted error messages
verr OpenBSD formatted error messages
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service