3 Copyright 1988, 1989, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
27 /* Created By: Chris D. Peterson
35 #include <X11/Intrinsic.h>
36 #include <X11/Xmu/Initer.h>
38 struct InitializerList {
39 XmuInitializerProc function; /* function to call */
40 XPointer data; /* Data to pass the function. */
41 XtAppContext * app_con_list; /* a null terminated list of app_contexts. */
47 static Bool AddToAppconList(XtAppContext**, XtAppContext);
49 static struct InitializerList * init_list = NULL;
50 static Cardinal init_list_length = 0;
53 XmuAddInitializer(XmuInitializerProc func, XPointer data)
56 init_list = (struct InitializerList *) XtRealloc( (char *) init_list,
57 (sizeof(struct InitializerList) *
60 init_list[init_list_length - 1].function = func;
61 init_list[init_list_length - 1].data = data;
62 init_list[init_list_length - 1].app_con_list = NULL;
66 XmuCallInitializers(XtAppContext app_con)
70 for (i = 0 ; i < init_list_length ; i++) {
71 if (AddToAppconList(&(init_list[i].app_con_list), app_con))
72 (init_list[i].function) (app_con, init_list[i].data);
81 * app_list - NULL terminated list of application contexts
82 * app_con - application context to test
85 * Adds an action to the application context list and
86 * returns True, if this app_con is already on the list then
87 * it is NOT added and False is returned.
90 * True if not found, False if found
93 AddToAppconList(XtAppContext **app_list, XtAppContext app_con)
96 XtAppContext *local_list;
99 local_list = *app_list;
100 if (*app_list != NULL) {
101 for ( ; *local_list != NULL ; i++, local_list++) {
102 if (*local_list == app_con)
107 *app_list = (XtAppContext *) XtRealloc((char *)(*app_list),
108 sizeof(XtAppContext *) * (i + 2) );
109 (*app_list)[i++] = app_con;
110 (*app_list)[i] = NULL;