Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,194 @@
/******************************************************************************
******************************************************************************
**
** File: records.c
** RCS: $XConsortium: records.c /main/4 1996/05/28 13:34:16 cde-hp $
**
** Description:
**
** (c) Copyright 1995, Hewlett-Packard Company, all rights reserved.
**
******************************************************************************
*****************************************************************************/
#define RECORDS_DOT_C
#include "dtpdmdP.h"
/********************************************************************
*
* Routines to BLOCK and UNBLOCK the signal SIGCLD.
*
* Use whenever modifying the array of client tracking
* records (critical section). If a SIGCLD happens,
* dtpdmd.c:handle_SIGCLD() will be called, and it must
* be able to work on a stable set of client tracking
* records.
*/
static void block_SIGCLD( void )
{
sigset_t newset;
int rtn;
sigemptyset( &newset );
sigaddset( &newset, SIGCLD );
rtn = sigprocmask( SIG_BLOCK, &newset, (sigset_t *) NULL );
}
static void unblock_SIGCLD( void )
{
sigset_t newset;
int rtn;
sigemptyset( &newset );
sigaddset( &newset, SIGCLD );
rtn = sigprocmask( SIG_UNBLOCK, &newset, (sigset_t *) NULL );
}
/********************************************************************
*
* Try to find a service record based on ID. Optionally create a
* new service record if one is not found.
*/
XpPdmServiceRec *find_rec( Window requestor )
{
int i;
XpPdmServiceRec *r;
if (!requestor)
return( (XpPdmServiceRec *) NULL );
/*
* See if the record already exists.
*/
for ( i=0; i < g.serviceRecNum; i++ ) {
if ( g.serviceRecs[i]->requestor == requestor )
return( g.serviceRecs[i] );
}
/*
* Will need to add - see if we need more room in the child
* tracking record array.
*/
block_SIGCLD();
if ( g.serviceRecNum + 1 > g.maxServiceRecNum ) {
g.maxServiceRecNum += 5;
if ( g.maxServiceRecNum == 5 ) {
g.serviceRecs =
(XpPdmServiceRec **) Xmalloc( sizeof(XpPdmServiceRec *) *
g.maxServiceRecNum );
}
else {
g.serviceRecs =
(XpPdmServiceRec **) Xrealloc( (char *) g.serviceRecs,
sizeof(XpPdmServiceRec *) *
g.maxServiceRecNum );
}
}
/*
* Create a new child tracking record and add to array.
*/
r = (XpPdmServiceRec *) Xmalloc( sizeof(XpPdmServiceRec) );
g.serviceRecs[g.serviceRecNum] = r;
memset( (void *) r, NULL, sizeof(XpPdmServiceRec) ); /* cheat NULLing */
r->mgr_flag = False;
r->mbox_flag = False;
r->message_pipe[0] = -1;
r->message_pipe[1] = -1;
g.serviceRecNum++;
unblock_SIGCLD();
return( r );
}
/********************************************************************
*
* Try to find a service record based on previously assigned
* mailbox window ID.
*/
XpPdmServiceRec *find_rec_by_mbox_win( Window window )
{
int i;
XpPdmServiceRec *r;
if (!window)
return( (XpPdmServiceRec *) NULL );
/*
* See if the record already exists.
*/
for ( i=0; i < g.serviceRecNum; i++ ) {
if ( g.serviceRecs[i]->mbox_window == window )
return( g.serviceRecs[i] );
}
return( (XpPdmServiceRec *) NULL );
}
/********************************************************************
*
* Delete the specified service record from global memory.
*/
void delete_rec( XpPdmServiceRec *rec )
{
int i,j;
block_SIGCLD();
for ( i=0; i< g.serviceRecNum; i++ ) {
if ( g.serviceRecs[i] == rec ) {
/*
* Delete memory for current rec
*/
if (rec->mbox_window)
XDestroyWindow( rec->selection_display, rec->mbox_window );
unlink( rec->auth_filename );
Xfree( g.serviceRecs[i]->video_display_str );
Xfree( g.serviceRecs[i]->print_display_str );
Xfree( g.serviceRecs[i]->locale_hint );
for ( j = 0; g.serviceRecs[i]->pdm_exec_argvs[j]; j++ )
Xfree( (char *) g.serviceRecs[i]->pdm_exec_argvs[j] );
Xfree( (char *) g.serviceRecs[i]->pdm_exec_argvs );
Xfree( g.serviceRecs[i]->pdm_exec_errormessage );
Xfree( g.serviceRecs[i]->message_string );
Xfree( g.serviceRecs[i]->message_string2 );
Xfree( g.serviceRecs[i]->in_buf );
for ( j=i; j < g.serviceRecs[i]->cookie_cnt; j++ )
Xfree( (char *) g.serviceRecs[i]->cookies[j] );
Xfree( (char *) g.serviceRecs[i]->cookies );
Xfree( (char *) g.serviceRecs[i] );
/*
* Compress list around defunct entry
*/
for ( j=i; j < g.serviceRecNum-1; j++ ) {
g.serviceRecs[j] = g.serviceRecs[j+1];
}
}
}
g.serviceRecNum--;
unblock_SIGCLD();
}