STATUS MOlongout( STATUS errstat, i8 val, i4 destlen, char *dest ) { char bufa[ MO_MAX_NUM_BUF ]; char bufb[ MO_MAX_NUM_BUF ]; char *p; char *q; i4 padlen; bufa[0] = EOS; /* Ignore errors in CVla8 -- force to 0 */ (void)CVla8( val, bufa ); padlen = MAX_I8_DIGITS_AND_SIGN - (i4)STlength( bufa ); p = bufb; q = bufa; /* put sign first, before pad */ if( bufa[0] == '-' ) *p++ = *q++; while( padlen-- > 0 ) *p++ = '0'; STcopy( q, p ); return( MOstrout( errstat, bufb, destlen, dest ) ); }
STATUS CS_scb_mask_get(i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf) { char buf[ 80 ]; i4 mask = *(i4 *)((char *)object + offset); MASK_BITS *mp; char *p = buf; char *q; for( mp = mask_bits; mp->str != NULL; mp++ ) { if( mask & mp->bit ) { if( p != buf ) *p++ = ','; for( q = mp->str; *p++ = *q++ ; ) continue; } } *p = EOS; return( MOstrout( MO_VALUE_TRUNCATED, buf, luserbuf, userbuf )); }
STATUS MO_classid_index(i4 msg, PTR cdata, i4 linstance, char *instance, PTR *instdata ) { STATUS stat = OK; MO_CLASS *cp; switch( msg ) { case MO_GET: if( OK == (stat = MO_getclass( instance, &cp ) ) ) *instdata = (PTR)cp; break; case MO_GETNEXT: if( OK == ( stat = MO_nxtclass( instance, &cp ) ) ) { *instdata = (PTR)cp; stat = MOstrout( MO_INSTANCE_TRUNCATED, cp->node.key, linstance, instance ); } break; default: stat = MO_BAD_MSG; break; } return( stat ); }
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 ); }
STATUS MO_mon_class_get( i4 offset, i4 size, PTR object, i4 lsbuf, char *sbuf ) { MO_MON_BLOCK *mp = (MO_MON_BLOCK *)object; return( MOstrout( MO_VALUE_TRUNCATED, mp->mo_class->node.key, lsbuf, sbuf ) ); }
/*{ ** 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 ); }
STATUS MOulongout( STATUS errstat, u_i8 val, i4 destlen, char *dest ) { char buf[ MO_MAX_NUM_BUF ]; char *p; /* put p after last possible converted decimal, + leading 0 */ /* comparison is plus 1 to account for space for EOS in the length */ if( destlen < MAX_UI8_DIGITS + 1 ) p = buf + destlen - 1; /* minus 1 because destlen is a length and includes '\0' */ else p = buf + MAX_UI8_DIGITS; /* Length constant used as 0-based offset to 1 beyond digits */ *p-- = EOS; while( val != 0 && p >= buf ) { *p-- = (char)((val % 10) + '0'); val /= 10; } while( p >= buf ) *p-- = '0'; return( MOstrout( errstat, buf, destlen, dest ) ); }
/* ** Name: ddc_dbname_get - remove a DB_CACHED_SESSION instance ** ** Description: ** ** ** ** Inputs: ** ** ** ** Outputs: ** ** None ** ** Returns: ** None. ** ** History: ** 13-Jul-98 (fanra01) ** Created. ** */ STATUS ddc_dbname_get (i4 offset, i4 objsize, PTR obj, i4 userbuflen, char * userbuf) { PDB_CACHED_SESSION session = (PDB_CACHED_SESSION) obj; PDB_CACHED_SESSION_SET sess_set = session->set; return (MOstrout(MO_VALUE_TRUNCATED, sess_set->name, userbuflen, userbuf)); }
STATUS GM_srv_get( i4 offset, i4 size, PTR object, i4 lsbuf, char *sbuf ) { STATUS cl_stat = OK; MOstrout( MO_VALUE_TRUNCATED, GM_my_server(), lsbuf, sbuf ); return( cl_stat ); }
STATUS MOptrxout( STATUS errstat, PTR ptr, i4 destlen, char *dest ) { char buf[ CV_DEC_PTR_SIZE + 1 ]; CVptrax( ptr, buf ); return( MOstrout( errstat, buf, destlen, dest ) ); }
STATUS MO_ipindex(i4 msg, PTR cdata, i4 linstance, char *instance, PTR *instdata ) { STATUS stat = MO_NO_INSTANCE; MO_INSTANCE *ip; ip = MO_getinstance( (char *)cdata, instance ); switch( msg ) { case MO_GET: if( ip != NULL ) stat = OK; break; case MO_GETNEXT: if( ip != NULL ) { ip = (MO_INSTANCE *) SPnext( &ip->node, MO_instances ); if( ip != NULL && !STequal( (char *)ip->classdef->node.key, (char *)cdata ) ) ip = NULL; } else /* didn't find directly */ { if( *instance == EOS ) ip = MO_getinstance( (char *)cdata, (char *)NULL ); else break; } if( ip == NULL ) stat = MO_NO_NEXT; else stat = MOstrout( MO_INSTANCE_TRUNCATED, ip->instance, linstance, instance ); break; default: stat = MO_BAD_MSG; break; } *instdata = (PTR)ip; return( stat ); }
static STATUS GM_subpindex(i4 msg, PTR cdata, i4 linstance, char *instance, PTR *instdata ) { STATUS cl_stat = MO_NO_INSTANCE; GM_PLACE_BLK *pb; SPBLK lookup; lookup.key = instance; pb = (GM_PLACE_BLK *)SPlookup( &lookup, &GM_globals.gwm_places ); switch( msg ) { case MO_GET: if( pb != NULL ) cl_stat = OK; break; case MO_GETNEXT: if( pb != NULL ) { pb = (GM_PLACE_BLK *) SPfnext( &pb->place_blk ); } else /* didn't find directly */ { if( *instance == EOS ) pb = (GM_PLACE_BLK *)SPfhead( &GM_globals.gwm_places ); else break; } if( pb == NULL ) cl_stat = MO_NO_NEXT; else cl_stat = MOstrout( MO_INSTANCE_TRUNCATED, pb->place_key, linstance, instance ); break; default: cl_stat = MO_BAD_MSG; break; } *instdata = (PTR)pb; return( cl_stat ); }
/*{ ** Name: <func name> - <short comment> ** ** Description: ** ** MO get method. Given pointer to the connect block ** with the place pointer, return a nice decoded version of the place. ** ** With this version, a too-long place is truncated with no error. ** ** Re-entrancy: ** yes. ** ** Inputs: ** offset byte offset to apply to the object (should be 0) ** size ignored ** object pointer to the GM_CONN_BLK. ** lsbuf length of the output buffer. ** ** Outputs: ** sbuf the buffer to fill. ** ** Returns: ** OK. ** ** History: ** 2-Feb-1993 (daveb) ** documented. */ STATUS GM_cplace_get( i4 offset, i4 size, PTR object, i4 lsbuf, char *sbuf ) { STATUS cl_stat = OK; GM_CONN_BLK *cb = (GM_CONN_BLK *)((char *)object + offset); GM_PLACE_BLK *pb = cb->conn_place; MOstrout( MO_VALUE_TRUNCATED, pb->place_blk.key, lsbuf, sbuf ); return( cl_stat ); }
STATUS GM_sflags_get( i4 offset, i4 size, PTR object, i4 lsbuf, char *sbuf ) { char buf[ 100 ]; i4 flags = *(i4*)((char *)object + offset); /* FIXME wired to GCA values */ MEfill( sizeof(buf), 0, buf ); TRformat(NULL, 0, buf, sizeof(buf), "%v", "NMSVR,GCB,GCD,UNUSED,TRAP,INSTALL,ACP,RCP,INGRES,GCC,GCN", (flags & GCA_RG_MIB_MASK) >> 20 ); return (MOstrout( MO_VALUE_TRUNCATED, buf, lsbuf, sbuf )); }
STATUS MO_nullstr_get( i4 offset, i4 size, PTR object, i4 lsbuf, char *sbuf ) { STATUS ret_val = OK; char *objp = (char *)object + offset; char *cobj = *(char **)objp; ret_val = MOstrout( MO_VALUE_TRUNCATED, cobj ? cobj : "<NULL>", lsbuf, sbuf ); # if 0 if( ret_val != OK ) MO_breakpoint(); # endif return( ret_val ); }
STATUS MO_class_get(i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf) { MO_CLASS *cp = (MO_CLASS *)object; char *src; if( CMdigit( (char *)cp->node.key ) ) src = cp->twin->node.key; else src = cp->node.key; return( MOstrout( MO_VALUE_TRUNCATED, src, luserbuf, userbuf ) ); }
/* ** Name: ADFmo_adg_op_use_get - MO Get function for the op_use field ** ** Description: ** This routine is called by MO to provide a "user-friendly" ** interpretation of the operation use. ** ** Inputs: ** offset - offset into the ADI_OPRATION, ignored. ** objsize - size of the use field, ignored ** object - the ADI_OPRATION address ** luserbuf - length of the output buffer ** ** Outputs: ** userbuf - written with nice status string ** ** Returns: ** STATUS ** ** History: ** 18-Jun-2008 (kiria01) b120519 ** Created */ static STATUS ADFmo_adg_op_use_get( i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf ) { ADI_OPRATION *op = (ADI_OPRATION *)object; char format_buf [30]; MEfill(sizeof(format_buf), (u_char)0, format_buf); TRformat(NULL, 0, format_buf, sizeof(format_buf), "%w", use_string, op->adi_opuse); return (MOstrout( MO_VALUE_TRUNCATED, format_buf, luserbuf, userbuf )); }
/* ** Name: ADFmo_adg_fi_type_get - MO Get function for the fi_type field ** ** Description: ** This routine is called by MO to provide a "user-friendly" ** interpretation of the operation type. ** ** Inputs: ** offset - offset into the ADI_FI_DESC, ignored. ** objsize - size of the type field, ignored ** object - the ADI_FI_DESC address ** luserbuf - length of the output buffer ** ** Outputs: ** userbuf - written with nice status string ** ** Returns: ** STATUS ** ** History: ** 22-may-1996 (shero03) ** Created from LK_lkb_rsb_get. */ static STATUS ADFmo_adg_fi_type_get( i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf ) { ADI_FI_DESC *fi = (ADI_FI_DESC *)object; char format_buf [30]; MEfill(sizeof(format_buf), (u_char)0, format_buf); TRformat(NULL, 0, format_buf, sizeof(format_buf), "%w", type_string, fi->adi_fitype); return (MOstrout( MO_VALUE_TRUNCATED, format_buf, luserbuf, userbuf )); }
STATUS CS_thread_id_get(i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf) { char buf[ 20 ]; char *str = buf; CS_SCB *scb = (CS_SCB *)object; /* ** If CS_THREAD_ID is a structure, this will need to be ** modified to fit! */ (void) MOlongout( 0, *(i8*)&scb->cs_thread_id, sizeof(buf), buf ); return( MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf )); }
STATUS CS_scb_thread_type_get(i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf) { CS_SCB *scb = (CS_SCB *)object; char buf[ 80 ]; char *str = buf; if( scb->cs_thread_type == CS_INTRNL_THREAD ) str = "internal"; else if( scb->cs_thread_type == CS_USER_THREAD ) str = "user"; else (void) MOlongout( 0, scb->cs_thread_type, sizeof(buf), buf ); return( MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf )); }
STATUS CS_scb_self_get(i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf) { char buf[ 24 ]; char *str = buf; CS_SCB *scb = (CS_SCB *)object; if( scb->cs_self == CS_DONT_CARE ) str = "CS_DONT_CARE"; else if( scb->cs_self == CS_ADDER_ID ) str = "CS_ADDER_ID"; else (void) MOsidout( 0, (PTR)scb->cs_self, sizeof(buf), buf ); return( MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf )); }
/*{ ** Name: CS_state_get - MO get function for cs_state field ** ** Description: ** A nice interpretation of the cs_state fields. ** ** 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 nice state string. ** ** Returns: ** standard get function returns. ** ** History: ** 26-Oct-1992 (daveb) ** documented. */ STATUS CS_scb_state_get(i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf) { CS_SCB *scb = (CS_SCB *)object; char *str; switch (scb->cs_state) { case CS_FREE: str = "CS_FREE"; break; case CS_COMPUTABLE: str = "CS_COMPUTABLE"; break; case CS_STACK_WAIT: str = "CS_STACK_WAIT"; break; case CS_UWAIT: str = "CS_UWAIT"; break; case CS_EVENT_WAIT: str = "CS_EVENT_WAIT"; break; case CS_MUTEX: str = "CS_MUTEX"; break; case CS_CNDWAIT: str = "CS_CNDWAIT"; break; default: str = "<invalid>"; break; } return( MOstrout( MO_VALUE_TRUNCATED, str, luserbuf, userbuf )); }
STATUS MO_getnext(i4 valperms, i4 lclassid, i4 linstance, char *classid, char *instance, i4 *lsbufp, char *sbuf, i4 *operms ) { STATUS stat = OK; STATUS xstat = OK; MO_INSTANCE *ip; MO_CLASS *cp; /* this class */ PTR idata; MO_ngetnext++; # ifdef xDEBUG SIprintf("getnext entry: %s:%s\n", classid, instance ); # endif ip = NULL; cp = NULL; *sbuf = EOS; if( *instance != EOS ) { ip = MO_getinstance( classid, instance ); if( ip != NULL ) cp = ip->classdef; else if( OK != MO_getclass( classid, &cp ) ) stat = MO_NO_CLASSID; } else if( *classid != EOS && OK != MO_getclass( classid, &cp ) ) { stat = MO_NO_CLASSID; } /* ** Now do the real work: Given the starting point implied ** by ip and cp, find the next visible instance. */ if( stat == OK ) { if( cp == NULL ) /* start with first class */ { cp = (MO_CLASS *) SPfhead( MO_classes ); ip = NULL; } /* ** Loop over classes looking for the next valid instance. ** ** On exit, if cp != NULL, it's the class of the found instance; ** if NULL, then we never found a good instance. */ for( ; cp != NULL ; cp = (MO_CLASS *)SPnext( &cp->node, MO_classes ) ) { if( (cp->perms & MO_ANY_READ) != 0 || (valperms & MO_READ & cp->perms) != 0 ) { stat = (*cp->idx)( MO_GETNEXT, cp->cdata, linstance, instance, &idata ); if( stat == OK ) { stat = (*cp->get)( cp->offset, cp->size, idata, *lsbufp, sbuf ); if( stat == OK ) break; } } /* Now caller's ip and instance are bogus; set to search state */ ip = NULL; *instance = EOS; } if( cp == NULL ) stat = MO_NO_NEXT; if( stat == OK || MO_IS_TRUNCATED( stat ) ) xstat = MOstrout( MO_CLASSID_TRUNCATED, cp->node.key, lclassid, classid ); if( stat == OK ) stat = xstat; } *lsbufp = (i4)STlength( sbuf ); if( stat == OK || stat == MO_VALUE_TRUNCATED ) { *operms = cp->perms; (VOID) MO_tell_class( cp, instance, sbuf, MO_GET ); } # ifdef xDEBUG SIprintf("getnext exit: (%d) %s:%s - %s\n", stat, classid, instance, sbuf ); # endif return( stat ); }
/*{ ** 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 ); }