2 * Copyright (C) 2003-2007 Kim Woelders
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies of the Software, its documentation and marketing & publicity
13 * materials, and acknowledgment shall be given in the documentation, materials
14 * and software packages that this Software was used.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #if 0 /* No dynamic registration yet */
28 EModuleRegister(EModule * em)
30 p_modules = EREALLOC(EModule *, p_modules, n_modules + 1);
31 p_modules[n_modules++] = em;
36 ModuleListGet(int *num)
43 ModuleListFree(const EModule ** lst __UNUSED__)
47 static const EModule *
48 EModuleFind(const char *name)
53 for (i = 0; i < n_modules; i++)
56 if (!strncmp(name, pm->name, 4) ||
57 (pm->nick && !strcmp(name, pm->nick)))
64 ModuleConfigSet(const char *name, const char *item, const char *params)
68 em = EModuleFind(name);
75 CfgItemListNamedItemSet(em->cfg.lst, em->cfg.num, item, params);
81 EmodCfgItemShow(const EModule * em, const CfgItem * ci)
88 CfgItemToString(ci, buf, sizeof(buf));
89 IpcPrintf(" %s.%s = %s\n", em->name, ci->name, buf);
93 EmodCfgNamedItemShow(const EModule * em, const char *item)
97 ci = CfgItemFind(em->cfg.lst, em->cfg.num, item);
99 EmodCfgItemShow(em, ci);
101 IpcPrintf("! %s.%s *** Not found ***\n", em->name, item);
105 ModuleConfigShow(const char *name, const char *item)
111 Eprintf("ModuleConfigShow: %s:%s\n", name, item);
113 em = EModuleFind(name);
119 EmodCfgNamedItemShow(em, item);
123 for (i = 0; i < em->cfg.num; i++)
124 EmodCfgItemShow(em, em->cfg.lst + i);
131 ModulesSignal(int sig, void *prm)
135 for (i = 0; i < n_modules; i++)
136 if (p_modules[i]->Signal)
137 p_modules[i]->Signal(sig, prm);
142 ModulesGetCfgItems(const CfgItem *** ppi, int *pni)
149 for (i = 0; i < n_modules; i++)
151 if (p_modules[i]->cfg.lst)
153 n = p_modules[i]->cfg.num;
154 pi = EREALLOC(CfgItem *, pi, k + n);
155 for (j = 0; j < n; j++)
156 pi[k++] = &(p_modules[i]->cfg.lst[j]);
165 ModulesGetIpcItems(const IpcItem *** ppi, int *pni)
172 for (i = 0; i < n_modules; i++)
174 if (p_modules[i]->ipc.lst)
176 n = p_modules[i]->ipc.num;
177 pi = EREALLOC(const IpcItem *, pi, k + n);
179 for (j = 0; j < n; j++)
180 pi[k++] = &(p_modules[i]->ipc.lst[j]);
188 ModulesConfigShow(void)
193 /* Load module configs */
194 pml = ModuleListGet(&nml);
195 for (i = 0; i < nml; i++)
197 /* Somewhat inefficient but ... later */
198 ModuleConfigShow(pml[i]->name, NULL);