Beispiel #1
0
    int sent7;
    char        c;
    char        c1[2];
    int         offpre;
    int         offpost;
} myStruct;

static const
chfPluginEnumType colorEnum[] = { {"R", 1}, {"G", 2}, {"B", 4}, {NULL,0} };

static const
chfPluginArgDef sloppyTaggedOpts[] = {
    chfInt32     (myStruct, tval,    "t" , 0, 0),
    chfTagInt32  (myStruct, ival,    "I" , tval, 1, 0, 0),
    chfTagBoolean(myStruct, flag,    "F" , tval, 2, 0, 0),
    chfTagDouble (myStruct, dval,    "D" , tval, 3, 0, 0),
    chfTagString (myStruct, str,     "S" , tval, 4, 0, 0),
    chfTagEnum   (myStruct, enumval, "C" , tval, 5, 0, 0, colorEnum),
    chfPluginArgEnd
};

static const
chfPluginArgDef strictTaggedOpts[] = {
    chfInt32     (myStruct, tval,    "t" , 1, 0),
    chfBoolean   (myStruct, flag,    "f" , 1, 0),
    chfTagInt32  (myStruct, ival,    "I" , tval, 1, 0, 0),
    chfTagBoolean(myStruct, flag,    "F" , tval, 2, 0, 0),
    chfTagDouble (myStruct, dval,    "D" , tval, 3, 1, 0),
    chfTagDouble (myStruct, dval,    "D2", tval, 4, 1, 0),
    chfTagEnum   (myStruct, enumval, "C" , tval, 5, 0, 0, colorEnum),
    chfPluginArgEnd
Beispiel #2
0
    int    mode;
    double cval;
    double hyst;
    double last;
} myStruct;

static void *myStructFreeList;

static const
chfPluginEnumType modeEnum[] = { {"abs", 0}, {"rel", 1}, {NULL,0} };

static const
chfPluginArgDef opts[] = {
    chfDouble    (myStruct, cval, "d", 0, 1),
    chfEnum      (myStruct, mode, "m", 0, 1, modeEnum),
    chfTagDouble (myStruct, cval, "abs", mode, 0, 0, 1),
    chfTagDouble (myStruct, cval, "rel", mode, 1, 0, 1),
    chfPluginArgEnd
};

static void * allocPvt(void)
{
    return freeListCalloc(myStructFreeList);
}

static void freePvt(void *pvt)
{
    freeListFree(myStructFreeList, pvt);
}

static int parse_ok(void *pvt)