Exemple #1
0
static int mavis_init_in(mavis_ctx * mcx)
{
    int i;

    DebugIn(DEBUG_MAVIS);

    mcx->lastdump = mcx->startup_time = time(NULL);

    if (!mcx->path)
	logmsg("Warning: %s: module lacks path definition", MAVIS_name);
    else if (!mcx->argv[0]) {
	mcx->argv[0] = Xstrdup(basename(mcx->path));
	mcx->argv[1] = NULL;
    }

    if (mcx->child_min > mcx->child_max)
	mcx->child_min = mcx->child_max;

    if (!mcx->io_context_parent)
	mcx->io_context_local = mcx->io = io_init();
    mcx->cx = Xcalloc(mcx->child_max, sizeof(struct context *));
    mcx->cx_stat = Xcalloc(mcx->child_max, sizeof(struct context_stat));
    for (i = 0; i < mcx->child_min; i++)
	fork_child(mcx, i);

    mcx->backlog_serial = RB_tree_new(compare_serial, NULL);
    mcx->backlog_app_ctx = RB_tree_new(compare_app_ctx, NULL);
    mcx->backlog_fifo = RB_tree_new(compare_fifo, free_payload);
    mcx->outgoing = RB_tree_new(compare_app_ctx, free_payload);
    mcx->junkcontexts = RB_tree_new(compare_ctx, free_context);

    DebugOut(DEBUG_MAVIS);
    return MAVIS_INIT_OK;
}
Exemple #2
0
Atom
XInternAtom(Display * display, _Xconst char *atom_name, Bool only_if_exists)
{
	unsigned char hash = hash_str(atom_name);
	struct hash_t *val;

	for (val = hash_list[hash]; val; val = val->next)
		if (strcmp(val->name, atom_name) == 0) {
			return val->atom;
		}

	if (only_if_exists == True)
		return None;

	if (!hash_list[hash])
		val = hash_list[hash] =
			(struct hash_t *) Xcalloc(1, sizeof(struct hash_t));
	else {
		struct hash_t *h = hash_list[hash];
		while (h->next)
			h = h->next;
		val = h->next =
			(struct hash_t *) Xcalloc(1, sizeof(struct hash_t));
	}

	val->name = strdup(atom_name);
	val->atom = atom_id++;
	return val->atom;
}
Exemple #3
0
static void ResizeTable(DB db)
{
    TableEntry *otable;
    register TableEntry entry, next, *pold, *head;
    register int i, j;

    otable = db->table;
    for (i = INITHASHMASK+1; (i + i) < db->numentries; )
	i += i;
    db->table = Xcalloc(i, sizeof(TableEntry));
    if (!db->table) {
	db->table = otable;
	return;
    }
    j = db->mask + 1;
    db->mask = i - 1;
    for (pold = otable ; --j >= 0; pold++) {
	for (entry = *pold; entry; entry = next) {
	    next = entry->next;
	    head = &Hash(db, entry->rid, entry->context);
	    entry->next = *head;
	    *head = entry;
	}
    }
    Xfree((char *) otable);
}
/*
 * XCreateAssocTable - Create an XAssocTable.  The size argument should be
 * a power of two for efficiency reasons.  Some size suggestions: use 32
 * buckets per 100 objects;  a reasonable maximum number of object per
 * buckets is 8.  If there is an error creating the XAssocTable, a NULL
 * pointer is returned.
 */
