/[svn]/ircd-hybrid/trunk/src/conf_db.c
ViewVC logotype

Diff of /ircd-hybrid/trunk/src/conf_db.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1620 by michael, Wed Oct 31 22:54:58 2012 UTC revision 1621 by michael, Wed Oct 31 23:11:40 2012 UTC
# Line 41  Line 41 
41   * \param f dbFile Struct Member   * \param f dbFile Struct Member
42   * \return int 0 if failure, 1 > is the version number   * \return int 0 if failure, 1 > is the version number
43   */   */
44  int  uint32_t
45  get_file_version(struct dbFILE *f)  get_file_version(struct dbFILE *f)
46  {  {
47    FILE *fp = f->fp;    uint32_t version = 0;
   int version = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp);  
48    
49    if (ferror(fp))    if (read_uint32(&version, f) == -1)
50    {    {
51      ilog(LOG_TYPE_IRCD, "Error reading version number on %s", f->filename);      ilog(LOG_TYPE_IRCD, "Error reading version number on %s: %s",
52             f->filename, strerror(errno));
53      return 0;      return 0;
54    }    }
55    else if (feof(fp))  
56    {    if (version < 1)
     ilog(LOG_TYPE_IRCD, "Error reading version number on %s: End of file detected",  
          f->filename);  
     return 0;  
   }  
   else if (version < 1)  
57    {    {
58      ilog(LOG_TYPE_IRCD, "Invalid version number (%d) on %s",      ilog(LOG_TYPE_IRCD, "Invalid version number (%u) on %s",
59           version, f->filename);           version, f->filename);
60      return 0;      return 0;
61    }    }

Legend:
Removed from v.1620  
changed lines
  Added in v.1621

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28