Vulcan Logic SRM  

SRM - Documentation


^ SRM Documentation
^ API documentation

- SRM Modules
- Function Argument Handling

IV. Function Argument Handling

Function arguments are handled with the macros you can find in this section of the manual.

This example below shows how easy it is to handle parameters passed to functions in SRM modules. This example shows the handling of two mandatory parameters (srm and foo) and one optional parameter (bar).

Example 1. Argument handling


SRM_FUNCTION(srm_foo_bar)
{
    srm_value *srm, *foo, *bar;
      
    SRM_ARGC_CHECK_BETWEEN(2,3);

    SRM_GET_ARG(0, srm, STR);
    SRM_GET_ARG(1, foo, U32);

    if (SRM_ARGC == 3) {
        SRM_GET_ARG(2, bar, STR);
    }
}
    

Table of Contents
SRM_ARGC --  This macro represents the number of arguments passed to this function.
SRM_ARGC_CHECK --  This macro check for a fixed number of arguments passed to the function.
SRM_ARGC_CHECK_BETWEEN --  This macro check for a fixed range of numbers of arguments passed to the function.
SRM_GET_ARG --  This macro fetches a parameter from the parameter list.
Prev: ext_skel script Next: SRM_ARGC


© 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by The Vulcan Logic Group