XAssocTable *XCreateAssocTable(int size)
{
	register XAssocTable *table;	/* XAssocTable to be initialized. */
	register XAssoc *buckets;	/* Pointer to the first bucket in */
					/* the bucket array. */
	
	/* XMalloc the XAssocTable. */
	if ((table = (XAssocTable *)Xmalloc(sizeof(XAssocTable))) == NULL) {
		/* XMalloc call failed! */
		errno = ENOMEM;
		return(NULL);
	}
	
	/* XMalloc the buckets (actually just their headers). */
	buckets = (XAssoc *)Xcalloc((unsigned)size, (unsigned)sizeof(XAssoc));
	if (buckets == NULL) {
		/* XCalloc call failed! */
		errno = ENOMEM;
		return(NULL);
	}

	/* Insert table data into the XAssocTable structure. */
	table->buckets = buckets;
	table->size = size;

	while (--size >= 0) {
		/* Initialize each bucket. */
		buckets->prev = buckets;
		buckets->next = buckets;
		buckets++;
	}

	return(table);
}
Exemple #5
0
XExtCodes *XInitExtension (
	Display *dpy,
	_Xconst char *name)
{
	XExtCodes codes;	/* temp. place for extension information. */
	register _XExtension *ext;/* need a place to build it all */
	if (!XQueryExtension(dpy, name,
		&codes.major_opcode, &codes.first_event,
		&codes.first_error)) return (NULL);

	LockDisplay (dpy);
	if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) ||
	    ! (ext->name = strdup(name))) {
	    if (ext) Xfree((char *) ext);
	    UnlockDisplay(dpy);
	    return (XExtCodes *) NULL;
	}
	codes.extension = dpy->ext_number++;
	ext->codes = codes;

	/* chain it onto the display list */
	ext->next = dpy->ext_procs;
	dpy->ext_procs = ext;
	UnlockDisplay (dpy);

	return (&ext->codes);		/* tell him which extension */
}
Exemple #6
0
static void LoadGameList(void)
{
    for (size_t i = 0; i < ARRAY_SIZE(internalgrpfiles); i++)
    {
        grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));

        fg->name = Xstrdup(internalgrpfiles[i].name);
        fg->crcval = internalgrpfiles[i].crcval;
        fg->size = internalgrpfiles[i].size;
        fg->game = internalgrpfiles[i].game;
        fg->dependency = internalgrpfiles[i].dependency;

        if (internalgrpfiles[i].scriptname)
            fg->scriptname = dup_filename(internalgrpfiles[i].scriptname);

        if (internalgrpfiles[i].defname)
            fg->defname = dup_filename(internalgrpfiles[i].defname);

        fg->postprocessing = internalgrpfiles[i].postprocessing;

        fg->next = listgrps;
        listgrps = fg;
    }

    CACHE1D_FIND_REC * const srch = klistpath("/", "*.grpinfo", CACHE1D_FIND_FILE);

    for (CACHE1D_FIND_REC *sidx = srch; sidx; sidx = sidx->next)
        LoadList(sidx->name);

    klistfree(srch);
}
Exemple #7
0
static GLboolean
AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
{
   __GLXscreenConfigs *psc;
   GLint i, screens;

   /*
    ** First allocate memory for the array of per screen configs.
    */
   screens = ScreenCount(dpy);
   priv->screenConfigs = Xmalloc(screens * sizeof *priv->screenConfigs);
   if (!priv->screenConfigs) {
      return GL_FALSE;
   }

   priv->serverGLXversion =
      __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
   if (priv->serverGLXversion == NULL) {
      FreeScreenConfigs(priv);
      return GL_FALSE;
   }

   for (i = 0; i < screens; i++) {
      psc = Xcalloc(1, sizeof *psc);
      if (!psc)
         return GL_FALSE;
      getFBConfigs(psc, priv, i);
      priv->screenConfigs[i] = psc;
   }

   SyncHandle();

   return GL_TRUE;
}
Exemple #8
0
Region
XPolygonRegion(XPoint *points, int n, int rule)
{
	Region		region;
	int		i;
	GR_POINT *	local;

	region = (Region)Xcalloc(1, sizeof(Region *));
	if (!region)
		return NULL;

	/* must copy points, since dimensions differ*/
	local = ALLOCA(n * sizeof(GR_POINT));
	if (!local) {
		Xfree(region);
		return 0;
	}

	for (i=0; i < n; i++) {
		local[i].x = points[i].x;
		local[i].y = points[i].y;
	}

	/* convert rule to NX format*/
	rule = (rule == EvenOddRule)? GR_POLY_EVENODD: GR_POLY_WINDING;

	region->rid = GrNewPolygonRegion(rule, n, local);
	FREEA(local);

	return region;
}
Exemple #9
0
static int32_t LoadGroupsCache(void)
{
    struct grpcache *fg;

    int32_t fsize, fmtime, fcrcval;
    char *fname;

    scriptfile *script;

    script = scriptfile_fromfile(GRPCACHEFILE);
    if (!script) return -1;

    while (!scriptfile_eof(script))
    {
        if (scriptfile_getstring(script, &fname)) break;    // filename
        if (scriptfile_getnumber(script, &fsize)) break;    // filesize
        if (scriptfile_getnumber(script, &fmtime)) break;   // modification time
        if (scriptfile_getnumber(script, &fcrcval)) break;  // crc checksum

        fg = (struct grpcache *)Xcalloc(1, sizeof(struct grpcache));
        fg->next = grpcache;
        grpcache = fg;

        Bstrncpy(fg->name, fname, BMAX_PATH);
        fg->size = fsize;
        fg->mtime = fmtime;
        fg->crcval = fcrcval;
    }

    scriptfile_close(script);
    return 0;
}
Exemple #10
0
static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth)
{
    const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1);
    pthtyp *pth;

    // load from art
    for (pth=texcache.list[j]; pth; pth=pth->next)
        if (pth->picnum == dapicnum && pth->palnum == dapalnum && pth->shade == dashade && 
                (pth->flags & (PTH_CLAMPED+PTH_HIGHTILE)) == TO_PTH_CLAMPED(dameth) &&
                polymost_want_npotytex(dameth, tilesiz[dapicnum].y) == !!(pth->flags&PTH_NPOTWALL)
           )
        {
            if (pth->flags & PTH_INVALIDATED)
            {
                pth->flags &= ~PTH_INVALIDATED;
                gloadtile_art(dapicnum, dapalnum, dashade, dameth, pth, 0);
            }

            return(pth);
        }

    pth = (pthtyp *)Xcalloc(1,sizeof(pthtyp));

    gloadtile_art(dapicnum,dapalnum,dashade,dameth,pth,1);

    pth->next = texcache.list[j];
    texcache.list[j] = pth;

    return(pth);
}
/*
 *	NAME
 *		LoadColornameDB - Load the Color Name Database
 *
 *	SYNOPSIS
 */
