⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asn_obj.h

📁 ASN.1语法解析代码
💻 H
字号:
/*****************************************************************************
File:     asn_obj.h
Contents: Header file for the ASN_GEN program and the basic library
        functions.
System:   ASN development.
Created:
Author:   Charles W. Gardiner <gardiner@bbn.com>

Remarks:

COPYRIGHT 1995 BBN Systems and Technologies, A Division of BBN Inc.
150 CambridgePark Drive
Cambridge, Ma. 02140
617-873-4000
*****************************************************************************/
#ifndef _ASN_OBJ_H
#define _ASN_OBJ_H
/* $Header: /nfs/sub-rosa/u2/IOS_Project/ASN/Dev/rcs/lib/asn_obj/asn_obj.h,v 1.23 1995/09/25 22:15:29 gardiner Exp $ */
/* sfcsid[] = "@(#)asn_obj.h 282P" */

#include "asn.h"
#include "asn_error.h"

extern int asn_errno, asn_obj_err(int);
extern ulong decode_asn_lth(const uchar **), decode_asn_tag(const uchar **);
extern char asn_map_string[];
extern void stuff(int);

/* AsnObj flags defines */
#define ASN_FILLED_FLAG    1
#define ASN_POINTER_FLAG   2
#define ASN_OPTIONAL_FLAG  4
#define ASN_OF_FLAG        8
/* #define ASN_CHOICE_FLAG 0x10 */
#define ASN_FALSE_FLAG  0x20        /* used only in asn_gen */
#define ASN_SUB_INDEF_FLAG 0x20     /* used only in C++ */
#define ASN_TABLE_FLAG  0x40
#define ASN_DUPED_FLAG  0x80
#define ASN_SUB_EXPORT_FLAG 0x100   /* used only in asn_gen */
#define ASN_DEFAULT_FLAG 0x200
/* #define ASN_SIGNED_FLAG  0x400 */
#define ASN_DEFINED_FLAG 0x800
#define ASN_CHOSEN_FLAG  0x1000     /* used only in C++ */
#define ASN_DEFINER_FLAG 0x1000     /* used only in asn_gen */
#define ASN_EXPORT_FLAG  0x2000     /* used only in asn_gen */
#define ASN_INDEF_LTH_FLAG 0x2000   /* used only in C++ */
#define ASN_EXPLICIT_FLAG 0x4000
#define ASN_ENUM_FLAG     0x8000

#ifdef __cplusplus

  /* values for mode in encodesize() and readsize() */
  /* zero is sizing or vsizing */
#define ASN_READING 1          /* reading or encoding */
#define ASN_RE_SIZING 2        /* re_sizing or re_vsizing */
#define ASN_RE_READING 3       /* re-reading or re_encoding */

class AsnObj;

class UcharArray
    {
  public:
    UcharArray(int);
    UcharArray(const uchar *, int);
    ~UcharArray(){ delete [] ua;}
    int size() { return siz; }
    uchar& operator[](int index) { return ua[index]; }
    int append(const uchar *, int);
    int fill(const uchar *, int);
    void copy(AsnObj *) const;
    int diff(const AsnObj *) const;
    int diff(const char *) const;
  protected:
    int siz;
    uchar *ua;
    };

/* char_table masks */
#define ASN_NUMERIC_MASK  1
#define ASN_PRINTABLE_MASK 4
#define ASN_T61_MASK       8

class AsnPtr;

