Subversion Repositories SvarDOS

Rev

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

Rev 1823 Rev 1881
Line 31... Line 31...
31
#include <string.h> /* memcpy() */
31
#include <string.h> /* memcpy() */
32
 
32
 
33
#include "svarlang.lib\svarlang.h"
33
#include "svarlang.lib\svarlang.h"
34
 
34
 
35
#include "env.h"
35
#include "env.h"
-
 
36
#include "rmodinit.h"
36
 
37
 
37
#include "helpers.h"
38
#include "helpers.h"
38
 
39
 
39
 
40
 
40
 
41
 
Line 673... Line 674...
673
  /* rely on OpenWatcom's strupr() if DOS has no NLS support */
674
  /* rely on OpenWatcom's strupr() if DOS has no NLS support */
674
  if (errcode != 0) strupr(buff);
675
  if (errcode != 0) strupr(buff);
675
}
676
}
676
 
677
 
677
 
678
 
678
/* reload nls ressources from svarcom.lng into svarlang_mem */
679
/* reload nls ressources from svarcom.lng into svarlang_mem and rmod */
679
void nls_langreload(char *buff, unsigned short env) {
680
void nls_langreload(char *buff, unsigned short rmodseg) {
680
  const char far *dosdir;
681
  const char far *dosdir;
681
  const char far *lang;
682
  const char far *lang;
682
  static unsigned short lastlang;
683
  static unsigned short lastlang;
683
  unsigned short dosdirlen;
684
  unsigned short dosdirlen;
-
 
685
  unsigned short rmodenvseg = *(unsigned short far *)MK_FP(rmodseg, RMOD_OFFSET_ENVSEG);
-
 
686
  unsigned char far *rmodcritmsg = MK_FP(rmodseg, RMOD_OFFSET_CRITMSG);
-
 
687
  int i;
684
 
688
 
685
  /* look up the LANG env variable, upcase it and copy to lang */
689
  /* look up the LANG env variable, upcase it and copy to lang */
686
  lang = env_lookup_val(env, "LANG");
690
  lang = env_lookup_val(rmodenvseg, "LANG");
687
  if ((lang == NULL) || (lang[0] == 0)) return;
691
  if ((lang == NULL) || (lang[0] == 0)) return;
688
  _fmemcpy(buff, lang, 2);
692
  _fmemcpy(buff, lang, 2);
689
  buff[2] = 0;
693
  buff[2] = 0;
690
 
694
 
691
  /* check if there is need to reload at all */
695
  /* check if there is need to reload at all */
692
  if (memcmp(&lastlang, buff, 2) == 0) return;
696
  if (memcmp(&lastlang, buff, 2) == 0) return;
693
 
697
 
694
  buff[4] = 0;
698
  buff[4] = 0;
695
  dosdir = env_lookup_val(env, "DOSDIR");
699
  dosdir = env_lookup_val(rmodenvseg, "DOSDIR");
696
  if (dosdir == NULL) return;
700
  if (dosdir == NULL) return;
697
 
701
 
698
  _fstrcpy(buff + 4, dosdir);
702
  _fstrcpy(buff + 4, dosdir);
699
  dosdirlen = strlen(buff + 4);
703
  dosdirlen = strlen(buff + 4);
700
  if (buff[4 + dosdirlen - 1] == '\\') dosdirlen--;
704
  if (buff[4 + dosdirlen - 1] == '\\') dosdirlen--;
701
  memcpy(buff + 4 + dosdirlen, "\\SVARCOM.LNG", 13);
705
  memcpy(buff + 4 + dosdirlen, "\\SVARCOM.LNG", 13);
702
 
706
 
703
  /* try loading %DOSDIR%\SVARCOM.LNG */
707
  /* try loading %DOSDIR%\SVARCOM.LNG */
704
  if (svarlang_load(buff + 4, buff) != 0) {
708
  if (svarlang_load(buff + 4, buff) != 0) {
705
    /* failed! try %DOSDIR%\BIN\SVARCOM.LNG now */
709
    /* failed! try %DOSDIR%\BIN\SVARCOM.LNG */
706
    memcpy(buff + 4 + dosdirlen, "\\BIN\\SVARCOM.LNG", 17);
710
    memcpy(buff + 4 + dosdirlen, "\\BIN\\SVARCOM.LNG", 17);
707
    if (svarlang_load(buff + 4, buff) != 0) return;
711
    if (svarlang_load(buff + 4, buff) != 0) return;
708
  }
712
  }
709
 
713
 
710
  _fmemcpy(&lastlang, lang, 2);
714
  _fmemcpy(&lastlang, lang, 2);
-
 
715
 
-
 
716
  /* update RMOD's critical handler with new strings */
-
 
717
  for (i = 0; i < 7; i++) {
-
 
718
    int len;
-
 
719
    len = strlen(svarlang_str(3, i));
-
 
720
    if (len > 15) len = 15;
-
 
721
    _fmemcpy(rmodcritmsg + (i * 16), svarlang_str(3, i), len);
-
 
722
    _fmemcpy(rmodcritmsg + (i * 16) + len, "$", 1);
-
 
723
  }
-
 
724
  /* The ARIF string is special: always 4 bytes long and no $ terminator */
-
 
725
  _fmemcpy(rmodcritmsg + (7 * 16), svarlang_str(3,9), 4);
711
}
726
}
712
 
727
 
713
 
728
 
714
/* locates executable fname in path and fill res with result. returns 0 on success,
729
/* locates executable fname in path and fill res with result. returns 0 on success,
715
 * -1 on failed match and -2 on failed match + "don't even try with other paths"
730
 * -1 on failed match and -2 on failed match + "don't even try with other paths"