static Status
LoadColornameDB(void)
/*
 *	DESCRIPTION
 *		Loads the Color Name Database from a text file.
 *
 *	RETURNS
 *		XcmsSuccess if succeeded, otherwise XcmsFailure.
 *
 */
{
    int size;
    FILE *stream;
    char *pathname;
    struct stat txt;
    int length;

    /* use and name of this env var is not part of the standard */
    /* implementation-dependent feature */
    if ((pathname = getenv("XCMSDB")) == NULL) {
	pathname = XCMSDB;
    }
#ifdef __UNIXOS2__
    pathname = __XOS2RedirRoot(pathname);
#endif

    length = strlen(pathname);
    if ((length == 0) || (length >= (BUFSIZ - 5))){
	XcmsColorDbState = XcmsDbInitFailure;
	return(XcmsFailure);
    }

    if (stat(pathname, &txt)) {
	/* can't stat file */
	XcmsColorDbState = XcmsDbInitFailure;
	return(XcmsFailure);
    }

    if ((stream = _XFopenFile (pathname, "r")) == NULL) {
	return(XcmsFailure);
    }

    stringSectionSize(stream, &nEntries, &size);
    rewind(stream);

    strings = (char *) Xmalloc(size);
    pairs = (XcmsPair *)Xcalloc(nEntries, sizeof(XcmsPair));

    ReadColornameDB(stream, pairs, strings);
    (void) fclose(stream);

    /*
     * sort the pair recs
     */
    qsort((char *)pairs, nEntries, sizeof(XcmsPair), FirstCmp);

    XcmsColorDbState = XcmsDbInitSuccess;
    return(XcmsSuccess);
}
Exemple #12
0
/* Creates a new XlcCharSet, given its name (including side suffix) and
   Compound Text ESC sequence (normally at most 4 bytes). */
