| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/enable.def |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | static int dyn_load_builtin (WORD_LIST *, int, char *); | - | ||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | static int dyn_unload_builtin (char *); | - | ||||||||||||||||||||||||
| 17 | static void delete_builtin (struct builtin *); | - | ||||||||||||||||||||||||
| 18 | static int local_dlclose (void *); | - | ||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | static void list_some_builtins (int); | - | ||||||||||||||||||||||||
| 27 | static int enable_shell_command (char *, int); | - | ||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | int | - | ||||||||||||||||||||||||
| 33 | enable_builtin (list) | - | ||||||||||||||||||||||||
| 34 | WORD_LIST *list; | - | ||||||||||||||||||||||||
| 35 | { | - | ||||||||||||||||||||||||
| 36 | int result, flags; | - | ||||||||||||||||||||||||
| 37 | int opt, filter; | - | ||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||
| 39 | char *filename; | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | result = 0; | - | ||||||||||||||||||||||||
| 43 | flags = 0; | - | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | reset_internal_getopt (); | - | ||||||||||||||||||||||||
| 46 | while ((
| 45-81 | ||||||||||||||||||||||||
| 47 | { | - | ||||||||||||||||||||||||
| 48 | switch (opt) | - | ||||||||||||||||||||||||
| 49 | { | - | ||||||||||||||||||||||||
| 50 | case executed 9 times by 1 test: 'a':case 'a':Executed by:
executed 9 times by 1 test: case 'a':Executed by:
| 9 | ||||||||||||||||||||||||
| 51 | flags |= 0x01; | - | ||||||||||||||||||||||||
| 52 | break; executed 9 times by 1 test: break;Executed by:
| 9 | ||||||||||||||||||||||||
| 53 | case executed 18 times by 1 test: 'n':case 'n':Executed by:
executed 18 times by 1 test: case 'n':Executed by:
| 18 | ||||||||||||||||||||||||
| 54 | flags |= 0x08; | - | ||||||||||||||||||||||||
| 55 | break; executed 18 times by 1 test: break;Executed by:
| 18 | ||||||||||||||||||||||||
| 56 | case executed 27 times by 1 test: 'p':case 'p':Executed by:
executed 27 times by 1 test: case 'p':Executed by:
| 27 | ||||||||||||||||||||||||
| 57 | flags |= 0x10; | - | ||||||||||||||||||||||||
| 58 | break; executed 27 times by 1 test: break;Executed by:
| 27 | ||||||||||||||||||||||||
| 59 | case executed 27 times by 1 test: 's':case 's':Executed by:
executed 27 times by 1 test: case 's':Executed by:
| 27 | ||||||||||||||||||||||||
| 60 | flags |= 0x20; | - | ||||||||||||||||||||||||
| 61 | break; executed 27 times by 1 test: break;Executed by:
| 27 | ||||||||||||||||||||||||
| 62 | case never executed: 'f':case 'f':never executed: case 'f': | 0 | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | flags |= 0x04; | - | ||||||||||||||||||||||||
| 65 | filename = list_optarg; | - | ||||||||||||||||||||||||
| 66 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | case never executed: 'd':case 'd':never executed: case 'd': | 0 | ||||||||||||||||||||||||
| 73 | flags |= 0x02; | - | ||||||||||||||||||||||||
| 74 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | case never executed: -99:case -99:never executed: builtin_help (); returncase -99:never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||||||||||||||
| 80 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 81 | builtin_usage (); | - | ||||||||||||||||||||||||
| 82 | return never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||||||||||||||
| 83 | } | - | ||||||||||||||||||||||||
| 84 | } | - | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | list = loptend; | - | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | if (restricted
| 0-45 | ||||||||||||||||||||||||
| 91 | { | - | ||||||||||||||||||||||||
| 92 | sh_restricted ((char *) | - | ||||||||||||||||||||||||
| 93 | ((void *)0) | - | ||||||||||||||||||||||||
| 94 | ); | - | ||||||||||||||||||||||||
| 95 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | if (list == 0
| 0-27 | ||||||||||||||||||||||||
| 100 | { | - | ||||||||||||||||||||||||
| 101 | filter = (
| 9-18 | ||||||||||||||||||||||||
| 102 | : (
| 9 | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | if (flags & 0x20
| 0-27 | ||||||||||||||||||||||||
| 105 | filter |= 4; executed 27 times by 1 test: filter |= 4;Executed by:
| 27 | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | list_some_builtins (filter); | - | ||||||||||||||||||||||||
| 108 | } executed 27 times by 1 test: end of blockExecuted by:
| 27 | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | else if (flags & 0x04
| 0-18 | ||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||
| 112 | filter = (
| 0 | ||||||||||||||||||||||||
| 113 | if (flags & 0x20
| 0 | ||||||||||||||||||||||||
| 114 | filter |= 4; never executed: filter |= 4; | 0 | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | result = dyn_load_builtin (list, filter, filename); | - | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | set_itemlist_dirty (&it_builtins); | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | else if (flags & 0x02
| 0-18 | ||||||||||||||||||||||||
| 124 | { | - | ||||||||||||||||||||||||
| 125 | while (list
| 0 | ||||||||||||||||||||||||
| 126 | { | - | ||||||||||||||||||||||||
| 127 | opt = dyn_unload_builtin (list->word->word); | - | ||||||||||||||||||||||||
| 128 | if (opt == 1
| 0 | ||||||||||||||||||||||||
| 129 | result = 1; never executed: result = 1; | 0 | ||||||||||||||||||||||||
| 130 | list = list->next; | - | ||||||||||||||||||||||||
| 131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | set_itemlist_dirty (&it_builtins); | - | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||
| 137 | else | - | ||||||||||||||||||||||||
| 138 | { | - | ||||||||||||||||||||||||
| 139 | while (list
| 18-19 | ||||||||||||||||||||||||
| 140 | { | - | ||||||||||||||||||||||||
| 141 | opt = enable_shell_command (list->word->word, flags & 0x08); | - | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | if (opt == 1
| 2-17 | ||||||||||||||||||||||||
| 144 | { | - | ||||||||||||||||||||||||
| 145 | sh_notbuiltin (list->word->word); | - | ||||||||||||||||||||||||
| 146 | result = 1; | - | ||||||||||||||||||||||||
| 147 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 148 | list = list->next; | - | ||||||||||||||||||||||||
| 149 | } executed 19 times by 1 test: end of blockExecuted by:
| 19 | ||||||||||||||||||||||||
| 150 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||||||||
| 151 | return executed 45 times by 1 test: (result);return (result);Executed by:
executed 45 times by 1 test: return (result);Executed by:
| 45 | ||||||||||||||||||||||||
| 152 | } | - | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | static void | - | ||||||||||||||||||||||||
| 157 | list_some_builtins (filter) | - | ||||||||||||||||||||||||
| 158 | int filter; | - | ||||||||||||||||||||||||
| 159 | { | - | ||||||||||||||||||||||||
| 160 | register int i; | - | ||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | for (i = 0; i < num_shell_builtins
| 27-2052 | ||||||||||||||||||||||||
| 163 | { | - | ||||||||||||||||||||||||
| 164 | if (shell_builtins[i].function == 0
| 0-1647 | ||||||||||||||||||||||||
| 165 | continue; executed 405 times by 1 test: continue;Executed by:
| 405 | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | if ((
| 0-1647 | ||||||||||||||||||||||||
| 168 | (
| 432-1215 | ||||||||||||||||||||||||
| 169 | continue; executed 1215 times by 1 test: continue;Executed by:
| 1215 | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | if ((
| 0-288 | ||||||||||||||||||||||||
| 172 | printf ("enable %s\n", shell_builtins[i].name); executed 288 times by 1 test: printf ("enable %s\n", shell_builtins[i].name);Executed by:
| 288 | ||||||||||||||||||||||||
| 173 | else if ((
| 0-144 | ||||||||||||||||||||||||
| 174 | ((
| 0-144 | ||||||||||||||||||||||||
| 175 | printf ("enable -n %s\n", shell_builtins[i].name); never executed: printf ("enable -n %s\n", shell_builtins[i].name); | 0 | ||||||||||||||||||||||||
| 176 | } executed 432 times by 1 test: end of blockExecuted by:
| 432 | ||||||||||||||||||||||||
| 177 | } executed 27 times by 1 test: end of blockExecuted by:
| 27 | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||
| 181 | static int | - | ||||||||||||||||||||||||
| 182 | enable_shell_command (name, disable_p) | - | ||||||||||||||||||||||||
| 183 | char *name; | - | ||||||||||||||||||||||||
| 184 | int disable_p; | - | ||||||||||||||||||||||||
| 185 | { | - | ||||||||||||||||||||||||
| 186 | struct builtin *b; | - | ||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||
| 188 | b = builtin_address_internal (name, 1); | - | ||||||||||||||||||||||||
| 189 | if (b == 0
| 2-17 | ||||||||||||||||||||||||
| 190 | return executed 2 times by 1 test: (1);return (1);Executed by:
executed 2 times by 1 test: return (1);Executed by:
| 2 | ||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||
| 192 | if (disable_p
| 8-9 | ||||||||||||||||||||||||
| 193 | b->flags &= ~0x01; executed 9 times by 1 test: b->flags &= ~0x01;Executed by:
| 9 | ||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||
| 195 | else if (restricted
| 0-8 | ||||||||||||||||||||||||
| 196 | { | - | ||||||||||||||||||||||||
| 197 | sh_restricted ((char *) | - | ||||||||||||||||||||||||
| 198 | ((void *)0) | - | ||||||||||||||||||||||||
| 199 | ); | - | ||||||||||||||||||||||||
| 200 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 201 | } | - | ||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | else | - | ||||||||||||||||||||||||
| 204 | b->flags |= 0x01; executed 8 times by 1 test: b->flags |= 0x01;Executed by:
| 8 | ||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | set_itemlist_dirty (&it_enabled); | - | ||||||||||||||||||||||||
| 208 | set_itemlist_dirty (&it_disabled); | - | ||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | return executed 17 times by 1 test: (0);return (0);Executed by:
executed 17 times by 1 test: return (0);Executed by:
| 17 | ||||||||||||||||||||||||
| 212 | } | - | ||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | static int | - | ||||||||||||||||||||||||
| 221 | dyn_load_builtin (list, flags, filename) | - | ||||||||||||||||||||||||
| 222 | WORD_LIST *list; | - | ||||||||||||||||||||||||
| 223 | int flags; | - | ||||||||||||||||||||||||
| 224 | char *filename; | - | ||||||||||||||||||||||||
| 225 | { | - | ||||||||||||||||||||||||
| 226 | WORD_LIST *l; | - | ||||||||||||||||||||||||
| 227 | void *handle; | - | ||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | int total, size, new, replaced, r; | - | ||||||||||||||||||||||||
| 230 | char *struct_name, *name, *funcname; | - | ||||||||||||||||||||||||
| 231 | sh_load_func_t *loadfunc; | - | ||||||||||||||||||||||||
| 232 | struct builtin **new_builtins, *b, *new_shell_builtins, *old_builtin; | - | ||||||||||||||||||||||||
| 233 | char *loadables_path, *load_path; | - | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | if (list == 0
| 0 | ||||||||||||||||||||||||
| 236 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||
| 242 | handle = 0; | - | ||||||||||||||||||||||||
| 243 | if (absolute_program (filename) == 0
| 0 | ||||||||||||||||||||||||
| 244 | { | - | ||||||||||||||||||||||||
| 245 | loadables_path = get_string_value ("BASH_LOADABLES_PATH"); | - | ||||||||||||||||||||||||
| 246 | if (loadables_path
| 0 | ||||||||||||||||||||||||
| 247 | { | - | ||||||||||||||||||||||||
| 248 | load_path = find_in_path (filename, loadables_path, 0x20|0x4); | - | ||||||||||||||||||||||||
| 249 | if (load_path
| 0 | ||||||||||||||||||||||||
| 250 | { | - | ||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||
| 254 | handle = dlopen (load_path, | - | ||||||||||||||||||||||||
| 255 | 0x00001 | - | ||||||||||||||||||||||||
| 256 | ); | - | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | sh_xfree((load_path), "./enable.def", 327); | - | ||||||||||||||||||||||||
| 259 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 260 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 261 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | if (handle == 0
| 0 | ||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | handle = dlopen (filename, never executed: handle = dlopen (filename, 0x00001 ); | 0 | ||||||||||||||||||||||||
| 269 | 0x00001 never executed: handle = dlopen (filename, 0x00001 ); | 0 | ||||||||||||||||||||||||
| 270 | ); never executed: handle = dlopen (filename, 0x00001 ); | 0 | ||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||
| 273 | if (handle == 0
| 0 | ||||||||||||||||||||||||
| 274 | { | - | ||||||||||||||||||||||||
| 275 | name = printable_filename (filename, 0); | - | ||||||||||||||||||||||||
| 276 | builtin_error ( | - | ||||||||||||||||||||||||
| 277 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||
| 278 | "cannot open shared object %s: %s" | - | ||||||||||||||||||||||||
| 279 | , 5) | - | ||||||||||||||||||||||||
| 280 | , name, dlerror ()); | - | ||||||||||||||||||||||||
| 281 | if (name != filename
| 0 | ||||||||||||||||||||||||
| 282 | sh_xfree((name), "./enable.def", 345); never executed: sh_xfree((name), "./enable.def", 345); | 0 | ||||||||||||||||||||||||
| 283 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 284 | } | - | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | for (new = 0, l = list; l
| 0 | ||||||||||||||||||||||||
| 287 | ; never executed: ; | 0 | ||||||||||||||||||||||||
| 288 | new_builtins = (struct builtin **)sh_xmalloc((new * sizeof (struct builtin *)), "./enable.def", 351); | - | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | for (replaced = new = 0; list
| 0 | ||||||||||||||||||||||||
| 294 | { | - | ||||||||||||||||||||||||
| 295 | name = list->word->word; | - | ||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||
| 297 | size = strlen (name); | - | ||||||||||||||||||||||||
| 298 | struct_name = (char *)sh_xmalloc((size + 8), "./enable.def", 361); | - | ||||||||||||||||||||||||
| 299 | strcpy (struct_name, name); | - | ||||||||||||||||||||||||
| 300 | strcpy (struct_name + size, "_struct"); | - | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | b = (struct builtin *)dlsym (handle, struct_name); | - | ||||||||||||||||||||||||
| 303 | if (b == 0
| 0 | ||||||||||||||||||||||||
| 304 | { | - | ||||||||||||||||||||||||
| 305 | name = printable_filename (filename, 0); | - | ||||||||||||||||||||||||
| 306 | builtin_error ( | - | ||||||||||||||||||||||||
| 307 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||
| 308 | "cannot find %s in shared object %s: %s" | - | ||||||||||||||||||||||||
| 309 | , 5) | - | ||||||||||||||||||||||||
| 310 | , | - | ||||||||||||||||||||||||
| 311 | struct_name, name, dlerror ()); | - | ||||||||||||||||||||||||
| 312 | if (name != filename
| 0 | ||||||||||||||||||||||||
| 313 | sh_xfree((name), "./enable.def", 372); never executed: sh_xfree((name), "./enable.def", 372); | 0 | ||||||||||||||||||||||||
| 314 | sh_xfree((struct_name), "./enable.def", 373); | - | ||||||||||||||||||||||||
| 315 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 316 | } | - | ||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||
| 318 | funcname = sh_xrealloc((struct_name), (size + sizeof ("_builtin_load") + 1), "./enable.def", 377); | - | ||||||||||||||||||||||||
| 319 | strcpy (funcname, name); | - | ||||||||||||||||||||||||
| 320 | strcpy (funcname + size, "_builtin_load"); | - | ||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | loadfunc = (sh_load_func_t *)dlsym (handle, funcname); | - | ||||||||||||||||||||||||
| 323 | if (loadfunc
| 0 | ||||||||||||||||||||||||
| 324 | { | - | ||||||||||||||||||||||||
| 325 | r = (*loadfunc) (name); | - | ||||||||||||||||||||||||
| 326 | if (r == 0
| 0 | ||||||||||||||||||||||||
| 327 | { | - | ||||||||||||||||||||||||
| 328 | builtin_error ( | - | ||||||||||||||||||||||||
| 329 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||
| 330 | "load function for %s returns failure (%d): not loaded" | - | ||||||||||||||||||||||||
| 331 | , 5) | - | ||||||||||||||||||||||||
| 332 | , name, r); | - | ||||||||||||||||||||||||
| 333 | sh_xfree((funcname), "./enable.def", 388); | - | ||||||||||||||||||||||||
| 334 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 335 | } | - | ||||||||||||||||||||||||
| 336 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 337 | sh_xfree((funcname), "./enable.def", 392); | - | ||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | b->flags &= ~0x04; | - | ||||||||||||||||||||||||
| 340 | if (flags & 4
| 0 | ||||||||||||||||||||||||
| 341 | b->flags |= 0x08; never executed: b->flags |= 0x08; | 0 | ||||||||||||||||||||||||
| 342 | b->handle = handle; | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | if (old_builtin = builtin_address_internal (name, 1)
| 0 | ||||||||||||||||||||||||
| 345 | { | - | ||||||||||||||||||||||||
| 346 | replaced++; | - | ||||||||||||||||||||||||
| 347 | __builtin_memcpy (((char *)old_builtin), ((char *)b), (sizeof (struct builtin))); | - | ||||||||||||||||||||||||
| 348 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 349 | else | - | ||||||||||||||||||||||||
| 350 | new_builtins[new++] = b; never executed: new_builtins[new++] = b; | 0 | ||||||||||||||||||||||||
| 351 | } | - | ||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | if (replaced == 0
| 0 | ||||||||||||||||||||||||
| 354 | { | - | ||||||||||||||||||||||||
| 355 | sh_xfree((new_builtins), "./enable.def", 410); | - | ||||||||||||||||||||||||
| 356 | dlclose (handle); | - | ||||||||||||||||||||||||
| 357 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 358 | } | - | ||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||
| 360 | if (new
| 0 | ||||||||||||||||||||||||
| 361 | { | - | ||||||||||||||||||||||||
| 362 | total = num_shell_builtins + new; | - | ||||||||||||||||||||||||
| 363 | size = (total + 1) * sizeof (struct builtin); | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | new_shell_builtins = (struct builtin *)sh_xmalloc((size), "./enable.def", 420); | - | ||||||||||||||||||||||||
| 366 | __builtin_memcpy (((char *)new_shell_builtins), ((char *)shell_builtins), (num_shell_builtins * sizeof (struct builtin))) | - | ||||||||||||||||||||||||
| 367 | ; | - | ||||||||||||||||||||||||
| 368 | for (replaced = 0; replaced < new
| 0 | ||||||||||||||||||||||||
| 369 | __builtin_memcpy (((char *)&new_shell_builtins[num_shell_builtins + replaced]), ((char *)new_builtins[replaced]), (sizeof (struct builtin))) never executed: __builtin_memcpy (((char *)&new_shell_builtins[num_shell_builtins + replaced]), ((char *)new_builtins[replaced]), (sizeof (struct builtin))) ; | 0 | ||||||||||||||||||||||||
| 370 | 0 | |||||||||||||||||||||||||
| 371 | ; never executed: __builtin_memcpy (((char *)&new_shell_builtins[num_shell_builtins + replaced]), ((char *)new_builtins[replaced]), (sizeof (struct builtin))) ; | 0 | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | new_shell_builtins[total].name = (char *)0; | - | ||||||||||||||||||||||||
| 374 | new_shell_builtins[total].function = (sh_builtin_func_t *)0; | - | ||||||||||||||||||||||||
| 375 | new_shell_builtins[total].flags = 0; | - | ||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | if (shell_builtins != static_shell_builtins
| 0 | ||||||||||||||||||||||||
| 378 | sh_xfree((shell_builtins), "./enable.def", 433); never executed: sh_xfree((shell_builtins), "./enable.def", 433); | 0 | ||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | shell_builtins = new_shell_builtins; | - | ||||||||||||||||||||||||
| 381 | num_shell_builtins = total; | - | ||||||||||||||||||||||||
| 382 | initialize_shell_builtins (); | - | ||||||||||||||||||||||||
| 383 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | sh_xfree((new_builtins), "./enable.def", 440); | - | ||||||||||||||||||||||||
| 386 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | static void | - | ||||||||||||||||||||||||
| 392 | delete_builtin (b) | - | ||||||||||||||||||||||||
| 393 | struct builtin *b; | - | ||||||||||||||||||||||||
| 394 | { | - | ||||||||||||||||||||||||
| 395 | int ind, size; | - | ||||||||||||||||||||||||
| 396 | struct builtin *new_shell_builtins; | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | - | |||||||||||||||||||||||||
| 399 | - | |||||||||||||||||||||||||
| 400 | ind = b - shell_builtins; | - | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | size = num_shell_builtins * sizeof (struct builtin); | - | ||||||||||||||||||||||||
| 405 | new_shell_builtins = (struct builtin *)sh_xmalloc((size), "./enable.def", 460); | - | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | if (ind
| 0 | ||||||||||||||||||||||||
| 409 | __builtin_memcpy (((char *)new_shell_builtins), ((char *)shell_builtins), (ind * sizeof (struct builtin))) never executed: __builtin_memcpy (((char *)new_shell_builtins), ((char *)shell_builtins), (ind * sizeof (struct builtin))) ; | 0 | ||||||||||||||||||||||||
| 410 | ; never executed: __builtin_memcpy (((char *)new_shell_builtins), ((char *)shell_builtins), (ind * sizeof (struct builtin))) ; | 0 | ||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||
| 413 | __builtin_memcpy (((char *)(&new_shell_builtins[ind])), ((char *)(&shell_builtins[ind+1])), ((num_shell_builtins - ind) * sizeof (struct builtin))) | - | ||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | ; | - | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | if (shell_builtins != static_shell_builtins
| 0 | ||||||||||||||||||||||||
| 418 | sh_xfree((shell_builtins), "./enable.def", 473); never executed: sh_xfree((shell_builtins), "./enable.def", 473); | 0 | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | num_shell_builtins--; | - | ||||||||||||||||||||||||
| 422 | shell_builtins = new_shell_builtins; | - | ||||||||||||||||||||||||
| 423 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | static int | - | ||||||||||||||||||||||||
| 428 | local_dlclose (handle) | - | ||||||||||||||||||||||||
| 429 | void *handle; | - | ||||||||||||||||||||||||
| 430 | { | - | ||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | return never executed: (dlclose (handle));return (dlclose (handle));never executed: return (dlclose (handle)); | 0 | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | } | - | ||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||
| 439 | static int | - | ||||||||||||||||||||||||
| 440 | dyn_unload_builtin (name) | - | ||||||||||||||||||||||||
| 441 | char *name; | - | ||||||||||||||||||||||||
| 442 | { | - | ||||||||||||||||||||||||
| 443 | struct builtin *b; | - | ||||||||||||||||||||||||
| 444 | void *handle; | - | ||||||||||||||||||||||||
| 445 | char *funcname; | - | ||||||||||||||||||||||||
| 446 | sh_unload_func_t *unloadfunc; | - | ||||||||||||||||||||||||
| 447 | int ref, i, size; | - | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | b = builtin_address_internal (name, 1); | - | ||||||||||||||||||||||||
| 450 | if (b == 0
| 0 | ||||||||||||||||||||||||
| 451 | { | - | ||||||||||||||||||||||||
| 452 | sh_notbuiltin (name); | - | ||||||||||||||||||||||||
| 453 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 454 | } | - | ||||||||||||||||||||||||
| 455 | if (b->flags & 0x04
| 0 | ||||||||||||||||||||||||
| 456 | { | - | ||||||||||||||||||||||||
| 457 | builtin_error ( | - | ||||||||||||||||||||||||
| 458 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||
| 459 | "%s: not dynamically loaded" | - | ||||||||||||||||||||||||
| 460 | , 5) | - | ||||||||||||||||||||||||
| 461 | , name); | - | ||||||||||||||||||||||||
| 462 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 463 | } | - | ||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||
| 465 | handle = (void *)b->handle; | - | ||||||||||||||||||||||||
| 466 | for (ref = i = 0; i < num_shell_builtins
| 0 | ||||||||||||||||||||||||
| 467 | { | - | ||||||||||||||||||||||||
| 468 | if (shell_builtins[i].handle == b->handle
| 0 | ||||||||||||||||||||||||
| 469 | ref++; never executed: ref++; | 0 | ||||||||||||||||||||||||
| 470 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | size = strlen (name); | - | ||||||||||||||||||||||||
| 474 | funcname = sh_xmalloc((size + sizeof ("_builtin_unload") + 1), "./enable.def", 525); | - | ||||||||||||||||||||||||
| 475 | strcpy (funcname, name); | - | ||||||||||||||||||||||||
| 476 | strcpy (funcname + size, "_builtin_unload"); | - | ||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||
| 478 | unloadfunc = (sh_unload_func_t *)dlsym (handle, funcname); | - | ||||||||||||||||||||||||
| 479 | if (unloadfunc
| 0 | ||||||||||||||||||||||||
| 480 | (* never executed: unloadfunc) (name);(*unloadfunc) (name);never executed: (*unloadfunc) (name); | 0 | ||||||||||||||||||||||||
| 481 | sh_xfree((funcname), "./enable.def", 532); | - | ||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | if (ref == 1
| 0 | ||||||||||||||||||||||||
| 486 | { | - | ||||||||||||||||||||||||
| 487 | builtin_error ( | - | ||||||||||||||||||||||||
| 488 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||
| 489 | "%s: cannot delete: %s" | - | ||||||||||||||||||||||||
| 490 | , 5) | - | ||||||||||||||||||||||||
| 491 | , name, dlerror ()); | - | ||||||||||||||||||||||||
| 492 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||
| 493 | } | - | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||
| 496 | delete_builtin (b); | - | ||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||
| 499 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |