summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2007-01-12 14:04:13 (UTC)
committer Michael Krelin <hacker@klever.net>2007-01-12 14:04:13 (UTC)
commit782d7a9e2c07ff6621b754595642aa3fec377bd2 (patch) (unidiff)
tree491a9d726bf8d027350c81877be2dd2baca40971
parentd6a92f4891cd730c1c3cdba90f474cf253534120 (diff)
downloadlibopkele-782d7a9e2c07ff6621b754595642aa3fec377bd2.zip
libopkele-782d7a9e2c07ff6621b754595642aa3fec377bd2.tar.gz
libopkele-782d7a9e2c07ff6621b754595642aa3fec377bd2.tar.bz2
added more doxygen comments
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/util.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/include/opkele/util.h b/include/opkele/util.h
index 80d8b03..2a7a859 100644
--- a/include/opkele/util.h
+++ b/include/opkele/util.h
@@ -10,12 +10,16 @@
10namespace opkele { 10namespace opkele {
11 using std::string; 11 using std::string;
12 using std::vector; 12 using std::vector;
13 13
14 namespace util { 14 namespace util {
15 15
16 /**
17 * Convenience class encapsulating SSL BIGNUM object for the purpose of
18 * automatical freeing.
19 */
16 class bignum_t { 20 class bignum_t {
17 public: 21 public:
18 BIGNUM *_bn; 22 BIGNUM *_bn;
19 23
20 bignum_t() : _bn(0) { } 24 bignum_t() : _bn(0) { }
21 bignum_t(BIGNUM *bn) : _bn(bn) { } 25 bignum_t(BIGNUM *bn) : _bn(bn) { }
@@ -23,12 +27,16 @@ namespace opkele {
23 27
24 bignum_t& operator=(BIGNUM *bn) { if(_bn) BN_free(_bn); _bn = bn; return *this; } 28 bignum_t& operator=(BIGNUM *bn) { if(_bn) BN_free(_bn); _bn = bn; return *this; }
25 29
26 operator const BIGNUM*(void) const { return _bn; } 30 operator const BIGNUM*(void) const { return _bn; }
27 operator BIGNUM*(void) { return _bn; } 31 operator BIGNUM*(void) { return _bn; }
28 }; 32 };
33 /**
34 * Convenience clas encapsulating SSL DH object for the purpose of
35 * automatic freeing.
36 */
29 class dh_t { 37 class dh_t {
30 public: 38 public:
31 DH *_dh; 39 DH *_dh;
32 40
33 dh_t() : _dh(0) { } 41 dh_t() : _dh(0) { }
34 dh_t(DH *dh) : _dh(dh) { } 42 dh_t(DH *dh) : _dh(dh) { }
@@ -40,25 +48,83 @@ namespace opkele {
40 operator DH*(void) { return _dh; } 48 operator DH*(void) { return _dh; }
41 49
42 DH* operator->() { return _dh; } 50 DH* operator->() { return _dh; }
43 const DH* operator->() const { return _dh; } 51 const DH* operator->() const { return _dh; }
44 }; 52 };
45 53
54 /**
55 * Convert base64-encoded SSL BIGNUM to internal representation.
56 * @param b64 base64-encoded number
57 * @return SSL BIGNUM
58 * @throw failed_conversion in case of error
59 */
46 BIGNUM *base64_to_bignum(const string& b64); 60 BIGNUM *base64_to_bignum(const string& b64);
61 /**
62 * Convert decimal representation to SSL BIGNUM.
63 * @param dec decimal representation
64 * @return resulting BIGNUM
65 * @throw failed_conversion in case of error
66 */
47 BIGNUM *dec_to_bignum(const string& dec); 67 BIGNUM *dec_to_bignum(const string& dec);
68 /**
69 * Convert SSL BIGNUM data to base64 encoded string.
70 * @param bn BIGNUM
71 * @return base64encoded string
72 */
48 string bignum_to_base64(const BIGNUM *bn); 73 string bignum_to_base64(const BIGNUM *bn);
49 74
75 /**
76 * Convert internal time representation to w3c format
77 * @param t internal representation
78 * @return w3c time
79 * @throw failed_conversion in case of error
80 */
50 string time_to_w3c(time_t t); 81 string time_to_w3c(time_t t);
82 /**
83 * Convert W3C time representation to internal time_t
84 * @param w w3c representation
85 * @return converted time
86 * @throw failed_conversion in case of error
87 */
51 time_t w3c_to_time(const string& w); 88 time_t w3c_to_time(const string& w);
52 89
90 /**
91 * Encode string to the representation suitable for using in URL.
92 * @param str string to encode
93 * @return encoded string
94 * @throw failed_conversion in case of failure
95 */
53 string url_encode(const string& str); 96 string url_encode(const string& str);
54 97
98 /**
99 * Convert number to string
100 * @param l number
101 * @return string representation
102 * @throw failed_conversion in case of failure
103 */
55 string long_to_string(long l); 104 string long_to_string(long l);
105 /**
106 * Convert string to number
107 * @param s string, containing the number
108 * @return the number
109 * @throw failed_conversion in case of failure
110 */
56 long string_to_long(const string& s); 111 long string_to_long(const string& s);
57 112
113 /**
114 * Encode binary data using base64.
115 * @param data pointer to binary data
116 * @param length length of data
117 * @return encoded data
118 */
58 string encode_base64(const void *data,size_t length); 119 string encode_base64(const void *data,size_t length);
120 /**
121 * Decode binary data from base64 representation.
122 * @param data base64-encoded data
123 * @param rv container for decoded binary
124 */
59 void decode_base64(const string& data,vector<unsigned char>& rv); 125 void decode_base64(const string& data,vector<unsigned char>& rv);
60 } 126 }
61 127
62} 128}
63 129
64#endif /* __OPKELE_UTIL_H */ 130#endif /* __OPKELE_UTIL_H */