mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-16 14:41:02 +02:00
zsh-workers/8770
This commit is contained in:
parent
f853592fa0
commit
f8b0dee880
30 changed files with 338 additions and 336 deletions
|
@ -1390,20 +1390,20 @@ item(tt(zmodload) tt(-ua) [ tt(-i) ] var(builtin) ...)(
|
||||||
Equivalent to tt(-ab) and tt(-ub).
|
Equivalent to tt(-ab) and tt(-ub).
|
||||||
)
|
)
|
||||||
item(tt(zmodload -e) [ var(string) ... ])(
|
item(tt(zmodload -e) [ var(string) ... ])(
|
||||||
The tt(-e) option without arguments lists all modules loaded or linked
|
The tt(-e) option without arguments lists all loaded modules loaded.
|
||||||
into the shell. With arguments only the return status is set to zero
|
With arguments only the return status is set to zero
|
||||||
if all var(string)s given as arguments are names of modules loaded or
|
if all var(string)s given as arguments are names of loaded modules
|
||||||
linked in and to one if at least on var(string) is not the name of a
|
and to one if at least on var(string) is not the name of a
|
||||||
module loaded or linked. This can be used to test for the availability
|
loaded module. This can be used to test for the availability
|
||||||
of things implemented by modules.
|
of things implemented by modules.
|
||||||
)
|
)
|
||||||
enditem()
|
enditem()
|
||||||
|
|
||||||
In a shell without dynamic loading only the tt(-e) option is
|
Note that tt(zsh) makes no difference between modules that were linked
|
||||||
supported and the tt(-i) option is ignored. In such a shell the return
|
into the shell and modules that are loaded dynamically. In both cases
|
||||||
status of tt(zmodload) without arguments or options is one whereas in
|
this builtin command has to be used to make available the builtins and
|
||||||
a shell with dynamic loading the return status without arguments or
|
other things defined by modules (unless the module is autoloaded on
|
||||||
options is always zero. This can be used to test if the shell supports
|
these definitions). This is even true for systems that don't support
|
||||||
dynamic loading of modules or not.
|
dynamic loading of modules.
|
||||||
)
|
)
|
||||||
enditem()
|
enditem()
|
||||||
|
|
|
@ -151,9 +151,7 @@ The third one, named `cleanup_foo' for module `foo' is called when the
|
||||||
user tries to unload a module and should de-register the builtins
|
user tries to unload a module and should de-register the builtins
|
||||||
etc. The last function, `finish_foo' is called when the module is
|
etc. The last function, `finish_foo' is called when the module is
|
||||||
actually unloaded and should finalize all the data initialized in the
|
actually unloaded and should finalize all the data initialized in the
|
||||||
`setup'-function. Since the last two functions are only executed when
|
`setup'-function.
|
||||||
the module is used as an dynamically loaded module you can surround
|
|
||||||
it with `#ifdef MODULE' and `#endif'.
|
|
||||||
In short, the `cleanup'-function should undo what the `boot'-function
|
In short, the `cleanup'-function should undo what the `boot'-function
|
||||||
did, and the `finish'-function should undo what the `setup'-function
|
did, and the `finish'-function should undo what the `setup'-function
|
||||||
did.
|
did.
|
||||||
|
|
|
@ -637,8 +637,6 @@ boot_rlimits(Module m)
|
||||||
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_rlimits(Module m)
|
cleanup_rlimits(Module m)
|
||||||
|
@ -653,5 +651,3 @@ finish_rlimits(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -200,8 +200,6 @@ boot_sched(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_sched(Module m)
|
cleanup_sched(Module m)
|
||||||
|
@ -224,5 +222,3 @@ finish_sched(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -136,8 +136,6 @@ boot_cap(Module m)
|
||||||
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_cap(Module m)
|
cleanup_cap(Module m)
|
||||||
|
@ -152,5 +150,3 @@ finish_cap(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -110,8 +110,6 @@ boot_clone(Module m)
|
||||||
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_clone(Module m)
|
cleanup_clone(Module m)
|
||||||
|
@ -126,5 +124,3 @@ finish_clone(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -212,8 +212,6 @@ boot_example(Module m)
|
||||||
!addwrapper(m, wrapper));
|
!addwrapper(m, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_example(Module m)
|
cleanup_example(Module m)
|
||||||
|
@ -234,5 +232,3 @@ finish_example(Module m)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -523,8 +523,6 @@ boot_files(Module m)
|
||||||
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_files(Module m)
|
cleanup_files(Module m)
|
||||||
|
@ -539,5 +537,3 @@ finish_files(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -346,8 +346,6 @@ boot_mapfile(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_mapfile(Module m)
|
cleanup_mapfile(Module m)
|
||||||
|
@ -370,5 +368,3 @@ finish_mapfile(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -462,8 +462,6 @@ boot_mathfunc(Module m)
|
||||||
return !addmathfuncs(m->nam, mftab, sizeof(mftab)/sizeof(*mftab));
|
return !addmathfuncs(m->nam, mftab, sizeof(mftab)/sizeof(*mftab));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_mathfunc(Module m)
|
cleanup_mathfunc(Module m)
|
||||||
|
@ -478,5 +476,3 @@ finish_mathfunc(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -901,18 +901,12 @@ getpmmodule(HashTable ht, char *name)
|
||||||
pm->old = NULL;
|
pm->old = NULL;
|
||||||
pm->level = 0;
|
pm->level = 0;
|
||||||
|
|
||||||
for (node = firstnode(bltinmodules); node; incnode(node))
|
|
||||||
if (!strcmp(name, (char *) getdata(node))) {
|
|
||||||
type = "builtin";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
Module m;
|
Module m;
|
||||||
|
|
||||||
for (node = firstnode(modules); node; incnode(node)) {
|
for (node = firstnode(modules); node; incnode(node)) {
|
||||||
m = (Module) getdata(node);
|
m = (Module) getdata(node);
|
||||||
if (m->handle && !(m->flags & MOD_UNLOAD) &&
|
if (m->u.handle && !(m->flags & MOD_UNLOAD) &&
|
||||||
!strcmp(name, m->nam)) {
|
!strcmp(name, m->nam)) {
|
||||||
type = "loaded";
|
type = "loaded";
|
||||||
break;
|
break;
|
||||||
|
@ -937,7 +931,6 @@ getpmmodule(HashTable ht, char *name)
|
||||||
if (modpmfound)
|
if (modpmfound)
|
||||||
type = "autoloaded";
|
type = "autoloaded";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (type)
|
if (type)
|
||||||
pm->u.str = dupstring(type);
|
pm->u.str = dupstring(type);
|
||||||
else {
|
else {
|
||||||
|
@ -972,16 +965,10 @@ scanpmmodules(HashTable ht, ScanFunc func, int flags)
|
||||||
pm.level = 0;
|
pm.level = 0;
|
||||||
|
|
||||||
pm.u.str = dupstring("builtin");
|
pm.u.str = dupstring("builtin");
|
||||||
for (node = firstnode(bltinmodules); node; incnode(node)) {
|
|
||||||
pm.nam = (char *) getdata(node);
|
|
||||||
addlinknode(done, pm.nam);
|
|
||||||
func((HashNode) &pm, flags);
|
|
||||||
}
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
pm.u.str = dupstring("loaded");
|
pm.u.str = dupstring("loaded");
|
||||||
for (node = firstnode(modules); node; incnode(node)) {
|
for (node = firstnode(modules); node; incnode(node)) {
|
||||||
m = (Module) getdata(node);
|
m = (Module) getdata(node);
|
||||||
if (m->handle && !(m->flags & MOD_UNLOAD)) {
|
if (m->u.handle && !(m->flags & MOD_UNLOAD)) {
|
||||||
pm.nam = m->nam;
|
pm.nam = m->nam;
|
||||||
addlinknode(done, pm.nam);
|
addlinknode(done, pm.nam);
|
||||||
func((HashNode) &pm, flags);
|
func((HashNode) &pm, flags);
|
||||||
|
@ -1012,7 +999,6 @@ scanpmmodules(HashTable ht, ScanFunc func, int flags)
|
||||||
func((HashNode) &pm, flags);
|
func((HashNode) &pm, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Functions for the dirstack special parameter. */
|
/* Functions for the dirstack special parameter. */
|
||||||
|
@ -1919,8 +1905,6 @@ boot_parameter(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_parameter(Module m)
|
cleanup_parameter(Module m)
|
||||||
|
@ -1949,5 +1933,3 @@ finish_parameter(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -602,8 +602,6 @@ boot_stat(Module m)
|
||||||
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_stat(Module m)
|
cleanup_stat(Module m)
|
||||||
|
@ -618,5 +616,3 @@ finish_stat(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -3213,8 +3213,6 @@ boot_zftp(Module m)
|
||||||
return !ret;
|
return !ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_zftp(Module m)
|
cleanup_zftp(Module m)
|
||||||
|
@ -3249,5 +3247,3 @@ finish_zftp(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -3764,8 +3764,6 @@ boot_compctl(Module m)
|
||||||
return (addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab)) != 1);
|
return (addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab)) != 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_compctl(Module m)
|
cleanup_compctl(Module m)
|
||||||
|
@ -3789,5 +3787,3 @@ finish_compctl(Module m)
|
||||||
compctlreadptr = fallback_compctlread;
|
compctlreadptr = fallback_compctlread;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1389,8 +1389,6 @@ boot_complete(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_complete(Module m)
|
cleanup_complete(Module m)
|
||||||
|
@ -1414,7 +1412,8 @@ cleanup_complete(Module m)
|
||||||
int
|
int
|
||||||
finish_complete(Module m)
|
finish_complete(Module m)
|
||||||
{
|
{
|
||||||
freearray(compwords);
|
if (compwords)
|
||||||
|
freearray(compwords);
|
||||||
zsfree(compprefix);
|
zsfree(compprefix);
|
||||||
zsfree(compsuffix);
|
zsfree(compsuffix);
|
||||||
zsfree(compiprefix);
|
zsfree(compiprefix);
|
||||||
|
@ -1446,5 +1445,3 @@ finish_complete(Module m)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -935,8 +935,6 @@ boot_complist(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_complist(Module m)
|
cleanup_complist(Module m)
|
||||||
|
@ -957,5 +955,3 @@ finish_complist(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -2837,8 +2837,6 @@ boot_computil(Module m)
|
||||||
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_computil(Module m)
|
cleanup_computil(Module m)
|
||||||
|
@ -2865,5 +2863,3 @@ finish_computil(Module m)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -98,8 +98,6 @@ boot_deltochar(Module m)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_deltochar(Module m)
|
cleanup_deltochar(Module m)
|
||||||
|
@ -115,5 +113,3 @@ finish_deltochar(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -611,9 +611,6 @@ static struct isrch_spot {
|
||||||
|
|
||||||
static int max_spot = 0;
|
static int max_spot = 0;
|
||||||
|
|
||||||
/**/
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
void
|
void
|
||||||
free_isrch_spots(void)
|
free_isrch_spots(void)
|
||||||
|
@ -621,9 +618,6 @@ free_isrch_spots(void)
|
||||||
zfree(isrch_spots, max_spot * sizeof(*isrch_spots));
|
zfree(isrch_spots, max_spot * sizeof(*isrch_spots));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
#endif /* MODULE */
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static void
|
static void
|
||||||
set_isrch_spot(int num, int hl, int pos, int cs, int len, int dir, int nomatch)
|
set_isrch_spot(int num, int hl, int pos, int cs, int len, int dir, int nomatch)
|
||||||
|
|
|
@ -1000,8 +1000,6 @@ init_keymaps(void)
|
||||||
lastnamed = refthingy(t_undefinedkey);
|
lastnamed = refthingy(t_undefinedkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/* cleanup entry point (for unloading the zle module) */
|
/* cleanup entry point (for unloading the zle module) */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -1013,8 +1011,6 @@ cleanup_keymaps(void)
|
||||||
zfree(keybuf, keybufsz);
|
zfree(keybuf, keybufsz);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MODULE */
|
|
||||||
|
|
||||||
/* Create the default keymaps. For efficiency reasons, this function *
|
/* Create the default keymaps. For efficiency reasons, this function *
|
||||||
* assigns directly to the km->first array. It knows that there are no *
|
* assigns directly to the km->first array. It knows that there are no *
|
||||||
* prefix bindings in the way, and that it is using a simple keymap. */
|
* prefix bindings in the way, and that it is using a simple keymap. */
|
||||||
|
|
|
@ -1043,8 +1043,6 @@ boot_zle(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_zle(Module m)
|
cleanup_zle(Module m)
|
||||||
|
@ -1093,5 +1091,3 @@ finish_zle(Module m)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MODULE */
|
|
||||||
|
|
|
@ -286,8 +286,6 @@ addzlefunction(char *name, ZleIntFunc ifunc, int flags)
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
|
|
||||||
/* Delete an internal widget provided by a module. Don't try to delete *
|
/* Delete an internal widget provided by a module. Don't try to delete *
|
||||||
* a widget from the fixed table -- it would be bad. (Thanks, Egon.) */
|
* a widget from the fixed table -- it would be bad. (Thanks, Egon.) */
|
||||||
|
|
||||||
|
@ -309,8 +307,6 @@ deletezlefunction(Widget w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DYNAMIC */
|
|
||||||
|
|
||||||
/***************/
|
/***************/
|
||||||
/* zle builtin */
|
/* zle builtin */
|
||||||
/***************/
|
/***************/
|
||||||
|
@ -550,18 +546,10 @@ bin_zle_complete(char *name, char **args, char *ops, char func)
|
||||||
Thingy t;
|
Thingy t;
|
||||||
Widget w, cw;
|
Widget w, cw;
|
||||||
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
if (!require_module(name, "complete", 0, 0)) {
|
if (!require_module(name, "complete", 0, 0)) {
|
||||||
zerrnam(name, "can't load complete module", NULL, 0);
|
zerrnam(name, "can't load complete module", NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (!module_linked("complete")) {
|
|
||||||
zerrnam(name, "complete module not available", NULL, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
t = rthingy((args[1][0] == '.') ? args[1] : dyncat(".", args[1]));
|
t = rthingy((args[1][0] == '.') ? args[1] : dyncat(".", args[1]));
|
||||||
cw = t->widget;
|
cw = t->widget;
|
||||||
unrefthingy(t);
|
unrefthingy(t);
|
||||||
|
|
|
@ -230,8 +230,6 @@ boot_zleparameter(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
cleanup_zleparameter(Module m)
|
cleanup_zleparameter(Module m)
|
||||||
|
@ -255,5 +253,3 @@ finish_zleparameter(Module m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -123,12 +123,7 @@ static struct builtin builtins[] =
|
||||||
BUILTIN("whence", 0, bin_whence, 0, -1, 0, "acmpvfsw", NULL),
|
BUILTIN("whence", 0, bin_whence, 0, -1, 0, "acmpvfsw", NULL),
|
||||||
BUILTIN("where", 0, bin_whence, 0, -1, 0, "pmsw", "ca"),
|
BUILTIN("where", 0, bin_whence, 0, -1, 0, "pmsw", "ca"),
|
||||||
BUILTIN("which", 0, bin_whence, 0, -1, 0, "ampsw", "c"),
|
BUILTIN("which", 0, bin_whence, 0, -1, 0, "ampsw", "c"),
|
||||||
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ILabcfdipue", NULL),
|
BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ILabcfdipue", NULL),
|
||||||
#else
|
|
||||||
BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ei", NULL),
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -229,14 +224,11 @@ execbuiltin(LinkList args, Builtin bn)
|
||||||
|
|
||||||
arg = (char *) ugetnode(args);
|
arg = (char *) ugetnode(args);
|
||||||
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
if (!bn->handlerfunc) {
|
if (!bn->handlerfunc) {
|
||||||
zwarnnam(name, "autoload failed", NULL, 0);
|
zwarnnam(name, "autoload failed", NULL, 0);
|
||||||
deletebuiltin(bn->nam);
|
deletebuiltin(bn->nam);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* get some information about the command */
|
/* get some information about the command */
|
||||||
flags = bn->flags;
|
flags = bn->flags;
|
||||||
optstr = bn->optstr;
|
optstr = bn->optstr;
|
||||||
|
@ -3209,6 +3201,8 @@ zexit(int val, int from_signal)
|
||||||
if (in_exit++ && from_signal) {
|
if (in_exit++ && from_signal) {
|
||||||
LASTALLOC_RETURN;
|
LASTALLOC_RETURN;
|
||||||
}
|
}
|
||||||
|
exit_modules();
|
||||||
|
|
||||||
if (isset(MONITOR)) {
|
if (isset(MONITOR)) {
|
||||||
/* send SIGHUP to any jobs left running */
|
/* send SIGHUP to any jobs left running */
|
||||||
killrunjobs(from_signal);
|
killrunjobs(from_signal);
|
||||||
|
|
12
Src/exec.c
12
Src/exec.c
|
@ -1504,13 +1504,12 @@ execcmd(Cmd cmd, int input, int output, int how, int last1)
|
||||||
}
|
}
|
||||||
if (!(hn->flags & BINF_PREFIX)) {
|
if (!(hn->flags & BINF_PREFIX)) {
|
||||||
is_builtin = 1;
|
is_builtin = 1;
|
||||||
#ifdef DYNAMIC
|
|
||||||
/* autoload the builtin if necessary */
|
/* autoload the builtin if necessary */
|
||||||
if (!((Builtin) hn)->handlerfunc) {
|
if (!((Builtin) hn)->handlerfunc) {
|
||||||
load_module(((Builtin) hn)->optstr);
|
load_module(((Builtin) hn)->optstr);
|
||||||
hn = builtintab->getnode(builtintab, cmdarg);
|
hn = builtintab->getnode(builtintab, cmdarg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
assign = (hn->flags & BINF_MAGICEQUALS);
|
assign = (hn->flags & BINF_MAGICEQUALS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1619,13 +1618,12 @@ execcmd(Cmd cmd, int input, int output, int how, int last1)
|
||||||
}
|
}
|
||||||
if (!(hn->flags & BINF_PREFIX)) {
|
if (!(hn->flags & BINF_PREFIX)) {
|
||||||
is_builtin = 1;
|
is_builtin = 1;
|
||||||
#ifdef DYNAMIC
|
|
||||||
/* autoload the builtin if necessary */
|
/* autoload the builtin if necessary */
|
||||||
if (!((Builtin) hn)->handlerfunc) {
|
if (!((Builtin) hn)->handlerfunc) {
|
||||||
load_module(((Builtin) hn)->optstr);
|
load_module(((Builtin) hn)->optstr);
|
||||||
hn = builtintab->getnode(builtintab, cmdarg);
|
hn = builtintab->getnode(builtintab, cmdarg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
|
cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
|
||||||
|
@ -3072,11 +3070,11 @@ runshfunc(List list, FuncWrap wrap, char *name)
|
||||||
wrap->module->wrapper++;
|
wrap->module->wrapper++;
|
||||||
cont = wrap->handler(list, wrap->next, name);
|
cont = wrap->handler(list, wrap->next, name);
|
||||||
wrap->module->wrapper--;
|
wrap->module->wrapper--;
|
||||||
#ifdef DYNAMIC
|
|
||||||
if (!wrap->module->wrapper &&
|
if (!wrap->module->wrapper &&
|
||||||
(wrap->module->flags & MOD_UNLOAD))
|
(wrap->module->flags & MOD_UNLOAD))
|
||||||
unload_module(wrap->module, NULL);
|
unload_module(wrap->module, NULL, 0);
|
||||||
#endif
|
|
||||||
if (!cont)
|
if (!cont)
|
||||||
return;
|
return;
|
||||||
wrap = wrap->next;
|
wrap = wrap->next;
|
||||||
|
|
27
Src/init.c
27
Src/init.c
|
@ -599,11 +599,9 @@ setupvals(void)
|
||||||
mailpath = mkarray(NULL);
|
mailpath = mkarray(NULL);
|
||||||
watch = mkarray(NULL);
|
watch = mkarray(NULL);
|
||||||
psvar = mkarray(NULL);
|
psvar = mkarray(NULL);
|
||||||
#ifdef DYNAMIC
|
|
||||||
module_path = mkarray(ztrdup(MODULE_DIR));
|
module_path = mkarray(ztrdup(MODULE_DIR));
|
||||||
modules = newlinklist();
|
modules = newlinklist();
|
||||||
#endif
|
linkedmodules = newlinklist();
|
||||||
bltinmodules = newlinklist();
|
|
||||||
|
|
||||||
/* Set default prompts */
|
/* Set default prompts */
|
||||||
if(unset(INTERACTIVE)) {
|
if(unset(INTERACTIVE)) {
|
||||||
|
@ -940,9 +938,10 @@ sourcehome(char *s)
|
||||||
void
|
void
|
||||||
init_bltinmods(void)
|
init_bltinmods(void)
|
||||||
{
|
{
|
||||||
static struct module mod = { NULL, 0, NULL, NULL };
|
|
||||||
#include "bltinmods.list"
|
#include "bltinmods.list"
|
||||||
mod.nam = NULL;
|
|
||||||
|
load_module("zsh");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -969,13 +968,13 @@ noop_function_int(int nothing)
|
||||||
/**/
|
/**/
|
||||||
ZleVoidFn trashzleptr = noop_function;
|
ZleVoidFn trashzleptr = noop_function;
|
||||||
/**/
|
/**/
|
||||||
ZleVoidFn gotwordptr;
|
ZleVoidFn gotwordptr = noop_function;
|
||||||
/**/
|
/**/
|
||||||
ZleVoidFn refreshptr;
|
ZleVoidFn refreshptr = noop_function;
|
||||||
/**/
|
/**/
|
||||||
ZleVoidIntFn spaceinlineptr;
|
ZleVoidIntFn spaceinlineptr = noop_function_int;
|
||||||
/**/
|
/**/
|
||||||
ZleReadFn zlereadptr;
|
ZleReadFn zlereadptr = autoload_zleread;
|
||||||
|
|
||||||
#else /* !LINKED_XMOD_zle */
|
#else /* !LINKED_XMOD_zle */
|
||||||
|
|
||||||
|
@ -989,11 +988,10 @@ ZleReadFn zlereadptr = autoload_zleread;
|
||||||
ZleReadFn zlereadptr = fallback_zleread;
|
ZleReadFn zlereadptr = fallback_zleread;
|
||||||
# endif /* !UNLINKED_XMOD_zle */
|
# endif /* !UNLINKED_XMOD_zle */
|
||||||
|
|
||||||
/**/
|
#endif /* !LINKED_XMOD_zle */
|
||||||
# ifdef UNLINKED_XMOD_zle
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static unsigned char *
|
unsigned char *
|
||||||
autoload_zleread(char *lp, char *rp, int ha)
|
autoload_zleread(char *lp, char *rp, int ha)
|
||||||
{
|
{
|
||||||
zlereadptr = fallback_zleread;
|
zlereadptr = fallback_zleread;
|
||||||
|
@ -1001,9 +999,6 @@ autoload_zleread(char *lp, char *rp, int ha)
|
||||||
return zleread(lp, rp, ha);
|
return zleread(lp, rp, ha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
# endif /* UNLINKED_XMOD_zle */
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
unsigned char *
|
unsigned char *
|
||||||
fallback_zleread(char *lp, char *rp, int ha)
|
fallback_zleread(char *lp, char *rp, int ha)
|
||||||
|
@ -1017,8 +1012,6 @@ fallback_zleread(char *lp, char *rp, int ha)
|
||||||
return (unsigned char *)shingetline();
|
return (unsigned char *)shingetline();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !LINKED_XMOD_zle */
|
|
||||||
|
|
||||||
/* compctl entry point pointers. Similar to the ZLE ones. */
|
/* compctl entry point pointers. Similar to the ZLE ones. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#
|
#
|
||||||
# Written by Andrew Main
|
# Written by Andrew Main
|
||||||
#
|
#
|
||||||
|
|
||||||
srcdir=${srcdir-`echo $0|sed 's%/[^/][^/]*$%%'`}
|
srcdir=${srcdir-`echo $0|sed 's%/[^/][^/]*$%%'`}
|
||||||
test "x$srcdir" = "x$0" && srcdir=.
|
test "x$srcdir" = "x$0" && srcdir=.
|
||||||
test "x$srcdir" = "x" && srcdir=.
|
test "x$srcdir" = "x" && srcdir=.
|
||||||
|
@ -18,40 +19,32 @@ trap "rm -f $1; exit 1" 1 2 15
|
||||||
|
|
||||||
exec > $1
|
exec > $1
|
||||||
|
|
||||||
echo "#ifdef DYNAMIC"
|
|
||||||
for x_mod in $x_mods; do
|
for x_mod in $x_mods; do
|
||||||
case $bin_mods in
|
echo "/* non-linked-in known module \`$x_mod' */"
|
||||||
*" $x_mod "*) ;;
|
eval "loc=\$loc_$x_mod"
|
||||||
*) echo "/* non-linked-in known module \`$x_mod' */"
|
unset moddeps autobins autoinfixconds autoprefixconds autoparams
|
||||||
eval "loc=\$loc_$x_mod"
|
unset automathfuncs
|
||||||
unset moddeps autobins autoinfixconds autoprefixconds autoparams
|
. $srcdir/../$loc/${x_mod}.mdd
|
||||||
unset automathfuncs
|
for bin in $autobins; do
|
||||||
. $srcdir/../$loc/${x_mod}.mdd
|
echo " add_autobin(\"$bin\", \"$x_mod\");"
|
||||||
for bin in $autobins; do
|
done
|
||||||
echo " add_autobin(\"$bin\", \"$x_mod\");"
|
for cond in $autoinfixconds; do
|
||||||
done
|
echo " add_autocond(\"$cond\", 1, \"$x_mod\");"
|
||||||
for cond in $autoinfixconds; do
|
done
|
||||||
echo " add_autocond(\"$cond\", 1, \"$x_mod\");"
|
for cond in $autoprefixconds; do
|
||||||
done
|
echo " add_autocond(\"$cond\", 0, \"$x_mod\");"
|
||||||
for cond in $autoprefixconds; do
|
done
|
||||||
echo " add_autocond(\"$cond\", 0, \"$x_mod\");"
|
for param in $autoparams; do
|
||||||
done
|
echo " add_autoparam(\"$param\", \"$x_mod\");"
|
||||||
for param in $autoparams; do
|
done
|
||||||
echo " add_autoparam(\"$param\", \"$x_mod\");"
|
for mfunc in $automathfuncs; do
|
||||||
done
|
echo " add_automath(\"$mfunc\", \"$x_mod\");"
|
||||||
for mfunc in $automathfuncs; do
|
done
|
||||||
echo " add_automath(\"$mfunc\", \"$x_mod\");"
|
for dep in $moddeps; do
|
||||||
done
|
echo " add_dep(\"$x_mod\", \"$dep\");"
|
||||||
for dep in $moddeps; do
|
done
|
||||||
case $bin_mods in
|
|
||||||
*" $dep "*)
|
|
||||||
echo " /* depends on \`$dep' */" ;;
|
|
||||||
*) echo " add_dep(\"$x_mod\", \"$dep\");" ;;
|
|
||||||
esac
|
|
||||||
done ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
echo "#endif /* DYNAMIC */"
|
|
||||||
echo
|
echo
|
||||||
done_mods=" "
|
done_mods=" "
|
||||||
for bin_mod in $bin_mods; do
|
for bin_mod in $bin_mods; do
|
||||||
|
@ -68,6 +61,15 @@ for bin_mod in $bin_mods; do
|
||||||
exit 1 ;;
|
exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
echo " register_module(mod.nam = \"$bin_mod\"); setup_$bin_mod(&mod); boot_$bin_mod(&mod);"
|
echo " {"
|
||||||
|
echo " extern int setup_${bin_mod} _((Module));"
|
||||||
|
echo " extern int boot_${bin_mod} _((Module));"
|
||||||
|
echo " extern int cleanup_${bin_mod} _((Module));"
|
||||||
|
echo " extern int finish_${bin_mod} _((Module));"
|
||||||
|
echo
|
||||||
|
echo " register_module(\"$bin_mod\","
|
||||||
|
echo " setup_${bin_mod}, boot_${bin_mod},"
|
||||||
|
echo " cleanup_${bin_mod}, finish_${bin_mod});"
|
||||||
|
echo " }"
|
||||||
done_mods="$done_mods$bin_mod "
|
done_mods="$done_mods$bin_mod "
|
||||||
done
|
done
|
||||||
|
|
385
Src/module.c
385
Src/module.c
|
@ -30,10 +30,10 @@
|
||||||
#include "zsh.mdh"
|
#include "zsh.mdh"
|
||||||
#include "module.pro"
|
#include "module.pro"
|
||||||
|
|
||||||
/* List of builtin modules. */
|
/* List of linked-in modules. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
LinkList bltinmodules;
|
LinkList linkedmodules;
|
||||||
|
|
||||||
|
|
||||||
/* The `zsh' module contains all the base code that can't actually be built *
|
/* The `zsh' module contains all the base code that can't actually be built *
|
||||||
|
@ -54,30 +54,55 @@ boot_zsh(Module m)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
int
|
||||||
|
cleanup_zsh(Module m)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
int
|
||||||
|
finish_zsh(Module m)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* This registers a builtin module. */
|
/* This registers a builtin module. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
void
|
void
|
||||||
register_module(char *n)
|
register_module(char *n, Module_func setup, Module_func boot,
|
||||||
|
Module_func cleanup, Module_func finish)
|
||||||
{
|
{
|
||||||
|
Linkedmod m;
|
||||||
|
|
||||||
PERMALLOC {
|
PERMALLOC {
|
||||||
addlinknode(bltinmodules, n);
|
m = (Linkedmod) zalloc(sizeof(*m));
|
||||||
|
|
||||||
|
m->name = ztrdup(n);
|
||||||
|
m->setup = setup;
|
||||||
|
m->boot = boot;
|
||||||
|
m->cleanup = cleanup;
|
||||||
|
m->finish = finish;
|
||||||
|
|
||||||
|
addlinknode(linkedmodules, m);
|
||||||
} LASTALLOC;
|
} LASTALLOC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if a module is linked in. */
|
/* Check if a module is linked in. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
Linkedmod
|
||||||
module_linked(char *name)
|
module_linked(char const *name)
|
||||||
{
|
{
|
||||||
LinkNode node;
|
LinkNode node;
|
||||||
|
|
||||||
for (node = firstnode(bltinmodules); node; incnode(node))
|
for (node = firstnode(linkedmodules); node; incnode(node))
|
||||||
if (!strcmp((char *) getdata(node), name))
|
if (!strcmp(((Linkedmod) getdata(node))->name, name))
|
||||||
return 1;
|
return (Linkedmod) getdata(node);
|
||||||
|
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* addbuiltin() can be used to add a new builtin. It returns zero on *
|
/* addbuiltin() can be used to add a new builtin. It returns zero on *
|
||||||
|
@ -157,9 +182,6 @@ addwrapper(Module m, FuncWrap w)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
|
|
||||||
/* $module_path ($MODULE_PATH) */
|
/* $module_path ($MODULE_PATH) */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -254,6 +276,9 @@ deletewrapper(Module m, FuncWrap w)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
#ifdef DYNAMIC
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
#ifdef AIXDYNAMIC
|
#ifdef AIXDYNAMIC
|
||||||
|
|
||||||
|
@ -271,8 +296,8 @@ load_and_bind(const char *fn)
|
||||||
int err = loadbind(0, (void *) addbuiltin, ret);
|
int err = loadbind(0, (void *) addbuiltin, ret);
|
||||||
for (node = firstnode(modules); !err && node; incnode(node)) {
|
for (node = firstnode(modules); !err && node; incnode(node)) {
|
||||||
Module m = (Module) getdata(node);
|
Module m = (Module) getdata(node);
|
||||||
if (m->handle)
|
if (m->u.handle)
|
||||||
err |= loadbind(0, m->handle, ret);
|
err |= loadbind(0, m->u.handle, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -361,8 +386,6 @@ hpux_dlsym(void *handle, char *name)
|
||||||
# define RTLD_GLOBAL 0
|
# define RTLD_GLOBAL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (*Module_func) _((Module));
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static void *
|
static void *
|
||||||
try_load_module(char const *name)
|
try_load_module(char const *name)
|
||||||
|
@ -414,6 +437,19 @@ do_load_module(char const *name)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
#else /* !DYNAMIC */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static void *
|
||||||
|
do_load_module(char const *name)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
#endif /* !DYNAMIC */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static LinkNode
|
static LinkNode
|
||||||
find_module(const char *name)
|
find_module(const char *name)
|
||||||
|
@ -429,35 +465,38 @@ find_module(const char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
#ifdef DYNAMIC
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
#ifdef AIXDYNAMIC
|
#ifdef AIXDYNAMIC
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
setup_module(Module m)
|
dyn_setup_module(Module m)
|
||||||
{
|
{
|
||||||
return ((int (*)_((int,Module))) m->handle)(0, m);
|
return ((int (*)_((int,Module))) m->u.handle)(0, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
init_module(Module m)
|
dyn_boot_module(Module m)
|
||||||
{
|
{
|
||||||
return ((int (*)_((int,Module))) m->handle)(1, m);
|
return ((int (*)_((int,Module))) m->u.handle)(1, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
cleanup_module(Module m)
|
dyn_cleanup_module(Module m)
|
||||||
{
|
{
|
||||||
return ((int (*)_((int,Module))) m->handle)(2, m);
|
return ((int (*)_((int,Module))) m->u.handle)(2, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
finish_module(Module m)
|
dyn_finish_module(Module m)
|
||||||
{
|
{
|
||||||
return ((int (*)_((int,Module))) m->handle)(3, m);
|
return ((int (*)_((int,Module))) m->u.handle)(3, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -480,19 +519,19 @@ module_func(Module m, char *name, char *name_s)
|
||||||
if ((t = strrchr(s, '.')))
|
if ((t = strrchr(s, '.')))
|
||||||
*t = '\0';
|
*t = '\0';
|
||||||
#ifdef DYNAMIC_NAME_CLASH_OK
|
#ifdef DYNAMIC_NAME_CLASH_OK
|
||||||
fn = (Module_func) dlsym(m->handle, name);
|
fn = (Module_func) dlsym(m->u.handle, name);
|
||||||
#else /* !DYNAMIC_NAME_CLASH_OK */
|
#else /* !DYNAMIC_NAME_CLASH_OK */
|
||||||
if (strlen(s) + 6 > PATH_MAX)
|
if (strlen(s) + 6 > PATH_MAX)
|
||||||
return NULL;
|
return NULL;
|
||||||
sprintf(buf, name_s, s);
|
sprintf(buf, name_s, s);
|
||||||
fn = (Module_func) dlsym(m->handle, buf);
|
fn = (Module_func) dlsym(m->u.handle, buf);
|
||||||
#endif /* !DYNAMIC_NAME_CLASH_OK */
|
#endif /* !DYNAMIC_NAME_CLASH_OK */
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
setup_module(Module m)
|
dyn_setup_module(Module m)
|
||||||
{
|
{
|
||||||
Module_func fn = module_func(m, STR_SETUP, STR_SETUP_S);
|
Module_func fn = module_func(m, STR_SETUP, STR_SETUP_S);
|
||||||
|
|
||||||
|
@ -504,7 +543,7 @@ setup_module(Module m)
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
init_module(Module m)
|
dyn_boot_module(Module m)
|
||||||
{
|
{
|
||||||
Module_func fn = module_func(m, STR_BOOT, STR_BOOT_S);
|
Module_func fn = module_func(m, STR_BOOT, STR_BOOT_S);
|
||||||
|
|
||||||
|
@ -516,7 +555,7 @@ init_module(Module m)
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
cleanup_module(Module m)
|
dyn_cleanup_module(Module m)
|
||||||
{
|
{
|
||||||
Module_func fn = module_func(m, STR_CLEANUP, STR_CLEANUP_S);
|
Module_func fn = module_func(m, STR_CLEANUP, STR_CLEANUP_S);
|
||||||
|
|
||||||
|
@ -531,7 +570,7 @@ cleanup_module(Module m)
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
finish_module(Module m)
|
dyn_finish_module(Module m)
|
||||||
{
|
{
|
||||||
Module_func fn = module_func(m, STR_FINISH, STR_FINISH_S);
|
Module_func fn = module_func(m, STR_FINISH, STR_FINISH_S);
|
||||||
int r;
|
int r;
|
||||||
|
@ -542,42 +581,115 @@ finish_module(Module m)
|
||||||
zwarnnam(m->nam, "no finish function", NULL, 0);
|
zwarnnam(m->nam, "no finish function", NULL, 0);
|
||||||
r = 1;
|
r = 1;
|
||||||
}
|
}
|
||||||
dlclose(m->handle);
|
dlclose(m->u.handle);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
#endif /* !AIXDYNAMIC */
|
#endif /* !AIXDYNAMIC */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
setup_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ?
|
||||||
|
(m->u.linked->setup)(m) : dyn_setup_module(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
boot_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ?
|
||||||
|
(m->u.linked->boot)(m) : dyn_boot_module(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
cleanup_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ?
|
||||||
|
(m->u.linked->cleanup)(m) : dyn_cleanup_module(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
finish_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ?
|
||||||
|
(m->u.linked->finish)(m) : dyn_finish_module(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
#else /* !DYNAMIC */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
setup_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ? (m->u.linked->setup)(m) : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
boot_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ? (m->u.linked->boot)(m) : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
cleanup_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ? (m->u.linked->cleanup)(m) : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static int
|
||||||
|
finish_module(Module m)
|
||||||
|
{
|
||||||
|
return ((m->flags & MOD_LINKED) ? (m->u.linked->finish)(m) : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
#endif /* !DYNAMIC */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
load_module(char const *name)
|
load_module(char const *name)
|
||||||
{
|
{
|
||||||
Module m;
|
Module m;
|
||||||
void *handle;
|
void *handle = NULL;
|
||||||
|
Linkedmod linked;
|
||||||
LinkNode node, n;
|
LinkNode node, n;
|
||||||
|
int set;
|
||||||
if (module_linked(name))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (!(node = find_module(name))) {
|
if (!(node = find_module(name))) {
|
||||||
if (!(handle = do_load_module(name)))
|
if (!(linked = module_linked(name)) &&
|
||||||
return NULL;
|
!(handle = do_load_module(name)))
|
||||||
|
return 0;
|
||||||
m = zcalloc(sizeof(*m));
|
m = zcalloc(sizeof(*m));
|
||||||
m->nam = ztrdup(name);
|
m->nam = ztrdup(name);
|
||||||
m->handle = handle;
|
if (handle) {
|
||||||
m->flags |= MOD_SETUP;
|
m->u.handle = handle;
|
||||||
|
m->flags |= MOD_SETUP;
|
||||||
|
} else {
|
||||||
|
m->u.linked = linked;
|
||||||
|
m->flags |= MOD_SETUP | MOD_LINKED;
|
||||||
|
}
|
||||||
PERMALLOC {
|
PERMALLOC {
|
||||||
node = addlinknode(modules, m);
|
node = addlinknode(modules, m);
|
||||||
} LASTALLOC;
|
} LASTALLOC;
|
||||||
if (setup_module(m) || init_module(m)) {
|
if ((set = setup_module(m)) || boot_module(m)) {
|
||||||
finish_module(m);
|
if (!set)
|
||||||
|
finish_module(m);
|
||||||
remnode(modules, node);
|
remnode(modules, node);
|
||||||
zsfree(m->nam);
|
zsfree(m->nam);
|
||||||
zfree(m, sizeof(*m));
|
zfree(m, sizeof(*m));
|
||||||
m->flags &= ~MOD_SETUP;
|
m->flags &= ~MOD_SETUP;
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
m->flags |= MOD_INIT_S | MOD_INIT_B;
|
||||||
m->flags &= ~MOD_SETUP;
|
m->flags &= ~MOD_SETUP;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -586,7 +698,7 @@ load_module(char const *name)
|
||||||
return 1;
|
return 1;
|
||||||
if (m->flags & MOD_UNLOAD)
|
if (m->flags & MOD_UNLOAD)
|
||||||
m->flags &= ~MOD_UNLOAD;
|
m->flags &= ~MOD_UNLOAD;
|
||||||
else if (m->handle)
|
else if ((m->flags & MOD_LINKED) ? m->u.linked : m->u.handle)
|
||||||
return 1;
|
return 1;
|
||||||
if (m->flags & MOD_BUSY) {
|
if (m->flags & MOD_BUSY) {
|
||||||
zerr("circular dependencies for module %s", name, 0);
|
zerr("circular dependencies for module %s", name, 0);
|
||||||
|
@ -600,24 +712,39 @@ load_module(char const *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
m->flags &= ~MOD_BUSY;
|
m->flags &= ~MOD_BUSY;
|
||||||
if (!m->handle) {
|
if (!m->u.handle) {
|
||||||
if (!(m->handle = do_load_module(name)))
|
handle = NULL;
|
||||||
|
if (!(linked = module_linked(name)) &&
|
||||||
|
!(handle = do_load_module(name)))
|
||||||
return 0;
|
return 0;
|
||||||
m->flags |= MOD_SETUP;
|
if (handle) {
|
||||||
|
m->u.handle = handle;
|
||||||
|
m->flags |= MOD_SETUP;
|
||||||
|
} else {
|
||||||
|
m->u.linked = linked;
|
||||||
|
m->flags |= MOD_SETUP | MOD_LINKED;
|
||||||
|
}
|
||||||
if (setup_module(m)) {
|
if (setup_module(m)) {
|
||||||
finish_module(m->handle);
|
if (handle)
|
||||||
m->handle = NULL;
|
m->u.handle = NULL;
|
||||||
|
else
|
||||||
|
m->u.linked = NULL;
|
||||||
m->flags &= ~MOD_SETUP;
|
m->flags &= ~MOD_SETUP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
m->flags |= MOD_INIT_S;
|
||||||
}
|
}
|
||||||
m->flags |= MOD_SETUP;
|
m->flags |= MOD_SETUP;
|
||||||
if (init_module(m)) {
|
if (boot_module(m)) {
|
||||||
finish_module(m->handle);
|
finish_module(m);
|
||||||
m->handle = NULL;
|
if (m->flags & MOD_LINKED)
|
||||||
|
m->u.linked = NULL;
|
||||||
|
else
|
||||||
|
m->u.handle = NULL;
|
||||||
m->flags &= ~MOD_SETUP;
|
m->flags &= ~MOD_SETUP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
m->flags |= MOD_INIT_B;
|
||||||
m->flags &= ~MOD_SETUP;
|
m->flags &= ~MOD_SETUP;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -638,12 +765,12 @@ require_module(char *nam, char *module, int res, int test)
|
||||||
LinkNode node;
|
LinkNode node;
|
||||||
|
|
||||||
/* First see if the module is linked in. */
|
/* First see if the module is linked in. */
|
||||||
for (node = firstnode(bltinmodules); node; incnode(node)) {
|
for (node = firstnode(linkedmodules); node; incnode(node)) {
|
||||||
if (!strcmp((char *) getdata(node), nam))
|
if (!strcmp((char *) getdata(node), nam))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
node = find_module(module);
|
node = find_module(module);
|
||||||
if (node && (m = ((Module) getdata(node)))->handle &&
|
if (node && (m = ((Module) getdata(node)))->u.handle &&
|
||||||
!(m->flags & MOD_UNLOAD)) {
|
!(m->flags & MOD_UNLOAD)) {
|
||||||
if (test) {
|
if (test) {
|
||||||
zwarnnam(nam, "module %s already loaded.", module, 0);
|
zwarnnam(nam, "module %s already loaded.", module, 0);
|
||||||
|
@ -710,6 +837,47 @@ autoloadscan(HashNode hn, int printflags)
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cleanup and finish all modules. */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
void
|
||||||
|
exit_modules(void)
|
||||||
|
{
|
||||||
|
Module m;
|
||||||
|
char *name;
|
||||||
|
LinkNode node, next, mn, dn;
|
||||||
|
int del, used;
|
||||||
|
|
||||||
|
while (nonempty(modules)) {
|
||||||
|
for (node = firstnode(modules); (next = node); node = next) {
|
||||||
|
incnode(next);
|
||||||
|
del = used = 0;
|
||||||
|
name = ((Module) getdata(node))->nam;
|
||||||
|
for (mn = firstnode(modules); !used && mn; incnode(mn)) {
|
||||||
|
m = (Module) getdata(mn);
|
||||||
|
if (m->deps && m->u.handle)
|
||||||
|
for (dn = firstnode(m->deps); dn; incnode(dn))
|
||||||
|
if (!strcmp((char *) getdata(dn), name)) {
|
||||||
|
if (m->flags & MOD_UNLOAD)
|
||||||
|
del = 1;
|
||||||
|
else {
|
||||||
|
used = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!used) {
|
||||||
|
m = (Module) getdata(node);
|
||||||
|
if (del)
|
||||||
|
m->wrapper++;
|
||||||
|
unload_module(m, NULL, 1);
|
||||||
|
if (del)
|
||||||
|
m->wrapper--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
bin_zmodload(char *nam, char **args, char *ops, int func)
|
bin_zmodload(char *nam, char **args, char *ops, int func)
|
||||||
|
@ -761,13 +929,9 @@ bin_zmodload_exist(char *nam, char **args, char *ops)
|
||||||
Module m;
|
Module m;
|
||||||
|
|
||||||
if (!*args) {
|
if (!*args) {
|
||||||
for (node = firstnode(bltinmodules); node; incnode(node)) {
|
|
||||||
nicezputs((char *) getdata(node), stdout);
|
|
||||||
putchar('\n');
|
|
||||||
}
|
|
||||||
for (node = firstnode(modules); node; incnode(node)) {
|
for (node = firstnode(modules); node; incnode(node)) {
|
||||||
m = (Module) getdata(node);
|
m = (Module) getdata(node);
|
||||||
if (m->handle && !(m->flags & MOD_UNLOAD)) {
|
if (m->u.handle && !(m->flags & MOD_UNLOAD)) {
|
||||||
nicezputs(m->nam, stdout);
|
nicezputs(m->nam, stdout);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
@ -778,13 +942,10 @@ bin_zmodload_exist(char *nam, char **args, char *ops)
|
||||||
|
|
||||||
for (; !ret && *args; args++) {
|
for (; !ret && *args; args++) {
|
||||||
f = 0;
|
f = 0;
|
||||||
for (node = firstnode(bltinmodules);
|
|
||||||
!f && node; incnode(node))
|
|
||||||
f = !strcmp(*args, (char *) getdata(node));
|
|
||||||
for (node = firstnode(modules);
|
for (node = firstnode(modules);
|
||||||
!f && node; incnode(node)) {
|
!f && node; incnode(node)) {
|
||||||
m = (Module) getdata(node);
|
m = (Module) getdata(node);
|
||||||
if (m->handle && !(m->flags & MOD_UNLOAD))
|
if (m->u.handle && !(m->flags & MOD_UNLOAD))
|
||||||
f = !strcmp(*args, m->nam);
|
f = !strcmp(*args, m->nam);
|
||||||
}
|
}
|
||||||
ret = !f;
|
ret = !f;
|
||||||
|
@ -825,7 +986,7 @@ bin_zmodload_dep(char *nam, char **args, char *ops)
|
||||||
m->deps = NULL;
|
m->deps = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m->deps && !m->handle) {
|
if (!m->deps && !m->u.handle) {
|
||||||
remnode(modules, node);
|
remnode(modules, node);
|
||||||
zsfree(m->nam);
|
zsfree(m->nam);
|
||||||
zfree(m, sizeof(*m));
|
zfree(m, sizeof(*m));
|
||||||
|
@ -1111,9 +1272,13 @@ bin_zmodload_param(char *nam, char **args, char *ops)
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
unload_module(Module m, LinkNode node)
|
unload_module(Module m, LinkNode node, int force)
|
||||||
{
|
{
|
||||||
if (m->handle && !(m->flags & MOD_UNLOAD) && cleanup_module(m))
|
if ((m->flags & MOD_INIT_S) &&
|
||||||
|
!(m->flags & MOD_UNLOAD) &&
|
||||||
|
((m->flags & MOD_LINKED) ?
|
||||||
|
(m->u.linked && m->u.linked->cleanup(m)) :
|
||||||
|
(m->u.handle && cleanup_module(m))))
|
||||||
return 1;
|
return 1;
|
||||||
else {
|
else {
|
||||||
int del = (m->flags & MOD_UNLOAD);
|
int del = (m->flags & MOD_UNLOAD);
|
||||||
|
@ -1123,9 +1288,19 @@ unload_module(Module m, LinkNode node)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
m->flags &= ~MOD_UNLOAD;
|
m->flags &= ~MOD_UNLOAD;
|
||||||
if (m->handle)
|
if (m->flags & MOD_INIT_B) {
|
||||||
finish_module(m);
|
if (m->flags & MOD_LINKED) {
|
||||||
m->handle = NULL;
|
if (m->u.linked) {
|
||||||
|
m->u.linked->finish(m);
|
||||||
|
m->u.linked = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m->u.handle) {
|
||||||
|
finish_module(m);
|
||||||
|
m->u.handle = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (del && m->deps) {
|
if (del && m->deps) {
|
||||||
/* The module was unloaded delayed, unload all modules *
|
/* The module was unloaded delayed, unload all modules *
|
||||||
* on which it depended. */
|
* on which it depended. */
|
||||||
|
@ -1145,7 +1320,9 @@ unload_module(Module m, LinkNode node)
|
||||||
|
|
||||||
for (an = firstnode(modules); du && an; incnode(an)) {
|
for (an = firstnode(modules); du && an; incnode(an)) {
|
||||||
am = (Module) getdata(an);
|
am = (Module) getdata(an);
|
||||||
if (am != m && am->handle && am->deps) {
|
if (am != m && am->deps &&
|
||||||
|
((am->flags & MOD_LINKED) ?
|
||||||
|
am->u.linked : am->u.handle)) {
|
||||||
LinkNode sn;
|
LinkNode sn;
|
||||||
|
|
||||||
for (sn = firstnode(am->deps); du && sn;
|
for (sn = firstnode(am->deps); du && sn;
|
||||||
|
@ -1156,11 +1333,11 @@ unload_module(Module m, LinkNode node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (du)
|
if (du)
|
||||||
unload_module(dm, NULL);
|
unload_module(dm, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!m->deps) {
|
if(!m->deps || force) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
for (node = firstnode(modules); node; incnode(node))
|
for (node = firstnode(modules); node; incnode(node))
|
||||||
if (m == (Module) getdata(node))
|
if (m == (Module) getdata(node))
|
||||||
|
@ -1193,7 +1370,7 @@ bin_zmodload_load(char *nam, char **args, char *ops)
|
||||||
|
|
||||||
for (mn = firstnode(modules); mn; incnode(mn)) {
|
for (mn = firstnode(modules); mn; incnode(mn)) {
|
||||||
m = (Module) getdata(mn);
|
m = (Module) getdata(mn);
|
||||||
if (m->deps && m->handle)
|
if (m->deps && m->u.handle)
|
||||||
for (dn = firstnode(m->deps); dn; incnode(dn))
|
for (dn = firstnode(m->deps); dn; incnode(dn))
|
||||||
if (!strcmp((char *) getdata(dn), *args)) {
|
if (!strcmp((char *) getdata(dn), *args)) {
|
||||||
if (m->flags & MOD_UNLOAD)
|
if (m->flags & MOD_UNLOAD)
|
||||||
|
@ -1208,7 +1385,7 @@ bin_zmodload_load(char *nam, char **args, char *ops)
|
||||||
m = (Module) getdata(node);
|
m = (Module) getdata(node);
|
||||||
if (del)
|
if (del)
|
||||||
m->wrapper++;
|
m->wrapper++;
|
||||||
if (unload_module(m, node))
|
if (unload_module(m, node, 0))
|
||||||
ret = 1;
|
ret = 1;
|
||||||
if (del)
|
if (del)
|
||||||
m->wrapper--;
|
m->wrapper--;
|
||||||
|
@ -1223,7 +1400,7 @@ bin_zmodload_load(char *nam, char **args, char *ops)
|
||||||
/* list modules */
|
/* list modules */
|
||||||
for (node = firstnode(modules); node; incnode(node)) {
|
for (node = firstnode(modules); node; incnode(node)) {
|
||||||
m = (Module) getdata(node);
|
m = (Module) getdata(node);
|
||||||
if (m->handle && !(m->flags & MOD_UNLOAD)) {
|
if (m->u.handle && !(m->flags & MOD_UNLOAD)) {
|
||||||
if(ops['L']) {
|
if(ops['L']) {
|
||||||
printf("zmodload ");
|
printf("zmodload ");
|
||||||
if(m->nam[0] == '-')
|
if(m->nam[0] == '-')
|
||||||
|
@ -1245,46 +1422,6 @@ bin_zmodload_load(char *nam, char **args, char *ops)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
#else /* DYNAMIC */
|
|
||||||
|
|
||||||
/* This is the version for shells without dynamic linking. */
|
|
||||||
|
|
||||||
/**/
|
|
||||||
int
|
|
||||||
bin_zmodload(char *nam, char **args, char *ops, int func)
|
|
||||||
{
|
|
||||||
/* We understand only the -e option (and ignore -i). */
|
|
||||||
|
|
||||||
if (ops['e'] || *args) {
|
|
||||||
LinkNode node;
|
|
||||||
|
|
||||||
if (!*args) {
|
|
||||||
for (node = firstnode(bltinmodules); node; incnode(node)) {
|
|
||||||
nicezputs((char *) getdata(node), stdout);
|
|
||||||
putchar('\n');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (; *args; args++) {
|
|
||||||
for (node = firstnode(bltinmodules); node; incnode(node))
|
|
||||||
if (!strcmp(*args, (char *) getdata(node)))
|
|
||||||
break;
|
|
||||||
if (!node) {
|
|
||||||
if (!ops['e'])
|
|
||||||
zerrnam(nam, "cannot load module: `%s'", *args, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* Otherwise we return 1 -- different from the dynamic version. */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**/
|
|
||||||
#endif /* DYNAMIC */
|
|
||||||
|
|
||||||
/* The list of module-defined conditions. */
|
/* The list of module-defined conditions. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -1299,9 +1436,7 @@ Conddef
|
||||||
getconddef(int inf, char *name, int autol)
|
getconddef(int inf, char *name, int autol)
|
||||||
{
|
{
|
||||||
Conddef p;
|
Conddef p;
|
||||||
#ifdef DYNAMIC
|
|
||||||
int f = 1;
|
int f = 1;
|
||||||
#endif
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
for (p = condtab; p; p = p->next) {
|
for (p = condtab; p; p = p->next) {
|
||||||
|
@ -1309,7 +1444,6 @@ getconddef(int inf, char *name, int autol)
|
||||||
!strcmp(name, p->name))
|
!strcmp(name, p->name))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef DYNAMIC
|
|
||||||
if (autol && p && p->module) {
|
if (autol && p && p->module) {
|
||||||
/* This is a definition for an autoloaded condition, load the *
|
/* This is a definition for an autoloaded condition, load the *
|
||||||
* module if we haven't tried that already. */
|
* module if we haven't tried that already. */
|
||||||
|
@ -1322,7 +1456,6 @@ getconddef(int inf, char *name, int autol)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
} while (!p);
|
} while (!p);
|
||||||
return p;
|
return p;
|
||||||
|
@ -1341,11 +1474,9 @@ addconddef(Conddef c)
|
||||||
if (p) {
|
if (p) {
|
||||||
if (!p->module || (p->flags & CONDF_ADDED))
|
if (!p->module || (p->flags & CONDF_ADDED))
|
||||||
return 1;
|
return 1;
|
||||||
#ifdef DYNAMIC
|
|
||||||
/* There is an autoload definition. */
|
/* There is an autoload definition. */
|
||||||
|
|
||||||
deleteconddef(p);
|
deleteconddef(p);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
c->next = condtab;
|
c->next = condtab;
|
||||||
condtab = c;
|
condtab = c;
|
||||||
|
@ -1616,9 +1747,6 @@ deleteparamdefs(char const *nam, Paramdef d, int size)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
|
|
||||||
/* This adds a definition for autoloading a module for a condition. */
|
/* This adds a definition for autoloading a module for a condition. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -1709,9 +1837,6 @@ add_autoparam(char *nam, char *module)
|
||||||
pm->flags |= PM_AUTOLOAD;
|
pm->flags |= PM_AUTOLOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* List of math functions. */
|
/* List of math functions. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -1725,7 +1850,6 @@ getmathfunc(char *name, int autol)
|
||||||
|
|
||||||
for (p = mathfuncs; p; q = p, p = p->next)
|
for (p = mathfuncs; p; q = p, p = p->next)
|
||||||
if (!strcmp(name, p->name)) {
|
if (!strcmp(name, p->name)) {
|
||||||
#ifdef DYNAMIC
|
|
||||||
if (autol && p->module) {
|
if (autol && p->module) {
|
||||||
char *n = dupstring(p->module);
|
char *n = dupstring(p->module);
|
||||||
|
|
||||||
|
@ -1741,7 +1865,6 @@ getmathfunc(char *name, int autol)
|
||||||
|
|
||||||
return getmathfunc(name, 0);
|
return getmathfunc(name, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1790,8 +1913,6 @@ addmathfuncs(char const *nam, MathFunc f, int size)
|
||||||
return hadf ? hads : 1;
|
return hadf ? hads : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
add_automathfunc(char *nam, char *module)
|
add_automathfunc(char *nam, char *module)
|
||||||
|
@ -1859,5 +1980,3 @@ deletemathfuncs(char const *nam, MathFunc f, int size)
|
||||||
}
|
}
|
||||||
return hadf ? hads : 1;
|
return hadf ? hads : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DYNAMIC */
|
|
||||||
|
|
12
Src/params.c
12
Src/params.c
|
@ -203,10 +203,8 @@ IPDEF8("WATCH", &watch, "watch", 0),
|
||||||
IPDEF8("PATH", &path, "path", PM_RESTRICTED),
|
IPDEF8("PATH", &path, "path", PM_RESTRICTED),
|
||||||
IPDEF8("PSVAR", &psvar, "psvar", 0),
|
IPDEF8("PSVAR", &psvar, "psvar", 0),
|
||||||
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
/* MODULE_PATH is not imported for security reasons */
|
/* MODULE_PATH is not imported for security reasons */
|
||||||
IPDEF8("MODULE_PATH", &module_path, "module_path", PM_DONTIMPORT|PM_RESTRICTED),
|
IPDEF8("MODULE_PATH", &module_path, "module_path", PM_DONTIMPORT|PM_RESTRICTED),
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IPDEF9F(A,B,C,D) {NULL,A,D|PM_ARRAY|PM_SPECIAL|PM_DONTIMPORT,BR((void *)B),SFN(arrvarsetfn),GFN(arrvargetfn),stdunsetfn,0,NULL,C,NULL,0}
|
#define IPDEF9F(A,B,C,D) {NULL,A,D|PM_ARRAY|PM_SPECIAL|PM_DONTIMPORT,BR((void *)B),SFN(arrvarsetfn),GFN(arrvargetfn),stdunsetfn,0,NULL,C,NULL,0}
|
||||||
#define IPDEF9(A,B,C) IPDEF9F(A,B,C,0)
|
#define IPDEF9(A,B,C) IPDEF9F(A,B,C,0)
|
||||||
|
@ -234,9 +232,7 @@ IPDEF9("manpath", &manpath, "MANPATH"),
|
||||||
IPDEF9("psvar", &psvar, "PSVAR"),
|
IPDEF9("psvar", &psvar, "PSVAR"),
|
||||||
IPDEF9("watch", &watch, "WATCH"),
|
IPDEF9("watch", &watch, "WATCH"),
|
||||||
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
IPDEF9F("module_path", &module_path, "MODULE_PATH", PM_RESTRICTED),
|
IPDEF9F("module_path", &module_path, "MODULE_PATH", PM_RESTRICTED),
|
||||||
#endif
|
|
||||||
IPDEF9F("path", &path, "PATH", PM_RESTRICTED),
|
IPDEF9F("path", &path, "PATH", PM_RESTRICTED),
|
||||||
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
|
@ -254,10 +250,6 @@ static Param argvparam;
|
||||||
/**/
|
/**/
|
||||||
HashTable paramtab, realparamtab;
|
HashTable paramtab, realparamtab;
|
||||||
|
|
||||||
#ifndef DYNAMIC
|
|
||||||
#define getparamnode gethashnode2
|
|
||||||
#endif /* DYNAMIC */
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
HashTable
|
HashTable
|
||||||
newparamtable(int size, char const *name)
|
newparamtable(int size, char const *name)
|
||||||
|
@ -280,8 +272,6 @@ newparamtable(int size, char const *name)
|
||||||
return ht;
|
return ht;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
|
||||||
#ifdef DYNAMIC
|
|
||||||
/**/
|
/**/
|
||||||
static HashNode
|
static HashNode
|
||||||
getparamnode(HashTable ht, char *nam)
|
getparamnode(HashTable ht, char *nam)
|
||||||
|
@ -302,8 +292,6 @@ getparamnode(HashTable ht, char *nam)
|
||||||
}
|
}
|
||||||
return hn;
|
return hn;
|
||||||
}
|
}
|
||||||
/**/
|
|
||||||
#endif /* DYNAMIC */
|
|
||||||
|
|
||||||
/* Copy a parameter hash table */
|
/* Copy a parameter hash table */
|
||||||
|
|
||||||
|
|
19
Src/zsh.h
19
Src/zsh.h
|
@ -300,6 +300,7 @@ typedef struct funcwrap *FuncWrap;
|
||||||
typedef struct builtin *Builtin;
|
typedef struct builtin *Builtin;
|
||||||
typedef struct nameddir *Nameddir;
|
typedef struct nameddir *Nameddir;
|
||||||
typedef struct module *Module;
|
typedef struct module *Module;
|
||||||
|
typedef struct linkedmod *Linkedmod;
|
||||||
|
|
||||||
typedef struct patprog *Patprog;
|
typedef struct patprog *Patprog;
|
||||||
typedef struct process *Process;
|
typedef struct process *Process;
|
||||||
|
@ -917,7 +918,10 @@ struct builtin {
|
||||||
struct module {
|
struct module {
|
||||||
char *nam;
|
char *nam;
|
||||||
int flags;
|
int flags;
|
||||||
void *handle;
|
union {
|
||||||
|
void *handle;
|
||||||
|
Linkedmod linked;
|
||||||
|
} u;
|
||||||
LinkList deps;
|
LinkList deps;
|
||||||
int wrapper;
|
int wrapper;
|
||||||
};
|
};
|
||||||
|
@ -925,6 +929,19 @@ struct module {
|
||||||
#define MOD_BUSY (1<<0)
|
#define MOD_BUSY (1<<0)
|
||||||
#define MOD_UNLOAD (1<<1)
|
#define MOD_UNLOAD (1<<1)
|
||||||
#define MOD_SETUP (1<<2)
|
#define MOD_SETUP (1<<2)
|
||||||
|
#define MOD_LINKED (1<<3)
|
||||||
|
#define MOD_INIT_S (1<<4)
|
||||||
|
#define MOD_INIT_B (1<<5)
|
||||||
|
|
||||||
|
typedef int (*Module_func) _((Module));
|
||||||
|
|
||||||
|
struct linkedmod {
|
||||||
|
char *name;
|
||||||
|
Module_func setup;
|
||||||
|
Module_func boot;
|
||||||
|
Module_func cleanup;
|
||||||
|
Module_func finish;
|
||||||
|
};
|
||||||
|
|
||||||
/* C-function hooks */
|
/* C-function hooks */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue