Merge commit '37e84ab74e939caf52150fc3352081786ecc0c29' into merges
[unleashed.git] / usr / src / cmd / msgfmt / sun_msgfmt.h
blob98f06183a9d356393d00ccede4e6eaed6a3c3ee2
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ifndef _SUN_MSGFMT_H
28 #define _SUN_MSGFMT_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <string.h>
33 #include <locale.h>
34 #include <stdio.h>
35 #include <wchar.h>
36 #include <ctype.h>
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <sys/stat.h>
40 #include <sys/mman.h>
41 #include <signal.h>
42 #include <malloc.h>
43 #include <libintl.h>
44 #include <stdlib.h>
45 #include <fcntl.h>
46 #include <unistd.h>
47 #include "../../lib/libc/inc/msgfmt.h"
48 #include "common.h"
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
54 #define DOMAIN_TOKEN L"domain" /* domain token in po file */
55 #define DOMAIN_LEN 6
56 #define MSGID_TOKEN L"msgid" /* msg id token in po file */
57 #define MSGID_LEN 5
58 #define MSGSTR_TOKEN L"msgstr" /* target str token in po file */
59 #define MSGSTR_LEN 6
61 #ifdef DEBUG_MMAP
62 #define MAX_VALUE_LEN 3 /* size of msg id and target str */
63 #define LINE_SIZE 1
64 #else
65 #define MAX_VALUE_LEN 512 /* size of msg id and target str */
66 #define LINE_SIZE 512
67 #endif
70 * check if the next character is possible valid character.
72 #define CK_NXT_CH(a, l) \
73 ((a[(l) - 1] == L' ') || (a[(l) - 1] == L'\t') || \
74 (a[(l) - 1] == L'\n') || (a[(l) - 1] == L'\0'))
76 struct msg_chain {
77 char *msgid; /* msg id string */
78 char *msgstr; /* msg target string */
79 int msgid_offset; /* msg id offset in mo file */
80 int msgstr_offset; /* msg target string offset in mo file */
81 struct msg_chain *next; /* next node */
84 struct domain_struct {
85 char *domain; /* domain name */
86 struct msg_chain *first_elem; /* head of msg link list */
87 struct msg_chain *current_elem; /* most recently used msg */
88 struct domain_struct *next; /* next domain node */
91 #define ERR_EXEC_FAILED \
92 "failed to execute %s.\n"
94 #define ERR_USAGE \
95 "Usage: msgfmt [-D dir | --directory=dir] [-f | --use-fuzzy]\n" \
96 " [-g] [-o outfile | --output-file=outfile]\n" \
97 " [-s] [--strict] [-v] [--verbose] files ...\n"
99 #define ERR_GNU_ON_SUN \
100 "-g and -s are mutually exclusive.\n"
102 #define ERR_STAT_FAILED \
103 "stat failed for %s.\n"
105 #define ERR_MMAP_FAILED \
106 "mmap failed for %s.\n"
108 #define ERR_MUNMAP_FAILED \
109 "munmap failed for %s.\n"
111 #define ERR_NOSPC \
112 "Error, No space after directive at line number %d.\n"
114 #define ERR_EXITING \
115 "Exiting...\n"
117 #define WARN_NO_MSGSTR \
118 "Consecutive MSGID tokens " \
119 "encountered at line number: %d, ignored.\n"
121 #define WARN_NO_MSGID \
122 "Consecutive MSGSTR tokens " \
123 "encountered at line number: %d, ignored.\n"
125 #define WARN_SYNTAX_ERR \
126 "Syntax at line number: %d, " \
127 "line ignored\n"
129 #define WARN_MISSING_QUOTE \
130 "Syntax at line number: %d, " \
131 "Missing \", ignored\n"
133 #define WARN_MISSING_QUOTE_AT_EOL \
134 "Syntax at line number: %d, " \
135 "Missing \" at EOL, ignored\n"
137 #define WARN_INVALID_STRING \
138 "the string after closing \" " \
139 "is ignored at line number %d.\n"
141 #define WARN_DUP_MSG \
142 "Duplicate id \"%s\" at line number: " \
143 "%d, line ignored\n"
145 #define DIAG_GNU_FOUND \
146 "GNU PO file found.\n"
148 #define DIAG_INVOKING_GNU \
149 "Generating the MO file in the GNU MO format.\n"
151 #ifdef __cplusplus
153 #endif
155 #endif /* _SUN_MSGFMT_H */