static int prec_and_type_match(Data_Obj *dp1,Data_Obj *dp2,const char *func_name) { if( OBJ_PREC(dp1) != OBJ_PREC(dp2) ){ sprintf(DEFAULT_ERROR_STRING,"Function %s: precisions of objects %s (%s) and %s (%s) do not match!?", func_name,OBJ_NAME(dp1),OBJ_PREC_NAME(dp1),OBJ_NAME(dp2),OBJ_PREC_NAME(dp2)); NWARN(DEFAULT_ERROR_STRING); return(0); } return(1); }
static COMMAND_FUNC( do_xyplot ) { Data_Obj *dp; dp=PICK_OBJ("data vector"); if( dp==NO_OBJ ) return; INSIST_RAM_OBJ(dp,"xyplot") if( bad_plot_vec2(QSP_ARG dp,2,"xyplot") ) return; switch( OBJ_MACH_PREC(dp) ) { case PREC_SP: float_xyplot(dp); break; case PREC_DP: double_xyplot(dp); break; default: sprintf(ERROR_STRING,"do_xyplot: unhandled precision %s (object %s)", OBJ_PREC_NAME(dp),OBJ_NAME(dp)); WARN(ERROR_STRING); break; } }
static COMMAND_FUNC( do_tellprec ) { Data_Obj *dp; const char *s; dp = get_obj( QSP_ARG NAMEOF("data object") ); s = NAMEOF("variable name"); if( dp == NULL ) return; assign_var(s,OBJ_PREC_NAME(dp)); }
static COMMAND_FUNC( do_read_str ) { Data_Obj *dp; const char *s; dp=PICK_OBJ(""); s=NAMEOF("string"); if( dp == NO_OBJ ) return; INSIST_RAM_OBJ(dp,"read_string") #ifdef QUIP_DEBUG //if( debug ) dptrace(dp); #endif /* QUIP_DEBUG */ if( ! IS_STRING(dp) ){ sprintf(ERROR_STRING,"do_read_str: object %s (%s) does not have string precision", OBJ_NAME(dp),OBJ_PREC_NAME(dp)); WARN(ERROR_STRING); return; } if( (strlen(s)+1) > OBJ_COMPS(dp) ){ sprintf(ERROR_STRING, "Type dimension (%d) of string object %s is too small for string of length %d", OBJ_COMPS(dp),OBJ_NAME(dp),(int)strlen(s)); WARN(ERROR_STRING); return; } if( ! IS_CONTIGUOUS(dp) ){ sprintf(ERROR_STRING,"Sorry, object %s must be contiguous for string reading", OBJ_NAME(dp)); WARN(ERROR_STRING); return; } strcpy((char *)OBJ_DATA_PTR(dp),s); }
int good_polh_vector(QSP_ARG_DECL Data_Obj *dp) { int n_expected_words; /* The polhemus can output floats, but we'll assume it's all short here... */ if( dp == NULL ) return(0); if( OBJ_PREC(dp) != PREC_IN && OBJ_PREC(dp) != PREC_UIN ) { sprintf(ERROR_STRING, "Object %s has %s precision, should be %s or %s for polhemus data", OBJ_NAME(dp), OBJ_PREC_NAME(dp), NAME_FOR_PREC_CODE(PREC_IN), NAME_FOR_PREC_CODE(PREC_UIN) ); warn(ERROR_STRING); return(0); } if( n_active_stations == 2 ) n_expected_words = station_info[0].sd_multi_prf.rf_n_words + station_info[1].sd_multi_prf.rf_n_words; else n_expected_words = station_info[curr_station_idx].sd_multi_prf.rf_n_words ; if( OBJ_COMPS(dp) != n_expected_words ) { sprintf(ERROR_STRING, "Object %s has bad type dimensions (%d), should be %d", OBJ_NAME(dp), OBJ_COMPS(dp), n_expected_words); warn(ERROR_STRING); return(0); } if( !IS_CONTIGUOUS(dp) ) { sprintf(ERROR_STRING, "good_polh_vector: Object %s must be contiguous", OBJ_NAME(dp)); warn(ERROR_STRING); return(0); } return(1); }
static COMMAND_FUNC( do_wrt_str ) { Data_Obj *dp; const char *s; dp=PICK_OBJ(""); s=NAMEOF("variable"); if( dp == NO_OBJ ) return; dp = insure_ram_obj(QSP_ARG dp); if( dp == NO_OBJ ) return; if( ! IS_STRING(dp) ){ sprintf(ERROR_STRING,"do_read_str: object %s (%s) does not have string precision", OBJ_NAME(dp),OBJ_PREC_NAME(dp)); WARN(ERROR_STRING); return; } ASSIGN_VAR(s,(char *)OBJ_DATA_PTR(dp)); DELETE_IF_COPY(dp) }
const char *_get_dobj_prec_name(QSP_ARG_DECL Data_Obj *dp) { assert( dp != NULL ); return OBJ_PREC_NAME(dp); }