1 #include <string.h>
2 #include <grass/raster.h>
3 #include <grass/glocale.h>
4 #include "kappa.h"
5 #include "local_proto.h"
6 
7 
prn_header(void)8 void prn_header(void)
9 {
10     int i, len;
11     char buf[1024], *titles, *label;
12     char *mask;
13     FILE *fd;
14 
15     if (output == NULL)
16 	fd = stdout;
17     else if ((fd = fopen(output, "w")) == NULL) {
18 	G_fatal_error(_("Cannot open file <%s> to write header"), output);
19 	return;
20     }
21 
22     /* print header */
23     fprintf(fd, "\t\t\t%s\n", title);
24     sprintf(buf, "LOCATION: %s\t\t\t\t%s", G_location(), G_date());
25     fprintf(fd, "%s\n", buf);
26     if ((mask = maskinfo()))
27 	sprintf(buf, "MASK: %s", mask);
28 
29     fprintf(fd, "%s\n", buf);
30     fprintf(fd, "MAPS: ");
31     label = "MAP";
32     len = strlen(label);
33 
34     for (i = 0; i < nlayers; i++) {
35 	titles = Rast_get_cats_title(&(layers[i].labels));
36 	if (titles)
37 	    G_strip(titles);
38 	if (titles == NULL || *titles == 0)
39 	    titles = "(untitled)";
40 	sprintf(buf, "%*s%-*s%d = %s (%s in %s)", i * 6, "", len, label,
41 		i + 1, titles, layers[i].name, layers[i].mapset);
42 	fprintf(fd, "%s\n", buf);
43     }
44 
45     if (output != NULL)
46 	fclose(fd);
47 }
48