-
Notifications
You must be signed in to change notification settings - Fork 2
/
nlsaspct.h
130 lines (106 loc) · 4.16 KB
/
nlsaspct.h
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
/*
DISKCOPY.EXE, floppy diskette duplicator similar to MSDOS Diskcopy.
Copyright (C) 1998, Matthew Stanford.
Copyright (C) 1999, 2000, 2001 Imre Leber.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have recieved a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
If you have any questions, comments, suggestions, or fixes please
email me at: [email protected]
*/
#ifndef INTERNATIONALIZATION_ASPECT_H_
#define INTERNATIONALIZATION_ASPECT_H_
/*
** Poor man's aspect oriented implementation of the internationalization
** aspect on diskcopy.
**
** Crosscuts are explicitelly named in the component code. I.e. no full
** seperation of concerns.
*/
#include "cats\catgets.h"
#define DISKCOPY_NLS_FILE_BASE "diskcopy"
/*
** Aspect definition to define the data used in the implementation
** of the aspect.
*/
#define CROSSCUT_NLS_DATA \
char *Cade[5]; \
nl_catd catd; \
\
char CatYES='Y'; /* Default values for YES and NO, */ \
char CatNO ='N'; /* can be overwritten */
/*
** This definition imports the NLS data objects in the
** current name space.
*/
#define CROSSCUT_NLS_DATA_IMPORT \
extern char* Cade[]; \
extern nl_catd catd; \
\
extern char CatYES; \
extern char CatNO;
/*
** This definition opens the catalog and sets catYES and catNO,
** i.e. the NLS values for 'Y' and 'N'.
*/
#define CROSSCUT_NLS_OPEN \
{ \
/* Try opening NLS catalog*/ \
catd = catopen (DISKCOPY_NLS_FILE_BASE, 1); \
\
/* Get the definition for YES and NO chars */ \
Cade[0] = catgets (catd, 0, 0, "Y"); \
CatYES=*(char *)Cade[0]; \
Cade[0] = catgets (catd, 0, 1, "N"); \
CatNO =*(char *)Cade[0]; \
}
/*
** This definition closes the catalog.
*/
#define CROSSCUT_NLS_CLOSE \
{ \
/* Close the catalog */ \
catclose(catd); \
}
/*
** This (generic) aspect gets the indicated message from the catalog
** and writes it on the screen.
*/
#define NLS_PRINTSTRING(setnum, msgnum, message) \
{ \
Cade[0] = catgets (catd, setnum, msgnum, message); \
printf("%s", Cade[0]); \
}
/*
** This (generic) aspect gets the indicated message from the catalog
** and writes it on the screen, followed by a newline.
*/
#define NLS_PUTSTRING(setnum, msgnum, message) \
{ \
Cade[0] = catgets (catd, setnum, msgnum, message); \
printf("%s", Cade[0]); \
puts(""); \
}
/*
** This definition returns the indicated string.
*/
#define NLS_STRING(setnum, msgnum, message) \
catgets(catd, setnum, msgnum, message)
/*
** These definitions test wether the char is the NLS char for YES or NO.
*/
#define NLS_TEST_YES_NO(x) \
((x == CatYES) || (x == CatNO))
#define NLS_TEST_YES(x) \
(x == CatYES)
#define NLS_TEST_NO(x) \
(x == CatNO)
#endif