| 1 |
/* |
| 2 |
* @progname tools.li |
| 3 |
* @version none |
| 4 |
* @author anon |
| 5 |
* @category |
| 6 |
* @output string and event function values |
| 7 |
* @description |
| 8 |
* |
| 9 |
* a library providing lifelines database tools, bapt() and get_picture(). |
| 10 |
|
| 11 |
NODE func bapt(INDI) - scans for both BAPL and BAPM (unlike baptism() builtin) |
| 12 |
STRING func get_picture(INDI) - finds an image file name |
| 13 |
|
| 14 |
*/ |
| 15 |
|
| 16 |
|
| 17 |
func bapt (indi) { |
| 18 |
fornodes(inode(indi), node) { |
| 19 |
if (eq(0, strcmp(tag(node), "BAPL"))) { |
| 20 |
return(node) |
| 21 |
} |
| 22 |
if (eq(0, strcmp(tag(node), "BAPM"))) { |
| 23 |
return(node) |
| 24 |
} |
| 25 |
} |
| 26 |
return(0) |
| 27 |
} |
| 28 |
|
| 29 |
func get_picture (indi) { |
| 30 |
/* Note: this code assumes a tag structure I use to represent |
| 31 |
external files. It looks like: |
| 32 |
|
| 33 |
1 EXTL |
| 34 |
2 FILE pics/scott.gif |
| 35 |
2 FORM GIF |
| 36 |
2 DATE Jul 1989 |
| 37 |
1 EXTL |
| 38 |
2 URL http://www.intele.net/~toddm/toddpic.gif |
| 39 |
2 FORM GIF |
| 40 |
|
| 41 |
where the first defines an external file stored on the same file |
| 42 |
system and gives the path in the FILE record and the type in the |
| 43 |
FORM record. The second defines an external file stored on another |
| 44 |
site and provides a URL for referencing it. I have proposed this as |
| 45 |
an extension to GEDCOM, but nobody said very much. |
| 46 |
*/ |
| 47 |
|
| 48 |
set(found, 0) |
| 49 |
set(path, "") |
| 50 |
fornodes(inode(indi), node) { |
| 51 |
if (not(strcmp("EXTL", tag(node)))) { |
| 52 |
set(m, child(node)) |
| 53 |
if (not(strcmp("FILE", tag(m)))) { /* files on local system */ |
| 54 |
set(path, value(m)) |
| 55 |
set(o, sibling(m)) |
| 56 |
if (not(strcmp("FORM", tag(o)))) { |
| 57 |
if (not(strcmp("GIF", value(o)))) { |
| 58 |
set(found, 1) |
| 59 |
} |
| 60 |
elsif (not (strcmp("JPEG", value(o)))) { |
| 61 |
set(found, 1) |
| 62 |
} |
| 63 |
} |
| 64 |
} |
| 65 |
else{ |
| 66 |
if(not(strcmp("URL", tag(m)))) { /* files on remote system */ |
| 67 |
set(path, value(m)) |
| 68 |
set(o, sibling(m)) |
| 69 |
if (not(strcmp("FORM", tag(o)))) { |
| 70 |
if (not(strcmp("GIF", value(o)))) { |
| 71 |
set(found, 1) |
| 72 |
} |
| 73 |
elsif (not (strcmp("JPEG", value(o)))) { |
| 74 |
set(found, 1) |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
return(path) |
| 82 |
} |
| 83 |
|