GCD_CIB * gcd_new_cib( u_i2 count ) { GCD_CIB *cib = NULL; u_i2 len = sizeof( GCD_CIB ) + (sizeof(CONN_PARM) * (count - 1)); if ( count < ARR_SIZE( GCD_global.cib_free ) ) if (! (cib = (GCD_CIB *)QUremove(GCD_global.cib_free[count].q_next))) if ( (cib = (GCD_CIB *)MEreqmem( 0, len, FALSE, NULL )) ) cib->id = GCD_global.cib_total++; if ( ! cib ) gcu_erlog(0, GCD_global.language, E_GC4808_NO_MEMORY, NULL, 0, NULL); else { u_i4 id = cib->id; char buff[16]; MEfill( len, 0, (PTR)cib ); cib->id = id; cib->parm_max = count; QUinit( &cib->caps ); MOulongout( 0, (u_i8)cib->id, sizeof( buff ), buff ); MOattach( MO_INSTANCE_VAR, GCD_MIB_DBMS, buff, (PTR)cib ); GCD_global.cib_active++; if ( GCD_global.gcd_trace_level >= 6 ) TRdisplay( "%4d GCD new CIB (%d)\n", -1, cib->id ); } return( cib ); }
STATUS MOuivget( i4 offset, i4 size, PTR object, i4 lsbuf, char *sbuf ) { STATUS stat = OK; /* lint truncation warning if size of ptr > int, but code valid */ u_i4 ival = (u_i4)((char *)object + offset); if( stat == OK ) stat = MOulongout( MO_VALUE_TRUNCATED, ival, lsbuf, sbuf ); return( stat ); }
/*{ ** Name: CS_scb_lio_get -- MO get methods for sum of LIO ** read/writes. ** ** Description: ** Returns the sum of LIO read/writes. ** ** Inputs: ** offset ignored. ** objsize ignored. ** object the CS_SCB in question. ** luserbuf length of output buffer ** ** Outputs: ** userbuf Sum of reads+writes. ** ** ** Returns: ** OK ** MO_VALUE_TRUNCATED ** ** History: ** 20-Sep-2000 (jenjo02) ** created. */ STATUS CS_scb_lio_get(i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf) { CS_SCB *scb = (CS_SCB *)object; return (MOulongout( MO_VALUE_TRUNCATED, (u_i8)(scb->cs_lior + scb->cs_liow), luserbuf, userbuf)); }
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; }
/*{ ** 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 (daveb) ** initialize str to buf; discovered by mikem. */ STATUS CS_scb_memory_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_COMPUTABLE: if ( !(scb->cs_mask & CS_MUTEX_MASK) ) { stat = MOulongout( MO_VALUE_TRUNCATED, scb->cs_memory, luserbuf, userbuf ); break; } /* Drop into next case */ case CS_MUTEX: buf[0] = scb->cs_mask & CS_SMUTEX_MASK ? 's' : 'x'; buf[1] = ' '; (void) MOulongout( 0, scb->cs_memory, sizeof(buf)-2, &buf[2] ); stat = MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf ); break; default: stat = MOulongout( MO_VALUE_TRUNCATED, scb->cs_memory, luserbuf, userbuf ); break; } return( stat ); }