/* $Id: lcaGetNelem.c,v 1.7 2007/05/31 21:16:45 till Exp $ */ /* matlab wrapper for ezcaGetNelem */ /* Author: Till Straumann , 2002-2003 */ /* LICENSE: EPICS open license, see ../LICENSE file */ #include "mglue.h" #include "multiEzca.h" #include #include #include void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { PVs pvs = { {0} }; LcaError theErr; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( 1 < nlhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Need one output arg"); goto cleanup; } if ( 1 != nrhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected one rhs argument"); goto cleanup; } if ( buildPVs(prhs[0],&pvs, &theErr) ) goto cleanup; if ( ! (plhs[0] = mxCreateNumericMatrix( pvs.m, 1, mxINT32_CLASS, mxREAL )) ) { lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } if ( multi_ezca_get_nelem( pvs.names, pvs.m, mxGetData(plhs[0]), &theErr) ) { goto cleanup; } nlhs = 0; cleanup: releasePVs(&pvs); /* do this LAST (in case mexErrMsgTxt is called) */ ERR_CHECK(nlhs, plhs, &theErr); }