GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
edit_hist.c
Go to the documentation of this file.
1 
2 /****************************************************************************
3  *
4  * MODULE: edit library functions
5  * AUTHOR(S): Originally part of gis lib dir in CERL GRASS code
6  * Subsequent (post-CVS) contributors:
7  * Glynn Clements <glynn gclements.plus.com>,
8  * Radim Blazek <radim.blazek gmail.com>,
9  * Eric G. Miller <egm2 jps.net>,
10  * Markus Neteler <neteler itc.it>,
11  * Brad Douglas <rez touchofmadness.com>,
12  * Bernhard Reiter <bernhard intevation.de>
13  * PURPOSE: libraries for interactively editing raster support data
14  * COPYRIGHT: (C) 1996-2006 by the GRASS Development Team
15  *
16  * This program is free software under the GNU General Public
17  * License (>=v2). Read the file COPYING that comes with GRASS
18  * for details.
19  *
20  *****************************************************************************/
21 /*
22  **********************************************************************
23  *
24  * E_edit_history (hist)
25  * struct History *hist
26  *
27  * Interactively prompts the user for history information.
28  * Uses screen oriented prompting through the visual_ask library.
29  * Programs using this must be compiled with the GRASS library $(VASKLIB)
30  * and include $(CURSES) in the compile line
31  *
32  * Returns: 1 ok
33  * -1 user canceled edit
34  *
35  **********************************************************************/
36 
37 #include <grass/gis.h>
38 #include <grass/vask.h>
39 #include <grass/edit.h>
40 
41 int E_edit_history(struct History *phist)
42 {
43  int len;
44  int i;
45 
46  if (!*phist->mapid)
47  sprintf(phist->mapid, "%s : %s", G_date(), "filename");
48  if (!*phist->title)
49  sprintf(phist->title, "%s", "filename");
50  if (!*phist->mapset)
51  sprintf(phist->mapset, "%s", G_mapset());
52  if (!*phist->creator)
53  sprintf(phist->creator, "%s", G_whoami());
54  if (!*phist->maptype)
55  sprintf(phist->maptype, "raster");
56 
57  V_clear();
58  V_line(0, " ENTER/CORRECT FILE HISTORY INFORMATION");
59  V_line(2, "Map ID ...");
60  V_line(4, "Title ....");
61  V_line(6, "Project ..");
62  V_line(8, "Creator ..");
63  V_line(10, "Maptype ..");
64  V_line(12, "Data source");
65  V_line(16, "Data Description");
66  V_line(19, "For history comments see next page");
67 
68  len = RECORD_LEN - 1;
69  if (len > 65)
70  len = 65;
71  phist->mapid[len] = 0;
72  phist->title[len] = 0;
73  phist->mapset[len] = 0;
74  phist->creator[len] = 0;
75  phist->maptype[len] = 0;
76  len--;
77 
78  V_const(phist->mapid, 's', 2, 11, len);
79  V_ques(phist->title, 's', 4, 11, len);
80  V_const(phist->mapset, 's', 6, 11, len);
81  V_const(phist->creator, 's', 8, 11, len);
82  V_ques(phist->maptype, 's', 10, 11, len);
83 
84  phist->datsrc_1[len] = 0;
85  phist->datsrc_2[len] = 0;
86  phist->keywrd[len] = 0;
87  len--;
88 
89  V_ques(phist->datsrc_1, 's', 13, 0, len);
90  V_ques(phist->datsrc_2, 's', 14, 0, len);
91  V_ques(phist->keywrd, 's', 17, 0, len);
92 
93  V_intrpt_ok();
94  if (!V_call())
95  return -1;
96 
97  G_strip(phist->title);
98  G_strip(phist->maptype);
99  G_strip(phist->datsrc_1);
100  G_strip(phist->datsrc_2);
101  G_strip(phist->keywrd);
102 
103  V_clear();
104  V_line(0, " ENTER/CORRECT FILE HISTORY COMMENTS");
105  V_ques(phist->edhist[0], 's', 2, 0, len);
106  V_ques(phist->edhist[1], 's', 3, 0, len);
107  V_ques(phist->edhist[2], 's', 4, 0, len);
108  V_ques(phist->edhist[3], 's', 5, 0, len);
109  V_ques(phist->edhist[4], 's', 6, 0, len);
110  V_ques(phist->edhist[5], 's', 7, 0, len);
111  V_ques(phist->edhist[6], 's', 8, 0, len);
112  V_ques(phist->edhist[7], 's', 9, 0, len);
113  V_ques(phist->edhist[8], 's', 10, 0, len);
114  V_ques(phist->edhist[9], 's', 11, 0, len);
115  V_ques(phist->edhist[10], 's', 12, 0, len);
116  V_ques(phist->edhist[11], 's', 13, 0, len);
117  V_ques(phist->edhist[12], 's', 14, 0, len);
118  V_ques(phist->edhist[13], 's', 15, 0, len);
119  V_ques(phist->edhist[14], 's', 16, 0, len);
120  V_ques(phist->edhist[15], 's', 17, 0, len);
121  V_ques(phist->edhist[16], 's', 18, 0, len);
122  V_ques(phist->edhist[17], 's', 19, 0, len);
123  V_ques(phist->edhist[18], 's', 20, 0, len);
124  V_ques(phist->edhist[19], 's', 21, 0, 65);
125 
126  len++;
127  for (i = 0; i <= 19; i++)
128  phist->edhist[i][len] = 0;
129 
130  V_intrpt_ok();
131  if (!V_call())
132  return -1;
133 
134  for (i = 0; i <= 19; i++)
135  G_strip(phist->edhist[i]);
136 
137  for (phist->edlinecnt = 19; phist->edlinecnt > 0; phist->edlinecnt--) {
138  if (*phist->edhist[phist->edlinecnt] != 0)
139  break;
140  }
141  phist->edlinecnt++;
142  V_clear();
143 
144  return (1);
145 }
char * G_mapset(void)
current mapset name
Definition: mapset.c:31
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void V_clear(void)
Zero out prompt and answer arrays.
Definition: V_clear.c:44
int V_line(int linenumber, const char *text)
Definition: V_line.c:50
int V_call(void)
Interact with the user.
Definition: V_call.c:149
int G_strip(char *buf)
Removes all leading and trailing white space from string.
Definition: strings.c:389
char * G_whoami(void)
Gets user&#39;s name.
Definition: gis/whoami.c:40
int V_const(void *src, int var_type, int row, int col, int length)
Definition: V_const.c:51
int E_edit_history(struct History *phist)
Definition: edit_hist.c:41
char * G_date(void)
Current date and time.
Definition: date.c:30
int V_ques(void *src, int var_type, int row, int col, int length)
Definition: V_ques.c:80
void V_intrpt_ok(void)
Allow CTRL-C.
Definition: V_call.c:455