Subversion Repositories SvarDOS

Rev

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

Rev 1375 Rev 1376
Line 171... Line 171...
171
 
171
 
172
int svarlang_load(const char *fname, const char *lang) {
172
int svarlang_load(const char *fname, const char *lang) {
173
  unsigned short langid;
173
  unsigned short langid;
174
  unsigned short buff16[2];
174
  unsigned short buff16[2];
175
  FHANDLE fd;
175
  FHANDLE fd;
-
 
176
  signed char exitcode = 0;
176
  struct {
177
  struct {
177
    unsigned long sig;
178
    unsigned long sig;
178
    unsigned short string_count;
179
    unsigned short string_count;
179
  } hdr;
180
  } hdr;
180
 
181
 
Line 184... Line 185...
184
  fd = FOPEN(fname);
185
  fd = FOPEN(fname);
185
  if (!fd) return(-1);
186
  if (!fd) return(-1);
186
 
187
 
187
  /* read hdr, sig should be "SvL\x1a" (0x1a4c7653) */
188
  /* read hdr, sig should be "SvL\x1a" (0x1a4c7653) */
188
  if ((FREAD(fd, &hdr, 6) != 6) || (hdr.sig != 0x1a4c7653L) || (hdr.string_count != svarlang_string_count)) {
189
  if ((FREAD(fd, &hdr, 6) != 6) || (hdr.sig != 0x1a4c7653L) || (hdr.string_count != svarlang_string_count)) {
189
    FCLOSE(fd);
190
    exitcode = -2;
190
    return(-2);
191
    goto FCLOSE_AND_EXIT;
191
  }
192
  }
192
 
193
 
193
  for (;;) {
194
  for (;;) {
194
    /* read next lang id and string table size in file */
195
    /* read next lang id and string table size in file */
195
    if (FREAD(fd, buff16, 4) != 4) {
196
    if (FREAD(fd, buff16, 4) != 4) {
196
      FCLOSE(fd);
197
      exitcode = -3;
197
      return(-3);
198
      goto FCLOSE_AND_EXIT;
198
    }
199
    }
199
 
200
 
200
    /* is it the lang I am looking for? */
201
    /* is it the lang I am looking for? */
201
    if (buff16[0] == langid) break;
202
    if (buff16[0] == langid) break;
202
 
203
 
Line 207... Line 208...
207
 
208
 
208
  /* load dictionary & strings, but only if I have enough memory space */
209
  /* load dictionary & strings, but only if I have enough memory space */
209
  if ((buff16[1] >= svarlang_memsz)
210
  if ((buff16[1] >= svarlang_memsz)
210
   || (FREAD(fd, svarlang_dict, svarlang_string_count * 4) != svarlang_string_count * 4)
211
   || (FREAD(fd, svarlang_dict, svarlang_string_count * 4) != svarlang_string_count * 4)
211
   || (FREAD(fd, svarlang_mem, buff16[1]) != buff16[1])) {
212
   || (FREAD(fd, svarlang_mem, buff16[1]) != buff16[1])) {
212
    FCLOSE(fd);
-
 
213
    return(-4);
213
    exitcode = -4;
214
  }
214
  }
215
 
215
 
-
 
216
  FCLOSE_AND_EXIT:
-
 
217
 
216
  FCLOSE(fd);
218
  FCLOSE(fd);
217
  return(0);
219
  return(exitcode);
218
}
220
}