Beispiel #1
0
void glGetHistogram(GLenum target, GLboolean reset, GLenum format,
		    GLenum type, GLvoid *values)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    xGLXGetHistogramReply reply;
    GLubyte *buf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_GetHistogram,__GLX_PAD(14));
    __GLX_SINGLE_PUT_LONG(0,(long)target);
    __GLX_SINGLE_PUT_LONG(4,(long)format);
    __GLX_SINGLE_PUT_LONG(8,(long)type);
    __GLX_SINGLE_PUT_CHAR(12,gc->state.storePack.swapEndian);
    __GLX_SINGLE_PUT_CHAR(13,reset);
    __GLX_SINGLE_READ_XREPLY();
    compsize = (long)reply.length << 2;

    if (compsize != 0) {
        /* Allocate a holding buffer to transform the data from */
        buf = (GLubyte*)Xmalloc(compsize);
        if (!buf) {
            /* Throw data away */
            _XEatData(dpy, compsize);
            __glXSetError(gc, GL_OUT_OF_MEMORY);
        } else {
            GLint width;

            /*
            ** Fetch data into holding buffer.  Apply pixel store pack modes
            ** to put data back into client memory
            */
            width = (int)reply.width;
            __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf),(long)compsize);
            __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, values);
            Xfree((char*) buf);
        }
    } else {
        /*
        ** GL error occured, don't modify user's buffer.
        */
    }
    __GLX_SINGLE_END();
}
Beispiel #2
0
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
		  GLenum format, GLenum type, GLvoid *pixels)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    xGLXReadPixelsReply reply;
    GLubyte *buf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_ReadPixels,__GLX_PAD(26));
    __GLX_SINGLE_PUT_LONG(0,x);
    __GLX_SINGLE_PUT_LONG(4,y);
    __GLX_SINGLE_PUT_LONG(8,width);
    __GLX_SINGLE_PUT_LONG(12,height);
    __GLX_SINGLE_PUT_LONG(16,format);
    __GLX_SINGLE_PUT_LONG(20,type);
    __GLX_SINGLE_PUT_CHAR(24,gc->state.storePack.swapEndian);
    __GLX_SINGLE_PUT_CHAR(25,GL_FALSE);
    __GLX_SINGLE_READ_XREPLY();
    compsize = reply.length << 2;

    if (compsize != 0) {
	/* Allocate a holding buffer to transform the data from */
	buf = (GLubyte*) Xmalloc(compsize);
	if (!buf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize);
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	} else {
	    /*
	    ** Fetch data into holding buffer.  Apply pixel store pack modes
	    ** to put data back into client memory
	    */
	    __GLX_SINGLE_GET_CHAR_ARRAY(buf,compsize);
	    __glEmptyImage(gc, 2, width, height, 1, format, type, buf, pixels);
	    Xfree((char*) buf);
	}
    } else {
	/*
	** GL error occurred; don't modify user's buffer.
	*/
    }
    __GLX_SINGLE_END();
}
Beispiel #3
0
/*
 * Given a display pointer and screen number, determine the name of
 * the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
 * Return True for success, False for failure.
 */
