Procházet zdrojové kódy

Elminate FILE* <-> struct Map_info* hack from sites library
Use "const" where appropriate in sites library
Disable raster/simwe as it's too badly broken


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31995 15284696-431f-4ddb-bdfa-cd5b030d7da7

Glynn Clements před 17 roky
rodič
revize
a9b2c30b3e

+ 17 - 15
include/P_site.h

@@ -2,6 +2,8 @@
 #ifndef GRASS_P_SITE_H
 #ifndef GRASS_P_SITE_H
 #define GRASS_P_SITE_H
 #define GRASS_P_SITE_H
 
 
+struct Map_info;
+
 /* The same for old and new, format independent */
 /* The same for old and new, format independent */
 Site *G_site_new_struct (RASTER_MAP_TYPE cattype, int ndim, int ns, int nd);
 Site *G_site_new_struct (RASTER_MAP_TYPE cattype, int ndim, int ns, int nd);
 void G_site_free_struct (Site *s);
 void G_site_free_struct (Site *s);
@@ -10,8 +12,8 @@ int G_site_d_cmp (const void *a, const void *b);
 int G_site_c_cmp (const void *a, const void *b);
 int G_site_c_cmp (const void *a, const void *b);
 int G_site_s_cmp (const void *a, const void *b);
 int G_site_s_cmp (const void *a, const void *b);
 char *G_site_format (const Site *s, const char *fs, int id);
 char *G_site_format (const Site *s, const char *fs, int id);
-/* SITE_ATT * G_sites_get_atts (FILE * ptr, int* cat);*/
-int G_sites_get_fields (FILE * ptr, char*** cnames, int** ctypes, int** ndx);
+/* SITE_ATT * G_sites_get_atts (struct Map_info * ptr, int* cat);*/
+int G_sites_get_fields (struct Map_info * ptr, char*** cnames, int** ctypes, int** ndx);
 void G_sites_free_fields (int ncols, char** cnames, int* ctypes, int* ndx);
 void G_sites_free_fields (int ncols, char** cnames, int* ctypes, int* ndx);
 
 
 /* Old version used by v.in.sites */
 /* Old version used by v.in.sites */
@@ -21,25 +23,25 @@ int G_oldsite_get (FILE *p, Site *s);
 int G__oldsite_get ( FILE *, Site *, int);
 int G__oldsite_get ( FILE *, Site *, int);
 
 
 /* New version based on vectors used in old, not updated sites modules */
 /* New version based on vectors used in old, not updated sites modules */
-int G_site_get (FILE *p, Site *s);
-int G_site_put (FILE *p, const Site *s);
-int G_site_describe (FILE *p, int *dims, int *cat, int *strs, int *dbls);
-int G_site_get_head (FILE *p, Site_head *head);
-int G_site_put_head (FILE *p, Site_head *head);
-FILE * G_sites_open_old (char *name, char *mapset);
-FILE * G_sites_open_new (char *name);
-void G_sites_close ( FILE * );
+int G_site_get (struct Map_info *p, Site *s);
+int G_site_put (struct Map_info *p, const Site *s);
+int G_site_describe (struct Map_info *p, int *dims, int *cat, int *strs, int *dbls);
+int G_site_get_head (struct Map_info *p, Site_head *head);
+int G_site_put_head (struct Map_info *p, Site_head *head);
+struct Map_info * G_sites_open_old (const char *name, const char *mapset);
+struct Map_info * G_sites_open_new (const char *name);
+void G_sites_close ( struct Map_info * );
 char * G_find_sites (char *name, const char *mapset);
 char * G_find_sites (char *name, const char *mapset);
 char * G_find_sites2 (const char *name, const char *mapset);
 char * G_find_sites2 (const char *name, const char *mapset);
 char * G_ask_sites_new (const char *prompt, char *name);
 char * G_ask_sites_new (const char *prompt, char *name);
 char * G_ask_sites_old (const char *prompt, char *name);
 char * G_ask_sites_old (const char *prompt, char *name);
 char * G_ask_sites_any (const char *prompt, char *name);
 char * G_ask_sites_any (const char *prompt, char *name);
 char * G_ask_sites_in_mapset (const char *prompt, char *name);
 char * G_ask_sites_in_mapset (const char *prompt, char *name);
