Subversion Repositories SvarDOS

Rev

Rev 608 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 608 Rev 611
Line 64... Line 64...
64
  if (fd == NULL) return(0); /* "file doesn't exist" is not an error condition */
64
  if (fd == NULL) return(0); /* "file doesn't exist" is not an error condition */
65
  filesize = fread(filebuff, 1, sizeof(filebuff), fd);
65
  filesize = fread(filebuff, 1, sizeof(filebuff), fd);
66
  fclose(fd);
66
  fclose(fd);
67
 
67
 
68
  /* check that it's a country file - should start with 0xFF COUNTRY 0x00 */
68
  /* check that it's a country file - should start with 0xFF COUNTRY 0x00 */
69
  if (memcmp(filebuff, "\377COUNTRY\0", 9) != 0) return(-2);
69
  if (memcmp(filebuff, "\377COUNTRY\0", 9) != 0) return(COUNTRY_ERR_INV_FORMAT);
70
 
70
 
71
  /* check that it's one of my country.sys files - should contain a trailer */
71
  /* check that it's one of my country.sys files - should contain a trailer */
72
  if (memcmp(filebuff + filesize - 8, "LOCALCFG", 8) != 0) return(-3);
72
  if (memcmp(filebuff + filesize - 8, "LOCALCFG", 8) != 0) return(COUNTRY_ERR_NOT_LOCALCFG);
73
 
73
 
74
  /* read the offset of the entries index - must be at least 23 */
74
  /* read the offset of the entries index - must be at least 23 */
75
  functiondata = filebuff + 19;
75
  functiondata = filebuff + 19;
76
  firstentryoffs = *((unsigned short *)functiondata);
76
  firstentryoffs = *((unsigned short *)functiondata);
77
  if ((firstentryoffs < 23) || (firstentryoffs >= filesize)) return(-4);
77
  if ((firstentryoffs < 23) || (firstentryoffs >= filesize)) return(-4);