static Bool
driGetDriverName(Display * dpy, int scrNum, char **driverName)
{
    int directCapable;
    Bool b;
    int event, error;
    int driverMajor, driverMinor, driverPatch;

    *driverName = NULL;

    if (XF86DRIQueryExtension(dpy, &event, &error)) {    /* DRI1 */
        if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) {
            ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n");
            return False;
        }
        if (!directCapable) {
            ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n");
            return False;
        }

        b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor,
                                       &driverPatch, driverName);
        if (!b) {
            ErrorMessageF("Cannot determine driver name for screen %d\n",
                          scrNum);
            return False;
        }

        InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
                     driverMajor, driverMinor, driverPatch, *driverName,
                     scrNum);

        return True;
    }
    else if (DRI2QueryExtension(dpy, &event, &error)) {  /* DRI2 */
        char *dev;
        Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev);

        if (ret)
            Xfree(dev);

        return ret;
    }

    return False;
}
Beispiel #4
0
static __GLcontextModes *
createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
                            int screen, GLboolean tagged_only)
{
   INT32 buf[__GLX_TOTAL_CONFIG], *props;
   unsigned prop_size;
   __GLcontextModes *modes, *m;
   int i;

   if (nprops == 0)
      return NULL;

   /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */

   /* Check number of properties */
   if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
      return NULL;

   /* Allocate memory for our config structure */
   modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
   if (!modes)
      return NULL;

   prop_size = nprops * __GLX_SIZE_INT32;
   if (prop_size <= sizeof(buf))
      props = buf;
   else
      props = Xmalloc(prop_size);

   /* Read each config structure and convert it into our format */
   m = modes;
   for (i = 0; i < nvisuals; i++) {
      _XRead(dpy, (char *) props, prop_size);
      /* Older X servers don't send this so we default it here. */
      m->drawableType = GLX_WINDOW_BIT;
      __glXInitializeVisualConfigFromTags(m, nprops, props,
                                     tagged_only, GL_TRUE);
      m->screen = screen;
      m = m->next;
   }

   if (props != buf)
      Xfree(props);

   return modes;
}
Beispiel #5
0
void *
queue_get(queue_t *q)
{
  queue_element_t *e;
  void *data;

  if (q->elements == 0)
    return (NULL);

  e = q->head;
  q->elements--;
  q->head = e->next;
  data = e->data;
  Xfree(e);

  return (data);
}
Beispiel #6
0
int
XQueryColors(
    register Display *dpy,
    Colormap cmap,
    XColor *defs, 		/* RETURN */
    int ncolors)
{
    register int i;
    xrgb *color;
    xQueryColorsReply rep;
    long nbytes;
    register xQueryColorsReq *req;

    LockDisplay(dpy);
    GetReq(QueryColors, req);

    req->cmap = cmap;
    req->length += ncolors; /* each pixel is a CARD32 */

    for (i = 0; i < ncolors; i++)
      Data32 (dpy, (long *)&defs[i].pixel, 4L);
       /* XXX this isn't very efficient */

    if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {
	if ((color = (xrgb *)
	    Xmalloc((unsigned) (nbytes = (long) ncolors * SIZEOF(xrgb))))) {

	    _XRead(dpy, (char *) color, nbytes);

	    for (i = 0; i < ncolors; i++) {
		register XColor *def = &defs[i];
		register xrgb *rgb = &color[i];
		def->red = rgb->red;
		def->green = rgb->green;
		def->blue = rgb->blue;
		def->flags = DoRed | DoGreen | DoBlue;
	    }
	    Xfree((char *)color);
	}
	else _XEatData(dpy, (unsigned long) nbytes);
    }
    UnlockDisplay(dpy);
    SyncHandle();
    return 1;
}
Beispiel #7
0
char *
_Xsetlocale(
    int		  category,
    _Xconst char  *name
)
{
    static char *xsl_name;
    char *old_name;
    XrmMethods methods;
    XPointer state;

    if (category != LC_CTYPE && category != LC_ALL)
	return NULL;
    if (!name) {
	if (xsl_name)
	    return xsl_name;
	return "C";
    }
    if (!*name)
	name = getenv("LC_CTYPE");
    if (!name || !*name)
	name = getenv("LANG");
    if (name && strlen(name) >= MAXLOCALE)
	name = NULL;
    if (!name || !*name || !_XOpenLC((char *) name))
	name = "C";
    old_name = xsl_name;
    xsl_name = (char *)name;
    methods = _XrmInitParseInfo(&state);
    xsl_name = old_name;
    if (!methods)
	return NULL;
    name = (*methods->lcname)(state);
    xsl_name = Xmalloc(strlen(name) + 1);
    if (!xsl_name) {
	xsl_name = old_name;
	(*methods->destroy)(state);
	return NULL;
    }
    strcpy(xsl_name, name);
    if (old_name)
	Xfree(old_name);
    (*methods->destroy)(state);
    return xsl_name;
}
Beispiel #8
0
int
XFreeGC (
    register Display *dpy,
    GC gc)
    {
    register xResourceReq *req;
    register _XExtension *ext;
    LockDisplay(dpy);
    /* call out to any extensions interested */
    for (ext = dpy->ext_procs; ext; ext = ext->next)
	if (ext->free_GC) (*ext->free_GC)(dpy, gc, &ext->codes);
    GetResReq (FreeGC, gc->gid, req);
    UnlockDisplay(dpy);
    SyncHandle();
    _XFreeExtData(gc->ext_data);
    Xfree (gc);
    return 1;
    }
