Subversion Repositories SvarDOS

Rev

Details | Last modification | View Log | RSS feed

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