Explorar o código

Eliminate preprocessor abuse

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32675 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements %!s(int64=16) %!d(string=hai) anos
pai
achega
94516acb96
Modificáronse 100 ficheiros con 417 adicións e 534 borrados
  1. 0 5
      db/drivers/dbf/globals.h
  2. 3 1
      db/drivers/dbf/main.c
  3. 0 1
      db/drivers/dbf/main_debug.c
  4. 0 5
      db/drivers/mysql/globals.h
  5. 3 1
      db/drivers/mysql/main.c
  6. 0 5
      db/drivers/odbc/globals.h
  7. 2 1
      db/drivers/odbc/main.c
  8. 0 5
      db/drivers/ogr/globals.h
  9. 4 1
      db/drivers/ogr/main.c
  10. 0 7
      db/drivers/postgres/globals.h
  11. 5 1
      db/drivers/postgres/main.c
  12. 0 4
      display/d.colors/externs.h
  13. 5 2
      display/d.colors/set_sigs.c
  14. 0 10
      display/d.histogram/dhist.h
  15. 16 1
      display/d.histogram/main.c
  16. 9 14
      display/d.histogram/options.h
  17. 0 1
      display/d.measure/main.c
  18. 14 1
      display/d.profile/main.c
  19. 0 16
      display/d.profile/profile.h
  20. 0 1
      display/d.rast.arrow/arrow.c
  21. 0 1
      display/d.rast.num/number.c
  22. 4 1
      display/d.rast/main.c
  23. 0 5
      display/d.rast/mask.h
  24. 6 1
      display/d.title/main.c
  25. 4 10
      display/d.title/options.h
  26. 4 1
      display/d.what.vect/main.c
  27. 3 9
      display/d.what.vect/what.h
  28. 4 10
      display/d.zoom/local_proto.h
  29. 6 1
      display/d.zoom/main.c
  30. 1 9
      general/g.mapsets/externs.h
  31. 7 1
      general/g.mapsets/main_cmd.c
  32. 0 1
      general/g.mapsets/main_inter.c
  33. 5 11
      general/g.mkfontcap/local_proto.h
  34. 7 2
      general/g.mkfontcap/main.c
  35. 2 8
      general/g.proj/local_proto.h
  36. 3 1
      general/g.proj/main.c
  37. 1 1
      general/manage/cmd/copy.c
  38. 0 1
      general/manage/cmd/list.c
  39. 1 1
      general/manage/cmd/remove.c
  40. 1 1
      general/manage/cmd/rename.c
  41. 3 0
      general/manage/lib/read_list.c
  42. 0 5
      general/manage/list.h
  43. 0 1
      imagery/i.cca/main.c
  44. 28 44
      imagery/i.class/globals.h
  45. 40 2
      imagery/i.class/main.c
  46. 2 3
      imagery/i.fft/fftmain.c
  47. 1 7
      imagery/i.fft/globals.h
  48. 1 7
      imagery/i.ifft/globals.h
  49. 2 3
      imagery/i.ifft/ifftmain.c
  50. 7 12
      imagery/i.ortho.photo/photo.camera/globals.h
  51. 14 1
      imagery/i.ortho.photo/photo.camera/main.c
  52. 1 1
      imagery/i.ortho.photo/photo.elev/main.c
  53. 6 12
      imagery/i.ortho.photo/photo.init/globals.h
  54. 11 1
      imagery/i.ortho.photo/photo.init/main.c
  55. 6 11
      imagery/i.zc/main.c
  56. 0 4
      include/sqlp.h
  57. 2 2
      lib/db/sqlp/sql.c
  58. 3 4
      lib/dspf/cell_table.h
  59. 1 7
      lib/dspf/viz.h
  60. 0 2
      lib/proj/get_proj.c
  61. 0 4
      ps/ps.map/border.h
  62. 0 4
      ps/ps.map/colortable.h
  63. 0 4
      ps/ps.map/comment.h
  64. 1 4
      ps/ps.map/decorate.h
  65. 0 4
      ps/ps.map/group.h
  66. 0 4
      ps/ps.map/header.h
  67. 0 4
      ps/ps.map/labels.h
  68. 16 1
      ps/ps.map/main.c
  69. 0 4
      ps/ps.map/map_info.h
  70. 1 8
      ps/ps.map/ps_info.h
  71. 0 4
      ps/ps.map/vector.h
  72. 15 2
      raster/r.cost/main.c
  73. 0 24
      raster/r.cost/stash.h
  74. 0 1
      raster/r.digit/main.c
  75. 16 1
      raster/r.drain/tinf.c
  76. 2 18
      raster/r.drain/tinf.h
  77. 15 1
      raster/r.fill.dir/tinf.c
  78. 0 17
      raster/r.fill.dir/tinf.h
  79. 14 2
      raster/r.flow/calc.c
  80. 0 4
      raster/r.flow/mem.h
  81. 0 17
      raster/r.flow/r.flow.h
  82. 2 1
      raster/r.in.gridatb/file_io.c
  83. 4 11
      raster/r.in.gridatb/local_proto.h
  84. 5 2
      raster/r.in.gridatb/main.c
  85. 2 1
      raster/r.le/r.le.patch/main.c
  86. 0 4
      raster/r.le/r.le.patch/patch.h
  87. 7 13
      raster/r.los/cmd_line.h
  88. 9 1
      raster/r.los/main.c
  89. 5 11
      raster/r.mfilter/glob.h
  90. 7 1
      raster/r.mfilter/main.c
  91. 5 11
      raster/r.out.gridatb/local_proto.h
  92. 8 4
      raster/r.out.gridatb/main.c
  93. 0 5
      raster/r.out.vtk/globaldefs.h
  94. 5 1
      raster/r.out.vtk/main.c
  95. 3 5
      raster/r.out.vtk/parameters.h
  96. 21 29
      raster/r.param.scale/main.c
  97. 6 12
      raster/r.param.scale/param.h
  98. 0 1
      raster/r.random.cells/gasdev.c
  99. 0 1
      raster/r.random.cells/indep.c
  100. 0 0
      raster/r.random.cells/init.c

+ 0 - 5
db/drivers/dbf/globals.h

@@ -78,10 +78,5 @@ typedef struct
     int *order;			/* array of row indexes (sorted by ORDER BY) */
 } cursor;
 
-#ifdef MAIN
-DATABASE db;
-dbString *errMsg = NULL;
-#else
 extern DATABASE db;
 extern dbString *errMsg;
-#endif

+ 3 - 1
db/drivers/dbf/main.c

@@ -15,7 +15,6 @@
 *
 *****************************************************************************/
 
-#define MAIN
 #include <stdlib.h>
 #include <string.h>
 #include <grass/dbmi.h>
@@ -23,6 +22,9 @@
 #include "proto.h"
 #include "dbdriver.h"
 
+DATABASE db;
+dbString *errMsg = NULL;
+
 int main(int argc, char *argv[])
 {
     char *name;

+ 0 - 1
db/drivers/dbf/main_debug.c

@@ -3,7 +3,6 @@
 * just a test for debugging purpose, imitating dbf driver -a.sh.
 *****************************************************************************/
 
-#define MAIN
 #include <stdlib.h>
 #include <grass/dbmi.h>
 #include <grass/gis.h>

+ 0 - 5
db/drivers/mysql/globals.h

@@ -18,10 +18,5 @@ typedef struct
     unsigned int port;
 } CONNPAR;
 
-#ifdef MAIN
-MYSQL *connection;		/* Database connection */
-dbString *errMsg = NULL;	/* error message */
-#else
 extern MYSQL *connection;
 extern dbString *errMsg;
-#endif

+ 3 - 1
db/drivers/mysql/main.c

@@ -15,9 +15,11 @@
 #include <grass/dbmi.h>
 #include "dbdriver.h"
 
-#define MAIN
 #include "globals.h"
 
