summaryrefslogtreecommitdiff
path: root/guile/src
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-02-27 19:51:57 +0100
committerLudovic Courtès <ludo@gnu.org>2011-02-27 19:51:57 +0100
commitff30c8e72faa2aa4a75630ec9fcea9cac9b4cdce (patch)
tree8130e2680c223a97577ab69a294249e2ed4258d6 /guile/src
parentf5c363dcaeb9ad068725c6c3c6e6b24266241ee4 (diff)
downloadgnutls-ff30c8e72faa2aa4a75630ec9fcea9cac9b4cdce.tar.gz
guile: Wrap `gnutls_priority_set_direct'; deprecate the old method.
Diffstat (limited to 'guile/src')
-rw-r--r--guile/src/core.c44
-rw-r--r--guile/src/errors.c13
-rw-r--r--guile/src/errors.h14
3 files changed, 60 insertions, 11 deletions
diff --git a/guile/src/core.c b/guile/src/core.c
index dfe0fc33dd..e0b264bf88 100644
--- a/guile/src/core.c
+++ b/guile/src/core.c
@@ -1,5 +1,5 @@
/* GnuTLS --- Guile bindings for GnuTLS.
- Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
GnuTLS is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -532,7 +532,49 @@ SCM_DEFINE (scm_gnutls_set_default_export_priority_x,
return SCM_UNSPECIFIED;
}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_gnutls_set_session_priorities_x,
+ "set-session-priorities!", 2, 0, 0,
+ (SCM session, SCM priorities),
+ "Have @var{session} use the given @var{priorities} for "
+ "the ciphers, key exchange methods, MACs and compression "
+ "methods. @var{priorities} must be a string; see the "
+ "manual for the syntax. When @var{priorities} cannot be "
+ "parsed, an @code{error/invalid-request} error is raised, "
+ "with an extra argument indication the position of the "
+ "error.\n")
+#define FUNC_NAME s_scm_gnutls_set_session_priorities_x
+{
+ int err;
+ char *c_priorities;
+ const char *err_pos;
+ gnutls_session_t c_session;
+
+ c_session = scm_to_gnutls_session (session, 1, FUNC_NAME);
+ c_priorities = scm_to_locale_string (priorities); /* XXX: to_latin1_string */
+ err = gnutls_priority_set_direct (c_session, c_priorities, &err_pos);
+ free (c_priorities);
+
+ switch (err)
+ {
+ case GNUTLS_E_SUCCESS:
+ break;
+ case GNUTLS_E_INVALID_REQUEST:
+ {
+ size_t pos;
+ pos = err_pos - c_priorities;
+ scm_gnutls_error_with_args (err, FUNC_NAME,
+ scm_list_1 (scm_from_size_t (pos)));
+ break;
+ }
+ default:
+ scm_gnutls_error (err, FUNC_NAME);
+ }
+
+ return SCM_UNSPECIFIED;
+}
#undef FUNC_NAME
SCM_DEFINE (scm_gnutls_cipher_suite_to_string, "cipher-suite->string",
diff --git a/guile/src/errors.c b/guile/src/errors.c
index b2bbd8f826..987dd42113 100644
--- a/guile/src/errors.c
+++ b/guile/src/errors.c
@@ -1,5 +1,5 @@
/* GnuTLS --- Guile bindings for GnuTLS.
- Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
GnuTLS is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -30,7 +30,7 @@
SCM_SYMBOL (gnutls_error_key, "gnutls-error");
void
-scm_gnutls_error (int c_err, const char *c_func)
+scm_gnutls_error_with_args (int c_err, const char *c_func, SCM args)
{
SCM err, func;
@@ -38,13 +38,20 @@ scm_gnutls_error (int c_err, const char *c_func)
err = scm_from_gnutls_error (c_err);
func = scm_from_locale_symbol (c_func);
- (void) scm_throw (gnutls_error_key, scm_list_2 (err, func));
+ (void) scm_throw (gnutls_error_key, scm_cons2 (err, func, args));
/* XXX: This is actually never reached, but since the Guile headers don't
declare `scm_throw ()' as `noreturn', we must add this to avoid GCC's
complaints. */
abort ();
}
+
+void
+scm_gnutls_error (int c_err, const char *c_func)
+{
+ scm_gnutls_error_with_args (c_err, c_func, SCM_EOL);
+}
+
void
diff --git a/guile/src/errors.h b/guile/src/errors.h
index 337cdb6ed0..341807d04e 100644
--- a/guile/src/errors.h
+++ b/guile/src/errors.h
@@ -1,5 +1,5 @@
/* GnuTLS --- Guile bindings for GnuTLS.
- Copyright (C) 2007, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
GnuTLS is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -22,12 +22,12 @@
#include "utils.h"
-SCM_API void
-scm_gnutls_error (int, const char *)
+SCM_API void scm_gnutls_error_with_args (int, const char *, SCM)
NO_RETURN;
- SCM_API void scm_init_gnutls_error (void);
-#endif
+SCM_API void scm_gnutls_error (int, const char *)
+ NO_RETURN;
-/* arch-tag: e7a92e44-b399-4c85-99d4-2dd3564600f7
- */
+SCM_API void scm_init_gnutls_error (void);
+
+#endif