Esempio n. 1
0
    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
};
Esempio n. 2
0
typedef struct myStruct {
    syncMode mode;
    char state[STATE_NAME_LENGTH];
    dbStateId id;
    db_field_log *lastfl;
    int laststate:1;
} myStruct;

static void *myStructFreeList;

static const
chfPluginArgDef opts[] = {
    chfEnum      (myStruct, mode,  "m", 1, 1, modeEnum),
    chfString    (myStruct, state, "s", 1, 0),
    chfTagString (myStruct, state, "before", mode, 0, 1, 0),
    chfTagString (myStruct, state, "first",  mode, 1, 1, 0),
    chfTagString (myStruct, state, "last",   mode, 2, 1, 0),
    chfTagString (myStruct, state, "after",  mode, 3, 1, 0),
    chfTagString (myStruct, state, "while",  mode, 4, 1, 0),
    chfTagString (myStruct, state, "unless", mode, 5, 1, 0),
    chfPluginArgEnd
};

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

static void freePvt(void *pvt)