+MYSQL *connection;		/* Database connection */
+dbString *errMsg = NULL;	/* error message */
+
 int main(int argc, char *argv[])
 {
     init_dbdriver();

+ 0 - 5
db/drivers/odbc/globals.h

@@ -11,10 +11,5 @@ typedef struct _cursor
     int nrows;			/* number of rows selected by SELECT statement */
 } cursor;
 
-#ifdef MAIN
-SQLHENV ODenvi;			/* Handle ODBC environment */
-SQLHDBC ODconn;			/* Handle connection  */
-#else
 extern SQLHENV ODenvi;		/* Handle ODBC environment */
 extern SQLHDBC ODconn;		/* Handle connection  */
-#endif

+ 2 - 1
db/drivers/odbc/main.c

@@ -1,10 +1,11 @@
-#define MAIN
 #include <stdlib.h>
 #include <grass/dbmi.h>
 #include "odbc.h"
 #include "globals.h"
 #include "dbdriver.h"
 
+SQLHENV ODenvi;			/* Handle ODBC environment */
+SQLHDBC ODconn;			/* Handle connection  */
 
 int main(int argc, char **argv)
 {

+ 0 - 5
db/drivers/ogr/globals.h

@@ -26,10 +26,5 @@ typedef struct
     int ncols;			/* num columns */
 } cursor;
 
-#ifdef MAIN
-OGRDataSourceH hDs;
-dbString *errMsg = NULL;	/* error message */
-#else
 extern OGRDataSourceH hDs;
 extern dbString *errMsg;
-#endif

+ 4 - 1
db/drivers/ogr/main.c

@@ -14,13 +14,16 @@
 *   	    	for details.
 *
 *****************************************************************************/
-#define MAIN
+
 #include <stdlib.h>
 #include <grass/dbmi.h>
 #include "ogr_api.h"
 #include "globals.h"
 #include "dbdriver.h"
 
+OGRDataSourceH hDs;
+dbString *errMsg = NULL;	/* error message */
+
 int main(int argc, char *argv[])
 {
     init_dbdriver();

+ 0 - 7
db/drivers/postgres/globals.h

@@ -52,14 +52,7 @@ typedef enum
 } PG_TYPES;
 
 
-#ifdef MAIN
-PGconn *pg_conn;		/* Database connection */
-int (*pg_types)[2] = NULL;	/* array of types, first is internal code, second PG_TYPE_* */
-int pg_ntypes = 0;
-dbString *errMsg = NULL;	/* error message */
-#else
 extern PGconn *pg_conn;
 extern dbString *errMsg;
 extern int (*pg_types)[2];
 extern int pg_ntypes;
-#endif

+ 5 - 1
db/drivers/postgres/main.c

@@ -1,9 +1,13 @@
-#define MAIN
 #include <stdlib.h>
 #include <grass/dbmi.h>
 #include "globals.h"
 #include "dbdriver.h"
 
+PGconn *pg_conn;		/* Database connection */
+int (*pg_types)[2] = NULL;	/* array of types, first is internal code, second PG_TYPE_* */
+int pg_ntypes = 0;
+dbString *errMsg = NULL;	/* error message */
+
 int main(int argc, char *argv[])
 {
     init_dbdriver();

+ 0 - 4
display/d.colors/externs.h

@@ -3,8 +3,4 @@ struct signalflag
     int interrupt;
 };
 
-#ifdef SIG_MAIN
-struct signalflag signalflag;
-#else
 extern struct signalflag signalflag;
-#endif

+ 5 - 2
display/d.colors/set_sigs.c

@@ -1,8 +1,11 @@
-#define SIG_MAIN
+
 #include "externs.h"
 #include <signal.h>
+#include <grass/config.h>
+
+struct signalflag signalflag;
 
-void sigint();
+extern RETSIGTYPE sigint(int);
 
 int set_signals(void)
 {

+ 0 - 10
display/d.histogram/dhist.h

@@ -26,19 +26,9 @@ struct units
     long int every;		/* tic_mark number interval */
 };
 
-#ifdef MAIN
-
-struct stat_list dist_stats;
-struct Categories cats;
-struct FPRange fp_range;
-int is_fp;
-
-#else
 extern struct Categories cats;
 extern struct FPRange fp_range;
 
-#endif
-
 /* bar.c */
 int bar(struct stat_list *, struct Colors *);
 float rem(long int, long int);

+ 16 - 1
display/d.histogram/main.c

@@ -37,10 +37,25 @@
 #include <grass/display.h>
 #include <grass/raster.h>
 #include <grass/glocale.h>
-#define MAIN
+
 #include "options.h"
 #include "dhist.h"
 
+struct stat_list dist_stats;
+struct Categories cats;
+struct FPRange fp_range;
+int is_fp;
+
+char *map_name;
+int color;
+float size;
+int style;
+int type;
+int is_fp;
+int nodata;
+int nsteps;
+int cat_ranges;
+
 int main(int argc, char **argv)
 {
     int text_height;

+ 9 - 14
display/d.histogram/options.h

@@ -1,18 +1,13 @@
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
 
-GLOBAL char *map_name;
-GLOBAL int color;
-GLOBAL float size;
-GLOBAL int style;
-GLOBAL int type;
-GLOBAL int is_fp;
-GLOBAL int nodata;
-GLOBAL int nsteps;
-GLOBAL int cat_ranges;
+extern char *map_name;
+extern int color;
+extern float size;
+extern int style;
+extern int type;
+extern int is_fp;
+extern int nodata;
+extern int nsteps;
+extern int cat_ranges;
 
 #define PIE	1
 #define BAR	2

+ 0 - 1
display/d.measure/main.c

@@ -25,7 +25,6 @@
 #include <grass/display.h>
 #include <grass/raster.h>
 #include <grass/glocale.h>
-#define MAIN
 #include "local_proto.h"
 
 int main(int argc, char **argv)

+ 14 - 1
display/d.profile/main.c

@@ -20,7 +20,6 @@
 
 
 #define DEBUG
-#define MAIN
 #define USE_OLD_CODE		/* Frame set-up still needs old code ATM. */
 #include <stdio.h>
 #include <stdlib.h>
@@ -31,6 +30,20 @@
 #include <grass/glocale.h>
 #include "profile.h"
 
+struct windows windows[] = {
+    {"mou", 85, 100, 0, 50},
+    {"sta", 85, 100, 50, 100},
+    {"map", 0, 85, 0, 50},
+    {"orig", 0, 100, 0, 1009}
+};
+
+struct windows profiles[] = {
+    {"pro1", 64, 85, 50, 100},
+    {"pro2", 43, 64, 50, 100},
+    {"pro3", 22, 43, 50, 100},
+    {"pro4", 0, 22, 50, 100}
+};
+
 struct Profile profile;
 
 void myDcell(char *name, char *mapset, int overlay);

+ 0 - 16
display/d.profile/profile.h

@@ -48,24 +48,8 @@ struct Profile
     UCAT MinCat, MaxCat;
 };
 
-#ifdef MAIN
-struct windows windows[] = {
-    {"mou", 85, 100, 0, 50},
-    {"sta", 85, 100, 50, 100},
-    {"map", 0, 85, 0, 50},
-    {"orig", 0, 100, 0, 1009}
-};
-
-struct windows profiles[] = {
-    {"pro1", 64, 85, 50, 100},
-    {"pro2", 43, 64, 50, 100},
-    {"pro3", 22, 43, 50, 100},
-    {"pro4", 0, 22, 50, 100}
-};
-#else
 extern struct windows windows[];
 extern struct windows profiles[];
-#endif
 
 #define MOU     windows[0]
 #define STA     windows[1]

+ 0 - 1
display/d.rast.arrow/arrow.c

@@ -46,7 +46,6 @@
 # define RpD ((2 * M_PI) / 360.)	/* radians/degree */
 # define D2R(d) (double)(d * RpD)	/* degrees->radians */
 
-#define MAIN
 static void arrow_mag(double, double);
 static void arrow_360(double);
 static void arrow_se(void);

+ 0 - 1
display/d.rast.num/number.c

@@ -42,7 +42,6 @@
 #include <grass/colors.h>
 #include <grass/glocale.h>
 