static void
dri2_destroy_context(struct glx_context *context)
{
   struct dri2_context *pcp = (struct dri2_context *) context;
   struct dri2_screen *psc = (struct dri2_screen *) context->psc;

   driReleaseDrawables(&pcp->base);

   if (context->xid)
      glx_send_destroy_context(psc->base.dpy, context->xid);

   if (context->extensions)
      XFree((char *) context->extensions);

   (*psc->core->destroyContext) (pcp->driContext);

   Xfree(pcp);
}
Beispiel #10
0
/*
 * Exported function for querying the DRI driver for a given screen.
 *
 * The returned char pointer points to a static array that will be
 * overwritten by subsequent calls.
 */
PUBLIC const char *
glXGetScreenDriver(Display * dpy, int scrNum)
{
    static char ret[32];
    char *driverName;
    if (driGetDriverName(dpy, scrNum, &driverName)) {
        int len;
        if (!driverName)
            return NULL;
        len = strlen(driverName);
        if (len >= 31)
            return NULL;
        memcpy(ret, driverName, len + 1);
        Xfree(driverName);
        return ret;
    }
    return NULL;
}
Beispiel #11
0
static int
period_htmloutput(orchids_t *ctx, mod_entry_t *mod, FILE *menufp, html_output_cfg_t *htmlcfg)
{
  FILE *fp;
  int i;
  strhash_elmt_t *helmt;
  size_t ctx_array_sz;
  char **ctx_array;

  fprintf(menufp,
	  "<a href=\"orchids-period.html\" "
          "target=\"main\">Periods</a><br/>\n");

  fp = create_html_file(htmlcfg, "orchids-period.html", NO_CACHE);
  fprintf_html_header(fp, "Orchids frequencies / phases tables");

  fprintf(fp, "<center><h1>Orchids frequencies / phases tables</h1></center>\n");

  ctx_array = NULL;
  ctx_array_sz = 0;
  for (i = 0; i < ctx->temporal->size; i++) {
    for (helmt = ctx->temporal->htable[i]; helmt; helmt = helmt->next) {
      ctx_array_sz++;
      ctx_array = Xrealloc(ctx_array, ctx_array_sz * sizeof (char *));
      ctx_array[ ctx_array_sz - 1 ] = helmt->key;
/*       period_output_gnuplot(); */
    }
  }
  qsort(ctx_array, ctx_array_sz, sizeof (char *), qsort_strcmp);

  fprintf(fp, "%zd context%s<br/><br/><br/>\n",
          ctx_array_sz, ctx_array_sz > 1 ? "s" : "");

  for (i = 0; i < ctx_array_sz; i++)
    fprintf(fp, "%i: %s<br/>\n", i, ctx_array[i]);

  if (ctx_array_sz > 0)
    Xfree(ctx_array);

  fprintf_html_trailer(fp);
  Xfclose(fp);

  return (0);
}
Beispiel #12
0
static void mavis_drop_in(mavis_ctx * mcx)
{
    int i;

    free(mcx->path);

    for (i = 0; mcx->argv[i]; i++)
	Xfree(&mcx->argv[i]);

    for (i = 0; i < mcx->child_max; i++)
	if (mcx->cx[i]) {
	    if (mcx->cx[i]->fd_in > -1)
		io_close(mcx->io, mcx->cx[i]->fd_in);
	    if (mcx->cx[i]->fd_out > -1)
		io_close(mcx->io, mcx->cx[i]->fd_out);
	    if (mcx->cx[i]->fd_err > -1)
		io_close(mcx->io, mcx->cx[i]->fd_err);
	    if (mcx->cx[i]) {
		kill(mcx->cx[i]->pid, SIGTERM);
	    }

	    av_free(mcx->cx[i]->ac);

	    free(mcx->cx[i]);
	}

    RB_tree_delete(mcx->junkcontexts);

    RB_tree_delete(mcx->backlog_app_ctx);
    RB_tree_delete(mcx->backlog_serial);
    RB_tree_delete(mcx->backlog_fifo);
    RB_tree_delete(mcx->outgoing);

    if (mcx->env) {
	for (i = 0; i < mcx->envcount; i++)
	    free(mcx->env[i]);
	free(mcx->env);
    }

    free(mcx->cx);
    free(mcx->cx_stat);

    io_destroy(mcx->io_context_local, NULL);
}
Beispiel #13
0
void
__glXReadPixelReply(Display * dpy, struct glx_context * gc, unsigned max_dim,
                    GLint width, GLint height, GLint depth, GLenum format,
                    GLenum type, void *dest, GLboolean dimensions_in_reply)
{
   xGLXSingleReply reply;
   GLint size;

   (void) _XReply(dpy, (xReply *) & reply, 0, False);

   if (dimensions_in_reply) {
      width = reply.pad3;
      height = reply.pad4;
      depth = reply.pad5;

      if ((height == 0) || (max_dim < 2)) {
         height = 1;
      }
      if ((depth == 0) || (max_dim < 3)) {
         depth = 1;
      }
   }

   size = reply.length * 4;
   if (size != 0) {
      void *buf = Xmalloc(size);

      if (buf == NULL) {
         _XEatData(dpy, size);
         __glXSetError(gc, GL_OUT_OF_MEMORY);
      }
      else {
         const GLint extra = 4 - (size & 3);

         _XRead(dpy, buf, size);
         if (extra < 4) {
            _XEatData(dpy, extra);
         }

         __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
         Xfree(buf);
      }
   }
}
Beispiel #14
0
int
XSetFontPath (
    register Display *dpy,
    char **directories,
    int ndirs)
{
	register int n = 0;
	register int i;
	register int nbytes;
	char *p;
	register xSetFontPathReq *req;
	int retCode;

        LockDisplay(dpy);
	GetReq (SetFontPath, req);
	req->nFonts = ndirs;
	for (i = 0; i < ndirs; i++) {
		n += safestrlen (directories[i]) + 1;
	}
	nbytes = (n + 3) & ~3;
	req->length += nbytes >> 2;
	if ((p = Xmalloc (nbytes))) {
		/*
	 	 * pack into counted strings.
	 	 */
		char	*tmp = p;

		for (i = 0; i < ndirs; i++) {
			register int length = safestrlen (directories[i]);
			*p = length;
			memcpy (p + 1, directories[i], length);
			p += length + 1;
		}
		Data (dpy, tmp, nbytes);
		Xfree ((char *) tmp);
		retCode = 1;
	}
	else
		retCode = 0;

        UnlockDisplay(dpy);
	SyncHandle();
	return (retCode);
}
Beispiel #15
0
static void
AndSort (bool_tree_node * and_tree, TermList * tl, CompFunc comp)
{
  bool_tree_node **list = NULL;
  bool_tree_node *child = NULL;
  int count = 0;
  int i = 0;

  if (BOOL_TAG (and_tree) != N_and)
    return;

  /* --- Convert linked list into an array for sorting --- */
  child = BOOL_CHILD (and_tree);
  count = 0;
  while (child)
    {
      count++;
      child = BOOL_SIBLING (child);
    }

  if (!(list = Xmalloc (sizeof (bool_tree_node *) * count)))
    return;

  child = BOOL_CHILD (and_tree);
  for (i = 0; i < count; i++)
    {
      list[i] = child;
      child = BOOL_SIBLING (child);
    }
  /* ----------------------------------------------------- */

  term_list = tl;
  qsort (list, count, sizeof (bool_tree_node *), comp);

  /* --- Convert array back into linked list --- */
  for (i = 0; i < count - 1; i++)
    BOOL_SIBLING (list[i]) = list[i + 1];
  BOOL_SIBLING (list[count - 1]) = NULL;
  BOOL_CHILD (and_tree) = list[0];
  Xfree (list);
  /* ----------------------------------------------------- */

}				/*AndSort */
Beispiel #16
0
/*	Create a new empty region	*/
Region
XCreateRegion()
{
    Region temp;

    if (! (temp = ( Region )Xmalloc( (unsigned) sizeof( REGION ))))
	return (Region) NULL;
    if (! (temp->rects = ( BOX * )Xmalloc( (unsigned) sizeof( BOX )))) {
	Xfree((char *) temp);
	return (Region) NULL;
    }
    temp->numRects = 0;
    temp->extents.x1 = 0;
    temp->extents.y1 = 0;
    temp->extents.x2 = 0;
    temp->extents.y2 = 0;
    temp->size = 1;
    return( temp );
}
AutoAwayPlugin::~AutoAwayPlugin()
{
#ifdef WIN32
    _IdleUIGetLastInputTime = NULL;
    if (hLibUI)
        FreeLibrary(hLibUI);
#elif defined(HAVE_CARBON_CARBNON_H) && !defined(HAVE_X)
    RemoveEventLoopTimer(mTimerRef);
#else
    // We load static Xss in our autoaway.so's process space, but the bastard
    // registers for shutdown in the XDisplay variable, so after autoaway.so
    // unloads, its code will still be called (as part of the XCloseDisplay).
    // As Xss offers no function to unregister itself, we'll have to be a little
    // messy here:
    QWidgetList *list = QApplication::topLevelWidgets();
    QWidgetListIt it(*list);
    QWidget *w = it.current();
    delete list;
    if (w != NULL)
    {
       Display* dpy = w->x11Display();
       LockDisplay(dpy);
       // Original code from Xlib's ClDisplay.c
       _XExtension *ext, *prev_ext = NULL;
       for (ext = dpy->ext_procs; ext; prev_ext = ext, ext = ext->next)
       {
           if (ext->name && (strcmp(ext->name, ScreenSaverName) == 0))
           {
               if (ext->close_display)
                  (*ext->close_display)(dpy, &ext->codes);
               if (prev_ext)
                   prev_ext->next = ext->next;
               else
                   dpy->ext_procs = ext->next;
               Xfree((char*)ext);
               break;
           }
       }
       UnlockDisplay(dpy);
    }
#endif
    free_data(autoAwayData, &data);
}
Beispiel #18
0
void
_XUnregisterFilter(
    Display *display,
    Window window,
    Bool (*filter)(
		   Display*, Window, XEvent*, XPointer
		   ),
    XPointer client_data)
{
    register XFilterEventList	*prev, fl;

    for (prev = &display->im_filters; (fl = *prev); ) {
	if (fl->window == window &&
	    fl->filter == filter && fl->client_data == client_data) {
	    *prev = fl->next;
	    Xfree((char *)fl);
	} else
	    prev = &fl->next;
    }
}
Beispiel #19
0
char *
XSetLocaleModifiers(
    const char *modifiers)
{
    XLCd lcd = _XlcCurrentLC();
    char *user_mods;
    char *mapped_mods;

    if (!lcd)
	return (char *) NULL;
    if (!modifiers)
	return lcd->core->modifiers;
    user_mods = getenv("XMODIFIERS");
    mapped_mods = (*lcd->methods->map_modifiers) (lcd, user_mods, modifiers);
    if (mapped_mods) {
	Xfree(lcd->core->modifiers);
	lcd->core->modifiers = mapped_mods;
    }
    return mapped_mods;
}
static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
					   XID xDrawable,
					   GLXDrawable drawable,
					   const __GLcontextModes *modes)
{
    __GLXDRIdrawable *pdraw;
    __GLXDRIdrawablePrivate *pdp;
    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
    const __DRIswrastExtension *swrast = psc->swrast;

    /* Old dri can't handle GLX 1.3+ drawable constructors. */
    if (xDrawable != drawable)
	return NULL;

    pdp = Xmalloc(sizeof(*pdp));
    if (!pdp)
	return NULL;

    pdraw = &(pdp->base);
    pdraw->xDrawable = xDrawable;
    pdraw->drawable = drawable;
    pdraw->psc = psc;

    XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID);

    /* Create a new drawable */
    pdraw->driDrawable =
	(*swrast->createNewDrawable)(psc->__driScreen,
				     config->driConfig,
				     pdp);

    if (!pdraw->driDrawable) {
	XDestroyDrawable(pdp, psc->dpy, xDrawable);
	Xfree(pdp);
	return NULL;
    }

    pdraw->destroyDrawable = driDestroyDrawable;

    return pdraw;
}
static void
_XQueryColors(
    register Display *dpy,
    Colormap cmap,
    XColor *defs, 		/* RETURN */
    int ncolors)
{
    register int i;
    xQueryColorsReply rep;
    register xQueryColorsReq *req;

    GetReq(QueryColors, req);

    req->cmap = cmap;
    SetReqLen(req, ncolors, ncolors); /* each pixel is a CARD32 */

    for (i = 0; i < ncolors; i++)
      Data32 (dpy, (long *)&defs[i].pixel, 4L);
       /* XXX this isn't very efficient */

    if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {
	unsigned long nbytes = (long) ncolors * SIZEOF(xrgb);
	xrgb *color = Xmalloc(nbytes);
	if (color != NULL) {

	    _XRead(dpy, (char *) color, nbytes);

	    for (i = 0; i < ncolors; i++) {
		register XColor *def = &defs[i];
		register xrgb *rgb = &color[i];
		def->red = rgb->red;
		def->green = rgb->green;
		def->blue = rgb->blue;
		def->flags = DoRed | DoGreen | DoBlue;
	    }
	    Xfree(color);
	}
	else
	    _XEatDataWords(dpy, rep.length);
    }
}
Beispiel #22
0
/*
** Free the per screen configs data as well as the array of
** __glXScreenConfigs.
*/
static void
FreeScreenConfigs(__GLXdisplayPrivate * priv)
{
   __GLXscreenConfigs *psc;
   GLint i, screens;

   /* Free screen configuration information */
   screens = ScreenCount(priv->dpy);
   for (i = 0; i < screens; i++) {
      psc = priv->screenConfigs[i];
      if (!psc)
         continue;
      if (psc->configs) {
         _gl_context_modes_destroy(psc->configs);
         psc->configs = NULL;   /* NOTE: just for paranoia */
      }
      Xfree((char *) psc->serverGLXexts);
   }
   XFree((char *) priv->screenConfigs);
   priv->screenConfigs = NULL;
}
/*
 * XDeleteAssoc - Delete an association in an XAssocTable keyed on
 * an XId.  An association may be removed only once.  Redundant
 * deletes are meaningless (but cause no problems).
 */