XlcCharSet
_XlcCreateDefaultCharSet(
    const char *name,
    const char *ct_sequence)
{
    XlcCharSet charset;
    int name_len, ct_sequence_len;
    const char *colon;
    char *tmp;

    charset = Xcalloc(1, sizeof(XlcCharSetRec));
    if (charset == NULL)
	return (XlcCharSet) NULL;

    name_len = strlen(name);
    ct_sequence_len = strlen(ct_sequence);

    /* Fill in name and xrm_name.  */
    tmp = (char *) Xmalloc(name_len + 1 + ct_sequence_len + 1);
    if (tmp == NULL) {
	Xfree((char *) charset);
	return (XlcCharSet) NULL;
    }
    memcpy(tmp, name, name_len+1);
    charset->name = tmp;
    charset->xrm_name = XrmStringToQuark(charset->name);

    /* Fill in encoding_name and xrm_encoding_name.  */
    if ((colon = strchr(charset->name, ':')) != NULL) {
        unsigned int length = colon - charset->name;
        char *encoding_tmp = (char *) Xmalloc(length + 1);
        if (encoding_tmp == NULL) {
            Xfree((char *) charset->name);
            Xfree((char *) charset);
            return (XlcCharSet) NULL;
        }
        memcpy(encoding_tmp, charset->name, length);
        encoding_tmp[length] = '\0';
        charset->encoding_name = encoding_tmp;
        charset->xrm_encoding_name = XrmStringToQuark(charset->encoding_name);
    } else {
        charset->encoding_name = charset->name;
        charset->xrm_encoding_name = charset->xrm_name;
    }

    /* Fill in ct_sequence.  */
    tmp += name_len + 1;
    memcpy(tmp, ct_sequence, ct_sequence_len+1);
    charset->ct_sequence = tmp;

    /* Fill in side, char_size, set_size. */
    if (!_XlcParseCharSet(charset))
        /* If ct_sequence is not usable in Compound Text, remove it. */
        charset->ct_sequence = "";

    return (XlcCharSet) charset;
}
Exemple #13
0
XClassHint *XAllocClassHint (void)
{
    register XClassHint *h;

    if ((h = (XClassHint *) Xcalloc (1, (unsigned) sizeof (XClassHint))))
      h->res_name = h->res_class = NULL;

    return h;
}
Exemple #14
0
void set_display(Display* dpy) {
  static Depth dlist[1];
  static Visual vlist[1];
  static Screen slist[1];
  static char vstring[] = "libB11";
  Colormap cmap = 0;

  BRect rect;
  display_mode mode;
  BScreen screen;
  screen.GetMode(&mode);
  
  memset(slist, 0, sizeof(Screen));

  dlist[0].depth = mode.space;
  dlist[0].nvisuals = 1;
  dlist[0].visuals  = vlist;

  vlist[0].ext_data     = NULL;
  vlist[0].visualid     = 0;
  vlist[0].c_class       = TrueColor;
  vlist[0].bits_per_rgb = 24;
  vlist[0].map_entries  = 256;
  vlist[0].red_mask     = 255;
  vlist[0].green_mask   = 255 << 8;
  vlist[0].blue_mask    = 255 << 16;
  rect = screen.Frame();
  slist[0].width       = static_cast<int>(rect.right - rect.left);
  slist[0].height      = static_cast<int>(rect.bottom - rect.top);
  slist[0].mwidth      = 260;
  slist[0].mheight     = 190;
  slist[0].ndepths     = 1;
  slist[0].depths      = dlist;
  slist[0].root_depth  = mode.space;
  slist[0].root_visual = vlist;
  slist[0].default_gc  = NULL;
  slist[0].cmap        = cmap;
  slist[0].white_pixel = 0xFFFFFF;
  slist[0].black_pixel = 0;

  slist[0].display = dpy;

  dpy->ext_data            = NULL;
  dpy->fd                  = 0;
  dpy->proto_major_version = 11;
  dpy->proto_minor_version = 4;
  dpy->vendor              = vstring;
  dpy->display_name        = vstring;
  dpy->nscreens            = 1;
  dpy->screens             = slist;
  dpy->max_keycode         = 255;
  dpy->qlen                = 0;
  dpy->head = dpy->tail    = NULL;
  dpy->qfree               = NULL;

  dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1, sizeof(_XFreeFuncRec));
}
Exemple #15
0
Public XIM
_XimOpenIM(
    XLCd		 lcd,
    Display		*dpy,
    XrmDatabase		 rdb,
    char		*res_name,
    char		*res_class)
{
    Xim			 im;
    register int	 i;

    if (!(im = Xcalloc(1, sizeof(XimRec))))
	return (XIM)NULL;

    im->core.lcd       = lcd;
    im->core.ic_chain  = (XIC)NULL;
    im->core.display   = dpy;
    im->core.rdb       = rdb;
    im->core.res_name  = NULL;
    im->core.res_class = NULL;
    if((res_name != NULL) && (*res_name != '\0')){
	if(!(im->core.res_name  = strdup(res_name)))
	    goto Error1;
    }
    if((res_class != NULL) && (*res_class != '\0')){
	if(!(im->core.res_class = strdup(res_class)))
	    goto Error2;
    }
    if(!(im->core.im_name = _XimMakeImName(lcd)))
	goto Error3;

    for(i= 0; ; i++) {
	if(_XimImSportRec[i].checkprocessing(im)) {
	    if(!(_XimImSportRec[i].im_open(im)))
		goto Error4;
	    if(!_XimSetIMStructureList(im))
		goto Error4;
	    return (XIM)im;
	}
    }

Error4 :
    _XimImSportRec[i].im_free(im);
    Xfree(im);
    return NULL;
Error3 :
    if(im->core.im_name)
	Xfree(im->core.im_name);
Error2:
    if(im->core.res_class)
	Xfree(im->core.res_class);
Error1:
    if(im->core.res_name)
	Xfree(im->core.res_name);
    Xfree(im);
    return NULL;
}
Exemple #16
0
pointer
XNFcalloc(unsigned long n)
{
    pointer r;

    r = Xcalloc(n);
    if (!r)
	FatalError("XNFcalloc failed\n");
    return r;
   
}
Exemple #17
0
Region
XCreateRegion(void)
{
	Region		region;

	region = (Region)Xcalloc(1, sizeof(Region *));
	if (!region)
		return NULL;

	region->rid = GrNewRegion();
	return region;
}
Exemple #18
0
/*
 *	NAME
 *		_XcmsInitDefaultCCCs
 *
 *	SYNOPSIS
 */
