Subversion Repositories SvarDOS

Rev

Rev 1137 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1137 Rev 1629
Line 1... Line 1...
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021-2022 Mateusz Viste
4
 * Copyright (C) 2021-2024 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Line 646... Line 646...
646
}
646
}
647
 
647
 
648
 
648
 
649
/* reload nls ressources from svarcom.lng into svarlang_mem */
649
/* reload nls ressources from svarcom.lng into svarlang_mem */
650
void nls_langreload(char *buff, unsigned short env) {
650
void nls_langreload(char *buff, unsigned short env) {
651
  const char far *nlspath;
651
  const char far *dosdir;
652
  const char far *lang;
652
  const char far *lang;
653
  static unsigned short lastlang;
653
  static unsigned short lastlang;
-
 
654
  unsigned short dosdirlen;
654
 
655
 
655
  /* look up the LANG env variable, upcase it and copy to lang */
656
  /* look up the LANG env variable, upcase it and copy to lang */
656
  lang = env_lookup_val(env, "LANG");
657
  lang = env_lookup_val(env, "LANG");
657
  if ((lang == NULL) || (lang[0] == 0)) return;
658
  if ((lang == NULL) || (lang[0] == 0)) return;
658
  _fmemcpy(buff, lang, 2);
659
  _fmemcpy(buff, lang, 2);
Line 660... Line 661...
660
 
661
 
661
  /* check if there is need to reload at all */
662
  /* check if there is need to reload at all */
662
  if (memcmp(&lastlang, buff, 2) == 0) return;
663
  if (memcmp(&lastlang, buff, 2) == 0) return;
663
 
664
 
664
  buff[4] = 0;
665
  buff[4] = 0;
665
  nlspath = env_lookup_val(env, "NLSPATH");
666
  dosdir = env_lookup_val(env, "DOSDIR");
666
  if (nlspath != NULL) _fstrcpy(buff + 4, nlspath);
667
  if (dosdir == NULL) return;
667
 
668
 
-
 
669
  _fstrcpy(buff + 4, dosdir);
-
 
670
  dosdirlen = strlen(buff + 4);
-
 
671
  if (buff[4 + dosdirlen - 1] == '\\') dosdirlen--;
-
 
672
  memcpy(buff + 4 + dosdirlen, "\\SVARCOM.LNG", 13);
-
 
673
 
-
 
674
  /* try loading %DOSDIR%\SVARCOM.LNG */
-
 
675
  if (svarlang_load(buff + 4, buff) != 0) {
-
 
676
    /* failed! try %DOSDIR%\BIN\SVARCOM.LNG now */
-
 
677
    memcpy(buff + 4 + dosdirlen, "\\BIN\\SVARCOM.LNG", 17);
668
  if (svarlang_load("SVARCOM", buff, buff + 4) != 0) return;
678
    if (svarlang_load(buff + 4, buff) != 0) return;
-
 
679
  }
669
 
680
 
670
  _fmemcpy(&lastlang, lang, 2);
681
  _fmemcpy(&lastlang, lang, 2);
671
}
682
}
672
 
683
 
673
 
684