My Project
linkoptions.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * mrfioc2 is distributed subject to a Software License Agreement found
5 * in file LICENSE that is included with this distribution.
6 \*************************************************************************/
7 /*
8  * Author: Michael Davidsaver <mdavidsaver@gmail.com>
9  */
10 
11 #ifndef LINKOPTIONS_H
12 #define LINKOPTIONS_H
13 
14 #include <shareLib.h>
15 #include <dbDefs.h>
16 #include <epicsTypes.h>
17 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76 typedef enum linkOption {
77  linkOptionInvalid=0,
78  linkOptionInt32,
79  linkOptionDouble,
80  linkOptionString,
81  linkOptionEnum
82 } linkOption;
83 
84 typedef struct linkOptionEnumType {
85  const char *name;
86  const int value;
87 } linkOptionEnumType;
88 
89 typedef struct linkOptionDef {
90  const char * name;
91  linkOption optType;
92  int required:1;
93  int overwrite:1;
94  epicsUInt32 offset;
95  epicsUInt32 size;
96  const linkOptionEnumType *Enums;
97 } linkOptionDef;
98 
99 #define linkInt32(Struct, Member, Name, Req, Over) \
100 {Name, linkOptionInt32, Req, Over, OFFSET(Struct, Member), sizeof( ((Struct*)0)->Member ), NULL}
101 
102 #define linkDouble(Struct, Member, Name, Req, Over) \
103 {Name, linkOptionDouble, Req, Over, OFFSET(Struct, Member), sizeof( ((Struct*)0)->Member ), NULL}
104 
105 #define linkString(Struct, Member, Name, Req, Over) \
106 {Name, linkOptionString, Req, Over, OFFSET(Struct, Member), sizeof( ((Struct*)0)->Member ), NULL}
107 
108 #define linkEnum(Struct, Member, Name, Req, Over, Enums) \
109 {Name, linkOptionEnum, Req, Over, OFFSET(Struct, Member), sizeof( ((Struct*)0)->Member ), Enums}
110 
111 #define linkOptionEnd {0,linkOptionInvalid,0,0,0,0,NULL}
112 
113 /* Extra output when parsing and converting */
114 #define LINKOPTIONDEBUG 1
115 
129 epicsShareFunc
130 int
131 epicsShareAPI
132 linkOptionsStore(const linkOptionDef* opts, void* user, const char* str, int options);
133 
141 epicsShareFunc
142 const char*
143 epicsShareAPI
144 linkOptionsEnumString(const linkOptionEnumType *Enums, int i, const char* def);
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* LINKOPTIONS_H */
epicsShareFunc const char *epicsShareAPI linkOptionsEnumString(const linkOptionEnumType *Enums, int i, const char *def)
Return the string associated with Enum 'i'.
Definition: linkoptions.c:226
epicsShareFunc int epicsShareAPI linkOptionsStore(const linkOptionDef *opts, void *user, const char *str, int options)
Parse a string a store the result.
Definition: linkoptions.c:135