-#define MAIN
 int draw_number(double, int, RASTER_MAP_TYPE);
 
 int D_x, D_y;

+ 4 - 1
display/d.rast/main.c

@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/raster.h>
-#define MAIN
+
 #include "mask.h"
 #include "local_proto.h"
 #include <grass/glocale.h>
@@ -29,6 +29,9 @@
 static int parse_catlist(char **, Mask *);
 static int parse_vallist(char **, d_Mask *);
 
+d_Mask d_mask;
+Mask mask;
+
 int main(int argc, char **argv)
 {
     char *mapset;

+ 0 - 5
display/d.rast/mask.h

@@ -22,10 +22,5 @@ typedef struct _d_mask
     d_Interval *list;
 } d_Mask;
 
-#ifdef MAIN
-d_Mask d_mask;
-Mask mask;
-#else
 extern d_Mask d_mask;
 extern Mask mask;
-#endif

+ 6 - 1
display/d.title/main.c

@@ -22,10 +22,15 @@
 #include <grass/raster.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
-#define MAIN
+
 #include "options.h"
 #include "local_proto.h"
 
+char map_name[GNAME_MAX];
+char color[128];
+float size;
+int type;
+
 int main(int argc, char **argv)
 {
     char *mapset;

+ 4 - 10
display/d.title/options.h

@@ -1,14 +1,8 @@
 
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
-GLOBAL char map_name[GNAME_MAX];
-GLOBAL char color[128];
-GLOBAL float size;
-GLOBAL int type;
+extern char map_name[GNAME_MAX];
+extern char color[128];
+extern float size;
+extern int type;
 
 #define NORMAL	1
 #define FANCY	2

+ 4 - 1
display/d.what.vect/main.c

@@ -24,7 +24,6 @@
  *
  */
 
-#define MAIN
 #include <stdlib.h>
 #include <string.h>
 #include <grass/glocale.h>
@@ -36,6 +35,10 @@
 #include <grass/dbmi.h>
 #include <grass/glocale.h>
 
+char **vect;
+int nvects;
+struct Map_info *Map;
+
 /* Vector map grabbing taken from d.zoom */
 
 int main(int argc, char **argv)

+ 3 - 9
display/d.what.vect/what.h

@@ -12,12 +12,6 @@ void flash_line(struct Map_info *, plus_t, struct line_pnts *, int);
 /* attr.c */
 int disp_attr(char *, char *, char *, char *, int);
 
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL	extern
-#endif
-
-GLOBAL char **vect;
-GLOBAL int nvects;
-GLOBAL struct Map_info *Map;
+extern char **vect;
+extern int nvects;
+extern struct Map_info *Map;

+ 4 - 10
display/d.zoom/local_proto.h

@@ -40,13 +40,7 @@ int set_win(struct Cell_head *, double, double, double, double, int);
 /* quit.c */
 int quit(struct Cell_head *, struct Cell_head *);
 
-#ifdef MAIN
-#define	GLOBAL
-#else
-#define	GLOBAL	extern
-#endif
-
-GLOBAL char *cmd;
-GLOBAL char **rast, **vect, **list;
-GLOBAL int nrasts, nvects, nlists;
-GLOBAL double U_east, U_west, U_south, U_north;
+extern char *cmd;
+extern char **rast, **vect, **list;
+extern int nrasts, nvects, nlists;
+extern double U_east, U_west, U_south, U_north;

+ 6 - 1
display/d.zoom/main.c

@@ -26,10 +26,15 @@
 #include <grass/display.h>
 #include <grass/raster.h>
 #include <grass/Vect.h>
-#define	MAIN
+
 #include "local_proto.h"
 #include <grass/glocale.h>
 
+char *cmd;
+char **rast, **vect, **list;
+int nrasts, nvects, nlists;
+double U_east, U_west, U_south, U_north;
+
 int main(int argc, char **argv)
 {
     int stat;

+ 1 - 9
general/g.mapsets/externs.h

@@ -1,18 +1,10 @@
-#ifdef MAIN
-char *mapset_name[GMAPSET_MAX];
-int nmapsets;
-int choice[GMAPSET_MAX];
-int nchoices;
-int curr_mapset[GMAPSET_MAX];
-int ncurr_mapsets;
-#else
+
 extern char *mapset_name[];
 extern int nmapsets;
 extern int choice[];
 extern int nchoices;
 extern int curr_mapset[];
 extern int ncurr_mapsets;
-#endif
 
 #define	REPLACE	0
 #define ADD	1

+ 7 - 1
general/g.mapsets/main_cmd.c

@@ -17,7 +17,6 @@
  *
  *****************************************************************************/
 
-#define MAIN
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -27,6 +26,13 @@
 #include "local_proto.h"
 #include "externs.h"
 
+char *mapset_name[GMAPSET_MAX];
+int nmapsets;
+int choice[GMAPSET_MAX];
+int nchoices;
+int curr_mapset[GMAPSET_MAX];
+int ncurr_mapsets;
+
 static char Path[GPATH_MAX];
 
 int main(int argc, char *argv[])

+ 0 - 1
general/g.mapsets/main_inter.c

@@ -15,7 +15,6 @@
  *
  *****************************************************************************/
 
-#define MAIN
 #include "externs.h"
 #include "local_proto.h"
 #include <grass/gis.h>

+ 5 - 11
general/g.mkfontcap/local_proto.h

@@ -1,15 +1,9 @@
-#ifdef G_MKFONTCAP_MAIN
-#  define G_MKFONTCAP_GLOBAL
-#else
-#  define G_MKFONTCAP_GLOBAL extern
-#endif
+extern char **searchdirs;
+extern int numsearchdirs;
 
-G_MKFONTCAP_GLOBAL char **searchdirs;
-G_MKFONTCAP_GLOBAL int numsearchdirs;
-
-G_MKFONTCAP_GLOBAL struct GFONT_CAP *fontcap;
-G_MKFONTCAP_GLOBAL int totalfonts;
-G_MKFONTCAP_GLOBAL int maxfonts;
+extern struct GFONT_CAP *fontcap;
+extern int totalfonts;
+extern int maxfonts;
 
 /* freetype_fonts.c */
 void find_freetype_fonts(void);

+ 7 - 2
general/g.mkfontcap/main.c

@@ -14,8 +14,6 @@
  *
  *****************************************************************************/
 
-#define G_MKFONTCAP_MAIN 1
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -29,6 +27,13 @@
 
 #include "local_proto.h"
 
+char **searchdirs;
+int numsearchdirs;
+
+struct GFONT_CAP *fontcap;
+int totalfonts;
+int maxfonts;
+
 static const char *standarddirs[] = {
     /* These are the directories that are searched for Freetype-compatible
      * font files by default. They may contain an environment variable 

+ 2 - 8
general/g.proj/local_proto.h

@@ -1,11 +1,5 @@
-#ifdef G_PROJ_MAIN
-#  define G_PROJ_GLOBAL
-#else
-#  define G_PROJ_GLOBAL extern
-#endif
-
-G_PROJ_GLOBAL struct Key_Value *projinfo, *projunits;
-G_PROJ_GLOBAL struct Cell_head cellhd;
+extern struct Key_Value *projinfo, *projunits;
+extern struct Cell_head cellhd;
 
 /* input.c */
 void input_currloc(void);

+ 3 - 1
general/g.proj/main.c

@@ -19,9 +19,11 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
-#define G_PROJ_MAIN
 #include "local_proto.h"
 
+struct Key_Value *projinfo, *projunits;
+struct Cell_head cellhd;
+
 int main(int argc, char *argv[])
 {
     struct Flag *printinfo,	/* Print contents of PROJ_INFO & PROJ_UNITS */

+ 1 - 1
general/manage/cmd/copy.c

@@ -17,7 +17,7 @@
  *               for details.
  *
  *****************************************************************************/
-#define MAIN
+
 #include <stdlib.h>
 #include <string.h>
 #include <grass/glocale.h>

+ 0 - 1
general/manage/cmd/list.c

@@ -17,7 +17,6 @@
  *
  *****************************************************************************/
 
-#define MAIN
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>

+ 1 - 1
general/manage/cmd/remove.c

@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <grass/glocale.h>
-#define MAIN
+
 #include "list.h"
 #include "local_proto.h"
 

+ 1 - 1
general/manage/cmd/rename.c

@@ -16,7 +16,7 @@
  *               for details.
  *
  *****************************************************************************/
-#define MAIN
+
 #include <stdlib.h>
 #include <string.h>
 #include <grass/gis.h>

+ 3 - 0
general/manage/lib/read_list.c

@@ -17,6 +17,9 @@ read the element list file
 	  .
 ******************************************************************/
 
+int nlist;
+struct list *list;
+
 static int format_error(char *, int, char *);
 
 int read_list(int check_if_empty)

+ 0 - 5
general/manage/list.h

@@ -13,11 +13,6 @@ struct list
     char *maindesc;		/* main element description */
 };
 
-#ifdef MAIN
-int nlist;
-struct list *list;
-#endif
-
 extern int nlist;
 extern struct list *list;
 

+ 0 - 1
imagery/i.cca/main.c

@@ -38,7 +38,6 @@
 #include <string.h>
 #include <math.h>
 
-#define MAIN
 #include <grass/imagery.h>
 #include <grass/gmath.h>
 #include <grass/glocale.h>

+ 28 - 44
imagery/i.class/globals.h

@@ -3,30 +3,23 @@
 
 #include "defs.h"
 
-#ifndef GLOBAL
-#  define GLOBAL extern
-#  define INIT(x)
-#else
-#  define INIT(x) = x
-#endif
+extern Window *PROMPT_WINDOW;
 
-GLOBAL Window *PROMPT_WINDOW;
+extern int SCREEN_TOP;
+extern int SCREEN_BOTTOM;
+extern int SCREEN_LEFT;
+extern int SCREEN_RIGHT;
 
-GLOBAL int SCREEN_TOP;
-GLOBAL int SCREEN_BOTTOM;
-GLOBAL int SCREEN_LEFT;
-GLOBAL int SCREEN_RIGHT;
+extern View *VIEW_MAP1;
+extern View *VIEW_TITLE1;
+extern View *VIEW_MAP1_ZOOM;
+extern View *VIEW_TITLE1_ZOOM;
 
-GLOBAL View *VIEW_MAP1;
-GLOBAL View *VIEW_TITLE1;
-GLOBAL View *VIEW_MAP1_ZOOM;
-GLOBAL View *VIEW_TITLE1_ZOOM;
+extern View *VIEW_MASK1;
+extern View *VIEW_MENU;
+extern View *VIEW_HISTO;
 
-GLOBAL View *VIEW_MASK1;
-GLOBAL View *VIEW_MENU;
-GLOBAL View *VIEW_HISTO;
-
-GLOBAL int THE_COLORS[10];
+extern int THE_COLORS[10];
 
 #define BLACK	THE_COLORS[0]
 #define BLUE	THE_COLORS[1]
@@ -49,6 +42,7 @@ GLOBAL int THE_COLORS[10];
 #define NUM_RED 	7
 #define NUM_WHITE	8
 #define NUM_YELLOW	9
+
 #define NAME_BLACK	"Black"
 #define NAME_BLUE	"Blue"
 #define NAME_BROWN	"Brown"
@@ -59,35 +53,25 @@ GLOBAL int THE_COLORS[10];
 #define NAME_RED 	"Red"
 #define NAME_WHITE	"White"
 #define NAME_YELLOW	"Yellow"
-#define MY_COLORS {{0,0,0},         /*black*/ \
-		     {50,50,255},     /*blue*/  \
-		     {170,200,70}, /*brown*/ \
-		     {0,255,0},     /*green*/ \
-		     {150,150,150}, /*grey*/  \
-		     {220,170,0},   /*orange*/\
-		     {200,0,200},   /*purple*/\
-		     {255,0,0},     /*red*/   \
-		     {255,255,255}, /*white*/ \
-		     {255,255,0}}	/*yellow */
-GLOBAL struct
+
+struct Color_table
 {
     int red, grn, blue;
-} Color_table[10] INIT(MY_COLORS);
-
-GLOBAL struct Ref Refer;
-GLOBAL FILE *outsig_fd;
-GLOBAL struct Signature Sigs;
-GLOBAL struct Cell_head Band_cellhd;
+};
 
-double row_to_northing();
-double col_to_easting();
+extern struct Color_table Color_table[10];
 
-GLOBAL int *Bandfd;
-GLOBAL struct region Region;
-GLOBAL struct signalflag signalflag;
-GLOBAL CELL **Bandbuf;
+extern struct Ref Refer;
+extern FILE *outsig_fd;
+extern struct Signature Sigs;
+extern struct Cell_head Band_cellhd;
 
+extern int *Bandfd;
+extern struct region Region;
+extern struct signalflag signalflag;
+extern CELL **Bandbuf;
 
-#undef INIT
+extern double row_to_northing(struct Cell_head *, int, double);
+extern double col_to_easting(struct Cell_head *, int, double);
 
 #endif /* __GLOBALS_H__ */

+ 40 - 2
imagery/i.class/main.c

@@ -18,8 +18,6 @@
  *               for details.
  *
  *****************************************************************************/
-#define MAIN
-#define GLOBAL
 
 #include <stdlib.h>
 #include <string.h>
@@ -29,6 +27,46 @@
 #include "globals.h"
 #include "local_proto.h"
 
+Window *PROMPT_WINDOW;
+
+int SCREEN_TOP;
+int SCREEN_BOTTOM;
+int SCREEN_LEFT;
+int SCREEN_RIGHT;
+
+View *VIEW_MAP1;
+View *VIEW_TITLE1;
+View *VIEW_MAP1_ZOOM;
+View *VIEW_TITLE1_ZOOM;
+
+View *VIEW_MASK1;
+View *VIEW_MENU;
+View *VIEW_HISTO;
+
+int THE_COLORS[10];
+
+struct Color_table Color_table[10] = {
+    {0,0,0},		/*black*/
+    {50,50,255},	/*blue*/ 
+    {170,200,70},	/*brown*/
+    {0,255,0},		/*green*/
+    {150,150,150},	/*grey*/ 
+    {220,170,0},	/*orange*/
+    {200,0,200},	/*purple*/
+    {255,0,0},		/*red*/	 
+    {255,255,255},	/*white*/
+    {255,255,0}		/*yellow */
+};
+
+struct Ref Refer;
+FILE *outsig_fd;
+struct Signature Sigs;
+struct Cell_head Band_cellhd;
+
+int *Bandfd;
+struct region Region;
+struct signalflag signalflag;
+CELL **Bandbuf;
 
 /* function prototypes */
 static int check_files(char *, char *, char *, char *);

+ 2 - 3
imagery/i.fft/fftmain.c

@@ -33,8 +33,6 @@
 
  */
 
-#define MAIN
-
 #include <string.h>
 #include <stdlib.h>
 #include <math.h>
@@ -44,12 +42,13 @@
 #include "globals.h"
 #include "local_proto.h"
 
+char Cellmap_real[GNAME_MAX], Cellmap_imag[GNAME_MAX];
 
 int main(int argc, char *argv[])
 {
     /* Global variable & function declarations */
     int Range;
-    char Cellmap_orig[50];
+    char Cellmap_orig[GNAME_MAX];
     int inputfd, realfd, imagfd;	/* the input and output file descriptors */
     char *inmapset;		/* the input mapset name */
     struct Cell_head window;

+ 1 - 7
imagery/i.fft/globals.h

@@ -1,12 +1,6 @@
 #ifndef __L_GLOBALS_H__
 #define __L_GLOBALS_H__
 
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
-GLOBAL char Cellmap_real[50], Cellmap_imag[50];
+extern char Cellmap_real[], Cellmap_imag[];
 
 #endif /* __L_GLOBALS_H__ */

+ 1 - 7
imagery/i.ifft/globals.h

@@ -1,12 +1,6 @@
 #ifndef __L_GLOBALS_H__
 #define __L_GLOBALS_H__
 
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
-GLOBAL char Cellmap_real[50], Cellmap_imag[50];
+extern char Cellmap_real[], Cellmap_imag[];
 
 #endif /* __L_GLOBALS_H__ */

+ 2 - 3
imagery/i.ifft/ifftmain.c

@@ -12,8 +12,6 @@
 
  */
 
-#define MAIN
-
 #include <string.h>
 #include <stdlib.h>
 #include <math.h>
@@ -23,11 +21,12 @@
 #include "globals.h"
 #include "local_proto.h"
 
+char Cellmap_real[GNAME_MAX], Cellmap_imag[GNAME_MAX];
 
 int main(int argc, char *argv[])
 {
     /* Global variable & function declarations */
-    char Cellmap_orig[50];
+    char Cellmap_orig[GNAME_MAX];
     FILE *realfp, *imagfp;	/* the input and output file descriptors */
     int outputfd, maskfd;	/* the input and output file descriptors */
     char *realmapset, *imagmapset;	/* the input mapset names */

+ 7 - 12
imagery/i.ortho.photo/photo.camera/globals.h

@@ -1,22 +1,17 @@
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
 /* State flags  Most are Toggles */
-GLOBAL char Data_Loaded;	/* is there data in memory */
+extern char Data_Loaded;	/* is there data in memory */
 
 				/* used for abnormal exit logic */
-GLOBAL char Files_Open;		/* is there data in memory */
+extern char Files_Open;		/* is there data in memory */
 
-GLOBAL struct Ortho_Camera_File_Ref cam_info;
+extern struct Ortho_Camera_File_Ref cam_info;
 
-GLOBAL char *camera;
+extern char *camera;
 
 /* hold the names of files etc.  mostly used by main.c */
-GLOBAL char *N_path;
-GLOBAL char *N_name;
-GLOBAL char *N_camera;
+extern char *N_path;
+extern char *N_name;
+extern char *N_camera;
 
 /* mod_cam_info.c */
 int mod_cam_info(int, struct Ortho_Camera_File_Ref *);

+ 14 - 1
imagery/i.ortho.photo/photo.camera/main.c

@@ -18,11 +18,24 @@
 /* select_camera */
 /* select a camera reference file for a given imagery group */
 
-#define  MAIN   1
 #include <stdlib.h>
 #include "orthophoto.h"
 #include "globals.h"
 
+char Data_Loaded;	/* is there data in memory */
+
+ 			/* used for abnormal exit logic */
+char Files_Open;	/* is there data in memory */
+
+struct Ortho_Camera_File_Ref cam_info;
+
+char *camera;
+
+/* hold the names of files etc.  mostly used by main.c */
+char *N_path;
+char *N_name;
+char *N_camera;
+
 int main(int argc, char *argv[])
 {
     static int have_old;

+ 1 - 1
imagery/i.ortho.photo/photo.elev/main.c

@@ -18,7 +18,7 @@
 /* main.c */
 
 /* read the target for the block and cast it into the alternate GRASS env */
-#define MAIN
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>

+ 6 - 12
imagery/i.ortho.photo/photo.init/globals.h

@@ -1,23 +1,17 @@
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
 #include "orthophoto.h"
 
 /* State flags  Most are Toggles */
-GLOBAL char Data_Loaded;	/* is there data in memory */
+extern  char Data_Loaded;	/* is there data in memory */
 
 				/* used for abnormal exit logic */
-GLOBAL char Files_Open;		/* is there data in memory */
+extern  char Files_Open;		/* is there data in memory */
 
-GLOBAL struct Ortho_Image_Group group;
+extern  struct Ortho_Image_Group group;
 
 /* hold the names of files etc.  mostly used by main.c */
-GLOBAL char *N_path;
-GLOBAL char *N_name;
-GLOBAL char *N_camera;
+extern  char *N_path;
+extern  char *N_name;
+extern  char *N_camera;
 
 #define DEG_TO_RADS 0.01745329
 #define RAD_TO_DEGS 57.29578

+ 11 - 1
imagery/i.ortho.photo/photo.init/main.c

@@ -17,11 +17,21 @@
  *
  *****************************************************************************/
 
-#define  MAIN  1
 #include <stdlib.h>
 #include <string.h>
 #include "globals.h"
 
+char Data_Loaded;	/* is there data in memory */
+
+			/* used for abnormal exit logic */
+char Files_Open;	/* is there data in memory */
+
+struct Ortho_Image_Group group;
+
+/* hold the names of files etc.  mostly used by main.c */
+char *N_path;
+char *N_name;
+char *N_camera;
 
 int main(int argc, char *argv[])
 {

+ 6 - 11
imagery/i.zc/main.c

@@ -19,8 +19,6 @@
  *
  *****************************************************************************/
 
-#define MAIN
-
 #include <stdlib.h>
 #include <math.h>
 #include <grass/gis.h>
@@ -45,7 +43,6 @@ int main(int argc, char *argv[])
     int size;			/* the length of one side */
     long totsize;		/* the Total number of data points */
     double *data[2];		/* Data structure containing real & complex values of FFT */
-    int save_args();		/* function to stash the command line arguments */
     struct GModule *module;
     struct Option *input_map, *output_map, *width, *threshold, *orientations;
     const char *me;
@@ -67,7 +64,6 @@ int main(int argc, char *argv[])
     input_map->multiple = NO;
     input_map->gisprompt = "old,cell,raster";
     input_map->description = _("Name of input raster map");
-#define INPUT_MAP input_map->answer
 
     output_map = G_define_option();
     output_map->key = "output";
@@ -76,7 +72,6 @@ int main(int argc, char *argv[])
     output_map->multiple = NO;
     output_map->gisprompt = "new,cell,raster";
     output_map->description = _("Zero crossing raster map");
-#define OUTPUT_MAP output_map->answer
 
     width = G_define_option();
     width->key = "width";
@@ -107,16 +102,16 @@ int main(int argc, char *argv[])
 	exit(EXIT_FAILURE);
 
     /* open input cell map */
-    if ((inmapset = G_find_cell(INPUT_MAP, "")) == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), INPUT_MAP);
+    if ((inmapset = G_find_cell(input_map->answer, "")) == NULL)
+	G_fatal_error(_("Raster map <%s> not found"), input_map->answer);
 
-    inputfd = G_open_cell_old(INPUT_MAP, inmapset);
+    inputfd = G_open_cell_old(input_map->answer, inmapset);
     if (inputfd < 0)
 	exit(EXIT_FAILURE);
 
     /* check command line args for validity */
-    if (G_legal_filename(OUTPUT_MAP) < 0)
-	G_fatal_error(_("<%s> is an illegal file name"), OUTPUT_MAP);
+    if (G_legal_filename(output_map->answer) < 0)
+	G_fatal_error(_("<%s> is an illegal file name"), output_map->answer);
 
     sscanf(threshold->answer, "%1lf", &Thresh);
     if (Thresh <= 0.0)
@@ -188,7 +183,7 @@ int main(int argc, char *argv[])
 
     /* open the output cell maps and allocate cell row buffers */
     G_message(_("Writing transformed data to file..."));
-    if ((zcfd = G_open_cell_new(OUTPUT_MAP)) < 0)
+    if ((zcfd = G_open_cell_new(output_map->answer)) < 0)
 	exit(EXIT_FAILURE);
 
     cell_row = G_allocate_cell_buf();

+ 0 - 4
include/sqlp.h

@@ -141,8 +141,4 @@ SQLPNODE *sqpNewValueNode(char *strval, int intval, double dblval, int type);
 
 void sqpFreeNode(SQLPNODE *);
 
-#ifdef SQLP_MAIN
-SQLPSTMT *sqlpStmt;
-#else
 extern SQLPSTMT *sqlpStmt;
-#endif

+ 2 - 2
lib/db/sqlp/sql.c

@@ -28,8 +28,6 @@
 *
 *****************************************************************************/
 
-#define SQLP_MAIN
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -37,6 +35,8 @@
 #include <assert.h>
 #include <grass/sqlp.h>
 
+SQLPSTMT *sqlpStmt;
+
 /* save string to value */
 int sqpSaveStr(SQLPVALUE * val, char *c)
 {

+ 3 - 4
lib/dspf/cell_table.h

@@ -1,4 +1,5 @@
-#ifdef MAIN
+#include "viz.h"
+
 CELL_ENTRY cell_table[256] = {
     {0, {0, 0, 0, 0, 0, 0, 0, 0}
      ,
@@ -2305,6 +2306,4 @@ CELL_ENTRY cell_table[256] = {
      }
     ,
 };
-#else
-extern CELL_ENTRY cell_table[256];
-#endif
+

+ 1 - 7
lib/dspf/viz.h

@@ -98,10 +98,4 @@ int print_head_info(file_info *);
 /* struct_copy.c */
 int struct_copy(char *, char *, int);
 
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
-#include "cell_table.h"
+extern CELL_ENTRY cell_table[];

+ 0 - 2
lib/proj/get_proj.c

@@ -23,8 +23,6 @@
 #include <grass/gprojects.h>
 #include <grass/glocale.h>
 
-#define MAIN
-
 /* Finder function for datum conversion lookup tables */
 #define FINDERFUNC set_proj_lib
 #define PERMANENT "PERMANENT"

+ 0 - 4
ps/ps.map/border.h

@@ -14,8 +14,4 @@ struct border
     double width;
 };
 
-#ifdef MAIN
-struct border brd;
-#else
 extern struct border brd;
-#endif

+ 0 - 4
ps/ps.map/colortable.h

@@ -21,8 +21,4 @@ struct colortable
     int range_override;
 };
 
-#ifdef MAIN
-struct colortable ct;
-#else
 extern struct colortable ct;
-#endif

+ 0 - 4
ps/ps.map/comment.h

@@ -13,8 +13,4 @@ struct comment
     int color;
 };
 
-#ifdef MAIN
-struct comment cmt;
-#else
 extern struct comment cmt;
-#endif

+ 1 - 4
ps/ps.map/decorate.h

@@ -17,8 +17,5 @@ struct scalebar
     int color, bgcolor;
 };
 
-#ifdef MAIN
-struct scalebar sb;
-#else
 extern struct scalebar sb;
-#endif
+

+ 0 - 4
ps/ps.map/group.h

@@ -11,8 +11,4 @@ struct PS_group
     int do_group;
 };
 
-#ifdef MAIN
-struct PS_group grp;
-#else
 extern struct PS_group grp;
-#endif

+ 0 - 4
ps/ps.map/header.h

@@ -14,8 +14,4 @@ struct header
     FILE *fp;
 };
 
-#ifdef MAIN
-struct header hdr;
-#else
 extern struct header hdr;
-#endif

+ 0 - 4
ps/ps.map/labels.h

@@ -9,8 +9,4 @@ struct labels
     char *other;
 };
 
-#ifdef MAIN
-struct labels labels;
-#else
 extern struct labels labels;
-#endif

+ 16 - 1
ps/ps.map/main.c

@@ -18,7 +18,6 @@
  *
  *****************************************************************************/
 
-#define MAIN
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -39,6 +38,22 @@
 #include "group.h"
 #include "local_proto.h"
 
+struct border brd;
+struct map_info m_info;
+struct labels labels;
+struct colortable ct;
+struct PS_data PS;
+int WHITE = 0;
+int BLACK = 1;
+int GREY = 9;
+int sec_draw;
+struct vector vector;
+struct header hdr;
+struct scalebar sb;
+struct comment cmt;
+struct PS_group grp;
+
+
 #define KEY(x) (strcmp(key,x)==0)
 
 FILE *tracefd;

+ 0 - 4
ps/ps.map/map_info.h

@@ -11,8 +11,4 @@ struct map_info
     int color, bgcolor, border;
 };
 
-#ifdef MAIN
-struct map_info m_info;
-#else
 extern struct map_info m_info;
