Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* functions that read/write from/to the localcfg country.sys-like file.
|
2 |
* functions that read/write from/to the localcfg country.sys-like file.
|
3 |
* Copyright (C) Mateusz Viste 2015
|
3 |
* Copyright (C) Mateusz Viste 2015-2022
|
4 |
*/
|
4 |
*/
|
5 |
|
5 |
|
6 |
#ifndef country_h_sentinel
|
6 |
#ifndef country_h_sentinel
|
7 |
#define country_h_sentinel
|
7 |
#define country_h_sentinel
|
8 |
|
8 |
|
Line 16... |
Line 16... |
16 |
COUNTRY_TIME12 = 0, /* AM/PM format (like 6:32 PM) */
|
16 |
COUNTRY_TIME12 = 0, /* AM/PM format (like 6:32 PM) */
|
17 |
COUNTRY_TIME24 = 1 /* 24h format (like 18:32) */
|
17 |
COUNTRY_TIME24 = 1 /* 24h format (like 18:32) */
|
18 |
};
|
18 |
};
|
19 |
|
19 |
|
20 |
|
20 |
|
- |
|
21 |
|
21 |
struct country {
|
22 |
struct country {
|
- |
|
23 |
|
- |
|
24 |
struct {
|
22 |
char currency[5]; /* currency symbold, ASCIIZ, 4 letters max */
|
25 |
unsigned short id; /* international id (48=PL, 33=FR, 01=US...) */
|
23 |
enum COUNTRY_DATEFMT datefmt; /* date format */
|
26 |
unsigned short codepage; /* usual codepage */
|
24 |
enum COUNTRY_TIMEFMT timefmt; /* time format */
|
27 |
unsigned short datefmt; /* date format */
|
25 |
short id; /* international ID */
|
28 |
char currsym[5]; /* currency symbol */
|
26 |
short codepage; /* usual codepage */
|
29 |
char thousands[2]; /* thousands separator */
|
27 |
unsigned char currencyprec; /* currency precision (2 = 0.12) */
|
30 |
char decimal[2]; /* decimal separator (like . or ,) */
|
28 |
unsigned char currencydecsym; /* set if the currency symbol should replace the decimal point */
|
31 |
char datesep[2]; /* date separator (usually '-', '.' or '/') */
|
29 |
unsigned char currencyspace; /* set if the currency symbol should be one space away from the value */
|
32 |
char timesep[2]; /* time separator (usually ':') */
|
30 |
unsigned char currencypos; /* 0=currency symbol precedes the value, 1=follows it */
|
33 |
unsigned char currpos:1; /* 0=currency precedes the value, 1=follows it */
|
- |
|
34 |
unsigned char currspace:1; /* set if the currency symbol should be one space away from the value */
|
31 |
char decimal; /* decimal separator (like . or ,) */
|
35 |
unsigned char currdecsym:1; /* set if the currency symbol should replace the decimal point */
|
32 |
char thousands; /* thousands separatot */
|
36 |
unsigned char ZEROED:5;
|
33 |
char datesep; /* date separator (usually '-', '.' or '/') */
|
37 |
unsigned char currprec; /* currency precision (2 = 0.12) */
|
34 |
char timesep; /* time separator (usually ':') */
|
38 |
unsigned char timefmt; /* time format */
|
- |
|
39 |
} CTYINFO;
|
- |
|
40 |
|
- |
|
41 |
struct {
|
35 |
char yes; /* the "yes" character (example: 'Y') */
|
42 |
char yes[2];
|
36 |
char no; /* the "no" character (example: 'N') */
|
43 |
char no[2];
|
- |
|
44 |
} YESNO;
|
- |
|
45 |
|
37 |
};
|
46 |
};
|
38 |
|
47 |
|
39 |
/* Loads data from a country.sys file into a country struct.
|
48 |
/* Loads data from a country.sys file into a country struct.
|
40 |
* Returns 0 on success, non-zero otherwise. */
|
49 |
* Returns 0 on success, non-zero otherwise. */
|
41 |
int country_read(struct country *countrydata, char *fname);
|
50 |
int country_read(struct country *countrydata, const char *fname);
|
42 |
|
51 |
|
43 |
/* Computes a new country.sys file based on data from a country struct.
|
52 |
/* Computes a new country.sys file based on data from a country struct.
|
44 |
* Returns 0 on success, non-zero otherwise. */
|
53 |
* Returns 0 on success, non-zero otherwise. */
|
45 |
int country_write(char *fname, struct country *countrydata);
|
54 |
int country_write(const char *fname, struct country *countrydata);
|
46 |
|
55 |
|
47 |
#endif
|
56 |
#endif
|