summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-01-15 10:24:17 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-01-15 10:24:17 +0100
commitb4c9200a7044104a668e8be17c4790c2072ff0a2 (patch)
tree5f719349dabd0802acf0c52407372ad6c60b1b91 /doc/examples
parent16fc2ccaa033bac1fe94f9de7b1444ea730d8e0e (diff)
downloadgnutls-b4c9200a7044104a668e8be17c4790c2072ff0a2.tar.gz
Introduced GNUTLS_DEFAULT_PRIORITY macro
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/ex-cert-select-pkcs11.c9
-rw-r--r--doc/examples/ex-cert-select.c9
-rw-r--r--doc/examples/ex-client-dtls.c9
-rw-r--r--doc/examples/ex-client-srp.c9
-rw-r--r--doc/examples/ex-client-x509.c9
-rw-r--r--doc/examples/ex-serv-anon.c8
-rw-r--r--doc/examples/ex-serv-pgp.c7
-rw-r--r--doc/examples/ex-serv-psk.c7
-rw-r--r--doc/examples/ex-serv-srp.c8
9 files changed, 32 insertions, 43 deletions
diff --git a/doc/examples/ex-cert-select-pkcs11.c b/doc/examples/ex-cert-select-pkcs11.c
index 2f623872c3..7d091b1791 100644
--- a/doc/examples/ex-cert-select-pkcs11.c
+++ b/doc/examples/ex-cert-select-pkcs11.c
@@ -19,10 +19,8 @@
#include <fcntl.h>
#include <getpass.h> /* for getpass() */
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
-# define DEFAULT_PRIORITY "NORMAL"
+#if GNUTLS_VERSION_NUMBER < 0x030300
+# define GNUTLS_DEFAULT_PRIORITY "NORMAL"
#endif
/* A TLS client that loads the certificate and key.
@@ -100,7 +98,8 @@ int main(void)
gnutls_certificate_allocate_credentials(&xcred);
/* priorities */
- gnutls_priority_init(&priorities_cache, DEFAULT_PRIORITY, NULL);
+ gnutls_priority_init(&priorities_cache,
+ GNUTLS_DEFAULT_PRIORITY, NULL);
/* sets the trusted cas file
*/
diff --git a/doc/examples/ex-cert-select.c b/doc/examples/ex-cert-select.c
index d5282b6ef5..5f12bb84a7 100644
--- a/doc/examples/ex-cert-select.c
+++ b/doc/examples/ex-cert-select.c
@@ -28,10 +28,8 @@
#define KEY_FILE "key.pem"
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
-# define DEFAULT_PRIORITY "NORMAL"
+#if GNUTLS_VERSION_NUMBER < 0x030300
+# define GNUTLS_DEFAULT_PRIORITY "NORMAL"
#endif
extern int tcp_connect(void);
@@ -112,7 +110,8 @@ int main(void)
gnutls_certificate_allocate_credentials(&xcred);
/* priorities */
- gnutls_priority_init(&priorities_cache, DEFAULT_PRIORITY, NULL);
+ gnutls_priority_init(&priorities_cache,
+ GNUTLS_DEFAULT_PRIORITY, NULL);
/* sets the trusted cas file
*/
diff --git a/doc/examples/ex-client-dtls.c b/doc/examples/ex-client-dtls.c
index 625b69badd..c625240679 100644
--- a/doc/examples/ex-client-dtls.c
+++ b/doc/examples/ex-client-dtls.c
@@ -14,10 +14,8 @@
#include <gnutls/gnutls.h>
#include <gnutls/dtls.h>
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
-# define DEFAULT_PRIORITY "NORMAL"
+#if GNUTLS_VERSION_NUMBER < 0x030300
+# define GNUTLS_DEFAULT_PRIORITY "NORMAL"
#endif
/* A very basic Datagram TLS client, over UDP with X.509 authentication.
@@ -59,7 +57,8 @@ int main(void)
gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
/* Use default priorities */
- ret = gnutls_priority_set_direct(session, DEFAULT_PRIORITY, &err);
+ ret = gnutls_priority_set_direct(session,
+ GNUTLS_DEFAULT_PRIORITY, &err);
if (ret < 0) {
if (ret == GNUTLS_E_INVALID_REQUEST) {
fprintf(stderr, "Syntax error at: %s\n", err);
diff --git a/doc/examples/ex-client-srp.c b/doc/examples/ex-client-srp.c
index ef065db008..dc3b51cbd5 100644
--- a/doc/examples/ex-client-srp.c
+++ b/doc/examples/ex-client-srp.c
@@ -9,10 +9,8 @@
#include <string.h>
#include <gnutls/gnutls.h>
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
-# define DEFAULT_PRIORITY "NORMAL"
+#if GNUTLS_VERSION_NUMBER < 0x030300
+# define GNUTLS_DEFAULT_PRIORITY "NORMAL"
#endif
/* Those functions are defined in other examples.
@@ -62,7 +60,8 @@ int main(void)
/* Set the priorities.
*/
gnutls_priority_set_direct(session,
- DEFAULT_PRIORITY":+SRP:+SRP-RSA:+SRP-DSS",
+ GNUTLS_DEFAULT_PRIORITY
+ ":+SRP:+SRP-RSA:+SRP-DSS",
NULL);
/* put the SRP credentials to the current session
diff --git a/doc/examples/ex-client-x509.c b/doc/examples/ex-client-x509.c
index 0dc9d880e1..2860a0c0cc 100644
--- a/doc/examples/ex-client-x509.c
+++ b/doc/examples/ex-client-x509.c
@@ -11,10 +11,8 @@
#include <gnutls/x509.h>
#include "examples.h"
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
-# define DEFAULT_PRIORITY "NORMAL"
+#if GNUTLS_VERSION_NUMBER < 0x030300
+# define GNUTLS_DEFAULT_PRIORITY "NORMAL"
#endif
/* A very basic TLS client, with X.509 authentication and server certificate
@@ -72,7 +70,8 @@ int main(void)
strlen("my_host_name"));
/* Use default priorities */
- ret = gnutls_priority_set_direct(session, DEFAULT_PRIORITY, &err);
+ ret = gnutls_priority_set_direct(session,
+ GNUTLS_DEFAULT_PRIORITY, &err);
if (ret < 0) {
if (ret == GNUTLS_E_INVALID_REQUEST) {
fprintf(stderr, "Syntax error at: %s\n", err);
diff --git a/doc/examples/ex-serv-anon.c b/doc/examples/ex-serv-anon.c
index 497a589024..6ebfbdf082 100644
--- a/doc/examples/ex-serv-anon.c
+++ b/doc/examples/ex-serv-anon.c
@@ -15,10 +15,8 @@
#include <unistd.h>
#include <gnutls/gnutls.h>
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
-# define DEFAULT_PRIORITY "NORMAL"
+#if GNUTLS_VERSION_NUMBER < 0x030300
+# define GNUTLS_DEFAULT_PRIORITY "NORMAL"
#endif
/* This is a sample TLS 1.0 echo server, for anonymous authentication only.
@@ -98,7 +96,7 @@ int main(void)
for (;;) {
gnutls_init(&session, GNUTLS_SERVER);
gnutls_priority_set_direct(session,
- DEFAULT_PRIORITY
+ GNUTLS_DEFAULT_PRIORITY
":+ANON-ECDH:+ANON-DH",
NULL);
gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
diff --git a/doc/examples/ex-serv-pgp.c b/doc/examples/ex-serv-pgp.c
index e0ba60be35..519c2a74f5 100644
--- a/doc/examples/ex-serv-pgp.c
+++ b/doc/examples/ex-serv-pgp.c
@@ -16,9 +16,7 @@
#include <gnutls/gnutls.h>
#include <gnutls/openpgp.h>
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
+#if GNUTLS_VERSION_NUMBER < 0x030300
# define DEFAULT_PRIORITY "NORMAL"
#endif
@@ -112,7 +110,8 @@ int main(void)
for (;;) {
gnutls_init(&session, GNUTLS_SERVER);
gnutls_priority_set_direct(session,
- DEFAULT_PRIORITY":+CTYPE-OPENPGP", NULL);
+ GNUTLS_DEFAULT_PRIORITY
+ ":+CTYPE-OPENPGP", NULL);
/* request client certificate if any.
*/
diff --git a/doc/examples/ex-serv-psk.c b/doc/examples/ex-serv-psk.c
index 809c49114d..0c4c93ed11 100644
--- a/doc/examples/ex-serv-psk.c
+++ b/doc/examples/ex-serv-psk.c
@@ -15,9 +15,7 @@
#include <unistd.h>
#include <gnutls/gnutls.h>
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
+#if GNUTLS_VERSION_NUMBER < 0x030300
# define DEFAULT_PRIORITY "NORMAL"
#endif
@@ -107,7 +105,8 @@ int main(void)
generate_dh_params();
gnutls_priority_init(&priority_cache,
- DEFAULT_PRIORITY":+PSK:+ECDHE-PSK:+DHE-PSK",
+ GNUTLS_DEFAULT_PRIORITY
+ ":+PSK:+ECDHE-PSK:+DHE-PSK",
NULL);
gnutls_certificate_set_dh_params(x509_cred, dh_params);
diff --git a/doc/examples/ex-serv-srp.c b/doc/examples/ex-serv-srp.c
index d8b3ac7c7f..3b2cd57021 100644
--- a/doc/examples/ex-serv-srp.c
+++ b/doc/examples/ex-serv-srp.c
@@ -15,10 +15,8 @@
#include <unistd.h>
#include <gnutls/gnutls.h>
-#if GNUTLS_VERSION_NUMBER >= 0x030300
-# define DEFAULT_PRIORITY "SYSTEM"
-#else
-# define DEFAULT_PRIORITY "NORMAL"
+#if GNUTLS_VERSION_NUMBER < 0x030300
+# define GNUTLS_DEFAULT_PRIORITY "NORMAL"
#endif
#define SRP_PASSWD "tpasswd"
@@ -96,7 +94,7 @@ int main(void)
for (;;) {
gnutls_init(&session, GNUTLS_SERVER);
gnutls_priority_set_direct(session,
- DEFAULT_PRIORITY
+ GNUTLS_DEFAULT_PRIORITY
":-KX-ALL:+SRP:+SRP-DSS:+SRP-RSA",
NULL);
gnutls_credentials_set(session, GNUTLS_CRD_SRP, srp_cred);