Structures for passing information
The introduction of parameters necessitates several additions to the lists that are passed to Mosel via the interface structure.
List of subroutines
In the list of subroutines, the following two lines are new (they must be added at the beginning of the list and in the order shown here):
static XPRMdsofct tabfct[]= { {"", XPRM_FCT_GETPAR, XPRM_TYP_NOT, 0, NULL, task_getpar}, {"", XPRM_FCT_SETPAR, XPRM_TYP_NOT, 0, NULL, task_setpar}, ... }
These two subroutines do not take any names (first parameter). The macros XPRM_FCT_GETPAR and XPRM_FCT_SETPAR identify them as implementations of Mosel's getparam and setparam subroutines for this module.
List of services
We have also got two new services:
static XPRMdsoserv tabserv[]= { {XPRM_SRV_RESET, (void *)task_reset}, {XPRM_SRV_PARAM, (void *)task_findparam}, {XPRM_SRV_PARLST, (void *)task_nextparam} };
Module context
The user is free to store the control parameters in any way that is convenient for him. There is no predefined format for this list since it is not passed as such to Mosel. In our example we have chosen the following structure for storing parameters (their names — always in lower case only, types and access rights, and descriptions):
static struct { char *name; int type; char *desc; } taskparams[]={ {"taskmaxtime", XPRM_TYP_REAL|XPRM_CPAR_READ|XPRM_CPAR_WRITE, "a time limit value"}, {"tasknamelength", XPRM_TYP_INT|XPRM_CPAR_READ|XPRM_CPAR_WRITE, "maximum length of task names"} };
The current values of the parameters are stored in the context of the module since they may be modified (these values must be initialized when the context is created):
typedef struct { s_task *firsttask; int maxname; double maxtime; } s_taskctx;