int
_XcmsInitDefaultCCCs(
    Display *dpy)
/*
 *	DESCRIPTION
 *		Initializes the Xcms per Display Info structure
 *		(XcmsPerDpyInfo).
 *
 *	RETURNS
 *		Returns 0 if failed; otherwise non-zero.
 *
 */
{
    int nScrn = ScreenCount(dpy);
    int i;
    XcmsCCC ccc;

    if (nScrn <= 0) {
	return(0);
    }

    /*
     * Create an array of XcmsCCC structures, one for each screen.
     * They serve as the screen's default CCC.
     */
    if (!(ccc = (XcmsCCC)
	    Xcalloc((unsigned)nScrn, (unsigned) sizeof(XcmsCCCRec)))) {
	return(0);
    }
    dpy->cms.defaultCCCs = (XPointer)ccc;
    dpy->free_funcs->defaultCCCs = _XcmsFreeDefaultCCCs;

    for (i = 0; i < nScrn; i++, ccc++) {
	ccc->dpy = dpy;
	ccc->screenNumber = i;
	ccc->visual = DefaultVisual(dpy, i);
	/*
	 * Used calloc to allocate memory so:
	 *	ccc->clientWhitePt->format == XcmsUndefinedFormat
	 *	ccc->gamutCompProc == NULL
	 *	ccc->whitePtAdjProc == NULL
	 *	ccc->pPerScrnInfo = NULL
	 *
	 * Don't need to create XcmsPerScrnInfo and its functionSet and
	 * pScreenData components until the default CCC is accessed.
	 * Note that the XcmsDefaultCCC routine calls _XcmsInitScrnInto
	 * to do this.
	 */
	ccc->gamutCompProc = XCMSCOMPPROC;
    }

    return(1);
}
Exemple #19
0
int32_t texcache_loadoffsets(void)
{
    int32_t foffset, fsize, i;
    char *fname;

    scriptfile *script;

    Bstrcpy(ptempbuf,TEXCACHEFILE);
    Bstrcat(ptempbuf,".cache");
    script = scriptfile_fromfile(ptempbuf);

    if (!script) return -1;

    while (!scriptfile_eof(script))
    {
        if (scriptfile_getstring(script, &fname)) break;	// hashed filename
        if (scriptfile_getnumber(script, &foffset)) break;	// offset in cache
        if (scriptfile_getnumber(script, &fsize)) break;	// size

        i = hash_find(&texcache.hashes,fname);
        if (i > -1)
        {
            // update an existing entry
            texcacheindex *t = texcache.iptrs[i];
            t->offset = foffset;
            t->len = fsize;
            /*initprintf("%s %d got a match for %s offset %d\n",__FILE__, __LINE__, fname,foffset);*/
        }
        else
        {
            Bstrncpyz(texcache.currentindex->name, fname, BMAX_PATH);
            texcache.currentindex->offset = foffset;
            texcache.currentindex->len = fsize;
            texcache.currentindex->next = (texcacheindex *)Xcalloc(1, sizeof(texcacheindex));
            hash_add(&texcache.hashes, fname, texcache.numentries, 1);
            if (++texcache.numentries > texcache.iptrcnt)
            {
                texcache.iptrcnt += 512;
                texcache.iptrs = (texcacheindex **) Xrealloc(texcache.iptrs, sizeof(intptr_t) * texcache.iptrcnt);
            }
            texcache.iptrs[texcache.numentries-1] = texcache.currentindex;
            texcache.currentindex = texcache.currentindex->next;
        }
    }

    scriptfile_close(script);
    return 0;
}
Exemple #20
0
void RTS_Init(const char *filename)
{
    // open all the files, load headers, and count lumps

    rts_numlumps = 0;
    rts_lumpinfo = NULL;   // will be realloced as lumps are added

    if (RTS_AddFile(filename))
        return;

    if (rts_numlumps == 0)
        return;

    rts_lumpcache = (void **)Xcalloc(rts_numlumps, sizeof(rts_lumpcache[0]));

    RTS_Started = TRUE;
}
Exemple #21
0
XExtCodes *XAddExtension (Display *dpy)
{
    register _XExtension *ext;

    LockDisplay (dpy);
    if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension)))) {
	UnlockDisplay(dpy);
	return (XExtCodes *) NULL;
    }
    ext->codes.extension = dpy->ext_number++;

    /* chain it onto the display list */
    ext->next = dpy->ext_procs;
    dpy->ext_procs = ext;
    UnlockDisplay (dpy);

    return (&ext->codes);		/* tell him which extension */
}
Exemple #22
0
void texcache_init(void)
{
    if (!texcache.index)
        texcache.filehandle = -1;

    texcache_closefiles();
    texcache_clearmemcache();
    texcache_freeptrs();

    texcache.currentindex = texcache.firstindex = (texcacheindex *)Xcalloc(1, sizeof(texcacheindex));
    texcache.numentries = 0;

    //    Bmemset(&firstcacheindex, 0, sizeof(texcacheindex));
    //    Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));

    texcache.hashes.size = TEXCACHEHASHSIZE;
    hash_init(&texcache.hashes);
}
Exemple #23
0
mavis_ctx *Mavis_new(void *handle, struct io_context * io, char *id)
{
    mavis_ctx *mcx = Xcalloc(1, sizeof(mavis_ctx) + strlen(id ? id : MAVIS_name));
    mcx->handle = handle;
    mcx->append = Mavis_append;
    mcx->init = Mavis_init;
    mcx->drop = Mavis_drop;
    mcx->send = Mavis_send;
    mcx->recv = Mavis_recv;
    mcx->parse = Mavis_parse;
    mcx->cancel = Mavis_cancel;
    mcx->io = io;
    strcpy(mcx->identifier, id ? id : MAVIS_name);
#ifdef HAVE_mavis_new
    mavis_new(mcx);
#endif
    return mcx;
}
Exemple #24
0
DPSCAPData
DPSCAPCreate(
    Display *dpy, Display *agent)
{
    register DPSCAPData my = (DPSCAPData)Xcalloc(1, sizeof(DPSCAPDataRec));

    if (my == (DPSCAPData)NULL) return(NULL);
    my->dpy = dpy;
    my->agent = agent;
    my->typePSOutput = XInternAtom(
      dpy,
      DPSCAP_TYPE_PSOUTPUT,
      False);
    my->typePSOutputWithLen = XInternAtom(
      dpy,
      DPSCAP_TYPE_PSOUTPUT_LEN,
      False);
    my->typePSStatus = XInternAtom(
      dpy,
      DPSCAP_TYPE_PSSTATUS,
      False);
    my->typeNoop = XInternAtom(
      dpy,
      DPSCAP_TYPE_NOOP,
      False);
    my->typeSync = XInternAtom(
      dpy,
      DPSCAP_TYPE_SYNC,
      False);
    my->typeXError = XInternAtom(
      dpy,
      DPSCAP_TYPE_XERROR,
      False);
    my->typePSReady = XInternAtom(
      dpy,
      DPSCAP_TYPE_PSREADY,
      False);
    my->typeResume = XInternAtom(
      dpy,
      DPSCAP_TYPE_RESUME,
      False);
    return(my);
}
Exemple #25
0
int
XRebindKeysym (
    Display *dpy,
    KeySym keysym,
    KeySym *mlist,
    int nm,		/* number of modifiers in mlist */
    _Xconst unsigned char *str,
    int nbytes)
{
    register struct _XKeytrans *tmp, *p;
    int nb;

    if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
	return 0;
    LockDisplay(dpy);
    tmp = dpy->key_bindings;
    nb = sizeof(KeySym) * nm;

    if ((! (p = Xcalloc( 1, sizeof(struct _XKeytrans)))) ||
	((! (p->string = Xmalloc(nbytes))) && (nbytes > 0)) ||
	((! (p->modifiers = Xmalloc(nb))) && (nb > 0))) {
	if (p) {
	    if (p->string) Xfree(p->string);
	    if (p->modifiers) Xfree(p->modifiers);
	    Xfree(p);
	}
	UnlockDisplay(dpy);
	return 0;
    }

    dpy->key_bindings = p;
    dpy->free_funcs->key_bindings = _XFreeKeyBindings;
    p->next = tmp;	/* chain onto list */
    memcpy (p->string, str, nbytes);
    p->len = nbytes;
    memcpy ((char *) p->modifiers, (char *) mlist, nb);
    p->key = keysym;
    p->mlen = nm;
    ComputeMaskFromKeytrans(dpy, p);
    UnlockDisplay(dpy);
    return 0;
}
Exemple #26
0
static int dir_visited(struct context *ctx, struct stat *st)
{
    int i = 0;

    if (!ctx->visited_dirs)
	ctx->visited_dirs = Xcalloc(1, sizeof(struct visited_dirs));
    else
	for (i = 0; i < ctx->visited_dirs->size; i++)
	    if (ctx->visited_dirs->cyc[i].ino == (long) st->st_ino && ctx->visited_dirs->cyc[i].dev == (long) st->st_dev)
		return -1;

    ctx->visited_dirs->cyc[ctx->visited_dirs->current].dev = (long) st->st_dev;
    ctx->visited_dirs->cyc[ctx->visited_dirs->current].ino = (long) st->st_ino;

    if (ctx->visited_dirs->size < VD_SIZE)
	ctx->visited_dirs->size++;

    if (++ctx->visited_dirs->current == VD_SIZE)
	ctx->visited_dirs->current = 0;

    return 0;
}
Exemple #27
0
static RecordSetPtr
BitVectorCreateSet(RecordSetInterval *pIntervals, int nIntervals,
		   void *pMem, int memsize)
{
    BitVectorSetPtr pbvs;
    int i, j;
    unsigned long *pbitvec;

    /* allocate all storage needed by this set in one chunk */

    if (pMem)
    {
	memset(pMem, 0, memsize);
	pbvs = (BitVectorSetPtr)pMem;
	pbvs->baseSet.ops = &BitVectorNoFreeOperations;
    }
    else
    {
	pbvs = (BitVectorSetPtr)Xcalloc(memsize);
	if (!pbvs) return NULL;
	pbvs->baseSet.ops = &BitVectorSetOperations;
    }

    pbvs->maxMember = maxMemberInInterval(pIntervals, nIntervals);

    /* fill in the set */

    pbitvec = (unsigned long *)(&pbvs[1]);
    for (i = 0; i < nIntervals; i++)
    {
	for (j = pIntervals[i].first; j <= (int)pIntervals[i].last; j++)
	{
	    pbitvec[j/BITS_PER_LONG] |= ((unsigned long)1 << (j % BITS_PER_LONG));
	}
    }
    return (RecordSetPtr)pbvs;
}
Exemple #28
0
/*
 * The conversation function. Alas, OSF-RFC 86.0 doesn't go into
 * much detail, so this is largely based upon linux-pam documentation.
 */
