source: tags/svn.1.5.4/ARBDB/adlink.cxx

Last change on this file was 6366, checked in by westram, 15 years ago
  • fixed whitespace (scripted)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : adlink.cxx                                        //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include "gb_main.h"
12#include "gb_data.h"
13
14GBDATA *GB_follow_link(GBDATA *gb_link) {
15    char *s;
16    const char *link;
17    char c;
18    GB_MAIN_TYPE *Main = GB_MAIN(gb_link);
19    GBDATA *result;
20    GB_Link_Follower lf;
21    link = (char *)GB_read_link_pntr(gb_link);
22    if (!link) return 0;
23    s = const_cast<char*>(strchr(link, ':'));
24    if (!s) {
25        GB_export_errorf("Your link '%s' does not contain a ':' character", link);
26        return 0;
27    }
28    c = *s;
29    *s = 0;
30    lf = (GB_Link_Follower)GBS_read_hash(Main->resolve_link_hash, link);
31    *s = c;
32    if (!lf) {
33        GB_export_errorf("Your link tag '%s' is unknown to the system", link);
34        return 0;
35    }
36    result = lf(GB_get_root(gb_link), gb_link, s+1);
37    return result;
38}
39
40
41GB_ERROR GB_install_link_follower(GBDATA *gb_main, const char *link_type, GB_Link_Follower link_follower) {
42    GB_ERROR error = 0;
43    GB_MAIN_TYPE *Main = GB_MAIN(gb_main);
44    if (!Main->resolve_link_hash) {
45        Main->resolve_link_hash = GBS_create_hash(256, GB_MIND_CASE);
46    }
47    error = GB_check_link_name(link_type);
48    if (error) return error;
49    GBS_write_hash(Main->resolve_link_hash, link_type, (long)link_follower);
50    return 0;
51}
Note: See TracBrowser for help on using the repository browser.