Debian Codegraph @

reports/bury.c

raw
1 /* bury.c.
2 Written 1999, Dennis Nicklaus, [email protected]
3 This program is used as a filter to help format the output of the
4 Lifelines report called "burial_index".
5 This program makes it so each cemetery name only appears once, with
6 the list of people buried in that cemetery listed below it.
7 You can compile this simply with:
8 cc -o bury bury.c
9 To use this, first run the burial index program, then run the
10 output of that through Unix's sort (just default arguments to sort),
11 then run it through this program. Suppose your output from burial
12 index is called "iowa.txt".
13 What I typically do is:
14 sort iowa.txt | bury > iowa.sort
15
16 How it works: It just compares each "cemetery name" with the previous one
17 in the file. If the cemetery name is different, it begins a new heading
18 for that cemetery, and lists under it each name that follows with the
19 same cemetery name. That's why it's important to run through sort, first.
20 For MY typical record, which looks like
21 1 NAME First /Last/
22 1 BIRT
23 2 DATE 31 Dec 1900
24 1 DEAT
25 2 DATE 1 Jan 2000
26 1 BURI
27 2 PLAC town,county,state
28 3 ADDR cemeteryname
29 The lifelines report burial_index produces a line which looks like:
30
31 town,cemetery : Last, First (1900-2000)
32
33 Since I generally make a index for a town, county, or state, running
34 sort with default (no) parameters works for me.
35 These sorted lines are the input to this program.
36 */
37
38 #include <stdio.h>
39 char getline (char *line)
40 {
41 char c;
42 int in=0;
43 c=getchar();
44 while ((c != '\n') && (c != EOF)){
45 line[in++] = c;
46 c=getchar();
47 }
48 line[in]=0;
49 return c;
50 }
51 main()
52 {
53 char line[200],last[200],*name;
54 int colon,in,maxcompare;
55 while(getline(line) != EOF){
56 colon = strcspn(line,":");
57 maxcompare = strlen(last);
58 if (colon > maxcompare) maxcompare = colon;
59 if (strncmp(line,last,maxcompare)){ /* then they are different */
60 strncpy(last,line,colon);
61 last[colon] = '\0';
62 printf("\n\t\t\t%s\n",last);
63 }
64 name = line+colon+1;
65 printf("%s\n",name);
66 }
67 }
68 /* Sample output after going through bury.c:
69 Carlisle, Carlisle Cemetery
70 Morgan, Chester Howell (1889-1900)
71 Morgan, Elmer Eugene (1861-1931)
72 Morgan, nee Dressler, Mary Alice (1861-1950)
73
74 Carroll
75 Walden, nee Lucey, Kathleen J. ``Kay'' (1918-1996)
76
77 Carroll, Mt. Olivet Cemetery
78 Foley, George (1878-1948)
79 Foley, nee Cuddy, Mary Cornelia (1885-1972)
80 Hamill, Robert J. (1872-1953)
81 Hamill, nee Lucey, Jennie Frances (1874-1940)
82 Lucey, Edward J. (1849-1922)
83 Lucey, George Raymond (1884-1971)
84 Lucey, Rosemary (1920-1951)
85 Lucey, nee Kemp, Clara Catherine (1887-1969)
86 Lucey, Jeremiah ``Jerry'' (1886-1914)
87 Lucey, John (1883-1914)
88 Lucey, Julia (-1914)
89 Lucey, Margaret (-1914)
90 Lucey, nee Grace, Mary Elizabeth (1856-1914)
91
92 */