matlab_gs_cancel.c

Go to the documentation of this file.
00001 
00007 /* $Id: matlab_gs_cancel.c,v 1.7 2007/07/24 19:24:32 yarkhan Exp $ */
00008 /* $UTK_Copyright: $ */
00009 
00010 #include <stdio.h>
00011 #include <string.h>
00012 
00013 #include <matrix.h>
00014 #include <mex.h>
00015 
00016 #ifdef HAVE_CONFIG_H
00017 #include "config.h"
00018 #endif /* HAVE_CONFIG_H */
00019 
00020 #include "grpc.h"
00021 #include "matlab_gs.h"
00022 
00023 
00033 void 
00034 matlab_gs_cancel(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
00035 {
00036   int i;
00037   grpc_sessionid_t sessionID;
00038   int retval;
00039 
00040   /* reset global error setting */
00041   matlab_gs_error_num = 0;  
00042 
00043   /* Check arguments */
00044   if (nrhs != 2 || nlhs != 1) {
00045     mexErrMsgTxt("Usage: status = gs_cancel(sessionId)\n");
00046     DO_ERROR_MACRO(GRPC_OTHER_ERROR_CODE);
00047   }
00048 
00049   /* Get sessionid from rhs */
00050   sessionID = (int)mxGetPr(prhs[1])[0];
00051   if (sessionID < 0) {
00052     matlab_gs_error_num = GRPC_OTHER_ERROR_CODE;
00053     DO_ERROR_MACRO(GRPC_OTHER_ERROR_CODE);
00054   }
00055 
00056   /* Call cancel */
00057   retval = grpc_cancel(sessionID);
00058   if (retval != GRPC_NO_ERROR) DO_ERROR_MACRO(grpc_errno);
00059 
00060   /* If OK, output result, else error */
00061   plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
00062   mxGetPr(plhs[0])[0] = (double)retval;
00063 
00064   return; 
00065 
00066 
00067 
00068  error:
00069   /* Create blank output for left hand side */ 
00070   plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
00071   mxGetPr(plhs[0])[0] = (double)-1;
00072   for (i=1;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL);
00073 
00074   mexPrintf("Warning: GridSolve call failed: %d:%d: %s; %s\n", grpc_errno, grpc_minor_errno, grpc_error_string(grpc_errno), grpc_minor_error_string(grpc_minor_errno));  
00075 
00076   return;
00077 
00078 }