-#endif

+ 1 - 8
ps/ps.map/ps_info.h

@@ -80,13 +80,6 @@ struct PS_data
 #ifdef GREY
 #undef GREY
 #endif
-#ifdef MAIN
-struct PS_data PS;
-int WHITE = 0;
-int BLACK = 1;
-int GREY = 9;
-int sec_draw;
-#else
+
 extern struct PS_data PS;
 extern int WHITE, BLACK, GREY, sec_draw;
-#endif

+ 0 - 4
ps/ps.map/vector.h

@@ -99,8 +99,4 @@ struct vector
     LAYER *layer;
 };
 
-#ifdef MAIN
-struct vector vector;
-#else
 extern struct vector vector;
-#endif

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

@@ -48,8 +48,6 @@
  * if "output" doesn't exist, but is expected (this is bad design).
  */
 
-#define MAIN
-
 #define SEGCOLSIZE 	256
 
 #include <stdlib.h>
@@ -69,6 +67,21 @@
 
 struct Cell_head window;
 
+struct variables
+{
+    char *alias;
+    int position;
+} variables[] = {
+    {"output", CUM_COST_LAYER},
+    {"input", COST_LAYER},
+    {"coor", START_PT}
+};
+
+char cum_cost_layer[64];
+char cost_layer[64];
+struct start_pt *head_start_pt = NULL;
+struct start_pt *head_end_pt = NULL;
+
 
 int main(int argc, char *argv[])
 {

+ 0 - 24
raster/r.cost/stash.h

@@ -37,35 +37,11 @@ struct start_pt
     struct start_pt *next;
 };
 
