| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
#include "tbl-incl.h" |
| 40 |
|
| 41 |
static int indentIncrG = 4; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
void TblPrintCType PROTO ((TBLTypeDef *tblTd, TBLType *tblT, FILE *f, unsigned short int indent)); |
| 46 |
|
| 47 |
static char *genericFieldNameG = "field"; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
void |
| 54 |
TblPrintCHdr PARAMS ((tbl, f), |
| 55 |
TBL *tbl _AND_ |
| 56 |
FILE *f) |
| 57 |
{ |
| 58 |
TBLTypeDef *tblTd; |
| 59 |
TBLModule *tblMod; |
| 60 |
|
| 61 |
|
| 62 |
fprintf (f,"/*\n"); |
| 63 |
fprintf (f," * type definitions for the values that the snacc table\n"); |
| 64 |
fprintf (f," * decoder will return and snacc table encoder expects\n"); |
| 65 |
fprintf (f," * for the type table that contains the following modules:\n"); |
| 66 |
fprintf (f," * \n"); |
| 67 |
FOR_EACH_LIST_ELMT (tblMod, tbl->modules) |
| 68 |
{ |
| 69 |
if (!tblMod->isUseful) |
| 70 |
{ |
| 71 |
if (tblMod->name.octs != NULL) |
| 72 |
fprintf (f," * %s\n",tblMod->name.octs); |
| 73 |
else |
| 74 |
{ |
| 75 |
fprintf (f," <no name> id = "); |
| 76 |
PrintAsnOid (f, &tblMod->id, 0); |
| 77 |
fprintf (f,"\n"); |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
fprintf (f," *\n"); |
| 82 |
fprintf (f," * UBC snacc written by Mike Sample\n"); |
| 83 |
fprintf (f," * NOTE: This is a machine generated file \n"); |
| 84 |
fprintf (f," * NOTE2: Table routines don't use this so feel free to make changes\n"); |
| 85 |
fprintf (f," * that do not affect the structure. Changing field \n"); |
| 86 |
fprintf (f," * and type names is fine.\n"); |
| 87 |
fprintf (f," */\n\n\n"); |
| 88 |
|
| 89 |
|
| 90 |
FOR_EACH_LIST_ELMT (tblMod, tbl->modules) |
| 91 |
{ |
| 92 |
if (!tblMod->isUseful) |
| 93 |
{ |
| 94 |
fprintf (f,"/* start of module %s's definitions */\n\n", tblMod->name.octs); |
| 95 |
FOR_EACH_LIST_ELMT (tblTd, tblMod->typeDefs) |
| 96 |
{ |
| 97 |
fprintf (f,"typedef "); |
| 98 |
TblPrintCType (tblTd, tblTd->type, f, 0); |
| 99 |
fprintf (f," %s;\n\n", tblTd->typeName.octs); |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
void |
| 112 |
TblPrintCType PARAMS ((tblTd, tblT, f, indent), |
| 113 |
TBLTypeDef *tblTd _AND_ |
| 114 |
TBLType *tblT _AND_ |
| 115 |
FILE *f _AND_ |
| 116 |
unsigned short int indent) |
| 117 |
{ |
| 118 |
TBLType *structElmtType; |
| 119 |
TBLType *choiceElmtType; |
| 120 |
void *tmp; |
| 121 |
int currElmt; |
| 122 |
int currFieldNo; |
| 123 |
|
| 124 |
|
| 125 |
switch (tblT->typeId) |
| 126 |
{ |
| 127 |
case TBL_TYPEREF: |
| 128 |
fprintf (f, "%s",tblT->content->a.typeRef->typeDefPtr->typeName.octs); |
| 129 |
break; |
| 130 |
|
| 131 |
case TBL_SEQUENCE: |
| 132 |
case TBL_SET: |
| 133 |
fprintf (f,"struct %s\n", tblTd->typeName.octs); |
| 134 |
Indent (f, indent); |
| 135 |
fprintf (f,"{\n"); |
| 136 |
currFieldNo = 0; |
| 137 |
tmp = CURR_LIST_NODE (tblT->content->a.elmts); |
| 138 |
FOR_EACH_LIST_ELMT (structElmtType, tblT->content->a.elmts) |
| 139 |
{ |
| 140 |
Indent (f, indent+indentIncrG); |
| 141 |
TblPrintCType (tblTd, structElmtType, f, indent+indentIncrG); |
| 142 |
if (structElmtType->fieldName.octs != NULL) |
| 143 |
fprintf (f," %s;", structElmtType->fieldName.octs); |
| 144 |
else |
| 145 |
fprintf (f," %s%d;", genericFieldNameG, currFieldNo++); |
| 146 |
|
| 147 |
fprintf (f,"\n"); |
| 148 |
} |
| 149 |
|
| 150 |
SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); |
| 151 |
fprintf (f,"}"); |
| 152 |
break; |
| 153 |
|
| 154 |
case TBL_SEQUENCEOF: |
| 155 |
case TBL_SETOF: |
| 156 |
fprintf (f,"AsnList"); |
| 157 |
break; |
| 158 |
|
| 159 |
case TBL_CHOICE: |
| 160 |
fprintf (f,"struct %s\n", tblTd->typeName.octs); |
| 161 |
Indent (f, indent); |
| 162 |
fprintf (f,"{\n"); |
| 163 |
|
| 164 |
Indent (f, indent+indentIncrG); |
| 165 |
fprintf (f,"enum\n"); |
| 166 |
Indent (f, indent+indentIncrG); |
| 167 |
fprintf (f,"{\n"); |
| 168 |
currElmt = 0; |
| 169 |
currFieldNo = 0; |
| 170 |
tmp = CURR_LIST_NODE (tblT->content->a.elmts); |
| 171 |
FOR_EACH_LIST_ELMT (choiceElmtType, tblT->content->a.elmts) |
| 172 |
{ |
| 173 |
Indent (f, indent+indentIncrG+indentIncrG); |
| 174 |
if (choiceElmtType->fieldName.octs != NULL) |
| 175 |
fprintf (f,"%s", choiceElmtType->fieldName.octs); |
| 176 |
else |
| 177 |
fprintf (f," %s%d", genericFieldNameG, currFieldNo++); |
| 178 |
fprintf (f,"_ID = %d", currElmt++); |
| 179 |
if (choiceElmtType != LAST_LIST_ELMT (tblT->content->a.elmts)) |
| 180 |
fprintf (f,","); |
| 181 |
fprintf (f,"\n"); |
| 182 |
} |
| 183 |
Indent (f, indent); |
| 184 |
fprintf (f," } choiceId;\n"); |
| 185 |
|
| 186 |
|
| 187 |
Indent (f, indent+indentIncrG); |
| 188 |
fprintf (f,"union\n"); |
| 189 |
Indent (f, indent+indentIncrG); |
| 190 |
fprintf (f,"{\n"); |
| 191 |
currFieldNo = 0; |
| 192 |
FOR_EACH_LIST_ELMT (choiceElmtType, tblT->content->a.elmts) |
| 193 |
{ |
| 194 |
Indent (f, indent+indentIncrG+indentIncrG); |
| 195 |
TblPrintCType (tblTd, choiceElmtType, f, indent+indentIncrG+indentIncrG); |
| 196 |
if (choiceElmtType->fieldName.octs != NULL) |
| 197 |
fprintf (f," %s;\n", choiceElmtType->fieldName.octs); |
| 198 |
else |
| 199 |
fprintf (f," %s%d;", genericFieldNameG, currFieldNo++); |
| 200 |
} |
| 201 |
SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp); |
| 202 |
Indent (f, indent+indentIncrG); |
| 203 |
fprintf (f,"} a;\n"); |
| 204 |
Indent (f, indent); |
| 205 |
fprintf (f,"}"); |
| 206 |
break; |
| 207 |
|
| 208 |
case TBL_BOOLEAN: |
| 209 |
fprintf (f,"AsnBool"); |
| 210 |
break; |
| 211 |
|
| 212 |
case TBL_INTEGER: |
| 213 |
case TBL_ENUMERATED: |
| 214 |
fprintf (f,"AsnInt"); |
| 215 |
break; |
| 216 |
|
| 217 |
case TBL_BITSTRING: |
| 218 |
fprintf (f,"AsnBits"); |
| 219 |
break; |
| 220 |
|
| 221 |
case TBL_OCTETSTRING: |
| 222 |
fprintf (f,"AsnOcts"); |
| 223 |
break; |
| 224 |
|
| 225 |
case TBL_NULL: |
| 226 |
fprintf (f,"AsnNull"); |
| 227 |
break; |
| 228 |
|
| 229 |
case TBL_OID: |
| 230 |
fprintf (f,"AsnOid"); |
| 231 |
break; |
| 232 |
|
| 233 |
case TBL_REAL: |
| 234 |
fprintf (f,"AsnReal"); |
| 235 |
break; |
| 236 |
|
| 237 |
default: |
| 238 |
fprintf (f, "<ERROR - unknown type!>"); |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
if (tblT != tblTd->type) |
| 247 |
fprintf (f,"*"); |
| 248 |
|
| 249 |
|
| 250 |
} |