view examples/myprop.c @ 16590:2d968b7830d6

handle A, R, and W fopen modes correctly (bug #38851) * file-io.cc (normalize_fopen_mode): New function. Handle 'A'. Also handle 'b' and 't' suffixes here. Use Octave:fopen-mode warning id. (fopen_mode_to_ios_mode): Only convert from mode string to ios mode. (do_stream_open): Call normalize_fopen_mode before calling fopen_mode_to_ios_mode. Don't process mode string directly. * io.tst: Update test for fopen modes.
author John W. Eaton <jwe@octave.org>
date Mon, 29 Apr 2013 13:46:55 -0400
parents 1b48b209a8d6
children be41c30bcb44
line wrap: on
line source

#include "mex.h"

void
mexFunction (int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
{
  double handle;
  char property[256];

  if (nrhs < 2 || nrhs > 3)
    mexErrMsgTxt ("incorrect number of arguments");
  if (!mxIsDouble (prhs[0]))
    mexErrMsgTxt ("handle expected to be a double scalar");
  if (!mxIsChar (prhs[1]))
    mexErrMsgTxt ("expected property to be a string");
  
  handle = mxGetScalar (prhs[0]);
  mxGetString (prhs[1], property, 256);
  plhs[0] = mxDuplicateArray (mexGet (handle, property));
  
  if (nrhs == 3)
    if (mexSet (handle, property, mxDuplicateArray (prhs[2])))
      mexErrMsgTxt ("failed to set property");
}