int
XDeleteAssoc(Display *dpy, XAssocTable *table, XID x_id)
{
	int hash;
	register XAssoc *bucket;
	register XAssoc *Entry;

	/* Hash the XId to get the bucket number. */
	hash = x_id & (table->size - 1);
	/* Look up the bucket to get the entries in that bucket. */
	bucket = &table->buckets[hash];
	/* Get the first entry in the bucket. */
	Entry = bucket->next;

	/* Scan through the entries in the bucket for the right XId. */
	for (; Entry != bucket; Entry = Entry->next) {
		if (Entry->x_id == x_id) {
			/* We have the right XId. */
			if (Entry->display == dpy) {
				/* We have the right display. */
				/* We have the right entry! */
				/* Remove it from the queue and */
				/* free the entry. */
				Entry->prev->next = Entry->next;
				Entry->next->prev = Entry->prev;
				Xfree((char *)Entry);
				return 0;
			}
			/* Oops, identical XId's on different displays! */
			continue;
		}
		if (Entry->x_id > x_id) {
			/* We have gone past where it should be. */
			/* It is apparently not in the table. */
			return 0;
		}
	}
	/* It is apparently not in the table. */
	return 0;
}
Beispiel #24
0
static __GLXDRIcontext *
driCreateContext(__GLXscreenConfigs * psc,
                 const __GLcontextModes * mode,
                 GLXContext gc, GLXContext shareList, int renderType)
{
   __GLXDRIcontextPrivate *pcp, *pcp_shared;
   __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
   const __DRIcoreExtension *core;
   __DRIcontext *shared = NULL;

   if (!psc || !psc->driScreen)
      return NULL;

   core = psc->core;

   if (shareList) {
      pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
      shared = pcp_shared->driContext;
   }

   pcp = Xmalloc(sizeof *pcp);
   if (pcp == NULL)
      return NULL;

   pcp->psc = psc;
   pcp->driContext =
      (*core->createNewContext) (psc->__driScreen,
                                 config->driConfig, shared, pcp);
   if (pcp->driContext == NULL) {
      Xfree(pcp);
      return NULL;
   }

   pcp->base.destroyContext = driDestroyContext;
   pcp->base.bindContext = driBindContext;
   pcp->base.unbindContext = driUnbindContext;

   return &pcp->base;
}
/**
 * Send a large image to the server.  If necessary, a buffer is allocated
 * to hold the unpacked data that is copied from the clients memory.
 * 
 * \param gc        Current GLX context
 * \param compsize  Size, in bytes, of the image portion
 * \param dim       Number of dimensions of the image
 * \param width     Width of the image
 * \param height    Height of the image, must be 1 for 1D images
 * \param depth     Depth of the image, must be 1 for 1D or 2D images
 * \param format    Format of the image
 * \param type      Data type of the image
 * \param src       Pointer to the image data
 * \param pc        Pointer to end of the command header
 * \param modes     Pointer to the pixel unpack data
 *
 * \todo
 * Modify this function so that \c NULL images are sent using
 * \c __glXSendLargeChunk instead of __glXSendLargeCommand.  Doing this
 * will eliminate the need to allocate a buffer for that case.
 *
 * \bugs
 * The \c fastImageUnpack path, which is thankfully never used, is completely
 * broken.
 */
void
__glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
                    GLint width, GLint height, GLint depth,
                    GLenum format, GLenum type, const GLvoid * src,
                    GLubyte * pc, GLubyte * modes)
{
   if (!gc->fastImageUnpack || (src == NULL)) {
      /* Allocate a temporary holding buffer */
      GLubyte *buf = (GLubyte *) Xmalloc(compsize);
      if (!buf) {
         __glXSetError(gc, GL_OUT_OF_MEMORY);
         return;
      }

      /* Apply pixel store unpack modes to copy data into buf */
      if (src != NULL) {
         (*gc->fillImage) (gc, dim, width, height, depth, format, type,
                           src, buf, modes);
      }
      else {
         if (dim < 3) {
            (void) memcpy(modes, __glXDefaultPixelStore + 4, 20);
         }
         else {
            (void) memcpy(modes, __glXDefaultPixelStore + 0, 36);
         }
      }

      /* Send large command */
      __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);

      /* Free buffer */
      Xfree((char *) buf);
   }
   else {
      /* Just send the data straight as is */
      __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, pc, compsize);
   }
}
Beispiel #26
0
Bool XDGAOpenFramebuffer(
    Display	*dpy,
    int 	screen
){
    XExtDisplayInfo *info = xdga_find_display (dpy);
    xXDGAOpenFramebufferReply rep;
    xXDGAOpenFramebufferReq *req;
    char *deviceName = NULL;
    Bool ret;

    XDGACheckExtension (dpy, info, False);

    LockDisplay(dpy);
    GetReq(XDGAOpenFramebuffer, req);
    req->reqType = info->codes->major_opcode;
    req->dgaReqType = X_XDGAOpenFramebuffer;
    req->screen = screen;
    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
	UnlockDisplay(dpy);
	SyncHandle();
	return False;
    }

    if(rep.length) {
	deviceName = Xmalloc(rep.length << 2);
	_XRead(dpy, deviceName, rep.length << 2);
    }

    ret = XDGAMapFramebuffer(screen, deviceName,
				(unsigned char*)(long)rep.mem1, 
				rep.size, rep.offset, rep.extra);

    if(deviceName)
	Xfree(deviceName);	

    UnlockDisplay(dpy);
    SyncHandle();
    return ret;
}
Beispiel #27
0
static __DRIbuffer *
dri2GetBuffers(__DRIdrawable * driDrawable,
               int *width, int *height,
               unsigned int *attachments, int count,
               int *out_count, void *loaderPrivate)
{
    __GLXDRIdrawablePrivate *pdraw = loaderPrivate;
    DRI2Buffer *buffers;

    buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
                             width, height, attachments, count, out_count);
    if (buffers == NULL)
        return NULL;

    pdraw->width = *width;
    pdraw->height = *height;
    process_buffers(pdraw, buffers, *out_count);

    Xfree(buffers);

    return pdraw->buffers;
}
Beispiel #28
0
char *authgetuser(VOID_A)
{
#ifdef	FD
	int wastty;
#endif
	char *cp;

#ifdef	FD
	if (!(wastty = isttyiomode)) ttyiomode(1);
	cp = inputstr(USER_K, 1, -1, NULL, -1);
	if (!wastty) stdiomode();
#else
	cp = gets2("User: ");
#endif

	if (cp && !*cp) {
		Xfree(cp);
		cp = NULL;
	}

	return(cp);
}
Beispiel #29
0
void
_XCloseLC(
    XLCd lcd)
{
    XLCdList cur, *prev;

    for (prev = &lcd_list; (cur = *prev); prev = &cur->next) {
	if (cur->lcd == lcd) {
	    if (--cur->ref_count < 1) {
		(*lcd->methods->close)(lcd);
		*prev = cur->next;
		Xfree(cur);
	    }
	    break;
	}
    }

    if(loader_list) {
	_XlcDeInitLoader();
	loader_list = NULL;
    }
}
static int
ProcXCMiscGetXIDList(ClientPtr client)
{
    REQUEST(xXCMiscGetXIDListReq);
    xXCMiscGetXIDListReply rep;
    int n;
    XID *pids;
    unsigned int count;

    REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);

    if (stuff->count > UINT32_MAX / sizeof(XID))
	    return BadAlloc;

    pids = (XID *)Xalloc(stuff->count * sizeof(XID));
    if (!pids)
    {
	return BadAlloc;
    }
    count = GetXIDList(client, stuff->count, pids);
    rep.type = X_Reply;
    rep.sequenceNumber = client->sequence;
    rep.length = count;
    rep.count = count;
    if (client->swapped) {
    	swaps(&rep.sequenceNumber, n);
	swapl(&rep.length, n);
	swapl(&rep.count, n);
    }
    WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *)&rep);
    if (count)
    {
    	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
	WriteSwappedDataToClient(client, count * sizeof(XID), pids);
    }
    Xfree(pids);
    return(client->noClientException);
}