00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mex.h"
00019
00020 void
00021 mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
00022 {
00023 double lock;
00024
00025 (void) plhs;
00026
00027
00028 if (nrhs != 1 || !mxIsDouble(prhs[0]) ||
00029 mxGetN(prhs[0])*mxGetM(prhs[0]) != 1 || mxIsComplex(prhs[0])) {
00030 mexErrMsgTxt("Input argument must be a real scalar double");
00031 }
00032 if(nlhs > 0){
00033 mexErrMsgTxt("No output arguments expected.");
00034 }
00035 lock = mxGetScalar(prhs[0]);
00036 if((lock != 0.0) && lock != 1.0 && lock != -1.0) {
00037 mexErrMsgTxt("Input argument must be either 1 to lock or -1 to\
00038 unlock or 0 for lock status.\n");
00039 }
00040 if(mexIsLocked()) {
00041 if(lock > 0.0) {
00042 mexErrMsgTxt("MEX-file is already locked\n");
00043 }
00044 else if(lock < 0.0) {
00045 mexUnlock();
00046 mexPrintf("MEX-file is unlocked\n");
00047 }
00048 else {
00049 mexPrintf("MEX-file is locked\n");
00050 }
00051 } else {
00052 if(lock < 0.0) {
00053 mexErrMsgTxt("MEX-file is already unlocked\n");
00054 }
00055 else if(lock > 0.0) {
00056 mexLock();
00057 mexPrintf("MEX-file is locked\n");
00058 }
00059 else {
00060 mexPrintf("MEX-file is unlocked\n");
00061 }
00062 }
00063 }