-int G__site_put ( FILE *, Site *, int);
+int G__site_put ( struct Map_info *, Site *, int);
 
 
-FILE *G_fopen_sites_old(char *, char *);
-FILE *G_fopen_sites_new(char *);
-int G_get_site(FILE *, double *, double *, char **);
-int G_put_site(FILE *, double, double, const char *);
+struct Map_info *G_fopen_sites_old(const char *, const char *);
+struct Map_info *G_fopen_sites_new(const char *);
+int G_get_site(struct Map_info *, double *, double *, char **);
+int G_put_site(struct Map_info *, double, double, const char *);
 
 
 #endif
 #endif

+ 19 - 48
lib/sites/sites.c

@@ -48,16 +48,13 @@ static int site_att_cmp ( const void *pa, const void *pb) {
  *                      -2 on other fatal error or insufficient data,
  *                      -2 on other fatal error or insufficient data,
  *                       1 on format mismatch (extra data)
  *                       1 on format mismatch (extra data)
  */
  */
-int G_site_get ( FILE *fptr, Site *s)
+int G_site_get (struct Map_info *Map, Site *s)
 {
 {
     int    i, type, cat;
     int    i, type, cat;
-    struct Map_info *Map;
     static struct line_pnts *Points = NULL;
     static struct line_pnts *Points = NULL;
     static struct line_cats *Cats = NULL;
     static struct line_cats *Cats = NULL;
     SITE_ATT *sa;
     SITE_ATT *sa;
 
 
-    Map = (struct Map_info *) fptr;
-
     if ( Points == NULL ) Points = Vect_new_line_struct ();
     if ( Points == NULL ) Points = Vect_new_line_struct ();
     if ( Cats == NULL ) Cats = Vect_new_cats_struct ();
     if ( Cats == NULL ) Cats = Vect_new_cats_struct ();
 
 
@@ -101,14 +98,11 @@ int G_site_get ( FILE *fptr, Site *s)
 
 
 
 
 /* Writes a site to file open on fptr. */
 /* Writes a site to file open on fptr. */
-int G_site_put ( FILE *fptr, const Site *s)
+int G_site_put (struct Map_info *Map, const Site *s)
 {
 {
-    struct Map_info *Map;
     static struct line_pnts *Points = NULL;
     static struct line_pnts *Points = NULL;
     static struct line_cats *Cats = NULL;
     static struct line_cats *Cats = NULL;
 
 
-    Map = (struct Map_info *) fptr;
-
     if ( Points == NULL ) Points = Vect_new_line_struct ();
     if ( Points == NULL ) Points = Vect_new_line_struct ();
     if ( Cats == NULL ) Cats = Vect_new_cats_struct ();
     if ( Cats == NULL ) Cats = Vect_new_cats_struct ();
 
 
@@ -140,13 +134,8 @@ int G_site_put ( FILE *fptr, const Site *s)
  *                      -1 on EOF,
  *                      -1 on EOF,
  *                      -2 for other error.
  *                      -2 for other error.
  */
  */
-int G_site_describe ( FILE *ptr,
-  int *dims,int *cat,int *strs,int *dbls)
+int G_site_describe (struct Map_info *Map, int *dims,int *cat,int *strs,int *dbls)
 {
 {
-    struct Map_info *Map;
-
-    Map = (struct Map_info *) ptr;
-    
     if ( Vect_is_3d(Map) ) {
     if ( Vect_is_3d(Map) ) {
 	G_debug (1, "Vector is 3D -> number of site dimensions is 3");
 	G_debug (1, "Vector is 3D -> number of site dimensions is 3");
 	*dims = 3;
 	*dims = 3;
@@ -168,13 +157,10 @@ int G_site_describe ( FILE *ptr,
 /*-
 /*-
  * Writes site_head struct.
  * Writes site_head struct.
  */
  */
-int G_site_put_head ( FILE *ptr, Site_head *head)
+int G_site_put_head ( struct Map_info *Map, Site_head *head)
 {
 {
-    struct Map_info *Map;
     static char buf[128];
     static char buf[128];
 
 
-    Map = (struct Map_info *) ptr;
-
     if (head->name!=NULL)
     if (head->name!=NULL)
 	Vect_set_map_name (Map, head->name);
 	Vect_set_map_name (Map, head->name);
       
       
@@ -217,12 +203,8 @@ int G_site_put_head ( FILE *ptr, Site_head *head)
 /*-
 /*-
  * Fills in site_head struct.
  * Fills in site_head struct.
  */
  */
-int G_site_get_head (FILE *ptr, Site_head *head)
+int G_site_get_head (struct Map_info *Map, Site_head *head)
 {
 {
-    struct Map_info *Map;
-
-    Map = (struct Map_info *) ptr;
-
     head->name = Vect_get_name(Map);
     head->name = Vect_get_name(Map);
     head->desc = Vect_get_comment(Map);
     head->desc = Vect_get_comment(Map);
     head->form = NULL;
     head->form = NULL;
@@ -275,11 +257,11 @@ int G_site_get_head (FILE *ptr, Site_head *head)
  *      rejects all names that begin with .
  *      rejects all names that begin with .
  **********************************************************************
  **********************************************************************
  *
  *
- *  FILE *
+ *  struct Map_info *
  *  G_sites_open_old (name, mapset)
  *  G_sites_open_old (name, mapset)
  *      opens the existing site list file 'name' in the 'mapset'
  *      opens the existing site list file 'name' in the 'mapset'
  *
  *
- *  FILE *
+ *  struct Map_info *
  *  G_sites_open_new (name)
  *  G_sites_open_new (name)
  *      opens a new site list file 'name' in the current mapset
  *      opens a new site list file 'name' in the current mapset
  *
  *
@@ -325,7 +307,7 @@ char * G_ask_sites_in_mapset (const char *prompt, char *name)
 }
 }
 
 
 
 
-FILE * G_sites_open_old (char *name,char *mapset)
+struct Map_info * G_sites_open_old (const char *name, const char *mapset)
 {
 {
     struct Map_info *Map;
     struct Map_info *Map;
     struct field_info *fi;
     struct field_info *fi;
@@ -357,7 +339,7 @@ FILE * G_sites_open_old (char *name,char *mapset)
     fi = Vect_get_field(Map, 1);
     fi = Vect_get_field(Map, 1);
     if ( fi == NULL ) {  /* not attribute table */ 
     if ( fi == NULL ) {  /* not attribute table */ 
 	G_debug ( 1, "No attribute table" );
 	G_debug ( 1, "No attribute table" );
-	return (FILE *) Map;
+	return Map;
     }
     }
     
     
     driver = db_start_driver_open_database ( fi->driver, fi->database );
     driver = db_start_driver_open_database ( fi->driver, fi->database );
@@ -453,11 +435,11 @@ FILE * G_sites_open_old (char *name,char *mapset)
     /* sort attributes */
     /* sort attributes */
     qsort ( (void *)Map->site_att, Map->n_site_att, sizeof(SITE_ATT), site_att_cmp );
     qsort ( (void *)Map->site_att, Map->n_site_att, sizeof(SITE_ATT), site_att_cmp );
     
     
-    return (FILE *) Map;
+    return Map;
 }
 }
 
 
 
 
-FILE * G_sites_open_new (char *name)
+struct Map_info *G_sites_open_new (const char *name)
 {
 {
     struct Map_info *Map;
     struct Map_info *Map;
     
     
@@ -470,16 +452,13 @@ FILE * G_sites_open_new (char *name)
 
 
     G_debug ( 1, "New vector map opened");
     G_debug ( 1, "New vector map opened");
 
 
-    return (FILE *) Map;
+    return Map;
 }
 }
 
 
 
 
-void G_sites_close ( FILE * ptr)
+void G_sites_close (struct Map_info *Map)
 {
 {
     int i, j;
     int i, j;
-    struct Map_info *Map;
-
-    Map = (struct Map_info *) ptr;
 
 
     if (Map->mode == GV_MODE_WRITE || Map->mode == GV_MODE_RW)
     if (Map->mode == GV_MODE_WRITE || Map->mode == GV_MODE_RW)
 	Vect_build (Map, stderr);
 	Vect_build (Map, stderr);
@@ -505,19 +484,19 @@ void G_sites_close ( FILE * ptr)
 /* They are retained here only for backwards */
 /* They are retained here only for backwards */
 /* compatability while porting applications  */
 /* compatability while porting applications  */
 /*********************************************/
 /*********************************************/
-FILE *G_fopen_sites_old (char *name, char *mapset)
+struct Map_info *G_fopen_sites_old (const char *name, const char *mapset)
 {
 {
     return G_sites_open_old (name, mapset);
     return G_sites_open_old (name, mapset);
 }
 }
 
 
 
 
-FILE *G_fopen_sites_new (char *name)
+struct Map_info *G_fopen_sites_new (const char *name)
 {
 {
     return G_sites_open_new (name);
     return G_sites_open_new (name);
 }
 }
 
 
 
 
-int G_get_site ( FILE *fd, double *east,double *north, char **desc)
+int G_get_site (struct Map_info *fd, double *east,double *north, char **desc)
 {
 {
     /* TODO ? */
     /* TODO ? */
     G_fatal_error ( "G_get_site() not yet updated.");
     G_fatal_error ( "G_get_site() not yet updated.");
@@ -526,7 +505,7 @@ int G_get_site ( FILE *fd, double *east,double *north, char **desc)
 }
 }
 
 
 
 
-int G_put_site ( FILE *fd, double east,double north, const char *desc)
+int G_put_site (struct Map_info *fd, double east,double north, const char *desc)
 {
 {
     /* TODO ? */
     /* TODO ? */
     G_fatal_error ( "G_put_site() not yet updated.");
     G_fatal_error ( "G_put_site() not yet updated.");
@@ -1209,19 +1188,13 @@ char *G_site_format (const Site *s, const char *fs, int id)
 
 
  Functions to obtain fields in order to draw sites with each point having a
  Functions to obtain fields in order to draw sites with each point having a
  geometric property depending from database values.
  geometric property depending from database values.
-
- IN ALL THESE FUNCTIONS I FOLLOW THE CONVENTION TO PASS Map_info* as FILE*
-  FOR COHERENCE WITH OTHER ALREADY WRITTEN FUNCTION IN sites.c FILE.
 */
 */
 
 
 /*
 /*
  Returns a pointer to the SITE_ATT in Map_info *ptr and with category cat
  Returns a pointer to the SITE_ATT in Map_info *ptr and with category cat
 */
 */
-SITE_ATT * G_sites_get_atts (FILE * ptr, int* cat)
+SITE_ATT * G_sites_get_atts (struct Map_info *Map, int* cat)
 {
 {
-    struct Map_info *Map;
-    Map = (struct Map_info *) ptr;
-
 	return (SITE_ATT *) bsearch ( (void *) cat, (void *)Map->site_att, Map->n_site_att,
 	return (SITE_ATT *) bsearch ( (void *) cat, (void *)Map->site_att, Map->n_site_att,
 					 sizeof(SITE_ATT), site_att_cmp );
 					 sizeof(SITE_ATT), site_att_cmp );
 }
 }
@@ -1231,9 +1204,8 @@ SITE_ATT * G_sites_get_atts (FILE * ptr, int* cat)
 
 
   WARNING: user is responsible to free allocated memory, directly or calling G_sites_free_fields()
   WARNING: user is responsible to free allocated memory, directly or calling G_sites_free_fields()
 */
 */
-int G_sites_get_fields(FILE * ptr, char*** cnames, int** ctypes, int** ndx)
+int G_sites_get_fields(struct Map_info *Map, char*** cnames, int** ctypes, int** ndx)
 {
 {
-    struct Map_info *Map;
     struct field_info *fi;
     struct field_info *fi;
     int nrows, row, ncols, col, ndbl, nstr, ctype;
     int nrows, row, ncols, col, ndbl, nstr, ctype;
 
 
@@ -1251,7 +1223,6 @@ int G_sites_get_fields(FILE * ptr, char*** cnames, int** ctypes, int** ndx)
 		Should it be not true in the future, maybe we'll have to change this by choosing
 		Should it be not true in the future, maybe we'll have to change this by choosing
 		appropriate fields and multiple categories */
 		appropriate fields and multiple categories */
 
 
-    Map = (struct Map_info *) ptr;
     fi = (struct field_info *)Vect_get_field(Map, 1);
     fi = (struct field_info *)Vect_get_field(Map, 1);
 
 
 
 

+ 0 - 1
raster/Makefile

@@ -106,7 +106,6 @@ SUBDIRS = \
 	r.watershed \
 	r.watershed \
 	r.what \
 	r.what \
 	r.what.color \
 	r.what.color \
-	simwe \
 	wildfire
 	wildfire
 
 
 GDALBASED = r.in.gdal r.out.gdal
 GDALBASED = r.in.gdal r.out.gdal

+ 2 - 2
raster/r.cost/main.c

@@ -459,7 +459,7 @@ int main(int argc, char *argv[])
      */
      */
     if (opt7->answer) {
     if (opt7->answer) {
 #if 1
 #if 1
-	FILE *fp;
+	struct Map_info *fp;
 	struct start_pt *new_start_pt;
 	struct start_pt *new_start_pt;
 	Site *site = NULL;	/* pointer to Site */
 	Site *site = NULL;	/* pointer to Site */
 	int got_one = 0;
 	int got_one = 0;
@@ -510,7 +510,7 @@ int main(int argc, char *argv[])
 
 
     if (opt8->answer) {
     if (opt8->answer) {
 #if 1
 #if 1
-	FILE *fp;
+	struct Map_info *fp;
 	struct start_pt *new_start_pt;
 	struct start_pt *new_start_pt;
 	Site *site = NULL;	/* pointer to Site */
 	Site *site = NULL;	/* pointer to Site */
 	int dims, strs, dbls;
 	int dims, strs, dbls;

+ 1 - 1
raster/r.drain/main.c

@@ -204,7 +204,7 @@ int main(int argc, char **argv)
     }
     }
     if (vpointopt->answer) {
     if (vpointopt->answer) {
 	for (i = 0; vpointopt->answers[i] != NULL; i++) {
 	for (i = 0; vpointopt->answers[i] != NULL; i++) {
-	    FILE *fp;
+	    struct Map_info *fp;
 	    /* struct start_pt  *new_start_pt; */
 	    /* struct start_pt  *new_start_pt; */
 	    Site *site = NULL;	/* pointer to Site */
 	    Site *site = NULL;	/* pointer to Site */
 	    int dims, strs, dbls;
 	    int dims, strs, dbls;

+ 1 - 1
raster/r.volume/main.c

@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
     char *curr_mapset, *data_mapset, *clump_mapset;
     char *curr_mapset, *data_mapset, *clump_mapset;
     double avg, vol, total_vol, east, north, *sum;
     double avg, vol, total_vol, east, north, *sum;
     struct Cell_head window;
     struct Cell_head window;
-    FILE *fd_sites = NULL;
+    struct Map_info *fd_sites = NULL;
     Site *mysite;
     Site *mysite;
     Site_head site_info;
     Site_head site_info;
     struct GModule *module;
     struct GModule *module;

+ 2 - 2
raster/r.walk/main.c

@@ -393,7 +393,7 @@ int main(int argc, char *argv[])
 
 
 
 
     if (opt7->answer) {
     if (opt7->answer) {
-	FILE *fp;
+	struct Map_info *fp;
 	struct start_pt *new_start_pt;
 	struct start_pt *new_start_pt;
 	Site *site = NULL;	/* pointer to Site */
 	Site *site = NULL;	/* pointer to Site */
 	int dims, strs, dbls;
 	int dims, strs, dbls;
@@ -439,7 +439,7 @@ int main(int argc, char *argv[])
     }
     }
 
 
     if (opt8->answer) {
     if (opt8->answer) {
-	FILE *fp;
+	struct Map_info *fp;
 	struct start_pt *new_start_pt;
 	struct start_pt *new_start_pt;
 	Site *site = NULL;	/* pointer to Site */
 	Site *site = NULL;	/* pointer to Site */
 	int dims, strs, dbls;
 	int dims, strs, dbls;

+ 19 - 19
visualization/nviz/src/site_attr_commands.c

@@ -288,7 +288,7 @@ int attr_eval_color(float xvalue, int n, float *x,
 							float *mr, float *mg, float *mb);
 							float *mr, float *mg, float *mb);
 
 
 /* better move to ../../../include/P_site.h */
 /* better move to ../../../include/P_site.h */
-SITE_ATT * G_sites_get_atts (FILE * ptr, int* cat);
+SITE_ATT * G_sites_get_atts (struct Map_info * ptr, int* cat);
 
 
 /*******************************************************************************/
 /*******************************************************************************/
 /*******************************************************************************/
 /*******************************************************************************/
@@ -322,7 +322,7 @@ int Nsite_attr_get_fields_name_cmd(data, interp, argc, argv)
     if (argc != 2) return (TCL_ERROR);
     if (argc != 2) return (TCL_ERROR);
 
 
 	Map = (struct Map_info *)G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
 	Map = (struct Map_info *)G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
-	ncols=G_sites_get_fields((FILE *)Map, &cnames, &ctypes, &ndx);
+	ncols=G_sites_get_fields(Map, &cnames, &ctypes, &ndx);
 
 
 	for(i=0; i<ncols; i++) {
 	for(i=0; i<ncols; i++) {
 		sprintf(buf, "%s", cnames[i]);
 		sprintf(buf, "%s", cnames[i]);
@@ -354,8 +354,8 @@ int Nsite_attr_get_fields_type_cmd(data, interp, argc, argv)
 
 
     if (argc != 2) return (TCL_ERROR);
     if (argc != 2) return (TCL_ERROR);
 
 
-	Map = (struct Map_info *)G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
-	ncols=G_sites_get_fields((FILE *)Map, &cnames, &ctypes, &ndx);
+	Map = G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
+	ncols=G_sites_get_fields(Map, &cnames, &ctypes, &ndx);
 
 
 	for(i=0; i<ncols; i++) {
 	for(i=0; i<ncols; i++) {
 		sprintf(buf, "%c", ctypes[i]);
 		sprintf(buf, "%c", ctypes[i]);
@@ -387,8 +387,8 @@ int Nsite_attr_get_fields_name_and_type_cmd(data, interp, argc, argv)
 
 
     if (argc != 2) return (TCL_ERROR);
     if (argc != 2) return (TCL_ERROR);
 
 
-	Map = (struct Map_info *)G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
-	ncols=G_sites_get_fields((FILE *)Map, &cnames, &ctypes, &ndx);
+	Map = G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
+	ncols=G_sites_get_fields(Map, &cnames, &ctypes, &ndx);
 
 
 	for(i=0; i<ncols; i++) {
 	for(i=0; i<ncols; i++) {
 		sprintf(buf, "%s", cnames[i]);
 		sprintf(buf, "%s", cnames[i]);
@@ -433,8 +433,8 @@ int Nsite_attr_get_field_values_cmd(data, interp, argc, argv)
 
 
 	index=atoi(argv[2]);
 	index=atoi(argv[2]);
 
 
-	Map = (struct Map_info *)G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
-	ncols=G_sites_get_fields((FILE *)Map, &cnames, &ctypes, &ndx);
+	Map = G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
+	ncols=G_sites_get_fields(Map, &cnames, &ctypes, &ndx);
 
 
 	for (i=0; i<Map->n_site_att; i++) {
 	for (i=0; i<Map->n_site_att; i++) {
 		sa = &(Map->site_att[i]);
 		sa = &(Map->site_att[i]);
@@ -483,8 +483,8 @@ int Nsite_attr_get_field_not_emtpy_cats_cmd(data, interp, argc, argv)
 
 
 	index=atoi(argv[2]);
 	index=atoi(argv[2]);
 
 
-	Map = (struct Map_info *)G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
-	ncols=G_sites_get_fields((FILE *)Map, &cnames, &ctypes, &ndx);
+	Map = G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
+	ncols=G_sites_get_fields(Map, &cnames, &ctypes, &ndx);
 
 
 	for (i=0; i<Map->n_site_att; i++) {
 	for (i=0; i<Map->n_site_att; i++) {
 		sa = &(Map->site_att[i]);
 		sa = &(Map->site_att[i]);
@@ -534,11 +534,11 @@ int Nsite_attr_get_record_values_cmd(data, interp, argc, argv)
 
 
 	cat=atoi(argv[2]);
 	cat=atoi(argv[2]);
 
 
-	Map = (struct Map_info *)G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
-	ncols=G_sites_get_fields((FILE *)Map, &cnames, &ctypes, &ndx);
+	Map = G_sites_open_old(argv[1], G_find_vector2(argv[1], ""));
+	ncols=G_sites_get_fields(Map, &cnames, &ctypes, &ndx);
 
 
 
 
-	if ( (sa = (SITE_ATT *)G_sites_get_atts((FILE *)Map, &cat)) == NULL ) return (TCL_ERROR);
+	if ( (sa = (SITE_ATT *)G_sites_get_atts(Map, &cat)) == NULL ) return (TCL_ERROR);
 
 
 	for (i=0; i<ncols; i++) {
 	for (i=0; i<ncols; i++) {
 		switch(ctypes[i]) {
 		switch(ctypes[i]) {
@@ -606,10 +606,10 @@ int site_attr_open_map(geosite * gp, int index,
 {
 {
 	const char *function_name="site_attr_open_map";
 	const char *function_name="site_attr_open_map";
 
 
-	*Map = (struct Map_info *)G_sites_open_old(gp->filename, G_find_vector2(gp->filename, ""));
+	*Map = G_sites_open_old(gp->filename, G_find_vector2(gp->filename, ""));
 
 
 	/* this is needed to find association between names and proper indexes/types */
 	/* this is needed to find association between names and proper indexes/types */
-	*ncols=G_sites_get_fields((FILE *)*Map, cnames, ctypes, ndx);
+	*ncols=G_sites_get_fields(*Map, cnames, ctypes, ndx);
 
 
 	if (*ncols <= 0) {
 	if (*ncols <= 0) {
 		printf("WARNING / \"%s()\": site \"%s\" database error\n", function_name, gp->filename);
 		printf("WARNING / \"%s()\": site \"%s\" database error\n", function_name, gp->filename);
@@ -748,10 +748,10 @@ int site_attr_set_color(geosite * gp, int nattr, int index, int n, const char**
 			gpt->color[nattr] = attr_eval_color(gpt->cat, n, x, yr, yg, yb, mr, mg, mb);
 			gpt->color[nattr] = attr_eval_color(gpt->cat, n, x, yr, yg, yb, mr, mg, mb);
 		}
 		}
 		else if (ctypes[index] == 'd') {
 		else if (ctypes[index] == 'd') {
-			if ( (sa = (SITE_ATT *)G_sites_get_atts((FILE *)Map, &(gpt->cat))) == NULL ) continue;
+			if ( (sa = (SITE_ATT *)G_sites_get_atts(Map, &(gpt->cat))) == NULL ) continue;
 			else gpt->color[nattr] = attr_eval_color(sa->dbl[ndx[index]], n, x, yr, yg, yb, mr, mg, mb);
 			else gpt->color[nattr] = attr_eval_color(sa->dbl[ndx[index]], n, x, yr, yg, yb, mr, mg, mb);
 		} else {
 		} else {
-			if ( (sa = (SITE_ATT *)G_sites_get_atts((FILE *)Map, &(gpt->cat))) == NULL ) continue;
+			if ( (sa = (SITE_ATT *)G_sites_get_atts(Map, &(gpt->cat))) == NULL ) continue;
 			else gpt->color[nattr] = attr_eval_color_string(sa->str[ndx[index]], n, argvX, yr, yg, yb);
 			else gpt->color[nattr] = attr_eval_color_string(sa->str[ndx[index]], n, argvX, yr, yg, yb);
 		}
 		}
 	}
 	}
@@ -783,11 +783,11 @@ int site_attr_set_size(geosite * gp, int nattr, int index, int n, const char** a
 			gpt->size[nattr] = attr_eval_entry(gpt->cat, n, x, y, m);
 			gpt->size[nattr] = attr_eval_entry(gpt->cat, n, x, y, m);
 		}
 		}
 		else if (ctypes[index] == 'd') {
 		else if (ctypes[index] == 'd') {
-			if ( (sa = (SITE_ATT *)G_sites_get_atts((FILE *)Map, &(gpt->cat))) == NULL ) continue;
+			if ( (sa = (SITE_ATT *)G_sites_get_atts(Map, &(gpt->cat))) == NULL ) continue;
 			else gpt->size[nattr] = attr_eval_entry(sa->dbl[ndx[index]], n, x, y, m);
 			else gpt->size[nattr] = attr_eval_entry(sa->dbl[ndx[index]], n, x, y, m);
 		}
 		}
 		else {
 		else {
-			if ( (sa = (SITE_ATT *)G_sites_get_atts((FILE *)Map, &(gpt->cat))) == NULL ) continue;
+			if ( (sa = (SITE_ATT *)G_sites_get_atts(Map, &(gpt->cat))) == NULL ) continue;
 			else gpt->size[nattr] = attr_eval_entry_string(sa->str[ndx[index]], n, argvX, y);
 			else gpt->size[nattr] = attr_eval_entry_string(sa->str[ndx[index]], n, argvX, y);
 		}
 		}
 	}
 	}