matlab_gs_putenv.c File Reference

#include <stdio.h>
#include <string.h>
#include <matrix.h>
#include <mex.h>
#include "matlab_gs.h"
Include dependency graph for matlab_gs_putenv.c:

Go to the source code of this file.


void matlab_gs_putenv (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

Detailed Description

Matlab client call

Definition in file matlab_gs_putenv.c.

Function Documentation

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 */

/* Error handling */
  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));  

Here is the call graph for this function:

Here is the caller graph for this function: