|
Packit |
cd2a55 |
/*
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
Copyright 1988, 1989, 1998 The Open Group
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit |
cd2a55 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit |
cd2a55 |
the above copyright notice appear in all copies and that both that
|
|
Packit |
cd2a55 |
copyright notice and this permission notice appear in supporting
|
|
Packit |
cd2a55 |
documentation.
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
The above copyright notice and this permission notice shall be included in
|
|
Packit |
cd2a55 |
all copies or substantial portions of the Software.
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
cd2a55 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
cd2a55 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit |
cd2a55 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit |
cd2a55 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit |
cd2a55 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit |
cd2a55 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit |
cd2a55 |
in this Software without prior written authorization from The Open Group.
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
*/
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
/* Created By: Chris D. Peterson
|
|
Packit |
cd2a55 |
* MIT X Consortium
|
|
Packit |
cd2a55 |
* Date: May 8, 1989
|
|
Packit |
cd2a55 |
*/
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
cd2a55 |
#include <config.h>
|
|
Packit |
cd2a55 |
#endif
|
|
Packit |
cd2a55 |
#include <X11/Intrinsic.h>
|
|
Packit |
cd2a55 |
#include <X11/Xmu/Initer.h>
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
struct InitializerList {
|
|
Packit |
cd2a55 |
XmuInitializerProc function; /* function to call */
|
|
Packit |
cd2a55 |
XPointer data; /* Data to pass the function. */
|
|
Packit |
cd2a55 |
XtAppContext * app_con_list; /* a null terminated list of app_contexts. */
|
|
Packit |
cd2a55 |
};
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
/*
|
|
Packit |
cd2a55 |
* Prototypes
|
|
Packit |
cd2a55 |
*/
|
|
Packit |
cd2a55 |
static Bool AddToAppconList(XtAppContext**, XtAppContext);
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
static struct InitializerList * init_list = NULL;
|
|
Packit |
cd2a55 |
static Cardinal init_list_length = 0;
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
void
|
|
Packit |
cd2a55 |
XmuAddInitializer(XmuInitializerProc func, XPointer data)
|
|
Packit |
cd2a55 |
{
|
|
Packit |
cd2a55 |
init_list_length++;
|
|
Packit |
cd2a55 |
init_list = (struct InitializerList *) XtRealloc( (char *) init_list,
|
|
Packit |
cd2a55 |
(sizeof(struct InitializerList) *
|
|
Packit |
cd2a55 |
init_list_length) );
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
init_list[init_list_length - 1].function = func;
|
|
Packit |
cd2a55 |
init_list[init_list_length - 1].data = data;
|
|
Packit |
cd2a55 |
init_list[init_list_length - 1].app_con_list = NULL;
|
|
Packit |
cd2a55 |
}
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
void
|
|
Packit |
cd2a55 |
XmuCallInitializers(XtAppContext app_con)
|
|
Packit |
cd2a55 |
{
|
|
Packit |
cd2a55 |
unsigned i;
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
for (i = 0 ; i < init_list_length ; i++) {
|
|
Packit |
cd2a55 |
if (AddToAppconList(&(init_list[i].app_con_list), app_con))
|
|
Packit |
cd2a55 |
(init_list[i].function) (app_con, init_list[i].data);
|
|
Packit |
cd2a55 |
}
|
|
Packit |
cd2a55 |
}
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
/*
|
|
Packit |
cd2a55 |
* Function:
|
|
Packit |
cd2a55 |
* AddToAppconList
|
|
Packit |
cd2a55 |
*
|
|
Packit |
cd2a55 |
* Parameters:
|
|
Packit |
cd2a55 |
* app_list - NULL terminated list of application contexts
|
|
Packit |
cd2a55 |
* app_con - application context to test
|
|
Packit |
cd2a55 |
*
|
|
Packit |
cd2a55 |
* Description:
|
|
Packit |
cd2a55 |
* Adds an action to the application context list and
|
|
Packit |
cd2a55 |
* returns True, if this app_con is already on the list then
|
|
Packit |
cd2a55 |
* it is NOT added and False is returned.
|
|
Packit |
cd2a55 |
*
|
|
Packit |
cd2a55 |
* Returns:
|
|
Packit |
cd2a55 |
* True if not found, False if found
|
|
Packit |
cd2a55 |
*/
|
|
Packit |
cd2a55 |
static Bool
|
|
Packit |
cd2a55 |
AddToAppconList(XtAppContext **app_list, XtAppContext app_con)
|
|
Packit |
cd2a55 |
{
|
|
Packit |
cd2a55 |
int i;
|
|
Packit |
cd2a55 |
XtAppContext *local_list;
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
i = 0;
|
|
Packit |
cd2a55 |
local_list = *app_list;
|
|
Packit |
cd2a55 |
if (*app_list != NULL) {
|
|
Packit |
cd2a55 |
for ( ; *local_list != NULL ; i++, local_list++) {
|
|
Packit |
cd2a55 |
if (*local_list == app_con)
|
|
Packit |
cd2a55 |
return (False);
|
|
Packit |
cd2a55 |
}
|
|
Packit |
cd2a55 |
}
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
*app_list = (XtAppContext *) XtRealloc((char *)(*app_list),
|
|
Packit |
cd2a55 |
sizeof(XtAppContext *) * (i + 2) );
|
|
Packit |
cd2a55 |
(*app_list)[i++] = app_con;
|
|
Packit |
cd2a55 |
(*app_list)[i] = NULL;
|
|
Packit |
cd2a55 |
|
|
Packit |
cd2a55 |
return (True);
|
|
Packit |
cd2a55 |
}
|
|
Packit |
cd2a55 |
|