00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CODEX_ASN1_BASE_H__
00022 #define __CODEX_ASN1_BASE_H__
00023
00024
00025 #include <openssl/asn1.h>
00026 #include <openssl/asn1_mac.h>
00027 #include <openssl/err.h>
00028 #include <string>
00029 #include <iostream>
00030 #include "config.h"
00031
00032 #ifdef NEED_CHAR_TRAITS_UCHAR
00033 namespace std {
00034 template<>
00035 struct char_traits<unsigned char>
00036 {
00037 typedef unsigned char char_type;
00038 typedef unsigned int int_type;
00039 typedef streampos pos_type;
00040 typedef streamoff off_type;
00041 typedef mbstate_t state_type;
00042
00043 static void
00044 assign(char_type& __c1, const char_type& __c2)
00045 { __c1 = __c2; }
00046
00047 static bool
00048 eq(const char_type& __c1, const char_type& __c2)
00049 { return __c1 == __c2; }
00050
00051 static bool
00052 lt(const char_type& __c1, const char_type& __c2)
00053 { return __c1 < __c2; }
00054
00055 static int
00056 compare(const char_type* __s1, const char_type* __s2, size_t __n)
00057 { return memcmp(__s1, __s2, __n); }
00058
00059 static size_t
00060 length(const char_type* __s)
00061 { return strlen((const char*)__s); }
00062
00063 static const char_type*
00064 find(const char_type* __s, size_t __n, const char_type& __a)
00065 { return static_cast<const char_type*>(memchr(__s, __a, __n)); }
00066
00067 static char_type*
00068 move(char_type* __s1, const char_type* __s2, size_t __n)
00069 { return static_cast<char_type*>(memmove(__s1, __s2, __n)); }
00070
00071 static char_type*
00072 copy(char_type* __s1, const char_type* __s2, size_t __n)
00073 { return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
00074
00075 static char_type*
00076 assign(char_type* __s, size_t __n, char_type __a)
00077 { return static_cast<char_type*>(memset(__s, __a, __n)); }
00078
00079 static char_type
00080 to_char_type(const int_type& __c)
00081 { return static_cast<char_type>(__c); }
00082
00083
00084
00085 static int_type
00086 to_int_type(const char_type& __c)
00087 { return static_cast<int_type>(static_cast<unsigned char>(__c)); }
00088
00089 static bool
00090 eq_int_type(const int_type& __c1, const int_type& __c2)
00091 { return __c1 == __c2; }
00092
00093 static int_type
00094 eof() { return static_cast<int_type>(EOF); }
00095
00096 static int_type
00097 not_eof(const int_type& __c)
00098 { return (__c == eof()) ? 0 : __c; }
00099 };
00100 }
00101 #endif
00102
00103 using namespace std;
00104
00135 namespace CODEX_ASN1
00136 {
00138 typedef basic_string< unsigned char > ustring;
00139
00142 class Base
00143 {
00144 public :
00146 Base( bool initialized );
00148 virtual ~Base();
00149
00157 virtual int marshal( unsigned char ** pp ) const = 0;
00158
00168 virtual void* unmarshal( void* bogus,
00169 unsigned char** pp,
00170 long length ) = 0;
00171
00175 bool initialized() const { return m_initialized; }
00176
00177 protected :
00179 bool m_initialized;
00180
00181 private :
00182 void operator=( const Base& );
00183 };
00184
00185 }
00186
00187 #endif