author | Michael Krelin <hacker@klever.net> | 2007-12-27 00:08:36 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-01-04 18:17:46 (UTC) |
commit | ed6883769a03b36402c2c78b1dcee0c7efeb70bc (patch) (unidiff) | |
tree | ec96f9c7feeb02d2822ec9872b937b54ab82fb8a | |
parent | e63de16a9885641b5070ec834225cb562bc2042f (diff) | |
download | libopkele-ed6883769a03b36402c2c78b1dcee0c7efeb70bc.zip libopkele-ed6883769a03b36402c2c78b1dcee0c7efeb70bc.tar.gz libopkele-ed6883769a03b36402c2c78b1dcee0c7efeb70bc.tar.bz2 |
changed auto_ptr to shared_ptr
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | acinclude.m4 | 17 | ||||
-rw-r--r-- | configure.ac | 32 | ||||
-rw-r--r-- | include/Makefile.am | 3 | ||||
-rw-r--r-- | include/opkele/consumer.h | 6 | ||||
-rw-r--r-- | include/opkele/server.h | 4 | ||||
-rw-r--r-- | include/opkele/types.h | 7 |
6 files changed, 59 insertions, 10 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 80defc7..fbb4cdc 100644 --- a/acinclude.m4 +++ b/acinclude.m4 | |||
@@ -1,166 +1,183 @@ | |||
1 | dnl AC_WITH_DOXYGEN([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) | 1 | dnl AC_WITH_DOXYGEN([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) |
2 | dnl Outputs: | 2 | dnl Outputs: |
3 | dnl AC_SUBST: DOXYGEN HAVE_DOXYGEN | 3 | dnl AC_SUBST: DOXYGEN HAVE_DOXYGEN |
4 | dnl AM_CONDTIONAL: HAVE_DOXYGEN | 4 | dnl AM_CONDTIONAL: HAVE_DOXYGEN |
5 | AC_DEFUN([AC_WITH_DOXYGEN],[ | 5 | AC_DEFUN([AC_WITH_DOXYGEN],[ |
6 | HAVE_DOXYGEN="no" | 6 | HAVE_DOXYGEN="no" |
7 | AC_PATH_PROG([DOXYGEN],[doxygen],[false]) | 7 | AC_PATH_PROG([DOXYGEN],[doxygen],[false]) |
8 | if test "${DOXYGEN}" = "false" ; then | 8 | if test "${DOXYGEN}" = "false" ; then |
9 | ifelse([$2], , :, [$2]) | 9 | ifelse([$2], , :, [$2]) |
10 | else | 10 | else |
11 | HAVE_DOXYGEN="yes" | 11 | HAVE_DOXYGEN="yes" |
12 | AC_SUBST([DOXYGEN]) | 12 | AC_SUBST([DOXYGEN]) |
13 | $1 | 13 | $1 |
14 | fi | 14 | fi |
15 | AC_SUBST([HAVE_DOXYGEN]) | 15 | AC_SUBST([HAVE_DOXYGEN]) |
16 | AM_CONDITIONAL([HAVE_DOXYGEN],[test "${HAVE_DOXYGEN}" = "yes"]) | 16 | AM_CONDITIONAL([HAVE_DOXYGEN],[test "${HAVE_DOXYGEN}" = "yes"]) |
17 | ]) | 17 | ]) |
18 | 18 | ||
19 | dnl AC_WITH_DOT([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) | 19 | dnl AC_WITH_DOT([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) |
20 | dnl Outputs: | 20 | dnl Outputs: |
21 | dnl AC_SUBST: DOT HAVE_DOT | 21 | dnl AC_SUBST: DOT HAVE_DOT |
22 | dnl AM_CONDITIONAL: HAVE_DOT | 22 | dnl AM_CONDITIONAL: HAVE_DOT |
23 | AC_DEFUN([AC_WITH_DOT],[ | 23 | AC_DEFUN([AC_WITH_DOT],[ |
24 | HAVE_DOT="no" | 24 | HAVE_DOT="no" |
25 | AC_PATH_PROG([DOT],[dot],[false]) | 25 | AC_PATH_PROG([DOT],[dot],[false]) |
26 | if test "${DOT}" = "false" ; then | 26 | if test "${DOT}" = "false" ; then |
27 | ifelse([$2], , :, [$2]) | 27 | ifelse([$2], , :, [$2]) |
28 | else | 28 | else |
29 | HAVE_DOT="yes" | 29 | HAVE_DOT="yes" |
30 | AC_SUBST([DOT]) | 30 | AC_SUBST([DOT]) |
31 | $1 | 31 | $1 |
32 | fi | 32 | fi |
33 | AC_SUBST([HAVE_DOT]) | 33 | AC_SUBST([HAVE_DOT]) |
34 | AM_CONDITIONAL([HAVE_DOT],[test "${HAVE_DOT}" = "yes"]) | 34 | AM_CONDITIONAL([HAVE_DOT],[test "${HAVE_DOT}" = "yes"]) |
35 | ]) | 35 | ]) |
36 | 36 | ||
37 | dnl AC_WITH_PCRE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) | 37 | dnl AC_WITH_PCRE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) |
38 | dnl Outputs: | 38 | dnl Outputs: |
39 | dnl AC_SUBST: PCRE_CONFIG PCRE_PREFIX PCRE_EXEC_PREFIX | 39 | dnl AC_SUBST: PCRE_CONFIG PCRE_PREFIX PCRE_EXEC_PREFIX |
40 | dnl PCRE_VERSION PCRE_CFLAGS PCRE_LIBS | 40 | dnl PCRE_VERSION PCRE_CFLAGS PCRE_LIBS |
41 | dnl PCRE_LIBS_POSIX PCRE_CFLAGS_POSIX | 41 | dnl PCRE_LIBS_POSIX PCRE_CFLAGS_POSIX |
42 | dnl AC_DEFINE: HAVE_PCRE PCRE_VERSION | 42 | dnl AC_DEFINE: HAVE_PCRE PCRE_VERSION |
43 | dnl env: HAVE_PCRE=yes|no | 43 | dnl env: HAVE_PCRE=yes|no |
44 | AC_DEFUN([AC_WITH_PCRE],[ | 44 | AC_DEFUN([AC_WITH_PCRE],[ |
45 | HAVE_PCRE="no" | 45 | HAVE_PCRE="no" |
46 | PCRE_CONFIG="" | 46 | PCRE_CONFIG="" |
47 | PCRE_PREFIX="" | 47 | PCRE_PREFIX="" |
48 | PCRE_EXEC_PREFIX="" | 48 | PCRE_EXEC_PREFIX="" |
49 | PCRE_VERSION="" | 49 | PCRE_VERSION="" |
50 | PCRE_CFLAGS="" | 50 | PCRE_CFLAGS="" |
51 | PCRE_LIBS="" | 51 | PCRE_LIBS="" |
52 | PCRE_LOCATIONS="${PATH}:/usr/local/bin:/usr/bin" | 52 | PCRE_LOCATIONS="${PATH}:/usr/local/bin:/usr/bin" |
53 | test -z "$WANT_PCRE" && WANT_PCRE="" | 53 | test -z "$WANT_PCRE" && WANT_PCRE="" |
54 | AC_ARG_WITH([pcre], | 54 | AC_ARG_WITH([pcre], |
55 | AC_HELP_STRING([--with-pcre=location],[Look for pcre in specified locations]), | 55 | AC_HELP_STRING([--with-pcre=location],[Look for pcre in specified locations]), |
56 | [ | 56 | [ |
57 | if test "${withval}" = "no" ; then | 57 | if test "${withval}" = "no" ; then |
58 | WANT_PCRE="no" | 58 | WANT_PCRE="no" |
59 | else | 59 | else |
60 | if test -x "${withval}" ; then | 60 | if test -x "${withval}" ; then |
61 | PCRE_CONFIG="${withval}" | 61 | PCRE_CONFIG="${withval}" |
62 | elif test -x "${withval}/pcre-config" ; then | 62 | elif test -x "${withval}/pcre-config" ; then |
63 | PCRE_CONFIG="${withval}/pcre-config" | 63 | PCRE_CONFIG="${withval}/pcre-config" |
64 | elif test -x "${withval}/bin/pcre-config" ; then | 64 | elif test -x "${withval}/bin/pcre-config" ; then |
65 | PCRE_CONFIG="${withval}/bin/pcre-config" | 65 | PCRE_CONFIG="${withval}/bin/pcre-config" |
66 | fi | 66 | fi |
67 | fi | 67 | fi |
68 | ] | 68 | ] |
69 | ) | 69 | ) |
70 | if test "${WANT_PCRE}" = "no" ; then | 70 | if test "${WANT_PCRE}" = "no" ; then |
71 | ifelse([$2], , :, [$2]) | 71 | ifelse([$2], , :, [$2]) |
72 | else | 72 | else |
73 | if test -z "${PCRE_CONFIG}" ; then | 73 | if test -z "${PCRE_CONFIG}" ; then |
74 | AC_PATH_PROG(PCRE_CONFIG,[pcre-config],false,[${PCRE_LOCATIONS}]) | 74 | AC_PATH_PROG(PCRE_CONFIG,[pcre-config],false,[${PCRE_LOCATIONS}]) |
75 | if test "${PCRE_CONFIG}" = "false" ; then | 75 | if test "${PCRE_CONFIG}" = "false" ; then |
76 | ifelse([$2], , :, [$2]) | 76 | ifelse([$2], , :, [$2]) |
77 | else | 77 | else |
78 | HAVE_PCRE="yes" | 78 | HAVE_PCRE="yes" |
79 | PCRE_PREFIX="`${PCRE_CONFIG} --prefix`" | 79 | PCRE_PREFIX="`${PCRE_CONFIG} --prefix`" |
80 | PCRE_EXEC_PREFIX="`${PCRE_CONFIG} --exec-prefix`" | 80 | PCRE_EXEC_PREFIX="`${PCRE_CONFIG} --exec-prefix`" |
81 | PCRE_VERSION="`${PCRE_CONFIG} --version`" | 81 | PCRE_VERSION="`${PCRE_CONFIG} --version`" |
82 | PCRE_CFLAGS="`${PCRE_CONFIG} --cflags`" | 82 | PCRE_CFLAGS="`${PCRE_CONFIG} --cflags`" |
83 | PCRE_LIBS="`${PCRE_CONFIG} --libs`" | 83 | PCRE_LIBS="`${PCRE_CONFIG} --libs`" |
84 | PCRE_CFLAGS_POSIX="`${PCRE_CONFIG} --cflags-posix`" | 84 | PCRE_CFLAGS_POSIX="`${PCRE_CONFIG} --cflags-posix`" |
85 | PCRE_LIBS_POSIX="`${PCRE_CONFIG} --libs-posix`" | 85 | PCRE_LIBS_POSIX="`${PCRE_CONFIG} --libs-posix`" |
86 | AC_SUBST([PCRE_CONFIG]) | 86 | AC_SUBST([PCRE_CONFIG]) |
87 | AC_SUBST([PCRE_PREFIX]) | 87 | AC_SUBST([PCRE_PREFIX]) |
88 | AC_SUBST([PCRE_EXEC_PREFIX]) | 88 | AC_SUBST([PCRE_EXEC_PREFIX]) |
89 | AC_SUBST([PCRE_VERSION]) | 89 | AC_SUBST([PCRE_VERSION]) |
90 | AC_SUBST([PCRE_CFLAGS]) | 90 | AC_SUBST([PCRE_CFLAGS]) |
91 | AC_SUBST([PCRE_LIBS]) | 91 | AC_SUBST([PCRE_LIBS]) |
92 | AC_SUBST([PCRE_CFLAGS_POSIX]) | 92 | AC_SUBST([PCRE_CFLAGS_POSIX]) |
93 | AC_SUBST([PCRE_LIBS_POSIX]) | 93 | AC_SUBST([PCRE_LIBS_POSIX]) |
94 | AC_DEFINE([HAVE_PCRE],,[pcre support]) | 94 | AC_DEFINE([HAVE_PCRE],,[pcre support]) |
95 | AC_DEFINE_UNQUOTED([PCRE_VERSION],["${PCRE_VERSION}"],[pcre version]) | 95 | AC_DEFINE_UNQUOTED([PCRE_VERSION],["${PCRE_VERSION}"],[pcre version]) |
96 | $1 | 96 | $1 |
97 | fi | 97 | fi |
98 | fi | 98 | fi |
99 | fi | 99 | fi |
100 | ]) | 100 | ]) |
101 | 101 | ||
102 | dnl AC_WITH_PCREPP([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) | 102 | dnl AC_WITH_PCREPP([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) |
103 | dnl Outputs: | 103 | dnl Outputs: |
104 | dnl AC_SUBST: PCREPP_CONFIG PCREPP_PREFIX PCREPP_EXEC_PREFIX | 104 | dnl AC_SUBST: PCREPP_CONFIG PCREPP_PREFIX PCREPP_EXEC_PREFIX |
105 | dnl PCREPP_VERSION PCREPP_CFLAGS PCREPP_LIBS | 105 | dnl PCREPP_VERSION PCREPP_CFLAGS PCREPP_LIBS |
106 | dnl AC_DEFINE: HAVE_PCREPP PCREPP_VERSION | 106 | dnl AC_DEFINE: HAVE_PCREPP PCREPP_VERSION |
107 | dnl env: HAVE_PCREPP=yes|no | 107 | dnl env: HAVE_PCREPP=yes|no |
108 | AC_DEFUN([AC_WITH_PCREPP],[ | 108 | AC_DEFUN([AC_WITH_PCREPP],[ |
109 | HAVE_PCREPP="no" | 109 | HAVE_PCREPP="no" |
110 | PCREPP_CONFIG="" | 110 | PCREPP_CONFIG="" |
111 | PCREPP_PREFIX="" | 111 | PCREPP_PREFIX="" |
112 | PCREPP_EXEC_PREFIX="" | 112 | PCREPP_EXEC_PREFIX="" |
113 | PCREPP_VERSION="" | 113 | PCREPP_VERSION="" |
114 | PCREPP_CFLAGS="" | 114 | PCREPP_CFLAGS="" |
115 | PCREPP_LIBS="" | 115 | PCREPP_LIBS="" |
116 | PCREPP_LOCATIONS="${PATH}:/usr/local/bin:/usr/bin" | 116 | PCREPP_LOCATIONS="${PATH}:/usr/local/bin:/usr/bin" |
117 | test -z "$WANT_PCREPP" && WANT_PCREPP="" | 117 | test -z "$WANT_PCREPP" && WANT_PCREPP="" |
118 | AC_ARG_WITH([pcrepp], | 118 | AC_ARG_WITH([pcrepp], |
119 | AC_HELP_STRING([--with-pcrepp=location],[Look for pcre++ in specified locations]), | 119 | AC_HELP_STRING([--with-pcrepp=location],[Look for pcre++ in specified locations]), |
120 | [ | 120 | [ |
121 | if test "${withval}" = "no" ; then | 121 | if test "${withval}" = "no" ; then |
122 | WANT_PCREPP="no" | 122 | WANT_PCREPP="no" |
123 | else | 123 | else |
124 | if test -x "${withval}" ; then | 124 | if test -x "${withval}" ; then |
125 | PCREPP_CONFIG="${withval}" | 125 | PCREPP_CONFIG="${withval}" |
126 | elif test -x "${withval}/pcre++-config" ; then | 126 | elif test -x "${withval}/pcre++-config" ; then |
127 | PCREPP_CONFIG="${withval}/pcre++-config" | 127 | PCREPP_CONFIG="${withval}/pcre++-config" |
128 | elif test -x "${withval}/bin/pcre++-config" ; then | 128 | elif test -x "${withval}/bin/pcre++-config" ; then |
129 | PCREPP_CONFIG="${withval}/bin/pcre++-config" | 129 | PCREPP_CONFIG="${withval}/bin/pcre++-config" |
130 | fi | 130 | fi |
131 | fi | 131 | fi |
132 | ] | 132 | ] |
133 | ) | 133 | ) |
134 | if test "${WANT_PCREPP}" = "no" ; then | 134 | if test "${WANT_PCREPP}" = "no" ; then |
135 | ifelse([$2], , :, [$2]) | 135 | ifelse([$2], , :, [$2]) |
136 | else | 136 | else |
137 | if test "${HAVE_PCRE}" != "yes" ; then | 137 | if test "${HAVE_PCRE}" != "yes" ; then |
138 | ifelse([$2], , :, [$2]) | 138 | ifelse([$2], , :, [$2]) |
139 | else | 139 | else |
140 | if test -z "${PCREPP_CONFIG}" ; then | 140 | if test -z "${PCREPP_CONFIG}" ; then |
141 | AC_PATH_PROG([PCREPP_CONFIG],[pcre++-config],false,[${PCREPP_LOCATIONS}]) | 141 | AC_PATH_PROG([PCREPP_CONFIG],[pcre++-config],false,[${PCREPP_LOCATIONS}]) |
142 | if test "${PCREPP_CONFIG}" = "false" ; then | 142 | if test "${PCREPP_CONFIG}" = "false" ; then |
143 | ifelse([$2], , :, [$2]) | 143 | ifelse([$2], , :, [$2]) |
144 | else | 144 | else |
145 | HAVE_PCREPP="yes" | 145 | HAVE_PCREPP="yes" |
146 | PCREPP_PREFIX="`${PCREPP_CONFIG} --prefix`" | 146 | PCREPP_PREFIX="`${PCREPP_CONFIG} --prefix`" |
147 | PCREPP_EXEC_PREFIX="`${PCREPP_CONFIG} --exec-prefix`" | 147 | PCREPP_EXEC_PREFIX="`${PCREPP_CONFIG} --exec-prefix`" |
148 | PCREPP_VERSION="`${PCREPP_CONFIG} --version`" | 148 | PCREPP_VERSION="`${PCREPP_CONFIG} --version`" |
149 | PCREPP_CFLAGS="`${PCREPP_CONFIG} --cflags` ${PCRE_CFLAGS}" | 149 | PCREPP_CFLAGS="`${PCREPP_CONFIG} --cflags` ${PCRE_CFLAGS}" |
150 | PCREPP_LIBS="`${PCREPP_CONFIG} --libs` ${PCRE_LIBS}" | 150 | PCREPP_LIBS="`${PCREPP_CONFIG} --libs` ${PCRE_LIBS}" |
151 | AC_SUBST([PCREPP_CONFIG]) | 151 | AC_SUBST([PCREPP_CONFIG]) |
152 | AC_SUBST([PCREPP_PREFIX]) | 152 | AC_SUBST([PCREPP_PREFIX]) |
153 | AC_SUBST([PCREPP_EXEC_PREFIX]) | 153 | AC_SUBST([PCREPP_EXEC_PREFIX]) |
154 | AC_SUBST([PCREPP_VERSION]) | 154 | AC_SUBST([PCREPP_VERSION]) |
155 | AC_SUBST([PCREPP_CFLAGS]) | 155 | AC_SUBST([PCREPP_CFLAGS]) |
156 | AC_SUBST([PCREPP_LIBS]) | 156 | AC_SUBST([PCREPP_LIBS]) |
157 | AC_DEFINE([HAVE_PCREPP],,[pcre++ support]) | 157 | AC_DEFINE([HAVE_PCREPP],,[pcre++ support]) |
158 | AC_DEFINE_UNQUOTED([PCREPP_VERSION],["${PCREPP_VERSION}"],[pcre++ version]) | 158 | AC_DEFINE_UNQUOTED([PCREPP_VERSION],["${PCREPP_VERSION}"],[pcre++ version]) |
159 | $1 | 159 | $1 |
160 | fi | 160 | fi |
161 | fi | 161 | fi |
162 | fi | 162 | fi |
163 | fi | 163 | fi |
164 | ]) | 164 | ]) |
165 | 165 | ||
166 | dnl AC_CHECK_SHAREDPTR(NS,HEADER[,ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) | ||
167 | AC_DEFUN([AC_CHECK_SHAREDPTR],[ | ||
168 | AC_LANG_PUSH([C++]) | ||
169 | AC_MSG_CHECKING([for $1::shared_ptr<> in $2]) | ||
170 | AC_COMPILE_IFELSE([ | ||
171 | #include <$2> | ||
172 | int main(int c,char**v) { $1::shared_ptr<int> spi(new int(0)); return *spi; } | ||
173 | ],[ | ||
174 | AC_MSG_RESULT([found]) | ||
175 | $3 | ||
176 | ],[ | ||
177 | AC_MSG_RESULT([not found]) | ||
178 | $4 | ||
179 | ]) | ||
180 | AC_LANG_POP([C++]) | ||
181 | ]) | ||
182 | |||
166 | m4_include([acinclude.d/libcurl.m4]) | 183 | m4_include([acinclude.d/libcurl.m4]) |
diff --git a/configure.ac b/configure.ac index 1bd1873..c4e9a74 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,150 +1,182 @@ | |||
1 | AC_INIT([libopkele], [0.4], [libopkele-bugs@klever.net]) | 1 | AC_INIT([libopkele], [0.4], [libopkele-bugs@klever.net]) |
2 | AC_CONFIG_SRCDIR([include/opkele/opkele-config.h]) | 2 | AC_CONFIG_SRCDIR([include/opkele/opkele-config.h]) |
3 | AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h]) | 3 | AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h]) |
4 | AM_INIT_AUTOMAKE([dist-bzip2]) | 4 | AM_INIT_AUTOMAKE([dist-bzip2]) |
5 | 5 | ||
6 | AC_PROG_INSTALL | 6 | AC_PROG_INSTALL |
7 | AC_PROG_CXX | 7 | AC_PROG_CXX |
8 | AC_PROG_CC | 8 | AC_PROG_CC |
9 | AC_PROG_LIBTOOL | 9 | AC_PROG_LIBTOOL |
10 | PKG_PROG_PKG_CONFIG | 10 | PKG_PROG_PKG_CONFIG |
11 | 11 | ||
12 | AC_HEADER_STDC | 12 | AC_HEADER_STDC |
13 | 13 | ||
14 | AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) | 14 | AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) |
15 | 15 | ||
16 | AC_MSG_CHECKING([for source tree version]) | 16 | AC_MSG_CHECKING([for source tree version]) |
17 | if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then | 17 | if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then |
18 | PACKAGE_SRC_VERSION="$(cd $srcdir && git describe --tags $headrev)" | 18 | PACKAGE_SRC_VERSION="$(cd $srcdir && git describe --tags $headrev)" |
19 | test "$PACKAGE_SRC_VERSION" = "$PACKAGE_VERSION" \ | 19 | test "$PACKAGE_SRC_VERSION" = "$PACKAGE_VERSION" \ |
20 | -o "${PACKAGE_SRC_VERSION#${PACKAGE_VERSION}-}" != "$PACKAGE_SRC_VERSION" || PACKAGE_SRC_VERSION="${PACKAGE_VERSION}:${PACKAGE_SRC_VERSION}" | 20 | -o "${PACKAGE_SRC_VERSION#${PACKAGE_VERSION}-}" != "$PACKAGE_SRC_VERSION" || PACKAGE_SRC_VERSION="${PACKAGE_VERSION}:${PACKAGE_SRC_VERSION}" |
21 | ( cd $srcdir && git diff-index $headrev | read dirt ) && PACKAGE_SRC_VERSION="${PACKAGE_SRC_VERSION}-dirty" | 21 | ( cd $srcdir && git diff-index $headrev | read dirt ) && PACKAGE_SRC_VERSION="${PACKAGE_SRC_VERSION}-dirty" |
22 | else | 22 | else |
23 | PACKAGE_SRC_VERSION="$PACKAGE_VERSION" | 23 | PACKAGE_SRC_VERSION="$PACKAGE_VERSION" |
24 | fi | 24 | fi |
25 | AC_MSG_RESULT([$PACKAGE_SRC_VERSION]) | 25 | AC_MSG_RESULT([$PACKAGE_SRC_VERSION]) |
26 | AC_SUBST([PACKAGE_SRC_VERSION]) | 26 | AC_SUBST([PACKAGE_SRC_VERSION]) |
27 | AC_DEFINE_UNQUOTED([PACKAGE_SRC_VERSION],["$PACKAGE_SRC_VERSION"],[more or less precise source tree version]) | 27 | AC_DEFINE_UNQUOTED([PACKAGE_SRC_VERSION],["$PACKAGE_SRC_VERSION"],[more or less precise source tree version]) |
28 | 28 | ||
29 | tr1_mem_std="false" | ||
30 | tr1_mem_boost="false" | ||
31 | AC_CHECK_SHAREDPTR(std::tr1,tr1/memory,[ tr1_mem_std=true ]) | ||
32 | AC_CHECK_SHAREDPTR(boost,boost/shared_ptr.hpp,[ tr1_mem_boost=true ]) | ||
33 | tr1_mem="" | ||
34 | AC_ARG_WITH([tr1-memory], | ||
35 | AC_HELP_STRING([--with-tr1-memory=<boost|std>],[select tr1/memory (shared_ptr<>) implementation to use]), | ||
36 | [ tr1_mem="$withval" ] | ||
37 | ) | ||
38 | AC_MSG_CHECKING([for tr1/memory implementation to use]) | ||
39 | test -z "$tr1_mem" && $tr1_mem_std && tr1_mem=std | ||
40 | test -z "$tr1_mem" && $tr1_mem_boost && tr1_mem=boost | ||
41 | test -z "$tr1_mem" && AC_MSG_RESULT([none found]) || AC_MSG_RESULT([$tr1_mem]) | ||
42 | case "$tr1_mem" in | ||
43 | std) | ||
44 | $tr1_mem_std || AC_MSG_ERROR([std implementation requested, but not found]) | ||
45 | OPKELE_TR1_MEM_NS=std::tr1 | ||
46 | OPKELE_TR1_MEM_HEADER=tr1/memory | ||
47 | ;; | ||
48 | boost) | ||
49 | $tr1_mem_boost || AC_MSG_ERROR([boost implementation requested, but not found]) | ||
50 | OPKELE_TR1_MEM_NS=boost | ||
51 | OPKELE_TR1_MEM_HEADER=boost/shared_ptr.hpp | ||
52 | ;; | ||
53 | *) | ||
54 | AC_MSG_ERROR([no shared_ptr<> implementation found]) | ||
55 | ;; | ||
56 | esac | ||
57 | AC_SUBST([OPKELE_TR1_MEM_NS]) | ||
58 | AC_SUBST([OPKELE_TR1_MEM_HEADER]) | ||
59 | |||
29 | PKG_CHECK_MODULES([OPENSSL],[openssl],,[ | 60 | PKG_CHECK_MODULES([OPENSSL],[openssl],,[ |
30 | AC_MSG_ERROR([no openssl library found. get one from http://www.openssl.org/]) | 61 | AC_MSG_ERROR([no openssl library found. get one from http://www.openssl.org/]) |
31 | ]) | 62 | ]) |
32 | 63 | ||
33 | WANT_KONFORKA="yes" | 64 | WANT_KONFORKA="yes" |
34 | AC_ARG_ENABLE([konforka], | 65 | AC_ARG_ENABLE([konforka], |
35 | AC_HELP_STRING([--disable-konforka],[do not use konforka library (default: use if found)]), | 66 | AC_HELP_STRING([--disable-konforka],[do not use konforka library (default: use if found)]), |
36 | [ | 67 | [ |
37 | test "${enableval}" = "no" && WANT_KONFORKA="no" | 68 | test "${enableval}" = "no" && WANT_KONFORKA="no" |
38 | ] | 69 | ] |
39 | ) | 70 | ) |
40 | if test "${WANT_KONFORKA}" = "yes" ; then | 71 | if test "${WANT_KONFORKA}" = "yes" ; then |
41 | PKG_CHECK_MODULES([KONFORKA],[konforka],[ | 72 | PKG_CHECK_MODULES([KONFORKA],[konforka],[ |
42 | AC_SUBST([KONFORKA_CFLAGS]) | 73 | AC_SUBST([KONFORKA_CFLAGS]) |
43 | AC_SUBST([KONFORKA_LIBS]) | 74 | AC_SUBST([KONFORKA_LIBS]) |
44 | AC_DEFINE([HAVE_KONFORKA],,[defined in presence of konforka library]) | 75 | AC_DEFINE([HAVE_KONFORKA],,[defined in presence of konforka library]) |
45 | AC_DEFINE([OPKELE_HAVE_KONFORKA],,[defined in presence of konforka library]) | 76 | AC_DEFINE([OPKELE_HAVE_KONFORKA],,[defined in presence of konforka library]) |
46 | AC_SUBST([KONFORKA_KONFORKA],[konforka]) | 77 | AC_SUBST([KONFORKA_KONFORKA],[konforka]) |
47 | ],[true]) | 78 | ],[true]) |
48 | fi | 79 | fi |
49 | 80 | ||
50 | WANT_DOXYGEN="yes" | 81 | WANT_DOXYGEN="yes" |
51 | AC_ARG_ENABLE([doxygen], | 82 | AC_ARG_ENABLE([doxygen], |
52 | AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), | 83 | AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), |
53 | [ | 84 | [ |
54 | test "${enableval}" = "no" && WANT_DOXYGEN="no" | 85 | test "${enableval}" = "no" && WANT_DOXYGEN="no" |
55 | ] | 86 | ] |
56 | ) | 87 | ) |
57 | if test "${WANT_DOXYGEN}" = "yes" ; then | 88 | if test "${WANT_DOXYGEN}" = "yes" ; then |
58 | AC_WITH_DOXYGEN | 89 | AC_WITH_DOXYGEN |
59 | AC_WITH_DOT | 90 | AC_WITH_DOT |
60 | else | 91 | else |
61 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) | 92 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) |
62 | AM_CONDITIONAL([HAVE_DOT],[false]) | 93 | AM_CONDITIONAL([HAVE_DOT],[false]) |
63 | fi | 94 | fi |
64 | 95 | ||
65 | LIBCURL_CHECK_CONFIG(,,,[ | 96 | LIBCURL_CHECK_CONFIG(,,,[ |
66 | AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) | 97 | AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) |
67 | ]) | 98 | ]) |
68 | 99 | ||
69 | AC_CHECK_HEADER([expat.h],[ | 100 | AC_CHECK_HEADER([expat.h],[ |
70 | AC_CHECK_LIB([expat],[XML_ParserCreate],[ | 101 | AC_CHECK_LIB([expat],[XML_ParserCreate],[ |
71 | EXPAT_LIBS=-lexpat | 102 | EXPAT_LIBS=-lexpat |
72 | EXPAT_CFLAGS= | 103 | EXPAT_CFLAGS= |
73 | AC_SUBST([EXPAT_LIBS]) | 104 | AC_SUBST([EXPAT_LIBS]) |
74 | AC_SUBST([EXPAT_CFLAGS]) | 105 | AC_SUBST([EXPAT_CFLAGS]) |
75 | ],[ | 106 | ],[ |
76 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) | 107 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) |
77 | ]) | 108 | ]) |
78 | ],[ | 109 | ],[ |
79 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) | 110 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) |
80 | ]) | 111 | ]) |
81 | 112 | ||
82 | if test -n "$PCRE_LIBS" -a -n "$PCRE_CFLAGS" ; then | 113 | if test -n "$PCRE_LIBS" -a -n "$PCRE_CFLAGS" ; then |
83 | AC_SUBST([PCRE_CFLAGS]) | 114 | AC_SUBST([PCRE_CFLAGS]) |
84 | AC_SUBST([PCRE_LIBS]) | 115 | AC_SUBST([PCRE_LIBS]) |
85 | : | 116 | : |
86 | else | 117 | else |
87 | PKG_CHECK_MODULES([PCRE],[libpcre],,[ | 118 | PKG_CHECK_MODULES([PCRE],[libpcre],,[ |
88 | AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/]) | 119 | AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/]) |
89 | ]) | 120 | ]) |
90 | fi | 121 | fi |
91 | 122 | ||
92 | curl_ssl_verify_host="true" | 123 | curl_ssl_verify_host="true" |
93 | AC_ARG_ENABLE([ssl-verify-host], | 124 | AC_ARG_ENABLE([ssl-verify-host], |
94 | AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), | 125 | AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), |
95 | [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] | 126 | [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] |
96 | ) | 127 | ) |
97 | ${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) | 128 | ${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) |
98 | 129 | ||
99 | curl_ssl_verify_peer="true" | 130 | curl_ssl_verify_peer="true" |
100 | AC_ARG_ENABLE([ssl-verify-peer], | 131 | AC_ARG_ENABLE([ssl-verify-peer], |
101 | AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), | 132 | AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), |
102 | [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] | 133 | [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] |
103 | ) | 134 | ) |
104 | ${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) | 135 | ${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) |
105 | 136 | ||
106 | postels_law=true | 137 | postels_law=true |
107 | AC_ARG_ENABLE([postels-law], | 138 | AC_ARG_ENABLE([postels-law], |
108 | AC_HELP_STRING([--disable-postels-law],[Be strict, do not adhere to Postel's Law ("be conservative in what you do, be liberal in what you accept from others", RFC 793)]), | 139 | AC_HELP_STRING([--disable-postels-law],[Be strict, do not adhere to Postel's Law ("be conservative in what you do, be liberal in what you accept from others", RFC 793)]), |
109 | [ test "${enableval}" = "no" && postels_law=false ] | 140 | [ test "${enableval}" = "no" && postels_law=false ] |
110 | ) | 141 | ) |
111 | $postels_law && AC_DEFINE([POSTELS_LAW],,[defined if we want to adhere to Postel's Law]) | 142 | $postels_law && AC_DEFINE([POSTELS_LAW],,[defined if we want to adhere to Postel's Law]) |
112 | 143 | ||
113 | AC_DEFINE_UNQUOTED([OPKELE_SRC_DIR],["$PWD"],[source directory]) | 144 | AC_DEFINE_UNQUOTED([OPKELE_SRC_DIR],["$PWD"],[source directory]) |
114 | 145 | ||
115 | nitpick=false | 146 | nitpick=false |
116 | AC_ARG_ENABLE([nitpicking], | 147 | AC_ARG_ENABLE([nitpicking], |
117 | AC_HELP_STRING([--enable-nitpicking],[make compiler somewhat overly fastidious about the code it deals with]), | 148 | AC_HELP_STRING([--enable-nitpicking],[make compiler somewhat overly fastidious about the code it deals with]), |
118 | [ test "$enableval" = "no" || nitpick=true ] | 149 | [ test "$enableval" = "no" || nitpick=true ] |
119 | ) | 150 | ) |
120 | if $nitpick ; then | 151 | if $nitpick ; then |
121 | CPP_NITPICK="-pedantic -Wall -Wextra -Wundef -Wshadow \ | 152 | CPP_NITPICK="-pedantic -Wall -Wextra -Wundef -Wshadow \ |
122 | -Wunsafe-loop-optimizations -Wconversion -Wmissing-format-attribute \ | 153 | -Wunsafe-loop-optimizations -Wconversion -Wmissing-format-attribute \ |
123 | -Wredundant-decls -ansi" | 154 | -Wredundant-decls -ansi" |
124 | # -Wlogical-op -Wmissing-noreturn | 155 | # -Wlogical-op -Wmissing-noreturn |
125 | C_NITPICK="$CPP_NITPICK" | 156 | C_NITPICK="$CPP_NITPICK" |
126 | CXX_NITPICK="$C_NITPICK" | 157 | CXX_NITPICK="$C_NITPICK" |
127 | 158 | ||
128 | CPPFLAGS="$CPPFLAGS $CPP_NITPICK" | 159 | CPPFLAGS="$CPPFLAGS $CPP_NITPICK" |
129 | CFLAGS="$CFLAGS $C_NITPICK" | 160 | CFLAGS="$CFLAGS $C_NITPICK" |
130 | CXXFLAGS="$CXXFLAGS $CXX_NITPICK" | 161 | CXXFLAGS="$CXXFLAGS $CXX_NITPICK" |
131 | fi | 162 | fi |
132 | 163 | ||
133 | xri_proxy_url="http://beta.xri.net/" | 164 | xri_proxy_url="http://beta.xri.net/" |
134 | AC_MSG_CHECKING([for XRI resolver proxy]) | 165 | AC_MSG_CHECKING([for XRI resolver proxy]) |
135 | AC_ARG_ENABLE([xri-proxy], | 166 | AC_ARG_ENABLE([xri-proxy], |
136 | AC_HELP_STRING([--with-xri-proxy=url],[set xri proxy for use when resolving xri identities, default is http://xr_proxy_url]), | 167 | AC_HELP_STRING([--with-xri-proxy=url],[set xri proxy for use when resolving xri identities, default is http://xr_proxy_url]), |
137 | [ xri_proxy_url="$withval" ] | 168 | [ xri_proxy_url="$withval" ] |
138 | ) | 169 | ) |
139 | AC_MSG_RESULT([$xri_proxy_url]) | 170 | AC_MSG_RESULT([$xri_proxy_url]) |
140 | AC_DEFINE_UNQUOTED([XRI_PROXY_URL],["$xri_proxy_url"],[XRI proxy resolver URL]) | 171 | AC_DEFINE_UNQUOTED([XRI_PROXY_URL],["$xri_proxy_url"],[XRI proxy resolver URL]) |
141 | 172 | ||
142 | AC_CONFIG_FILES([ | 173 | AC_CONFIG_FILES([ |
143 | Makefile | 174 | Makefile |
144 | libopkele.pc | 175 | libopkele.pc |
145 | Doxyfile | 176 | Doxyfile |
146 | include/Makefile | 177 | include/Makefile |
178 | include/opkele/tr1-mem.h | ||
147 | lib/Makefile | 179 | lib/Makefile |
148 | test/Makefile | 180 | test/Makefile |
149 | ]) | 181 | ]) |
150 | AC_OUTPUT | 182 | AC_OUTPUT |
diff --git a/include/Makefile.am b/include/Makefile.am index 078c6dc..26cb614 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
@@ -1,19 +1,20 @@ | |||
1 | nobase_include_HEADERS = \ | 1 | nobase_include_HEADERS = \ |
2 | opkele/acconfig.h \ | 2 | opkele/acconfig.h \ |
3 | opkele/opkele-config.h \ | 3 | opkele/opkele-config.h \ |
4 | opkele/types.h \ | 4 | opkele/types.h \ |
5 | opkele/association.h \ | 5 | opkele/association.h \ |
6 | opkele/exception.h \ | 6 | opkele/exception.h \ |
7 | opkele/server.h \ | 7 | opkele/server.h \ |
8 | opkele/consumer.h \ | 8 | opkele/consumer.h \ |
9 | opkele/extension.h \ | 9 | opkele/extension.h \ |
10 | opkele/sreg.h \ | 10 | opkele/sreg.h \ |
11 | opkele/extension_chain.h \ | 11 | opkele/extension_chain.h \ |
12 | opkele/xconsumer.h \ | 12 | opkele/xconsumer.h \ |
13 | opkele/xserver.h \ | 13 | opkele/xserver.h \ |
14 | opkele/discovery.h \ | 14 | opkele/discovery.h \ |
15 | opkele/uris.h | 15 | opkele/uris.h \ |
16 | opkele/tr1-mem.h | ||
16 | EXTRA_DIST = \ | 17 | EXTRA_DIST = \ |
17 | opkele/data.h \ | 18 | opkele/data.h \ |
18 | opkele/curl.h opkele/expat.h \ | 19 | opkele/curl.h opkele/expat.h \ |
19 | opkele/util.h | 20 | opkele/util.h |
diff --git a/include/opkele/consumer.h b/include/opkele/consumer.h index c463787..3c1d318 100644 --- a/include/opkele/consumer.h +++ b/include/opkele/consumer.h | |||
@@ -1,174 +1,174 @@ | |||
1 | #ifndef __OPKELE_CONSUMER_H | 1 | #ifndef __OPKELE_CONSUMER_H |
2 | #define __OPKELE_CONSUMER_H | 2 | #define __OPKELE_CONSUMER_H |
3 | 3 | ||
4 | #include <opkele/types.h> | 4 | #include <opkele/types.h> |
5 | #include <opkele/extension.h> | 5 | #include <opkele/extension.h> |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * @file | 8 | * @file |
9 | * @brief OpenID consumer-side functionality | 9 | * @brief OpenID consumer-side functionality |
10 | */ | 10 | */ |
11 | 11 | ||
12 | namespace opkele { | 12 | namespace opkele { |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * implementation of basic consumer functionality | 15 | * implementation of basic consumer functionality |
16 | * | 16 | * |
17 | * @note | 17 | * @note |
18 | * The consumer uses libcurl internally, which means that if you're using | 18 | * The consumer uses libcurl internally, which means that if you're using |
19 | * libopkele in multithreaded environment you should call curl_global_init | 19 | * libopkele in multithreaded environment you should call curl_global_init |
20 | * yourself before spawning any threads. | 20 | * yourself before spawning any threads. |
21 | */ | 21 | */ |
22 | class consumer_t { | 22 | class consumer_t { |
23 | public: | 23 | public: |
24 | 24 | ||
25 | virtual ~consumer_t() { } | 25 | virtual ~consumer_t() { } |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * store association. The function should be overridden in the real | 28 | * store association. The function should be overridden in the real |
29 | * implementation to provide persistent associations store. | 29 | * implementation to provide persistent associations store. |
30 | * @param server the OpenID server | 30 | * @param server the OpenID server |
31 | * @param handle association handle | 31 | * @param handle association handle |
32 | * @param secret the secret associated with the server and handle | 32 | * @param secret the secret associated with the server and handle |
33 | * @param expires_in the number of seconds until the handle is expired | 33 | * @param expires_in the number of seconds until the handle is expired |
34 | * @return the auto_ptr<> for the newly allocated association_t object | 34 | * @return the assoc_t for the newly allocated association_t object |
35 | */ | 35 | */ |
36 | virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0; | 36 | virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0; |
37 | /** | 37 | /** |
38 | * retrieve stored association. The function should be overridden | 38 | * retrieve stored association. The function should be overridden |
39 | * in the real implementation to provide persistent assocations | 39 | * in the real implementation to provide persistent assocations |
40 | * store. | 40 | * store. |
41 | * | 41 | * |
42 | * @note | 42 | * @note |
43 | * The user is responsible for handling associations expiry and | 43 | * The user is responsible for handling associations expiry and |
44 | * this function should never return an expired or invalidated | 44 | * this function should never return an expired or invalidated |
45 | * association. | 45 | * association. |
46 | * | 46 | * |
47 | * @param server the OpenID server | 47 | * @param server the OpenID server |
48 | * @param handle association handle | 48 | * @param handle association handle |
49 | * @return the autho_ptr<> for the newly allocated association_t object | 49 | * @return the autho_ptr<> for the newly allocated association_t object |
50 | * @throw failed_lookup if no unexpired association found | 50 | * @throw failed_lookup if no unexpired association found |
51 | */ | 51 | */ |
52 | virtual assoc_t retrieve_assoc(const string& server,const string& handle) = 0; | 52 | virtual assoc_t retrieve_assoc(const string& server,const string& handle) = 0; |
53 | /** | 53 | /** |
54 | * invalidate stored association. The function should be overridden | 54 | * invalidate stored association. The function should be overridden |
55 | * in the real implementation of the consumer. | 55 | * in the real implementation of the consumer. |
56 | * @param server the OpenID server | 56 | * @param server the OpenID server |
57 | * @param handle association handle | 57 | * @param handle association handle |
58 | */ | 58 | */ |
59 | virtual void invalidate_assoc(const string& server,const string& handle) = 0; | 59 | virtual void invalidate_assoc(const string& server,const string& handle) = 0; |
60 | /** | 60 | /** |
61 | * retrieve any unexpired association for the server. If the | 61 | * retrieve any unexpired association for the server. If the |
62 | * function is not overridden in the real implementation, the new | 62 | * function is not overridden in the real implementation, the new |
63 | * association will be established for each request. | 63 | * association will be established for each request. |
64 | * | 64 | * |
65 | * @note | 65 | * @note |
66 | * The user is responsible for handling associations and this | 66 | * The user is responsible for handling associations and this |
67 | * function should never return an expired or invalidated | 67 | * function should never return an expired or invalidated |
68 | * association. | 68 | * association. |
69 | * | 69 | * |
70 | * @note | 70 | * @note |
71 | * It may be a good idea to pre-expire associations shortly before | 71 | * It may be a good idea to pre-expire associations shortly before |
72 | * their time is really up to avoid association expiry in the | 72 | * their time is really up to avoid association expiry in the |
73 | * middle of negotiations. | 73 | * middle of negotiations. |
74 | * | 74 | * |
75 | * @param server the OpenID server | 75 | * @param server the OpenID server |
76 | * @return the auto_ptr<> for the newly allocated association_t object | 76 | * @return the assoc_t for the newly allocated association_t object |
77 | * @throw failed_lookup in case of absence of the handle | 77 | * @throw failed_lookup in case of absence of the handle |
78 | */ | 78 | */ |
79 | virtual assoc_t find_assoc(const string& server); | 79 | virtual assoc_t find_assoc(const string& server); |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * retrieve the metainformation contained in link tags from the | 82 | * retrieve the metainformation contained in link tags from the |
83 | * page pointed by url. the function may implement caching of the | 83 | * page pointed by url. the function may implement caching of the |
84 | * information. | 84 | * information. |
85 | * @param url url to harvest for link tags | 85 | * @param url url to harvest for link tags |
86 | * @param server reference to the string object where to put | 86 | * @param server reference to the string object where to put |
87 | * openid.server value | 87 | * openid.server value |
88 | * @param delegate reference to the string object where to put the | 88 | * @param delegate reference to the string object where to put the |
89 | * openid.delegate value (if any) | 89 | * openid.delegate value (if any) |
90 | */ | 90 | */ |
91 | virtual void retrieve_links(const string& url,string& server,string& delegate); | 91 | virtual void retrieve_links(const string& url,string& server,string& delegate); |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * perform the associate request to OpenID server. | 94 | * perform the associate request to OpenID server. |
95 | * @param server the OpenID server | 95 | * @param server the OpenID server |
96 | * @return the auto_ptr<> for the newly allocated association_t | 96 | * @return the assoc_t for the newly allocated association_t |
97 | * object, representing established association | 97 | * object, representing established association |
98 | * @throw exception in case of error | 98 | * @throw exception in case of error |
99 | */ | 99 | */ |
100 | assoc_t associate(const string& server); | 100 | assoc_t associate(const string& server); |
101 | /** | 101 | /** |
102 | * prepare the parameters for the checkid_immediate | 102 | * prepare the parameters for the checkid_immediate |
103 | * request. | 103 | * request. |
104 | * @param identity the identity to verify | 104 | * @param identity the identity to verify |
105 | * @param return_to the return_to url to pass with the request | 105 | * @param return_to the return_to url to pass with the request |
106 | * @param trust_root the trust root to advertise with the request | 106 | * @param trust_root the trust root to advertise with the request |
107 | * @param ext pointer to an extension(s) hooks object | 107 | * @param ext pointer to an extension(s) hooks object |
108 | * @return the location string | 108 | * @return the location string |
109 | * @throw exception in case of error | 109 | * @throw exception in case of error |
110 | */ | 110 | */ |
111 | virtual string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); | 111 | virtual string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); |
112 | /** | 112 | /** |
113 | * prepare the parameters for the checkid_setup | 113 | * prepare the parameters for the checkid_setup |
114 | * request. | 114 | * request. |
115 | * @param identity the identity to verify | 115 | * @param identity the identity to verify |
116 | * @param return_to the return_to url to pass with the request | 116 | * @param return_to the return_to url to pass with the request |
117 | * @param trust_root the trust root to advertise with the request | 117 | * @param trust_root the trust root to advertise with the request |
118 | * @param ext pointer to an extension(s) hooks object | 118 | * @param ext pointer to an extension(s) hooks object |
119 | * @return the location string | 119 | * @return the location string |
120 | * @throw exception in case of error | 120 | * @throw exception in case of error |
121 | */ | 121 | */ |
122 | virtual string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); | 122 | virtual string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); |
123 | /** | 123 | /** |
124 | * the actual implementation behind checkid_immediate() and | 124 | * the actual implementation behind checkid_immediate() and |
125 | * checkid_setup() functions. | 125 | * checkid_setup() functions. |
126 | * @param mode checkid_* mode - either mode_checkid_immediate or mode_checkid_setup | 126 | * @param mode checkid_* mode - either mode_checkid_immediate or mode_checkid_setup |
127 | * @param identity the identity to verify | 127 | * @param identity the identity to verify |
128 | * @param return_to the return_to url to pass with the request | 128 | * @param return_to the return_to url to pass with the request |
129 | * @param trust_root the trust root to advertise with the request | 129 | * @param trust_root the trust root to advertise with the request |
130 | * @param ext pointer to an extension(s) hooks object | 130 | * @param ext pointer to an extension(s) hooks object |
131 | * @return the location string | 131 | * @return the location string |
132 | * @throw exception in case of error | 132 | * @throw exception in case of error |
133 | */ | 133 | */ |
134 | virtual string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); | 134 | virtual string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); |
135 | /** | 135 | /** |
136 | * verify the id_res response | 136 | * verify the id_res response |
137 | * @param pin the response parameters | 137 | * @param pin the response parameters |
138 | * @param identity the identity being checked (if not specified, | 138 | * @param identity the identity being checked (if not specified, |
139 | * @param ext pointer to an extension(s) hooks object | 139 | * @param ext pointer to an extension(s) hooks object |
140 | * extracted from the openid.identity parameter | 140 | * extracted from the openid.identity parameter |
141 | * @throw id_res_mismatch in case of signature mismatch | 141 | * @throw id_res_mismatch in case of signature mismatch |
142 | * @throw id_res_setup in case of openid.user_setup_url failure | 142 | * @throw id_res_setup in case of openid.user_setup_url failure |
143 | * (supposedly checkid_immediate only) | 143 | * (supposedly checkid_immediate only) |
144 | * @throw id_res_failed in case of failure | 144 | * @throw id_res_failed in case of failure |
145 | * @throw id_res_expired_on_delivery if the association expired before it could've been verified | 145 | * @throw id_res_expired_on_delivery if the association expired before it could've been verified |
146 | * @throw exception in case of other failures | 146 | * @throw exception in case of other failures |
147 | */ | 147 | */ |
148 | virtual void id_res(const params_t& pin,const string& identity="",extension_t *ext=0); | 148 | virtual void id_res(const params_t& pin,const string& identity="",extension_t *ext=0); |
149 | /** | 149 | /** |
150 | * perform a check_authentication request. | 150 | * perform a check_authentication request. |
151 | * @param server the OpenID server | 151 | * @param server the OpenID server |
152 | * @param p request parameters | 152 | * @param p request parameters |
153 | */ | 153 | */ |
154 | void check_authentication(const string& server,const params_t& p); | 154 | void check_authentication(const string& server,const params_t& p); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | * normalize URL by adding http:// and trailing slash if needed. | 157 | * normalize URL by adding http:// and trailing slash if needed. |
158 | * @param url | 158 | * @param url |
159 | * @return normalized url | 159 | * @return normalized url |
160 | */ | 160 | */ |
161 | static string normalize(const string& url); | 161 | static string normalize(const string& url); |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Canonicalize URL, by normalizing its appearance and following redirects. | 164 | * Canonicalize URL, by normalizing its appearance and following redirects. |
165 | * @param url | 165 | * @param url |
166 | * @return canonicalized url | 166 | * @return canonicalized url |
167 | */ | 167 | */ |
168 | virtual string canonicalize(const string& url); | 168 | virtual string canonicalize(const string& url); |
169 | 169 | ||
170 | }; | 170 | }; |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | #endif /* __OPKELE_CONSUMER_H */ | 174 | #endif /* __OPKELE_CONSUMER_H */ |
diff --git a/include/opkele/server.h b/include/opkele/server.h index dd7fc41..3c25646 100644 --- a/include/opkele/server.h +++ b/include/opkele/server.h | |||
@@ -1,98 +1,98 @@ | |||
1 | #ifndef __OPKELE_SERVER_H | 1 | #ifndef __OPKELE_SERVER_H |
2 | #define __OPKELE_SERVER_H | 2 | #define __OPKELE_SERVER_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * @file | 5 | * @file |
6 | * @brief OpenID server-side functionality | 6 | * @brief OpenID server-side functionality |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <opkele/types.h> | 9 | #include <opkele/types.h> |
10 | #include <opkele/extension.h> | 10 | #include <opkele/extension.h> |
11 | 11 | ||
12 | namespace opkele { | 12 | namespace opkele { |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * implementation of basic server functionality | 15 | * implementation of basic server functionality |
16 | */ | 16 | */ |
17 | class server_t { | 17 | class server_t { |
18 | public: | 18 | public: |
19 | 19 | ||
20 | virtual ~server_t() { } | 20 | virtual ~server_t() { } |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * allocate the new association. The function should be overridden | 23 | * allocate the new association. The function should be overridden |
24 | * in the real implementation to provide persistent assocations | 24 | * in the real implementation to provide persistent assocations |
25 | * store. | 25 | * store. |
26 | * @param mode the mode of request being processed to base the | 26 | * @param mode the mode of request being processed to base the |
27 | * statelessness of the association upon | 27 | * statelessness of the association upon |
28 | * @return the auto_ptr<> for the newly allocated association_t object | 28 | * @return the assoc_t for the newly allocated association_t object |
29 | */ | 29 | */ |
30 | virtual assoc_t alloc_assoc(mode_t mode) = 0; | 30 | virtual assoc_t alloc_assoc(mode_t mode) = 0; |
31 | /** | 31 | /** |
32 | * retrieve the association. The function should be overridden in | 32 | * retrieve the association. The function should be overridden in |
33 | * the reqal implementation to provide persistent assocations | 33 | * the reqal implementation to provide persistent assocations |
34 | * store. | 34 | * store. |
35 | * @param h association handle | 35 | * @param h association handle |
36 | * @return the auto_ptr<> for the newly allocated association_t object | 36 | * @return the assoc_t for the newly allocated association_t object |
37 | * @throw failed_lookup in case of failure | 37 | * @throw failed_lookup in case of failure |
38 | */ | 38 | */ |
39 | virtual assoc_t retrieve_assoc(const string& h) = 0; | 39 | virtual assoc_t retrieve_assoc(const string& h) = 0; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * validate the identity. | 42 | * validate the identity. |
43 | * @param assoc association object | 43 | * @param assoc association object |
44 | * @param pin incoming request parameters | 44 | * @param pin incoming request parameters |
45 | * @param identity being verified | 45 | * @param identity being verified |
46 | * @param trust_root presented in the request | 46 | * @param trust_root presented in the request |
47 | * @throw exception if identity can not be confirmed | 47 | * @throw exception if identity can not be confirmed |
48 | */ | 48 | */ |
49 | virtual void validate(const association_t& assoc,const params_t& pin,const string& identity,const string& trust_root) = 0; | 49 | virtual void validate(const association_t& assoc,const params_t& pin,const string& identity,const string& trust_root) = 0; |
50 | 50 | ||
51 | 51 | ||
52 | /** | 52 | /** |
53 | * process the associate request. | 53 | * process the associate request. |
54 | * @param pin the incoming request parameters | 54 | * @param pin the incoming request parameters |
55 | * @param pout the store for the response parameters | 55 | * @param pout the store for the response parameters |
56 | */ | 56 | */ |
57 | void associate(const params_t& pin,params_t& pout); | 57 | void associate(const params_t& pin,params_t& pout); |
58 | /** | 58 | /** |
59 | * process the checkid_immediate request. | 59 | * process the checkid_immediate request. |
60 | * @param pin the incoming request parameters | 60 | * @param pin the incoming request parameters |
61 | * @param return_to reference to the object to store return_to url to | 61 | * @param return_to reference to the object to store return_to url to |
62 | * @param pout the response parameters | 62 | * @param pout the response parameters |
63 | * @param ext pointer to the extension hooks object | 63 | * @param ext pointer to the extension hooks object |
64 | * @throw exception in case of errors or negative reply | 64 | * @throw exception in case of errors or negative reply |
65 | */ | 65 | */ |
66 | virtual void checkid_immediate(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); | 66 | virtual void checkid_immediate(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); |
67 | /** | 67 | /** |
68 | * process the checkid_setup request. | 68 | * process the checkid_setup request. |
69 | * @param pin the incoming request parameters | 69 | * @param pin the incoming request parameters |
70 | * @param return_to reference to the object to store return_to url to | 70 | * @param return_to reference to the object to store return_to url to |
71 | * @param pout the response parameters | 71 | * @param pout the response parameters |
72 | * @param ext pointer to the extension hooks object | 72 | * @param ext pointer to the extension hooks object |
73 | * @throw exception in case of errors or negative reply | 73 | * @throw exception in case of errors or negative reply |
74 | */ | 74 | */ |
75 | virtual void checkid_setup(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); | 75 | virtual void checkid_setup(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); |
76 | /** | 76 | /** |
77 | * the actual functionality behind checkid_immediate() and | 77 | * the actual functionality behind checkid_immediate() and |
78 | * checkid_setup() | 78 | * checkid_setup() |
79 | * @param mode the request being processed (either | 79 | * @param mode the request being processed (either |
80 | * mode_checkid_immediate or mode_checkid_setup) | 80 | * mode_checkid_immediate or mode_checkid_setup) |
81 | * @param pin the incoming request parameters | 81 | * @param pin the incoming request parameters |
82 | * @param return_to reference to the object to store return_to url to | 82 | * @param return_to reference to the object to store return_to url to |
83 | * @param pout the response parameters | 83 | * @param pout the response parameters |
84 | * @param ext pointer to the extension hooks object | 84 | * @param ext pointer to the extension hooks object |
85 | * @throw exception in case of errors or negative reply | 85 | * @throw exception in case of errors or negative reply |
86 | */ | 86 | */ |
87 | virtual void checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); | 87 | virtual void checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); |
88 | /** | 88 | /** |
89 | * process the check_authentication request. | 89 | * process the check_authentication request. |
90 | * @param pin incoming request parameters | 90 | * @param pin incoming request parameters |
91 | * @param pout response parameters | 91 | * @param pout response parameters |
92 | */ | 92 | */ |
93 | void check_authentication(const params_t& pin,params_t& pout); | 93 | void check_authentication(const params_t& pin,params_t& pout); |
94 | }; | 94 | }; |
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | #endif /* __OPKELE_SERVER_H */ | 98 | #endif /* __OPKELE_SERVER_H */ |
diff --git a/include/opkele/types.h b/include/opkele/types.h index ca07df5..d959021 100644 --- a/include/opkele/types.h +++ b/include/opkele/types.h | |||
@@ -1,243 +1,242 @@ | |||
1 | #ifndef __OPKELE_TYPES_H | 1 | #ifndef __OPKELE_TYPES_H |
2 | #define __OPKELE_TYPES_H | 2 | #define __OPKELE_TYPES_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * @file | 5 | * @file |
6 | * @brief various types declarations | 6 | * @brief various types declarations |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <ostream> | 9 | #include <ostream> |
10 | #include <vector> | 10 | #include <vector> |
11 | #include <string> | 11 | #include <string> |
12 | #include <map> | 12 | #include <map> |
13 | #include <memory> | ||
14 | #include <set> | 13 | #include <set> |
14 | #include <opkele/tr1-mem.h> | ||
15 | 15 | ||
16 | namespace opkele { | 16 | namespace opkele { |
17 | using std::vector; | 17 | using std::vector; |
18 | using std::string; | 18 | using std::string; |
19 | using std::map; | 19 | using std::map; |
20 | using std::ostream; | 20 | using std::ostream; |
21 | using std::auto_ptr; | ||
22 | using std::multimap; | 21 | using std::multimap; |
23 | using std::set; | 22 | using std::set; |
24 | 23 | ||
25 | /** | 24 | /** |
26 | * the OpenID operation mode | 25 | * the OpenID operation mode |
27 | */ | 26 | */ |
28 | typedef enum _mode_t { | 27 | typedef enum _mode_t { |
29 | mode_associate, | 28 | mode_associate, |
30 | mode_checkid_immediate, | 29 | mode_checkid_immediate, |
31 | mode_checkid_setup, | 30 | mode_checkid_setup, |
32 | mode_check_association | 31 | mode_check_association |
33 | } mode_t; | 32 | } mode_t; |
34 | 33 | ||
35 | /** | 34 | /** |
36 | * the association secret container | 35 | * the association secret container |
37 | */ | 36 | */ |
38 | class secret_t : public vector<unsigned char> { | 37 | class secret_t : public vector<unsigned char> { |
39 | public: | 38 | public: |
40 | 39 | ||
41 | /** | 40 | /** |
42 | * xor the secret and hmac together and encode, using base64 | 41 | * xor the secret and hmac together and encode, using base64 |
43 | * @param key_d pointer to the message digest | 42 | * @param key_d pointer to the message digest |
44 | * @param rv reference to the return value | 43 | * @param rv reference to the return value |
45 | */ | 44 | */ |
46 | void enxor_to_base64(const unsigned char *key_d,string& rv) const; | 45 | void enxor_to_base64(const unsigned char *key_d,string& rv) const; |
47 | /** | 46 | /** |
48 | * decode base64-encoded secret and xor it with the message digest | 47 | * decode base64-encoded secret and xor it with the message digest |
49 | * @param key_d pointer to the message digest | 48 | * @param key_d pointer to the message digest |
50 | * @param b64 base64-encoded secret value | 49 | * @param b64 base64-encoded secret value |
51 | */ | 50 | */ |
52 | void enxor_from_base64(const unsigned char *key_d,const string& b64); | 51 | void enxor_from_base64(const unsigned char *key_d,const string& b64); |
53 | /** | 52 | /** |
54 | * plainly encode to base64 representation | 53 | * plainly encode to base64 representation |
55 | * @param rv reference to the return value | 54 | * @param rv reference to the return value |
56 | */ | 55 | */ |
57 | void to_base64(string& rv) const; | 56 | void to_base64(string& rv) const; |
58 | /** | 57 | /** |
59 | * decode cleartext secret from base64 | 58 | * decode cleartext secret from base64 |
60 | * @param b64 base64-encoded representation of the secret value | 59 | * @param b64 base64-encoded representation of the secret value |
61 | */ | 60 | */ |
62 | void from_base64(const string& b64); | 61 | void from_base64(const string& b64); |
63 | }; | 62 | }; |
64 | 63 | ||
65 | /** | 64 | /** |
66 | * Interface to the association. | 65 | * Interface to the association. |
67 | */ | 66 | */ |
68 | class association_t { | 67 | class association_t { |
69 | public: | 68 | public: |
70 | 69 | ||
71 | virtual ~association_t() { } | 70 | virtual ~association_t() { } |
72 | 71 | ||
73 | /** | 72 | /** |
74 | * retrieve the server with which association was established. | 73 | * retrieve the server with which association was established. |
75 | * @return server name | 74 | * @return server name |
76 | */ | 75 | */ |
77 | virtual string server() const = 0; | 76 | virtual string server() const = 0; |
78 | /** | 77 | /** |
79 | * retrieve the association handle. | 78 | * retrieve the association handle. |
80 | * @return handle | 79 | * @return handle |
81 | */ | 80 | */ |
82 | virtual string handle() const = 0; | 81 | virtual string handle() const = 0; |
83 | /** | 82 | /** |
84 | * retrieve the association type. | 83 | * retrieve the association type. |
85 | * @return association type | 84 | * @return association type |
86 | */ | 85 | */ |
87 | virtual string assoc_type() const = 0; | 86 | virtual string assoc_type() const = 0; |
88 | /** | 87 | /** |
89 | * retrieve the association secret. | 88 | * retrieve the association secret. |
90 | * @return association secret | 89 | * @return association secret |
91 | */ | 90 | */ |
92 | virtual secret_t secret() const = 0; | 91 | virtual secret_t secret() const = 0; |
93 | /** | 92 | /** |
94 | * retrieve the number of seconds the association expires in. | 93 | * retrieve the number of seconds the association expires in. |
95 | * @return seconds till expiration | 94 | * @return seconds till expiration |
96 | */ | 95 | */ |
97 | virtual int expires_in() const = 0; | 96 | virtual int expires_in() const = 0; |
98 | /** | 97 | /** |
99 | * check whether the association is stateless. | 98 | * check whether the association is stateless. |
100 | * @return true if stateless | 99 | * @return true if stateless |
101 | */ | 100 | */ |
102 | virtual bool stateless() const = 0; | 101 | virtual bool stateless() const = 0; |
103 | /** | 102 | /** |
104 | * check whether the association is expired. | 103 | * check whether the association is expired. |
105 | * @return true if expired | 104 | * @return true if expired |
106 | */ | 105 | */ |
107 | virtual bool is_expired() const = 0; | 106 | virtual bool is_expired() const = 0; |
108 | }; | 107 | }; |
109 | 108 | ||
110 | /** | 109 | /** |
111 | * the auto_ptr<> for association_t object type | 110 | * the shared_ptr<> for association_t object type |
112 | */ | 111 | */ |
113 | typedef auto_ptr<association_t> assoc_t; | 112 | typedef tr1mem::shared_ptr<association_t> assoc_t; |
114 | 113 | ||
115 | /** | 114 | /** |
116 | * request/response parameters map | 115 | * request/response parameters map |
117 | */ | 116 | */ |
118 | class params_t : public map<string,string> { | 117 | class params_t : public map<string,string> { |
119 | public: | 118 | public: |
120 | 119 | ||
121 | /** | 120 | /** |
122 | * check whether the parameter is present. | 121 | * check whether the parameter is present. |
123 | * @param n the parameter name | 122 | * @param n the parameter name |
124 | * @return true if yes | 123 | * @return true if yes |
125 | */ | 124 | */ |
126 | bool has_param(const string& n) const; | 125 | bool has_param(const string& n) const; |
127 | /** | 126 | /** |
128 | * retrieve the parameter (const version) | 127 | * retrieve the parameter (const version) |
129 | * @param n the parameter name | 128 | * @param n the parameter name |
130 | * @return the parameter value | 129 | * @return the parameter value |
131 | * @throw failed_lookup if there is no such parameter | 130 | * @throw failed_lookup if there is no such parameter |
132 | */ | 131 | */ |
133 | const string& get_param(const string& n) const; | 132 | const string& get_param(const string& n) const; |
134 | /** | 133 | /** |
135 | * retrieve the parameter. | 134 | * retrieve the parameter. |
136 | * @param n the parameter name | 135 | * @param n the parameter name |
137 | * @return the parameter value | 136 | * @return the parameter value |
138 | * @throw failed_lookup if there is no such parameter | 137 | * @throw failed_lookup if there is no such parameter |
139 | */ | 138 | */ |
140 | string& get_param(const string& n); | 139 | string& get_param(const string& n); |
141 | 140 | ||
142 | /** | 141 | /** |
143 | * parse the OpenID key/value data. | 142 | * parse the OpenID key/value data. |
144 | * @param kv the OpenID key/value data | 143 | * @param kv the OpenID key/value data |
145 | */ | 144 | */ |
146 | void parse_keyvalues(const string& kv); | 145 | void parse_keyvalues(const string& kv); |
147 | /** | 146 | /** |
148 | * sign the fields. | 147 | * sign the fields. |
149 | * @param secret the secret used for signing | 148 | * @param secret the secret used for signing |
150 | * @param sig reference to the string, containing base64-encoded | 149 | * @param sig reference to the string, containing base64-encoded |
151 | * result | 150 | * result |
152 | * @param slist the comma-separated list of fields to sign | 151 | * @param slist the comma-separated list of fields to sign |
153 | * @param prefix the string to prepend to parameter names | 152 | * @param prefix the string to prepend to parameter names |
154 | */ | 153 | */ |
155 | void sign(secret_t secret,string& sig,const string& slist,const char *prefix=0) const; | 154 | void sign(secret_t secret,string& sig,const string& slist,const char *prefix=0) const; |
156 | 155 | ||
157 | /** | 156 | /** |
158 | * append parameters to the URL as a GET-request parameters. | 157 | * append parameters to the URL as a GET-request parameters. |
159 | * @param url the base URL | 158 | * @param url the base URL |
160 | * @param prefix the string to prepend to parameter names | 159 | * @param prefix the string to prepend to parameter names |
161 | * @return the ready-to-use location | 160 | * @return the ready-to-use location |
162 | */ | 161 | */ |
163 | string append_query(const string& url,const char *prefix = "openid.") const; | 162 | string append_query(const string& url,const char *prefix = "openid.") const; |
164 | 163 | ||
165 | /** | 164 | /** |
166 | * make up a query string suitable for use in GET and POST | 165 | * make up a query string suitable for use in GET and POST |
167 | * requests. | 166 | * requests. |
168 | * @param prefix string to prened to parameter names | 167 | * @param prefix string to prened to parameter names |
169 | * @return query string | 168 | * @return query string |
170 | */ | 169 | */ |
171 | string query_string(const char *prefix = "openid.") const; | 170 | string query_string(const char *prefix = "openid.") const; |
172 | }; | 171 | }; |
173 | 172 | ||
174 | /** | 173 | /** |
175 | * dump the key/value pairs for the parameters to the stream. | 174 | * dump the key/value pairs for the parameters to the stream. |
176 | * @param o output stream | 175 | * @param o output stream |
177 | * @param p the parameters | 176 | * @param p the parameters |
178 | */ | 177 | */ |
179 | ostream& operator << (ostream& o,const params_t& p); | 178 | ostream& operator << (ostream& o,const params_t& p); |
180 | 179 | ||
181 | namespace xrd { | 180 | namespace xrd { |
182 | 181 | ||
183 | struct priority_compare { | 182 | struct priority_compare { |
184 | inline bool operator()(long a,long b) const { | 183 | inline bool operator()(long a,long b) const { |
185 | return (a<0) ? false : (b<0) ? false : (a<b); | 184 | return (a<0) ? false : (b<0) ? false : (a<b); |
186 | } | 185 | } |
187 | }; | 186 | }; |
188 | 187 | ||
189 | template <typename _DT> | 188 | template <typename _DT> |
190 | class priority_map : public multimap<long,_DT,priority_compare> { | 189 | class priority_map : public multimap<long,_DT,priority_compare> { |
191 | typedef multimap<long,_DT,priority_compare> map_type; | 190 | typedef multimap<long,_DT,priority_compare> map_type; |
192 | public: | 191 | public: |
193 | 192 | ||
194 | inline _DT& add(long priority,const _DT& d) { | 193 | inline _DT& add(long priority,const _DT& d) { |
195 | return insert(typename map_type::value_type(priority,d))->second; | 194 | return insert(typename map_type::value_type(priority,d))->second; |
196 | } | 195 | } |
197 | }; | 196 | }; |
198 | 197 | ||
199 | typedef priority_map<string> canonical_ids_t; | 198 | typedef priority_map<string> canonical_ids_t; |
200 | typedef priority_map<string> local_ids_t; | 199 | typedef priority_map<string> local_ids_t; |
201 | typedef set<string> types_t; | 200 | typedef set<string> types_t; |
202 | typedef priority_map<string> uris_t; | 201 | typedef priority_map<string> uris_t; |
203 | 202 | ||
204 | class service_t { | 203 | class service_t { |
205 | public: | 204 | public: |
206 | types_t types; | 205 | types_t types; |
207 | uris_t uris; | 206 | uris_t uris; |
208 | local_ids_t local_ids; | 207 | local_ids_t local_ids; |
209 | 208 | ||
210 | void clear() { | 209 | void clear() { |
211 | types.clear(); | 210 | types.clear(); |
212 | uris.clear(); local_ids.clear(); | 211 | uris.clear(); local_ids.clear(); |
213 | } | 212 | } |
214 | }; | 213 | }; |
215 | typedef priority_map<service_t> services_t; | 214 | typedef priority_map<service_t> services_t; |
216 | 215 | ||
217 | class XRD_t { | 216 | class XRD_t { |
218 | public: | 217 | public: |
219 | time_t expires; | 218 | time_t expires; |
220 | 219 | ||
221 | canonical_ids_t canonical_ids; | 220 | canonical_ids_t canonical_ids; |
222 | local_ids_t local_ids; | 221 | local_ids_t local_ids; |
223 | services_t services; | 222 | services_t services; |
224 | 223 | ||
225 | void clear() { | 224 | void clear() { |
226 | expires = 0; | 225 | expires = 0; |
227 | canonical_ids.clear(); local_ids.clear(); | 226 | canonical_ids.clear(); local_ids.clear(); |
228 | services.clear(); | 227 | services.clear(); |
229 | } | 228 | } |
230 | bool empty() const { | 229 | bool empty() const { |
231 | return | 230 | return |
232 | canonical_ids.empty() | 231 | canonical_ids.empty() |
233 | && local_ids.empty() | 232 | && local_ids.empty() |
234 | && services.empty(); | 233 | && services.empty(); |
235 | } | 234 | } |
236 | 235 | ||
237 | }; | 236 | }; |
238 | 237 | ||
239 | } | 238 | } |
240 | 239 | ||
241 | } | 240 | } |
242 | 241 | ||
243 | #endif /* __OPKELE_TYPES_H */ | 242 | #endif /* __OPKELE_TYPES_H */ |