Exemplo n.º 1
0
XtCacheRef *_XtGetResources(
    register 	Widget	  	w,
    		ArgList	  	args,
    		Cardinal  	num_args,
		XtTypedArgList	typed_args,
		Cardinal*	num_typed_args)
{
    XrmName	    *names, names_s[50];
    XrmClass	    *classes, classes_s[50];
    XrmQuark	    quark_cache[100];
    XrmQuarkList    quark_args;
    WidgetClass     wc;
    ConstraintWidgetClass   cwc;
    XtCacheRef	    *cache_refs, *cache_refs_core;
    Cardinal	    count;

    wc = XtClass(w);

    count = CountTreeDepth(w);
    names = (XrmName*) XtStackAlloc (count * sizeof(XrmName), names_s);
    classes = (XrmClass*) XtStackAlloc (count * sizeof(XrmClass), classes_s);
    if (names == NULL || classes == NULL) _XtAllocError(NULL);

    /* Get names, classes for widget and ancestors */
    GetNamesAndClasses(w, names, classes);
   
    /* Compile arg list into quarks */
    CacheArgs(args, num_args, typed_args, *num_typed_args, quark_cache,
	      XtNumber(quark_cache), &quark_args);

    /* Get normal resources */
    LOCK_PROCESS;
    cache_refs = GetResources(w, (char*)w, names, classes,
	(XrmResourceList *) wc->core_class.resources,
	wc->core_class.num_resources, quark_args, args, num_args,
	typed_args, num_typed_args, XtIsWidget(w));

    if (w->core.constraints != NULL) {
	cwc = (ConstraintWidgetClass) XtClass(w->core.parent);
	cache_refs_core =
	    GetResources(w, (char*)w->core.constraints, names, classes,
	    (XrmResourceList *) cwc->constraint_class.resources,
	    cwc->constraint_class.num_resources,
	    quark_args, args, num_args, typed_args, num_typed_args, False);
	if (cache_refs_core) {
	    XtFree((char *)cache_refs_core);
	}
    }
    FreeCache(quark_cache, quark_args);
    UNLOCK_PROCESS;
    XtStackFree((XtPointer)names, names_s);
    XtStackFree((XtPointer)classes, classes_s);
    return cache_refs;
} /* _XtGetResources */
Exemplo n.º 2
0
static void InitFds (
    XtAppContext app,
    Boolean ignoreEvents,
    Boolean ignoreInputs,
    wait_fds_ptr_t wf)
{
    int ii;
    app->rebuild_fdlist = FALSE;
#ifndef USE_POLL
    wf->nfds = app->fds.nfds;
    if( !ignoreInputs ) {
	wf->rmask = app->fds.rmask;
	wf->wmask = app->fds.wmask;
	wf->emask = app->fds.emask;
     } else
	wf->rmask = wf->wmask = wf->emask = zero_fd;

     if (!ignoreEvents)
	for (ii = 0; ii < app->count; ii++) {
	    FD_SET (ConnectionNumber(app->list[ii]), &wf->rmask);
	}
#else
#ifndef POLLRDNORM
#define POLLRDNORM 0
#endif

#ifndef POLLRDBAND
#define POLLRDBAND 0
#endif

#ifndef POLLWRNORM
#define POLLWRNORM 0
#endif

#ifndef POLLWRBAND
#define POLLWRBAND 0
#endif

#define XPOLL_READ (POLLIN|POLLRDNORM|POLLPRI|POLLRDBAND)
#define XPOLL_WRITE (POLLOUT|POLLWRNORM|POLLWRBAND)
#define XPOLL_EXCEPT 0

    if (!ignoreEvents)
	wf->fdlistlen = wf->num_dpys = app->count;
    else
	wf->fdlistlen = wf->num_dpys = 0;

    if (!ignoreInputs && app->input_list != NULL) {
	int ii;
	for (ii = 0; ii < (int) app->input_max; ii++)
	    if (app->input_list[ii] != NULL)
		wf->fdlistlen++;
    }

    if (!wf->fdlist || wf->fdlist == wf->stack) {
	wf->fdlist = (struct pollfd*)
	    XtStackAlloc (sizeof (struct pollfd) * wf->fdlistlen, wf->stack);
    } else {
	wf->fdlist = (struct pollfd*)
	    XtRealloc ((char*) wf->fdlist,
		       sizeof (struct pollfd) * wf->fdlistlen);
    }

    if (wf->fdlistlen) {
	struct pollfd* fdlp = wf->fdlist;
	InputEvent* iep;

	if (!ignoreEvents)
	    for (ii = 0 ; ii < wf->num_dpys; ii++, fdlp++) {
		fdlp->fd = ConnectionNumber (app->list[ii]);
		fdlp->events = POLLIN;
	    }
	if (!ignoreInputs && app->input_list != NULL)
	    for (ii = 0; ii < app->input_max; ii++)
		if (app->input_list[ii] != NULL) {
		    iep = app->input_list[ii];
		    fdlp->fd = ii;
		    fdlp->events = 0;
		    for ( ; iep; iep = iep->ie_next) {
			if (iep->ie_condition & XtInputReadMask)
			    fdlp->events |= XPOLL_READ;
			if (iep->ie_condition & XtInputWriteMask)
			    fdlp->events |= XPOLL_WRITE;
			if (iep->ie_condition & XtInputExceptMask)
			    fdlp->events |= XPOLL_EXCEPT;
		    }
		    fdlp++;
		}
    }
#endif
}
Exemplo n.º 3
0
static int AccessFile (
    char* path,
    char* pathbuf,
    int len_pathbuf,
    char** pathret)
{
    unsigned long drives;
    int i, len;
    char* drive;
    char buf[MAX_PATH];
    char* bufp;

    /* just try the "raw" name first and see if it works */
    if (access_file (path, pathbuf, len_pathbuf, pathret))
        return 1;

#if defined(WIN32) && defined(__MINGW32__)
    /* don't try others */
    return 0;
#endif

    /* try the places set in the environment */
    drive = getenv ("_XBASEDRIVE");
#ifdef __UNIXOS2__
    if (!drive)
        drive = getenv ("X11ROOT");
#endif
    if (!drive)
        drive = "C:";
    len = strlen (drive) + strlen (path);
    bufp = XtStackAlloc (len + 1, buf);
    strcpy (bufp, drive);
    strcat (bufp, path);
    if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
        XtStackFree (bufp, buf);
        return 1;
    }

#ifndef __UNIXOS2__
    /* one last place to look */
    drive = getenv ("HOMEDRIVE");
    if (drive) {
        len = strlen (drive) + strlen (path);
        bufp = XtStackAlloc (len + 1, buf);
        strcpy (bufp, drive);
        strcat (bufp, path);
        if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
            XtStackFree (bufp, buf);
            return 1;
        }
    }

    /* does OS/2 (with or with gcc-emx) have getdrives()? */
    /* tried everywhere else, go fishing */
    drives = _getdrives ();
#define C_DRIVE ('C' - 'A')
#define Z_DRIVE ('Z' - 'A')
    for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
        if ((1 << i) & drives) {
            len = 2 + strlen (path);
            bufp = XtStackAlloc (len + 1, buf);
            *bufp = 'A' + i;
            *(bufp + 1) = ':';
            *(bufp + 2) = '\0';
            strcat (bufp, path);
            if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
                XtStackFree (bufp, buf);
                return 1;
            }
        }
    }
#endif
    return 0;
}