-#ifdef MAIN
-
-struct variables
-{
-    char *alias;
-    int position;
-}
-
-variables[] = {
-    {
-    "output", CUM_COST_LAYER}, {
-    "input", COST_LAYER}, {
-    "coor", START_PT}
-};
-
-char cum_cost_layer[64];
-char cost_layer[64];
-struct start_pt *head_start_pt = NULL;
-struct start_pt *head_end_pt = NULL;
-
-#else
-
 extern char cum_cost_layer[];
 extern char cost_layer[];
 extern struct start_pt *head_start_pt;
 extern struct start_pt *head_end_pt;
 
-#endif
-
 int process_answers(char **, struct start_pt **, struct start_pt **);
 int time_to_stop(int, int);
 

+ 0 - 1
raster/r.digit/main.c

@@ -17,7 +17,6 @@
  *
  ***************************************************************************/
 
-#define MAIN
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>

+ 16 - 1
raster/r.drain/tinf.c

@@ -2,9 +2,24 @@
 #include <float.h>
 #include <math.h>
 #include <grass/gis.h>
-#define TINF_MAIN
 #include "tinf.h"
 
+int (*is_null) (void *);
+void (*set_null_value) (void *, int);
+int (*bpe) ();
+void *(*get_max) (void *, void *);
+void *(*get_min) (void *, void *);
+int (*get_row) (int, void *, int);
+void *(*get_buf) ();
+int (*put_row) (int, void *);
+double (*slope) (void *, void *, double);
+void (*set_min) (void *);
+void (*set_max) (void *);
+void (*diff) (void *, void *);
+void (*sum) (void *, void *);
+void (*quot) (void *, void *);
+void (*prod) (void *, void *);
+
 /* To add a new multitype function, use the function below to initialize
  * the function pointer to each of the three typed functions.  The function
  * pointers and the function prototypes are defined in a header file.   

+ 2 - 18
raster/r.drain/tinf.h

@@ -68,23 +68,7 @@ void prod_d(void *, void *);
 
 /* to add a new multitype function, add a pointer for the function and
  * its argument list to the list below */
