#include <unistd.h>
#include <stdlib.h>
struct AsnNameDesc
{
const char *const name;
const AsnIntType value;
};
struct AsnTypeDesc;
struct AsnMemberDesc {
const char *const name;
const AsnTypeDesc *const desc;
AsnMemberDesc (const char *, const AsnTypeDesc *);
AsnMemberDesc();
#if TCL
virtual int TclGetDesc (Tcl_DString *) const;
virtual int TclGetDesc2 (Tcl_DString *) const;
#endif
};
struct AsnSe_MemberDesc: AsnMemberDesc {
bool optional;
AsnSe_MemberDesc (const char *, const AsnTypeDesc *, bool);
AsnSe_MemberDesc();
#if TCL
int TclGetDesc2 (Tcl_DString *) const;
#endif
};
typedef AsnMemberDesc AsnChoiceMemberDesc;
typedef AsnSe_MemberDesc AsnSetMemberDesc;
typedef AsnSe_MemberDesc AsnSequenceMemberDesc;
struct AsnModuleDesc;
class AsnType;
struct AsnTypeDesc
{
const AsnModuleDesc *module;
const char *const name; const bool pdu;
const enum Type {
VOID,
ALIAS,
INTEGER,
REAL,
NUL_, BOOLEAN,
ENUMERATED,
BIT_STRING,
OCTET_STRING,
OBJECT_IDENTIFIER,
SET,
SEQUENCE,
SET_OF,
SEQUENCE_OF,
CHOICE,
ANY
} type;
AsnType *(*create)();
static const char *const typenames[];
AsnTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)());
virtual const AsnModuleDesc *getmodule() const;
virtual const char *getname() const;
virtual bool ispdu() const;
virtual Type gettype() const;
virtual const AsnNameDesc *getnames() const;
#if TCL
virtual int TclGetDesc (Tcl_DString *) const;
virtual int TclGetDesc2 (Tcl_DString *) const;
#endif
};
struct AsnNamesTypeDesc: AsnTypeDesc
{
const AsnNameDesc *const names;
AsnNamesTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnNameDesc *);
const AsnNameDesc *getnames() const;
#if TCL
int TclGetDesc (Tcl_DString *) const;
int TclGetDesc2 (Tcl_DString *) const;
#endif
};
struct AsnEnumTypeDesc: AsnNamesTypeDesc
{
AsnEnumTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnNameDesc *);
#if TCL
int TclGetDesc2 (Tcl_DString *) const;
#endif
};
struct AsnMembersTypeDesc: AsnTypeDesc
{
AsnMembersTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)());
#if TCL
int TclGetDesc (Tcl_DString *) const;
#endif
};
struct AsnChoiceTypeDesc: AsnMembersTypeDesc
{
const AsnChoiceMemberDesc *const members;
AsnChoiceTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnChoiceMemberDesc *);
int choicebyname (const char *name) const;
const char *choicebyvalue (int value) const;
#if TCL
int TclGetDesc2 (Tcl_DString *) const;
#endif
};
struct AsnSe_TypeDesc: AsnMembersTypeDesc
{
const AsnSe_MemberDesc *const members;
AsnSe_TypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnSe_MemberDesc *);
#if TCL
int mandatmemberr (Tcl_Interp *interp, const char *membername) const;
int TclGetDesc2 (Tcl_DString *) const;
#endif
};
struct AsnListTypeDesc: AsnTypeDesc
{
const AsnTypeDesc *const base;
AsnListTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnTypeDesc *);
#if TCL
int TclGetDesc (Tcl_DString *) const;
#endif
};
struct AsnAliasTypeDesc: AsnTypeDesc
{
const AsnTypeDesc *const alias;
AsnAliasTypeDesc (const AsnModuleDesc *, const char *, bool ispdu, Type, AsnType *(*create)(), const AsnTypeDesc *);
const AsnModuleDesc *getmodule() const;
const char *getname() const;
bool ispdu() const;
Type gettype() const;
const AsnNameDesc *getnames() const;
#if TCL
int TclGetDesc (Tcl_DString *) const;
#endif
};
typedef AsnTypeDesc AsnRealTypeDesc;
typedef AsnTypeDesc AsnNullTypeDesc;
typedef AsnTypeDesc AsnBoolTypeDesc;
typedef AsnNamesTypeDesc AsnIntTypeDesc;
typedef AsnNamesTypeDesc AsnBitsTypeDesc;
typedef AsnTypeDesc AsnOctsTypeDesc;
typedef AsnTypeDesc AsnOidTypeDesc;
typedef AsnSe_TypeDesc AsnSetTypeDesc;
typedef AsnSe_TypeDesc AsnSequenceTypeDesc;
struct AsnModuleDesc
{
const char *const name;
const AsnTypeDesc **const types;
};
extern const AsnModuleDesc *asnModuleDescs[];
#if TCL
struct Args
{
int c;
char **v;
Args();
virtual ~Args();
};
struct TmpFD
{
int fd;
TmpFD() { fd = -1; }
TmpFD (int _fd) { fd = _fd; }
~TmpFD() { if (fd > 0) ::close (fd); }
int operator = (int _fd){ return fd = _fd; }
};
extern int debinify (Tcl_Interp *interp, const char *in, size_t len);
extern int binify (Tcl_Interp *interp, const char *str, char *buf, size_t *len);
#endif