Subversion Repositories SvarDOS

Rev

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

Rev 1300 Rev 1373
Line 169... Line 169...
169
#endif
169
#endif
170
 
170
 
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 long hdr;
-
 
175
  unsigned short buff16[2];
174
  unsigned short buff16[2];
176
  FHANDLE fd;
175
  FHANDLE fd;
-
 
176
  struct {
-
 
177
    unsigned long sig;
177
  unsigned short string_count;
178
    unsigned short string_count;
-
 
179
  } hdr;
178
 
180
 
179
  langid = *((unsigned short *)lang);
181
  langid = *((unsigned short *)lang);
180
  langid &= 0xDFDF; /* make sure lang is upcase */
182
  langid &= 0xDFDF; /* make sure lang is upcase */
181
 
183
 
182
  fd = FOPEN(fname);
184
  fd = FOPEN(fname);
183
  if (!fd) return(-1);
185
  if (!fd) return(-1);
184
 
186
 
185
  /* read hdr, should be "SvL\x1a" */
187
  /* read hdr, sig should be "SvL\x1a" (0x1a4c7653) */
186
  if ((FREAD(fd, &hdr, 4) != 4) || (hdr != 0x1a4c7653L)) { /* 0x1a4c7653 = 'SvL\x1a' */
188
  if ((FREAD(fd, &hdr, 6) != 6) || (hdr.sig != 0x1a4c7653L) || (hdr.string_count != svarlang_string_count)) {
187
    FCLOSE(fd);
189
    FCLOSE(fd);
188
    return(-3);
190
    return(-2);
189
  }
-
 
190
 
-
 
191
  /* read string count */
-
 
192
  if ((FREAD(fd, &string_count, 2) != 2) || (string_count != svarlang_string_count)) {
-
 
193
    FCLOSE(fd);
-
 
194
    return(-6);
-
 
195
  }
191
  }
196
 
192
 
197
  /* read next lang id and string table size in file */
193
  /* read next lang id and string table size in file */
198
  while (FREAD(fd, buff16, 4) == 4) {
194
  while (FREAD(fd, buff16, 4) == 4) {
199
 
195