#include <stdio.h>#include <string.h>#include <matrix.h>#include <mex.h>#include "matlab_gs.h"
Go to the source code of this file.
Functions | |
| void | matlab_gs_putenv (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) |
Matlab client call
Definition in file matlab_gs_putenv.c.
| void matlab_gs_putenv | ( | int | nlhs, | |
| mxArray * | plhs[], | |||
| int | nrhs, | |||
| const mxArray * | prhs[] | |||
| ) |
Put a variable=value pair into the environment (gs_putenv("VAR=value")).
| nlhs | - Number of left hand side arguments from Matlab | |
| plhs | - Pointer to left hand side arguments from Matlab | |
| rlhs | - Number of right hand side arguments from Matlab | |
| plhs | - Pointer to right hand side arguments from Matlab |
Definition at line 27 of file matlab_gs_putenv.c.
{
char *env_equal_val;
int i, len, retval;
/* Check arguments */
if (nrhs != 2) {
mexPrintf("Usage: gs_putenv('VAR=value') \n");
goto error;
}
/* Get string */
if (!mxIsChar(prhs[1])) goto error;
len = (mxGetM(prhs[1]) * mxGetN(prhs[1]) * sizeof(mxChar)) + 1;
if ((env_equal_val = matlab_gs_calloc(len, 1)) == NULL) goto error;
if (mxGetString(prhs[1],env_equal_val,len) != 0) goto error;
retval = putenv(env_equal_val);
if (nlhs > 1) {
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
mxGetPr(plhs[0])[0] = (double)retval;
}
/* Finalize */
return;
/* Error handling */
error:
for (i=0;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL);
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));
return;
}


1.6.3-20100507