-#ifdef TINF_MAIN
-int (*is_null) (void *);
-void (*set_null_value) (void *, int);
-int (*bpe) ();
-void *(*get_max) (void *, void *);
-void *(*get_min) (void *, void *);
-int (*get_row) (int, void *, int);
-void *(*get_buf) ();
-int (*put_row) (int, void *);
-double (*slope) (void *, void *, double);
-void (*set_min) (void *);
-void (*set_max) (void *);
-void (*diff) (void *, void *);
-void (*sum) (void *, void *);
-void (*quot) (void *, void *);
-void (*prod) (void *, void *);
-#else
+
 extern int (*is_null) (void *);
 extern void (*set_null_value) (void *, int);
 extern int (*bpe) ();
@@ -100,7 +84,7 @@ extern void (*diff) (void *, void *);
 extern void (*sum) (void *, void *);
 extern void (*quot) (void *, void *);
 extern void (*prod) (void *, void *);
-#endif
+
 /* probably not something of general interest */
 
 double slope_c(void *, void *, double);

+ 15 - 1
raster/r.fill.dir/tinf.c

@@ -2,7 +2,6 @@
 #include <float.h>
 #include <math.h>
 #include <grass/gis.h>
-#define TINF_MAIN
 #include "tinf.h"
 
 /* To add a new multitype function, use the function below to initialize
@@ -10,6 +9,21 @@
  * pointers and the function prototypes are defined in a header file.   
  * The actual functions follow. */
 
