1 2014-08-21 Florian Weimer <fweimer@redhat.com>
4 * iconv/gconv_trans.c (struct known_trans, search_tree, lock,
5 trans_compare, open_translit, __gconv_translit_find):
6 Remove module loading code.
8 diff --git a/iconv/gconv_trans.c b/iconv/gconv_trans.c
9 index 1e25854..d71c029 100644
10 --- a/iconv/gconv_trans.c
11 +++ b/iconv/gconv_trans.c
12 @@ -238,181 +238,11 @@ __gconv_transliterate (struct __gconv_step *step,
13 return __GCONV_ILLEGAL_INPUT;
17 -/* Structure to represent results of found (or not) transliteration
21 - /* This structure must remain the first member. */
22 - struct trans_struct info;
30 -/* Tree with results of previous calls to __gconv_translit_find. */
31 -static void *search_tree;
33 -/* We modify global data. */
34 -__libc_lock_define_initialized (static, lock);
37 -/* Compare two transliteration entries. */
39 -trans_compare (const void *p1, const void *p2)
41 - const struct known_trans *s1 = (const struct known_trans *) p1;
42 - const struct known_trans *s2 = (const struct known_trans *) p2;
44 - return strcmp (s1->info.name, s2->info.name);
48 -/* Open (maybe reopen) the module named in the struct. Get the function
49 - and data structure pointers we need. */
51 -open_translit (struct known_trans *trans)
53 - __gconv_trans_query_fct queryfct;
55 - trans->handle = __libc_dlopen (trans->fname);
56 - if (trans->handle == NULL)
57 - /* Not available. */
60 - /* Find the required symbol. */
61 - queryfct = __libc_dlsym (trans->handle, "gconv_trans_context");
62 - if (queryfct == NULL)
64 - /* We cannot live with that. */
66 - __libc_dlclose (trans->handle);
67 - trans->handle = NULL;
71 - /* Get the context. */
72 - if (queryfct (trans->info.name, &trans->info.csnames, &trans->info.ncsnames)
76 - /* Of course we also have to have the actual function. */
77 - trans->info.trans_fct = __libc_dlsym (trans->handle, "gconv_trans");
78 - if (trans->info.trans_fct == NULL)
81 - /* Now the optional functions. */
82 - trans->info.trans_init_fct =
83 - __libc_dlsym (trans->handle, "gconv_trans_init");
84 - trans->info.trans_context_fct =
85 - __libc_dlsym (trans->handle, "gconv_trans_context");
86 - trans->info.trans_end_fct =
87 - __libc_dlsym (trans->handle, "gconv_trans_end");
89 - trans->open_count = 1;
97 __gconv_translit_find (struct trans_struct *trans)
99 - struct known_trans **found;
100 - const struct path_elem *runp;
103 - /* We have to have a name. */
104 - assert (trans->name != NULL);
106 - /* Acquire the lock. */
107 - __libc_lock_lock (lock);
109 - /* See whether we know this module already. */
110 - found = __tfind (trans, &search_tree, trans_compare);
113 - /* Is this module available? */
114 - if ((*found)->handle != NULL)
116 - /* Maybe we have to reopen the file. */
117 - if ((*found)->handle != (void *) -1)
118 - /* The object is not unloaded. */
120 - else if (open_translit (*found) == 0)
122 - /* Copy the data. */
123 - *trans = (*found)->info;
124 - (*found)->open_count++;
131 - size_t name_len = strlen (trans->name) + 1;
133 - struct known_trans *newp;
135 - /* We have to continue looking for the module. */
136 - if (__gconv_path_elem == NULL)
137 - __gconv_get_path ();
139 - /* See whether we have to append .so. */
140 - if (name_len <= 4 || memcmp (&trans->name[name_len - 4], ".so", 3) != 0)
143 - /* Create a new entry. */
144 - newp = (struct known_trans *) malloc (sizeof (struct known_trans)
145 - + (__gconv_max_path_elem_len
152 - /* Clear the struct. */
153 - memset (newp, '\0', sizeof (struct known_trans));
155 - /* Store a copy of the module name. */
156 - newp->info.name = cp = (char *) (newp + 1);
157 - cp = __mempcpy (cp, trans->name, name_len);
161 - /* Search in all the directories. */
162 - for (runp = __gconv_path_elem; runp->name != NULL; ++runp)
164 - cp = __mempcpy (__stpcpy ((char *) newp->fname, runp->name),
165 - trans->name, name_len);
167 - memcpy (cp, ".so", sizeof (".so"));
169 - if (open_translit (newp) == 0)
171 - /* We found a module. */
178 - newp->fname = NULL;
180 - /* In any case we'll add the entry to our search tree. */
181 - if (__tsearch (newp, &search_tree, trans_compare) == NULL)
183 - /* Yickes, this should not happen. Unload the object. */
185 - /* XXX unload here. */
190 - __libc_lock_unlock (lock);
193 + /* This function always fails. Transliteration module loading is
194 + not implemented. */