1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* 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.
*
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#ifndef _SUN_MSGFMT_H
#define _SUN_MSGFMT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <locale.h>
#include <stdio.h>
#include <wchar.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <signal.h>
#include <malloc.h>
#include <libintl.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include "../../lib/libc/inc/msgfmt.h"
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DOMAIN_TOKEN L"domain" /* domain token in po file */
#define DOMAIN_LEN 6
#define MSGID_TOKEN L"msgid" /* msg id token in po file */
#define MSGID_LEN 5
#define MSGSTR_TOKEN L"msgstr" /* target str token in po file */
#define MSGSTR_LEN 6
#ifdef DEBUG_MMAP
#define MAX_VALUE_LEN 3 /* size of msg id and target str */
#define LINE_SIZE 1
#else
#define MAX_VALUE_LEN 512 /* size of msg id and target str */
#define LINE_SIZE 512
#endif
/*
* check if the next character is possible valid character.
*/
#define CK_NXT_CH(a, l) \
((a[(l) - 1] == L' ') || (a[(l) - 1] == L'\t') || \
(a[(l) - 1] == L'\n') || (a[(l) - 1] == L'\0'))
struct msg_chain {
char *msgid; /* msg id string */
char *msgstr; /* msg target string */
int msgid_offset; /* msg id offset in mo file */
int msgstr_offset; /* msg target string offset in mo file */
struct msg_chain *next; /* next node */
};
struct domain_struct {
char *domain; /* domain name */
struct msg_chain *first_elem; /* head of msg link list */
struct msg_chain *current_elem; /* most recently used msg */
struct domain_struct *next; /* next domain node */
};
#define ERR_EXEC_FAILED \
"failed to execute %s.\n"
#define ERR_USAGE \
"Usage: msgfmt [-D dir | --directory=dir] [-f | --use-fuzzy]\n" \
" [-g] [-o outfile | --output-file=outfile]\n" \
" [-s] [--strict] [-v] [--verbose] files ...\n"
#define ERR_GNU_ON_SUN \
"-g and -s are mutually exclusive.\n"
#define ERR_STAT_FAILED \
"stat failed for %s.\n"
#define ERR_MMAP_FAILED \
"mmap failed for %s.\n"
#define ERR_MUNMAP_FAILED \
"munmap failed for %s.\n"
#define ERR_NOSPC \
"Error, No space after directive at line number %d.\n"
#define ERR_EXITING \
"Exiting...\n"
#define WARN_NO_MSGSTR \
"Consecutive MSGID tokens " \
"encountered at line number: %d, ignored.\n"
#define WARN_NO_MSGID \
"Consecutive MSGSTR tokens " \
"encountered at line number: %d, ignored.\n"
#define WARN_SYNTAX_ERR \
"Syntax at line number: %d, " \
"line ignored\n"
#define WARN_MISSING_QUOTE \
"Syntax at line number: %d, " \
"Missing \", ignored\n"
#define WARN_MISSING_QUOTE_AT_EOL \
"Syntax at line number: %d, " \
"Missing \" at EOL, ignored\n"
#define WARN_INVALID_STRING \
"the string after closing \" " \
"is ignored at line number %d.\n"
#define WARN_DUP_MSG \
"Duplicate id \"%s\" at line number: " \
"%d, line ignored\n"
#define DIAG_GNU_FOUND \
"GNU PO file found.\n"
#define DIAG_INVOKING_GNU \
"Generating the MO file in the GNU MO format.\n"
#ifdef __cplusplus
}
#endif
#endif /* _SUN_MSGFMT_H */
|