DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

mkcatdefs(CP)


mkcatdefs -- preprocess a message source file

Syntax

mkcatdefs [ -a archive ] [ -h | -s ] sym_name source_file ...

Description

mkcatdefs reads the file source_file, containing message source information, and writes message source data to a file called sym_name_msg.h.

mkcatdefs also writes the message source data, with numbers instead of symbolic identifiers, to the standard output. This output is suitable for use as input to gencat(CP).

With option -a, mkcatdefs appends @archive to the name of the message catalog defined in sym_name_msg.h (the MF_PROG macro). This indicates that the message catalog is to be found under an archive directory, archive, where a number of related message catalog files are stored.

The -h option suppresses the generation of a _msg.h file.

The -s option causes mkcatdefs to generate a _msg.sh file, suitable for inclusion in Bourne or Korn shell scripts that use dspmsg(C) to print locale-dependent messages.

Programs that use message catalogs print messages by using a message ID number as an index into a message catalog. (Messages are stored, one per line, in the catalog file.) By substituting a translated message catalog, the program can be made to print messages in a different language without being recompiled.

It is easier for a human programmer to work with symbolic message names than raw message ID numbers. Consequently, a message file source_file is used to link symbolic message names to message catalog numbers. mkcatdefs reads the source_file; it creates a _msg.h or _msg.sh that is sourced into the program using the message catalog. When the program encounters a symbolic name defined in source_file, it dereferences the symbolic name to an appropriate message number, then dereferences the message number to a message in the message catalog.

The minimal localization system only accepts numbers as references to messages in the message catalog (hence the provision of mkcatdefs). The SCO OpenServer system additionally permits you to use alphanumeric identifiers. Alphanumeric identifiers may be assigned to sets and messages in the same manner as numerical identifiers.

Source file format

mkcatdefs recognizes the following commands in the source file:

$ comment
A line beginning with a $ symbol followed by one or more spaces is interpreted as a comment unless it occurs within message text.

$delset n [ comment ]
The delset command removes all the messages belonging to set n from the catalog.

$quote [ char ][ comment ]
The quote command uses the specified character char as a delimiter, before and after the message text.

$set n [ comment ]
The set command groups a set of messages under a set number n. n can be an alphanumeric string up to 65 bytes long (containing only ASCII letters, digits, or the underscore character). If no set number is specified, the assigned set number is either 1 or the previous set number plus 1.

identifier message_text
An identifier that is not preceded by one of the mkcatdefs commands is associated with the message message_text. If the source file contains a $quote command, the message_text is output between quotation characters. Message message_text may contain the following special characters:

\b
backspace

\f
formfeed

\n
newline

\r
carriage return

\t
horizontal tab

\v
vertical tab

\\
backslash

\ddd
single byte character with the octal value ddd

\xdddd
single byte or double byte character with the hexadecimal value ddd

\<Return>
escape the subsequent <Return> character, allowing the message to continue on the next line of the input file
Note that hexadecimal or octal values with less than the maximum number of digits must be padded with zeros to prevent parsing errors. If the messages are displayed by applications that call printf(S), the usual printf format specifiers may be used. If the messages are displayed using dspmsg(C), the messages may contain the %s or %n$s format specifiers.

Examples

The following message source file, prog.msg, may be used to provide messages for a program called prog:
   $       @(#) prog.msg 25.1 93/12/07
   $quote "
   $set MS_PROG
   PROG_MSG_ST_USAGE  "usage: settime [-f file | mmddhhmm[yy]] file ...\n"
   PROG_MSG_TO_USAGE  "usage: prog [-acm] \
   [-r ref_file | -t [[CC]YY]MMDDhhmm[.SS]] file ...\n"
   PROG_MSG_TO_USAGE2 "       prog [-acm] [MMDDhhmm[yy]] file ...\n"
   PROG_ERR_NOREF     "Cannot stat reference file %s"
   PROG_MSG_ILL_DATE  "Invalid date specifier %s"
   PROG_MSG_NOCR      "cannot create %s"
   PROG_MSG_NOST      "cannot stat %s"
   PROG_MSG_NCT       "cannot change times on %s"
To process this file, issue the command:

mkcatdefs -a archive prog prog.msg

This produces the following output file prog_msg.h:

   #ifndef _H_PROG_MSG
   #define _H_PROG_MSG
   #include <limits.h>
   #include <nl_types.h>
   #define MF_PROG "prog.cat@archive"
   #ifndef MC_FLAGS
   #define MC_FLAGS NL_CAT_LOCALE
   #endif
   #ifndef MSGSTR
   extern char *catgets_safe(nl_catd, int, int, char *);
   #ifdef lint
   #define MSGSTR(num,str) (str)
   #define MSGSTR_SET(set,num,str) (str)
   #else
   #define MSGSTR(num,str) catgets_safe(catd, MS_PROG, (num), (str))
   #define MSGSTR_SET(set,num,str) catgets_safe(catd, (set), (num), (str))
   #endif
   #endif
   /* The following was generated from */
   /* prog.msg */
   

#define MS_PROG 1 #define PROG_MSG_ST_USAGE 1 #define PROG_MSG_TO_USAGE 2 #define PROG_MSG_TO_USAGE2 3 #define PROG_ERR_NOREF 4 #define PROG_MSG_ILL_DATE 5 #define PROG_MSG_NOCR 6 #define PROG_MSG_NOST 7 #define PROG_MSG_NCT 8 #endif /* _H_PROG_MSG */

The message source data, with message numbers, written to the standard output by the preceding command is:
   1  "usage: settime [-f file | mmddhhmm[yy]] file ...\n"
   2  "usage: prog [-acm] \
   [-r ref_file | -t [[CC]YY]MMDDhhmm[.SS]] file ...\n"
   3 "       prog [-acm] [MMDDhhmm[yy]] file ...\n"
   4     "Cannot stat reference file %s"
   5  "Invalid date specifier %s"
   6      "cannot create %s"
   7      "cannot stat %s"
   8       "cannot change times on %s"

See also

dspmsg(C), gencat(CP), localedef(C), localedef(F), printf(S)

Standards conformance

mkcatdefs is not part of any currently supported standard; it is an extension of AT&T System V that is maintained by The SCO Group.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005