source: trunk/src/matlab/RpMatlabInterface.cc @ 708

Last change on this file since 708 was 115, checked in by mmc, 19 years ago

Updated all copyright notices.

File size: 1.9 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Interface Helper Functions
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2005  Purdue Research Foundation
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13#include "RpMatlabInterface.h"
14
15int
16getIntInput ( const mxArray* prhs ) {
17
18    int retVal = -1;
19    retVal = (int) getDoubleInput(prhs);
20    return retVal;
21}
22
23double
24getDoubleInput ( const mxArray* prhs ) {
25
26    double retVal = -1;
27
28    /* Input must be a double. */
29    if (mxIsDouble(prhs) != 1) {
30        mexErrMsgTxt("Input must be a double.");
31        return retVal;
32    }
33
34    /* Input must be a scalar. */
35    if ( (mxGetN(prhs)*mxGetM(prhs)) != 1) {
36        mexErrMsgTxt("Input must be a scalar.");
37        return retVal;
38    }
39
40    retVal = *mxGetPr(prhs);
41
42    return retVal;
43}
44
45char*
46getStringInput ( const mxArray* prhs ) {
47
48    int         buflen = 0;
49    int         status = 0;
50    char*       path = NULL;
51
52    /* Input must be a string. */
53    if (mxIsChar(prhs) != 1)
54        mexErrMsgTxt("Input must be a string.");
55
56    /* Input must be a row vector. */
57    if ( (mxGetM(prhs)) != 1)
58        mexErrMsgTxt("Input must be a row vector.");
59
60    /* Get the length of the input string. */
61    buflen = (mxGetM(prhs) * mxGetN(prhs)) + 1;
62
63    /* Allocate memory for input and output strings. */
64    path = (char*) mxCalloc(buflen, sizeof(char));
65
66    /* Copy the string data from prhs[0] into a C string
67     * path. */
68    status = mxGetString(prhs, path, buflen);
69    if (status != 0)
70        mexWarnMsgTxt("Not enough space. String is truncated.");
71
72    return path;
73}
Note: See TracBrowser for help on using the repository browser.