Esempio n. 1
0
/*{
** Name:	MO_mon_id_get	-- get method for monitor id.
**
** Description:
**	A get method to make the monitor id visible.
**
** Re-entrancy:
**	yes.
**
** Inputs:
**	offset		ignored
**	objsize		ignored
**	object		an MO_MON_BLOCK
**	luserbuf	length of out buf
**
** Outputs:
**	userbuf		out buf
**
** Returns:
**	OK
**	MO_VALUE_TRUNCATED
**
** Side Effects:
**	May temporarily allocated some memory, freed before return.
**
** History:
**	24-sep-92 (daveb)
**	    documented
**	7-sep-93 (swm)
**	    call MOptrout() rather than MOulongout() for mp->mon_data to
**	    avoid i4/pointer truncation errors.
*/
STATUS
MO_mon_id_get(i4 offset,
	     i4  objsize,
	     PTR object,
	     i4  luserbuf,
	     char *userbuf)
{
    STATUS ret_val = OK;
    MO_MON_BLOCK *mp = (MO_MON_BLOCK *)object;
    char localbuf[ MO_MAX_NUM_BUF * 3 + 2 ];
    char numbuf[ MO_MAX_NUM_BUF ];
    i4  len;
    char *outbuf;

    (void)MOptrout( 0, mp->mon_data, sizeof( numbuf ), numbuf );
    len = (i4)(STlength( mp->mo_class->node.key ) + STlength(numbuf) + 2);
    if(  len <= sizeof( localbuf ) )
	outbuf = localbuf;
    else
	outbuf = MO_alloc( len, &ret_val );

    if( ret_val == OK )
    {
	STprintf( outbuf, "%s.%s", mp->mo_class->node.key, numbuf );
	ret_val = MOstrout( MO_VALUE_TRUNCATED, outbuf, luserbuf, userbuf );
	if( outbuf != localbuf )
	    MO_free( outbuf, len );
    }
# if 0
    if( ret_val != OK )
	/* FIXME */
# endif

    return( ret_val );
}
Esempio n. 2
0
STATUS
GM_mk_conn_instance( PTR srvr_key,
		    PTR conn_key,
		    i4  linstance,
		    char *instance )
{
    i4		len;
    STATUS	cl_stat;

    len = STlength( (char *)srvr_key );
    cl_stat = MOstrout( MO_INSTANCE_TRUNCATED, (char *)srvr_key,
		       linstance, instance );
    if( cl_stat == OK )
    {
	if( len >= linstance - 1 )
	{
	    cl_stat = MO_INSTANCE_TRUNCATED;
	}
	else
	{
	    instance[ len ] = '.';
	    cl_stat = MOptrout( MO_INSTANCE_TRUNCATED, conn_key,
			    linstance - len - 1, &instance[ len + 1 ] );
	}
    }
    return( cl_stat );
}
Esempio n. 3
0
/*
** Name: ddc_sess_detach - remove a DB_CACHED_SESSION instance
**
** Description:
**
**      Wrapper for MOdetach.
**
** Inputs:
**
**      name            name for active session
**
** Outputs:
**
**      None
**
** Returns:
**      None.
**
** History:
**      13-Jul-98 (fanra01)
**          Created.
**
*/
VOID
ddc_sess_detach (PDB_CACHED_SESSION dbSession)
{
	char name[80];

	if (MOptrout(0, (PTR)dbSession, sizeof(name), name) == OK)
		MOdetach (db_access_name, name);
}
Esempio n. 4
0
/*
** Name: ddc_sess_attach - make an instance based on the session name.
**
** Description:
**
**      Wrapper for MOattach.  Create an instance of the WTS_SESSION.
**
** Inputs:
**
**      name            name of active session (unique key)
**      dbSession       pointer to a cached db session structure
**
** Outputs:
**
**      none
**
** Returns:
**      OK              function completed successfully
**
** History:
**      02-Mar-98 (fanra01)
**          Created.
**
*/
STATUS
ddc_sess_attach (PDB_CACHED_SESSION  dbSession)
{
	STATUS status;
	char name[80];

	status = MOptrout(0, (PTR)dbSession, sizeof(name), name);
	if (status == OK)
		status = MOattach (MO_INSTANCE_VAR, db_access_name, name, (PTR)dbSession);
return(status);
}
Esempio n. 5
0
STATUS
CS_scb_index(i4 msg,
	     PTR cdata,
	     i4  linstance,
	     char *instance, 
	     PTR *instdata )
{
    STATUS stat = OK;
    PTR ptr;

# ifdef OS_THREADS_USED
    CS_synch_lock( &Cs_srv_block.cs_scb_mutex );
# endif /* OS_THREADS_USED */
    switch( msg )
    {
    case MO_GET:
	if( OK == (stat = CS_get_block( instance,
				       Cs_srv_block.cs_scb_ptree,
				       &ptr ) ) )
	    *instdata = (PTR) CS_find_scb((CS_SID) ptr);
	break;

    case MO_GETNEXT:
	if( OK == ( stat = CS_nxt_block( instance,
					Cs_srv_block.cs_scb_ptree,
					&ptr ) ) )
	{
	    *instdata = (PTR) CS_find_scb((CS_SID) ptr);
	    stat = MOptrout( MO_INSTANCE_TRUNCATED,
			      ptr,
			      linstance,
			      instance );
	}
	break;

    default:
	stat = MO_BAD_MSG;
	break;
    }
# ifdef OS_THREADS_USED
    CS_synch_unlock( &Cs_srv_block.cs_scb_mutex );
# endif /* OS_THREADS_USED */
    return( stat );
}
Esempio n. 6
0
STATUS
CS_scb_index(i4 msg,
	     PTR cdata,
	     i4 linstance,
	     char *instance, 
	     PTR *instdata )
{
    STATUS stat = OK;
    PTR ptr;

    switch( msg )
    {
    case MO_GET:
	if( OK == (stat = CS_get_block( instance,
				       Cs_srv_block.cs_scb_ptree,
				       &ptr ) ) )
	    *instdata = (PTR) CS_find_scb((CS_SID) ptr);
	break;

    case MO_GETNEXT:
	if( OK == ( stat = CS_nxt_block( instance,
					Cs_srv_block.cs_scb_ptree,
					&ptr ) ) )
	{
            *instdata = (PTR) CS_find_scb((CS_SID) ptr);
            stat = MOptrout( MO_INSTANCE_TRUNCATED,
                              ptr,
			      linstance,
			      instance );
	}
	break;

    default:
	stat = MO_BAD_MSG;
	break;
    }
    return( stat );
}
Esempio n. 7
0
/*{
** Name:	CS_memory_get	- MO get function for cs_memory field
**
** Description:
**	A nice interpretation of the cs_memory field.
**
** Re-entrancy:
**	yes.
**
** Inputs:
**	offset		offset into the SCB, ignored.
**	objsize		size of the cs_self field, ignored.
**	object		the CS_SCB in question.
**	luserbuf	length of output buffer
**
**
** Outputs:
**	userbuf		written with string.
**
** Returns:
**	standard get function returns.
**
** History:
**	26-Oct-1992 (daveb)
**	    documented. 
**	18-jan-1993 (mikem)
**	    Initialized str to point to buf in the CS_scb_memory_get() routine.
**	    It was not initialized in the CS_MUTEX case.  
**	14-oct-93 (swm)
**	    Bug #56445
**	    Assign sem or cnd pointers to new cs_sync_obj (synchronisation
**	    object) rather than overloading cs_memory which is a i4;
**	    pointers do not fit into i4s on all machines!
**	    Also, now that semaphores are exclusive, remove unnecessary
**	    code that negates the sem address.
**	    Changed CS_scb_memory_get() to get cs_sync_obj field rather
**	    than cs_memory when cs_state field is CS_CNDWAIT or CS_MUTEX.
**	    Also, since semaphores are exclusive eliminate the test for a
**	    negated semaphore address.
**	16-oct-93 (swm)
**	    Bug #56445
**	    Changed name of CS_scb_memory_get() to CS_scb_sync_obj_get()
**	    to reflect the nature of information actually returned.
**	16-Nov-1998 (jenjo02)
**	    Updated CS_EVENT_WAIT mask interpretations to coincide
**	    with current reality.
*/
STATUS
CS_scb_sync_obj_get(i4 offset,
		  i4  objsize,
		  PTR object,
		  i4  luserbuf,
		  char *userbuf)
{
    STATUS stat;
    char buf[ 80 ];
    char *str = buf;
    
    CS_SCB *scb = (CS_SCB *)object;

    switch (scb->cs_state)
    {
    case CS_EVENT_WAIT:

	str = scb->cs_memory & CS_DIO_MASK ?
		  scb->cs_memory & CS_IOR_MASK ?
		  "DIOR" : "DIOW"
		:
	      scb->cs_memory & CS_BIO_MASK ?
		  scb->cs_memory & CS_IOR_MASK ?
		  "BIOR" : "BIOW"
		:
	      scb->cs_memory & CS_LIO_MASK ?
		  scb->cs_memory & CS_IOR_MASK ?
		  "LIOR" : "LIOW"
		:
	      scb->cs_memory & CS_LOCK_MASK ?
		  "LOCK"
		:
	      scb->cs_memory & CS_LOG_MASK ?
		  "LOG"
		:
	      scb->cs_memory & CS_LKEVENT_MASK ?
		  "LKEvnt"
		:
	      scb->cs_memory & CS_LGEVENT_MASK ?
		  "LGEvnt"
		:
	      scb->cs_memory & CS_TIMEOUT_MASK ?
		  "TIME"
		:
		  "OTHER";
	stat = MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf );
	break;

    case CS_MUTEX:

	buf[0] = 'x';
	buf[1] = ' ';
	(void) MOptrout( 0, scb->cs_sync_obj, sizeof(buf), &buf[2] );
	stat = MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf );
	break;

    case CS_CNDWAIT:
	stat =  MOptrout( MO_VALUE_TRUNCATED, scb->cs_sync_obj,
			   luserbuf, userbuf );

    default:

	stat =  MOulongout( MO_VALUE_TRUNCATED, scb->cs_memory,
			   luserbuf, userbuf );

	break;
    }
    return( stat );
}