8815 mega_sas: variable set but not used
[unleashed.git] / usr / src / man / man1 / genmsg.1
blob8b761cfe06ff5e6b1dc587dcfbc85314988c579f
1 '\" te
2 .\"  Portions Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH GENMSG 1 "May 14, 2004"
7 .SH NAME
8 genmsg \- generate a message source file by extracting messages from source
9 files
10 .SH SYNOPSIS
11 .LP
12 .nf
13 \fBgenmsg\fR [\fB-abdfrntx\fR] [\fB-c\fR \fImessage-tag\fR] [\fB-g\fR \fIproject-file\fR]
14      [\fB-l\fR \fIproject-file\fR] [\fB-m\fR \fIprefix\fR] [\fB-M\fR \fIsuffix\fR]
15      [\fB-o\fR \fImessage-file\fR] [\fB-p\fR \fIpreprocessor\fR] [\fB-s\fR \fIset-tags\fR] \fI file\fR...
16 .fi
18 .SH DESCRIPTION
19 .sp
20 .LP
21 The \fBgenmsg\fR utility extracts message strings with calls to
22 \fBcatgets\fR(3C) from source files and writes them in a format suitable for
23 input to \fBgencat\fR(1).
24 .SS "Invocation"
25 .sp
26 .LP
27 \fBgenmsg\fR reads one or more input files and, by default, generates a message
28 source file whose name is composed of the first input file name with
29 \fB\&.msg\fR. If the \fB-o\fR option is specified, \fBgenmsg\fR uses the option
30 argument for its output file.
31 .sp
33 .sp
34 .TS
35 box;
36 l | l
37 l | l .
38 \fICommand\fR   \fIOutput File\fR
40 \fBgenmsg prog.c\fR     prog.c.msg
41 \fBgensmg main.c util.c tool.c\fR       main.c.msg
42 \fBgenmsg -o prog.msg mail.c util.c\fR  prog.msg
43 .TE
45 .sp
46 .LP
47 \fBgenmsg\fR also allows you to invoke a preprocessor to solve the dependencies
48 of macros and define statements for the \fBcatgets\fR(3C) calls.
49 .SS "Auto Message Numbering"
50 .sp
51 .LP
52 \fBgenmsg\fR replaces message numbers with the calculated numbers based upon
53 the project file if the message numbers are \fB-1\fR, and it generates copies
54 of the input files with the new message numbers and a copy of the project file
55 with the new maximum message numbers.
56 .sp
57 .LP
58 A project file is a database that stores a list of set numbers with their
59 maximum message numbers. Each line in a project file is composed of a set
60 number and its maximum message number:
61 .sp
62 .ne 2
63 .na
64 \fB\fISet_number\fR\fR
65 .ad
66 .RS 14n
67 \fIMaximum_message_number\fR
68 .RE
70 .sp
71 .LP
72 In a project file, a line beginning with a number sign (\fB#\fR) or an
73 \fBASCII\fR space is considered as a comment and ignored.
74 .sp
75 .LP
76 \fBgenmsg\fR also has the reverse operation to replace all message numbers with
77 \fB-1\fR.
78 .SS "Comment Extraction"
79 .sp
80 .LP
81 \fBgenmsg\fR allows you to comment about messages and set numbers to inform the
82 translator how the messages should be translated. It extracts the comment,
83 which is surrounded with the comment indicators and has the specified tag
84 inside the comment, from the input file and writes it with a dollar (\fB$\fR)
85 prefix in the output file. \fBgenmsg\fR supports the C and C++ comment
86 indicators, '\fB/*\fR', '\fB*/\fR', and '\fB//\fR'.
87 .SS "Testing"
88 .sp
89 .LP
90 \fBgenmsg\fR generates two kinds of messages for testing, prefixed messages and
91 long messages. Prefixed messages allow you to check that your program is
92 retrieving the messages from the message catalog. Long messages allow you to
93 check the appearance of your window program's initial size and position.
94 .SH OPTIONS
95 .sp
96 .LP
97 The following options are supported:
98 .sp
99 .ne 2
101 \fB\fB-a\fR\fR
103 .RS 19n
104 Append the output into the message file \fImessage-file\fR that is specified by
105 the \fB-o\fR option. If two different messages that have the same set and
106 message number are found, the message in the specified message file is kept and
107 the other message in the input file is discarded.
111 .ne 2
113 \fB\fB-b\fR\fR
115 .RS 19n
116 Place the extracted comment after the corresponding message in the output file.
117 This option changes the placement behavior of the \fB-s\fR or \fB-c\fR option.
121 .ne 2
123 \fB\fB-c\fR\fI message-tag\fR\fR
125 .RS 19n
126 Extract message comments having \fImessage-tag\fR inside them from the input
127 files and write them with a '\fB$\fR' prefix as a comment in the output file.
131 .ne 2
133 \fB\fB-d\fR\fR
135 .RS 19n
136 Include an original text of a message as a comment to be preserved along with
137 its translations. With this option, the translator can see the original
138 messages even after they are replaced with their translations.
142 .ne 2
144 \fB\fB-f\fR\fR
146 .RS 19n
147 Overwrite the input files and the project file when used with the \fB-l\fR or
148 \fB-r\fR option. With the \fB-r\fR option, \fBgenmsg\fR overwrites only the
149 input files.
153 .ne 2
155 \fB\fB-g\fR\fI project-file\fR\fR
157 .RS 19n
158 Generate \fIproject-file\fR that has a list of set numbers and their maximum
159 message numbers in the input files.
163 .ne 2
165 \fB\fB-l\fR\fI project-file\fR\fR
167 .RS 19n
168 Replace message numbers with the calculated numbers based upon
169 \fIproject-file\fR if the message numbers are \fB-1\fR in the input files, and
170 then generate copies of the input files with the new message numbers and a copy
171 of \fIproject-file\fR with the new maximum message numbers. If
172 \fIproject-file\fR is not found, \fBgenmsg\fR uses the maximum message number
173 in the input file as a base number and generates \fIproject-file\fR.
177 .ne 2
179 \fB\fB-m\fR\fI prefix\fR\fR
181 .RS 19n
182 Fill in the message with \fIprefix\fR. This option is useful for testing.
186 .ne 2
188 \fB\fB-M\fR\fI suffix\fR\fR
190 .RS 19n
191 Fill in the message with \fIsuffix\fR. This option is useful for testing.
195 .ne 2
197 \fB\fB-n\fR\fR
199 .RS 19n
200 Add comment lines to the output file indicating the file name and line number
201 in the input files where each extracted string is encountered.
205 .ne 2
207 \fB\fB-o\fR\fI message-file\fR\fR
209 .RS 19n
210 Write the output to \fImessage-file\fR.
214 .ne 2
216 \fB\fB-p\fR\fI preprocessor\fR\fR
218 .RS 19n
219 Invoke \fIpreprocessor\fR to preprocess macros and define statements for the
220 \fBcatgets\fR(3C) calls. \fBgenmsg\fR first invokes the option argument as a
221 preprocesser and then starts the normal process against the output from the
222 preprocessor. \fBgenmsg\fR initiates this process for all the input files.
226 .ne 2
228 \fB\fB-r\fR\fR
230 .RS 19n
231 Replace message numbers with \fB-1\fR. This is the reverse operation of the
232 \fB-l\fR option.
236 .ne 2
238 \fB\fB-s\fR\fI set-tag\fR\fR
240 .RS 19n
241 Extract set number comments having \fIset-tag\fR inside them from the input
242 files and write them with a '\fB$\fR' prefix as a comment in the output file.
243 If multiple comments are specified for one set number, the first one is
244 extracted and the rest of them are discarded.
248 .ne 2
250 \fB\fB-t\fR\fR
252 .RS 19n
253 Generate a message that is three times as long as the original message. This
254 option is useful for testing.
258 .ne 2
260 \fB\fB-x\fR\fR
262 .RS 19n
263 Suppress warning messages about message and set number range checks and
264 conflicts.
267 .SH OPERANDS
269 .ne 2
271 \fB\fIfile\fR\fR
273 .RS 8n
274 An input source file.
277 .SH EXAMPLES
279 \fBExample 1 \fRAssigning Message Numbers and Generating New Files
282 Suppose that you have the following source and project files:
285 .in +2
287 example% cat test.c
288 printf(catgets(catfd, 1, -1, "line too long\en"));
289 printf(catgets(catfd, 2, -1, "invalid code\en"));
291 example% cat proj
292 1   10
293 2   20
295 .in -2
300 The command
303 .in +2
305 example% genmsg \fB-l\fR proj test.c
307 .in -2
312 would assign the calculated message numbers based upon \fBproj\fR and generate
313 the following files:
316 .ne 2
318 \fB\fBtest.c.msg\fR\fR
320 .RS 14n
321 Message file
325 .ne 2
327 \fB\fBproj.new\fR\fR
329 .RS 14n
330 Updated project file
334 .ne 2
336 \fB\fBtest.c.new\fR\fR
338 .RS 14n
339 New source file
343 .in +2
345 example% cat test.c.msg
346 $quote "
347 $set    1
348 11      "line too long\en"
349 $set    2
350 21      "invalid code\en"
352 example% cat proj.new
353 1   11
354 2   21
356 example% cat test.c.new
357 printf(catgets(catfd, 1, 11, "line too long\en"));
358 printf(catgets(catfd, 2, 21, "invalid code\en"));
360 .in -2
364 \fBExample 2 \fRExtracting Comments Into a File
367 The command
370 .in +2
372 example% genmsg \fB-s\fR SET \fB-c\fR MSG test.c
373 example% cat test.c
374 /* SET: tar messages */
375 /* MSG: don't translate "tar". */
376 catgets(catfd, 1, 1, "tar: tape write error");
377 // MSG: don't translate "tar" and "\fB-I\fR".
378 catgets(catfd, 1, 2, "tar: missing argument for \fB-I\fR flag");
380 .in -2
385 would extract the comments and write them in the following output file:
388 .in +2
390 example% cat test.c.msg
391 $ /* SET: tar messages */
392 $set    1
393 $ /* MSG: don't translate "tar". */
394 1       "tar: tape write error"
395 $ // MSG: don't translate "tar" and "-I".
396 2       "tar: missing argument for -I flag"
398 .in -2
402 \fBExample 3 \fRGenerating Test Messages
405 The following command:
408 .in +2
410 example% genmsg \fB-m\fR PRE: \fB-M\fR :FIX test.c
412 .in -2
417 might generate the following messages for testing:
420 .in +2
422 example% cat test.c.msg
423 1       "PRE:OK:FIX"
424 2       "PRE:Cancel:FIX"
426 .in -2
430 \fBExample 4 \fRParsing a Macro and Writing the Extracted Messages
433 Given the following input:
436 .in +2
438 example% cat example.c
439 #include <nl_types.h>
440 #define MSG1    "message1"
441 #define MSG2    "message2"
442 #define MSG3    "message3"
443 #define MSG(n)  catgets(catd, 1, n, MSG ## n)
444 void
445 main(int argc, char **argv)
447 nl_catd catd = catopen(argv[0], NL_CAT_LOCALE);
448 (void) printf("%s0\en, MSG(1));
449 (void) printf("%s0\en, MSG(2));
450 (void) printf("%s0\en, MSG(3));
451 (void) catclose(catd);
454 .in -2
459 The following command:
462 .in +2
464 example% genmsg \fB-p\fR "cc \fB-E\fR" \fB-o\fR example.msg example.c
466 .in -2
471 would parse the \fBMSG\fR macros and write the extracted messages in
472 \fBexample.msg\fR.
475 \fBExample 5 \fRAssigning Calculated Message Numbers
478 Suppose that you have the following header, source, and project files:
481 .in +2
483 example% cat ../inc/msg.h
484 #define WARN_SET        1
485 #define ERR_SET 2
486 #define WARN_MSG(id, msg) catgets(catd, WARN_SET, (id), (msg))
487 #define ERR_MSG(id, msg)  catgets(catd, ERR_SET, (id), (msg))
488 example% example.c
489 #include "msg.h"
490 printf("%s, WARN_MSG(-1, "Warning error"));
491 printf("%s, ERR_MSG(-1, "Fatal error"));
492 example % proj
493 1     10
494 2     10
496 .in -2
501 The command
504 .in +2
506 example% genmsg \fB-f\fR -p "cc \fB-E\fR \fB-I\fR../inc" \fB-l\fR proj \e
507    \fB-o\fR example.msg example.c
509 .in -2
514 would assign each of the \fB-1\fR message numbers a calculated number based
515 upon  \fBproj\fR and would overwrite the results to \fBexample.c\fR and
516 \fBproj\fR. Also, this command writes the extracted messages in
517 \fBexample.msg\fR.
519 .SH ENVIRONMENT VARIABLES
522 See \fBenviron\fR(5) for descriptions of the following environment variables
523 that affect the execution of \fBgenmsg\fR: \fBLC_MESSAGES\fR and \fBNLSPATH\fR.
524 .SH EXIT STATUS
527 The following exit values are returned:
529 .ne 2
531 \fB\fB0\fR\fR
533 .RS 6n
534 Successful completion.
538 .ne 2
540 \fB\fB>0\fR\fR
542 .RS 6n
543 An error occurred.
546 .SH SEE ALSO
549 \fBgencat\fR(1), \fBcatgets\fR(3C), \fBcatopen\fR(3C), \fBattributes\fR(5),
550 \fBenviron\fR(5)
551 .SH NOTES
554 \fBgenmsg\fR does not handle pointers or variables in the \fBcatgets\fR(3C)
555 call. For example:
557 .in +2
560 const int set_num = 1;
561 extern int msg_num(const char *);
562 const char *msg = "Hello";
563 catgets(catd, set_num, msg_num(msg), msg);
565 .in -2
570 When the auto message numbering is turned on with a preprocessor, if there are
571 multiple \fB-1's\fR in the \fBcatgets\fR(3C) line, \fBgenmsg\fR replaces all of
572 the \fB-1's\fR in the line with a calculated number. For example, given the
573 input:
575 .in +2
577 #define MSG(id, msg) catgets(catd, 1, (id), (msg))
578 if (ret == -1) printf("%s, MSG(-1, "Failed"));
580 .in -2
585 the command
587 .in +2
589 genmsg \fB-l\fR proj \fB-p\fR "cc \fB-E\fR"
591 .in -2
596 would produce:
598 .in +2
600    #define MSG(id, msg) catgets(catd, 1, (id), (msg))
601    if (ret == 1) printf("%s, MSG(1, "Failed"));
603 .in -2
608 The workaround would be to split it into two lines as follows:
610 .in +2
612    if (ret == -1)
613          printf("%s, MSG(-1, "Failed"));
615 .in -2