Преглед на файлове

Add gis.h version check

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31628 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements преди 17 години
родител
ревизия
43013732ce
променени са 3 файла, в които са добавени 14 реда и са изтрити 4 реда
  1. 3 0
      include/gis.h
  2. 2 2
      include/gisdefs.h
  3. 9 2
      lib/gis/gisinit.c

+ 3 - 0
include/gis.h

@@ -42,6 +42,9 @@ static const char *GRASS_copyright __attribute__((unused))
 
 #define GIS_H_VERSION "$Revision$"
 
+#define G_gisinit(pgm) G__gisinit(GIS_H_VERSION, (pgm))
+#define G_no_gisinit() G__no_gisinit(GIS_H_VERSION)
+
 /* Define TRUE and FALSE for boolean comparisons */
 #ifndef TRUE
 #define TRUE 1

+ 2 - 2
include/gisdefs.h

@@ -588,8 +588,8 @@ char *G_gisdbase(void);
 int G_gishelp(const char *, const char *);
 
 /* gisinit.c */
-int G_gisinit(const char *);
-int G_no_gisinit(void);
+int G__gisinit(const char *, const char *);
+int G__no_gisinit(const char *);
 int G__check_gisinit(void);
 
 /* histo_eq.c */

+ 9 - 2
lib/gis/gisinit.c

@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <grass/gis.h>
 #include "G.h"
@@ -36,7 +37,7 @@ static int gisinit(void);
  * \return exit() is called on error
  */
 
-int G_gisinit(const char *pgm)
+int G__gisinit(const char *version, const char *pgm)
 {
     char *mapset;
 
@@ -45,6 +46,9 @@ int G_gisinit(const char *pgm)
 
     G_set_program_name (pgm);
 
+    if (strcmp(version, GIS_H_VERSION) != 0)
+        G_fatal_error(_("Incompatible library version for module"));
+
    /* Make sure location and mapset are set */
     G_location_path();
     switch (G__mapset_permissions (mapset = G_mapset()))
@@ -75,11 +79,14 @@ int G_gisinit(const char *pgm)
  * \return always returns 0 on success
  */
 
-int G_no_gisinit(void)
+int G__no_gisinit(const char *version)
 {
     if ( initialized )
 	return 0;
 
+    if (strcmp(version, GIS_H_VERSION) != 0)
+        G_fatal_error(_("Incompatible library version for module"));
+
     gisinit();
 
     return 0;