#include "lsl_common.h" /* function [NumAvailable] = lsl_samples_available(LibHandle,Inlet) */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /* handle of the desired field */ mxArray *field; /* temp pointer */ uintptr_t *pTmp; /* function handle */ lsl_samples_available_t func; /* input/output variables */ uintptr_t inlet; unsigned result; if (nrhs != 2) mexErrMsgTxt("2 input argument(s) required."); if (nlhs != 1) mexErrMsgTxt("1 output argument(s) required."); /* get function handle */ field = mxGetField(prhs[0],0,"lsl_samples_available"); if (!field) mexErrMsgTxt("The field does not seem to exist."); pTmp = (uintptr_t*)mxGetData(field); if (!pTmp) mexErrMsgTxt("The field seems to be empty."); func = (lsl_samples_available_t*)*pTmp; /* get additional inputs */ inlet = *(uintptr_t*)mxGetData(prhs[1]); /* invoke & return */ result = func(inlet); plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); *(double*)mxGetData(plhs[0]) = (double)result; }