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