Diff for /freem/src/global_bltin.c between versions 1.11 and 1.12

version 1.11, 2025/04/08 21:41:13 version 1.12, 2025/04/09 00:43:07
Line 24 Line 24
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.   *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *   *
  *   $Log$   *   $Log$
    *   Revision 1.12  2025/04/09 00:43:07  snw
    *   Exit with fatal error if a header mismatch found
    *
  *   Revision 1.11  2025/04/08 21:41:13  snw   *   Revision 1.11  2025/04/08 21:41:13  snw
  *   Make insert, update, and splitp global handler functions take a ptr to a global_handle instead of a file descriptor   *   Make insert, update, and splitp global handler functions take a ptr to a global_handle instead of a file descriptor
  *   *
Line 294  int gbl_write_header(global_handle *g, g Line 297  int gbl_write_header(global_handle *g, g
     if (g->opened == FALSE) {      if (g->opened == FALSE) {
         return FALSE;          return FALSE;
     }      }
       
     gbl_lock (g, 1);      gbl_lock (g, 1);
     old_position = lseek (g->fd, 0, SEEK_CUR);      old_position = lseek (g->fd, 0, SEEK_CUR);
     lseek (g->fd, 0, SEEK_SET);      lseek (g->fd, 0, SEEK_SET);
Line 306  int gbl_write_header(global_handle *g, g Line 309  int gbl_write_header(global_handle *g, g
   
     lseek (g->fd, old_position, SEEK_SET);      lseek (g->fd, old_position, SEEK_SET);
     gbl_unlock (g);      gbl_unlock (g);
   
       gbl_read_header (g, &g->header);
           
     return TRUE;          return TRUE;    
 } /* gbl_write_header() */  } /* gbl_write_header() */
Line 383  int gbl_create(global_handle *g) Line 388  int gbl_create(global_handle *g)
 short gbl_open(global_handle *g, short action)  short gbl_open(global_handle *g, short action)
 {  {
     int result;      int result;
     global_header h;  
           
     if (g->opened == FALSE) {      if (g->opened == FALSE) {
         while (1) {          while (1) {
Line 414  short gbl_open(global_handle *g, short a Line 418  short gbl_open(global_handle *g, short a
         }          }
         else {          else {
             g->opened = TRUE;              g->opened = TRUE;
             result = gbl_read_header (g, &h);              result = gbl_read_header (g, &g->header);
               
             if (result == GBL_HDR_OK) {              if (result == GBL_HDR_OK) {
                 g->opened = TRUE;                  g->opened = TRUE;
             }              }
             else {              else {                
                 gbl_close (g);                                  gbl_close (g);
                   set_io (UNIX);
                   
                   switch (result) {
                       
                       case GBL_HDR_BADMAGIC:
                           fprintf (stderr, "gbl_open:  bad magic value in %s [FATAL]\n", g->global_name);
                           exit (1);
                           break;
   
                       case GBL_HDR_BADVERSION:
                           fprintf (stderr, "gbl_open:  global version is %d in %s (must be %d) [FATAL]\n", g->header.format_version, g->global_name, GBL_FORMAT_VERSION);
                           exit (1);
                           break;
   
                   }
                           
                 return FALSE;                  return FALSE;
             }              }
         }          }

Removed from v.1.11  
changed lines
  Added in v.1.12


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>