Subversion Repositories SvarDOS

Rev

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

Rev 623 Rev 814
Line 50... Line 50...
50
  FILE *fd;
50
  FILE *fd;
51
  char buff[128];
51
  char buff[128];
52
  unsigned short buff16[2];
52
  unsigned short buff16[2];
53
  unsigned short i;
53
  unsigned short i;
54
 
54
 
55
  if ((lang == NULL) || (nlspath == NULL)) return(-1);
55
  if (lang == NULL) return(-1);
-
 
56
  if (nlspath == NULL) nlspath = ""; /* nlspath can be NULL, treat is as empty */
56
 
57
 
57
  langid = *((unsigned short *)lang);
58
  langid = *((unsigned short *)lang);
58
  langid &= 0xDFDF; /* make sure lang is upcase */
59
  langid &= 0xDFDF; /* make sure lang is upcase */
59
 
60
 
-
 
61
  TRYNEXTPATH:
-
 
62
 
-
 
63
  /* skip any leading ';' separators */
-
 
64
  while (*nlspath == ';') nlspath++;
-
 
65
 
60
  /* copy nlspath to buff and remember len */
66
  /* copy nlspath to buff and remember len */
61
  for (i = 0; nlspath[i] != 0; i++) buff[i] = nlspath[i];
67
  for (i = 0; (nlspath[i] != 0) && (nlspath[i] != ';'); i++) buff[i] = nlspath[i];
-
 
68
  nlspath += i;
62
 
69
 
63
  /* */
70
  /* ignore the trailing backslash (I add one myself) */
64
  if ((i > 0) && (buff[i - 1] == '\\')) i--;
71
  if ((i > 0) && (buff[i - 1] == '\\')) i--;
65
 
72
 
66
  buff[i++] = '\\';
73
  buff[i++] = '\\';
67
  strcpy(buff + i, progname);
74
  strcpy(buff + i, progname);
68
  strcat(buff + i, ".lng");
75
  strcat(buff + i, ".lng");
69
 
76
 
70
  fd = fopen(buff, "rb");
77
  fd = fopen(buff, "rb");
-
 
78
  if (fd == NULL) { /* failed to open file - either abort or try next path */
71
  if (fd == NULL) return(-2);
79
    if (*nlspath == 0) return(-2);
-
 
80
    goto TRYNEXTPATH;
-
 
81
  }
72
 
82
 
73
  /* read hdr, should be "SvL\33" */
83
  /* read hdr, should be "SvL\33" */
74
  if ((fread(buff, 1, 4, fd) != 4) || (memcmp(buff, "SvL\33", 4) != 0)) {
84
  if ((fread(buff, 1, 4, fd) != 4) || (memcmp(buff, "SvL\33", 4) != 0)) {
75
    fclose(fd);
85
    fclose(fd);
76
    return(-3);
86
    return(-3);