static int pam_conv(int num_msg, PAM_CONV_ARG2_TYPE ** msg, struct pam_response **response, void *appdata_ptr)
{
    int count;
    struct pam_response *reply = Xcalloc(num_msg, sizeof(struct pam_response));

    for (count = 0; count < num_msg; count++)
	switch (msg[count]->msg_style) {
	case PAM_PROMPT_ECHO_ON:
	    reply[count].resp = Xstrdup(((struct appdata *) appdata_ptr)->user);
	    break;
	case PAM_PROMPT_ECHO_OFF:
	    reply[count].resp = Xstrdup(((struct appdata *) appdata_ptr)->pass);
	case PAM_TEXT_INFO:
	    break;
	default:
	    while (--count > -1)
		Xfree(&reply[count].resp);
	    Xfree(&reply);
	    return PAM_CONV_ERR;	/* won't happen */
	}

    *response = reply;
    return PAM_SUCCESS;
}
Exemple #29
0
static __GLXDRIscreen *
driCreateScreen(__GLXscreenConfigs * psc, int screen,
                __GLXdisplayPrivate * priv)
{
   __GLXDRIscreen *psp;
   const __DRIconfig **driver_configs;
   const __DRIextension **extensions;
   const char *driverName = "swrast";
   int i;

   psp = Xcalloc(1, sizeof *psp);
   if (psp == NULL)
      return NULL;

   psc->driver = driOpenDriver(driverName);
   if (psc->driver == NULL)
      goto handle_error;

   extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
   if (extensions == NULL) {
      ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
      goto handle_error;
   }

   for (i = 0; extensions[i]; i++) {
      if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
         psc->core = (__DRIcoreExtension *) extensions[i];
      if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
         psc->swrast = (__DRIswrastExtension *) extensions[i];
   }

   if (psc->core == NULL || psc->swrast == NULL) {
      ErrorMessageF("core dri extension not found\n");
      goto handle_error;
   }

   psc->__driScreen =
      psc->swrast->createNewScreen(screen,
                                   loader_extensions, &driver_configs, psc);
   if (psc->__driScreen == NULL) {
      ErrorMessageF("failed to create dri screen\n");
      goto handle_error;
   }

   driBindExtensions(psc);
   driBindCommonExtensions(psc);

   psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
   psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);

   psc->driver_configs = driver_configs;

   psp->destroyScreen = driDestroyScreen;
   psp->createContext = driCreateContext;
   psp->createDrawable = driCreateDrawable;
   psp->swapBuffers = driSwapBuffers;
   psp->waitX = NULL;
   psp->waitGL = NULL;

   return psp;

 handle_error:
   Xfree(psp);

   if (psc->driver)
      dlclose(psc->driver);

   ErrorMessageF("reverting to indirect rendering\n");

   return NULL;
}
Exemple #30
0
static void LoadList(const char * filename)
{
    scriptfile *script = scriptfile_fromfile(filename);

    if (!script)
        return;

    scriptfile_addsymbolvalue("GAMEFLAG_DUKE", GAMEFLAG_DUKE);
    scriptfile_addsymbolvalue("GAMEFLAG_ADDON", GAMEFLAG_DUKE|GAMEFLAG_ADDON);
    scriptfile_addsymbolvalue("GAMEFLAG_NAM", GAMEFLAG_NAM);
    scriptfile_addsymbolvalue("GAMEFLAG_NAPALM", GAMEFLAG_NAM|GAMEFLAG_NAPALM);
    scriptfile_addsymbolvalue("GAMEFLAG_WW2GI", GAMEFLAG_NAM|GAMEFLAG_WW2GI);
    scriptfile_addsymbolvalue("DUKE15_CRC", DUKE15_CRC);
    scriptfile_addsymbolvalue("DUKEPP_CRC", DUKEPP_CRC);
    scriptfile_addsymbolvalue("DUKE13_CRC", DUKE13_CRC);
    scriptfile_addsymbolvalue("DUKEDC13_CRC", DUKEDC13_CRC);
    scriptfile_addsymbolvalue("DUKEDCPP_CRC", DUKEDCPP_CRC);
    scriptfile_addsymbolvalue("DUKEDC_CRC", DUKEDC_CRC);
    scriptfile_addsymbolvalue("VACA13_CRC", VACA13_CRC);
    scriptfile_addsymbolvalue("VACAPP_CRC", VACAPP_CRC);
    scriptfile_addsymbolvalue("VACA15_CRC", VACA15_CRC);
    scriptfile_addsymbolvalue("DUKECB_CRC", DUKECB_CRC);
    scriptfile_addsymbolvalue("DUKENW_CRC", DUKENW_CRC);
    scriptfile_addsymbolvalue("DZ2_13_CRC", DZ2_13_CRC);
    scriptfile_addsymbolvalue("DZ2_PP_CRC", DZ2_PP_CRC);
    scriptfile_addsymbolvalue("NAM_CRC", NAM_CRC);
    scriptfile_addsymbolvalue("NAPALM_CRC", NAPALM_CRC);
    scriptfile_addsymbolvalue("WW2GI_CRC", WW2GI_CRC);

    while (!scriptfile_eof(script))
    {
        enum
        {
            T_GRPINFO,
            T_GAMENAME,
            T_CRC,
            T_SIZE,
            T_DEPCRC,
            T_SCRIPTNAME,
            T_DEFNAME,
            T_FLAGS,
        };

        static const tokenlist profiletokens[] =
        {
            { "grpinfo",            T_GRPINFO },
        };

        int32_t token = getatoken(script,profiletokens,ARRAY_SIZE(profiletokens));
        switch (token)
        {
        case T_GRPINFO:
        {
            int32_t gsize = 0, gcrcval = 0, gflags = GAMEFLAG_DUKE, gdepcrc = DUKE15_CRC;
            char *gname = NULL, *gscript = NULL, *gdef = NULL;
            char *grpend = NULL;

            static const tokenlist grpinfotokens[] =
            {
                { "name",           T_GAMENAME },
                { "scriptname",     T_SCRIPTNAME },
                { "defname",        T_DEFNAME },
                { "crc",            T_CRC },
                { "dependency",     T_DEPCRC },
                { "size",           T_SIZE },
                { "flags",          T_FLAGS },

            };

            if (scriptfile_getbraces(script,&grpend)) break;

            while (script->textptr < grpend)
            {
                int32_t token = getatoken(script,grpinfotokens,ARRAY_SIZE(grpinfotokens));

                switch (token)
                {
                case T_GAMENAME:
                    scriptfile_getstring(script,&gname); break;
                case T_SCRIPTNAME:
                    scriptfile_getstring(script,&gscript); break;
                case T_DEFNAME:
                    scriptfile_getstring(script,&gdef); break;

                case T_FLAGS:
                    scriptfile_getsymbol(script,&gflags); gflags &= GAMEFLAGMASK; break;
                case T_DEPCRC:
                    scriptfile_getsymbol(script,&gdepcrc); break;
                case T_CRC:
                    scriptfile_getsymbol(script,&gcrcval); break;
                case T_SIZE:
                    scriptfile_getnumber(script,&gsize); break;
                default:
                    break;
                }

                grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t));
                fg->next = listgrps;
                listgrps = fg;

                if (gname)
                    fg->name = Xstrdup(gname);

                fg->size = gsize;
                fg->crcval = gcrcval;
                fg->dependency = gdepcrc;
                fg->game = gflags;

                if (gscript)
                    fg->scriptname = dup_filename(gscript);

                if (gdef)
                    fg->defname = dup_filename(gdef);
            }
            break;
        }

        default:
            break;
        }
    }

    scriptfile_close(script);
    scriptfile_clearsymbols();
}