This is Unofficial EPICS BASE Doxygen Site
epicsDynLink.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2014 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 /*
10  * On 68K targets, all symbols have an underscore prepended to their name.
11  * This code permits both standards to work, as long as you're not looking
12  * for a symbol name that actually begins with an underscore.
13  */
14 
15 #include <string.h>
16 
17 #include "epicsDynLink.h"
18 
19 #if _WRS_VXWORKS_MAJOR < 6 || _WRS_VXWORKS_MINOR < 9
20 
21 static int symNoUnderscore(SYMTAB_ID symTblId)
22 {
23  static int init = 0;
24  static int noUnderscore = 0;
25 
26  if (!init) {
27  char name[] = "symFindByNameEPICS";
28  char *pSymValue;
29  SYM_TYPE type;
30 
31  if (symFindByName(symTblId, name, &pSymValue, &type) == OK)
32  noUnderscore = 1;
33  init = 1;
34  }
35  return noUnderscore;
36 }
37 
38 STATUS symFindByNameEPICS(SYMTAB_ID symTblId, char *name, char **ppvalue,
39  SYM_TYPE *pType)
40 {
41  if (name[0] == '_' && symNoUnderscore(symTblId))
42  name++;
43 
44  return symFindByName(symTblId, name, ppvalue, pType);
45 }
46 
47 STATUS symFindByNameAndTypeEPICS(SYMTAB_ID symTblId, char *name,
48  char **ppvalue, SYM_TYPE *pType, SYM_TYPE sType, SYM_TYPE mask)
49 {
50  if (name[0] == '_' && symNoUnderscore(symTblId))
51  name++;
52 
53  return symFindByNameAndType(symTblId, name, ppvalue, pType, sType, mask);
54 }
55 
56 #else /* VxWorks 6.9 deprecated the symFindBy routines */
57 
58 STATUS symFindByNameEPICS(SYMTAB_ID symTblId, char *name, char **ppvalue,
59  SYM_TYPE *pType)
60 {
61  SYMBOL_DESC symDesc;
62  STATUS status;
63 
64  memset(&symDesc, 0, sizeof(SYMBOL_DESC));
65  symDesc.mask = SYM_FIND_BY_NAME;
66  symDesc.name = name + (name[0] == '_');
67  status = symFind(sysSymTbl, &symDesc);
68  if (!status) {
69  *ppvalue = symDesc.value;
70  *pType = symDesc.type;
71  }
72  return status;
73 }
74 
75 STATUS symFindByNameAndTypeEPICS(SYMTAB_ID symTblId, char *name,
76  char **ppvalue, SYM_TYPE *pType, SYM_TYPE sType, SYM_TYPE mask)
77 {
78  SYMBOL_DESC symDesc;
79  STATUS status;
80 
81  memset(&symDesc, 0, sizeof(SYMBOL_DESC));
82  symDesc.mask = SYM_FIND_BY_NAME | SYM_FIND_BY_TYPE;
83  symDesc.name = name + (name[0] == '_');
84  symDesc.type = sType;
85  symDesc.typeMask = mask;
86  status = symFind(sysSymTbl, &symDesc);
87  if (!status) {
88  *ppvalue = symDesc.value;
89  *pType = symDesc.type;
90  }
91  return status;
92 }
93 
94 #endif
pvd::Status status
pvd::StructureConstPtr type