Subversion Repositories SvarDOS

Rev

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

Rev 1251 Rev 1277
Line 133... Line 133...
133
    pop bx
133
    pop bx
134
  }
134
  }
135
}
135
}
136
 
136
 
137
 
137
 
138
int svarlang_load(const char *progname, const char *lang, const char *nlspath) {
138
int svarlang_load(const char *fname, const char *lang) {
139
  unsigned short langid;
139
  unsigned short langid;
140
  unsigned short fd;
140
  unsigned short fd;
141
  char buff[128];
141
  char hdr[4];
142
  unsigned short buff16[2];
142
  unsigned short buff16[2];
143
  unsigned short i;
-
 
144
 
-
 
145
  if (lang == NULL) return(-1);
-
 
146
  if (nlspath == NULL) nlspath = ""; /* nlspath can be NULL, treat is as empty */
-
 
147
 
143
 
148
  langid = *((unsigned short *)lang);
144
  langid = *((unsigned short *)lang);
149
  langid &= 0xDFDF; /* make sure lang is upcase */
145
  langid &= 0xDFDF; /* make sure lang is upcase */
150
 
146
 
151
  TRYNEXTPATH:
-
 
152
 
-
 
153
  /* skip any leading ';' separators */
-
 
154
  while (*nlspath == ';') nlspath++;
-
 
155
 
-
 
156
  /* copy nlspath to buff and remember len */
-
 
157
  for (i = 0; (nlspath[i] != 0) && (nlspath[i] != ';'); i++) buff[i] = nlspath[i];
-
 
158
  nlspath += i;
-
 
159
 
-
 
160
  /* add a trailing backslash if there is none (non-empty paths empty) */
-
 
161
  if ((i > 0) && (buff[i - 1] != '\\')) buff[i++] = '\\';
-
 
162
 
-
 
163
  strcpy(buff + i, progname);
-
 
164
  strcat(buff + i, ".lng");
-
 
165
 
-
 
166
  fd = FOPEN(buff);
147
  fd = FOPEN(fname);
167
  if (fd == 0xffff) { /* failed to open file - either abort or try next path */
-
 
168
    if (*nlspath == 0) return(-2);
148
  if (fd == 0xffff) return(-1);
169
    goto TRYNEXTPATH;
-
 
170
  }
-
 
171
 
149
 
172
  /* read hdr, should be "SvL\33" */
150
  /* read hdr, should be "SvL\33" */
173
  if ((FREAD(fd, buff, 4) != 4) || (memcmp(buff, "SvL\33", 4) != 0)) {
151
  if ((FREAD(fd, hdr, 4) != 4) || (memcmp(hdr, "SvL\33", 4) != 0)) {
174
    FCLOSE(fd);
152
    FCLOSE(fd);
175
    return(-3);
153
    return(-3);
176
  }
154
  }
177
 
155
 
178
  /* read next lang id in file */
156
  /* read next lang id in file */