class AsnObj
    {
  public:
    AsnObj();
    virtual ~AsnObj();
    AsnObj *_next, *_sub, *_supra;
    ulong _tag, _type;
    ushort _flags, _mask;
    int _min, _max;
    UcharArray *_valp;
    void clear();
    void _clear(int);
    void fill_upward(int);
    int _append(const uchar *, ulong);
    const AsnObj *check_choice() const;
    int check_efilled() const;
    int check_vfilled() const;
    int check_filled() const;
    int decode(const uchar *);
    int decode(const uchar *, long);
    int dump(char *) const;
    int dump_size() const;
    int _dumpsize(char *, int, int) const;
    int _dumpread(char *, int, int) const;
    int encode(uchar *) const;
    int encode_lth(uchar *, ulong) const;
    int encode_tag(uchar *, ulong)const;
    int get_file(const char *);
    int get_file(int);
    int is_default() const;
    int match(const uchar *, const uchar *);
    int put_file(const char *) const;
    int put_file(int) const;
    int read(uchar *) const;
    int read(long *) const;
    int read_empty(int, int) const;
    int re_encode(uchar *) const;
    int re_read(uchar *) const;
    int re_size() const;
    int re_vsize() const;
    int set_asn_lth(uchar *from, uchar *to, int mode) const;
    int size() const;
    int vsize() const;
    int write(const uchar *, const ulong );
    int write(const long);
    int tag(ulong *) const;
    int _encodesize(uchar *, int) const;
    int _read(uchar *) const;
    int _readsize(uchar *, int) const;
    int _write(const uchar *, ulong );
    int copy(AsnObj *) const;
    int diff(const AsnObj *) const;
    void operator=(const AsnObj &);
    int operator!=(const AsnObj &) const;
    int operator==(const AsnObj &) const;
    void map() const;
    int map(char **, int, int) const;
    };

extern void multi_stuff(int, const AsnObj *, const AsnObj *);
extern void map(AsnObj *);

class AsnTableObj : public AsnObj
    {
  public:
    UcharArray *wherep;
    int set_definees(int) const;
    void operator=(const AsnTableObj &);
    int operator==(const AsnTableObj &) const;
    int operator!=(const AsnTableObj &) const;
    AsnTableObj();
    ~AsnTableObj();
    };

extern int set_definees(AsnTableObj *, int);

class AsnAny : public AsnObj
    {
  public:
    AsnAny();
    };

class AsnNumeric : public AsnObj
    {
  public:
    int operator!=(const long) const;
    int operator==(const long) const;
    void operator=(const long);
    operator long () const;
    };

class AsnBoolean : public AsnNumeric
    {
  public:
    short _default;
    void operator=(const long);
    AsnBoolean();
    };

class AsnInteger : public AsnNumeric
    {
  public:
    void operator=(const long);
    AsnInteger();
    };

class AsnBitString : public AsnObj
    {
  public:
    int read(uchar *, int *) const;
    int vsize() const;
    int write(const uchar *, ulong, int);
    AsnBitString();
    };

class AsnString : public AsnObj
    {
  public:
    int operator!=(const char *) const;
    int operator==(const char *) const;
    };

class AsnOctetString : public AsnString
    {
  public:
    void operator=(const char *);
    AsnOctetString();
    };

class AsnNull : public AsnObj
    {
  public:
    AsnNull();
    };

class AsnObjectIdentifier : public AsnObj
    {
  public:
    int read(uchar *) const;
    int vsize() const;
    int write(const char *, ulong);
    int _readsize(uchar *, int) const;
    void operator=(const char *);
    AsnObjectIdentifier();
    };

class AsnEnumerated : public AsnNumeric
    {
  public:
    void operator=(const long);
    AsnEnumerated();
    };

class AsnNumericString : public AsnString
    {
  public:
    void operator=(const char *);
    AsnNumericString();
    };

class AsnPrintableString : public AsnString
    {
  public:
    void operator=(const char *);
    AsnPrintableString();
    };

class AsnVideotexString : public AsnString
    {
  public:
    void operator=(const char *);
    AsnVideotexString();
    };

class AsnTeletexString : public AsnString
    {
  public:
    void operator=(const char *);
    AsnTeletexString();
    };

class AsnUTCTime : public AsnNumeric
    {
  public:
    void operator=(const long val);
    AsnUTCTime();
    };

class AsnGeneralizedTime : public AsnNumeric
    {
  public:
    void operator=(const long val);
    AsnGeneralizedTime();
    };

