Exemplo n.º 1
0
static II_VOID
initStmtHndl( IIAPI_STMTHNDL *stmtHndl )
{
    stmtHndl->sh_flags &= ~(IIAPI_SH_PARAMETERS | IIAPI_QF_ALL_FLAGS);

    if ( stmtHndl->sh_queryText )  MEfree( stmtHndl->sh_queryText );
    stmtHndl->sh_queryText = NULL;

    if ( stmtHndl->sh_parmDescriptor )
    {
	i4 i;

	for( i = 0; i < stmtHndl->sh_parmCount; i++ )
	    if ( stmtHndl->sh_parmDescriptor[i].ds_columnName )
	    	MEfree( (II_PTR)stmtHndl->sh_parmDescriptor[i].ds_columnName );

	MEfree( (II_PTR)stmtHndl->sh_parmDescriptor );
    	stmtHndl->sh_parmDescriptor = NULL;
    }

    stmtHndl->sh_parmCount = 0;
    stmtHndl->sh_parmIndex = 0;
    stmtHndl->sh_parmSend = 0;
    return;
}
Exemplo n.º 2
0
/* Name: adu_map_delete_unimap - cleans up the unicode mapping table.
**
** Description:
**      This routines, releases the memory allocated for unicode
**	mapping table
**
** Input:
**              Unibase         pointer to unimap table.
**              unidefault 	pointer to default table.
**
** Output:
**              None. 
**
** History:
**      23-Jan-2004 (gupsh01)
**          Added.
**	10-Aug-2005 (gupsh01)
**	    Modify this routine to pass in the address
**	    of UniBase and Unidefault, so we can free them
**	    (Bug 115022) 
*/
static void 
adu_map_delete_unimap(
    u_i2	***UniBase, 
    u_i2	**Unidefault)
{
    int i;
    if (*UniBase)
    {
      for (i=0; i<256; i++)
      {
        if ((*UniBase)[i] && ((*UniBase)[i] != *Unidefault))
        {
	  /* delete (UniBase)[i]; */
	  MEfree ((char *)(*UniBase)[i]);
	  (*UniBase)[i] = NULL;
        }
      }
      MEfree ((char *)(*UniBase));
      *UniBase = NULL;      
    }
    if (*Unidefault)
    {
      /* delete Unidefault; */
      MEfree ((char *)(*Unidefault));
      *Unidefault = NULL;
    }   
}
Exemplo n.º 3
0
bool
gcd_alloc_qdesc( QDATA *qdata, u_i2 count, PTR desc )
{
    qdata->max_rows = 0;
    qdata->max_cols = count;
    qdata->col_cnt = 0;
    qdata->cur_col = 0;
    qdata->more_segments = FALSE;
    qdata->desc = NULL;
    if ( ! qdata->max_cols )  return( FALSE );

    if ( desc )
	qdata->desc = desc;
    else
    {
	/*
	** Expand descriptor array if needed.
	*/
	if ( qdata->max_cols > qdata->desc_max )
	{
	    if ( qdata->param_desc )
	    {
		IIAPI_DESCRIPTOR *desc = (IIAPI_DESCRIPTOR *)qdata->param_desc;
		u_i2		 i;

		for( i = 0; i < qdata->desc_max; i++ )
		    if ( desc[i].ds_columnName )  
			MEfree( desc[i].ds_columnName );

		MEfree( qdata->param_desc );
	    }


	    if ( ! (qdata->param_desc = 
	    		MEreqmem( 0, sizeof(IIAPI_DESCRIPTOR) * 
				     qdata->max_cols, TRUE, NULL )) )
	    {
		gcu_erlog( 0, GCD_global.language, 
			   E_GC4808_NO_MEMORY, NULL, 0, NULL);
		return( FALSE );
	    }

	    qdata->desc_max = qdata->max_cols;
	}

	qdata->desc = qdata->param_desc;
    }

    return( TRUE );
}
Exemplo n.º 4
0
/*
** Name: SAclose - close an operating system audit trail
**
** Description:
**	This rouitne closes an operating system audit trail previously opened
**	by SAopen(). The routine should check that the given trail has been
**	opened before attempting to close it, it will also call SAflush()
**	to flush all outstanding audit records to the audit trail.
**
** Inputs:
**	aud_trail_d	descriptor that identifies this audit trail
**
** Outputs:
**	err_code	pointer to a variable used to return OS errors
**
** Returns:
**	OK              if operation succeeded
**	SA_NOOPEN       the audit trail decsribed by this descriptor has not
**			been opened
**	SA_BADPARAM     bad parameter values were passed to the routine
**	SA_NOSUPP       the operation is not supported by this implimentation of
**			SA.
**	FAIL            the operation failed
**
** History:
**	7-jan-94 (stephenb)
**	    Initial creation as a stub
**	28-feb-94 (stephenb)
**	    Updated to current SA spec.
*/
STATUS
SAclose(PTR             *aud_trail_d,
	CL_ERR_DESC     *err_code)
{
    STATUS	cl_stat;

    /*
    ** Check that the audit trail is open, this is just a dummy check
    ** that the stub routine SAopen() has been called.
    */
    if (STcompare(((SA_DESC*)*aud_trail_d)->sa_desc, "OS"))
	return (SA_NOOPEN);
    /*
    ** Call SAflush() to flush outstanding records
    */
    cl_stat = SAflush(aud_trail_d, err_code);
    if (cl_stat != OK)
	return (cl_stat);

    /*
    ** Re-claim memory
    */
    cl_stat = MEfree(*aud_trail_d);
    if (cl_stat != OK)
	return (SA_MFREE);
    else
	return (OK);
}
Exemplo n.º 5
0
/*
** Name: FWrite_Fvalue
**
** Decription:
**      The input buffer should be written to file.
**
** Inputs:
**      sess        ice session structure
**      line        pointer to the current line
**      linelen     length of the line
**
** Outputs:
**      pos         number of characters handled.
**
** Return:
**      GSTAT_OK    success
**      other       failure
**
** History:
**      23-Oct-98 (fanra01)
**          Created.
*/
static GSTATUS
FWrite_Fvalue (WTS_SESSION* sess, char* line, i4  linelen, i4 * pos)
{
    GSTATUS     err = GSTAT_OK;
    PWTS_UPLOAD load= sess->load;
    i4          count =0;

    if ((err = WCSWrite(linelen, line, &count, sess->list->file)) == GSTAT_OK)
    {
        load->state = US_FWRITE;
    }
    else
    {
        UPLOADED_FILE*  upload = sess->list;

        if (upload != NULL)
        {
            sess->list = upload->next;
            CLEAR_STATUS(WCSClose(upload->file));
            MEfree ((PTR)upload);
        }
    }
    *pos += count;
    return (err);
}
Exemplo n.º 6
0
bool
gcn_can_auth( GCN_RESOLVE_CB *grcb )
{
    /*
    ** If the installation password has already
    ** been processed, just use it.  Otherwise,
    ** check if there is an installation password.
    ** (check for reserved internal login).
    */
    if ( grcb->flags & GCN_RSLV_IP )
    {
	grcb->pwd = grcb->ip;
	grcb->flags &= ~GCN_RSLV_PWD_ENC;
    }
    else  if ( *grcb->vnode  &&  ! STcompare( grcb->usr, GCN_NOUSER )  &&
	       STcompare( grcb->pwd, GCN_NOPASS ) )
    {
	/*
	** Save installation password.  Flag the fact that 
	** the installation password has been decoded in 
	** case we come through here again.
	*/
	if ( grcb->ip )  MEfree( (PTR)grcb->ip );	/* Should not happen */
	grcb->ip = STalloc( grcb->pwd );
	grcb->pwd = grcb->ip;
	grcb->flags |= GCN_RSLV_IP;
    }

    return( ((grcb->flags & GCN_RSLV_IP) != 0) );
}
Exemplo n.º 7
0
static void
gcd_free_rcb( GCD_RCB *rcb )
{
    if ( GCD_global.gcd_trace_level >= 6 )
	TRdisplay( "%4d    GCD del RCB (%p)\n", rcb->ccb->id, rcb );

    MEfree( (PTR)rcb );
    return;
}
Exemplo n.º 8
0
II_EXTERN IIAPI_THREAD *
IIapi_thread( II_VOID )
{
    IIAPI_THREAD	*thread;
    STATUS		status;
    i4		tid = PCtid();

    IIAPI_TRACE( IIAPI_TR_VERBOSE )
	( "IIapi_thread(%d): retrieving local storage\n", tid );

    status = MEtls_get( &IIapi_static->api_thread, (PTR *)&thread );

    if ( status != OK )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_thread: error retrieving local storage: 0x%x\n", status );
	
	return( NULL );
    }

    if ( ! thread )
    {
	thread = (IIAPI_THREAD *)MEreqmem( 0, sizeof( IIAPI_THREAD ),
					   TRUE, &status );
	
	if ( ! thread )
	{
	    IIAPI_TRACE( IIAPI_TR_FATAL )
		( "IIapi_thread: error allocating local storage 0x%x\n",
		  status );
	}
	else
	{
	    IIAPI_TRACE( IIAPI_TR_INFO )
		("IIapi_thread(%d): allocated local storage %p\n",tid,thread);
	
	    QUinit( &thread->api_op_q );

	    status = MEtls_set( &IIapi_static->api_thread, (PTR)thread );

	    if ( status != OK )
	    {
		IIAPI_TRACE( IIAPI_TR_ERROR )
		    ( "IIapi_thread: error saving local storage 0x%x\n",
		      status );
	    
		MEfree( (PTR)thread );
		thread = NULL;
	    }
	}
    }

    IIAPI_TRACE( IIAPI_TR_DETAIL )
	( "IIapi_thread(%d): retrieved local storage %p\n", tid, thread );

    return( thread );
}
Exemplo n.º 9
0
void
gcd_del_pcb( GCD_PCB *pcb )
{
    if ( GCD_global.gcd_trace_level >= 6 )
	TRdisplay( "%4d    GCD del PCB (%p)\n", pcb->ccb->id, pcb );

    if ( pcb->rcb )  gcd_del_rcb( pcb->rcb );
    MEfree( (PTR)pcb );
    return;
}
Exemplo n.º 10
0
/*
** Name: cleanup_queues
**
** Description:
**      Empty reamaining info in the merge and GCN queues.
**
** Input:
**
** Output:
**
** Returns:
**      VOID
**
** History:
**      15-Nov-2010 (Ralph Loen)
**          Created.
*/
void cleanup_queues()
{
    QUEUE *q;

    /*
    ** Empty information remaining in queues, if any.
    */
    for (q = gcn_qhead.q_prev; q != &gcn_qhead; q = gcn_qhead.q_prev)
    {
        QUremove(q);
        MEfree((PTR)q);
    }

    for (q = merge_qhead.q_prev; q != &merge_qhead; q = merge_qhead.q_prev)
    {
        QUremove(q);
        MEfree((PTR)q);
    }
}
Exemplo n.º 11
0
void
gcd_release_sp( GCD_CCB *ccb, GCD_SPCB *target )
{
    while( ccb->xact.savepoints  &&  ccb->xact.savepoints != target )
    {
	GCD_SPCB *sp = ccb->xact.savepoints;
	ccb->xact.savepoints = sp->next;
	sp->next = NULL;
	MEfree( (PTR)sp );
    }
    return;
}
Exemplo n.º 12
0
STATUS
gcn_request( char *gcn_host, i4  *assoc_no, i4 *protocol )
{
    GCA_RQ_PARMS	request;
    STATUS		status = OK;
    char		tbuff[ GC_HOSTNAME_MAX + 12 ];
    char		*target;
    i4			len;

    /* 
    ** Prepare for GCA_REQUEST service call 
    */
    len = (gcn_host ? STlength( gcn_host ) + 2 : 0) + 10;
    target = (len <= sizeof( tbuff )) 
    	     ? tbuff : (char *)MEreqmem( 0, len, FALSE, NULL );

    if ( ! target )  return( E_GC0013_ASSFL_MEM );

    STprintf( target, "%s%s/IINMSVR", 
	      gcn_host ? gcn_host : "", gcn_host ? "::" : "" );

    MEfill( sizeof( request ), '\0', (PTR)&request );
    request.gca_peer_protocol = GCA_PROTOCOL_LEVEL_63;
    request.gca_partner_name = target;

    /* 
    ** Make GCA_REQUEST service call 
    */
    gca_call( &gcn_gca_cb, GCA_REQUEST, (GCA_PARMLIST *)&request,
	      GCA_SYNC_FLAG, NULL, GCN_RCV_TIMEOUT, &status );

    gcn_checkerr( "GCA_REQUEST", 
		  &status, request.gca_status, &request.gca_os_status );

    if ( status != OK )  goto done;

    if ( gcn_host  &&  request.gca_peer_protocol < GCA_PROTOCOL_LEVEL_50 )
    {
        gcn_release( request.gca_assoc_id );
	CL_CLEAR_ERR( &request.gca_os_status );
	gcn_checkerr( "GCA_REQUEST", 
		      &status, E_GC000A_INT_PROT_LVL, &request.gca_os_status );
	goto done;
    }

    *assoc_no = request.gca_assoc_id;
    *protocol = request.gca_peer_protocol;

  done :

    if ( target != tbuff )  MEfree( (PTR)target );
    return( status );
}
Exemplo n.º 13
0
/*
** Name: WTSCloseUpLoad() - 
**
** Description:
**
** Inputs:
**
** Outputs:
**
** Returns:
**	GSTATUS	:	GSTAT_OK
**
** Exceptions:
**	None
**
** Side Effects:
**	None
**
** History:
*/
GSTATUS
WTSCloseUpLoad(
	WTS_SESSION	*session)
{
    GSTATUS     err = GSTAT_OK;
    PWTS_UPLOAD next = session->load;
    PWTS_UPLOAD load;
    UPLOADED_FILE*  upload;

    session->load = NULL;
    while (next != NULL)
    {
        load = next;
        if (load->state != US_END)
        {
            upload = session->list;
            if (upload != NULL)
            {
                session->list = upload->next;
                CLEAR_STATUS(WCSClose(upload->file));
                MEfree ((PTR)upload);
            }
            /*
            **  Trace untimely end
            */
        }
        if (load->buf     ) MEfree (load->buf     );
        if (load->start   ) MEfree (load->start   );
        if (load->end     ) MEfree (load->end     );
        if (load->varname ) MEfree (load->varname );
        if (load->icefname) MEfree (load->icefname);
        if (load->filename) MEfree (load->filename);
        if (load->type    ) MEfree (load->type    );
        if (load->encode  ) MEfree (load->encode  );
        next = load->next;
        MEfree ((PTR)load);
    }
    return(err);
}
Exemplo n.º 14
0
static VOID
psy_pop_all(PSY_STK *base)
{
    PSY_STK *stk;
    if (base->head)
    {
	for (stk = base->head; base != stk; stk = base->head)
	{
	    base->head = stk->head;
	    MEfree((PTR)stk);
	}
    }
}
Exemplo n.º 15
0
/* Name: adu_map_delete_vldtbl - cleans up the memory for validity table. 
**
** Description:
**      This routines, releases the memory allocated for 
**	state table for validity check on valid code points.
**
** Input:
**              validity_table - pointer to the validity table.
**
** Output:
**              None. 
**
** History:
**      02-Sep-2004 (gupsh01)
**          Added.
*/
static void 
adu_map_delete_vldtbl (
    ADU_MAP_STATETABLE *validity_table)
{
    int i;
    ADU_MAP_STATETABLE  *ptr = NULL;

    if (validity_table)
    {
      for (ptr=validity_table; ptr != NULL; ptr = ptr->next)
      {
	/* For every row in the state table */

	/* Delete all arrays entries in the state table */
        for (i=0; i<256; i++)
        {
    	   if (ptr->state_table[i])
           {
	     MEfree ((char *)(ptr->state_table[i]));
	     ptr->state_table[i] = NULL;
	   }
        }

	/* Delete the statetable entries itself. */
    	if (ptr->state_table)
	{
	  MEfree ((char *)ptr->state_table);
	  ptr->state_table = NULL;
	}
      }

      if (validity_table)
      {
	MEfree ((char *)validity_table);
        validity_table = NULL;
      }
    }
}
Exemplo n.º 16
0
/* Name: adu_deletemap - Cleans up the memory allocated for mapping tables. 
**
** Description:
**      Releases memory allocated for coercion mapping tables.
** Input:
**	None 
** Output:
**	None 
**
** History:
**      23-Jan-2004 (gupsh01)
**          Created.
**	17-Feb-2004 (gupsh01)
**	    Fixed handling the map header.
**      16-Apr-2004 (loera01)
**          Removed redundant MEfree of Adf_globs->Adu_maptbl.
**	02-Sep-2004 (gupsh01)
**	    Add cleaning up of validity table memory.
**	10-Aug-2005 (gupsh01)
**	    Free charmapptr and unimapptr.(Bug 115022) 
**
*/
DB_STATUS
adu_deletemap(void)
{
   DB_STATUS		status;
   ADU_MAP_HEADER 	*header;
   ADU_MAP_CHARMAP	*charmapptr;
   ADU_MAP_UNIMAP	*unimapptr;
   ADU_MAP_STATETABLE   *validity_tbl;

   header = ((ADU_MAP_INFO *)(Adf_globs->Adu_maptbl))->header;
   charmapptr = ((ADU_MAP_INFO *)(Adf_globs->Adu_maptbl))->charmapptr;
   unimapptr = ((ADU_MAP_INFO *)(Adf_globs->Adu_maptbl))->unimapptr;
   validity_tbl = ((ADU_MAP_INFO *)(Adf_globs->Adu_maptbl))->validity_tbl;

   if (header)
     MEfree ((char *)header);

   adu_map_delete_charmap (
		&charmapptr->charmap, 
		&charmapptr->chardefault2d, 
		&charmapptr->chardefault1d);

   adu_map_delete_unimap (
		&unimapptr->unimap, 
		&unimapptr->unidefault);

   adu_map_delete_vldtbl (validity_tbl);

   MEfree ((char *)charmapptr);
   MEfree ((char *)unimapptr);

   if (Adf_globs->Adu_maptbl)
     MEfree ((char *)Adf_globs->Adu_maptbl);

   Adf_globs->Adu_maptbl = NULL;

   return (E_DB_OK);
}
Exemplo n.º 17
0
void
gcd_free_qdata( QDATA *qdata )
{
    qdata->max_rows = 0;
    qdata->max_cols = 0;
    qdata->col_cnt = 0;
    qdata->cur_col = 0;
    qdata->more_segments = FALSE;
    qdata->desc = NULL;

    if ( qdata->param_desc )
    {
	IIAPI_DESCRIPTOR *desc = (IIAPI_DESCRIPTOR *)qdata->param_desc;
	u_i2		 i;

	for( i = 0; i < qdata->desc_max; i++ )
	    if ( desc[i].ds_columnName )  MEfree( desc[i].ds_columnName );

	MEfree( qdata->param_desc );
	qdata->param_desc = NULL;
    }

    qdata->desc_max = 0;

    if ( qdata->data )  MEfree( qdata->data );
    qdata->data = NULL;
    qdata->data_max = 0;

    if ( qdata->data_buff )  MEfree( qdata->data_buff );
    qdata->data_buff = NULL;
    qdata->db_max = 0;

    if ( qdata->blob_buff )  MEfree( qdata->blob_buff );
    qdata->blob_buff = NULL;
    qdata->bb_max = 0;

    return;
}
Exemplo n.º 18
0
static void
undefine( char *symbol )
{
	SYMBOL **symptr_anchor;
	SYMBOL *symptr;

	/* Try and locate the symbol in the list */
	for (symptr_anchor = &symtab.head;
		*symptr_anchor != NULL; 
		symptr_anchor = &symptr->next )
	{
		symptr = *symptr_anchor;
		if( STequal( symbol, symptr->name ) != 0 ) 
		{
			*symptr_anchor = symptr->next;
			MEfree( symptr->name );
			MEfree( symptr->value );
			MEfree( (PTR)symptr );
			symtab.nsym--;
			break;
		}
	}
}
Exemplo n.º 19
0
static 
VOID	
RemoveServer( SERVER_ENTRY *target )
{
	SERVER_ENTRY *cur, *prev;

	/* The last server in the list is always the name server which never
	** gets removed.
	*/
	if ( NULL == target->next )
		return;
	
	cur = server_list;
	prev = NULL;
	
	while( cur != target )
	{
		prev = cur;
		cur = cur->next;
	}
	if ( prev )
		prev->next = cur->next;
	else
		server_list = cur->next;
		
	UnmapViewOfFile( cur->lpMapping );
	CloseHandle( cur->hMapping );
	CloseHandle( cur->RequestingEvent );
	CloseHandle( cur->ListeningEvent );
	
	if( cur->name )
		MEfree( cur->name );
	
	MEfree( (char *) cur );
	nServers--;
	
}	
Exemplo n.º 20
0
VOID
RSmem_free(
char *buf1,
char *buf2,
char *buf3,
char *buf4,
char *buf5)
{
	if(buf1)
	   MEfree((PTR)buf1);

	if(buf2)
	   MEfree((PTR)buf2);
	 
	if(buf3)
	   MEfree((PTR)buf3);
	
	if(buf4)
	   MEfree((PTR)buf4);

	if(buf5)
	   MEfree((PTR)buf5);

}
Exemplo n.º 21
0
/*
** Name: FWrite_EBound
**
** Decription:
**      A terminating boundary is recevied during upload of a file.  Indicating
**      the file has completed and should now be closed.
**
** Inputs:
**      sess        ice session structure
**      line        pointer to the current line
**      linelen     length of the line
**
** Outputs:
**      pos         number of characters handled.
**
** Return:
**      GSTAT_OK    success
**      other       failure
**
** History:
**      23-Oct-98 (fanra01)
**          Created.
*/
static GSTATUS
FWrite_EBound (WTS_SESSION* sess, char* line, i4  linelen, i4 * pos)
{
    GSTATUS     err = GSTAT_OK;
    PWTS_UPLOAD load= sess->load;
    UPLOADED_FILE*  upload = sess->list;

    if (upload != NULL)
    {
        sess->list = upload->next;
        CLEAR_STATUS(WCSClose(upload->file));
        MEfree ((PTR)upload);
    }
    load->state = US_END;
    return (err);
}
Exemplo n.º 22
0
/* Name: adu_map_delete_charmap - cleans up a charmap table. 
**
** Description:
**      This routines, deletes the inmemory charmap table and default arrays.
**
** Input:
**              Base            pointer to charmap table.
**              Default2D       pointer to 2D default array.
**              Default         pointer to default array.
**
** Output:
**		None.
** History:
**      23-Jan-2004 (gupsh01)
**          Added.
**	10-Aug-2005 (gupsh01)
**	    Free Base and Default2D. (Bug 115022) 
*/
static void 
adu_map_delete_charmap(
    u_i4 	****Base, 
    u_i4 	***Default2D, 
    u_i4 	**Default)
{
    i4 i,j,k;
    if (*Base)
    {
      for (j=0; j<256; j++)
      {
        if ((*Base)[j] && ((*Base)[j] != *Default2D))
        {
    	for (k=0; k<256; k++)
    	{
     	  if ((*Base)[j][k] && ((*Base)[j][k] != *Default))
    	  {
     	    /* delete ((*Base)[j][k]); */
	    MEfree ((char *)(*Base)[j][k]);
    	    (*Base)[j][k] = NULL;
    	  }
    	}
    	/* delete (*Base)[j]; */ 
    	MEfree ((char *)(*Base)[j]); 
    	(*Base)[j] = NULL;
        }
      }
      MEfree (*Base);	  
      *Base = NULL;    
    }

    if (*Default2D)
    {
      for (i=0; i<256; i++)
      {
        if ((*Default2D)[i] && ((*Default2D)[i] != *Default))
        {
    	/* delete ((*Default2D)[i]); */
	MEfree ((char *)(*Default2D)[i]);
    	(*Default2D)[i] = NULL;
        }
      }
      MEfree ((char *)*Default2D);
      *Default2D=NULL;
    }
    if (*Default)
    {
      /* delete *Default; */
      MEfree ((char *)*Default);	  
      *Default=NULL;
    }
}
Exemplo n.º 23
0
DB_STATUS
IICXfree_icas_xn_cb(
            IICX_ICAS_XN_CB       *icas_xn_cb_p    /* IN */
           )
{
    STATUS             cl_status;
    char               ebuf[20];

    if ((cl_status = MEfree( (PTR)icas_xn_cb_p )) != OK)
    {
      CVna((i4)cl_status, ebuf);
      IICXerror(GE_LOGICAL_ERROR, E_CX0003_CX_CB_FREE, 2, ebuf, 
                                     ERx("IIcx_icas_xn_cb"));
      return( E_DB_FATAL );
    }

    return( E_DB_OK );

} /* IICXfree_icas_xn_cb */
Exemplo n.º 24
0
static PTR
psy_pop(PSY_STK *base)
{
    /* Point to true list head block */
    PSY_STK *stk = base->head ? base->head : base;
    
    if (!stk->sp)
    {
        if (base == stk)
        {
            /*stack underflow*/
            return NULL;
        }
        base->head = stk->head;

        MEfree((PTR)stk);
        stk = base->head;
   }
   return stk->list[--stk->sp];
}
Exemplo n.º 25
0
/*
** Name: WSMRemoveUsrSession() - remove a session from the hashtable and the timeout list.
**
** Description:
**
** Inputs:
**	USR_PSESSION*	: user session 
**
** Outputs:
**
** Returns:
**	GSTATUS	:	GSTAT_OK
**
** Exceptions:
**	None
**
** Side Effects:
**	None
**
** History:
**      03-Jun-1999 (fanra01)
**          Add removal of user session variable semaphore.
*/
GSTATUS 
WSMRemoveUsrSession ( 
    USR_PSESSION    session)
{
    GSTATUS err = GSTAT_OK;
    USR_PSESSION tmp;

    CLEAR_STATUS(WPSCleanFilesTimeout (session->name));

    CLEAR_STATUS(DDFdelhash(
                        usr_sessions,
                        session->name,
                        STlength(session->name),
                        (PTR*) &tmp));

    CLEAR_STATUS(WSMRemoveTimeout(session));

    if (session->requested_counter <= 0)
    {
        while (session->transactions != NULL)
            CLEAR_STATUS( WSMRollback(session->transactions, FALSE) );

        if (session->name != NULL)
            usr_sess_detach(session->name);

        if (session->userid != SYSTEM_ID)
            CLEAR_STATUS(DDSReleaseUser(session->userid));

        err = DDFSemOpen(&session->usrvarsem, TRUE);
        if (err == GSTAT_OK)
        {
            CLEAR_STATUS(WSFCleanVariable(session->vars));
            CLEAR_STATUS(DDFrmhash(&session->vars));
            CLEAR_STATUS(DDFSemClose(&session->usrvarsem));
        }
        CLEAR_STATUS(DDFSemDestroy(&session->usrvarsem));
        MEfreetag(session->mem_tag);
        MEfree((PTR)session);
    }
return(err);
}
Exemplo n.º 26
0
 void  SAXImportHandlers::writeChars ( const   XMLByte* const  toWrite
# if XERCES_VERSION_MAJOR > 2
        			     , XMLSize_t    count
# else
        			     , const unsigned int    count
# endif
        			     , XMLFormatter* const   formatter)
{
    /* format each piece of CDATA value based on other information */
    int inlen = STlength((char *)toWrite);

    if (!(isMetaInfoSet))
    {
      cerr<<"ERROR: Either table or table metadata information is not found."<<endl;
      ThrowXML(RuntimeException, XMLExcepts::NoError);
    } 
     
    /* collect the string parsed */
    if (datalen == 0)
    {
      datalen = inlen;
      MEcopy (toWrite, datalen, dataval);
    }	
    else 
    {
      int oldlen = datalen;
      datalen += inlen;
      /* Increase the buffer size to hold the value */
      if (datalen > oldlen)
      {
 	char *temp = dataval;
	int factor = (datalen/(DB_MAXSTRING + 32)) + 1;    
	temp = (char *)MEreqmem(0, (DB_MAXSTRING + 32)*factor, TRUE, NULL);
	MEcopy (dataval, oldlen, temp);
	MEfree(dataval);
	dataval = temp;
      }
      MEcopy (toWrite, inlen, dataval + oldlen);	
    }
}
Exemplo n.º 27
0
/*
** Name: WSMReleaseActSession() - Clean an active session
**
** Description:
**
** Inputs:
**	ACT_PSESSION* : active session
**
** Outputs:
**	ACT_PSESSION* : active session
**
** Returns:
**	GSTATUS	:	GSTAT_OK
**
** Exceptions:
**	None
**
** Side Effects:
**	None
**
** History:
**      03-Jul-98 (fanra01)
**          Rename wts_sess_detach to act_sess_detach.
**      26-Aug-2003 (fanra01)
**          Removed explicit memory frees which are part of tagged memory
**          free.
*/
GSTATUS 
WSMReleaseActSession(
	ACT_PSESSION	*act_session) 
{
	GSTATUS err = GSTAT_OK;
	ACT_PSESSION session = *act_session;
	if (session != NULL)
	{
		*act_session = NULL;
		if (session->name != NULL)
			act_sess_detach(session->name);

		err = DDFSemOpen(&actSessSemaphore, TRUE);
		if (err == GSTAT_OK)
		{
			if (session->previous != NULL)
				session->previous->next = session->next;
			else
				active_sessions = session->next;

			if (session->next != NULL)
				session->next->previous = session->previous;
			CLEAR_STATUS(DDFSemClose(&actSessSemaphore));
		}

		CLEAR_STATUS( WSMCleanUserTimeout() );
		CLEAR_STATUS( WPSCleanFilesTimeout(NULL) );
		CLEAR_STATUS( DBCleanTimeout() );

		CLEAR_STATUS(WSFCleanVariable(session->vars));
		CLEAR_STATUS (DDFrmhash(&session->vars));
		MEfreetag(session->mem_tag);

		MEfree((PTR)session);
	}
return(err);
}
Exemplo n.º 28
0
void
gcd_del_cib( GCD_CIB *cib )
{
    GCD_CAPS	*caps;
    char	buff[16];
    u_i2	i;

    GCD_global.cib_active--;

    MOulongout( 0, (u_i8)cib->id, sizeof( buff ), buff );
    MOdetach( GCD_MIB_DBMS, buff );

    while( (caps = (GCD_CAPS *)QUremove( cib->caps.q_next )) )
    {
	MEfree( caps->data );
	MEfree( (PTR)caps );
    }

    if ( cib->database )  MEfree( (PTR)cib->database );
    if ( cib->username )  MEfree( (PTR)cib->username );
    if ( cib->password )  MEfree( (PTR)cib->password );
    for( i = 0; i < cib->parm_cnt; i++ )  MEfree( (PTR)cib->parms[i].value );

    if ( GCD_global.gcd_trace_level >= 6 )
	TRdisplay( "%4d    GCD del CIB (%d)\n", -1, cib->id );

    if ( cib->parm_max < ARR_SIZE( GCD_global.cib_free ) )
	QUinsert( &cib->q, GCD_global.cib_free[ cib->parm_max ].q_prev );
    else
    {
	MEfree( (PTR)cib );
	GCD_global.cib_total--;
    }

    return;
}
Exemplo n.º 29
0
VOID
CS_sampler(void)
{
	CS_SCB	*an_scb;
	i4 	sleeptime, elapsed, seconds, event;
	i4	starttime, stoptime;
	i4 	cs_thread_type;
	i4 	cs_state;
	bool	attached = FALSE;
	u_i4	bior, biow;
	u_i4	dior, diork, diow, diowk;
	u_i4	lior, liork, liow, liowk;

  /*
  ** This thread goes into a loop:
  **	1. Lock the sampler block
  **	2. Do sampling
  **	3. Sleep for the specified interval
  ** The thread will exit normally when the sampler block pointer is NULL.
  ** The thread exits abnormally if it cannot lock the block.
  */
  starttime = CS_checktime();
  elapsed = 0;

  /* Prime the local I/O, Transaction rate counters */
  bior  = Cs_srv_block.cs_wtstatistics.cs_bior_done;
  biow  = Cs_srv_block.cs_wtstatistics.cs_biow_done;
  dior  = Cs_srv_block.cs_wtstatistics.cs_dior_done;
  diork = Cs_srv_block.cs_wtstatistics.cs_dior_kbytes;
  diow  = Cs_srv_block.cs_wtstatistics.cs_diow_done;
  diowk = Cs_srv_block.cs_wtstatistics.cs_diow_kbytes;
  lior  = Cs_srv_block.cs_wtstatistics.cs_lior_done;
  liork = Cs_srv_block.cs_wtstatistics.cs_lior_kbytes;
  liow  = Cs_srv_block.cs_wtstatistics.cs_liow_done;
  liowk = Cs_srv_block.cs_wtstatistics.cs_liow_kbytes;

  /* Transaction rates cannot be determined */
  CsSamplerBlkPtr->txn[CURR] = 0;
  CsSamplerBlkPtr->txn[PEAK] = 0;

  for (;;)
  {
				 
    if (LockSamplerBlk(&hCsSamplerSem) != OK)
    {
    	ExitThread((DWORD)-1);
    }

    if (CsSamplerBlkPtr->shutdown)
    {
	/*
	** Detach the sampler block Managed Object
	*/
	if (attached)
	    MOdetach(CSsamp_index_name, "CsSamplerBlkPtr");

	MEfree((PTR)CsSamplerBlkPtr);
	CsSamplerBlkPtr = NULL;

	CSsamp_stopping = TRUE;
    	UnlockSamplerBlk(hCsSamplerSem);
	CloseHandle(hCsSamplerSem);
	hCsSamplerSem = NULL;

    	ExitThread(0);
    }

    if (!attached)
    {
	/*
	** Attach the sampler block Managed Object
	*/
	MOattach(MO_INSTANCE_VAR, CSsamp_index_name, "CsSamplerBlkPtr",
		 (PTR) CsSamplerBlkPtr);
	attached = TRUE;
    }

    ++CsSamplerBlkPtr->numsamples;   /* Count the number of times we sample */

    /* Loop thru all the SCBs in the server */
    for (an_scb = Cs_srv_block.cs_known_list->cs_next;
    	 an_scb && an_scb != Cs_srv_block.cs_known_list;
	 an_scb = an_scb->cs_next)
    {
	if (an_scb->cs_thread_type >= -1 && 
	    an_scb->cs_thread_type <= MAXSAMPTHREADS - 1)
	    cs_thread_type = an_scb->cs_thread_type;
	else
	    cs_thread_type = MAXSAMPTHREADS - 1; /* use the <invalid> thread */

	/* If Factotum thread, try to isolate which kind */
	if ( cs_thread_type == CS_FACTOTUM )
	{
	    if ( MEcmp((char *)&an_scb->cs_username, " <WriteBehind", 13) == 0 )
		cs_thread_type = CS_WRITE_BEHIND;
	    else if ( MEcmp((char *)&an_scb->cs_username, " <Sort", 6) == 0 )
		cs_thread_type = CS_SORT;
	}

	if (an_scb->cs_state >= 0 &&
	    an_scb->cs_state <= MAXSTATES - 1) 
	    cs_state = an_scb->cs_state;
	else
	    cs_state = MAXSTATES - 1;		/* use the <invalid> state */

	++CsSamplerBlkPtr->Thread[cs_thread_type].numthreadsamples;

	if ( cs_thread_type == CS_NORMAL )
	    ++CsSamplerBlkPtr->totusersamples;
	else
	    ++CsSamplerBlkPtr->totsyssamples;

	switch (cs_state)
	{
	    case CS_COMPUTABLE:		/* Count current facility */
	    {	
	    	i4  facility;

		++CsSamplerBlkPtr->Thread[cs_thread_type].state[cs_state];
		facility = (*Cs_srv_block.cs_facility)(an_scb);
		if (facility >= MAXFACS || facility < 0)
		    facility = MAXFACS - 1;
		++CsSamplerBlkPtr->Thread[cs_thread_type].facility[facility];
		break;
	    }

	    case CS_EVENT_WAIT:		/* Count event types */
		if ( an_scb->cs_memory & CS_BIO_MASK )
		    ++CsSamplerBlkPtr->Thread[cs_thread_type].evwait[EV_BIO];
		else if ( an_scb->cs_memory & CS_DIO_MASK )
		    ++CsSamplerBlkPtr->Thread[cs_thread_type].evwait[EV_DIO];
		else if ( an_scb->cs_memory & CS_LIO_MASK )
		    ++CsSamplerBlkPtr->Thread[cs_thread_type].evwait[EV_LIO];
		else if ( an_scb->cs_memory & CS_LOG_MASK )
		    ++CsSamplerBlkPtr->Thread[cs_thread_type].evwait[EV_LOG];
		else if (an_scb->cs_memory & CS_LOCK_MASK)
		{
		    ++CsSamplerBlkPtr->Thread[cs_thread_type].evwait[EV_LOCK];
		    AddLock( an_scb->cs_sync_obj ?
		    		*((LK_LOCK_KEY *)an_scb->cs_sync_obj) :
		    		dummy_lock,
			     cs_thread_type );
		}
		else
		    ++CsSamplerBlkPtr->Thread[cs_thread_type].state[cs_state];
		event = (an_scb->cs_memory & CS_DIO_MASK ?
			  an_scb->cs_memory & CS_IOR_MASK ?
			  0 : 1
			 :
			 an_scb->cs_memory & CS_LIO_MASK ?
			  an_scb->cs_memory & CS_IOR_MASK ?
			  2 : 3
			 :
			 an_scb->cs_memory & CS_BIO_MASK ?
			  an_scb->cs_memory & CS_IOR_MASK ?
			  4 : 5
			 :
			 an_scb->cs_memory & CS_LOG_MASK ?
			  6 :
			 an_scb->cs_memory & CS_LOCK_MASK ?
			  7 :
			 an_scb->cs_memory & CS_LGEVENT_MASK ?
			  8 :
			 an_scb->cs_memory & CS_LKEVENT_MASK ?
			  9 :
			 /* else it is ...   unknown */
			  10);

		switch (cs_thread_type)
		{
		    case CS_USER_THREAD:
			++CsSamplerBlkPtr->numusereventsamples;
			++CsSamplerBlkPtr->userevent[event]; /* count event type */
			break;
		    default:
			++CsSamplerBlkPtr->numsyseventsamples;
			++CsSamplerBlkPtr->sysevent[event]; /* count event type */
			break;
		} /* switch (cs_thread_type) */
		break;

	    case CS_MUTEX:
		++CsSamplerBlkPtr->Thread[cs_thread_type].state[cs_state];
		AddMutex( ((CS_SEMAPHORE *)an_scb->cs_sync_obj),
				cs_thread_type );
		break;

	    /* Uninteresting states */
	    default:
		++CsSamplerBlkPtr->Thread[cs_thread_type].state[cs_state];
		break;
	} /* switch (cs_state) */
    } /* for */

    /*
    ** If a second or more worth of intervals appear to have elapsed,
    ** compute current and peak per-second I/O, Transaction rates.
    */
    if ( (elapsed += CsSamplerBlkPtr->interval) >= 1000 )
    {
	/* Get the current time; the interval is not reliable! */
	stoptime = CS_checktime();

	if ( (seconds = stoptime - starttime) )
	{
	    if ( (CsSamplerBlkPtr->bior[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_bior_done - bior)
		       / seconds)
		    > CsSamplerBlkPtr->bior[PEAK] )
		CsSamplerBlkPtr->bior[PEAK] = CsSamplerBlkPtr->bior[CURR];

	    if ( (CsSamplerBlkPtr->biow[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_biow_done - biow)
		       / seconds)
		    > CsSamplerBlkPtr->biow[PEAK] )
		CsSamplerBlkPtr->biow[PEAK] = CsSamplerBlkPtr->biow[CURR];

	    if ( (CsSamplerBlkPtr->dior[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_dior_done - dior)
		       / seconds)
		    > CsSamplerBlkPtr->dior[PEAK] )
		CsSamplerBlkPtr->dior[PEAK] = CsSamplerBlkPtr->dior[CURR];

	    if ( (CsSamplerBlkPtr->diork[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_dior_kbytes - diork)
		       / seconds)
		    > CsSamplerBlkPtr->diork[PEAK] )
		CsSamplerBlkPtr->diork[PEAK] = CsSamplerBlkPtr->diork[CURR];

	    if ( (CsSamplerBlkPtr->diow[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_diow_done - diow)
		       / seconds)
		    > CsSamplerBlkPtr->diow[PEAK] )
		CsSamplerBlkPtr->diow[PEAK] = CsSamplerBlkPtr->diow[CURR];

	    if ( (CsSamplerBlkPtr->diowk[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_diow_kbytes - diowk)
		       / seconds)
		    > CsSamplerBlkPtr->diowk[PEAK] )
		CsSamplerBlkPtr->diowk[PEAK] = CsSamplerBlkPtr->diowk[CURR];

	    if ( (CsSamplerBlkPtr->lior[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_lior_done - lior)
			/ seconds)
		    > CsSamplerBlkPtr->lior[PEAK] )
		CsSamplerBlkPtr->lior[PEAK] = CsSamplerBlkPtr->lior[CURR];

	    if ( (CsSamplerBlkPtr->liork[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_lior_kbytes - liork)
			/ seconds)
		    > CsSamplerBlkPtr->liork[PEAK] )
		CsSamplerBlkPtr->liork[PEAK] = CsSamplerBlkPtr->liork[CURR];

	    if ( (CsSamplerBlkPtr->liow[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_liow_done - liow)
			/ seconds)
		    > CsSamplerBlkPtr->liow[PEAK] )
		CsSamplerBlkPtr->liow[PEAK] = CsSamplerBlkPtr->liow[CURR];

	    if ( (CsSamplerBlkPtr->liowk[CURR] =
		   (Cs_srv_block.cs_wtstatistics.cs_liow_kbytes - liowk)
			/ seconds)
		    > CsSamplerBlkPtr->liowk[PEAK] )
		CsSamplerBlkPtr->liowk[PEAK] = CsSamplerBlkPtr->liowk[CURR];

	    /* Transaction rate cannot be determined */
	}

	starttime = CS_checktime();
	elapsed = 0;
        bior  = Cs_srv_block.cs_wtstatistics.cs_bior_done;
        biow  = Cs_srv_block.cs_wtstatistics.cs_biow_done;
        dior  = Cs_srv_block.cs_wtstatistics.cs_dior_done;
        diork = Cs_srv_block.cs_wtstatistics.cs_dior_kbytes;
        diow  = Cs_srv_block.cs_wtstatistics.cs_diow_done;
        diowk = Cs_srv_block.cs_wtstatistics.cs_diow_kbytes;
	lior  = Cs_srv_block.cs_wtstatistics.cs_lior_done;
	liork = Cs_srv_block.cs_wtstatistics.cs_lior_kbytes;
	liow  = Cs_srv_block.cs_wtstatistics.cs_liow_done;
	liowk = Cs_srv_block.cs_wtstatistics.cs_liow_kbytes;
    }

    sleeptime = CsSamplerBlkPtr->interval;

    UnlockSamplerBlk(hCsSamplerSem);

    Sleep (sleeptime);
  } /* for (;;) */

} /* CS_sampler */
Exemplo n.º 30
0
i4
main (int argc, char **argv) 
{
    STATUS status=OK;
    PTR drvH=NULL;
    char **list=NULL;
    ATTR_ID **attrList=NULL;
    char **defAttr=NULL;
    i4 count=0, attrCount = 0, retcount;
    i4 i;
    bool badCmdLine = FALSE, rmPkg = FALSE, has_default = FALSE, has_alt
        = FALSE, isReadOnly = FALSE, mgrSpecified = FALSE, batch = FALSE,
	def_or_alt=FALSE;
    i4 pathType = OCFG_SYS_PATH; 
    char altPath[OCFG_MAX_STRLEN] = "\0";
    char drvMgr[OCFG_MAX_STRLEN] = "\0";
    char line[MAXLINE],prompt[MAXLINE];
    char driverPath[OCFG_MAX_STRLEN];
    char *dirPath;
    char driverName[OCFG_MAX_STRLEN];
    char *ii_installation;
    char *p = NULL;
    char custName[OCFG_MAX_STRLEN];
    char etxt[512];

    ATTR_ID driverList[6] = 
    {
        { DRV_ATTR_DRIVER,          "\0" },
        { DRV_ATTR_DRIVER_ODBC_VER, DRV_STR_VERSION },
        { DRV_ATTR_DRIVER_READONLY, DRV_STR_N },
        { DRV_ATTR_DRIVER_TYPE,     DRV_STR_INGRES },
        { DRV_ATTR_VENDOR,          DRV_STR_INGRES_CORP },
        { DRV_ATTR_DONT_DLCLOSE,    DRV_STR_ONE }
    };
    int drvCount = sizeof(driverList) / sizeof(driverList[0]);

    ATTR_ID **drvList = (ATTR_ID **)MEreqmem( (u_i2) 0, 
	(u_i4)drvCount, TRUE, (STATUS *) NULL);

    for (i = 0; i < drvCount; i++)
    {
        drvList[i] = (ATTR_ID *)MEreqmem( (u_i2) 0, 
	    (u_i4)sizeof(ATTR_ID), TRUE, (STATUS *) NULL);
        drvList[i]->id = driverList[i].id;
        drvList[i]->value = (char *)MEreqmem( (u_i2) 0, 
    	    (u_i4)OCFG_MAX_STRLEN, TRUE, (STATUS *) NULL);
        STcopy(driverList[i].value, drvList[i]->value);
    }

    if ( argc > 7 )
        badCmdLine = TRUE;

    /*
    ** Parse the command line.  Reject invalid arguments.
    */
    if ( !badCmdLine && argc > 1 )
    {
	if (checkArgs("-h", argc, argv, NULL, NULL ) )
	{
	   display_help();
           PCexit(0);	
	}
	if (checkArgs("-help", argc, argv, NULL, NULL ) )
	{
	   display_help();
           PCexit(0);	
	}
        if ( checkArgs("-batch", argc, argv, NULL, NULL ) )
            batch = TRUE;
        if ( checkArgs("-rmpkg", argc, argv, NULL, NULL ) )
            rmPkg = TRUE;
        if (checkArgs("-r", argc, argv, NULL, NULL ) )
            isReadOnly = TRUE;
        if ( checkArgs("-p", argc, argv, altPath, NULL ) )
            pathType = OCFG_ALT_PATH;
        if ( checkArgs("-m", argc, argv, NULL, drvMgr ) )
			mgrSpecified = TRUE;
    }

    /*
    ** Set driver manager according to user input.  Default is unixODBC.
    */
    if (mgrSpecified && !STbcompare( drvMgr, 0, MGR_STR_CAI_PT, 0, TRUE ) )
        driverManager = MGR_VALUE_CAI_PT;
    else
	driverManager = MGR_VALUE_UNIX_ODBC;

    /*
    ** If none of the arguments are recognized, flag an error.
    */
    if ( !batch && !rmPkg && !isReadOnly && pathType != OCFG_ALT_PATH && !mgrSpecified && argc > 1)
        badCmdLine = TRUE;

    if ( badCmdLine )
    {
        display_help();
        PCexit(FAIL);
    }
    
    if ( isReadOnly )
        STcopy(DRV_STR_Y, drvList[2]->value); 
    else
        STcopy(DRV_STR_N, drvList[2]->value); 

    if ( !writeMgrFile( altPath ) )
    {
        SIprintf("Aborting due to error writing %s/files/%s\n",
           SYSTEM_LOCATION_SUBDIRECTORY, MGR_STR_FILE_NAME); 
        PCexit(FAIL);
    }
    defAttr = getDefaultInfo(); 
    if (defAttr == NULL)
    {
        SIprintf("Aborting due to error reading %s/install/%s\n",
            SYSTEM_LOCATION_VARIABLE, INFO_STR_FILE_NAME);
        PCexit(FAIL);
    }

    /*
    ** Get the path of the driver library and create the path/libname string.
    */
    NMgtAt(SYSTEM_LOCATION_VARIABLE,&dirPath);  /* usually II_SYSTEM */
    if (dirPath != NULL && *dirPath)
        STlcopy(dirPath,driverPath,sizeof(driverPath)-20-1);
    else
    {
        SIprintf("Error--%s is not defined\n",SYSTEM_LOCATION_VARIABLE);
        PCexit(FAIL);
    }
# ifdef VMS
    STcat(driverPath,"[");
    STcat(driverPath,SYSTEM_LOCATION_SUBDIRECTORY);  /* usually "ingres"  */
    STcat(driverPath,".library]");
    if ( isReadOnly )
        STcat(driverPath,defAttr[INFO_ATTR_RONLY_DRV_FNAME]);
    else
        STcat(driverPath,defAttr[INFO_ATTR_DRIVER_FILE_NAME]);
# else
    STcat(driverPath,"/");
    STcat(driverPath,SYSTEM_LOCATION_SUBDIRECTORY);  /* usually "ingres"  */
    STcat(driverPath,"/lib/");
    if ( isReadOnly )
        STcat(driverPath,defAttr[INFO_ATTR_RONLY_DRV_FNAME]);
    else
        STcat(driverPath,defAttr[INFO_ATTR_DRIVER_FILE_NAME]);
# endif /* ifdef VMS */
    STcopy(driverPath,drvList[0]->value);
    /*
    ** Initialize the cache from the odbcinst.ini file.
    */
    openConfig(NULL, pathType, altPath, &drvH, &status);
    if (status != OK)
    {
        STprintf(etxt,"Could not open from path %s.\n",
            pathType == OCFG_ALT_PATH ? altPath : "/usr/local/etc");
        display_err(etxt,status);
        PCexit(FAIL);
    }
    if (rmPkg)
    {
        delConfigEntry( drvH, defAttr[INFO_ATTR_DRIVER_NAME], &status );
        delConfigEntry( drvH, defAttr[INFO_ATTR_ALT_DRIVER_NAME], &status );
        closeConfig(drvH, &status);
        PCexit(OK);
    }
    /*
    ** Get the driver count.
    */
    retcount = listConfig( drvH, count, list, &status );
    if (status != OK)
    {
        STprintf(etxt,"Could not list drivers.\n");
        display_err(etxt,status);
        PCexit(FAIL);
    }
    count = retcount;
    if (count)
    {
        /*
        ** Get the list of recognized drivers.
        */
	list = (char **)MEreqmem( (u_i2) 0, 
	    (u_i4)(count * sizeof(char *)), TRUE, 
	    (STATUS *) NULL);
	for (i = 0; i < count; i++)
	    list[i] =  (char *)MEreqmem( (u_i2) 0, (u_i4)OCFG_MAX_STRLEN, 
	        TRUE, (STATUS *) NULL);
        listConfig( drvH, count, list, &status );
        if (status != OK)
        {
            STprintf(etxt,"Could not list drivers.\n");
            display_err(etxt,status);
            PCexit(FAIL);
        }
    }
    for (i = 0; i < count; i++)
    {
        def_or_alt = FALSE;
	if (!has_default)
	{
            has_default = STbcompare( list[i], 0, 
                defAttr[INFO_ATTR_DRIVER_NAME], 0, TRUE ) 
                   == 0 ? TRUE : FALSE;
            if (has_default)
                def_or_alt = TRUE; 
        }
        if (!has_alt)
        {
            has_alt = STbcompare( list[i], 0, 
                defAttr[INFO_ATTR_ALT_DRIVER_NAME], 0, 
                   TRUE ) == 0 ? TRUE : FALSE;
            if (has_alt)
                def_or_alt = TRUE; 
        }
        if (def_or_alt)
        {
            if ( !batch )
	    {
                STprintf(prompt,
         "\tInstallation has pre-defined version of %s.\n\tOverwrite? (Yes/No)", 
		list[i]);
                if ( line_get( prompt, "", FALSE, line ) == EOF )
                {
                    SIprintf("ODBC driver installation safely aborted\n");
                    PCexit(OK);
                }
                STzapblank(line,line);
                if ( line[0] != 'y' && line [0] != 'Y' )
                {
                    SIprintf( "%s left untouched\n", list[i] );
		    continue; 
                }
            } /* if (!batch) */
            STcopy(list[i],driverName);
            setConfigEntry( drvH, driverName, drvCount, drvList, &status );
            if (status != OK)
            {
                STprintf(etxt,"Could not write driver entry.\n");
                display_err(etxt,status);
                PCexit(FAIL);
            }
        } /* if (has_default || has_alt) */ 
        else if ( !batch )
        {
                STprintf(prompt,
         "\tInstallation has custom version of %s.\n\tDelete? (Yes/No)", 
		list[i]);
                if ( line_get( prompt, "", FALSE, line ) == EOF )
                {
                    SIprintf("ODBC driver installation safely aborted\n");
                    PCexit(OK);
                }
                STzapblank(line,line);
                if ( line[0] != 'y' && line [0] != 'Y' )
                {
                    SIprintf( "%s left untouched\n", list[i] );
                    continue;
                }
            STcopy(list[i],driverName);
            delConfigEntry( drvH, driverName, &status );
            if (status != OK)
            {
                STprintf(etxt,"Could not write driver entry.\n");
                display_err(etxt,status);
                PCexit(FAIL);
            } 
        } /* if (!batch) && !has_default */
    } /* for (count... */
    if (!has_default) 
    {
        setConfigEntry( drvH, defAttr[INFO_ATTR_DRIVER_NAME], drvCount,
	    drvList, &status );
        if (status != OK)
        {
            STprintf(etxt,"Could not write driver entry.\n");
            display_err(etxt,status);
            PCexit(FAIL);
        }
    }
    if (!has_alt) 
    {
        setConfigEntry( drvH, defAttr[INFO_ATTR_ALT_DRIVER_NAME], drvCount,
	    drvList, &status );
        if (status != OK)
        {
            STprintf(etxt,"Could not write driver entry.\n");
            display_err(etxt,status);
            PCexit(FAIL);
        }
    }
    closeConfig(drvH, &status);
    if (status != OK)
    {
        STprintf(etxt,"Could not close driver info.\n");
        display_err(etxt,status);
        PCexit(FAIL);
    }
    if (count)
    {
        for (i = 0; i < count; i++)
	    MEfree((PTR)list[i]);
        MEfree((PTR)list);
    }
    for (i = 0; i < drvCount; i++)
    {
        MEfree((PTR)drvList[i]->value);
        MEfree((PTR)drvList[i]);
    }
    MEfree((PTR)drvList);

    PCexit(OK);
}