Debian Codegraph @

reports/gedall.ll

raw
1 /*
2 * @progname gedall.ll
3 * @version 2000-02-20
4 * @author Paul B. McBride ([email protected])
5 * @category
6 * @output GEDCOM
7 * @description
8 *
9 * This LifeLines report program produces a GEDCOM file containing
10 * the entire LifeLines database, including header, trailer, and
11 * submitter records. It also gives the option to keep or remove user defined
12 * tags, and to remove any other tags.
13 *
14 * modified Sep 2005 to use getproperties to automatically generate the header
15 * by Stephen Dum [email protected]
16 *
17 * The default action is to remove all user defined tags. These are tags
18 * which begin with an underscore, "_", character.
19 *
20 * When a tag line is removed, lines following it with higher level
21 * numbers are also removed.
22 *
23 * This report program may require LifeLines 3.0.3 or later.
24 *
25 * The gedcom header is generated in main() using property's
26 * obtained from the lifelines config file (~/.linesrc on unix else
27 * lines.cfg - or from properties set in the database) with values from
28 * the user defined properties
29 * user.fullname
30 * user.email
31 * user.address
32 *
33 * This report program was tested on databases created from the Test Book
34 * sample GEDCOM files at http://www.gentech.org
35 *
36 * 20 Feb 2000 Paul B. McBride ([email protected])
37 */
38
39 global(REMOVEUSERTAGS)
40 global(REMOVELISTEDTAGS)
41 global(REMOVETAG_LIST)
42
43 global(removed_line_count)
44 global(removed_udt_count)
45
46 proc main ()
47 {
48 list(REMOVETAG_LIST) /* list of tags to be removed */
49 set(REMOVELISTEDTAGS, 0) /* set to 1 if there are tags to be removed */
50 set(REMOVEUSERTAGS, askyn("Remove user defined tags (_*)"))
51 set(removed_udt_count, 0)
52 set(removed_line_count, 0)
53
54 while(1) {
55 getstrmsg(remtag, "Enter any other tag to be removed")
56 if(gt(strlen(remtag),0)) {
57 set(REMOVELISTEDTAGS, 1)
58 enqueue(REMOVETAG_LIST, remtag)
59 }
60 else { break() }
61 }
62
63 /* header file */
64 "0 HEAD " nl()
65 "1 SOUR LIFELINES" nl()
66 "2 VERS " version() nl()
67 "2 NAME LifeLines" nl()
68 /*
69 "2 CORP ... " nl()
70 "3 ADDR .... " nl()
71 */
72 "1 SUBM @SM1@" nl()
73 "1 GEDC " nl()
74 "2 VERS 5.5" nl()
75 "2 FORM Lineage-Linked" nl()
76 "1 CHAR ASCII" nl()
77 "1 DATE " stddate(gettoday()) nl()
78 /* and referenced submitter */
79 "0 @SM1@ SUBM" nl()
80 "1 NAME " getproperty("user.fullname") nl()
81 "1 ADDR " getproperty("user.address") nl()
82 "2 CONT E-mail: " getproperty("user.email") nl()
83
84 set(icnt, 0)
85 forindi(p, n) {
86 call ged_write_node(root(p))
87 set(icnt, add(icnt,1))
88 }
89 print(d(icnt), " INDI records (I*)...\n")
90 set(fcnt, 0)
91 forfam(f, n) {
92 call ged_write_node(root(f))
93 set(fcnt, add(fcnt,1))
94 }
95 print(d(fcnt), " FAM records (F*)...\n")
96 set(ecnt, 0)
97 foreven(e, n) {
98 call ged_write_node(root(e))
99 set(ecnt, add(ecnt,1))
100 }
101 print(d(ecnt), " EVEN records (E*)...\n")
102 set(scnt, 0)
103 forsour(s, n) {
104 call ged_write_node(root(s))
105 set(scnt, add(scnt,1))
106 }
107 print(d(scnt), " SOUR records (S*)...\n")
108 set(ocnt, 0)
109 forothr(o, n) {
110 call ged_write_node(root(o))
111 set(ocnt, add(ocnt,1))
112 }
113 print(d(ocnt), " other level 0 records (X*)\n")
114
115 if(gt(removed_udt_count, 0)) {
116 print(d(removed_udt_count), " user defined tag structures were removed.\n")
117 }
118 if(gt(removed_line_count, 0)) {
119 print(d(removed_line_count), " lines were removed, as requested.\n")
120 }
121
122 "0 TRLR" nl() /* trailer */
123 }
124
125 proc ged_write_node(n)
126 {
127 set(remlevel, 10000) /* this value is larger than the largest level number */
128 traverse(n, m, level) {
129 if(le(level, remlevel)) {
130 set(remlevel, 10000) /* end of previous tag removal if any */
131 if(REMOVEUSERTAGS) {
132 if(t, tag(m)) {
133 if(eqstr(trim(t, 1), "_")) {
134 set(remlevel, level) /* remove line, and subordinate tag lines */
135 set(removed_udt_count, add(removed_udt_count, 1))
136 }
137 }
138 }
139 }
140 if(lt(level, remlevel)) {
141 if(REMOVELISTEDTAGS) {
142 if(t, tag(m)) {
143 forlist(REMOVETAG_LIST, rt, n) {
144 if(eqstr(t, rt)) {
145 set(remlevel, level)
146 break()
147 }
148 }
149 }
150 }
151 }
152 if(lt(level, remlevel)) {
153 /* output this line to the GEDCOM file */
154 d(level)
155 if (xref(m)) { " " xref(m) }
156 " " tag(m)
157 if (v, value(m)) {
158 " " v
159 }
160 "\n"
161 }
162 else {
163 set(removed_line_count, add(removed_line_count, 1))
164 }
165 }
166 }
167
168 func askyn(msg)
169 {
170 set(prompt, concat(msg, "? [y/n] "))
171 getstrmsg(str, prompt)
172 if(and(gt(strlen(str), 0),
173 or(eq(strcmp(str, "n"),0), eq(strcmp(str, "N"),0)))) {
174 return(0)
175 }
176 return(1)
177 }