+int (*is_null) (void *);
+int (*bpe) ();
+void *(*get_max) (void *, void *);
+void *(*get_min) (void *, void *);
+int (*get_row) (int, void *, int);
+void *(*get_buf) ();
+int (*put_row) (int, void *);
+double (*slope) (void *, void *, double);
+void (*set_min) (void *);
+void (*set_max) (void *);
+void (*diff) (void *, void *);
+void (*sum) (void *, void *);
+void (*quot) (void *, void *);
+void (*prod) (void *, void *);
+
 void set_func_pointers(int in_type)
 {
     switch (in_type) {

+ 0 - 17
raster/r.fill.dir/tinf.h

@@ -65,22 +65,6 @@ void prod_d(void *, void *);
 /* to add a new multitype function, add a pointer for the function and
  * its argument list to the list below */
 
-#ifdef TINF_MAIN
-int (*is_null) (void *);
-int (*bpe) ();
-void *(*get_max) (void *, void *);
-void *(*get_min) (void *, void *);
-int (*get_row) (int, void *, int);
-void *(*get_buf) ();
-int (*put_row) (int, void *);
-double (*slope) (void *, void *, double);
-void (*set_min) (void *);
-void (*set_max) (void *);
-void (*diff) (void *, void *);
-void (*sum) (void *, void *);
-void (*quot) (void *, void *);
-void (*prod) (void *, void *);
-#else
 extern int (*is_null) (void *);
 extern int (*bpe) ();
 extern void *(*get_max) (void *, void *);
@@ -95,7 +79,6 @@ extern void (*diff) (void *, void *);
 extern void (*sum) (void *, void *);
 extern void (*quot) (void *, void *);
 extern void (*prod) (void *, void *);
-#endif
 
 /* probably not something of general interest */
 

+ 14 - 2
raster/r.flow/calc.c

@@ -26,8 +26,6 @@
  **  Update MN: commented line 387
  */
 
-#define MAIN
-
 #include <stdlib.h>		/* for the random number generation */
 #include <time.h>
 #include <grass/gis.h>
@@ -47,6 +45,20 @@
 #define ROW	1		/* |            */
 #define COL	0		/* /            */
 
+CELL v;				/* address for segment retrieval macros */
+
+/* heap memory */
+struct Cell_head region;	/* resolution and boundaries            */
+struct Map_info fl;		/* output vector file header            */
+struct BM *bitbar;		/* space-efficient barrier matrix       */
+int lgfd;			/* output length file descriptor        */
+char string[1024];		/* space for strings                    */
+layer el, as, ds;		/* elevation, aspect, density           */
+double *ew_dist;		/* east-west distances for rows         */
+double *epsilon[2];		/* quantization errors for rows         */
+
+/* command-line parameters */
+params parm;
 
 typedef struct
 {

+ 0 - 4
raster/r.flow/mem.h

@@ -8,11 +8,7 @@
 #define SEGCOLS ((int) (region.cols/3) + 1)
 #define SEGROWS ((int)(MB/region.cols/3) <= 1 ? 1 : (int)(MB/region.cols/3))
 
-#ifdef MAIN
-CELL v;				/* address for segment retrieval macros */
-#else
 extern CELL v;
-#endif
 
 
 /*

+ 0 - 17
raster/r.flow/r.flow.h

@@ -80,22 +80,6 @@ typedef struct
 layer;
 
 /******************************* GLOBALS ********************************/
-#ifdef MAIN
-
-/* heap memory */
-struct Cell_head region;	/* resolution and boundaries            */
-struct Map_info fl;		/* output vector file header            */
-struct BM *bitbar;		/* space-efficient barrier matrix       */
-int lgfd;			/* output length file descriptor        */
-char string[1024];		/* space for strings                    */
-layer el, as, ds;		/* elevation, aspect, density           */
-double *ew_dist;		/* east-west distances for rows         */
-double *epsilon[2];		/* quantization errors for rows         */
-
-/* command-line parameters */
-params parm;
-
-#else
 
 extern struct Cell_head region;
 extern struct Map_info fl;
@@ -108,4 +92,3 @@ extern double *epsilon[2];
 
 extern params parm;
 
-#endif

+ 2 - 1
raster/r.in.gridatb/file_io.c

@@ -4,8 +4,9 @@
 #include "local_proto.h"
 
 
-void rdwr_gridatb()
+void rdwr_gridatb(void)
 {
+    char buf[1024];
     FILE *fp;
     int fd, i, j, retval;
     float idx;

+ 4 - 11
raster/r.in.gridatb/local_proto.h

@@ -6,14 +6,7 @@ int adjcellhd(struct Cell_head *cellhd);
 void rdwr_gridatb(void);
 
 
-#ifdef MAIN
-#	define	GLOBAL
-#else
-#	define	GLOBAL	extern
-#endif
-
-GLOBAL struct Cell_head cellhd;
-GLOBAL FCELL *cell;
-GLOBAL char *file;
-GLOBAL char *mapset, *oname;
-GLOBAL char buf[1024];
+extern struct Cell_head cellhd;
+extern FCELL *cell;
+extern char *file;
+extern char *mapset, *oname;

+ 5 - 2
raster/r.in.gridatb/main.c

@@ -16,13 +16,16 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#define	MAIN
 #include "local_proto.h"
-#undef	MAIN
 
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
+struct Cell_head cellhd;
+FCELL *cell;
+char *file;
+char *mapset, *oname;
+
 int main(int argc, char **argv)
 {
     struct

+ 2 - 1
raster/r.le/r.le.patch/main.c

@@ -26,9 +26,10 @@
 #include <grass/glocale.h>
 
 #include <grass/config.h>
-#define MAIN
+
 #include "patch.h"
 
+jmp_buf jmp;
 
 struct CHOICE *choice;
 

+ 0 - 4
raster/r.le/r.le.patch/patch.h

@@ -39,11 +39,7 @@
 #define  BIG   1000000000.0
 #define  PI    M_PI
 
-#ifdef MAIN
-jmp_buf jmp;
-#else
 extern jmp_buf jmp;
-#endif
 
 typedef struct __dirdesc
 {

+ 7 - 13
raster/r.los/cmd_line.h

@@ -8,16 +8,10 @@
 
 /****************************************************************/
 
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
-GLOBAL double east;
-GLOBAL double north;
-GLOBAL double obs_elev;
-GLOBAL double max_dist;
-GLOBAL char *elev_layer;
-GLOBAL char *patt_layer;
-GLOBAL char *out_layer;
+extern double east;
+extern double north;
+extern double obs_elev;
+extern double max_dist;
+extern char *elev_layer;
+extern char *patt_layer;
+extern char *out_layer;

+ 9 - 1
raster/r.los/main.c

@@ -34,7 +34,7 @@
 #include <math.h>
 #include <fcntl.h>
 #include <grass/gis.h>
-#define MAIN
+
 #include <grass/segment.h>
 #include <grass/gprojects.h>
 #include <grass/glocale.h>
@@ -50,6 +50,14 @@
 
 struct Cell_head window;	/*      database window         */
 
+double east;
+double north;
+double obs_elev;
+double max_dist;
+char *elev_layer;
+char *patt_layer;
+char *out_layer;
+
 int main(int argc, char *argv[])
 {
     int row_viewpt, col_viewpt, nrows, ncols, a, b, row, patt_flag;

+ 5 - 11
raster/r.mfilter/glob.h

@@ -1,11 +1,5 @@
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
-GLOBAL int nrows, ncols;
-GLOBAL int buflen;
-GLOBAL int direction;
-GLOBAL int zero_only;
-GLOBAL int preserve_edges;
+extern int nrows, ncols;
+extern int buflen;
+extern int direction;
+extern int zero_only;
+extern int preserve_edges;

+ 7 - 1
raster/r.mfilter/main.c

@@ -14,7 +14,7 @@
  *               for details.
  *
  *****************************************************************************/
-#define MAIN
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -23,6 +23,12 @@
 #include "filter.h"
 #include "glob.h"
 
+int nrows, ncols;
+int buflen;
+int direction;
+int zero_only;
+int preserve_edges;
+
 int main(int argc, char *argv[])
 {
     FILTER *filter;

+ 5 - 11
raster/r.out.gridatb/local_proto.h

@@ -6,14 +6,8 @@ int adjcellhd(struct Cell_head *cellhd);
 void rdwr_gridatb(void);
 
 
-#ifdef MAIN
-#	define	GLOBAL
-#else
-#	define	GLOBAL	extern
-#endif
-
-GLOBAL struct Cell_head cellhd;
-GLOBAL FCELL *cell;
-GLOBAL char *file;
-GLOBAL char *mapset, *iname;
-GLOBAL char overwr;
+extern struct Cell_head cellhd;
+extern FCELL *cell;
+extern char *file;
+extern char *mapset, *iname;
+extern char overwr;

+ 8 - 4
raster/r.out.gridatb/main.c

@@ -16,13 +16,17 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#define	MAIN
-#include "local_proto.h"
-#undef	MAIN
-
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
+#include "local_proto.h"
+
+struct Cell_head cellhd;
+FCELL *cell;
+char *file;
+char *mapset, *iname;
+char overwr;
+
 int main(int argc, char **argv)
 {
     struct

+ 0 - 5
raster/r.out.vtk/globaldefs.h

@@ -21,12 +21,7 @@
 #define TRIANGLE_STRIPS 1
 #define VERTICES 2
 
-#ifdef MAIN
-double x_extent;
-double y_extent;
-#else
 extern double x_extent;
 extern double y_extent;
-#endif
 
 #endif

+ 5 - 1
raster/r.out.vtk/main.c

@@ -23,10 +23,14 @@
 #include <grass/config.h>
 #include "writeascii.h"
 
-#define MAIN
 #include "parameters.h"
 #include "globaldefs.h"
 
+paramType param;		/*Parameters */
+
+double x_extent;
+double y_extent;
+
 /*local protos */
 static void check_input_maps(void);
 

+ 3 - 5
raster/r.out.vtk/parameters.h

@@ -28,13 +28,11 @@ typedef struct
 } paramType;
 
 /*global structs */
-#ifdef MAIN
-paramType param;		/*Parameters */
-#else
+
 extern paramType param;		/*Parameters */
-#endif
+
 
 /*prototype */
-void set_params();
+void set_params(void);
 
 #endif

+ 21 - 29
raster/r.param.scale/main.c

@@ -12,53 +12,45 @@
  *
  *****************************************************************************/
 
-#define MAIN
-
 #include <grass/glocale.h>
 #include "param.h"
 
-int main(int argc, char **argv)
-{
-
-    /*--------------------------------------------------------------------------*/
-    /*                                 INITIALISE                               */
+char
+ *rast_in_name,			/* Name of the raster file to process.  */
+ *rast_out_name,		/* Name of the raster output file.      */
+ *mapset_in,			/* If no problems, these will be names  */
+ *mapset_out,			/* of mapsets containing the files to   */
+				/* be processed. Otherwise, error code. */
+  constrained;			/* Flag that forces quadtratic through  */
 
-    /*--------------------------------------------------------------------------*/
+				/* the central cell of the window.      */
 
+int
+  fd_in,			/* File descriptor for input and        */
+  fd_out,			/* output raster files.                 */
+  wsize,			/* Size of local processing window.     */
+  mparam;			/* Morphometric parameter to calculate. */
 
 
-    /*--------------------------------------------------------------------------*/
-    /*                               GET INPUT FROM USER                        */
-
-    /*--------------------------------------------------------------------------*/
+double
+  resoln,			/* Planimetric resolution.              */
+  exponent,			/* Distance weighting exponent.         */
+  zscale,			/* Vertical scaling factor.             */
+  slope_tol,			/* Vertical tolerences for surface      */
+  curve_tol;			/* feature identification.              */
 
+int main(int argc, char **argv)
+{
     interface(argc, argv);
 
-
-    /*--------------------------------------------------------------------------*/
-    /*                        OPEN INPUT AND OUTPUT RASTER FILES                */
-
-    /*--------------------------------------------------------------------------*/
-
     /* Make sure that the current projection is not lat/long */
     if ((G_projection() == PROJECTION_LL))
 	G_fatal_error(_("Lat/Long location is not supported"));
 
     open_files();
 
-
-    /*--------------------------------------------------------------------------*/
-    /*                       PROCESS SURFACE FOR FEATURE DETECTION              */
-
-    /*--------------------------------------------------------------------------*/
-
     process();
 
-    /*--------------------------------------------------------------------------*/
-    /*                     CLOSE ALL OPENED FILES AND FREE MEMORY               */
-
-    /*--------------------------------------------------------------------------*/
-
     close_down();
 
     if (mparam == FEATURE) {

+ 6 - 12
raster/r.param.scale/param.h

@@ -81,10 +81,8 @@ DCELL feature(double *coeff);	/* Set of six quadratic coefficents.    */
 
 /* ------ Global variables ------ */
 
-#ifndef MAIN
-extern				/* Externally defined if not main()     */
-#endif
- char *rast_in_name,		/* Name of the raster file to process.  */
+extern char
+ *rast_in_name,			/* Name of the raster file to process.  */
  *rast_out_name,		/* Name of the raster output file.      */
  *mapset_in,			/* If no problems, these will be names  */
  *mapset_out,			/* of mapsets containing the files to   */
@@ -93,19 +91,15 @@ extern				/* Externally defined if not main()     */
 
 				/* the central cell of the window.      */
 
-#ifndef MAIN
-extern				/* Externally defined if not main()     */
-#endif
- int fd_in,			/* File descriptor for input and        */
+extern int
+  fd_in,			/* File descriptor for input and        */
   fd_out,			/* output raster files.                 */
   wsize,			/* Size of local processing window.     */
   mparam;			/* Morphometric parameter to calculate. */
 
 
-#ifndef MAIN
-extern				/* Externally defined if not main()     */
-#endif
- double resoln,			/* Planimetric resolution.              */
+extern double
+  resoln,			/* Planimetric resolution.              */
   exponent,			/* Distance weighting exponent.         */
   zscale,			/* Vertical scaling factor.             */
   slope_tol,			/* Vertical tolerences for surface      */

+ 0 - 1
raster/r.random.cells/gasdev.c

@@ -3,7 +3,6 @@
 #undef TRACE
 #undef DEBUG
 
-#undef MAIN
 #include <math.h>
 #include "ransurf.h"
 #include "local_proto.h"

+ 0 - 1
raster/r.random.cells/indep.c

@@ -3,7 +3,6 @@
 #undef TRACE
 #undef DEBUG
 
-#undef MAIN
 #include <grass/gis.h>
 #include "ransurf.h"
 

+ 0 - 0
raster/r.random.cells/init.c


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio