*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <netdb.h>
#ifdef SERVER_DGA
#else
#include <unistd.h>
#endif /* SERVER_DGA */
#include "dga_incls.h"
#include "pix_grab.h"
/* Some structure definition for internal bookkeeping
* NOTE: there is only one locking window created per device for
* the use of all pixmaps on that device
*/
typedef struct dga_pixlist {
int num_clientp;
} *Dga_pixlist;
#ifdef SERVER_DGA
extern SHPX_CLIENT_ENTRY shpx_client_directory[];
extern int Dga_shpx_client_count;
#else
static int Dga_shpx_client_count = 0;
#endif /* SERVER_DGA */
/******************************************
*
* dga_pix_grab:
*
* create shared memory file for pixmap information
* map to lock page
*
* arguments:
*
* Dga_token token; INPUT
* magic cookie supplied by the server
*
* returns a user virtual address for a dga_window structure.
* returns NULL if anything goes awry.
*
*****************************************/
{
char *dpystr;
/* Remember to account for multiple clients grabbing the same pixmap
* later
*/
/* First determine if this is a X pixmap - if so, get
* the dpy and pixid
*/
#ifdef DEBUG
#endif
return (PIX_FAILED);
}
if (!dga_plist) {
/* This is the first time through this code so get the
* retained path */
#ifdef DEBUG
"dga_pix_grab: XDgaGetRetainedPath failed\n");
#endif
return (PIX_FAILED);
}
}
#ifndef SERVER_DGA
/* Now get the port number for this display */
if (dpystr[0] == ':')
else
if (Dga_shpx_client_count == 0) {
/* Now start by initializing all the per client structs -
* all 64 of them - if thie is the first time you
* are grabbing a pixmap
*/
for (i = 0; i < SHPX_MAX_CLIENTS; i++) {
shpx_client_directory[i].cid = 0;
shpx_client_directory[i].fd = 0;
shpx_client_directory[i].size = 0;
shpx_client_directory[i].npix = 0;
}
} else
#endif /* SERVER_DGA */
{
/* If it is not the first time, see if this client has grabbed
* a pixmap before and therefore done all the set up.
* Search through the client structures for matching token
*/
i = 0;
while ((i < SHPX_MAX_CLIENTS) &&
i++;
}
if ((i == SHPX_MAX_CLIENTS) &&
return(0);
}
}
if ((Dga_shpx_client_count > 0) && (i < SHPX_MAX_CLIENTS)) {
/* We found a match and the pixmap already has been grabbed before */
shpx_client_directory[i].npix++;
}
#ifndef SERVER_DGA
else {
/* This client has Never grabbed before set up the direct
* structure etc.
* Open the shared file using server command line
* -sharedretainedpath variable for file path if it is
* set, else use /tmp. This is because these files can
* be very big and there usually isn't much space in /tmp.
*/
c_fn[0] = 0;
else
#ifdef SYSV
#else
pagesize = getpagesize();
#endif
i = 0;
i++;
return(0);
/* map the shpx directory for this client and map at 4 megabytes */
c_fd,
(off_t)0);
return(0);
}
}
#endif /* SERVER_DGA */
/* The first 2 entries on the file have special meaning. */
i = 2;
entry_found = 0;
while ((i < SHPX_MAX_PIXMAPS) && (!entry_found)) {
entry_found = 1;
else
i++;
}
if (!entry_found) {
#ifndef SERVER_DGA
#endif /* SERVER_DGA */
return(0);
}
infop = (SHARED_PIXMAP_INFO *)
#ifndef SERVER_DGA
#endif /* SERVER_DGA */
return(0);
}
#ifndef SERVER_DGA
#endif /* SERVER_DGA */
return(0);
}
/* BMAC - Find out about the rache code - what should I do there? */
/* Now fill out the Dga_pixmap structure */
return NULL ;
#ifdef MT
clientp->shadow_chngcnt[0] = 0;
#endif
/* This is the new location added for locking performance
* For windows it pts to the second member in the c_wm_chngcnt
* array but here I think that it just pts to the previous field
* since for pixmaps the array ctr is -1 always
*/
clientp->c_devinfocnt = 0;
clientp->c_cachecnt = 0;
clientp->p_dir_index = i;
#ifdef MT
if (dgaThreaded) {
} else {
}
#else
#endif
#ifdef SERVER_DGA
#else
/* Check to see if there are already a lockp and unlockp
* for this device--if not create 'em
*/
if (dga_plist) {
}
if (!lockp) {
/* only get new lock pages if necessary */
/* REMIND Daryl: What else do we need to clean up? */
return(NULL);
}
}
#endif /* SERVER_DGA */
/* add to linked list of grabbed pixmaps - for internal bookkeeping
*/
if (!dga_plist) {
if ((dga_plist =
return NULL ;
} else {
if ((new_plist =
return NULL;
}
#ifdef MT
if (dgaThreaded) {
} else {
}
#endif
return ((Dga_pixmap) clientp);
}
void
{
u_int i;
/* Find pixmap in dga_plist */
while (pixlist) {
#ifndef SERVER_DGA
i = 0;
while ((i < SHPX_MAX_CLIENTS) &&
i++;
}
if ((i == SHPX_MAX_CLIENTS) &&
return;
}
shpx_client_directory[i].npix--;
if (!shpx_client_directory[i].npix) {
shpx_client_directory[i].cid = 0;
shpx_client_directory[i].fd = 0;
shpx_client_directory[i].size = 0;
}
#endif /* SERVER_DGA */
if (prev_pixlist)
else
#ifndef SERVER_DGA
if (!dga_plist) {
}
#endif /* SERVER_DGA */
if(--Dga_shpx_client_count < 0)
return;
} else {
}
}
}
#ifdef COMMENT
/* TODO: Daryl what is this routine supposed to be used for??? */
int
{
/* this checks to see if the shared pixmap info
* area has changed and if so reinits the data
*/
/* This routine seems to requoire that the handle have
1. if the pixmap is cached or not
2. what type the pixmap is = like retained one??
3. something called sh_rache_scr0, sh_rache_scr1;
4. something called sh_Scr_Virt[]; virtual screen table */
}
#endif
int
{
/* Something changed */
return 1;
} else
/* Nothing has changed */
return 0;
}
int
{
/* Something changed */
return 1;
} else
/* Nothing has changed */
return 0;
}
char *
{
/* CHECK THIS ! */
}
void *
{
}
int
{
}
{
}
void *
{
}