/[hurd]/hurd/libstore/typed.c
ViewVC logotype

Diff of /hurd/libstore/typed.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by marcus, Sat Aug 2 22:02:03 2003 UTC revision 1.8 by roland, Mon Aug 4 18:05:21 2003 UTC
# Line 1  Line 1 
1  /* Support for opening `typed' stores  /* Support for opening `typed' stores
2    
3     Copyright (C) 1997,98,2001,02,03 Free Software Foundation, Inc.     Copyright (C) 1997,1998,2001,2002,2003 Free Software Foundation, Inc.
4     Written by Miles Bader <miles@gnu.org>     Written by Miles Bader <miles@gnu.org>
5    
6     This file is part of the GNU Hurd.     This file is part of the GNU Hurd.
# Line 64  store_find_class (const char *name, cons Line 64  store_find_class (const char *name, cons
64       and examine each one's "store_std_classes" section.  */       and examine each one's "store_std_classes" section.  */
65  # pragma weak _r_debug  # pragma weak _r_debug
66  # pragma weak dlsym  # pragma weak dlsym
67    # pragma weak dlopen
68    # pragma weak dlclose
69  # pragma weak dlerror  # pragma weak dlerror
70    if (dlsym)    if (dlsym)
71      {      {
72        struct link_map *map;        struct link_map *map;
73        for (map = _r_debug.r_map; map != 0; map = map->l_next)        for (map = _r_debug.r_map; map != 0; map = map->l_next)
74          {          {
75            const struct store_class *const *start;            const struct store_class *const *start, *const *stop;
76            const struct store_class *const *stop;  
77            start = dlsym (map, "__start_store_std_classes");            /* We cannot just use MAP directly because it may not have been
78            if (start == 0)               opened by dlopen such that its data structures are fully set
79                 up for dlsym.  */
80              void *module = dlopen (map->l_name, RTLD_NOLOAD);
81              if (module == 0)
82              {              {
83                (void) dlerror ();        /* Required to avoid a leak! */                (void) dlerror (); /* Required to avoid a leak! */
84                continue;                continue;
85              }              }
86            if (start == __start_store_std_classes)  
87              continue;            start = dlsym (map, "__start_store_std_classes");
88            stop = dlsym (map, "__stop_store_std_classes");            if (start == 0)
89            if (stop == 0)              (void) dlerror ();  /* Required to avoid a leak! */
90              else if (start != __start_store_std_classes) /*  */
91              {              {
92                (void) dlerror ();        /* Required to avoid a leak! */                stop = dlsym (map, "__stop_store_std_classes");
93                continue;                if (stop == 0)
94                    (void) dlerror (); /* Required to avoid a leak! */
95                  else
96                    for (cl = start; cl < stop; ++cl)
97                      if (strlen ((*cl)->name) == (clname_end - name)
98                          && strncmp (name, (*cl)->name, (clname_end - name)) == 0)
99                        {
100                          dlclose (module);
101                          return *cl;
102                        }
103              }              }
104            for (cl = start; cl < stop; ++cl)            dlclose (module);
             if (strlen ((*cl)->name) == (clname_end - name)  
                 && strncmp (name, (*cl)->name, (clname_end - name)) == 0)  
               return *cl;  
105          }          }
106      }      }
107    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26