Subversion Repositories SvarDOS

Rev

Rev 586 | Rev 591 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 586 Rev 588
Line 1... Line 1...
1
/*
1
/*
2
 * Locales configuration for DOS
2
 * Locales configuration for SvarDOS
-
 
3
 *
3
 * Copyright (C) Mateusz Viste 2015
4
 * Copyright (C) Mateusz Viste 2015-2022
4
 *
5
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 * 1. Redistributions of source code must retain the above copyright notice,
Line 17... Line 18...
17
#include <string.h> /* strchr */
18
#include <string.h> /* strchr */
18
 
19
 
19
#include "country.h"
20
#include "country.h"
20
 
21
 
21
#define PVER "0.90"
22
#define PVER "0.90"
22
#define PDATE "2015"
23
#define PDATE "2015-2022"
23
 
24
 
24
 
25
 
25
static void about(void) {
26
static void about(void) {
26
  puts("localcfg v" PVER " - locales configuration for DOS\n"
27
  puts("localcfg v" PVER " - locales configuration for DOS\n"
27
       "Copyright (C) Mateusz Viste 2015 / http://localcfg.sourceforge.net\n"
28
       "Copyright (C) Mateusz Viste 2015 / http://localcfg.sourceforge.net\n"
Line 244... Line 245...
244
  /* if I'm here, something went wrong */
245
  /* if I'm here, something went wrong */
245
  return(-4);
246
  return(-4);
246
}
247
}
247
 
248
 
248
 
249
 
-
 
250
/* converts a path to its canonic representation, returns 0 on success
-
 
251
 * or DOS err on failure (invalid drive) */
-
 
252
static unsigned short file_truename(const char *dst, char *src) {
-
 
253
  unsigned short res = 0;
-
 
254
  _asm {
-
 
255
    push es
-
 
256
    mov ah, 0x60  /* query truename, DS:SI=src, ES:DI=dst */
-
 
257
    push ds
-
 
258
    pop es
-
 
259
    mov si, src
-
 
260
    mov di, dst
-
 
261
    int 0x21
-
 
262
    jnc DONE
-
 
263
    mov [res], ax
-
 
264
    DONE:
-
 
265
    pop es
-
 
266
  }
-
 
267
  return(res);
-
 
268
}
-
 
269
 
-
 
270
 
249
int main(int argc, char **argv) {
271
int main(int argc, char **argv) {
250
  struct country cntdata;
272
  struct country cntdata;
251
  int changedflag;
273
  int changedflag;
252
  int x;
274
  int x;
253
  char *fname;
275
  static char fname[130];
254
 
276
 
255
  if ((argc < 2) || (argv[1][0] == '/')) {
277
  if ((argc < 2) || (argv[1][0] == '/')) {
256
    about();
278
    about();
257
    return(1);
279
    return(1);
258
  }
280
  }
259
 
281
 
-
 
282
  if (file_truename(fname, argv[1]) != 0) {
-
 
283
    puts("ERROR: bad file path");
260
  fname = argv[1];
284
    return(1);
-
 
285
  }
261
 
286
 
262
  x = country_read(&cntdata, fname);
287
  x = country_read(&cntdata, fname);
263
  if (x != 0) {
288
  if (x != 0) {
264
    printf("ERROR: failed to read the preference file [%d]\n", x);
289
    printf("ERROR: failed to read the preference file [%d]\n", x);
265
    return(2);
290
    return(2);
Line 283... Line 308...
283
  printf("Time format...........: %s\n", timestring(&cntdata));
308
  printf("Time format...........: %s\n", timestring(&cntdata));
284
  printf("Yes/No letters........: %c/%c\n", cntdata.yes, cntdata.no);
309
  printf("Yes/No letters........: %c/%c\n", cntdata.yes, cntdata.no);
285
  printf("Currency example......: %s\n", currencystring(&cntdata));
310
  printf("Currency example......: %s\n", currencystring(&cntdata));
286
 
311
 
287
  printf("\n"
312
  printf("\n"
288
         "Note: Please make sure your CONFIG.SYS contains a COUNTRY directive pointing\n"
313
         "Please make sure your CONFIG.SYS contains a COUNTRY directive that points to\n"
289
         "      to your custom preferences file. Example:\n"
314
         "your custom preferences file:\n"
290
         "      COUNTRY=%03d,,C:\\MYPREFS.SYS\n\n", cntdata.id);
315
         "COUNTRY=%03d,%03d,%s\n\n", cntdata.id, cntdata.codepage, fname);
291
 
316
 
292
  /* if anything changed, write the new file */
317
  /* if anything changed, write the new file */
293
  if (changedflag != 0) country_write(fname, &cntdata);
318
  if (changedflag != 0) country_write(fname, &cntdata);
294
 
319
 
295
  return(0);
320
  return(0);