--- Begin Message ---
Package: snacc
Version: 1.3bbn-2.0.cats.4
Severity: normal
Tags: patch
I thought it was time to post our local changes.
I don't claim everything is necessarily the best solution.
The most important thing was probably teaching snacc about the CSTA
macros (well, actually they're the ROSE macros). There were also various
small bugfixes I don't exactly remember much about - sorry. And I know
I've gone back and forth about how to handle ANY DEFINED BY. At least
the current way seems to work, though it may be over-complicated from
the history.
diff -ausrN y/snacc-1.3bbn/c-examples/any/example.c
snacc-1.3bbn/c-examples/any/example.c
--- y/snacc-1.3bbn/c-examples/any/example.c Wed Jul 23 15:33:44 2003
+++ snacc-1.3bbn/c-examples/any/example.c Wed May 21 15:45:18 2003
@@ -81,7 +81,7 @@
}
size = sbuf.st_size;
- origData = (char*)malloc (size);
+ origData = (char*)calloc(1, size);
if (read (fd, origData, size) != size)
{
perror ("main: read");
@@ -135,7 +135,7 @@
* value (may be larger than decoded value if encoding
* with indef lengths - so add 512 slush bytes)
*/
- encData = (char*) malloc (size + 512);
+ encData = (char*) calloc(1, size + 512);
SBufInit (&encBuf, encData, size + 512);
SBufResetInWriteRvsMode (&encBuf);
diff -ausrN y/snacc-1.3bbn/c-examples/simple/expbuf-ex.c
snacc-1.3bbn/c-examples/simple/expbuf-ex.c
--- y/snacc-1.3bbn/c-examples/simple/expbuf-ex.c Wed Jul 23 15:33:44 2003
+++ snacc-1.3bbn/c-examples/simple/expbuf-ex.c Wed May 21 15:45:18 2003
@@ -79,7 +79,7 @@
}
size = sbuf.st_size;
- origData = (char*)malloc (size);
+ origData = (char*)calloc(1, size);
if (read (fd, origData, size) != size)
{
perror ("main: read");
diff -ausrN y/snacc-1.3bbn/c-examples/simple/minbuf-ex.c
snacc-1.3bbn/c-examples/simple/minbuf-ex.c
--- y/snacc-1.3bbn/c-examples/simple/minbuf-ex.c Wed Jul 23 15:33:44 2003
+++ snacc-1.3bbn/c-examples/simple/minbuf-ex.c Wed May 21 15:45:18 2003
@@ -80,7 +80,7 @@
}
size = sbuf.st_size;
- origData = (char*)malloc (size);
+ origData = (char*)calloc(1, size);
if (read (fd, origData, size) != size)
{
perror ("main: read");
@@ -127,7 +127,7 @@
* with indef lengths - so add 512 slush bytes)
*/
encBufSize = size + 512;
- encData = (char*) malloc (encBufSize);
+ encData = (char*) calloc(1, encBufSize);
/*
* set 'buffer' up for writing by setting ptr
diff -ausrN y/snacc-1.3bbn/c-examples/simple/sbuf-ex.c
snacc-1.3bbn/c-examples/simple/sbuf-ex.c
--- y/snacc-1.3bbn/c-examples/simple/sbuf-ex.c Wed Jul 23 15:33:44 2003
+++ snacc-1.3bbn/c-examples/simple/sbuf-ex.c Wed May 21 15:45:18 2003
@@ -77,7 +77,7 @@
}
size = sbuf.st_size;
- origData = (char*)malloc (size);
+ origData = (char*)calloc(1, size);
if (read (fd, origData, size) != size)
{
perror ("main: read");
@@ -127,7 +127,7 @@
* value (may be larger than decoded value if encoding
* with indef lengths - so add 512 slush bytes)
*/
- encData = (char*) malloc (size + 512);
+ encData = (char*) calloc(1, size + 512);
SBufInit (&encBuf, encData, size + 512);
SBufResetInWriteRvsMode (&encBuf);
diff -ausrN y/snacc-1.3bbn/c-lib/inc/asn-any.h snacc-1.3bbn/c-lib/inc/asn-any.h
--- y/snacc-1.3bbn/c-lib/inc/asn-any.h Sat Jan 27 02:02:58 2001
+++ snacc-1.3bbn/c-lib/inc/asn-any.h Wed May 21 15:45:18 2003
@@ -78,16 +78,16 @@
* used before encoding or decoding a type so the proper
* encode or decode routine is used.
*/
-void SetAnyTypeByInt PROTO ((AsnAny *v, AsnInt id));
-void SetAnyTypeByOid PROTO ((AsnAny *v, AsnOid *id));
+void SetAnyTypeByInt PROTO ((AsnAny *v, AsnInt id, char *kind));
+void SetAnyTypeByOid PROTO ((AsnAny *v, AsnOid *id, char *kind));
/*
* used to initialize the hash table (s)
*/
-void InstallAnyByInt PROTO ((int anyId, AsnInt intId, unsigned int size,
EncodeFcn encode, DecodeFcn decode, FreeFcn free, PrintFcn print));
+void InstallAnyByInt PROTO ((int anyId, AsnInt intId, char *kind, unsigned int
size, EncodeFcn encode, DecodeFcn decode, FreeFcn free, PrintFcn print));
-void InstallAnyByOid PROTO ((int anyId, AsnOid *oid, unsigned int size,
EncodeFcn encode, DecodeFcn decode, FreeFcn free, PrintFcn print));
+void InstallAnyByOid PROTO ((int anyId, AsnOid *oid, char *kind, unsigned int
size, EncodeFcn encode, DecodeFcn decode, FreeFcn free, PrintFcn print));
/*
diff -ausrN y/snacc-1.3bbn/c-lib/inc/exp-buf.h snacc-1.3bbn/c-lib/inc/exp-buf.h
--- y/snacc-1.3bbn/c-lib/inc/exp-buf.h Sat Jan 27 02:02:59 2001
+++ snacc-1.3bbn/c-lib/inc/exp-buf.h Wed May 21 15:45:18 2003
@@ -86,9 +86,9 @@
extern unsigned long expBufDataBlkSizeG;
#define ExpBufInit( size) expBufDataBlkSizeG = size;
-#define ExpBufAllocBuf() ((ExpBuf *)malloc (sizeof (ExpBuf)))
+#define ExpBufAllocBuf() ((ExpBuf *)calloc(1, sizeof (ExpBuf)))
#define ExpBufFreeBuf( ptr) free (ptr)
-#define ExpBufAllocData() ((void *)malloc (expBufDataBlkSizeG))
+#define ExpBufAllocData() ((void *)calloc(1, expBufDataBlkSizeG))
#define ExpBufFreeData( ptr) free (ptr)
#define ExpBufFreeBufAndData( b) { ExpBufFreeData ((b)->blkStart);
ExpBufFreeBuf (b); }
#define ExpBufNext( b) ((b)->next)
diff -ausrN y/snacc-1.3bbn/c-lib/inc/str-stk.h snacc-1.3bbn/c-lib/inc/str-stk.h
--- y/snacc-1.3bbn/c-lib/inc/str-stk.h Sat Jan 27 02:02:59 2001
+++ snacc-1.3bbn/c-lib/inc/str-stk.h Wed May 21 15:45:18 2003
@@ -71,7 +71,7 @@
strStkG.nextFreeElmt = 0;\
strStkG.totalByteLen = 0;\
if (strStkG.stk == NULL){\
- strStkG.stk = (StrStkElmt*) malloc ((strStkG.initialNumElmts) *sizeof
(StrStkElmt));\
+ strStkG.stk = (StrStkElmt*) calloc(1, (strStkG.initialNumElmts) *sizeof
(StrStkElmt));\
strStkG.numElmts = strStkG.initialNumElmts;}\
}
diff -ausrN y/snacc-1.3bbn/c-lib/src/asn-any.c snacc-1.3bbn/c-lib/src/asn-any.c
--- y/snacc-1.3bbn/c-lib/src/asn-any.c Sat Jan 27 02:02:56 2001
+++ snacc-1.3bbn/c-lib/src/asn-any.c Wed May 21 15:45:18 2003
@@ -43,21 +43,42 @@
Table *anyIntHashTblG = NULL;
/*
+ * each is a two-level table, indexed by typekind
+ */
+
+static Table *TableByKind(Table **Master, char *kind)
+{
+ Hash hash;
+ Table *tbl;
+
+ if (*Master == NULL)
+ *Master = InitHash();
+
+ hash = MakeHash(kind, strlen(kind));
+ if (!CheckForAndReturnValue (*Master, hash, &tbl)) {
+ tbl = InitHash();
+ Insert (*Master, tbl, hash);
+ }
+ return tbl;
+}
+
+/*
* given an ANY type value and a integer hash key, this defines
* this any values type (gets ptr to hash tbl entry from int key).
* The hash table entry contains ptrs to the encode/decode etc. routines.
*/
void
-SetAnyTypeByInt PARAMS ((v, id),
+SetAnyTypeByInt PARAMS ((v, id, kind),
AsnAny *v _AND_
- AsnInt id)
+ AsnInt id _AND_
+ char *kind)
{
Hash hash;
void *anyInfo;
/* use int as hash string */
hash = MakeHash ((char*)&id, sizeof (id));
- if (CheckForAndReturnValue (anyIntHashTblG, hash, &anyInfo))
+ if (CheckForAndReturnValue (TableByKind(&anyIntHashTblG, kind), hash,
&anyInfo))
v->ai = (AnyInfo*) anyInfo;
else
v->ai = NULL; /* indicates failure */
@@ -68,16 +89,23 @@
/*
* Same as SetAnyTypeByInt except that the hash key is an OBJECT IDENTIFER.
*/
-void SetAnyTypeByOid PARAMS ((v, id),
+void SetAnyTypeByOid PARAMS ((v, id, kind),
AsnAny *v _AND_
- AsnOid *id)
+ AsnOid *id _AND_
+ char *kind)
{
Hash hash;
void *anyInfo;
+ kind = "-oid-";
+ { FILE *l = fopen("csta-any.log", "a");
+ fprintf(l, "SetAnyTypeByOid id=");
+ PrintAsnOid(l, id, 0);
+ fprintf(l, " kind=%s\n", kind);
+ fclose(l); }
/* use encoded oid as hash string */
hash = MakeHash (id->octs, id->octetLen);
- if (CheckForAndReturnValue (anyOidHashTblG, hash, &anyInfo))
+ if (CheckForAndReturnValue (TableByKind(&anyOidHashTblG, kind), hash,
&anyInfo))
v->ai = (AnyInfo*) anyInfo;
else
v->ai = NULL; /* indicates failure */
@@ -99,9 +127,10 @@
* Future calls to SetAnyTypeByInt/Oid will reference this table.
*/
void
-InstallAnyByInt PARAMS ((anyId, intId, size, Encode, Decode, Free, Print),
+InstallAnyByInt PARAMS ((anyId, intId, kind, size, Encode, Decode, Free,
Print),
int anyId _AND_
AsnInt intId _AND_
+ char *kind _AND_
unsigned int size _AND_
EncodeFcn Encode _AND_
DecodeFcn Decode _AND_
@@ -111,7 +140,7 @@
AnyInfo *a;
Hash h;
- a = (AnyInfo*) malloc (sizeof (AnyInfo));
+ a = (AnyInfo*) calloc(1, sizeof (AnyInfo));
a->anyId = anyId;
a->oid.octs = NULL;
a->oid.octetLen = 0;
@@ -122,11 +151,8 @@
a->Free = Free;
a->Print = Print;
- if (anyIntHashTblG == NULL)
- anyIntHashTblG = InitHash();
-
h = MakeHash ((char*)&intId, sizeof (intId));
- Insert (anyIntHashTblG, a, h);
+ Insert (TableByKind(&anyIntHashTblG, kind), a, h);
} /* InstallAnyByOid */
@@ -135,9 +161,10 @@
* Same as InstallAnyByInt except the oid is used as the hash key
*/
void
-InstallAnyByOid PARAMS ((anyId, oid, size, Encode, Decode, Free, Print),
+InstallAnyByOid PARAMS ((anyId, oid, kind, size, Encode, Decode, Free, Print),
int anyId _AND_
AsnOid *oid _AND_
+ char *kind _AND_
unsigned int size _AND_
EncodeFcn Encode _AND_
DecodeFcn Decode _AND_
@@ -147,7 +174,13 @@
AnyInfo *a;
Hash h;
- a = (AnyInfo*) malloc (sizeof (AnyInfo));
+ kind = "-oid-";
+ { FILE *l = fopen("csta-any.log", "a");
+ fprintf(l, "InstallAnyByOid id=");
+ PrintAsnOid(l, oid, 0);
+ fprintf(l, " kind=%s anyId=%d\n", kind, anyId);
+ fclose(l); }
+ a = (AnyInfo*) calloc(1, sizeof (AnyInfo));
a->anyId = anyId;
a->oid.octs = oid->octs;
a->oid.octetLen = oid->octetLen;
@@ -159,10 +192,7 @@
h = MakeHash (oid->octs, oid->octetLen);
- if (anyOidHashTblG == NULL)
- anyOidHashTblG = InitHash();
-
- Insert (anyOidHashTblG, a, h);
+ Insert (TableByKind(&anyOidHashTblG, kind), a, h);
} /* InstallAnyByOid */
diff -ausrN y/snacc-1.3bbn/c-lib/src/asn-oid.c snacc-1.3bbn/c-lib/src/asn-oid.c
--- y/snacc-1.3bbn/c-lib/src/asn-oid.c Sat Jan 27 02:02:57 2001
+++ snacc-1.3bbn/c-lib/src/asn-oid.c Wed May 21 15:45:18 2003
@@ -298,9 +298,9 @@
secondArcNum = arcNum - (firstArcNum * 40);
- headOid = (OID*)malloc (sizeof (OID));
+ headOid = (OID*)calloc(1, sizeof (OID));
headOid->arcNum = firstArcNum;
- headOid->next = (OID*)malloc (sizeof (OID));
+ headOid->next = (OID*)calloc(1, sizeof (OID));
headOid->next->arcNum = secondArcNum;
nextOid = &headOid->next->next;
@@ -311,7 +311,7 @@
arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f);
i++;
- *nextOid = (OID*)malloc (sizeof (OID));
+ *nextOid = (OID*)calloc(1, sizeof (OID));
(*nextOid)->arcNum = arcNum;
nextOid = &(*nextOid)->next;
}
diff -ausrN y/snacc-1.3bbn/c-lib/src/exp-buf.c snacc-1.3bbn/c-lib/src/exp-buf.c
--- y/snacc-1.3bbn/c-lib/src/exp-buf.c Sat Jan 27 02:02:57 2001
+++ snacc-1.3bbn/c-lib/src/exp-buf.c Wed May 21 15:45:18 2003
@@ -163,7 +163,7 @@
ExpBuf*
ExpBufAllocBuf()
{
- return (ExpBuf*)malloc (sizeof (ExpBuf));
+ return (ExpBuf*)calloc(1, sizeof (ExpBuf));
}
void
@@ -176,7 +176,7 @@
char*
ExpBufAllocData()
{
- return (char*)malloc (expBufDataBlkSizeG);
+ return (char*)calloc(1, expBufDataBlkSizeG);
}
void
diff -ausrN y/snacc-1.3bbn/c-lib/src/hash.c snacc-1.3bbn/c-lib/src/hash.c
--- y/snacc-1.3bbn/c-lib/src/hash.c Sat Jan 27 02:02:57 2001
+++ snacc-1.3bbn/c-lib/src/hash.c Wed May 21 15:45:18 2003
@@ -107,7 +107,7 @@
{
HashSlot *foo;
- foo = (HashSlot *) malloc (sizeof (HashSlot));
+ foo = (HashSlot *) calloc(1, sizeof (HashSlot));
if (foo == NULL)
return NULL;
memzero (foo, sizeof (HashSlot));
@@ -120,7 +120,7 @@
{
Table *new_table;
- new_table = (Table *) malloc (sizeof (Table));
+ new_table = (Table *) calloc(1, sizeof (Table));
if (new_table == NULL)
return NULL;
memzero (new_table, sizeof (Table));
diff -ausrN y/snacc-1.3bbn/c-lib/src/nibble-alloc.c
snacc-1.3bbn/c-lib/src/nibble-alloc.c
--- y/snacc-1.3bbn/c-lib/src/nibble-alloc.c Sat Jan 27 02:02:57 2001
+++ snacc-1.3bbn/c-lib/src/nibble-alloc.c Wed May 21 15:45:18 2003
@@ -55,11 +55,11 @@
{
NibbleMem *nm;
- nm = (NibbleMem*) malloc (sizeof (NibbleMem));
+ nm = (NibbleMem*) calloc(1, sizeof (NibbleMem));
nm->incrementSize = incrementSize;
- nm->currNibbleBuf = nm->firstNibbleBuf = (NibbleBuf*)malloc (sizeof
(NibbleBuf));
- nm->firstNibbleBuf->curr = nm->firstNibbleBuf->start = (char*) malloc
(initialSize);
+ nm->currNibbleBuf = nm->firstNibbleBuf = (NibbleBuf*)calloc(1, sizeof
(NibbleBuf));
+ nm->firstNibbleBuf->curr = nm->firstNibbleBuf->start = (char*) calloc(1,
initialSize);
nm->firstNibbleBuf->end = nm->firstNibbleBuf->start + initialSize;
nm->firstNibbleBuf->next = NULL;
memzero (nm->currNibbleBuf->start, initialSize);
@@ -86,9 +86,9 @@
else
newBufSize = nm->incrementSize;
- nm->currNibbleBuf->next = (NibbleBuf*) malloc (sizeof (NibbleBuf));
+ nm->currNibbleBuf->next = (NibbleBuf*) calloc(1, sizeof (NibbleBuf));
nm->currNibbleBuf = nm->currNibbleBuf->next;
- nm->currNibbleBuf->curr = nm->currNibbleBuf->start = (char*) malloc
(newBufSize);
+ nm->currNibbleBuf->curr = nm->currNibbleBuf->start = (char*) calloc(1,
newBufSize);
nm->currNibbleBuf->end = nm->currNibbleBuf->start + newBufSize;
nm->currNibbleBuf->next = NULL;
memzero (nm->currNibbleBuf->start, newBufSize);
diff -ausrN y/snacc-1.3bbn/c-lib/src/tbl-util.c
snacc-1.3bbn/c-lib/src/tbl-util.c
--- y/snacc-1.3bbn/c-lib/src/tbl-util.c Sat Jan 27 02:02:58 2001
+++ snacc-1.3bbn/c-lib/src/tbl-util.c Wed May 21 15:45:18 2003
@@ -59,7 +59,7 @@
fseek (f, 0, 0); /* seek to beginning */
*size = fsize;
- fileData = (char *) malloc (fsize);
+ fileData = (char *) calloc(1, fsize);
if (fileData == NULL)
{
diff -ausrN y/snacc-1.3bbn/compiler/back-ends/c-gen/gen-any.c
snacc-1.3bbn/compiler/back-ends/c-gen/gen-any.c
--- y/snacc-1.3bbn/compiler/back-ends/c-gen/gen-any.c Sat Jan 27 02:02:53 2001
+++ snacc-1.3bbn/compiler/back-ends/c-gen/gen-any.c Wed May 21 15:45:18 2003
@@ -35,6 +35,7 @@
*/
#include <stdio.h>
+#include <assert.h>
#include "asn-incl.h"
#include "mem.h"
@@ -212,6 +213,17 @@
{
FOR_EACH_LIST_ELMT (ar, arl)
{
+ char kind[20];
+ char *p;
+
+ p = ar->anyIdName;
+ p = strstr(p, "_ANY_ID");
+ assert(p);
+ do { p--; } while (*p != '_');
+ p++;
+ strcpy(kind, p);
+ p = strchr(kind, '_');
+ *p = 0;
encRoutineName = r->typeConvTbl[j].encodeRoutineName;
decRoutineName = r->typeConvTbl[j].decodeRoutineName;
@@ -236,9 +248,9 @@
}
if (ar->id->choiceId == OIDORINT_OID)
- fprintf (src," InstallAnyByOid (%s, &oid%d, sizeof
(%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, i++, r->typeConvTbl[j].cTypeName, encRoutineName,
decRoutineName, freeRoutineName, printRoutineName);
+ fprintf (src," InstallAnyByOid (%s, &oid%d, \"%s\",
sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, i++, kind, r->typeConvTbl[j].cTypeName, encRoutineName,
decRoutineName, freeRoutineName, printRoutineName);
else
- fprintf (src," InstallAnyByInt (%s, %d, sizeof (%s),
(EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, ar->id->a.intId, r->typeConvTbl[j].cTypeName, encRoutineName,
decRoutineName, freeRoutineName, printRoutineName);
+ fprintf (src," InstallAnyByInt (%s, %d, \"%s\", sizeof
(%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, ar->id->a.intId, kind, r->typeConvTbl[j].cTypeName,
encRoutineName, decRoutineName, freeRoutineName, printRoutineName);
}
}
}
@@ -250,6 +262,18 @@
ctdi = td->cTypeDefInfo;
FOR_EACH_LIST_ELMT (ar, td->anyRefs)
{
+ char kind[20];
+ char *p;
+
+ p = ar->anyIdName;
+ p = strstr(p, "_ANY_ID");
+ assert(p);
+ do { p--; } while (*p != '_');
+ p++;
+ strcpy(kind, p);
+ p = strchr(kind, '_');
+ *p = 0;
+
typeId = GetBuiltinType (td->type);
encRoutineName = ctdi->encodeRoutineName;
@@ -275,9 +299,9 @@
}
if (ar->id->choiceId == OIDORINT_OID)
- fprintf (src," InstallAnyByOid (%s, &oid%d, sizeof
(%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, i++, ctdi->cTypeName, encRoutineName, decRoutineName,
freeRoutineName, printRoutineName);
+ fprintf (src," InstallAnyByOid (%s, &oid%d, \"%s\",
sizeof (%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, i++, kind, ctdi->cTypeName, encRoutineName, decRoutineName,
freeRoutineName, printRoutineName);
else
- fprintf (src," InstallAnyByInt (%s, %d, sizeof (%s),
(EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, ar->id->a.intId, ctdi->cTypeName, encRoutineName,
decRoutineName, freeRoutineName, printRoutineName);
+ fprintf (src," InstallAnyByInt (%s, %d, \"%s\", sizeof
(%s), (EncodeFcn) B%s, (DecodeFcn)B%s, (FreeFcn)%s, (PrintFcn)%s);\n\n",
ar->anyIdName, ar->id->a.intId, kind, ctdi->cTypeName, encRoutineName,
decRoutineName, freeRoutineName, printRoutineName);
}
}
}
@@ -289,14 +313,14 @@
fprintf (src," * (usually done via MACROs) you must manually do
the code\n");
fprintf (src," * to fill the hash tbl.\n");
fprintf (src," * if the ids are INTEGER use the following:\n");
- fprintf (src," * InstallAnyByInt (??_ANY_ID, intVal, sizeof (Foo),
(EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo,
(PrintFcn)PrintFoo);\n");
+ fprintf (src," * InstallAnyByInt (??_ANY_ID, intVal, kind, sizeof
(Foo), (EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo,
(PrintFcn)PrintFoo);\n");
fprintf (src," * if the ids are OBJECT IDENTIFIERs use the
following:\n");
- fprintf (src," * InstallAnyByOid (??_ANY_ID, oidVal, sizeof
(Foo), (EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo,
(PrintFcn)PrintFoo);\n");
+ fprintf (src," * InstallAnyByOid (??_ANY_ID, oidVal, kind,
sizeof (Foo), (EncodeFcn) BEncFoo, (DecodeFcn)BDecFoo, (FreeFcn)FreeFoo,
(PrintFcn)PrintFoo);\n");
fprintf (src," * put the ??_ANY_IDs in the AnyId enum.\n\n");
fprintf (src," * For example if you have some thing like\n");
fprintf (src," * T1 ::= SEQUENCE { id INTEGER, ANY DEFINED BY id
}\n");
fprintf (src," * and the id 1 maps to the type BOOLEAN use the
following:\n");
- fprintf (src," * InstallAnyByInt (SOMEBOOL_ANY_ID, 1, sizeof
(AsnBool), (EncodeFcn) BEncAsnBool, (DecodeFcn)BDecAsnBool, (FreeFcn)NULL,
(PrintFcn)PrintAsnBool);;\n");
+ fprintf (src," * InstallAnyByInt (SOMEBOOL_ANY_ID, 1, \"T1\",
sizeof (AsnBool), (EncodeFcn) BEncAsnBool, (DecodeFcn)BDecAsnBool,
(FreeFcn)NULL, (PrintFcn)PrintAsnBool);;\n");
fprintf (src," */\n ???????\n"); /* generate compile error */
}
diff -ausrN y/snacc-1.3bbn/compiler/back-ends/c-gen/gen-dec.c
snacc-1.3bbn/compiler/back-ends/c-gen/gen-dec.c
--- y/snacc-1.3bbn/compiler/back-ends/c-gen/gen-dec.c Sat Jan 27 02:02:53 2001
+++ snacc-1.3bbn/compiler/back-ends/c-gen/gen-dec.c Wed May 21 15:45:18 2003
@@ -575,7 +575,22 @@
char idVarRef[MAX_VAR_REF];
NamedType *idNamedType;
enum BasicTypeChoiceId tmpTypeId;
+ char kind[20];
+ char *p, *q;
+ /* determine kind */
+ p = elmtVarName;
+ q = kind;
+ while (*p) {
+ if (isalnum(*p)) {
+ *q++ = toupper(*p);
+ *q = 0;
+ }
+ else
+ q = kind;
+ p++;
+ }
+
ctri = t->cTypeRefInfo;
/* check if meant to be encoded */
@@ -587,7 +602,7 @@
if (tmpType->basicType->choiceId == BASICTYPE_ANY)
{
fprintf (src,"/* ANY - Fix Me ! */\n");
- fprintf (src," SetAnyTypeBy???(%s, ???);\n", elmtVarName);
+ fprintf (src," SetAnyTypeBy???(%s, ???, \"%s\");\n", elmtVarName,
kind);
fprintf (src," B%s (b, %s, &%s%d, env);\n",
ctri->decodeRoutineName, elmtVarName, decodedLenVarNameG, totalLevel);
}
else if (tmpType->basicType->choiceId == BASICTYPE_ANYDEFINEDBY)
@@ -599,13 +614,13 @@
if (tmpTypeId == BASICTYPE_OID)
{
MakeVarPtrRef (genDecCRulesG, td, parent, idNamedType->type,
parentVarName, idVarRef);
- fprintf (src, " SetAnyTypeByOid (%s, %s);\n", elmtVarName,
idVarRef);
+ fprintf (src, " SetAnyTypeByOid (%s, %s, \"%s\");\n",
elmtVarName, idVarRef, kind);
}
else
{
/* want to ref int by value not ptr */
MakeVarValueRef (genDecCRulesG, td, parent, idNamedType->type,
parentVarName, idVarRef);
- fprintf (src, " SetAnyTypeByInt (%s, %s);\n", elmtVarName,
idVarRef);
+ fprintf (src, " SetAnyTypeByInt (%s, %s, \"%s\");\n",
elmtVarName, idVarRef, kind);
}
fprintf (src," B%s (b, %s, &%s%d, env);\n",
ctri->decodeRoutineName, elmtVarName, decodedLenVarNameG, totalLevel);
}
diff -ausrN y/snacc-1.3bbn/compiler/back-ends/c-gen/gen-enc.c
snacc-1.3bbn/compiler/back-ends/c-gen/gen-enc.c
--- y/snacc-1.3bbn/compiler/back-ends/c-gen/gen-enc.c Sat Jan 27 02:02:53 2001
+++ snacc-1.3bbn/compiler/back-ends/c-gen/gen-enc.c Wed May 21 15:45:18 2003
@@ -393,6 +393,8 @@
enum BasicTypeChoiceId tmpTypeId;
Type *tmpType;
NamedType *idNamedType;
+ char kind[20];
+ char *p, *q;
if ((e->type == NULL) || (e->type->cTypeRefInfo == NULL))
return;
@@ -406,6 +408,19 @@
MakeVarPtrRef (genEncCRulesG, td, parent, e->type, varName, elmtVarRef);
+ /* determine kind */
+ p = elmtVarRef;
+ q = kind;
+ while (*p) {
+ if (isalnum(*p)) {
+ *q++ = toupper(*p);
+ *q = 0;
+ }
+ else
+ q = kind;
+ p++;
+ }
+
if (e->type->optional || (e->type->defaultVal != NULL))
fprintf (src, " if (%s (%s))\n {\n", ctri->optTestRoutineName,
elmtVarRef);
@@ -422,13 +437,13 @@
if (tmpTypeId == BASICTYPE_OID)
{
MakeVarPtrRef (genEncCRulesG, td, parent, idNamedType->type,
varName, idVarRef);
- fprintf (src, " SetAnyTypeByOid (%s, %s);\n", elmtVarRef,
idVarRef);
+ fprintf (src, " SetAnyTypeByOid (%s, %s, \"%s\");\n",
elmtVarRef, idVarRef, kind);
}
else
{
/* want to ref int by value not ptr */
MakeVarValueRef (genEncCRulesG, td, parent, idNamedType->type,
varName, idVarRef);
- fprintf (src, " SetAnyTypeByInt (%s, %s);\n", elmtVarRef,
idVarRef);
+ fprintf (src, " SetAnyTypeByInt (%s, %s, \"%s\");\n",
elmtVarRef, idVarRef, kind);
}
/* ANY's enc's do tag and len so zap the Content suffix */
@@ -449,7 +464,7 @@
case C_ANY:
/* ANY's enc's do tag and len so zap the Content suffix */
fprintf (src," /* ANY - Fix Me! */\n");
- fprintf (src, " SetAnyTypeBy???(%s, ???);\n", elmtVarRef);
+ fprintf (src, " SetAnyTypeBy???(%s, ???, \"%s\");\n",
elmtVarRef, kind);
fprintf (src, " %s = B%s (b, %s);\n", itemLenNameG,
ctri->encodeRoutineName, elmtVarRef);
break;
@@ -527,7 +542,21 @@
Type *tmpType;
enum BasicTypeChoiceId tmpTypeId;
TypeDef *idNamedType;
+ char kind[20];
+ char *p, *q;
+ /* determine kind */
+ p = elmtVarRef;
+ q = kind;
+ while (*p) {
+ if (isalnum(*p)) {
+ *q++ = toupper(*p);
+ *q = 0;
+ }
+ else
+ q = kind;
+ p++;
+ }
ctri = t->basicType->a.setOf->cTypeRefInfo;
@@ -560,7 +589,7 @@
case C_ANY:
/* ANY's enc's do tag and len so zap the Content suffix */
fprintf (src," /* ANY - Fix Me! */\n");
- fprintf (src, " SetAnyTypeBy???(%s, ???);\n", elmtVarRef);
+ fprintf (src, " SetAnyTypeBy???(%s, ???, \"%s\");\n",
elmtVarRef, kind);
fprintf (src, " %s = B%s (b, %s);\n", itemLenNameG,
ctri->encodeRoutineName, elmtVarRef);
break;
diff -ausrN y/snacc-1.3bbn/compiler/core/asn1module.h
snacc-1.3bbn/compiler/core/asn1module.h
--- y/snacc-1.3bbn/compiler/core/asn1module.h Sat Jan 27 02:02:47 2001
+++ snacc-1.3bbn/compiler/core/asn1module.h Wed May 21 15:45:18 2003
@@ -469,7 +469,8 @@
MACROTYPE_AFPROTECTED,
MACROTYPE_AFSIGNATURE,
MACROTYPE_AFSIGNED,
- MACROTYPE_SNMPOBJECTTYPE
+ MACROTYPE_SNMPOBJECTTYPE,
+ MACROTYPE_CSTAEVENT
} choiceId;
union MacroTypeChoiceUnion
{
@@ -498,6 +499,7 @@
struct Type *afSignature; /* [22] IMPLICIT Type */
struct Type *afSigned; /* [23] IMPLICIT Type */
struct SnmpObjectTypeMacroType *snmpObjectType; /* [24] IMPLICIT
SnmpObjectTypeMacroType */
+ struct CstaEventMacroType *cstaEvent; /* [25] IMPLICIT CstaEventMacroType
*/
} a;
} MacroType;
@@ -567,6 +569,14 @@
struct Value *value; /* [1] IMPLICIT Value */
} a;
} TypeOrValue;
+
+
+
+
+typedef struct CstaEventMacroType /* SEQUENCE */
+{
+ struct Type *type; /* Type */
+} CstaEventMacroType;
diff -ausrN y/snacc-1.3bbn/compiler/core/do-macros.c
snacc-1.3bbn/compiler/core/do-macros.c
--- y/snacc-1.3bbn/compiler/core/do-macros.c Sat Jan 27 02:02:48 2001
+++ snacc-1.3bbn/compiler/core/do-macros.c Wed Jul 23 15:25:10 2003
@@ -69,6 +69,8 @@
void DefineType PROTO ((Module *m, TypeDef *td, Type *t, char *name));
+void ProcessCstaEventMacroType PROTO ((Module *m, TypeDef *td, Type *t,
BasicType *bt, CstaEventMacroType *event, ValueDef *v));
+
void ProcessRosOperationMacroType PROTO ((Module *m, TypeDef *td, Type *t,
BasicType *bt, RosOperationMacroType *op, ValueDef *v));
void ProcessRosErrorMacroType PROTO ((Module *m, TypeDef *td, Type *t,
BasicType *bt, RosErrorMacroType *err, ValueDef *v));
@@ -302,6 +304,10 @@
case BASICTYPE_MACROTYPE:
switch (bt->a.macroType->choiceId)
{
+ case MACROTYPE_CSTAEVENT:
+ ProcessCstaEventMacroType (m, td, type, bt,
bt->a.macroType->a.cstaEvent,v);
+ break;
+
case MACROTYPE_ASNABSTRACTOPERATION:
case MACROTYPE_ROSOPERATION:
@@ -447,6 +453,66 @@
void
+DefineTypeWithAny PARAMS ((m, td, t, v, k),
+ Module *m _AND_
+ TypeDef *td _AND_
+ Type *t _AND_
+ ValueDef *v _AND_
+ char *k)
+{
+ char anyId[256];
+ AnyRefList **arlHndl;
+
+ if (t != NULL)
+ DefineType (m, td, t, v->definedName);
+
+
+ /*
+ * add ANY ref stuff to type ref'd by this macro so it is
+ * included in the ANY hash table.
+ */
+
+ m->hasAnys = TRUE;
+
+ strcpy (anyId, v->definedName);
+ strcat (anyId, k);
+/* Str2UCase (anyId, strlen (anyId)); */
+ Dash2Underscore (anyId, strlen (anyId));
+ strcat (anyId, "_ANY_ID");
+
+ arlHndl = GetAnyRefListHndl (t);
+
+
+ if (v->value->basicValue->choiceId == BASICVALUE_OID)
+ AddAnyRefByOid (arlHndl, anyId, v->value->basicValue->a.oid);
+ else
+ AddAnyRefByInt (arlHndl, anyId, v->value->basicValue->a.integer);
+
+
+
+ /* make a choice with all the object type elmts */
+} /* DefineTypeWithAny */
+
+void
+ProcessCstaEventMacroType PARAMS ((m, td, t, bt, event, v),
+ Module *m _AND_
+ TypeDef *td _AND_
+ Type *t _AND_
+ BasicType *bt _AND_
+ CstaEventMacroType *event _AND_
+ ValueDef *v)
+{
+ char anyId[256];
+ AnyRefList **arlHndl;
+
+ if ((event != NULL) && (event->type != NULL))
+ DefineTypeWithAny (m, td, event->type, v, "_EVENTINFO");
+
+} /* ProcessCstaEventMacroType */
+
+
+
+void
ProcessRosOperationMacroType PARAMS ((m, td, t, bt, op, v),
Module *m _AND_
TypeDef *td _AND_
@@ -457,10 +523,10 @@
{
if (op->arguments != NULL)
- DefineType (m, td, op->arguments->type, v->definedName);
+ DefineTypeWithAny (m, td, op->arguments->type, v, "_ARGUMENT");
if (op->result != NULL)
- DefineType (m, td, op->result->type, v->definedName);
+ DefineTypeWithAny (m, td, op->result->type, v, "_RESULT");
} /* ProcessRosOperationMacroType */
@@ -476,7 +542,7 @@
ValueDef *v)
{
if ((err != NULL) && (err->parameter != NULL))
- DefineType (m, td, err->parameter->type, v->definedName);
+ DefineTypeWithAny (m, td, err->parameter->type, v, "_PARAMETER");
} /* ProcessRosErrorMacroType */
@@ -662,65 +728,7 @@
AnyRefList **arlHndl;
if ((ot != NULL) && (ot->syntax != NULL))
- DefineType (m, td, ot->syntax, v->definedName);
-
- /*
- * add ANY ref stuff to type ref'd by this macro so it is
- * included in the ANY hash table.
- */
-
- /*
- * do this since the SNMP spec doesn't have an ANY type
- * but uses the mechanism. (SNMP uses an OCTET STRING
- * where the 'ANY' value is
- */
- m->hasAnys = TRUE;
+ DefineTypeWithAny (m, td, ot->syntax, v, "_SYNTAX");
- strcpy (anyId, v->definedName);
-/* Str2UCase (anyId, strlen (anyId)); */
- strcat (anyId, "_ANY_ID");
-
- arlHndl = GetAnyRefListHndl (ot->syntax);
-
-
- if (v->value->basicValue->choiceId == BASICVALUE_OID)
- AddAnyRefByOid (arlHndl, anyId, v->value->basicValue->a.oid);
-
- /* integer types are not allowed, but relax constraints anyway */
- else
- AddAnyRefByInt (arlHndl, anyId, v->value->basicValue->a.integer);
-
-
-
- /* make a choice with all the object type elmts */
- /* USING THE ANY HASH TABLE NOW
- if (snmpObjectSyntaxesG == NULL)
- {
- snmpObjectSyntaxesG = (TypeDef*) Malloc (sizeof (TypeDef));
- SetupType (&snmpObjectSyntaxesG->type, BASICTYPE_CHOICE, 0);
- snmpObjectSyntaxesG->type->basicType->a.choice =
- AsnListNew (sizeof (void*));
- snmpObjectSyntaxesG->definedName = "SnmpOpaqueTypes";
-
- }
- */
-
- /* NOT DONE ANYMORE
- * make each field in the choice the same as the object
- * types SYNTAX field type (adjusted by Define type)
- * make choice field name same as OBJ-TYPE value Defs name
- *
- * NOTE - using ptrs to type/fieldname, not duplicating them
- * this may cause freeing probs
- */
- /*
- nt = MT (NamedType);
- nt->fieldName = v->definedName;
- nt->type = ot->syntax;
-
- tmpNtHndl = (NamedType**)
- AsnListAppend (snmpObjectSyntaxesG->type->basicType->a.choice);
- *tmpNtHndl = nt;
- */
} /* ProcessSnmpObjectTypeMacro */
diff -ausrN y/snacc-1.3bbn/compiler/core/err-chk.c
snacc-1.3bbn/compiler/core/err-chk.c
--- y/snacc-1.3bbn/compiler/core/err-chk.c Sat Jan 27 02:02:48 2001
+++ snacc-1.3bbn/compiler/core/err-chk.c Wed May 21 15:45:18 2003
@@ -470,6 +470,7 @@
refdType = GetType
(type->basicType->a.anyDefinedBy->link->type);
if ((refdType->basicType->choiceId != BASICTYPE_INTEGER) &&
(refdType->basicType->choiceId != BASICTYPE_ENUMERATED) &&
+ (refdType->basicType->choiceId != BASICTYPE_CHOICE) &&
(refdType->basicType->choiceId != BASICTYPE_OID))
{
PrintErrLoc (m->asn1SrcFileName, type->lineNo);
diff -ausrN y/snacc-1.3bbn/compiler/core/lex-asn1.l
snacc-1.3bbn/compiler/core/lex-asn1.l
--- y/snacc-1.3bbn/compiler/core/lex-asn1.l Sat Jan 27 02:02:47 2001
+++ snacc-1.3bbn/compiler/core/lex-asn1.l Wed May 21 15:45:18 2003
@@ -239,6 +239,9 @@
<INITIAL>UNBIND return UNBIND_SYM;
<INITIAL>UNBIND-ERROR return UNBINDERROR_SYM;
+<INITIAL>EVENT return EVENT_SYM;
+<INITIAL>EVENTINFO return EVENTINFO_SYM;
+
<INITIAL>APPLICATION-CONTEXT return AC_SYM;
<INITIAL>APPLICATION-SERVICE-ELEMENTS return ASES_SYM;
<INITIAL>REMOTE return REMOTE_SYM;
diff -ausrN y/snacc-1.3bbn/compiler/core/link-types.c
snacc-1.3bbn/compiler/core/link-types.c
--- y/snacc-1.3bbn/compiler/core/link-types.c Sat Jan 27 02:02:49 2001
+++ snacc-1.3bbn/compiler/core/link-types.c Wed May 21 15:45:18 2003
@@ -68,6 +68,8 @@
void TypeLinkValue PROTO ((ModuleList *m, Module *currMod, ValueDef *head,
Type *valuesType, Value *v));
+void TypeLinkCstaEventMacroType PROTO ((ModuleList *m, Module *currMod,
TypeDef *head, Type *t, BasicType *bt, CstaEventMacroType *event));
+
void TypeLinkRosOperationMacroType PROTO ((ModuleList *m, Module *currMod,
TypeDef *head, Type *t, BasicType *bt, RosOperationMacroType *op));
@@ -648,6 +650,10 @@
case BASICTYPE_MACROTYPE:
switch (bt->a.macroType->choiceId)
{
+ case MACROTYPE_CSTAEVENT:
+ TypeLinkCstaEventMacroType (m, currMod, head, type, bt,
bt->a.macroType->a.cstaEvent);
+ break;
+
case MACROTYPE_ROSOPERATION:
case MACROTYPE_ASNABSTRACTOPERATION:
TypeLinkRosOperationMacroType (m, currMod, head, type, bt,
bt->a.macroType->a.rosOperation);
@@ -896,6 +902,25 @@
v->valueType = valuesType->basicType->choiceId;
} /* TypeLinkValue */
+
+
+/*
+ * link any type refs in this macro's parsed data struct
+ */
+void
+TypeLinkCstaEventMacroType PARAMS ((m, currMod, head, t, bt, event),
+ ModuleList *m _AND_
+ Module *currMod _AND_
+ TypeDef *head _AND_
+ Type *t _AND_
+ BasicType *bt _AND_
+ CstaEventMacroType *event)
+{
+ if (event != NULL)
+ {
+ TypeLinkType (m, currMod, head, event->type);
+ }
+} /* TypeLinkCstaEventMacroType */
/*
diff -ausrN y/snacc-1.3bbn/compiler/core/link-values.c
snacc-1.3bbn/compiler/core/link-values.c
--- y/snacc-1.3bbn/compiler/core/link-values.c Sat Jan 27 02:02:49 2001
+++ snacc-1.3bbn/compiler/core/link-values.c Wed May 21 15:45:18 2003
@@ -72,6 +72,8 @@
void ValueLinkOid PROTO ((ModuleList *m, Module *currMod, ValueDef *head,
Value *v, OID *oid));
+void ValueLinkCstaEventMacroType PROTO ((ModuleList *m, Module *currMod,
TypeDef *head, Type *t, BasicType *bt, CstaEventMacroType *event));
+
void ValueLinkRosOperationMacroType PROTO ((ModuleList *m, Module *currMod,
TypeDef *head, Type *t, BasicType *bt, RosOperationMacroType *op));
void ValueLinkRosErrorMacroType PROTO ((ModuleList *m, Module *currMod,
TypeDef *head, Type *t, BasicType *bt, RosErrorMacroType *err));
@@ -423,6 +425,11 @@
case BASICTYPE_MACROTYPE:
switch (bt->a.macroType->choiceId)
{
+ case MACROTYPE_CSTAEVENT:
+
+ ValueLinkCstaEventMacroType (m, currMod, head, type, bt,
bt->a.macroType->a.cstaEvent);
+ break;
+
case MACROTYPE_ROSOPERATION:
case MACROTYPE_ASNABSTRACTOPERATION:
@@ -921,6 +928,22 @@
linkOidCallDepthG--;
} /* ValueLinkOid */
+
+
+void
+ValueLinkCstaEventMacroType PARAMS ((m, currMod, head, t, bt, event),
+ ModuleList *m _AND_
+ Module *currMod _AND_
+ TypeDef *head _AND_
+ Type *t _AND_
+ BasicType *bt _AND_
+ CstaEventMacroType *event)
+{
+ if (event != NULL)
+ {
+ ValueLinkType (m, currMod, head, event->type);
+ }
+} /* ValueLinkCstaEventMacroType */
void
diff -ausrN y/snacc-1.3bbn/compiler/core/mem.c snacc-1.3bbn/compiler/core/mem.c
--- y/snacc-1.3bbn/compiler/core/mem.c Sat Jan 27 02:02:49 2001
+++ snacc-1.3bbn/compiler/core/mem.c Wed May 21 15:45:18 2003
@@ -54,7 +54,7 @@
void*
Malloc PARAMS ((size), int size)
{
- void *retVal = malloc (size);
+ void *retVal = calloc(1, size);
if (retVal == NULL)
{
diff -ausrN y/snacc-1.3bbn/compiler/core/normalize.c
snacc-1.3bbn/compiler/core/normalize.c
--- y/snacc-1.3bbn/compiler/core/normalize.c Sat Jan 27 02:02:49 2001
+++ snacc-1.3bbn/compiler/core/normalize.c Wed May 21 15:45:18 2003
@@ -492,7 +492,7 @@
case BASICTYPE_ANY:
case BASICTYPE_ANYDEFINEDBY:
- m->hasAnys = TRUE;
+ /*m->hasAnys = TRUE; what for?!*/
/* NO LONGER DONE
* change ANY defs embedded in other types
* into type refs
diff -ausrN y/snacc-1.3bbn/compiler/core/parse-asn1.y
snacc-1.3bbn/compiler/core/parse-asn1.y
--- y/snacc-1.3bbn/compiler/core/parse-asn1.y Sat Jan 27 02:02:47 2001
+++ snacc-1.3bbn/compiler/core/parse-asn1.y Wed May 21 15:45:18 2003
@@ -62,6 +62,9 @@
%{
+#define YYDEBUG 1
+#define YYERROR_VERBOSE 1
+
#include "snacc.h"
#if STDC_HEADERS || HAVE_STRING_H
@@ -302,6 +305,7 @@
OBJECTTYPE_SYM SYNTAX_SYM ACCESS_SYM STATUS_SYM
DESCRIPTION_SYM REFERENCE_SYM INDEX_SYM
DEFVAL_SYM
+ EVENT_SYM EVENTINFO_SYM
/*
* Type definitions of non-terminal symbols
@@ -393,6 +397,10 @@
%type <typeOrValuePtr> TypeOrValue
+%type <typePtr> CstaEventMacroType
+
+%type <typePtr> CstaEventinfo
+
%type <typePtr> RosOperationMacroType RosOperationMacroBody RosErrorMacroType
RosBindMacroType RosUnbindMacroType
RosAseMacroType RosAcMacroType
@@ -2030,6 +2038,7 @@
| AfSignatureMacroType
| AfSignedMacroType
| SnmpObjectTypeMacroType
+ | CstaEventMacroType
;
DefinedMacroName:
@@ -2058,6 +2067,7 @@
| SIGNATURE_SYM { $$ = "SIGNATURE"; }
| PROTECTED_SYM { $$ = "PROTECTED"; }
| OBJECTTYPE_SYM { $$ = "OBJECT-TYPE"; }
+ | EVENT_SYM { $$ = "EVENT"; }
;
@@ -2120,6 +2130,29 @@
| empty { $$ = NULL; }
;
+
+
+
+/*
+ * CSTA EVENT macro - kh 2001-10-22
+ */
+CstaEventMacroType:
+ EVENT_SYM CstaEventinfo
+ {
+ CstaEventMacroType *c;
+ /*
+ * defines event macro type
+ */
+ SetupMacroType (&$$, MACROTYPE_CSTAEVENT, myLineNoG);
+ c = $$->basicType->a.macroType->a.cstaEvent = MT (CstaEventMacroType);
+ c->type = $2;
+ }
+;
+
+CstaEventinfo:
+ EVENTINFO_SYM Type { $$ = $2; }
+ | empty { $$ = NULL; }
+;
Files y/snacc-1.3bbn/compiler/core/parser.h and
snacc-1.3bbn/compiler/core/parser.h are identical
diff -ausrN y/snacc-1.3bbn/compiler/core/print.c
snacc-1.3bbn/compiler/core/print.c
--- y/snacc-1.3bbn/compiler/core/print.c Sat Jan 27 02:02:50 2001
+++ snacc-1.3bbn/compiler/core/print.c Wed May 21 15:45:18 2003
@@ -542,6 +542,10 @@
case BASICTYPE_MACROTYPE:
switch (bt->a.macroType->choiceId)
{
+ case MACROTYPE_CSTAEVENT:
+ PrintCstaEventMacroType (f, head, t, bt,
bt->a.macroType->a.cstaEvent);
+ break;
+
case MACROTYPE_ROSOPERATION:
case MACROTYPE_ASNABSTRACTOPERATION:
PrintRosOperationMacroType (f, head, t, bt,
bt->a.macroType->a.rosOperation);
@@ -1287,6 +1291,34 @@
void
+PrintCstaEventMacroType PARAMS ((f, head, t, bt, event),
+ FILE *f _AND_
+ TypeDef *head _AND_
+ Type *t _AND_
+ BasicType *bt _AND_
+ CstaEventMacroType *event)
+{
+ fprintf (f,"EVENT");
+
+ indentG += indentStepG;
+
+ if (event->type != NULL)
+ {
+ fprintf (f, "\n");
+ INDENT (f, indentG);
+ fprintf (f,"EVENTINFO ");
+ indentG += indentStepG;
+ INDENT (f, indentG);
+ PrintType (f, head, event->type);
+ indentG -= indentStepG;
+ }
+
+ indentG -= indentStepG;
+
+} /* PrintCstaEventMacroType */
+
+
+void
PrintRosOperationMacroType PARAMS ((f, head, t, bt, op),
FILE *f _AND_
TypeDef *head _AND_
@@ -1335,7 +1367,7 @@
indentG -= indentStepG;
}
- if ((op->errors == NULL) || (!LIST_EMPTY (op->errors)))
+ if ((op->errors != NULL) && (!LIST_EMPTY (op->errors)))
{
fprintf (f,"\n");
INDENT (f, indentG);
diff -ausrN y/snacc-1.3bbn/compiler/core/print.h
snacc-1.3bbn/compiler/core/print.h
--- y/snacc-1.3bbn/compiler/core/print.h Sat Jan 27 02:02:48 2001
+++ snacc-1.3bbn/compiler/core/print.h Wed May 21 15:45:18 2003
@@ -78,6 +78,8 @@
void PrintTypeById PROTO ((FILE *f, int typeId));
+void PrintCstaEventMacroType PROTO ((FILE *f, TypeDef *head, Type *t,
BasicType *bt, CstaEventMacroType *op));
+
void PrintRosOperationMacroType PROTO ((FILE *f, TypeDef *head, Type *t,
BasicType *bt, RosOperationMacroType *op));
void PrintRosErrorMacroType PROTO ((FILE *f, TypeDef *head, Type *t, BasicType
*bt, RosErrorMacroType *err));
diff -ausrN y/snacc-1.3bbn/compiler/core/snacc.c
snacc-1.3bbn/compiler/core/snacc.c
--- y/snacc-1.3bbn/compiler/core/snacc.c Sat Jan 27 02:02:51 2001
+++ snacc-1.3bbn/compiler/core/snacc.c Wed May 21 15:45:18 2003
@@ -170,7 +170,7 @@
FILE *fp)
{
fprintf (fp, "\nUsage: %s ", prgName);
- fprintf (fp, "[-h] [-P] [-t] [-v] [-e] [-d] [-p] [-f]\n");
+ fprintf (fp, "[-h] [-P] [-D] [-t] [-v] [-e] [-d] [-p] [-f]\n");
#if IDL
fprintf (fp, " [-c | -C | -[T|O] <table output file> | -idl
]\n");
#else
@@ -200,6 +200,7 @@
fprintf (fp, " snacc/asn1specs/ directory).\n");
fprintf (fp, " -P print the parsed ASN.1 modules to stdout from their
parse trees\n");
fprintf (fp, " (helpful debugging)\n");
+ fprintf (fp, " -D print parsing debugging information to stderr\n");
fprintf (fp, " -t generate type definitions\n");
fprintf (fp, " -v generate value definitions (limited)\n");
fprintf (fp, " -e generate encode routines\n");
@@ -332,10 +333,12 @@
long longJmpVal = -100;
int novolatilefuncs = FALSE;
+#if 0
#ifdef YYDEBUG
/* prints yacc debugging info to stdout */
yydebug = 1;
#endif
+#endif
if (argc <= 1)
@@ -367,6 +370,12 @@
currArg++;
break;
+ case 'D':
+ /* prints yacc debugging info to stdout */
+ yydebug = 1;
+ currArg++;
+ break;
+
case 'v':
genValueCode = TRUE;
currArg++;
@@ -1063,7 +1072,7 @@
{
char *in, *out;
- out = currMod->cxxname = (char *)malloc (strlen (in =
currMod->modId->name)+1);
+ out = currMod->cxxname = (char *)Malloc (strlen (in =
currMod->modId->name)+1);
do
*out++ = *in == '-' ? '_' : *in;
while (*in++);
@@ -1234,7 +1243,7 @@
{
char *in, *out;
- out = currMod->idlname = (char *)malloc (strlen (in =
currMod->modId->name)+1);
+ out = currMod->idlname = (char *)Malloc (strlen (in =
currMod->modId->name)+1);
do
*out++ = *in == '-' ? '_' : *in;
while (*in++);
diff -ausrN y/snacc-1.3bbn/debian/changelog snacc-1.3bbn/debian/changelog
--- y/snacc-1.3bbn/debian/changelog Wed Jul 23 15:33:44 2003
+++ snacc-1.3bbn/debian/changelog Wed Jul 23 15:25:38 2003
@@ -1,3 +1,33 @@
+snacc (1.3bbn-2.0.cats.4) unstable; urgency=low
+
+ * make sure ANY_ID's don't have dashes
+
+ -- Kai Henningsen <k...@lisbeth2.intern.cats.ms> Wed, 23 Jul 2003 15:25:16
+0200
+
+snacc (1.3bbn-2.0.cats.3) unstable; urgency=low
+
+ * rebuilt for older libc
+
+ -- Kai Henningsen <kai@lisbeth> Wed, 21 May 2003 15:45:59 +0200
+
+snacc (1.3bbn-2.0.cats.2) unstable; urgency=low
+
+ * various fixes
+
+ -- Kai Henningsen <k...@cats.ms> Mon, 28 Apr 2003 17:04:16 +0200
+
+snacc (1.3bbn-2.0.cats.1) unstable; urgency=low
+
+ * Local changes
+ - add EVENT MACRO
+ - enable YYDEBUG and YYERROR_VERBOSE,
+ enable yydebug on -D
+ * fix SEGV when OPERATION has no ERROR
+ * Incidentally, the code to reserve C identifiers isn't there.
+ compiler/core/define.c, NewObjList()
+
+ -- Kai Henningsen <k...@cats.ms> Wed, 17 Oct 2001 17:39:21 +0200
+
snacc (1.3bbn-2) unstable; urgency=low
* Builds binary-all package in binary-arch target (closes: #87203).
diff -ausrN y/snacc-1.3bbn/debian/rules snacc-1.3bbn/debian/rules
--- y/snacc-1.3bbn/debian/rules Wed Jul 23 15:33:44 2003
+++ snacc-1.3bbn/debian/rules Wed May 21 15:45:18 2003
@@ -4,7 +4,8 @@
#export DH_VERBOSE=1
# This is the debhelper compatability version to use.
-export DH_COMPAT=3
+#export DH_COMPAT=3
+export DH_COMPAT=2
DEB=$(shell pwd)/debian
PREFIX=$(DEB)/tmp/usr
@@ -12,7 +13,7 @@
configure: configure-stamp
configure-stamp:
dh_testdir
- ./configure --prefix=/usr --mandir=/usr/share/man
+ CC=gcc-3.0 CFLAGS='-Wall -W' ./configure --prefix=/usr
--mandir=/usr/share/man
touch configure-stamp
@@ -35,12 +36,40 @@
-$(MAKE) clean
# Remove binary files, dpkg-source complains about unrepresentable
# change in source or so otherwise
- -rm ./c-examples/simple/good-pr.ber \
+ rm -f ./c-examples/simple/good-pr.ber \
./c++-examples/simple/good-pr.ber \
./tbl-example/p-rec.ber
dh_clean
+ -find -type l -print0 | xargs -0 rm -fv
+ -find \( -name "*.o" -o -name "*.lo" -o -name "*.a" -o -name "*.so.*"
\) -print0 | xargs -0 rm -fv
+ -find \( -name .deps -o -name .libs -o -name Makefile \) -print0 |
xargs -0 rm -rfv
+
+ rm -fv config.cache config.status config.log libtool
+ rm -fv \
+ c++-lib/c++/asn-useful.C \
+ c++-lib/c++/asn-useful.h \
+ c-lib/ebuf/asn-useful.c \
+ c-lib/ebuf/asn-useful.h \
+ c-lib/ebuf/tbl.c \
+ c-lib/ebuf/tbl.h \
+ c-lib/mbuf/asn-useful.c \
+ c-lib/mbuf/asn-useful.h \
+ c-lib/mbuf/tbl.c \
+ c-lib/mbuf/tbl.h \
+ c-lib/sbuf/asn-useful.c \
+ c-lib/sbuf/asn-useful.h \
+ c-lib/sbuf/tbl.c \
+ c-lib/sbuf/tbl.h \
+ c-lib/tbl/asn-useful.c \
+ c-lib/tbl/asn-useful.h \
+ c-lib/tbl/tbl.c \
+ c-lib/tbl/tbl.h
+ rm -fv snaccconfig.h config.h
+ rm -fv compiler/core/lex-asn1.c compiler/core/parse-asn1.c
compiler/core/parse-asn1.h
+ rm -fv debian/berdecode.1 debian/snacc-config.1
+
install: install-stamp
install-stamp: build-stamp
dh_testdir
@@ -92,7 +121,7 @@
dh_installexamples -a
dh_installmanpages --package=snacc
dh_installchangelogs -a ChangeLog
- dh_strip -a
+ #dh_strip -a
dh_link -a
dh_compress -a
dh_fixperms -a
diff -ausrN y/snacc-1.3bbn/tbl-tools/pval/pval.c
snacc-1.3bbn/tbl-tools/pval/pval.c
--- y/snacc-1.3bbn/tbl-tools/pval/pval.c Sat Jan 27 02:03:04 2001
+++ snacc-1.3bbn/tbl-tools/pval/pval.c Wed May 21 15:45:18 2003
@@ -77,7 +77,7 @@
return 1;
}
- fileArr = (char **) malloc ((argc -1) * sizeof (char *));
+ fileArr = (char **) calloc(1, (argc -1) * sizeof (char *));
/*
* parse cmd line args
-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux lisbeth 2.4.20+lisbeth-20030620 #1 Fri Jun 20 10:35:30 CEST 2003
i686
Locale: LANG=C, LC_CTYPE=C
Versions of packages snacc depends on:
ii libc6 2.3.1-17 GNU C Library: Shared libraries an
ii libsnacc0 1.3bbn-2.0.cats.4 ASN.1 to C or C++ or IDL compiler,
--- End Message ---