mbgtools-lx  4.2.8
ctry.h
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: ctry.h 1.14 2017/06/23 09:53:27 martin REL_M $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Definitions and prototypes for ctry.c.
10  *
11  * -----------------------------------------------------------------------
12  * $Log: ctry.h $
13  * Revision 1.14 2017/06/23 09:53:27 martin
14  * Fixed spelling in an earlier log message.
15  * Revision 1.13 2012/11/29 12:01:09 martin
16  * Don't include mbg_tgt.h explicitly since this will anyway be
17  * included by words.h for non-firmware targets. So mbg_tgt.h
18  * must not necessarily be added to firmware projects.
19  * Revision 1.12 2011/06/22 07:37:57Z martin
20  * Cleaned up handling of pragma pack().
21  * Revision 1.11 2010/07/15 08:33:41 martin
22  * Added some macros implemented by Stefan.
23  * Updated function prototypes.
24  * Revision 1.10 2007/03/29 12:21:10 martin
25  * Updated function prototypes.
26  * Revision 1.9 2004/10/26 07:38:50Z martin
27  * Redefined interface data types using C99 fixed-size definitions.
28  * Updated function prototypes.
29  * Revision 1.8 2004/04/14 08:47:28 martin
30  * Pack structures 1 byte aligned.
31  * Revision 1.7 2002/02/19 09:28:00Z MARTIN
32  * Use new header mbg_tgt.h to check the target environment.
33  * Revision 1.6 2001/09/14 12:04:40 MARTIN
34  * Modified definition for CLSTR.
35  * Updated function prototypes.
36  * Revision 1.5 2001/02/28 15:07:06 MARTIN
37  * Modified preprocessor syntax.
38  * Revision 1.4 2000/11/27 14:13:27 MARTIN
39  * New types CLSTR, PLSTR, and PCLSTR.
40  * New macro _lstr() calls lstr_lng() for the current language.
41  * Definitions associated with ctry_fmt_dt() and ctry_fmt_times()
42  * have been moved to a new file ctry_fmt.h.
43  * Updated function prototypes.
44  * Revision 1.3 2000/08/17 15:35:02 MARTIN
45  * No init function by default (previously DOS),
46  * Revision 1.2 2000/07/21 09:48:34 MARTIN
47  * Initial revision
48  *
49  **************************************************************************/
50 
51 #ifndef _CTRY_H
52 #define _CTRY_H
53 
54 
55 /* Other headers to be included */
56 
57 #include <words.h>
58 
59 #if defined( MBG_TGT_NETWARE )
60  #include <ctry_nw.h>
61 #elif defined( MBG_TGT_OS2 )
62  #include <ctry_os2.h>
63 #elif defined( MBG_TGT_WIN32 )
64  // #include <ctry_w32.h>
65 #elif defined( MBG_TGT_LINUX )
66  // #include <ctry_lx.h>
67 #elif defined( MBG_TGT_DOS )
68  #include <ctry_dos.h>
69 #else
70  // nothing to include for C166 etc.
71 #endif
72 
73 #include <use_pack.h>
74 
75 
76 #ifdef _CTRY
77  #define _ext
78 #else
79  #define _ext extern
80 #endif
81 
82 
83 /* Start of header body */
84 
85 #if defined( _USE_PACK )
86  #pragma pack( 1 ) // set byte alignment
87  #define _USING_BYTE_ALIGNMENT
88 #endif
89 
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 
96 // the definitions below are used to support different languages:
97 typedef uint8_t LANGUAGE;
99 
100 // codes used with LANGUAGE:
101 #if !defined LNG_DEFINED
102  enum
103  {
107  };
108 
109  #define LNG_DEFINED
110 #endif
111 
112 // the type below is used to declare string variables
113 // for several languages
114 typedef char *LSTR[N_LNG]; // array of strings
115 typedef char **PLSTR; // pointer to array
116 
117 // same as above, but const
118 typedef const char * const CLSTR[N_LNG]; // array of strings
119 typedef const char * const *PCLSTR; // pointer to array
120 
121 
122 // the definitions below are used to handle date and time
123 // formats used by different countries:
124 typedef struct
125 {
126  CTRY_CODE code;
127 
128  uint8_t dt_fmt; // (codes defined below)
129  uint8_t tm_fmt; // (codes defined below)
130  char dt_sep; // (valid chars defined below)
131  char tm_sep; // (valid chars defined below)
132 } CTRY;
133 
134 
135 // codes used with CTRY.code:
136 #define CTRY_US 1
137 #define CTRY_UK 44
138 #define CTRY_GERMANY 49
139 
140 
141 #ifndef CTRY_DEFINED
142 
143  #define CTRY_DEFINED
144 
145  // codes used with CTRY.dt_fmt:
146  enum
147  {
152  };
153 
154  // codes used with CTRY.tm_fmt:
155  enum
156  {
158  // TM_FMT_12H, // not yet supported
160  };
161 
162 
163  // codes used with CTRY.dt_sep:
164  #define DT_SEP_DOT '.'
165  #define DT_SEP_MINUS '-'
166  #define DT_SEP_SLASH '/'
167 
168  // a zero-terminated list of valid dt_sep characters
169  #define DT_SEP_LIST { DT_SEP_DOT, DT_SEP_MINUS, DT_SEP_SLASH, 0 }
170 
171 
172  // codes used with CTRY.tm_sep:
173  #define TM_SEP_COLON ':'
174  #define TM_SEP_DOT '.'
175 
176  // a zero-terminated list of valid tm_sep characters
177  #define TM_SEP_LIST { TM_SEP_COLON, TM_SEP_DOT, 0 }
178 
179 #endif // CTRY_DEFINED
180 
181 
182 extern LANGUAGE language;
183 extern CTRY ctry;
184 
185 
186 #define _ctry_init() \
187  ctry_setup( ctry_get_code() )
188 
189 
190 #define _next_language() \
191 { \
192  if ( ++language >= N_LNG ) \
193  language = 0; \
194  \
195 } // next_language
196 
197 
198 // macro to call lstr_lng with the current language
199 #define _lstr( _s ) lstr_lng( (_s), language )
200 
201 // macro to call clstr_lng with the current language, and a set of strings
202 #define _clstr( _s ) clstr_lng( language, _s )
203 
204 // macros used in wxWidgets projects
205 #if defined( __WXWINDOWS__ )
206  #define _wx_lstr( _s ) wxString::From8BitData( lstr_lng( (_s), language ) )
207  #define _wx_clstr( _s ) wxString::From8BitData( clstr_lng( language, _s ) )
208 #endif
209 
210 
211 /* ----- function prototypes begin ----- */
212 
213 /* This section was generated automatically */
214 /* by MAKEHDR, do not remove the comments. */
215 
216  int lstr_idx( CLSTR s, int lng ) ;
217  int lstr_array_idx( CLSTR s, int idx, int n_lng, int lng ) ;
218  const char *lstr_lng( CLSTR s, int lng ) ;
219  void ctry_setup( CTRY_CODE code ) ;
220  void ctry_next( void ) ;
221  const char *clstr_lng( int index, ... ) ;
222 
223 /* ----- function prototypes end ----- */
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 
230 #if defined( _USING_BYTE_ALIGNMENT )
231  #pragma pack() // set default alignment
232  #undef _USING_BYTE_ALIGNMENT
233 #endif
234 
235 /* End of header body */
236 
237 
238 #undef _ext
239 
240 #endif /* _CTRY_H */
241 
uint16_t CTRY_CODE
Definition: ctry.h:98
const char *const CLSTR[N_LNG]
Definition: ctry.h:118
char * LSTR[N_LNG]
Definition: ctry.h:114
char ** PLSTR
Definition: ctry.h:115
Definition: ctry.h:159
LANGUAGE language
Definition: mbgstatus.c:125
unsigned short uint16_t
Definition: words.h:213
uint8_t LANGUAGE
Definition: ctry.h:97
char tm_sep
Definition: ctry.h:131
CTRY_CODE code
Definition: ctry.h:126
uint8_t tm_fmt
Definition: ctry.h:129
unsigned idx
Definition: cfg_hlp.h:735
int lstr_array_idx(CLSTR s, int idx, int n_lng, int lng)
Definition: ctry.c:73
unsigned char uint8_t
Definition: words.h:210
void ctry_setup(CTRY_CODE code)
Definition: ctry.c:92
uint8_t dt_fmt
Definition: ctry.h:128
const char * lstr_lng(CLSTR s, int lng)
Definition: ctry.c:83
Definition: ctry.h:106
CTRY ctry
Definition: mbgstatus.c:126
const char * clstr_lng(int index,...)
Definition: ctry.c:155
void ctry_next(void)
Definition: ctry.c:132
int lstr_idx(CLSTR s, int lng)
Definition: ctry.c:51
char dt_sep
Definition: ctry.h:130
Definition: ctry.h:124
const char *const * PCLSTR
Definition: ctry.h:119
Definition: ctry.h:151