Subversion Repositories SvarDOS

Rev

Rev 591 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 591 Rev 611
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-2022
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
 
9
enum COUNTRY_DATEFMT {
9
enum COUNTRY_DATEFMT {
10
  COUNTRY_DATE_MDY = 0, /* Month, Day, Year */
10
  COUNTRY_DATE_MDY = 0, /* Month, Day, Year */
11
  COUNTRY_DATE_DMY = 1, /* Day, Month, Year */
11
  COUNTRY_DATE_DMY = 1, /* Day, Month, Year */
12
  COUNTRY_DATE_YMD = 2  /* Year, Month, Day */
12
  COUNTRY_DATE_YMD = 2  /* Year, Month, Day */
13
};
13
};
14
 
14
 
15
enum COUNTRY_TIMEFMT {
15
enum COUNTRY_TIMEFMT {
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
#define COUNTRY_ERR_INV_FORMAT -86
-
 
21
#define COUNTRY_ERR_NOT_LOCALCFG -87
21
 
22
 
22
struct country {
23
struct country {
23
 
24
 
24
  struct {
25
  struct {
25
    unsigned short id;          /* international id (48=PL, 33=FR, 01=US...) */
26
    unsigned short id;          /* international id (48=PL, 33=FR, 01=US...) */
26
    unsigned short codepage;    /* usual codepage */
27
    unsigned short codepage;    /* usual codepage */
27
    unsigned short datefmt;     /* date format */
28
    unsigned short datefmt;     /* date format */
28
    char currsym[5];            /* currency symbol */
29
    char currsym[5];            /* currency symbol */
29
    char thousands[2];          /* thousands separator */
30
    char thousands[2];          /* thousands separator */
30
    char decimal[2];            /* decimal separator (like . or ,) */
31
    char decimal[2];            /* decimal separator (like . or ,) */
31
    char datesep[2];            /* date separator (usually '-', '.' or '/') */
32
    char datesep[2];            /* date separator (usually '-', '.' or '/') */
32
    char timesep[2];            /* time separator (usually ':') */
33
    char timesep[2];            /* time separator (usually ':') */
33
    unsigned char currpos:1;    /* 0=currency precedes the value, 1=follows it */
34
    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 */
35
    unsigned char currspace:1;  /* set if the currency symbol should be one space away from the value */
35
    unsigned char currdecsym:1; /* set if the currency symbol should replace the decimal point */
36
    unsigned char currdecsym:1; /* set if the currency symbol should replace the decimal point */
36
    unsigned char ZEROED:5;
37
    unsigned char ZEROED:5;
37
    unsigned char currprec;     /* currency precision (2 = 0.12) */
38
    unsigned char currprec;     /* currency precision (2 = 0.12) */
38
    unsigned char timefmt;      /* time format */
39
    unsigned char timefmt;      /* time format */
39
  } CTYINFO;
40
  } CTYINFO;
40
 
41
 
41
  struct {
42
  struct {
42
    char yes[2];
43
    char yes[2];
43
    char no[2];
44
    char no[2];
44
  } YESNO;
45
  } YESNO;
45
 
46
 
46
};
47
};
47
 
48
 
48
/* Loads data from a country.sys file into a country struct.
49
/* Loads data from a country.sys file into a country struct.
49
 * Returns 0 on success, non-zero otherwise. */
50
 * Returns 0 on success, non-zero otherwise. */
50
int country_read(struct country *countrydata, const char *fname);
51
int country_read(struct country *countrydata, const char *fname);
51
 
52
 
52
/* Computes a new country.sys file based on data from a country struct.
53
/* Computes a new country.sys file based on data from a country struct.
53
 * Returns 0 on success, non-zero otherwise. */
54
 * Returns 0 on success, non-zero otherwise. */
54
int country_write(const char *fname, struct country *countrydata);
55
int country_write(const char *fname, struct country *countrydata);
55
 
56
 
56
#endif
57
#endif
57
 
58