class AsnSequence : public AsnObj
    {
  public:
    void operator=(const AsnSequence &);
    int operator!=(const AsnSequence &) const;
    int operator==(const AsnSequence &) const;
    AsnSequence();
    };

class AsnLink
    {
  public:
    AsnLink *_next;
    AsnObj *objp;
    AsnLink();
    ~AsnLink();
    };

class AsnSet : public AsnObj
    {
  public:
    AsnLink *_relinksp;
    void operator=(const AsnSet &);
    int operator!=(const AsnSet &) const;
    int operator==(const AsnSet &) const;
    AsnSet();
    ~AsnSet();
    };

class AsnOf : public AsnObj             /* only heirs used */
    {
  public:
    int numitems() const;
    void operator=(const AsnOf &);
    int operator!=(const AsnOf &) const;
    int operator==(const AsnOf &) const;
    AsnOf();
    };

class AsnSequenceOf : public AsnOf
    {
  public:
    AsnSequenceOf();
    };

class AsnSetOf : public AsnOf
    {
  public:
    AsnSetOf();
    };

class AsnDup : public AsnObj
    {
  public:
    virtual AsnDup *_dup();         // makes new instance of object.
    void _set_pointers(AsnDup *);   // called by all _dup()
    };

AsnObj *_dupAsnObj(AsnDup *);

class AsnPtr : public AsnDup    // from AsnDup in case it is an array
    {
  public:
    AsnObj *_ptr;
    virtual void _point();      // makes new pointed-to object
    void _set_ptr();       // called by all _point()
    void operator=(AsnObj *);
    void operator=(const AsnPtr &);
    int operator==(const AsnPtr &) const;
    int operator!=(const AsnPtr &) const;
    AsnPtr();
    ~AsnPtr();
    };

class AsnArray : public AsnDup  /* member of an array, not set/sequence of */
    {                           /* needs the dup() for itself */
  public:
    int insert();
    int remove();
    AsnArray& operator[](int index);
    AsnArray *index_op(int);
//    AsnArray& operator++();
//    AsnArray& operator--();
    ~AsnArray();
    };

class AsnNumericArray : public AsnArray
    {
  public:
    void operator=(const long);
    };

class AsnStringArray : public AsnArray
    {
  public:
    void operator=(const char *);
    };

class AsnOfArray : public AsnArray  /* member of an array AND a set/seq of */
    {                               /* only its heirs are used */
  public:
    int numitems() const;
    AsnOfArray();
    };

class AsnArrayOfSequencesOf : public AsnOfArray
    {
  public:
    AsnArrayOfSequencesOf();
    };

class AsnArrayOfSetsOf : public AsnOfArray
    {
  public:
    AsnArrayOfSetsOf();
    };

class AsnPtrArray : public AsnPtr /* member of an array AND is a ptr */
    {                               /* only its heirs are used  */
  public:
    int insert();
    int remove();
//    AsnPtrArray& operator++();
//    AsnPtrArray& operator--();
    AsnPtrArray *index_op(int);
    AsnPtrArray();
    ~AsnPtrArray();
    };

class AsnPtrOfArray : public AsnPtrArray  // member of an array AND is a ptr
    {                                     // to SET/SEQ OF
  public:
    int numitems() const;
    };


class AsnPtrArraySequenceOf : public AsnPtrOfArray
    {
  public:
    AsnPtrArraySequenceOf();
    };

class AsnPtrArraySetOf : public AsnPtrOfArray
    {
  public:
    AsnPtrArraySetOf();
    };

class AsnChoice : public AsnObj
    {
  public:
    void operator=(const AsnChoice &);
    int operator!=(const AsnChoice &) const;
    int operator==(const AsnChoice &) const;
    AsnChoice();
    };

class AsnNone : public AsnObj
    {
  public:
    AsnNone();
    };

class AsnNotAsn1 : public AsnObj
    {
  public:
    AsnNotAsn1();
    };

#endif
#endif /* _ASN_OBJ_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -