00001 #ifndef __BER_H
00002 #define __BER_H
00003
00004 #undef Bool
00005
00006 class BerPtr
00007 {
00008 uchar *Ptr;
00009 int Len;
00010
00011 public:
00012 BerPtr(void *p, int l);
00013
00014 int GetLen() { return Len; }
00015 uchar *Uchar();
00016 int *Int();
00017 void *Void();
00018
00019 BerPtr &operator +=(int By);
00020 };
00021
00022 class EncBer
00023 {
00024 int Type;
00025 int Arg;
00026 EncBer *Parent;
00027 void _Int(int Type, int Int);
00028
00029 public:
00030 GBytePipe Buf;
00031
00032 EncBer(EncBer *p = 0, int type = 0, int arg = 0);
00033 ~EncBer();
00034
00035
00036 EncBer *Sequence();
00037 EncBer *Set();
00038 EncBer *Application(int App);
00039
00040 void Enum(int i) { _Int(10, i); }
00041 void Int(int i) { _Int(2, i); }
00042 void Str(char *s = 0);
00043 };
00044
00045 typedef bool (*BerGetData)(int This, uchar &c);
00046
00047 class DecBer
00048 {
00049
00050 int Len;
00051
00052
00053 bool Constructed;
00054
00055
00056 int This;
00057 BerGetData GetFunc;
00058
00059
00060 uchar *Raw;
00061
00062
00063 bool HasData();
00064 bool Get(uchar &c);
00065 uchar *GetLen(int Len);
00066 int _Dec(int &Type, int &Arg, int &Size, bool &Construct);
00067 bool _Int(int Type, int &i);
00068 void _Skip(int Bytes);
00069
00070
00071 DecBer(uchar *raw, int len, bool constructed);
00072
00073 public:
00074 DecBer(BerGetData Func, int This = 0, int Len = 0);
00075 ~DecBer();
00076
00077
00078 DecBer *Sequence();
00079 DecBer *Set();
00080 DecBer *Application(int &App);
00081 DecBer *Context(int &App);
00082
00083 bool Bool(int &i);
00084 bool Int(int &i);
00085 bool Enum(int &i);
00086 bool Str(char *&s);
00087 };
00088
00089 #endif