File: edit_hist.c

package info (click to toggle)
grass 6.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 104,028 kB
  • ctags: 40,409
  • sloc: ansic: 419,980; python: 63,559; tcl: 46,692; cpp: 29,791; sh: 18,564; makefile: 7,000; xml: 3,505; yacc: 561; perl: 559; lex: 480; sed: 70; objc: 7
file content (145 lines) | stat: -rw-r--r-- 4,584 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

/****************************************************************************
 *
 * MODULE:       edit library functions
 * AUTHOR(S):    Originally part of gis lib dir in CERL GRASS code
 *               Subsequent (post-CVS) contributors:
 *               Glynn Clements <glynn gclements.plus.com>,
 *               Radim Blazek <radim.blazek gmail.com>,
 *               Eric G. Miller <egm2 jps.net>,
 *               Markus Neteler <neteler itc.it>,
 *               Brad Douglas <rez touchofmadness.com>,
 *               Bernhard Reiter <bernhard intevation.de>
 * PURPOSE:      libraries for interactively editing raster support data
 * COPYRIGHT:    (C) 1996-2006 by the GRASS Development Team
 *
 *               This program is free software under the GNU General Public
 *               License (>=v2). Read the file COPYING that comes with GRASS
 *               for details.
 *
 *****************************************************************************/
/*
 **********************************************************************
 *
 *   E_edit_history (hist)
 *      struct History *hist 
 *
 *   Interactively prompts the user for history information.
 *   Uses screen oriented prompting through the visual_ask library.
 *   Programs using this must be compiled with the GRASS library $(VASKLIB)
 *   and include $(CURSES) in the compile line
 *
 *   Returns: 1 ok
 *           -1 user canceled edit
 *
 **********************************************************************/

#include <grass/gis.h>
#include <grass/vask.h>
#include <grass/edit.h>

int E_edit_history(struct History *phist)
{
    int len;
    int i;

    if (!*phist->mapid)
	sprintf(phist->mapid, "%s : %s", G_date(), "filename");
    if (!*phist->title)
	sprintf(phist->title, "%s", "filename");
    if (!*phist->mapset)
	sprintf(phist->mapset, "%s", G_mapset());
    if (!*phist->creator)
	sprintf(phist->creator, "%s", G_whoami());
    if (!*phist->maptype)
	sprintf(phist->maptype, "raster");

    V_clear();
    V_line(0, "		 ENTER/CORRECT FILE HISTORY INFORMATION");
    V_line(2, "Map ID ...");
    V_line(4, "Title ....");
    V_line(6, "Project ..");
    V_line(8, "Creator ..");
    V_line(10, "Maptype ..");
    V_line(12, "Data source");
    V_line(16, "Data Description");
    V_line(19, "For history comments see next page");

    len = RECORD_LEN - 1;
    if (len > 65)
	len = 65;
    phist->mapid[len] = 0;
    phist->title[len] = 0;
    phist->mapset[len] = 0;
    phist->creator[len] = 0;
    phist->maptype[len] = 0;
    len--;

    V_const(phist->mapid, 's', 2, 11, len);
    V_ques(phist->title, 's', 4, 11, len);
    V_const(phist->mapset, 's', 6, 11, len);
    V_const(phist->creator, 's', 8, 11, len);
    V_ques(phist->maptype, 's', 10, 11, len);

    phist->datsrc_1[len] = 0;
    phist->datsrc_2[len] = 0;
    phist->keywrd[len] = 0;
    len--;

    V_ques(phist->datsrc_1, 's', 13, 0, len);
    V_ques(phist->datsrc_2, 's', 14, 0, len);
    V_ques(phist->keywrd, 's', 17, 0, len);

    V_intrpt_ok();
    if (!V_call())
	return -1;

    G_strip(phist->title);
    G_strip(phist->maptype);
    G_strip(phist->datsrc_1);
    G_strip(phist->datsrc_2);
    G_strip(phist->keywrd);

    V_clear();
    V_line(0, "		 ENTER/CORRECT FILE HISTORY COMMENTS");
    V_ques(phist->edhist[0], 's', 2, 0, len);
    V_ques(phist->edhist[1], 's', 3, 0, len);
    V_ques(phist->edhist[2], 's', 4, 0, len);
    V_ques(phist->edhist[3], 's', 5, 0, len);
    V_ques(phist->edhist[4], 's', 6, 0, len);
    V_ques(phist->edhist[5], 's', 7, 0, len);
    V_ques(phist->edhist[6], 's', 8, 0, len);
    V_ques(phist->edhist[7], 's', 9, 0, len);
    V_ques(phist->edhist[8], 's', 10, 0, len);
    V_ques(phist->edhist[9], 's', 11, 0, len);
    V_ques(phist->edhist[10], 's', 12, 0, len);
    V_ques(phist->edhist[11], 's', 13, 0, len);
    V_ques(phist->edhist[12], 's', 14, 0, len);
    V_ques(phist->edhist[13], 's', 15, 0, len);
    V_ques(phist->edhist[14], 's', 16, 0, len);
    V_ques(phist->edhist[15], 's', 17, 0, len);
    V_ques(phist->edhist[16], 's', 18, 0, len);
    V_ques(phist->edhist[17], 's', 19, 0, len);
    V_ques(phist->edhist[18], 's', 20, 0, len);
    V_ques(phist->edhist[19], 's', 21, 0, 65);

    len++;
    for (i = 0; i <= 19; i++)
	phist->edhist[i][len] = 0;

    V_intrpt_ok();
    if (!V_call())
	return -1;

    for (i = 0; i <= 19; i++)
	G_strip(phist->edhist[i]);

    for (phist->edlinecnt = 19; phist->edlinecnt > 0; phist->edlinecnt--) {
	if (*phist->edhist[phist->edlinecnt] != 0)
	    break;
    }
    phist->edlinecnt++;
    V_clear();

    return (1);
}