File: tools.li

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (83 lines) | stat: -rw-r--r-- 2,115 bytes parent folder | download | duplicates (5)
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
/*
 * @progname       tools.li
 * @version        none
 * @author         anon
 * @category       
 * @output         string and event function values
 * @description    
 *
 * a library providing lifelines database tools, bapt() and get_picture().

NODE func bapt(INDI) - scans for both BAPL and BAPM (unlike baptism() builtin)
STRING func get_picture(INDI) - finds an image file name

*/


func bapt (indi) {
  fornodes(inode(indi), node) {
    if (eq(0, strcmp(tag(node), "BAPL"))) {
      return(node)
    }
    if (eq(0, strcmp(tag(node), "BAPM"))) {
      return(node)
    }
  }
  return(0)
}

func get_picture (indi) {
/* Note: this code assumes a tag structure I use to represent
   external files. It looks like:

1 EXTL
  2 FILE pics/scott.gif
  2 FORM GIF
  2 DATE Jul 1989
1 EXTL
  2 URL http://www.intele.net/~toddm/toddpic.gif
  2 FORM GIF

   where the first defines an external file stored on the same file
   system and gives the path in the FILE record and the type in the
   FORM record. The second defines an external file stored on another
   site and provides a URL for referencing it. I have proposed this as
   an extension to GEDCOM, but nobody said very much.
*/

  set(found, 0)
  set(path, "")
  fornodes(inode(indi), node) {
    if (not(strcmp("EXTL", tag(node)))) {
      set(m, child(node))
      if (not(strcmp("FILE", tag(m)))) {    /* files on local system */
        set(path, value(m))
        set(o, sibling(m))
        if (not(strcmp("FORM", tag(o)))) {
          if (not(strcmp("GIF", value(o)))) {
            set(found, 1)
          }
          elsif (not (strcmp("JPEG", value(o)))) {
            set(found, 1)
          }
        }
      }
      else{
       if(not(strcmp("URL", tag(m)))) {     /* files on remote system */
          set(path, value(m))
          set(o, sibling(m))
          if (not(strcmp("FORM", tag(o)))) {
            if (not(strcmp("GIF", value(o)))) {
              set(found, 1)
            }
            elsif (not (strcmp("JPEG", value(o)))) {
              set(found, 1)
            }
          }
        }
      }
    }
  }
  return(path)
}