summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-11-08 22:14:07 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-11-08 22:17:10 +0100
commit76c93d23c073ef8b885503b7d28a31ffe2add6d8 (patch)
tree1dd2d22a197bc40c5330e516969a7cb1ae9bc96f /tests
parent559a144f6bbcbb611453f82e655dd7438c14d1a7 (diff)
downloadgnutls-76c93d23c073ef8b885503b7d28a31ffe2add6d8.tar.gz
reindented code
Diffstat (limited to 'tests')
-rw-r--r--tests/anonself.c429
-rw-r--r--tests/certder.c658
-rw-r--r--tests/certificate_set_x509_crl.c118
-rw-r--r--tests/certuniqueid.c370
-rw-r--r--tests/chainverify-unsorted.c1364
-rw-r--r--tests/chainverify.c299
-rw-r--r--tests/crq_apis.c354
-rw-r--r--tests/crq_key_id.c316
-rw-r--r--tests/cve-2008-4989.c396
-rw-r--r--tests/cve-2009-1415.c99
-rw-r--r--tests/cve-2009-1416.c54
-rw-r--r--tests/dhepskself.c420
-rw-r--r--tests/dn.c189
-rw-r--r--tests/dn2.c120
-rw-r--r--tests/dtls/dtls-stress.c840
-rw-r--r--tests/eagain-common.h191
-rw-r--r--tests/gc.c126
-rw-r--r--tests/hostname-check.c1557
-rw-r--r--tests/infoaccess.c385
-rw-r--r--tests/init_roundtrip.c25
-rw-r--r--tests/key-openssl.c172
-rw-r--r--tests/mini-alpn.c447
-rw-r--r--tests/mini-cert-status.c437
-rw-r--r--tests/mini-deflate.c179
-rw-r--r--tests/mini-dtls-heartbeat.c548
-rw-r--r--tests/mini-dtls-hello-verify.c528
-rw-r--r--tests/mini-dtls-large.c480
-rw-r--r--tests/mini-dtls-record.c607
-rw-r--r--tests/mini-dtls-rehandshake.c593
-rw-r--r--tests/mini-dtls-srtp.c536
-rw-r--r--tests/mini-eagain-dtls.c177
-rw-r--r--tests/mini-eagain.c155
-rw-r--r--tests/mini-emsgsize-dtls.c248
-rw-r--r--tests/mini-handshake-timeout.c323
-rw-r--r--tests/mini-loss-time.c389
-rw-r--r--tests/mini-overhead.c480
-rw-r--r--tests/mini-record-2.c564
-rw-r--r--tests/mini-record-range.c566
-rw-r--r--tests/mini-record.c589
-rw-r--r--tests/mini-rehandshake.c222
-rw-r--r--tests/mini-rsa-psk.c495
-rw-r--r--tests/mini-tdb.c270
-rw-r--r--tests/mini-termination.c467
-rw-r--r--tests/mini-x509-2.c250
-rw-r--r--tests/mini-x509-callbacks.c301
-rw-r--r--tests/mini-x509-cas.c214
-rw-r--r--tests/mini-x509.c186
-rw-r--r--tests/mini-xssl.c579
-rw-r--r--tests/moredn.c99
-rw-r--r--tests/mpi.c74
-rw-r--r--tests/nul-in-x509-names.c201
-rw-r--r--tests/ocsp.c2503
-rw-r--r--tests/openpgp-auth.c502
-rw-r--r--tests/openpgp-auth2.c407
-rw-r--r--tests/openpgp-keyring.c478
-rw-r--r--tests/openpgp_test.c249
-rw-r--r--tests/openpgpself.c1023
-rw-r--r--tests/openssl.c37
-rw-r--r--tests/parse_ca.c93
-rw-r--r--tests/pgps2kgnu.c123
-rw-r--r--tests/pkcs12_encode.c356
-rw-r--r--tests/pkcs12_s2k.c231
-rw-r--r--tests/pkcs12_s2k_pem.c96
-rw-r--r--tests/pkcs12_simple.c217
-rw-r--r--tests/priorities.c135
-rw-r--r--tests/pskself.c401
-rw-r--r--tests/record-sizes-range.c236
-rw-r--r--tests/record-sizes.c220
-rw-r--r--tests/resume-dtls.c915
-rw-r--r--tests/resume.c906
-rw-r--r--tests/rng-fork.c119
-rw-r--r--tests/rsa-encrypt-decrypt.c220
-rw-r--r--tests/safe-renegotiation/srn0.c242
-rw-r--r--tests/safe-renegotiation/srn1.c199
-rw-r--r--tests/safe-renegotiation/srn2.c343
-rw-r--r--tests/safe-renegotiation/srn3.c200
-rw-r--r--tests/safe-renegotiation/srn4.c247
-rw-r--r--tests/safe-renegotiation/srn5.c258
-rw-r--r--tests/set_pkcs12_cred.c154
-rw-r--r--tests/setcredcrash.c31
-rw-r--r--tests/simple.c118
-rw-r--r--tests/slow/cipher-test.c1155
-rw-r--r--tests/slow/gendh.c32
-rw-r--r--tests/slow/keygen.c99
-rw-r--r--tests/srp/mini-srp.c482
-rw-r--r--tests/suite/ecore/eina_config.h14
-rw-r--r--tests/suite/ecore/src/include/Eina.h5
-rw-r--r--tests/suite/ecore/src/include/eina_accessor.h61
-rw-r--r--tests/suite/ecore/src/include/eina_array.h80
-rw-r--r--tests/suite/ecore/src/include/eina_benchmark.h22
-rw-r--r--tests/suite/ecore/src/include/eina_binshare.h19
-rw-r--r--tests/suite/ecore/src/include/eina_config.h14
-rw-r--r--tests/suite/ecore/src/include/eina_convert.h21
-rw-r--r--tests/suite/ecore/src/include/eina_counter.h15
-rw-r--r--tests/suite/ecore/src/include/eina_cpu.h23
-rw-r--r--tests/suite/ecore/src/include/eina_error.h18
-rw-r--r--tests/suite/ecore/src/include/eina_file.h40
-rw-r--r--tests/suite/ecore/src/include/eina_fp.h103
-rw-r--r--tests/suite/ecore/src/include/eina_hamster.h2
-rw-r--r--tests/suite/ecore/src/include/eina_hash.h194
-rw-r--r--tests/suite/ecore/src/include/eina_inlist.h80
-rw-r--r--tests/suite/ecore/src/include/eina_iterator.h54
-rw-r--r--tests/suite/ecore/src/include/eina_lalloc.h21
-rw-r--r--tests/suite/ecore/src/include/eina_list.h166
-rw-r--r--tests/suite/ecore/src/include/eina_log.h186
-rw-r--r--tests/suite/ecore/src/include/eina_magic.h19
-rw-r--r--tests/suite/ecore/src/include/eina_main.h17
-rw-r--r--tests/suite/ecore/src/include/eina_matrixsparse.h82
-rw-r--r--tests/suite/ecore/src/include/eina_mempool.h40
-rw-r--r--tests/suite/ecore/src/include/eina_module.h69
-rw-r--r--tests/suite/ecore/src/include/eina_quadtree.h37
-rw-r--r--tests/suite/ecore/src/include/eina_rbtree.h62
-rw-r--r--tests/suite/ecore/src/include/eina_rectangle.h105
-rw-r--r--tests/suite/ecore/src/include/eina_safety_checks.h6
-rw-r--r--tests/suite/ecore/src/include/eina_sched.h2
-rw-r--r--tests/suite/ecore/src/include/eina_str.h65
-rw-r--r--tests/suite/ecore/src/include/eina_strbuf.h94
-rw-r--r--tests/suite/ecore/src/include/eina_stringshare.h38
-rw-r--r--tests/suite/ecore/src/include/eina_tiler.h48
-rw-r--r--tests/suite/ecore/src/include/eina_trash.h18
-rw-r--r--tests/suite/ecore/src/include/eina_types.h261
-rw-r--r--tests/suite/ecore/src/include/eina_unicode.h37
-rw-r--r--tests/suite/ecore/src/include/eina_ustrbuf.h71
-rw-r--r--tests/suite/ecore/src/include/eina_ustringshare.h33
-rw-r--r--tests/suite/ecore/src/lib/Ecore.h804
-rw-r--r--tests/suite/ecore/src/lib/Ecore_Getopt.h317
-rw-r--r--tests/suite/ecore/src/lib/ecore.c494
-rw-r--r--tests/suite/ecore/src/lib/ecore_anim.c270
-rw-r--r--tests/suite/ecore/src/lib/ecore_app.c48
-rw-r--r--tests/suite/ecore/src/lib/ecore_events.c879
-rw-r--r--tests/suite/ecore/src/lib/ecore_exe.c2507
-rw-r--r--tests/suite/ecore/src/lib/ecore_getopt.c2879
-rw-r--r--tests/suite/ecore/src/lib/ecore_glib.c364
-rw-r--r--tests/suite/ecore/src/lib/ecore_idle_enterer.c239
-rw-r--r--tests/suite/ecore/src/lib/ecore_idle_exiter.c211
-rw-r--r--tests/suite/ecore/src/lib/ecore_idler.c200
-rw-r--r--tests/suite/ecore/src/lib/ecore_job.c110
-rw-r--r--tests/suite/ecore/src/lib/ecore_main.c2054
-rw-r--r--tests/suite/ecore/src/lib/ecore_pipe.c557
-rw-r--r--tests/suite/ecore/src/lib/ecore_poll.c584
-rw-r--r--tests/suite/ecore/src/lib/ecore_private.h154
-rw-r--r--tests/suite/ecore/src/lib/ecore_signal.c942
-rw-r--r--tests/suite/ecore/src/lib/ecore_thread.c1485
-rw-r--r--tests/suite/ecore/src/lib/ecore_time.c106
-rw-r--r--tests/suite/ecore/src/lib/ecore_timer.c777
-rw-r--r--tests/suite/ecore/src/lib/eina_accessor.c121
-rw-r--r--tests/suite/ecore/src/lib/eina_array.c543
-rw-r--r--tests/suite/ecore/src/lib/eina_benchmark.c430
-rw-r--r--tests/suite/ecore/src/lib/eina_binshare.c53
-rw-r--r--tests/suite/ecore/src/lib/eina_chained_mempool.c422
-rw-r--r--tests/suite/ecore/src/lib/eina_convert.c595
-rw-r--r--tests/suite/ecore/src/lib/eina_counter.c368
-rw-r--r--tests/suite/ecore/src/lib/eina_cpu.c235
-rw-r--r--tests/suite/ecore/src/lib/eina_error.c201
-rw-r--r--tests/suite/ecore/src/lib/eina_file.c577
-rw-r--r--tests/suite/ecore/src/lib/eina_fp.c1002
-rw-r--r--tests/suite/ecore/src/lib/eina_hamster.c103
-rw-r--r--tests/suite/ecore/src/lib/eina_hash.c1855
-rw-r--r--tests/suite/ecore/src/lib/eina_inlist.c576
-rw-r--r--tests/suite/ecore/src/lib/eina_iterator.c124
-rw-r--r--tests/suite/ecore/src/lib/eina_lalloc.c158
-rw-r--r--tests/suite/ecore/src/lib/eina_list.c1879
-rw-r--r--tests/suite/ecore/src/lib/eina_log.c2408
-rw-r--r--tests/suite/ecore/src/lib/eina_magic.c311
-rw-r--r--tests/suite/ecore/src/lib/eina_main.c310
-rw-r--r--tests/suite/ecore/src/lib/eina_matrixsparse.c1967
-rw-r--r--tests/suite/ecore/src/lib/eina_mempool.c328
-rw-r--r--tests/suite/ecore/src/lib/eina_module.c648
-rw-r--r--tests/suite/ecore/src/lib/eina_private.h15
-rw-r--r--tests/suite/ecore/src/lib/eina_quadtree.c1346
-rw-r--r--tests/suite/ecore/src/lib/eina_rbtree.c797
-rw-r--r--tests/suite/ecore/src/lib/eina_rectangle.c678
-rw-r--r--tests/suite/ecore/src/lib/eina_safety_checks.c16
-rw-r--r--tests/suite/ecore/src/lib/eina_sched.c79
-rw-r--r--tests/suite/ecore/src/lib/eina_share_common.c1070
-rw-r--r--tests/suite/ecore/src/lib/eina_share_common.h44
-rw-r--r--tests/suite/ecore/src/lib/eina_str.c639
-rw-r--r--tests/suite/ecore/src/lib/eina_strbuf.c118
-rw-r--r--tests/suite/ecore/src/lib/eina_strbuf_common.c680
-rw-r--r--tests/suite/ecore/src/lib/eina_strbuf_common.h105
-rw-r--r--tests/suite/ecore/src/lib/eina_stringshare.c1106
-rw-r--r--tests/suite/ecore/src/lib/eina_tiler.c1860
-rw-r--r--tests/suite/ecore/src/lib/eina_unicode.c156
-rw-r--r--tests/suite/ecore/src/lib/eina_ustrbuf.c18
-rw-r--r--tests/suite/ecore/src/lib/eina_ustringshare.c78
-rw-r--r--tests/suite/ecore/src/lib/eina_value.c12
-rw-r--r--tests/suite/mini-eagain2.c304
-rw-r--r--tests/suite/mini-record-timing.c1103
-rw-r--r--tests/utils.c207
-rw-r--r--tests/utils.h27
-rw-r--r--tests/x509_altname.c161
-rw-r--r--tests/x509cert-tl.c448
-rw-r--r--tests/x509cert.c283
-rw-r--r--tests/x509dn.c748
-rw-r--r--tests/x509self.c719
-rw-r--r--tests/x509sign-verify.c441
196 files changed, 39559 insertions, 39849 deletions
diff --git a/tests/anonself.c b/tests/anonself.c
index 9cdaaf576c..ac6df9fa3e 100644
--- a/tests/anonself.c
+++ b/tests/anonself.c
@@ -33,10 +33,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -53,10 +52,9 @@ main (int argc, char** argv)
#include "utils.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
/* A very basic TLS client, with anonymous authentication.
@@ -65,93 +63,87 @@ tls_log_func (int level, const char *str)
#define MAX_BUF 1024
#define MSG "Hello TLS"
-static void
-client (int sd)
+static void client(int sd)
{
- int ret, ii;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug)
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
- close (sd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
-
- gnutls_global_deinit ();
+ int ret, ii;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ end:
+
+ close(sd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+
+ gnutls_global_deinit();
}
/* This is a sample TLS 1.0 echo server, for anonymous authentication only.
@@ -163,38 +155,39 @@ end:
/* These are global */
gnutls_anon_server_credentials_t anoncred;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
- gnutls_dh_set_prime_bits (session, DH_BITS);
+ gnutls_dh_set_prime_bits(session, DH_BITS);
- return session;
+ return session;
}
static gnutls_dh_params_t dh_params;
-static int
-generate_dh_params (void)
+static int generate_dh_params(void)
{
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- /* Generate Diffie-Hellman parameters - for use with DHE
- * kx algorithms. These should be discarded and regenerated
- * once a day, once a week or once a month. Depending on the
- * security requirements.
- */
- gnutls_dh_params_init (&dh_params);
- return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ /* Generate Diffie-Hellman parameters - for use with DHE
+ * kx algorithms. These should be discarded and regenerated
+ * once a day, once a week or once a month. Depending on the
+ * security requirements.
+ */
+ gnutls_dh_params_init(&dh_params);
+ return gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
}
int err, ret;
@@ -203,119 +196,109 @@ gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
-static void
-server (int sd)
+static void server(int sd)
{
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- if (debug)
- success ("Launched, generating DH parameters...\n");
-
- generate_dh_params ();
-
- gnutls_anon_set_server_dh_params (anoncred, dh_params);
-
- session = initialize_tls_session ();
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- return;
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ if (debug)
+ success("Launched, generating DH parameters...\n");
+
+ generate_dh_params();
+
+ gnutls_anon_set_server_dh_params(anoncred, dh_params);
+
+ session = initialize_tls_session();
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- pid_t child;
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (sockets[0]);
- wait (&status);
- }
- else
- client (sockets[1]);
+ pid_t child;
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(sockets[0]);
+ wait(&status);
+ } else
+ client(sockets[1]);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/certder.c b/tests/certder.c
index 9a902b03c2..a794991761 100644
--- a/tests/certder.c
+++ b/tests/certder.c
@@ -28,307 +28,389 @@
#include <gnutls/x509.h>
#include "utils.h"
-void
-doit (void)
+void doit(void)
{
- int ret;
- unsigned char der[] = {
- 0x30, 0x82, 0x04, 0x10, 0x30, 0x82, 0x03, 0x79,
- 0xa0, 0x07, 0x02, 0x84, 0x90, 0x00, 0x00, 0x00,
- 0x02, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09,
- 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
- 0x04, 0x05, 0x00, 0x30, 0x81, 0xbb, 0x31, 0x0b,
- 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
- 0x02, 0x2d, 0x2d, 0x31, 0x12, 0x30, 0x10, 0x06,
- 0x03, 0x55, 0x04, 0x08, 0x13, 0x09, 0x53, 0x6f,
- 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31,
- 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07,
- 0x13, 0x08, 0x53, 0x6f, 0x6d, 0x65, 0x43, 0x69,
- 0x74, 0x79, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03,
- 0x55, 0x04, 0x0a, 0x13, 0x10, 0x53, 0x6f, 0x6d,
- 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a,
- 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30,
- 0x1d, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16,
- 0x53, 0x6f, 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61,
- 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e,
- 0x61, 0x6c, 0x55, 0x6e, 0x69, 0x74, 0x31, 0x1e,
- 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
- 0x15, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f,
- 0x73, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x31, 0x29,
- 0x30, 0x27, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
- 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x1a, 0x72,
- 0x6f, 0x6f, 0x74, 0x40, 0x6c, 0x6f, 0x63, 0x61,
- 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x6c, 0x6f,
- 0x63, 0x61, 0x6c, 0x64, 0x6f, 0x6d, 0x61, 0x69,
- 0x6e, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x34, 0x30,
- 0x32, 0x31, 0x38, 0x32, 0x30, 0x30, 0x32, 0x33,
- 0x34, 0x5a, 0x17, 0x0d, 0x30, 0x35, 0x31, 0x31,
- 0x31, 0x37, 0x32, 0x30, 0x30, 0x32, 0x33, 0x34,
- 0x5a, 0x30, 0x81, 0xbb, 0x31, 0x0b, 0x30, 0x09,
- 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x2d,
- 0x2d, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55,
- 0x04, 0x08, 0x13, 0x09, 0x53, 0x6f, 0x6d, 0x65,
- 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x11, 0x30,
- 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x08,
- 0x53, 0x6f, 0x6d, 0x65, 0x43, 0x69, 0x74, 0x79,
- 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04,
- 0x0a, 0x13, 0x10, 0x53, 0x6f, 0x6d, 0x65, 0x4f,
- 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30, 0x1d, 0x06,
- 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16, 0x53, 0x6f,
- 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69,
- 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
- 0x55, 0x6e, 0x69, 0x74, 0x31, 0x1e, 0x30, 0x1c,
- 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x15, 0x6c,
- 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
- 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x64, 0x6f,
- 0x6d, 0x61, 0x69, 0x6e, 0x31, 0x29, 0x30, 0x27,
- 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
- 0x01, 0x09, 0x01, 0x16, 0x1a, 0x72, 0x6f, 0x6f,
- 0x74, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68,
- 0x6f, 0x73, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61,
- 0x6c, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x30,
- 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
- 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
- 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89,
- 0x02, 0x81, 0x81, 0x00, 0xda, 0x3d, 0xb7, 0x66,
- 0x9a, 0x41, 0x4f, 0xca, 0x1d, 0xd1, 0xc4, 0x1f,
- 0xc9, 0x4c, 0xc6, 0x76, 0x45, 0xc5, 0x8e, 0x2f,
- 0x3d, 0x45, 0xf5, 0x16, 0x9f, 0xb5, 0x22, 0x0b,
- 0x61, 0x60, 0xa4, 0x42, 0x42, 0x98, 0xae, 0x45,
- 0xe1, 0x4a, 0x17, 0x0b, 0x6e, 0xf7, 0x4e, 0xc0,
- 0x1e, 0xe7, 0x78, 0xd0, 0x80, 0xfc, 0xde, 0x0a,
- 0x96, 0x43, 0x13, 0xe4, 0xb5, 0xef, 0x47, 0xca,
- 0x8f, 0xb3, 0x13, 0x92, 0x10,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,
- 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x11,
- 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13,
- 0x08, 0x53, 0x6f, 0x6d, 0x65, 0x43, 0x69, 0x74,
- 0x79, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55,
- 0x04, 0x0a, 0x13, 0x10, 0x53, 0x6f, 0x6d, 0x65,
- 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61,
- 0x74, 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30, 0x1d,
- 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16, 0x53,
- 0x6f, 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e,
- 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61,
- 0x6c, 0x55, 0x6e, 0x69, 0x74, 0x31, 0x1e, 0x30,
- 0x1c, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x15,
- 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73,
- 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x64,
- 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x31, 0x29, 0x30,
- 0x27, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
- 0x0d, 0x01, 0x09, 0x01, 0x16, 0x1a, 0x72, 0x6f,
- 0x6f, 0x74, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x6c, 0x6f, 0x63,
- 0x61, 0x6c, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e,
- 0x82, 0x01, 0x00, 0x30, 0x0c, 0x06, 0x03, 0x55,
- 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01,
- 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
- 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x04, 0x05, 0x00,
- 0x03, 0x81, 0x81, 0x00, 0xcd, 0xc9, 0x30, 0x6d,
- 0x02, 0x65, 0x41, 0xea, 0x0e, 0x46, 0x08, 0x6c,
- 0x2f, 0xd5, 0xa7, 0xe4, 0x29, 0xd7, 0x3f, 0x18,
- 0x16, 0xd7, 0x4b, 0x6f, 0x9d, 0xc0, 0x5b, 0xbf,
- 0x68, 0x7b, 0x2e, 0x66, 0xa5, 0x1b, 0xfd, 0xff,
- 0x09, 0x25, 0xa5, 0x56, 0x37, 0x41, 0xd8, 0xaf,
- 0x07, 0xa6, 0x12, 0xa8, 0x58, 0xc4, 0x42, 0x9c,
- 0xce, 0x90, 0x6a, 0x9e, 0x7e, 0x04, 0x27, 0xe3,
- 0xfa, 0x8e, 0xe5, 0xdc, 0xa8, 0x5a, 0xf7, 0xc9,
- 0x0d, 0x23, 0x56, 0x8e, 0x46, 0x84, 0xe8, 0x34,
- 0x83, 0x86, 0xca, 0xc1, 0xcd, 0xfe, 0x68, 0x00,
- 0x67, 0x3f, 0x24, 0x3b, 0x50, 0x63, 0x21, 0x7f,
- 0xba, 0xc6, 0xdb, 0xff, 0xf4, 0x3a, 0x10, 0xb6,
- 0xb5, 0x09, 0x4d, 0x41, 0xff, 0xef, 0xc0, 0x84,
- 0x48, 0x1b, 0x51, 0x87, 0xe6, 0x85, 0xf0, 0x1e,
- 0xbd, 0x99, 0x0d, 0xd3, 0x98, 0xd0, 0xab, 0xd8,
- 0x30, 0x2a, 0xd5, 0x74
- };
+ int ret;
+ unsigned char der[] = {
+ 0x30, 0x82, 0x04, 0x10, 0x30, 0x82, 0x03, 0x79,
+ 0xa0, 0x07, 0x02, 0x84, 0x90, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
+ 0x04, 0x05, 0x00, 0x30, 0x81, 0xbb, 0x31, 0x0b,
+ 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
+ 0x02, 0x2d, 0x2d, 0x31, 0x12, 0x30, 0x10, 0x06,
+ 0x03, 0x55, 0x04, 0x08, 0x13, 0x09, 0x53, 0x6f,
+ 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31,
+ 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07,
+ 0x13, 0x08, 0x53, 0x6f, 0x6d, 0x65, 0x43, 0x69,
+ 0x74, 0x79, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03,
+ 0x55, 0x04, 0x0a, 0x13, 0x10, 0x53, 0x6f, 0x6d,
+ 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a,
+ 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30,
+ 0x1d, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16,
+ 0x53, 0x6f, 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61,
+ 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x61, 0x6c, 0x55, 0x6e, 0x69, 0x74, 0x31, 0x1e,
+ 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
+ 0x15, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f,
+ 0x73, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x31, 0x29,
+ 0x30, 0x27, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x1a, 0x72,
+ 0x6f, 0x6f, 0x74, 0x40, 0x6c, 0x6f, 0x63, 0x61,
+ 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x6c, 0x6f,
+ 0x63, 0x61, 0x6c, 0x64, 0x6f, 0x6d, 0x61, 0x69,
+ 0x6e, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x34, 0x30,
+ 0x32, 0x31, 0x38, 0x32, 0x30, 0x30, 0x32, 0x33,
+ 0x34, 0x5a, 0x17, 0x0d, 0x30, 0x35, 0x31, 0x31,
+ 0x31, 0x37, 0x32, 0x30, 0x30, 0x32, 0x33, 0x34,
+ 0x5a, 0x30, 0x81, 0xbb, 0x31, 0x0b, 0x30, 0x09,
+ 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x2d,
+ 0x2d, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55,
+ 0x04, 0x08, 0x13, 0x09, 0x53, 0x6f, 0x6d, 0x65,
+ 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x11, 0x30,
+ 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x08,
+ 0x53, 0x6f, 0x6d, 0x65, 0x43, 0x69, 0x74, 0x79,
+ 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04,
+ 0x0a, 0x13, 0x10, 0x53, 0x6f, 0x6d, 0x65, 0x4f,
+ 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30, 0x1d, 0x06,
+ 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16, 0x53, 0x6f,
+ 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69,
+ 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
+ 0x55, 0x6e, 0x69, 0x74, 0x31, 0x1e, 0x30, 0x1c,
+ 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x15, 0x6c,
+ 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
+ 0x2e, 0x6c, 0x6f, 0x63, 0x61,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,
- 0x3, 0x55, 0x4, 0x8, 0x13, 0x9, 0x53,
- 0x6f, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74,
- 0x65, 0x31, 0x11, 0x30, 0xf, 0x6, 0x3,
- 0x55, 0x4, 0x7, 0x13, 0x8, 0x53, 0x6f,
- 0x6d, 0x65, 0x43, 0x69, 0x74, 0x79,
- 0x31, 0x19, 0x30, 0x17, 0x6, 0x3, 0x55,
- 0x4, 0xa, 0x13, 0x10, 0x53, 0x6f, 0x6d,
- 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69,
- 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x31,
- 0x1f, 0x30, 0x1d, 0x6, 0x3, 0x55, 0x4, 0xb,
- 0x13, 0x16, 0x53, 0x6f, 0x6d, 0x65, 0x4f,
- 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61,
- 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x55,
- 0x6e, 0x69, 0x74, 0x31, 0x1e, 0x30, 0x1c,
- 0x6, 0x3, 0x55, 0x4, 0x3, 0x13, 0x15, 0x6c,
- 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73,
- 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x31,
- 0x29, 0x30, 0x27, 0x6, 0x9, 0x2a, 0x86,
- 0x48, 0x86, 0xf7, 0xd, 0x1, 0x9, 0x1, 0x16,
- 0x1a, 0x72
- };
+ /* Triggers crash in _asn1_get_objectid_der. */
+ unsigned char der2[] = {
+ 0x30, 0x82, 0x04, 0x10, 0x30, 0x82, 0x03, 0x79,
+ 0xa0, 0x3, 0x2, 0x1, 0x2, 0x2, 0x1, 0x0, 0x30,
+ 0x11, 0x6, 0x84, 0x10, 0x0, 0x0, 0x0, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0xd, 0x1, 0x1, 0x4,
+ 0x5, 0x0, 0x30, 0x81, 0xbb, 0x31, 0xb, 0x30,
+ 0x9, 0x6, 0x3, 0x55, 0x4, 0x6, 0x13, 0x2,
+ 0x2d, 0x2d, 0x31, 0x12, 0x30, 0x10, 0x6,
+ 0x3, 0x55, 0x4, 0x8, 0x13, 0x9, 0x53,
+ 0x6f, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74,
+ 0x65, 0x31, 0x11, 0x30, 0xf, 0x6, 0x3,
+ 0x55, 0x4, 0x7, 0x13, 0x8, 0x53, 0x6f,
+ 0x6d, 0x65, 0x43, 0x69, 0x74, 0x79,
+ 0x31, 0x19, 0x30, 0x17, 0x6, 0x3, 0x55,
+ 0x4, 0xa, 0x13, 0x10, 0x53, 0x6f, 0x6d,
+ 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69,
+ 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x31,
+ 0x1f, 0x30, 0x1d, 0x6, 0x3, 0x55, 0x4, 0xb,
+ 0x13, 0x16, 0x53, 0x6f, 0x6d, 0x65, 0x4f,
+ 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x55,
+ 0x6e, 0x69, 0x74, 0x31, 0x1e, 0x30, 0x1c,
+ 0x6, 0x3, 0x55, 0x4, 0x3, 0x13, 0x15, 0x6c,
+ 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73,
+ 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x31,
+ 0x29, 0x30, 0x27, 0x6, 0x9, 0x2a, 0x86,
+ 0x48, 0x86, 0xf7, 0xd, 0x1, 0x9, 0x1, 0x16,
+ 0x1a, 0x72
+ };
- /* Triggers crash in asn1_der_decoding. */
- unsigned char der3[] = {
- 0x30, 0x82, 0x4, 0x10, 0x30, 0x82, 0x3, 0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0x16,
- 0x1a, 0x72, 0x6f, 0x6f, 0x74, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68,
- 0x6f, 0x73, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x64, 0x6f, 0x6d,
- 0x61, 0x69, 0x6e, 0x30, 0x1e, 0x17, 0xd, 0x30, 0x34, 0x30, 0x32, 0x31,
- 0x38, 0x32, 0x30, 0x30, 0x32, 0x33, 0x34, 0x5a, 0x17, 0xd, 0x30, 0x35,
- 0x31, 0x31, 0x31, 0x37, 0x32, 0x30, 0x30, 0x32, 0x33, 0x34, 0x5a, 0x30,
- 0x81, 0xbb, 0x31, 0xb, 0x30, 0x9, 0x6, 0x3, 0x55, 0x4, 0x6, 0x13, 0x2,
- 0x2d, 0x2d, 0x31, 0x12, 0x30, 0x10, 0x6, 0x3, 0x55, 0x4, 0x8, 0x13, 0x9,
- 0x53, 0x6f, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x11, 0x30,
- 0xf, 0x6, 0x3, 0x55, 0x4, 0x7, 0x13, 0x8, 0x53, 0x6f, 0x6d, 0x65, 0x43,
- 0x69, 0x74, 0x79, 0x31, 0x19, 0x30, 0x17, 0x6, 0x3, 0x55, 0x4, 0xa,
- 0x13, 0x10, 0x53, 0x6f, 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69,
- 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30, 0x1d, 0x6, 0x3,
- 0x55, 0x4, 0xb, 0x13, 0x16, 0x53, 0x6f, 0x6d, 0x65, 0x4f, 0x72, 0x67,
- 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x55,
- 0x6e, 0x69, 0x74, 0x31, 0x1e, 0x30, 0x1c, 0x6, 0x3, 0x55, 0x4, 0x3,
- 0x13, 0x15, 0x6c, 0x6f, 0x63, 0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d, 0xc0, 0x5b,
- 0xbf, 0x68, 0x7b, 0x2e, 0x66, 0xa5, 0x1b, 0xfd, 0xff, 0x9, 0x25, 0xa5,
- 0x56, 0x37, 0x41, 0xd8, 0xaf, 0x7, 0xa6, 0x12, 0xa8, 0x58, 0xc4, 0x42,
- 0x9c, 0xce, 0x90, 0x6a, 0x9e, 0x7e, 0x4, 0x27, 0xe3, 0xfa, 0x8e, 0xe5,
- 0xdc, 0xa8, 0x5a, 0xf7, 0xc9, 0xd, 0x23, 0x56, 0x8e, 0x46, 0x84, 0xe8,
- 0x34, 0x83, 0x86, 0xca, 0xc1, 0xcd, 0xfe, 0x68, 0x0, 0x67, 0x3f, 0x24,
- 0x3b, 0x50, 0x63, 0x21, 0x7f, 0xba, 0xc6, 0xdb, 0xff, 0xf4, 0x3a, 0x10,
- 0xb6, 0xb5, 0x9, 0x4d, 0x41, 0xff, 0xef, 0xc0, 0x84, 0x48, 0x1b, 0x51,
- 0x87, 0xe6, 0x85, 0xf0, 0x1e, 0xbd, 0x99, 0xd, 0xd3, 0x98, 0xd0, 0xab,
- 0xd8, 0x30, 0x2a, 0xd5, 0x74
- };
- gnutls_datum_t derCert = { der, sizeof (der) };
- gnutls_datum_t der2Cert = { der2, sizeof (der2) };
- gnutls_datum_t der3Cert = { der3, sizeof (der3) };
- gnutls_x509_crt_t cert;
+ /* Triggers crash in asn1_der_decoding. */
+ unsigned char der3[] = {
+ 0x30, 0x82, 0x4, 0x10, 0x30, 0x82, 0x3, 0x79,
+ 0xa0, 0x3, 0x2, 0x1, 0x2, 0x2, 0x1, 0x0,
+ 0x30, 0x11, 0x6, 0x9, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0xd,
+ 0x1, 0x1, 0x4, 0x5, 0x84, 0x10, 0x0, 0x0, 0x0, 0x30, 0x81,
+ 0xbb, 0x31,
+ 0xb, 0x30, 0x9, 0x6, 0x3, 0x55, 0x4, 0x6, 0x13, 0x2, 0x2d,
+ 0x2d, 0x31,
+ 0x12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, 0xd7, 0x3f, 0x18, 0x16, 0xd7, 0x4b, 0x6f, 0x9d,
+ 0xc0, 0x5b,
+ 0xbf, 0x68, 0x7b, 0x2e, 0x66, 0xa5, 0x1b, 0xfd, 0xff, 0x9,
+ 0x25, 0xa5,
+ 0x56, 0x37, 0x41, 0xd8, 0xaf, 0x7, 0xa6, 0x12, 0xa8, 0x58,
+ 0xc4, 0x42,
+ 0x9c, 0xce, 0x90, 0x6a, 0x9e, 0x7e, 0x4, 0x27, 0xe3, 0xfa,
+ 0x8e, 0xe5,
+ 0xdc, 0xa8, 0x5a, 0xf7, 0xc9, 0xd, 0x23, 0x56, 0x8e, 0x46,
+ 0x84, 0xe8,
+ 0x34, 0x83, 0x86, 0xca, 0xc1, 0xcd, 0xfe, 0x68, 0x0, 0x67,
+ 0x3f, 0x24,
+ 0x3b, 0x50, 0x63, 0x21, 0x7f, 0xba, 0xc6, 0xdb, 0xff, 0xf4,
+ 0x3a, 0x10,
+ 0xb6, 0xb5, 0x9, 0x4d, 0x41, 0xff, 0xef, 0xc0, 0x84, 0x48,
+ 0x1b, 0x51,
+ 0x87, 0xe6, 0x85, 0xf0, 0x1e, 0xbd, 0x99, 0xd, 0xd3, 0x98,
+ 0xd0, 0xab,
+ 0xd8, 0x30, 0x2a, 0xd5, 0x74
+ };
+ gnutls_datum_t derCert = { der, sizeof(der) };
+ gnutls_datum_t der2Cert = { der2, sizeof(der2) };
+ gnutls_datum_t der3Cert = { der3, sizeof(der3) };
+ gnutls_x509_crt_t cert;
- ret = global_init ();
- if (ret < 0)
- fail ("init %d\n", ret);
+ ret = global_init();
+ if (ret < 0)
+ fail("init %d\n", ret);
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- fail ("crt_init %d\n", ret);
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0)
+ fail("crt_init %d\n", ret);
- ret = gnutls_x509_crt_import (cert, &derCert, GNUTLS_X509_FMT_DER);
- if (ret != GNUTLS_E_ASN1_DER_ERROR)
- fail ("crt_import %d\n", ret);
+ ret = gnutls_x509_crt_import(cert, &derCert, GNUTLS_X509_FMT_DER);
+ if (ret != GNUTLS_E_ASN1_DER_ERROR)
+ fail("crt_import %d\n", ret);
- gnutls_x509_crt_deinit (cert);
+ gnutls_x509_crt_deinit(cert);
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- fail ("crt_init %d\n", ret);
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0)
+ fail("crt_init %d\n", ret);
- ret = gnutls_x509_crt_import (cert, &der2Cert, GNUTLS_X509_FMT_DER);
- if (ret != GNUTLS_E_ASN1_DER_ERROR)
- fail ("crt2_import %d\n", ret);
+ ret = gnutls_x509_crt_import(cert, &der2Cert, GNUTLS_X509_FMT_DER);
+ if (ret != GNUTLS_E_ASN1_DER_ERROR)
+ fail("crt2_import %d\n", ret);
- gnutls_x509_crt_deinit (cert);
+ gnutls_x509_crt_deinit(cert);
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- fail ("crt_init %d\n", ret);
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0)
+ fail("crt_init %d\n", ret);
- ret = gnutls_x509_crt_import (cert, &der3Cert, GNUTLS_X509_FMT_DER);
- if (ret != GNUTLS_E_ASN1_DER_ERROR)
- fail ("crt3_import %d\n", ret);
+ ret = gnutls_x509_crt_import(cert, &der3Cert, GNUTLS_X509_FMT_DER);
+ if (ret != GNUTLS_E_ASN1_DER_ERROR)
+ fail("crt3_import %d\n", ret);
- if (debug)
- success ("done\n");
+ if (debug)
+ success("done\n");
- gnutls_x509_crt_deinit (cert);
+ gnutls_x509_crt_deinit(cert);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
diff --git a/tests/certificate_set_x509_crl.c b/tests/certificate_set_x509_crl.c
index 5e76e79706..7aa19581cc 100644
--- a/tests/certificate_set_x509_crl.c
+++ b/tests/certificate_set_x509_crl.c
@@ -33,81 +33,77 @@
#include <gnutls/x509.h>
static char crl[] =
- "-----B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EgTm90IFZhbGlkYXRlZDEm\n"
+ "MCQGA1UECxMdRGlnaXRhbCBJRCBDbGFzcyAxIC0gTmV0c2NhcGUxGDAWBgNVBAMU\n"
+ "D1NpbW9uIEpvc2Vmc3NvbjEiMCAGCSqGSIb3DQEJARYTc2ltb25Aam9zZWZzc29u\n"
+ "Lm9yZxcNMDYxMjI3MDgwMjM0WhcNMDcwMjA3MDgwMjM1WjAjMCECEC4QNwPfRoWd\n"
+ "elUNpllhhTgXDTA2MTIyNzA4MDIzNFowCwYJKoZIhvcNAQEFA4GBAD0zX+J2hkcc\n"
+ "Nbrq1Dn5IKL8nXLgPGcHv1I/le1MNo9t1ohGQxB5HnFUkRPAY82fR6Epor4aHgVy\n"
+ "b+5y+neKN9Kn2mPF4iiun+a4o26CjJ0pArojCL1p8T0yyi9Xxvyc/ezaZ98HiIyP\n"
+ "c3DGMNR+oUmSjKZ0jIhAYmeLxaPHfQwR\n" "-----END X509 CRL-----\n";
/* Test regression of bug reported by Max Kellermann <max@duempel.org>
in Message-ID: <20061211075202.GA1517@roonstrasse.net> to the
gnutls-dev@gnupg.org list. */
-int
-main (void)
+int main(void)
{
- int rc;
- gnutls_certificate_credentials_t crt;
- gnutls_datum_t crldatum = { (uint8_t*)crl, strlen (crl) };
- gnutls_x509_crl_t crl;
+ int rc;
+ gnutls_certificate_credentials_t crt;
+ gnutls_datum_t crldatum = { (uint8_t *) crl, strlen(crl) };
+ gnutls_x509_crl_t crl;
- rc = global_init ();
- if (rc)
- {
- printf ("global_init rc %d: %s\n", rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = global_init();
+ if (rc) {
+ printf("global_init rc %d: %s\n", rc, gnutls_strerror(rc));
+ return 1;
+ }
- rc = gnutls_certificate_allocate_credentials (&crt);
- if (rc)
- {
- printf ("gnutls_certificate_allocate_credentials rc %d: %s\n",
- rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = gnutls_certificate_allocate_credentials(&crt);
+ if (rc) {
+ printf
+ ("gnutls_certificate_allocate_credentials rc %d: %s\n",
+ rc, gnutls_strerror(rc));
+ return 1;
+ }
- rc = gnutls_certificate_set_x509_crl_mem (crt, &crldatum,
- GNUTLS_X509_FMT_PEM);
- if (rc != 1)
- {
- printf ("gnutls_certificate_set_x509_crl_mem num %d\n", rc);
- return 1;
- }
+ rc = gnutls_certificate_set_x509_crl_mem(crt, &crldatum,
+ GNUTLS_X509_FMT_PEM);
+ if (rc != 1) {
+ printf("gnutls_certificate_set_x509_crl_mem num %d\n", rc);
+ return 1;
+ }
- rc = gnutls_x509_crl_init (&crl);
- if (rc)
- {
- printf ("gnutls_x509_crl_init rc %d: %s\n", rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = gnutls_x509_crl_init(&crl);
+ if (rc) {
+ printf("gnutls_x509_crl_init rc %d: %s\n", rc,
+ gnutls_strerror(rc));
+ return 1;
+ }
- rc = gnutls_x509_crl_import (crl, &crldatum, GNUTLS_X509_FMT_PEM);
- if (rc)
- {
- printf ("gnutls_x509_crl_import rc %d: %s\n", rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = gnutls_x509_crl_import(crl, &crldatum, GNUTLS_X509_FMT_PEM);
+ if (rc) {
+ printf("gnutls_x509_crl_import rc %d: %s\n", rc,
+ gnutls_strerror(rc));
+ return 1;
+ }
- rc = gnutls_certificate_set_x509_crl (crt, &crl, 1);
- if (rc < 0)
- {
- printf ("gnutls_certificate_set_x509_crl rc %d: %s\n",
- rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = gnutls_certificate_set_x509_crl(crt, &crl, 1);
+ if (rc < 0) {
+ printf("gnutls_certificate_set_x509_crl rc %d: %s\n",
+ rc, gnutls_strerror(rc));
+ return 1;
+ }
- gnutls_x509_crl_deinit (crl);
+ gnutls_x509_crl_deinit(crl);
- gnutls_certificate_free_credentials (crt);
+ gnutls_certificate_free_credentials(crt);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- return 0;
+ return 0;
}
diff --git a/tests/certuniqueid.c b/tests/certuniqueid.c
index 536ab0f849..38fc9b37f0 100644
--- a/tests/certuniqueid.c
+++ b/tests/certuniqueid.c
@@ -30,164 +30,216 @@
#include "gnutls/x509.h"
#include "utils.h"
-void
-doit (void)
+void doit(void)
{
- int ret;
- unsigned char der[] = {
- 0x30, 0x82, 0x03, 0x00, 0x30, 0x82, 0x01, 0xec, 0xa0, 0x03, 0x02, 0x01,
- 0x02, 0x02, 0x10, 0xbd,
- 0x76, 0xdf, 0x42, 0x47, 0x0a, 0x00, 0x8d, 0x47, 0x3e, 0x74, 0x3f, 0xa1,
- 0xdc, 0x8b, 0xbd, 0x30,
- 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1d, 0x05, 0x00, 0x30, 0x2d,
- 0x31, 0x2b, 0x30, 0x29,
- 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x22, 0x77, 0x00, 0x32, 0x00, 0x6b,
- 0x00, 0x38, 0x00, 0x72,
- 0x00, 0x32, 0x00, 0x2e, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x74, 0x00, 0x77,
- 0x00, 0x73, 0x00, 0x2e,
- 0x00, 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x00, 0x00, 0x30, 0x1e, 0x17,
- 0x0d, 0x31, 0x30, 0x30,
- 0x34, 0x32, 0x38, 0x31, 0x31, 0x34, 0x31, 0x35, 0x34, 0x5a, 0x17, 0x0d,
- 0x31, 0x31, 0x30, 0x34,
- 0x32, 0x38, 0x31, 0x31, 0x34, 0x31, 0x35, 0x34, 0x5a, 0x30, 0x2d, 0x31,
- 0x2b, 0x30, 0x29, 0x06,
- 0x03, 0x55, 0x04, 0x03, 0x13, 0x22, 0x77, 0x00, 0x32, 0x00, 0x6b, 0x00,
- 0x38, 0x00, 0x72, 0x00,
- 0x32, 0x00, 0x2e, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x74, 0x00, 0x77, 0x00,
- 0x73, 0x00, 0x2e, 0x00,
- 0x6e, 0x00, 0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0xe5, 0x46, 0xd4,
- 0x1c, 0x83, 0xa1, 0x28,
- 0x79, 0x76, 0x81, 0x48, 0x38, 0x72, 0xbc, 0x3f, 0x25, 0x53, 0x31, 0xaa,
- 0x02, 0xd1, 0x9b, 0x03,
- 0xa2, 0x5c, 0x94, 0x21, 0xb3, 0x8e, 0xdf, 0x2a, 0xa5, 0x4c, 0x65, 0xa2,
- 0xf9, 0xac, 0x38, 0x7a,
- 0xf9, 0x45, 0xb3, 0xd5, 0xda, 0xe5, 0xb9, 0x56, 0x9e, 0x47, 0xd5, 0x06,
- 0xe6, 0xca, 0xd7, 0x6e,
- 0x06, 0xdb, 0x6e, 0xa7, 0x7b, 0x4b, 0x13, 0x40, 0x3c, 0x12, 0x76, 0x99,
- 0x65, 0xb4, 0x54, 0xa1,
- 0xd8, 0x21, 0x5c, 0x27
- };
-
- gnutls_datum_t derCert = { der, sizeof (der) };
-
- gnutls_x509_crt_t cert;
-
- int result;
- unsigned char expectedId[] =
- { 0xbd, 0x8b, 0xdc, 0xa1, 0x3f, 0x74, 0x3e, 0x47, 0x8d, 0x00, 0x0a, 0x47,
- 0x42, 0xdf, 0x76, 0xbd
- };
-
- char buf[17];
- size_t buf_size;
-
- ret = global_init ();
- if (ret < 0)
- fail ("init %d\n", ret);
-
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- fail ("crt_init %d\n", ret);
-
- ret = gnutls_x509_crt_import (cert, &derCert, GNUTLS_X509_FMT_DER);
- if (ret < 0)
- fail ("crt_import %d\n", ret);
-
- buf_size = 15;
- result = gnutls_x509_crt_get_issuer_unique_id (cert, buf, &buf_size);
- if (result != GNUTLS_E_SHORT_MEMORY_BUFFER)
- fail ("get_issuer_unique_id short error %d\n", result);
- if (buf_size != 16)
- fail ("get_issuer_unique_id buf size %zd\n", buf_size);
-
- buf_size = 16;
- result = gnutls_x509_crt_get_issuer_unique_id (cert, buf, &buf_size);
- if (result < 0)
- fail ("get_issuer_unique_id %d\n", result);
- if (memcmp (buf, expectedId, buf_size) != 0)
- fail ("expected id mismatch for issuer\n");
-
- buf_size = 15;
- result = gnutls_x509_crt_get_subject_unique_id (cert, buf, &buf_size);
- if (result != GNUTLS_E_SHORT_MEMORY_BUFFER)
- fail ("get_subject_unique_id short error %d\n", result);
- if (buf_size != 16)
- fail ("get_subject_unique_id buf size %zd\n", buf_size);
-
- buf_size = 16;
- result = gnutls_x509_crt_get_subject_unique_id (cert, buf, &buf_size);
- if (result < 0)
- fail ("get_subject_unique_id %d\n", result);
- if (memcmp (buf, expectedId, buf_size) != 0)
- fail ("expected id mismatch for subject\n");
-
- gnutls_x509_crt_deinit (cert);
-
- gnutls_global_deinit ();
+ int ret;
+ unsigned char der[] = {
+ 0x30, 0x82, 0x03, 0x00, 0x30, 0x82, 0x01, 0xec, 0xa0, 0x03,
+ 0x02, 0x01,
+ 0x02, 0x02, 0x10, 0xbd,
+ 0x76, 0xdf, 0x42, 0x47, 0x0a, 0x00, 0x8d, 0x47, 0x3e, 0x74,
+ 0x3f, 0xa1,
+ 0xdc, 0x8b, 0xbd, 0x30,
+ 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1d, 0x05, 0x00,
+ 0x30, 0x2d,
+ 0x31, 0x2b, 0x30, 0x29,
+ 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x22, 0x77, 0x00, 0x32,
+ 0x00, 0x6b,
+ 0x00, 0x38, 0x00, 0x72,
+ 0x00, 0x32, 0x00, 0x2e, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x74,
+ 0x00, 0x77,
+ 0x00, 0x73, 0x00, 0x2e,
+ 0x00, 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x00, 0x00, 0x30,
+ 0x1e, 0x17,
+ 0x0d, 0x31, 0x30, 0x30,
+ 0x34, 0x32, 0x38, 0x31, 0x31, 0x34, 0x31, 0x35, 0x34, 0x5a,
+ 0x17, 0x0d,
+ 0x31, 0x31, 0x30, 0x34,
+ 0x32, 0x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0x47, 0x8d, 0x00,
+0x0a, 0x47,
+ 0x42, 0xdf, 0x76, 0xbd
+ };
+
+ char buf[17];
+ size_t buf_size;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("init %d\n", ret);
+
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0)
+ fail("crt_init %d\n", ret);
+
+ ret = gnutls_x509_crt_import(cert, &derCert, GNUTLS_X509_FMT_DER);
+ if (ret < 0)
+ fail("crt_import %d\n", ret);
+
+ buf_size = 15;
+ result =
+ gnutls_x509_crt_get_issuer_unique_id(cert, buf, &buf_size);
+ if (result != GNUTLS_E_SHORT_MEMORY_BUFFER)
+ fail("get_issuer_unique_id short error %d\n", result);
+ if (buf_size != 16)
+ fail("get_issuer_unique_id buf size %zd\n", buf_size);
+
+ buf_size = 16;
+ result =
+ gnutls_x509_crt_get_issuer_unique_id(cert, buf, &buf_size);
+ if (result < 0)
+ fail("get_issuer_unique_id %d\n", result);
+ if (memcmp(buf, expectedId, buf_size) != 0)
+ fail("expected id mismatch for issuer\n");
+
+ buf_size = 15;
+ result =
+ gnutls_x509_crt_get_subject_unique_id(cert, buf, &buf_size);
+ if (result != GNUTLS_E_SHORT_MEMORY_BUFFER)
+ fail("get_subject_unique_id short error %d\n", result);
+ if (buf_size != 16)
+ fail("get_subject_unique_id buf size %zd\n", buf_size);
+
+ buf_size = 16;
+ result =
+ gnutls_x509_crt_get_subject_unique_id(cert, buf, &buf_size);
+ if (result < 0)
+ fail("get_subject_unique_id %d\n", result);
+ if (memcmp(buf, expectedId, buf_size) != 0)
+ fail("expected id mismatch for subject\n");
+
+ gnutls_x509_crt_deinit(cert);
+
+ gnutls_global_deinit();
}
diff --git a/tests/chainverify-unsorted.c b/tests/chainverify-unsorted.c
index 0c793f67eb..829b13636f 100644
--- a/tests/chainverify-unsorted.c
+++ b/tests/chainverify-unsorted.c
@@ -39,710 +39,718 @@
/* gnutls_trust_list_*().
*/
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "<%d>| %s", level, str);
+ fprintf(stderr, "<%d>| %s", level, str);
}
-const char ca_str[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG\n"
- "A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz\n"
- "cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2\n"
- "MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV\n"
- "BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt\n"
- "YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN\n"
- "ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE\n"
- "BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is\n"
- "I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G\n"
- "CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do\n"
- "lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc\n"
- "AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k\n"
- "-----END CERTIFICATE-----\n";
-const gnutls_datum_t ca = { (void*)ca_str, sizeof(ca_str) };
+const char ca_str[] =
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG\n"
+ "A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz\n"
+ "cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2\n"
+ "MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV\n"
+ "BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt\n"
+ "YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN\n"
+ "ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE\n"
+ "BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is\n"
+ "I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G\n"
+ "CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do\n"
+ "lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc\n"
+ "AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k\n"
+ "-----END CERTIFICATE-----\n";
+const gnutls_datum_t ca = { (void *) ca_str, sizeof(ca_str) };
/* Chain1 is sorted */
static const char chain1[] = {
- /* chain[0] */
- "-----BEGIN CERTIFICATE-----\n"
- "MIIGCDCCBPCgAwIBAgIQakrDGzEQ5utI8PxRo5oXHzANBgkqhkiG9w0BAQUFADCB\n"
- "vjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQ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0OFwKgUp3CxiizbXxCqEQc=\n"
- "-----END CERTIFICATE-----\n"
- /* chain[3] (CA) */
- "-----BEGIN CERTIFICATE-----\n"
- "MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG\n"
- "A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz\n"
- "cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2\n"
- "MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV\n"
- "BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt\n"
- "YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN\n"
- "ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE\n"
- "BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is\n"
- "I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G\n"
- "CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do\n"
- "lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc\n"
- "AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k\n"
- "-----END CERTIFICATE-----\n"
+ /* chain[0] */
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIGCDCCBPCgAwIBAgIQakrDGzEQ5utI8PxRo5oXHzANBgkqhkiG9w0BAQUFADCB\n"
+ "vjELMAkGA1UEB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2OmufTqj/ZA1k\n"
+ "-----END CERTIFICATE-----\n"
};
/* Chain2 is unsorted - reverse order */
static const char chain2[] = {
- /* chain[0] */
- "-----BEGIN CERTIFICATE-----\n"
- "MIIGCDCCBPCgAwIBAgIQakrDGzEQ5utI8PxRo5oXHzANBgkqhkiG9w0BAQUFADCB\n"
- "vjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n"
- "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug\n"
- "YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNjE4MDYGA1UEAxMv\n"
- "VmVyaVNpZ24gQ2xhc3MgMyBFeHRlbmRlZCBWYWxpZGF0aW9uIFNTTCBTR0MgQ0Ew\n"
- "HhcNMDcwNTA5MDAwMDAwWhcNMDkwNTA4MjM1OTU5WjCCAUAxEDAOBgNVBAUTBzI0\n"
- "OTc4ODYxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIBAhMIRGVs\n"
- "YXdhcmUxCzAJBgNVBAYTAlVTMQ4wDAYDVQQRFAU5NDA0MzETMBEGA1UECBMKQ2Fs\n"
- "aWZvcm5pYTEWMBQGA1UEBxQNTW91bnRhaW4gVmlldzEiMCAGA1UECRQZNDg3IEVh\n"
- "c3QgTWlkZGxlZmllbGQgUm9hZDEXMBUGA1UEChQOVmVyaVNpZ24sIEluYy4xJTAj\n"
- "BgNVBAsUHFByb2R1Y3Rpb24gU2VjdXJpdHkgU2VydmljZXMxMzAxBgNVBAsUKlRl\n"
- "cm1zIG9mIHVzZSBhdCB3d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNjEZMBcGA1UE\n"
- "AxQQd3d3LnZlcmlzaWduLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA\n"
- "xxA35ev879drgQCpENGRQ3ARaCPz/WneT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Mn6R5hjuvOfa0E6N\n"
+ "eLvincBZK8DOlQ0kDHLKNF5wIokrSrDxaIfz7kSNKEB3OW5IckUxXWs5DoYC6maZ\n"
+ "kzEP32fepp+MnUzOcW86Ifa5ND/5btia9z7a84Ffelxtj3z2mXS3/+QXXe1hXqtI\n"
+ "u5aNZkU5tBIK9nDpnHYiS2DpKhs0Sfei1GfAsSatE7rZhAHBq+GObXAWO3eskZq7\n"
+ "Gh/aWKfkT8Fhrryi/ks=\n" "-----END CERTIFICATE-----\n"
};
/* Chain3 is unsorted - random order */
static const char chain3[] = {
- /* chain[0] */
- "-----BEGIN CERTIFICATE-----\n"
- "MIIGCDCCBPCgAwIBAgIQakrDGzEQ5utI8PxRo5oXHzANBgkqhkiG9w0BAQUFADCB\n"
- "vjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n"
- "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug\n"
- "YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNjE4MDYGA1UEAxMv\n"
- "VmVyaVNpZ24gQ2xhc3MgMyBFeHRlbmRlZCBWYWxpZGF0aW9uIFNTTCBTR0MgQ0Ew\n"
- "HhcNMDcwNTA5MDAwMDAwWhcNMDkwNTA4MjM1OTU5WjCCAUAxEDAOBgNVBAUTBzI0\n"
- "OTc4ODYxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIBAhMIRGVs\n"
- "YXdhcmUxCzAJBgNVBAYTAlVTMQ4wDAYDVQQRFAU5NDA0MzETMBEGA1UECBMKQ2Fs\n"
- "aWZvcm5pYTEWMBQGA1UEBxQNTW91bnRhaW4gVmlldzEiMCAGA1UECRQZNDg3IEVh\n"
- "c3QgTWlkZGxlZmllbGQgUm9hZDEXMBUGA1UEChQOVmVyaVNpZ24sIEluYy4xJTAj\n"
- "Bg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1cmUtb2NzcC52ZXJpc2lnbi5jb20wHwYDVR0j\n"
+ "BBgwFoAUf9Nlp8Ld7LvwMAnzQzn6Aq8zMTMwDQYJKoZIhvcNAQEFBQADggEBAFqi\n"
+ "sb/rjdQ4qIBywtw4Lqyncfkro7tHu21pbxA2mIzHVi67vKtKm3rW8oKT4BT+is6D\n"
+ "t4Pbk4errGV5Sf1XqbHOCR+6EBXECQ5i4/kKJdVkmPDyqA92Mn6R5hjuvOfa0E6N\n"
+ "eLvincBZK8DOlQ0kDHLKNF5wIokrSrDxaIfz7kSNKEB3OW5IckUxXWs5DoYC6maZ\n"
+ "kzEP32fepp+MnUzOcW86Ifa5ND/5btia9z7a84Ffelxtj3z2mXS3/+QXXe1hXqtI\n"
+ "u5aNZkU5tBIK9nDpnHYiS2DpKhs0Sfei1GfAsSatE7rZhAHBq+GObXAWO3eskZq7\n"
+ "Gh/aWKfkT8Fhrryi/ks=\n" "-----END CERTIFICATE-----\n"
};
/* Chain4 is unsorted - random order and includes random certs */
static const char chain4[] = {
- /* chain[0] */
- "-----BEGIN CERTIFICATE-----\n"
- "MIIGCDCCBPCgAwIBAgIQakrDGzEQ5utI8PxRo5oXHzANBgkqhkiG9w0BAQUFADCB\n"
- "vjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n"
- "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug\n"
- "YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNjE4MDYGA1UEAxMv\n"
- "VmVyaVNpZ24gQ2xhc3MgMyBFeHRlbmRlZCBWYWxpZGF0aW9uIFNTTCBTR0MgQ0Ew\n"
- "HhcNMDcwNTA5MDAwMDAwWhcNMDkwNTA4MjM1OTU5WjCCAUAxEDAOBgNVBAUTBzI0\n"
- "OTc4ODYxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBg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PBgNVHRMECDAGAQH/AgEAMEQGA1UdIAQ9MDswOQYLYIZIAYb4RQEHAQEw\n"
+ "KjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL0NQUzA0BgNV\n"
+ "HSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIGCWCGSAGG+EIEAQYKYIZIAYb4RQEI\n"
+ "ATALBgNVHQ8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgEGMDEGA1UdHwQqMCgwJqAk\n"
+ "oCKGIGh0dHA6Ly9jcmwudmVyaXNpZ24uY29tL3BjYTMuY3JsMA0GCSqGSIb3DQEB\n"
+ "BQUAA4GBAAgB7ORolANC8XPxI6I63unx2sZUxCM+hurPajozq+qcBBQHNgYL+Yhv\n"
+ "1RPuKSvD5HKNRO3RrCAJLeH24RkFOLA9D59/+J4C3IYChmFOJl9en5IeDCSk9dBw\n"
+ "E88mw0M9SR2egi5SX7w+xmYpAY5Okiy8RnUDgqxz6dl+C2fvVFIa\n"
+ "-----END CERTIFICATE-----\n"
};
-static time_t mytime (time_t * t)
+static time_t mytime(time_t * t)
{
- time_t then = 1207000800;
+ time_t then = 1207000800;
- if (t)
- *t = then;
+ if (t)
+ *t = then;
- return then;
+ return then;
}
-void
-doit (void)
+void doit(void)
{
- int ret;
- gnutls_datum_t data;
- gnutls_x509_crt_t *crts;
- unsigned int crts_size, i;
- gnutls_x509_trust_list_t tl;
- unsigned int status, flags = GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN;
- unsigned int not_flags = GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN;
-
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_time_function (mytime);
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (6);
-
- /* test for gnutls_certificate_get_issuer() */
- gnutls_x509_trust_list_init(&tl, 0);
-
- ret = gnutls_x509_trust_list_add_trust_mem(tl, &ca, NULL, GNUTLS_X509_FMT_PEM, 0, 0);
- if (ret < 0)
- {
- fail("gnutls_x509_trust_list_add_trust_mem\n");
- exit(1);
- }
-
- /* Chain 1 */
- data.data = (void*) chain1;
- data.size = sizeof(chain1);
- ret = gnutls_x509_crt_list_import2(&crts, &crts_size, &data, GNUTLS_X509_FMT_PEM, 0);
- if (ret < 0)
- {
- fail("gnutls_x509_crt_list_import2: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags, &status, NULL);
- if (ret < 0 || status != 0)
- {
- fail("gnutls_x509_trust_list_verify_crt - 1\n");
- exit(1);
- }
-
- for (i=0;i<crts_size;i++)
- gnutls_x509_crt_deinit(crts[i]);
- gnutls_free(crts);
-
- /* Chain 2 */
- data.data = (void*) chain2;
- data.size = sizeof(chain2);
- ret = gnutls_x509_crt_list_import2(&crts, &crts_size, &data, GNUTLS_X509_FMT_PEM, 0);
- if (ret < 0)
- {
- fail("gnutls_x509_crt_list_import2: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags, &status, NULL);
- if (ret < 0 || status != 0)
- {
- fail("gnutls_x509_trust_list_verify_crt - 2\n");
- exit(1);
- }
-
- for (i=0;i<crts_size;i++)
- gnutls_x509_crt_deinit(crts[i]);
- gnutls_free(crts);
-
- /* Chain 3 */
- data.data = (void*) chain3;
- data.size = sizeof(chain3);
- ret = gnutls_x509_crt_list_import2(&crts, &crts_size, &data, GNUTLS_X509_FMT_PEM, 0);
- if (ret < 0)
- {
- fail("gnutls_x509_crt_list_import2: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags, &status, NULL);
- if (ret < 0 || status != 0)
- {
- fail("gnutls_x509_trust_list_verify_crt - 3\n");
- exit(1);
- }
-
- for (i=0;i<crts_size;i++)
- gnutls_x509_crt_deinit(crts[i]);
- gnutls_free(crts);
-
- /* Chain 4 */
- data.data = (void*) chain4;
- data.size = sizeof(chain4);
- ret = gnutls_x509_crt_list_import2(&crts, &crts_size, &data, GNUTLS_X509_FMT_PEM, 0);
- if (ret < 0)
- {
- fail("gnutls_x509_crt_list_import2: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags, &status, NULL);
- if (ret < 0 || status != 0)
- {
- fail("gnutls_x509_trust_list_verify_crt - 4\n");
- exit(1);
- }
-
- for (i=0;i<crts_size;i++)
- gnutls_x509_crt_deinit(crts[i]);
- gnutls_free(crts);
-
- /* Check if an unsorted list would fail if the unsorted flag is not given */
- data.data = (void*) chain2;
- data.size = sizeof(chain2);
- ret = gnutls_x509_crt_list_import2(&crts, &crts_size, &data, GNUTLS_X509_FMT_PEM, 0);
- if (ret < 0)
- {
- fail("gnutls_x509_crt_list_import2: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, not_flags, &status, NULL);
- if (ret < 0 || status == 0)
- {
- fail("gnutls_x509_trust_list_verify_crt - 5\n");
- exit(1);
- }
-
- for (i=0;i<crts_size;i++)
- gnutls_x509_crt_deinit(crts[i]);
- gnutls_free(crts);
-
- gnutls_x509_trust_list_deinit(tl, 1);
-
- gnutls_global_deinit();
-
- if (debug) success("success");
+ int ret;
+ gnutls_datum_t data;
+ gnutls_x509_crt_t *crts;
+ unsigned int crts_size, i;
+ gnutls_x509_trust_list_t tl;
+ unsigned int status, flags = GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN;
+ unsigned int not_flags = GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN;
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_time_function(mytime);
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(6);
+
+ /* test for gnutls_certificate_get_issuer() */
+ gnutls_x509_trust_list_init(&tl, 0);
+
+ ret =
+ gnutls_x509_trust_list_add_trust_mem(tl, &ca, NULL,
+ GNUTLS_X509_FMT_PEM, 0,
+ 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_add_trust_mem\n");
+ exit(1);
+ }
+
+ /* Chain 1 */
+ data.data = (void *) chain1;
+ data.size = sizeof(chain1);
+ ret =
+ gnutls_x509_crt_list_import2(&crts, &crts_size, &data,
+ GNUTLS_X509_FMT_PEM, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_list_import2: %s\n",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags,
+ &status, NULL);
+ if (ret < 0 || status != 0) {
+ fail("gnutls_x509_trust_list_verify_crt - 1\n");
+ exit(1);
+ }
+
+ for (i = 0; i < crts_size; i++)
+ gnutls_x509_crt_deinit(crts[i]);
+ gnutls_free(crts);
+
+ /* Chain 2 */
+ data.data = (void *) chain2;
+ data.size = sizeof(chain2);
+ ret =
+ gnutls_x509_crt_list_import2(&crts, &crts_size, &data,
+ GNUTLS_X509_FMT_PEM, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_list_import2: %s\n",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags,
+ &status, NULL);
+ if (ret < 0 || status != 0) {
+ fail("gnutls_x509_trust_list_verify_crt - 2\n");
+ exit(1);
+ }
+
+ for (i = 0; i < crts_size; i++)
+ gnutls_x509_crt_deinit(crts[i]);
+ gnutls_free(crts);
+
+ /* Chain 3 */
+ data.data = (void *) chain3;
+ data.size = sizeof(chain3);
+ ret =
+ gnutls_x509_crt_list_import2(&crts, &crts_size, &data,
+ GNUTLS_X509_FMT_PEM, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_list_import2: %s\n",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags,
+ &status, NULL);
+ if (ret < 0 || status != 0) {
+ fail("gnutls_x509_trust_list_verify_crt - 3\n");
+ exit(1);
+ }
+
+ for (i = 0; i < crts_size; i++)
+ gnutls_x509_crt_deinit(crts[i]);
+ gnutls_free(crts);
+
+ /* Chain 4 */
+ data.data = (void *) chain4;
+ data.size = sizeof(chain4);
+ ret =
+ gnutls_x509_crt_list_import2(&crts, &crts_size, &data,
+ GNUTLS_X509_FMT_PEM, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_list_import2: %s\n",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_trust_list_verify_crt(tl, crts, crts_size, flags,
+ &status, NULL);
+ if (ret < 0 || status != 0) {
+ fail("gnutls_x509_trust_list_verify_crt - 4\n");
+ exit(1);
+ }
+
+ for (i = 0; i < crts_size; i++)
+ gnutls_x509_crt_deinit(crts[i]);
+ gnutls_free(crts);
+
+ /* Check if an unsorted list would fail if the unsorted flag is not given */
+ data.data = (void *) chain2;
+ data.size = sizeof(chain2);
+ ret =
+ gnutls_x509_crt_list_import2(&crts, &crts_size, &data,
+ GNUTLS_X509_FMT_PEM, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_list_import2: %s\n",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_trust_list_verify_crt(tl, crts, crts_size,
+ not_flags, &status, NULL);
+ if (ret < 0 || status == 0) {
+ fail("gnutls_x509_trust_list_verify_crt - 5\n");
+ exit(1);
+ }
+
+ for (i = 0; i < crts_size; i++)
+ gnutls_x509_crt_deinit(crts[i]);
+ gnutls_free(crts);
+
+ gnutls_x509_trust_list_deinit(tl, 1);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("success");
}
diff --git a/tests/chainverify.c b/tests/chainverify.c
index 8f6d78466b..45596e65c6 100644
--- a/tests/chainverify.c
+++ b/tests/chainverify.c
@@ -37,14 +37,14 @@
verifying certificates. To avoid a time bomb, we hard code the
current time. This should work fine on systems where the library
call to time is resolved at run-time. */
-static time_t mytime (time_t * t)
+static time_t mytime(time_t * t)
{
- time_t then = 1256803113;
+ time_t then = 1256803113;
- if (t)
- *t = then;
+ if (t)
+ *t = then;
- return then;
+ return then;
}
/* *INDENT-OFF* */
@@ -785,164 +785,171 @@ static struct
};
/* *INDENT-ON* */
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
-void
-doit (void)
+void doit(void)
{
- int exit_val = 0;
- size_t i;
- int ret;
+ int exit_val = 0;
+ size_t i;
+ int ret;
- /* The overloading of time() seems to work in linux (ELF?)
- * systems only. Disable it on windows.
- */
+ /* The overloading of time() seems to work in linux (ELF?)
+ * systems only. Disable it on windows.
+ */
#ifdef _WIN32
- exit(77);
+ exit(77);
#endif
- ret = global_init ();
- if (ret != 0)
- {
- fail ("%d: %s\n", ret, gnutls_strerror (ret));
- exit (1);
- }
-
- gnutls_global_set_time_function (mytime);
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- for (i = 0; chains[i].chain; i++)
- {
- unsigned int verify_status;
- gnutls_x509_crt_t certs[4];
- gnutls_x509_crt_t ca;
- gnutls_datum_t tmp;
- size_t j;
-
- if (debug)
- printf ("Chain '%s' (%d)...\n", chains[i].name, (int) i);
-
- for (j = 0; chains[i].chain[j]; j++)
- {
- if (debug > 2)
- printf ("\tAdding certificate %d...", (int) j);
-
- ret = gnutls_x509_crt_init (&certs[j]);
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_init[%d,%d]: %s",
- (int) i, (int) j, gnutls_strerror (ret));
- exit (1);
- }
-
- tmp.data = (unsigned char *) chains[i].chain[j];
- tmp.size = strlen (chains[i].chain[j]);
-
- ret = gnutls_x509_crt_import (certs[j], &tmp, GNUTLS_X509_FMT_PEM);
- if (debug > 2)
- printf ("done\n");
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_import[%d,%d]: %s",
- (int) i, (int) j, gnutls_strerror (ret));
- exit (1);
- }
-
- gnutls_x509_crt_print (certs[j], GNUTLS_CRT_PRINT_ONELINE, &tmp);
- if (debug)
- printf ("\tCertificate %d: %.*s\n", (int) j, tmp.size, tmp.data);
- gnutls_free (tmp.data);
- }
-
- if (debug > 2)
- printf ("\tAdding CA certificate...");
-
- ret = gnutls_x509_crt_init (&ca);
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_init: %s",
- gnutls_strerror (ret));
- exit (1);
- }
-
- tmp.data = (unsigned char *) *chains[i].ca;
- tmp.size = strlen (*chains[i].ca);
-
- ret = gnutls_x509_crt_import (ca, &tmp, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_import: %s",
- gnutls_strerror (ret));
- exit (1);
+ ret = global_init();
+ if (ret != 0) {
+ fail("%d: %s\n", ret, gnutls_strerror(ret));
+ exit(1);
}
- if (debug > 2)
- printf ("done\n");
-
- gnutls_x509_crt_print (ca, GNUTLS_CRT_PRINT_ONELINE, &tmp);
- if (debug)
- printf ("\tCA Certificate: %.*s\n", tmp.size, tmp.data);
- gnutls_free (tmp.data);
-
- if (debug)
- printf ("\tVerifying...");
-
- ret = gnutls_x509_crt_list_verify (certs, j,
- &ca, 1, NULL, 0,
- chains[i].verify_flags,
- &verify_status);
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_list_verify[%d,%d]: %s",
- (int) i, (int) j, gnutls_strerror (ret));
- exit (1);
- }
-
- if (verify_status != chains[i].expected_verify_result)
- {
- gnutls_datum_t out1, out2;
- gnutls_certificate_verification_status_print(verify_status, GNUTLS_CRT_X509, &out1, 0);
- gnutls_certificate_verification_status_print(chains[i].expected_verify_result, GNUTLS_CRT_X509, &out2, 0);
- fail ("chain[%s]:\nverify_status: %d: %s\nexpected: %d: %s\n", chains[i].name,
- verify_status, out1.data, chains[i].expected_verify_result, out2.data);
- gnutls_free(out1.data);
- gnutls_free(out2.data);
+ gnutls_global_set_time_function(mytime);
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ for (i = 0; chains[i].chain; i++) {
+ unsigned int verify_status;
+ gnutls_x509_crt_t certs[4];
+ gnutls_x509_crt_t ca;
+ gnutls_datum_t tmp;
+ size_t j;
+
+ if (debug)
+ printf("Chain '%s' (%d)...\n", chains[i].name,
+ (int) i);
+
+ for (j = 0; chains[i].chain[j]; j++) {
+ if (debug > 2)
+ printf("\tAdding certificate %d...",
+ (int) j);
+
+ ret = gnutls_x509_crt_init(&certs[j]);
+ if (ret < 0) {
+ fprintf(stderr,
+ "gnutls_x509_crt_init[%d,%d]: %s",
+ (int) i, (int) j,
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ tmp.data = (unsigned char *) chains[i].chain[j];
+ tmp.size = strlen(chains[i].chain[j]);
+
+ ret =
+ gnutls_x509_crt_import(certs[j], &tmp,
+ GNUTLS_X509_FMT_PEM);
+ if (debug > 2)
+ printf("done\n");
+ if (ret < 0) {
+ fprintf(stderr,
+ "gnutls_x509_crt_import[%d,%d]: %s",
+ (int) i, (int) j,
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ gnutls_x509_crt_print(certs[j],
+ GNUTLS_CRT_PRINT_ONELINE,
+ &tmp);
+ if (debug)
+ printf("\tCertificate %d: %.*s\n", (int) j,
+ tmp.size, tmp.data);
+ gnutls_free(tmp.data);
+ }
+
+ if (debug > 2)
+ printf("\tAdding CA certificate...");
+
+ ret = gnutls_x509_crt_init(&ca);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_init: %s",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ tmp.data = (unsigned char *) *chains[i].ca;
+ tmp.size = strlen(*chains[i].ca);
+
+ ret =
+ gnutls_x509_crt_import(ca, &tmp, GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_import: %s",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ if (debug > 2)
+ printf("done\n");
+
+ gnutls_x509_crt_print(ca, GNUTLS_CRT_PRINT_ONELINE, &tmp);
+ if (debug)
+ printf("\tCA Certificate: %.*s\n", tmp.size,
+ tmp.data);
+ gnutls_free(tmp.data);
+
+ if (debug)
+ printf("\tVerifying...");
+
+ ret = gnutls_x509_crt_list_verify(certs, j,
+ &ca, 1, NULL, 0,
+ chains[i].verify_flags,
+ &verify_status);
+ if (ret < 0) {
+ fprintf(stderr,
+ "gnutls_x509_crt_list_verify[%d,%d]: %s",
+ (int) i, (int) j, gnutls_strerror(ret));
+ exit(1);
+ }
+
+ if (verify_status != chains[i].expected_verify_result) {
+ gnutls_datum_t out1, out2;
+ gnutls_certificate_verification_status_print
+ (verify_status, GNUTLS_CRT_X509, &out1, 0);
+ gnutls_certificate_verification_status_print(chains
+ [i].
+ expected_verify_result,
+ GNUTLS_CRT_X509,
+ &out2,
+ 0);
+ fail("chain[%s]:\nverify_status: %d: %s\nexpected: %d: %s\n", chains[i].name, verify_status, out1.data, chains[i].expected_verify_result, out2.data);
+ gnutls_free(out1.data);
+ gnutls_free(out2.data);
#if 0
- j = 0;
- do
- {
- fprintf (stderr, "%s\n", chains[i].chain[j]);
- }
- while (chains[i].chain[++j] != NULL);
+ j = 0;
+ do {
+ fprintf(stderr, "%s\n",
+ chains[i].chain[j]);
+ }
+ while (chains[i].chain[++j] != NULL);
#endif
- if (!debug)
- exit (1);
- }
- else if (debug)
- printf ("done\n");
- if (debug)
- printf ("\tCleanup...");
+ if (!debug)
+ exit(1);
+ } else if (debug)
+ printf("done\n");
+ if (debug)
+ printf("\tCleanup...");
- gnutls_x509_crt_deinit (ca);
- for (j = 0; chains[i].chain[j]; j++)
- gnutls_x509_crt_deinit (certs[j]);
+ gnutls_x509_crt_deinit(ca);
+ for (j = 0; chains[i].chain[j]; j++)
+ gnutls_x509_crt_deinit(certs[j]);
- if (debug)
- printf ("done\n\n\n");
- }
+ if (debug)
+ printf("done\n\n\n");
+ }
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- if (debug)
- printf ("Exit status...%d\n", exit_val);
+ if (debug)
+ printf("Exit status...%d\n", exit_val);
- exit (exit_val);
+ exit(exit_val);
}
diff --git a/tests/crq_apis.c b/tests/crq_apis.c
index 38233d7395..daf8d89e18 100644
--- a/tests/crq_apis.c
+++ b/tests/crq_apis.c
@@ -32,186 +32,188 @@
#include "utils.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", "crq_key_id", level, str);
+ fprintf(stderr, "%s |<%d>| %s", "crq_key_id", level, str);
}
static unsigned char key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
- "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
- "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
- "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
- "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+Qn6hw4x2p5rogdvhhIL1mdWo7jWeVJTF\n"
- "RKB7zLdMPs3ySdtcIQaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
- "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
- "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
- "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
- "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
- "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
- "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
- "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
- "-----END RSA PRIVATE KEY-----\n";
-const gnutls_datum_t key = { key_pem, sizeof (key_pem) };
-
-void
-doit (void)
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
+ "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
+ "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
+ "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
+ "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+Qn6hw4x2p5rogdvhhIL1mdWo7jWeVJTF\n"
+ "RKB7zLdMPs3ySdtcIQaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
+ "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
+ "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
+ "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
+ "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
+ "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
+ "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
+ "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
+ "-----END RSA PRIVATE KEY-----\n";
+const gnutls_datum_t key = { key_pem, sizeof(key_pem) };
+
+void doit(void)
{
- gnutls_x509_privkey_t pkey;
- gnutls_x509_crt_t crt;
- gnutls_x509_crq_t crq;
-
- gnutls_datum_t out;
+ gnutls_x509_privkey_t pkey;
+ gnutls_x509_crt_t crt;
+ gnutls_x509_crq_t crq;
+
+ gnutls_datum_t out;
- size_t s = 0;
-
- char smallbuf[10];
-
- int ret;
-
- ret = global_init ();
- if (ret < 0)
- fail ("global_init\n");
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- ret = gnutls_x509_crq_init (&crq);
- if (ret != 0)
- fail ("gnutls_x509_crq_init\n");
-
- ret = gnutls_x509_privkey_init (&pkey);
- if (ret != 0)
- fail ("gnutls_x509_privkey_init\n");
-
- ret = gnutls_x509_crt_init (&crt);
- if (ret != 0)
- fail ("gnutls_x509_crt_init\n");
-
- ret = gnutls_x509_privkey_import (pkey, &key, GNUTLS_X509_FMT_PEM);
- if (ret != 0)
- fail ("gnutls_x509_privkey_import\n");
-
- ret = gnutls_x509_crq_set_version (crq, 0);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_version\n");
-
- ret = gnutls_x509_crq_set_key (crq, pkey);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_key\n");
-
- s = 0;
- ret = gnutls_x509_crq_get_extension_info (crq, 0, NULL, &s, NULL);
- if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- fail ("gnutls_x509_crq_get_extension_info\n");
-
- ret = gnutls_x509_crq_set_basic_constraints (crq, 0, 0);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_basic_constraints %d\n", ret);
-
- ret = gnutls_x509_crq_set_key_usage (crq, 0);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_key_usage %d\n", ret);
-
- ret = gnutls_x509_crq_get_challenge_password (crq, NULL, &s);
- if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- fail ("%d: gnutls_x509_crq_get_challenge_password %d: %s\n", __LINE__, ret, gnutls_strerror(ret));
-
- ret = gnutls_x509_crq_set_challenge_password (crq, "foo");
- if (ret != 0)
- fail ("gnutls_x509_crq_set_challenge_password %d\n", ret);
-
- s = 0;
- ret = gnutls_x509_crq_get_challenge_password (crq, NULL, &s);
- if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER || s != 4)
- fail ("%d: gnutls_x509_crq_get_challenge_password %d: %s (passlen: %d)\n", __LINE__, ret, gnutls_strerror(ret), (int)s);
-
- s = 10;
- ret = gnutls_x509_crq_get_challenge_password (crq, smallbuf, &s);
- if (ret != 0 || s != 3 || strcmp (smallbuf, "foo") != 0)
- fail ("%d: gnutls_x509_crq_get_challenge_password3 %d/%d/%s\n",
- __LINE__, ret, (int) s, smallbuf);
-
- s = 0;
- ret = gnutls_x509_crq_get_extension_info (crq, 0, NULL, &s, NULL);
- if (ret != 0)
- fail ("gnutls_x509_crq_get_extension_info2\n");
-
- s = 0;
- ret = gnutls_x509_crq_get_extension_data (crq, 0, NULL, &s);
- if (ret != 0)
- fail ("gnutls_x509_crq_get_extension_data\n");
-
- ret = gnutls_x509_crq_set_subject_alt_name (crq, GNUTLS_SAN_DNSNAME,
- "foo", 3, 1);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_subject_alt_name\n");
-
- ret = gnutls_x509_crq_set_subject_alt_name (crq, GNUTLS_SAN_DNSNAME,
- "bar", 3, 1);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_subject_alt_name\n");
-
- ret = gnutls_x509_crq_set_subject_alt_name (crq, GNUTLS_SAN_DNSNAME,
- "apa", 3, 0);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_subject_alt_name\n");
-
- ret = gnutls_x509_crq_set_subject_alt_name (crq, GNUTLS_SAN_DNSNAME,
- "foo", 3, 1);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_subject_alt_name\n");
-
- s = 0;
- ret = gnutls_x509_crq_get_key_purpose_oid (crq, 0, NULL, &s, NULL);
- if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- fail ("gnutls_x509_crq_get_key_purpose_oid %d\n", ret);
-
- s = 0;
- ret =
- gnutls_x509_crq_set_key_purpose_oid (crq, GNUTLS_KP_TLS_WWW_SERVER, 0);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_key_purpose_oid %d\n", ret);
-
- s = 0;
- ret = gnutls_x509_crq_get_key_purpose_oid (crq, 0, NULL, &s, NULL);
- if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
- fail ("gnutls_x509_crq_get_key_purpose_oid %d\n", ret);
-
- s = 0;
- ret =
- gnutls_x509_crq_set_key_purpose_oid (crq, GNUTLS_KP_TLS_WWW_CLIENT, 1);
- if (ret != 0)
- fail ("gnutls_x509_crq_set_key_purpose_oid2 %d\n", ret);
-
- ret = gnutls_x509_crq_print (crq, GNUTLS_CRT_PRINT_FULL, &out);
- if (ret != 0)
- fail ("gnutls_x509_crq_print\n");
- if (debug)
- printf ("crq: %.*s\n", out.size, out.data);
- gnutls_free (out.data);
-
- ret = gnutls_x509_crt_set_version (crt, 3);
- if (ret != 0)
- fail ("gnutls_x509_crt_set_version\n");
-
- ret = gnutls_x509_crt_set_crq_extensions (crt, crq);
- if (ret != 0)
- fail ("gnutls_x509_crt_set_crq_extensions\n");
-
- ret = gnutls_x509_crt_print (crt, GNUTLS_CRT_PRINT_FULL, &out);
- if (ret != 0)
- fail ("gnutls_x509_crt_print\n");
- if (debug)
- printf ("crt: %.*s\n", out.size, out.data);
- gnutls_free (out.data);
-
- gnutls_x509_crq_deinit (crq);
- gnutls_x509_crt_deinit (crt);
- gnutls_x509_privkey_deinit (pkey);
-
- gnutls_global_deinit ();
+ size_t s = 0;
+
+ char smallbuf[10];
+
+ int ret;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("global_init\n");
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ ret = gnutls_x509_crq_init(&crq);
+ if (ret != 0)
+ fail("gnutls_x509_crq_init\n");
+
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret != 0)
+ fail("gnutls_x509_privkey_init\n");
+
+ ret = gnutls_x509_crt_init(&crt);
+ if (ret != 0)
+ fail("gnutls_x509_crt_init\n");
+
+ ret = gnutls_x509_privkey_import(pkey, &key, GNUTLS_X509_FMT_PEM);
+ if (ret != 0)
+ fail("gnutls_x509_privkey_import\n");
+
+ ret = gnutls_x509_crq_set_version(crq, 0);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_version\n");
+
+ ret = gnutls_x509_crq_set_key(crq, pkey);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_key\n");
+
+ s = 0;
+ ret = gnutls_x509_crq_get_extension_info(crq, 0, NULL, &s, NULL);
+ if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ fail("gnutls_x509_crq_get_extension_info\n");
+
+ ret = gnutls_x509_crq_set_basic_constraints(crq, 0, 0);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_basic_constraints %d\n", ret);
+
+ ret = gnutls_x509_crq_set_key_usage(crq, 0);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_key_usage %d\n", ret);
+
+ ret = gnutls_x509_crq_get_challenge_password(crq, NULL, &s);
+ if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ fail("%d: gnutls_x509_crq_get_challenge_password %d: %s\n",
+ __LINE__, ret, gnutls_strerror(ret));
+
+ ret = gnutls_x509_crq_set_challenge_password(crq, "foo");
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_challenge_password %d\n", ret);
+
+ s = 0;
+ ret = gnutls_x509_crq_get_challenge_password(crq, NULL, &s);
+ if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER || s != 4)
+ fail("%d: gnutls_x509_crq_get_challenge_password %d: %s (passlen: %d)\n", __LINE__, ret, gnutls_strerror(ret), (int) s);
+
+ s = 10;
+ ret = gnutls_x509_crq_get_challenge_password(crq, smallbuf, &s);
+ if (ret != 0 || s != 3 || strcmp(smallbuf, "foo") != 0)
+ fail("%d: gnutls_x509_crq_get_challenge_password3 %d/%d/%s\n", __LINE__, ret, (int) s, smallbuf);
+
+ s = 0;
+ ret = gnutls_x509_crq_get_extension_info(crq, 0, NULL, &s, NULL);
+ if (ret != 0)
+ fail("gnutls_x509_crq_get_extension_info2\n");
+
+ s = 0;
+ ret = gnutls_x509_crq_get_extension_data(crq, 0, NULL, &s);
+ if (ret != 0)
+ fail("gnutls_x509_crq_get_extension_data\n");
+
+ ret = gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME,
+ "foo", 3, 1);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_subject_alt_name\n");
+
+ ret = gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME,
+ "bar", 3, 1);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_subject_alt_name\n");
+
+ ret = gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME,
+ "apa", 3, 0);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_subject_alt_name\n");
+
+ ret = gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME,
+ "foo", 3, 1);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_subject_alt_name\n");
+
+ s = 0;
+ ret = gnutls_x509_crq_get_key_purpose_oid(crq, 0, NULL, &s, NULL);
+ if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ fail("gnutls_x509_crq_get_key_purpose_oid %d\n", ret);
+
+ s = 0;
+ ret =
+ gnutls_x509_crq_set_key_purpose_oid(crq,
+ GNUTLS_KP_TLS_WWW_SERVER,
+ 0);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_key_purpose_oid %d\n", ret);
+
+ s = 0;
+ ret = gnutls_x509_crq_get_key_purpose_oid(crq, 0, NULL, &s, NULL);
+ if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
+ fail("gnutls_x509_crq_get_key_purpose_oid %d\n", ret);
+
+ s = 0;
+ ret =
+ gnutls_x509_crq_set_key_purpose_oid(crq,
+ GNUTLS_KP_TLS_WWW_CLIENT,
+ 1);
+ if (ret != 0)
+ fail("gnutls_x509_crq_set_key_purpose_oid2 %d\n", ret);
+
+ ret = gnutls_x509_crq_print(crq, GNUTLS_CRT_PRINT_FULL, &out);
+ if (ret != 0)
+ fail("gnutls_x509_crq_print\n");
+ if (debug)
+ printf("crq: %.*s\n", out.size, out.data);
+ gnutls_free(out.data);
+
+ ret = gnutls_x509_crt_set_version(crt, 3);
+ if (ret != 0)
+ fail("gnutls_x509_crt_set_version\n");
+
+ ret = gnutls_x509_crt_set_crq_extensions(crt, crq);
+ if (ret != 0)
+ fail("gnutls_x509_crt_set_crq_extensions\n");
+
+ ret = gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_FULL, &out);
+ if (ret != 0)
+ fail("gnutls_x509_crt_print\n");
+ if (debug)
+ printf("crt: %.*s\n", out.size, out.data);
+ gnutls_free(out.data);
+
+ gnutls_x509_crq_deinit(crq);
+ gnutls_x509_crt_deinit(crt);
+ gnutls_x509_privkey_deinit(pkey);
+
+ gnutls_global_deinit();
}
diff --git a/tests/crq_key_id.c b/tests/crq_key_id.c
index 5fb14fd80b..c9c4fd7a9a 100644
--- a/tests/crq_key_id.c
+++ b/tests/crq_key_id.c
@@ -33,171 +33,161 @@
#include "utils.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", "crq_key_id", level, str);
+ fprintf(stderr, "%s |<%d>| %s", "crq_key_id", level, str);
}
-void
-doit (void)
+void doit(void)
{
- gnutls_x509_privkey_t pkey;
- gnutls_privkey_t abs_pkey;
- gnutls_x509_crq_t crq;
-
- size_t pkey_key_id_len;
- unsigned char *pkey_key_id = NULL;
-
- size_t crq_key_id_len;
- unsigned char *crq_key_id = NULL;
-
- gnutls_pk_algorithm_t algorithm;
-
- int ret;
-
- ret = global_init ();
- if (ret < 0)
- fail ("global_init: %d\n", ret);
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- for (algorithm = GNUTLS_PK_RSA; algorithm <= GNUTLS_PK_DSA; algorithm++)
- {
- ret = gnutls_x509_crq_init (&crq);
- if (ret < 0)
- fail ("gnutls_x509_crq_init: %d\n", ret);
-
- ret = gnutls_x509_privkey_init (&pkey);
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_init: %d\n", ret);
- }
-
- ret = gnutls_privkey_init (&abs_pkey);
- if (ret < 0)
- {
- fail ("gnutls_privkey_init: %d\n", ret);
- }
-
- ret = gnutls_x509_privkey_generate (pkey, algorithm, 1024, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_generate (rsa): %d\n", ret);
- }
- else if (debug)
- {
- success ("Key[%s] generation ok: %d\n",
- gnutls_pk_algorithm_get_name (algorithm), ret);
- }
-
- pkey_key_id_len = 0;
- ret = gnutls_x509_privkey_get_key_id (pkey, 0, pkey_key_id,
- &pkey_key_id_len);
- if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
- {
- fail ("gnutls_x509_privkey_get_key_id incorrectly returns %d\n",
- ret);
- }
-
- pkey_key_id = malloc (sizeof (unsigned char) * pkey_key_id_len);
- ret = gnutls_x509_privkey_get_key_id (pkey, 0, pkey_key_id,
- &pkey_key_id_len);
- if (ret != GNUTLS_E_SUCCESS)
- {
- fail ("gnutls_x509_privkey_get_key_id incorrectly returns %d\n",
- ret);
- }
-
- ret = gnutls_x509_crq_set_version (crq, 1);
- if (ret < 0)
- {
- fail ("gnutls_x509_crq_set_version: %d\n", ret);
- }
-
- ret = gnutls_x509_crq_set_key (crq, pkey);
- if (ret < 0)
- {
- fail ("gnutls_x509_crq_set_key: %d\n", ret);
- }
-
- ret = gnutls_x509_crq_set_dn_by_oid (crq, GNUTLS_OID_X520_COMMON_NAME,
- 0, "CN-Test", 7);
- if (ret < 0)
- {
- fail ("gnutls_x509_crq_set_dn_by_oid: %d\n", ret);
- }
-
- ret = gnutls_privkey_import_x509( abs_pkey, pkey, 0);
- if (ret < 0)
- {
- fail ("gnutls_privkey_import_x509: %d\n", ret);
- }
-
- ret = gnutls_x509_crq_privkey_sign (crq, abs_pkey, GNUTLS_DIG_SHA1, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_crq_sign: %d\n", ret);
- }
-
- ret = gnutls_x509_crq_verify (crq, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_crq_verify: %d\n", ret);
- }
-
- crq_key_id_len = 0;
- ret = gnutls_x509_crq_get_key_id (crq, 0, crq_key_id, &crq_key_id_len);
- if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
- {
- fail ("gnutls_x509_crq_get_key_id incorrectly returns %d\n", ret);
- }
-
- crq_key_id = malloc (sizeof (unsigned char) * crq_key_id_len);
- ret = gnutls_x509_crq_get_key_id (crq, 0, crq_key_id, &crq_key_id_len);
- if (ret != GNUTLS_E_SUCCESS)
- {
- fail ("gnutls_x509_crq_get_key_id incorrectly returns %d\n", ret);
- }
-
- if (crq_key_id_len == pkey_key_id_len)
- {
- ret = memcmp (crq_key_id, pkey_key_id, crq_key_id_len);
- if (ret == 0)
- {
- if (debug)
- success ("Key ids are identical. OK.\n");
- }
- else
- {
- fail ("Key ids differ incorrectly: %d\n", ret);
- }
- }
- else
- {
- fail ("Key_id lengths differ incorrectly: %d - %d\n",
- (int) crq_key_id_len, (int) pkey_key_id_len);
- }
-
-
- if (pkey_key_id)
- {
- free (pkey_key_id);
- pkey_key_id = NULL;
- }
-
- if (crq_key_id)
- {
- free (crq_key_id);
- crq_key_id = NULL;
- }
-
- gnutls_x509_crq_deinit (crq);
- gnutls_x509_privkey_deinit (pkey);
- gnutls_privkey_deinit (abs_pkey);
- }
-
- gnutls_global_deinit ();
+ gnutls_x509_privkey_t pkey;
+ gnutls_privkey_t abs_pkey;
+ gnutls_x509_crq_t crq;
+
+ size_t pkey_key_id_len;
+ unsigned char *pkey_key_id = NULL;
+
+ size_t crq_key_id_len;
+ unsigned char *crq_key_id = NULL;
+
+ gnutls_pk_algorithm_t algorithm;
+
+ int ret;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("global_init: %d\n", ret);
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ for (algorithm = GNUTLS_PK_RSA; algorithm <= GNUTLS_PK_DSA;
+ algorithm++) {
+ ret = gnutls_x509_crq_init(&crq);
+ if (ret < 0)
+ fail("gnutls_x509_crq_init: %d\n", ret);
+
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_init: %d\n", ret);
+ }
+
+ ret = gnutls_privkey_init(&abs_pkey);
+ if (ret < 0) {
+ fail("gnutls_privkey_init: %d\n", ret);
+ }
+
+ ret =
+ gnutls_x509_privkey_generate(pkey, algorithm, 1024, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_generate (rsa): %d\n",
+ ret);
+ } else if (debug) {
+ success("Key[%s] generation ok: %d\n",
+ gnutls_pk_algorithm_get_name(algorithm),
+ ret);
+ }
+
+ pkey_key_id_len = 0;
+ ret = gnutls_x509_privkey_get_key_id(pkey, 0, pkey_key_id,
+ &pkey_key_id_len);
+ if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) {
+ fail("gnutls_x509_privkey_get_key_id incorrectly returns %d\n", ret);
+ }
+
+ pkey_key_id =
+ malloc(sizeof(unsigned char) * pkey_key_id_len);
+ ret =
+ gnutls_x509_privkey_get_key_id(pkey, 0, pkey_key_id,
+ &pkey_key_id_len);
+ if (ret != GNUTLS_E_SUCCESS) {
+ fail("gnutls_x509_privkey_get_key_id incorrectly returns %d\n", ret);
+ }
+
+ ret = gnutls_x509_crq_set_version(crq, 1);
+ if (ret < 0) {
+ fail("gnutls_x509_crq_set_version: %d\n", ret);
+ }
+
+ ret = gnutls_x509_crq_set_key(crq, pkey);
+ if (ret < 0) {
+ fail("gnutls_x509_crq_set_key: %d\n", ret);
+ }
+
+ ret =
+ gnutls_x509_crq_set_dn_by_oid(crq,
+ GNUTLS_OID_X520_COMMON_NAME,
+ 0, "CN-Test", 7);
+ if (ret < 0) {
+ fail("gnutls_x509_crq_set_dn_by_oid: %d\n", ret);
+ }
+
+ ret = gnutls_privkey_import_x509(abs_pkey, pkey, 0);
+ if (ret < 0) {
+ fail("gnutls_privkey_import_x509: %d\n", ret);
+ }
+
+ ret =
+ gnutls_x509_crq_privkey_sign(crq, abs_pkey,
+ GNUTLS_DIG_SHA1, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_crq_sign: %d\n", ret);
+ }
+
+ ret = gnutls_x509_crq_verify(crq, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_crq_verify: %d\n", ret);
+ }
+
+ crq_key_id_len = 0;
+ ret =
+ gnutls_x509_crq_get_key_id(crq, 0, crq_key_id,
+ &crq_key_id_len);
+ if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) {
+ fail("gnutls_x509_crq_get_key_id incorrectly returns %d\n", ret);
+ }
+
+ crq_key_id =
+ malloc(sizeof(unsigned char) * crq_key_id_len);
+ ret =
+ gnutls_x509_crq_get_key_id(crq, 0, crq_key_id,
+ &crq_key_id_len);
+ if (ret != GNUTLS_E_SUCCESS) {
+ fail("gnutls_x509_crq_get_key_id incorrectly returns %d\n", ret);
+ }
+
+ if (crq_key_id_len == pkey_key_id_len) {
+ ret =
+ memcmp(crq_key_id, pkey_key_id,
+ crq_key_id_len);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("Key ids are identical. OK.\n");
+ } else {
+ fail("Key ids differ incorrectly: %d\n",
+ ret);
+ }
+ } else {
+ fail("Key_id lengths differ incorrectly: %d - %d\n", (int) crq_key_id_len, (int) pkey_key_id_len);
+ }
+
+
+ if (pkey_key_id) {
+ free(pkey_key_id);
+ pkey_key_id = NULL;
+ }
+
+ if (crq_key_id) {
+ free(crq_key_id);
+ crq_key_id = NULL;
+ }
+
+ gnutls_x509_crq_deinit(crq);
+ gnutls_x509_privkey_deinit(pkey);
+ gnutls_privkey_deinit(abs_pkey);
+ }
+
+ gnutls_global_deinit();
}
diff --git a/tests/cve-2008-4989.c b/tests/cve-2008-4989.c
index c054426b7f..1e54115659 100644
--- a/tests/cve-2008-4989.c
+++ b/tests/cve-2008-4989.c
@@ -37,235 +37,227 @@
verification tester. */
static const char *pem_certs[] = {
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB6zCCAVQCCQCgwnB/k0WZrDANBgkqhkiG9w0BAQUFADA9MQswCQYDVQQGEwJE\n"
- "RTEXMBUGA1UEChMOR05VIFRMUyBBdHRhY2sxFTATBgNVBAMTDGludGVybWVkaWF0\n"
- "ZTAeFw0wODExMDMxMjA1MDRaFw0wODEyMDMxMjA1MDRaMDcxCzAJBgNVBAYTAkRF\n"
- "MRcwFQYDVQQKEw5HTlUgVExTIEF0dGFjazEPMA0GA1UEAxMGc2VydmVyMIGfMA0G\n"
- "CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKdL9g5ErMLOLRCjiomZlNLhy0moWGaKIW\n"
- "aX6vyUIfh8d6FcArHoKoqhmX7ckvod50sOYPojQesDpl7gVaQNA6Ntr1VCcuNPef\n"
- "UKWtEwL0Qu9JbPnUoIYd7mAaqVQgFp6W6yzV/dp63LH4XSdzBMhpZ/EU6vZoE8Sv\n"
- "VLdqj5r6jwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAH4QRR7sZEbjW00tXYk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x8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR3\n"
+ "2HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA\n"
+ "MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7\n"
+ "W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7OR\n"
+ "tvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE\n"
+ "uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQ\n"
+ "aEfZYGDm/Ac9IiAXxPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqd\n"
+ "E8hhuvU5HIe6uL17In/2/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+\n"
+ "MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+\n"
+ "fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA==\n"
+ "-----END CERTIFICATE-----\n"
};
#define CHAIN_LENGTH (sizeof (pem_certs) / sizeof (pem_certs[0]))
static const char *pem_self_cert = {
- "-----BEGIN CERTIFICATE-----\n"
- "MIIDgjCCAmygAwIBAgIBADALBgkqhkiG9w0BAQUwSzELMAkGA1UEBhMCQlIxFDAS\n"
- "BgNVBAoTC01pbmFzIExpdnJlMSYwJAYDVQQDEx1UaGFkZXUgTGltYSBkZSBTb3V6\n"
- "YSBDYXNjYXJkbzAeFw0wODA1MzAxOTUzNDNaFw0wODExMjYxOTUzNDNaMEsxCzAJ\n"
- "BgNVBAYTAkJSMRQwEgYDVQQKEwtNaW5hcyBMaXZyZTEmMCQGA1UEAxMdVGhhZGV1\n"
- "IExpbWEgZGUgU291emEgQ2FzY2FyZG8wggEfMAsGCSqGSI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\n"
+ "8lS7Ph/f9JUYHp2DtgsQWcNQbrUZOPFBu8J4MD6cDWG5Uxwl3YASg30ZdmMDNT8B\n"
+ "HshYz0HUOAhYwVSI3J/f7LFhD5OpjSroHgE7wA9UJrerAp9f7e3e9D7kNQ8DlvLP\n"
+ "kz6Jh+5M/xD3JO1yl+evaCp3LA+z4M2xiNvtzkAEgj3t6RaJ81Sh5XGiooDYZ14R\n"
+ "DgEBYLTUfBYBPzoaahPEdG/f0kUjUBJ34fkBUSjJKURPTHJfDfA=\n"
+ "-----END CERTIFICATE-----\n"
};
-int
-main (int argc, char *argv[])
+int main(int argc, char *argv[])
{
- int ret;
- gnutls_x509_crt_t certs[3];
- gnutls_x509_crt_t ca;
- gnutls_x509_crt_t self_cert;
- gnutls_datum_t tmp;
- size_t i;
- unsigned int verify_status;
+ int ret;
+ gnutls_x509_crt_t certs[3];
+ gnutls_x509_crt_t ca;
+ gnutls_x509_crt_t self_cert;
+ gnutls_datum_t tmp;
+ size_t i;
+ unsigned int verify_status;
- ret = global_init ();
- if (ret != 0)
- {
- printf ("%d: %s\n", ret, gnutls_strerror (ret));
- return EXIT_FAILURE;
- }
+ ret = global_init();
+ if (ret != 0) {
+ printf("%d: %s\n", ret, gnutls_strerror(ret));
+ return EXIT_FAILURE;
+ }
- for (i = 0; i < CHAIN_LENGTH; i++)
- {
- ret = gnutls_x509_crt_init (&certs[i]);
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_init[%d]: %s", (int) i,
- gnutls_strerror (ret));
- exit(1);
- }
+ for (i = 0; i < CHAIN_LENGTH; i++) {
+ ret = gnutls_x509_crt_init(&certs[i]);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_init[%d]: %s",
+ (int) i, gnutls_strerror(ret));
+ exit(1);
+ }
- tmp.data = (unsigned char *) pem_certs[i];
- tmp.size = strlen (pem_certs[i]);
+ tmp.data = (unsigned char *) pem_certs[i];
+ tmp.size = strlen(pem_certs[i]);
- ret = gnutls_x509_crt_import (certs[i], &tmp, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_import[%d]: %s", (int) i,
- gnutls_strerror (ret));
- exit(1);
- }
- }
+ ret =
+ gnutls_x509_crt_import(certs[i], &tmp,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_import[%d]: %s",
+ (int) i, gnutls_strerror(ret));
+ exit(1);
+ }
+ }
- ret = gnutls_x509_crt_init (&ca);
- if (ret < 0)
- {
- fprintf(stderr, "gnutls_x509_crt_init: %s",
- gnutls_strerror (ret));
- exit(1);
- }
+ ret = gnutls_x509_crt_init(&ca);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_init: %s",
+ gnutls_strerror(ret));
+ exit(1);
+ }
- tmp.data = (unsigned char *) pem_ca;
- tmp.size = strlen (pem_ca);
+ tmp.data = (unsigned char *) pem_ca;
+ tmp.size = strlen(pem_ca);
- ret = gnutls_x509_crt_import (ca, &tmp, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf(stderr, "gnutls_x509_crt_import: %s",
- gnutls_strerror (ret));
- exit(1);
- }
+ ret = gnutls_x509_crt_import(ca, &tmp, GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_import: %s",
+ gnutls_strerror(ret));
+ exit(1);
+ }
- ret = gnutls_x509_crt_list_verify (certs, CHAIN_LENGTH,
- &ca, 1,
- NULL, 0,
- GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
- &verify_status);
- if (ret < 0)
- {
- fprintf(stderr, "gnutls_x509_crt_list_verify[%d]: %s", (int) i,
- gnutls_strerror (ret));
- exit(1);
- }
+ ret = gnutls_x509_crt_list_verify(certs, CHAIN_LENGTH,
+ &ca, 1,
+ NULL, 0,
+ GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
+ &verify_status);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_list_verify[%d]: %s",
+ (int) i, gnutls_strerror(ret));
+ exit(1);
+ }
- if (verify_status != (GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID))
- {
- fprintf( stderr, "verify_status: %d", verify_status);
- exit(1);
- }
+ if (verify_status !=
+ (GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID)) {
+ fprintf(stderr, "verify_status: %d", verify_status);
+ exit(1);
+ }
- gnutls_x509_crt_deinit (ca);
- for (i = 0; i < CHAIN_LENGTH; i++)
- gnutls_x509_crt_deinit (certs[i]);
+ gnutls_x509_crt_deinit(ca);
+ for (i = 0; i < CHAIN_LENGTH; i++)
+ gnutls_x509_crt_deinit(certs[i]);
- /* Also test chain length of 1, since the initial patch to solve the
- problem caused a crash in this situation. */
+ /* Also test chain length of 1, since the initial patch to solve the
+ problem caused a crash in this situation. */
- ret = gnutls_x509_crt_init (&self_cert);
- if (ret < 0)
- {
- fprintf( stderr, "gnutls_x509_crt_init: %s",
- gnutls_strerror (ret));
- exit(1);
- }
+ ret = gnutls_x509_crt_init(&self_cert);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_init: %s",
+ gnutls_strerror(ret));
+ exit(1);
+ }
- tmp.data = (unsigned char *) pem_self_cert;
- tmp.size = strlen (pem_self_cert);
+ tmp.data = (unsigned char *) pem_self_cert;
+ tmp.size = strlen(pem_self_cert);
- ret = gnutls_x509_crt_import (self_cert, &tmp, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf (stderr, "gnutls_x509_crt_import: %s",
- gnutls_strerror (ret));
- exit(1);
- }
- ret = gnutls_x509_crt_list_verify (&self_cert, 1,
- &self_cert, 1,
- NULL, 0,
- GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
- &verify_status);
- if (ret < 0)
- {
- fprintf(stderr, "gnutls_x509_crt_list_verify[%d]: %s", (int) i,
- gnutls_strerror (ret));
- exit(1);
- }
+ ret = gnutls_x509_crt_import(self_cert, &tmp, GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_import: %s",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+ ret = gnutls_x509_crt_list_verify(&self_cert, 1,
+ &self_cert, 1,
+ NULL, 0,
+ GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
+ &verify_status);
+ if (ret < 0) {
+ fprintf(stderr, "gnutls_x509_crt_list_verify[%d]: %s",
+ (int) i, gnutls_strerror(ret));
+ exit(1);
+ }
- if (verify_status != 0)
- {
- fprintf(stderr, "verify_status: %d", verify_status);
- exit(1);
- }
+ if (verify_status != 0) {
+ fprintf(stderr, "verify_status: %d", verify_status);
+ exit(1);
+ }
- gnutls_x509_crt_deinit (self_cert);
+ gnutls_x509_crt_deinit(self_cert);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- return 0;
+ return 0;
}
diff --git a/tests/cve-2009-1415.c b/tests/cve-2009-1415.c
index f9b3d6c4e3..8f27ded013 100644
--- a/tests/cve-2009-1415.c
+++ b/tests/cve-2009-1415.c
@@ -50,67 +50,68 @@
#include <gnutls/abstract.h>
static char dsa_cert[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIDbzCCAtqgAwIBAgIERiYdRTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTQxWhcNMDgwNDE3MTMyOTQxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCCAbQwggEpBgcqhkjOOAQBMIIBHAKBgLmE9VqBvhoNxYpzjwybL5u2DkvD\n"
- "dBp/ZK2d8yjFoEe8m1dW8ZfVfjcD6fJM9OOLfzCjXS+7oaI3wuo1jx+xX6aiXwHx\n"
- "IzYr5E8vLd2d1TqmOa96UXzSJY6XdM8exXtLdkOBBx8GFLhuW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9glwxnet2+avzgUQDUFwUSxOhodpyeaACXD\n"
+ "o0gGVpcH8sOBTQ+aTdM37hGkPxoXjtIkR/LgG5nP2H2JRd5TkW8l13JdM4MJFB4W\n"
+ "QcDzQ8REwidsfh9uKAluk1c/KQ==\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t dsa_cert_dat = {
- (void*)dsa_cert, sizeof (dsa_cert)
+ (void *) dsa_cert, sizeof(dsa_cert)
};
-int
-main (void)
+int main(void)
{
- gnutls_x509_crt_t crt;
- gnutls_pubkey_t pubkey;
- gnutls_datum_t data = { (void *) "foo", 3 };
- gnutls_datum_t sig = { (void *) "bar", 3 };
- int ret;
+ gnutls_x509_crt_t crt;
+ gnutls_pubkey_t pubkey;
+ gnutls_datum_t data = { (void *) "foo", 3 };
+ gnutls_datum_t sig = { (void *) "bar", 3 };
+ int ret;
- global_init ();
+ global_init();
- ret = gnutls_x509_crt_init (&crt);
- if (ret < 0)
- return 1;
+ ret = gnutls_x509_crt_init(&crt);
+ if (ret < 0)
+ return 1;
- ret = gnutls_pubkey_init (&pubkey);
- if (ret < 0)
- return 1;
+ ret = gnutls_pubkey_init(&pubkey);
+ if (ret < 0)
+ return 1;
- ret = gnutls_x509_crt_import (crt, &dsa_cert_dat, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- return 1;
+ ret =
+ gnutls_x509_crt_import(crt, &dsa_cert_dat,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ return 1;
- ret = gnutls_pubkey_import_x509( pubkey, crt, 0);
- if (ret < 0)
- return 1;
+ ret = gnutls_pubkey_import_x509(pubkey, crt, 0);
+ if (ret < 0)
+ return 1;
- ret = gnutls_pubkey_verify_data (pubkey, 0, &data, &sig);
- if (ret < 0 && ret != GNUTLS_E_PK_SIG_VERIFY_FAILED)
- return 1;
+ ret = gnutls_pubkey_verify_data(pubkey, 0, &data, &sig);
+ if (ret < 0 && ret != GNUTLS_E_PK_SIG_VERIFY_FAILED)
+ return 1;
- //printf ("success!\n");
+ //printf ("success!\n");
- gnutls_x509_crt_deinit (crt);
- gnutls_pubkey_deinit( pubkey);
- gnutls_global_deinit ();
+ gnutls_x509_crt_deinit(crt);
+ gnutls_pubkey_deinit(pubkey);
+ gnutls_global_deinit();
- return 0;
+ return 0;
}
diff --git a/tests/cve-2009-1416.c b/tests/cve-2009-1416.c
index 667e1958e0..5bfb43cd7b 100644
--- a/tests/cve-2009-1416.c
+++ b/tests/cve-2009-1416.c
@@ -46,41 +46,39 @@
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
-int
-main (void)
+int main(void)
{
- gnutls_x509_privkey_t key;
- gnutls_datum_t p, q, g, y, x;
- int ret;
+ gnutls_x509_privkey_t key;
+ gnutls_datum_t p, q, g, y, x;
+ int ret;
- global_init ();
+ global_init();
- ret = gnutls_x509_privkey_init (&key);
- if (ret < 0)
- return 1;
+ ret = gnutls_x509_privkey_init(&key);
+ if (ret < 0)
+ return 1;
- ret = gnutls_x509_privkey_generate (key, GNUTLS_PK_DSA, 512, 0);
- if (ret < 0)
- return 1;
+ ret = gnutls_x509_privkey_generate(key, GNUTLS_PK_DSA, 512, 0);
+ if (ret < 0)
+ return 1;
- ret = gnutls_x509_privkey_export_dsa_raw (key, &p, &q, &g, &y, &x);
- if (ret < 0)
- return 1;
+ ret = gnutls_x509_privkey_export_dsa_raw(key, &p, &q, &g, &y, &x);
+ if (ret < 0)
+ return 1;
- if (q.size == 3 && memcmp (q.data, "\x01\x00\x01", 3) == 0)
- {
- printf ("buggy\n");
- return 1;
- }
+ if (q.size == 3 && memcmp(q.data, "\x01\x00\x01", 3) == 0) {
+ printf("buggy\n");
+ return 1;
+ }
- gnutls_free (p.data);
- gnutls_free (q.data);
- gnutls_free (g.data);
- gnutls_free (y.data);
- gnutls_free (x.data);
+ gnutls_free(p.data);
+ gnutls_free(q.data);
+ gnutls_free(g.data);
+ gnutls_free(y.data);
+ gnutls_free(x.data);
- gnutls_x509_privkey_deinit (key);
- gnutls_global_deinit ();
+ gnutls_x509_privkey_deinit(key);
+ gnutls_global_deinit();
- return 0;
+ return 0;
}
diff --git a/tests/dhepskself.c b/tests/dhepskself.c
index dcb91fa15e..64db452d26 100644
--- a/tests/dhepskself.c
+++ b/tests/dhepskself.c
@@ -33,10 +33,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -58,94 +57,86 @@ main (int argc, char** argv)
#define MAX_BUF 1024
#define MSG "Hello TLS"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
-static void
-client (int sd)
+static void client(int sd)
{
- int ret, ii;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_psk_client_credentials_t pskcred;
- const gnutls_datum_t key = { (void *) "DEADBEEF", 8 };
-
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (5);
-
- gnutls_psk_allocate_client_credentials (&pskcred);
- gnutls_psk_set_client_credentials (pskcred, "test", &key,
- GNUTLS_PSK_KEY_HEX);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NORMAL:+DHE-PSK", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_PSK, pskcred);
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug)
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- fputc (buffer[ii], stdout);
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
- close (sd);
-
- gnutls_deinit (session);
-
- gnutls_psk_free_client_credentials (pskcred);
-
- gnutls_global_deinit ();
+ int ret, ii;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_psk_client_credentials_t pskcred;
+ const gnutls_datum_t key = { (void *) "DEADBEEF", 8 };
+
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(5);
+
+ gnutls_psk_allocate_client_credentials(&pskcred);
+ gnutls_psk_set_client_credentials(pskcred, "test", &key,
+ GNUTLS_PSK_KEY_HEX);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, "NORMAL:+DHE-PSK", NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_PSK, pskcred);
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++)
+ fputc(buffer[ii], stdout);
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ end:
+
+ close(sd);
+
+ gnutls_deinit(session);
+
+ gnutls_psk_free_client_credentials(pskcred);
+
+ gnutls_global_deinit();
}
/* This is a sample TLS 1.0 echo server, for PSK authentication.
@@ -156,50 +147,50 @@ end:
/* These are global */
gnutls_psk_server_credentials_t server_pskcred;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct(session, "NORMAL:+DHE-PSK", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, "NORMAL:+DHE-PSK", NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_PSK, server_pskcred);
+ gnutls_credentials_set(session, GNUTLS_CRD_PSK, server_pskcred);
- return session;
+ return session;
}
static gnutls_dh_params_t dh_params;
-static int
-generate_dh_params (void)
+static int generate_dh_params(void)
{
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- /* Generate Diffie-Hellman parameters - for use with DHE
- * kx algorithms. These should be discarded and regenerated
- * once a day, once a week or once a month. Depending on the
- * security requirements.
- */
- gnutls_dh_params_init (&dh_params);
- return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ /* Generate Diffie-Hellman parameters - for use with DHE
+ * kx algorithms. These should be discarded and regenerated
+ * once a day, once a week or once a month. Depending on the
+ * security requirements.
+ */
+ gnutls_dh_params_init(&dh_params);
+ return gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
}
static int
-pskfunc (gnutls_session_t session, const char *username, gnutls_datum_t * key)
+pskfunc(gnutls_session_t session, const char *username,
+ gnutls_datum_t * key)
{
- if (debug)
- printf ("psk callback to get %s's password\n", username);
- key->data = gnutls_malloc (4);
- key->data[0] = 0xDE;
- key->data[1] = 0xAD;
- key->data[2] = 0xBE;
- key->data[3] = 0xEF;
- key->size = 4;
- return 0;
+ if (debug)
+ printf("psk callback to get %s's password\n", username);
+ key->data = gnutls_malloc(4);
+ key->data[0] = 0xDE;
+ key->data[1] = 0xAD;
+ key->data[2] = 0xBE;
+ key->data[3] = 0xEF;
+ key->size = 4;
+ return 0;
}
int err, ret;
@@ -208,111 +199,102 @@ gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
-static void
-server (int sd)
+static void server(int sd)
{
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- generate_dh_params ();
-
- gnutls_psk_allocate_server_credentials (&server_pskcred);
- gnutls_psk_set_server_credentials_function (server_pskcred, pskfunc);
- gnutls_psk_set_server_dh_params (server_pskcred, dh_params);
-
- session = initialize_tls_session ();
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- return;
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
- gnutls_deinit (session);
-
- gnutls_psk_free_server_credentials (server_pskcred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ generate_dh_params();
+
+ gnutls_psk_allocate_server_credentials(&server_pskcred);
+ gnutls_psk_set_server_credentials_function(server_pskcred,
+ pskfunc);
+ gnutls_psk_set_server_dh_params(server_pskcred, dh_params);
+
+ session = initialize_tls_session();
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+ gnutls_deinit(session);
+
+ gnutls_psk_free_server_credentials(server_pskcred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- pid_t child;
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (sockets[0]);
- wait (&status);
- }
- else
- client (sockets[1]);
+ pid_t child;
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(sockets[0]);
+ wait(&status);
+ } else
+ client(sockets[1]);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/dn.c b/tests/dn.c
index e8e12c3ada..05710fda3b 100644
--- a/tests/dn.c
+++ b/tests/dn.c
@@ -30,105 +30,100 @@
#include "utils.h"
static char pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIE8jCCAtqgAwIBAgIDAkQVMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv\n"
- "b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ\n"
- "Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y\n"
- "dEBjYWNlcnQub3JnMB4XDTA2MDUxNTE1MjEzMVoXDTA3MDUxNTE1MjEzMVowPjEY\n"
- "MBYGA1UEAxMPQ0FjZXJ0IFdvVCBVc2VyMSIwIAYJKoZIhvcNAQkBFhNzaW1vbkBq\n"
- "b3NlZnNzb24ub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuddO\n"
- "vxr7gfof8Ejtk/EOC16m0UdymQhwQwfPM5wWKJCJK9l5GoXSHe+s/+6HPLhXo2do\n"
- "byUS6X3w7ODO6MGnlWALJUapUa2LinofYwYWFVlOlwyuN2lW+xQgeQjn24R8Glzl\n"
- "KQ2f5C9JOE3RSGnHr7VH/6JJ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3lcq\n"
+ "+dmDgpDn168TY1Iug80uVKg7AfkLrA==\n" "-----END CERTIFICATE-----\n";
+
+static void print_dn(gnutls_x509_dn_t dn)
{
- int i, j, ret = 0;
- gnutls_x509_ava_st ava;
-
- for (i = 0; ret == 0; i++)
- for (j = 0; ret == 0; j++)
- {
- ret = gnutls_x509_dn_get_rdn_ava (dn, i, j, &ava);
- if (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
- {
- if (j > 0)
- {
- j = 0;
- ret = 0;
- }
- break;
- }
- if (ret < 0)
- fail ("get_rdn_ava %d\n", ret);
- if (debug)
- printf ("dn[%d][%d] OID=%.*s\n\tDATA=%.*s\n", i, j,
- ava.oid.size, ava.oid.data, ava.value.size, ava.value.data);
- }
+ int i, j, ret = 0;
+ gnutls_x509_ava_st ava;
+
+ for (i = 0; ret == 0; i++)
+ for (j = 0; ret == 0; j++) {
+ ret = gnutls_x509_dn_get_rdn_ava(dn, i, j, &ava);
+ if (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) {
+ if (j > 0) {
+ j = 0;
+ ret = 0;
+ }
+ break;
+ }
+ if (ret < 0)
+ fail("get_rdn_ava %d\n", ret);
+ if (debug)
+ printf
+ ("dn[%d][%d] OID=%.*s\n\tDATA=%.*s\n",
+ i, j, ava.oid.size, ava.oid.data,
+ ava.value.size, ava.value.data);
+ }
}
-void
-doit (void)
+void doit(void)
{
- int ret;
- gnutls_datum_t pem_cert = { (unsigned char*)pem, sizeof (pem) };
- gnutls_x509_crt_t cert;
- gnutls_x509_dn_t xdn;
-
- ret = global_init ();
- if (ret < 0)
- fail ("init %d\n", ret);
-
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- fail ("crt_init %d\n", ret);
-
- ret = gnutls_x509_crt_import (cert, &pem_cert, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("crt_import %d\n", ret);
-
- ret = gnutls_x509_crt_get_issuer (cert, &xdn);
- if (ret < 0)
- fail ("get_issuer %d\n", ret);
-
- if (debug)
- {
- printf ("Issuer:\n");
- print_dn (xdn);
- }
-
- ret = gnutls_x509_crt_get_subject (cert, &xdn);
- if (ret < 0)
- fail ("get_subject %d\n", ret);
-
- if (debug)
- {
- printf ("Subject:\n");
- print_dn (xdn);
- }
-
- if (debug)
- success ("done\n");
-
- gnutls_x509_crt_deinit (cert);
- gnutls_global_deinit ();
+ int ret;
+ gnutls_datum_t pem_cert = { (unsigned char *) pem, sizeof(pem) };
+ gnutls_x509_crt_t cert;
+ gnutls_x509_dn_t xdn;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("init %d\n", ret);
+
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0)
+ fail("crt_init %d\n", ret);
+
+ ret = gnutls_x509_crt_import(cert, &pem_cert, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("crt_import %d\n", ret);
+
+ ret = gnutls_x509_crt_get_issuer(cert, &xdn);
+ if (ret < 0)
+ fail("get_issuer %d\n", ret);
+
+ if (debug) {
+ printf("Issuer:\n");
+ print_dn(xdn);
+ }
+
+ ret = gnutls_x509_crt_get_subject(cert, &xdn);
+ if (ret < 0)
+ fail("get_subject %d\n", ret);
+
+ if (debug) {
+ printf("Subject:\n");
+ print_dn(xdn);
+ }
+
+ if (debug)
+ success("done\n");
+
+ gnutls_x509_crt_deinit(cert);
+ gnutls_global_deinit();
}
diff --git a/tests/dn2.c b/tests/dn2.c
index a490c4dccb..cd750782c5 100644
--- a/tests/dn2.c
+++ b/tests/dn2.c
@@ -30,75 +30,75 @@
#include "utils.h"
static char pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIFpzCCBI+gAwIBAgIQSOyh48ZYvgTFR8HspnpkMzANBgkqhkiG9w0BAQUFADCB\n"
- "vjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n"
- "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJ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Wh0dHA6Ly9FVkludGwtY3JsLnZlcmlzaWduLmNvbS9FVkludGwyMDA2\n"
+ "LmNybDAoBgNVHSUEITAfBggrBgEFBQcDAQYIKwYBBQUHAwIGCWCGSAGG+EIEATAf\n"
+ "BgNVHSMEGDAWgBROQ8gddu83U3pP8lhvlPM44tW93zB2BggrBgEFBQcBAQRqMGgw\n"
+ "KwYIKwYBBQUHMAGGH2h0dHA6Ly9FVkludGwtb2NzcC52ZXJpc2lnbi5jb20wOQYI\n"
+ "KwYBBQUHMAKGLWh0dHA6Ly9FVkludGwtYWlhLnZlcmlzaWduLmNvbS9FVkludGwy\n"
+ "MDA2LmNlcjBuBggrBgEFBQcBDARiMGChXqBcMFowWDBWFglpbWFnZS9naWYwITAf\n"
+ "MAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsHiyEFGDAmFiRodHRwOi8vbG9nby52\n"
+ "ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJKoZIhvcNAQEFBQADggEBAKpNJQYO\n"
+ "JTp34I24kvRF01WpOWOmfBx4K1gqruda/7U0UZqgTgBJVvwraKf6WeTZpHRqDCTw\n"
+ "iwySv7jil+gLMT0qIZxL1pII90z71tz08h8xYi1MOLeciG87O9C5pteL/iEtiMxB\n"
+ "96B6WWBo9mzgwSM1d8LDhrarZ7uQhm+kBAMyEXhmDnCPWhvExvxJzjEmOlxjThyP\n"
+ "2yvIgfLyDfplRe+jUbsY7YNe08eEyoLRq1jwPuRWTaEx2gA7C6pq45747/HkJrtF\n"
+ "ya3ULM/AJv6Nj6pobxzQ5rEkUGEwKavu7GMjLrSMnHrbVCiQrn1v6c7B9nSPA31L\n"
+ "/do1TDFI0vSl5+M=\n" "-----END CERTIFICATE-----\n";
static const char *info =
- "subject `jurisdictionOfIncorporationCountryName=DE,jurisdictionOfIncorporationLocalityName=Muenchen,businessCategory=V1.0\\, Clause 5.(b),serialNumber=HRB 144261,C=DE,postalCode=80807,ST=Bavaria,L=Muenchen,street=Frankfurter Ring 129,O=GMX GmbH,CN=www.gmx.de', issuer `C=US,O=VeriSign\\, Inc.,OU=VeriSign Trust Network,OU=Terms of use at https://www.verisign.com/rpa (c)06,CN=VeriSign Class 3 Extended Validation SSL SGC CA', RSA key 1024 bits, signed using RSA-SHA1, activated `2008-11-13 00:00:00 UTC', expires `2009-11-13 23:59:59 UTC', SHA-1 fingerprint `7ece297c45d5b17685224b4e929a30e91a9553cb'";
+ "subject `jurisdictionOfIncorporationCountryName=DE,jurisdictionOfIncorporationLocalityName=Muenchen,businessCategory=V1.0\\, Clause 5.(b),serialNumber=HRB 144261,C=DE,postalCode=80807,ST=Bavaria,L=Muenchen,street=Frankfurter Ring 129,O=GMX GmbH,CN=www.gmx.de', issuer `C=US,O=VeriSign\\, Inc.,OU=VeriSign Trust Network,OU=Terms of use at https://www.verisign.com/rpa (c)06,CN=VeriSign Class 3 Extended Validation SSL SGC CA', RSA key 1024 bits, signed using RSA-SHA1, activated `2008-11-13 00:00:00 UTC', expires `2009-11-13 23:59:59 UTC', SHA-1 fingerprint `7ece297c45d5b17685224b4e929a30e91a9553cb'";
-void
-doit (void)
+void doit(void)
{
- gnutls_datum_t pem_cert = { (void*)pem, sizeof (pem) };
- gnutls_x509_crt_t cert;
- gnutls_datum_t out;
- int ret;
+ gnutls_datum_t pem_cert = { (void *) pem, sizeof(pem) };
+ gnutls_x509_crt_t cert;
+ gnutls_datum_t out;
+ int ret;
- ret = global_init ();
- if (ret < 0)
- fail ("init %d\n", ret);
+ ret = global_init();
+ if (ret < 0)
+ fail("init %d\n", ret);
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- fail ("crt_init %d\n", ret);
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0)
+ fail("crt_init %d\n", ret);
- ret = gnutls_x509_crt_import (cert, &pem_cert, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("crt_import %d\n", ret);
+ ret = gnutls_x509_crt_import(cert, &pem_cert, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("crt_import %d\n", ret);
- ret = gnutls_x509_crt_print (cert, GNUTLS_CRT_PRINT_ONELINE, &out);
- if (ret < 0)
- fail ("x509_crt_print %d\n", ret);
+ ret = gnutls_x509_crt_print(cert, GNUTLS_CRT_PRINT_ONELINE, &out);
+ if (ret < 0)
+ fail("x509_crt_print %d\n", ret);
- if (out.size != strlen (info) ||
- strcasecmp ((char*)out.data, info) != 0)
- fail ("comparison fail (%d/%d)\nexpect: %s\n got: %.*s\n",
- out.size, (int) strlen (info), info, out.size, out.data);
+ if (out.size != strlen(info) ||
+ strcasecmp((char *) out.data, info) != 0)
+ fail("comparison fail (%d/%d)\nexpect: %s\n got: %.*s\n",
+ out.size, (int) strlen(info), info, out.size,
+ out.data);
- gnutls_x509_crt_deinit (cert);
- gnutls_global_deinit ();
- gnutls_free (out.data);
+ gnutls_x509_crt_deinit(cert);
+ gnutls_global_deinit();
+ gnutls_free(out.data);
- if (debug)
- success ("done\n");
+ if (debug)
+ success("done\n");
}
diff --git a/tests/dtls/dtls-stress.c b/tests/dtls/dtls-stress.c
index 7e758bbbf3..ebbfc09342 100644
--- a/tests/dtls/dtls-stress.c
+++ b/tests/dtls/dtls-stress.c
@@ -107,13 +107,14 @@ typedef struct {
typedef struct {
gnutls_datum_t packets[5];
- int* order;
+ int *order;
int count;
} filter_permute_state_t;
-typedef void (*filter_fn)(gnutls_transport_ptr_t, const unsigned char*, size_t);
+typedef void (*filter_fn) (gnutls_transport_ptr_t, const unsigned char *,
+ size_t);
-typedef int (*match_fn)(const unsigned char*, size_t);
+typedef int (*match_fn) (const unsigned char *, size_t);
enum role { SERVER, CLIENT };
@@ -122,128 +123,201 @@ enum role { SERVER, CLIENT };
// {{{ static data
static int permutations2[2][2]
- = { { 0, 1 }, { 1, 0 } };
+= { {0, 1}, {1, 0} };
-static const char* permutation_names2[]
- = { "01", "10", 0 };
+static const char *permutation_names2[]
+= { "01", "10", 0 };
static int permutations3[6][3]
- = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 }, { 1, 2, 0 }, { 2, 0, 1 }, { 2, 1, 0 } };
+= { {0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0} };
-static const char* permutation_names3[]
- = { "012", "021", "102", "120", "201", "210", 0 };
+static const char *permutation_names3[]
+= { "012", "021", "102", "120", "201", "210", 0 };
static int permutations5[120][5]
- = { { 0, 1, 2, 3, 4 }, { 0, 2, 1, 3, 4 }, { 1, 0, 2, 3, 4 }, { 1, 2, 0, 3, 4 }, { 2, 0, 1, 3, 4 }, { 2, 1, 0, 3, 4 },
- { 0, 1, 3, 2, 4 }, { 0, 2, 3, 1, 4 }, { 1, 0, 3, 2, 4 }, { 1, 2, 3, 0, 4 }, { 2, 0, 3, 1, 4 }, { 2, 1, 3, 0, 4 },
- { 0, 3, 1, 2, 4 }, { 0, 3, 2, 1, 4 }, { 1, 3, 0, 2, 4 }, { 1, 3, 2, 0, 4 }, { 2, 3, 0, 1, 4 }, { 2, 3, 1, 0, 4 },
- { 3, 0, 1, 2, 4 }, { 3, 0, 2, 1, 4 }, { 3, 1, 0, 2, 4 }, { 3, 1, 2, 0, 4 }, { 3, 2, 0, 1, 4 }, { 3, 2, 1, 0, 4 },
- { 0, 1, 2, 4, 3 }, { 0, 2, 1, 4, 3 }, { 1, 0, 2, 4, 3 }, { 1, 2, 0, 4, 3 }, { 2, 0, 1, 4, 3 }, { 2, 1, 0, 4, 3 },
- { 0, 1, 3, 4, 2 }, { 0, 2, 3, 4, 1 }, { 1, 0, 3, 4, 2 }, { 1, 2, 3, 4, 0 }, { 2, 0, 3, 4, 1 }, { 2, 1, 3, 4, 0 },
- { 0, 3, 1, 4, 2 }, { 0, 3, 2, 4, 1 }, { 1, 3, 0, 4, 2 }, { 1, 3, 2, 4, 0 }, { 2, 3, 0, 4, 1 }, { 2, 3, 1, 4, 0 },
- { 3, 0, 1, 4, 2 }, { 3, 0, 2, 4, 1 },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 0, 1, 3 }, { 4, 2, 1, 0, 3 },
- { 4, 0, 1, 3, 2 }, { 4, 0, 2, 3, 1 }, { 4, 1, 0, 3, 2 }, { 4, 1, 2, 3, 0 }, { 4, 2, 0, 3, 1 }, { 4, 2, 1, 3, 0 },
- { 4, 0, 3, 1, 2 }, { 4, 0, 3, 2, 1 }, { 4, 1, 3, 0, 2 }, { 4, 1, 3, 2, 0 }, { 4, 2, 3, 0, 1 }, { 4, 2, 3, 1, 0 },
- { 4, 3, 0, 1, 2 }, { 4, 3, 0, 2, 1 }, { 4, 3, 1, 0, 2 }, { 4, 3, 1, 2, 0 }, { 4, 3, 2, 0, 1 }, { 4, 3, 2, 1, 0 } };
-
-static const char* permutation_names5[]
- = { "01234", "02134", "10234", "12034", "20134", "21034", "01324", "02314", "10324", "12304", "20314", "21304",
- "03124", "03214", "13024", "13204", "23014", "23104", "30124", "30214", "31024", "31204", "32014", "32104",
- "01243", "02143", "10243", "12043", "20143", "21043", "01342", "02341", "10342", "12340", "20341", "21340",
- "03142", "03241", "13042", "13240", "23041", "23140", "30142", "30241", "31042", "31240", "32041", "32140",
- "01423", "02413", "10423", "12403", "20413", "21403", "01432", "02431", "10432", "12430", "20431", "21430",
- "03412", "03421", "13402", "13420", "23401", "23410", "30412", "30421", "31402", "31420", "32401", "32410",
- "04123", "04213", "14023", "14203", "24013", "24103", "04132", "04231", "14032", "14230", "24031", "24130",
- "04312", "04321", "14302", "14320", "24301", "24310", "34012", "34021", "34102", "34120", "34201", "34210",
- "40123", "40213", "41023", "41203", "42013", "42103", "40132", "40231", "41032", "41230", "42031", "42130",
- "40312", "40321", "41302", "41320", "42301", "42310", "43012", "43021", "43102", "43120", "43201", "43210", 0 };
-
-static const char* filter_names[8]
- = { "SHello",
- "SKeyExchange",
- "SHelloDone",
- "CKeyExchange",
- "CChangeCipherSpec",
- "CFinished",
- "SChangeCipherSpec",
- "SFinished" };
-
-static const char* filter_names_full[12]
- = { "SHello",
- "SCertificate",
- "SKeyExchange",
- "SCertificateRequest",
- "SHelloDone",
- "CCertificate",
- "CKeyExchange",
- "CCertificateVerify",
- "CChangeCipherSpec",
- "CFinished",
- "SChangeCipherSpec",
- "SFinished" };
+= { {0, 1, 2, 3, 4}, {0, 2, 1, 3, 4}, {1, 0, 2, 3, 4}, {1, 2, 0, 3, 4}, {2,
+ 0,
+ 1,
+ 3,
+ 4},
+ {2, 1, 0, 3, 4},
+{0, 1, 3, 2, 4}, {0, 2, 3, 1, 4}, {1, 0, 3, 2, 4}, {1, 2, 3, 0, 4}, {2, 0,
+ 3, 1,
+ 4},
+ {2, 1, 3, 0, 4},
+{0, 3, 1, 2, 4}, {0, 3, 2, 1, 4}, {1, 3, 0, 2, 4}, {1, 3, 2, 0, 4}, {2, 3,
+ 0, 1,
+ 4},
+ {2, 3, 1, 0, 4},
+{3, 0, 1, 2, 4}, {3, 0, 2, 1, 4}, {3, 1, 0, 2, 4}, {3, 1, 2, 0, 4}, {3, 2,
+ 0, 1,
+ 4},
+ {3, 2, 1, 0, 4},
+{0, 1, 2, 4, 3}, {0, 2, 1, 4, 3}, {1, 0, 2, 4, 3}, {1, 2, 0, 4, 3}, {2, 0,
+ 1, 4,
+ 3},
+ {2, 1, 0, 4, 3},
+{0, 1, 3, 4, 2}, {0, 2, 3, 4, 1}, {1, 0, 3, 4, 2}, {1, 2, 3, 4, 0}, {2, 0,
+ 3, 4,
+ 1},
+ {2, 1, 3, 4, 0},
+{0, 3, 1, 4, 2}, {0, 3, 2, 4, 1}, {1, 3, 0, 4, 2}, {1, 3, 2, 4, 0}, {2, 3,
+ 0, 4,
+ 1},
+ {2, 3, 1, 4, 0},
+{3, 0, 1, 4, 2}, {3, 0, 2, 4, 1}, {3, 1, 0, 4, 2}, {3, 1, 2, 4, 0}, {3, 2,
+ 0, 4,
+ 1},
+ {3, 2, 1, 4, 0},
+{0, 1, 4, 2, 3}, {0, 2, 4, 1, 3}, {1, 0, 4, 2, 3}, {1, 2, 4, 0, 3}, {2, 0,
+ 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{4, 1, 3, 2, 0}, {4, 2,
+ 3, 0,
+ 1},
+ {4, 2, 3, 1, 0},
+{4, 3, 0, 1, 2}, {4, 3, 0, 2, 1}, {4, 3, 1, 0, 2}, {4, 3, 1, 2, 0}, {4, 3,
+ 2, 0,
+ 1},
+ {4, 3, 2, 1, 0}
+};
+
+static const char *permutation_names5[]
+ = { "01234", "02134", "10234", "12034", "20134", "21034", "01324",
+ "02314", "10324", "12304", "20314", "21304",
+ "03124", "03214", "13024", "13204", "23014", "23104", "30124",
+ "30214", "31024", "31204", "32014", "32104",
+ "01243", "02143", "10243", "12043", "20143", "21043", "01342",
+ "02341", "10342", "12340", "20341", "21340",
+ "03142", "03241", "13042", "13240", "23041", "23140", "30142",
+ "30241", "31042", "31240", "32041", "32140",
+ "01423", "02413", "10423", "12403", "20413", "21403", "01432",
+ "02431", "10432", "12430", "20431", "21430",
+ "03412", "03421", "13402", "13420", "23401", "23410", "30412",
+ "30421", "31402", "31420", "32401", "32410",
+ "04123", "04213", "14023", "14203", "24013", "24103", "04132",
+ "04231", "14032", "14230", "24031", "24130",
+ "04312", "04321", "14302", "14320", "24301", "24310", "34012",
+ "34021", "34102", "34120", "34201", "34210",
+ "40123", "40213", "41023", "41203", "42013", "42103", "40132",
+ "40231", "41032", "41230", "42031", "42130",
+ "40312", "40321", "41302", "41320", "42301", "42310", "43012",
+ "43021", "43102", "43120", "43201", "43210", 0
+};
+
+static const char *filter_names[8]
+ = { "SHello",
+ "SKeyExchange",
+ "SHelloDone",
+ "CKeyExchange",
+ "CChangeCipherSpec",
+ "CFinished",
+ "SChangeCipherSpec",
+ "SFinished"
+};
+
+static const char *filter_names_full[12]
+ = { "SHello",
+ "SCertificate",
+ "SKeyExchange",
+ "SCertificateRequest",
+ "SHelloDone",
+ "CCertificate",
+ "CKeyExchange",
+ "CCertificateVerify",
+ "CChangeCipherSpec",
+ "CFinished",
+ "SChangeCipherSpec",
+ "SFinished"
+};
static const unsigned char PUBKEY[] =
- "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
- "\n"
- "mI0ETz0XRAEEAKXSU/tg2yGvoKf/r1pdzj7dnfPHeS+BRiT34763uUhibAbTgMkp\n"
- "v44OlBPiAaZ54uuXVkz8e4pgvrBgQwIRtNp3xPaWF1CfC4F+V4LdZV8l8IG+AfES\n"
- "K0GbfUS4q8vjnPJ0TyxnXE2KtbcRdzZzWBshJ8KChKwbH2vvrMrlmEeZABEBAAG0\n"
- "CHRlc3Qga2V5iLgEEwECACIFAk89F0QCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4B\n"
- "AheAAAoJEMNjhmkfkLY9J/YD+wYZ2BD/0/c5gkkDP2NlVvrLGyFmEwQcR7DcaQYB\n"
- "P3/Teq2gnscZ5Xm/z1qgGEpwmaVfVHY8mfEj8bYI8jAu0v1C1jCtJPUTmxf9tmkZ\n"
- "QYFNR8T+F5Xae2XseOH70lSN/AEiW02BEBFlGBx0a3T30muFfqi/KawaE7KKn2e4\n"
- "uNWvuI0ETz0XRAEEAKgZExsb7Lf9P3DmwJSvNVdkGVny7wr4/M1s0CDX20NkO7Y1\n"
- "Ao9g+qFo5MlCOEuzjVaEYmM+rro7qyxmDKsaNIzZF1VN5UeYgPFyLcBK7C+QwUqw\n"
- "1PUl/w4dFq8neQyqIPUVGRwQPlwpkkabRPNT3t/7KgDJvYzV9uu+cXCyfqErABEB\n"
- "AAGInwQYAQIACQUCTz0XRAIbDAAKCRDDY4ZpH5C2PTBtBACVsR6l4HtuzQb5WFQt\n"
- "sD/lQEk6BEY9aVfK957Oj+A4alGEGObToqVJFo/nq+P7aWExIXucJQRL8lYnC7u+\n"
- "GjPVCun5TYzKMiryxHPkQr9NBx4hh8JjkDCc8nAgI3il49uPYkmsv70CgqJFFtT8\n"
- "NfM+8fS537I+XA+hfjt20NUFIA==\n"
- "=oD3a\n"
- "-----END PGP PUBLIC KEY BLOCK-----\n";
-
-static const unsigned char PRIVKEY[] =
- "-----BEGIN PGP PRIVATE KEY BLOCK-----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AEA\n"
+ "A/4wX+brqkGZQTv8lateHn3PRHM3O34nPjgiNeo/SV9EKZg1e1PdRx9ZTAJrGK9y\n"
+ "uZ03BKn7vZIy7fD4ufVzV/s/BaypVmvwjZud8fdMgsMQAJYtoMhozbOtUelCFpja\n"
+ "I1xAbDBx1PAAbS8Sh022/0jvOGnZhvkgZMG90z7AEANUYQIAwzywU087TcJk8Bzd\n"
+ "37JGWyE4f3iYFGA+r8BoIOrxvvgfUHKxdhG0gaT8SDeRAwNY6D43dCBZkG7Uel1F\n"
+ "x9MlLQIA3Goaz58hEN0fdm4TM7A8crtMB+f8/h87EneBgMl+Yj/3sklhyahR6Itm\n"
+ "lGuAAGTAOmD7i8OmS/a1ac5MtHAGtwH6A0B5GjaL8VnLQo4vFnuR7JuCQaLqGadV\n"
+ "mBmKxVHElduLf/VauBQPD5KZA+egpg+laJ4JLVXMmKIZGqRzopcIWZnKiJ8EGAEC\n"
+ "AAkFAk89F0QCGwwACgkQw2OGaR+Qtj0wbQQAlbEepeB7bs0G+VhULbA/5UBJOgRG\n"
+ "PWlXyveezo/gOGpRhBjm06KlSRaP56vj+2lhMSF7nCUES/JWJwu7vhoz1Qrp+U2M\n"
+ "yjIq8sRz5EK/TQceIYfCY5AwnPJwICN4pePbj2JJrL+9AoKiRRbU/DXzPvH0ud+y\n"
+ "PlwPoX47dtDVBSA=\n" "=EVlv\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
// }}}
@@ -266,31 +340,34 @@ int run_id;
// {{{ logging and error handling
-static void logfn(int level, const char* s)
+static void logfn(int level, const char *s)
{
if (debug) {
- fprintf(stdout, "%i %s|<%i> %s", run_id, role_name, level, s);
+ fprintf(stdout, "%i %s|<%i> %s", run_id, role_name, level,
+ s);
}
}
-static void auditfn(gnutls_session_t session, const char* s)
+static void auditfn(gnutls_session_t session, const char *s)
{
if (debug) {
fprintf(stdout, "%i %s| %s", run_id, role_name, s);
}
}
-static void drop(const char* packet)
+static void drop(const char *packet)
{
if (debug) {
- fprintf(stdout, "%i %s| dropping %s\n", run_id, role_name, packet);
+ fprintf(stdout, "%i %s| dropping %s\n", run_id, role_name,
+ packet);
}
}
static int _process_error(int loc, int code, int die)
{
if (code < 0 && (die || code != GNUTLS_E_AGAIN)) {
- fprintf(stdout, "%i <%s tls> line %i: %s", run_id, role_name, loc, gnutls_strerror(code));
+ fprintf(stdout, "%i <%s tls> line %i: %s", run_id,
+ role_name, loc, gnutls_strerror(code));
if (gnutls_error_is_fatal(code) || die) {
fprintf(stdout, " (fatal)\n");
exit(1);
@@ -310,7 +387,9 @@ static void _process_error_or_timeout(int loc, int err, time_t tdiff)
if (err != GNUTLS_E_TIMEDOUT || tdiff >= 60) {
_process_error(loc, err, 0);
} else {
- fprintf(stdout, "%i %s| line %i: {spurious timeout} (fatal)", run_id, role_name, loc);
+ fprintf(stdout,
+ "%i %s| line %i: {spurious timeout} (fatal)",
+ run_id, role_name, loc);
exit(1);
}
}
@@ -318,9 +397,10 @@ static void _process_error_or_timeout(int loc, int err, time_t tdiff)
#define process_error_or_timeout(code, tdiff) _process_error_or_timeout(__LINE__, code, tdiff)
-static void rperror(const char* name)
+static void rperror(const char *name)
{
- fprintf(stdout, "%i %s| %s: %s\n", run_id, role_name, name, strerror(errno));
+ fprintf(stdout, "%i %s| %s: %s\n", run_id, role_name, name,
+ strerror(errno));
}
// }}}
@@ -340,20 +420,27 @@ filter_packet_state_t state_packet_ClientFinished = { 0 };
filter_packet_state_t state_packet_ServerChangeCipherSpec = { 0 };
filter_packet_state_t state_packet_ServerFinished = { 0 };
-filter_permute_state_t state_permute_ServerHello = { { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, 0, 0 };
-filter_permute_state_t state_permute_ServerHelloFull = { { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, 0, 0 };
-filter_permute_state_t state_permute_ServerFinished = { { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, 0, 0 };
-filter_permute_state_t state_permute_ClientFinished = { { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, 0, 0 };
-filter_permute_state_t state_permute_ClientFinishedFull = { { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, 0, 0 };
+filter_permute_state_t state_permute_ServerHello =
+ { {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, 0, 0 };
+filter_permute_state_t state_permute_ServerHelloFull =
+ { {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, 0, 0 };
+filter_permute_state_t state_permute_ServerFinished =
+ { {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, 0, 0 };
+filter_permute_state_t state_permute_ClientFinished =
+ { {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, 0, 0 };
+filter_permute_state_t state_permute_ClientFinishedFull =
+ { {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, 0, 0 };
filter_fn filter_chain[32];
int filter_current_idx;
-static void filter_permute_state_free_buffer(filter_permute_state_t* state)
+static void filter_permute_state_free_buffer(filter_permute_state_t *
+ state)
{
unsigned int i;
- for (i = 0; i < sizeof(state->packets) / sizeof(state->packets[0]); i++) {
+ for (i = 0; i < sizeof(state->packets) / sizeof(state->packets[0]);
+ i++) {
free(state->packets[i].data);
state->packets[i].data = NULL;
}
@@ -367,36 +454,54 @@ static void filter_clear_state(void)
filter_permute_state_free_buffer(&state_permute_ServerHelloFull);
filter_permute_state_free_buffer(&state_permute_ServerFinished);
filter_permute_state_free_buffer(&state_permute_ClientFinished);
- filter_permute_state_free_buffer(&state_permute_ClientFinishedFull);
-
- memset(&state_packet_ServerHello, 0, sizeof(state_packet_ServerHello));
- memset(&state_packet_ServerCertificate, 0, sizeof(state_packet_ServerCertificate));
- memset(&state_packet_ServerKeyExchange, 0, sizeof(state_packet_ServerKeyExchange));
- memset(&state_packet_ServerCertificateRequest, 0, sizeof(state_packet_ServerCertificateRequest));
- memset(&state_packet_ServerHelloDone, 0, sizeof(state_packet_ServerHelloDone));
- memset(&state_packet_ClientCertificate, 0, sizeof(state_packet_ClientCertificate));
- memset(&state_packet_ClientKeyExchange, 0, sizeof(state_packet_ClientKeyExchange));
- memset(&state_packet_ClientCertificateVerify, 0, sizeof(state_packet_ClientCertificateVerify));
- memset(&state_packet_ClientChangeCipherSpec, 0, sizeof(state_packet_ClientChangeCipherSpec));
- memset(&state_packet_ClientFinished, 0, sizeof(state_packet_ClientFinished));
- memset(&state_packet_ServerChangeCipherSpec, 0, sizeof(state_packet_ServerChangeCipherSpec));
- memset(&state_packet_ServerFinished, 0, sizeof(state_packet_ServerFinished));
- memset(&state_permute_ServerHello, 0, sizeof(state_permute_ServerHello));
- memset(&state_permute_ServerHelloFull, 0, sizeof(state_permute_ServerHelloFull));
- memset(&state_permute_ServerFinished, 0, sizeof(state_permute_ServerFinished));
- memset(&state_permute_ClientFinished, 0, sizeof(state_permute_ClientFinished));
- memset(&state_permute_ClientFinishedFull, 0, sizeof(state_permute_ClientFinishedFull));
+ filter_permute_state_free_buffer
+ (&state_permute_ClientFinishedFull);
+
+ memset(&state_packet_ServerHello, 0,
+ sizeof(state_packet_ServerHello));
+ memset(&state_packet_ServerCertificate, 0,
+ sizeof(state_packet_ServerCertificate));
+ memset(&state_packet_ServerKeyExchange, 0,
+ sizeof(state_packet_ServerKeyExchange));
+ memset(&state_packet_ServerCertificateRequest, 0,
+ sizeof(state_packet_ServerCertificateRequest));
+ memset(&state_packet_ServerHelloDone, 0,
+ sizeof(state_packet_ServerHelloDone));
+ memset(&state_packet_ClientCertificate, 0,
+ sizeof(state_packet_ClientCertificate));
+ memset(&state_packet_ClientKeyExchange, 0,
+ sizeof(state_packet_ClientKeyExchange));
+ memset(&state_packet_ClientCertificateVerify, 0,
+ sizeof(state_packet_ClientCertificateVerify));
+ memset(&state_packet_ClientChangeCipherSpec, 0,
+ sizeof(state_packet_ClientChangeCipherSpec));
+ memset(&state_packet_ClientFinished, 0,
+ sizeof(state_packet_ClientFinished));
+ memset(&state_packet_ServerChangeCipherSpec, 0,
+ sizeof(state_packet_ServerChangeCipherSpec));
+ memset(&state_packet_ServerFinished, 0,
+ sizeof(state_packet_ServerFinished));
+ memset(&state_permute_ServerHello, 0,
+ sizeof(state_permute_ServerHello));
+ memset(&state_permute_ServerHelloFull, 0,
+ sizeof(state_permute_ServerHelloFull));
+ memset(&state_permute_ServerFinished, 0,
+ sizeof(state_permute_ServerFinished));
+ memset(&state_permute_ClientFinished, 0,
+ sizeof(state_permute_ClientFinished));
+ memset(&state_permute_ClientFinishedFull, 0,
+ sizeof(state_permute_ClientFinishedFull));
}
static void filter_run_next(gnutls_transport_ptr_t fd,
- const unsigned char* buffer, size_t len)
+ const unsigned char *buffer, size_t len)
{
filter_fn fn = filter_chain[filter_current_idx];
filter_current_idx++;
if (fn) {
fn(fd, buffer, len);
} else {
- send((int)(intptr_t) fd, buffer, len, 0);
+ send((int) (intptr_t) fd, buffer, len, 0);
}
filter_current_idx--;
}
@@ -405,64 +510,78 @@ static void filter_run_next(gnutls_transport_ptr_t fd,
// {{{ packet match functions
-static int match_ServerHello(const unsigned char* buffer, size_t len)
+static int match_ServerHello(const unsigned char *buffer, size_t len)
{
- return role == SERVER && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 2;
+ return role == SERVER && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 2;
}
-static int match_ServerCertificate(const unsigned char* buffer, size_t len)
+static int match_ServerCertificate(const unsigned char *buffer, size_t len)
{
- return role == SERVER && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 11;
+ return role == SERVER && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 11;
}
-static int match_ServerKeyExchange(const unsigned char* buffer, size_t len)
+static int match_ServerKeyExchange(const unsigned char *buffer, size_t len)
{
- return role == SERVER && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 12;
+ return role == SERVER && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 12;
}
-static int match_ServerCertificateRequest(const unsigned char* buffer, size_t len)
+static int match_ServerCertificateRequest(const unsigned char *buffer,
+ size_t len)
{
- return role == SERVER && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 13;
+ return role == SERVER && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 13;
}
-static int match_ServerHelloDone(const unsigned char* buffer, size_t len)
+static int match_ServerHelloDone(const unsigned char *buffer, size_t len)
{
- return role == SERVER && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 14;
+ return role == SERVER && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 14;
}
-static int match_ClientCertificate(const unsigned char* buffer, size_t len)
+static int match_ClientCertificate(const unsigned char *buffer, size_t len)
{
- return role == CLIENT && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 11;
+ return role == CLIENT && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 11;
}
-static int match_ClientKeyExchange(const unsigned char* buffer, size_t len)
+static int match_ClientKeyExchange(const unsigned char *buffer, size_t len)
{
- return role == CLIENT && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 16;
+ return role == CLIENT && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 16;
}
-static int match_ClientCertificateVerify(const unsigned char* buffer, size_t len)
+static int match_ClientCertificateVerify(const unsigned char *buffer,
+ size_t len)
{
- return role == CLIENT && len >= 13 + 1 && buffer[0] == 22 && buffer[13] == 15;
+ return role == CLIENT && len >= 13 + 1 && buffer[0] == 22
+ && buffer[13] == 15;
}
-static int match_ClientChangeCipherSpec(const unsigned char* buffer, size_t len)
+static int match_ClientChangeCipherSpec(const unsigned char *buffer,
+ size_t len)
{
return role == CLIENT && len >= 13 && buffer[0] == 20;
}
-static int match_ClientFinished(const unsigned char* buffer, size_t len)
+static int match_ClientFinished(const unsigned char *buffer, size_t len)
{
- return role == CLIENT && len >= 13 && buffer[0] == 22 && buffer[4] == 1;
+ return role == CLIENT && len >= 13 && buffer[0] == 22
+ && buffer[4] == 1;
}
-static int match_ServerChangeCipherSpec(const unsigned char* buffer, size_t len)
+static int match_ServerChangeCipherSpec(const unsigned char *buffer,
+ size_t len)
{
return role == SERVER && len >= 13 && buffer[0] == 20;
}
-static int match_ServerFinished(const unsigned char* buffer, size_t len)
+static int match_ServerFinished(const unsigned char *buffer, size_t len)
{
- return role == SERVER && len >= 13 && buffer[0] == 22 && buffer[4] == 1;
+ return role == SERVER && len >= 13 && buffer[0] == 22
+ && buffer[4] == 1;
}
// }}}
@@ -482,26 +601,26 @@ static int match_ServerFinished(const unsigned char* buffer, size_t len)
}
DECLARE_FILTER(ServerHello)
-DECLARE_FILTER(ServerCertificate)
-DECLARE_FILTER(ServerKeyExchange)
-DECLARE_FILTER(ServerCertificateRequest)
-DECLARE_FILTER(ServerHelloDone)
-DECLARE_FILTER(ClientCertificate)
-DECLARE_FILTER(ClientKeyExchange)
-DECLARE_FILTER(ClientCertificateVerify)
-DECLARE_FILTER(ClientChangeCipherSpec)
-DECLARE_FILTER(ClientFinished)
-DECLARE_FILTER(ServerChangeCipherSpec)
-DECLARE_FILTER(ServerFinished)
-
+ DECLARE_FILTER(ServerCertificate)
+ DECLARE_FILTER(ServerKeyExchange)
+ DECLARE_FILTER(ServerCertificateRequest)
+ DECLARE_FILTER(ServerHelloDone)
+ DECLARE_FILTER(ClientCertificate)
+ DECLARE_FILTER(ClientKeyExchange)
+ DECLARE_FILTER(ClientCertificateVerify)
+ DECLARE_FILTER(ClientChangeCipherSpec)
+ DECLARE_FILTER(ClientFinished)
+ DECLARE_FILTER(ServerChangeCipherSpec)
+ DECLARE_FILTER(ServerFinished)
// }}}
-
// {{{ flight permutation filters
-
-static void filter_permute_state_run(filter_permute_state_t* state, int packetCount,
- gnutls_transport_ptr_t fd, const unsigned char* buffer, size_t len)
+static void filter_permute_state_run(filter_permute_state_t * state,
+ int packetCount,
+ gnutls_transport_ptr_t fd,
+ const unsigned char *buffer,
+ size_t len)
{
- unsigned char* data = malloc(len);
+ unsigned char *data = malloc(len);
int packet = state->order[state->count];
memcpy(data, buffer, len);
@@ -534,30 +653,36 @@ static void filter_permute_state_run(filter_permute_state_t* state, int packetCo
filter_run_next(fd, buffer, len); \
}
-static match_fn permute_match_ServerHello[] = { match_ServerHello, match_ServerKeyExchange, match_ServerHelloDone };
-static match_fn permute_match_ServerHelloFull[] = { match_ServerHello, match_ServerCertificate, match_ServerKeyExchange,
- match_ServerCertificateRequest, match_ServerHelloDone };
-static match_fn permute_match_ServerFinished[] = { match_ServerChangeCipherSpec, match_ServerFinished };
-static match_fn permute_match_ClientFinished[] = { match_ClientKeyExchange, match_ClientChangeCipherSpec, match_ClientFinished };
-static match_fn permute_match_ClientFinishedFull[] = { match_ClientCertificate, match_ClientKeyExchange,
- match_ClientCertificateVerify, match_ClientChangeCipherSpec, match_ClientFinished };
+static match_fn permute_match_ServerHello[] =
+ { match_ServerHello, match_ServerKeyExchange, match_ServerHelloDone };
+static match_fn permute_match_ServerHelloFull[] =
+ { match_ServerHello, match_ServerCertificate, match_ServerKeyExchange,
+ match_ServerCertificateRequest, match_ServerHelloDone
+};
+static match_fn permute_match_ServerFinished[] =
+ { match_ServerChangeCipherSpec, match_ServerFinished };
+static match_fn permute_match_ClientFinished[] =
+ { match_ClientKeyExchange, match_ClientChangeCipherSpec,
+match_ClientFinished };
+static match_fn permute_match_ClientFinishedFull[] =
+ { match_ClientCertificate, match_ClientKeyExchange,
+ match_ClientCertificateVerify, match_ClientChangeCipherSpec,
+ match_ClientFinished
+};
DECLARE_PERMUTE(ServerHello)
-DECLARE_PERMUTE(ServerHelloFull)
-DECLARE_PERMUTE(ServerFinished)
-DECLARE_PERMUTE(ClientFinished)
-DECLARE_PERMUTE(ClientFinishedFull)
-
+ DECLARE_PERMUTE(ServerHelloFull)
+ DECLARE_PERMUTE(ServerFinished)
+ DECLARE_PERMUTE(ClientFinished)
+ DECLARE_PERMUTE(ClientFinishedFull)
// }}}
-
// {{{ emergency deadlock resolution time bomb
-
timer_t killtimer_tid = 0;
static void killtimer_set(void)
{
struct sigevent sig;
- struct itimerspec tout = { { 0, 0 }, { 2 * timeout_seconds, 0 } };
+ struct itimerspec tout = { {0, 0}, {2 * timeout_seconds, 0} };
if (killtimer_tid != 0) {
timer_delete(killtimer_tid);
@@ -581,9 +706,10 @@ static void killtimer_set(void)
gnutls_certificate_credentials_t cred;
gnutls_session_t session;
-static ssize_t writefn(gnutls_transport_ptr_t fd, const void* buffer, size_t len)
+static ssize_t writefn(gnutls_transport_ptr_t fd, const void *buffer,
+ size_t len)
{
- filter_run_next(fd, (const unsigned char*) buffer, len);
+ filter_run_next(fd, (const unsigned char *) buffer, len);
return len;
}
@@ -591,7 +717,8 @@ static void await(int fd, int timeout)
{
if (nonblock) {
struct pollfd p = { fd, POLLIN, 0 };
- if (poll(&p, 1, timeout) < 0 && errno != EAGAIN && errno != EINTR) {
+ if (poll(&p, 1, timeout) < 0 && errno != EAGAIN
+ && errno != EINTR) {
rperror("poll");
exit(3);
}
@@ -600,25 +727,33 @@ static void await(int fd, int timeout)
static void cred_init(void)
{
- gnutls_datum_t key = { (unsigned char*) PUBKEY, sizeof(PUBKEY) };
- gnutls_datum_t sec = { (unsigned char*) PRIVKEY, sizeof(PRIVKEY) };
+ gnutls_datum_t key = { (unsigned char *) PUBKEY, sizeof(PUBKEY) };
+ gnutls_datum_t sec =
+ { (unsigned char *) PRIVKEY, sizeof(PRIVKEY) };
gnutls_certificate_allocate_credentials(&cred);
- gnutls_certificate_set_openpgp_key_mem(cred, &key, &sec, GNUTLS_OPENPGP_FMT_BASE64);
+ gnutls_certificate_set_openpgp_key_mem(cred, &key, &sec,
+ GNUTLS_OPENPGP_FMT_BASE64);
}
static void session_init(int sock, int server)
{
- gnutls_init(&session, GNUTLS_DATAGRAM | (server ? GNUTLS_SERVER : GNUTLS_CLIENT)
- | GNUTLS_NONBLOCK * nonblock);
- gnutls_priority_set_direct(session, "+CTYPE-OPENPGP:+CIPHER-ALL:+MAC-ALL:+ECDHE-RSA:+ANON-ECDH", 0);
+ gnutls_init(&session,
+ GNUTLS_DATAGRAM | (server ? GNUTLS_SERVER :
+ GNUTLS_CLIENT)
+ | GNUTLS_NONBLOCK * nonblock);
+ gnutls_priority_set_direct(session,
+ "+CTYPE-OPENPGP:+CIPHER-ALL:+MAC-ALL:+ECDHE-RSA:+ANON-ECDH",
+ 0);
gnutls_transport_set_int(session, sock);
if (full) {
- gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ cred);
if (server) {
- gnutls_certificate_server_set_request(session, GNUTLS_CERT_REQUIRE);
+ gnutls_certificate_server_set_request(session,
+ GNUTLS_CERT_REQUIRE);
}
} else if (server) {
gnutls_anon_server_credentials_t cred;
@@ -633,14 +768,15 @@ static void session_init(int sock, int server)
gnutls_transport_set_push_function(session, writefn);
gnutls_dtls_set_mtu(session, 1400);
- gnutls_dtls_set_timeouts(session, retransmit_milliseconds, timeout_seconds * 1000);
+ gnutls_dtls_set_timeouts(session, retransmit_milliseconds,
+ timeout_seconds * 1000);
}
static void client(int sock)
{
int err = 0;
time_t started = time(0);
- const char* line = "foobar!";
+ const char *line = "foobar!";
char buffer[8192];
int len;
@@ -655,13 +791,15 @@ static void client(int sock)
}
} while (err != 0);
process_error_or_timeout(err, time(0) - started);
-
+
killtimer_set();
die_on_error(gnutls_record_send(session, line, strlen(line)));
-
+
do {
await(sock, -1);
- len = process_error(gnutls_record_recv(session, buffer, sizeof(buffer)));
+ len =
+ process_error(gnutls_record_recv
+ (session, buffer, sizeof(buffer)));
} while (len < 0);
if (len > 0 && strncmp(line, buffer, len) == 0) {
@@ -672,7 +810,7 @@ static void client(int sock)
}
static void server(int sock)
-{
+{
int err;
time_t started = time(0);
char buffer[8192];
@@ -695,7 +833,9 @@ static void server(int sock)
killtimer_set();
do {
await(sock, -1);
- len = process_error(gnutls_record_recv(session, buffer, sizeof(buffer)));
+ len =
+ process_error(gnutls_record_recv
+ (session, buffer, sizeof(buffer)));
} while (len < 0);
die_on_error(gnutls_record_send(session, buffer, len));
@@ -707,19 +847,21 @@ static void server(int sock)
// {{{ test running/handling itself
#if 0
-static void udp_sockpair(int* socks)
+static void udp_sockpair(int *socks)
{
- struct sockaddr_in6 sa = { AF_INET6, htons(30000), 0, in6addr_loopback, 0 };
- struct sockaddr_in6 sb = { AF_INET6, htons(20000), 0, in6addr_loopback, 0 };
+ struct sockaddr_in6 sa =
+ { AF_INET6, htons(30000), 0, in6addr_loopback, 0 };
+ struct sockaddr_in6 sb =
+ { AF_INET6, htons(20000), 0, in6addr_loopback, 0 };
socks[0] = socket(AF_INET6, SOCK_DGRAM, 0);
socks[1] = socket(AF_INET6, SOCK_DGRAM, 0);
- bind(socks[0], (struct sockaddr*) &sa, sizeof(sa));
- bind(socks[1], (struct sockaddr*) &sb, sizeof(sb));
+ bind(socks[0], (struct sockaddr *) &sa, sizeof(sa));
+ bind(socks[1], (struct sockaddr *) &sb, sizeof(sb));
- connect(socks[1], (struct sockaddr*) &sa, sizeof(sa));
- connect(socks[0], (struct sockaddr*) &sb, sizeof(sb));
+ connect(socks[1], (struct sockaddr *) &sa, sizeof(sa));
+ connect(socks[0], (struct sockaddr *) &sb, sizeof(sb));
}
#endif
@@ -741,14 +883,14 @@ static int run_test(void)
if (!(pid1 = fork())) {
role = SERVER;
- server(fds[1]); // noreturn
+ server(fds[1]); // noreturn
} else if (pid1 < 0) {
rperror("fork server");
exit(2);
}
if (!(pid2 = fork())) {
role = CLIENT;
- client(fds[0]); // noreturn
+ client(fds[0]); // noreturn
} else if (pid2 < 0) {
rperror("fork client");
exit(2);
@@ -761,69 +903,83 @@ static int run_test(void)
close(fds[1]);
if (!WIFSIGNALED(status2) && WEXITSTATUS(status2) != 3) {
- return !!WEXITSTATUS(status2);
+ return ! !WEXITSTATUS(status2);
} else {
return 3;
}
}
static filter_fn filters[8]
- = { filter_packet_ServerHello,
- filter_packet_ServerKeyExchange,
- filter_packet_ServerHelloDone,
- filter_packet_ClientKeyExchange,
- filter_packet_ClientChangeCipherSpec,
- filter_packet_ClientFinished,
- filter_packet_ServerChangeCipherSpec,
- filter_packet_ServerFinished };
+ = { filter_packet_ServerHello,
+ filter_packet_ServerKeyExchange,
+ filter_packet_ServerHelloDone,
+ filter_packet_ClientKeyExchange,
+ filter_packet_ClientChangeCipherSpec,
+ filter_packet_ClientFinished,
+ filter_packet_ServerChangeCipherSpec,
+ filter_packet_ServerFinished
+};
static filter_fn filters_full[12]
- = { filter_packet_ServerHello,
- filter_packet_ServerCertificate,
- filter_packet_ServerKeyExchange,
- filter_packet_ServerCertificateRequest,
- filter_packet_ServerHelloDone,
- filter_packet_ClientCertificate,
- filter_packet_ClientKeyExchange,
- filter_packet_ClientCertificateVerify,
- filter_packet_ClientChangeCipherSpec,
- filter_packet_ClientFinished,
- filter_packet_ServerChangeCipherSpec,
- filter_packet_ServerFinished };
-
-static int run_one_test(int dropMode, int serverFinishedPermute, int serverHelloPermute, int clientFinishedPermute)
+ = { filter_packet_ServerHello,
+ filter_packet_ServerCertificate,
+ filter_packet_ServerKeyExchange,
+ filter_packet_ServerCertificateRequest,
+ filter_packet_ServerHelloDone,
+ filter_packet_ClientCertificate,
+ filter_packet_ClientKeyExchange,
+ filter_packet_ClientCertificateVerify,
+ filter_packet_ClientChangeCipherSpec,
+ filter_packet_ClientFinished,
+ filter_packet_ServerChangeCipherSpec,
+ filter_packet_ServerFinished
+};
+
+static int run_one_test(int dropMode, int serverFinishedPermute,
+ int serverHelloPermute, int clientFinishedPermute)
{
int fnIdx = 0;
int res, filterIdx;
- filter_fn* local_filters = full ? filters_full : filters;
- const char** local_filter_names = full ? filter_names_full : filter_names;
- const char** permutation_namesX = full ? permutation_names5 : permutation_names3;
+ filter_fn *local_filters = full ? filters_full : filters;
+ const char **local_filter_names =
+ full ? filter_names_full : filter_names;
+ const char **permutation_namesX =
+ full ? permutation_names5 : permutation_names3;
int filter_count = full ? 12 : 8;
- run_id = ((dropMode * 2 + serverFinishedPermute) * (full ? 120 : 6) + serverHelloPermute) * (full ? 120 : 6) + clientFinishedPermute;
+ run_id =
+ ((dropMode * 2 + serverFinishedPermute) * (full ? 120 : 6) +
+ serverHelloPermute) * (full ? 120 : 6) +
+ clientFinishedPermute;
filter_clear_state();
if (full) {
filter_chain[fnIdx++] = filter_permute_ServerHelloFull;
- state_permute_ServerHelloFull.order = permutations5[serverHelloPermute];
+ state_permute_ServerHelloFull.order =
+ permutations5[serverHelloPermute];
filter_chain[fnIdx++] = filter_permute_ClientFinishedFull;
- state_permute_ClientFinishedFull.order = permutations5[clientFinishedPermute];
+ state_permute_ClientFinishedFull.order =
+ permutations5[clientFinishedPermute];
} else {
filter_chain[fnIdx++] = filter_permute_ServerHello;
- state_permute_ServerHello.order = permutations3[serverHelloPermute];
+ state_permute_ServerHello.order =
+ permutations3[serverHelloPermute];
filter_chain[fnIdx++] = filter_permute_ClientFinished;
- state_permute_ClientFinished.order = permutations3[clientFinishedPermute];
+ state_permute_ClientFinished.order =
+ permutations3[clientFinishedPermute];
}
filter_chain[fnIdx++] = filter_permute_ServerFinished;
- state_permute_ServerFinished.order = permutations2[serverFinishedPermute];
+ state_permute_ServerFinished.order =
+ permutations2[serverFinishedPermute];
if (dropMode) {
for (filterIdx = 0; filterIdx < filter_count; filterIdx++) {
if (dropMode & (1 << filterIdx)) {
- filter_chain[fnIdx++] = local_filters[filterIdx];
+ filter_chain[fnIdx++] =
+ local_filters[filterIdx];
}
}
}
@@ -832,30 +988,34 @@ static int run_one_test(int dropMode, int serverFinishedPermute, int serverHello
res = run_test();
switch (res) {
- case 0:
- fprintf(stdout, "%i ++ ", run_id);
- break;
- case 1:
- fprintf(stdout, "%i -- ", run_id);
- break;
- case 2:
- fprintf(stdout, "%i !! ", run_id);
- break;
- case 3:
- fprintf(stdout, "%i TT ", run_id);
- break;
+ case 0:
+ fprintf(stdout, "%i ++ ", run_id);
+ break;
+ case 1:
+ fprintf(stdout, "%i -- ", run_id);
+ break;
+ case 2:
+ fprintf(stdout, "%i !! ", run_id);
+ break;
+ case 3:
+ fprintf(stdout, "%i TT ", run_id);
+ break;
}
- fprintf(stdout, "SHello(%s), ", permutation_namesX[serverHelloPermute]);
- fprintf(stdout, "SFinished(%s), ", permutation_names2[serverFinishedPermute]);
- fprintf(stdout, "CFinished(%s) :- ", permutation_namesX[clientFinishedPermute]);
+ fprintf(stdout, "SHello(%s), ",
+ permutation_namesX[serverHelloPermute]);
+ fprintf(stdout, "SFinished(%s), ",
+ permutation_names2[serverFinishedPermute]);
+ fprintf(stdout, "CFinished(%s) :- ",
+ permutation_namesX[clientFinishedPermute]);
if (dropMode) {
for (filterIdx = 0; filterIdx < filter_count; filterIdx++) {
if (dropMode & (1 << filterIdx)) {
if (dropMode & ((1 << filterIdx) - 1)) {
fprintf(stdout, ", ");
}
- fprintf(stdout, "%s", local_filter_names[filterIdx]);
+ fprintf(stdout, "%s",
+ local_filter_names[filterIdx]);
}
}
}
@@ -867,7 +1027,8 @@ static int run_one_test(int dropMode, int serverFinishedPermute, int serverHello
static int run_test_by_id(int id)
{
int pscale = full ? 120 : 6;
- int dropMode, serverFinishedPermute, serverHelloPermute, clientFinishedPermute;
+ int dropMode, serverFinishedPermute, serverHelloPermute,
+ clientFinishedPermute;
clientFinishedPermute = id % pscale;
id /= pscale;
@@ -880,10 +1041,11 @@ static int run_test_by_id(int id)
dropMode = id;
- return run_one_test(dropMode, serverFinishedPermute, serverHelloPermute, clientFinishedPermute);
+ return run_one_test(dropMode, serverFinishedPermute,
+ serverHelloPermute, clientFinishedPermute);
}
-int* job_pids;
+int *job_pids;
int job_limit;
int children = 0;
@@ -918,7 +1080,8 @@ static int wait_children(int child_limit)
if (WEXITSTATUS(status)) {
result = 1;
if (!run_to_end && !fail) {
- fprintf(stderr, "One test failed, waiting for remaining tests\n");
+ fprintf(stderr,
+ "One test failed, waiting for remaining tests\n");
fail = 1;
child_limit = 0;
}
@@ -944,7 +1107,9 @@ static int run_tests_from_id_list(int childcount)
while ((ret = fscanf(stdin, "%i\n", &test_id)) > 0) {
int pid;
- if (test_id < 0 || test_id > 2 * (full ? 120 * 120 * (1 << 12) : 6 * 6 * 256)) {
+ if (test_id < 0
+ || test_id >
+ 2 * (full ? 120 * 120 * (1 << 12) : 6 * 6 * 256)) {
fprintf(stderr, "Invalid test id %i\n", test_id);
break;
}
@@ -971,25 +1136,38 @@ static int run_tests_from_id_list(int childcount)
static int run_all_tests(int childcount)
{
- int dropMode, serverFinishedPermute, serverHelloPermute, clientFinishedPermute;
+ int dropMode, serverFinishedPermute, serverHelloPermute,
+ clientFinishedPermute;
int result = 0;
for (dropMode = 0; dropMode != 1 << (full ? 12 : 8); dropMode++)
- for (serverFinishedPermute = 0; serverFinishedPermute < 2; serverFinishedPermute++)
- for (serverHelloPermute = 0; serverHelloPermute < (full ? 120 : 6); serverHelloPermute++)
- for (clientFinishedPermute = 0; clientFinishedPermute < (full ? 120 : 6); clientFinishedPermute++) {
- int pid;
- if (!(pid = fork())) {
- exit(run_one_test(dropMode, serverFinishedPermute, serverHelloPermute, clientFinishedPermute));
- } else if (pid < 0) {
- rperror("fork");
- result = 4;
- break;
- } else {
- register_child(pid);
- result |= wait_children(childcount);
- }
- }
+ for (serverFinishedPermute = 0; serverFinishedPermute < 2;
+ serverFinishedPermute++)
+ for (serverHelloPermute = 0;
+ serverHelloPermute < (full ? 120 : 6);
+ serverHelloPermute++)
+ for (clientFinishedPermute = 0;
+ clientFinishedPermute <
+ (full ? 120 : 6);
+ clientFinishedPermute++) {
+ int pid;
+ if (!(pid = fork())) {
+ exit(run_one_test
+ (dropMode,
+ serverFinishedPermute,
+ serverHelloPermute,
+ clientFinishedPermute));
+ } else if (pid < 0) {
+ rperror("fork");
+ result = 4;
+ break;
+ } else {
+ register_child(pid);
+ result |=
+ wait_children
+ (childcount);
+ }
+ }
result |= wait_children(0);
@@ -998,7 +1176,8 @@ static int run_all_tests(int childcount)
// }}}
-static int parse_permutation(const char* arg, const char* permutations[], int* val)
+static int parse_permutation(const char *arg, const char *permutations[],
+ int *val)
{
*val = 0;
while (permutations[*val]) {
@@ -1011,7 +1190,7 @@ static int parse_permutation(const char* arg, const char* permutations[], int* v
return 0;
}
-int main(int argc, const char* argv[])
+int main(int argc, const char *argv[])
{
int dropMode = 0;
int serverFinishedPermute = 0;
@@ -1047,8 +1226,8 @@ int main(int argc, const char* argv[])
} else if (strcmp("-batch", argv[arg]) == 0) {
batch = 1;
} else if (strcmp("-d", argv[arg]) == 0) {
- char* end;
- int level = strtol(argv[arg+1], &end, 10);
+ char *end;
+ int level = strtol(argv[arg + 1], &end, 10);
if (*end == '\0') {
debug = level;
arg++;
@@ -1058,7 +1237,7 @@ int main(int argc, const char* argv[])
} else if (strcmp("-nb", argv[arg]) == 0) {
nonblock = 1;
} else if (strcmp("-timeout", argv[arg]) == 0) {
- char* end;
+ char *end;
int val;
NEXT_ARG(timeout);
@@ -1069,7 +1248,7 @@ int main(int argc, const char* argv[])
FAIL_ARG(timeout);
}
} else if (strcmp("-retransmit", argv[arg]) == 0) {
- char* end;
+ char *end;
int val;
NEXT_ARG(retransmit);
@@ -1080,7 +1259,7 @@ int main(int argc, const char* argv[])
FAIL_ARG(retransmit);
}
} else if (strcmp("-j", argv[arg]) == 0) {
- char* end;
+ char *end;
int val;
NEXT_ARG(timeout);
@@ -1094,31 +1273,43 @@ int main(int argc, const char* argv[])
full = 1;
} else if (strcmp("-shello", argv[arg]) == 0) {
NEXT_ARG(shello);
- if (!parse_permutation(argv[arg], full ? permutation_names5 : permutation_names3, &serverHelloPermute)) {
+ if (!parse_permutation
+ (argv[arg],
+ full ? permutation_names5 :
+ permutation_names3, &serverHelloPermute)) {
FAIL_ARG(shell);
}
} else if (strcmp("-sfinished", argv[arg]) == 0) {
NEXT_ARG(sfinished);
- if (!parse_permutation(argv[arg], permutation_names2, &serverFinishedPermute)) {
+ if (!parse_permutation
+ (argv[arg], permutation_names2,
+ &serverFinishedPermute)) {
FAIL_ARG(sfinished);
}
} else if (strcmp("-cfinished", argv[arg]) == 0) {
NEXT_ARG(cfinished);
- if (!parse_permutation(argv[arg], full ? permutation_names5 : permutation_names3, &clientFinishedPermute)) {
+ if (!parse_permutation
+ (argv[arg],
+ full ? permutation_names5 :
+ permutation_names3, &clientFinishedPermute)) {
FAIL_ARG(cfinished);
}
} else {
int drop;
int filter_count = full ? 12 : 8;
- const char** local_filter_names = full ? filter_names_full : filter_names;
+ const char **local_filter_names =
+ full ? filter_names_full : filter_names;
for (drop = 0; drop < filter_count; drop++) {
- if (strcmp(local_filter_names[drop], argv[arg]) == 0) {
+ if (strcmp
+ (local_filter_names[drop],
+ argv[arg]) == 0) {
dropMode |= (1 << drop);
break;
}
}
if (drop == filter_count) {
- fprintf(stderr, "Unknown packet %s\n", argv[arg]);
+ fprintf(stderr, "Unknown packet %s\n",
+ argv[arg]);
exit(8);
}
}
@@ -1131,8 +1322,11 @@ int main(int argc, const char* argv[])
gnutls_global_set_audit_log_function(auditfn);
gnutls_global_set_log_level(debug);
- if (dropMode || serverFinishedPermute || serverHelloPermute || clientFinishedPermute) {
- return run_one_test(dropMode, serverFinishedPermute, serverHelloPermute, clientFinishedPermute);
+ if (dropMode || serverFinishedPermute || serverHelloPermute
+ || clientFinishedPermute) {
+ return run_one_test(dropMode, serverFinishedPermute,
+ serverHelloPermute,
+ clientFinishedPermute);
} else {
job_pids = calloc(sizeof(int), job_limit);
if (batch) {
@@ -1145,11 +1339,11 @@ int main(int argc, const char* argv[])
// vim: foldmethod=marker
-#else /* NO POSIX TIMERS */
+#else /* NO POSIX TIMERS */
-int main(int argc, const char* argv[])
+int main(int argc, const char *argv[])
{
- exit(77);
+ exit(77);
}
#endif
diff --git a/tests/eagain-common.h b/tests/eagain-common.h
index dac712b8b3..995658d0b2 100644
--- a/tests/eagain-common.h
+++ b/tests/eagain-common.h
@@ -1,6 +1,6 @@
#define min(x,y) ((x)<(y)?(x):(y))
-extern const char* side;
+extern const char *side;
#define HANDSHAKE_EXPECT(c, s, clierr, serverr) \
sret = cret = GNUTLS_E_AGAIN; \
@@ -133,10 +133,10 @@ extern const char* side;
TRANSFER2(c, s, msg, msglen, buf, buflen, 0); \
TRANSFER2(c, s, msg, msglen, buf, buflen, 1)
-static char to_server[64*1024];
+static char to_server[64 * 1024];
static size_t to_server_len = 0;
-static char to_client[64*1024];
+static char to_client[64 * 1024];
static size_t to_client_len = 0;
#ifdef RANDOMIZE
@@ -153,158 +153,173 @@ static size_t to_client_len = 0;
#ifndef IGNORE_PUSH
static ssize_t
-client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+client_push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
- size_t newlen;
- RETURN_RND_EAGAIN(tr);
+ size_t newlen;
+ RETURN_RND_EAGAIN(tr);
- len = min(len, sizeof(to_server)-to_server_len);
+ len = min(len, sizeof(to_server) - to_server_len);
- newlen = to_server_len + len;
- memcpy (to_server + to_server_len, data, len);
- to_server_len = newlen;
+ newlen = to_server_len + len;
+ memcpy(to_server + to_server_len, data, len);
+ to_server_len = newlen;
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: pushed %d bytes to server (avail: %d)\n", (int)len, (int)to_server_len);
+ fprintf(stderr, "eagain: pushed %d bytes to server (avail: %d)\n",
+ (int) len, (int) to_server_len);
#endif
- return len;
+ return len;
}
#endif
static ssize_t
-client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
+client_pull(gnutls_transport_ptr_t tr, void *data, size_t len)
{
- RETURN_RND_EAGAIN(tr);
+ RETURN_RND_EAGAIN(tr);
- if (to_client_len == 0)
- {
+ if (to_client_len == 0) {
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: Not enough data by server (asked for: %d, have: %d)\n", (int)len, (int)to_client_len);
+ fprintf(stderr,
+ "eagain: Not enough data by server (asked for: %d, have: %d)\n",
+ (int) len, (int) to_client_len);
#endif
- gnutls_transport_set_errno ((gnutls_session_t)tr, EAGAIN);
- return -1;
- }
+ gnutls_transport_set_errno((gnutls_session_t) tr, EAGAIN);
+ return -1;
+ }
- len = min(len, to_client_len);
+ len = min(len, to_client_len);
- memcpy (data, to_client, len);
+ memcpy(data, to_client, len);
- memmove (to_client, to_client + len, to_client_len - len);
- to_client_len -= len;
+ memmove(to_client, to_client + len, to_client_len - len);
+ to_client_len -= len;
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: pulled %d bytes by client (avail: %d)\n", (int)len, (int)to_client_len);
+ fprintf(stderr, "eagain: pulled %d bytes by client (avail: %d)\n",
+ (int) len, (int) to_client_len);
#endif
- return len;
+ return len;
}
static ssize_t
-server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
+server_pull(gnutls_transport_ptr_t tr, void *data, size_t len)
{
- //success ("server_pull len %d has %d\n", len, to_server_len);
- RETURN_RND_EAGAIN(tr);
+ //success ("server_pull len %d has %d\n", len, to_server_len);
+ RETURN_RND_EAGAIN(tr);
- if (to_server_len == 0)
- {
+ if (to_server_len == 0) {
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: Not enough data by client (asked for: %d, have: %d)\n", (int)len, (int)to_server_len);
+ fprintf(stderr,
+ "eagain: Not enough data by client (asked for: %d, have: %d)\n",
+ (int) len, (int) to_server_len);
#endif
- gnutls_transport_set_errno ((gnutls_session_t)tr, EAGAIN);
- return -1;
- }
+ gnutls_transport_set_errno((gnutls_session_t) tr, EAGAIN);
+ return -1;
+ }
- len = min(len, to_server_len);
+ len = min(len, to_server_len);
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: pulled %d bytes by server (avail: %d)\n", (int)len, (int)to_server_len);
+ fprintf(stderr, "eagain: pulled %d bytes by server (avail: %d)\n",
+ (int) len, (int) to_server_len);
#endif
- memcpy (data, to_server, len);
+ memcpy(data, to_server, len);
- memmove (to_server, to_server + len, to_server_len - len);
- to_server_len -= len;
+ memmove(to_server, to_server + len, to_server_len - len);
+ to_server_len -= len;
- return len;
+ return len;
}
#ifndef IGNORE_PUSH
static ssize_t
-server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+server_push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
- size_t newlen;
- RETURN_RND_EAGAIN(tr);
+ size_t newlen;
+ RETURN_RND_EAGAIN(tr);
// hexprint (data, len);
- len = min(len, sizeof(to_client)-to_client_len);
+ len = min(len, sizeof(to_client) - to_client_len);
- newlen = to_client_len + len;
- memcpy (to_client + to_client_len, data, len);
- to_client_len = newlen;
+ newlen = to_client_len + len;
+ memcpy(to_client + to_client_len, data, len);
+ to_client_len = newlen;
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: pushed %d bytes to client (avail: %d)\n", (int)len, (int)to_client_len);
+ fprintf(stderr, "eagain: pushed %d bytes to client (avail: %d)\n",
+ (int) len, (int) to_client_len);
#endif
- return len;
+ return len;
}
#endif
/* inline is used to avoid a gcc warning if used in mini-eagain */
-inline static int server_pull_timeout_func(gnutls_transport_ptr_t ptr, unsigned int ms)
+inline static int server_pull_timeout_func(gnutls_transport_ptr_t ptr,
+ unsigned int ms)
{
-int ret;
+ int ret;
- if (to_server_len > 0)
- ret = 1; /* available data */
- else
- ret = 0; /* timeout */
+ if (to_server_len > 0)
+ ret = 1; /* available data */
+ else
+ ret = 0; /* timeout */
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: server_pull_timeout: %d (avail: cli %d, serv %d)\n", ret, (int)to_client_len, (int)to_server_len);
+ fprintf(stderr,
+ "eagain: server_pull_timeout: %d (avail: cli %d, serv %d)\n",
+ ret, (int) to_client_len, (int) to_server_len);
#endif
- return ret;
+ return ret;
}
-inline static int client_pull_timeout_func(gnutls_transport_ptr_t ptr, unsigned int ms)
+inline static int client_pull_timeout_func(gnutls_transport_ptr_t ptr,
+ unsigned int ms)
{
-int ret;
+ int ret;
- if (to_client_len > 0)
- ret = 1;
- else
- ret = 0;
+ if (to_client_len > 0)
+ ret = 1;
+ else
+ ret = 0;
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: client_pull_timeout: %d (avail: cli %d, serv %d)\n", ret, (int)to_client_len, (int)to_server_len);
+ fprintf(stderr,
+ "eagain: client_pull_timeout: %d (avail: cli %d, serv %d)\n",
+ ret, (int) to_client_len, (int) to_server_len);
#endif
- return ret;
+ return ret;
}
inline static void reset_buffers(void)
{
- to_server_len = 0;
- to_client_len = 0;
+ to_server_len = 0;
+ to_client_len = 0;
}
-inline static int record_send_loop(gnutls_session_t session, const void * data, size_t sizeofdata, int use_null_on_retry)
+inline static int record_send_loop(gnutls_session_t session,
+ const void *data, size_t sizeofdata,
+ int use_null_on_retry)
{
-int ret;
-const void * retry_data;
-size_t retry_sizeofdata;
-
- if( use_null_on_retry ) {
- retry_data = 0;
- retry_sizeofdata = 0;
- }
- else {
- retry_data = data;
- retry_sizeofdata = sizeofdata;
- }
-
- ret = gnutls_record_send( session, data, sizeofdata );
- while( ret == GNUTLS_E_AGAIN ) {
- ret = gnutls_record_send( session, retry_data, retry_sizeofdata );
- }
-
- return ret;
+ int ret;
+ const void *retry_data;
+ size_t retry_sizeofdata;
+
+ if (use_null_on_retry) {
+ retry_data = 0;
+ retry_sizeofdata = 0;
+ } else {
+ retry_data = data;
+ retry_sizeofdata = sizeofdata;
+ }
+
+ ret = gnutls_record_send(session, data, sizeofdata);
+ while (ret == GNUTLS_E_AGAIN) {
+ ret =
+ gnutls_record_send(session, retry_data,
+ retry_sizeofdata);
+ }
+
+ return ret;
}
diff --git a/tests/gc.c b/tests/gc.c
index 1b7c144b22..275a13877e 100644
--- a/tests/gc.c
+++ b/tests/gc.c
@@ -33,81 +33,71 @@
#include "../lib/x509/pbkdf2-sha1.h"
#include "../lib/debug.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
-void
-doit (void)
+void doit(void)
{
- unsigned char digest[20];
- int err;
+ unsigned char digest[20];
+ int err;
- /* XXX: We need this to fix secure memory. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
+ /* XXX: We need this to fix secure memory. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
- err =
- gnutls_hmac_fast (GNUTLS_MAC_MD5, "keykeykey", 9, "abcdefgh", 8, digest);
- if (err < 0)
- fail ("gnutls_hmac_fast(MD5) failed: %d\n", err);
- else
- {
- if (memcmp (digest, "\x3c\xb0\x9d\x83\x28\x01\xef\xc0"
- "\x7b\xb3\xaf\x42\x69\xe5\x93\x9a", 16) == 0)
- {
- if (debug)
- success ("gnutls_hmac_fast(MD5) OK\n");
- }
- else
- {
- hexprint (digest, 16);
- fail ("gnutls_hmac_fast(MD5) failure\n");
- }
- }
+ err =
+ gnutls_hmac_fast(GNUTLS_MAC_MD5, "keykeykey", 9, "abcdefgh", 8,
+ digest);
+ if (err < 0)
+ fail("gnutls_hmac_fast(MD5) failed: %d\n", err);
+ else {
+ if (memcmp(digest, "\x3c\xb0\x9d\x83\x28\x01\xef\xc0"
+ "\x7b\xb3\xaf\x42\x69\xe5\x93\x9a", 16) == 0) {
+ if (debug)
+ success("gnutls_hmac_fast(MD5) OK\n");
+ } else {
+ hexprint(digest, 16);
+ fail("gnutls_hmac_fast(MD5) failure\n");
+ }
+ }
- err =
- gnutls_hmac_fast (GNUTLS_MAC_SHA1, "keykeykey", 9, "abcdefgh", 8,
- digest);
- if (err < 0)
- fail ("gnutls_hmac_fast(SHA1) failed: %d\n", err);
- else
- {
- if (memcmp (digest, "\x58\x93\x7a\x58\xfe\xea\x82\xf8"
- "\x0e\x64\x62\x01\x40\x2b\x2c\xed\x5d\x54\xc1\xfa",
- 20) == 0)
- {
- if (debug)
- success ("gnutls_hmac_fast(SHA1) OK\n");
- }
- else
- {
- hexprint (digest, 20);
- fail ("gnutls_hmac_fast(SHA1) failure\n");
- }
- }
+ err =
+ gnutls_hmac_fast(GNUTLS_MAC_SHA1, "keykeykey", 9, "abcdefgh",
+ 8, digest);
+ if (err < 0)
+ fail("gnutls_hmac_fast(SHA1) failed: %d\n", err);
+ else {
+ if (memcmp(digest, "\x58\x93\x7a\x58\xfe\xea\x82\xf8"
+ "\x0e\x64\x62\x01\x40\x2b\x2c\xed\x5d\x54\xc1\xfa",
+ 20) == 0) {
+ if (debug)
+ success("gnutls_hmac_fast(SHA1) OK\n");
+ } else {
+ hexprint(digest, 20);
+ fail("gnutls_hmac_fast(SHA1) failure\n");
+ }
+ }
- err = _gnutls_pbkdf2_sha1 ("password", 8, (unsigned char*)"salt", 4, 4711, digest, 16);
- if (err < 0)
- fail ("_gnutls_pkcs5_pbkdf2_sha1() failed: %d\n", err);
- else
- {
- if (memcmp (digest, "\x09\xb7\x85\x57\xdd\xf6\x07\x15"
- "\x1c\x52\x34\xde\xba\x5c\xdc\x59", 16) == 0)
- {
- if (debug)
- success ("_gnutls_pkcs5_pbkdf2_sha1() OK\n");
- }
- else
- {
- hexprint (digest, 16);
- fail ("_gnutls_pkcs5_pbkdf2_sha1() failure\n");
- }
- }
+ err =
+ _gnutls_pbkdf2_sha1("password", 8, (unsigned char *) "salt", 4,
+ 4711, digest, 16);
+ if (err < 0)
+ fail("_gnutls_pkcs5_pbkdf2_sha1() failed: %d\n", err);
+ else {
+ if (memcmp(digest, "\x09\xb7\x85\x57\xdd\xf6\x07\x15"
+ "\x1c\x52\x34\xde\xba\x5c\xdc\x59", 16) == 0) {
+ if (debug)
+ success
+ ("_gnutls_pkcs5_pbkdf2_sha1() OK\n");
+ } else {
+ hexprint(digest, 16);
+ fail("_gnutls_pkcs5_pbkdf2_sha1() failure\n");
+ }
+ }
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
diff --git a/tests/hostname-check.c b/tests/hostname-check.c
index 2dd31da3f0..d644fe0d07 100644
--- a/tests/hostname-check.c
+++ b/tests/hostname-check.c
@@ -41,828 +41,833 @@
/* Certificate with no SAN nor CN. */
char pem1[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 00\n"
- " Issuer: O=GnuTLS hostname check test CA\n"
- " Validity:\n"
- " Not Before: Fri Feb 16 12:59:09 UTC 2007\n"
- " Not After: Fri Mar 30 12:59:13 UTC 2007\n"
- " Subject: O=GnuTLS hostname check test CA\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
- " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
- " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
- " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
- " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
- " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
- " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
- " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
- " Exponent:\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Key Identifier (not critical):\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- " Signature Algorithm: RSA-SHA\n"
- " Signature:\n"
- " 7b:e8:11:6c:15:3f:f9:01:a0:f1:28:0c:62:50:58:f8\n"
- " 92:44:fb:bf:ab:20:8a:3b:81:ca:e5:68:60:71:df:2b\n"
- " e8:50:58:82:32:ef:fb:6e:4a:72:2c:c9:37:4f:88:1d\n"
- " d7:1b:68:5b:db:83:1b:1a:f3:b4:8e:e0:88:03:e2:43\n"
- " 91:be:d8:b1:ca:f2:62:ec:a1:fd:1a:c8:41:8c:fe:53\n"
- " 1b:be:03:c9:a1:3d:f4:ae:57:fc:44:a6:34:bb:2c:2e\n"
- " a7:56:14:1f:89:e9:3a:ec:1f:a3:da:d7:a1:94:3b:72\n"
- " 1d:12:71:b9:65:a1:85:a2:4c:3a:d1:2c:e9:e9:ea:1c\n"
- "Other Information:\n"
- " MD5 fingerprint:\n"
- " fd845ded8c28ba5e78d6c1844ceafd24\n"
- " SHA-1 fingerprint:\n"
- " 0bae431dda3cae76012b82276e4cd92ad7961798\n"
- " Public Key ID:\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB8TCCAVygAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
- "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDcwMjE2MTI1OTA5WhcNMDcwMzMw\n"
- "MTI1OTEzWjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
- "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGAvuyYeh1vfmslnuggeEKgZAVmQ5lt\n"
- "SdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T7EPH/N6RvB4BprdssgcQLsthR3XK\n"
- "A84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRikfYSW2JazLrtCC4yRCas/SPOUxu7\n"
- "8of+3HiTfFm/oXUCAwEAAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU\n"
- "6Twc+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBAHvoEWwVP/kBoPEo\n"
- "DGJQWPiSRPu/qyCKO4HK5Whgcd8r6FBYgjLv+25KcizJN0+IHdcbaFvbgxsa87SO\n"
- "4IgD4kORvtixyvJi7KH9GshBjP5TG74DyaE99K5X/ESmNLssLqdWFB+J6TrsH6Pa\n"
- "16GUO3IdEnG5ZaGFokw60Szp6eoc\n" "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 00\n"
+ " Issuer: O=GnuTLS hostname check test CA\n"
+ " Validity:\n"
+ " Not Before: Fri Feb 16 12:59:09 UTC 2007\n"
+ " Not After: Fri Mar 30 12:59:13 UTC 2007\n"
+ " Subject: O=GnuTLS hostname check test CA\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
+ " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
+ " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
+ " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
+ " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
+ " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
+ " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
+ " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
+ " Exponent:\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Key Identifier (not critical):\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ " Signature Algorithm: RSA-SHA\n"
+ " Signature:\n"
+ " 7b:e8:11:6c:15:3f:f9:01:a0:f1:28:0c:62:50:58:f8\n"
+ " 92:44:fb:bf:ab:20:8a:3b:81:ca:e5:68:60:71:df:2b\n"
+ " e8:50:58:82:32:ef:fb:6e:4a:72:2c:c9:37:4f:88:1d\n"
+ " d7:1b:68:5b:db:83:1b:1a:f3:b4:8e:e0:88:03:e2:43\n"
+ " 91:be:d8:b1:ca:f2:62:ec:a1:fd:1a:c8:41:8c:fe:53\n"
+ " 1b:be:03:c9:a1:3d:f4:ae:57:fc:44:a6:34:bb:2c:2e\n"
+ " a7:56:14:1f:89:e9:3a:ec:1f:a3:da:d7:a1:94:3b:72\n"
+ " 1d:12:71:b9:65:a1:85:a2:4c:3a:d1:2c:e9:e9:ea:1c\n"
+ "Other Information:\n"
+ " MD5 fingerprint:\n"
+ " fd845ded8c28ba5e78d6c1844ceafd24\n"
+ " SHA-1 fingerprint:\n"
+ " 0bae431dda3cae76012b82276e4cd92ad7961798\n"
+ " Public Key ID:\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIB8TCCAVygAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
+ "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDcwMjE2MTI1OTA5WhcNMDcwMzMw\n"
+ "MTI1OTEzWjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
+ "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGAvuyYeh1vfmslnuggeEKgZAVmQ5lt\n"
+ "SdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T7EPH/N6RvB4BprdssgcQLsthR3XK\n"
+ "A84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRikfYSW2JazLrtCC4yRCas/SPOUxu7\n"
+ "8of+3HiTfFm/oXUCAwEAAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU\n"
+ "6Twc+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBAHvoEWwVP/kBoPEo\n"
+ "DGJQWPiSRPu/qyCKO4HK5Whgcd8r6FBYgjLv+25KcizJN0+IHdcbaFvbgxsa87SO\n"
+ "4IgD4kORvtixyvJi7KH9GshBjP5TG74DyaE99K5X/ESmNLssLqdWFB+J6TrsH6Pa\n"
+ "16GUO3IdEnG5ZaGFokw60Szp6eoc\n" "-----END CERTIFICATE-----\n";
/* Certificate with CN but no SAN. */
char pem2[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 00\n"
- " Issuer: CN=www.example.org\n"
- " Validity:\n"
- " Not Before: Fri Feb 16 13:30:30 UTC 2007\n"
- " Not After: Fri Mar 30 13:30:32 UTC 2007\n"
- " Subject: CN=www.example.org\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
- " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
- " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
- " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
- " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
- " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
- " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
- " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
- " Exponent:\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Key Identifier (not critical):\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- " Signature Algorithm: RSA-SHA\n"
- " Signature:\n"
- " b0:4e:ac:fb:89:12:36:27:f3:72:b8:1a:57:dc:bf:f3\n"
- " a9:27:de:15:75:94:4f:65:cc:3a:59:12:4b:91:0e:28\n"
- " b9:8d:d3:6e:ac:5d:a8:3e:b9:35:81:0c:8f:c7:95:72\n"
- " d9:51:61:06:00:c6:aa:68:54:c8:52:3f:b6:1f:21:92\n"
- " c8:fd:15:50:15:ac:d4:18:29:a1:ff:c9:25:5a:ce:5e\n"
- " 11:7f:82:b2:94:8c:44:3c:3f:de:d7:3b:ff:1c:da:9c\n"
- " 81:fa:63:e1:a7:67:ee:aa:fa:d0:c9:2f:66:1b:5e:af\n"
- " 46:8c:f9:53:55:e7:80:7e:74:95:98:d4:2d:5f:94:ab\n"
- "Other Information:\n"
- " MD5 fingerprint:\n"
- " 30cda7de4f0360892547974f45111ac1\n"
- " SHA-1 fingerprint:\n"
- " 39e3f8fec6a8d842390b6536998a957c1a6b7322\n"
- " Public Key ID:\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB1TCCAUCgAwIBAgIBADALBgkqhkiG9w0BAQUwGjEYMBYGA1UEAxMPd3d3LmV4\n"
- "YW1wbGUub3JnMB4XDTA3MDIxNjEzMzAzMFoXDTA3MDMzMDEzMzAzMlowGjEYMBYG\n"
- "A1UEAxMPd3d3LmV4YW1wbGUub3JnMIGcMAsGCSqGSIb3DQEBAQOBjAAwgYgCgYC+\n"
- "7Jh6HW9+ayWe6CB4QqBkBWZDmW1J1RjsfblYZLKAoxRhnQpPvi/wLvzSq1w231Ps\n"
- "Q8f83pG8HgGmt2yyBxAuy2FHdcoDziNuOPE0JxoazfeW87PwDWd/yneEP5wp9GKR\n"
- "9hJbYlrMuu0ILjJEJqz9I85TG7vyh/7ceJN8Wb+hdQIDAQABozIwMDAPBgNVHRMB\n"
- "Af8EBTADAQH/MB0GA1UdDgQWBBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG\n"
- "9w0BAQUDgYEAsE6s+4kSNifzcrgaV9y/86kn3hV1lE9lzDpZEkuRDii5jdNurF2o\n"
- "Prk1gQyPx5Vy2VFhBgDGqmhUyFI/th8hksj9FVAVrNQYKaH/ySVazl4Rf4KylIxE\n"
- "PD/e1zv/HNqcgfpj4adn7qr60MkvZhter0aM+VNV54B+dJWY1C1flKs=\n"
- "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 00\n"
+ " Issuer: CN=www.example.org\n"
+ " Validity:\n"
+ " Not Before: Fri Feb 16 13:30:30 UTC 2007\n"
+ " Not After: Fri Mar 30 13:30:32 UTC 2007\n"
+ " Subject: CN=www.example.org\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
+ " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
+ " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
+ " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
+ " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
+ " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
+ " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
+ " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
+ " Exponent:\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Key Identifier (not critical):\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ " Signature Algorithm: RSA-SHA\n"
+ " Signature:\n"
+ " b0:4e:ac:fb:89:12:36:27:f3:72:b8:1a:57:dc:bf:f3\n"
+ " a9:27:de:15:75:94:4f:65:cc:3a:59:12:4b:91:0e:28\n"
+ " b9:8d:d3:6e:ac:5d:a8:3e:b9:35:81:0c:8f:c7:95:72\n"
+ " d9:51:61:06:00:c6:aa:68:54:c8:52:3f:b6:1f:21:92\n"
+ " c8:fd:15:50:15:ac:d4:18:29:a1:ff:c9:25:5a:ce:5e\n"
+ " 11:7f:82:b2:94:8c:44:3c:3f:de:d7:3b:ff:1c:da:9c\n"
+ " 81:fa:63:e1:a7:67:ee:aa:fa:d0:c9:2f:66:1b:5e:af\n"
+ " 46:8c:f9:53:55:e7:80:7e:74:95:98:d4:2d:5f:94:ab\n"
+ "Other Information:\n"
+ " MD5 fingerprint:\n"
+ " 30cda7de4f0360892547974f45111ac1\n"
+ " SHA-1 fingerprint:\n"
+ " 39e3f8fec6a8d842390b6536998a957c1a6b7322\n"
+ " Public Key ID:\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIB1TCCAUCgAwIBAgIBADALBgkqhkiG9w0BAQUwGjEYMBYGA1UEAxMPd3d3LmV4\n"
+ "YW1wbGUub3JnMB4XDTA3MDIxNjEzMzAzMFoXDTA3MDMzMDEzMzAzMlowGjEYMBYG\n"
+ "A1UEAxMPd3d3LmV4YW1wbGUub3JnMIGcMAsGCSqGSIb3DQEBAQOBjAAwgYgCgYC+\n"
+ "7Jh6HW9+ayWe6CB4QqBkBWZDmW1J1RjsfblYZLKAoxRhnQpPvi/wLvzSq1w231Ps\n"
+ "Q8f83pG8HgGmt2yyBxAuy2FHdcoDziNuOPE0JxoazfeW87PwDWd/yneEP5wp9GKR\n"
+ "9hJbYlrMuu0ILjJEJqz9I85TG7vyh/7ceJN8Wb+hdQIDAQABozIwMDAPBgNVHRMB\n"
+ "Af8EBTADAQH/MB0GA1UdDgQWBBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG\n"
+ "9w0BAQUDgYEAsE6s+4kSNifzcrgaV9y/86kn3hV1lE9lzDpZEkuRDii5jdNurF2o\n"
+ "Prk1gQyPx5Vy2VFhBgDGqmhUyFI/th8hksj9FVAVrNQYKaH/ySVazl4Rf4KylIxE\n"
+ "PD/e1zv/HNqcgfpj4adn7qr60MkvZhter0aM+VNV54B+dJWY1C1flKs=\n"
+ "-----END CERTIFICATE-----\n";
/* Certificate with SAN but no CN. */
char pem3[] =
- "X.509 Certificate Information:"
- " Version: 3\n"
- " Serial Number (hex): 00\n"
- " Issuer: O=GnuTLS hostname check test CA\n"
- " Validity:\n"
- " Not Before: Fri Feb 16 13:36:27 UTC 2007\n"
- " Not After: Fri Mar 30 13:36:29 UTC 2007\n"
- " Subject: O=GnuTLS hostname check test CA\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
- " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
- " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
- " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
- " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
- " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
- " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
- " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
- " Exponent:\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Alternative Name (not critical):\n"
- " DNSname: www.example.org\n"
- " Key Purpose (not critical):\n"
- " TLS WWW Server.\n"
- " Subject Key Identifier (not critical):\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- " Signature Algorithm: RSA-SHA\n"
- " Signature:\n"
- " a1:30:bc:01:b3:0f:98:7f:8e:76:7d:23:87:34:15:7f\n"
- " a6:ae:a1:fb:87:75:e3:e8:1a:e5:5e:03:5d:bf:44:75\n"
- " 46:4f:d2:a1:28:50:84:49:6d:3b:e0:bc:4e:de:79:85\n"
- " fa:e1:07:b7:6e:0c:14:04:4a:82:b9:f3:22:6a:bc:99\n"
- " 14:20:3b:49:1f:e4:97:d9:ea:eb:73:9a:83:a6:cc:b8\n"
- " 55:fb:52:8e:5f:86:7c:9d:fa:af:03:76:ae:97:e0:64\n"
- " 50:59:73:22:99:55:cf:da:59:31:0a:e8:6d:a0:53:bc\n"
- " 39:63:2e:ac:92:4a:e9:8b:1e:d0:03:df:33:bb:4e:88\n"
- "Other Information:\n"
- " MD5 fingerprint:\n"
- " df3f57d00c8149bd826b177d6ea4f369\n"
- " SHA-1 fingerprint:\n"
- " e95e56e2acac305f72ea6f698c11624663a595bd\n"
- " Public Key ID:\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIICIjCCAY2gAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
- "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDcwMjE2MTMzNjI3WhcNMDcwMzMw\n"
- "MTMzNjI5WjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
- "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGAvuyYeh1vfmslnuggeEKgZAVmQ5lt\n"
- "SdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T7EPH/N6RvB4BprdssgcQLsthR3XK\n"
- "A84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRikfYSW2JazLrtCC4yRCas/SPOUxu7\n"
- "8of+3HiTfFm/oXUCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAaBgNVHREEEzAR\n"
- "gg93d3cuZXhhbXBsZS5vcmcwEwYDVR0lBAwwCgYIKwYBBQUHAwEwHQYDVR0OBBYE\n"
- "FOk8HPutkm7mBqRWLKLhwFMnyPKVMAsGCSqGSIb3DQEBBQOBgQChMLwBsw+Yf452\n"
- "fSOHNBV/pq6h+4d14+ga5V4DXb9EdUZP0qEoUIRJbTvgvE7eeYX64Qe3bgwUBEqC\n"
- "ufMiaryZFCA7SR/kl9nq63Oag6bMuFX7Uo5fhnyd+q8Ddq6X4GRQWXMimVXP2lkx\n"
- "CuhtoFO8OWMurJJK6Yse0APfM7tOiA==\n" "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:"
+ " Version: 3\n"
+ " Serial Number (hex): 00\n"
+ " Issuer: O=GnuTLS hostname check test CA\n"
+ " Validity:\n"
+ " Not Before: Fri Feb 16 13:36:27 UTC 2007\n"
+ " Not After: Fri Mar 30 13:36:29 UTC 2007\n"
+ " Subject: O=GnuTLS hostname check test CA\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
+ " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
+ " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
+ " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
+ " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
+ " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
+ " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
+ " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
+ " Exponent:\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Alternative Name (not critical):\n"
+ " DNSname: www.example.org\n"
+ " Key Purpose (not critical):\n"
+ " TLS WWW Server.\n"
+ " Subject Key Identifier (not critical):\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ " Signature Algorithm: RSA-SHA\n"
+ " Signature:\n"
+ " a1:30:bc:01:b3:0f:98:7f:8e:76:7d:23:87:34:15:7f\n"
+ " a6:ae:a1:fb:87:75:e3:e8:1a:e5:5e:03:5d:bf:44:75\n"
+ " 46:4f:d2:a1:28:50:84:49:6d:3b:e0:bc:4e:de:79:85\n"
+ " fa:e1:07:b7:6e:0c:14:04:4a:82:b9:f3:22:6a:bc:99\n"
+ " 14:20:3b:49:1f:e4:97:d9:ea:eb:73:9a:83:a6:cc:b8\n"
+ " 55:fb:52:8e:5f:86:7c:9d:fa:af:03:76:ae:97:e0:64\n"
+ " 50:59:73:22:99:55:cf:da:59:31:0a:e8:6d:a0:53:bc\n"
+ " 39:63:2e:ac:92:4a:e9:8b:1e:d0:03:df:33:bb:4e:88\n"
+ "Other Information:\n"
+ " MD5 fingerprint:\n"
+ " df3f57d00c8149bd826b177d6ea4f369\n"
+ " SHA-1 fingerprint:\n"
+ " e95e56e2acac305f72ea6f698c11624663a595bd\n"
+ " Public Key ID:\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICIjCCAY2gAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
+ "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDcwMjE2MTMzNjI3WhcNMDcwMzMw\n"
+ "MTMzNjI5WjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
+ "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGAvuyYeh1vfmslnuggeEKgZAVmQ5lt\n"
+ "SdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T7EPH/N6RvB4BprdssgcQLsthR3XK\n"
+ "A84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRikfYSW2JazLrtCC4yRCas/SPOUxu7\n"
+ "8of+3HiTfFm/oXUCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAaBgNVHREEEzAR\n"
+ "gg93d3cuZXhhbXBsZS5vcmcwEwYDVR0lBAwwCgYIKwYBBQUHAwEwHQYDVR0OBBYE\n"
+ "FOk8HPutkm7mBqRWLKLhwFMnyPKVMAsGCSqGSIb3DQEBBQOBgQChMLwBsw+Yf452\n"
+ "fSOHNBV/pq6h+4d14+ga5V4DXb9EdUZP0qEoUIRJbTvgvE7eeYX64Qe3bgwUBEqC\n"
+ "ufMiaryZFCA7SR/kl9nq63Oag6bMuFX7Uo5fhnyd+q8Ddq6X4GRQWXMimVXP2lkx\n"
+ "CuhtoFO8OWMurJJK6Yse0APfM7tOiA==\n" "-----END CERTIFICATE-----\n";
/* Certificate with wildcard SAN but no CN. */
char pem4[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 00\n"
- " Issuer:\n"
- " Validity:\n"
- " Not Before: Fri Feb 16 13:40:10 UTC 2007\n"
- " Not After: Fri Mar 30 13:40:12 UTC 2007\n"
- " Subject:\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
- " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
- " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
- " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
- " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
- " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
- " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
- " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
- " Exponent:\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Alternative Name (not critical):\n"
- " DNSname: *.example.org\n"
- " Key Purpose (not critical):\n"
- " TLS WWW Server.\n"
- " Subject Key Identifier (not critical):\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- " Signature Algorithm: RSA-SHA\n"
- " Signature:\n"
- " b1:62:e5:e3:0b:a5:99:58:b0:1c:5c:f5:d1:3f:7c:bb\n"
- " 67:e1:43:c5:d7:a2:5c:db:f2:5a:f3:03:fc:76:e4:4d\n"
- " c1:a0:89:36:24:82:a4:a1:ad:f5:83:e3:96:75:f4:c4\n"
- " f3:eb:ff:3a:9b:da:d2:2c:58:d4:10:37:50:33:d1:39\n"
- " 53:71:9e:48:2d:b2:5b:27:ce:1e:d9:d5:36:59:ac:17\n"
- " 3a:83:cc:59:6b:8f:6a:24:b8:9f:f0:e6:14:03:23:5a\n"
- " 87:e7:33:10:32:11:58:a2:bb:f1:e5:5a:88:87:bb:80\n"
- " 1b:b6:bb:12:18:cb:15:d5:3a:fc:99:e4:42:5a:ba:45\n"
- "Other Information:\n"
- " MD5 fingerprint:\n"
- " a411da7b0fa064d214116d5f94e06c24\n"
- " SHA-1 fingerprint:\n"
- " 3596e796c73ed096d762ab3d440a9ab55a386b3b\n"
- " Public Key ID:\n"
- " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB0DCCATugAwIBAgIBADALBgkqhkiG9w0BAQUwADAeFw0wNzAyMTYxMzQwMTBa\n"
- "Fw0wNzAzMzAxMzQwMTJaMAAwgZwwCwYJKoZIhvcNAQEBA4GMADCBiAKBgL7smHod\n"
- "b35rJZ7oIHhCoGQFZkOZbUnVGOx9uVhksoCjFGGdCk++L/Au/NKrXDbfU+xDx/ze\n"
- "kbweAaa3bLIHEC7LYUd1ygPOI2448TQnGhrN95bzs/ANZ3/Kd4Q/nCn0YpH2Elti\n"
- "Wsy67QguMkQmrP0jzlMbu/KH/tx4k3xZv6F1AgMBAAGjYTBfMA8GA1UdEwEB/wQF\n"
- "MAMBAf8wGAYDVR0RBBEwD4INKi5leGFtcGxlLm9yZzATBgNVHSUEDDAKBggrBgEF\n"
- "BQcDATAdBgNVHQ4EFgQU6Twc+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEF\n"
- "A4GBALFi5eMLpZlYsBxc9dE/fLtn4UPF16Jc2/Ja8wP8duRNwaCJNiSCpKGt9YPj\n"
- "lnX0xPPr/zqb2tIsWNQQN1Az0TlTcZ5ILbJbJ84e2dU2WawXOoPMWWuPaiS4n/Dm\n"
- "FAMjWofnMxAyEViiu/HlWoiHu4AbtrsSGMsV1Tr8meRCWrpF\n"
- "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 00\n"
+ " Issuer:\n"
+ " Validity:\n"
+ " Not Before: Fri Feb 16 13:40:10 UTC 2007\n"
+ " Not After: Fri Mar 30 13:40:12 UTC 2007\n"
+ " Subject:\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " be:ec:98:7a:1d:6f:7e:6b:25:9e:e8:20:78:42:a0:64\n"
+ " 05:66:43:99:6d:49:d5:18:ec:7d:b9:58:64:b2:80:a3\n"
+ " 14:61:9d:0a:4f:be:2f:f0:2e:fc:d2:ab:5c:36:df:53\n"
+ " ec:43:c7:fc:de:91:bc:1e:01:a6:b7:6c:b2:07:10:2e\n"
+ " cb:61:47:75:ca:03:ce:23:6e:38:f1:34:27:1a:1a:cd\n"
+ " f7:96:f3:b3:f0:0d:67:7f:ca:77:84:3f:9c:29:f4:62\n"
+ " 91:f6:12:5b:62:5a:cc:ba:ed:08:2e:32:44:26:ac:fd\n"
+ " 23:ce:53:1b:bb:f2:87:fe:dc:78:93:7c:59:bf:a1:75\n"
+ " Exponent:\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Alternative Name (not critical):\n"
+ " DNSname: *.example.org\n"
+ " Key Purpose (not critical):\n"
+ " TLS WWW Server.\n"
+ " Subject Key Identifier (not critical):\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ " Signature Algorithm: RSA-SHA\n"
+ " Signature:\n"
+ " b1:62:e5:e3:0b:a5:99:58:b0:1c:5c:f5:d1:3f:7c:bb\n"
+ " 67:e1:43:c5:d7:a2:5c:db:f2:5a:f3:03:fc:76:e4:4d\n"
+ " c1:a0:89:36:24:82:a4:a1:ad:f5:83:e3:96:75:f4:c4\n"
+ " f3:eb:ff:3a:9b:da:d2:2c:58:d4:10:37:50:33:d1:39\n"
+ " 53:71:9e:48:2d:b2:5b:27:ce:1e:d9:d5:36:59:ac:17\n"
+ " 3a:83:cc:59:6b:8f:6a:24:b8:9f:f0:e6:14:03:23:5a\n"
+ " 87:e7:33:10:32:11:58:a2:bb:f1:e5:5a:88:87:bb:80\n"
+ " 1b:b6:bb:12:18:cb:15:d5:3a:fc:99:e4:42:5a:ba:45\n"
+ "Other Information:\n"
+ " MD5 fingerprint:\n"
+ " a411da7b0fa064d214116d5f94e06c24\n"
+ " SHA-1 fingerprint:\n"
+ " 3596e796c73ed096d762ab3d440a9ab55a386b3b\n"
+ " Public Key ID:\n"
+ " e93c1cfbad926ee606a4562ca2e1c05327c8f295\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIB0DCCATugAwIBAgIBADALBgkqhkiG9w0BAQUwADAeFw0wNzAyMTYxMzQwMTBa\n"
+ "Fw0wNzAzMzAxMzQwMTJaMAAwgZwwCwYJKoZIhvcNAQEBA4GMADCBiAKBgL7smHod\n"
+ "b35rJZ7oIHhCoGQFZkOZbUnVGOx9uVhksoCjFGGdCk++L/Au/NKrXDbfU+xDx/ze\n"
+ "kbweAaa3bLIHEC7LYUd1ygPOI2448TQnGhrN95bzs/ANZ3/Kd4Q/nCn0YpH2Elti\n"
+ "Wsy67QguMkQmrP0jzlMbu/KH/tx4k3xZv6F1AgMBAAGjYTBfMA8GA1UdEwEB/wQF\n"
+ "MAMBAf8wGAYDVR0RBBEwD4INKi5leGFtcGxlLm9yZzATBgNVHSUEDDAKBggrBgEF\n"
+ "BQcDATAdBgNVHQ4EFgQU6Twc+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEF\n"
+ "A4GBALFi5eMLpZlYsBxc9dE/fLtn4UPF16Jc2/Ja8wP8duRNwaCJNiSCpKGt9YPj\n"
+ "lnX0xPPr/zqb2tIsWNQQN1Az0TlTcZ5ILbJbJ84e2dU2WawXOoPMWWuPaiS4n/Dm\n"
+ "FAMjWofnMxAyEViiu/HlWoiHu4AbtrsSGMsV1Tr8meRCWrpF\n"
+ "-----END CERTIFICATE-----\n";
/* Certificate with multiple wildcards SAN but no CN. */
char pem6[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 00\n"
- " Validity:\n"
- " Not Before: Sat May 3 11:00:51 UTC 2008\n"
- " Not After: Sat May 17 11:00:54 UTC 2008\n"
- " Subject: O=GnuTLS hostname check test CA\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " d2:05:c1:65:cb:bd:1e:2e:eb:7b:87:07:94:4c:93:33\n"
- " f3:81:83:7d:32:1b:71:4e:4e:7f:c7:bc:bf:4b:2f:f2\n"
- " 49:b5:cf:bf:c0:b8:e8:29:cc:f3:61:bd:2e:1d:e4:e8\n"
- " 19:dd:c5:bd:2e:f0:35:b1:fd:30:d7:f5:a8:7c:83:9a\n"
- " 13:9e:bf:25:ed:08:a6:05:9e:7b:4e:23:59:c3:0e:5a\n"
- " f3:bf:54:c7:dc:d4:13:57:a1:0f:a2:9e:c8:ab:75:66\n"
- " de:07:84:8d:68:ad:71:04:e0:9c:bd:cb:f6:08:7a:97\n"
- " 42:f8:10:94:29:01:4a:7e:61:d7:04:21:05:4c:f1:07\n"
- " Exponent:\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Alternative Name (not critical):\n"
- " DNSname: *.*.example.org\n"
- " Key Purpose (not critical):\n"
- " TLS WWW Server.\n"
- " Subject Key Identifier (not critical):\n"
- " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
- "Other Information:\n"
- " Public Key ID:\n"
- " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIICIjCCAY2gAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
- "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDgwNTAzMTEwMDUxWhcNMDgwNTE3\n"
- "MTEwMDU0WjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
- "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA0gXBZcu9Hi7re4cHlEyTM/OBg30y\n"
- "G3FOTn/HvL9LL/JJtc+/wLjoKczzYb0uHeToGd3FvS7wNbH9MNf1qHyDmhOevyXt\n"
- "CKYFnntOI1nDDlrzv1TH3NQTV6EPop7Iq3Vm3geEjWitcQTgnL3L9gh6l0L4EJQp\n"
- "AUp+YdcEIQVM8QcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAaBgNVHREEEzAR\n"
- "gg8qLiouZXhhbXBsZS5vcmcwEwYDVR0lBAwwCgYIKwYBBQUHAwEwHQYDVR0OBBYE\n"
- "FFST5lmbKDtFKTeIGK75pKu/TZkYMAsGCSqGSIb3DQEBBQOBgQAQ9PStleVvfmlK\n"
- "wRs8RE/oOO+ouC3qLdnumNEITMRFh8Q12/X4yMLD3CH0aQ/hvHcP26PxAWzpNutk\n"
- "swNx7AzsCu6pN1t1aI3jLgo8e4/zZi57e8QcRuXZPDJxtJxVhJZX/C4pSz802WhS\n"
- "64NgtpHEMu9JUHFhtRwPcvVGYqPUUA==\n" "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 00\n"
+ " Validity:\n"
+ " Not Before: Sat May 3 11:00:51 UTC 2008\n"
+ " Not After: Sat May 17 11:00:54 UTC 2008\n"
+ " Subject: O=GnuTLS hostname check test CA\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " d2:05:c1:65:cb:bd:1e:2e:eb:7b:87:07:94:4c:93:33\n"
+ " f3:81:83:7d:32:1b:71:4e:4e:7f:c7:bc:bf:4b:2f:f2\n"
+ " 49:b5:cf:bf:c0:b8:e8:29:cc:f3:61:bd:2e:1d:e4:e8\n"
+ " 19:dd:c5:bd:2e:f0:35:b1:fd:30:d7:f5:a8:7c:83:9a\n"
+ " 13:9e:bf:25:ed:08:a6:05:9e:7b:4e:23:59:c3:0e:5a\n"
+ " f3:bf:54:c7:dc:d4:13:57:a1:0f:a2:9e:c8:ab:75:66\n"
+ " de:07:84:8d:68:ad:71:04:e0:9c:bd:cb:f6:08:7a:97\n"
+ " 42:f8:10:94:29:01:4a:7e:61:d7:04:21:05:4c:f1:07\n"
+ " Exponent:\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Alternative Name (not critical):\n"
+ " DNSname: *.*.example.org\n"
+ " Key Purpose (not critical):\n"
+ " TLS WWW Server.\n"
+ " Subject Key Identifier (not critical):\n"
+ " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
+ "Other Information:\n"
+ " Public Key ID:\n"
+ " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICIjCCAY2gAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
+ "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDgwNTAzMTEwMDUxWhcNMDgwNTE3\n"
+ "MTEwMDU0WjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
+ "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA0gXBZcu9Hi7re4cHlEyTM/OBg30y\n"
+ "G3FOTn/HvL9LL/JJtc+/wLjoKczzYb0uHeToGd3FvS7wNbH9MNf1qHyDmhOevyXt\n"
+ "CKYFnntOI1nDDlrzv1TH3NQTV6EPop7Iq3Vm3geEjWitcQTgnL3L9gh6l0L4EJQp\n"
+ "AUp+YdcEIQVM8QcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAaBgNVHREEEzAR\n"
+ "gg8qLiouZXhhbXBsZS5vcmcwEwYDVR0lBAwwCgYIKwYBBQUHAwEwHQYDVR0OBBYE\n"
+ "FFST5lmbKDtFKTeIGK75pKu/TZkYMAsGCSqGSIb3DQEBBQOBgQAQ9PStleVvfmlK\n"
+ "wRs8RE/oOO+ouC3qLdnumNEITMRFh8Q12/X4yMLD3CH0aQ/hvHcP26PxAWzpNutk\n"
+ "swNx7AzsCu6pN1t1aI3jLgo8e4/zZi57e8QcRuXZPDJxtJxVhJZX/C4pSz802WhS\n"
+ "64NgtpHEMu9JUHFhtRwPcvVGYqPUUA==\n" "-----END CERTIFICATE-----\n";
/* Certificate with prefixed and suffixed wildcard SAN but no CN. */
char pem7[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 00\n"
- " Validity:\n"
- " Not Before: Sat May 3 11:02:43 UTC 2008\n"
- " Not After: Sat May 17 11:02:45 UTC 2008\n"
- " Subject: O=GnuTLS hostname check test CA\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " d2:05:c1:65:cb:bd:1e:2e:eb:7b:87:07:94:4c:93:33\n"
- " f3:81:83:7d:32:1b:71:4e:4e:7f:c7:bc:bf:4b:2f:f2\n"
- " 49:b5:cf:bf:c0:b8:e8:29:cc:f3:61:bd:2e:1d:e4:e8\n"
- " 19:dd:c5:bd:2e:f0:35:b1:fd:30:d7:f5:a8:7c:83:9a\n"
- " 13:9e:bf:25:ed:08:a6:05:9e:7b:4e:23:59:c3:0e:5a\n"
- " f3:bf:54:c7:dc:d4:13:57:a1:0f:a2:9e:c8:ab:75:66\n"
- " de:07:84:8d:68:ad:71:04:e0:9c:bd:cb:f6:08:7a:97\n"
- " 42:f8:10:94:29:01:4a:7e:61:d7:04:21:05:4c:f1:07\n"
- " Exponent:\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Alternative Name (not critical):\n"
- " DNSname: foo*bar.example.org\n"
- " Key Purpose (not critical):\n"
- " TLS WWW Server.\n"
- " Subject Key Identifier (not critical):\n"
- " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
- "Other Information:\n"
- " Public Key ID:\n"
- " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIICJjCCAZGgAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
- "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDgwNTAzMTEwMjQzWhcNMDgwNTE3\n"
- "MTEwMjQ1WjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
- "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA0gXBZcu9Hi7re4cHlEyTM/OBg30y\n"
- "G3FOTn/HvL9LL/JJtc+/wLjoKczzYb0uHeToGd3FvS7wNbH9MNf1qHyDmhOevyXt\n"
- "CKYFnntOI1nDDlrzv1TH3NQTV6EPop7Iq3Vm3geEjWitcQTgnL3L9gh6l0L4EJQp\n"
- "AUp+YdcEIQVM8QcCAwEAAaNnMGUwDwYDVR0TAQH/BAUwAwEB/zAeBgNVHREEFzAV\n"
- "ghNmb28qYmFyLmV4YW1wbGUub3JnMBMGA1UdJQQMMAoGCCsGAQUFBwMBMB0GA1Ud\n"
- "DgQWBBRUk+ZZmyg7RSk3iBiu+aSrv02ZGDALBgkqhkiG9w0BAQUDgYEAPPNe38jc\n"
- "8NsZQVKKLYc1Y4y8LRPhvnxkSnlcGa1RzYZY1s12BZ6OVIfyxD1Z9BcNdqRSq7bQ\n"
- "kEicsGp5ugGQTNq6aSlzYOUD9/fUP3jDsH7HVb36aCF3waGCQWj+pLqK0LYcW2p/\n"
- "xnr5+z4YevFBhn7l/fMhg8TzKejxYm7TECg=\n" "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 00\n"
+ " Validity:\n"
+ " Not Before: Sat May 3 11:02:43 UTC 2008\n"
+ " Not After: Sat May 17 11:02:45 UTC 2008\n"
+ " Subject: O=GnuTLS hostname check test CA\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " d2:05:c1:65:cb:bd:1e:2e:eb:7b:87:07:94:4c:93:33\n"
+ " f3:81:83:7d:32:1b:71:4e:4e:7f:c7:bc:bf:4b:2f:f2\n"
+ " 49:b5:cf:bf:c0:b8:e8:29:cc:f3:61:bd:2e:1d:e4:e8\n"
+ " 19:dd:c5:bd:2e:f0:35:b1:fd:30:d7:f5:a8:7c:83:9a\n"
+ " 13:9e:bf:25:ed:08:a6:05:9e:7b:4e:23:59:c3:0e:5a\n"
+ " f3:bf:54:c7:dc:d4:13:57:a1:0f:a2:9e:c8:ab:75:66\n"
+ " de:07:84:8d:68:ad:71:04:e0:9c:bd:cb:f6:08:7a:97\n"
+ " 42:f8:10:94:29:01:4a:7e:61:d7:04:21:05:4c:f1:07\n"
+ " Exponent:\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Alternative Name (not critical):\n"
+ " DNSname: foo*bar.example.org\n"
+ " Key Purpose (not critical):\n"
+ " TLS WWW Server.\n"
+ " Subject Key Identifier (not critical):\n"
+ " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
+ "Other Information:\n"
+ " Public Key ID:\n"
+ " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICJjCCAZGgAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
+ "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDgwNTAzMTEwMjQzWhcNMDgwNTE3\n"
+ "MTEwMjQ1WjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
+ "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA0gXBZcu9Hi7re4cHlEyTM/OBg30y\n"
+ "G3FOTn/HvL9LL/JJtc+/wLjoKczzYb0uHeToGd3FvS7wNbH9MNf1qHyDmhOevyXt\n"
+ "CKYFnntOI1nDDlrzv1TH3NQTV6EPop7Iq3Vm3geEjWitcQTgnL3L9gh6l0L4EJQp\n"
+ "AUp+YdcEIQVM8QcCAwEAAaNnMGUwDwYDVR0TAQH/BAUwAwEB/zAeBgNVHREEFzAV\n"
+ "ghNmb28qYmFyLmV4YW1wbGUub3JnMBMGA1UdJQQMMAoGCCsGAQUFBwMBMB0GA1Ud\n"
+ "DgQWBBRUk+ZZmyg7RSk3iBiu+aSrv02ZGDALBgkqhkiG9w0BAQUDgYEAPPNe38jc\n"
+ "8NsZQVKKLYc1Y4y8LRPhvnxkSnlcGa1RzYZY1s12BZ6OVIfyxD1Z9BcNdqRSq7bQ\n"
+ "kEicsGp5ugGQTNq6aSlzYOUD9/fUP3jDsH7HVb36aCF3waGCQWj+pLqK0LYcW2p/\n"
+ "xnr5+z4YevFBhn7l/fMhg8TzKejxYm7TECg=\n" "-----END CERTIFICATE-----\n";
/* Certificate with ending wildcard SAN but no CN. */
char pem8[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 00\n"
- " Validity:\n"
- " Not Before: Sat May 3 11:24:38 UTC 2008\n"
- " Not After: Sat May 17 11:24:40 UTC 2008\n"
- " Subject: O=GnuTLS hostname check test CA\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " d2:05:c1:65:cb:bd:1e:2e:eb:7b:87:07:94:4c:93:33\n"
- " f3:81:83:7d:32:1b:71:4e:4e:7f:c7:bc:bf:4b:2f:f2\n"
- " 49:b5:cf:bf:c0:b8:e8:29:cc:f3:61:bd:2e:1d:e4:e8\n"
- " 19:dd:c5:bd:2e:f0:35:b1:fd:30:d7:f5:a8:7c:83:9a\n"
- " 13:9e:bf:25:ed:08:a6:05:9e:7b:4e:23:59:c3:0e:5a\n"
- " f3:bf:54:c7:dc:d4:13:57:a1:0f:a2:9e:c8:ab:75:66\n"
- " de:07:84:8d:68:ad:71:04:e0:9c:bd:cb:f6:08:7a:97\n"
- " 42:f8:10:94:29:01:4a:7e:61:d7:04:21:05:4c:f1:07\n"
- " Exponent:\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Alternative Name (not critical):\n"
- " DNSname: www.example.*\n"
- " Key Purpose (not critical):\n"
- " TLS WWW Server.\n"
- " Subject Key Identifier (not critical):\n"
- " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
- "Other Information:\n"
- " Public Key ID:\n"
- " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIICIDCCAYugAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
- "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDgwNTAzMTEyNDM4WhcNMDgwNTE3\n"
- "MTEyNDQwWjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
- "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA0gXBZcu9Hi7re4cHlEyTM/OBg30y\n"
- "G3FOTn/HvL9LL/JJtc+/wLjoKczzYb0uHeToGd3FvS7wNbH9MNf1qHyDmhOevyXt\n"
- "CKYFnntOI1nDDlrzv1TH3NQTV6EPop7Iq3Vm3geEjWitcQTgnL3L9gh6l0L4EJQp\n"
- "AUp+YdcEIQVM8QcCAwEAAaNhMF8wDwYDVR0TAQH/BAUwAwEB/zAYBgNVHREEETAP\n"
- "gg13d3cuZXhhbXBsZS4qMBMGA1UdJQQMMAoGCCsGAQUFBwMBMB0GA1UdDgQWBBRU\n"
- "k+ZZmyg7RSk3iBiu+aSrv02ZGDALBgkqhkiG9w0BAQUDgYEAZ7gLXtXwFW61dSAM\n"
- "0Qt6IN68WBH7LCzetSF8ofG1WVUImCUU3pqXhXYtPGTrswOh2AavWTRbzVTtrFvf\n"
- "WJg09Z7H6I70RPvAYGsK9t9qJ/4TPoYTGYQgsTbVpkv13O54O6jzemd8Zws/xMH5\n"
- "7/q6C7P5OUmGOtfVe7UVDY0taQM=\n" "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 00\n"
+ " Validity:\n"
+ " Not Before: Sat May 3 11:24:38 UTC 2008\n"
+ " Not After: Sat May 17 11:24:40 UTC 2008\n"
+ " Subject: O=GnuTLS hostname check test CA\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " d2:05:c1:65:cb:bd:1e:2e:eb:7b:87:07:94:4c:93:33\n"
+ " f3:81:83:7d:32:1b:71:4e:4e:7f:c7:bc:bf:4b:2f:f2\n"
+ " 49:b5:cf:bf:c0:b8:e8:29:cc:f3:61:bd:2e:1d:e4:e8\n"
+ " 19:dd:c5:bd:2e:f0:35:b1:fd:30:d7:f5:a8:7c:83:9a\n"
+ " 13:9e:bf:25:ed:08:a6:05:9e:7b:4e:23:59:c3:0e:5a\n"
+ " f3:bf:54:c7:dc:d4:13:57:a1:0f:a2:9e:c8:ab:75:66\n"
+ " de:07:84:8d:68:ad:71:04:e0:9c:bd:cb:f6:08:7a:97\n"
+ " 42:f8:10:94:29:01:4a:7e:61:d7:04:21:05:4c:f1:07\n"
+ " Exponent:\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Alternative Name (not critical):\n"
+ " DNSname: www.example.*\n"
+ " Key Purpose (not critical):\n"
+ " TLS WWW Server.\n"
+ " Subject Key Identifier (not critical):\n"
+ " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
+ "Other Information:\n"
+ " Public Key ID:\n"
+ " 5493e6599b283b4529378818aef9a4abbf4d9918\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICIDCCAYugAwIBAgIBADALBgkqhkiG9w0BAQUwKDEmMCQGA1UEChMdR251VExT\n"
+ "IGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0EwHhcNMDgwNTAzMTEyNDM4WhcNMDgwNTE3\n"
+ "MTEyNDQwWjAoMSYwJAYDVQQKEx1HbnVUTFMgaG9zdG5hbWUgY2hlY2sgdGVzdCBD\n"
+ "QTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA0gXBZcu9Hi7re4cHlEyTM/OBg30y\n"
+ "G3FOTn/HvL9LL/JJtc+/wLjoKczzYb0uHeToGd3FvS7wNbH9MNf1qHyDmhOevyXt\n"
+ "CKYFnntOI1nDDlrzv1TH3NQTV6EPop7Iq3Vm3geEjWitcQTgnL3L9gh6l0L4EJQp\n"
+ "AUp+YdcEIQVM8QcCAwEAAaNhMF8wDwYDVR0TAQH/BAUwAwEB/zAYBgNVHREEETAP\n"
+ "gg13d3cuZXhhbXBsZS4qMBMGA1UdJQQMMAoGCCsGAQUFBwMBMB0GA1UdDgQWBBRU\n"
+ "k+ZZmyg7RSk3iBiu+aSrv02ZGDALBgkqhkiG9w0BAQUDgYEAZ7gLXtXwFW61dSAM\n"
+ "0Qt6IN68WBH7LCzetSF8ofG1WVUImCUU3pqXhXYtPGTrswOh2AavWTRbzVTtrFvf\n"
+ "WJg09Z7H6I70RPvAYGsK9t9qJ/4TPoYTGYQgsTbVpkv13O54O6jzemd8Zws/xMH5\n"
+ "7/q6C7P5OUmGOtfVe7UVDY0taQM=\n" "-----END CERTIFICATE-----\n";
/* Certificate with SAN and CN but for different names. */
char pem9[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 4a827d5c\n"
- " Issuer: O=GnuTLS hostname check test CA,CN=foo.example.org\n"
- " Validity:\n"
- " Not Before: Wed Aug 12 08:29:17 UTC 2009\n"
- " Not After: Thu Aug 13 08:29:23 UTC 2009\n"
- " Subject: O=GnuTLS hostname check test CA,CN=foo.example.org\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " bb:66:43:f5:f2:c5:d7:b6:8c:cc:c5:df:f5:88:3b:b1\n"
- " c9:4b:6a:0e:a1:ad:20:50:40:08:80:a1:4f:5c:a3:d0\n"
- " f8:6c:cf:e6:3c:f7:ec:04:76:13:17:8b:64:89:22:5b\n"
- " c0:dd:53:7c:3b:ed:7c:04:bb:80:b9:28:be:8e:9b:c6\n"
- " 8e:a0:a5:12:cb:f5:57:1e:a2:e7:bb:b7:33:49:9f:e3\n"
- " bb:4a:ae:6a:4d:68:ff:c9:11:e2:32:8d:ce:3d:80:0b\n"
- " 8d:75:ef:d8:00:81:8f:28:04:03:a0:22:8d:61:04:07\n"
- " fa:b6:37:7d:21:07:49:d2:09:61:69:98:90:a3:58:a9\n"
- " Exponent (bits 24):\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): TRUE\n"
- " Subject Alternative Name (not critical):\n"
- " DNSname: bar.example.org\n"
- " Key Purpose (not critical):\n"
- " TLS WWW Server.\n"
- " Subject Key Identifier (not critical):\n"
- " 4cb90a9bfa1d34e37edecbd20715fea1dacb6891\n"
- " Signature Algorithm: RSA-SHA\n"
- " Signature:\n"
- " a2:1f:d2:90:5f:c9:1c:6f:92:1d:c5:0b:ac:b0:17:23\n"
- " c5:67:46:94:6f:0f:62:7d:66:4c:28:ff:b7:10:73:60\n"
- " ae:0e:a2:47:82:83:bb:89:0d:f1:16:5e:f9:5b:35:4b\n"
- " ce:ee:5e:d0:ad:b5:8b:cc:37:b3:ac:4d:1b:58:c2:4f\n"
- " 1c:7f:c6:ac:3d:25:18:67:37:f0:27:11:9b:2c:20:b6\n"
- " 78:24:21:a6:77:44:e7:1a:e5:f6:bf:45:84:32:81:67\n"
- " af:8d:96:26:f7:39:31:6b:63:c5:15:9d:e0:a0:9a:1e\n"
- " 96:12:cb:ad:85:cb:a7:d4:86:ac:d8:f5:e9:a4:2b:20\n"
- "Other Information:\n"
- " MD5 fingerprint:\n"
- " f27b18092c7497f206e70f504eee0f8e\n"
- " SHA-1 fingerprint:\n"
- " bebdac9d0dd54e8f044642e0f065fae5d75ca6e5\n"
- " Public Key ID:\n"
- " 4cb90a9bfa1d34e37edecbd20715fea1dacb6891\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIICWTCCAcSgAwIBAgIESoJ9XDALBgkqhkiG9w0BAQUwQjEmMCQGA1UEChMdR251\n"
- "VExTIGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0ExGDAWBgNVBAMTD2Zvby5leGFtcGxl\n"
- "Lm9yZzAeFw0wOTA4MTIwODI5MTdaFw0wOTA4MTMwODI5MjNaMEIxJjAkBgNVBAoT\n"
- "HUdudVRMUyBob3N0bmFtZSBjaGVjayB0ZXN0IENBMRgwFgYDVQQDEw9mb28uZXhh\n"
- "bXBsZS5vcmcwgZwwCwYJKoZIhvcNAQEBA4GMADCBiAKBgLtmQ/Xyxde2jMzF3/WI\n"
- "O7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeLZIkiW8DdU3w77XwEu4C5KL6O\n"
- "m8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKNzj2AC41179gAgY8oBAOgIo1h\n"
- "BAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wGgYD\n"
- "VR0RBBMwEYIPYmFyLmV4YW1wbGUub3JnMBMGA1UdJQQMMAoGCCsGAQUFBwMBMB0G\n"
- "A1UdDgQWBBRMuQqb+h00437ey9IHFf6h2stokTALBgkqhkiG9w0BAQUDgYEAoh/S\n"
- "kF/JHG+SHcULrLAXI8VnRpRvD2J9Zkwo/7cQc2CuDqJHgoO7iQ3xFl75WzVLzu5e\n"
- "0K21i8w3s6xNG1jCTxx/xqw9JRhnN/AnEZssILZ4JCGmd0TnGuX2v0WEMoFnr42W\n"
- "Jvc5MWtjxRWd4KCaHpYSy62Fy6fUhqzY9emkKyA=\n" "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 4a827d5c\n"
+ " Issuer: O=GnuTLS hostname check test CA,CN=foo.example.org\n"
+ " Validity:\n"
+ " Not Before: Wed Aug 12 08:29:17 UTC 2009\n"
+ " Not After: Thu Aug 13 08:29:23 UTC 2009\n"
+ " Subject: O=GnuTLS hostname check test CA,CN=foo.example.org\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " bb:66:43:f5:f2:c5:d7:b6:8c:cc:c5:df:f5:88:3b:b1\n"
+ " c9:4b:6a:0e:a1:ad:20:50:40:08:80:a1:4f:5c:a3:d0\n"
+ " f8:6c:cf:e6:3c:f7:ec:04:76:13:17:8b:64:89:22:5b\n"
+ " c0:dd:53:7c:3b:ed:7c:04:bb:80:b9:28:be:8e:9b:c6\n"
+ " 8e:a0:a5:12:cb:f5:57:1e:a2:e7:bb:b7:33:49:9f:e3\n"
+ " bb:4a:ae:6a:4d:68:ff:c9:11:e2:32:8d:ce:3d:80:0b\n"
+ " 8d:75:ef:d8:00:81:8f:28:04:03:a0:22:8d:61:04:07\n"
+ " fa:b6:37:7d:21:07:49:d2:09:61:69:98:90:a3:58:a9\n"
+ " Exponent (bits 24):\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): TRUE\n"
+ " Subject Alternative Name (not critical):\n"
+ " DNSname: bar.example.org\n"
+ " Key Purpose (not critical):\n"
+ " TLS WWW Server.\n"
+ " Subject Key Identifier (not critical):\n"
+ " 4cb90a9bfa1d34e37edecbd20715fea1dacb6891\n"
+ " Signature Algorithm: RSA-SHA\n"
+ " Signature:\n"
+ " a2:1f:d2:90:5f:c9:1c:6f:92:1d:c5:0b:ac:b0:17:23\n"
+ " c5:67:46:94:6f:0f:62:7d:66:4c:28:ff:b7:10:73:60\n"
+ " ae:0e:a2:47:82:83:bb:89:0d:f1:16:5e:f9:5b:35:4b\n"
+ " ce:ee:5e:d0:ad:b5:8b:cc:37:b3:ac:4d:1b:58:c2:4f\n"
+ " 1c:7f:c6:ac:3d:25:18:67:37:f0:27:11:9b:2c:20:b6\n"
+ " 78:24:21:a6:77:44:e7:1a:e5:f6:bf:45:84:32:81:67\n"
+ " af:8d:96:26:f7:39:31:6b:63:c5:15:9d:e0:a0:9a:1e\n"
+ " 96:12:cb:ad:85:cb:a7:d4:86:ac:d8:f5:e9:a4:2b:20\n"
+ "Other Information:\n"
+ " MD5 fingerprint:\n"
+ " f27b18092c7497f206e70f504eee0f8e\n"
+ " SHA-1 fingerprint:\n"
+ " bebdac9d0dd54e8f044642e0f065fae5d75ca6e5\n"
+ " Public Key ID:\n"
+ " 4cb90a9bfa1d34e37edecbd20715fea1dacb6891\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICWTCCAcSgAwIBAgIESoJ9XDALBgkqhkiG9w0BAQUwQjEmMCQGA1UEChMdR251\n"
+ "VExTIGhvc3RuYW1lIGNoZWNrIHRlc3QgQ0ExGDAWBgNVBAMTD2Zvby5leGFtcGxl\n"
+ "Lm9yZzAeFw0wOTA4MTIwODI5MTdaFw0wOTA4MTMwODI5MjNaMEIxJjAkBgNVBAoT\n"
+ "HUdudVRMUyBob3N0bmFtZSBjaGVjayB0ZXN0IENBMRgwFgYDVQQDEw9mb28uZXhh\n"
+ "bXBsZS5vcmcwgZwwCwYJKoZIhvcNAQEBA4GMADCBiAKBgLtmQ/Xyxde2jMzF3/WI\n"
+ "O7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeLZIkiW8DdU3w77XwEu4C5KL6O\n"
+ "m8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKNzj2AC41179gAgY8oBAOgIo1h\n"
+ "BAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wGgYD\n"
+ "VR0RBBMwEYIPYmFyLmV4YW1wbGUub3JnMBMGA1UdJQQMMAoGCCsGAQUFBwMBMB0G\n"
+ "A1UdDgQWBBRMuQqb+h00437ey9IHFf6h2stokTALBgkqhkiG9w0BAQUDgYEAoh/S\n"
+ "kF/JHG+SHcULrLAXI8VnRpRvD2J9Zkwo/7cQc2CuDqJHgoO7iQ3xFl75WzVLzu5e\n"
+ "0K21i8w3s6xNG1jCTxx/xqw9JRhnN/AnEZssILZ4JCGmd0TnGuX2v0WEMoFnr42W\n"
+ "Jvc5MWtjxRWd4KCaHpYSy62Fy6fUhqzY9emkKyA=\n"
+ "-----END CERTIFICATE-----\n";
/* Certificate with SAN and CN that match iff you truncate the SAN to
the embedded NUL.
See <http://thread.gmane.org/gmane.network.gnutls.general/1735>. */
char pem10[] =
- "X.509 Certificate Information:\n"
- " Version: 3\n"
- " Serial Number (hex): 0b5d0a870d09\n"
- " Issuer: C=NN,O=Edel Curl Arctic Illudium Research Cloud,CN=Nothern Nowhere Trust Anchor\n"
- " Validity:\n"
- " Not Before: Tue Aug 04 22:07:33 UTC 2009\n"
- " Not After: Sat Oct 21 22:07:33 UTC 2017\n"
- " Subject: C=NN,O=Edel Curl Arctic Illudium Research Cloud,CN=localhost\n"
- " Subject Public Key Algorithm: RSA\n"
- " Modulus (bits 1024):\n"
- " be:67:3b:b4:ea:c0:85:b4:c3:56:c1:a4:96:23:36:f5\n"
- " c6:77:aa:ad:e5:c1:dd:ce:c1:9a:97:07:dd:16:90:eb\n"
- " f0:38:b5:95:6b:a6:0f:b9:73:4e:7d:82:57:ab:5f:b5\n"
- " ba:5c:a0:48:8c:82:77:fd:67:d8:53:44:61:86:a5:06\n"
- " 19:bf:73:51:68:2e:1a:0a:c5:05:39:ca:3d:ca:83:ed\n"
- " 07:fe:ae:b7:73:1d:60:dd:ab:9e:0e:7e:02:f3:68:42\n"
- " 93:27:c8:5f:c5:fa:cb:a9:84:06:2f:f3:66:bd:de:7d\n"
- " 29:82:57:47:e4:a9:df:bf:8b:bc:c0:46:33:5a:7b:87\n"
- " Exponent (bits 24):\n"
- " 01:00:01\n"
- " Extensions:\n"
- " Subject Alternative Name (not critical):\n"
- "warning: SAN contains an embedded NUL, replacing with '!'\n"
- " DNSname: localhost!h\n"
- " Key Usage (not critical):\n"
- " Key encipherment.\n"
- " Key Purpose (not critical):\n"
- " TLS WWW Server.\n"
- " Subject Key Identifier (not critical):\n"
- " 0c37a3db0f73b3388a69d36eb3a7d6d8774eda67\n"
- " Authority Key Identifier (not critical):\n"
- " 126b24d24a68b7a1b01ccdbfd64ccc405b7fe040\n"
- " Basic Constraints (critical):\n"
- " Certificate Authority (CA): FALSE\n"
- " Signature Algorithm: RSA-SHA\n"
- " Signature:\n"
- " 88:a0:17:77:77:bf:c1:8a:18:4e:a3:94:6e:45:18:31\n"
- " fa:2f:7b:1f:ee:95:20:d1:cd:40:df:ee:f0:45:2e:e9\n"
- " e6:cf:c8:77:bd:85:16:d7:9f:18:52:78:3f:ea:9c:86\n"
- " 62:6e:db:90:b0:cd:f1:c1:6f:2d:87:4a:a0:be:b3:dc\n"
- " 6d:e4:6b:d1:da:b9:10:25:7e:35:1f:1b:aa:a7:09:2f\n"
- " 84:77:27:b0:48:a8:6d:54:57:38:35:22:34:03:0f:d4\n"
- " 5d:ab:1c:72:15:b1:d9:89:56:10:12:fb:7d:0d:18:12\n"
- " a9:0a:38:dc:93:cf:69:ff:75:86:9e:e3:6b:eb:92:6c\n"
- " 55:16:d5:65:8b:d7:9c:5e:4b:82:c8:92:6c:8b:e6:18\n"
- " a2:f8:8c:65:aa:b6:eb:23:ed:cb:99:db:fc:8b:8e:1d\n"
- " 7a:39:c9:f5:7b:7f:58:7b:ed:01:6c:3c:40:ec:e3:a9\n"
- " 5f:c4:3d:cb:81:17:03:6d:2d:d7:bd:00:5f:c4:79:f2\n"
- " fb:ab:c6:0e:a2:01:8b:a1:42:73:de:96:29:3e:bf:d7\n"
- " d9:51:a7:d4:98:07:7f:f0:f4:cd:00:a1:e1:ac:6c:05\n"
- " ac:ab:93:1b:b0:5c:2c:13:ad:ff:27:dc:80:99:34:66\n"
- " bd:e3:31:54:d5:b6:3f:ce:d4:08:a3:52:28:61:5e:bd\n"
- "Other Information:\n"
- " MD5 fingerprint:\n"
- " 0b4d6d944200cdd1639008b24dc0fe0a\n"
- " SHA-1 fingerprint:\n"
- " ce85660f5451b0cc12f525577f0eb9411a20c76b\n"
- " Public Key ID:\n"
- " a1d18c15e65c7c4935512eeea7ca5d3e6baad4e1\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIIDQzCCAiugAwIBAgIGC10Khw0JMA0GCSqGSIb3DQEBBQUAMGcxCzAJBgNVBAYT\n"
- "Ak5OMTEwLwYDVQQKDChFZGVsIEN1cmwgQXJjdGljIElsbHVkaXVtIFJlc2VhcmNo\n"
- "IENsb3VkMSUwIwYDVQQDDBxOb3RoZXJuIE5vd2hlcmUgVHJ1c3QgQW5jaG9yMB4X\n"
- "DTA5MDgwNDIyMDczM1oXDTE3MTAyMTIyMDczM1owVDELMAkGA1UEBhMCTk4xMTAv\n"
- "BgNVBAoMKEVkZWwgQ3VybCBBcmN0aWMgSWxsdWRpdW0gUmVzZWFyY2ggQ2xvdWQx\n"
- "EjAQBgNVBAMMCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA\n"
- "vmc7tOrAhbTDVsGkliM29cZ3qq3lwd3OwZqXB90WkOvwOLWVa6YPuXNOfYJXq1+1\n"
- "ulygSIyCd/1n2FNEYYalBhm/c1FoLhoKxQU5yj3Kg+0H/q63cx1g3aueDn4C82hC\n"
- "kyfIX8X6y6mEBi/zZr3efSmCV0fkqd+/i7zARjNae4cCAwEAAaOBizCBiDAWBgNV\n"
- "HREEDzANggtsb2NhbGhvc3QAaDALBgNVHQ8EBAMCBSAwEwYDVR0lBAwwCgYIKwYB\n"
- "BQUHAwEwHQYDVR0OBBYEFAw3o9sPc7M4imnTbrOn1th3TtpnMB8GA1UdIwQYMBaA\n"
- "FBJrJNJKaLehsBzNv9ZMzEBbf+BAMAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEF\n"
- "BQADggEBAIigF3d3v8GKGE6jlG5FGDH6L3sf7pUg0c1A3+7wRS7p5s/Id72FFtef\n"
- "GFJ4P+qchmJu25CwzfHBby2HSqC+s9xt5GvR2rkQJX41HxuqpwkvhHcnsEiobVRX\n"
- "ODUiNAMP1F2rHHIVsdmJVhAS+30NGBKpCjjck89p/3WGnuNr65JsVRbVZYvXnF5L\n"
- "gsiSbIvmGKL4jGWqtusj7cuZ2/yLjh16Ocn1e39Ye+0BbDxA7OOpX8Q9y4EXA20t\n"
- "170AX8R58vurxg6iAYuhQnPelik+v9fZUafUmAd/8PTNAKHhrGwFrKuTG7BcLBOt\n"
- "/yfcgJk0Zr3jMVTVtj/O1AijUihhXr0=\n" "-----END CERTIFICATE-----\n";
+ "X.509 Certificate Information:\n"
+ " Version: 3\n"
+ " Serial Number (hex): 0b5d0a870d09\n"
+ " Issuer: C=NN,O=Edel Curl Arctic Illudium Research Cloud,CN=Nothern Nowhere Trust Anchor\n"
+ " Validity:\n"
+ " Not Before: Tue Aug 04 22:07:33 UTC 2009\n"
+ " Not After: Sat Oct 21 22:07:33 UTC 2017\n"
+ " Subject: C=NN,O=Edel Curl Arctic Illudium Research Cloud,CN=localhost\n"
+ " Subject Public Key Algorithm: RSA\n"
+ " Modulus (bits 1024):\n"
+ " be:67:3b:b4:ea:c0:85:b4:c3:56:c1:a4:96:23:36:f5\n"
+ " c6:77:aa:ad:e5:c1:dd:ce:c1:9a:97:07:dd:16:90:eb\n"
+ " f0:38:b5:95:6b:a6:0f:b9:73:4e:7d:82:57:ab:5f:b5\n"
+ " ba:5c:a0:48:8c:82:77:fd:67:d8:53:44:61:86:a5:06\n"
+ " 19:bf:73:51:68:2e:1a:0a:c5:05:39:ca:3d:ca:83:ed\n"
+ " 07:fe:ae:b7:73:1d:60:dd:ab:9e:0e:7e:02:f3:68:42\n"
+ " 93:27:c8:5f:c5:fa:cb:a9:84:06:2f:f3:66:bd:de:7d\n"
+ " 29:82:57:47:e4:a9:df:bf:8b:bc:c0:46:33:5a:7b:87\n"
+ " Exponent (bits 24):\n"
+ " 01:00:01\n"
+ " Extensions:\n"
+ " Subject Alternative Name (not critical):\n"
+ "warning: SAN contains an embedded NUL, replacing with '!'\n"
+ " DNSname: localhost!h\n"
+ " Key Usage (not critical):\n"
+ " Key encipherment.\n"
+ " Key Purpose (not critical):\n"
+ " TLS WWW Server.\n"
+ " Subject Key Identifier (not critical):\n"
+ " 0c37a3db0f73b3388a69d36eb3a7d6d8774eda67\n"
+ " Authority Key Identifier (not critical):\n"
+ " 126b24d24a68b7a1b01ccdbfd64ccc405b7fe040\n"
+ " Basic Constraints (critical):\n"
+ " Certificate Authority (CA): FALSE\n"
+ " Signature Algorithm: RSA-SHA\n"
+ " Signature:\n"
+ " 88:a0:17:77:77:bf:c1:8a:18:4e:a3:94:6e:45:18:31\n"
+ " fa:2f:7b:1f:ee:95:20:d1:cd:40:df:ee:f0:45:2e:e9\n"
+ " e6:cf:c8:77:bd:85:16:d7:9f:18:52:78:3f:ea:9c:86\n"
+ " 62:6e:db:90:b0:cd:f1:c1:6f:2d:87:4a:a0:be:b3:dc\n"
+ " 6d:e4:6b:d1:da:b9:10:25:7e:35:1f:1b:aa:a7:09:2f\n"
+ " 84:77:27:b0:48:a8:6d:54:57:38:35:22:34:03:0f:d4\n"
+ " 5d:ab:1c:72:15:b1:d9:89:56:10:12:fb:7d:0d:18:12\n"
+ " a9:0a:38:dc:93:cf:69:ff:75:86:9e:e3:6b:eb:92:6c\n"
+ " 55:16:d5:65:8b:d7:9c:5e:4b:82:c8:92:6c:8b:e6:18\n"
+ " a2:f8:8c:65:aa:b6:eb:23:ed:cb:99:db:fc:8b:8e:1d\n"
+ " 7a:39:c9:f5:7b:7f:58:7b:ed:01:6c:3c:40:ec:e3:a9\n"
+ " 5f:c4:3d:cb:81:17:03:6d:2d:d7:bd:00:5f:c4:79:f2\n"
+ " fb:ab:c6:0e:a2:01:8b:a1:42:73:de:96:29:3e:bf:d7\n"
+ " d9:51:a7:d4:98:07:7f:f0:f4:cd:00:a1:e1:ac:6c:05\n"
+ " ac:ab:93:1b:b0:5c:2c:13:ad:ff:27:dc:80:99:34:66\n"
+ " bd:e3:31:54:d5:b6:3f:ce:d4:08:a3:52:28:61:5e:bd\n"
+ "Other Information:\n"
+ " MD5 fingerprint:\n"
+ " 0b4d6d944200cdd1639008b24dc0fe0a\n"
+ " SHA-1 fingerprint:\n"
+ " ce85660f5451b0cc12f525577f0eb9411a20c76b\n"
+ " Public Key ID:\n"
+ " a1d18c15e65c7c4935512eeea7ca5d3e6baad4e1\n"
+ "\n"
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIDQzCCAiugAwIBAgIGC10Khw0JMA0GCSqGSIb3DQEBBQUAMGcxCzAJBgNVBAYT\n"
+ "Ak5OMTEwLwYDVQQKDChFZGVsIEN1cmwgQXJjdGljIElsbHVkaXVtIFJlc2VhcmNo\n"
+ "IENsb3VkMSUwIwYDVQQDDBxOb3RoZXJuIE5vd2hlcmUgVHJ1c3QgQW5jaG9yMB4X\n"
+ "DTA5MDgwNDIyMDczM1oXDTE3MTAyMTIyMDczM1owVDELMAkGA1UEBhMCTk4xMTAv\n"
+ "BgNVBAoMKEVkZWwgQ3VybCBBcmN0aWMgSWxsdWRpdW0gUmVzZWFyY2ggQ2xvdWQx\n"
+ "EjAQBgNVBAMMCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA\n"
+ "vmc7tOrAhbTDVsGkliM29cZ3qq3lwd3OwZqXB90WkOvwOLWVa6YPuXNOfYJXq1+1\n"
+ "ulygSIyCd/1n2FNEYYalBhm/c1FoLhoKxQU5yj3Kg+0H/q63cx1g3aueDn4C82hC\n"
+ "kyfIX8X6y6mEBi/zZr3efSmCV0fkqd+/i7zARjNae4cCAwEAAaOBizCBiDAWBgNV\n"
+ "HREEDzANggtsb2NhbGhvc3QAaDALBgNVHQ8EBAMCBSAwEwYDVR0lBAwwCgYIKwYB\n"
+ "BQUHAwEwHQYDVR0OBBYEFAw3o9sPc7M4imnTbrOn1th3TtpnMB8GA1UdIwQYMBaA\n"
+ "FBJrJNJKaLehsBzNv9ZMzEBbf+BAMAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEF\n"
+ "BQADggEBAIigF3d3v8GKGE6jlG5FGDH6L3sf7pUg0c1A3+7wRS7p5s/Id72FFtef\n"
+ "GFJ4P+qchmJu25CwzfHBby2HSqC+s9xt5GvR2rkQJX41HxuqpwkvhHcnsEiobVRX\n"
+ "ODUiNAMP1F2rHHIVsdmJVhAS+30NGBKpCjjck89p/3WGnuNr65JsVRbVZYvXnF5L\n"
+ "gsiSbIvmGKL4jGWqtusj7cuZ2/yLjh16Ocn1e39Ye+0BbDxA7OOpX8Q9y4EXA20t\n"
+ "170AX8R58vurxg6iAYuhQnPelik+v9fZUafUmAd/8PTNAKHhrGwFrKuTG7BcLBOt\n"
+ "/yfcgJk0Zr3jMVTVtj/O1AijUihhXr0=\n" "-----END CERTIFICATE-----\n";
char pem_too_many[] = "\n"
- " Subject: C=BE,CN=******************.gnutls.org\n"
- "\n"
- "-----BEGIN CERTIFICATE-----\n"
- "MIIDljCCAk6gAwIBAgIETcMNdjANBgkqhkiG9w0BAQsFADA6MQswCQYDVQQGEwJC\n"
- "RTErMCkGA1UEAxMiKioq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GA1UdJQQMMAoGCCsGAQUFBwMBMB0GA1UdDgQW\n"
+ "BBSSU9ZxufhoqrNT9o31OUVmnKflMTANBgkqhkiG9w0BAQsFAAOCATEAUMK435LP\n"
+ "0XpmpWLBBuC6VLLIsAGmXRv7odw8sG9fOctalsbK3zd9pDOaoFI/128GOmlTp1aC\n"
+ "n4a/pZ9G5wTKRvdxVqecdYkozDtAS35uwCSQPU/P12Oug6kA4NNJDxF3FGm5eov6\n"
+ "SnZDL0Qlhat9y0yOakaOkVNwESAwgUEYClZeR45htvH5oP48XEgwqHQ9jPS2MXAe\n"
+ "QLBjqqeYzIvWqwT4z14tIkN0VWWqqVo/dzV+lfNwQy0UL8iWVYnks8wKs2SBkVHx\n"
+ "41wBR3uCgCDwlYGDLIG1cm0n7mXrnE7KNcrwQKXL8WGNRAVvx5MVO1vDoWPyQ1Y4\n"
+ "sDdnQiVER9ee/KxO6IgCTGh+nCBTSSYgLX2E/m789quPvzyi9Hf/go28he6E3dSK\n"
+ "q7/LRSxaZenB/Q==\n" "-----END CERTIFICATE-----\n";
#ifdef ENABLE_OPENPGP
/* Check basic OpenPGP comparison too.
<http://thread.gmane.org/gmane.comp.encryption.gpg.gnutls.devel/3812>. */
char pem11[] =
- "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
- "Version: GnuPG v1.4.6 (GNU/Linux)\n"
- "\n"
- "mQGiBEXInlgRBAD0teb6ohIlchkHcFlmmvtVW1KXexlDfXExf8T+fOz5z354GPOX\n"
- "sDq98ztCEE3hnPEOFj4NT0X3nEtrvLkhmZqrDHSbuJACB4qxeHwEbGFx7OIDW8+u\n"
- "4sKxpaza1GVf1NQ7VIaQiXaGHy8Esn9SW7oNhK6z5l4TIRlm3OBt3cxU3wCgjnnO\n"
- "jpGJeeo0OnZzSH+xsNLJQEcEAOmUc+7N9OhpT/gqddIgzYRr/FD0Ad6HBfABol6Q\n"
- "wWCapzIxggnZJ9i+lHujpcA8idtrBU/DGhkGtW95QaHwQ8d5SvetM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_x509_crt_t x509;
#ifdef ENABLE_OPENPGP
- gnutls_openpgp_crt_t pgp;
+ gnutls_openpgp_crt_t pgp;
#endif
- gnutls_datum_t data;
- int ret;
+ gnutls_datum_t data;
+ int ret;
- ret = global_init ();
- if (ret < 0)
- fail ("global_init: %d\n", ret);
+ ret = global_init();
+ if (ret < 0)
+ fail("global_init: %d\n", ret);
- ret = gnutls_x509_crt_init (&x509);
- if (ret < 0)
- fail ("gnutls_x509_crt_init: %d\n", ret);
+ ret = gnutls_x509_crt_init(&x509);
+ if (ret < 0)
+ fail("gnutls_x509_crt_init: %d\n", ret);
#ifdef ENABLE_OPENPGP
- ret = gnutls_openpgp_crt_init (&pgp);
- if (ret < 0)
- fail ("gnutls_openpgp_crt_init: %d\n", ret);
+ ret = gnutls_openpgp_crt_init(&pgp);
+ if (ret < 0)
+ fail("gnutls_openpgp_crt_init: %d\n", ret);
#endif
- if (debug)
- success ("Testing pem1...\n");
- data.data = (unsigned char*)pem1;
- data.size = strlen (pem1);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- if (debug)
- success ("Testing pem2...\n");
- data.data = (unsigned char*)pem2;
- data.size = strlen (pem2);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "www.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "*.example.org");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- if (debug)
- success ("Testing pem3...\n");
- data.data = (unsigned char*)pem3;
- data.size = strlen (pem3);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "www.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "*.example.org");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- if (debug)
- success ("Testing pem4...\n");
- data.data = (unsigned char*)pem4;
- data.size = strlen (pem4);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "www.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo.example.com");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- if (debug)
- success ("Testing pem6...\n");
- data.data = (unsigned char*)pem6;
- data.size = strlen (pem6);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo.example.org");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "bar.foo.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- if (debug)
- success ("Testing pem7...\n");
- data.data = (unsigned char*)pem7;
- data.size = strlen (pem7);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo.bar.example.org");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foobar.bar.example.org");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foobar.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foobazbar.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- if (debug)
- success ("Testing pem8...\n");
- data.data = (unsigned char*)pem8;
- data.size = strlen (pem8);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "www.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "www.example.");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "www.example.com");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "www.example.foo.com");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- if (debug)
- success ("Testing pem9...\n");
- data.data = (unsigned char*)pem9;
- data.size = strlen (pem9);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "foo.example.org");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "bar.example.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- if (debug)
- success ("Testing pem10...\n");
- data.data = (unsigned char*)pem10;
- data.size = strlen (pem10);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "localhost");
- if (ret)
- fail ("Hostname incorrectly matches (%d)\n", ret);
-
- if (debug)
- success ("Testing pem_too_many...\n");
- data.data = (unsigned char*)pem_too_many;
- data.size = strlen (pem_too_many);
-
- ret = gnutls_x509_crt_import (x509, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import: %d\n", ret);
-
- ret = gnutls_x509_crt_check_hostname (x509, "localhost.gnutls.gnutls.org");
- if (ret)
- fail ("Hostname verification should have failed (too many wildcards)\n");
+ if (debug)
+ success("Testing pem1...\n");
+ data.data = (unsigned char *) pem1;
+ data.size = strlen(pem1);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem2...\n");
+ data.data = (unsigned char *) pem2;
+ data.size = strlen(pem2);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "www.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "*.example.org");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem3...\n");
+ data.data = (unsigned char *) pem3;
+ data.size = strlen(pem3);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "www.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "*.example.org");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem4...\n");
+ data.data = (unsigned char *) pem4;
+ data.size = strlen(pem4);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "www.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo.example.com");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem6...\n");
+ data.data = (unsigned char *) pem6;
+ data.size = strlen(pem6);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo.example.org");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "bar.foo.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem7...\n");
+ data.data = (unsigned char *) pem7;
+ data.size = strlen(pem7);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo.bar.example.org");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ ret =
+ gnutls_x509_crt_check_hostname(x509, "foobar.bar.example.org");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foobar.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret =
+ gnutls_x509_crt_check_hostname(x509, "foobazbar.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem8...\n");
+ data.data = (unsigned char *) pem8;
+ data.size = strlen(pem8);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "www.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "www.example.");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "www.example.com");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "www.example.foo.com");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem9...\n");
+ data.data = (unsigned char *) pem9;
+ data.size = strlen(pem9);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "foo.example.org");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "bar.example.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem10...\n");
+ data.data = (unsigned char *) pem10;
+ data.size = strlen(pem10);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret = gnutls_x509_crt_check_hostname(x509, "localhost");
+ if (ret)
+ fail("Hostname incorrectly matches (%d)\n", ret);
+
+ if (debug)
+ success("Testing pem_too_many...\n");
+ data.data = (unsigned char *) pem_too_many;
+ data.size = strlen(pem_too_many);
+
+ ret = gnutls_x509_crt_import(x509, &data, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import: %d\n", ret);
+
+ ret =
+ gnutls_x509_crt_check_hostname(x509,
+ "localhost.gnutls.gnutls.org");
+ if (ret)
+ fail("Hostname verification should have failed (too many wildcards)\n");
#ifdef ENABLE_OPENPGP
- if (debug)
- success ("Testing pem11...\n");
- data.data = (unsigned char*)pem11;
- data.size = strlen (pem11);
-
- ret = gnutls_openpgp_crt_import (pgp, &data, GNUTLS_OPENPGP_FMT_BASE64);
- if (ret < 0)
- fail ("gnutls_openpgp_crt_import: %d\n", ret);
-
- ret = gnutls_openpgp_crt_check_hostname (pgp, "test.gnutls.org");
- if (!ret)
- fail ("Hostname incorrectly does not match (%d)\n", ret);
-
- gnutls_openpgp_crt_deinit (pgp);
+ if (debug)
+ success("Testing pem11...\n");
+ data.data = (unsigned char *) pem11;
+ data.size = strlen(pem11);
+
+ ret =
+ gnutls_openpgp_crt_import(pgp, &data,
+ GNUTLS_OPENPGP_FMT_BASE64);
+ if (ret < 0)
+ fail("gnutls_openpgp_crt_import: %d\n", ret);
+
+ ret = gnutls_openpgp_crt_check_hostname(pgp, "test.gnutls.org");
+ if (!ret)
+ fail("Hostname incorrectly does not match (%d)\n", ret);
+
+ gnutls_openpgp_crt_deinit(pgp);
#endif
- gnutls_x509_crt_deinit (x509);
+ gnutls_x509_crt_deinit(x509);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
diff --git a/tests/infoaccess.c b/tests/infoaccess.c
index 2f7e79bb4f..71189ed51f 100644
--- a/tests/infoaccess.c
+++ b/tests/infoaccess.c
@@ -33,206 +33,199 @@
#include "utils.h"
static char cert_with_aia_data[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJC\n"
- "TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0\n"
- "aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0\n"
- "aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAzMTkxODMzMzNaFw0yMTAzMTcxODMz\n"
- "MzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUw\n"
- "IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQDEyVR\n"
- "dW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG\n"
- "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Yp\n"
- "li4kVEAkOPcahdxYTMukJ0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2D\n"
- "rOpm2RgbaIr1VxqYuvXtdj182d6Uaj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IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYD\n"
+ "VQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6tlCL\n"
+ "MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSk\n"
+ "fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8\n"
+ "7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R\n"
+ "cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y\n"
+ "mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW\n"
+ "xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK\n"
+ "SnQ2+Q==\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t cert_with_aia = {
- (void*)cert_with_aia_data, sizeof (cert_with_aia_data)
+ (void *) cert_with_aia_data, sizeof(cert_with_aia_data)
};
-void
-doit (void)
+void doit(void)
{
- gnutls_x509_crt_t crt;
- int ret;
- gnutls_datum_t data;
- unsigned int critical;
-
- ret = global_init ();
- if (ret < 0)
- {
- fail ("global_init\n");
- exit (1);
- }
-
- ret = gnutls_x509_crt_init (&crt);
- if (ret != 0)
- {
- fail ("gnutls_x509_crt_init\n");
- exit (1);
- }
-
- ret = gnutls_x509_crt_import (crt, &cert_with_aia, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import\n");
- exit (1);
- }
-
- /* test null input */
- ret = gnutls_x509_crt_get_authority_info_access (NULL, 0, 0, NULL, NULL);
- if (ret != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_x509_crt_get_authority_info_access null input\n");
- exit (1);
- }
-
- /* test unused enum */
- ret = gnutls_x509_crt_get_authority_info_access (crt, 0, 44, NULL, NULL);
- if (ret != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_x509_crt_get_authority_info_access insane input\n");
- exit (1);
- }
-
- /* test basic query with null output */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 0, GNUTLS_IA_ACCESSMETHOD_OID, NULL, NULL);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access "
- "GNUTLS_IA_ACCESSMETHOD_OID null output critical\n");
- exit (1);
- }
-
- /* test same as previous but also check that critical flag is
- correct */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 0, GNUTLS_IA_ACCESSMETHOD_OID, NULL, &critical);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access "
- "GNUTLS_IA_ACCESSMETHOD_OID null output\n");
- exit (1);
- }
-
- if (critical != 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access "
- "critical failed: %d\n", critical);
- exit (1);
- }
-
- /* basic query of another type */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 0, GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE, NULL, NULL);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access "
- "GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE null output\n");
- exit (1);
- }
-
- /* basic query of another type, with out-of-bound sequence */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 1, GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE, NULL, NULL);
- if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- {
- fail ("gnutls_x509_crt_get_authority_info_access "
- "GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE out-of-bounds\n");
- exit (1);
- }
-
- /* basic query and check output value */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 0, GNUTLS_IA_ACCESSMETHOD_OID, &data, NULL);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access "
- "GNUTLS_IA_ACCESSMETHOD_OID\n");
- exit (1);
- }
-
- if (memcmp ("1.3.6.1.5.5.7.48.1", data.data, data.size) != 0)
- {
- fail ("memcmp OCSP OID failed\n");
- exit (1);
- }
- gnutls_free (data.data);
-
- /* basic query of another type and check output value */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 0, GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE, &data, NULL);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access "
- "GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE\n");
- exit (1);
- }
-
- if (memcmp ("uniformResourceIdentifier", data.data, data.size) != 0)
- {
- fail ("memcmp URI failed\n");
- exit (1);
- }
- gnutls_free (data.data);
-
- /* specific query */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 0, GNUTLS_IA_URI, &data, NULL);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access GNUTLS_IA_URI\n");
- exit (1);
- }
-
- if (memcmp ("https://ocsp.quovadisoffshore.com", data.data, data.size) != 0)
- {
- fail ("memcmp URI value failed\n");
- exit (1);
- }
- gnutls_free (data.data);
-
- /* even more specific query */
- ret = gnutls_x509_crt_get_authority_info_access
- (crt, 0, GNUTLS_IA_OCSP_URI, &data, NULL);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_get_authority_info_access GNUTLS_IA_OCSP_URI\n");
- exit (1);
- }
-
- if (memcmp ("https://ocsp.quovadisoffshore.com", data.data, data.size) != 0)
- {
- fail ("memcmp URI value failed\n");
- exit (1);
- }
- gnutls_free (data.data);
-
- gnutls_x509_crt_deinit (crt);
-
- gnutls_global_deinit ();
+ gnutls_x509_crt_t crt;
+ int ret;
+ gnutls_datum_t data;
+ unsigned int critical;
+
+ ret = global_init();
+ if (ret < 0) {
+ fail("global_init\n");
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_init(&crt);
+ if (ret != 0) {
+ fail("gnutls_x509_crt_init\n");
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(crt, &cert_with_aia,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import\n");
+ exit(1);
+ }
+
+ /* test null input */
+ ret =
+ gnutls_x509_crt_get_authority_info_access(NULL, 0, 0, NULL,
+ NULL);
+ if (ret != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_x509_crt_get_authority_info_access null input\n");
+ exit(1);
+ }
+
+ /* test unused enum */
+ ret =
+ gnutls_x509_crt_get_authority_info_access(crt, 0, 44, NULL,
+ NULL);
+ if (ret != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_x509_crt_get_authority_info_access insane input\n");
+ exit(1);
+ }
+
+ /* test basic query with null output */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 0, GNUTLS_IA_ACCESSMETHOD_OID, NULL, NULL);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_get_authority_info_access "
+ "GNUTLS_IA_ACCESSMETHOD_OID null output critical\n");
+ exit(1);
+ }
+
+ /* test same as previous but also check that critical flag is
+ correct */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 0, GNUTLS_IA_ACCESSMETHOD_OID, NULL, &critical);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_get_authority_info_access "
+ "GNUTLS_IA_ACCESSMETHOD_OID null output\n");
+ exit(1);
+ }
+
+ if (critical != 0) {
+ fail("gnutls_x509_crt_get_authority_info_access "
+ "critical failed: %d\n", critical);
+ exit(1);
+ }
+
+ /* basic query of another type */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 0, GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE, NULL,
+ NULL);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_get_authority_info_access "
+ "GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE null output\n");
+ exit(1);
+ }
+
+ /* basic query of another type, with out-of-bound sequence */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 1, GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE, NULL,
+ NULL);
+ if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
+ fail("gnutls_x509_crt_get_authority_info_access "
+ "GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE out-of-bounds\n");
+ exit(1);
+ }
+
+ /* basic query and check output value */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 0, GNUTLS_IA_ACCESSMETHOD_OID, &data, NULL);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_get_authority_info_access "
+ "GNUTLS_IA_ACCESSMETHOD_OID\n");
+ exit(1);
+ }
+
+ if (memcmp("1.3.6.1.5.5.7.48.1", data.data, data.size) != 0) {
+ fail("memcmp OCSP OID failed\n");
+ exit(1);
+ }
+ gnutls_free(data.data);
+
+ /* basic query of another type and check output value */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 0, GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE, &data,
+ NULL);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_get_authority_info_access "
+ "GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE\n");
+ exit(1);
+ }
+
+ if (memcmp("uniformResourceIdentifier", data.data, data.size) != 0) {
+ fail("memcmp URI failed\n");
+ exit(1);
+ }
+ gnutls_free(data.data);
+
+ /* specific query */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 0, GNUTLS_IA_URI, &data, NULL);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_get_authority_info_access GNUTLS_IA_URI\n");
+ exit(1);
+ }
+
+ if (memcmp
+ ("https://ocsp.quovadisoffshore.com", data.data,
+ data.size) != 0) {
+ fail("memcmp URI value failed\n");
+ exit(1);
+ }
+ gnutls_free(data.data);
+
+ /* even more specific query */
+ ret = gnutls_x509_crt_get_authority_info_access
+ (crt, 0, GNUTLS_IA_OCSP_URI, &data, NULL);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_get_authority_info_access GNUTLS_IA_OCSP_URI\n");
+ exit(1);
+ }
+
+ if (memcmp
+ ("https://ocsp.quovadisoffshore.com", data.data,
+ data.size) != 0) {
+ fail("memcmp URI value failed\n");
+ exit(1);
+ }
+ gnutls_free(data.data);
+
+ gnutls_x509_crt_deinit(crt);
+
+ gnutls_global_deinit();
}
diff --git a/tests/init_roundtrip.c b/tests/init_roundtrip.c
index c96dd50345..4160b61bfe 100644
--- a/tests/init_roundtrip.c
+++ b/tests/init_roundtrip.c
@@ -30,23 +30,22 @@
/* See <http://bugs.gentoo.org/272388>. */
-void
-doit (void)
+void doit(void)
{
- int res;
+ int res;
- res = global_init ();
- if (res != 0)
- fail ("global_init\n");
+ res = global_init();
+ if (res != 0)
+ fail("global_init\n");
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- res = global_init ();
- if (res != 0)
- fail ("global_init2\n");
+ res = global_init();
+ if (res != 0)
+ fail("global_init2\n");
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- if (debug)
- success ("init-deinit round-trip success\n");
+ if (debug)
+ success("init-deinit round-trip success\n");
}
diff --git a/tests/key-openssl.c b/tests/key-openssl.c
index 3d8fd51eb3..1fb599d7d7 100644
--- a/tests/key-openssl.c
+++ b/tests/key-openssl.c
@@ -33,94 +33,94 @@
#include "utils.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", "crq_key_id", level, str);
+ fprintf(stderr, "%s |<%d>| %s", "crq_key_id", level, str);
}
-const char key1[] =
-"-----BEGIN RSA PRIVATE KEY-----\n"
-"Proc-Type: 4,ENCRYPTED\n"
-"DEK-Info: DES-EDE3-CBC,82B2F7684A1713F8\n"
-"\n"
-"1zzOuu89dfFc2UkFCtSJBsBeEFxV8wE84OSxoWu4aYkPhl1LR08BchaTbjeLTP0b\n"
-"t961vVpva0ekJkwGDEgmqlGjmhJq9y2sJfq7IeYa8OdTilfGrG1xeJ1QGBi6SCfR\n"
-"s/PhkMxwGBtrZ2Z7bEcLT5dQKmKRqsthnClQggmngvk7zX7bPk0hKQKvf+FDxt6x\n"
-"hzEaF3k9juU6vAVVSakrZ4QDqk9MUuTGHx0ksTDcC4EESS0l3Ybuum/rAzR4lQKR\n"
-"4OLmAeYBDl+l/PSMllfd5x/z1YXYoiAbkpT4ix0lyZJgHrvrYIeUtJk2ODiMHezL\n"
-"9BbK7EobtOGmrDLUNVX5BpdaExkWMGkioqzs2QqD/VkKu8RcNSsHVGqkdWKuhzXo\n"
-"wcczQ+RiHckN2uy/zApubEWZNLPeDQ499kaF+QdZ+h4RM6E1r1Gu+A==\n"
-"-----END RSA PRIVATE KEY-----\n";
-
-const char key2[] =
-"-----BEGIN RSA PRIVATE KEY-----\n"
-"Proc-Type: 4,ENCRYPTED\n"
-"DEK-Info: AES-128-CBC,2A57FF97B701B3F760145D7446929481\n"
-"\n"
-"mGAPhSw48wZBnkHOhfMDg8yL2IBgMuTmeKE4xoHi7T6isHBNfkqMd0iJ+DJP/OKb\n"
-"t+7lkKjj/xQ7w/bOBvBxlfRe4MW6+ejCdAFD9XSolW6WN6CEJPMI4UtmOK5inqcC\n"
-"8l2l54f/VGrVN9uavU3KlXCjrd3Jp9B0Mu4Zh/UU4+EWs9rJAZfLIn+vHZ3OHetx\n"
-"g74LdV7nC7lt/fjxc1caNIfgHs40dUt9FVrnJvAtkcNMtcjX/D+L8ZrLgQzIWFcs\n"
-"WAbUZj7Me22mCli3RPET7Je37K59IzfWgbWFCGaNu3X02g5xtCfdcn/Uqy9eofH0\n"
-"YjKRhpgXPeGJCkoRqDeUHQNPpVP5HrzDZMVK3E4DC03C8qvgsYvuwYt3KkbG2fuA\n"
-"F3bDyqlxSOm7uxF/K3YzI44v8/D8GGnLBTpN+ANBdiY=\n"
-"-----END RSA PRIVATE KEY-----\n";
-
-void
-doit (void)
+const char key1[] =
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "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hpgXPeGJCkoRqDeUHQNPpVP5HrzDZMVK3E4DC03C8qvgsYvuwYt3KkbG2fuA\n"
+ "F3bDyqlxSOm7uxF/K3YzI44v8/D8GGnLBTpN+ANBdiY=\n"
+ "-----END RSA PRIVATE KEY-----\n";
+
+void doit(void)
{
- gnutls_x509_privkey_t pkey;
- int ret;
- gnutls_datum_t key;
-
- ret = global_init ();
- if (ret < 0)
- fail ("global_init: %d\n", ret);
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- ret = gnutls_x509_privkey_init (&pkey);
- if (ret < 0)
- fail ("gnutls_x509_privkey_init: %d\n", ret);
-
- key.data = (void*)key1;
- key.size = sizeof(key1);
- ret = gnutls_x509_privkey_import_openssl (pkey, &key, "123456");
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_import_openssl (key1): %s\n", gnutls_strerror(ret)) ;
- }
- gnutls_x509_privkey_deinit (pkey);
-
- ret = gnutls_x509_privkey_init (&pkey);
- if (ret < 0)
- fail ("gnutls_x509_privkey_init: %d\n", ret);
-
- key.data = (void*)key2;
- key.size = sizeof(key2);
- ret = gnutls_x509_privkey_import_openssl (pkey, &key, "a123456");
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_import_openssl (key2): %s\n", gnutls_strerror(ret)) ;
- }
-
- gnutls_x509_privkey_deinit (pkey);
-
- ret = gnutls_x509_privkey_init (&pkey);
- if (ret < 0)
- fail ("gnutls_x509_privkey_init: %d\n", ret);
-
- key.data = (void*)key1;
- key.size = sizeof(key1);
- ret = gnutls_x509_privkey_import2 (pkey, &key, GNUTLS_X509_FMT_PEM, "123456", 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_import2: %s\n", gnutls_strerror(ret)) ;
- }
- gnutls_x509_privkey_deinit (pkey);
-
- gnutls_global_deinit ();
+ gnutls_x509_privkey_t pkey;
+ int ret;
+ gnutls_datum_t key;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("global_init: %d\n", ret);
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_init: %d\n", ret);
+
+ key.data = (void *) key1;
+ key.size = sizeof(key1);
+ ret = gnutls_x509_privkey_import_openssl(pkey, &key, "123456");
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_import_openssl (key1): %s\n",
+ gnutls_strerror(ret));
+ }
+ gnutls_x509_privkey_deinit(pkey);
+
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_init: %d\n", ret);
+
+ key.data = (void *) key2;
+ key.size = sizeof(key2);
+ ret = gnutls_x509_privkey_import_openssl(pkey, &key, "a123456");
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_import_openssl (key2): %s\n",
+ gnutls_strerror(ret));
+ }
+
+ gnutls_x509_privkey_deinit(pkey);
+
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_init: %d\n", ret);
+
+ key.data = (void *) key1;
+ key.size = sizeof(key1);
+ ret =
+ gnutls_x509_privkey_import2(pkey, &key, GNUTLS_X509_FMT_PEM,
+ "123456", 0);
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_import2: %s\n",
+ gnutls_strerror(ret));
+ }
+ gnutls_x509_privkey_deinit(pkey);
+
+ gnutls_global_deinit();
}
diff --git a/tests/mini-alpn.c b/tests/mini-alpn.c
index 69ddd88191..355141a771 100644
--- a/tests/mini-alpn.c
+++ b/tests/mini-alpn.c
@@ -27,10 +27,9 @@
#if defined(_WIN32) || !defined(ENABLE_ALPN)
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -47,21 +46,19 @@ main (int argc, char** argv)
#include "utils.h"
-static void terminate (void);
+static void terminate(void);
/* This program tests the rehandshake in DTLS
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* These are global */
@@ -70,253 +67,229 @@ static pid_t child;
/* A very basic DTLS client, with anonymous authentication, that negotiates SRTP
*/
-static void
-client (int fd, const char* protocol1, const char* protocol2)
+static void client(int fd, const char *protocol1, const char *protocol2)
{
- gnutls_session_t session;
- int ret;
- gnutls_datum_t proto;
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
- if (protocol1)
- {
- gnutls_datum_t t[2];
- t[0].data = (void*)protocol1;
- t[0].size = strlen(protocol1);
- t[1].data = (void*)protocol2;
- t[1].size = strlen(protocol2);
-
- ret = gnutls_alpn_set_protocols(session, t, 2, 0);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
- }
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit (1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- ret = gnutls_alpn_get_selected_protocol(session, &proto);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
-
- if (debug)
- {
- fprintf(stderr, "selected protocol: %.*s\n", (int)proto.size, proto.data);
- }
-
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
-
- gnutls_global_deinit ();
+ gnutls_session_t session;
+ int ret;
+ gnutls_datum_t proto;
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+ if (protocol1) {
+ gnutls_datum_t t[2];
+ t[0].data = (void *) protocol1;
+ t[0].size = strlen(protocol1);
+ t[1].data = (void *) protocol2;
+ t[1].size = strlen(protocol2);
+
+ ret = gnutls_alpn_set_protocols(session, t, 2, 0);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
+ }
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ ret = gnutls_alpn_get_selected_protocol(session, &proto);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
+
+ if (debug) {
+ fprintf(stderr, "selected protocol: %.*s\n",
+ (int) proto.size, proto.data);
+ }
+
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+
+ gnutls_global_deinit();
}
-static void
-terminate (void)
+static void terminate(void)
{
- int status;
+ int status;
- kill (child, SIGTERM);
- wait (&status);
- exit (1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
-static void
-server (int fd, const char* protocol1, const char* protocol2)
+static void server(int fd, const char *protocol1, const char *protocol2)
{
- int ret;
- gnutls_session_t session;
- gnutls_anon_server_credentials_t anoncred;
- gnutls_datum_t t[2];
-
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
-
- t[0].data = (void*)protocol1;
- t[0].size = strlen(protocol1);
- t[1].data = (void*)protocol2;
- t[1].size = strlen(protocol2);
-
- ret = gnutls_alpn_set_protocols(session, t, 2, 0);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
-
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n",
- gnutls_strerror (ret));
- terminate ();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- ret = gnutls_alpn_get_selected_protocol(session, &t[0]);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
-
+ int ret;
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ gnutls_datum_t t[2];
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ t[0].data = (void *) protocol1;
+ t[0].size = strlen(protocol1);
+ t[1].data = (void *) protocol2;
+ t[1].size = strlen(protocol2);
+
+ ret = gnutls_alpn_set_protocols(session, t, 2, 0);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
+
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ ret = gnutls_alpn_get_selected_protocol(session, &t[0]);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
#if 0
- if (debug)
- {
- success ("Protocol: %.*s\n", (int)t[0].size, t[0].data);
- }
+ if (debug) {
+ success("Protocol: %.*s\n", (int) t[0].size, t[0].data);
+ }
#endif
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
- close (fd);
- gnutls_deinit (session);
+ close(fd);
+ gnutls_deinit(session);
- gnutls_anon_free_server_credentials (anoncred);
+ gnutls_anon_free_server_credentials(anoncred);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- if (debug)
- success ("server: finished\n");
+ if (debug)
+ success("server: finished\n");
}
-static void
-start (const char* p1, const char* p2)
+static void start(const char *p1, const char *p2)
{
- int fd[2];
- int ret;
-
- ret = socketpair (AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror ("socketpair");
- exit (1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit (1);
- }
-
- if (child)
- {
- int status;
- /* parent */
-
- server (fd[0], p1, p2);
- wait (&status);
- if (WEXITSTATUS (status) != 0)
- fail ("Child died with status %d\n", WEXITSTATUS (status));
- }
- else
- {
- close (fd[0]);
- client (fd[1], p2, p1);
- exit (0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+
+ server(fd[0], p1, p2);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ close(fd[0]);
+ client(fd[1], p2, p1);
+ exit(0);
+ }
}
-void
-doit (void)
+void doit(void)
{
- start ("spdy/2", "spdy/3");
- start ("spdy/3", "spdy/2");
+ start("spdy/2", "spdy/3");
+ start("spdy/3", "spdy/2");
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-cert-status.c b/tests/mini-cert-status.c
index 3b58e7b2f7..77dc030125 100644
--- a/tests/mini-cert-status.c
+++ b/tests/mini-cert-status.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -53,57 +53,55 @@ int main()
* decoding.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
// fprintf (stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQM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"bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
- "h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PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
@@ -112,213 +110,200 @@ const gnutls_datum_t server_key = { server_key_pem,
#define MAX_BUF 1024
-static void
-client (int fd)
+static void client(int fd)
{
- int ret;
- const char *p;
- gnutls_certificate_credentials_t x509_cred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
- gnutls_certificate_allocate_credentials (&x509_cred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- ret = gnutls_priority_set_direct (session, "NONE:+VERS-TLS1.0:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA", &p);
- if (ret < 0)
- {
- fail("error in setting priority: %s\n", p);
- exit(1);
- }
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- if (debug)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- }
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ int ret;
+ const char *p;
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ ret =
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.0:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA",
+ &p);
+ if (ret < 0) {
+ fail("error in setting priority: %s\n", p);
+ exit(1);
+ }
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ if (debug) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ }
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
/* These are global */
pid_t child;
-static void
-server (int fd, unsigned status, int expected)
+static void server(int fd, unsigned status, int expected)
{
-int ret;
-char buffer[MAX_BUF + 1];
-gnutls_session_t session;
-gnutls_certificate_credentials_t x509_cred;
-
- /* this must be called once in the program
- */
- global_init ();
- memset(buffer, 0, sizeof(buffer));
-
- gnutls_init (&session, GNUTLS_SERVER);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NONE:+VERS-TLS1.0:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA", NULL);
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
- gnutls_certificate_server_set_request(session, status);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret == expected)
- {
- if (debug)
- success("server: Handshake finished as expected\n");
- goto finish;
- }
- else
- {
- fail("expected %d, handshake returned %d\n", expected, ret);
- }
-
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-finish:
- close(fd);
- gnutls_deinit (session);
-
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+ gnutls_certificate_credentials_t x509_cred;
+
+ /* this must be called once in the program
+ */
+ global_init();
+ memset(buffer, 0, sizeof(buffer));
+
+ gnutls_init(&session, GNUTLS_SERVER);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.0:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA",
+ NULL);
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_certificate_server_set_request(session, status);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret == expected) {
+ if (debug)
+ success
+ ("server: Handshake finished as expected\n");
+ goto finish;
+ } else {
+ fail("expected %d, handshake returned %d\n", expected,
+ ret);
+ }
+
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+ finish:
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (unsigned status, int expected)
+static void start(unsigned status, int expected)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], status, expected);
- waitpid(-1, NULL, 0);
- //kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1]);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], status, expected);
+ waitpid(-1, NULL, 0);
+ //kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1]);
+ exit(0);
+ }
}
static void ch_handler(int sig)
{
-int status = 0;
-
- waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- }
- return;
+ int status = 0;
+
+ waitpid(-1, &status, 0);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fail("Child died with sigsegv\n");
+ }
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
+ signal(SIGCHLD, ch_handler);
- start(GNUTLS_CERT_IGNORE, 0);
- start(GNUTLS_CERT_REQUEST, 0);
- start(GNUTLS_CERT_REQUIRE, GNUTLS_E_NO_CERTIFICATE_FOUND);
+ start(GNUTLS_CERT_IGNORE, 0);
+ start(GNUTLS_CERT_REQUEST, 0);
+ start(GNUTLS_CERT_REQUIRE, GNUTLS_E_NO_CERTIFICATE_FOUND);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-deflate.c b/tests/mini-deflate.c
index fa4ad27e1a..1307f100b1 100644
--- a/tests/mini-deflate.c
+++ b/tests/mini-deflate.c
@@ -32,104 +32,107 @@
#ifdef HAVE_LIBZ
-# include "eagain-common.h"
-# include "utils.h"
+#include "eagain-common.h"
+#include "utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
-# define MAX_BUF 6*1024
-# define MSG "Hello TLS, and Hello and Hello and Hello"
+#define MAX_BUF 6*1024
+#define MSG "Hello TLS, and Hello and Hello and Hello"
-void
-doit (void)
+void doit(void)
{
- /* Server stuff. */
- gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { (unsigned char*) pkcs3, strlen (pkcs3) };
- static gnutls_dh_params_t dh_params;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
- /* Need to enable anonymous KX specifically. */
- char buffer[MAX_BUF + 1];
- ssize_t ns;
- int ret, transferred = 0, msglen;
- const char * str;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- /* Init server */
- gnutls_anon_allocate_server_credentials (&s_anoncred);
- gnutls_dh_params_init (&dh_params);
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
- gnutls_init (&server, GNUTLS_SERVER);
- ret = gnutls_priority_set_direct (server, "NONE:+VERS-TLS-ALL:+AES-128-CBC:+MAC-ALL:+SIGN-ALL:+COMP-DEFLATE:+ANON-DH", &str);
- if (ret < 0)
- {
- fprintf(stderr, "error at: %s\n", str);
- exit(1);
- }
-
- gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT);
- ret = gnutls_priority_set_direct (client, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-DEFLATE:+ANON-DH", &str);
- if (ret < 0)
- {
- fprintf(stderr, "error at: %s\n", str);
- exit(1);
- }
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- if (debug)
- success ("Handshake established\n");
-
- msglen = strlen(MSG);
- TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
- if (debug)
- fputs ("\n", stdout);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_anon_free_client_credentials (c_anoncred);
- gnutls_anon_free_server_credentials (s_anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
+ /* Server stuff. */
+ gnutls_anon_server_credentials_t s_anoncred;
+ const gnutls_datum_t p3 =
+ { (unsigned char *) pkcs3, strlen(pkcs3) };
+ static gnutls_dh_params_t dh_params;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+ /* Need to enable anonymous KX specifically. */
+ char buffer[MAX_BUF + 1];
+ ssize_t ns;
+ int ret, transferred = 0, msglen;
+ const char *str;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ /* Init server */
+ gnutls_anon_allocate_server_credentials(&s_anoncred);
+ gnutls_dh_params_init(&dh_params);
+ gnutls_dh_params_import_pkcs3(dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ gnutls_anon_set_server_dh_params(s_anoncred, dh_params);
+ gnutls_init(&server, GNUTLS_SERVER);
+ ret =
+ gnutls_priority_set_direct(server,
+ "NONE:+VERS-TLS-ALL:+AES-128-CBC:+MAC-ALL:+SIGN-ALL:+COMP-DEFLATE:+ANON-DH",
+ &str);
+ if (ret < 0) {
+ fprintf(stderr, "error at: %s\n", str);
+ exit(1);
+ }
+
+ gnutls_credentials_set(server, GNUTLS_CRD_ANON, s_anoncred);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ ret =
+ gnutls_priority_set_direct(client,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-DEFLATE:+ANON-DH",
+ &str);
+ if (ret < 0) {
+ fprintf(stderr, "error at: %s\n", str);
+ exit(1);
+ }
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ if (debug)
+ success("Handshake established\n");
+
+ msglen = strlen(MSG);
+ TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
+ if (debug)
+ fputs("\n", stdout);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_anon_free_client_credentials(c_anoncred);
+ gnutls_anon_free_server_credentials(s_anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
}
#else
-int main(int argc, char** argv)
+int main(int argc, char **argv)
{
- return 77;
+ return 77;
}
#endif
diff --git a/tests/mini-dtls-heartbeat.c b/tests/mini-dtls-heartbeat.c
index 5b4d995aeb..1fea6b65df 100644
--- a/tests/mini-dtls-heartbeat.c
+++ b/tests/mini-dtls-heartbeat.c
@@ -29,10 +29,9 @@
#if defined(_WIN32) || !defined(ENABLE_HEARTBEAT)
-int
-main ()
+int main()
{
- exit (77);
+ exit(77);
}
#else
@@ -49,21 +48,19 @@ main ()
#include "utils.h"
-static void terminate (void);
+static void terminate(void);
/* This program tests the rehandshake in DTLS
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* These are global */
@@ -75,306 +72,279 @@ static pid_t child;
#define MAX_BUF 1024
-static void
-client (int fd, int server_init)
+static void client(int fd, int server_init)
{
- gnutls_session_t session;
- int ret, ret2;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
- gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
- gnutls_dtls_set_mtu (session, 1500);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit (1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: DTLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- if (!server_init)
- {
- do
- {
- ret =
- gnutls_record_recv (session, buffer, sizeof (buffer));
-
- if (ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED)
- {
- if (debug)
- success ("Ping received. Replying with pong.\n");
- ret2 = gnutls_heartbeat_pong (session, 0);
- if (ret2 < 0)
- {
- fail ("pong: %s\n", gnutls_strerror (ret));
- terminate ();
- }
- }
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED
- || ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED);
-
- if (ret < 0)
- {
- fail ("recv: %s\n", gnutls_strerror (ret));
- terminate();
- }
- }
- else
- {
- do
- {
- ret =
- gnutls_heartbeat_ping (session, 256, 5,
- GNUTLS_HEARTBEAT_WAIT);
-
- if (debug)
- success ("Ping sent.\n");
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- fail ("ping: %s\n", gnutls_strerror (ret));
- terminate ();
- }
- }
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
-
- gnutls_global_deinit ();
+ gnutls_session_t session;
+ int ret, ret2;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: DTLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ if (!server_init) {
+ do {
+ ret =
+ gnutls_record_recv(session, buffer,
+ sizeof(buffer));
+
+ if (ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED) {
+ if (debug)
+ success
+ ("Ping received. Replying with pong.\n");
+ ret2 = gnutls_heartbeat_pong(session, 0);
+ if (ret2 < 0) {
+ fail("pong: %s\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ }
+ }
+ while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED
+ || ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED);
+
+ if (ret < 0) {
+ fail("recv: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
+ } else {
+ do {
+ ret =
+ gnutls_heartbeat_ping(session, 256, 5,
+ GNUTLS_HEARTBEAT_WAIT);
+
+ if (debug)
+ success("Ping sent.\n");
+ }
+ while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ fail("ping: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+
+ gnutls_global_deinit();
}
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
- gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
- gnutls_dtls_set_mtu (session, 1500);
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
+ gnutls_dtls_set_mtu(session, 1500);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
- return session;
+ return session;
}
-static void
-terminate (void)
+static void terminate(void)
{
- int status;
+ int status;
- kill (child, SIGTERM);
- wait (&status);
- exit (1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
-static void
-server (int fd, int server_init)
+static void server(int fd, int server_init)
{
- int ret, ret2;
- char buffer[MAX_BUF + 1];
- gnutls_session_t session;
- gnutls_anon_server_credentials_t anoncred;
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- session = initialize_tls_session ();
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n",
- gnutls_strerror (ret));
- terminate ();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- if (server_init)
- {
- do
- {
- ret =
- gnutls_record_recv (session, buffer, sizeof (buffer));
-
- if (ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED)
- {
- if (debug)
- success ("Ping received. Replying with pong.\n");
- ret2 = gnutls_heartbeat_pong (session, 0);
- if (ret2 < 0)
- {
- fail ("pong: %s\n", gnutls_strerror (ret));
- terminate ();
- }
- }
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED
- || ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED);
- }
- else
- {
- do
- {
- ret =
- gnutls_heartbeat_ping (session, 256, 5,
- GNUTLS_HEARTBEAT_WAIT);
-
- if (debug)
- success ("Ping sent.\n");
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- fail ("ping: %s\n", gnutls_strerror (ret));
- terminate ();
- }
- }
-
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret, ret2;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ session = initialize_tls_session();
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ if (server_init) {
+ do {
+ ret =
+ gnutls_record_recv(session, buffer,
+ sizeof(buffer));
+
+ if (ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED) {
+ if (debug)
+ success
+ ("Ping received. Replying with pong.\n");
+ ret2 = gnutls_heartbeat_pong(session, 0);
+ if (ret2 < 0) {
+ fail("pong: %s\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ }
+ }
+ while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED
+ || ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED);
+ } else {
+ do {
+ ret =
+ gnutls_heartbeat_ping(session, 256, 5,
+ GNUTLS_HEARTBEAT_WAIT);
+
+ if (debug)
+ success("Ping sent.\n");
+ }
+ while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ fail("ping: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
+ }
+
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void
-start (int server_initiated)
+static void start(int server_initiated)
{
- int fd[2];
- int ret;
-
- ret = socketpair (AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror ("socketpair");
- exit (1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit (1);
- }
-
- if (child)
- {
- int status;
- /* parent */
-
- server (fd[0], server_initiated);
- wait (&status);
- if (WEXITSTATUS (status) != 0)
- fail ("Child died with status %d\n", WEXITSTATUS (status));
- }
- else
- {
- close (fd[0]);
- client (fd[1], server_initiated);
- exit (0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+
+ server(fd[0], server_initiated);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ close(fd[0]);
+ client(fd[1], server_initiated);
+ exit(0);
+ }
}
-void
-doit (void)
+void doit(void)
{
- start (0);
- start (1);
+ start(0);
+ start(1);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-dtls-hello-verify.c b/tests/mini-dtls-hello-verify.c
index 534d8a6178..c5e3d96993 100644
--- a/tests/mini-dtls-hello-verify.c
+++ b/tests/mini-dtls-hello-verify.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -53,16 +53,14 @@ static void terminate(void);
/* This program tests the client hello verify in DTLS
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* A very basic TLS client, with anonymous authentication.
@@ -71,100 +69,94 @@ client_log_func (int level, const char *str)
#define MAX_BUF 1024
static ssize_t
-push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
-int fd = (long int)tr;
+ int fd = (long int) tr;
- return send(fd, data, len, 0);
+ return send(fd, data, len, 0);
}
-static void
-client (int fd)
+static void client(int fd)
{
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT|GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu( session, 1500);
- gnutls_handshake_set_timeout(session, 20*1000);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- do {
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- exit(1);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
-end:
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
-
- gnutls_global_deinit ();
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
+ gnutls_handshake_set_timeout(session, 20 * 1000);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ do {
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ end:
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+
+ gnutls_global_deinit();
}
@@ -173,188 +165,186 @@ pid_t child;
static void terminate(void)
{
-int status;
+ int status;
- kill(child, SIGTERM);
- wait(&status);
- exit(1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
#define CLI_ADDR (void*)"test"
#define CLI_ADDR_LEN 4
-static void
-server (int fd)
+static void server(int fd)
{
-int ret, csend = 0;
-gnutls_anon_server_credentials_t anoncred;
-char buffer[MAX_BUF + 1];
-gnutls_datum_t cookie_key;
-gnutls_dtls_prestate_st prestate;
-gnutls_session_t session;
-
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- ret = gnutls_key_generate(&cookie_key, GNUTLS_COOKIE_KEY_SIZE);
- if (ret < 0)
- {
- fail("Cannot generate key: %s\n", gnutls_strerror(ret));
- terminate();
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER|GNUTLS_DATAGRAM);
- gnutls_handshake_set_timeout(session, 20*1000);
- gnutls_dtls_set_mtu( session, 1500);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL);
-
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push);
-
- for (;;)
- {
- ret = recv(fd, buffer, sizeof(buffer), MSG_PEEK);
- if (ret < 0)
- {
- fail("Cannot receive data\n");
- terminate();
- }
-
- memset(&prestate, 0, sizeof(prestate));
- ret = gnutls_dtls_cookie_verify(&cookie_key, CLI_ADDR, CLI_ADDR_LEN, buffer, ret, &prestate);
- if (ret < 0) /* cookie not valid */
- {
- if (debug) success("Sending hello verify request\n");
-
- ret = gnutls_dtls_cookie_send(&cookie_key, CLI_ADDR, CLI_ADDR_LEN, &prestate, (gnutls_transport_ptr_t)(long)fd, push);
- if (ret < 0)
- {
- fail("Cannot send data\n");
- terminate();
- }
-
- /* discard peeked data*/
- recv(fd, buffer, sizeof(buffer), 0);
- csend++;
-
- if (csend > 2)
- {
- fail("too many cookies sent\n");
- terminate();
- }
-
- continue;
- }
-
- /* success */
- break;
- }
-
- gnutls_dtls_prestate_set(session, &prestate);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- do {
- ret = gnutls_record_send (session, buffer, sizeof (buffer));
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: data sending has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
-
-
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
- gnutls_free(cookie_key.data);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret, csend = 0;
+ gnutls_anon_server_credentials_t anoncred;
+ char buffer[MAX_BUF + 1];
+ gnutls_datum_t cookie_key;
+ gnutls_dtls_prestate_st prestate;
+ gnutls_session_t session;
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ ret = gnutls_key_generate(&cookie_key, GNUTLS_COOKIE_KEY_SIZE);
+ if (ret < 0) {
+ fail("Cannot generate key: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_handshake_set_timeout(session, 20 * 1000);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push);
+
+ for (;;) {
+ ret = recv(fd, buffer, sizeof(buffer), MSG_PEEK);
+ if (ret < 0) {
+ fail("Cannot receive data\n");
+ terminate();
+ }
+
+ memset(&prestate, 0, sizeof(prestate));
+ ret =
+ gnutls_dtls_cookie_verify(&cookie_key, CLI_ADDR,
+ CLI_ADDR_LEN, buffer, ret,
+ &prestate);
+ if (ret < 0) { /* cookie not valid */
+ if (debug)
+ success("Sending hello verify request\n");
+
+ ret =
+ gnutls_dtls_cookie_send(&cookie_key, CLI_ADDR,
+ CLI_ADDR_LEN,
+ &prestate,
+ (gnutls_transport_ptr_t)
+ (long) fd, push);
+ if (ret < 0) {
+ fail("Cannot send data\n");
+ terminate();
+ }
+
+ /* discard peeked data */
+ recv(fd, buffer, sizeof(buffer), 0);
+ csend++;
+
+ if (csend > 2) {
+ fail("too many cookies sent\n");
+ terminate();
+ }
+
+ continue;
+ }
+
+ /* success */
+ break;
+ }
+
+ gnutls_dtls_prestate_set(session, &prestate);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ do {
+ ret = gnutls_record_send(session, buffer, sizeof(buffer));
+ } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: data sending has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+
+
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+ gnutls_free(cookie_key.data);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void doit (void)
+void doit(void)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- int status;
- /* parent */
-
- server (fd[0]);
- wait (&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
- }
- else
- {
- close(fd[0]);
- client (fd[1]);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+
+ server(fd[0]);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ close(fd[0]);
+ client(fd[1]);
+ exit(0);
+ }
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-dtls-large.c b/tests/mini-dtls-large.c
index 2aeea92421..c724dad34f 100644
--- a/tests/mini-dtls-large.c
+++ b/tests/mini-dtls-large.c
@@ -27,10 +27,9 @@
#if defined(_WIN32) || !defined(ENABLE_HEARTBEAT)
-int
-main ()
+int main()
{
- exit (77);
+ exit(77);
}
#else
@@ -47,21 +46,19 @@ main ()
#include "utils.h"
-static void terminate (void);
+static void terminate(void);
/* This program tests the rehandshake in DTLS
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* These are global */
@@ -74,258 +71,245 @@ static pid_t child;
#define MAX_MTU 20*1024
-static void
-client (int fd)
+static void client(int fd)
{
- gnutls_session_t session;
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
- gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
- gnutls_dtls_set_mtu (session, 1500);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit (1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: DTLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- do
- {
- ret =
- gnutls_record_recv (session, buffer, sizeof (buffer));
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED || ret > 0);
-
- if (ret < 0)
- {
- fail ("recv: %s\n", gnutls_strerror (ret));
- terminate();
- }
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
-
- gnutls_global_deinit ();
+ gnutls_session_t session;
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: DTLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ do {
+ ret = gnutls_record_recv(session, buffer, sizeof(buffer));
+ }
+ while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED
+ || ret > 0);
+
+ if (ret < 0) {
+ fail("recv: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+
+ gnutls_global_deinit();
}
-static void
-terminate (void)
+static void terminate(void)
{
- int status;
+ int status;
- kill (child, SIGTERM);
- wait (&status);
- exit (1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
-static void
-server (int fd)
+static void server(int fd)
{
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_session_t session;
- gnutls_anon_server_credentials_t anoncred;
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu (session, 1500);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
-
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n",
- gnutls_strerror (ret));
- terminate ();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- ret = gnutls_record_send(session, buffer, gnutls_dtls_get_data_mtu(session)+12);
- if (ret != GNUTLS_E_LARGE_PACKET)
- {
- fail ("send[%d]: %s\n", __LINE__, gnutls_strerror (ret));
- terminate ();
- }
-
- ret = gnutls_record_send(session, buffer, gnutls_dtls_get_data_mtu(session)+5048);
- if (ret != GNUTLS_E_LARGE_PACKET)
- {
- fail ("send[%d]: %s\n", __LINE__, gnutls_strerror (ret));
- terminate ();
- }
-
- ret = gnutls_record_send(session, buffer, gnutls_dtls_get_data_mtu(session));
- if (ret < 0)
- {
- fail ("send[%d]: %s\n", __LINE__, gnutls_strerror (ret));
- terminate ();
- }
-
- gnutls_dtls_set_mtu (session, MAX_MTU);
- ret = gnutls_record_send(session, buffer, gnutls_dtls_get_data_mtu(session)+12);
- if (ret != GNUTLS_E_LARGE_PACKET)
- {
- fail ("send[%d]: %s\n", __LINE__, gnutls_strerror (ret));
- terminate ();
- }
-
- ret = gnutls_record_send(session, buffer, gnutls_dtls_get_data_mtu(session)+5048);
- if (ret != GNUTLS_E_LARGE_PACKET)
- {
- fail ("send[%d]: %s\n", __LINE__, gnutls_strerror (ret));
- terminate ();
- }
-
- ret = gnutls_record_send(session, buffer, gnutls_dtls_get_data_mtu(session));
- if (ret > 16384 || ret < 0)
- {
- fail ("send[%d]: %s\n", __LINE__, gnutls_strerror (ret));
- terminate ();
- }
-
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session) + 12);
+ if (ret != GNUTLS_E_LARGE_PACKET) {
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ terminate();
+ }
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session) + 5048);
+ if (ret != GNUTLS_E_LARGE_PACKET) {
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ terminate();
+ }
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session));
+ if (ret < 0) {
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ terminate();
+ }
+
+ gnutls_dtls_set_mtu(session, MAX_MTU);
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session) + 12);
+ if (ret != GNUTLS_E_LARGE_PACKET) {
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ terminate();
+ }
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session) + 5048);
+ if (ret != GNUTLS_E_LARGE_PACKET) {
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ terminate();
+ }
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session));
+ if (ret > 16384 || ret < 0) {
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ terminate();
+ }
+
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void
-start (void)
+static void start(void)
{
- int fd[2];
- int ret;
-
- ret = socketpair (AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror ("socketpair");
- exit (1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit (1);
- }
-
- if (child)
- {
- int status;
- /* parent */
-
- server (fd[0]);
- wait (&status);
- if (WEXITSTATUS (status) != 0)
- fail ("Child died with status %d\n", WEXITSTATUS (status));
- }
- else
- {
- close (fd[0]);
- client (fd[1]);
- exit (0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+
+ server(fd[0]);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ close(fd[0]);
+ client(fd[1]);
+ exit(0);
+ }
}
-void
-doit (void)
+void doit(void)
{
- start ();
+ start();
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-dtls-record.c b/tests/mini-dtls-record.c
index 5128d2ed9d..37d1ebfb46 100644
--- a/tests/mini-dtls-record.c
+++ b/tests/mini-dtls-record.c
@@ -24,17 +24,16 @@
#include <config.h>
#endif
-#define REL_LAYER
+#define REL_LAYER
#include <stdio.h>
#include <stdlib.h>
#if defined(_WIN32)
-int
-main ()
+int main()
{
- exit (77);
+ exit(77);
}
#else
@@ -53,7 +52,7 @@ main ()
#include "utils.h"
static int test_finished = 0;
-static void terminate (void);
+static void terminate(void);
/* This program tests the rehandshake in DTLS
*/
@@ -66,16 +65,14 @@ tls_audit_log_func (gnutls_session_t session, const char *str)
}
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* These are global */
@@ -88,363 +85,351 @@ static pid_t child;
#define MAX_SEQ 128
-static int msg_seq[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 16, 5, 32, 11, 11, 11, 11, 12, 10, 13, 14,
- 15, 16, 17, 19, 20, 18, 22, 24, 23, 25, 26, 27, 29, 28, 29, 29, 30, 31, 32, 33, 34, 35, 37, 36, 38, 39,
- 42, 37, 40, 41, 41, -1};
+static int msg_seq[] =
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 16, 5, 32, 11, 11, 11, 11, 12,
+10, 13, 14,
+ 15, 16, 17, 19, 20, 18, 22, 24, 23, 25, 26, 27, 29, 28, 29, 29, 30,
+ 31, 32, 33, 34, 35, 37, 36, 38, 39,
+ 42, 37, 40, 41, 41, -1
+};
+
static unsigned int current = 0;
static unsigned int pos = 0;
-unsigned char* stored_messages[MAX_SEQ];
+unsigned char *stored_messages[MAX_SEQ];
unsigned int stored_sizes[MAX_SEQ];
static ssize_t
-odd_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+odd_push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
-ssize_t ret;
-unsigned i;
-
- if (msg_seq[current] == -1 || test_finished != 0)
- {
- test_finished = 1;
- return len;
- }
-
- stored_messages[current] = malloc(len);
- memcpy(stored_messages[current], data, len);
- stored_sizes[current] = len;
-
- if (pos != current)
- {
- for (i=pos;i<=current;i++)
- {
- if (stored_messages[msg_seq[i]] != NULL)
- {
- do
- {
- ret = send((long int)tr, stored_messages[msg_seq[i]], stored_sizes[msg_seq[i]], 0);
- }
- while(ret == -1 && errno == EAGAIN);
- pos++;
- }
- else
- break;
- }
- }
- else if (msg_seq[current] == (int)current)
- {
- do
- {
- ret = send((long int)tr, data, len, 0);
- }
- while(ret == -1 && errno == EAGAIN);
-
- current++;
- pos++;
-
- return ret;
- }
- else if (stored_messages[msg_seq[current]] != NULL)
- {
- do
- {
- ret = send((long int)tr, stored_messages[msg_seq[current]], stored_sizes[msg_seq[current]], 0);
- }
- while(ret == -1 && errno == EAGAIN);
- current++;
- pos++;
- return ret;
- }
-
- current++;
-
- return len;
+ ssize_t ret;
+ unsigned i;
+
+ if (msg_seq[current] == -1 || test_finished != 0) {
+ test_finished = 1;
+ return len;
+ }
+
+ stored_messages[current] = malloc(len);
+ memcpy(stored_messages[current], data, len);
+ stored_sizes[current] = len;
+
+ if (pos != current) {
+ for (i = pos; i <= current; i++) {
+ if (stored_messages[msg_seq[i]] != NULL) {
+ do {
+ ret =
+ send((long int) tr,
+ stored_messages[msg_seq
+ [i]],
+ stored_sizes[msg_seq[i]],
+ 0);
+ }
+ while (ret == -1 && errno == EAGAIN);
+ pos++;
+ } else
+ break;
+ }
+ } else if (msg_seq[current] == (int) current) {
+ do {
+ ret = send((long int) tr, data, len, 0);
+ }
+ while (ret == -1 && errno == EAGAIN);
+
+ current++;
+ pos++;
+
+ return ret;
+ } else if (stored_messages[msg_seq[current]] != NULL) {
+ do {
+ ret =
+ send((long int) tr,
+ stored_messages[msg_seq[current]],
+ stored_sizes[msg_seq[current]], 0);
+ }
+ while (ret == -1 && errno == EAGAIN);
+ current++;
+ pos++;
+ return ret;
+ }
+
+ current++;
+
+ return len;
}
static ssize_t
-n_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+n_push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
- return send((unsigned long)tr, data, len, 0);
+ return send((unsigned long) tr, data, len, 0);
}
/* The first five messages are handshake. Thus corresponds to msg_seq+5 */
-static int recv_msg_seq[] = { 1, 2, 3, 4, 5, 6, 12, 28, 7, 8, 9, 10, 11, 13, 15, 16, 14, 18, 20, 19, 21, 22,
- 23, 25, 24, 26, 27, 29, 30, 31, 33, 32, 34, 35, 38, 36, 37, -1};
+static int recv_msg_seq[] =
+ { 1, 2, 3, 4, 5, 6, 12, 28, 7, 8, 9, 10, 11, 13, 15, 16, 14, 18, 20,
+19, 21, 22,
+ 23, 25, 24, 26, 27, 29, 30, 31, 33, 32, 34, 35, 38, 36, 37, -1
+};
-static void
-client (int fd)
+static void client(int fd)
{
- gnutls_session_t session;
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- unsigned char seq[8];
- uint64_t useq;
- unsigned current = 0;
+ gnutls_session_t session;
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ unsigned char seq[8];
+ uint64_t useq;
+ unsigned current = 0;
#ifndef REL_LAYER
- struct timespec ts;
+ struct timespec ts;
- ts.tv_sec = 0;
- ts.tv_nsec = 100*1000*1000;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100 * 1000 * 1000;
#endif
-
- memset(buffer, 0, sizeof(buffer));
-
- /* Need to enable anonymous KX specifically. */
+
+ memset(buffer, 0, sizeof(buffer));
+
+ /* Need to enable anonymous KX specifically. */
/* gnutls_global_set_audit_log_function (tls_audit_log_func); */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (99);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
- gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
- gnutls_dtls_set_mtu (session, 1500);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit (1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- gnutls_record_send( session, buffer, 1);
-
- if (debug)
- success ("client: DTLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
- do
- {
- ret = gnutls_record_recv_seq (session, buffer, sizeof (buffer), seq);
-
- if (ret > 0)
- {
- useq = seq[3] | (seq[2] << 8) | (seq[1] << 16) | (seq[0] << 24);
- useq <<= 32;
- useq |= seq[7] | (seq[6] << 8) | (seq[5] << 16) | (seq[4] << 24);
-
- if (recv_msg_seq[current] == -1)
- {
- fail("received message sequence differs\n");
- terminate();
- }
-
- if ((uint32_t)recv_msg_seq[current] != (uint32_t)useq)
- {
- fail("received message sequence differs\n");
- terminate();
- }
-
- current++;
- }
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(99);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ gnutls_record_send(session, buffer, 1);
+
+ if (debug)
+ success("client: DTLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+ do {
+ ret =
+ gnutls_record_recv_seq(session, buffer, sizeof(buffer),
+ seq);
+
+ if (ret > 0) {
+ useq =
+ seq[3] | (seq[2] << 8) | (seq[1] << 16) |
+ (seq[0] << 24);
+ useq <<= 32;
+ useq |=
+ seq[7] | (seq[6] << 8) | (seq[5] << 16) |
+ (seq[4] << 24);
+
+ if (recv_msg_seq[current] == -1) {
+ fail("received message sequence differs\n");
+ terminate();
+ }
+
+ if ((uint32_t) recv_msg_seq[current] !=
+ (uint32_t) useq) {
+ fail("received message sequence differs\n");
+ terminate();
+ }
+
+ current++;
+ }
#ifndef REL_LAYER
- nanosleep(&ts, NULL);
+ nanosleep(&ts, NULL);
#endif
- }
- while ((ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED || ret > 0));
+ }
+ while ((ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED
+ || ret > 0));
- gnutls_bye (session, GNUTLS_SHUT_WR);
+ gnutls_bye(session, GNUTLS_SHUT_WR);
- close (fd);
+ close(fd);
- gnutls_deinit (session);
+ gnutls_deinit(session);
- gnutls_anon_free_client_credentials (anoncred);
+ gnutls_anon_free_client_credentials(anoncred);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
-static void
-terminate (void)
+static void terminate(void)
{
- int status;
+ int status;
- kill (child, SIGTERM);
- wait (&status);
- exit (1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
-static void
-server (int fd)
+static void server(int fd)
{
- int ret;
- gnutls_session_t session;
- gnutls_anon_server_credentials_t anoncred;
- char c;
+ int ret;
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ char c;
#ifndef REL_LAYER
- struct timespec ts;
-
- ts.tv_sec = 0;
- ts.tv_nsec = 100*1000*1000;
+ struct timespec ts;
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100 * 1000 * 1000;
#endif
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
- gnutls_transport_set_push_function (session, odd_push);
- gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
- gnutls_dtls_set_mtu (session, 1500);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n",
- gnutls_strerror (ret));
- terminate ();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- gnutls_record_recv(session, &c, 1);
- do
- {
- do
- {
- ret = gnutls_record_send( session, &c, 1);
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- fail ("send: %s\n", gnutls_strerror (ret));
- terminate ();
- }
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_transport_set_push_function(session, odd_push);
+ gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ gnutls_record_recv(session, &c, 1);
+ do {
+ do {
+ ret = gnutls_record_send(session, &c, 1);
+ }
+ while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ fail("send: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
#ifndef REL_LAYER
- nanosleep(&ts, NULL);
+ nanosleep(&ts, NULL);
#endif
- }
- while (test_finished == 0);
+ }
+ while (test_finished == 0);
- gnutls_transport_set_push_function (session, n_push);
+ gnutls_transport_set_push_function(session, n_push);
#ifndef REL_LAYER
- nanosleep(&ts, NULL);
+ nanosleep(&ts, NULL);
#endif
- do
- {
- ret = gnutls_bye (session, GNUTLS_SHUT_WR);
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+ do {
+ ret = gnutls_bye(session, GNUTLS_SHUT_WR);
+ }
+ while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- close (fd);
- gnutls_deinit (session);
+ close(fd);
+ gnutls_deinit(session);
- gnutls_anon_free_server_credentials (anoncred);
+ gnutls_anon_free_server_credentials(anoncred);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- if (debug)
- success ("server: finished\n");
+ if (debug)
+ success("server: finished\n");
}
-static void
-start (void)
+static void start(void)
{
- int fd[2];
- int ret;
+ int fd[2];
+ int ret;
#ifdef REL_LAYER
- ret = socketpair (AF_UNIX, SOCK_STREAM, 0, fd);
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
#else
- ret = socketpair (AF_UNIX, SOCK_DGRAM, 0, fd);
+ ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, fd);
#endif
- if (ret < 0)
- {
- perror ("socketpair");
- exit (1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit (1);
- }
-
- if (child)
- {
- int status;
- /* parent */
-
- server (fd[0]);
- wait (&status);
- if (WEXITSTATUS (status) != 0)
- fail ("Child died with status %d\n", WEXITSTATUS (status));
- }
- else
- {
- close (fd[0]);
- client (fd[1]);
- exit (0);
- }
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+
+ server(fd[0]);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ close(fd[0]);
+ client(fd[1]);
+ exit(0);
+ }
}
-void
-doit (void)
+void doit(void)
{
- start ();
+ start();
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-dtls-rehandshake.c b/tests/mini-dtls-rehandshake.c
index 187d9297b4..84828b5bdb 100644
--- a/tests/mini-dtls-rehandshake.c
+++ b/tests/mini-dtls-rehandshake.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -53,16 +53,14 @@ static void terminate(void);
/* This program tests the rehandshake in DTLS
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* A very basic TLS client, with anonymous authentication.
@@ -74,132 +72,123 @@ client_log_func (int level, const char *str)
gnutls_session_t session;
static ssize_t
-push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
-int fd = (long int)tr;
+ int fd = (long int) tr;
- return send(fd, data, len, 0);
+ return send(fd, data, len, 0);
}
-static void
-client (int fd, int server_init)
+static void client(int fd, int server_init)
{
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT|GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu( session, 1500);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- if (!server_init)
- {
- if (debug) success("Initiating client rehandshake\n");
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("2nd client gnutls_handshake: %s\n", gnutls_strerror(ret));
- terminate();
- }
- }
- else
- {
- do {
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- }
-
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- if (server_init && ret == GNUTLS_E_REHANDSHAKE)
- {
- if (debug) success("Initiating rehandshake due to server request\n");
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- }
-
- if (ret != 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- exit(1);
- }
- }
-
- do {
- ret = gnutls_record_send (session, MSG, strlen (MSG));
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
-end:
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
-
- gnutls_global_deinit ();
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ if (!server_init) {
+ if (debug)
+ success("Initiating client rehandshake\n");
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("2nd client gnutls_handshake: %s\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ } else {
+ do {
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+ }
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ if (server_init && ret == GNUTLS_E_REHANDSHAKE) {
+ if (debug)
+ success
+ ("Initiating rehandshake due to server request\n");
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ }
+
+ if (ret != 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+ }
+
+ do {
+ ret = gnutls_record_send(session, MSG, strlen(MSG));
+ } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ end:
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+
+ gnutls_global_deinit();
}
@@ -207,201 +196,195 @@ end:
gnutls_anon_server_credentials_t anoncred;
pid_t child;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER|GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu( session, 1500);
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
- return session;
+ return session;
}
static void terminate(void)
{
-int status;
+ int status;
- kill(child, SIGTERM);
- wait(&status);
- exit(1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
-static void
-server (int fd, int server_init)
+static void server(int fd, int server_init)
{
-int ret;
-char buffer[MAX_BUF + 1];
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- session = initialize_tls_session ();
-
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- if (server_init)
- {
- if (debug) success("server: Sending dummy packet\n");
- ret = gnutls_rehandshake(session);
- if (ret < 0)
- {
- fail ("gnutls_rehandshake: %s\n", gnutls_strerror(ret));
- terminate();
- }
-
- if (debug) success("server: Initiating rehandshake\n");
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("server: 2nd gnutls_handshake: %s\n", gnutls_strerror(ret));
- terminate();
- }
- }
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
-
- do {
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- if (!server_init && ret == GNUTLS_E_REHANDSHAKE)
- {
- if (debug) success("Initiating rehandshake due to client request\n");
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret == 0) break;
- }
-
- fail ("server: Received corrupted data(%s). Closing...\n", gnutls_strerror(ret));
- terminate();
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- do {
- ret = gnutls_record_send (session, buffer, strlen (buffer));
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- }
- }
-
-
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ char buffer[MAX_BUF + 1];
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ session = initialize_tls_session();
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ if (server_init) {
+ if (debug)
+ success("server: Sending dummy packet\n");
+ ret = gnutls_rehandshake(session);
+ if (ret < 0) {
+ fail("gnutls_rehandshake: %s\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+
+ if (debug)
+ success("server: Initiating rehandshake\n");
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("server: 2nd gnutls_handshake: %s\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ }
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+
+ do {
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ if (!server_init && ret == GNUTLS_E_REHANDSHAKE) {
+ if (debug)
+ success
+ ("Initiating rehandshake due to client request\n");
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0
+ && gnutls_error_is_fatal(ret) == 0);
+ if (ret == 0)
+ break;
+ }
+
+ fail("server: Received corrupted data(%s). Closing...\n", gnutls_strerror(ret));
+ terminate();
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ do {
+ ret =
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+ }
+ }
+
+
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (int server_initiated)
+static void start(int server_initiated)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- int status;
- /* parent */
-
- server (fd[0], server_initiated);
- wait (&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
- }
- else
- {
- close(fd[0]);
- client (fd[1], server_initiated);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+
+ server(fd[0], server_initiated);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ close(fd[0]);
+ client(fd[1], server_initiated);
+ exit(0);
+ }
}
-void
-doit (void)
+void doit(void)
{
- start(0);
- start(1);
+ start(0);
+ start(1);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-dtls-srtp.c b/tests/mini-dtls-srtp.c
index 6d3d8000bd..07e624e2af 100644
--- a/tests/mini-dtls-srtp.c
+++ b/tests/mini-dtls-srtp.c
@@ -29,10 +29,9 @@
#if defined(_WIN32) || !defined(ENABLE_DTLS_SRTP)
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -49,21 +48,19 @@ main (int argc, char** argv)
#include "utils.h"
-static void terminate (void);
+static void terminate(void);
/* This program tests the rehandshake in DTLS
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* These are global */
@@ -73,284 +70,273 @@ static pid_t child;
/* A very basic DTLS client, with anonymous authentication, that negotiates SRTP
*/
-static void
-client (int fd, int profile)
+static void client(int fd, int profile)
{
- gnutls_session_t session;
- int ret;
- gnutls_anon_client_credentials_t anoncred;
- uint8_t km[MAX_KEY_MATERIAL];
- char buf[2*MAX_KEY_MATERIAL];
- gnutls_datum_t cli_key, cli_salt, server_key, server_salt;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
- gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
- gnutls_dtls_set_mtu (session, 1500);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
- if (profile)
- ret = gnutls_srtp_set_profile_direct(session, "SRTP_AES128_CM_HMAC_SHA1_80",
- NULL);
- else
- ret = gnutls_srtp_set_profile_direct(session, "SRTP_NULL_HMAC_SHA1_80",
- NULL);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
-
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit (1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: DTLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- ret = gnutls_srtp_get_keys (session, km, sizeof(km), &cli_key, &cli_salt, &server_key, &server_salt);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
-
- if (debug)
- {
- size_t size = sizeof(buf);
- gnutls_hex_encode(&cli_key, buf, &size);
- success ("Client key: %s\n", buf);
-
- size = sizeof(buf);
- gnutls_hex_encode(&cli_salt, buf, &size);
- success ("Client salt: %s\n", buf);
-
- size = sizeof(buf);
- gnutls_hex_encode(&server_key, buf, &size);
- success ("Server key: %s\n", buf);
-
- size = sizeof(buf);
- gnutls_hex_encode(&server_salt, buf, &size);
- success ("Server salt: %s\n", buf);
- }
-
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
-
- gnutls_global_deinit ();
+ gnutls_session_t session;
+ int ret;
+ gnutls_anon_client_credentials_t anoncred;
+ uint8_t km[MAX_KEY_MATERIAL];
+ char buf[2 * MAX_KEY_MATERIAL];
+ gnutls_datum_t cli_key, cli_salt, server_key, server_salt;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+ if (profile)
+ ret =
+ gnutls_srtp_set_profile_direct(session,
+ "SRTP_AES128_CM_HMAC_SHA1_80",
+ NULL);
+ else
+ ret =
+ gnutls_srtp_set_profile_direct(session,
+ "SRTP_NULL_HMAC_SHA1_80",
+ NULL);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
+
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: DTLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ ret =
+ gnutls_srtp_get_keys(session, km, sizeof(km), &cli_key,
+ &cli_salt, &server_key, &server_salt);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
+
+ if (debug) {
+ size_t size = sizeof(buf);
+ gnutls_hex_encode(&cli_key, buf, &size);
+ success("Client key: %s\n", buf);
+
+ size = sizeof(buf);
+ gnutls_hex_encode(&cli_salt, buf, &size);
+ success("Client salt: %s\n", buf);
+
+ size = sizeof(buf);
+ gnutls_hex_encode(&server_key, buf, &size);
+ success("Server key: %s\n", buf);
+
+ size = sizeof(buf);
+ gnutls_hex_encode(&server_salt, buf, &size);
+ success("Server salt: %s\n", buf);
+ }
+
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+
+ gnutls_global_deinit();
}
-static void
-terminate (void)
+static void terminate(void)
{
- int status;
+ int status;
- kill (child, SIGTERM);
- wait (&status);
- exit (1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
-static void
-server (int fd, int profile)
+static void server(int fd, int profile)
{
- int ret;
- gnutls_session_t session;
- gnutls_anon_server_credentials_t anoncred;
- uint8_t km[MAX_KEY_MATERIAL];
- char buf[2*MAX_KEY_MATERIAL];
- gnutls_datum_t cli_key, cli_salt, server_key, server_salt;
-
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
- gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
- gnutls_dtls_set_mtu (session, 1500);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
- NULL);
-
- if (profile)
- ret = gnutls_srtp_set_profile_direct(session, "SRTP_AES128_CM_HMAC_SHA1_80",
- NULL);
- else
- ret = gnutls_srtp_set_profile_direct(session, "SRTP_NULL_HMAC_SHA1_80",
- NULL);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
-
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n",
- gnutls_strerror (ret));
- terminate ();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- ret = gnutls_srtp_get_keys (session, km, sizeof(km), &cli_key, &cli_salt, &server_key, &server_salt);
- if (ret < 0)
- {
- gnutls_perror(ret);
- exit(1);
- }
-
- if (debug)
- {
- size_t size = sizeof(buf);
- gnutls_hex_encode(&cli_key, buf, &size);
- success ("Client key: %s\n", buf);
-
- size = sizeof(buf);
- gnutls_hex_encode(&cli_salt, buf, &size);
- success ("Client salt: %s\n", buf);
-
- size = sizeof(buf);
- gnutls_hex_encode(&server_key, buf, &size);
- success ("Server key: %s\n", buf);
-
- size = sizeof(buf);
- gnutls_hex_encode(&server_salt, buf, &size);
- success ("Server salt: %s\n", buf);
- }
-
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ uint8_t km[MAX_KEY_MATERIAL];
+ char buf[2 * MAX_KEY_MATERIAL];
+ gnutls_datum_t cli_key, cli_salt, server_key, server_salt;
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ if (profile)
+ ret =
+ gnutls_srtp_set_profile_direct(session,
+ "SRTP_AES128_CM_HMAC_SHA1_80",
+ NULL);
+ else
+ ret =
+ gnutls_srtp_set_profile_direct(session,
+ "SRTP_NULL_HMAC_SHA1_80",
+ NULL);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
+
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ ret =
+ gnutls_srtp_get_keys(session, km, sizeof(km), &cli_key,
+ &cli_salt, &server_key, &server_salt);
+ if (ret < 0) {
+ gnutls_perror(ret);
+ exit(1);
+ }
+
+ if (debug) {
+ size_t size = sizeof(buf);
+ gnutls_hex_encode(&cli_key, buf, &size);
+ success("Client key: %s\n", buf);
+
+ size = sizeof(buf);
+ gnutls_hex_encode(&cli_salt, buf, &size);
+ success("Client salt: %s\n", buf);
+
+ size = sizeof(buf);
+ gnutls_hex_encode(&server_key, buf, &size);
+ success("Server key: %s\n", buf);
+
+ size = sizeof(buf);
+ gnutls_hex_encode(&server_salt, buf, &size);
+ success("Server salt: %s\n", buf);
+ }
+
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void
-start (int profile)
+static void start(int profile)
{
- int fd[2];
- int ret;
-
- ret = socketpair (AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror ("socketpair");
- exit (1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit (1);
- }
-
- if (child)
- {
- int status;
- /* parent */
-
- server (fd[0], profile);
- wait (&status);
- if (WEXITSTATUS (status) != 0)
- fail ("Child died with status %d\n", WEXITSTATUS (status));
- }
- else
- {
- close (fd[0]);
- client (fd[1], profile);
- exit (0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+
+ server(fd[0], profile);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ close(fd[0]);
+ client(fd[1], profile);
+ exit(0);
+ }
}
-void
-doit (void)
+void doit(void)
{
- start (0);
- start (1);
+ start(0);
+ start(1);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-eagain-dtls.c b/tests/mini-eagain-dtls.c
index 84e174b7ed..8b1a501916 100644
--- a/tests/mini-eagain-dtls.c
+++ b/tests/mini-eagain-dtls.c
@@ -34,12 +34,11 @@
#define RANDOMIZE
#include "eagain-common.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static int handshake = 0;
@@ -47,86 +46,94 @@ static int handshake = 0;
#define MAX_BUF 1024
#define MSG "Hello TLS, and hi and how are you and more data here... and more... and even more and even more more data..."
-void
-doit (void)
+void doit(void)
{
- /* Server stuff. */
- gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- static gnutls_dh_params_t dh_params;
- gnutls_session_t server;
- int sret, cret;
- /* Client stuff. */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
- /* Need to enable anonymous KX specifically. */
- char buffer[MAX_BUF + 1];
- ssize_t ns;
- int ret, transferred = 0, msglen;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (99);
-
- /* Init server */
- gnutls_anon_allocate_server_credentials (&s_anoncred);
- gnutls_dh_params_init (&dh_params);
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
- gnutls_init (&server, GNUTLS_SERVER|GNUTLS_DATAGRAM|GNUTLS_NONBLOCK);
- ret = gnutls_priority_set_direct (server, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (ret < 0)
- exit(1);
- gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_pull_timeout_function (server, server_pull_timeout_func);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT|GNUTLS_DATAGRAM|GNUTLS_NONBLOCK);
- cret = gnutls_priority_set_direct (client, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (cret < 0)
- exit(1);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_pull_timeout_function (client, client_pull_timeout_func);
- gnutls_transport_set_ptr (client, client);
-
- handshake = 1;
- HANDSHAKE(client, server);
-
- handshake = 0;
- if (debug)
- success ("Handshake established\n");
-
- do
- {
- ret = gnutls_record_send (client, MSG, strlen (MSG));
- }
- while(ret == GNUTLS_E_AGAIN);
- //success ("client: sent %d\n", ns);
-
- msglen = strlen(MSG);
- TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
-
- if (debug)
- fputs ("\n", stdout);
-
- gnutls_bye (client, GNUTLS_SHUT_WR);
- gnutls_bye (server, GNUTLS_SHUT_WR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_anon_free_client_credentials (c_anoncred);
- gnutls_anon_free_server_credentials (s_anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
+ /* Server stuff. */
+ gnutls_anon_server_credentials_t s_anoncred;
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ static gnutls_dh_params_t dh_params;
+ gnutls_session_t server;
+ int sret, cret;
+ /* Client stuff. */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
+ /* Need to enable anonymous KX specifically. */
+ char buffer[MAX_BUF + 1];
+ ssize_t ns;
+ int ret, transferred = 0, msglen;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(99);
+
+ /* Init server */
+ gnutls_anon_allocate_server_credentials(&s_anoncred);
+ gnutls_dh_params_init(&dh_params);
+ gnutls_dh_params_import_pkcs3(dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ gnutls_anon_set_server_dh_params(s_anoncred, dh_params);
+ gnutls_init(&server,
+ GNUTLS_SERVER | GNUTLS_DATAGRAM | GNUTLS_NONBLOCK);
+ ret =
+ gnutls_priority_set_direct(server,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (ret < 0)
+ exit(1);
+ gnutls_credentials_set(server, GNUTLS_CRD_ANON, s_anoncred);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_pull_timeout_function(server,
+ server_pull_timeout_func);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client,
+ GNUTLS_CLIENT | GNUTLS_DATAGRAM | GNUTLS_NONBLOCK);
+ cret =
+ gnutls_priority_set_direct(client,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (cret < 0)
+ exit(1);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_pull_timeout_function(client,
+ client_pull_timeout_func);
+ gnutls_transport_set_ptr(client, client);
+
+ handshake = 1;
+ HANDSHAKE(client, server);
+
+ handshake = 0;
+ if (debug)
+ success("Handshake established\n");
+
+ do {
+ ret = gnutls_record_send(client, MSG, strlen(MSG));
+ }
+ while (ret == GNUTLS_E_AGAIN);
+ //success ("client: sent %d\n", ns);
+
+ msglen = strlen(MSG);
+ TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
+
+ if (debug)
+ fputs("\n", stdout);
+
+ gnutls_bye(client, GNUTLS_SHUT_WR);
+ gnutls_bye(server, GNUTLS_SHUT_WR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_anon_free_client_credentials(c_anoncred);
+ gnutls_anon_free_server_credentials(s_anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
}
diff --git a/tests/mini-eagain.c b/tests/mini-eagain.c
index d95c644c74..8f913e66b2 100644
--- a/tests/mini-eagain.c
+++ b/tests/mini-eagain.c
@@ -35,12 +35,11 @@
#define RANDOMIZE
#include "eagain-common.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static int handshake = 0;
@@ -48,76 +47,82 @@ static int handshake = 0;
#define MAX_BUF 1024
#define MSG "Hello TLS, and hi and how are you and more data here... and more... and even more and even more more data..."
-void
-doit (void)
+void doit(void)
{
- /* Server stuff. */
- gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { (unsigned char *) pkcs3, strlen (pkcs3) };
- static gnutls_dh_params_t dh_params;
- gnutls_session_t server;
- int sret, cret;
- /* Client stuff. */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
- /* Need to enable anonymous KX specifically. */
- char buffer[MAX_BUF + 1];
- ssize_t ns;
- int ret, transferred = 0, msglen;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_anon_allocate_server_credentials (&s_anoncred);
- gnutls_dh_params_init (&dh_params);
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
- gnutls_init (&server, GNUTLS_SERVER);
- ret = gnutls_priority_set_direct (server, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (ret < 0)
- exit(1);
- gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT);
- ret = gnutls_priority_set_direct (client, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (ret < 0)
- exit(1);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- handshake = 1;
- HANDSHAKE(client, server);
-
- handshake = 0;
- if (debug)
- success ("Handshake established\n");
-
- msglen = strlen(MSG);
- TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
- if (debug)
- fputs ("\n", stdout);
-
- gnutls_bye (client, GNUTLS_SHUT_WR);
- gnutls_bye (server, GNUTLS_SHUT_WR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_anon_free_client_credentials (c_anoncred);
- gnutls_anon_free_server_credentials (s_anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
+ /* Server stuff. */
+ gnutls_anon_server_credentials_t s_anoncred;
+ const gnutls_datum_t p3 =
+ { (unsigned char *) pkcs3, strlen(pkcs3) };
+ static gnutls_dh_params_t dh_params;
+ gnutls_session_t server;
+ int sret, cret;
+ /* Client stuff. */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
+ /* Need to enable anonymous KX specifically. */
+ char buffer[MAX_BUF + 1];
+ ssize_t ns;
+ int ret, transferred = 0, msglen;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_anon_allocate_server_credentials(&s_anoncred);
+ gnutls_dh_params_init(&dh_params);
+ gnutls_dh_params_import_pkcs3(dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ gnutls_anon_set_server_dh_params(s_anoncred, dh_params);
+ gnutls_init(&server, GNUTLS_SERVER);
+ ret =
+ gnutls_priority_set_direct(server,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (ret < 0)
+ exit(1);
+ gnutls_credentials_set(server, GNUTLS_CRD_ANON, s_anoncred);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ ret =
+ gnutls_priority_set_direct(client,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (ret < 0)
+ exit(1);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ handshake = 1;
+ HANDSHAKE(client, server);
+
+ handshake = 0;
+ if (debug)
+ success("Handshake established\n");
+
+ msglen = strlen(MSG);
+ TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
+ if (debug)
+ fputs("\n", stdout);
+
+ gnutls_bye(client, GNUTLS_SHUT_WR);
+ gnutls_bye(server, GNUTLS_SHUT_WR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_anon_free_client_credentials(c_anoncred);
+ gnutls_anon_free_server_credentials(s_anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
}
diff --git a/tests/mini-emsgsize-dtls.c b/tests/mini-emsgsize-dtls.c
index e3ca6723ee..d69122f83e 100644
--- a/tests/mini-emsgsize-dtls.c
+++ b/tests/mini-emsgsize-dtls.c
@@ -36,12 +36,11 @@
#define IGNORE_PUSH
#include "eagain-common.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static int handshake = 0;
@@ -50,136 +49,145 @@ static int handshake = 0;
#define MSG "Hello TLS, and hi and how are you and more data here... and more... and even more and even more more data..."
static ssize_t
-client_push_300 (gnutls_transport_ptr_t tr, const void *data, size_t len)
+client_push_300(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
- size_t newlen;
-
- if (len > 300)
- {
- gnutls_transport_set_errno ((gnutls_session_t)tr, EMSGSIZE);
- return -1;
- }
-
- len = min(len, sizeof(to_server)-to_server_len);
-
- newlen = to_server_len + len;
- memcpy (to_server + to_server_len, data, len);
- to_server_len = newlen;
+ size_t newlen;
+
+ if (len > 300) {
+ gnutls_transport_set_errno((gnutls_session_t) tr,
+ EMSGSIZE);
+ return -1;
+ }
+
+ len = min(len, sizeof(to_server) - to_server_len);
+
+ newlen = to_server_len + len;
+ memcpy(to_server + to_server_len, data, len);
+ to_server_len = newlen;
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: pushed %d bytes to server (avail: %d)\n", (int)len, (int)to_server_len);
+ fprintf(stderr, "eagain: pushed %d bytes to server (avail: %d)\n",
+ (int) len, (int) to_server_len);
#endif
- return len;
+ return len;
}
static ssize_t
-server_push_300 (gnutls_transport_ptr_t tr, const void *data, size_t len)
+server_push_300(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
- size_t newlen;
+ size_t newlen;
- if (len > 300)
- {
- gnutls_transport_set_errno ((gnutls_session_t)tr, EMSGSIZE);
- return -1;
- }
+ if (len > 300) {
+ gnutls_transport_set_errno((gnutls_session_t) tr,
+ EMSGSIZE);
+ return -1;
+ }
- len = min(len, sizeof(to_client)-to_client_len);
+ len = min(len, sizeof(to_client) - to_client_len);
- newlen = to_client_len + len;
- memcpy (to_client + to_client_len, data, len);
- to_client_len = newlen;
+ newlen = to_client_len + len;
+ memcpy(to_client + to_client_len, data, len);
+ to_client_len = newlen;
#ifdef EAGAIN_DEBUG
- fprintf(stderr, "eagain: pushed %d bytes to client (avail: %d)\n", (int)len, (int)to_client_len);
+ fprintf(stderr, "eagain: pushed %d bytes to client (avail: %d)\n",
+ (int) len, (int) to_client_len);
#endif
- return len;
+ return len;
}
-void
-doit (void)
+void doit(void)
{
- /* Server stuff. */
- gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- static gnutls_dh_params_t dh_params;
- gnutls_session_t server;
- int sret, cret;
- /* Client stuff. */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
- /* Need to enable anonymous KX specifically. */
- char buffer[MAX_BUF + 1];
- ssize_t ns;
- int ret, transferred = 0, msglen;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (99);
-
- /* Init server */
- gnutls_anon_allocate_server_credentials (&s_anoncred);
- gnutls_dh_params_init (&dh_params);
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
- gnutls_init (&server, GNUTLS_SERVER|GNUTLS_DATAGRAM|GNUTLS_NONBLOCK);
- ret = gnutls_priority_set_direct (server, "NONE:+VERS-DTLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (ret < 0)
- exit(1);
- gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
- gnutls_transport_set_push_function (server, server_push_300);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_pull_timeout_function (server, server_pull_timeout_func);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT|GNUTLS_DATAGRAM|GNUTLS_NONBLOCK);
- cret = gnutls_priority_set_direct (client, "NONE:+VERS-DTLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (cret < 0)
- exit(1);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_transport_set_push_function (client, client_push_300);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_pull_timeout_function (client, client_pull_timeout_func);
- gnutls_transport_set_ptr (client, client);
-
- handshake = 1;
- HANDSHAKE_DTLS(client, server);
-
- if (gnutls_protocol_get_version(client) != GNUTLS_DTLS1_2)
- {
- fail("Error in negotiated version\n");
- exit(1);
- }
-
- handshake = 0;
- if (debug)
- success ("Handshake established\n");
-
- do
- {
- ret = gnutls_record_send (client, MSG, strlen (MSG));
- }
- while(ret == GNUTLS_E_AGAIN);
- //success ("client: sent %d\n", ns);
-
- msglen = strlen(MSG);
- TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
-
- if (debug)
- fputs ("\n", stdout);
-
- gnutls_bye (client, GNUTLS_SHUT_WR);
- gnutls_bye (server, GNUTLS_SHUT_WR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_anon_free_client_credentials (c_anoncred);
- gnutls_anon_free_server_credentials (s_anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
+ /* Server stuff. */
+ gnutls_anon_server_credentials_t s_anoncred;
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ static gnutls_dh_params_t dh_params;
+ gnutls_session_t server;
+ int sret, cret;
+ /* Client stuff. */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
+ /* Need to enable anonymous KX specifically. */
+ char buffer[MAX_BUF + 1];
+ ssize_t ns;
+ int ret, transferred = 0, msglen;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(99);
+
+ /* Init server */
+ gnutls_anon_allocate_server_credentials(&s_anoncred);
+ gnutls_dh_params_init(&dh_params);
+ gnutls_dh_params_import_pkcs3(dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ gnutls_anon_set_server_dh_params(s_anoncred, dh_params);
+ gnutls_init(&server,
+ GNUTLS_SERVER | GNUTLS_DATAGRAM | GNUTLS_NONBLOCK);
+ ret =
+ gnutls_priority_set_direct(server,
+ "NONE:+VERS-DTLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (ret < 0)
+ exit(1);
+ gnutls_credentials_set(server, GNUTLS_CRD_ANON, s_anoncred);
+ gnutls_transport_set_push_function(server, server_push_300);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_pull_timeout_function(server,
+ server_pull_timeout_func);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client,
+ GNUTLS_CLIENT | GNUTLS_DATAGRAM | GNUTLS_NONBLOCK);
+ cret =
+ gnutls_priority_set_direct(client,
+ "NONE:+VERS-DTLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (cret < 0)
+ exit(1);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_transport_set_push_function(client, client_push_300);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_pull_timeout_function(client,
+ client_pull_timeout_func);
+ gnutls_transport_set_ptr(client, client);
+
+ handshake = 1;
+ HANDSHAKE_DTLS(client, server);
+
+ if (gnutls_protocol_get_version(client) != GNUTLS_DTLS1_2) {
+ fail("Error in negotiated version\n");
+ exit(1);
+ }
+
+ handshake = 0;
+ if (debug)
+ success("Handshake established\n");
+
+ do {
+ ret = gnutls_record_send(client, MSG, strlen(MSG));
+ }
+ while (ret == GNUTLS_E_AGAIN);
+ //success ("client: sent %d\n", ns);
+
+ msglen = strlen(MSG);
+ TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
+
+ if (debug)
+ fputs("\n", stdout);
+
+ gnutls_bye(client, GNUTLS_SHUT_WR);
+ gnutls_bye(server, GNUTLS_SHUT_WR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_anon_free_client_credentials(c_anoncred);
+ gnutls_anon_free_server_credentials(s_anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
}
diff --git a/tests/mini-handshake-timeout.c b/tests/mini-handshake-timeout.c
index 5fea3aee5a..02b412e69d 100644
--- a/tests/mini-handshake-timeout.c
+++ b/tests/mini-handshake-timeout.c
@@ -32,7 +32,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -52,202 +52,185 @@ int main()
/* This program tests whether the handshake timeout value is enforced.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* A very basic TLS client, with anonymous authentication.
*/
-static void
-client (int fd, int wait)
+static void client(int fd, int wait)
{
- int ret;
- gnutls_anon_client_credentials_t anoncred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
- gnutls_handshake_set_timeout( session, 20*1000);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NORMAL:+ANON-ECDH", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- gnutls_deinit(session);
- gnutls_anon_free_client_credentials(anoncred);
- gnutls_global_deinit();
-
- if (ret < 0)
- {
- if (ret != GNUTLS_E_TIMEDOUT || wait == 0)
- {
- if (debug) fail("client: unexpected error: %s\n", gnutls_strerror(ret));
- exit(1);
- }
- if (debug) success("client: expected timeout occured\n");
- return;
- }
- else
- {
- gnutls_bye(session, GNUTLS_SHUT_WR);
-
- if (wait != 0)
- {
- fail ("client: handshake was completed unexpectedly\n");
- gnutls_perror (ret);
- exit(1);
- }
- }
-
- return;
+ int ret;
+ gnutls_anon_client_credentials_t anoncred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+ gnutls_handshake_set_timeout(session, 20 * 1000);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, "NORMAL:+ANON-ECDH", NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ gnutls_deinit(session);
+ gnutls_anon_free_client_credentials(anoncred);
+ gnutls_global_deinit();
+
+ if (ret < 0) {
+ if (ret != GNUTLS_E_TIMEDOUT || wait == 0) {
+ if (debug)
+ fail("client: unexpected error: %s\n",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+ if (debug)
+ success("client: expected timeout occured\n");
+ return;
+ } else {
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ if (wait != 0) {
+ fail("client: handshake was completed unexpectedly\n");
+ gnutls_perror(ret);
+ exit(1);
+ }
+ }
+
+ return;
}
-static void
-initialize_tls_session (gnutls_session_t * session)
+static void initialize_tls_session(gnutls_session_t * session)
{
- gnutls_init (session, GNUTLS_SERVER);
+ gnutls_init(session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (*session, "NORMAL:+ANON-ECDH", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(*session, "NORMAL:+ANON-ECDH", NULL);
}
-static void
-server (int fd, int wait)
+static void server(int fd, int wait)
{
-int ret;
-gnutls_session_t session;
-gnutls_anon_server_credentials_t anoncred;
-
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- initialize_tls_session (&session);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- gnutls_transport_set_int (session, fd);
-
- if (wait) sleep(25);
- else
- {
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret == 0)
- gnutls_bye(session, GNUTLS_SHUT_RDWR);
- }
-
- gnutls_deinit (session);
- gnutls_anon_free_server_credentials(anoncred);
- gnutls_global_deinit();
+ int ret;
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ initialize_tls_session(&session);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ gnutls_transport_set_int(session, fd);
+
+ if (wait)
+ sleep(25);
+ else {
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret == 0)
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+ }
+
+ gnutls_deinit(session);
+ gnutls_anon_free_server_credentials(anoncred);
+ gnutls_global_deinit();
}
-static void start (int wait)
+static void start(int wait)
{
- int fd[2];
- int ret;
- pid_t child;
-
- if (debug && wait)
- fprintf(stderr, "\nWill test timeout\n");
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], wait);
- close(fd[0]);
- }
- else
- {
- close(fd[0]);
- client (fd[1], wait);
- close(fd[1]);
- exit(0);
- }
+ int fd[2];
+ int ret;
+ pid_t child;
+
+ if (debug && wait)
+ fprintf(stderr, "\nWill test timeout\n");
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], wait);
+ close(fd[0]);
+ } else {
+ close(fd[0]);
+ client(fd[1], wait);
+ close(fd[1]);
+ exit(0);
+ }
}
static void ch_handler(int sig)
{
-int status;
- wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
- return;
+ int status;
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n", WEXITSTATUS(status));
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
+ signal(SIGCHLD, ch_handler);
+
+ /* make sure that normal handshake occurs */
+ start(0);
- /* make sure that normal handshake occurs */
- start(0);
-
- /* check the handshake with an expected timeout */
- start(1);
+ /* check the handshake with an expected timeout */
+ start(1);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-loss-time.c b/tests/mini-loss-time.c
index 6b88eb9378..6a10606b5b 100644
--- a/tests/mini-loss-time.c
+++ b/tests/mini-loss-time.c
@@ -32,7 +32,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -53,43 +53,41 @@ int main()
* in a minute.
*/
-static void print_type(const unsigned char* buf, int size)
+static void print_type(const unsigned char *buf, int size)
{
- if (buf[0] == 22 && size >= 13) {
- if (buf[13] == 1)
- fprintf(stderr, "Client Hello\n");
- else if (buf[13] == 2)
- fprintf(stderr, "Server Hello\n");
- else if (buf[13] == 12)
- fprintf(stderr, "Server Key exchange\n");
- else if (buf[13] == 14)
- fprintf(stderr, "Server Hello Done\n");
- else if (buf[13] == 11)
- fprintf(stderr, "Certificate\n");
- else if (buf[13] == 16)
- fprintf(stderr, "Client Key Exchange\n");
- else if (buf[4] == 1)
- fprintf(stderr, "Finished\n");
- else if (buf[13] == 11)
- fprintf(stderr, "Server Hello Done\n");
- else
- fprintf(stderr, "Unknown handshake\n");
- } else if (buf[0] == 20) {
- fprintf(stderr, "Change Cipher Spec\n");
- } else
- fprintf(stderr, "Unknown\n");
+ if (buf[0] == 22 && size >= 13) {
+ if (buf[13] == 1)
+ fprintf(stderr, "Client Hello\n");
+ else if (buf[13] == 2)
+ fprintf(stderr, "Server Hello\n");
+ else if (buf[13] == 12)
+ fprintf(stderr, "Server Key exchange\n");
+ else if (buf[13] == 14)
+ fprintf(stderr, "Server Hello Done\n");
+ else if (buf[13] == 11)
+ fprintf(stderr, "Certificate\n");
+ else if (buf[13] == 16)
+ fprintf(stderr, "Client Key Exchange\n");
+ else if (buf[4] == 1)
+ fprintf(stderr, "Finished\n");
+ else if (buf[13] == 11)
+ fprintf(stderr, "Server Hello Done\n");
+ else
+ fprintf(stderr, "Unknown handshake\n");
+ } else if (buf[0] == 20) {
+ fprintf(stderr, "Change Cipher Spec\n");
+ } else
+ fprintf(stderr, "Unknown\n");
}
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
/* A very basic TLS client, with anonymous authentication.
@@ -100,86 +98,82 @@ static int packet_to_lose;
gnutls_session_t session;
static ssize_t
-push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
-int fd = (long int)tr;
-
- counter++;
-
- if (packet_to_lose != -1 && packet_to_lose == counter) {
- if (debug)
- {
- fprintf(stderr, "Discarding packet %d: ", counter);
- print_type(data, len);
- }
-
- packet_to_lose = 1;
- counter = 0;
- return len;
- }
- return send(fd, data, len, 0);
+ int fd = (long int) tr;
+
+ counter++;
+
+ if (packet_to_lose != -1 && packet_to_lose == counter) {
+ if (debug) {
+ fprintf(stderr, "Discarding packet %d: ", counter);
+ print_type(data, len);
+ }
+
+ packet_to_lose = 1;
+ counter = 0;
+ return len;
+ }
+ return send(fd, data, len, 0);
}
-static void
-client (int fd, int packet)
+static void client(int fd, int packet)
{
- int ret;
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT|GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu( session, 1500);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- counter = 0;
- packet_to_lose = packet;
-
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- gnutls_deinit(session);
- gnutls_global_deinit();
-
- if (ret < 0)
- {
- if (ret == GNUTLS_E_TIMEDOUT) return;
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- exit(1);
+ int ret;
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ counter = 0;
+ packet_to_lose = packet;
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ gnutls_deinit(session);
+ gnutls_global_deinit();
+
+ if (ret < 0) {
+ if (ret == GNUTLS_E_TIMEDOUT)
+ return;
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ exit(1);
}
@@ -187,129 +181,122 @@ client (int fd, int packet)
gnutls_anon_server_credentials_t anoncred;
pid_t child;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER|GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu( session, 1500);
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL",
+ NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
- return session;
+ return session;
}
-static void
-server (int fd, int packet)
+static void server(int fd, int packet)
{
-int ret;
- /* this must be called once in the program
- */
- global_init ();
+ int ret;
+ /* this must be called once in the program
+ */
+ global_init();
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
- gnutls_anon_allocate_server_credentials (&anoncred);
+ gnutls_anon_allocate_server_credentials(&anoncred);
- session = initialize_tls_session ();
+ session = initialize_tls_session();
- counter = 0;
- packet_to_lose = packet;
+ counter = 0;
+ packet_to_lose = packet;
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push);
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push);
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- gnutls_deinit (session);
- gnutls_global_deinit();
+ gnutls_deinit(session);
+ gnutls_global_deinit();
- if (ret < 0)
- {
- return;
- }
+ if (ret < 0) {
+ return;
+ }
}
-static void start (int server_packet, int client_packet)
+static void start(int server_packet, int client_packet)
{
- int fd[2];
- int ret;
-
- if (debug)
- fprintf(stderr, "\nWill discard %s packet %d\n",
- (client_packet!=-1)?"client":"server", (client_packet!=-1)?client_packet:server_packet);
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], server_packet);
- close(fd[0]);
- kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1], client_packet);
- close(fd[1]);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ if (debug)
+ fprintf(stderr, "\nWill discard %s packet %d\n",
+ (client_packet != -1) ? "client" : "server",
+ (client_packet !=
+ -1) ? client_packet : server_packet);
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], server_packet);
+ close(fd[0]);
+ kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1], client_packet);
+ close(fd[1]);
+ exit(0);
+ }
}
static void ch_handler(int sig)
{
-int status;
- wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
- return;
+ int status;
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n", WEXITSTATUS(status));
+ return;
}
-void
-doit (void)
+void doit(void)
{
-time_t tstart, tstop;
+ time_t tstart, tstop;
+
+ signal(SIGCHLD, ch_handler);
- signal(SIGCHLD, ch_handler);
+ tstart = time(0);
+ start(2, -1);
- tstart = time(0);
- start(2, -1);
+ tstop = time(0);
- tstop = time(0);
-
- tstop = tstop - tstart;
+ tstop = tstop - tstart;
- if (!(tstop < 70 && tstop > 55))
- fail("Time difference: %u\n", (unsigned)tstop);
+ if (!(tstop < 70 && tstop > 55))
+ fail("Time difference: %u\n", (unsigned) tstop);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-overhead.c b/tests/mini-overhead.c
index fb6ceae352..cf5d1e19c2 100644
--- a/tests/mini-overhead.c
+++ b/tests/mini-overhead.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -55,57 +55,55 @@ static void terminate(void);
* decoding.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
// fprintf (stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBA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TFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkA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MOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
@@ -115,87 +113,80 @@ const gnutls_datum_t server_key = { server_key_pem,
#define MAX_BUF 1024
#define MTU 1500
-static void
-client (int fd, const char* prio, unsigned overhead)
+static void client(int fd, const char *prio, unsigned overhead)
{
- int ret;
- gnutls_anon_client_credentials_t anoncred;
- gnutls_certificate_credentials_t x509_cred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
- gnutls_certificate_allocate_credentials (&x509_cred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT|GNUTLS_DATAGRAM);
-
- /* Use default priorities */
- ret = gnutls_priority_set_direct (session, prio, NULL);
- if (ret < 0)
- {
- fail("error in setting priority: %s\n", prio);
- exit(1);
- }
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- gnutls_dtls_set_mtu(session, MTU);
- ret = gnutls_dtls_get_data_mtu(session);
-
- if (MTU-ret != (int)overhead)
- {
- fail("overhead for %s is %d, expected %u\n", prio, MTU-ret, overhead);
- exit(1);
- }
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ int ret;
+ gnutls_anon_client_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+ gnutls_certificate_allocate_credentials(&x509_cred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+
+ /* Use default priorities */
+ ret = gnutls_priority_set_direct(session, prio, NULL);
+ if (ret < 0) {
+ fail("error in setting priority: %s\n", prio);
+ exit(1);
+ }
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ gnutls_dtls_set_mtu(session, MTU);
+ ret = gnutls_dtls_get_data_mtu(session);
+
+ if (MTU - ret != (int) overhead) {
+ fail("overhead for %s is %d, expected %u\n", prio,
+ MTU - ret, overhead);
+ exit(1);
+ }
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
@@ -204,155 +195,154 @@ gnutls_anon_server_credentials_t anoncred;
gnutls_certificate_credentials_t x509_cred;
pid_t child;
-static gnutls_session_t
-initialize_tls_session (const char* prio)
+static gnutls_session_t initialize_tls_session(const char *prio)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER|GNUTLS_DATAGRAM);
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, prio, NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, prio, NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
- return session;
+ return session;
}
static void terminate(void)
{
- kill(child, SIGTERM);
- exit(1);
+ kill(child, SIGTERM);
+ exit(1);
}
-static void
-server (int fd, const char* prio)
+static void server(int fd, const char *prio)
{
-int ret;
-char buffer[MAX_BUF + 1];
-gnutls_session_t session;
-
- /* this must be called once in the program
- */
- global_init ();
- memset(buffer, 0, sizeof(buffer));
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- session = initialize_tls_session (prio);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
- close(fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+
+ /* this must be called once in the program
+ */
+ global_init();
+ memset(buffer, 0, sizeof(buffer));
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ session = initialize_tls_session(prio);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (const char* prio, unsigned overhead)
+static void start(const char *prio, unsigned overhead)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], prio);
- waitpid(-1, NULL, 0);
- //kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1], prio, overhead);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], prio);
+ waitpid(-1, NULL, 0);
+ //kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1], prio, overhead);
+ exit(0);
+ }
}
static void ch_handler(int sig)
{
-int status = 0;
-
- waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n", WEXITSTATUS(status));
- terminate();
- }
- return;
+ int status = 0;
+
+ waitpid(-1, &status, 0);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fail("Child died with sigsegv\n");
+ else
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ terminate();
+ }
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
-
- /* 13 + 20(sha1) + 16(iv) + 16(max pad) */
- start("NONE:+VERS-DTLS1.0:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA", 65);
- /* 13 + 16(tag) + 4(iv) */
- start("NONE:+VERS-DTLS1.0:+AES-128-GCM:+AEAD:+SIGN-ALL:+COMP-NULL:+RSA", 37);
- /* 13 + 20(tag) */
- start("NONE:+VERS-DTLS1.0:+SALSA20-256:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA", 33);
- /* 13 + 12(tag) */
- start("NONE:+VERS-DTLS1.0:+SALSA20-256:+UMAC-96:+SIGN-ALL:+COMP-NULL:+RSA", 25);
+ signal(SIGCHLD, ch_handler);
+
+ /* 13 + 20(sha1) + 16(iv) + 16(max pad) */
+ start
+ ("NONE:+VERS-DTLS1.0:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA",
+ 65);
+ /* 13 + 16(tag) + 4(iv) */
+ start
+ ("NONE:+VERS-DTLS1.0:+AES-128-GCM:+AEAD:+SIGN-ALL:+COMP-NULL:+RSA",
+ 37);
+ /* 13 + 20(tag) */
+ start
+ ("NONE:+VERS-DTLS1.0:+SALSA20-256:+SHA1:+SIGN-ALL:+COMP-NULL:+RSA",
+ 33);
+ /* 13 + 12(tag) */
+ start
+ ("NONE:+VERS-DTLS1.0:+SALSA20-256:+UMAC-96:+SIGN-ALL:+COMP-NULL:+RSA",
+ 25);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-record-2.c b/tests/mini-record-2.c
index da609a2c6f..f531070baa 100644
--- a/tests/mini-record-2.c
+++ b/tests/mini-record-2.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -55,57 +55,55 @@ static void terminate(void);
* by the record layer, under different ciphersuites.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "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cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
- "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
- "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
- "-----END RSA PRIVATE KEY-----\n";
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
+ "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
+ "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
@@ -114,99 +112,92 @@ const gnutls_datum_t server_key = { server_key_pem,
#define MAX_BUF 24*1024
-static void
-client (int fd, const char* prio)
+static void client(int fd, const char *prio)
{
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- gnutls_certificate_credentials_t x509_cred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
- memset(buffer, 2, sizeof(buffer));
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
- gnutls_certificate_allocate_credentials (&x509_cred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, prio, NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client (%s): Handshake has failed (%s)\n\n", prio, gnutls_strerror (ret));
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- do {
- do {
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- } while( ret > 0);
-
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- if (ret != 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- exit(1);
- }
- }
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
-end:
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+ memset(buffer, 2, sizeof(buffer));
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+ gnutls_certificate_allocate_credentials(&x509_cred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client (%s): Handshake has failed (%s)\n\n", prio,
+ gnutls_strerror(ret));
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ do {
+ do {
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+ } while (ret > 0);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ if (ret != 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ end:
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
@@ -215,148 +206,138 @@ pid_t child;
static void terminate(void)
{
- kill(child, SIGTERM);
- exit(1);
+ kill(child, SIGTERM);
+ exit(1);
}
-static void
-server (int fd, const char* prio, int ign)
+static void server(int fd, const char *prio, int ign)
{
-int ret;
-unsigned i;
-char buffer[MAX_BUF + 1];
-gnutls_session_t session;
-gnutls_anon_server_credentials_t anoncred;
-gnutls_certificate_credentials_t x509_cred;
-
- /* this must be called once in the program
- */
- global_init ();
- memset(buffer, 0, sizeof(buffer));
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, prio, NULL);
-
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server (%s): Handshake has failed (%s)\n\n", prio, gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- for (i=1;i<16384;i++)
- {
- do {
- ret = gnutls_record_send (session, buffer, i);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- fail("server (%s): Error sending %d byte packet: %s\n", prio, i, gnutls_strerror(ret));
- terminate();
- }
- }
-
- /* Try sending a bit more */
- i = 21056;
- do {
- ret = gnutls_record_send (session, buffer, i);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- fail("server (%s): Error sending %d byte packet: %s\n", prio, i, gnutls_strerror(ret));
- terminate();
- }
- else if (ign == 0 && ret != 16384)
- {
- fail("server (%s): Error sending %d byte packet; sent %d bytes instead of 16384\n", prio, i, ret);
- terminate();
- }
-
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ unsigned i;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+
+ /* this must be called once in the program
+ */
+ global_init();
+ memset(buffer, 0, sizeof(buffer));
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server (%s): Handshake has failed (%s)\n\n", prio,
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ for (i = 1; i < 16384; i++) {
+ do {
+ ret = gnutls_record_send(session, buffer, i);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ fail("server (%s): Error sending %d byte packet: %s\n", prio, i, gnutls_strerror(ret));
+ terminate();
+ }
+ }
+
+ /* Try sending a bit more */
+ i = 21056;
+ do {
+ ret = gnutls_record_send(session, buffer, i);
+ } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ fail("server (%s): Error sending %d byte packet: %s\n",
+ prio, i, gnutls_strerror(ret));
+ terminate();
+ } else if (ign == 0 && ret != 16384) {
+ fail("server (%s): Error sending %d byte packet; sent %d bytes instead of 16384\n", prio, i, ret);
+ terminate();
+ }
+
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (const char* prio, int ign)
+static void start(const char *prio, int ign)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], prio, ign);
- kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1], prio);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], prio, ign);
+ kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1], prio);
+ exit(0);
+ }
}
#define AES_CBC "NONE:+VERS-TLS1.0:-CIPHER-ALL:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-NULL:+ANON-ECDH:+CURVE-ALL"
@@ -375,38 +356,37 @@ static void start (const char* prio, int ign)
static void ch_handler(int sig)
{
-int status;
- wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n", WEXITSTATUS(status));
- terminate();
- }
- return;
+ int status;
+ wait(&status);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fail("Child died with sigsegv\n");
+ else
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ terminate();
+ }
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
+ signal(SIGCHLD, ch_handler);
- start(NULL_SHA1, 0);
+ start(NULL_SHA1, 0);
- start(NEW_ARCFOUR_SHA1, 1);
- start(NEW_AES_CBC, 1);
- start(NEW_AES_CBC_SHA256, 1);
- start(NEW_AES_GCM, 1);
+ start(NEW_ARCFOUR_SHA1, 1);
+ start(NEW_AES_CBC, 1);
+ start(NEW_AES_CBC_SHA256, 1);
+ start(NEW_AES_GCM, 1);
- start(AES_CBC, 1);
- start(AES_CBC_SHA256, 1);
- start(AES_GCM, 0);
+ start(AES_CBC, 1);
+ start(AES_CBC_SHA256, 1);
+ start(AES_GCM, 0);
- start(ARCFOUR_SHA1, 0);
- start(ARCFOUR_MD5, 0);
+ start(ARCFOUR_SHA1, 0);
+ start(ARCFOUR_MD5, 0);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-record-range.c b/tests/mini-record-range.c
index 532ace27a3..10b793737a 100644
--- a/tests/mini-record-range.c
+++ b/tests/mini-record-range.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -57,57 +57,55 @@ static int to_send;
/* This program tests the robustness of record range sending.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVH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YEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5Nt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vWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
@@ -117,111 +115,103 @@ const gnutls_datum_t server_key = { server_key_pem,
static ssize_t
-push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
-int fd = (long int)tr;
-
- if (to_send >= 0 && len < HIGH(MAX_BUF))
- {
- fail("Sent data (%u) are lower than expected (%u)\n", (unsigned)len, (unsigned)HIGH(MAX_BUF));
- terminate();
- }
- return send(fd, data, len, 0);
+ int fd = (long int) tr;
+
+ if (to_send >= 0 && len < HIGH(MAX_BUF)) {
+ fail("Sent data (%u) are lower than expected (%u)\n",
+ (unsigned) len, (unsigned) HIGH(MAX_BUF));
+ terminate();
+ }
+ return send(fd, data, len, 0);
}
-static void
-client (int fd, const char* prio)
+static void client(int fd, const char *prio)
{
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- gnutls_certificate_credentials_t x509_cred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
- gnutls_certificate_allocate_credentials (&x509_cred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, prio, NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- do {
- do {
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- } while( ret > 0);
-
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- if (ret != 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- exit(1);
- }
- }
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
-end:
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+ gnutls_certificate_allocate_credentials(&x509_cred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ do {
+ do {
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+ } while (ret > 0);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ if (ret != 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ end:
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
@@ -230,173 +220,167 @@ pid_t child;
static void terminate(void)
{
- kill(child, SIGTERM);
- exit(1);
+ kill(child, SIGTERM);
+ exit(1);
}
-static void
-server (int fd, const char* prio)
+static void server(int fd, const char *prio)
{
-int ret;
-char buffer[MAX_BUF + 1];
-gnutls_session_t session;
-gnutls_anon_server_credentials_t anoncred;
-gnutls_certificate_credentials_t x509_cred;
-gnutls_range_st range;
-
- to_send = 0;
-
- range.low = MAX_BUF;
- range.high = HIGH(MAX_BUF);
-
- /* this must be called once in the program
- */
- global_init ();
- memset(buffer, 0, sizeof(buffer));
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, prio, NULL);
-
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- gnutls_transport_set_push_function (session, push);
-
- if (gnutls_record_can_use_length_hiding(session) == 0)
- {
- fail("Length hiding isn't possible\n");
- terminate();
- }
-
- do
- {
- do {
- ret = gnutls_record_send_range (session, buffer, sizeof (buffer), &range);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- fail("Error sending packet: %s\n", gnutls_strerror(ret));
- terminate();
- }
- to_send++;
- }
- while(to_send < 4);
-
- to_send = -1;
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_range_st range;
+
+ to_send = 0;
+
+ range.low = MAX_BUF;
+ range.high = HIGH(MAX_BUF);
+
+ /* this must be called once in the program
+ */
+ global_init();
+ memset(buffer, 0, sizeof(buffer));
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ gnutls_transport_set_push_function(session, push);
+
+ if (gnutls_record_can_use_length_hiding(session) == 0) {
+ fail("Length hiding isn't possible\n");
+ terminate();
+ }
+
+ do {
+ do {
+ ret =
+ gnutls_record_send_range(session, buffer,
+ sizeof(buffer),
+ &range);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ fail("Error sending packet: %s\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ to_send++;
+ }
+ while (to_send < 4);
+
+ to_send = -1;
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (const char* prio)
+static void start(const char *prio)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], prio);
- kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1], prio);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], prio);
+ kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1], prio);
+ exit(0);
+ }
}
#define AES_CBC "NORMAL:+ANON-ECDH:+CURVE-ALL:%NEW_PADDING"
static void ch_handler(int sig)
{
-int status;
- wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n", WEXITSTATUS(status));
- terminate();
- }
- return;
+ int status;
+ wait(&status);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fail("Child died with sigsegv\n");
+ else
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ terminate();
+ }
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
+ signal(SIGCHLD, ch_handler);
- start(AES_CBC);
+ start(AES_CBC);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-record.c b/tests/mini-record.c
index 4f0316f4e9..001c1eabf5 100644
--- a/tests/mini-record.c
+++ b/tests/mini-record.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -55,57 +55,55 @@ static void terminate(void);
* decoding.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
- "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
- "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
- "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
- "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
- "-----END RSA PRIVATE KEY-----\n";
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
+ "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
+ "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
@@ -118,140 +116,133 @@ static int to_send = -1;
static int mtu = 0;
static ssize_t
-push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+push(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
-int fd = (long int)tr;
+ int fd = (long int) tr;
- return send(fd, data, len, 0);
+ return send(fd, data, len, 0);
}
#define RECORD_HEADER_SIZE (5+8)
static ssize_t
-push_crippled (gnutls_transport_ptr_t tr, const void *data, size_t len)
+push_crippled(gnutls_transport_ptr_t tr, const void *data, size_t len)
{
-int fd = (long int)tr;
-int _len, ret;
-uint8_t* _data = (void*)data;
-
- if (to_send == -1)
- return send(fd, data, len, 0);
- else
- {
+ int fd = (long int) tr;
+ int _len, ret;
+ uint8_t *_data = (void *) data;
+
+ if (to_send == -1)
+ return send(fd, data, len, 0);
+ else {
#if 0
- _len = ((uint8_t*)data)[11] << 8 | ((uint8_t*)data)[12];
-fprintf(stderr, "mtu: %d, len: %d", mtu, (int)_len);
-fprintf(stderr, " send: %d\n", (int)to_send);
+ _len =
+ ((uint8_t *) data)[11] << 8 | ((uint8_t *) data)[12];
+ fprintf(stderr, "mtu: %d, len: %d", mtu, (int) _len);
+ fprintf(stderr, " send: %d\n", (int) to_send);
#endif
-
- _len = to_send;
- _data[11] = _len >> 8;
- _data[12] = _len;
- /* correct len */
- ret = send(fd, data, RECORD_HEADER_SIZE+_len, 0);
+ _len = to_send;
+ _data[11] = _len >> 8;
+ _data[12] = _len;
+
+ /* correct len */
+ ret = send(fd, data, RECORD_HEADER_SIZE + _len, 0);
- if (ret < 0) return ret;
+ if (ret < 0)
+ return ret;
- return len;
- }
+ return len;
+ }
}
-static void
-client (int fd, const char* prio)
+static void client(int fd, const char *prio)
{
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- gnutls_certificate_credentials_t x509_cred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
- gnutls_certificate_allocate_credentials (&x509_cred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT|GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu( session, 1500);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, prio, NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- do {
- do {
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- } while( ret > 0);
-
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- if (ret != 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- exit(1);
- }
- }
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
-end:
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+ gnutls_certificate_allocate_credentials(&x509_cred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ do {
+ do {
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+ } while (ret > 0);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ if (ret != 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ end:
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
@@ -260,136 +251,131 @@ pid_t child;
static void terminate(void)
{
- kill(child, SIGTERM);
- exit(1);
+ kill(child, SIGTERM);
+ exit(1);
}
-static void
-server (int fd, const char* prio)
+static void server(int fd, const char *prio)
{
-int ret;
-char buffer[MAX_BUF + 1];
-gnutls_session_t session;
-gnutls_anon_server_credentials_t anoncred;
-gnutls_certificate_credentials_t x509_cred;
-
- /* this must be called once in the program
- */
- global_init ();
- memset(buffer, 0, sizeof(buffer));
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- gnutls_init (&session, GNUTLS_SERVER|GNUTLS_DATAGRAM);
- gnutls_dtls_set_mtu(session, 1500);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, prio, NULL);
-
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_push_function (session, push_crippled);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
- mtu = gnutls_dtls_get_mtu(session);
-
- do
- {
- do {
- ret = gnutls_record_send (session, buffer, sizeof (buffer));
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
-
- if (ret < 0)
- {
- fail("Error sending %d byte packet: %s\n", to_send, gnutls_strerror(ret));
- terminate();
- }
- to_send++;
- }
- while(to_send < 64);
-
- to_send = -1;
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+ gnutls_anon_server_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+
+ /* this must be called once in the program
+ */
+ global_init();
+ memset(buffer, 0, sizeof(buffer));
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
+ gnutls_dtls_set_mtu(session, 1500);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+ gnutls_transport_set_push_function(session, push_crippled);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+ mtu = gnutls_dtls_get_mtu(session);
+
+ do {
+ do {
+ ret =
+ gnutls_record_send(session, buffer,
+ sizeof(buffer));
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+
+ if (ret < 0) {
+ fail("Error sending %d byte packet: %s\n", to_send,
+ gnutls_strerror(ret));
+ terminate();
+ }
+ to_send++;
+ }
+ while (to_send < 64);
+
+ to_send = -1;
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (const char* prio)
+static void start(const char *prio)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], prio);
- kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1], prio);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], prio);
+ kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1], prio);
+ exit(0);
+ }
}
#define AES_CBC "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
@@ -402,32 +388,31 @@ static void start (const char* prio)
static void ch_handler(int sig)
{
-int status;
- wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n", WEXITSTATUS(status));
- terminate();
- }
- return;
+ int status;
+ wait(&status);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fail("Child died with sigsegv\n");
+ else
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ terminate();
+ }
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
+ signal(SIGCHLD, ch_handler);
- start(NEW_AES_CBC);
- start(NEW_AES_CBC_SHA256);
- start(NEW_AES_GCM);
+ start(NEW_AES_CBC);
+ start(NEW_AES_CBC_SHA256);
+ start(NEW_AES_GCM);
- start(AES_CBC);
- start(AES_CBC_SHA256);
- start(AES_GCM);
+ start(AES_CBC);
+ start(AES_CBC_SHA256);
+ start(AES_GCM);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-rehandshake.c b/tests/mini-rehandshake.c
index d3fe336319..995277b263 100644
--- a/tests/mini-rehandshake.c
+++ b/tests/mini-rehandshake.c
@@ -32,131 +32,129 @@
#include "utils.h"
#include "eagain-common.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMB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bU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkH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ILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
-void
-doit (void)
+void doit(void)
{
- int exit_code = EXIT_SUCCESS;
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- sret = gnutls_rehandshake (server);
- if (debug)
- {
- tls_log_func (0, "gnutls_rehandshake (server)...\n");
- tls_log_func (0, gnutls_strerror (sret));
- tls_log_func (0, "\n");
- }
-
- {
- ssize_t n;
- char b[1];
- n = gnutls_record_recv (client, b, 1);
- if (n != GNUTLS_E_REHANDSHAKE)
- abort ();
- }
-
- HANDSHAKE(client, server);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- {
- if (exit_code == 0)
- puts ("Self-test successful");
- else
- puts ("Self-test failed");
- }
+ int exit_code = EXIT_SUCCESS;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server, "NORMAL", NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ sret = gnutls_rehandshake(server);
+ if (debug) {
+ tls_log_func(0, "gnutls_rehandshake (server)...\n");
+ tls_log_func(0, gnutls_strerror(sret));
+ tls_log_func(0, "\n");
+ }
+
+ {
+ ssize_t n;
+ char b[1];
+ n = gnutls_record_recv(client, b, 1);
+ if (n != GNUTLS_E_REHANDSHAKE)
+ abort();
+ }
+
+ HANDSHAKE(client, server);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug) {
+ if (exit_code == 0)
+ puts("Self-test successful");
+ else
+ puts("Self-test failed");
+ }
}
diff --git a/tests/mini-rsa-psk.c b/tests/mini-rsa-psk.c
index 3ec4170397..b6bc190f1a 100644
--- a/tests/mini-rsa-psk.c
+++ b/tests/mini-rsa-psk.c
@@ -34,10 +34,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -56,108 +55,101 @@ main (int argc, char** argv)
/* A very basic TLS client, with PSK authentication.
*/
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
#define MAX_BUF 1024
#define MSG "Hello TLS"
-static void
-client (int sd)
+static void client(int sd)
{
- int ret, ii;
- gnutls_session_t session;
- gnutls_certificate_credentials_t clientx509cred;
- char buffer[MAX_BUF + 1];
- gnutls_psk_client_credentials_t pskcred;
- /* Need to enable anonymous KX specifically. */
- const gnutls_datum_t key = { (void *) "DEADBEEF", 8 };
-
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- side = "client";
-
- gnutls_certificate_allocate_credentials (&clientx509cred);
-
- gnutls_psk_allocate_client_credentials (&pskcred);
- gnutls_psk_set_client_credentials (pskcred, "test", &key,
- GNUTLS_PSK_KEY_HEX);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NORMAL:-KX-ALL:+RSA-PSK", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_PSK, pskcred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, clientx509cred);
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug)
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
- close (sd);
-
- gnutls_deinit (session);
-
- gnutls_psk_free_client_credentials (pskcred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
+ int ret, ii;
+ gnutls_session_t session;
+ gnutls_certificate_credentials_t clientx509cred;
+ char buffer[MAX_BUF + 1];
+ gnutls_psk_client_credentials_t pskcred;
+ /* Need to enable anonymous KX specifically. */
+ const gnutls_datum_t key = { (void *) "DEADBEEF", 8 };
+
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ side = "client";
+
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+
+ gnutls_psk_allocate_client_credentials(&pskcred);
+ gnutls_psk_set_client_credentials(pskcred, "test", &key,
+ GNUTLS_PSK_KEY_HEX);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, "NORMAL:-KX-ALL:+RSA-PSK",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_PSK, pskcred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ end:
+
+ close(sd);
+
+ gnutls_deinit(session);
+
+ gnutls_psk_free_client_credentials(pskcred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
}
/* This is a sample TLS 1.0 echo server, for PSK authentication.
@@ -166,78 +158,79 @@ end:
#define MAX_BUF 1024
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTI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
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
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ap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
/* These are global */
gnutls_psk_server_credentials_t server_pskcred;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NORMAL:-KX-ALL:+RSA-PSK", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, "NORMAL:-KX-ALL:+RSA-PSK",
+ NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_PSK, server_pskcred);
+ gnutls_credentials_set(session, GNUTLS_CRD_PSK, server_pskcred);
- return session;
+ return session;
}
static int
-pskfunc (gnutls_session_t session, const char *username, gnutls_datum_t * key)
+pskfunc(gnutls_session_t session, const char *username,
+ gnutls_datum_t * key)
{
- if (debug)
- printf ("psk: username %s\n", username);
- key->data = gnutls_malloc (4);
- key->data[0] = 0xDE;
- key->data[1] = 0xAD;
- key->data[2] = 0xBE;
- key->data[3] = 0xEF;
- key->size = 4;
- return 0;
+ if (debug)
+ printf("psk: username %s\n", username);
+ key->data = gnutls_malloc(4);
+ key->data[0] = 0xDE;
+ key->data[1] = 0xAD;
+ key->data[2] = 0xBE;
+ key->data[3] = 0xEF;
+ key->size = 4;
+ return 0;
}
int err, ret;
@@ -246,116 +239,108 @@ gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
-static void
-server (int sd)
+static void server(int sd)
{
- gnutls_certificate_credentials_t serverx509cred;
-
- /* this must be called once in the program
- */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- side = "server";
-
- gnutls_psk_allocate_server_credentials (&server_pskcred);
- gnutls_psk_set_server_credentials_function (server_pskcred, pskfunc);
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- session = initialize_tls_session ();
-
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, serverx509cred);
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- return;
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
- gnutls_deinit (session);
-
- gnutls_psk_free_server_credentials (server_pskcred);
- gnutls_certificate_free_credentials (serverx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ gnutls_certificate_credentials_t serverx509cred;
+
+ /* this must be called once in the program
+ */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ side = "server";
+
+ gnutls_psk_allocate_server_credentials(&server_pskcred);
+ gnutls_psk_set_server_credentials_function(server_pskcred,
+ pskfunc);
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ session = initialize_tls_session();
+
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+ gnutls_deinit(session);
+
+ gnutls_psk_free_server_credentials(server_pskcred);
+ gnutls_certificate_free_credentials(serverx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- pid_t child;
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (sockets[0]);
- wait (&status);
- }
- else
- client (sockets[1]);
+ pid_t child;
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(sockets[0]);
+ wait(&status);
+ } else
+ client(sockets[1]);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-tdb.c b/tests/mini-tdb.c
index 5f5f18ace1..cbd7520670 100644
--- a/tests/mini-tdb.c
+++ b/tests/mini-tdb.c
@@ -34,47 +34,47 @@
/* This will test whether the default public key storage backend
* is operating properly */
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoG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7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static char client_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t client_cert = { (void*)client_pem, sizeof (client_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
+ "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
+ "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
+ "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
+ "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
+ "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
+ "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
+ "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
+ "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
+ "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
+ "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t client_cert =
+ { (void *) client_pem, sizeof(client_pem) };
#define TMP_FILE "mini-tdb-tmp"
@@ -82,105 +82,109 @@ const gnutls_datum_t client_cert = { (void*)client_pem, sizeof (client_pem) };
void doit(void)
{
- gnutls_datum_t der_cert, der_cert2;
- int ret;
- gnutls_datum_t hash;
-
- /* the sha1 hash of the server's pubkey */
- hash.data = (void*)SHA1_HASH;
- hash.size = sizeof(SHA1_HASH)-1;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- ret = gnutls_pem_base64_decode_alloc("CERTIFICATE", &server_cert, &der_cert);
- if (ret < 0)
- {
- fail("base64 decoding\n");
- goto fail;
- }
-
- ret = gnutls_pem_base64_decode_alloc("CERTIFICATE", &client_cert, &der_cert2);
- if (ret < 0)
- {
- fail("base64 decoding\n");
- goto fail;
- }
-
- remove(TMP_FILE);
-
- /* verify whether the stored hash verification succeeeds */
- ret = gnutls_store_commitment(TMP_FILE, NULL, "localhost", "https",
- GNUTLS_DIG_SHA1, &hash, 0, 0);
- if (ret != 0)
- {
- fail("commitment storage: %s\n", gnutls_strerror(ret));
- goto fail;
- }
-
- if (debug)
- success("Commitment storage: passed\n");
-
- ret = gnutls_verify_stored_pubkey(TMP_FILE, NULL, "localhost", "https",
- GNUTLS_CRT_X509, &der_cert, 0);
- remove(TMP_FILE);
-
- if (ret != 0)
- {
- fail("commitment verification: %s\n", gnutls_strerror(ret));
- goto fail;
- }
-
- if (debug)
- success("Commitment verification: passed\n");
-
- /* verify whether the stored pubkey verification succeeeds */
- ret = gnutls_store_pubkey(TMP_FILE, NULL, "localhost", "https",
- GNUTLS_CRT_X509, &der_cert, 0, 0);
- if (ret != 0)
- {
- fail("storage: %s\n", gnutls_strerror(ret));
- goto fail;
- }
-
- if (debug)
- success("Public key storage: passed\n");
-
- ret = gnutls_verify_stored_pubkey(TMP_FILE, NULL, "localhost", "https",
- GNUTLS_CRT_X509, &der_cert, 0);
- if (ret != 0)
- {
- fail("pubkey verification: %s\n", gnutls_strerror(ret));
- goto fail;
- }
-
- ret = gnutls_verify_stored_pubkey(TMP_FILE, NULL, "localhost", "https",
- GNUTLS_CRT_X509, &der_cert2, 0);
- remove(TMP_FILE);
- if (ret == 0)
- {
- fail("verification succeed when shouldn't!\n");
- goto fail;
- }
- if (ret != GNUTLS_E_CERTIFICATE_KEY_MISMATCH)
- {
- fail("Wrong error code returned: %s!\n", gnutls_strerror(ret));
- goto fail;
- }
-
- if (debug)
- success("Public key verification: passed\n");
-
-
- gnutls_global_deinit();
- gnutls_free(der_cert.data);
- gnutls_free(der_cert2.data);
-
- return;
-fail:
- remove(TMP_FILE);
- exit(1);
+ gnutls_datum_t der_cert, der_cert2;
+ int ret;
+ gnutls_datum_t hash;
+
+ /* the sha1 hash of the server's pubkey */
+ hash.data = (void *) SHA1_HASH;
+ hash.size = sizeof(SHA1_HASH) - 1;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ ret =
+ gnutls_pem_base64_decode_alloc("CERTIFICATE", &server_cert,
+ &der_cert);
+ if (ret < 0) {
+ fail("base64 decoding\n");
+ goto fail;
+ }
+
+ ret =
+ gnutls_pem_base64_decode_alloc("CERTIFICATE", &client_cert,
+ &der_cert2);
+ if (ret < 0) {
+ fail("base64 decoding\n");
+ goto fail;
+ }
+
+ remove(TMP_FILE);
+
+ /* verify whether the stored hash verification succeeeds */
+ ret = gnutls_store_commitment(TMP_FILE, NULL, "localhost", "https",
+ GNUTLS_DIG_SHA1, &hash, 0, 0);
+ if (ret != 0) {
+ fail("commitment storage: %s\n", gnutls_strerror(ret));
+ goto fail;
+ }
+
+ if (debug)
+ success("Commitment storage: passed\n");
+
+ ret =
+ gnutls_verify_stored_pubkey(TMP_FILE, NULL, "localhost",
+ "https", GNUTLS_CRT_X509,
+ &der_cert, 0);
+ remove(TMP_FILE);
+
+ if (ret != 0) {
+ fail("commitment verification: %s\n",
+ gnutls_strerror(ret));
+ goto fail;
+ }
+
+ if (debug)
+ success("Commitment verification: passed\n");
+
+ /* verify whether the stored pubkey verification succeeeds */
+ ret = gnutls_store_pubkey(TMP_FILE, NULL, "localhost", "https",
+ GNUTLS_CRT_X509, &der_cert, 0, 0);
+ if (ret != 0) {
+ fail("storage: %s\n", gnutls_strerror(ret));
+ goto fail;
+ }
+
+ if (debug)
+ success("Public key storage: passed\n");
+
+ ret =
+ gnutls_verify_stored_pubkey(TMP_FILE, NULL, "localhost",
+ "https", GNUTLS_CRT_X509,
+ &der_cert, 0);
+ if (ret != 0) {
+ fail("pubkey verification: %s\n", gnutls_strerror(ret));
+ goto fail;
+ }
+
+ ret =
+ gnutls_verify_stored_pubkey(TMP_FILE, NULL, "localhost",
+ "https", GNUTLS_CRT_X509,
+ &der_cert2, 0);
+ remove(TMP_FILE);
+ if (ret == 0) {
+ fail("verification succeed when shouldn't!\n");
+ goto fail;
+ }
+ if (ret != GNUTLS_E_CERTIFICATE_KEY_MISMATCH) {
+ fail("Wrong error code returned: %s!\n",
+ gnutls_strerror(ret));
+ goto fail;
+ }
+
+ if (debug)
+ success("Public key verification: passed\n");
+
+
+ gnutls_global_deinit();
+ gnutls_free(der_cert.data);
+ gnutls_free(der_cert2.data);
+
+ return;
+ fail:
+ remove(TMP_FILE);
+ exit(1);
}
diff --git a/tests/mini-termination.c b/tests/mini-termination.c
index c4741b59ed..f396d58bc7 100644
--- a/tests/mini-termination.c
+++ b/tests/mini-termination.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -55,57 +55,55 @@ static void terminate(void);
* decoding.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
// fprintf (stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
- "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
- "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
- "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
- "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
- "-----END RSA PRIVATE KEY-----\n";
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
+ "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
+ "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
@@ -114,92 +112,86 @@ const gnutls_datum_t server_key = { server_key_pem,
#define MAX_BUF 1024
-static void
-client (int fd, const char* prio)
+static void client(int fd, const char *prio)
{
- int ret;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- gnutls_certificate_credentials_t x509_cred;
- gnutls_session_t session;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
- gnutls_anon_allocate_client_credentials (&anoncred);
- gnutls_certificate_allocate_credentials (&x509_cred);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, prio, NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
- do {
- do {
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- } while( ret > 0);
-
- if (ret == GNUTLS_E_PREMATURE_TERMINATION)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else
- {
- fail ("client: Unexpected error: %d (%s)\n", ret, gnutls_strerror (ret));
- exit(1);
- }
-
-end:
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_anon_free_client_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_session_t session;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+ gnutls_certificate_allocate_credentials(&x509_cred);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+ do {
+ do {
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+ } while (ret > 0);
+
+ if (ret == GNUTLS_E_PREMATURE_TERMINATION) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else {
+ fail("client: Unexpected error: %d (%s)\n", ret,
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
+ end:
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_anon_free_client_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
@@ -208,148 +200,139 @@ gnutls_anon_server_credentials_t anoncred;
gnutls_certificate_credentials_t x509_cred;
pid_t child;
-static gnutls_session_t
-initialize_tls_session (const char* prio)
+static gnutls_session_t initialize_tls_session(const char *prio)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, prio, NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, prio, NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
- return session;
+ return session;
}
static void terminate(void)
{
- kill(child, SIGTERM);
- exit(1);
+ kill(child, SIGTERM);
+ exit(1);
}
-static void
-server (int fd, const char* prio)
+static void server(int fd, const char *prio)
{
-int ret;
-char buffer[MAX_BUF + 1];
-gnutls_session_t session;
-
- /* this must be called once in the program
- */
- global_init ();
- memset(buffer, 0, sizeof(buffer));
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- session = initialize_tls_session (prio);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
- close(fd);
- gnutls_deinit (session);
-
- gnutls_anon_free_server_credentials (anoncred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+
+ /* this must be called once in the program
+ */
+ global_init();
+ memset(buffer, 0, sizeof(buffer));
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ session = initialize_tls_session(prio);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_anon_free_server_credentials(anoncred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (const char* prio)
+static void start(const char *prio)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], prio);
- waitpid(-1, NULL, 0);
- //kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1], prio);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], prio);
+ waitpid(-1, NULL, 0);
+ //kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1], prio);
+ exit(0);
+ }
}
static void ch_handler(int sig)
{
-int status = 0;
-
- waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n", WEXITSTATUS(status));
- terminate();
- }
- return;
+ int status = 0;
+
+ waitpid(-1, &status, 0);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fail("Child died with sigsegv\n");
+ else
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ terminate();
+ }
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
+ signal(SIGCHLD, ch_handler);
- start("NORMAL");
+ start("NORMAL");
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/mini-x509-2.c b/tests/mini-x509-2.c
index 7e98e5ab8d..3e0b42231f 100644
--- a/tests/mini-x509-2.c
+++ b/tests/mini-x509-2.c
@@ -35,145 +35,145 @@
/* This tests gnutls_certificate_set_x509_key() */
-const char* side;
+const char *side;
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZX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Wk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOj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60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- int exit_code = EXIT_SUCCESS;
- int ret;
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
- gnutls_x509_crt_t crt;
- gnutls_x509_privkey_t pkey;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- ret = gnutls_x509_crt_init(&crt);
- if (ret < 0)
- {
- fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_privkey_init(&pkey);
- if (ret < 0)
- {
- fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_crt_import(crt, &server_cert, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- ret = gnutls_x509_privkey_import(pkey, &server_key, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key (serverx509cred,
- &crt, 1, pkey);
- gnutls_x509_privkey_deinit(pkey);
- gnutls_x509_crt_deinit(crt);
-
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL:-CIPHER-ALL:+AES-128-GCM", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug > 0)
- {
- if (exit_code == 0)
- puts ("Self-test successful");
- else
- puts ("Self-test failed");
- }
+ int exit_code = EXIT_SUCCESS;
+ int ret;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+ gnutls_x509_crt_t crt;
+ gnutls_x509_privkey_t pkey;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ ret = gnutls_x509_crt_init(&crt);
+ if (ret < 0) {
+ fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret < 0) {
+ fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(crt, &server_cert, GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_privkey_import(pkey, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "error: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key(serverx509cred, &crt, 1, pkey);
+ gnutls_x509_privkey_deinit(pkey);
+ gnutls_x509_crt_deinit(crt);
+
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server,
+ "NORMAL:-CIPHER-ALL:+AES-128-GCM",
+ NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug > 0) {
+ if (exit_code == 0)
+ puts("Self-test successful");
+ else
+ puts("Self-test failed");
+ }
}
diff --git a/tests/mini-x509-callbacks.c b/tests/mini-x509-callbacks.c
index 0246f9d7cc..66ab17b6d4 100644
--- a/tests/mini-x509-callbacks.c
+++ b/tests/mini-x509-callbacks.c
@@ -37,21 +37,20 @@
* are tested.
*/
-const char* side;
+const char *side;
static int client_ok = 0, server_ok = 0;
static int pch_ok = 0;
-static int
-client_callback (gnutls_session_t session)
+static int client_callback(gnutls_session_t session)
{
- client_ok = 1;
- return 0;
+ client_ok = 1;
+ return 0;
}
-static int post_client_hello_callback (gnutls_session_t session)
+static int post_client_hello_callback(gnutls_session_t session)
{
- pch_ok = 1;
- return 0;
+ pch_ok = 1;
+ return 0;
}
unsigned int msg_order[] = {
@@ -67,169 +66,173 @@ unsigned int msg_order[] = {
GNUTLS_HANDSHAKE_FINISHED,
};
-static int handshake_callback (gnutls_session_t session, unsigned int htype, unsigned post, unsigned int incoming)
+static int handshake_callback(gnutls_session_t session, unsigned int htype,
+ unsigned post, unsigned int incoming)
{
-static unsigned idx = 0;
-unsigned int msg;
-
- if (msg_order[idx] != htype)
- {
- fail("%s: %s, expected %s\n", incoming!=0?"Received":"Sent", gnutls_handshake_description_get_name(htype), gnutls_handshake_description_get_name(msg_order[idx]));
- exit(1);
- }
- idx++;
-
- if (incoming != 0)
- {
- msg = gnutls_handshake_get_last_in(session);
- if (msg != htype)
- {
- fail("last input message was not recorded (exp: %d, found: %d) \n", msg, htype);
- exit(1);
- }
- }
- else
- {
- msg = gnutls_handshake_get_last_out(session);
- if (msg != htype)
- {
- fail("last output message was not recorded (exp: %d, found: %d) \n", msg, htype);
- exit(1);
- }
- }
-
- return 0;
+ static unsigned idx = 0;
+ unsigned int msg;
+
+ if (msg_order[idx] != htype) {
+ fail("%s: %s, expected %s\n",
+ incoming != 0 ? "Received" : "Sent",
+ gnutls_handshake_description_get_name(htype),
+ gnutls_handshake_description_get_name(msg_order
+ [idx]));
+ exit(1);
+ }
+ idx++;
+
+ if (incoming != 0) {
+ msg = gnutls_handshake_get_last_in(session);
+ if (msg != htype) {
+ fail("last input message was not recorded (exp: %d, found: %d) \n", msg, htype);
+ exit(1);
+ }
+ } else {
+ msg = gnutls_handshake_get_last_out(session);
+ if (msg != htype) {
+ fail("last output message was not recorded (exp: %d, found: %d) \n", msg, htype);
+ exit(1);
+ }
+ }
+
+ return 0;
}
-static int
-server_callback (gnutls_session_t session)
+static int server_callback(gnutls_session_t session)
{
- server_ok = 1;
+ server_ok = 1;
- if (gnutls_handshake_get_last_in(session) != GNUTLS_HANDSHAKE_CERTIFICATE_PKT)
- {
- fail("client's last input message was unexpected\n");
- exit(1);
- }
+ if (gnutls_handshake_get_last_in(session) !=
+ GNUTLS_HANDSHAKE_CERTIFICATE_PKT) {
+ fail("client's last input message was unexpected\n");
+ exit(1);
+ }
- if (gnutls_handshake_get_last_out(session) != GNUTLS_HANDSHAKE_SERVER_HELLO_DONE)
- {
- fail("client's last output message was unexpected\n");
- exit(1);
- }
+ if (gnutls_handshake_get_last_out(session) !=
+ GNUTLS_HANDSHAKE_SERVER_HELLO_DONE) {
+ fail("client's last output message was unexpected\n");
+ exit(1);
+ }
- return 0;
+ return 0;
}
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJH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mL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMO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"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
- gnutls_certificate_set_verify_function (serverx509cred, server_callback);
- gnutls_certificate_server_set_request (server, GNUTLS_CERT_REQUEST);
- gnutls_handshake_set_post_client_hello_function (server, post_client_hello_callback);
- gnutls_handshake_set_hook_function (server, GNUTLS_HANDSHAKE_ANY, GNUTLS_HOOK_POST, handshake_callback);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
- gnutls_certificate_set_verify_function (clientx509cred, client_callback);
-
- HANDSHAKE(client, server);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (pch_ok == 0)
- fail("Post client hello callback wasn't called\n");
-
- if (server_ok == 0)
- fail("Server certificate verify callback wasn't called\n");
-
- if (client_ok == 0)
- fail("Client certificate verify callback wasn't called\n");
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server, "NORMAL", NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+ gnutls_certificate_set_verify_function(serverx509cred,
+ server_callback);
+ gnutls_certificate_server_set_request(server, GNUTLS_CERT_REQUEST);
+ gnutls_handshake_set_post_client_hello_function(server,
+ post_client_hello_callback);
+ gnutls_handshake_set_hook_function(server, GNUTLS_HANDSHAKE_ANY,
+ GNUTLS_HOOK_POST,
+ handshake_callback);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+ gnutls_certificate_set_verify_function(clientx509cred,
+ client_callback);
+
+ HANDSHAKE(client, server);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (pch_ok == 0)
+ fail("Post client hello callback wasn't called\n");
+
+ if (server_ok == 0)
+ fail("Server certificate verify callback wasn't called\n");
+
+ if (client_ok == 0)
+ fail("Client certificate verify callback wasn't called\n");
}
diff --git a/tests/mini-x509-cas.c b/tests/mini-x509-cas.c
index 5e42093292..7b222ced67 100644
--- a/tests/mini-x509-cas.c
+++ b/tests/mini-x509-cas.c
@@ -35,127 +35,127 @@
/* Tests whether a very long CA list, that spans over multiple records
* is tolerated */
-const char* side;
+const char *side;
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN C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xWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzU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5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- int exit_code = EXIT_SUCCESS;
- const char* ca_file;
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN, ret;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- ca_file = getenv("CAFILE");
- if (ca_file == NULL)
- {
- ca_file = "certs/ca-certs.pem";
- }
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- ret = gnutls_certificate_set_x509_trust_file(serverx509cred, ca_file, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf(stderr, "%s\n", gnutls_strerror(ret));
- exit(1);
- }
-
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_certificate_server_set_request(server, GNUTLS_CERT_REQUEST);
- gnutls_priority_set_direct (server, "NORMAL", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug > 0)
- {
- if (exit_code == 0)
- puts ("Self-test successful");
- else
- puts ("Self-test failed");
- }
+ int exit_code = EXIT_SUCCESS;
+ const char *ca_file;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN, ret;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ ca_file = getenv("CAFILE");
+ if (ca_file == NULL) {
+ ca_file = "certs/ca-certs.pem";
+ }
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ ret =
+ gnutls_certificate_set_x509_trust_file(serverx509cred, ca_file,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "%s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_certificate_server_set_request(server, GNUTLS_CERT_REQUEST);
+ gnutls_priority_set_direct(server, "NORMAL", NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug > 0) {
+ if (exit_code == 0)
+ puts("Self-test successful");
+ else
+ puts("Self-test failed");
+ }
}
diff --git a/tests/mini-x509.c b/tests/mini-x509.c
index d05dbf821e..333d544df9 100644
--- a/tests/mini-x509.c
+++ b/tests/mini-x509.c
@@ -32,112 +32,114 @@
#include "utils.h"
#include "eagain-common.h"
-const char* side;
+const char *side;
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
- "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
- "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
- "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
- "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
- "-----END RSA PRIVATE KEY-----\n";
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
+ "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
+ "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- int exit_code = EXIT_SUCCESS;
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL:-CIPHER-ALL:+ARCFOUR-128", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug > 0)
- {
- if (exit_code == 0)
- puts ("Self-test successful");
- else
- puts ("Self-test failed");
- }
+ int exit_code = EXIT_SUCCESS;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server,
+ "NORMAL:-CIPHER-ALL:+ARCFOUR-128",
+ NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug > 0) {
+ if (exit_code == 0)
+ puts("Self-test successful");
+ else
+ puts("Self-test failed");
+ }
}
diff --git a/tests/mini-xssl.c b/tests/mini-xssl.c
index f448ca9644..c6d8c82dfc 100644
--- a/tests/mini-xssl.c
+++ b/tests/mini-xssl.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -57,196 +57,186 @@ static void terminate(void);
* decoding.
*/
-static time_t mytime (time_t * t)
+static time_t mytime(time_t * t)
{
- time_t then = 1359304177;
+ time_t then = 1359304177;
- if (t)
- *t = then;
+ if (t)
+ *t = then;
- return then;
+ return then;
}
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
// fprintf (stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d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AA4IBMQAesOgjGFi1zOYpA/N3gkUVRcBHDxmN7g2yOcqH\n"
+ "VfhFc+e4zhOehR11WCt2RgzNlnYVmV5zBmQBdTAt8Po/MVhLCDW1BULHlLvL0DFc\n"
+ "4sB1RlcGeQcCKQa4b+Q9VWf4f6TfuEWZQC5j5stiXjVgOqrOMrzKZ2eKWA4JsL9s\n"
+ "V+7ANSZE+hOt1X1mA8moyqe95U2Ecih+nFJSWSBd1WFiEzVnXv4FVWPXbH9HERDK\n"
+ "VbasjofWWmQO1YlQPishLgm1IbwqOkOk4sDgoLuUZ4GgP0DDeN6EmRDOzByrv+9u\n"
+ "f45Bl9IQf4IJNPLU9lEqjyMOydqT6kBi7fjV5ICuQZ4EeVJsOGuX7PqNyoDzJHLv\n"
+ "ferRfNLr6eQSHSxBhS0cVyDjb5gCawK6u7xTU+b7xikEie9k\n"
+ "-----END CERTIFICATE-----\n";
const gnutls_datum_t ca_cert = { ca_pem,
- sizeof (ca_pem)-1
+ sizeof(ca_pem) - 1
};
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICsDCCAWigAwIBAgIETeC0kjANBgkqhkiG9w0BAQsFADAZMRcwFQYDVQQDEw5H\n"
- "bnVUTFMgVGVzdCBDQTAeFw0xMTA1MjgwODM4NDNaFw0zODEwMTIwODM4NDZaMDEx\n"
- "LzAtBgNVBAMTJkdudVRMUyBUZXN0IHNlcnZlciAoRUNEU0EgY2VydGlmaWNhdGUp\n"
- "ME4wEAYHKoZIzj0CAQYFK4EEACEDOgAE0vMmf/W0rRoUqBxH5Uq+c/sR76ElmyZM\n"
- "e2zj3U9PRJ0maKstEOHkpaDaSU6s2Hyi9L88wS1ZX0ijgY0wgYowDAYDVR0TAQH/\n"
- "BAIwADAUBgNVHREEDTALgglsb2NhbGhvc3QwEwYDVR0lBAwwCgYIKwYBBQUHAwEw\n"
- "DwYDVR0PAQH/BAUDAweAADAdBgNVHQ4EFgQUJ97Q83IFpLgqeOnT1rX/J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Qw\n"
+ "HwYDVR0jBBgwFoAUTVa3agBY8WeS9KZ1VRuOUwED788wDQYJKoZIhvcNAQELBQAD\n"
+ "ggExAErP9z8CCwt7YwA+SHoulNjqcXsngeKAKN9fVgV/XuspG6L2nU1WZvCjjFj6\n"
+ "jggMbJSElyCuLZJKlTC/DihXUgRXyswOzg9qQ7dDv+V/Qi95XH5slXNzYxMQSdoA\n"
+ "IaULVVDZcMFMVSc+TyAchJ6XwUY9umiysz3lSOioMQCch4MA366ZNqqnq5OD4moH\n"
+ "1SUX8CbRjA6SLpvffexLTB2Af+mFi8ReTkXCwB1LGEH1HRp/XzBc+/F9mavy3g/6\n"
+ "Hnjf2E1h2GDYXcJCVfE+ArjNS+R94jJwRMFBvwD/x2hsvpSajDpO0+GIxlGGKdyh\n"
+ "7o4puz/BqHwSzX9h7I7RvFEogDUNUzLgHMdcjq5usnmQpdWNUP8Xs/WqLjML+/PT\n"
+ "+jyCwmll0lPlC2RqAx3pM1XrjjQ=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)-1
+ sizeof(server_cert_pem) - 1
};
static unsigned char server_key_pem[] =
- "-----BEGIN EC PRIVATE KEY-----\n"
- "MGgCAQEEHHX3xeBOGgIxxtuhhpbwdwZnJztR7+uZTHnYuL+gBwYFK4EEACGhPAM6\n"
- "AATS8yZ/9bStGhSoHEflSr5z+xHvoSWbJkx7bOPdT09EnSZoqy0Q4eSloNpJTqzY\n"
- "fKL0vzzBLVlfSA==\n"
- "-----END EC PRIVATE KEY-----\n";
+ "-----BEGIN EC PRIVATE KEY-----\n"
+ "MGgCAQEEHHX3xeBOGgIxxtuhhpbwdwZnJztR7+uZTHnYuL+gBwYFK4EEACGhPAM6\n"
+ "AATS8yZ/9bStGhSoHEflSr5z+xHvoSWbJkx7bOPdT09EnSZoqy0Q4eSloNpJTqzY\n"
+ "fKL0vzzBLVlfSA==\n" "-----END EC PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)-1
+ sizeof(server_key_pem) - 1
};
#define LINE1 "hello there people\n"
#define LINE2 "how are you doing today, all well?\n"
-static const char* test = NULL;
+static const char *test = NULL;
#define err_quit(r) {fail("%s: Error in line %d: %s\n", test, __LINE__, gnutls_strerror(r)); exit(1);}
-static void
-client (int fd, unsigned int vmethod, unsigned use_cert)
+static void client(int fd, unsigned int vmethod, unsigned use_cert)
{
- int ret;
- char *line = NULL;
- size_t line_len;
- xssl_cred_t cred;
- xssl_t sb;
- gnutls_cinput_st aux[6];
- unsigned int status;
- unsigned aux_size = 0;
-
- global_init ();
- gnutls_global_set_time_function (mytime);
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
- if (vmethod & GNUTLS_VMETHOD_GIVEN_CAS)
- {
- aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
- aux[aux_size].contents = GNUTLS_CINPUT_CAS;
- aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
- aux[aux_size].i1.mem = ca_cert;
- aux_size++;
- }
-
- if (use_cert != 0)
- {
- aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
- aux[aux_size].contents = GNUTLS_CINPUT_KEYPAIR;
- aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
- aux[aux_size].i1.mem = server_cert;
- aux[aux_size].i2.mem = server_key;
- aux_size++;
- }
-
- if (vmethod & GNUTLS_VMETHOD_TOFU)
- {
- aux[aux_size].type = GNUTLS_CINPUT_TYPE_FILE;
- aux[aux_size].contents = GNUTLS_CINPUT_TOFU_DB;
- aux[aux_size].i1.file = TOFU_DB_FILE;
- aux_size++;
- }
-
- ret = xssl_cred_init(&cred, vmethod, aux, aux_size);
- if (ret < 0)
- err_quit(ret);
-
- /* Initialize TLS session
- */
- ret = xssl_client_init(&sb, "localhost", NULL, (gnutls_transport_ptr_t)(long)fd,
- NULL, cred, &status, 0);
- if (ret < 0)
- {
- if (ret == GNUTLS_E_AUTH_ERROR)
- {
- gnutls_datum_t txt;
-
- gnutls_certificate_verification_status_print(status, GNUTLS_CRT_X509,
- &txt, 0);
-
- fprintf(stderr, "auth[%x]: %s\n", status, txt.data);
- gnutls_free(txt.data);
- }
- err_quit(ret);
- }
-
- ret = xssl_getline(sb, &line, &line_len);
- if (ret < 0)
- err_quit(ret);
-
- if (strcmp(line, LINE1) != 0)
- {
- fail("Error comparing first line\n");
- exit(1);
- }
-
- ret = xssl_getline(sb, &line, &line_len);
- if (ret < 0)
- err_quit(ret);
-
- if (strcmp(line, LINE2) != 0)
- {
- fail("Error comparing first line\n");
- exit(1);
- }
-
- gnutls_free(line);
-
- xssl_deinit(sb);
-
- close (fd);
-
- xssl_cred_deinit (cred);
-
- gnutls_global_deinit ();
+ int ret;
+ char *line = NULL;
+ size_t line_len;
+ xssl_cred_t cred;
+ xssl_t sb;
+ gnutls_cinput_st aux[6];
+ unsigned int status;
+ unsigned aux_size = 0;
+
+ global_init();
+ gnutls_global_set_time_function(mytime);
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+ if (vmethod & GNUTLS_VMETHOD_GIVEN_CAS) {
+ aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
+ aux[aux_size].contents = GNUTLS_CINPUT_CAS;
+ aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
+ aux[aux_size].i1.mem = ca_cert;
+ aux_size++;
+ }
+
+ if (use_cert != 0) {
+ aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
+ aux[aux_size].contents = GNUTLS_CINPUT_KEYPAIR;
+ aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
+ aux[aux_size].i1.mem = server_cert;
+ aux[aux_size].i2.mem = server_key;
+ aux_size++;
+ }
+
+ if (vmethod & GNUTLS_VMETHOD_TOFU) {
+ aux[aux_size].type = GNUTLS_CINPUT_TYPE_FILE;
+ aux[aux_size].contents = GNUTLS_CINPUT_TOFU_DB;
+ aux[aux_size].i1.file = TOFU_DB_FILE;
+ aux_size++;
+ }
+
+ ret = xssl_cred_init(&cred, vmethod, aux, aux_size);
+ if (ret < 0)
+ err_quit(ret);
+
+ /* Initialize TLS session
+ */
+ ret =
+ xssl_client_init(&sb, "localhost", NULL,
+ (gnutls_transport_ptr_t) (long) fd, NULL,
+ cred, &status, 0);
+ if (ret < 0) {
+ if (ret == GNUTLS_E_AUTH_ERROR) {
+ gnutls_datum_t txt;
+
+ gnutls_certificate_verification_status_print
+ (status, GNUTLS_CRT_X509, &txt, 0);
+
+ fprintf(stderr, "auth[%x]: %s\n", status,
+ txt.data);
+ gnutls_free(txt.data);
+ }
+ err_quit(ret);
+ }
+
+ ret = xssl_getline(sb, &line, &line_len);
+ if (ret < 0)
+ err_quit(ret);
+
+ if (strcmp(line, LINE1) != 0) {
+ fail("Error comparing first line\n");
+ exit(1);
+ }
+
+ ret = xssl_getline(sb, &line, &line_len);
+ if (ret < 0)
+ err_quit(ret);
+
+ if (strcmp(line, LINE2) != 0) {
+ fail("Error comparing first line\n");
+ exit(1);
+ }
+
+ gnutls_free(line);
+
+ xssl_deinit(sb);
+
+ close(fd);
+
+ xssl_cred_deinit(cred);
+
+ gnutls_global_deinit();
}
@@ -255,163 +245,154 @@ pid_t child;
static void terminate(void)
{
- kill(child, SIGTERM);
- exit(1);
+ kill(child, SIGTERM);
+ exit(1);
}
-static void
-server (int fd, unsigned vmethod)
+static void server(int fd, unsigned vmethod)
{
- int ret;
- xssl_cred_t cred;
- xssl_t sb;
- gnutls_cinput_st aux[6];
- unsigned aux_size = 0;
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (7);
- }
-
-
- aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
- aux[aux_size].contents = GNUTLS_CINPUT_KEYPAIR;
- aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
- aux[aux_size].i1.mem = server_cert;
- aux[aux_size].i2.mem = server_key;
- aux_size++;
-
- if (vmethod & GNUTLS_VMETHOD_GIVEN_CAS)
- {
- aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
- aux[aux_size].contents = GNUTLS_CINPUT_CAS;
- aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
- aux[aux_size].i1.mem = ca_cert;
- aux_size++;
- }
-
- ret = xssl_cred_init(&cred, vmethod, aux, aux_size);
- if (ret < 0)
- err_quit(ret);
-
- /* Initialize TLS session
- */
- ret = xssl_server_init(&sb, (gnutls_transport_ptr_t)(long)fd,
- NULL, cred, NULL, 0);
- if (ret < 0)
- err_quit(ret);
-
- ret = xssl_write(sb, LINE1, sizeof(LINE1)-1);
- if (ret < 0)
- err_quit(ret);
-
- ret = xssl_write(sb, LINE2, sizeof(LINE2)-1);
- if (ret < 0)
- err_quit(ret);
-
- ret = xssl_flush(sb);
- if (ret < 0)
- err_quit(ret);
-
- xssl_deinit(sb);
-
- close (fd);
-
- xssl_cred_deinit (cred);
-
- gnutls_global_deinit ();
+ int ret;
+ xssl_cred_t cred;
+ xssl_t sb;
+ gnutls_cinput_st aux[6];
+ unsigned aux_size = 0;
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(7);
+ }
+
+
+ aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
+ aux[aux_size].contents = GNUTLS_CINPUT_KEYPAIR;
+ aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
+ aux[aux_size].i1.mem = server_cert;
+ aux[aux_size].i2.mem = server_key;
+ aux_size++;
+
+ if (vmethod & GNUTLS_VMETHOD_GIVEN_CAS) {
+ aux[aux_size].type = GNUTLS_CINPUT_TYPE_MEM;
+ aux[aux_size].contents = GNUTLS_CINPUT_CAS;
+ aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
+ aux[aux_size].i1.mem = ca_cert;
+ aux_size++;
+ }
+
+ ret = xssl_cred_init(&cred, vmethod, aux, aux_size);
+ if (ret < 0)
+ err_quit(ret);
+
+ /* Initialize TLS session
+ */
+ ret = xssl_server_init(&sb, (gnutls_transport_ptr_t) (long) fd,
+ NULL, cred, NULL, 0);
+ if (ret < 0)
+ err_quit(ret);
+
+ ret = xssl_write(sb, LINE1, sizeof(LINE1) - 1);
+ if (ret < 0)
+ err_quit(ret);
+
+ ret = xssl_write(sb, LINE2, sizeof(LINE2) - 1);
+ if (ret < 0)
+ err_quit(ret);
+
+ ret = xssl_flush(sb);
+ if (ret < 0)
+ err_quit(ret);
+
+ xssl_deinit(sb);
+
+ close(fd);
+
+ xssl_cred_deinit(cred);
+
+ gnutls_global_deinit();
}
-static void start (unsigned vc, unsigned vs, unsigned ccert)
+static void start(unsigned vc, unsigned vs, unsigned ccert)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], vs);
- waitpid(-1, NULL, 0);
- //kill(child, SIGTERM);
- }
- else
- {
- close(fd[0]);
- client (fd[1], vc, ccert);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], vs);
+ waitpid(-1, NULL, 0);
+ //kill(child, SIGTERM);
+ } else {
+ close(fd[0]);
+ client(fd[1], vc, ccert);
+ exit(0);
+ }
}
static void ch_handler(int sig)
{
-int status = 0;
-
- waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n", WEXITSTATUS(status));
- terminate();
- }
- return;
+ int status = 0;
+
+ waitpid(-1, &status, 0);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fail("Child died with sigsegv\n");
+ else
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ terminate();
+ }
+ return;
}
-void
-doit (void)
+void doit(void)
{
- signal(SIGCHLD, ch_handler);
- signal(SIGPIPE, SIG_IGN);
-
- test = "test1: no auth";
- if (debug)
- fprintf(stderr, "running %s", test);
- start(GNUTLS_VMETHOD_NO_AUTH, GNUTLS_VMETHOD_NO_AUTH, 0);
-
- test = "test2: server auth";
- if (debug)
- fprintf(stderr, "running %s", test);
- start(GNUTLS_VMETHOD_GIVEN_CAS, GNUTLS_VMETHOD_NO_AUTH, 0);
-
- test = "test3: mutual auth";
- if (debug)
- fprintf(stderr, "running %s", test);
- start(GNUTLS_VMETHOD_GIVEN_CAS, GNUTLS_VMETHOD_GIVEN_CAS, 1);
-
- remove(TOFU_DB_FILE);
- test = "test4: trust on first use p1";
- if (debug)
- fprintf(stderr, "running %s", test);
- start(GNUTLS_VMETHOD_TOFU, GNUTLS_VMETHOD_NO_AUTH, 0);
-
- test = "test5: trust on first use p2";
- if (debug)
- fprintf(stderr, "running %s", test);
- start(GNUTLS_VMETHOD_TOFU, GNUTLS_VMETHOD_NO_AUTH, 0);
- remove(TOFU_DB_FILE);
+ signal(SIGCHLD, ch_handler);
+ signal(SIGPIPE, SIG_IGN);
+
+ test = "test1: no auth";
+ if (debug)
+ fprintf(stderr, "running %s", test);
+ start(GNUTLS_VMETHOD_NO_AUTH, GNUTLS_VMETHOD_NO_AUTH, 0);
+
+ test = "test2: server auth";
+ if (debug)
+ fprintf(stderr, "running %s", test);
+ start(GNUTLS_VMETHOD_GIVEN_CAS, GNUTLS_VMETHOD_NO_AUTH, 0);
+
+ test = "test3: mutual auth";
+ if (debug)
+ fprintf(stderr, "running %s", test);
+ start(GNUTLS_VMETHOD_GIVEN_CAS, GNUTLS_VMETHOD_GIVEN_CAS, 1);
+
+ remove(TOFU_DB_FILE);
+ test = "test4: trust on first use p1";
+ if (debug)
+ fprintf(stderr, "running %s", test);
+ start(GNUTLS_VMETHOD_TOFU, GNUTLS_VMETHOD_NO_AUTH, 0);
+
+ test = "test5: trust on first use p2";
+ if (debug)
+ fprintf(stderr, "running %s", test);
+ start(GNUTLS_VMETHOD_TOFU, GNUTLS_VMETHOD_NO_AUTH, 0);
+ remove(TOFU_DB_FILE);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/moredn.c b/tests/moredn.c
index 994a99522e..528be496e4 100644
--- a/tests/moredn.c
+++ b/tests/moredn.c
@@ -38,69 +38,72 @@
#include "utils.h"
static const char cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgw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q5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
static const gnutls_datum_t cert_datum = { (unsigned char *) cert_pem,
- sizeof (cert_pem)
+ sizeof(cert_pem)
};
-void
-doit (void)
+void doit(void)
{
- gnutls_x509_crt_t cert;
- gnutls_x509_dn_t sdn, dn2;
- unsigned char buf[8192], buf2[8192];
- size_t buflen, buf2len;
- gnutls_datum_t datum;
- int rv;
+ gnutls_x509_crt_t cert;
+ gnutls_x509_dn_t sdn, dn2;
+ unsigned char buf[8192], buf2[8192];
+ size_t buflen, buf2len;
+ gnutls_datum_t datum;
+ int rv;
- global_init ();
+ global_init();
- if (gnutls_x509_crt_init (&cert) != 0)
- fail ("cert init failure\n");
+ if (gnutls_x509_crt_init(&cert) != 0)
+ fail("cert init failure\n");
- if (gnutls_x509_crt_import (cert, &cert_datum, GNUTLS_X509_FMT_PEM) != 0)
- fail ("FAIL: could not import PEM cert\n");
+ if (gnutls_x509_crt_import(cert, &cert_datum, GNUTLS_X509_FMT_PEM)
+ != 0)
+ fail("FAIL: could not import PEM cert\n");
- if (gnutls_x509_crt_get_subject (cert, &sdn) != 0)
- fail ("FAIL: could not get subject DN.\n");
+ if (gnutls_x509_crt_get_subject(cert, &sdn) != 0)
+ fail("FAIL: could not get subject DN.\n");
- buflen = sizeof buf;
- rv = gnutls_x509_dn_export (sdn, GNUTLS_X509_FMT_DER, buf, &buflen);
- if (rv != 0)
- fail ("FAIL: could not export subject DN: %s\n", gnutls_strerror (rv));
+ buflen = sizeof buf;
+ rv = gnutls_x509_dn_export(sdn, GNUTLS_X509_FMT_DER, buf, &buflen);
+ if (rv != 0)
+ fail("FAIL: could not export subject DN: %s\n",
+ gnutls_strerror(rv));
- if (gnutls_x509_dn_init (&dn2) != 0)
- fail ("FAIL: DN init.\n");
+ if (gnutls_x509_dn_init(&dn2) != 0)
+ fail("FAIL: DN init.\n");
- datum.data = buf;
- datum.size = buflen;
+ datum.data = buf;
+ datum.size = buflen;
- if (gnutls_x509_dn_import (dn2, &datum) != 0)
- fail ("FAIL: re-import subject DN.\n");
+ if (gnutls_x509_dn_import(dn2, &datum) != 0)
+ fail("FAIL: re-import subject DN.\n");
- buf2len = sizeof buf2;
- rv = gnutls_x509_dn_export (dn2, GNUTLS_X509_FMT_DER, buf2, &buf2len);
- if (rv != 0)
- fail ("FAIL: could not export subject DN: %s\n", gnutls_strerror (rv));
+ buf2len = sizeof buf2;
+ rv = gnutls_x509_dn_export(dn2, GNUTLS_X509_FMT_DER, buf2,
+ &buf2len);
+ if (rv != 0)
+ fail("FAIL: could not export subject DN: %s\n",
+ gnutls_strerror(rv));
- if (buflen == buf2len && memcmp (buf, buf2, buflen) != 0)
- fail ("FAIL: export/import/export differ.\n");
+ if (buflen == buf2len && memcmp(buf, buf2, buflen) != 0)
+ fail("FAIL: export/import/export differ.\n");
- gnutls_x509_dn_deinit (dn2);
+ gnutls_x509_dn_deinit(dn2);
- gnutls_x509_crt_deinit (cert);
+ gnutls_x509_crt_deinit(cert);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
diff --git a/tests/mpi.c b/tests/mpi.c
index 3f7e0e725f..40788fd72d 100644
--- a/tests/mpi.c
+++ b/tests/mpi.c
@@ -32,58 +32,58 @@
#include "../lib/gnutls_errors.h"
#include "../lib/debug.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
-#define RND_BITS 510 /* not multiple of 8 */
-void
-doit (void)
+#define RND_BITS 510 /* not multiple of 8 */
+void doit(void)
{
- int rc;
- bigint_t n1, n2, n3, n4;
+ int rc;
+ bigint_t n1, n2, n3, n4;
- global_init ();
+ global_init();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (99);
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(99);
- n1 = _gnutls_mpi_new (1000);
- if (n1 == NULL)
- fail ("mpi_new failed\n");
+ n1 = _gnutls_mpi_new(1000);
+ if (n1 == NULL)
+ fail("mpi_new failed\n");
- n2 = _gnutls_mpi_set_ui (NULL, 2);
- if (n2 == NULL)
- fail ("mpi_set_ui failed\n");
+ n2 = _gnutls_mpi_set_ui(NULL, 2);
+ if (n2 == NULL)
+ fail("mpi_set_ui failed\n");
- n3 = _gnutls_mpi_set_ui (NULL, 5);
- if (n3 == NULL)
- fail ("mpi_set_ui failed\n");
+ n3 = _gnutls_mpi_set_ui(NULL, 5);
+ if (n3 == NULL)
+ fail("mpi_set_ui failed\n");
- _gnutls_mpi_randomize (n1, RND_BITS, GNUTLS_RND_NONCE);
+ _gnutls_mpi_randomize(n1, RND_BITS, GNUTLS_RND_NONCE);
- _gnutls_mpi_log ("rand:", n1);
+ _gnutls_mpi_log("rand:", n1);
- rc = _gnutls_mpi_get_nbits (n1);
- if (rc > RND_BITS)
- fail ("mpi_get_nbits failed... returned %d\n", rc);
+ rc = _gnutls_mpi_get_nbits(n1);
+ if (rc > RND_BITS)
+ fail("mpi_get_nbits failed... returned %d\n", rc);
- n4 = _gnutls_mpi_addm (NULL, n1, n3, n2);
- if (n4 == NULL)
- fail ("mpi_set_ui failed\n");
+ n4 = _gnutls_mpi_addm(NULL, n1, n3, n2);
+ if (n4 == NULL)
+ fail("mpi_set_ui failed\n");
- if (_gnutls_mpi_cmp_ui (n4, 0) != 0 && _gnutls_mpi_cmp_ui (n4, 1) != 0)
- fail ("mpi_cmp_ui failed\n");
+ if (_gnutls_mpi_cmp_ui(n4, 0) != 0
+ && _gnutls_mpi_cmp_ui(n4, 1) != 0)
+ fail("mpi_cmp_ui failed\n");
- _gnutls_mpi_release (&n1);
- _gnutls_mpi_release (&n2);
- _gnutls_mpi_release (&n3);
- _gnutls_mpi_release (&n4);
+ _gnutls_mpi_release(&n1);
+ _gnutls_mpi_release(&n2);
+ _gnutls_mpi_release(&n3);
+ _gnutls_mpi_release(&n4);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- if (debug) success ("mpi ops ok\n");
+ if (debug)
+ success("mpi ops ok\n");
}
diff --git a/tests/nul-in-x509-names.c b/tests/nul-in-x509-names.c
index aac7594bc8..208bd3899b 100644
--- a/tests/nul-in-x509-names.c
+++ b/tests/nul-in-x509-names.c
@@ -36,118 +36,113 @@
certs that trigger this bug. */
static char badguy_nul_cn_data[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIDjTCCAnWgAwIBAgIBATANBgkqhkiG9w0BAQUFADB0MQswCQYDVQQGEwJHQjES\n"
- "MBAGA1UECBMJQmVya3NoaXJlMRAwDgYDVQQHEwdOZXdidXJ5MRcwFQYDVQQKEw5N\n"
- "eSBDb21wYW55IEx0ZDELMAkGA1UECxMCQ0ExGTAXBgNVBAMTEE5VTEwtZnJpZW5k\n"
- "bHkgQ0EwHhcNMDkwODA0MDczMzQzWhcNMTkwODAyMDczMzQzWjAjMSEwHwYDVQQD\n"
- "Exh3d3cuYmFuay5jb20ALmJhZGd1eS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IB\n"
- "DwAwggEKAoIBAQDNJnCWqaZdPpztDwgVWnwXJWhorxO5rUH6ElTihHJ9WNHiQELB\n"
- "We0FPaoQU3AAiDp3oMBWnqx9ISpxRFEIvBcH2qijdtxRvBuK9gIaVb9GtERrJ16+\n"
- "5ReLVrLGgjYRg6i/9y8NF/bNR7VvK6ZBto0zX+rqi7Ea4pk4/1lbCqFxE8o3P7mw\n"
- "HpGayJM1DErgnfTSYcdOW0EKfDFUmdv1Zc6A08ICN2T9VBJ76qyFWVwX4S720Kjy\n"
- "0C6UWS/Cpl/aB957LhQH7eQnJDedCS6x+VpIuYAkQ+bLx24139VpNP/m1p7odmZu\n"
- "X1kBPJY77HILPB6VD85oE5wi3Ru1RChQSgV/AgMBAAGjezB5MAkGA1UdEwQCMAAw\n"
- "LAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0G\n"
- "A1UdD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vK6ZBto0zX+rqi7Ea4pk4/1lbCqFxE8o3P7mw\n"
+ "HpGayJM1DErgnfTSYcdOW0EKfDFUmdv1Zc6A08ICN2T9VBJ76qyFWVwX4S720Kjy\n"
+ "0C6UWS/Cpl/aB957LhQH7eQnJDedCS6x+VpIuYAkQ+bLx24139VpNP/m1p7odmZu\n"
+ "X1kBPJY77HILPB6VD85oE5wi3Ru1RChQSgV/AgMBAAGjezB5MAkGA1UdEwQCMAAw\n"
+ "LAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0G\n"
+ "A1UdDgQWBBQzFSS+2mY6BovZJzQ6r2JA5JVmXTAfBgNVHSMEGDAWgBQKaTlfnTAE\n"
+ "GAguAg7m6p2yJvbiajANBgkqhkiG9w0BAQUFAAOCAQEAMmUjH8jZU4SC0ArrFFEk\n"
+ "A7xsGypa/hvw6GkMKxmGz38ydtgr0s+LxNG2W5xgo5kuknIGzt6L0qLSiXwTqQtO\n"
+ "vhIJ5dYoOqynJlaUfxPuZH3elGB1wbxVl9SqE44C2LCwcFOuGFPOqrIshT7j8+Em\n"
+ "8/pc7vh7C8Y5tQQzXq64Xg5mzKjAag3sYMHF2TnqvRuPHH0WOLHoyDcBqkuZ3+QP\n"
+ "EL5h7prPzScFRgBg2Gp0CDI8i5ABagczDGyQ2+r7ahcadrtzFCfhpH7V3TCxXfIO\n"
+ "qtSy1Uz2T5EqB/Q3wc9IGcX+fpKWqN9QajGSo7EU/kHMSWKYTerFugUtScMicu9B\n"
+ "CQ==\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t badguy_nul_cn = {
- (void*)badguy_nul_cn_data, sizeof (badguy_nul_cn_data)
+ (void *) badguy_nul_cn_data, sizeof(badguy_nul_cn_data)
};
static char badguy_nul_san_data[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIDrTCCApWgAwIBAgIBADANBgkqhkiG9w0BAQUFADB0MQswCQYDVQQGEwJHQjES\n"
- "MB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CGSAGG\n"
+ "+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQU\n"
+ "MxUkvtpmOgaL2Sc0Oq9iQOSVZl0wHwYDVR0jBBgwFoAUCmk5X50wBBgILgIO5uqd\n"
+ "sib24mowJgYDVR0RBB8wHYIbd3d3LmJhbmsuY29tAHd3dy5iYWRndXkuY29tMA0G\n"
+ "CSqGSIb3DQEBBQUAA4IBAQAnbn2zqYZSV2qgxjBsHpQJp2+t/hGfvjKNAXuLlGbX\n"
+ "fLaxkPzk9bYyvGxxI7EYiNZHvNoHx15GcTrmQG7Bfx1WlnBl2FGp3J6lBgCY5x4Q\n"
+ "vIK6AOVOog8+7Irdb8bJweztbXwxPmaHR6GLFTwhfuwheD0hcHK6cMNk+B1P2dAn\n"
+ "PD5+olmuvprTAESncjrjP8ibxY+xlP4AD264FIjxA1CRUa/wHve4WqRXNS3xrciu\n"
+ "3SlhFH3q0TSAXBv960PcIW3GRPk7VHbEkVuspI5y59gk/6dawO8nw9fk+X9VjQ0w\n"
+ "7KLZbch29L6UPRIySpFP28PndgdaEpcYtxUAmFkhiT41\n"
+ "-----END CERTIFICATE-----\n";
const gnutls_datum_t badguy_nul_san = {
- (void*)badguy_nul_san_data, sizeof (badguy_nul_san_data)
+ (void *) badguy_nul_san_data, sizeof(badguy_nul_san_data)
};
-void
-doit (void)
+void doit(void)
{
- gnutls_x509_crt_t crt;
- int ret;
-
- ret = global_init ();
- if (ret < 0)
- {
- fail ("global_init");
- exit (1);
- }
-
- ret = gnutls_x509_crt_init (&crt);
- if (ret != 0)
- {
- fail ("gnutls_x509_crt_init");
- exit (1);
- }
-
- ret = gnutls_x509_crt_import (crt, &badguy_nul_cn, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import");
- exit (1);
- }
-
- ret = gnutls_x509_crt_check_hostname (crt, "www.bank.com");
- if (ret == 0)
- {
- if (debug)
- success ("gnutls_x509_crt_check_hostname OK (NUL-IN-CN)");
- }
- else
- {
- fail ("gnutls_x509_crt_check_hostname BROKEN (NUL-IN-CN)");
- }
-
- ret = gnutls_x509_crt_import (crt, &badguy_nul_san, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import");
- exit (1);
- }
-
- ret = gnutls_x509_crt_check_hostname (crt, "www.bank.com");
- if (ret == 0)
- {
- if (debug)
- success ("gnutls_x509_crt_check_hostname OK (NUL-IN-SAN)");
- }
- else
- {
- fail ("gnutls_x509_crt_check_hostname BROKEN (NUL-IN-SAN)");
- }
-
- gnutls_x509_crt_deinit (crt);
-
- gnutls_global_deinit ();
+ gnutls_x509_crt_t crt;
+ int ret;
+
+ ret = global_init();
+ if (ret < 0) {
+ fail("global_init");
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_init(&crt);
+ if (ret != 0) {
+ fail("gnutls_x509_crt_init");
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(crt, &badguy_nul_cn,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import");
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_check_hostname(crt, "www.bank.com");
+ if (ret == 0) {
+ if (debug)
+ success
+ ("gnutls_x509_crt_check_hostname OK (NUL-IN-CN)");
+ } else {
+ fail("gnutls_x509_crt_check_hostname BROKEN (NUL-IN-CN)");
+ }
+
+ ret =
+ gnutls_x509_crt_import(crt, &badguy_nul_san,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import");
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_check_hostname(crt, "www.bank.com");
+ if (ret == 0) {
+ if (debug)
+ success
+ ("gnutls_x509_crt_check_hostname OK (NUL-IN-SAN)");
+ } else {
+ fail("gnutls_x509_crt_check_hostname BROKEN (NUL-IN-SAN)");
+ }
+
+ gnutls_x509_crt_deinit(crt);
+
+ gnutls_global_deinit();
}
diff --git a/tests/ocsp.c b/tests/ocsp.c
index 9354897382..7269d9364e 100644
--- a/tests/ocsp.c
+++ b/tests/ocsp.c
@@ -33,28 +33,27 @@
#include "utils.h"
-static time_t mytime (time_t * t)
+static time_t mytime(time_t * t)
{
- time_t then = 1332548220;
+ time_t then = 1332548220;
- if (t)
- *t = then;
+ if (t)
+ *t = then;
- return then;
+ return then;
}
/* sample request */
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
#define REQ1 "\x30\x67\x30\x65\x30\x3e\x30\x3c\x30\x3a\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14\x13\x9d\xa0\x9e\xf4\x32\xab\x8f\xe2\x89\x56\x67\xfa\xd0\xd4\xe3\x35\x86\x71\xb9\x04\x14\x5d\xa7\xdd\x70\x06\x51\x32\x7e\xe7\xb6\x6d\xb3\xb5\xe5\xe0\x60\xea\x2e\x4d\xef\x02\x01\x1d\xa2\x23\x30\x21\x30\x1f\x06\x09\x2b\x06\x01\x05\x05\x07\x30\x01\x02\x04\x12\x04\x10\x35\xc5\xe3\x50\xc3\xcf\x04\x33\xcc\x9e\x06\x3a\x9a\x18\x80\xcc"
static const gnutls_datum_t req1 =
- { (unsigned char *) REQ1, sizeof (REQ1) - 1 };
+ { (unsigned char *) REQ1, sizeof(REQ1) - 1 };
#define REQ1INFO \
"OCSP Request Information:\n" \
@@ -79,7 +78,7 @@ static const gnutls_datum_t req1 =
#define RESP1 "\x30\x03\x0a\x01\x01"
static const gnutls_datum_t resp1 =
- { (unsigned char*) RESP1, sizeof (RESP1) - 1 };
+ { (unsigned char *) RESP1, sizeof(RESP1) - 1 };
#define RESP1INFO \
"OCSP Response Information:\n" \
@@ -126,1352 +125,1228 @@ static const gnutls_datum_t resp1 =
/* cut */
static const gnutls_datum_t resp2 =
- { (unsigned char*) RESP2, sizeof (RESP2) - 1 };
+ { (unsigned char *) RESP2, sizeof(RESP2) - 1 };
static unsigned char issuer_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIDuDCCAqCgAwIBAgIBADANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJDSDEZ\n"
- "MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS\n"
- "b290IENBMB4XDTA0MDkxMDEwMDExOFoXDTE5MDkwNzEwMDExOFowRTELMAkGA1UE\n"
- "BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u\n"
- "Z1N3YW4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/y\n"
- "X2LqPVZuWLPIeknK86xhz6ljd3NNhC2z+P1uoCP3sBMuZiZQEjFzhnKcbXxCeo2f\n"
- "FnvhOOjrrisSuVkzuu82oxXD3fIkzuS7m9V4E10EZzgmKWIf+WuNRfbgAuUINmLc\n"
- "4YGAXBQLPyzpP4Ou48hhz/YQo58Bics6PHy5v34qCVROIXDvqhj91P8g+pS+F21/\n"
- "7P+CH2jRcVIEHZtG8M/PweTPQ95dPzpYd2Ov6SZ/U7EWmbMmT8VcUYn1aChxFmy5\n"
- "gweVBWlkH6MP+1DeE0/tL5c87xo5KCeGK8Tdqpe7sBRC4pPEEHDQciTUvkeuJ1Pr\n"
- "K+1LwdqRxo7HgMRiDw8CAwEAAaOBsjCBrzASBgNVHRMBAf8ECDAGAQH/AgEBMAsG\n"
- "A1UdDwQEAwIBBjAdBgNVHQ4EFgQUXafdcAZRMn7ntm2zteXgYOouTe8wbQYDVR0j\n"
- "BGYwZIAUXafdcAZRMn7ntm2zteXgYOouTe+hSaRHMEUxCzAJBgNVBAYTAkNIMRkw\n"
- "FwYDVQQKExBMaW51eCBzdHJvbmdTd2FuMRswGQYDVQQDExJzdHJvbmdTd2FuIFJv\n"
- "b3QgQ0GCAQAwDQYJKoZIhvcNAQELBQADggEBACOSmqEBtBLR9aV3UyCI8gmzR5in\n"
- "Lte9aUXXS+qis6F2h2Stf4sN+Nl6Gj7REC6SpfEH4wWdwiUL5J0CJhyoOjQuDl3n\n"
- "1Dw3dE4/zqMZdyDKEYTU75TmvusNJBdGsLkrf7EATAjoi/nrTOYPPhSUZvPp/D+Y\n"
- "vORJ9Ej51GXlK1nwEB5iA8+tDYniNQn6BD1MEgIejzK+fbiy7braZB1kqhoEr2Si\n"
- "7luBSnU912sw494E88a2EWbmMvg2TVHPNzCpVkpNk7kifCiwmw9VldkqYy9y/lCa\n"
- "Epyp7lTfKw7cbD04Vk8QJW782L6Csuxkl346b17wmOqn8AZips3tFsuAY3w=\n"
- "-----END CERTIFICATE-----\n";
-const gnutls_datum_t issuer_data = { issuer_pem, sizeof (issuer_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIDuDCCAqCgAwIBAgIBADANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJDSDEZ\n"
+ "MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS\n"
+ "b290IENBMB4XDTA0MDkxMDEwMDExOFoXDTE5MDkwNzEwMDExOFowRTELMAkGA1UE\n"
+ "BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u\n"
+ "Z1N3YW4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/y\n"
+ "X2LqPVZuWLPIeknK86xhz6ljd3NNhC2z+P1uoCP3sBMuZiZQEjFzhnKcbXxCeo2f\n"
+ "FnvhOOjrrisSuVkzuu82oxXD3fIkzuS7m9V4E10EZzgmKWIf+WuNRfbgAuUINmLc\n"
+ "4YGAXBQLPyzpP4Ou48hhz/YQo58Bics6PHy5v34qCVROIXDvqhj91P8g+pS+F21/\n"
+ "7P+CH2jRcVIEHZtG8M/PweTPQ95dPzpYd2Ov6SZ/U7EWmbMmT8VcUYn1aChxFmy5\n"
+ "gweVBWlkH6MP+1DeE0/tL5c87xo5KCeGK8Tdqpe7sBRC4pPEEHDQciTUvkeuJ1Pr\n"
+ "K+1LwdqRxo7HgMRiDw8CAwEAAaOBsjCBrzASBgNVHRMBAf8ECDAGAQH/AgEBMAsG\n"
+ "A1UdDwQEAwIBBjAdBgNVHQ4EFgQUXafdcAZRMn7ntm2zteXgYOouTe8wbQYDVR0j\n"
+ "BGYwZIAUXafdcAZRMn7ntm2zteXgYOouTe+hSaRHMEUxCzAJBgNVBAYTAkNIMRkw\n"
+ "FwYDVQQKExBMaW51eCBzdHJvbmdTd2FuMRswGQYDVQQDExJzdHJvbmdTd2FuIFJv\n"
+ "b3QgQ0GCAQAwDQYJKoZIhvcNAQELBQADggEBACOSmqEBtBLR9aV3UyCI8gmzR5in\n"
+ "Lte9aUXXS+qis6F2h2Stf4sN+Nl6Gj7REC6SpfEH4wWdwiUL5J0CJhyoOjQuDl3n\n"
+ "1Dw3dE4/zqMZdyDKEYTU75TmvusNJBdGsLkrf7EATAjoi/nrTOYPPhSUZvPp/D+Y\n"
+ "vORJ9Ej51GXlK1nwEB5iA8+tDYniNQn6BD1MEgIejzK+fbiy7braZB1kqhoEr2Si\n"
+ "7luBSnU912sw494E88a2EWbmMvg2TVHPNzCpVkpNk7kifCiwmw9VldkqYy9y/lCa\n"
+ "Epyp7lTfKw7cbD04Vk8QJW782L6Csuxkl346b17wmOqn8AZips3tFsuAY3w=\n"
+ "-----END CERTIFICATE-----\n";
+const gnutls_datum_t issuer_data = { issuer_pem, sizeof(issuer_pem) };
static unsigned char subject_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIEIjCCAwqgAwIBAgIBHTANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJDSDEZ\n"
- "MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiB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qzKAqMBbIHFW8OOnh+nEY4IF5AzkZnFrw12G\n"
+ "I72Z882pw97lyKwZhSz/GMQFBJx+rnNdw5P1IJwTlG5PUdoDCte/Mcr1iiA+zOov\n"
+ "x55x1GoGxduoXWU5egrf1MtalRf9Pc8Xr4q3WEKTAmsZrVECAwEAAaOCAQYwggEC\n"
+ "MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgOoMB0GA1UdDgQWBBQfoamI2WSMtaCiVGQ5\n"
+ "tPI9dF1ufDBtBgNVHSMEZjBkgBRdp91wBlEyfue2bbO15eBg6i5N76FJpEcwRTEL\n"
+ "MAkGA1UEBhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMT\n"
+ "EnN0cm9uZ1N3YW4gUm9vdCBDQYIBADAfBgNVHREEGDAWgRRjYXJvbEBzdHJvbmdz\n"
+ "d2FuLm9yZzA5BgNVHR8EMjAwMC6gLKAqhihodHRwOi8vY3JsLnN0cm9uZ3N3YW4u\n"
+ "b3JnL3N0cm9uZ3N3YW4uY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQC8pqX3KrSzKeul\n"
+ "GdzydAV4hGwYB3WiB02oJ2nh5MJBu7J0Kn4IVkvLUHSSZhSRxx55tQZfdYqtXVS7\n"
+ "ZuyG+6rV7sb595SIRwfkLAdjbvv0yZIl4xx8j50K3yMR+9aXW1NSGPEkb8BjBUMr\n"
+ "F2kjGTOqomo8OIzyI369z9kJrtEhnS37nHcdpewZC1wHcWfJ6wd9wxmz2dVXmgVQ\n"
+ "L2BjXd/BcpLFaIC4h7jMXQ5FURjnU7K9xSa4T8PpR6FrQhOcIYBXAp94GiM8JqmK\n"
+ "ZBGUpeP+3cy4i3DV18Kyr64Q4XZlzhZClNE43sgMqiX88dc3znpDzT7T51j+d+9k\n"
+ "Rf5Z0GOR\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t subject_data = { subject_pem, sizeof(subject_pem) };
/* For testing verify functions. */
#define BLOG_RESP "\x30\x82\x06\xF8\x0A\x01\x00\xA0\x82\x06\xF1\x30\x82\x06\xED\x06\x09\x2B\x06\x01\x05\x05\x07\x30\x01\x01\x04\x82\x06\xDE\x30\x82\x06\xDA\x30\x82\x01\x25\xA1\x7E\x30\x7C\x31\x0B\x30\x09\x06\x03\x55\x04\x06\x13\x02\x41\x55\x31\x0C\x30\x0A\x06\x03\x55\x04\x08\x13\x03\x4E\x53\x57\x31\x0F\x30\x0D\x06\x03\x55\x04\x07\x13\x06\x53\x79\x64\x6E\x65\x79\x31\x14\x30\x12\x06\x03\x55\x04\x0A\x13\x0B\x43\x41\x63\x65\x72\x74\x20\x49\x6E\x63\x2E\x31\x1E\x30\x1C\x06\x03\x55\x04\x0B\x13\x15\x53\x65\x72\x76\x65\x72\x20\x41\x64\x6D\x69\x6E\x69\x73\x74\x72\x61\x74\x69\x6F\x6E\x31\x18\x30\x16\x06\x03\x55\x04\x03\x13\x0F\x6F\x63\x73\x70\x2E\x63\x61\x63\x65\x72\x74\x2E\x6F\x72\x67\x18\x0F\x32\x30\x31\x32\x30\x31\x31\x33\x30\x38\x35\x30\x34\x32\x5A\x30\x66\x30\x64\x30\x3C\x30\x09\x06\x05\x2B\x0E\x03\x02\x1A\x05\x00\x04\x14\xF2\x2A\x62\x16\x93\xA6\xDA\x5A\xD0\xB9\x8D\x3A\x13\x5E\x35\xD1\xEB\x18\x36\x61\x04\x14\x75\xA8\x71\x60\x4C\x88\x13\xF0\x78\xD9\x89\x77\xB5\x6D\xC5\x89\xDF\xBC\xB1\x7A\x02\x03\x00\xBC\xE0\x80\x00\x18\x0F\x32\x30\x31\x32\x30\x31\x31\x33\x30\x37\x32\x30\x34\x39\x5A\xA0\x11\x18\x0F\x32\x30\x31\x32\x30\x31\x31\x35\x30\x38\x35\x30\x34\x32\x5A\xA1\x2A\x30\x28\x30\x26\x06\x09\x2B\x06\x01\x05\x05\x07\x30\x01\x02\x04\x19\x04\x17\x73\x69\xD2\xC5\x6F\xC7\x7E\x2E\xB0\x2F\xCC\xC3\xE2\x80\xD6\x2A\xCE\xD3\xDE\x8F\x27\x1B\xB2\x30\x0D\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x05\x05\x00\x03\x82\x01\x01\x00\x3E\x50\x9D\xE9\xA2\xE0\xCA\x33\x88\x9B\x28\x7E\xE7\xA4\xAF\xDA\xBB\x75\x2D\xD9\x66\xA6\xD5\xFA\x17\x56\xC0\x3B\xDD\x74\xB6\x7E\x42\x2C\x28\xD0\x73\x91\x54\x69\xFA\xCF\xD8\xC7\x74\x1C\x5D\xBC\x8E\xCD\xE3\x0E\xD5\x3F\x80\x71\x9C\x95\x53\xC4\xD1\x95\x63\x5D\x72\xCE\xCC\x77\x9D\x7C\xAD\x47\x3F\x34\xDA\x90\x80\xC5\x15\xE1\x2B\xEE\x98\x57\xA3\xA7\x9F\xA2\xC3\xF5\x5E\xF7\x13\x26\x52\xDA\x09\x38\x5B\x18\x91\x07\x38\xCF\x09\xDA\x08\xED\x80\x4F\x26\x3A\xB9\xBE\xF6\xED\x65\x3F\xB1\x3A\x6D\xA3\x87\x22\xA3\x2A\xA5\x99\xCC\x06\xF3\x5A\xD5\x34\xFB\x9E\x32\x28\xC3\x3E\xF4\xAF\x33\x02\xCF\x6A\x74\x73\x17\x24\x17\x41\x0D\x7E\x86\x79\x83\x34\xE8\x82\x0A\x0D\x21\xED\xCB\x3B\xB7\x31\x64\xC9\xB6\x1E\xC7\x0C\x75\xCE\xBA\xB7\xDC\xB2\x67\x96\x2B\xAD\xBF\x86\x22\x81\x54\x66\xBA\x68\x89\xD7\x7E\x35\x60\x93\xEC\x6B\xD8\x59\x23\xA0\xD0\x95\x55\x8F\x93\x52\x48\x4E\x48\xCB\x92\xE9\x67\x71\x60\x07\xC9\xA3\x3B\xAC\xD1\xEA\x5B\x71\xDB\xC1\x94\x79\x85\x55\x8C\x03\x61\x9E\xC7\xD6\x32\x40\xFA\xDD\xF6\xC9\xF8\xE0\xFF\x4D\xAC\x54\xED\x61\xFE\xB2\xA0\x82\x04\x99\x30\x82\x04\x95\x30\x82\x04\x91\x30\x82\x02\x79\xA0\x03\x02\x01\x02\x02\x03\x00\xDC\xA6\x30\x0D\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x05\x05\x00\x30\x54\x31\x14\x30\x12\x06\x03\x55\x04\x0A\x13\x0B\x43\x41\x63\x65\x72\x74\x20\x49\x6E\x63\x2E\x31\x1E\x30\x1C\x06\x03\x55\x04\x0B\x13\x15\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x43\x41\x63\x65\x72\x74\x2E\x6F\x72\x67\x31\x1C\x30\x1A\x06\x03\x55\x04\x03\x13\x13\x43\x41\x63\x65\x72\x74\x20\x43\x6C\x61\x73\x73\x20\x33\x20\x52\x6F\x6F\x74\x30\x1E\x17\x0D\x31\x31\x30\x38\x32\x33\x30\x30\x30\x38\x33\x37\x5A\x17\x0D\x31\x33\x30\x38\x32\x32\x30\x30\x30\x38\x33\x37\x5A\x30\x7C\x31\x0B\x30\x09\x06\x03\x55\x04\x06\x13\x02\x41\x55\x31\x0C\x30\x0A\x06\x03\x55\x04\x08\x13\x03\x4E\x53\x57\x31\x0F\x30\x0D\x06\x03\x55\x04\x07\x13\x06\x53\x79\x64\x6E\x65\x79\x31\x14\x30\x12\x06\x03\x55\x04\x0A\x13\x0B\x43\x41\x63\x65\x72\x74\x20\x49\x6E\x63\x2E\x31\x1E\x30\x1C\x06\x03\x55\x04\x0B\x13\x15\x53\x65\x72\x76\x65\x72\x20\x41\x64\x6D\x69\x6E\x69\x73\x74\x72\x61\x74\x69\x6F\x6E\x31\x18\x30\x16\x06\x03\x55\x04\x03\x13\x0F\x6F\x63\x73\x70\x2E\x63\x61\x63\x65\x72\x74\x2E\x6F\x72\x67\x30\x82\x01\x22\x30\x0D\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x01\x05\x00\x03\x82\x01\x0F\x00\x30\x82\x01\x0A\x02\x82\x01\x01\x00\x9C\xC6\xD4\x6F\xE4\x23\xC7\xC3\x70\x4B\x75\x1F\xE4\xFC\xAE\xF6\x62\xC4\x60\xA1\xD6\xCF\xF9\x47\x40\x38\xD9\xAF\x06\xF5\xB3\x87\x09\xBA\x07\xC8\x7A\x3B\xE3\x3A\xE2\xC1\x6B\xDB\x0E\x9B\x7B\xB4\x98\x04\x40\x88\xC8\xE4\x20\x34\x9D\x5F\x94\xAE\x0C\xA0\x05\xA1\x74\x10\x3F\x1F\x93\x6D\xC5\xA0\xCE\x29\xB0\x2A\x03\x6E\xED\x3B\xD1\x9A\x7A\xF7\x0F\xA7\xB7\x39\xD7\xC3\xB4\xDE\x15\x67\x94\xF2\xEF\xB0\xDD\x5F\xE3\xC9\xD8\xD2\x34\x0E\x5D\x44\xDF\xBF\x99\xD8\x5E\x60\xF4\x39\x24\x8A\xFD\x5D\xC8\x46\x8D\x0A\xB1\x60\x7A\x4F\xD5\x27\x30\x60\x9E\x13\x06\xF8\x3A\xAA\xB3\xBB\x33\x34\x6F\x84\x81\x7E\x5C\xCC\x12\x89\xF2\xFE\x6E\x93\x83\xFA\x8B\xEE\xAB\x36\x4C\xB6\x40\xA9\xEE\xFB\xF8\x16\x5A\x55\xD1\x64\x0D\x49\xDA\x04\xDE\xD1\xC8\xCA\xEE\x5F\x24\xB1\x79\x78\xB3\x9A\x88\x13\xDD\x68\x51\x39\xE9\x68\x31\xAF\xD7\xF8\x4D\x35\x6D\x60\x58\x04\x42\xBB\x55\x92\x18\xF6\x98\x01\xA5\x74\x3B\xBC\x36\xDB\x20\x68\x18\xB8\x85\xD4\x8B\x6D\x30\x87\x4D\xD6\x33\x2D\x7A\x54\x36\x1D\x57\x42\x14\x5C\x7A\x62\x74\xD5\x1E\x2B\xD5\xBF\x04\xF3\xFF\xEC\x03\xC1\x02\x03\x01\x00\x01\xA3\x44\x30\x42\x30\x0C\x06\x03\x55\x1D\x13\x01\x01\xFF\x04\x02\x30\x00\x30\x27\x06\x03\x55\x1D\x25\x04\x20\x30\x1E\x06\x08\x2B\x06\x01\x05\x05\x07\x03\x02\x06\x08\x2B\x06\x01\x05\x05\x07\x03\x01\x06\x08\x2B\x06\x01\x05\x05\x07\x03\x09\x30\x09\x06\x03\x55\x1D\x11\x04\x02\x30\x00\x30\x0D\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x05\x05\x00\x03\x82\x02\x01\x00\x50\xDD\x63\xB7\x1A\x6F\x91\x4C\xE8\x7F\x82\x1A\x27\x04\x81\x05\xBB\xA6\x69\xAC\x41\x7B\x62\xFC\x4B\x08\xDC\x60\xCF\xB2\x5A\xF1\xB4\xB5\x27\x69\x6B\x12\xE4\x07\xC8\x16\xCE\x3B\x42\xCC\x02\x90\x66\x0E\x79\xB8\x6C\x4B\x90\x00\xC5\x66\x64\x92\x2B\x2B\x48\x0E\x84\xC2\x6D\xBF\xA5\xDE\x16\xE3\xBD\x19\xF5\x5C\x93\xA1\x86\x7F\xD9\x89\x78\x6A\x3F\x83\xF0\xAA\xF8\xEA\x1D\xA4\x13\xF7\x2A\x15\x4C\x51\x9C\xC4\xB0\xBE\x58\x66\xCF\x4C\x6C\x3D\x31\xE5\xF9\x54\x21\xCD\xA1\x30\x01\x6A\xB3\x1A\x48\x85\x34\x93\xB8\xF9\x15\x19\x48\x34\x8D\x73\xE7\x03\x50\xAF\xDE\x50\xC7\x62\xAF\x25\x22\x2B\xF6\xE8\x37\x2E\xE4\x71\xA9\x5C\x26\xEA\x79\xCB\x04\x29\x73\x6B\x8F\xDF\x1F\x5C\x41\x52\xC0\x36\xAA\xD7\x7D\x8E\x44\x54\x98\x06\x4C\x63\xA6\x0B\x01\x94\x5D\x0C\x5C\xD4\xCF\xCB\x0B\x7B\x2D\x56\xCC\xBF\x97\x7F\x15\x24\x1D\xBA\xEA\xB7\x97\xB0\x32\xAD\xFC\xEA\x6D\x94\x39\x7A\xE3\x25\x54\xFC\x4A\xF5\x3D\xBD\x2E\xD5\x31\x07\x49\x24\xCC\x92\x69\x0E\x79\xB9\xDF\xDB\x36\xBF\x04\x44\x15\xD0\x46\x99\x8C\xD2\x4C\x94\x38\x0E\x10\x64\x13\xAB\xD9\x1B\x54\x02\x31\x56\x20\xEE\x69\x95\xDF\x39\xBB\xE9\xA7\x6D\xC3\x23\x86\x0B\xD6\x34\x40\x37\xC3\xD4\x41\xA8\x2E\x71\x1D\x6E\x5B\xD7\xC5\x9F\x2A\xE6\x02\x80\xAE\x0A\x28\x69\x63\x4B\x89\x2E\xBD\x4F\x42\x58\xFB\x86\x9A\xA2\x18\xDC\xC6\x32\xC1\x46\xBA\x28\xD2\x8B\xCE\x56\x63\x04\x80\x51\x51\x39\x00\x3B\x00\xB9\x5F\x67\xFA\x90\x1E\xDA\x76\xB5\x31\xA5\xBD\x11\xD2\x5F\xDA\x5D\xD5\xF7\xEE\xAB\xC0\x62\x74\x60\x47\x32\x42\xFD\xB2\x2E\x04\x3A\x2E\xF2\xC8\xB3\x41\xA3\xBD\xFE\x94\x5F\xEF\x6E\xD7\x92\x7C\x1D\x04\xF0\xC6\x53\x8E\x46\xDC\x30\x3A\x35\x5F\x1A\x4B\xEA\x3B\x00\x8B\x97\xB5\xB9\xCE\x71\x6E\x5C\xD5\xA0\x0B\xB1\x33\x08\x89\x61\x23\xCF\x97\x9F\x8F\x9A\x50\xB5\xEC\xCE\x40\x8D\x82\x95\x8B\x79\x26\x66\xF3\xF4\x70\xD8\xEE\x58\xDD\x75\x29\xD5\x6A\x91\x51\x7A\x17\xBC\x4F\xD4\xA3\x45\x7B\x84\xE7\xBE\x69\x53\xC1\xE2\x5C\xC8\x45\xA0\x3A\xEC\xDF\x8A\x1E\xC1\x18\x84\x8B\x7A\x4E\x4E\x9E\x3A\x26\xFE\x5D\x22\xD4\xC5\x14\xBE\xEE\x06\xEB\x05\x4A\x66\xC9\xA4\xB3\x68\x04\xB0\x5D\x25\x54\xB3\x05\xED\x41\xF0\x65\x69\x6D\xA5\x4E\xB7\x97\xD8\xD8\xF5"
static const gnutls_datum_t blog_resp =
- { (unsigned char*) BLOG_RESP, sizeof (BLOG_RESP) - 1 };
+ { (unsigned char *) BLOG_RESP, sizeof(BLOG_RESP) - 1 };
static unsigned char blog_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIE8DCCAtigAwIBAgIDALzgMA0GCSqGSIb3DQEBBQUAMFQxFDASBgNVBAoTC0NB\n"
- "Y2VydCBJbmMuMR4wHAYDVQQLExVodHRwOi8vd3d3LkNBY2VydC5vcmcxHDAaBgNV\n"
- "BAMTE0NBY2VydCBDbGFzcyAzIFJvb3QwHhcNMTAxMTE2MjI1MjMzWhcNMTIxMTE1\n"
- "MjI1MjMzWjAdMRswGQYDVQQDExJibG9nLmpvc2Vmc3Nvbi5vcmcwggEiMA0GCSqG\n"
- "SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBKA6bm/Kip0i00vU+BOmUF2MBDTwps41c\n"
- "xKN5bDn7usWZj8loi6BHRPE2WzCVPnPRD1FJXBc4rXL8zZWrCRe1b4A+l8NjPN2o\n"
- "uUgJvYLXYQ2hXkvxlPBQPKNOudaOAVsahpyxk6g6Z3mskOfqPhxvjutHvMC4fOsJ\n"
- "1+FstMzvg5SpDd4uYM9m0UK8pbEUSuwW+fxyWqhciSi7kJtdrD6bwx3ub3t9GFkM\n"
- "9uTzImIslTq19w8AHQsTICNnmNwfUGF5XMUIuxun0HlFt2KUP5G3Qg9Cd18wZFql\n"
- "RQJvLA3nbVFtmN3M3yKXnGSsEn38ZJvC+UxFuSfYJN9UwgoG6gwhAgMBAAGjggEA\n"
- "MIH9MAwGA1UdEwEB/wQCMAAwNAYDVR0lBC0wKwYIKwYBBQUHAwIGCCsGAQUFBwMB\n"
- "BglghkgBhvhCBAEGCisGAQQBgjcKAwMwCwYDVR0PBAQDAgWgMDMGCCsGAQUFBwEB\n"
- "BCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuY2FjZXJ0Lm9yZy8wdQYDVR0R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T81G0XJ4C\n"
+ "SlVumGN0KcVPDjtiUYskMpUvyLF951Q4Uuih0Aa9c0LynyZq8yqr6sW5OTmnRfSU\n"
+ "DuUK5IH+IPq5PU7qteQSIy+63yjMQ+1wye1zfCWI+MyaS54AOn6uZObsr4grq41i\n"
+ "sTwnX8OF/z15dQBjDR18WoehsnbuMz3Ld7+w5UcVWRGDzTyZ7JrYisEywQ7TXcoK\n"
+ "1IlhD1TqwFucH7lIr4mPWNjL7Nw0sw11HN0Syt9H3upcq6lqyEI0ygfNZ9cdxvmX\n"
+ "WqOBxxLc6G/87G4nGW4jw3WrCX7LqSmChlR3SbEC1UhWpaQMQ+mOU5+vXon7blRV\n"
+ "zGJ/1wK8mKu3fKw9rm5TQ1xfJuRABbzsD3BrrUaHlREQQ+i6SCPVFGer6oeAaxyv\n"
+ "so0NCbmBQkcpmUUl0COIR/Lh/YT78PjIEfxaUnUlaZXvCbKPKP2cM8LY7ltEaTgJ\n"
+ "4W6sZi3QNFySzd4sz7J/YhY/jGjqku7TfpN/GOheW8AzKTBlm3WLps1YXys4TKrB\n"
+ "0RStfaPfRJI1PeSlrWl6+kQu/5O8WA8NK0JZ/0Jc4d5LNrtUXo4VU9XCthrxLkgL\n"
+ "3XWgZKFrqJd1UeJJ7OvkRYfI1c5i4oAP5ksuF0SHTpqnXE8K39kUnUx3B+ItJlZP\n"
+ "VXTFhXRc06QwYqYXuYSAmj7/GJk=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t blog_cert_data = { blog_cert_pem,
- sizeof (blog_cert_pem) };
+ sizeof(blog_cert_pem)
+};
static unsigned char blog_issuer_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIHWTCCBUGgAwIBAgIDCkGKMA0GCSqGSIb3DQEBCwUAMHkxEDAOBgNVBAoTB1Jv\n"
- "b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ\n"
- "Q0EgQ2VydCBTaWdu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iHq921F73OIZWWonO1sOn\n"
+ "ebJSoMbxhbQljPI/lrMQ2Y1sVzufb4Y6GIIiNsiwkTjbKqGTqoQ/9SdlrnPVyNXT\n"
+ "d+pLncdBu8fA46A/5H2kjXPmEkvfoXNzczqA6NXLji/L6hOn1kGLrPo8idck9U60\n"
+ "4GGSt/M3mMS+lqO3ig==\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t blog_issuer_data = { blog_issuer_pem,
- sizeof (blog_issuer_pem) };
+ sizeof(blog_issuer_pem)
+};
static unsigned char blog_signer_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIEkTCCAnmgAwIBAgIDANymMA0GCSqGSIb3DQEBBQUAMFQxFDASBgNVBAoTC0NB\n"
- "Y2VydCBJbmMuMR4wHAYDVQQLExVodHRwOi8vd3d3LkNBY2VydC5vcmcxHDAaBgNV\n"
- "BAMTE0NBY2VydCBDbGFzcyAzIFJvb3QwHhcNMTEwODIzMDAwODM3WhcNMTMwODIy\n"
- "MDAwODM3WjB8MQswCQYDVQQGEwJBVTEMMAoGA1UECBMDTlNXMQ8wDQYDVQQHEwZT\n"
- "eWRuZXkxFDASBgNVBAoTC0NBY2VydCBJbmMuMR4wHAYDVQQLExVTZXJ2ZXIgQWRt\n"
- "aW5pc3RyYXRpb24xGDAWBgNVBAMTD29jc3AuY2FjZXJ0Lm9yZzCCASIwDQYJKoZI\n"
- "hvcNAQEBBQADggEPADCCAQoCggEBAJzG1G/kI8fDcEt1H+T8rvZixGCh1s/5R0A4\n"
- "2a8G9bOHCboHyHo74zriwWvbDpt7tJgEQIjI5CA0nV+UrgygBaF0ED8fk23FoM4p\n"
- "sCoDbu070Zp69w+ntznXw7TeFWeU8u+w3V/jydjSNA5dRN+/mdheYPQ5JIr9XchG\n"
- "jQqxYHpP1ScwYJ4TBvg6qrO7MzRvhIF+XMwSifL+bpOD+ovuqzZMtkCp7vv4FlpV\n"
- "0WQNSdoE3tHIyu5fJLF5eLOaiBPdaFE56Wgxr9f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2kE/cqFUxRnMSwvlhmz0xs\n"
+ "PTHl+VQhzaEwAWqzGkiFNJO4+RUZSDSNc+cDUK/eUMdiryUiK/boNy7kcalcJup5\n"
+ "ywQpc2uP3x9cQVLANqrXfY5EVJgGTGOmCwGUXQxc1M/LC3stVsy/l38VJB266reX\n"
+ "sDKt/OptlDl64yVU/Er1Pb0u1TEHSSTMkmkOebnf2za/BEQV0EaZjNJMlDgOEGQT\n"
+ "q9kbVAIxViDuaZXfObvpp23DI4YL1jRAN8PUQagucR1uW9fFnyrmAoCuCihpY0uJ\n"
+ "Lr1PQlj7hpqiGNzGMsFGuijSi85WYwSAUVE5ADsAuV9n+pAe2na1MaW9EdJf2l3V\n"
+ "9+6rwGJ0YEcyQv2yLgQ6LvLIs0Gjvf6UX+9u15J8HQTwxlOORtwwOjVfGkvqOwCL\n"
+ "l7W5znFuXNWgC7EzCIlhI8+Xn4+aULXszkCNgpWLeSZm8/Rw2O5Y3XUp1WqRUXoX\n"
+ "vE/Uo0V7hOe+aVPB4lzIRaA67N+KHsEYhIt6Tk6eOib+XSLUxRS+7gbrBUpmyaSz\n"
+ "aASwXSVUswXtQfBlaW2lTreX2Nj1\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t blog_signer_data = { blog_signer_pem,
- sizeof (blog_signer_pem) };
+ sizeof(blog_signer_pem)
+};
-static void
-ocsp_invalid_calls (void)
+static void ocsp_invalid_calls(void)
{
- gnutls_ocsp_req_t req;
- gnutls_ocsp_resp_t resp;
- gnutls_datum_t dat;
- char c = 42;
- void *p = &c;
- int rc;
-
- rc = gnutls_ocsp_req_init (&req);
- if (rc != GNUTLS_E_SUCCESS)
- {
- fail ("gnutls_ocsp_req_init alloc\n");
- exit (1);
- }
- rc = gnutls_ocsp_resp_init (&resp);
- if (rc != GNUTLS_E_SUCCESS)
- {
- fail ("gnutls_ocsp_resp_init alloc\n");
- exit (1);
- }
-
- gnutls_ocsp_req_deinit (NULL);
- gnutls_ocsp_resp_deinit (NULL);
-
- rc = gnutls_ocsp_req_import (NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_import NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_import (NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_import NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_import (req, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_import NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_import (NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_import NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_import (NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_import NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_import (resp, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_import NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_export (NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_export NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_export (NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_export NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_export (req, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_export NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_export (NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_export NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_export (NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_export NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_export (resp, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_export NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_version (NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_get_version NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_cert_id (NULL, 0, NULL, NULL, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_get_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_cert_id (req, 0, NULL, NULL, NULL, NULL);
- if (rc != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- {
- fail ("gnutls_ocsp_req_get_cert_id empty\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (NULL, 0, NULL, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, 0, NULL, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1, NULL, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1, p, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1, NULL, p, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1, NULL, NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1, p, p, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1, p, NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1, NULL, p, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert (NULL, 0, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert (req, 0, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
-
- rc = gnutls_ocsp_req_add_cert (req, 0, p, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_add_cert (req, 0, NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_add_cert_id NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_extension (NULL, 0, NULL, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_get_extension NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_extension (req, 0, NULL, NULL, NULL);
- if (rc != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- {
- fail ("gnutls_ocsp_req_get_extension NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_extension (req, 0, p, p, p);
- if (rc != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- {
- fail ("gnutls_ocsp_req_get_extension NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_set_extension (NULL, NULL, 0, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_set_extension NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_set_extension (req, NULL, 0, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_set_extension NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_set_extension (req, p, 0, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_set_extension NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_set_extension (req, NULL, 0, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_set_extension NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_nonce (NULL, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_get_nonce NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_get_nonce (NULL, NULL, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_get_nonce NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_set_nonce (NULL, 0, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_set_nonce NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_set_nonce (req, 0, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_set_nonce NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_req_randomize_nonce (NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_req_randomize_nonce NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_status (NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_get_status NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_status (resp);
- if (rc != GNUTLS_E_ASN1_VALUE_NOT_FOUND)
- {
- fail ("gnutls_ocsp_resp_get_status %d\n", rc);
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_response (NULL, NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_get_response NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_response (NULL, p, p);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_get_response NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_response (resp, NULL, NULL);
- if (rc != GNUTLS_E_SUCCESS)
- {
- fail ("gnutls_ocsp_resp_get_response %d\n", rc);
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_version (NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_get_version NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_version (resp);
- if (rc != 1)
- {
- fail ("gnutls_ocsp_resp_get_version ret %d\n", rc);
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_responder (NULL, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_get_responder NULL\n");
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_responder (resp, NULL);
- if (rc != GNUTLS_E_INVALID_REQUEST)
- {
- fail ("gnutls_ocsp_resp_get_responder 2nd %d\n", rc);
- exit (1);
- }
-
- rc = gnutls_ocsp_resp_get_responder (resp, &dat);
- if (rc != GNUTLS_E_SUCCESS || dat.size != 0)
- {
- fail ("gnutls_ocsp_resp_get_responder %d\n", rc);
- exit (1);
- }
-
- gnutls_free (dat.data);
-
- gnutls_ocsp_req_deinit (req);
- gnutls_ocsp_resp_deinit (resp);
+ gnutls_ocsp_req_t req;
+ gnutls_ocsp_resp_t resp;
+ gnutls_datum_t dat;
+ char c = 42;
+ void *p = &c;
+ int rc;
+
+ rc = gnutls_ocsp_req_init(&req);
+ if (rc != GNUTLS_E_SUCCESS) {
+ fail("gnutls_ocsp_req_init alloc\n");
+ exit(1);
+ }
+ rc = gnutls_ocsp_resp_init(&resp);
+ if (rc != GNUTLS_E_SUCCESS) {
+ fail("gnutls_ocsp_resp_init alloc\n");
+ exit(1);
+ }
+
+ gnutls_ocsp_req_deinit(NULL);
+ gnutls_ocsp_resp_deinit(NULL);
+
+ rc = gnutls_ocsp_req_import(NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_import NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_import(NULL, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_import NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_import(req, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_import NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_import(NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_import NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_import(NULL, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_import NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_import(resp, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_import NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_export(NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_export NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_export(NULL, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_export NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_export(req, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_export NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_export(NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_export NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_export(NULL, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_export NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_export(resp, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_export NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_version(NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_get_version NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_cert_id(NULL, 0, NULL, NULL, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_get_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_cert_id(req, 0, NULL, NULL, NULL, NULL);
+ if (rc != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
+ fail("gnutls_ocsp_req_get_cert_id empty\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(NULL, 0, NULL, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, 0, NULL, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1, NULL, NULL,
+ NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1, p, NULL,
+ NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1, NULL, p,
+ NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1, NULL, NULL,
+ p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1, p, p, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1, p, NULL, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1, NULL, p, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert(NULL, 0, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert(req, 0, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+
+ rc = gnutls_ocsp_req_add_cert(req, 0, p, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_add_cert(req, 0, NULL, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_add_cert_id NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_extension(NULL, 0, NULL, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_get_extension NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_extension(req, 0, NULL, NULL, NULL);
+ if (rc != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
+ fail("gnutls_ocsp_req_get_extension NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_extension(req, 0, p, p, p);
+ if (rc != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
+ fail("gnutls_ocsp_req_get_extension NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_set_extension(NULL, NULL, 0, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_set_extension NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_set_extension(req, NULL, 0, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_set_extension NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_set_extension(req, p, 0, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_set_extension NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_set_extension(req, NULL, 0, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_set_extension NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_nonce(NULL, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_get_nonce NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_get_nonce(NULL, NULL, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_get_nonce NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_set_nonce(NULL, 0, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_set_nonce NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_set_nonce(req, 0, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_set_nonce NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_req_randomize_nonce(NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_req_randomize_nonce NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_status(NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_get_status NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_status(resp);
+ if (rc != GNUTLS_E_ASN1_VALUE_NOT_FOUND) {
+ fail("gnutls_ocsp_resp_get_status %d\n", rc);
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_response(NULL, NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_get_response NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_response(NULL, p, p);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_get_response NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_response(resp, NULL, NULL);
+ if (rc != GNUTLS_E_SUCCESS) {
+ fail("gnutls_ocsp_resp_get_response %d\n", rc);
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_version(NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_get_version NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_version(resp);
+ if (rc != 1) {
+ fail("gnutls_ocsp_resp_get_version ret %d\n", rc);
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_responder(NULL, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_get_responder NULL\n");
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_responder(resp, NULL);
+ if (rc != GNUTLS_E_INVALID_REQUEST) {
+ fail("gnutls_ocsp_resp_get_responder 2nd %d\n", rc);
+ exit(1);
+ }
+
+ rc = gnutls_ocsp_resp_get_responder(resp, &dat);
+ if (rc != GNUTLS_E_SUCCESS || dat.size != 0) {
+ fail("gnutls_ocsp_resp_get_responder %d\n", rc);
+ exit(1);
+ }
+
+ gnutls_free(dat.data);
+
+ gnutls_ocsp_req_deinit(req);
+ gnutls_ocsp_resp_deinit(resp);
}
/* import a request, query some fields and print and export it */
-static void
-req_parse (void)
+static void req_parse(void)
{
- gnutls_ocsp_req_t req;
- int ret;
- gnutls_datum_t d;
-
- /* init request */
-
- ret = gnutls_ocsp_req_init (&req);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_init\n");
- exit (1);
- }
-
- /* import ocsp request */
-
- ret = gnutls_ocsp_req_import (req, &req1);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_import %d\n", ret);
- exit (1);
- }
-
- /* simple version query */
-
- ret = gnutls_ocsp_req_get_version (req);
- if (ret != 1)
- {
- fail ("gnutls_ocsp_req_get_version %d\n", ret);
- exit (1);
- }
-
- /* check nonce */
- {
- gnutls_datum_t expect =
- { (unsigned char*) REQ1NONCE + 2, sizeof (REQ1NONCE) - 3 };
- gnutls_datum_t got;
- unsigned int critical;
-
- ret = gnutls_ocsp_req_get_nonce (req, &critical, &got);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_get_nonce %d\n", ret);
- exit (1);
- }
-
- if (critical != 0)
- {
- fail ("unexpected critical %d\n", critical);
- exit (1);
- }
-
- if (expect.size != got.size ||
- memcmp (expect.data, got.data, got.size) != 0)
- {
- fail ("ocsp request nonce memcmp failed\n");
- exit (1);
- }
-
- gnutls_free (got.data);
- }
-
- /* print request */
-
- ret = gnutls_ocsp_req_print (req, GNUTLS_OCSP_PRINT_FULL, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_print\n");
- exit (1);
- }
-
- if (strlen (REQ1INFO) != d.size - 1 ||
- memcmp (REQ1INFO, d.data, strlen (REQ1INFO)) != 0)
- {
- printf ("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
- strlen (REQ1INFO), REQ1INFO, (int) d.size - 1,
- (int) d.size, d.data);
- fail ("ocsp request print failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* test export */
- ret = gnutls_ocsp_req_export (req, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_export %d\n", ret);
- exit (1);
- }
-
- /* compare against earlier imported bytes */
-
- if (req1.size != d.size ||
- memcmp (req1.data, d.data, d.size) != 0)
- {
- fail ("ocsp request export memcmp failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* test setting nonce */
- {
- gnutls_datum_t n1 = { (unsigned char *) "foo", 3 };
- gnutls_datum_t n2 = { (unsigned char *) "foobar", 6 };
- gnutls_datum_t got;
- unsigned critical;
-
- ret = gnutls_ocsp_req_set_nonce (req, 0, &n1);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_set_nonce %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_req_get_nonce (req, &critical, &got);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_get_nonce %d\n", ret);
- exit (1);
- }
-
- if (critical != 0)
- {
- fail ("unexpected critical %d\n", critical);
- exit (1);
- }
-
- if (n1.size != got.size ||
- memcmp (n1.data, got.data, got.size) != 0)
- {
- fail ("ocsp request parse nonce memcmp failed\n");
- exit (1);
- }
-
- gnutls_free (got.data);
-
- /* set another time */
-
- ret = gnutls_ocsp_req_set_nonce (req, 1, &n2);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_set_nonce %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_req_get_nonce (req, &critical, &got);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_get_nonce %d\n", ret);
- exit (1);
- }
-
- if (critical != 1)
- {
- fail ("unexpected critical %d\n", critical);
- exit (1);
- }
-
- if (n2.size != got.size ||
- memcmp (n2.data, got.data, got.size) != 0)
- {
- fail ("ocsp request parse2 nonce memcmp failed\n");
- exit (1);
- }
-
- gnutls_free (got.data);
-
- /* randomize nonce */
-
- ret = gnutls_ocsp_req_randomize_nonce (req);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_randomize_nonce %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_req_get_nonce (req, &critical, &n1);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_get_nonce %d\n", ret);
- exit (1);
- }
-
- if (critical != 0)
- {
- fail ("unexpected random critical %d\n", critical);
- exit (1);
- }
-
- ret = gnutls_ocsp_req_randomize_nonce (req);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_randomize_nonce %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_req_get_nonce (req, &critical, &n2);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_get_nonce %d\n", ret);
- exit (1);
- }
-
- if (critical != 0)
- {
- fail ("unexpected random critical %d\n", critical);
- exit (1);
- }
-
- if (n2.size == got.size && memcmp (n1.data, n2.data, n1.size) == 0)
- {
- fail ("ocsp request random nonce memcmp failed\n");
- exit (1);
- }
-
- gnutls_free (n1.data);
- gnutls_free (n2.data);
- }
-
- /* cleanup */
-
- gnutls_ocsp_req_deinit (req);
+ gnutls_ocsp_req_t req;
+ int ret;
+ gnutls_datum_t d;
+
+ /* init request */
+
+ ret = gnutls_ocsp_req_init(&req);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_init\n");
+ exit(1);
+ }
+
+ /* import ocsp request */
+
+ ret = gnutls_ocsp_req_import(req, &req1);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_import %d\n", ret);
+ exit(1);
+ }
+
+ /* simple version query */
+
+ ret = gnutls_ocsp_req_get_version(req);
+ if (ret != 1) {
+ fail("gnutls_ocsp_req_get_version %d\n", ret);
+ exit(1);
+ }
+
+ /* check nonce */
+ {
+ gnutls_datum_t expect =
+ { (unsigned char *) REQ1NONCE + 2,
+ sizeof(REQ1NONCE) - 3 };
+ gnutls_datum_t got;
+ unsigned int critical;
+
+ ret = gnutls_ocsp_req_get_nonce(req, &critical, &got);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_get_nonce %d\n", ret);
+ exit(1);
+ }
+
+ if (critical != 0) {
+ fail("unexpected critical %d\n", critical);
+ exit(1);
+ }
+
+ if (expect.size != got.size ||
+ memcmp(expect.data, got.data, got.size) != 0) {
+ fail("ocsp request nonce memcmp failed\n");
+ exit(1);
+ }
+
+ gnutls_free(got.data);
+ }
+
+ /* print request */
+
+ ret = gnutls_ocsp_req_print(req, GNUTLS_OCSP_PRINT_FULL, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_print\n");
+ exit(1);
+ }
+
+ if (strlen(REQ1INFO) != d.size - 1 ||
+ memcmp(REQ1INFO, d.data, strlen(REQ1INFO)) != 0) {
+ printf("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
+ strlen(REQ1INFO), REQ1INFO, (int) d.size - 1,
+ (int) d.size, d.data);
+ fail("ocsp request print failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* test export */
+ ret = gnutls_ocsp_req_export(req, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_export %d\n", ret);
+ exit(1);
+ }
+
+ /* compare against earlier imported bytes */
+
+ if (req1.size != d.size || memcmp(req1.data, d.data, d.size) != 0) {
+ fail("ocsp request export memcmp failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* test setting nonce */
+ {
+ gnutls_datum_t n1 = { (unsigned char *) "foo", 3 };
+ gnutls_datum_t n2 = { (unsigned char *) "foobar", 6 };
+ gnutls_datum_t got;
+ unsigned critical;
+
+ ret = gnutls_ocsp_req_set_nonce(req, 0, &n1);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_set_nonce %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_req_get_nonce(req, &critical, &got);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_get_nonce %d\n", ret);
+ exit(1);
+ }
+
+ if (critical != 0) {
+ fail("unexpected critical %d\n", critical);
+ exit(1);
+ }
+
+ if (n1.size != got.size ||
+ memcmp(n1.data, got.data, got.size) != 0) {
+ fail("ocsp request parse nonce memcmp failed\n");
+ exit(1);
+ }
+
+ gnutls_free(got.data);
+
+ /* set another time */
+
+ ret = gnutls_ocsp_req_set_nonce(req, 1, &n2);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_set_nonce %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_req_get_nonce(req, &critical, &got);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_get_nonce %d\n", ret);
+ exit(1);
+ }
+
+ if (critical != 1) {
+ fail("unexpected critical %d\n", critical);
+ exit(1);
+ }
+
+ if (n2.size != got.size ||
+ memcmp(n2.data, got.data, got.size) != 0) {
+ fail("ocsp request parse2 nonce memcmp failed\n");
+ exit(1);
+ }
+
+ gnutls_free(got.data);
+
+ /* randomize nonce */
+
+ ret = gnutls_ocsp_req_randomize_nonce(req);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_randomize_nonce %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_req_get_nonce(req, &critical, &n1);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_get_nonce %d\n", ret);
+ exit(1);
+ }
+
+ if (critical != 0) {
+ fail("unexpected random critical %d\n", critical);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_req_randomize_nonce(req);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_randomize_nonce %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_req_get_nonce(req, &critical, &n2);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_get_nonce %d\n", ret);
+ exit(1);
+ }
+
+ if (critical != 0) {
+ fail("unexpected random critical %d\n", critical);
+ exit(1);
+ }
+
+ if (n2.size == got.size
+ && memcmp(n1.data, n2.data, n1.size) == 0) {
+ fail("ocsp request random nonce memcmp failed\n");
+ exit(1);
+ }
+
+ gnutls_free(n1.data);
+ gnutls_free(n2.data);
+ }
+
+ /* cleanup */
+
+ gnutls_ocsp_req_deinit(req);
}
/* check that creating a request (using low-level add_cert_id) ends up
with same DER as above. */
-static void
-req_addcert_id (void)
+static void req_addcert_id(void)
{
- gnutls_ocsp_req_t req;
- int ret;
- gnutls_datum_t d;
-
- /* init request */
-
- ret = gnutls_ocsp_req_init (&req);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_init\n");
- exit (1);
- }
-
- /* add ocsp request nonce */
-
- {
- gnutls_datum_t nonce =
- { (unsigned char*) REQ1NONCE, sizeof (REQ1NONCE) - 1 };
-
- ret = gnutls_ocsp_req_set_extension (req, "1.3.6.1.5.5.7.48.1.2",
- 0, &nonce);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_set_extension %d\n", ret);
- exit (1);
- }
- }
-
- /* add cert_id */
- {
- gnutls_datum_t issuer_name_hash =
- { (unsigned char*) REQ1INH, sizeof (REQ1INH) - 1 };
- gnutls_datum_t issuer_key_hash =
- { (unsigned char*) REQ1IKH, sizeof (REQ1IKH) - 1 };
- gnutls_datum_t serial_number =
- { (unsigned char*) REQ1SN, sizeof (REQ1SN) - 1 };
-
- ret = gnutls_ocsp_req_add_cert_id (req, GNUTLS_DIG_SHA1,
- &issuer_name_hash,
- &issuer_key_hash,
- &serial_number);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_add_cert_id %d\n", ret);
- exit (1);
- }
- }
-
- /* print request */
-
- ret = gnutls_ocsp_req_print (req, GNUTLS_OCSP_PRINT_FULL, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_print\n");
- exit (1);
- }
-
- if (strlen (REQ1INFO) != d.size - 1 ||
- memcmp (REQ1INFO, d.data, strlen (REQ1INFO)) != 0)
- {
- printf ("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
- strlen (REQ1INFO), REQ1INFO, (int) d.size - 1,
- (int) d.size, d.data);
- fail ("ocsp request print failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* test export */
- ret = gnutls_ocsp_req_export (req, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_export %d\n", ret);
- exit (1);
- }
-
- /* compare against earlier imported bytes */
-
- if (req1.size != d.size ||
- memcmp (req1.data, d.data, d.size) != 0)
- {
- fail ("ocsp request export memcmp failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* cleanup */
-
- gnutls_ocsp_req_deinit (req);
+ gnutls_ocsp_req_t req;
+ int ret;
+ gnutls_datum_t d;
+
+ /* init request */
+
+ ret = gnutls_ocsp_req_init(&req);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_init\n");
+ exit(1);
+ }
+
+ /* add ocsp request nonce */
+
+ {
+ gnutls_datum_t nonce =
+ { (unsigned char *) REQ1NONCE, sizeof(REQ1NONCE) - 1 };
+
+ ret =
+ gnutls_ocsp_req_set_extension(req,
+ "1.3.6.1.5.5.7.48.1.2",
+ 0, &nonce);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_set_extension %d\n", ret);
+ exit(1);
+ }
+ }
+
+ /* add cert_id */
+ {
+ gnutls_datum_t issuer_name_hash =
+ { (unsigned char *) REQ1INH, sizeof(REQ1INH) - 1 };
+ gnutls_datum_t issuer_key_hash =
+ { (unsigned char *) REQ1IKH, sizeof(REQ1IKH) - 1 };
+ gnutls_datum_t serial_number =
+ { (unsigned char *) REQ1SN, sizeof(REQ1SN) - 1 };
+
+ ret = gnutls_ocsp_req_add_cert_id(req, GNUTLS_DIG_SHA1,
+ &issuer_name_hash,
+ &issuer_key_hash,
+ &serial_number);
+ if (ret != 0) {
+ fail("gnutls_ocsp_add_cert_id %d\n", ret);
+ exit(1);
+ }
+ }
+
+ /* print request */
+
+ ret = gnutls_ocsp_req_print(req, GNUTLS_OCSP_PRINT_FULL, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_print\n");
+ exit(1);
+ }
+
+ if (strlen(REQ1INFO) != d.size - 1 ||
+ memcmp(REQ1INFO, d.data, strlen(REQ1INFO)) != 0) {
+ printf("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
+ strlen(REQ1INFO), REQ1INFO, (int) d.size - 1,
+ (int) d.size, d.data);
+ fail("ocsp request print failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* test export */
+ ret = gnutls_ocsp_req_export(req, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_export %d\n", ret);
+ exit(1);
+ }
+
+ /* compare against earlier imported bytes */
+
+ if (req1.size != d.size || memcmp(req1.data, d.data, d.size) != 0) {
+ fail("ocsp request export memcmp failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* cleanup */
+
+ gnutls_ocsp_req_deinit(req);
}
/* check that creating a request (using high-level add_cert) ends up
with same DER as above. */
-static void
-req_addcert (void)
+static void req_addcert(void)
{
- gnutls_ocsp_req_t req;
- int ret;
- gnutls_datum_t d;
-
- /* init request */
-
- ret = gnutls_ocsp_req_init (&req);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_init\n");
- exit (1);
- }
-
- /* add ocsp request nonce */
-
- {
- gnutls_datum_t nonce =
- { (unsigned char*) REQ1NONCE, sizeof (REQ1NONCE) - 1 };
-
- ret = gnutls_ocsp_req_set_extension (req, "1.3.6.1.5.5.7.48.1.2",
- 0, &nonce);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_set_extension %d\n", ret);
- exit (1);
- }
- }
-
- /* add cert_id */
- {
- gnutls_x509_crt_t issuer = NULL, subject = NULL;
-
- ret = gnutls_x509_crt_init (&issuer);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_init (issuer) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_init (&subject);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_init (subject) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_import (issuer, &issuer_data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import (issuer) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_import (subject, &subject_data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import (subject) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_req_add_cert (req, GNUTLS_DIG_SHA1,
- issuer, subject);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_add_cert %d\n", ret);
- exit (1);
- }
-
- gnutls_x509_crt_deinit (subject);
- gnutls_x509_crt_deinit (issuer);
- }
-
- /* print request */
-
- ret = gnutls_ocsp_req_print (req, GNUTLS_OCSP_PRINT_FULL, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_print\n");
- exit (1);
- }
-
- if (strlen (REQ1INFO) != d.size - 1 ||
- memcmp (REQ1INFO, d.data, strlen (REQ1INFO)) != 0)
- {
- printf ("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
- strlen (REQ1INFO), REQ1INFO, (int) d.size - 1,
- (int) d.size, d.data);
- fail ("ocsp request print failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* test export */
- ret = gnutls_ocsp_req_export (req, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_req_export %d\n", ret);
- exit (1);
- }
-
- /* compare against earlier imported bytes */
-
- if (req1.size != d.size ||
- memcmp (req1.data, d.data, d.size) != 0)
- {
- fail ("ocsp request export memcmp failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* cleanup */
-
- gnutls_ocsp_req_deinit (req);
+ gnutls_ocsp_req_t req;
+ int ret;
+ gnutls_datum_t d;
+
+ /* init request */
+
+ ret = gnutls_ocsp_req_init(&req);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_init\n");
+ exit(1);
+ }
+
+ /* add ocsp request nonce */
+
+ {
+ gnutls_datum_t nonce =
+ { (unsigned char *) REQ1NONCE, sizeof(REQ1NONCE) - 1 };
+
+ ret =
+ gnutls_ocsp_req_set_extension(req,
+ "1.3.6.1.5.5.7.48.1.2",
+ 0, &nonce);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_set_extension %d\n", ret);
+ exit(1);
+ }
+ }
+
+ /* add cert_id */
+ {
+ gnutls_x509_crt_t issuer = NULL, subject = NULL;
+
+ ret = gnutls_x509_crt_init(&issuer);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_init (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_init(&subject);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_init (subject) %d\n", ret);
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(issuer, &issuer_data,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(subject, &subject_data,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import (subject) %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_req_add_cert(req, GNUTLS_DIG_SHA1,
+ issuer, subject);
+ if (ret != 0) {
+ fail("gnutls_ocsp_add_cert %d\n", ret);
+ exit(1);
+ }
+
+ gnutls_x509_crt_deinit(subject);
+ gnutls_x509_crt_deinit(issuer);
+ }
+
+ /* print request */
+
+ ret = gnutls_ocsp_req_print(req, GNUTLS_OCSP_PRINT_FULL, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_print\n");
+ exit(1);
+ }
+
+ if (strlen(REQ1INFO) != d.size - 1 ||
+ memcmp(REQ1INFO, d.data, strlen(REQ1INFO)) != 0) {
+ printf("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
+ strlen(REQ1INFO), REQ1INFO, (int) d.size - 1,
+ (int) d.size, d.data);
+ fail("ocsp request print failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* test export */
+ ret = gnutls_ocsp_req_export(req, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_req_export %d\n", ret);
+ exit(1);
+ }
+
+ /* compare against earlier imported bytes */
+
+ if (req1.size != d.size || memcmp(req1.data, d.data, d.size) != 0) {
+ fail("ocsp request export memcmp failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* cleanup */
+
+ gnutls_ocsp_req_deinit(req);
}
-static void
-resp_import (void)
+static void resp_import(void)
{
- gnutls_ocsp_resp_t resp;
- int ret;
- gnutls_datum_t d;
-
- /* init response */
-
- ret = gnutls_ocsp_resp_init (&resp);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_resp_init\n");
- exit (1);
- }
-
- /* import ocsp response */
-
- ret = gnutls_ocsp_resp_import (resp, &resp1);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_resp_import %d\n", ret);
- exit (1);
- }
-
- /* print response */
-
- ret = gnutls_ocsp_resp_print (resp, GNUTLS_OCSP_PRINT_FULL, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_resp_print\n");
- exit (1);
- }
-
- if (strlen (RESP1INFO) != d.size - 1 ||
- memcmp (RESP1INFO, d.data, strlen (RESP1INFO)) != 0)
- {
- printf ("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
- strlen (RESP1INFO), RESP1INFO, (int) d.size - 1,
- (int) d.size, d.data);
- fail ("ocsp response print failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* import ocsp response */
-
- ret = gnutls_ocsp_resp_import (resp, &resp2);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_resp_import %d\n", ret);
- exit (1);
- }
-
- /* print response */
-
- ret = gnutls_ocsp_resp_print (resp, GNUTLS_OCSP_PRINT_FULL, &d);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_resp_print\n");
- exit (1);
- }
-
- if (memcmp (RESP2INFO, d.data, strlen (RESP2INFO)) != 0)
- {
- printf ("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
- strlen (RESP2INFO), RESP2INFO, (int) d.size - 1,
- (int) d.size, d.data);
- fail ("ocsp response print failed\n");
- exit (1);
- }
- gnutls_free (d.data);
-
- /* cleanup */
-
- gnutls_ocsp_resp_deinit (resp);
+ gnutls_ocsp_resp_t resp;
+ int ret;
+ gnutls_datum_t d;
+
+ /* init response */
+
+ ret = gnutls_ocsp_resp_init(&resp);
+ if (ret != 0) {
+ fail("gnutls_ocsp_resp_init\n");
+ exit(1);
+ }
+
+ /* import ocsp response */
+
+ ret = gnutls_ocsp_resp_import(resp, &resp1);
+ if (ret != 0) {
+ fail("gnutls_ocsp_resp_import %d\n", ret);
+ exit(1);
+ }
+
+ /* print response */
+
+ ret = gnutls_ocsp_resp_print(resp, GNUTLS_OCSP_PRINT_FULL, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_resp_print\n");
+ exit(1);
+ }
+
+ if (strlen(RESP1INFO) != d.size - 1 ||
+ memcmp(RESP1INFO, d.data, strlen(RESP1INFO)) != 0) {
+ printf("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
+ strlen(RESP1INFO), RESP1INFO, (int) d.size - 1,
+ (int) d.size, d.data);
+ fail("ocsp response print failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* import ocsp response */
+
+ ret = gnutls_ocsp_resp_import(resp, &resp2);
+ if (ret != 0) {
+ fail("gnutls_ocsp_resp_import %d\n", ret);
+ exit(1);
+ }
+
+ /* print response */
+
+ ret = gnutls_ocsp_resp_print(resp, GNUTLS_OCSP_PRINT_FULL, &d);
+ if (ret != 0) {
+ fail("gnutls_ocsp_resp_print\n");
+ exit(1);
+ }
+
+ if (memcmp(RESP2INFO, d.data, strlen(RESP2INFO)) != 0) {
+ printf("expected (len %ld):\n%s\ngot (len %d):\n%.*s\n",
+ strlen(RESP2INFO), RESP2INFO, (int) d.size - 1,
+ (int) d.size, d.data);
+ fail("ocsp response print failed\n");
+ exit(1);
+ }
+ gnutls_free(d.data);
+
+ /* cleanup */
+
+ gnutls_ocsp_resp_deinit(resp);
}
-static void
-resp_verify (void)
+static void resp_verify(void)
{
- gnutls_ocsp_resp_t resp;
- int ret;
- gnutls_x509_crt_t cert = NULL, issuer = NULL, signer = NULL;
- gnutls_x509_trust_list_t list;
- unsigned verify;
-
- /* init response */
-
- ret = gnutls_ocsp_resp_init (&resp);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_resp_init\n");
- exit (1);
- }
-
- /* import ocsp response */
-
- ret = gnutls_ocsp_resp_import (resp, &blog_resp);
- if (ret != 0)
- {
- fail ("gnutls_ocsp_resp_import %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_init (cert) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_init (&issuer);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_init (issuer) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_init (&signer);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_init (signer) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_import (cert, &blog_cert_data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import (cert) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_import (issuer, &blog_issuer_data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import (issuer) %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_crt_import (signer, &blog_signer_data, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fail ("gnutls_x509_crt_import (signer) %d\n", ret);
- exit (1);
- }
-
- /* check direct verify with signer (should succeed) */
-
- ret = gnutls_ocsp_resp_verify_direct (resp, signer, &verify, 0);
- if (ret < 0)
- {
- fail ("gnutls_ocsp_resp_verify_direct (signer) %d\n", ret);
- exit (1);
- }
-
- if (verify != 0)
- {
- fail ("gnutls_ocsp_resp_verify_direct %d\n", verify);
- exit (1);
- }
-
- /* check direct verify with cert (should fail) */
-
- ret = gnutls_ocsp_resp_verify_direct (resp, cert, &verify, 0);
- if (ret < 0)
- {
- fail ("gnutls_ocsp_resp_verify_direct (cert) %d\n", ret);
- exit (1);
- }
-
- if (verify != GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER)
- {
- fail ("gnutls_ocsp_resp_verify_direct3 %d\n", verify);
- exit (1);
- }
-
- /* check trust verify with issuer (should succeed) */
-
- ret = gnutls_x509_trust_list_init (&list, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_init %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_trust_list_add_cas (list, &issuer, 1, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_add_cas %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_resp_verify (resp, list, &verify, 0);
- if (ret < 0)
- {
- fail ("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
- exit (1);
- }
-
- if (verify != 0)
- {
- fail ("gnutls_ocsp_resp_verify %d\n", verify);
- exit (1);
- }
-
- gnutls_x509_trust_list_deinit (list, 0);
-
- /* check trust verify with signer (should succeed) */
-
- ret = gnutls_x509_trust_list_init (&list, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_init %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_trust_list_add_cas (list, &signer, 1, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_add_cas %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_resp_verify (resp, list, &verify, 0);
- if (ret < 0)
- {
- fail ("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
- exit (1);
- }
-
- if (verify != 0)
- {
- fail ("gnutls_ocsp_resp_verify %d\n", verify);
- exit (1);
- }
-
- gnutls_x509_trust_list_deinit (list, 0);
-
- /* check trust verify with cert (should fail) */
-
- ret = gnutls_x509_trust_list_init (&list, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_init %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_trust_list_add_cas (list, &cert, 1, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_add_cas %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_resp_verify (resp, list, &verify, 0);
- if (ret < 0)
- {
- fail ("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
- exit (1);
- }
-
- if (verify != GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER)
- {
- fail ("gnutls_ocsp_resp_verify %d\n", verify);
- exit (1);
- }
-
- gnutls_x509_trust_list_deinit (list, 0);
-
- /* check trust verify with all certs (should succeed) */
-
- ret = gnutls_x509_trust_list_init (&list, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_init %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_trust_list_add_cas (list, &cert, 1, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_add_cas %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_trust_list_add_cas (list, &issuer, 1, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_add_cas %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_x509_trust_list_add_cas (list, &signer, 1, 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_trust_list_add_cas %d\n", ret);
- exit (1);
- }
-
- ret = gnutls_ocsp_resp_verify (resp, list, &verify, 0);
- if (ret < 0)
- {
- fail ("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
- exit (1);
- }
-
- if (verify != 0)
- {
- fail ("gnutls_ocsp_resp_verify %d\n", verify);
- exit (1);
- }
-
- gnutls_x509_trust_list_deinit (list, 0);
-
- /* cleanup */
-
- gnutls_ocsp_resp_deinit (resp);
- gnutls_x509_crt_deinit (cert);
- gnutls_x509_crt_deinit (issuer);
- gnutls_x509_crt_deinit (signer);
+ gnutls_ocsp_resp_t resp;
+ int ret;
+ gnutls_x509_crt_t cert = NULL, issuer = NULL, signer = NULL;
+ gnutls_x509_trust_list_t list;
+ unsigned verify;
+
+ /* init response */
+
+ ret = gnutls_ocsp_resp_init(&resp);
+ if (ret != 0) {
+ fail("gnutls_ocsp_resp_init\n");
+ exit(1);
+ }
+
+ /* import ocsp response */
+
+ ret = gnutls_ocsp_resp_import(resp, &blog_resp);
+ if (ret != 0) {
+ fail("gnutls_ocsp_resp_import %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_init (cert) %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_init(&issuer);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_init (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_init(&signer);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_init (signer) %d\n", ret);
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(cert, &blog_cert_data,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import (cert) %d\n", ret);
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(issuer, &blog_issuer_data,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(signer, &blog_signer_data,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fail("gnutls_x509_crt_import (signer) %d\n", ret);
+ exit(1);
+ }
+
+ /* check direct verify with signer (should succeed) */
+
+ ret = gnutls_ocsp_resp_verify_direct(resp, signer, &verify, 0);
+ if (ret < 0) {
+ fail("gnutls_ocsp_resp_verify_direct (signer) %d\n", ret);
+ exit(1);
+ }
+
+ if (verify != 0) {
+ fail("gnutls_ocsp_resp_verify_direct %d\n", verify);
+ exit(1);
+ }
+
+ /* check direct verify with cert (should fail) */
+
+ ret = gnutls_ocsp_resp_verify_direct(resp, cert, &verify, 0);
+ if (ret < 0) {
+ fail("gnutls_ocsp_resp_verify_direct (cert) %d\n", ret);
+ exit(1);
+ }
+
+ if (verify != GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER) {
+ fail("gnutls_ocsp_resp_verify_direct3 %d\n", verify);
+ exit(1);
+ }
+
+ /* check trust verify with issuer (should succeed) */
+
+ ret = gnutls_x509_trust_list_init(&list, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_init %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_trust_list_add_cas(list, &issuer, 1, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_add_cas %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_resp_verify(resp, list, &verify, 0);
+ if (ret < 0) {
+ fail("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ if (verify != 0) {
+ fail("gnutls_ocsp_resp_verify %d\n", verify);
+ exit(1);
+ }
+
+ gnutls_x509_trust_list_deinit(list, 0);
+
+ /* check trust verify with signer (should succeed) */
+
+ ret = gnutls_x509_trust_list_init(&list, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_init %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_trust_list_add_cas(list, &signer, 1, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_add_cas %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_resp_verify(resp, list, &verify, 0);
+ if (ret < 0) {
+ fail("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ if (verify != 0) {
+ fail("gnutls_ocsp_resp_verify %d\n", verify);
+ exit(1);
+ }
+
+ gnutls_x509_trust_list_deinit(list, 0);
+
+ /* check trust verify with cert (should fail) */
+
+ ret = gnutls_x509_trust_list_init(&list, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_init %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_trust_list_add_cas(list, &cert, 1, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_add_cas %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_resp_verify(resp, list, &verify, 0);
+ if (ret < 0) {
+ fail("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ if (verify != GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER) {
+ fail("gnutls_ocsp_resp_verify %d\n", verify);
+ exit(1);
+ }
+
+ gnutls_x509_trust_list_deinit(list, 0);
+
+ /* check trust verify with all certs (should succeed) */
+
+ ret = gnutls_x509_trust_list_init(&list, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_init %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_trust_list_add_cas(list, &cert, 1, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_add_cas %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_trust_list_add_cas(list, &issuer, 1, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_add_cas %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_trust_list_add_cas(list, &signer, 1, 0);
+ if (ret < 0) {
+ fail("gnutls_x509_trust_list_add_cas %d\n", ret);
+ exit(1);
+ }
+
+ ret = gnutls_ocsp_resp_verify(resp, list, &verify, 0);
+ if (ret < 0) {
+ fail("gnutls_ocsp_resp_verify (issuer) %d\n", ret);
+ exit(1);
+ }
+
+ if (verify != 0) {
+ fail("gnutls_ocsp_resp_verify %d\n", verify);
+ exit(1);
+ }
+
+ gnutls_x509_trust_list_deinit(list, 0);
+
+ /* cleanup */
+
+ gnutls_ocsp_resp_deinit(resp);
+ gnutls_x509_crt_deinit(cert);
+ gnutls_x509_crt_deinit(issuer);
+ gnutls_x509_crt_deinit(signer);
}
-void
-doit (void)
+void doit(void)
{
- int ret;
-
- ret = global_init ();
- if (ret < 0)
- {
- fail ("global_init\n");
- exit (1);
- }
-
- gnutls_global_set_time_function (mytime);
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (99);
-
- ocsp_invalid_calls ();
- req_parse ();
- resp_import ();
- req_addcert_id ();
- req_addcert ();
- resp_verify ();
-
- /* we're done */
-
- gnutls_global_deinit ();
+ int ret;
+
+ ret = global_init();
+ if (ret < 0) {
+ fail("global_init\n");
+ exit(1);
+ }
+
+ gnutls_global_set_time_function(mytime);
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(99);
+
+ ocsp_invalid_calls();
+ req_parse();
+ resp_import();
+ req_addcert_id();
+ req_addcert();
+ resp_verify();
+
+ /* we're done */
+
+ gnutls_global_deinit();
}
diff --git a/tests/openpgp-auth.c b/tests/openpgp-auth.c
index ac2b616357..67faf73898 100644
--- a/tests/openpgp-auth.c
+++ b/tests/openpgp-auth.c
@@ -46,265 +46,281 @@ static const char message[] = "Hello, brave GNU world!";
static const char pub_key_file[] = "../guile/tests/openpgp-pub.asc";
static const char priv_key_file[] = "../guile/tests/openpgp-sec.asc";
static const char *key_id = NULL;
-static gnutls_datum_t stored_cli_cert = {NULL, 0};
+static gnutls_datum_t stored_cli_cert = { NULL, 0 };
-static void
-log_message (int level, const char *message)
+static void log_message(int level, const char *message)
{
- fprintf (stderr, "[%5d|%2d] %s", getpid (), level, message);
+ fprintf(stderr, "[%5d|%2d] %s", getpid(), level, message);
}
static
int key_recv_func(gnutls_session_t session, const unsigned char *keyfpr,
- unsigned int keyfpr_length, gnutls_datum_t * key)
+ unsigned int keyfpr_length, gnutls_datum_t * key)
{
key->data = gnutls_malloc(stored_cli_cert.size);
memcpy(key->data, stored_cli_cert.data, stored_cli_cert.size);
key->size = stored_cli_cert.size;
-
+
return 0;
}
-void
-doit ()
+void doit()
{
- int err, i;
- int sockets[2];
- const char *srcdir;
- pid_t child;
- char pub_key_path[512], priv_key_path[512];
-
- global_init ();
-
- srcdir = getenv ("srcdir") ? getenv ("srcdir") : ".";
-
- for (i = 0; i < 5; i++)
- {
- if (i <= 1)
- key_id = NULL; /* try using the master key */
- else if (i == 2)
- key_id = "auto"; /* test auto */
- else if (i >= 3)
- key_id = "f30fd423c143e7ba";
-
- if (debug)
- {
- gnutls_global_set_log_level (5);
- gnutls_global_set_log_function (log_message);
- }
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err != 0)
- fail ("socketpair %s\n", strerror (errno));
-
- if (sizeof(pub_key_path) < strlen (srcdir) + strlen (pub_key_file) + 2)
- abort();
-
- strcpy (pub_key_path, srcdir);
- strcat (pub_key_path, "/");
- strcat (pub_key_path, pub_key_file);
-
- if (sizeof(priv_key_path) < strlen (srcdir) + strlen (priv_key_file) + 2)
- abort();
-
- strcpy (priv_key_path, srcdir);
- strcat (priv_key_path, "/");
- strcat (priv_key_path, priv_key_file);
-
- child = fork ();
- if (child == -1)
- fail ("fork %s\n", strerror (errno));
-
- if (child == 0)
- {
- /* Child process (client). */
- gnutls_session_t session;
- gnutls_certificate_credentials_t cred;
- ssize_t sent;
-
- if (debug)
- printf ("client process %i\n", getpid ());
-
- err = gnutls_init (&session, GNUTLS_CLIENT);
- if (err != 0)
- fail ("client session %d\n", err);
-
- if (i==0) /* we use the primary key which is RSA. Test the RSA ciphersuite */
- gnutls_priority_set_direct (session,
- "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+RSA:+CTYPE-OPENPGP",
- NULL);
- else
- gnutls_priority_set_direct (session,
- "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+CTYPE-OPENPGP",
- NULL);
- gnutls_transport_set_int (session, sockets[0]);
-
- err = gnutls_certificate_allocate_credentials (&cred);
- if (err != 0)
- fail ("client credentials %d\n", err);
-
- err =
- gnutls_certificate_set_openpgp_key_file2 (cred,
- pub_key_path,
- priv_key_path, key_id,
- GNUTLS_OPENPGP_FMT_BASE64);
- if (err != 0)
- fail ("client openpgp keys %s\n", gnutls_strerror (err));
-
- err =
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cred);
- if (err != 0)
- fail ("client credential_set %d\n", err);
-
- gnutls_dh_set_prime_bits (session, 1024);
-
- if (i==4)
- gnutls_openpgp_send_cert(session, GNUTLS_OPENPGP_CERT_FINGERPRINT);
-
- err = gnutls_handshake (session);
- if (err != 0)
- fail ("client handshake %s (%d) \n", gnutls_strerror (err), err);
- else if (debug)
- printf ("client handshake successful\n");
-
- sent = gnutls_record_send (session, message, sizeof (message));
- if (sent != sizeof (message))
- fail ("client sent %li vs. %li\n",
- (long) sent, (long) sizeof (message));
-
- err = gnutls_bye (session, GNUTLS_SHUT_RDWR);
- if (err != 0)
- fail ("client bye %d\n", err);
-
- if (debug)
- printf ("client done\n");
-
- gnutls_deinit(session);
- gnutls_certificate_free_credentials (cred);
- gnutls_free(stored_cli_cert.data);
- gnutls_global_deinit ();
- return;
- }
- else
- {
- /* Parent process (server). */
- gnutls_session_t session;
- gnutls_dh_params_t dh_params;
- gnutls_certificate_credentials_t cred;
- char greetings[sizeof (message) * 2];
- ssize_t received;
- pid_t done;
- int status;
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
-
- if (debug)
- printf ("server process %i (child %i)\n", getpid (), child);
-
- err = gnutls_init (&session, GNUTLS_SERVER);
- if (err != 0)
- fail ("server session %d\n", err);
-
- gnutls_priority_set_direct (session,
- "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+RSA:+CTYPE-OPENPGP",
- NULL);
- gnutls_transport_set_int (session, sockets[1]);
-
- err = gnutls_certificate_allocate_credentials (&cred);
- if (err != 0)
- fail ("server credentials %d\n", err);
-
- err =
- gnutls_certificate_set_openpgp_key_file2 (cred,
- pub_key_path,
- priv_key_path, key_id,
- GNUTLS_OPENPGP_FMT_BASE64);
- if (err != 0)
- fail ("server openpgp keys %s\n", gnutls_strerror (err));
-
- err = gnutls_dh_params_init (&dh_params);
- if (err)
- fail ("server DH params init %d\n", err);
-
- err =
- gnutls_dh_params_import_pkcs3 (dh_params, &p3,
- GNUTLS_X509_FMT_PEM);
- if (err)
- fail ("server DH params generate %d\n", err);
-
- gnutls_certificate_set_dh_params (cred, dh_params);
-
- err =
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cred);
- if (err != 0)
- fail ("server credential_set %d\n", err);
-
- gnutls_certificate_server_set_request (session,
- GNUTLS_CERT_REQUIRE);
-
- if (i==4)
- gnutls_openpgp_set_recv_key_function(session, key_recv_func);
-
- err = gnutls_handshake (session);
- if (err != 0)
- fail ("server handshake %s (%d) \n", gnutls_strerror (err), err);
-
- if (stored_cli_cert.data == NULL)
- {
- const gnutls_datum_t* d;
- unsigned int d_size;
- d = gnutls_certificate_get_peers(session, &d_size);
- if (d != NULL)
- {
- stored_cli_cert.data = gnutls_malloc(d[0].size);
- memcpy(stored_cli_cert.data, d[0].data, d[0].size);
- stored_cli_cert.size = d[0].size;
- }
- }
-
- received =
- gnutls_record_recv (session, greetings, sizeof (greetings));
- if (received != sizeof (message)
- || memcmp (greetings, message, sizeof (message)))
- fail ("server received %li vs. %li\n", (long) received,
- (long) sizeof (message));
-
- err = gnutls_bye (session, GNUTLS_SHUT_RDWR);
- if (err != 0)
- fail ("server bye %s (%d) \n", gnutls_strerror (err), err);
-
- if (debug)
- printf ("server done\n");
-
- gnutls_deinit(session);
- gnutls_certificate_free_credentials (cred);
- gnutls_dh_params_deinit (dh_params);
-
- done = wait (&status);
- if (done < 0)
- fail ("wait %s\n", strerror (errno));
-
- if (done != child)
- fail ("who's that?! %d\n", done);
-
- if (WIFEXITED (status))
- {
- if (WEXITSTATUS (status) != 0)
- fail ("child exited with status %d\n", WEXITSTATUS (status));
- }
- else if (WIFSIGNALED (status))
- fail ("child stopped by signal %d\n", WTERMSIG (status));
- else
- fail ("child failed: %d\n", status);
- }
- }
-
- gnutls_free(stored_cli_cert.data);
- gnutls_global_deinit ();
+ int err, i;
+ int sockets[2];
+ const char *srcdir;
+ pid_t child;
+ char pub_key_path[512], priv_key_path[512];
+
+ global_init();
+
+ srcdir = getenv("srcdir") ? getenv("srcdir") : ".";
+
+ for (i = 0; i < 5; i++) {
+ if (i <= 1)
+ key_id = NULL; /* try using the master key */
+ else if (i == 2)
+ key_id = "auto"; /* test auto */
+ else if (i >= 3)
+ key_id = "f30fd423c143e7ba";
+
+ if (debug) {
+ gnutls_global_set_log_level(5);
+ gnutls_global_set_log_function(log_message);
+ }
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err != 0)
+ fail("socketpair %s\n", strerror(errno));
+
+ if (sizeof(pub_key_path) <
+ strlen(srcdir) + strlen(pub_key_file) + 2)
+ abort();
+
+ strcpy(pub_key_path, srcdir);
+ strcat(pub_key_path, "/");
+ strcat(pub_key_path, pub_key_file);
+
+ if (sizeof(priv_key_path) <
+ strlen(srcdir) + strlen(priv_key_file) + 2)
+ abort();
+
+ strcpy(priv_key_path, srcdir);
+ strcat(priv_key_path, "/");
+ strcat(priv_key_path, priv_key_file);
+
+ child = fork();
+ if (child == -1)
+ fail("fork %s\n", strerror(errno));
+
+ if (child == 0) {
+ /* Child process (client). */
+ gnutls_session_t session;
+ gnutls_certificate_credentials_t cred;
+ ssize_t sent;
+
+ if (debug)
+ printf("client process %i\n", getpid());
+
+ err = gnutls_init(&session, GNUTLS_CLIENT);
+ if (err != 0)
+ fail("client session %d\n", err);
+
+ if (i == 0) /* we use the primary key which is RSA. Test the RSA ciphersuite */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+RSA:+CTYPE-OPENPGP",
+ NULL);
+ else
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+CTYPE-OPENPGP",
+ NULL);
+ gnutls_transport_set_int(session, sockets[0]);
+
+ err =
+ gnutls_certificate_allocate_credentials(&cred);
+ if (err != 0)
+ fail("client credentials %d\n", err);
+
+ err =
+ gnutls_certificate_set_openpgp_key_file2(cred,
+ pub_key_path,
+ priv_key_path,
+ key_id,
+ GNUTLS_OPENPGP_FMT_BASE64);
+ if (err != 0)
+ fail("client openpgp keys %s\n",
+ gnutls_strerror(err));
+
+ err =
+ gnutls_credentials_set(session,
+ GNUTLS_CRD_CERTIFICATE,
+ cred);
+ if (err != 0)
+ fail("client credential_set %d\n", err);
+
+ gnutls_dh_set_prime_bits(session, 1024);
+
+ if (i == 4)
+ gnutls_openpgp_send_cert(session,
+ GNUTLS_OPENPGP_CERT_FINGERPRINT);
+
+ err = gnutls_handshake(session);
+ if (err != 0)
+ fail("client handshake %s (%d) \n",
+ gnutls_strerror(err), err);
+ else if (debug)
+ printf("client handshake successful\n");
+
+ sent =
+ gnutls_record_send(session, message,
+ sizeof(message));
+ if (sent != sizeof(message))
+ fail("client sent %li vs. %li\n",
+ (long) sent, (long) sizeof(message));
+
+ err = gnutls_bye(session, GNUTLS_SHUT_RDWR);
+ if (err != 0)
+ fail("client bye %d\n", err);
+
+ if (debug)
+ printf("client done\n");
+
+ gnutls_deinit(session);
+ gnutls_certificate_free_credentials(cred);
+ gnutls_free(stored_cli_cert.data);
+ gnutls_global_deinit();
+ return;
+ } else {
+ /* Parent process (server). */
+ gnutls_session_t session;
+ gnutls_dh_params_t dh_params;
+ gnutls_certificate_credentials_t cred;
+ char greetings[sizeof(message) * 2];
+ ssize_t received;
+ pid_t done;
+ int status;
+ const gnutls_datum_t p3 =
+ { (void *) pkcs3, strlen(pkcs3) };
+
+ if (debug)
+ printf("server process %i (child %i)\n",
+ getpid(), child);
+
+ err = gnutls_init(&session, GNUTLS_SERVER);
+ if (err != 0)
+ fail("server session %d\n", err);
+
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+RSA:+CTYPE-OPENPGP",
+ NULL);
+ gnutls_transport_set_int(session, sockets[1]);
+
+ err =
+ gnutls_certificate_allocate_credentials(&cred);
+ if (err != 0)
+ fail("server credentials %d\n", err);
+
+ err =
+ gnutls_certificate_set_openpgp_key_file2(cred,
+ pub_key_path,
+ priv_key_path,
+ key_id,
+ GNUTLS_OPENPGP_FMT_BASE64);
+ if (err != 0)
+ fail("server openpgp keys %s\n",
+ gnutls_strerror(err));
+
+ err = gnutls_dh_params_init(&dh_params);
+ if (err)
+ fail("server DH params init %d\n", err);
+
+ err =
+ gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
+ if (err)
+ fail("server DH params generate %d\n",
+ err);
+
+ gnutls_certificate_set_dh_params(cred, dh_params);
+
+ err =
+ gnutls_credentials_set(session,
+ GNUTLS_CRD_CERTIFICATE,
+ cred);
+ if (err != 0)
+ fail("server credential_set %d\n", err);
+
+ gnutls_certificate_server_set_request(session,
+ GNUTLS_CERT_REQUIRE);
+
+ if (i == 4)
+ gnutls_openpgp_set_recv_key_function
+ (session, key_recv_func);
+
+ err = gnutls_handshake(session);
+ if (err != 0)
+ fail("server handshake %s (%d) \n",
+ gnutls_strerror(err), err);
+
+ if (stored_cli_cert.data == NULL) {
+ const gnutls_datum_t *d;
+ unsigned int d_size;
+ d = gnutls_certificate_get_peers(session,
+ &d_size);
+ if (d != NULL) {
+ stored_cli_cert.data =
+ gnutls_malloc(d[0].size);
+ memcpy(stored_cli_cert.data,
+ d[0].data, d[0].size);
+ stored_cli_cert.size = d[0].size;
+ }
+ }
+
+ received =
+ gnutls_record_recv(session, greetings,
+ sizeof(greetings));
+ if (received != sizeof(message)
+ || memcmp(greetings, message, sizeof(message)))
+ fail("server received %li vs. %li\n",
+ (long) received,
+ (long) sizeof(message));
+
+ err = gnutls_bye(session, GNUTLS_SHUT_RDWR);
+ if (err != 0)
+ fail("server bye %s (%d) \n",
+ gnutls_strerror(err), err);
+
+ if (debug)
+ printf("server done\n");
+
+ gnutls_deinit(session);
+ gnutls_certificate_free_credentials(cred);
+ gnutls_dh_params_deinit(dh_params);
+
+ done = wait(&status);
+ if (done < 0)
+ fail("wait %s\n", strerror(errno));
+
+ if (done != child)
+ fail("who's that?! %d\n", done);
+
+ if (WIFEXITED(status)) {
+ if (WEXITSTATUS(status) != 0)
+ fail("child exited with status %d\n", WEXITSTATUS(status));
+ } else if (WIFSIGNALED(status))
+ fail("child stopped by signal %d\n",
+ WTERMSIG(status));
+ else
+ fail("child failed: %d\n", status);
+ }
+ }
+
+ gnutls_free(stored_cli_cert.data);
+ gnutls_global_deinit();
}
#else
-void
-doit ()
+void doit()
{
- exit (77);
+ exit(77);
}
#endif
diff --git a/tests/openpgp-auth2.c b/tests/openpgp-auth2.c
index ab2f3a92bc..12accbaa67 100644
--- a/tests/openpgp-auth2.c
+++ b/tests/openpgp-auth2.c
@@ -52,212 +52,227 @@ static const char message[] = "Hello, brave GNU world!";
static const char pub_key_file[] = "../guile/tests/openpgp-pub.asc";
static const char priv_key_file[] = "../guile/tests/openpgp-sec.asc";
static const char *key_id = NULL
- /* FIXME: The values below don't work as expected. */
- /* "auto" */
- /* "bd572cdcccc07c35" */ ;
+ /* FIXME: The values below don't work as expected. */
+ /* "auto" */
+ /* "bd572cdcccc07c35" */ ;
-static void
-log_message (int level, const char *message)
+static void log_message(int level, const char *message)
{
- fprintf (stderr, "[%5d|%2d] %s", getpid (), level, message);
+ fprintf(stderr, "[%5d|%2d] %s", getpid(), level, message);
}
-void
-doit ()
+void doit()
{
- int err;
- int sockets[2];
- const char *srcdir;
- char pub_key_path[512], priv_key_path[512];
- pid_t child;
-
- global_init ();
-
- srcdir = getenv ("srcdir") ? getenv ("srcdir") : ".";
-
- if (debug)
- {
- gnutls_global_set_log_level (10);
- gnutls_global_set_log_function (log_message);
- }
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err != 0)
- fail ("socketpair %s\n", strerror (errno));
-
- if (sizeof(pub_key_path) < strlen (srcdir) + strlen (pub_key_file) + 2)
- abort();
-
- strcpy (pub_key_path, srcdir);
- strcat (pub_key_path, "/");
- strcat (pub_key_path, pub_key_file);
-
- if (sizeof(priv_key_path) < strlen (srcdir) + strlen (priv_key_file) + 2)
- abort();
-
- strcpy (priv_key_path, srcdir);
- strcat (priv_key_path, "/");
- strcat (priv_key_path, priv_key_file);
-
- child = fork ();
- if (child == -1)
- fail ("fork %s\n", strerror (errno));
-
- if (child == 0)
- {
- /* Child process (client). */
- gnutls_session_t session;
- gnutls_certificate_credentials_t cred;
- ssize_t sent;
-
- if (debug)
- printf ("client process %i\n", getpid ());
-
- err = gnutls_init (&session, GNUTLS_CLIENT);
- if (err != 0)
- fail ("client session %d\n", err);
-
- gnutls_priority_set_direct (session, "NONE:+VERS-TLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+CTYPE-OPENPGP", NULL);
- gnutls_transport_set_int (session, sockets[0]);
-
- err = gnutls_certificate_allocate_credentials (&cred);
- if (err != 0)
- fail ("client credentials %d\n", err);
-
- err =
- gnutls_certificate_set_openpgp_key_file2 (cred,
- pub_key_path, priv_key_path,
- key_id,
- GNUTLS_OPENPGP_FMT_BASE64);
- if (err != 0)
- fail ("client openpgp keys %d\n", err);
-
- err = gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cred);
- if (err != 0)
- fail ("client credential_set %d\n", err);
-
- gnutls_dh_set_prime_bits (session, 1024);
-
- err = gnutls_handshake (session);
- if (err != 0)
- fail ("client handshake %s (%d) \n", gnutls_strerror(err), err);
- else if (debug)
- printf ("client handshake successful\n");
-
- sent = gnutls_record_send (session, message, sizeof (message));
- if (sent != sizeof (message))
- fail ("client sent %li vs. %li\n",
- (long) sent, (long) sizeof (message));
-
- err = gnutls_bye (session, GNUTLS_SHUT_RDWR);
- if (err != 0)
- fail ("client bye %d\n", err);
-
- if (debug)
- printf ("client done\n");
-
- gnutls_deinit(session);
- gnutls_certificate_free_credentials (cred);
- }
- else
- {
- /* Parent process (server). */
- gnutls_session_t session;
- gnutls_dh_params_t dh_params;
- gnutls_certificate_credentials_t cred;
- char greetings[sizeof (message) * 2];
- ssize_t received;
- pid_t done;
- int status;
- const gnutls_datum_t p3 = { (void*) pkcs3, strlen (pkcs3) };
-
- if (debug)
- printf ("server process %i (child %i)\n", getpid (), child);
-
- err = gnutls_init (&session, GNUTLS_SERVER);
- if (err != 0)
- fail ("server session %d\n", err);
-
- gnutls_priority_set_direct (session, "NONE:+VERS-TLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+CTYPE-OPENPGP", NULL);
- gnutls_transport_set_int (session, sockets[1]);
-
- err = gnutls_certificate_allocate_credentials (&cred);
- if (err != 0)
- fail ("server credentials %d\n", err);
-
- err =
- gnutls_certificate_set_openpgp_key_file2 (cred,
- pub_key_path, priv_key_path,
- key_id,
- GNUTLS_OPENPGP_FMT_BASE64);
- if (err != 0)
- fail ("server openpgp keys %d\n", err);
-
- err = gnutls_dh_params_init (&dh_params);
- if (err)
- fail ("server DH params init %d\n", err);
-
- err =
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- if (err)
- fail ("server DH params generate %d\n", err);
-
- gnutls_certificate_set_dh_params (cred, dh_params);
-
- err = gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cred);
- if (err != 0)
- fail ("server credential_set %d\n", err);
-
- gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUIRE);
-
- err = gnutls_handshake (session);
- if (err != 0)
- fail ("server handshake %s (%d) \n", gnutls_strerror(err), err);
-
- received = gnutls_record_recv (session, greetings, sizeof (greetings));
- if (received != sizeof (message)
- || memcmp (greetings, message, sizeof (message)))
- fail ("server received %li vs. %li\n",
- (long) received, (long) sizeof (message));
-
- err = gnutls_bye (session, GNUTLS_SHUT_RDWR);
- if (err != 0)
- fail ("server bye %s (%d) \n", gnutls_strerror(err), err);
-
- if (debug)
- printf ("server done\n");
-
- gnutls_deinit(session);
- gnutls_certificate_free_credentials (cred);
- gnutls_dh_params_deinit (dh_params);
-
- done = wait (&status);
- if (done < 0)
- fail ("wait %s\n", strerror (errno));
-
- if (done != child)
- fail ("who's that?! %d\n", done);
-
- if (WIFEXITED (status))
- {
- if (WEXITSTATUS (status) != 0)
- fail ("child exited with status %d\n", WEXITSTATUS (status));
- }
- else if (WIFSIGNALED (status))
- fail ("child stopped by signal %d\n", WTERMSIG (status));
- else
- fail ("child failed: %d\n", status);
- }
-
- gnutls_global_deinit ();
+ int err;
+ int sockets[2];
+ const char *srcdir;
+ char pub_key_path[512], priv_key_path[512];
+ pid_t child;
+
+ global_init();
+
+ srcdir = getenv("srcdir") ? getenv("srcdir") : ".";
+
+ if (debug) {
+ gnutls_global_set_log_level(10);
+ gnutls_global_set_log_function(log_message);
+ }
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err != 0)
+ fail("socketpair %s\n", strerror(errno));
+
+ if (sizeof(pub_key_path) <
+ strlen(srcdir) + strlen(pub_key_file) + 2)
+ abort();
+
+ strcpy(pub_key_path, srcdir);
+ strcat(pub_key_path, "/");
+ strcat(pub_key_path, pub_key_file);
+
+ if (sizeof(priv_key_path) <
+ strlen(srcdir) + strlen(priv_key_file) + 2)
+ abort();
+
+ strcpy(priv_key_path, srcdir);
+ strcat(priv_key_path, "/");
+ strcat(priv_key_path, priv_key_file);
+
+ child = fork();
+ if (child == -1)
+ fail("fork %s\n", strerror(errno));
+
+ if (child == 0) {
+ /* Child process (client). */
+ gnutls_session_t session;
+ gnutls_certificate_credentials_t cred;
+ ssize_t sent;
+
+ if (debug)
+ printf("client process %i\n", getpid());
+
+ err = gnutls_init(&session, GNUTLS_CLIENT);
+ if (err != 0)
+ fail("client session %d\n", err);
+
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+CTYPE-OPENPGP",
+ NULL);
+ gnutls_transport_set_int(session, sockets[0]);
+
+ err = gnutls_certificate_allocate_credentials(&cred);
+ if (err != 0)
+ fail("client credentials %d\n", err);
+
+ err =
+ gnutls_certificate_set_openpgp_key_file2(cred,
+ pub_key_path,
+ priv_key_path,
+ key_id,
+ GNUTLS_OPENPGP_FMT_BASE64);
+ if (err != 0)
+ fail("client openpgp keys %d\n", err);
+
+ err =
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ cred);
+ if (err != 0)
+ fail("client credential_set %d\n", err);
+
+ gnutls_dh_set_prime_bits(session, 1024);
+
+ err = gnutls_handshake(session);
+ if (err != 0)
+ fail("client handshake %s (%d) \n",
+ gnutls_strerror(err), err);
+ else if (debug)
+ printf("client handshake successful\n");
+
+ sent =
+ gnutls_record_send(session, message, sizeof(message));
+ if (sent != sizeof(message))
+ fail("client sent %li vs. %li\n",
+ (long) sent, (long) sizeof(message));
+
+ err = gnutls_bye(session, GNUTLS_SHUT_RDWR);
+ if (err != 0)
+ fail("client bye %d\n", err);
+
+ if (debug)
+ printf("client done\n");
+
+ gnutls_deinit(session);
+ gnutls_certificate_free_credentials(cred);
+ } else {
+ /* Parent process (server). */
+ gnutls_session_t session;
+ gnutls_dh_params_t dh_params;
+ gnutls_certificate_credentials_t cred;
+ char greetings[sizeof(message) * 2];
+ ssize_t received;
+ pid_t done;
+ int status;
+ const gnutls_datum_t p3 =
+ { (void *) pkcs3, strlen(pkcs3) };
+
+ if (debug)
+ printf("server process %i (child %i)\n", getpid(),
+ child);
+
+ err = gnutls_init(&session, GNUTLS_SERVER);
+ if (err != 0)
+ fail("server session %d\n", err);
+
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS1.2:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+DHE-DSS:+DHE-RSA:+CTYPE-OPENPGP",
+ NULL);
+ gnutls_transport_set_int(session, sockets[1]);
+
+ err = gnutls_certificate_allocate_credentials(&cred);
+ if (err != 0)
+ fail("server credentials %d\n", err);
+
+ err =
+ gnutls_certificate_set_openpgp_key_file2(cred,
+ pub_key_path,
+ priv_key_path,
+ key_id,
+ GNUTLS_OPENPGP_FMT_BASE64);
+ if (err != 0)
+ fail("server openpgp keys %d\n", err);
+
+ err = gnutls_dh_params_init(&dh_params);
+ if (err)
+ fail("server DH params init %d\n", err);
+
+ err =
+ gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
+ if (err)
+ fail("server DH params generate %d\n", err);
+
+ gnutls_certificate_set_dh_params(cred, dh_params);
+
+ err =
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ cred);
+ if (err != 0)
+ fail("server credential_set %d\n", err);
+
+ gnutls_certificate_server_set_request(session,
+ GNUTLS_CERT_REQUIRE);
+
+ err = gnutls_handshake(session);
+ if (err != 0)
+ fail("server handshake %s (%d) \n",
+ gnutls_strerror(err), err);
+
+ received =
+ gnutls_record_recv(session, greetings,
+ sizeof(greetings));
+ if (received != sizeof(message)
+ || memcmp(greetings, message, sizeof(message)))
+ fail("server received %li vs. %li\n",
+ (long) received, (long) sizeof(message));
+
+ err = gnutls_bye(session, GNUTLS_SHUT_RDWR);
+ if (err != 0)
+ fail("server bye %s (%d) \n", gnutls_strerror(err),
+ err);
+
+ if (debug)
+ printf("server done\n");
+
+ gnutls_deinit(session);
+ gnutls_certificate_free_credentials(cred);
+ gnutls_dh_params_deinit(dh_params);
+
+ done = wait(&status);
+ if (done < 0)
+ fail("wait %s\n", strerror(errno));
+
+ if (done != child)
+ fail("who's that?! %d\n", done);
+
+ if (WIFEXITED(status)) {
+ if (WEXITSTATUS(status) != 0)
+ fail("child exited with status %d\n",
+ WEXITSTATUS(status));
+ } else if (WIFSIGNALED(status))
+ fail("child stopped by signal %d\n",
+ WTERMSIG(status));
+ else
+ fail("child failed: %d\n", status);
+ }
+
+ gnutls_global_deinit();
}
#else
#include <stdlib.h>
-void
-doit ()
+void doit()
{
- exit (77);
+ exit(77);
}
#endif
diff --git a/tests/openpgp-keyring.c b/tests/openpgp-keyring.c
index c7423b8b7d..efdd97c30f 100644
--- a/tests/openpgp-keyring.c
+++ b/tests/openpgp-keyring.c
@@ -33,202 +33,326 @@
/* A hex-encoded raw OpenPGP keyring. This is a copy of (`sha1sum' output):
5fdce61bff528070dfabdd237d91be618c353b4e src/openpgp/cli_ring.gpg */
static unsigned char raw_keyring[] = {
- 0x99, 0x01, 0xA2, 0x04, 0x3C, 0x67, 0x95, 0x8D, 0x11, 0x04, 0x00, 0x80,
- 0xB1, 0x65, 0x21, 0x8B, 0xF8, 0x28, 0x06, 0x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, 0x30, 0xA0, 0x86, 0xC5, 0x9D, 0xED, 0x74, 0x8A, 0x11, 0x93,
- 0x3B, 0x89, 0x41, 0x4B, 0x50, 0xB6, 0xF1, 0x47, 0xD2, 0x18, 0x43, 0x26,
- 0xFF, 0xC2, 0x41, 0x32, 0xDC, 0x40, 0x8D, 0xB6, 0x32, 0xDC, 0x16, 0x33,
- 0x52, 0xD0, 0x8C, 0x03, 0xE6, 0xC6, 0x04, 0x6E, 0x95, 0xA1, 0xEE, 0x62,
- 0xE4, 0xB4, 0x25, 0x44, 0x72, 0x2E, 0x20, 0x57, 0x68, 0x6F, 0x20, 0x28,
- 0x4E, 0x6F, 0x20, 0x63, 0x6F, 0x6D, 0x6D, 0x65, 0x6E, 0x74, 0x73, 0x29,
- 0x20, 0x3C, 0x77, 0x68, 0x6F, 0x40, 0x77, 0x68, 0x6F, 0x69, 0x73, 0x2E,
- 0x6F, 0x72, 0x67, 0x3E, 0x88, 0x5D, 0x04, 0x13, 0x11, 0x02, 0x00, 0x1D,
- 0x05, 0x02, 0x3C, 0x67, 0x95, 0x8D, 0x05, 0x09, 0x03, 0xC2, 0x67, 0x00,
- 0x05, 0x0B, 0x07, 0x0A, 0x03, 0x04, 0x03, 0x15, 0x03, 0x02, 0x03, 0x16,
- 0x02, 0x01, 0x02, 0x17, 0x80, 0x00, 0x0A, 0x09, 0x10, 0x35, 0x14, 0x5C,
- 0xEA, 0xA7, 0xD9, 0x3C, 0x3F, 0x96, 0x58, 0x00, 0x9F, 0x78, 0x99, 0xCB,
- 0xC9, 0xF6, 0xE9, 0x4C, 0x30, 0x7B, 0x98, 0x38, 0x77, 0x68, 0x04, 0xDB,
- 0xFB, 0x43, 0xD7, 0xCF, 0x6F, 0x00, 0xA0, 0xA4, 0x5D, 0x02, 0x90, 0x55,
- 0x33, 0xA0, 0x6D, 0xCB, 0xEB, 0xD6, 0xC9, 0x71, 0xFA, 0x1D, 0xF1, 0x7A,
- 0x65, 0x38, 0xFE, 0x99, 0x01,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x13, 0x80, 0x8E, 0x9F, 0x5B, 0x10, 0xCE, 0x07, 0x5D, 0x34, 0x17,
- 0xB8, 0x01, 0x16, 0x49, 0x18, 0xB1, 0x31, 0xD3, 0x54, 0x4C, 0x87, 0x65,
- 0xA8, 0xEC, 0xB9, 0x97, 0x1F, 0x61, 0xA0, 0x9F, 0xC7, 0x3D, 0x50, 0x98,
- 0x06, 0x10, 0x6B, 0x59, 0x77, 0xD2, 0x11, 0xCB, 0x0E, 0x1D, 0x04, 0xD0,
- 0xED, 0x96, 0xBC, 0xE8, 0x9B, 0xAE, 0x8F, 0x73, 0xD8, 0x00, 0xB0, 0x52,
- 0x13, 0x9C, 0xBF, 0x8D, 0xB4, 0x49, 0x4F, 0x70, 0x65, 0x6E, 0x43, 0x44,
- 0x4B, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x6B, 0x65, 0x79, 0x20, 0x28,
- 0x4F, 0x6E, 0x6C, 0x79, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x6E, 0x64, 0x65,
- 0x64, 0x20, 0x66, 0x6F, 0x72, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x70,
- 0x75, 0x72, 0x70, 0x6F, 0x73, 0x65, 0x73, 0x21, 0x29, 0x20, 0x3C, 0x6F,
- 0x70, 0x65, 0x6E, 0x63, 0x64, 0x6B, 0x40, 0x66, 0x6F, 0x6F, 0x2D, 0x62,
- 0x61, 0x72, 0x2E, 0x6F, 0x72, 0x67, 0x3E, 0x88, 0x62, 0x04, 0x13, 0x11,
- 0x02, 0x00, 0x1A, 0x05, 0x02, 0x3C, 0x4A, 0xC5, 0x6C, 0x05, 0x0B, 0x07,
- 0x0A, 0x03, 0x04, 0x03, 0x15, 0x03, 0x02, 0x03, 0x16, 0x02, 0x01, 0x02,
- 0x1E, 0x01, 0x02, 0x17, 0x80, 0x00, 0x12, 0x09, 0x10, 0xBD, 0x57, 0x2C,
- 0xDC, 0xCC, 0xC0, 0x7C, 0x35, 0x07, 0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 0x9E, 0xB4,
+ 0x11,
+ 0x9A, 0x6F, 0xFB, 0xF4, 0x49, 0xE7, 0xD1, 0x54, 0xD8, 0x2E, 0x05,
+ 0xD4,
+ 0x08, 0x61, 0xDB
};
/* The ID of a key known to be in the above keyring. */
static const gnutls_openpgp_keyid_t id_in_keyring =
- /* "Dr. Who", first key in the keyring */
+ /* "Dr. Who", first key in the keyring */
{ 0x35, 0x14, 0x5c, 0xea,
- 0xa7, 0xd9, 0x3c, 0x3f
+ 0xa7, 0xd9, 0x3c, 0x3f
};
static const gnutls_openpgp_keyid_t id2_in_keyring =
- /* OpenCDK test key, second key in the keyring */
+ /* OpenCDK test key, second key in the keyring */
{ 0xbd, 0x57, 0x2c, 0xdc,
- 0xcc, 0xc0, 0x7c, 0x35
+ 0xcc, 0xc0, 0x7c, 0x35
};
static const gnutls_openpgp_keyid_t id_not_in_keyring =
- { 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
+ { 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%d| %s", level, str);
+ fprintf(stderr, "%d| %s", level, str);
}
-void
-doit (void)
+void doit(void)
{
- gnutls_openpgp_keyring_t keyring;
- gnutls_datum_t data;
- int ret;
-
- ret = global_init ();
- if (ret < 0)
- fail ("init %d\n", ret);
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- ret = gnutls_openpgp_keyring_init (&keyring);
- if (ret < 0)
- fail ("keyring-init %d\n", ret);
-
- data.data = raw_keyring;
- data.size = sizeof (raw_keyring) / sizeof (raw_keyring[0]);
- ret = gnutls_openpgp_keyring_import (keyring, &data,
- GNUTLS_OPENPGP_FMT_RAW);
- if (ret < 0)
- fail ("keyring-import %d\n", ret);
-
- ret = gnutls_openpgp_keyring_check_id (keyring, id_not_in_keyring, 0);
- if (ret == 0)
- fail ("keyring-check-id (not-in-keyring) %d\n", ret);
-
- ret = gnutls_openpgp_keyring_check_id (keyring, id_in_keyring, 0);
- if (ret != 0)
- fail ("keyring-check-id first key %d\n", ret);
-
- ret = gnutls_openpgp_keyring_check_id (keyring, id2_in_keyring, 0);
- if (ret != 0)
- fail ("keyring-check-id second key %d\n", ret);
-
- if (debug)
- success ("done\n");
-
- gnutls_openpgp_keyring_deinit (keyring);
- gnutls_global_deinit ();
+ gnutls_openpgp_keyring_t keyring;
+ gnutls_datum_t data;
+ int ret;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("init %d\n", ret);
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ ret = gnutls_openpgp_keyring_init(&keyring);
+ if (ret < 0)
+ fail("keyring-init %d\n", ret);
+
+ data.data = raw_keyring;
+ data.size = sizeof(raw_keyring) / sizeof(raw_keyring[0]);
+ ret = gnutls_openpgp_keyring_import(keyring, &data,
+ GNUTLS_OPENPGP_FMT_RAW);
+ if (ret < 0)
+ fail("keyring-import %d\n", ret);
+
+ ret =
+ gnutls_openpgp_keyring_check_id(keyring, id_not_in_keyring, 0);
+ if (ret == 0)
+ fail("keyring-check-id (not-in-keyring) %d\n", ret);
+
+ ret = gnutls_openpgp_keyring_check_id(keyring, id_in_keyring, 0);
+ if (ret != 0)
+ fail("keyring-check-id first key %d\n", ret);
+
+ ret = gnutls_openpgp_keyring_check_id(keyring, id2_in_keyring, 0);
+ if (ret != 0)
+ fail("keyring-check-id second key %d\n", ret);
+
+ if (debug)
+ success("done\n");
+
+ gnutls_openpgp_keyring_deinit(keyring);
+ gnutls_global_deinit();
}
/* Local Variables:
diff --git a/tests/openpgp_test.c b/tests/openpgp_test.c
index 4648477b53..861efaa610 100644
--- a/tests/openpgp_test.c
+++ b/tests/openpgp_test.c
@@ -15,150 +15,145 @@
#include <time.h>
#include <assert.h>
-static const char *
-get_pkalgo (int algo)
+static const char *get_pkalgo(int algo)
{
- switch (algo)
- {
- case GNUTLS_PK_DSA:
- return "DSA";
- case GNUTLS_PK_RSA:
- return "RSA";
- }
- return NULL;
+ switch (algo) {
+ case GNUTLS_PK_DSA:
+ return "DSA";
+ case GNUTLS_PK_RSA:
+ return "RSA";
+ }
+ return NULL;
}
-static const char *
-get_pktime (long timestamp)
+static const char *get_pktime(long timestamp)
{
- static char buf[128];
- struct tm *tb;
+ static char buf[128];
+ struct tm *tb;
- tb = localtime (&timestamp);
- sprintf (buf, "%04d-%02d-%02d", tb->tm_year + 1900, tb->tm_mon + 1,
- tb->tm_mday);
- return buf;
+ tb = localtime(&timestamp);
+ sprintf(buf, "%04d-%02d-%02d", tb->tm_year + 1900, tb->tm_mon + 1,
+ tb->tm_mday);
+ return buf;
}
int
-get_pubkey (gnutls_datum_t * pk, const gnutls_datum_t * kr, unsigned long kid)
+get_pubkey(gnutls_datum_t * pk, const gnutls_datum_t * kr,
+ unsigned long kid)
{
- unsigned char buf[4];
+ unsigned char buf[4];
- buf[0] = kid >> 24;
- buf[1] = kid >> 16;
- buf[2] = kid >> 8;
- buf[3] = kid;
- return gnutls_openpgp_get_key (pk, kr, KEY_ATTR_SHORT_KEYID, buf);
+ buf[0] = kid >> 24;
+ buf[1] = kid >> 16;
+ buf[2] = kid >> 8;
+ buf[3] = kid;
+ return gnutls_openpgp_get_key(pk, kr, KEY_ATTR_SHORT_KEYID, buf);
}
-int
-main (int argc, char **argv)
+int main(int argc, char **argv)
{
- gnutls_certificate_credentials ctx;
- gnutls_datum_t dat, xml, pk;
- gnutls_openpgp_name uid;
- gnutls_privkey *pkey;
- gnutls_cert *cert;
- unsigned char fpr[20], keyid[8];
- char *s, *t;
- size_t fprlen = 0;
- int rc, nbits = 0, i;
-
- rc = gnutls_certificate_allocate_credentials (&ctx);
- assert (rc == 0);
-
- s = "../doc/credentials/openpgp/cli_ring.gpg";
- rc = gnutls_certificate_set_openpgp_keyring_file (ctx, s);
- assert (rc == 0);
-
- s = "../doc/credentials/openpgp/pub.asc";
- t = "../doc/credentials/openpgp/sec.asc";
- rc = gnutls_certificate_set_openpgp_key_file (ctx, s, t);
- assert (rc == 0);
-
- dat = ctx->cert_list[0]->raw;
- assert (ctx->cert_list[0]);
- printf ("Key v%d\n", gnutls_openpgp_extract_key_version (&dat));
- rc = gnutls_openpgp_extract_key_name (&dat, 1, &uid);
- assert (rc == 0);
- printf ("userID %s\n", uid.name);
-
- rc = gnutls_openpgp_extract_key_pk_algorithm (&dat, &nbits);
- printf ("pk-algorithm %s %d bits\n", get_pkalgo (rc), nbits);
-
- rc = gnutls_openpgp_extract_key_creation_time (&dat);
- printf ("creation time %s\n", get_pktime (rc));
-
- rc = gnutls_openpgp_extract_key_expiration_time (&dat);
- printf ("expiration time %lu\n", rc);
-
- printf ("key fingerprint: ");
- rc = gnutls_openpgp_fingerprint (&dat, fpr, &fprlen);
- assert (rc == 0);
- for (i = 0; i < fprlen / 2; i++)
- printf ("%02X%02X ", fpr[2 * i], fpr[2 * i + 1]);
- printf ("\n");
-
- printf ("key id: ");
- rc = gnutls_openpgp_extract_key_id (&dat, keyid);
- assert (rc == 0);
- for (i = 0; i < 8; i++)
- printf ("%02X", keyid[i]);
- printf ("\n\n");
-
- printf ("Check MPIs\n");
- cert = ctx->cert_list[0];
- printf ("number of certs %d\n", *ctx->cert_list_length);
- assert (*ctx->cert_list_length == 1);
- printf ("number of items %d\n", cert->params_size);
- for (i = 0; i < cert->params_size; i++)
- {
- nbits = gcry_mpi_get_nbits (cert->params[i]);
- printf ("mpi %d %d bits\n", i, nbits);
- }
-
- printf ("\nCheck key\n");
- rc = gnutls_openpgp_verify_key (NULL, &ctx->keyring, &dat, 1);
- printf ("certifiacte status...%d\n", rc);
-
- printf ("\nSeckey\n");
- pkey = ctx->pkey;
- assert (pkey);
- assert (pkey->params_size);
- nbits = gcry_mpi_get_nbits (pkey->params[0]);
- rc = pkey->pk_algorithm;
- printf ("pk-algorithm %s %d bits\n", get_pkalgo (rc), nbits);
- printf ("number of items %d\n", pkey->params_size);
- for (i = 0; i < pkey->params_size; i++)
- {
- nbits = gcry_mpi_get_nbits (pkey->params[i]);
- printf ("mpi %d %d bits\n", i, nbits);
- }
-
- printf ("\nGet public key\n");
- rc = get_pubkey (&pk, &ctx->keyring, 0xA7D93C3F);
- assert (rc == 0);
-
- printf ("key fingerprint: ");
- gnutls_openpgp_fingerprint (&pk, fpr, &fprlen);
- for (i = 0; i < fprlen / 2; i++)
- printf ("%02X%02X ", fpr[2 * i], fpr[2 * i + 1]);
- printf ("\n");
- _gnutls_free_datum (&pk);
+ gnutls_certificate_credentials ctx;
+ gnutls_datum_t dat, xml, pk;
+ gnutls_openpgp_name uid;
+ gnutls_privkey *pkey;
+ gnutls_cert *cert;
+ unsigned char fpr[20], keyid[8];
+ char *s, *t;
+ size_t fprlen = 0;
+ int rc, nbits = 0, i;
+
+ rc = gnutls_certificate_allocate_credentials(&ctx);
+ assert(rc == 0);
+
+ s = "../doc/credentials/openpgp/cli_ring.gpg";
+ rc = gnutls_certificate_set_openpgp_keyring_file(ctx, s);
+ assert(rc == 0);
+
+ s = "../doc/credentials/openpgp/pub.asc";
+ t = "../doc/credentials/openpgp/sec.asc";
+ rc = gnutls_certificate_set_openpgp_key_file(ctx, s, t);
+ assert(rc == 0);
+
+ dat = ctx->cert_list[0]->raw;
+ assert(ctx->cert_list[0]);
+ printf("Key v%d\n", gnutls_openpgp_extract_key_version(&dat));
+ rc = gnutls_openpgp_extract_key_name(&dat, 1, &uid);
+ assert(rc == 0);
+ printf("userID %s\n", uid.name);
+
+ rc = gnutls_openpgp_extract_key_pk_algorithm(&dat, &nbits);
+ printf("pk-algorithm %s %d bits\n", get_pkalgo(rc), nbits);
+
+ rc = gnutls_openpgp_extract_key_creation_time(&dat);
+ printf("creation time %s\n", get_pktime(rc));
+
+ rc = gnutls_openpgp_extract_key_expiration_time(&dat);
+ printf("expiration time %lu\n", rc);
+
+ printf("key fingerprint: ");
+ rc = gnutls_openpgp_fingerprint(&dat, fpr, &fprlen);
+ assert(rc == 0);
+ for (i = 0; i < fprlen / 2; i++)
+ printf("%02X%02X ", fpr[2 * i], fpr[2 * i + 1]);
+ printf("\n");
+
+ printf("key id: ");
+ rc = gnutls_openpgp_extract_key_id(&dat, keyid);
+ assert(rc == 0);
+ for (i = 0; i < 8; i++)
+ printf("%02X", keyid[i]);
+ printf("\n\n");
+
+ printf("Check MPIs\n");
+ cert = ctx->cert_list[0];
+ printf("number of certs %d\n", *ctx->cert_list_length);
+ assert(*ctx->cert_list_length == 1);
+ printf("number of items %d\n", cert->params_size);
+ for (i = 0; i < cert->params_size; i++) {
+ nbits = gcry_mpi_get_nbits(cert->params[i]);
+ printf("mpi %d %d bits\n", i, nbits);
+ }
+
+ printf("\nCheck key\n");
+ rc = gnutls_openpgp_verify_key(NULL, &ctx->keyring, &dat, 1);
+ printf("certifiacte status...%d\n", rc);
+
+ printf("\nSeckey\n");
+ pkey = ctx->pkey;
+ assert(pkey);
+ assert(pkey->params_size);
+ nbits = gcry_mpi_get_nbits(pkey->params[0]);
+ rc = pkey->pk_algorithm;
+ printf("pk-algorithm %s %d bits\n", get_pkalgo(rc), nbits);
+ printf("number of items %d\n", pkey->params_size);
+ for (i = 0; i < pkey->params_size; i++) {
+ nbits = gcry_mpi_get_nbits(pkey->params[i]);
+ printf("mpi %d %d bits\n", i, nbits);
+ }
+
+ printf("\nGet public key\n");
+ rc = get_pubkey(&pk, &ctx->keyring, 0xA7D93C3F);
+ assert(rc == 0);
+
+ printf("key fingerprint: ");
+ gnutls_openpgp_fingerprint(&pk, fpr, &fprlen);
+ for (i = 0; i < fprlen / 2; i++)
+ printf("%02X%02X ", fpr[2 * i], fpr[2 * i + 1]);
+ printf("\n");
+ _gnutls_free_datum(&pk);
#if 0
- rc = gnutls_openpgp_key_to_xml (&dat, &xml, 1);
- printf ("rc=%d\n", rc);
- assert (rc == 0);
- xml.data[xml.size] = '\0';
- printf ("%s\n", xml.data);
- _gnutls_free_datum (&xml);
+ rc = gnutls_openpgp_key_to_xml(&dat, &xml, 1);
+ printf("rc=%d\n", rc);
+ assert(rc == 0);
+ xml.data[xml.size] = '\0';
+ printf("%s\n", xml.data);
+ _gnutls_free_datum(&xml);
#endif
- _gnutls_free_datum (&dat);
- gnutls_certificate_free_credentials (ctx);
+ _gnutls_free_datum(&dat);
+ gnutls_certificate_free_credentials(ctx);
- return 0;
+ return 0;
}
diff --git a/tests/openpgpself.c b/tests/openpgpself.c
index 950c67f64e..4fd2522965 100644
--- a/tests/openpgpself.c
+++ b/tests/openpgpself.c
@@ -33,10 +33,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -58,10 +57,10 @@ main (int argc, char** argv)
pid_t child;
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", child ? "server" : "client", level, str);
+ fprintf(stderr, "%s |<%d>| %s", child ? "server" : "client", level,
+ str);
}
/* A very basic TLS client, with anonymous authentication.
@@ -72,184 +71,173 @@ tls_log_func (int level, const char *str)
#define MSG "Hello TLS"
static unsigned char cert_txt[] =
-"-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
-"Version: GnuPG v1.4.10 (GNU/Linux)\n"
-"Comment: Test key for GnuTLS\n"
-"\n"
-"mI0ETYD2OQEEAMHmDBtJii82NbWuYcvEWCYnwa7GTcz2PYikYCcq/t5nkyb5Bfmx\n"
-"mh2hpto7Lr5d1L/shvab1gXCcrWEAREgNNk9LiowtLuTHBdeOFlJ1u1P1rvdFVKq\n"
-"2a6ft77Q5VltUDKPgTqz4NWH2KUlLfTvwJDnq2DxYsbwVpBDURuUocXhABEBAAG0\n"
-"CVRlc3QgdXNlcoi4BBMBAgAiBQJNgPY5AhsvBgsJCAcDAgYVCAIJCgsEFgIDAQIe\n"
-"AQIXgAAKCRAMTrFUBnAKMOVDA/9GEw7AokwJSGvHREriXcvMMK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n"
-"YA6i6aGF2KGx7WQwi2URIMPhihpOvAbkjfszYpFL4VP5wQ==\n"
-"=ydIq\n"
-"-----END PGP PUBLIC KEY BLOCK-----\n";
-
-const gnutls_datum_t cert = { cert_txt, sizeof (cert_txt) };
+ "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
+ "Version: GnuPG v1.4.10 (GNU/Linux)\n"
+ "Comment: Test key for GnuTLS\n"
+ "\n"
+ "mI0ETYD2OQEEAMHmDBtJii82NbWuYcvEWCYnwa7GTcz2PYikYCcq/t5nkyb5Bfmx\n"
+ "mh2hpto7Lr5d1L/shvab1gXCcrWEAREgNNk9LiowtLuTHBdeOFlJ1u1P1rvdFVKq\n"
+ "2a6ft77Q5VltUDKPgTqz4NWH2KUlLfTvwJDnq2DxYsbwVpBDURuUocXhABEBAAG0\n"
+ "CVRlc3QgdXNlcoi4BBMBAgAiBQJNgPY5AhsvBgsJCAcDAgYVCAIJCgsEFgIDAQIe\n"
+ "AQIXgAAKCRAMTrFUBnAKMOVDA/9GEw7AokwJSGvHREriXcvMMKp6c6SYqa0TVsTg\n"
+ "Gh3ENu/KTfGJIM5p+zR6xy+5u5DfP5qLrRdCnoczncR5w9fn3RsP8ju/Ga5z23Q+\n"
+ "6XxRKRkXjE/E0ZFulbuaBom/nhrOmmfqKe7Mor9Y4QwzL2wL3sf6jWLglwdFYS/X\n"
+ "W3wqjLkBogRNgPY5EQQApafdUhCAHj8LLXYCqOXRSPZbKzvB55NwWrdvnod0seUW\n"
+ "aiTSWBlKnSvIomdcII/E3bjdngK4fTJ+Xr5pEJuzBnW3w787r6jBJSq2Lp0T9SP4\n"
+ "CBzd0gXcOQkILvX1VzxAsYVULJA0mhAR3IHFcywjX6ENKuvs7ApniBNoXqi6d3cA\n"
+ "oIAzYKrjyZ+guM4IUlRRrB8abx5vBACJPV+d15GYgzt1d8zLvOl/mzs85Twj2SB1\n"
+ "ZqzK6H/6QxQkEZpP/UVFpXaUGUly3nGEqg1yw4cgqW4SSxgLFz6B23Si+cTsssE6\n"
+ "CYziN1UI6NjxkoG/npMm0wRp7Z+KylEolAdbFBAAprORkt58CrGgpYe8O/35+PWc\n"
+ "J9rjhwxxkQP/VCpbZLugkL4XHWGWFGG35S6k9F3xPPTPoX9Zoud+0bOeoOK5RQHo\n"
+ "e99sVNN4hxxPTM/rJXfTTZUoB6o84yulTSxb6C9ueHotDV0eB9QX1ov/ltmwy3XS\n"
+ "fXEyWtI0CDBuZgEww26Up0pzg4XTBYMkmXrxx3J9ihcCIYyAHoE13EWI5wQYAQIA\n"
+ "CQUCTYD2OQIbIgBSCRAMTrFUBnAKMEcgBBkRAgAGBQJNgPY5AAoJEPMP1CPBQ+e6\n"
+ "3fQAnR7HWLnQTbxCIhlBTZiuJv2HC6cbAJwJ6VsSU6ADCkMuGT3LLNo+UnckK+4i\n"
+ "BACcivWsW40ddtEQ0wno1uP65TmKq3aJrdODXTAnqkmNQKL7X7Fz+nmEWiS+LBH8\n"
+ "lRvAaeRPX2LV+DCJDbAPrYd7LkOHyuM0I+ZApto5cjem/EnO7op2QwkCCa6oUp0l\n"
+ "YA6i6aGF2KGx7WQwi2URIMPhihpOvAbkjfszYpFL4VP5wQ==\n"
+ "=ydIq\n" "-----END PGP PUBLIC KEY BLOCK-----\n";
+
+const gnutls_datum_t cert = { cert_txt, sizeof(cert_txt) };
static unsigned char key_txt[] =
-"-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
-"Version: GnuPG v1.4.10 (GNU/Linux)\n"
-"Comment: Test key for GnuTLS\n"
-"\n"
-"lQHYBE2A9jkBBADB5gwbSYovNjW1rmHLxFgmJ8Guxk3M9j2IpGAnKv7eZ5Mm+QX5\n"
-"sZodoabaOy6+XdS/7Ib2m9YFwnK1hAERIDTZPS4qMLS7kxwXXjhZSdbtT9a73RVS\n"
-"qtmun7e+0OVZbVAyj4E6s+DVh9ilJS3078CQ56tg8WLG8FaQQ1EblKHF4QARAQAB\n"
-"AAP9HJePsXZmqg+UW/Ya9bE+Tm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OI3\n"
-"VQjo2PGSgb+ekybTBGntn4rKUSiUB1sUEACms5GS3nwKsaClh7w7/fn49Zwn2uOH\n"
-"DHGRA/9UKltku6CQvhcdYZYUYbflLqT0XfE89M+hf1mi537Rs56g4rlFAeh732xU\n"
-"03iHHE9Mz+sld9NNlSgHqjzjK6VNLFvoL254ei0NXR4H1BfWi/+W2bDLddJ9cTJa\n"
-"0jQIMG5mATDDbpSnSnODhdMFgySZevHHcn2KFwIhjIAegTXcRQAAn2PK9kOqhjOJ\n"
-"KU5iaagnF176FwhdCO2I5wQYAQIACQUCTYD2OQIbIgBSCRAMTrFUBnAKMEcgBBkR\n"
-"AgAGBQJNgPY5AAoJEPMP1CPBQ+e63fQAniK5kU+dwIbkD+OHJHkC73V6v4D8AJ0Z\n"
-"+GBYj4nhKEX21QXfj55F3Zpg1e4iBACcivWsW40ddtEQ0wno1uP65TmKq3aJrdOD\n"
-"XTAnqkmNQKL7X7Fz+nmEWiS+LBH8lRvAaeRPX2LV+DCJDbAPrYd7LkOHyuM0I+ZA\n"
-"pto5cjem/EnO7op2QwkCCa6oUp0lYA6i6aGF2KGx7WQwi2URIMPhihpOvAbkjfsz\n"
-"YpFL4VP5wQ==\n"
-"=zzoN\n"
-"-----END PGP PRIVATE KEY BLOCK-----\n";
-
-const gnutls_datum_t key = { key_txt, sizeof (key_txt) };
-
-
-static void
-client (int sds[])
+ "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
+ "Version: GnuPG v1.4.10 (GNU/Linux)\n"
+ "Comment: Test key for GnuTLS\n"
+ "\n"
+ "lQHYBE2A9jkBBADB5gwbSYovNjW1rmHLxFgmJ8Guxk3M9j2IpGAnKv7eZ5Mm+QX5\n"
+ "sZodoabaOy6+XdS/7Ib2m9YFwnK1hAERIDTZPS4qMLS7kxwXXjhZSdbtT9a73RVS\n"
+ "qtmun7e+0OVZbVAyj4E6s+DVh9ilJS3078CQ56tg8WLG8FaQQ1EblKHF4QARAQAB\n"
+ "AAP9HJePsXZ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DXLDhyCpbhJLGAsXPoHbdKL5xOyywToJjOI3\n"
+ "VQjo2PGSgb+ekybTBGntn4rKUSiUB1sUEACms5GS3nwKsaClh7w7/fn49Zwn2uOH\n"
+ "DHGRA/9UKltku6CQvhcdYZYUYbflLqT0XfE89M+hf1mi537Rs56g4rlFAeh732xU\n"
+ "03iHHE9Mz+sld9NNlSgHqjzjK6VNLFvoL254ei0NXR4H1BfWi/+W2bDLddJ9cTJa\n"
+ "0jQIMG5mATDDbpSnSnODhdMFgySZevHHcn2KFwIhjIAegTXcRQAAn2PK9kOqhjOJ\n"
+ "KU5iaagnF176FwhdCO2I5wQYAQIACQUCTYD2OQIbIgBSCRAMTrFUBnAKMEcgBBkR\n"
+ "AgAGBQJNgPY5AAoJEPMP1CPBQ+e63fQAniK5kU+dwIbkD+OHJHkC73V6v4D8AJ0Z\n"
+ "+GBYj4nhKEX21QXfj55F3Zpg1e4iBACcivWsW40ddtEQ0wno1uP65TmKq3aJrdOD\n"
+ "XTAnqkmNQKL7X7Fz+nmEWiS+LBH8lRvAaeRPX2LV+DCJDbAPrYd7LkOHyuM0I+ZA\n"
+ "pto5cjem/EnO7op2QwkCCa6oUp0lYA6i6aGF2KGx7WQwi2URIMPhihpOvAbkjfsz\n"
+ "YpFL4VP5wQ==\n" "=zzoN\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
+
+const gnutls_datum_t key = { key_txt, sizeof(key_txt) };
+
+
+static void client(int sds[])
{
- int ret, ii, j;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_certificate_credentials_t xcred;
-
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (9);
-
- gnutls_certificate_allocate_credentials (&xcred);
-
- /* sets the trusted cas file
- */
- if (debug)
- success ("Setting key files...\n");
-
- ret = gnutls_certificate_set_openpgp_key_mem (xcred, &cert, &key,
- GNUTLS_OPENPGP_FMT_BASE64);
- if (ret < 0)
- {
- fail ("Could not set key files...\n");
- return;
- }
-
- for (j = 0; j < SESSIONS; j++)
- {
- int sd = sds[j];
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NORMAL:+CTYPE-OPENPGP", NULL);
-
- /* put the x509 credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake %d failed\n", j);
- gnutls_perror (ret);
- goto end;
- }
- else if (debug)
- {
- success ("client: Handshake %d was completed\n", j);
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- if (debug)
- print_info (session);
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug)
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
- close (sd);
-
- gnutls_deinit (session);
-
- }
-
-end:
-
- gnutls_certificate_free_credentials (xcred);
-
- gnutls_global_deinit ();
+ int ret, ii, j;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_certificate_credentials_t xcred;
+
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(9);
+
+ gnutls_certificate_allocate_credentials(&xcred);
+
+ /* sets the trusted cas file
+ */
+ if (debug)
+ success("Setting key files...\n");
+
+ ret = gnutls_certificate_set_openpgp_key_mem(xcred, &cert, &key,
+ GNUTLS_OPENPGP_FMT_BASE64);
+ if (ret < 0) {
+ fail("Could not set key files...\n");
+ return;
+ }
+
+ for (j = 0; j < SESSIONS; j++) {
+ int sd = sds[j];
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NORMAL:+CTYPE-OPENPGP", NULL);
+
+ /* put the x509 credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ xcred);
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake %d failed\n", j);
+ gnutls_perror(ret);
+ goto end;
+ } else if (debug) {
+ success("client: Handshake %d was completed\n", j);
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ if (debug)
+ print_info(session);
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ close(sd);
+
+ gnutls_deinit(session);
+
+ }
+
+ end:
+
+ gnutls_certificate_free_credentials(xcred);
+
+ gnutls_global_deinit();
}
/* This is a sample TLS 1.0 echo server, using X.509 authentication.
@@ -261,42 +249,42 @@ end:
/* These are global */
gnutls_certificate_credentials_t pgp_cred;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NORMAL:+CTYPE-OPENPGP", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, "NORMAL:+CTYPE-OPENPGP", NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, pgp_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, pgp_cred);
- /* request client certificate if any.
- */
- gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
+ /* request client certificate if any.
+ */
+ gnutls_certificate_server_set_request(session,
+ GNUTLS_CERT_REQUEST);
- gnutls_dh_set_prime_bits (session, DH_BITS);
+ gnutls_dh_set_prime_bits(session, DH_BITS);
- return session;
+ return session;
}
static gnutls_dh_params_t dh_params;
-static int
-generate_dh_params (void)
+static int generate_dh_params(void)
{
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- /* Generate Diffie-Hellman parameters - for use with DHE
- * kx algorithms. These should be discarded and regenerated
- * once a day, once a week or once a month. Depending on the
- * security requirements.
- */
- gnutls_dh_params_init (&dh_params);
- return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ /* Generate Diffie-Hellman parameters - for use with DHE
+ * kx algorithms. These should be discarded and regenerated
+ * once a day, once a week or once a month. Depending on the
+ * security requirements.
+ */
+ gnutls_dh_params_init(&dh_params);
+ return gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
}
int err, ret;
@@ -306,335 +294,320 @@ char buffer[MAX_BUF + 1];
int optval = 1;
static unsigned char server_crt_txt[] =
- "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
- "Version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n"
- "c/ca0asLAerzrHsldRAcwCbWkVxBBHySw2CLFjzpgdXhwRtsytMgHaapfAPbinAW\n"
- "jCPIEJx2gDZeZnTgi4DVbZn5E3UzHGyL69MEoXr5t+vpiemQFd/nGD+h/Q2A76od\n"
- "gvAryRvS1Soj8bcGHjUflayXGOSvaD8P2V5Vz0hS82QZcqWxD8qUBqbcB8atokmO\n"
- "IYxhKyRmO58T5Ma+iaxBTUIwee+pBYDgdH6E2dh9xLlwwzZKaCcIRCQcObkLsMVo\n"
- "fZJo+m0Xf8zI57NeQF+hXJhW7lIrWgQVr8IVp/lgo76acLHfL/t1n0Nhg4r2srz2\n"
- "fpP2w5laQ0qImYLnZhGFHU+rJUyFaHfhD8/svN2LuZkO570pjV/K68EaHnEfk5b8\n"
- "jWu/euohwcCwf20M1kTo3Bg=\n"
- "=Xjon\n" "-----END PGP PUBLIC KEY BLOCK-----\n";
-const gnutls_datum_t server_crt = { server_crt_txt, sizeof (server_crt_txt) };
+ "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
+ "Version: GnuPG v1.4.6 (GNU/Linux)\n"
+ "\n"
+ "mNEER2PogwEGINdIR4u5PR4SwADWwj/ztgtoi7XVbmlfbQTHpBYFxTSC88pISSNy\n"
+ "V/rgnlqunYP77F7aHL4KUReN3v9sKw01xSGEfox/JmlqUUg6CVvTjdeLfkuVIBnH\n"
+ "j+2KMlaxezp7IxtPaTXpXcSf8iOuVq7UX7p6tKbppKXO5GgmfA88VUVvGBs1/PQp\n"
+ "WKQdGrj+6I3RRmDN/hna1jGU/N23230Hbx+bu7g9cviiSh10ri7rdDhVJ67tRkRG\n"
+ "Usy3XO6dWC7EmzZlEO8AEQEAAbQQdGVzdDMuZ251dGxzLm9yZ4kBAAQTAQIAJgUC\n"
+ "R2PogwIbAwUJCWYBgAYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEKAh4/gImZBR\n"
+ "96QGH3E3zynETuQS3++hGMvMXq2mDJeT2e8964y/ifIOBpr2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-----\n";
+const gnutls_datum_t server_crt =
+ { server_crt_txt, sizeof(server_crt_txt) };
static unsigned char server_key_txt[] =
- "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
- "Version: GnuPG v1.4.6 (GNU/Linux)\n"
- "\n"
- "lQLGBEdj6IMBBiDXSEeLuT0eEsAA1sI/87YLaIu11W5pX20Ex6QWBcU0gvPKSEkj\n"
- "clf64J5arp2D++xe2hy+ClEXjd7/bCsNNcUhhH6MfyZpalFIOglb043Xi35LlSAZ\n"
- "x4/tijJWsXs6eyMbT2k16V3En/Ijrlau1F+6erSm6aSlzuRoJnwPPFVFbxgbNfz0\n"
- "KVikHRq4/uiN0UZgzf4Z2tYxlPzdt9t9B28fm7u4PXL4okoddK4u63Q4VSeu7UZE\n"
- "RlLMt1zunVguxJs2ZRDvABEBAAEABhwMx6crpb75ko5gXl9gsYSMj9O/YyCvU7Fi\n"
- "l8FnZ0dKMz3qs7jXyFlttLjh1DzYkXN6PAN5yp3+wnbK/e5eVeNSdo2WpJOwrVWO\n"
- "7pcQovHoKklAjmU98olaRhpv6BBTK+0tGUFaRrmrrYuz2xnwf3+kIpt4ahYW2dr9\n"
- "B+/pvBSVC/sv2+3PEQSsXlWCYVgkQ7WBN4GQdyjjxhQpcWdf8Z6unx4zuS3s7GGM\n"
- "4WaDxmDNCFlTGdrKPQeogtS3LVF9OiRCOvIlAxDmDvnC3zAwO/IvDUHFED9x9hmK\n"
- "MeVwCg8rwDMptVYN2hm+bjNzjV4pimUVd+w7edjEky0Jd/6tTH01CBUWxs9Pfup2\n"
- "cQ9zkYcVz1bwcoqeyRzFCJgi6PiVT38QFEvyusoVkwMQ747D6p7y+R52MEcIvcLb\n"
- "lBXhRviz3rW+Sch4+ohUPvBU41saM5B6UcOmhdPfdvPriI4qXwFxusGWt98NN3aW\n"
- "Ns2/L9kMX/SWnN6Elfj5hrrExDZ2CE60uuvfj+O/uXfO8LUDENE4vQrC399KLbJw\n"
- "uCaqjqLysYA9EY/Nv8RF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KXfL3HTDD\n"
- "CxNg7QIA06tApdo2j1gr3IrroUwQ7yvi56ELB1Lv+W3WLN8lzCfQ6Fs+7IJRrC2R\n"
- "0uzLMGOsSORGAFIbAuLIMpc6rHCeS50hiQGHBBgBAgAPBQJHiKV8AhsCBQkQ6s+A\n"
- "AKgJEKAh4/gImZBRnSAEGQECAAYFAkeIpXwACgkQg3tvtC4P4XYARwQAoCOE72RI\n"
- "4TxS7AQ4qXCxYv0tRRKQcmNz9xrRqwsB6vOseyV1EBzAJtaRXEEEfJLDYIsWPOmB\n"
- "1eHBG2zK0yAdpql8A9uKcBaMI8gQnHaANl5mdOCLgNVtmfkTdTMcbIvr0wShevm3\n"
- "6+mJ6ZAV3+cYP6H9DYDvqh2C8CvJG9LVKiPxtwYeNR+VrJcY5K9oPw/ZXlXPSFLz\n"
- "ZBlypbEPypQGptwHxq2iSY4hjGErJGY7nxPkxr6JrEFNQjB576kFgOB0foTZ2H3E\n"
- "uXDDNkpoJwhEJBw5uQuwxWh9kmj6bRd/zMjns15AX6FcmFbuUitaBBWvwhWn+WCj\n"
- "vppwsd8v+3WfQ2GDivayvPZ+k/bDmVpDSoiZgudmEYUdT6slTIVod+EPz+y83Yu5\n"
- "mQ7nvSmNX8rrwRoecR+TlvyNa7966iHBwLB/bQzWROjcGA==\n"
- "=mZnW\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
-const gnutls_datum_t server_key = { server_key_txt, sizeof (server_key_txt) };
+ "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
+ "Version: GnuPG v1.4.6 (GNU/Linux)\n"
+ "\n"
+ "lQLGBEdj6IMBBiDXSEeLuT0eEsAA1sI/87YLaIu11W5pX20Ex6QWBcU0gvPKSEkj\n"
+ "clf64J5arp2D++xe2hy+ClEXjd7/bCsNNcUhhH6MfyZpalFIOglb043Xi35LlSAZ\n"
+ "x4/tijJWsXs6eyMbT2k16V3En/Ijrlau1F+6erSm6aSlzuRoJnwPPFVFbxgbNfz0\n"
+ "KV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A9uKcBaMI8gQnHaANl5mdOCLgNVtmfkTdTMcbIvr0wShevm3\n"
+ "6+mJ6ZAV3+cYP6H9DYDvqh2C8CvJG9LVKiPxtwYeNR+VrJcY5K9oPw/ZXlXPSFLz\n"
+ "ZBlypbEPypQGptwHxq2iSY4hjGErJGY7nxPkxr6JrEFNQjB576kFgOB0foTZ2H3E\n"
+ "uXDDNkpoJwhEJBw5uQuwxWh9kmj6bRd/zMjns15AX6FcmFbuUitaBBWvwhWn+WCj\n"
+ "vppwsd8v+3WfQ2GDivayvPZ+k/bDmVpDSoiZgudmEYUdT6slTIVod+EPz+y83Yu5\n"
+ "mQ7nvSmNX8rrwRoecR+TlvyNa7966iHBwLB/bQzWROjcGA==\n"
+ "=mZnW\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
+const gnutls_datum_t server_key =
+ { server_key_txt, sizeof(server_key_txt) };
static unsigned char cert2048_txt[] =
-"-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
-"Version: GnuPG v1.4.10 (GNU/Linux)\n"
-"Comment: Test key for GnuTLS\n"
-"\n"
-"mQMuBE1/6bQRCAD8TQlwbkkX3bLJvemSA/BqT/z0OrJsuXKFQqK5Pp0BRTwC4iCg\n"
-"wnUFrr012up66YTzaA0aQpkf48gqxZ1XTGZtZ13+aAArChqKiffR7OS+BnROd+D3\n"
-"NkPF0tWDAqRFsybIej1GcdSyPw+neExSfoeYzNpUW9oX2iLh5QZC/xt++kE8tOr8\n"
-"BXiDW/+rudjf8Rc0ZI10vi12rb64eYd7szE49crS2YsjqarnncN+J7RX3jSifKrZ\n"
-"XqP/F5s/0a1Nfd4xQU2fsnbQwiIuKTQjU6BHD/2ILnhZImEUn4KqZvbEt6yIJiLy\n"
-"u+KerhTiuAhl+sx2DQf3EVxD8EpCwzFqXtF3AQD9Nf9OFJ2Cchwuz8Q5VDBoRFhP\n"
-"4p/hGWqAsmRSZlxdQQf/Q5R15CMDtCrZnuSeptfgdZUfB0gi0aYeKE2TWto5JEVP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B7/ynKCzvfuF8gBBkRCAAGBQJNf+m0AAoJEEPv0WrPxcc9\n"
-"aJwA/0zWQ0RfRhlC1nbf7ISEOF36WQjslGKXjf6z6rSNgphoAP4119FDX9jaW0B8\n"
-"HL9p+XRZTOTSo5GMLUTH5zo+zpTbB2cxAP9moc/i1z2D8AXTnUk7YfSm+o7rFThu\n"
-"2Cx0oO7h1g0MjQD6A/6e68DhK9altb/xqtHeG0jbLmvFRtkC0zu7WZjvSbc=\n"
-"=v3gg\n"
-"-----END PGP PUBLIC KEY BLOCK-----\n";
-
-const gnutls_datum_t cert2048 = { cert2048_txt, sizeof (cert2048_txt) };
+ "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
+ "Version: GnuPG v1.4.10 (GNU/Linux)\n"
+ "Comment: Test key for GnuTLS\n"
+ "\n"
+ "mQMuBE1/6bQRCAD8TQlwbkkX3bLJvemSA/BqT/z0OrJsuXKFQqK5Pp0BRTwC4iCg\n"
+ "wnUFrr012up66YTzaA0aQpkf48gqxZ1XTGZtZ13+aAArChqKiffR7OS+BnROd+D3\n"
+ "NkPF0tWDAqRFsybIej1GcdSyPw+neExSfoeYzNpUW9oX2iLh5QZC/xt++kE8tOr8\n"
+ "BXiDW/+rudjf8Rc0ZI10vi12rb64eYd7szE49crS2YsjqarnncN+J7RX3jSifKrZ\n"
+ "XqP/F5s/0a1Nfd4xQU2fsnbQwiIuKTQjU6BHD/2ILnhZImEUn4KqZvbEt6yIJiLy\n"
+ "u+KerhTiuAhl+sx2DQf3EVxD8EpCwzFqXtF3AQD9Nf9OFJ2Cchwuz8Q5VDBoRFhP\n"
+ "4p/hGWqAsmRSZlxdQQf/Q5R15CMDtCrZnuSeptfgdZUfB0gi0aYeKE2TWto5JEVP\n"
+ "i24IXSF2l1qF9IM2i9Fv7FBwZuLQj6s+vOsq0TSATvaTGdCpvqKOCHKBZtfqD/rv\n"
+ "XJ5o3oEOtDzXdxrW1f8yVbSeWRGT2iNDPNYCnz4d+njAK1q21Qs1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oAP4119FDX9jaW0B8\n"
+ "HL9p+XRZTOTSo5GMLUTH5zo+zpTbB2cxAP9moc/i1z2D8AXTnUk7YfSm+o7rFThu\n"
+ "2Cx0oO7h1g0MjQD6A/6e68DhK9altb/xqtHeG0jbLmvFRtkC0zu7WZjvSbc=\n"
+ "=v3gg\n" "-----END PGP PUBLIC KEY BLOCK-----\n";
+
+const gnutls_datum_t cert2048 = { cert2048_txt, sizeof(cert2048_txt) };
static unsigned char key2048_txt[] =
-"-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
-"Version: GnuPG v1.4.10 (GNU/Linux)\n"
-"Comment: Test key for GnuTLS\n"
-"\n"
-"lQNTBE1/6bQRCAD8TQlwbkkX3bLJvemSA/BqT/z0OrJsuXKFQqK5Pp0BRTwC4iCg\n"
-"wnUFrr012up66YTzaA0aQpkf48gqxZ1XTGZtZ13+aAArChqKiffR7OS+BnROd+D3\n"
-"NkPF0tWDAqRFsybIej1GcdSyPw+neExSfoeYzNpUW9oX2iLh5QZC/xt++kE8tOr8\n"
-"BXiDW/+rudjf8Rc0ZI10vi12rb64eYd7szE49crS2YsjqarnncN+J7RX3jSifKrZ\n"
-"XqP/F5s/0a1Nfd4xQU2fsnbQwiIuKTQjU6BHD/2ILnhZImEUn4KqZvbEt6yIJiLy\n"
-"u+KerhTiuAhl+sx2DQf3EVxD8EpCwzFqXtF3AQD9Nf9OFJ2Cchwuz8Q5VDBoRFhP\n"
-"4p/hGWqAsmRSZlxdQQf/Q5R15CMDtCrZnuSeptfgdZUfB0gi0aYeKE2TWto5JEVP\n"
-"i24IXSF2l1qF9IM2i9Fv7FBwZuLQj6s+vOsq0TSATvaTGdCpvqKOCHKBZtfqD/rv\n"
-"XJ5o3oEOtDzXdxrW1f8yVbSeWRGT2iNDPNYCnz4d+njAK1q21Qs1TRC/MKPP2EqB\n"
-"fjy7VE0k4mFCOCLqfEnEh5hmBzegNo6+pq/i7VHuDG/w6oMUILsf+IM+JlRqeTtJ\n"
-"iDDj6y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ku/SUnVrufZ/jIvQakhpmrLD/\n"
-"ZzEBAJ1w0ez3wUJbsfGlWBkb16pYpIh68/qvTTj84v5N0picAQC1p8JjouN88BJw\n"
-"9UquUquXdK1TY965biHIQ70uaOU4Hw==\n"
-"=Rrkw\n"
-"-----END PGP PRIVATE KEY BLOCK-----\n";
-
-const gnutls_datum_t key2048 = { key2048_txt, sizeof (key2048_txt) };
-
-
-static void
-server (int sds[])
+ "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
+ "Version: GnuPG v1.4.10 (GNU/Linux)\n"
+ "Comment: Test key for GnuTLS\n"
+ "\n"
+ "lQNTBE1/6bQRCAD8TQlwbkkX3bLJvemSA/BqT/z0OrJsuXKFQqK5Pp0BRTwC4iCg\n"
+ "wnUFrr012up66YTzaA0aQpkf48gqxZ1XTGZtZ13+aAArChqKiffR7OS+BnROd+D3\n"
+ "NkPF0tWDAqRFsybIej1GcdSyPw+neExSfoeYzNpUW9oX2iLh5QZC/xt++kE8tOr8\n"
+ "BXiDW/+rudjf8Rc0ZI10vi12rb64eYd7szE49crS2YsjqarnncN+J7RX3jSifKrZ\n"
+ "XqP/F5s/0a1Nfd4xQU2fsnbQwiIuKTQjU6BHD/2ILnhZImEUn4KqZvbEt6yIJiLy\n"
+ "u+KerhTiuAhl+sx2DQf3EVxD8EpCwzFqXtF3AQD9Nf9OFJ2Cchwuz8Q5VDBoRFhP\n"
+ "4p/hGWqAsmRSZlxdQQf/Q5R15CMDtCrZnuSeptfgdZUfB0gi0aYeKE2TWto5JEVP\n"
+ "i24IXSF2l1qF9IM2i9Fv7FBwZuLQj6s+vOsq0TSATvaTGdCpvqKOCHKBZtfqD/rv\n"
+ "XJ5o3oEOtDzXdxrW1f8yVbSeWRGT2iNDPNYCnz4d+njAK1q21Qs1TRC/MKPP2EqB\n"
+ "fjy7VE0k4mFCOCLqfEnEh5hmBzegNo6+pq/i7VHuDG/w6oMUILsf+IM+JlRqeTtJ\n"
+ "iDDj6yVxBdW/0jSn8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/RYoFGrhoY+nL22eza/Ku/SUnVrufZ/jIvQakhpmrLD/\n"
+ "ZzEBAJ1w0ez3wUJbsfGlWBkb16pYpIh68/qvTTj84v5N0picAQC1p8JjouN88BJw\n"
+ "9UquUquXdK1TY965biHIQ70uaOU4Hw==\n"
+ "=Rrkw\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
+
+const gnutls_datum_t key2048 = { key2048_txt, sizeof(key2048_txt) };
+
+
+static void server(int sds[])
{
- int j;
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (5);
-
- if (debug)
- success ("Launched, setting DH parameters...\n");
-
- generate_dh_params ();
-
- for (j = 0; j < SESSIONS; j++)
- {
- int sd = sds[j];
-
- if (j == 0)
- {
- gnutls_certificate_allocate_credentials (&pgp_cred);
- ret = gnutls_certificate_set_openpgp_key_mem2 (pgp_cred, &server_crt,
- &server_key, "auto",
- GNUTLS_OPENPGP_FMT_BASE64);
- }
- else
- {
- gnutls_certificate_free_credentials (pgp_cred);
- gnutls_certificate_allocate_credentials (&pgp_cred);
- ret =
- gnutls_certificate_set_openpgp_key_mem2 (pgp_cred, &cert2048, &key2048,
- "auto", GNUTLS_OPENPGP_FMT_BASE64);
- }
-
- if (ret < 0)
- {
- fail ("Could not set server key files...\n");
- goto end;
- }
-
- gnutls_certificate_set_dh_params (pgp_cred, dh_params);
-
- session = initialize_tls_session ();
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake %d has failed (%s)\n\n",
- j, gnutls_strerror (ret));
- goto end;
- }
- if (debug)
- success ("server: Handshake %d was completed\n", j);
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- if (debug)
- print_info (session);
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- goto end;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
- gnutls_deinit (session);
- }
-
-end:
- gnutls_certificate_free_credentials (pgp_cred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int j;
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(5);
+
+ if (debug)
+ success("Launched, setting DH parameters...\n");
+
+ generate_dh_params();
+
+ for (j = 0; j < SESSIONS; j++) {
+ int sd = sds[j];
+
+ if (j == 0) {
+ gnutls_certificate_allocate_credentials(&pgp_cred);
+ ret =
+ gnutls_certificate_set_openpgp_key_mem2
+ (pgp_cred, &server_crt, &server_key, "auto",
+ GNUTLS_OPENPGP_FMT_BASE64);
+ } else {
+ gnutls_certificate_free_credentials(pgp_cred);
+ gnutls_certificate_allocate_credentials(&pgp_cred);
+ ret =
+ gnutls_certificate_set_openpgp_key_mem2
+ (pgp_cred, &cert2048, &key2048, "auto",
+ GNUTLS_OPENPGP_FMT_BASE64);
+ }
+
+ if (ret < 0) {
+ fail("Could not set server key files...\n");
+ goto end;
+ }
+
+ gnutls_certificate_set_dh_params(pgp_cred, dh_params);
+
+ session = initialize_tls_session();
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake %d has failed (%s)\n\n",
+ j, gnutls_strerror(ret));
+ goto end;
+ }
+ if (debug)
+ success("server: Handshake %d was completed\n", j);
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ if (debug)
+ print_info(session);
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ goto end;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+ gnutls_deinit(session);
+ }
+
+ end:
+ gnutls_certificate_free_credentials(pgp_cred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- int client_sds[SESSIONS], server_sds[SESSIONS];
- int i;
-
- for (i = 0; i < SESSIONS; i++)
- {
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- server_sds[i] = sockets[0];
- client_sds[i] = sockets[1];
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (server_sds);
- wait (&status);
- }
- else
- client (client_sds);
+ int client_sds[SESSIONS], server_sds[SESSIONS];
+ int i;
+
+ for (i = 0; i < SESSIONS; i++) {
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ server_sds[i] = sockets[0];
+ client_sds[i] = sockets[1];
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(server_sds);
+ wait(&status);
+ } else
+ client(client_sds);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/openssl.c b/tests/openssl.c
index 4ed15e6ca7..aee870a707 100644
--- a/tests/openssl.c
+++ b/tests/openssl.c
@@ -30,30 +30,27 @@
#include <gnutls/openssl.h>
-void
-doit (void)
+void doit(void)
{
- MD5_CTX c;
- unsigned char md[MD5_DIGEST_LENGTH];
+ MD5_CTX c;
+ unsigned char md[MD5_DIGEST_LENGTH];
- if (global_init () != 0)
- fail ("global_init\n");
+ if (global_init() != 0)
+ fail("global_init\n");
- if (!gnutls_check_version (GNUTLS_VERSION))
- success ("gnutls_check_version ERROR\n");
+ if (!gnutls_check_version(GNUTLS_VERSION))
+ success("gnutls_check_version ERROR\n");
- MD5_Init (&c);
- MD5_Update (&c, "abc", 3);
- MD5_Final (&(md[0]), &c);
+ MD5_Init(&c);
+ MD5_Update(&c, "abc", 3);
+ MD5_Final(&(md[0]), &c);
- if (memcmp (md, "\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
- "\xd6\x96\x3f\x7d\x28\xe1\x7f\x72", sizeof (md)) != 0)
- {
- hexprint (md, sizeof (md));
- fail ("MD5 failure\n");
- }
- else if (debug)
- success ("MD5 OK\n");
+ if (memcmp(md, "\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
+ "\xd6\x96\x3f\x7d\x28\xe1\x7f\x72", sizeof(md)) != 0) {
+ hexprint(md, sizeof(md));
+ fail("MD5 failure\n");
+ } else if (debug)
+ success("MD5 OK\n");
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
diff --git a/tests/parse_ca.c b/tests/parse_ca.c
index f2d7b19e2f..0502e6a65b 100644
--- a/tests/parse_ca.c
+++ b/tests/parse_ca.c
@@ -29,60 +29,61 @@
#include "utils.h"
static char castr[] =
- "-----BEGIN CERTIFICATE-----\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c;
- gnutls_certificate_credentials_t cred;
- gnutls_datum_t ca = { (unsigned char*)castr, sizeof (castr) };
+ int rc;
+ gnutls_certificate_credentials_t cred;
+ gnutls_datum_t ca = { (unsigned char *) castr, sizeof(castr) };
- global_init ();
+ global_init();
- rc = gnutls_certificate_allocate_credentials (&cred);
- if (rc)
- fail ("allocate cred failed: %d\n", rc);
+ rc = gnutls_certificate_allocate_credentials(&cred);
+ if (rc)
+ fail("allocate cred failed: %d\n", rc);
- rc = gnutls_certificate_set_x509_trust_mem (cred, &ca, GNUTLS_X509_FMT_PEM);
- if (rc != 2)
- fail ("import ca failed: %d\n", rc);
+ rc = gnutls_certificate_set_x509_trust_mem(cred, &ca,
+ GNUTLS_X509_FMT_PEM);
+ if (rc != 2)
+ fail("import ca failed: %d\n", rc);
- ca.data = (unsigned char*) "";
- ca.size = 0;
+ ca.data = (unsigned char *) "";
+ ca.size = 0;
- rc = gnutls_certificate_set_x509_trust_mem (cred, &ca, GNUTLS_X509_FMT_PEM);
- if (rc != 0)
- fail ("import ca failed: %d\n", rc);
+ rc = gnutls_certificate_set_x509_trust_mem(cred, &ca,
+ GNUTLS_X509_FMT_PEM);
+ if (rc != 0)
+ fail("import ca failed: %d\n", rc);
- gnutls_certificate_free_credentials (cred);
+ gnutls_certificate_free_credentials(cred);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- if (debug)
- success ("import ok\n");
+ if (debug)
+ success("import ok\n");
}
diff --git a/tests/pgps2kgnu.c b/tests/pgps2kgnu.c
index f777896582..a8ae98231c 100644
--- a/tests/pgps2kgnu.c
+++ b/tests/pgps2kgnu.c
@@ -37,85 +37,80 @@
#include <gnutls/openpgp.h>
static char dummy_key[] =
- "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
- "Version: GnuPG v1.4.9 (GNU/Linux)\n"
- "\n"
- "lQCVBEO3YdABBACRqqEnucag4+vyZny2M67Pai5+5suIRRvY+Ly8Ms5MvgCi3EVV\n"
- "xT05O/+0ShiRaf+QicC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n"
- "Sy7EHDUxmJm5TzadFp9gq08qNzHBpXSYXXJ3JuWcL1/awUqp3tE1I6zZ0hZ38Ia6\n"
- "SdBMN88idnhDPqPoiKUEGAECAA8FAkO3YdACGyAFCQHhM4AACgkQQZUwSa4UDezm\n"
- "vQP/ZhK+2ly9oI2z7ZcNC/BJRch0/ybQ3haahII8pXXmOThpZohr/LUgoWgCZdXg\n"
- "vP6yiszNk2tIs8KphCAw7Lw/qzDC2hEORjWO4f46qk73RAgSqG/GyzI4ltWiDhqn\n"
- "vnQCFl3+QFSe4zinqykHnLwGPMXv428d/ZjkIc2ju8dRsn4=\n"
- "=CR5w\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
+ "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
+ "Version: GnuPG v1.4.9 (GNU/Linux)\n"
+ "\n"
+ "lQCVBEO3YdABBACRqqEnucag4+vyZny2M67Pai5+5suIRRvY+Ly8Ms5MvgCi3EVV\n"
+ "xT05O/+0ShiRaf+QicCOFrhbU9PZzzU+seEvkeW2UCu4dQfILkmj+HBEIltGnHr3\n"
+ "G0yegHj5pnqrcezERURf2e17gGFWX91cXB9Cm721FPXczuKraphKwCA9PwARAQAB\n"
+ "/gNlAkdOVQG0OURlbW9uc3RyYXRpb24gS2V5IGZvciBTMksgR05VIGV4dGVuc2lv\n"
+ "biAxMDAxIC0tIGdudS1kdW1teYi8BBMBAgAmBQJDt2HQAhsDBQkB4TOABgsJCAcD\n"
+ "AgQVAggDBBYCAwECHgECF4AACgkQQZUwSa4UDezTOQP/TMQXUVrWzHYZGopoPZ2+\n"
+ "ZS3qddiznBHsgb7MGYg1KlTiVJSroDUBCHIUJvdQKZV9zrzrFl47D07x6hGyUPHV\n"
+ "aZXvuITW8t1o5MMHkCy3pmJ2KgfDvdUxrBvLfgPMICA4c6zA0mWquee43syEW9NY\n"
+ "g3q61iPlQwD1J1kX1wlimLCdAdgEQ7dh0AEEANAwa63zlQbuy1Meliy8otwiOa+a\n"
+ "mH6pxxUgUNggjyjO5qx+rl25mMjvGIRX4/L1QwIBXJBVi3SgvJW1COZxZqBYqj9U\n"
+ "8HVT07mWKFEDf0rZLeUE2jTm16cF9fcW4DQhW+sfYm+hi2sY3HeMuwlUBK9KHfW2\n"
+ "+bGeDzVZ4pqfUEudABEBAAEAA/0bemib+wxub9IyVFUp7nPobjQC83qxLSNzrGI/\n"
+ "RHzgu/5CQi4tfLOnwbcQsLELfker2hYnjsLrT9PURqK4F7udrWEoZ1I1LymOtLG/\n"
+ "4tNZ7Mnul3wRC2tCn7FKx8sGJwGh/3li8vZ6ALVJAyOia5TZ/buX0+QZzt6+hPKk\n"
+ "7MU1WQIA4bUBjtrsqDwro94DvPj3/jBnMZbXr6WZIItLNeVDUcM8oHL807Am97K1\n"
+ "ueO/f6v1sGAHG6lVPTmtekqPSTWBfwIA7CGFvEyvSALfB8NUa6jtk27NCiw0csql\n"
+ "kuhCmwXGMVOiryKEfegkIahf2bAd/gnWHPrpWp7bUE20v8YoW22I4wIAhnm5Wr5Q\n"
+ "Sy7EHDUxmJm5TzadFp9gq08qNzHBpXSYXXJ3JuWcL1/awUqp3tE1I6zZ0hZ38Ia6\n"
+ "SdBMN88idnhDPqPoiKUEGAECAA8FAkO3YdACGyAFCQHhM4AACgkQQZUwSa4UDezm\n"
+ "vQP/ZhK+2ly9oI2z7ZcNC/BJRch0/ybQ3haahII8pXXmOThpZohr/LUgoWgCZdXg\n"
+ "vP6yiszNk2tIs8KphCAw7Lw/qzDC2hEORjWO4f46qk73RAgSqG/GyzI4ltWiDhqn\n"
+ "vnQCFl3+QFSe4zinqykHnLwGPMXv428d/ZjkIc2ju8dRsn4=\n"
+ "=CR5w\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
/* Test capability of reading the gnu-dummy OpenPGP S2K extension.
See: doc/DETAILS from gnupg
http://lists.gnu.org/archive/html/gnutls-devel/2008-08/msg00023.html
*/
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- int rc;
- gnutls_datum_t keydatum =
- { (unsigned char *) dummy_key, strlen (dummy_key) };
- gnutls_openpgp_privkey_t key;
+ int rc;
+ gnutls_datum_t keydatum =
+ { (unsigned char *) dummy_key, strlen(dummy_key) };
+ gnutls_openpgp_privkey_t key;
- if (argc > 1)
- {
- gnutls_global_set_log_function (tls_log_func);
- gnutls_global_set_log_level (9);
- }
+ if (argc > 1) {
+ gnutls_global_set_log_function(tls_log_func);
+ gnutls_global_set_log_level(9);
+ }
- rc = global_init ();
- if (rc)
- {
- printf ("global_init rc %d: %s\n", rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = global_init();
+ if (rc) {
+ printf("global_init rc %d: %s\n", rc, gnutls_strerror(rc));
+ return 1;
+ }
- rc = gnutls_openpgp_privkey_init (&key);
- if (rc)
- {
- printf ("gnutls_openpgp_privkey_init rc %d: %s\n",
- rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = gnutls_openpgp_privkey_init(&key);
+ if (rc) {
+ printf("gnutls_openpgp_privkey_init rc %d: %s\n",
+ rc, gnutls_strerror(rc));
+ return 1;
+ }
- rc = gnutls_openpgp_privkey_import (key, &keydatum,
- GNUTLS_OPENPGP_FMT_BASE64, NULL, 0);
- if (rc)
- {
- printf ("gnutls_openpgp_privkey_import rc %d: %s\n",
- rc, gnutls_strerror (rc));
- return 1;
- }
+ rc = gnutls_openpgp_privkey_import(key, &keydatum,
+ GNUTLS_OPENPGP_FMT_BASE64, NULL,
+ 0);
+ if (rc) {
+ printf("gnutls_openpgp_privkey_import rc %d: %s\n",
+ rc, gnutls_strerror(rc));
+ return 1;
+ }
- gnutls_openpgp_privkey_deinit (key);
+ gnutls_openpgp_privkey_deinit(key);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- return 0;
+ return 0;
}
diff --git a/tests/pkcs12_encode.c b/tests/pkcs12_encode.c
index caa3ce88f5..42a01812d3 100644
--- a/tests/pkcs12_encode.c
+++ b/tests/pkcs12_encode.c
@@ -34,192 +34,184 @@
#include <stdlib.h>
static char client_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t client_dat = { (void*)client_pem, sizeof (client_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
+ "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
+ "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
+ "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
+ "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
+ "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
+ "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
+ "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
+ "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
+ "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
+ "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t client_dat =
+ { (void *) client_pem, sizeof(client_pem) };
static char ca_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
- "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
- "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
- "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
- "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
- "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQAMB0GA1UdDgQWBBTpPBz7rZJu5gak\n"
- "Viyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAiaIRqGfp1jPpNeVhABK60SU0KIAy\n"
- "njuu7kHq5peUgYn8Jd9zNzExBOEp1VOipGsf6G66oQAhDFp2o8zkz7ZH71zR4HEW\n"
- "KoX6n5Emn6DvcEH/9pAhnGxNHJAoS7czTKv/JDZJhkqHxyrE1fuLsg5Qv25DTw7+\n"
- "PfqUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t ca_dat = { (void*)ca_pem, sizeof (ca_pem) };
-
-static void
-tls_log_func (int level, const char *str)
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
+ "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
+ "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
+ "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
+ "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
+ "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQAMB0GA1UdDgQWBBTpPBz7rZJu5gak\n"
+ "Viyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAiaIRqGfp1jPpNeVhABK60SU0KIAy\n"
+ "njuu7kHq5peUgYn8Jd9zNzExBOEp1VOipGsf6G66oQAhDFp2o8zkz7ZH71zR4HEW\n"
+ "KoX6n5Emn6DvcEH/9pAhnGxNHJAoS7czTKv/JDZJhkqHxyrE1fuLsg5Qv25DTw7+\n"
+ "PfqUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t ca_dat = { (void *) ca_pem, sizeof(ca_pem) };
+
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
-void
-doit (void)
+void doit(void)
{
- gnutls_pkcs12_t pkcs12;
- gnutls_x509_crt_t client;
- gnutls_x509_crt_t ca;
- gnutls_pkcs12_bag_t bag;
- unsigned char key_id_buf[20];
- gnutls_datum_t key_id;
- int ret, indx;
- char outbuf[10240];
- size_t size;
- int i;
-
- ret = global_init ();
- if (ret < 0)
- {
- fprintf(stderr, "global_init %d", ret);
- exit(1);
- }
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- /* Read certs. */
- ret = gnutls_x509_crt_init (&client);
- if (ret < 0)
- {
- fprintf(stderr, "crt_init: %d", ret);
- exit(1);
- }
-
- ret = gnutls_x509_crt_import (client, &client_dat, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf(stderr, "crt_import: %d", ret);
- exit(1);
- }
-
- ret = gnutls_x509_crt_init (&ca);
- if (ret < 0)
- {
- fprintf(stderr, "ca_init: %d", ret);
- exit(1);
- }
-
- ret = gnutls_x509_crt_import (ca, &ca_dat, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf(stderr, "ca_import: %d", ret);
- exit(1);
- }
-
- /* Create PKCS#12 structure. */
- ret = gnutls_pkcs12_init (&pkcs12);
- if (ret < 0)
- {
- fprintf(stderr, "pkcs12_init: %d", ret);
- exit(1);
- }
-
- /* Generate and add PKCS#12 cert bags. */
- for (i = 0; i < 2; i++)
- {
- ret = gnutls_pkcs12_bag_init (&bag);
- if (ret < 0)
- {
- fprintf(stderr, "bag_init: %d", ret);
- exit(1);
- }
-
- ret = gnutls_pkcs12_bag_set_crt (bag, i == 0 ? client : ca);
- if (ret < 0)
- {
- fprintf(stderr, "set_crt: %d", ret);
- exit(1);
- }
-
- indx = ret;
-
- ret = gnutls_pkcs12_bag_set_friendly_name (bag, indx,
- i == 0 ? "client" : "ca");
- if (ret < 0)
- {
- fprintf(stderr, "set_friendly_name: %d", ret);
- exit(1);
- }
-
- size = sizeof (key_id_buf);
- ret = gnutls_x509_crt_get_key_id (i == 0 ? client : ca, 0,
- key_id_buf, &size);
- if (ret < 0)
- {
- fprintf(stderr, "get_key_id: %d", ret);
- exit(1);
- }
-
- key_id.data = key_id_buf;
- key_id.size = size;
-
- ret = gnutls_pkcs12_bag_set_key_id (bag, indx, &key_id);
- if (ret < 0)
- {
- fprintf(stderr, "bag_set_key_id: %d", ret);
- exit(1);
- }
-
- ret = gnutls_pkcs12_bag_encrypt (bag, "pass",
- i == 0 ? GNUTLS_PKCS8_USE_PKCS12_3DES
- : GNUTLS_PKCS_USE_PKCS12_RC2_40);
- if (ret < 0)
- {
- fprintf(stderr, "bag_encrypt: %d: %s", ret,
- i == 0 ? "3DES" : "RC2-40");
- exit(1);
- }
-
- ret = gnutls_pkcs12_set_bag (pkcs12, bag);
- if (ret < 0)
- {
- fprintf(stderr, "set_bag: %d", ret);
- exit(1);
- }
-
- gnutls_pkcs12_bag_deinit (bag);
- }
-
- /* MAC the structure, export and print. */
- ret = gnutls_pkcs12_generate_mac (pkcs12, "pass");
- if (ret < 0)
- {
- fprintf(stderr, "generate_mac: %d", ret);
- exit(1);
- }
-
- size = sizeof (outbuf);
- ret = gnutls_pkcs12_export (pkcs12, GNUTLS_X509_FMT_PEM, outbuf, &size);
- if (ret < 0)
- {
- fprintf(stderr, "pkcs12_export: %d", ret);
- exit(1);
- }
-
- if (debug)
- fwrite (outbuf, size, 1, stdout);
-
- /* Cleanup. */
- gnutls_pkcs12_deinit (pkcs12);
- gnutls_x509_crt_deinit (client);
- gnutls_x509_crt_deinit (ca);
- gnutls_global_deinit ();
+ gnutls_pkcs12_t pkcs12;
+ gnutls_x509_crt_t client;
+ gnutls_x509_crt_t ca;
+ gnutls_pkcs12_bag_t bag;
+ unsigned char key_id_buf[20];
+ gnutls_datum_t key_id;
+ int ret, indx;
+ char outbuf[10240];
+ size_t size;
+ int i;
+
+ ret = global_init();
+ if (ret < 0) {
+ fprintf(stderr, "global_init %d", ret);
+ exit(1);
+ }
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ /* Read certs. */
+ ret = gnutls_x509_crt_init(&client);
+ if (ret < 0) {
+ fprintf(stderr, "crt_init: %d", ret);
+ exit(1);
+ }
+
+ ret =
+ gnutls_x509_crt_import(client, &client_dat,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "crt_import: %d", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_init(&ca);
+ if (ret < 0) {
+ fprintf(stderr, "ca_init: %d", ret);
+ exit(1);
+ }
+
+ ret = gnutls_x509_crt_import(ca, &ca_dat, GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "ca_import: %d", ret);
+ exit(1);
+ }
+
+ /* Create PKCS#12 structure. */
+ ret = gnutls_pkcs12_init(&pkcs12);
+ if (ret < 0) {
+ fprintf(stderr, "pkcs12_init: %d", ret);
+ exit(1);
+ }
+
+ /* Generate and add PKCS#12 cert bags. */
+ for (i = 0; i < 2; i++) {
+ ret = gnutls_pkcs12_bag_init(&bag);
+ if (ret < 0) {
+ fprintf(stderr, "bag_init: %d", ret);
+ exit(1);
+ }
+
+ ret = gnutls_pkcs12_bag_set_crt(bag, i == 0 ? client : ca);
+ if (ret < 0) {
+ fprintf(stderr, "set_crt: %d", ret);
+ exit(1);
+ }
+
+ indx = ret;
+
+ ret = gnutls_pkcs12_bag_set_friendly_name(bag, indx,
+ i ==
+ 0 ? "client" :
+ "ca");
+ if (ret < 0) {
+ fprintf(stderr, "set_friendly_name: %d", ret);
+ exit(1);
+ }
+
+ size = sizeof(key_id_buf);
+ ret = gnutls_x509_crt_get_key_id(i == 0 ? client : ca, 0,
+ key_id_buf, &size);
+ if (ret < 0) {
+ fprintf(stderr, "get_key_id: %d", ret);
+ exit(1);
+ }
+
+ key_id.data = key_id_buf;
+ key_id.size = size;
+
+ ret = gnutls_pkcs12_bag_set_key_id(bag, indx, &key_id);
+ if (ret < 0) {
+ fprintf(stderr, "bag_set_key_id: %d", ret);
+ exit(1);
+ }
+
+ ret = gnutls_pkcs12_bag_encrypt(bag, "pass",
+ i ==
+ 0 ?
+ GNUTLS_PKCS8_USE_PKCS12_3DES
+ :
+ GNUTLS_PKCS_USE_PKCS12_RC2_40);
+ if (ret < 0) {
+ fprintf(stderr, "bag_encrypt: %d: %s", ret,
+ i == 0 ? "3DES" : "RC2-40");
+ exit(1);
+ }
+
+ ret = gnutls_pkcs12_set_bag(pkcs12, bag);
+ if (ret < 0) {
+ fprintf(stderr, "set_bag: %d", ret);
+ exit(1);
+ }
+
+ gnutls_pkcs12_bag_deinit(bag);
+ }
+
+ /* MAC the structure, export and print. */
+ ret = gnutls_pkcs12_generate_mac(pkcs12, "pass");
+ if (ret < 0) {
+ fprintf(stderr, "generate_mac: %d", ret);
+ exit(1);
+ }
+
+ size = sizeof(outbuf);
+ ret =
+ gnutls_pkcs12_export(pkcs12, GNUTLS_X509_FMT_PEM, outbuf,
+ &size);
+ if (ret < 0) {
+ fprintf(stderr, "pkcs12_export: %d", ret);
+ exit(1);
+ }
+
+ if (debug)
+ fwrite(outbuf, size, 1, stdout);
+
+ /* Cleanup. */
+ gnutls_pkcs12_deinit(pkcs12);
+ gnutls_x509_crt_deinit(client);
+ gnutls_x509_crt_deinit(ca);
+ gnutls_global_deinit();
}
diff --git a/tests/pkcs12_s2k.c b/tests/pkcs12_s2k.c
index 1275097c64..b3c0518da3 100644
--- a/tests/pkcs12_s2k.c
+++ b/tests/pkcs12_s2k.c
@@ -31,145 +31,142 @@
#include "../../lib/x509/x509_int.h"
#include "../../lib/debug.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
-static const unsigned char *salt[3] = { (void*)"salt1", (void*)"ltsa22", (void*)"balt33" };
+static const unsigned char *salt[3] =
+ { (void *) "salt1", (void *) "ltsa22", (void *) "balt33" };
static const char *pw[3] = { "secret1", "verysecret2", "veryverysecret3" };
static const char *values[] = {
/* 1.0 */
- "85a3c676a66f0960f4807144a28c8d61a0001b81846f301a1ac164289879972f",
+ "85a3c676a66f0960f4807144a28c8d61a0001b81846f301a1ac164289879972f",
/* 1.2 */
- "e659da7d5989733a3d268e0bf7752c35c116e5c75919449a98f6812f82a15b16",
+ "e659da7d5989733a3d268e0bf7752c35c116e5c75919449a98f6812f82a15b16",
/* 1.2 */
- "878b8a88bf6166ce803b7498822205b1ac82870d3aec20807148779375a61f1e",
+ "878b8a88bf6166ce803b7498822205b1ac82870d3aec20807148779375a61f1e",
/* 2.0 */
- "1c845be764371d633c7fd1056967a9940385e110e85b58f826d39ae8561a0019",
+ "1c845be764371d633c7fd1056967a9940385e110e85b58f826d39ae8561a0019",
/* 2.1 */
- "de8dd3ffd59b65d3d5f59a1f71d7add582741f7752a786c045953e727e4465c0",
+ "de8dd3ffd59b65d3d5f59a1f71d7add582741f7752a786c045953e727e4465c0",
/* 2.2 */
#ifndef PKCS12_BROKEN_KEYGEN
- "9dd7f19e5e6aee5c5008b5deefd35889ab75193594ed49a605df4e93e7c2a155",
+ "9dd7f19e5e6aee5c5008b5deefd35889ab75193594ed49a605df4e93e7c2a155",
#else
- "9dd7f19e5e6aee5c5008b5deefd35889ab7519356f13478ecdee593c5ed689b1",
+ "9dd7f19e5e6aee5c5008b5deefd35889ab7519356f13478ecdee593c5ed689b1",
#endif
- /* 3.0 */
- "1c165e5a291a1539f3dbcf82a3e6ed566eb9d50ad4b0b3b57b599b08f0531236",
+ /* 3.0 */
+ "1c165e5a291a1539f3dbcf82a3e6ed566eb9d50ad4b0b3b57b599b08f0531236",
/* 3.1 */
- "5c9abee3cde31656eedfc131b7c2f8061032a3c705961ee2306a826c8b4b1a76",
+ "5c9abee3cde31656eedfc131b7c2f8061032a3c705961ee2306a826c8b4b1a76",
/* 3.2 */
- "a9c94e0acdaeaea54d1b1b681c3b64916396a352dea7ffe635fb2c11d8502e98"
+ "a9c94e0acdaeaea54d1b1b681c3b64916396a352dea7ffe635fb2c11d8502e98"
};
/* Values derived from
http://www.drh-consultancy.demon.co.uk/test.txt */
-static struct
-{
- int id;
- const char *password;
- const unsigned char *salt;
- size_t iter;
- size_t keylen;
- const char *key;
-} tv[] =
-{
- {
- 1, "smeg", (void*)"\x0A\x58\xCF\x64\x53\x0D\x82\x3F", 1, 24,
- "8aaae6297b6cb04642ab5b077851284eb7128f1a2a7fbca3"},
- {
- 2, "smeg", (void*)"\x0A\x58\xCF\x64\x53\x0D\x82\x3F", 1, 8, "79993dfe048d3b76"},
- {
- 1, "smeg", (void*)"\x64\x2B\x99\xAB\x44\xFB\x4B\x1F", 1, 24,
- "f3a95fec48d7711e985cfe67908c5ab79fa3d7c5caa5d966"},
- {
- 2, "smeg", (void*)"\x64\x2B\x99\xAB\x44\xFB\x4B\x1F", 1, 8, "c0a38d64a79bea1d"},
- {
- 3, "smeg", (void*)"\x3D\x83\xC0\xE4\x54\x6A\xC1\x40", 1, 20,
- "8d967d88f6caa9d714800ab3d48051d63f73a312"},
- {
- 1, "queeg", (void*)"\x05\xDE\xC9\x59\xAC\xFF\x72\xF7", 1000, 24,
- "ed2034e36328830ff09df1e1a07dd357185dac0d4f9eb3d4"},
- {
- 2, "queeg", (void*)"\x05\xDE\xC9\x59\xAC\xFF\x72\xF7", 1000, 8,
- "11dedad7758d4860"},
- {
- 1, "queeg", (void*)"\x16\x82\xC0\xFC\x5B\x3F\x7E\xC5", 1000, 24,
- "483dd6e919d7de2e8e648ba8f862f3fbfbdc2bcb2c02957f"},
- {
- 2, "queeg", (void*)"\x16\x82\xC0\xFC\x5B\x3F\x7E\xC5", 1000, 8,
- "9d461d1b00355c50"},
- {
- 3, "queeg", (void*)"\x26\x32\x16\xFC\xC2\xFA\xB3\x1C", 1000, 20,
- "5ec4c7a80df652294c3925b6489a7ab857c83476"}
+static struct {
+ int id;
+ const char *password;
+ const unsigned char *salt;
+ size_t iter;
+ size_t keylen;
+ const char *key;
+} tv[] = {
+ {
+ 1, "smeg", (void *) "\x0A\x58\xCF\x64\x53\x0D\x82\x3F", 1,
+ 24,
+ "8aaae6297b6cb04642ab5b077851284eb7128f1a2a7fbca3"}, {
+ 2, "smeg", (void *) "\x0A\x58\xCF\x64\x53\x0D\x82\x3F", 1,
+ 8, "79993dfe048d3b76"}, {
+ 1, "smeg", (void *) "\x64\x2B\x99\xAB\x44\xFB\x4B\x1F", 1,
+ 24,
+ "f3a95fec48d7711e985cfe67908c5ab79fa3d7c5caa5d966"}, {
+ 2, "smeg", (void *) "\x64\x2B\x99\xAB\x44\xFB\x4B\x1F", 1,
+ 8, "c0a38d64a79bea1d"}, {
+ 3, "smeg", (void *) "\x3D\x83\xC0\xE4\x54\x6A\xC1\x40", 1,
+ 20, "8d967d88f6caa9d714800ab3d48051d63f73a312"}, {
+ 1, "queeg", (void *) "\x05\xDE\xC9\x59\xAC\xFF\x72\xF7",
+ 1000, 24,
+ "ed2034e36328830ff09df1e1a07dd357185dac0d4f9eb3d4"}, {
+ 2, "queeg", (void *) "\x05\xDE\xC9\x59\xAC\xFF\x72\xF7",
+ 1000, 8, "11dedad7758d4860"}, {
+ 1, "queeg", (void *) "\x16\x82\xC0\xFC\x5B\x3F\x7E\xC5",
+ 1000, 24,
+ "483dd6e919d7de2e8e648ba8f862f3fbfbdc2bcb2c02957f"}, {
+ 2, "queeg", (void *) "\x16\x82\xC0\xFC\x5B\x3F\x7E\xC5",
+ 1000, 8, "9d461d1b00355c50"}, {
+ 3, "queeg", (void *) "\x26\x32\x16\xFC\xC2\xFA\xB3\x1C",
+ 1000, 20, "5ec4c7a80df652294c3925b6489a7ab857c83476"}
};
-void
-doit (void)
+void doit(void)
{
- int rc;
- unsigned int i, j, x;
- unsigned char key[32];
- char tmp[1024];
-
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (99);
-
- x = 0;
- for (i = 1; i < 4; i++)
- {
- for (j = 0; j < 3; j++)
- {
- rc =
- _gnutls_pkcs12_string_to_key (i, salt[j], strlen ((char*)salt[j]),
- j + i + 15, pw[j], sizeof (key),
- key);
- if (rc < 0)
- fail ("_gnutls_pkcs12_string_to_key failed[0]: %d\n", rc);
-
- if (strcmp (_gnutls_bin2hex (key, sizeof (key),
- tmp, sizeof (tmp), NULL),
- values[x]) != 0)
- fail ("_gnutls_pkcs12_string_to_key failed[1]\n");
-
- if (debug)
- printf ("ij: %d.%d: %s\n", i, j,
- _gnutls_bin2hex (key, sizeof (key), tmp, sizeof (tmp),
- NULL));
- x++;
- }
- }
- if (debug)
- printf ("\n");
-
- for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++)
- {
- rc = _gnutls_pkcs12_string_to_key (tv[i].id, tv[i].salt, 8,
- tv[i].iter, tv[i].password,
- tv[i].keylen, key);
- if (rc < 0)
- fail ("_gnutls_pkcs12_string_to_key failed[2]: %d\n", rc);
-
- if (memcmp (_gnutls_bin2hex (key, tv[i].keylen,
- tmp, sizeof (tmp), NULL),
- tv[i].key, tv[i].keylen) != 0)
- fail ("_gnutls_pkcs12_string_to_key failed[3]\n");
-
- if (debug)
- printf ("tv[%d]: %s\n", i,
- _gnutls_bin2hex (key, tv[i].keylen, tmp, sizeof (tmp), NULL));
- }
- if (debug)
- printf ("\n");
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("_gnutls_pkcs12_string_to_key ok\n");
+ int rc;
+ unsigned int i, j, x;
+ unsigned char key[32];
+ char tmp[1024];
+
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(99);
+
+ x = 0;
+ for (i = 1; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ rc = _gnutls_pkcs12_string_to_key(i, salt[j],
+ strlen((char *)
+ salt[j]),
+ j + i + 15,
+ pw[j],
+ sizeof(key),
+ key);
+ if (rc < 0)
+ fail("_gnutls_pkcs12_string_to_key failed[0]: %d\n", rc);
+
+ if (strcmp(_gnutls_bin2hex(key, sizeof(key),
+ tmp, sizeof(tmp), NULL),
+ values[x]) != 0)
+ fail("_gnutls_pkcs12_string_to_key failed[1]\n");
+
+ if (debug)
+ printf("ij: %d.%d: %s\n", i, j,
+ _gnutls_bin2hex(key, sizeof(key),
+ tmp, sizeof(tmp),
+ NULL));
+ x++;
+ }
+ }
+ if (debug)
+ printf("\n");
+
+ for (i = 0; i < sizeof(tv) / sizeof(tv[0]); i++) {
+ rc = _gnutls_pkcs12_string_to_key(tv[i].id, tv[i].salt, 8,
+ tv[i].iter,
+ tv[i].password,
+ tv[i].keylen, key);
+ if (rc < 0)
+ fail("_gnutls_pkcs12_string_to_key failed[2]: %d\n", rc);
+
+ if (memcmp(_gnutls_bin2hex(key, tv[i].keylen,
+ tmp, sizeof(tmp), NULL),
+ tv[i].key, tv[i].keylen) != 0)
+ fail("_gnutls_pkcs12_string_to_key failed[3]\n");
+
+ if (debug)
+ printf("tv[%d]: %s\n", i,
+ _gnutls_bin2hex(key, tv[i].keylen, tmp,
+ sizeof(tmp), NULL));
+ }
+ if (debug)
+ printf("\n");
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("_gnutls_pkcs12_string_to_key ok\n");
}
diff --git a/tests/pkcs12_s2k_pem.c b/tests/pkcs12_s2k_pem.c
index c7a22228a1..35b8947ed6 100644
--- a/tests/pkcs12_s2k_pem.c
+++ b/tests/pkcs12_s2k_pem.c
@@ -229,70 +229,58 @@
"UWl07o3w\n" \
"-----END ENCRYPTED PRIVATE KEY-----\n"
-static struct
-{
- const char *name;
- const char *password;
- const char *pkcs12key;
- int expected_result;
-} keys[] =
-{
- {
- "x_9607", "123456", X_9607, 0},
- {
- "x_9671", "123456", X_9671, 0},
- {
- "x_9925", "123456", X_9925, 0},
- {
- "x_9926", "123456", X_9926, 0},
- {
- "x_9927", "123456", X_9927, 0},
- {
- "x_9928", "123456", X_9928, 0},
- {
- "x_9929", "123456", X_9929, 0},
- {
- "x_9930", "123456", X_9930, 0},
- {
- "x_9931", "123456", X_9931, 0},
- {
- "x_9932", "123456", X_9932, 0}
+static struct {
+ const char *name;
+ const char *password;
+ const char *pkcs12key;
+ int expected_result;
+} keys[] = {
+ {
+ "x_9607", "123456", X_9607, 0}, {
+ "x_9671", "123456", X_9671, 0}, {
+ "x_9925", "123456", X_9925, 0}, {
+ "x_9926", "123456", X_9926, 0}, {
+ "x_9927", "123456", X_9927, 0}, {
+ "x_9928", "123456", X_9928, 0}, {
+ "x_9929", "123456", X_9929, 0}, {
+ "x_9930", "123456", X_9930, 0}, {
+ "x_9931", "123456", X_9931, 0}, {
+ "x_9932", "123456", X_9932, 0}
};
-int
-main (void)
+int main(void)
{
- gnutls_x509_privkey_t key;
- size_t i;
- int ret;
+ gnutls_x509_privkey_t key;
+ size_t i;
+ int ret;
- global_init ();
+ global_init();
- for (i = 0; i < sizeof (keys) / sizeof (keys[0]); i++)
- {
- gnutls_datum_t tmp;
+ for (i = 0; i < sizeof(keys) / sizeof(keys[0]); i++) {
+ gnutls_datum_t tmp;
- ret = gnutls_x509_privkey_init (&key);
- if (ret < 0)
- return 1;
+ ret = gnutls_x509_privkey_init(&key);
+ if (ret < 0)
+ return 1;
- tmp.data = (unsigned char *) keys[i].pkcs12key;
- tmp.size = strlen ((char*)tmp.data);
+ tmp.data = (unsigned char *) keys[i].pkcs12key;
+ tmp.size = strlen((char *) tmp.data);
- ret = gnutls_x509_privkey_import_pkcs8 (key, &tmp,
- GNUTLS_X509_FMT_PEM,
- keys[i].password, 0);
- gnutls_x509_privkey_deinit (key);
+ ret = gnutls_x509_privkey_import_pkcs8(key, &tmp,
+ GNUTLS_X509_FMT_PEM,
+ keys[i].password,
+ 0);
+ gnutls_x509_privkey_deinit(key);
- if (ret != keys[i].expected_result)
- {
- printf ("fail[%d]: %d: %s\n", (int) i, ret, gnutls_strerror (ret));
- return 1;
- }
+ if (ret != keys[i].expected_result) {
+ printf("fail[%d]: %d: %s\n", (int) i, ret,
+ gnutls_strerror(ret));
+ return 1;
+ }
- }
+ }
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- return 0;
+ return 0;
}
diff --git a/tests/pkcs12_simple.c b/tests/pkcs12_simple.c
index 61618f4c9a..bbfe97d181 100644
--- a/tests/pkcs12_simple.c
+++ b/tests/pkcs12_simple.c
@@ -31,112 +31,121 @@
#include <gnutls/x509.h>
#include "utils.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "<%d>| %s", level, str);
+ fprintf(stderr, "<%d>| %s", level, str);
}
-void
-doit (void)
+void doit(void)
{
- const char *filename, *password = "1234";
- gnutls_pkcs12_t pkcs12;
- unsigned char* file_data;
- size_t file_size;
- gnutls_datum_t data;
- gnutls_x509_crt_t * chain, * extras;
- unsigned int chain_size, extras_size, i;
- gnutls_x509_privkey_t pkey;
- int ret;
-
- ret = global_init ();
- if (ret < 0)
- fail ("global_init failed %d\n", ret);
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- ret = gnutls_pkcs12_init(&pkcs12);
- if (ret < 0)
- fail ("initialization failed: %s\n", gnutls_strerror(ret));
-
- filename = getenv ("PKCS12_MANY_CERTS_FILE");
-
- if (!filename)
- filename = "pkcs12-decode/pkcs12_5certs.p12";
-
- if (debug)
- success ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
- filename, password);
-
- file_data = (void*)read_binary_file( filename, &file_size);
- if (file_data == NULL)
- fail("cannot open file");
-
- data.data = file_data;
- data.size = file_size;
- ret = gnutls_pkcs12_import(pkcs12, &data, GNUTLS_X509_FMT_DER, 0);
- if (ret < 0)
- fail ("pkcs12_import failed %d: %s\n", ret, gnutls_strerror (ret));
-
- if (debug)
- success ("Read file OK\n");
-
- ret = gnutls_pkcs12_simple_parse (pkcs12, password, &pkey, &chain, &chain_size,
- &extras, &extras_size, NULL, 0);
- if (ret < 0)
- fail ("pkcs12_simple_parse failed %d: %s\n", ret, gnutls_strerror (ret));
-
- if (chain_size != 1)
- fail("chain size (%u) should have been 1\n", chain_size);
-
- if (extras_size != 4)
- fail("extras size (%u) should have been 4\n", extras_size);
-
- if (debug)
- {
- char dn[512];
- size_t dn_size;
-
- dn_size = sizeof(dn);
- ret = gnutls_x509_crt_get_dn(chain[0], dn, &dn_size);
- if (ret < 0)
- fail ("crt_get_dn failed %d: %s\n", ret, gnutls_strerror (ret));
-
- success("dn: %s\n", dn);
-
- dn_size = sizeof(dn);
- ret = gnutls_x509_crt_get_issuer_dn(chain[0], dn, &dn_size);
- if (ret < 0)
- fail ("crt_get_dn failed %d: %s\n", ret, gnutls_strerror (ret));
-
- success("issuer dn: %s\n", dn);
- }
-
- gnutls_pkcs12_deinit(pkcs12);
- gnutls_x509_privkey_deinit(pkey);
-
- for (i=0;i<chain_size;i++)
- gnutls_x509_crt_deinit(chain[i]);
- gnutls_free(chain);
-
- for (i=0;i<extras_size;i++)
- gnutls_x509_crt_deinit(extras[i]);
- gnutls_free(extras);
-
- /* Try gnutls_x509_privkey_import2() */
- ret = gnutls_x509_privkey_init(&pkey);
- if (ret < 0)
- fail ("gnutls_x509_privkey_init failed %d: %s\n", ret, gnutls_strerror (ret));
-
- ret = gnutls_x509_privkey_import2(pkey, &data, GNUTLS_X509_FMT_DER, password, 0);
- if (ret < 0)
- fail ("gnutls_x509_privkey_import2 failed %d: %s\n", ret, gnutls_strerror (ret));
- gnutls_x509_privkey_deinit(pkey);
-
- free(file_data);
-
- gnutls_global_deinit ();
+ const char *filename, *password = "1234";
+ gnutls_pkcs12_t pkcs12;
+ unsigned char *file_data;
+ size_t file_size;
+ gnutls_datum_t data;
+ gnutls_x509_crt_t *chain, *extras;
+ unsigned int chain_size, extras_size, i;
+ gnutls_x509_privkey_t pkey;
+ int ret;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("global_init failed %d\n", ret);
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ ret = gnutls_pkcs12_init(&pkcs12);
+ if (ret < 0)
+ fail("initialization failed: %s\n", gnutls_strerror(ret));
+
+ filename = getenv("PKCS12_MANY_CERTS_FILE");
+
+ if (!filename)
+ filename = "pkcs12-decode/pkcs12_5certs.p12";
+
+ if (debug)
+ success
+ ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
+ filename, password);
+
+ file_data = (void *) read_binary_file(filename, &file_size);
+ if (file_data == NULL)
+ fail("cannot open file");
+
+ data.data = file_data;
+ data.size = file_size;
+ ret = gnutls_pkcs12_import(pkcs12, &data, GNUTLS_X509_FMT_DER, 0);
+ if (ret < 0)
+ fail("pkcs12_import failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+
+ if (debug)
+ success("Read file OK\n");
+
+ ret =
+ gnutls_pkcs12_simple_parse(pkcs12, password, &pkey, &chain,
+ &chain_size, &extras, &extras_size,
+ NULL, 0);
+ if (ret < 0)
+ fail("pkcs12_simple_parse failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+
+ if (chain_size != 1)
+ fail("chain size (%u) should have been 1\n", chain_size);
+
+ if (extras_size != 4)
+ fail("extras size (%u) should have been 4\n", extras_size);
+
+ if (debug) {
+ char dn[512];
+ size_t dn_size;
+
+ dn_size = sizeof(dn);
+ ret = gnutls_x509_crt_get_dn(chain[0], dn, &dn_size);
+ if (ret < 0)
+ fail("crt_get_dn failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+
+ success("dn: %s\n", dn);
+
+ dn_size = sizeof(dn);
+ ret =
+ gnutls_x509_crt_get_issuer_dn(chain[0], dn, &dn_size);
+ if (ret < 0)
+ fail("crt_get_dn failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+
+ success("issuer dn: %s\n", dn);
+ }
+
+ gnutls_pkcs12_deinit(pkcs12);
+ gnutls_x509_privkey_deinit(pkey);
+
+ for (i = 0; i < chain_size; i++)
+ gnutls_x509_crt_deinit(chain[i]);
+ gnutls_free(chain);
+
+ for (i = 0; i < extras_size; i++)
+ gnutls_x509_crt_deinit(extras[i]);
+ gnutls_free(extras);
+
+ /* Try gnutls_x509_privkey_import2() */
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_init failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+
+ ret =
+ gnutls_x509_privkey_import2(pkey, &data, GNUTLS_X509_FMT_DER,
+ password, 0);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_import2 failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+ gnutls_x509_privkey_deinit(pkey);
+
+ free(file_data);
+
+ gnutls_global_deinit();
}
diff --git a/tests/priorities.c b/tests/priorities.c
index 751cbfd19c..bf183fe164 100644
--- a/tests/priorities.c
+++ b/tests/priorities.c
@@ -32,83 +32,80 @@
#include "utils.h"
static void
-try_prio (const char* prio, unsigned expected_cs, unsigned expected_ciphers)
+try_prio(const char *prio, unsigned expected_cs, unsigned expected_ciphers)
{
-int ret;
-gnutls_priority_t p;
-const char* err;
-const unsigned int * t;
-unsigned i, si, count = 0;
+ int ret;
+ gnutls_priority_t p;
+ const char *err;
+ const unsigned int *t;
+ unsigned i, si, count = 0;
- /* this must be called once in the program
- */
- global_init ();
-
- ret = gnutls_priority_init(&p, prio, &err);
- if (ret < 0)
- {
- fprintf(stderr, "error: %s: %s\n", gnutls_strerror(ret), err);
- exit(1);
- }
-
- for (i=0;;i++)
- {
- ret = gnutls_priority_get_cipher_suite_index(p, i, &si);
- if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE)
- continue;
- else if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- break;
- else if (ret == 0)
- {
- count++;
- /* fprintf(stderr, "%s\n", gnutls_cipher_suite_info(si, NULL, NULL, NULL, NULL, NULL)); */
- }
+ /* this must be called once in the program
+ */
+ global_init();
- }
-
- ret = gnutls_priority_cipher_list (p, &t);
- if ((unsigned)ret != expected_ciphers)
- {
+ ret = gnutls_priority_init(&p, prio, &err);
+ if (ret < 0) {
+ fprintf(stderr, "error: %s: %s\n", gnutls_strerror(ret),
+ err);
+ exit(1);
+ }
+
+ for (i = 0;; i++) {
+ ret = gnutls_priority_get_cipher_suite_index(p, i, &si);
+ if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE)
+ continue;
+ else if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ break;
+ else if (ret == 0) {
+ count++;
+ /* fprintf(stderr, "%s\n", gnutls_cipher_suite_info(si, NULL, NULL, NULL, NULL, NULL)); */
+ }
+
+ }
+
+ ret = gnutls_priority_cipher_list(p, &t);
+ if ((unsigned) ret != expected_ciphers) {
#if 0
-for (i=0;i<ret;i++)
- fprintf(stderr, "%s\n", gnutls_cipher_get_name(t[i]));
+ for (i = 0; i < ret; i++)
+ fprintf(stderr, "%s\n",
+ gnutls_cipher_get_name(t[i]));
#endif
- fail("expected %d ciphers, found %d\n", expected_ciphers, ret);
- exit(1);
- }
-
- gnutls_priority_deinit(p);
-
- /* fprintf(stderr, "count: %d\n", count); */
+ fail("expected %d ciphers, found %d\n", expected_ciphers,
+ ret);
+ exit(1);
+ }
+
+ gnutls_priority_deinit(p);
- if (debug)
- success ("finished: %s\n", prio);
-
- if (count != expected_cs)
- {
- fail("expected %d ciphersuites, found %d\n", expected_cs, count);
- exit(1);
- }
+ /* fprintf(stderr, "count: %d\n", count); */
+
+ if (debug)
+ success("finished: %s\n", prio);
+
+ if (count != expected_cs) {
+ fail("expected %d ciphersuites, found %d\n", expected_cs,
+ count);
+ exit(1);
+ }
}
-void
-doit (void)
+void doit(void)
{
-const int normal = 66;
-const int null = 5;
-const int sec128 = 56;
+ const int normal = 66;
+ const int null = 5;
+ const int sec128 = 56;
- try_prio("NORMAL", normal, 10);
- try_prio("NORMAL:-MAC-ALL:+MD5:+MAC-ALL", normal, 10);
- try_prio("NORMAL:+CIPHER-ALL", normal, 10); /* all (except null) */
- try_prio("NORMAL:-CIPHER-ALL:+NULL", null, 1); /* null */
- try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL", normal+null, 11); /* should be null + all */
- try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL:-CIPHER-ALL:+AES-128-CBC", 10, 1); /* should be null + all */
- try_prio("PERFORMANCE", normal, 10);
- try_prio("SECURE256", 20, 4);
- try_prio("SECURE128", sec128, 8);
- try_prio("SECURE128:+SECURE256", sec128, 8); /* should be the same as SECURE128 */
- try_prio("SECURE128:+SECURE256:+NORMAL", normal, 10); /* should be the same as NORMAL */
- try_prio("SUITEB192", 1, 1);
+ try_prio("NORMAL", normal, 10);
+ try_prio("NORMAL:-MAC-ALL:+MD5:+MAC-ALL", normal, 10);
+ try_prio("NORMAL:+CIPHER-ALL", normal, 10); /* all (except null) */
+ try_prio("NORMAL:-CIPHER-ALL:+NULL", null, 1); /* null */
+ try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL", normal + null, 11); /* should be null + all */
+ try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL:-CIPHER-ALL:+AES-128-CBC", 10, 1); /* should be null + all */
+ try_prio("PERFORMANCE", normal, 10);
+ try_prio("SECURE256", 20, 4);
+ try_prio("SECURE128", sec128, 8);
+ try_prio("SECURE128:+SECURE256", sec128, 8); /* should be the same as SECURE128 */
+ try_prio("SECURE128:+SECURE256:+NORMAL", normal, 10); /* should be the same as NORMAL */
+ try_prio("SUITEB192", 1, 1);
}
-
diff --git a/tests/pskself.c b/tests/pskself.c
index 3c924dddf2..8b3fe48ab8 100644
--- a/tests/pskself.c
+++ b/tests/pskself.c
@@ -33,10 +33,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -55,103 +54,94 @@ main (int argc, char** argv)
/* A very basic TLS client, with PSK authentication.
*/
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
#define MAX_BUF 1024
#define MSG "Hello TLS"
-static void
-client (int sd)
+static void client(int sd)
{
- int ret, ii;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_psk_client_credentials_t pskcred;
- /* Need to enable anonymous KX specifically. */
- const gnutls_datum_t key = { (void *) "DEADBEEF", 8 };
-
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- side = "client";
-
- gnutls_psk_allocate_client_credentials (&pskcred);
- gnutls_psk_set_client_credentials (pskcred, "test", &key,
- GNUTLS_PSK_KEY_HEX);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NORMAL:+PSK", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_PSK, pskcred);
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug)
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
- close (sd);
-
- gnutls_deinit (session);
-
- gnutls_psk_free_client_credentials (pskcred);
-
- gnutls_global_deinit ();
+ int ret, ii;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_psk_client_credentials_t pskcred;
+ /* Need to enable anonymous KX specifically. */
+ const gnutls_datum_t key = { (void *) "DEADBEEF", 8 };
+
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ side = "client";
+
+ gnutls_psk_allocate_client_credentials(&pskcred);
+ gnutls_psk_set_client_credentials(pskcred, "test", &key,
+ GNUTLS_PSK_KEY_HEX);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, "NORMAL:+PSK", NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_PSK, pskcred);
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ end:
+
+ close(sd);
+
+ gnutls_deinit(session);
+
+ gnutls_psk_free_client_credentials(pskcred);
+
+ gnutls_global_deinit();
}
/* This is a sample TLS 1.0 echo server, for PSK authentication.
@@ -162,35 +152,35 @@ end:
/* These are global */
gnutls_psk_server_credentials_t server_pskcred;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NORMAL:+PSK", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, "NORMAL:+PSK", NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_PSK, server_pskcred);
+ gnutls_credentials_set(session, GNUTLS_CRD_PSK, server_pskcred);
- return session;
+ return session;
}
static int
-pskfunc (gnutls_session_t session, const char *username, gnutls_datum_t * key)
+pskfunc(gnutls_session_t session, const char *username,
+ gnutls_datum_t * key)
{
- if (debug)
- printf ("psk: username %s\n", username);
- key->data = gnutls_malloc (4);
- key->data[0] = 0xDE;
- key->data[1] = 0xAD;
- key->data[2] = 0xBE;
- key->data[3] = 0xEF;
- key->size = 4;
- return 0;
+ if (debug)
+ printf("psk: username %s\n", username);
+ key->data = gnutls_malloc(4);
+ key->data[0] = 0xDE;
+ key->data[1] = 0xAD;
+ key->data[2] = 0xBE;
+ key->data[3] = 0xEF;
+ key->size = 4;
+ return 0;
}
int err, ret;
@@ -199,107 +189,98 @@ gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
-static void
-server (int sd)
+static void server(int sd)
{
- /* this must be called once in the program
- */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- side = "server";
-
- gnutls_psk_allocate_server_credentials (&server_pskcred);
- gnutls_psk_set_server_credentials_function (server_pskcred, pskfunc);
-
- session = initialize_tls_session ();
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- return;
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
- gnutls_deinit (session);
-
- gnutls_psk_free_server_credentials (server_pskcred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ /* this must be called once in the program
+ */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ side = "server";
+
+ gnutls_psk_allocate_server_credentials(&server_pskcred);
+ gnutls_psk_set_server_credentials_function(server_pskcred,
+ pskfunc);
+
+ session = initialize_tls_session();
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+ gnutls_deinit(session);
+
+ gnutls_psk_free_server_credentials(server_pskcred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- pid_t child;
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (sockets[0]);
- wait (&status);
- }
- else
- client (sockets[1]);
+ pid_t child;
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(sockets[0]);
+ wait(&status);
+ } else
+ client(sockets[1]);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/record-sizes-range.c b/tests/record-sizes-range.c
index ae378307a1..2f60649542 100644
--- a/tests/record-sizes-range.c
+++ b/tests/record-sizes-range.c
@@ -33,12 +33,11 @@
#include "utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
/* This test attempts to transfer various sizes using AES-128-CBC.
@@ -49,121 +48,124 @@ tls_log_func (int level, const char *str)
static char b1[MAX_BUF + 1];
static char buffer[MAX_BUF + 1];
-static void try_send(gnutls_session_t client, gnutls_session_t server,
- void* b1, ssize_t b1_size, void* b2, ssize_t b2_size, gnutls_range_st* range)
+static void try_send(gnutls_session_t client, gnutls_session_t server,
+ void *b1, ssize_t b1_size, void *b2, ssize_t b2_size,
+ gnutls_range_st * range)
{
-int ret, recvd;
-
- /* Try sending various other sizes */
- ret = gnutls_record_send_range(client, b1, b1_size, range);
- if (ret < 0)
- {
- fprintf(stderr, "Error sending %d bytes: %s\n", (int)b1_size, gnutls_strerror(ret));
- exit(1);
- }
-
- if (ret != b1_size)
- {
- fprintf(stderr, "Couldn't send %d bytes\n", (int)b1_size);
- exit(1);
- }
-
- recvd = 0;
- do
- {
- ret = gnutls_record_recv(server, b2, b2_size);
- if (ret < 0)
- {
- fprintf(stderr, "Error receiving %d bytes: %s\n", (int)b2_size, gnutls_strerror(ret));
- exit(1);
- }
- recvd += ret;
- }
- while (recvd < b1_size);
-
- if (recvd != b1_size)
- {
- fprintf(stderr, "Couldn't receive %d bytes, received %d\n", (int)b1_size, recvd);
- exit(1);
- }
-
+ int ret, recvd;
+
+ /* Try sending various other sizes */
+ ret = gnutls_record_send_range(client, b1, b1_size, range);
+ if (ret < 0) {
+ fprintf(stderr, "Error sending %d bytes: %s\n",
+ (int) b1_size, gnutls_strerror(ret));
+ exit(1);
+ }
+
+ if (ret != b1_size) {
+ fprintf(stderr, "Couldn't send %d bytes\n", (int) b1_size);
+ exit(1);
+ }
+
+ recvd = 0;
+ do {
+ ret = gnutls_record_recv(server, b2, b2_size);
+ if (ret < 0) {
+ fprintf(stderr, "Error receiving %d bytes: %s\n",
+ (int) b2_size, gnutls_strerror(ret));
+ exit(1);
+ }
+ recvd += ret;
+ }
+ while (recvd < b1_size);
+
+ if (recvd != b1_size) {
+ fprintf(stderr, "Couldn't receive %d bytes, received %d\n",
+ (int) b1_size, recvd);
+ exit(1);
+ }
+
}
-void
-doit (void)
+void doit(void)
{
- /* Server stuff. */
- gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { (unsigned char *) pkcs3, strlen (pkcs3) };
- static gnutls_dh_params_t dh_params;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
- /* Need to enable anonymous KX specifically. */
- gnutls_range_st range;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- /* Init server */
- gnutls_anon_allocate_server_credentials (&s_anoncred);
- gnutls_dh_params_init (&dh_params);
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_priority_set_direct (server, "NONE:+VERS-TLS-ALL:+AES-128-CBC:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH", NULL);
- gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_priority_set_direct (client, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH", NULL);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- memset(b1, 0, sizeof(b1));
- HANDSHAKE(client, server);
-
- if (debug)
- success ("Handshake established\n");
-
- memset(b1, 1, MAX_BUF);
-
- range.low = 1024;
- range.high = MAX_SEND;
-
-
- try_send(client, server, b1, MAX_SEND, buffer, MAX_BUF, &range);
- try_send(client, server, b1, 1024, buffer, MAX_BUF, &range);
- try_send(client, server, b1, 4096, buffer, MAX_BUF, &range);
- /*try_send(client, server, b1, 128, buffer, MAX_BUF, &range)*/;
-
-
- if (debug)
- fputs ("\n", stdout);
-
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_anon_free_client_credentials (c_anoncred);
- gnutls_anon_free_server_credentials (s_anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
+ /* Server stuff. */
+ gnutls_anon_server_credentials_t s_anoncred;
+ const gnutls_datum_t p3 =
+ { (unsigned char *) pkcs3, strlen(pkcs3) };
+ static gnutls_dh_params_t dh_params;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+ /* Need to enable anonymous KX specifically. */
+ gnutls_range_st range;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ /* Init server */
+ gnutls_anon_allocate_server_credentials(&s_anoncred);
+ gnutls_dh_params_init(&dh_params);
+ gnutls_dh_params_import_pkcs3(dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ gnutls_anon_set_server_dh_params(s_anoncred, dh_params);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_priority_set_direct(server,
+ "NONE:+VERS-TLS-ALL:+AES-128-CBC:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH",
+ NULL);
+ gnutls_credentials_set(server, GNUTLS_CRD_ANON, s_anoncred);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_priority_set_direct(client,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH",
+ NULL);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ memset(b1, 0, sizeof(b1));
+ HANDSHAKE(client, server);
+
+ if (debug)
+ success("Handshake established\n");
+
+ memset(b1, 1, MAX_BUF);
+
+ range.low = 1024;
+ range.high = MAX_SEND;
+
+
+ try_send(client, server, b1, MAX_SEND, buffer, MAX_BUF, &range);
+ try_send(client, server, b1, 1024, buffer, MAX_BUF, &range);
+ try_send(client, server, b1, 4096, buffer, MAX_BUF, &range);
+ /*try_send(client, server, b1, 128, buffer, MAX_BUF, &range) */ ;
+
+
+ if (debug)
+ fputs("\n", stdout);
+
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_anon_free_client_credentials(c_anoncred);
+ gnutls_anon_free_server_credentials(s_anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
}
diff --git a/tests/record-sizes.c b/tests/record-sizes.c
index 7baf599830..11edde15e1 100644
--- a/tests/record-sizes.c
+++ b/tests/record-sizes.c
@@ -33,12 +33,11 @@
#include "utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
/* This test attempts to transfer various sizes using ARCFOUR-128.
@@ -48,111 +47,112 @@ tls_log_func (int level, const char *str)
static char b1[MAX_BUF + 1];
static char buffer[MAX_BUF + 1];
-void
-doit (void)
+void doit(void)
{
- /* Server stuff. */
- gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { (unsigned char *) pkcs3, strlen (pkcs3) };
- static gnutls_dh_params_t dh_params;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN, i;
- /* Need to enable anonymous KX specifically. */
- ssize_t ns;
- int ret, transferred = 0;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- /* Init server */
- gnutls_anon_allocate_server_credentials (&s_anoncred);
- gnutls_dh_params_init (&dh_params);
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_priority_set_direct (server, "NONE:+VERS-TLS-ALL:+ARCFOUR-128:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH", NULL);
- gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_priority_set_direct (client, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH", NULL);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- memset(b1, 0, sizeof(b1));
- HANDSHAKE(client, server);
-
- if (debug)
- success ("Handshake established\n");
-
- memset(b1, 1, MAX_BUF);
-
- /* try the maximum allowed */
- ret = gnutls_record_send(client, b1, MAX_BUF);
- if (ret < 0)
- {
- fprintf(stderr, "Error sending %d bytes: %s\n", (int)MAX_BUF, gnutls_strerror(ret));
- exit(1);
- }
-
- if (ret != MAX_BUF)
- {
- fprintf(stderr, "Couldn't send %d bytes\n", (int)MAX_BUF);
- exit(1);
- }
-
- ret = gnutls_record_recv(server, buffer, MAX_BUF);
- if (ret < 0)
- {
- fprintf(stderr, "Error receiving %d bytes: %s\n", (int)MAX_BUF, gnutls_strerror(ret));
- exit(1);
- }
-
- if (ret != MAX_BUF)
- {
- fprintf(stderr, "Couldn't receive %d bytes, received %d\n", (int)MAX_BUF, ret);
- exit(1);
- }
-
- if (memcmp(b1, buffer, MAX_BUF) != 0)
- {
- fprintf(stderr, "Buffers do not match!\n");
- exit(1);
- }
-
- /* Try sending various other sizes */
- for (i=1;i<128;i++)
- {
- TRANSFER(client, server, b1, i, buffer, MAX_BUF);
- }
- if (debug)
- fputs ("\n", stdout);
-
-
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_anon_free_client_credentials (c_anoncred);
- gnutls_anon_free_server_credentials (s_anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
+ /* Server stuff. */
+ gnutls_anon_server_credentials_t s_anoncred;
+ const gnutls_datum_t p3 =
+ { (unsigned char *) pkcs3, strlen(pkcs3) };
+ static gnutls_dh_params_t dh_params;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN, i;
+ /* Need to enable anonymous KX specifically. */
+ ssize_t ns;
+ int ret, transferred = 0;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ /* Init server */
+ gnutls_anon_allocate_server_credentials(&s_anoncred);
+ gnutls_dh_params_init(&dh_params);
+ gnutls_dh_params_import_pkcs3(dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ gnutls_anon_set_server_dh_params(s_anoncred, dh_params);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_priority_set_direct(server,
+ "NONE:+VERS-TLS-ALL:+ARCFOUR-128:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH",
+ NULL);
+ gnutls_credentials_set(server, GNUTLS_CRD_ANON, s_anoncred);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_priority_set_direct(client,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-NULL:+ANON-DH",
+ NULL);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ memset(b1, 0, sizeof(b1));
+ HANDSHAKE(client, server);
+
+ if (debug)
+ success("Handshake established\n");
+
+ memset(b1, 1, MAX_BUF);
+
+ /* try the maximum allowed */
+ ret = gnutls_record_send(client, b1, MAX_BUF);
+ if (ret < 0) {
+ fprintf(stderr, "Error sending %d bytes: %s\n",
+ (int) MAX_BUF, gnutls_strerror(ret));
+ exit(1);
+ }
+
+ if (ret != MAX_BUF) {
+ fprintf(stderr, "Couldn't send %d bytes\n", (int) MAX_BUF);
+ exit(1);
+ }
+
+ ret = gnutls_record_recv(server, buffer, MAX_BUF);
+ if (ret < 0) {
+ fprintf(stderr, "Error receiving %d bytes: %s\n",
+ (int) MAX_BUF, gnutls_strerror(ret));
+ exit(1);
+ }
+
+ if (ret != MAX_BUF) {
+ fprintf(stderr, "Couldn't receive %d bytes, received %d\n",
+ (int) MAX_BUF, ret);
+ exit(1);
+ }
+
+ if (memcmp(b1, buffer, MAX_BUF) != 0) {
+ fprintf(stderr, "Buffers do not match!\n");
+ exit(1);
+ }
+
+ /* Try sending various other sizes */
+ for (i = 1; i < 128; i++) {
+ TRANSFER(client, server, b1, i, buffer, MAX_BUF);
+ }
+ if (debug)
+ fputs("\n", stdout);
+
+
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_anon_free_client_credentials(c_anoncred);
+ gnutls_anon_free_server_credentials(s_anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
}
diff --git a/tests/resume-dtls.c b/tests/resume-dtls.c
index fdb5545255..2e45522438 100644
--- a/tests/resume-dtls.c
+++ b/tests/resume-dtls.c
@@ -32,10 +32,9 @@
#if defined(_WIN32)
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -51,31 +50,31 @@ main (int argc, char** argv)
#include "utils.h"
-static void wrap_db_init (void);
-static void wrap_db_deinit (void);
-static int wrap_db_store (void *dbf, gnutls_datum_t key, gnutls_datum_t data);
-static gnutls_datum_t wrap_db_fetch (void *dbf, gnutls_datum_t key);
-static int wrap_db_delete (void *dbf, gnutls_datum_t key);
+static void wrap_db_init(void);
+static void wrap_db_deinit(void);
+static int wrap_db_store(void *dbf, gnutls_datum_t key,
+ gnutls_datum_t data);
+static gnutls_datum_t wrap_db_fetch(void *dbf, gnutls_datum_t key);
+static int wrap_db_delete(void *dbf, gnutls_datum_t key);
#define TLS_SESSION_CACHE 50
-struct params_res
-{
- const char *desc;
- int enable_db;
- int enable_session_ticket_server;
- int enable_session_ticket_client;
- int expect_resume;
+struct params_res {
+ const char *desc;
+ int enable_db;
+ int enable_session_ticket_server;
+ int enable_session_ticket_client;
+ int expect_resume;
};
pid_t child;
struct params_res resume_tests[] = {
- {"try to resume from db", 50, 0, 0, 1},
- {"try to resume from session ticket", 0, 1, 1, 1},
- {"try to resume from session ticket (server only)", 0, 1, 0, 0},
- {"try to resume from session ticket (client only)", 0, 0, 1, 0},
- {NULL, -1}
+ {"try to resume from db", 50, 0, 0, 1},
+ {"try to resume from session ticket", 0, 1, 1, 1},
+ {"try to resume from session ticket (server only)", 0, 1, 0, 0},
+ {"try to resume from session ticket (client only)", 0, 0, 1, 0},
+ {NULL, -1}
};
/* A very basic TLS client, with anonymous authentication.
@@ -85,149 +84,135 @@ struct params_res resume_tests[] = {
#define MAX_BUF 5*1024
#define MSG "Hello TLS"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", child ? "server" : "client", level, str);
+ fprintf(stderr, "%s |<%d>| %s", child ? "server" : "client", level,
+ str);
}
-static void
-client (int sds[], struct params_res *params)
+static void client(int sds[], struct params_res *params)
{
- int ret, ii;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- /* variables used in session resuming
- */
- int t;
- gnutls_datum_t session_data;
-
- if (debug)
- {
- gnutls_global_set_log_function (tls_log_func);
- gnutls_global_set_log_level (2);
- }
- global_init ();
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- for (t = 0; t < SESSIONS; t++)
- {
- int sd = sds[t];
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT|GNUTLS_DATAGRAM|GNUTLS_NO_EXTENSIONS);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- if (params->enable_session_ticket_client)
- gnutls_session_ticket_enable_client (session);
-
- if (t > 0)
- {
- /* if this is not the first time we connect */
- gnutls_session_set_data (session, session_data.data,
- session_data.size);
- gnutls_free (session_data.data);
- }
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (t == 0)
- { /* the first time we connect */
- /* get the session data size */
- ret = gnutls_session_get_data2 (session, &session_data);
- if (ret < 0)
- fail ("Getting resume data failed\n");
- }
- else
- { /* the second time we connect */
-
- /* check if we actually resumed the previous session */
- if (gnutls_session_is_resumed (session) != 0)
- {
- if (params->expect_resume)
- {
- if (debug)
- success ("- Previous session was resumed\n");
- }
- else
- fail ("- Previous session was resumed\n");
- }
- else
- {
- if (params->expect_resume)
- {
- fail ("*** Previous session was NOT resumed\n");
- }
- else
- {
- if (debug)
- success
- ("*** Previous session was NOT resumed (expected)\n");
- }
- }
- }
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug )
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
- close (sd);
-
- gnutls_deinit (session);
- }
-
-end:
- gnutls_anon_free_client_credentials (anoncred);
+ int ret, ii;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ /* variables used in session resuming
+ */
+ int t;
+ gnutls_datum_t session_data;
+
+ if (debug) {
+ gnutls_global_set_log_function(tls_log_func);
+ gnutls_global_set_log_level(2);
+ }
+ global_init();
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ for (t = 0; t < SESSIONS; t++) {
+ int sd = sds[t];
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session,
+ GNUTLS_CLIENT | GNUTLS_DATAGRAM |
+ GNUTLS_NO_EXTENSIONS);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ if (params->enable_session_ticket_client)
+ gnutls_session_ticket_enable_client(session);
+
+ if (t > 0) {
+ /* if this is not the first time we connect */
+ gnutls_session_set_data(session, session_data.data,
+ session_data.size);
+ gnutls_free(session_data.data);
+ }
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else {
+ if (debug)
+ success
+ ("client: Handshake was completed\n");
+ }
+
+ if (t == 0) { /* the first time we connect */
+ /* get the session data size */
+ ret =
+ gnutls_session_get_data2(session,
+ &session_data);
+ if (ret < 0)
+ fail("Getting resume data failed\n");
+ } else { /* the second time we connect */
+
+ /* check if we actually resumed the previous session */
+ if (gnutls_session_is_resumed(session) != 0) {
+ if (params->expect_resume) {
+ if (debug)
+ success
+ ("- Previous session was resumed\n");
+ } else
+ fail("- Previous session was resumed\n");
+ } else {
+ if (params->expect_resume) {
+ fail("*** Previous session was NOT resumed\n");
+ } else {
+ if (debug)
+ success
+ ("*** Previous session was NOT resumed (expected)\n");
+ }
+ }
+ }
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ close(sd);
+
+ gnutls_deinit(session);
+ }
+
+ end:
+ gnutls_anon_free_client_credentials(anoncred);
}
/* This is a sample TLS 1.0 echo server, for anonymous authentication only.
@@ -239,49 +224,50 @@ end:
gnutls_anon_server_credentials_t anoncred;
static gnutls_datum_t session_ticket_key = { NULL, 0 };
-static gnutls_session_t
-initialize_tls_session (struct params_res *params)
+static gnutls_session_t initialize_tls_session(struct params_res *params)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER|GNUTLS_DATAGRAM);
+ gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
- gnutls_dh_set_prime_bits (session, DH_BITS);
+ gnutls_dh_set_prime_bits(session, DH_BITS);
- if (params->enable_db)
- {
- gnutls_db_set_retrieve_function (session, wrap_db_fetch);
- gnutls_db_set_remove_function (session, wrap_db_delete);
- gnutls_db_set_store_function (session, wrap_db_store);
- gnutls_db_set_ptr (session, NULL);
- }
+ if (params->enable_db) {
+ gnutls_db_set_retrieve_function(session, wrap_db_fetch);
+ gnutls_db_set_remove_function(session, wrap_db_delete);
+ gnutls_db_set_store_function(session, wrap_db_store);
+ gnutls_db_set_ptr(session, NULL);
+ }
- if (params->enable_session_ticket_server)
- gnutls_session_ticket_enable_server (session, &session_ticket_key);
+ if (params->enable_session_ticket_server)
+ gnutls_session_ticket_enable_server(session,
+ &session_ticket_key);
- return session;
+ return session;
}
static gnutls_dh_params_t dh_params;
-static int
-generate_dh_params (void)
+static int generate_dh_params(void)
{
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- /* Generate Diffie-Hellman parameters - for use with DHE
- * kx algorithms. These should be discarded and regenerated
- * once a day, once a week or once a month. Depending on the
- * security requirements.
- */
- gnutls_dh_params_init (&dh_params);
- return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ /* Generate Diffie-Hellman parameters - for use with DHE
+ * kx algorithms. These should be discarded and regenerated
+ * once a day, once a week or once a month. Depending on the
+ * security requirements.
+ */
+ gnutls_dh_params_init(&dh_params);
+ return gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
}
int err, ret;
@@ -290,171 +276,152 @@ gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
-static void
-global_stop (void)
+static void global_stop(void)
{
- if (debug)
- success ("global stop\n");
+ if (debug)
+ success("global stop\n");
- gnutls_anon_free_server_credentials (anoncred);
+ gnutls_anon_free_server_credentials(anoncred);
- gnutls_dh_params_deinit (dh_params);
+ gnutls_dh_params_deinit(dh_params);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
-static void
-server (int sds[], struct params_res *params)
+static void server(int sds[], struct params_res *params)
{
- size_t t;
-
- /* this must be called once in the program, it is mostly for the server.
- */
- if (debug)
- {
- gnutls_global_set_log_function (tls_log_func);
- gnutls_global_set_log_level (2);
- }
-
- global_init ();
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- if (debug)
- success ("Launched, generating DH parameters...\n");
-
- generate_dh_params ();
-
- gnutls_anon_set_server_dh_params (anoncred, dh_params);
-
- if (params->enable_db)
- {
- wrap_db_init ();
- }
-
- if (params->enable_session_ticket_server)
- gnutls_session_ticket_key_generate (&session_ticket_key);
-
- for (t = 0; t < SESSIONS; t++)
- {
- int sd = sds[t];
-
- session = initialize_tls_session (params);
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n",
- gnutls_strerror (ret));
- return;
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
-
- gnutls_deinit (session);
- }
-
- if (params->enable_db)
- {
- wrap_db_deinit ();
- }
-
- gnutls_free (session_ticket_key.data);
- session_ticket_key.data = NULL;
-
- if (debug)
- success ("server: finished\n");
+ size_t t;
+
+ /* this must be called once in the program, it is mostly for the server.
+ */
+ if (debug) {
+ gnutls_global_set_log_function(tls_log_func);
+ gnutls_global_set_log_level(2);
+ }
+
+ global_init();
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ if (debug)
+ success("Launched, generating DH parameters...\n");
+
+ generate_dh_params();
+
+ gnutls_anon_set_server_dh_params(anoncred, dh_params);
+
+ if (params->enable_db) {
+ wrap_db_init();
+ }
+
+ if (params->enable_session_ticket_server)
+ gnutls_session_ticket_key_generate(&session_ticket_key);
+
+ for (t = 0; t < SESSIONS; t++) {
+ int sd = sds[t];
+
+ session = initialize_tls_session(params);
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+
+ gnutls_deinit(session);
+ }
+
+ if (params->enable_db) {
+ wrap_db_deinit();
+ }
+
+ gnutls_free(session_ticket_key.data);
+ session_ticket_key.data = NULL;
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- int i;
-
- for (i = 0; resume_tests[i].desc; i++)
- {
- int client_sds[SESSIONS], server_sds[SESSIONS];
- int j;
-
- printf ("%s\n", resume_tests[i].desc);
-
- for (j = 0; j < SESSIONS; j++)
- {
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- server_sds[j] = sockets[0];
- client_sds[j] = sockets[1];
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (server_sds, &resume_tests[i]);
- wait (&status);
- if (WEXITSTATUS(status) > 0)
- error_count++;
- global_stop ();
- }
- else
- {
- client (client_sds, &resume_tests[i]);
- gnutls_global_deinit ();
- if (error_count)
- exit(1);
- exit (0);
- }
- }
+ int i;
+
+ for (i = 0; resume_tests[i].desc; i++) {
+ int client_sds[SESSIONS], server_sds[SESSIONS];
+ int j;
+
+ printf("%s\n", resume_tests[i].desc);
+
+ for (j = 0; j < SESSIONS; j++) {
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ server_sds[j] = sockets[0];
+ client_sds[j] = sockets[1];
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(server_sds, &resume_tests[i]);
+ wait(&status);
+ if (WEXITSTATUS(status) > 0)
+ error_count++;
+ global_stop();
+ } else {
+ client(client_sds, &resume_tests[i]);
+ gnutls_global_deinit();
+ if (error_count)
+ exit(1);
+ exit(0);
+ }
+ }
}
/* Functions and other stuff needed for session resuming.
@@ -465,167 +432,157 @@ doit (void)
#define MAX_SESSION_ID_SIZE 32
#define MAX_SESSION_DATA_SIZE 1024
-typedef struct
-{
- unsigned char session_id[MAX_SESSION_ID_SIZE];
- unsigned int session_id_size;
+typedef struct {
+ unsigned char session_id[MAX_SESSION_ID_SIZE];
+ unsigned int session_id_size;
- char session_data[MAX_SESSION_DATA_SIZE];
- int session_data_size;
+ char session_data[MAX_SESSION_DATA_SIZE];
+ int session_data_size;
} CACHE;
static CACHE *cache_db;
static int cache_db_ptr = 0;
-static void
-wrap_db_init (void)
+static void wrap_db_init(void)
{
- /* allocate cache_db */
- cache_db = calloc (1, TLS_SESSION_CACHE * sizeof (CACHE));
+ /* allocate cache_db */
+ cache_db = calloc(1, TLS_SESSION_CACHE * sizeof(CACHE));
}
-static void
-wrap_db_deinit (void)
+static void wrap_db_deinit(void)
{
- free (cache_db);
- cache_db = NULL;
- return;
+ free(cache_db);
+ cache_db = NULL;
+ return;
}
static int
-wrap_db_store (void *dbf, gnutls_datum_t key, gnutls_datum_t data)
+wrap_db_store(void *dbf, gnutls_datum_t key, gnutls_datum_t data)
{
- if (debug)
- success ("resume db storing... (%d-%d)\n", key.size, data.size);
-
- if (debug)
- {
- unsigned int i;
- printf ("key:\n");
- for (i = 0; i < key.size; i++)
- {
- printf ("%02x ", key.data[i] & 0xFF);
- if ((i + 1) % 16 == 0)
- printf ("\n");
- }
- printf ("\n");
- printf ("data:\n");
- for (i = 0; i < data.size; i++)
- {
- printf ("%02x ", data.data[i] & 0xFF);
- if ((i + 1) % 16 == 0)
- printf ("\n");
- }
- printf ("\n");
- }
-
- if (cache_db == NULL)
- return -1;
-
- if (key.size > MAX_SESSION_ID_SIZE)
- return -1;
-
- if (data.size > MAX_SESSION_DATA_SIZE)
- return -1;
-
- memcpy (cache_db[cache_db_ptr].session_id, key.data, key.size);
- cache_db[cache_db_ptr].session_id_size = key.size;
-
- memcpy (cache_db[cache_db_ptr].session_data, data.data, data.size);
- cache_db[cache_db_ptr].session_data_size = data.size;
-
- cache_db_ptr++;
- cache_db_ptr %= TLS_SESSION_CACHE;
-
- return 0;
+ if (debug)
+ success("resume db storing... (%d-%d)\n", key.size,
+ data.size);
+
+ if (debug) {
+ unsigned int i;
+ printf("key:\n");
+ for (i = 0; i < key.size; i++) {
+ printf("%02x ", key.data[i] & 0xFF);
+ if ((i + 1) % 16 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ printf("data:\n");
+ for (i = 0; i < data.size; i++) {
+ printf("%02x ", data.data[i] & 0xFF);
+ if ((i + 1) % 16 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
+ if (cache_db == NULL)
+ return -1;
+
+ if (key.size > MAX_SESSION_ID_SIZE)
+ return -1;
+
+ if (data.size > MAX_SESSION_DATA_SIZE)
+ return -1;
+
+ memcpy(cache_db[cache_db_ptr].session_id, key.data, key.size);
+ cache_db[cache_db_ptr].session_id_size = key.size;
+
+ memcpy(cache_db[cache_db_ptr].session_data, data.data, data.size);
+ cache_db[cache_db_ptr].session_data_size = data.size;
+
+ cache_db_ptr++;
+ cache_db_ptr %= TLS_SESSION_CACHE;
+
+ return 0;
}
-static gnutls_datum_t
-wrap_db_fetch (void *dbf, gnutls_datum_t key)
+static gnutls_datum_t wrap_db_fetch(void *dbf, gnutls_datum_t key)
{
- gnutls_datum_t res = { NULL, 0 };
- int i;
-
- if (debug)
- success ("resume db fetch... (%d)\n", key.size);
- if (debug)
- {
- unsigned int i;
- printf ("key:\n");
- for (i = 0; i < key.size; i++)
- {
- printf ("%02x ", key.data[i] & 0xFF);
- if ((i + 1) % 16 == 0)
- printf ("\n");
- }
- printf ("\n");
- }
-
- if (cache_db == NULL)
- return res;
-
- for (i = 0; i < TLS_SESSION_CACHE; i++)
- {
- if (key.size == cache_db[i].session_id_size &&
- memcmp (key.data, cache_db[i].session_id, key.size) == 0)
- {
- if (debug)
- success ("resume db fetch... return info\n");
-
- res.size = cache_db[i].session_data_size;
-
- res.data = gnutls_malloc (res.size);
- if (res.data == NULL)
- return res;
-
- memcpy (res.data, cache_db[i].session_data, res.size);
-
- if (debug)
- {
- unsigned int i;
- printf ("data:\n");
- for (i = 0; i < res.size; i++)
- {
- printf ("%02x ", res.data[i] & 0xFF);
- if ((i + 1) % 16 == 0)
- printf ("\n");
- }
- printf ("\n");
- }
-
- return res;
- }
- }
-
- if (debug)
- success ("resume db fetch... NOT FOUND\n");
- return res;
+ gnutls_datum_t res = { NULL, 0 };
+ int i;
+
+ if (debug)
+ success("resume db fetch... (%d)\n", key.size);
+ if (debug) {
+ unsigned int i;
+ printf("key:\n");
+ for (i = 0; i < key.size; i++) {
+ printf("%02x ", key.data[i] & 0xFF);
+ if ((i + 1) % 16 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
+ if (cache_db == NULL)
+ return res;
+
+ for (i = 0; i < TLS_SESSION_CACHE; i++) {
+ if (key.size == cache_db[i].session_id_size &&
+ memcmp(key.data, cache_db[i].session_id,
+ key.size) == 0) {
+ if (debug)
+ success
+ ("resume db fetch... return info\n");
+
+ res.size = cache_db[i].session_data_size;
+
+ res.data = gnutls_malloc(res.size);
+ if (res.data == NULL)
+ return res;
+
+ memcpy(res.data, cache_db[i].session_data,
+ res.size);
+
+ if (debug) {
+ unsigned int i;
+ printf("data:\n");
+ for (i = 0; i < res.size; i++) {
+ printf("%02x ",
+ res.data[i] & 0xFF);
+ if ((i + 1) % 16 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
+ return res;
+ }
+ }
+
+ if (debug)
+ success("resume db fetch... NOT FOUND\n");
+ return res;
}
-static int
-wrap_db_delete (void *dbf, gnutls_datum_t key)
+static int wrap_db_delete(void *dbf, gnutls_datum_t key)
{
- int i;
+ int i;
- if (cache_db == NULL)
- return -1;
+ if (cache_db == NULL)
+ return -1;
- for (i = 0; i < TLS_SESSION_CACHE; i++)
- {
- if (key.size == cache_db[i].session_id_size &&
- memcmp (key.data, cache_db[i].session_id, key.size) == 0)
- {
+ for (i = 0; i < TLS_SESSION_CACHE; i++) {
+ if (key.size == cache_db[i].session_id_size &&
+ memcmp(key.data, cache_db[i].session_id,
+ key.size) == 0) {
- cache_db[i].session_id_size = 0;
- cache_db[i].session_data_size = 0;
+ cache_db[i].session_id_size = 0;
+ cache_db[i].session_data_size = 0;
- return 0;
- }
- }
+ return 0;
+ }
+ }
- return -1;
+ return -1;
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/resume.c b/tests/resume.c
index 262d888a9f..f23d08d513 100644
--- a/tests/resume.c
+++ b/tests/resume.c
@@ -33,10 +33,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -52,32 +51,32 @@ main (int argc, char** argv)
#include "utils.h"
-static void wrap_db_init (void);
-static void wrap_db_deinit (void);
-static int wrap_db_store (void *dbf, gnutls_datum_t key, gnutls_datum_t data);
-static gnutls_datum_t wrap_db_fetch (void *dbf, gnutls_datum_t key);
-static int wrap_db_delete (void *dbf, gnutls_datum_t key);
+static void wrap_db_init(void);
+static void wrap_db_deinit(void);
+static int wrap_db_store(void *dbf, gnutls_datum_t key,
+ gnutls_datum_t data);
+static gnutls_datum_t wrap_db_fetch(void *dbf, gnutls_datum_t key);
+static int wrap_db_delete(void *dbf, gnutls_datum_t key);
#define TLS_SESSION_CACHE 50
-struct params_res
-{
- const char *desc;
- int enable_db;
- int enable_session_ticket_server;
- int enable_session_ticket_client;
- int expect_resume;
+struct params_res {
+ const char *desc;
+ int enable_db;
+ int enable_session_ticket_server;
+ int enable_session_ticket_client;
+ int expect_resume;
};
pid_t child;
struct params_res resume_tests[] = {
- {"try to resume from db", 1, 0, 0, 1},
- {"try to resume from session ticket", 0, 1, 1, 1},
- {"try to resume from session ticket (server only)", 0, 1, 0, 0},
- {"try to resume from session ticket (client only)", 0, 0, 1, 0},
- {"try to resume from db and ticket", 1, 1, 1, 1},
- {NULL, -1}
+ {"try to resume from db", 1, 0, 0, 1},
+ {"try to resume from session ticket", 0, 1, 1, 1},
+ {"try to resume from session ticket (server only)", 0, 1, 0, 0},
+ {"try to resume from session ticket (client only)", 0, 0, 1, 0},
+ {"try to resume from db and ticket", 1, 1, 1, 1},
+ {NULL, -1}
};
/* A very basic TLS client, with anonymous authentication.
@@ -87,149 +86,134 @@ struct params_res resume_tests[] = {
#define MAX_BUF 5*1024
#define MSG "Hello TLS"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", child ? "server" : "client", level, str);
+ fprintf(stderr, "%s |<%d>| %s", child ? "server" : "client", level,
+ str);
}
-static void
-client (int sds[], struct params_res *params)
+static void client(int sds[], struct params_res *params)
{
- int ret, ii;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_anon_client_credentials_t anoncred;
- /* Need to enable anonymous KX specifically. */
-
- /* variables used in session resuming
- */
- int t;
- gnutls_datum_t session_data;
-
- if (debug)
- {
- gnutls_global_set_log_function (tls_log_func);
- gnutls_global_set_log_level (2);
- }
- global_init ();
-
- gnutls_anon_allocate_client_credentials (&anoncred);
-
- for (t = 0; t < SESSIONS; t++)
- {
- int sd = sds[t];
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT|GNUTLS_NO_EXTENSIONS);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
- if (params->enable_session_ticket_client)
- gnutls_session_ticket_enable_client (session);
-
- if (t > 0)
- {
- /* if this is not the first time we connect */
- gnutls_session_set_data (session, session_data.data,
- session_data.size);
- }
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (t == 0)
- { /* the first time we connect */
- /* get the session data size */
- ret = gnutls_session_get_data2 (session, &session_data);
- if (ret < 0)
- fail ("Getting resume data failed\n");
- }
- else
- { /* the second time we connect */
-
- /* check if we actually resumed the previous session */
- if (gnutls_session_is_resumed (session) != 0)
- {
- if (params->expect_resume)
- {
- if (debug)
- success ("- Previous session was resumed\n");
- }
- else
- fail ("- Previous session was resumed\n");
- }
- else
- {
- if (params->expect_resume)
- {
- fail ("*** Previous session was NOT resumed\n");
- }
- else
- {
- if (debug)
- success
- ("*** Previous session was NOT resumed (expected)\n");
- }
- }
- }
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug )
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
- close (sd);
-
- gnutls_deinit (session);
- }
- gnutls_free (session_data.data);
-
-end:
- gnutls_anon_free_client_credentials (anoncred);
+ int ret, ii;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_anon_client_credentials_t anoncred;
+ /* Need to enable anonymous KX specifically. */
+
+ /* variables used in session resuming
+ */
+ int t;
+ gnutls_datum_t session_data;
+
+ if (debug) {
+ gnutls_global_set_log_function(tls_log_func);
+ gnutls_global_set_log_level(2);
+ }
+ global_init();
+
+ gnutls_anon_allocate_client_credentials(&anoncred);
+
+ for (t = 0; t < SESSIONS; t++) {
+ int sd = sds[t];
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session,
+ GNUTLS_CLIENT | GNUTLS_NO_EXTENSIONS);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
+
+ if (params->enable_session_ticket_client)
+ gnutls_session_ticket_enable_client(session);
+
+ if (t > 0) {
+ /* if this is not the first time we connect */
+ gnutls_session_set_data(session, session_data.data,
+ session_data.size);
+ }
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else {
+ if (debug)
+ success
+ ("client: Handshake was completed\n");
+ }
+
+ if (t == 0) { /* the first time we connect */
+ /* get the session data size */
+ ret =
+ gnutls_session_get_data2(session,
+ &session_data);
+ if (ret < 0)
+ fail("Getting resume data failed\n");
+ } else { /* the second time we connect */
+
+ /* check if we actually resumed the previous session */
+ if (gnutls_session_is_resumed(session) != 0) {
+ if (params->expect_resume) {
+ if (debug)
+ success
+ ("- Previous session was resumed\n");
+ } else
+ fail("- Previous session was resumed\n");
+ } else {
+ if (params->expect_resume) {
+ fail("*** Previous session was NOT resumed\n");
+ } else {
+ if (debug)
+ success
+ ("*** Previous session was NOT resumed (expected)\n");
+ }
+ }
+ }
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ close(sd);
+
+ gnutls_deinit(session);
+ }
+ gnutls_free(session_data.data);
+
+ end:
+ gnutls_anon_free_client_credentials(anoncred);
}
/* This is a sample TLS 1.0 echo server, for anonymous authentication only.
@@ -241,49 +225,50 @@ end:
gnutls_anon_server_credentials_t anoncred;
static gnutls_datum_t session_ticket_key = { NULL, 0 };
-static gnutls_session_t
-initialize_tls_session (struct params_res *params)
+static gnutls_session_t initialize_tls_session(struct params_res *params)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
+ gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred);
- gnutls_dh_set_prime_bits (session, DH_BITS);
+ gnutls_dh_set_prime_bits(session, DH_BITS);
- if (params->enable_db)
- {
- gnutls_db_set_retrieve_function (session, wrap_db_fetch);
- gnutls_db_set_remove_function (session, wrap_db_delete);
- gnutls_db_set_store_function (session, wrap_db_store);
- gnutls_db_set_ptr (session, NULL);
- }
+ if (params->enable_db) {
+ gnutls_db_set_retrieve_function(session, wrap_db_fetch);
+ gnutls_db_set_remove_function(session, wrap_db_delete);
+ gnutls_db_set_store_function(session, wrap_db_store);
+ gnutls_db_set_ptr(session, NULL);
+ }
- if (params->enable_session_ticket_server)
- gnutls_session_ticket_enable_server (session, &session_ticket_key);
+ if (params->enable_session_ticket_server)
+ gnutls_session_ticket_enable_server(session,
+ &session_ticket_key);
- return session;
+ return session;
}
static gnutls_dh_params_t dh_params;
-static int
-generate_dh_params (void)
+static int generate_dh_params(void)
{
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- /* Generate Diffie-Hellman parameters - for use with DHE
- * kx algorithms. These should be discarded and regenerated
- * once a day, once a week or once a month. Depending on the
- * security requirements.
- */
- gnutls_dh_params_init (&dh_params);
- return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ /* Generate Diffie-Hellman parameters - for use with DHE
+ * kx algorithms. These should be discarded and regenerated
+ * once a day, once a week or once a month. Depending on the
+ * security requirements.
+ */
+ gnutls_dh_params_init(&dh_params);
+ return gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
}
int err, ret;
@@ -292,171 +277,152 @@ gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
-static void
-global_stop (void)
+static void global_stop(void)
{
- if (debug)
- success ("global stop\n");
+ if (debug)
+ success("global stop\n");
- gnutls_anon_free_server_credentials (anoncred);
+ gnutls_anon_free_server_credentials(anoncred);
- gnutls_dh_params_deinit (dh_params);
+ gnutls_dh_params_deinit(dh_params);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
-static void
-server (int sds[], struct params_res *params)
+static void server(int sds[], struct params_res *params)
{
- size_t t;
-
- /* this must be called once in the program, it is mostly for the server.
- */
- if (debug)
- {
- gnutls_global_set_log_function (tls_log_func);
- gnutls_global_set_log_level (2);
- }
-
- global_init ();
- gnutls_anon_allocate_server_credentials (&anoncred);
-
- if (debug)
- success ("Launched, generating DH parameters...\n");
-
- generate_dh_params ();
-
- gnutls_anon_set_server_dh_params (anoncred, dh_params);
-
- if (params->enable_db)
- {
- wrap_db_init ();
- }
-
- if (params->enable_session_ticket_server)
- gnutls_session_ticket_key_generate (&session_ticket_key);
-
- for (t = 0; t < SESSIONS; t++)
- {
- int sd = sds[t];
-
- session = initialize_tls_session (params);
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n",
- gnutls_strerror (ret));
- return;
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- /* see the Getting peer's information example */
- /* print_info(session); */
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
-
- gnutls_deinit (session);
- }
-
- if (params->enable_db)
- {
- wrap_db_deinit ();
- }
-
- gnutls_free (session_ticket_key.data);
- session_ticket_key.data = NULL;
-
- if (debug)
- success ("server: finished\n");
+ size_t t;
+
+ /* this must be called once in the program, it is mostly for the server.
+ */
+ if (debug) {
+ gnutls_global_set_log_function(tls_log_func);
+ gnutls_global_set_log_level(2);
+ }
+
+ global_init();
+ gnutls_anon_allocate_server_credentials(&anoncred);
+
+ if (debug)
+ success("Launched, generating DH parameters...\n");
+
+ generate_dh_params();
+
+ gnutls_anon_set_server_dh_params(anoncred, dh_params);
+
+ if (params->enable_db) {
+ wrap_db_init();
+ }
+
+ if (params->enable_session_ticket_server)
+ gnutls_session_ticket_key_generate(&session_ticket_key);
+
+ for (t = 0; t < SESSIONS; t++) {
+ int sd = sds[t];
+
+ session = initialize_tls_session(params);
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ /* see the Getting peer's information example */
+ /* print_info(session); */
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+
+ gnutls_deinit(session);
+ }
+
+ if (params->enable_db) {
+ wrap_db_deinit();
+ }
+
+ gnutls_free(session_ticket_key.data);
+ session_ticket_key.data = NULL;
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- int i;
-
- for (i = 0; resume_tests[i].desc; i++)
- {
- int client_sds[SESSIONS], server_sds[SESSIONS];
- int j;
-
- printf ("%s\n", resume_tests[i].desc);
-
- for (j = 0; j < SESSIONS; j++)
- {
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- server_sds[j] = sockets[0];
- client_sds[j] = sockets[1];
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (server_sds, &resume_tests[i]);
- wait (&status);
- if (WEXITSTATUS(status) > 0)
- error_count++;
- global_stop ();
- }
- else
- {
- client (client_sds, &resume_tests[i]);
- gnutls_global_deinit ();
- if (error_count)
- exit(1);
- exit (0);
- }
- }
+ int i;
+
+ for (i = 0; resume_tests[i].desc; i++) {
+ int client_sds[SESSIONS], server_sds[SESSIONS];
+ int j;
+
+ printf("%s\n", resume_tests[i].desc);
+
+ for (j = 0; j < SESSIONS; j++) {
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ server_sds[j] = sockets[0];
+ client_sds[j] = sockets[1];
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(server_sds, &resume_tests[i]);
+ wait(&status);
+ if (WEXITSTATUS(status) > 0)
+ error_count++;
+ global_stop();
+ } else {
+ client(client_sds, &resume_tests[i]);
+ gnutls_global_deinit();
+ if (error_count)
+ exit(1);
+ exit(0);
+ }
+ }
}
/* Functions and other stuff needed for session resuming.
@@ -467,163 +433,151 @@ doit (void)
#define MAX_SESSION_ID_SIZE 32
#define MAX_SESSION_DATA_SIZE 1024
-typedef struct
-{
- unsigned char session_id[MAX_SESSION_ID_SIZE];
- unsigned int session_id_size;
+typedef struct {
+ unsigned char session_id[MAX_SESSION_ID_SIZE];
+ unsigned int session_id_size;
- char session_data[MAX_SESSION_DATA_SIZE];
- int session_data_size;
+ char session_data[MAX_SESSION_DATA_SIZE];
+ int session_data_size;
} CACHE;
static CACHE *cache_db;
static int cache_db_ptr = 0;
-static void
-wrap_db_init (void)
+static void wrap_db_init(void)
{
- /* allocate cache_db */
- cache_db = calloc (1, TLS_SESSION_CACHE * sizeof (CACHE));
+ /* allocate cache_db */
+ cache_db = calloc(1, TLS_SESSION_CACHE * sizeof(CACHE));
}
-static void
-wrap_db_deinit (void)
+static void wrap_db_deinit(void)
{
- free (cache_db);
- cache_db = NULL;
- return;
+ free(cache_db);
+ cache_db = NULL;
+ return;
}
static int
-wrap_db_store (void *dbf, gnutls_datum_t key, gnutls_datum_t data)
+wrap_db_store(void *dbf, gnutls_datum_t key, gnutls_datum_t data)
{
- if (debug)
- {
- unsigned int i;
- fprintf (stderr, "resume db storing (%d-%d): ", key.size, data.size);
- for (i = 0; i < key.size; i++)
- {
- fprintf (stderr, "%02x", key.data[i] & 0xFF);
- }
- fprintf (stderr, "\n");
- fprintf (stderr, "data: ");
- for (i = 0; i < data.size; i++)
- {
- fprintf (stderr, "%02x", data.data[i] & 0xFF);
- }
- fprintf (stderr, "\n");
- }
-
- if (cache_db == NULL)
- return -1;
-
- if (key.size > MAX_SESSION_ID_SIZE)
- {
- fail("Key size is too large\n");
- return -1;
- }
-
- if (data.size > MAX_SESSION_DATA_SIZE)
- {
- fail("Data size is too large\n");
- return -1;
- }
-
- memcpy (cache_db[cache_db_ptr].session_id, key.data, key.size);
- cache_db[cache_db_ptr].session_id_size = key.size;
-
- memcpy (cache_db[cache_db_ptr].session_data, data.data, data.size);
- cache_db[cache_db_ptr].session_data_size = data.size;
-
- cache_db_ptr++;
- cache_db_ptr %= TLS_SESSION_CACHE;
-
- return 0;
+ if (debug) {
+ unsigned int i;
+ fprintf(stderr, "resume db storing (%d-%d): ", key.size,
+ data.size);
+ for (i = 0; i < key.size; i++) {
+ fprintf(stderr, "%02x", key.data[i] & 0xFF);
+ }
+ fprintf(stderr, "\n");
+ fprintf(stderr, "data: ");
+ for (i = 0; i < data.size; i++) {
+ fprintf(stderr, "%02x", data.data[i] & 0xFF);
+ }
+ fprintf(stderr, "\n");
+ }
+
+ if (cache_db == NULL)
+ return -1;
+
+ if (key.size > MAX_SESSION_ID_SIZE) {
+ fail("Key size is too large\n");
+ return -1;
+ }
+
+ if (data.size > MAX_SESSION_DATA_SIZE) {
+ fail("Data size is too large\n");
+ return -1;
+ }
+
+ memcpy(cache_db[cache_db_ptr].session_id, key.data, key.size);
+ cache_db[cache_db_ptr].session_id_size = key.size;
+
+ memcpy(cache_db[cache_db_ptr].session_data, data.data, data.size);
+ cache_db[cache_db_ptr].session_data_size = data.size;
+
+ cache_db_ptr++;
+ cache_db_ptr %= TLS_SESSION_CACHE;
+
+ return 0;
}
-static gnutls_datum_t
-wrap_db_fetch (void *dbf, gnutls_datum_t key)
+static gnutls_datum_t wrap_db_fetch(void *dbf, gnutls_datum_t key)
{
- gnutls_datum_t res = { NULL, 0 };
- int i;
-
- if (debug)
- {
- unsigned int i;
-
- fprintf (stderr, "resume db looking for (%d): ", key.size);
- for (i = 0; i < key.size; i++)
- {
- fprintf (stderr, "%02x", key.data[i] & 0xFF);
- }
- fprintf (stderr, "\n");
- }
-
- if (cache_db == NULL)
- return res;
-
- for (i = 0; i < TLS_SESSION_CACHE; i++)
- {
- if (key.size == cache_db[i].session_id_size &&
- memcmp (key.data, cache_db[i].session_id, key.size) == 0)
- {
- if (debug)
- success ("resume db fetch... return info\n");
-
- res.size = cache_db[i].session_data_size;
-
- res.data = gnutls_malloc (res.size);
- if (res.data == NULL)
- return res;
-
- memcpy (res.data, cache_db[i].session_data, res.size);
-
- if (debug)
- {
- unsigned int i;
- printf ("data:\n");
- for (i = 0; i < res.size; i++)
- {
- printf ("%02x ", res.data[i] & 0xFF);
- if ((i + 1) % 16 == 0)
- printf ("\n");
- }
- printf ("\n");
- }
-
- return res;
- }
- }
-
- if (debug)
- success ("resume db fetch... NOT FOUND\n");
- return res;
+ gnutls_datum_t res = { NULL, 0 };
+ int i;
+
+ if (debug) {
+ unsigned int i;
+
+ fprintf(stderr, "resume db looking for (%d): ", key.size);
+ for (i = 0; i < key.size; i++) {
+ fprintf(stderr, "%02x", key.data[i] & 0xFF);
+ }
+ fprintf(stderr, "\n");
+ }
+
+ if (cache_db == NULL)
+ return res;
+
+ for (i = 0; i < TLS_SESSION_CACHE; i++) {
+ if (key.size == cache_db[i].session_id_size &&
+ memcmp(key.data, cache_db[i].session_id,
+ key.size) == 0) {
+ if (debug)
+ success
+ ("resume db fetch... return info\n");
+
+ res.size = cache_db[i].session_data_size;
+
+ res.data = gnutls_malloc(res.size);
+ if (res.data == NULL)
+ return res;
+
+ memcpy(res.data, cache_db[i].session_data,
+ res.size);
+
+ if (debug) {
+ unsigned int i;
+ printf("data:\n");
+ for (i = 0; i < res.size; i++) {
+ printf("%02x ",
+ res.data[i] & 0xFF);
+ if ((i + 1) % 16 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
+ return res;
+ }
+ }
+
+ if (debug)
+ success("resume db fetch... NOT FOUND\n");
+ return res;
}
-static int
-wrap_db_delete (void *dbf, gnutls_datum_t key)
+static int wrap_db_delete(void *dbf, gnutls_datum_t key)
{
- int i;
+ int i;
- if (cache_db == NULL)
- return -1;
+ if (cache_db == NULL)
+ return -1;
- for (i = 0; i < TLS_SESSION_CACHE; i++)
- {
- if (key.size == cache_db[i].session_id_size &&
- memcmp (key.data, cache_db[i].session_id, key.size) == 0)
- {
+ for (i = 0; i < TLS_SESSION_CACHE; i++) {
+ if (key.size == cache_db[i].session_id_size &&
+ memcmp(key.data, cache_db[i].session_id,
+ key.size) == 0) {
- cache_db[i].session_id_size = 0;
- cache_db[i].session_data_size = 0;
+ cache_db[i].session_id_size = 0;
+ cache_db[i].session_data_size = 0;
- return 0;
- }
- }
+ return 0;
+ }
+ }
- return -1;
+ return -1;
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/rng-fork.c b/tests/rng-fork.c
index 7ff14153da..d2692e2f59 100644
--- a/tests/rng-fork.c
+++ b/tests/rng-fork.c
@@ -36,77 +36,72 @@
#include <gnutls/crypto.h>
#if !defined(_WIN32)
-static void dump(const char* name, unsigned char* buf, int buf_size)
+static void dump(const char *name, unsigned char *buf, int buf_size)
{
-int i;
- printf("%s: ", name);
- for(i=0;i<buf_size;i++)
- printf("%.2x:", buf[i]);
- printf("\n");
+ int i;
+ printf("%s: ", name);
+ for (i = 0; i < buf_size; i++)
+ printf("%.2x:", buf[i]);
+ printf("\n");
}
-
+
#define FILENAME "./rng-test"
-
-void
-doit (void)
+
+void doit(void)
{
- unsigned char buf1[32];
- unsigned char buf2[32];
- pid_t pid;
- int ret;
- FILE* fp;
+ unsigned char buf1[32];
+ unsigned char buf2[32];
+ pid_t pid;
+ int ret;
+ FILE *fp;
+
+ global_init();
+ pid = fork();
+ if (pid == 0) {
+ fp = fopen(FILENAME, "w");
+ if (fp == NULL)
+ fail("cannot open file");
+
+ gnutls_rnd(GNUTLS_RND_NONCE, buf1, sizeof(buf1));
+ if (debug)
+ dump("buf1", buf1, sizeof(buf1));
+
+ fwrite(buf1, 1, sizeof(buf1), fp);
+ fclose(fp);
+ } else {
+ /* daddy */
+ gnutls_rnd(GNUTLS_RND_NONCE, buf2, sizeof(buf2));
+ if (debug)
+ dump("buf2", buf2, sizeof(buf2));
+ waitpid(pid, NULL, 0);
+
+ fp = fopen(FILENAME, "r");
+ if (fp == NULL)
+ fail("cannot open file");
+
+ ret = fread(buf1, 1, sizeof(buf1), fp);
+
+ fclose(fp);
+ remove(FILENAME);
- global_init ();
- pid = fork();
- if (pid == 0)
- {
- fp = fopen(FILENAME, "w");
- if (fp == NULL)
- fail("cannot open file");
-
- gnutls_rnd (GNUTLS_RND_NONCE, buf1, sizeof (buf1));
- if (debug) dump("buf1", buf1, sizeof(buf1));
-
- fwrite(buf1, 1, sizeof(buf1), fp);
- fclose(fp);
- }
- else
- {
- /* daddy */
- gnutls_rnd (GNUTLS_RND_NONCE, buf2, sizeof (buf2));
- if (debug) dump("buf2", buf2, sizeof(buf2));
- waitpid(pid, NULL, 0);
-
- fp = fopen(FILENAME, "r");
- if (fp == NULL)
- fail("cannot open file");
-
- ret = fread(buf1, 1, sizeof(buf1), fp);
-
- fclose(fp);
- remove(FILENAME);
-
- if (ret != sizeof(buf1))
- {
- fail("error testing the random generator.");
- return;
- }
+ if (ret != sizeof(buf1)) {
+ fail("error testing the random generator.");
+ return;
+ }
- if (memcmp(buf1, buf2, sizeof(buf1))==0)
- {
- fail("error in the random generator. Produces same valus after fork()");
- return;
- }
- if(debug)
- success("success\n");
- }
+ if (memcmp(buf1, buf2, sizeof(buf1)) == 0) {
+ fail("error in the random generator. Produces same valus after fork()");
+ return;
+ }
+ if (debug)
+ success("success\n");
+ }
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
#else
-void
-doit (void)
+void doit(void)
{
- exit (77);
+ exit(77);
}
#endif
diff --git a/tests/rsa-encrypt-decrypt.c b/tests/rsa-encrypt-decrypt.c
index fbfe54fb4f..d6add7ec66 100644
--- a/tests/rsa-encrypt-decrypt.c
+++ b/tests/rsa-encrypt-decrypt.c
@@ -42,153 +42,155 @@
/* sha1 hash of "hello" string */
const gnutls_datum_t hash_data = {
- (void *)
- "\xaa\xf4\xc6\x1d\xdc\xc5\xe8\xa2\xda\xbe"
- "\xde\x0f\x3b\x48\x2c\xd9\xae\xa9\x43\x4d",
- 20
+ (void *)
+ "\xaa\xf4\xc6\x1d\xdc\xc5\xe8\xa2\xda\xbe"
+ "\xde\x0f\x3b\x48\x2c\xd9\xae\xa9\x43\x4d",
+ 20
};
const gnutls_datum_t raw_data = {
- (void *) "hello there",
- 11
+ (void *) "hello there",
+ 11
};
static char pem1_cert[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
+ "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
+ "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
+ "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
+ "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
+ "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
+ "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
+ "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
+ "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
+ "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
+ "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
static char pem1_key[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
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WmYkKNYqQIDAQAB\n"
+ "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
+ "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+Qn6hw4x2p5rogdvhhIL1mdWo7jWeVJTF\n"
+ "RKB7zLdMPs3ySdtcIQaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
+ "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
+ "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
+ "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
+ "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
+ "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
+ "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
+ "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t cert_dat[] = {
- {(void*)pem1_cert, sizeof (pem1_cert)}
+ {(void *) pem1_cert, sizeof(pem1_cert)}
};
const gnutls_datum_t key_dat[] = {
- {(void*)pem1_key, sizeof (pem1_key)}
+ {(void *) pem1_key, sizeof(pem1_key)}
};
-void
-doit (void)
+void doit(void)
{
- gnutls_x509_privkey_t key;
- gnutls_x509_crt_t crt;
- gnutls_pubkey_t pubkey;
- gnutls_privkey_t privkey;
- gnutls_datum_t out, out2;
- int ret;
- size_t i;
+ gnutls_x509_privkey_t key;
+ gnutls_x509_crt_t crt;
+ gnutls_pubkey_t pubkey;
+ gnutls_privkey_t privkey;
+ gnutls_datum_t out, out2;
+ int ret;
+ size_t i;
- global_init ();
+ global_init();
- for (i = 0; i < sizeof (key_dat) / sizeof (key_dat[0]); i++)
- {
- if (debug)
- success ("loop %d\n", (int) i);
+ for (i = 0; i < sizeof(key_dat) / sizeof(key_dat[0]); i++) {
+ if (debug)
+ success("loop %d\n", (int) i);
- ret = gnutls_x509_privkey_init (&key);
- if (ret < 0)
- fail ("gnutls_x509_privkey_init\n");
+ ret = gnutls_x509_privkey_init(&key);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_init\n");
- ret =
- gnutls_x509_privkey_import (key, &key_dat[i], GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_privkey_import\n");
+ ret =
+ gnutls_x509_privkey_import(key, &key_dat[i],
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_import\n");
- ret = gnutls_pubkey_init (&pubkey);
- if (ret < 0)
- fail ("gnutls_privkey_init\n");
+ ret = gnutls_pubkey_init(&pubkey);
+ if (ret < 0)
+ fail("gnutls_privkey_init\n");
- ret = gnutls_privkey_init (&privkey);
- if (ret < 0)
- fail ("gnutls_pubkey_init\n");
+ ret = gnutls_privkey_init(&privkey);
+ if (ret < 0)
+ fail("gnutls_pubkey_init\n");
- ret = gnutls_privkey_import_x509 (privkey, key, 0);
- if (ret < 0)
- fail ("gnutls_privkey_import_x509\n");
+ ret = gnutls_privkey_import_x509(privkey, key, 0);
+ if (ret < 0)
+ fail("gnutls_privkey_import_x509\n");
- ret = gnutls_x509_crt_init (&crt);
- if (ret < 0)
- fail ("gnutls_x509_crt_init\n");
+ ret = gnutls_x509_crt_init(&crt);
+ if (ret < 0)
+ fail("gnutls_x509_crt_init\n");
- ret = gnutls_x509_crt_import (crt, &cert_dat[i], GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import\n");
+ ret =
+ gnutls_x509_crt_import(crt, &cert_dat[i],
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import\n");
- ret =
- gnutls_pubkey_import_x509 (pubkey, crt, 0);
- if (ret < 0)
- fail ("gnutls_x509_pubkey_import\n");
+ ret = gnutls_pubkey_import_x509(pubkey, crt, 0);
+ if (ret < 0)
+ fail("gnutls_x509_pubkey_import\n");
- ret = gnutls_pubkey_encrypt_data(pubkey, 0, &hash_data, &out);
- if (ret < 0)
- fail ("gnutls_pubkey_encrypt_data\n");
+ ret =
+ gnutls_pubkey_encrypt_data(pubkey, 0, &hash_data,
+ &out);
+ if (ret < 0)
+ fail("gnutls_pubkey_encrypt_data\n");
- ret = gnutls_privkey_decrypt_data (privkey, 0,
- &out, &out2);
- if (ret < 0)
- fail ("gnutls_privkey_decrypt_data\n");
+ ret = gnutls_privkey_decrypt_data(privkey, 0, &out, &out2);
+ if (ret < 0)
+ fail("gnutls_privkey_decrypt_data\n");
- if (out2.size != hash_data.size)
- fail ("Decrypted data don't match original (1)\n");
+ if (out2.size != hash_data.size)
+ fail("Decrypted data don't match original (1)\n");
- if (memcmp(out2.data, hash_data.data, hash_data.size) != 0)
- fail ("Decrypted data don't match original (2)\n");
+ if (memcmp(out2.data, hash_data.data, hash_data.size) != 0)
+ fail("Decrypted data don't match original (2)\n");
- gnutls_free(out.data);
- gnutls_free(out2.data);
+ gnutls_free(out.data);
+ gnutls_free(out2.data);
- ret = gnutls_pubkey_encrypt_data(pubkey, 0, &raw_data, &out);
- if (ret < 0)
- fail ("gnutls_pubkey_encrypt_data\n");
+ ret =
+ gnutls_pubkey_encrypt_data(pubkey, 0, &raw_data, &out);
+ if (ret < 0)
+ fail("gnutls_pubkey_encrypt_data\n");
- ret = gnutls_privkey_decrypt_data (privkey, 0,
- &out, &out2);
- if (ret < 0)
- fail ("gnutls_privkey_decrypt_data\n");
+ ret = gnutls_privkey_decrypt_data(privkey, 0, &out, &out2);
+ if (ret < 0)
+ fail("gnutls_privkey_decrypt_data\n");
- if (out2.size != raw_data.size)
- fail ("Decrypted data don't match original (3)\n");
+ if (out2.size != raw_data.size)
+ fail("Decrypted data don't match original (3)\n");
- if (memcmp(out2.data, raw_data.data, raw_data.size) != 0)
- fail ("Decrypted data don't match original (4)\n");
+ if (memcmp(out2.data, raw_data.data, raw_data.size) != 0)
+ fail("Decrypted data don't match original (4)\n");
- if (debug) success("ok\n");
+ if (debug)
+ success("ok\n");
- gnutls_free(out.data);
- gnutls_free(out2.data);
- gnutls_x509_privkey_deinit (key);
- gnutls_x509_crt_deinit (crt);
- gnutls_privkey_deinit (privkey);
- gnutls_pubkey_deinit (pubkey);
- }
+ gnutls_free(out.data);
+ gnutls_free(out2.data);
+ gnutls_x509_privkey_deinit(key);
+ gnutls_x509_crt_deinit(crt);
+ gnutls_privkey_deinit(privkey);
+ gnutls_pubkey_deinit(pubkey);
+ }
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
diff --git a/tests/safe-renegotiation/srn0.c b/tests/safe-renegotiation/srn0.c
index 3ef03687e1..6eb10ad231 100644
--- a/tests/safe-renegotiation/srn0.c
+++ b/tests/safe-renegotiation/srn0.c
@@ -40,142 +40,140 @@
#include "../eagain-common.h"
#include "../utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwA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tm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vl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3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug) gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- if (!gnutls_safe_renegotiation_status (client) ||
- !gnutls_safe_renegotiation_status (server))
- {
- tls_log_func (0, "Session not using safe renegotiation!\n");
- exit(1);
- }
-
- sret = gnutls_rehandshake (server);
- if (debug)
- {
- tls_log_func (0, "gnutls_rehandshake (server)...\n");
- tls_log_func (0, gnutls_strerror (sret));
- tls_log_func (0, "\n");
- }
-
- {
- ssize_t n;
- char b[1];
- n = gnutls_record_recv (client, b, 1);
- if (n != GNUTLS_E_REHANDSHAKE)
- abort ();
- }
-
- HANDSHAKE(client, server);
-
- if (!gnutls_safe_renegotiation_status (client) ||
- !gnutls_safe_renegotiation_status (server))
- {
- tls_log_func (0,
- "Rehandshaked session not using safe renegotiation!\n");
- exit(1);
- }
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- {
- puts ("Self-test successful");
- }
-
- return;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server, "NORMAL", NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ if (!gnutls_safe_renegotiation_status(client) ||
+ !gnutls_safe_renegotiation_status(server)) {
+ tls_log_func(0, "Session not using safe renegotiation!\n");
+ exit(1);
+ }
+
+ sret = gnutls_rehandshake(server);
+ if (debug) {
+ tls_log_func(0, "gnutls_rehandshake (server)...\n");
+ tls_log_func(0, gnutls_strerror(sret));
+ tls_log_func(0, "\n");
+ }
+
+ {
+ ssize_t n;
+ char b[1];
+ n = gnutls_record_recv(client, b, 1);
+ if (n != GNUTLS_E_REHANDSHAKE)
+ abort();
+ }
+
+ HANDSHAKE(client, server);
+
+ if (!gnutls_safe_renegotiation_status(client) ||
+ !gnutls_safe_renegotiation_status(server)) {
+ tls_log_func(0,
+ "Rehandshaked session not using safe renegotiation!\n");
+ exit(1);
+ }
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug) {
+ puts("Self-test successful");
+ }
+
+ return;
}
diff --git a/tests/safe-renegotiation/srn1.c b/tests/safe-renegotiation/srn1.c
index 6a1df1ac98..ef41c6f912 100644
--- a/tests/safe-renegotiation/srn1.c
+++ b/tests/safe-renegotiation/srn1.c
@@ -39,118 +39,121 @@
#include "../eagain-common.h"
#include "../utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
- "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
- "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpT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W3HZLllpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug) gnutls_global_set_log_level (5);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL:%SAFE_RENEGOTIATION", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
- NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- /* Check that initially no session use the extension. */
- if (gnutls_safe_renegotiation_status (server)
- || gnutls_safe_renegotiation_status (client))
- {
- puts ("Client or server using extension before handshake?");
- abort ();
- }
-
- HANDSHAKE_EXPECT(client, server, GNUTLS_E_AGAIN, GNUTLS_E_SAFE_RENEGOTIATION_FAILED);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- {
- puts ("Self-test successful");
- }
-
- return;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(5);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server, "NORMAL:%SAFE_RENEGOTIATION",
+ NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client,
+ "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
+ NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ /* Check that initially no session use the extension. */
+ if (gnutls_safe_renegotiation_status(server)
+ || gnutls_safe_renegotiation_status(client)) {
+ puts("Client or server using extension before handshake?");
+ abort();
+ }
+
+ HANDSHAKE_EXPECT(client, server, GNUTLS_E_AGAIN,
+ GNUTLS_E_SAFE_RENEGOTIATION_FAILED);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug) {
+ puts("Self-test successful");
+ }
+
+ return;
}
diff --git a/tests/safe-renegotiation/srn2.c b/tests/safe-renegotiation/srn2.c
index 789c29cc89..04649c531e 100644
--- a/tests/safe-renegotiation/srn2.c
+++ b/tests/safe-renegotiation/srn2.c
@@ -37,194 +37,189 @@
#include "../eagain-common.h"
#include "../utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
- "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
- "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf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llpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug) gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- /* Check that initially no session use the extension. */
- if (gnutls_safe_renegotiation_status (server)
- || gnutls_safe_renegotiation_status (client))
- {
- puts ("Client or server using extension before handshake?");
- abort ();
- }
-
- HANDSHAKE(client, server);
-
- /* Check that both sessions use the extension. */
- if (!gnutls_safe_renegotiation_status (server)
- || !gnutls_safe_renegotiation_status (client))
- {
- puts ("Client or server not using safe renegotiation extension?");
- abort ();
- }
-
- sret = gnutls_rehandshake (server);
- if (debug)
- {
- tls_log_func (0, "gnutls_rehandshake (server)...\n");
- tls_log_func (0, gnutls_strerror (sret));
- tls_log_func (0, "\n");
- }
-
- {
- ssize_t n;
- char b[1];
- n = gnutls_record_recv (client, b, 1);
- if (n != GNUTLS_E_REHANDSHAKE)
- abort ();
- }
-
- HANDSHAKE(client, server);
-
- /* Check that session still use the extension. */
- if (!gnutls_safe_renegotiation_status (server)
- || !gnutls_safe_renegotiation_status (client))
- {
- puts ("Client or server not using safe renegotiation extension?");
- abort ();
- }
-
- /* Check that this API does not affect anything after first
- handshake.
- gnutls_safe_negotiation_set_initial (server, 0); */
-
- sret = gnutls_rehandshake (server);
- if (debug)
- {
- tls_log_func (0, "gnutls_rehandshake (server)...\n");
- tls_log_func (0, gnutls_strerror (sret));
- tls_log_func (0, "\n");
- }
-
- {
- ssize_t n;
- char b[1];
- n = gnutls_record_recv (client, b, 1);
- if (n != GNUTLS_E_REHANDSHAKE)
- abort ();
- }
-
- HANDSHAKE(client, server);
-
- /* Check that disabling the extension will break rehandshakes.
- gnutls_safe_renegotiation_set (client, 0); */
-
- sret = gnutls_rehandshake (server);
- if (debug)
- {
- tls_log_func (0, "gnutls_rehandshake (server)...\n");
- tls_log_func (0, gnutls_strerror (sret));
- tls_log_func (0, "\n");
- }
-
- {
- ssize_t n;
- char b[1];
- n = gnutls_record_recv (client, b, 1);
- if (n != GNUTLS_E_REHANDSHAKE)
- abort ();
- }
-
- HANDSHAKE(client, server);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- {
- puts ("Self-test successful");
- }
-
- return;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server, "NORMAL", NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ /* Check that initially no session use the extension. */
+ if (gnutls_safe_renegotiation_status(server)
+ || gnutls_safe_renegotiation_status(client)) {
+ puts("Client or server using extension before handshake?");
+ abort();
+ }
+
+ HANDSHAKE(client, server);
+
+ /* Check that both sessions use the extension. */
+ if (!gnutls_safe_renegotiation_status(server)
+ || !gnutls_safe_renegotiation_status(client)) {
+ puts("Client or server not using safe renegotiation extension?");
+ abort();
+ }
+
+ sret = gnutls_rehandshake(server);
+ if (debug) {
+ tls_log_func(0, "gnutls_rehandshake (server)...\n");
+ tls_log_func(0, gnutls_strerror(sret));
+ tls_log_func(0, "\n");
+ }
+
+ {
+ ssize_t n;
+ char b[1];
+ n = gnutls_record_recv(client, b, 1);
+ if (n != GNUTLS_E_REHANDSHAKE)
+ abort();
+ }
+
+ HANDSHAKE(client, server);
+
+ /* Check that session still use the extension. */
+ if (!gnutls_safe_renegotiation_status(server)
+ || !gnutls_safe_renegotiation_status(client)) {
+ puts("Client or server not using safe renegotiation extension?");
+ abort();
+ }
+
+ /* Check that this API does not affect anything after first
+ handshake.
+ gnutls_safe_negotiation_set_initial (server, 0); */
+
+ sret = gnutls_rehandshake(server);
+ if (debug) {
+ tls_log_func(0, "gnutls_rehandshake (server)...\n");
+ tls_log_func(0, gnutls_strerror(sret));
+ tls_log_func(0, "\n");
+ }
+
+ {
+ ssize_t n;
+ char b[1];
+ n = gnutls_record_recv(client, b, 1);
+ if (n != GNUTLS_E_REHANDSHAKE)
+ abort();
+ }
+
+ HANDSHAKE(client, server);
+
+ /* Check that disabling the extension will break rehandshakes.
+ gnutls_safe_renegotiation_set (client, 0); */
+
+ sret = gnutls_rehandshake(server);
+ if (debug) {
+ tls_log_func(0, "gnutls_rehandshake (server)...\n");
+ tls_log_func(0, gnutls_strerror(sret));
+ tls_log_func(0, "\n");
+ }
+
+ {
+ ssize_t n;
+ char b[1];
+ n = gnutls_record_recv(client, b, 1);
+ if (n != GNUTLS_E_REHANDSHAKE)
+ abort();
+ }
+
+ HANDSHAKE(client, server);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug) {
+ puts("Self-test successful");
+ }
+
+ return;
}
diff --git a/tests/safe-renegotiation/srn3.c b/tests/safe-renegotiation/srn3.c
index ecade2afad..cd83f24938 100644
--- a/tests/safe-renegotiation/srn3.c
+++ b/tests/safe-renegotiation/srn3.c
@@ -39,118 +39,122 @@
#include "../eagain-common.h"
#include "../utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTH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AMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1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2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug) gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
- NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL:%SAFE_RENEGOTIATION", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- /* Check that initially no session use the extension. */
- if (gnutls_safe_renegotiation_status (server)
- || gnutls_safe_renegotiation_status (client))
- {
- puts ("Client or server using extension before handshake?");
- abort ();
- }
-
- HANDSHAKE_EXPECT(client, server, GNUTLS_E_SAFE_RENEGOTIATION_FAILED, GNUTLS_E_AGAIN);
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- {
- puts ("Self-test successful");
- }
-
- return;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server,
+ "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
+ NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL:%SAFE_RENEGOTIATION",
+ NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ /* Check that initially no session use the extension. */
+ if (gnutls_safe_renegotiation_status(server)
+ || gnutls_safe_renegotiation_status(client)) {
+ puts("Client or server using extension before handshake?");
+ abort();
+ }
+
+ HANDSHAKE_EXPECT(client, server,
+ GNUTLS_E_SAFE_RENEGOTIATION_FAILED,
+ GNUTLS_E_AGAIN);
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug) {
+ puts("Self-test successful");
+ }
+
+ return;
}
diff --git a/tests/safe-renegotiation/srn4.c b/tests/safe-renegotiation/srn4.c
index 45552612da..cef03ef2c0 100644
--- a/tests/safe-renegotiation/srn4.c
+++ b/tests/safe-renegotiation/srn4.c
@@ -39,143 +39,144 @@
#include "../eagain-common.h"
#include "../utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHz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MBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K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P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug) gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL", NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
- NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- if (gnutls_safe_renegotiation_status (client) ||
- gnutls_safe_renegotiation_status (server))
- {
- tls_log_func (0, "Session using safe renegotiation but shouldn't!\n");
- exit(1);
- }
-
- sret = gnutls_rehandshake (server);
- if (debug)
- {
- tls_log_func (0, "gnutls_rehandshake (server)...\n");
- tls_log_func (0, gnutls_strerror (sret));
- tls_log_func (0, "\n");
- }
-
- {
- ssize_t n;
- char b[1];
- n = gnutls_record_recv (client, b, 1);
- if (n != GNUTLS_E_REHANDSHAKE)
- abort ();
- }
-
- HANDSHAKE_EXPECT(client, server, GNUTLS_E_AGAIN, GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED);
-
- if (gnutls_safe_renegotiation_status (client) ||
- gnutls_safe_renegotiation_status (server))
- {
- tls_log_func (0,
- "Rehandshaked session not using safe renegotiation!\n");
- exit(1);
- }
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- {
- puts ("Self-test successful");
- }
-
- return;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server, "NORMAL", NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client,
+ "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
+ NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ if (gnutls_safe_renegotiation_status(client) ||
+ gnutls_safe_renegotiation_status(server)) {
+ tls_log_func(0,
+ "Session using safe renegotiation but shouldn't!\n");
+ exit(1);
+ }
+
+ sret = gnutls_rehandshake(server);
+ if (debug) {
+ tls_log_func(0, "gnutls_rehandshake (server)...\n");
+ tls_log_func(0, gnutls_strerror(sret));
+ tls_log_func(0, "\n");
+ }
+
+ {
+ ssize_t n;
+ char b[1];
+ n = gnutls_record_recv(client, b, 1);
+ if (n != GNUTLS_E_REHANDSHAKE)
+ abort();
+ }
+
+ HANDSHAKE_EXPECT(client, server, GNUTLS_E_AGAIN,
+ GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED);
+
+ if (gnutls_safe_renegotiation_status(client) ||
+ gnutls_safe_renegotiation_status(server)) {
+ tls_log_func(0,
+ "Rehandshaked session not using safe renegotiation!\n");
+ exit(1);
+ }
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug) {
+ puts("Self-test successful");
+ }
+
+ return;
}
diff --git a/tests/safe-renegotiation/srn5.c b/tests/safe-renegotiation/srn5.c
index 8b7926347f..f1cd742069 100644
--- a/tests/safe-renegotiation/srn5.c
+++ b/tests/safe-renegotiation/srn5.c
@@ -40,148 +40,150 @@
#include "../eagain-common.h"
#include "../utils.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
- "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
- "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
- "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
- "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
- "-----END RSA PRIVATE KEY-----\n";
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
+ "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
+ "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
void doit(void)
{
- /* Server stuff. */
- gnutls_certificate_credentials_t serverx509cred;
- gnutls_session_t server;
- int sret = GNUTLS_E_AGAIN;
- /* Client stuff. */
- gnutls_certificate_credentials_t clientx509cred;
- gnutls_session_t client;
- int cret = GNUTLS_E_AGAIN;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug) gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_certificate_allocate_credentials (&serverx509cred);
- gnutls_certificate_set_x509_key_mem (serverx509cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- gnutls_init (&server, GNUTLS_SERVER);
- gnutls_credentials_set (server, GNUTLS_CRD_CERTIFICATE, serverx509cred);
- gnutls_priority_set_direct (server, "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
- NULL);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_certificate_allocate_credentials (&clientx509cred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, clientx509cred);
- gnutls_priority_set_direct (client, "NORMAL", NULL);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- HANDSHAKE(client, server);
-
- if (gnutls_safe_renegotiation_status (client))
- {
- tls_log_func (0, "Client thinks it is using safe renegotiation!\n");
- exit(1);
- }
-
- if (gnutls_safe_renegotiation_status (server))
- {
- tls_log_func (0, "Server thinks it is using safe renegotiation!\n");
- exit(1);
- }
-
- sret = gnutls_rehandshake (server);
- if (debug)
- {
- tls_log_func (0, "gnutls_rehandshake (server)...\n");
- tls_log_func (0, gnutls_strerror (sret));
- tls_log_func (0, "\n");
- }
-
- {
- ssize_t n;
- char b[1];
- n = gnutls_record_recv (client, b, 1);
- if (n != GNUTLS_E_REHANDSHAKE)
- abort ();
- }
-
- HANDSHAKE_EXPECT(client, server, GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED, GNUTLS_E_AGAIN);
-
- if (gnutls_safe_renegotiation_status (client) ||
- gnutls_safe_renegotiation_status (server))
- {
- tls_log_func (0,
- "Rehandshaked session not using safe renegotiation!\n");
- exit(1);
- }
-
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
- gnutls_bye (server, GNUTLS_SHUT_RDWR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_certificate_free_credentials (serverx509cred);
- gnutls_certificate_free_credentials (clientx509cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- {
- puts ("Self-test successful");
- }
-
- return;
+ /* Server stuff. */
+ gnutls_certificate_credentials_t serverx509cred;
+ gnutls_session_t server;
+ int sret = GNUTLS_E_AGAIN;
+ /* Client stuff. */
+ gnutls_certificate_credentials_t clientx509cred;
+ gnutls_session_t client;
+ int cret = GNUTLS_E_AGAIN;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_certificate_allocate_credentials(&serverx509cred);
+ gnutls_certificate_set_x509_key_mem(serverx509cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_init(&server, GNUTLS_SERVER);
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
+ serverx509cred);
+ gnutls_priority_set_direct(server,
+ "NORMAL:%DISABLE_SAFE_RENEGOTIATION",
+ NULL);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_certificate_allocate_credentials(&clientx509cred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ clientx509cred);
+ gnutls_priority_set_direct(client, "NORMAL", NULL);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ HANDSHAKE(client, server);
+
+ if (gnutls_safe_renegotiation_status(client)) {
+ tls_log_func(0,
+ "Client thinks it is using safe renegotiation!\n");
+ exit(1);
+ }
+
+ if (gnutls_safe_renegotiation_status(server)) {
+ tls_log_func(0,
+ "Server thinks it is using safe renegotiation!\n");
+ exit(1);
+ }
+
+ sret = gnutls_rehandshake(server);
+ if (debug) {
+ tls_log_func(0, "gnutls_rehandshake (server)...\n");
+ tls_log_func(0, gnutls_strerror(sret));
+ tls_log_func(0, "\n");
+ }
+
+ {
+ ssize_t n;
+ char b[1];
+ n = gnutls_record_recv(client, b, 1);
+ if (n != GNUTLS_E_REHANDSHAKE)
+ abort();
+ }
+
+ HANDSHAKE_EXPECT(client, server,
+ GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED,
+ GNUTLS_E_AGAIN);
+
+ if (gnutls_safe_renegotiation_status(client) ||
+ gnutls_safe_renegotiation_status(server)) {
+ tls_log_func(0,
+ "Rehandshaked session not using safe renegotiation!\n");
+ exit(1);
+ }
+
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_certificate_free_credentials(serverx509cred);
+ gnutls_certificate_free_credentials(clientx509cred);
+
+ gnutls_global_deinit();
+
+ if (debug) {
+ puts("Self-test successful");
+ }
+
+ return;
}
diff --git a/tests/set_pkcs12_cred.c b/tests/set_pkcs12_cred.c
index 3aad07d122..5038a8ef47 100644
--- a/tests/set_pkcs12_cred.c
+++ b/tests/set_pkcs12_cred.c
@@ -29,83 +29,87 @@
#include "utils.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "<%d>| %s", level, str);
+ fprintf(stderr, "<%d>| %s", level, str);
}
-void
-doit (void)
+void doit(void)
{
- gnutls_certificate_credentials_t x509cred;
- const char *file, *password;
- int ret;
-
- ret = global_init ();
- if (ret < 0)
- fail ("global_init failed %d\n", ret);
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- ret = gnutls_certificate_allocate_credentials (&x509cred);
- if (ret < 0)
- fail ("gnutls_certificate_allocate_credentials failed %d\n", ret);
-
- file = getenv ("PKCS12FILE");
- password = getenv ("PKCS12PASSWORD");
-
- if (!file)
- file = "pkcs12-decode/client.p12";
- if (!password)
- password = "foobar";
-
- if (debug)
- success ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
- file, password);
- ret = gnutls_certificate_set_x509_simple_pkcs12_file (x509cred,
- file,
- GNUTLS_X509_FMT_DER,
- password);
- if (ret < 0)
- fail ("x509_pkcs12 failed %d: %s\n", ret, gnutls_strerror (ret));
-
- if (debug)
- success ("Read file OK\n");
-
- gnutls_certificate_free_credentials (x509cred);
-
- /* try now if we can read correctly from a pkcs12 file that
- * contains two certificates (one unrelated with key)
- */
- ret = gnutls_certificate_allocate_credentials (&x509cred);
- if (ret < 0)
- fail ("gnutls_certificate_allocate_credentials failed %d\n", ret);
-
- file = getenv ("PKCS12FILE_2");
- password = getenv ("PKCS12PASSWORD_2");
-
- if (!file)
- file = "pkcs12-decode/pkcs12_2certs.p12";
- if (!password)
- password = "";
-
- if (debug)
- success ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
- file, password);
- ret = gnutls_certificate_set_x509_simple_pkcs12_file (x509cred,
- file,
- GNUTLS_X509_FMT_DER,
- password);
- if (ret < 0)
- fail ("x509_pkcs12 failed %d: %s\n", ret, gnutls_strerror (ret));
-
- if (debug)
- success ("Read file OK\n");
-
- gnutls_certificate_free_credentials (x509cred);
-
- gnutls_global_deinit ();
+ gnutls_certificate_credentials_t x509cred;
+ const char *file, *password;
+ int ret;
+
+ ret = global_init();
+ if (ret < 0)
+ fail("global_init failed %d\n", ret);
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ ret = gnutls_certificate_allocate_credentials(&x509cred);
+ if (ret < 0)
+ fail("gnutls_certificate_allocate_credentials failed %d\n",
+ ret);
+
+ file = getenv("PKCS12FILE");
+ password = getenv("PKCS12PASSWORD");
+
+ if (!file)
+ file = "pkcs12-decode/client.p12";
+ if (!password)
+ password = "foobar";
+
+ if (debug)
+ success
+ ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
+ file, password);
+ ret =
+ gnutls_certificate_set_x509_simple_pkcs12_file(x509cred, file,
+ GNUTLS_X509_FMT_DER,
+ password);
+ if (ret < 0)
+ fail("x509_pkcs12 failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+
+ if (debug)
+ success("Read file OK\n");
+
+ gnutls_certificate_free_credentials(x509cred);
+
+ /* try now if we can read correctly from a pkcs12 file that
+ * contains two certificates (one unrelated with key)
+ */
+ ret = gnutls_certificate_allocate_credentials(&x509cred);
+ if (ret < 0)
+ fail("gnutls_certificate_allocate_credentials failed %d\n",
+ ret);
+
+ file = getenv("PKCS12FILE_2");
+ password = getenv("PKCS12PASSWORD_2");
+
+ if (!file)
+ file = "pkcs12-decode/pkcs12_2certs.p12";
+ if (!password)
+ password = "";
+
+ if (debug)
+ success
+ ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
+ file, password);
+ ret =
+ gnutls_certificate_set_x509_simple_pkcs12_file(x509cred, file,
+ GNUTLS_X509_FMT_DER,
+ password);
+ if (ret < 0)
+ fail("x509_pkcs12 failed %d: %s\n", ret,
+ gnutls_strerror(ret));
+
+ if (debug)
+ success("Read file OK\n");
+
+ gnutls_certificate_free_credentials(x509cred);
+
+ gnutls_global_deinit();
}
diff --git a/tests/setcredcrash.c b/tests/setcredcrash.c
index 85bccd66d6..eade66785e 100644
--- a/tests/setcredcrash.c
+++ b/tests/setcredcrash.c
@@ -30,27 +30,26 @@
#include <utils.h>
#include <gnutls/gnutls.h>
-int
-main (int argc, char *argv[])
+int main(int argc, char *argv[])
{
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
- global_init ();
+ global_init();
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT);
- gnutls_set_default_priority (client);
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ gnutls_set_default_priority(client);
- /* Test setting the same credential type twice. Earlier GnuTLS had
- a bug that crashed when this happened. */
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
+ /* Test setting the same credential type twice. Earlier GnuTLS had
+ a bug that crashed when this happened. */
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_deinit (client);
- gnutls_anon_free_client_credentials (c_anoncred);
+ gnutls_deinit(client);
+ gnutls_anon_free_client_credentials(c_anoncred);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
- return 0;
+ return 0;
}
diff --git a/tests/simple.c b/tests/simple.c
index 8a9481376a..f249bfae41 100644
--- a/tests/simple.c
+++ b/tests/simple.c
@@ -28,72 +28,78 @@
#include "utils.h"
-void
-doit (void)
+void doit(void)
{
- if (debug)
- {
- printf ("GnuTLS header version %s.\n", GNUTLS_VERSION);
- printf ("GnuTLS library version %s.\n", gnutls_check_version (NULL));
- }
+ if (debug) {
+ printf("GnuTLS header version %s.\n", GNUTLS_VERSION);
+ printf("GnuTLS library version %s.\n",
+ gnutls_check_version(NULL));
+ }
- if (!gnutls_check_version (GNUTLS_VERSION))
- fail ("gnutls_check_version ERROR\n");
+ if (!gnutls_check_version(GNUTLS_VERSION))
+ fail("gnutls_check_version ERROR\n");
- {
- const gnutls_pk_algorithm_t *algs;
- size_t i;
- int pk;
+ {
+ const gnutls_pk_algorithm_t *algs;
+ size_t i;
+ int pk;
- algs = gnutls_pk_list ();
- if (!algs)
- fail ("gnutls_pk_list return NULL\n");
+ algs = gnutls_pk_list();
+ if (!algs)
+ fail("gnutls_pk_list return NULL\n");
- for (i = 0; algs[i]; i++)
- {
- if (debug)
- printf ("pk_list[%d] = %d = %s = %d\n", (int) i, algs[i],
- gnutls_pk_algorithm_get_name (algs[i]),
- gnutls_pk_get_id (gnutls_pk_algorithm_get_name (algs[i])));
- if (gnutls_pk_get_id (gnutls_pk_algorithm_get_name (algs[i]))
- != algs[i])
- fail ("gnutls_pk id's doesn't match\n");
- }
+ for (i = 0; algs[i]; i++) {
+ if (debug)
+ printf("pk_list[%d] = %d = %s = %d\n",
+ (int) i, algs[i],
+ gnutls_pk_algorithm_get_name(algs
+ [i]),
+ gnutls_pk_get_id
+ (gnutls_pk_algorithm_get_name
+ (algs[i])));
+ if (gnutls_pk_get_id
+ (gnutls_pk_algorithm_get_name(algs[i]))
+ != algs[i])
+ fail("gnutls_pk id's doesn't match\n");
+ }
- pk = gnutls_pk_get_id ("foo");
- if (pk != GNUTLS_PK_UNKNOWN)
- fail ("gnutls_pk unknown test failed (%d)\n", pk);
+ pk = gnutls_pk_get_id("foo");
+ if (pk != GNUTLS_PK_UNKNOWN)
+ fail("gnutls_pk unknown test failed (%d)\n", pk);
- if (debug)
- success ("gnutls_pk_list ok\n");
- }
+ if (debug)
+ success("gnutls_pk_list ok\n");
+ }
- {
- const gnutls_sign_algorithm_t *algs;
- size_t i;
- int pk;
+ {
+ const gnutls_sign_algorithm_t *algs;
+ size_t i;
+ int pk;
- algs = gnutls_sign_list ();
- if (!algs)
- fail ("gnutls_sign_list return NULL\n");
+ algs = gnutls_sign_list();
+ if (!algs)
+ fail("gnutls_sign_list return NULL\n");
- for (i = 0; algs[i]; i++)
- {
- if (debug)
- printf ("sign_list[%d] = %d = %s = %d\n", (int) i, algs[i],
- gnutls_sign_algorithm_get_name (algs[i]),
- gnutls_sign_get_id (gnutls_sign_algorithm_get_name
- (algs[i])));
- if (gnutls_sign_get_id (gnutls_sign_algorithm_get_name (algs[i])) !=
- algs[i])
- fail ("gnutls_sign id's doesn't match\n");
- }
+ for (i = 0; algs[i]; i++) {
+ if (debug)
+ printf("sign_list[%d] = %d = %s = %d\n",
+ (int) i, algs[i],
+ gnutls_sign_algorithm_get_name(algs
+ [i]),
+ gnutls_sign_get_id
+ (gnutls_sign_algorithm_get_name
+ (algs[i])));
+ if (gnutls_sign_get_id
+ (gnutls_sign_algorithm_get_name(algs[i])) !=
+ algs[i])
+ fail("gnutls_sign id's doesn't match\n");
+ }
- pk = gnutls_sign_get_id ("foo");
- if (pk != GNUTLS_PK_UNKNOWN)
- fail ("gnutls_sign unknown test failed (%d)\n", pk);
+ pk = gnutls_sign_get_id("foo");
+ if (pk != GNUTLS_PK_UNKNOWN)
+ fail("gnutls_sign unknown test failed (%d)\n", pk);
- if (debug)
- success ("gnutls_sign_list ok\n");
- }
+ if (debug)
+ success("gnutls_sign_list ok\n");
+ }
}
diff --git a/tests/slow/cipher-test.c b/tests/slow/cipher-test.c
index 90c4300a42..bbac05921e 100644
--- a/tests/slow/cipher-test.c
+++ b/tests/slow/cipher-test.c
@@ -11,634 +11,609 @@
* cpu instructions (AES-NI or padlock).
*/
-struct aes_vectors_st
-{
- const uint8_t *key;
- const uint8_t *plaintext;
- const uint8_t *ciphertext;
+struct aes_vectors_st {
+ const uint8_t *key;
+ const uint8_t *plaintext;
+ const uint8_t *ciphertext;
};
-struct aes_gcm_vectors_st
-{
- const uint8_t *key;
- const uint8_t *auth;
- unsigned int auth_size;
- const uint8_t *plaintext;
- unsigned int plaintext_size;
- const uint8_t *iv;
- const uint8_t *ciphertext;
- const uint8_t *tag;
+struct aes_gcm_vectors_st {
+ const uint8_t *key;
+ const uint8_t *auth;
+ unsigned int auth_size;
+ const uint8_t *plaintext;
+ unsigned int plaintext_size;
+ const uint8_t *iv;
+ const uint8_t *ciphertext;
+ const uint8_t *tag;
};
struct aes_gcm_vectors_st aes_gcm_vectors[] = {
#if 0
- {
- .key = (void*)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .auth = NULL,
- .auth_size = 0,
- .plaintext = NULL,
- .plaintext_size = 0,
- .ciphertext = NULL,
- .iv = (void*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .tag = (void*)
- "\x58\xe2\xfc\xce\xfa\x7e\x30\x61\x36\x7f\x1d\x57\xa4\xe7\x45\x5a"},
+ {
+ .key = (void *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .auth = NULL,
+ .auth_size = 0,
+ .plaintext = NULL,
+ .plaintext_size = 0,
+ .ciphertext = NULL,
+ .iv = (void *) "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .tag = (void *)
+ "\x58\xe2\xfc\xce\xfa\x7e\x30\x61\x36\x7f\x1d\x57\xa4\xe7\x45\x5a"},
#endif
- {
- .key = (void*)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .auth = NULL,
- .auth_size = 0,
- .plaintext = (void*)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .plaintext_size = 16,
- .ciphertext = (void*)
- "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78",
- .iv = (void*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .tag = (void*)
- "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf"},
- {
- .key = (void*)
- "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08",
- .auth = (void*)
- "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2",
- .auth_size = 20,
- .plaintext = (void*)
- "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39",
- .plaintext_size = 60,
- .ciphertext = (void*)
- "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91",
- .iv = (void*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88",
- .tag = (void*)
- "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47"}
+ {
+ .key = (void *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .auth = NULL,
+ .auth_size = 0,
+ .plaintext = (void *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .plaintext_size = 16,
+ .ciphertext = (void *)
+ "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78",
+ .iv = (void *) "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .tag = (void *)
+ "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf"},
+ {
+ .key = (void *)
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .auth = (void *)
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2",
+ .auth_size = 20,
+ .plaintext = (void *)
+ "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39",
+ .plaintext_size = 60,
+ .ciphertext = (void *)
+ "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91",
+ .iv = (void *) "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88",
+ .tag = (void *)
+ "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47"}
};
struct aes_vectors_st aes_vectors[] = {
- {
- .key =
- (uint8_t *)
- "\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .plaintext = (uint8_t *)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .ciphertext = (uint8_t *)
- "\x4b\xc3\xf8\x83\x45\x0c\x11\x3c\x64\xca\x42\xe1\x11\x2a\x9e\x87",
- },
- {
- .key = (uint8_t *)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .plaintext = (uint8_t *)
- "\xf3\x44\x81\xec\x3c\xc6\x27\xba\xcd\x5d\xc3\xfb\x08\xf2\x73\xe6",
- .ciphertext = (uint8_t *)
- "\x03\x36\x76\x3e\x96\x6d\x92\x59\x5a\x56\x7c\xc9\xce\x53\x7f\x5e",
- },
- {
- .key = (uint8_t *)
- "\x10\xa5\x88\x69\xd7\x4b\xe5\xa3\x74\xcf\x86\x7c\xfb\x47\x38\x59",
- .plaintext = (uint8_t *)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .ciphertext = (uint8_t *)
- "\x6d\x25\x1e\x69\x44\xb0\x51\xe0\x4e\xaa\x6f\xb4\xdb\xf7\x84\x65",
- },
- {
- .key = (uint8_t *)
- "\xca\xea\x65\xcd\xbb\x75\xe9\x16\x9e\xcd\x22\xeb\xe6\xe5\x46\x75",
- .plaintext = (uint8_t *)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .ciphertext = (uint8_t *)
- "\x6e\x29\x20\x11\x90\x15\x2d\xf4\xee\x05\x81\x39\xde\xf6\x10\xbb",
- },
- {
- .key = (uint8_t *)
- "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe",
- .plaintext = (uint8_t *)
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
- .ciphertext = (uint8_t *)
- "\x9b\xa4\xa9\x14\x3f\x4e\x5d\x40\x48\x52\x1c\x4f\x88\x77\xd8\x8e",
- },
+ {
+ .key = (uint8_t *)
+ "\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .plaintext = (uint8_t *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ciphertext = (uint8_t *)
+ "\x4b\xc3\xf8\x83\x45\x0c\x11\x3c\x64\xca\x42\xe1\x11\x2a\x9e\x87",
+ },
+ {
+ .key = (uint8_t *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .plaintext = (uint8_t *)
+ "\xf3\x44\x81\xec\x3c\xc6\x27\xba\xcd\x5d\xc3\xfb\x08\xf2\x73\xe6",
+ .ciphertext = (uint8_t *)
+ "\x03\x36\x76\x3e\x96\x6d\x92\x59\x5a\x56\x7c\xc9\xce\x53\x7f\x5e",
+ },
+ {
+ .key = (uint8_t *)
+ "\x10\xa5\x88\x69\xd7\x4b\xe5\xa3\x74\xcf\x86\x7c\xfb\x47\x38\x59",
+ .plaintext = (uint8_t *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ciphertext = (uint8_t *)
+ "\x6d\x25\x1e\x69\x44\xb0\x51\xe0\x4e\xaa\x6f\xb4\xdb\xf7\x84\x65",
+ },
+ {
+ .key = (uint8_t *)
+ "\xca\xea\x65\xcd\xbb\x75\xe9\x16\x9e\xcd\x22\xeb\xe6\xe5\x46\x75",
+ .plaintext = (uint8_t *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ciphertext = (uint8_t *)
+ "\x6e\x29\x20\x11\x90\x15\x2d\xf4\xee\x05\x81\x39\xde\xf6\x10\xbb",
+ },
+ {
+ .key = (uint8_t *)
+ "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe",
+ .plaintext = (uint8_t *)
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ciphertext = (uint8_t *)
+ "\x9b\xa4\xa9\x14\x3f\x4e\x5d\x40\x48\x52\x1c\x4f\x88\x77\xd8\x8e",
+ },
};
/* AES cipher */
-static int
-test_aes (void)
+static int test_aes(void)
{
- gnutls_cipher_hd_t hd;
- int ret;
- unsigned int i, j;
- uint8_t _iv[16];
- uint8_t tmp[128];
- gnutls_datum_t key, iv;
-
- fprintf (stdout, "Tests on AES Encryption: ");
- fflush (stdout);
- for (i = 0; i < sizeof (aes_vectors) / sizeof (aes_vectors[0]); i++)
- {
- memset (_iv, 0, sizeof (_iv));
- memset (tmp, 0, sizeof (tmp));
- key.data = (void *) aes_vectors[i].key;
- key.size = 16;
-
- iv.data = _iv;
- iv.size = 16;
-
- ret =
- gnutls_cipher_init (&hd, GNUTLS_CIPHER_AES_128_CBC, &key,
- &iv);
- if (ret < 0)
- {
- fprintf (stderr, "%d: AES test %d failed\n", __LINE__, i);
- return 1;
- }
-
- ret = gnutls_cipher_encrypt2 (hd, aes_vectors[i].plaintext, 16,
- tmp, sizeof(tmp));
- if (ret < 0)
- {
- fprintf (stderr, "%d: AES test %d failed\n", __LINE__, i);
- return 1;
- }
-
- gnutls_cipher_deinit (hd);
-
- if (memcmp (tmp, aes_vectors[i].ciphertext, 16) != 0)
- {
- fprintf (stderr, "AES test vector %d failed!\n", i);
-
- fprintf (stderr, "Cipher[%d]: ", 16);
- for (j = 0; j < 16; j++)
- fprintf (stderr, "%.2x:", (int) tmp[j]);
- fprintf (stderr, "\n");
-
- fprintf (stderr, "Expected[%d]: ", 16);
- for (j = 0; j < 16; j++)
- fprintf (stderr, "%.2x:",
- (int) aes_vectors[i].ciphertext[j]);
- fprintf (stderr, "\n");
- return 1;
- }
- }
- fprintf (stdout, "ok\n");
-
- fprintf (stdout, "Tests on AES Decryption: ");
- fflush (stdout);
- for (i = 0; i < sizeof (aes_vectors) / sizeof (aes_vectors[0]); i++)
- {
-
- memset (_iv, 0, sizeof (_iv));
- memset (tmp, 0x33, sizeof (tmp));
-
- key.data = (void *) aes_vectors[i].key;
- key.size = 16;
-
- iv.data = _iv;
- iv.size = 16;
-
- ret =
- gnutls_cipher_init (&hd, GNUTLS_CIPHER_AES_128_CBC, &key,
- &iv);
- if (ret < 0)
- {
- fprintf (stderr, "%d: AES test %d failed\n", __LINE__, i);
- return 1;
- }
-
- ret = gnutls_cipher_decrypt2 (hd, aes_vectors[i].ciphertext, 16,
- tmp, sizeof(tmp));
- if (ret < 0)
- {
- fprintf (stderr, "%d: AES test %d failed\n", __LINE__, i);
- return 1;
- }
-
- gnutls_cipher_deinit (hd);
-
- if (memcmp (tmp, aes_vectors[i].plaintext, 16) != 0)
- {
- fprintf (stderr, "AES test vector %d failed!\n", i);
-
- fprintf (stderr, "Plain[%d]: ", 16);
- for (j = 0; j < 16; j++)
- fprintf (stderr, "%.2x:", (int) tmp[j]);
- fprintf (stderr, "\n");
-
- fprintf (stderr, "Expected[%d]: ", 16);
- for (j = 0; j < 16; j++)
- fprintf (stderr, "%.2x:",
- (int) aes_vectors[i].plaintext[j]);
- fprintf (stderr, "\n");
- return 1;
- }
- }
-
- fprintf (stdout, "ok\n");
- fprintf (stdout, "\n");
-
- fprintf (stdout, "Tests on AES-GCM: ");
- fflush (stdout);
- for (i = 0; i < sizeof (aes_gcm_vectors) / sizeof (aes_gcm_vectors[0]);
- i++)
- {
- memset (tmp, 0, sizeof (tmp));
- key.data = (void *) aes_gcm_vectors[i].key;
- key.size = 16;
-
- iv.data = (void *) aes_gcm_vectors[i].iv;
- iv.size = 12;
-
- ret =
- gnutls_cipher_init (&hd, GNUTLS_CIPHER_AES_128_GCM, &key,
- &iv);
- if (ret < 0)
- {
- fprintf (stderr, "%d: AES-GCM test %d failed\n", __LINE__,
- i);
- return 1;
- }
-
- if (aes_gcm_vectors[i].auth_size > 0)
- {
- ret =
- gnutls_cipher_add_auth (hd, aes_gcm_vectors[i].auth,
- aes_gcm_vectors[i].auth_size);
-
- if (ret < 0)
- {
- fprintf (stderr, "%d: AES-GCM test %d failed\n",
- __LINE__, i);
- return 1;
- }
- }
-
- if (aes_gcm_vectors[i].plaintext_size > 0)
- {
- ret =
- gnutls_cipher_encrypt2 (hd,
- aes_gcm_vectors[i].plaintext,
- aes_gcm_vectors[i].
- plaintext_size, tmp,
- sizeof(tmp));
- if (ret < 0)
- {
- fprintf (stderr, "%d: AES-GCM test %d failed: %s\n",
- __LINE__, i, gnutls_strerror(ret));
- return 1;
- }
- }
-
-
- if (aes_gcm_vectors[i].plaintext_size > 0)
- if (memcmp
- (tmp, aes_gcm_vectors[i].ciphertext,
- aes_gcm_vectors[i].plaintext_size) != 0)
- {
- fprintf (stderr, "AES-GCM test vector %d failed!\n",
- i);
-
- fprintf (stderr, "Cipher[%d]: ",
- aes_gcm_vectors[i].plaintext_size);
- for (j = 0; j < aes_gcm_vectors[i].plaintext_size; j++)
- fprintf (stderr, "%.2x:", (int) tmp[j]);
- fprintf (stderr, "\n");
-
- fprintf (stderr, "Expected[%d]: ",
- aes_gcm_vectors[i].plaintext_size);
- for (j = 0; j < aes_gcm_vectors[i].plaintext_size; j++)
- fprintf (stderr, "%.2x:",
- (int) aes_gcm_vectors[i].ciphertext[j]);
- fprintf (stderr, "\n");
- return 1;
- }
-
- gnutls_cipher_tag (hd, tmp, 16);
- if (memcmp (tmp, aes_gcm_vectors[i].tag, 16) != 0)
- {
- fprintf (stderr, "AES-GCM test vector %d failed (tag)!\n",
- i);
-
- fprintf (stderr, "Tag[%d]: ", 16);
- for (j = 0; j < 16; j++)
- fprintf (stderr, "%.2x:", (int) tmp[j]);
- fprintf (stderr, "\n");
-
- fprintf (stderr, "Expected[%d]: ", 16);
- for (j = 0; j < 16; j++)
- fprintf (stderr, "%.2x:",
- (int) aes_gcm_vectors[i].tag[j]);
- fprintf (stderr, "\n");
- return 1;
- }
-
- gnutls_cipher_deinit (hd);
-
- }
- fprintf (stdout, "ok\n");
- fprintf (stdout, "\n");
-
-
- return 0;
+ gnutls_cipher_hd_t hd;
+ int ret;
+ unsigned int i, j;
+ uint8_t _iv[16];
+ uint8_t tmp[128];
+ gnutls_datum_t key, iv;
+
+ fprintf(stdout, "Tests on AES Encryption: ");
+ fflush(stdout);
+ for (i = 0; i < sizeof(aes_vectors) / sizeof(aes_vectors[0]); i++) {
+ memset(_iv, 0, sizeof(_iv));
+ memset(tmp, 0, sizeof(tmp));
+ key.data = (void *) aes_vectors[i].key;
+ key.size = 16;
+
+ iv.data = _iv;
+ iv.size = 16;
+
+ ret =
+ gnutls_cipher_init(&hd, GNUTLS_CIPHER_AES_128_CBC,
+ &key, &iv);
+ if (ret < 0) {
+ fprintf(stderr, "%d: AES test %d failed\n",
+ __LINE__, i);
+ return 1;
+ }
+
+ ret =
+ gnutls_cipher_encrypt2(hd, aes_vectors[i].plaintext,
+ 16, tmp, sizeof(tmp));
+ if (ret < 0) {
+ fprintf(stderr, "%d: AES test %d failed\n",
+ __LINE__, i);
+ return 1;
+ }
+
+ gnutls_cipher_deinit(hd);
+
+ if (memcmp(tmp, aes_vectors[i].ciphertext, 16) != 0) {
+ fprintf(stderr, "AES test vector %d failed!\n", i);
+
+ fprintf(stderr, "Cipher[%d]: ", 16);
+ for (j = 0; j < 16; j++)
+ fprintf(stderr, "%.2x:", (int) tmp[j]);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "Expected[%d]: ", 16);
+ for (j = 0; j < 16; j++)
+ fprintf(stderr, "%.2x:",
+ (int) aes_vectors[i].
+ ciphertext[j]);
+ fprintf(stderr, "\n");
+ return 1;
+ }
+ }
+ fprintf(stdout, "ok\n");
+
+ fprintf(stdout, "Tests on AES Decryption: ");
+ fflush(stdout);
+ for (i = 0; i < sizeof(aes_vectors) / sizeof(aes_vectors[0]); i++) {
+
+ memset(_iv, 0, sizeof(_iv));
+ memset(tmp, 0x33, sizeof(tmp));
+
+ key.data = (void *) aes_vectors[i].key;
+ key.size = 16;
+
+ iv.data = _iv;
+ iv.size = 16;
+
+ ret =
+ gnutls_cipher_init(&hd, GNUTLS_CIPHER_AES_128_CBC,
+ &key, &iv);
+ if (ret < 0) {
+ fprintf(stderr, "%d: AES test %d failed\n",
+ __LINE__, i);
+ return 1;
+ }
+
+ ret =
+ gnutls_cipher_decrypt2(hd, aes_vectors[i].ciphertext,
+ 16, tmp, sizeof(tmp));
+ if (ret < 0) {
+ fprintf(stderr, "%d: AES test %d failed\n",
+ __LINE__, i);
+ return 1;
+ }
+
+ gnutls_cipher_deinit(hd);
+
+ if (memcmp(tmp, aes_vectors[i].plaintext, 16) != 0) {
+ fprintf(stderr, "AES test vector %d failed!\n", i);
+
+ fprintf(stderr, "Plain[%d]: ", 16);
+ for (j = 0; j < 16; j++)
+ fprintf(stderr, "%.2x:", (int) tmp[j]);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "Expected[%d]: ", 16);
+ for (j = 0; j < 16; j++)
+ fprintf(stderr, "%.2x:",
+ (int) aes_vectors[i].plaintext[j]);
+ fprintf(stderr, "\n");
+ return 1;
+ }
+ }
+
+ fprintf(stdout, "ok\n");
+ fprintf(stdout, "\n");
+
+ fprintf(stdout, "Tests on AES-GCM: ");
+ fflush(stdout);
+ for (i = 0;
+ i < sizeof(aes_gcm_vectors) / sizeof(aes_gcm_vectors[0]);
+ i++) {
+ memset(tmp, 0, sizeof(tmp));
+ key.data = (void *) aes_gcm_vectors[i].key;
+ key.size = 16;
+
+ iv.data = (void *) aes_gcm_vectors[i].iv;
+ iv.size = 12;
+
+ ret =
+ gnutls_cipher_init(&hd, GNUTLS_CIPHER_AES_128_GCM,
+ &key, &iv);
+ if (ret < 0) {
+ fprintf(stderr, "%d: AES-GCM test %d failed\n",
+ __LINE__, i);
+ return 1;
+ }
+
+ if (aes_gcm_vectors[i].auth_size > 0) {
+ ret =
+ gnutls_cipher_add_auth(hd,
+ aes_gcm_vectors[i].auth,
+ aes_gcm_vectors[i].
+ auth_size);
+
+ if (ret < 0) {
+ fprintf(stderr,
+ "%d: AES-GCM test %d failed\n",
+ __LINE__, i);
+ return 1;
+ }
+ }
+
+ if (aes_gcm_vectors[i].plaintext_size > 0) {
+ ret =
+ gnutls_cipher_encrypt2(hd,
+ aes_gcm_vectors[i].
+ plaintext,
+ aes_gcm_vectors
+ [i].plaintext_size, tmp,
+ sizeof(tmp));
+ if (ret < 0) {
+ fprintf(stderr,
+ "%d: AES-GCM test %d failed: %s\n",
+ __LINE__, i, gnutls_strerror(ret));
+ return 1;
+ }
+ }
+
+
+ if (aes_gcm_vectors[i].plaintext_size > 0)
+ if (memcmp
+ (tmp, aes_gcm_vectors[i].ciphertext,
+ aes_gcm_vectors[i].plaintext_size) != 0) {
+ fprintf(stderr,
+ "AES-GCM test vector %d failed!\n",
+ i);
+
+ fprintf(stderr, "Cipher[%d]: ",
+ aes_gcm_vectors[i].plaintext_size);
+ for (j = 0;
+ j < aes_gcm_vectors[i].plaintext_size;
+ j++)
+ fprintf(stderr, "%.2x:",
+ (int) tmp[j]);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "Expected[%d]: ",
+ aes_gcm_vectors[i].plaintext_size);
+ for (j = 0;
+ j < aes_gcm_vectors[i].plaintext_size;
+ j++)
+ fprintf(stderr, "%.2x:",
+ (int) aes_gcm_vectors[i].
+ ciphertext[j]);
+ fprintf(stderr, "\n");
+ return 1;
+ }
+
+ gnutls_cipher_tag(hd, tmp, 16);
+ if (memcmp(tmp, aes_gcm_vectors[i].tag, 16) != 0) {
+ fprintf(stderr,
+ "AES-GCM test vector %d failed (tag)!\n",
+ i);
+
+ fprintf(stderr, "Tag[%d]: ", 16);
+ for (j = 0; j < 16; j++)
+ fprintf(stderr, "%.2x:", (int) tmp[j]);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "Expected[%d]: ", 16);
+ for (j = 0; j < 16; j++)
+ fprintf(stderr, "%.2x:",
+ (int) aes_gcm_vectors[i].tag[j]);
+ fprintf(stderr, "\n");
+ return 1;
+ }
+
+ gnutls_cipher_deinit(hd);
+
+ }
+ fprintf(stdout, "ok\n");
+ fprintf(stdout, "\n");
+
+
+ return 0;
}
-struct hash_vectors_st
-{
- const char *name;
- int algorithm;
- const uint8_t *key; /* if hmac */
- unsigned int key_size;
- const uint8_t *plaintext;
- unsigned int plaintext_size;
- const uint8_t *output;
- unsigned int output_size;
-} hash_vectors[] =
-{
- {
- .name = "SHA1",
- .algorithm = GNUTLS_MAC_SHA1,
- .key = NULL,
- .plaintext =
- (uint8_t *) "what do ya want for nothing?",
- .plaintext_size =
- sizeof ("what do ya want for nothing?") - 1,
- .output =
- (uint8_t *)
- "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32",
- .output_size = 20,
- },
- {
- .name = "SHA1",
- .algorithm = GNUTLS_MAC_SHA1,
- .key = NULL,
- .plaintext =
- (uint8_t *)
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- .plaintext_size = sizeof
- ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
- - 1,
- .output =
- (uint8_t *)
- "\xbe\xae\xd1\x6d\x65\x8e\xc7\x92\x9e\xdf\xd6\x2b\xfa\xfe\xac\x29\x9f\x0d\x74\x4d",
- .output_size = 20,
- },
- {
- .name = "SHA256",
- .algorithm = GNUTLS_MAC_SHA256,
- .key = NULL,
- .plaintext =
- (uint8_t *)
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- .plaintext_size = sizeof
- ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
- - 1,
- .output =
- (uint8_t *)
- "\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1",
- .output_size = 32,
- },
- {
- .name = "SHA256",
- .algorithm = GNUTLS_MAC_SHA256,
- .key = NULL,
- .plaintext =
- (uint8_t *)
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- .plaintext_size = sizeof
- ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
- - 1,
- .output =
- (uint8_t *)
- "\x50\xea\x82\x5d\x96\x84\xf4\x22\x9c\xa2\x9f\x1f\xec\x51\x15\x93\xe2\x81\xe4\x6a\x14\x0d\x81\xe0\x00\x5f\x8f\x68\x86\x69\xa0\x6c",
- .output_size = 32,
- },
- {
- .name = "SHA512",
- .algorithm = GNUTLS_MAC_SHA512,
- .key = NULL,
- .plaintext =
- (uint8_t *)
- "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
- .plaintext_size = sizeof
- ("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")
- - 1,
- .output =
- (uint8_t *)
- "\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14\x3f\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88\x90\x18\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4\xb5\x43\x3a\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b\x87\x4b\xe9\x09",
- .output_size = 64,
- },
- {
- .name = "HMAC-MD5",.algorithm = GNUTLS_MAC_MD5,.key =
- (uint8_t *) "Jefe",.key_size = 4,.plaintext =
- (uint8_t *) "what do ya want for nothing?",.
- plaintext_size =
- sizeof ("what do ya want for nothing?") - 1,.output =
- (uint8_t *)
- "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38",.output_size
- = 16,}
- ,
- /* from rfc4231 */
- {
- .name = "HMAC-SHA2-224",.algorithm = GNUTLS_MAC_SHA224,.key =
- (uint8_t *)
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.key_size
- = 20,.plaintext = (uint8_t *) "Hi There",.plaintext_size =
- sizeof ("Hi There") - 1,.output =
- (uint8_t *)
- "\x89\x6f\xb1\x12\x8a\xbb\xdf\x19\x68\x32\x10\x7c\xd4\x9d\xf3\x3f\x47\xb4\xb1\x16\x99\x12\xba\x4f\x53\x68\x4b\x22",.output_size
- = 28,}
- ,
- {
- .name = "HMAC-SHA2-256",.algorithm = GNUTLS_MAC_SHA256,.key =
- (uint8_t *)
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.key_size
- = 20,.plaintext = (uint8_t *) "Hi There",.plaintext_size =
- sizeof ("Hi There") - 1,.output =
- (uint8_t *)
- "\xb0\x34\x4c\x61\xd8\xdb\x38\x53\x5c\xa8\xaf\xce\xaf\x0b\xf1\x2b\x88\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32\xcf\xf7",.output_size
- = 32,}
- ,
- {
- .name = "HMAC-SHA2-384",.algorithm = GNUTLS_MAC_SHA384,.key =
- (uint8_t *)
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.key_size
- = 20,.plaintext = (uint8_t *) "Hi There",.plaintext_size =
- sizeof ("Hi There") - 1,.output =
- (uint8_t *)
- "\xaf\xd0\x39\x44\xd8\x48\x95\x62\x6b\x08\x25\xf4\xab\x46\x90\x7f\x15\xf9\xda\xdb\xe4\x10\x1e\xc6\x82\xaa\x03\x4c\x7c\xeb\xc5\x9c\xfa\xea\x9e\xa9\x07\x6e\xde\x7f\x4a\xf1\x52\xe8\xb2\xfa\x9c\xb6",.output_size
- = 48,}
- ,
- {
- .name = "HMAC-SHA2-512",.algorithm = GNUTLS_MAC_SHA512,.key =
- (uint8_t *)
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.key_size
- = 20,.plaintext = (uint8_t *) "Hi There",.plaintext_size =
- sizeof ("Hi There") - 1,.output =
- (uint8_t *)
- "\x87\xaa\x7c\xde\xa5\xef\x61\x9d\x4f\xf0\xb4\x24\x1a\x1d\x6c\xb0\x23\x79\xf4\xe2\xce\x4e\xc2\x78\x7a\xd0\xb3\x05\x45\xe1\x7c\xde\xda\xa8\x33\xb7\xd6\xb8\xa7\x02\x03\x8b\x27\x4e\xae\xa3\xf4\xe4\xbe\x9d\x91\x4e\xeb\x61\xf1\x70\x2e\x69\x6c\x20\x3a\x12\x68\x54",.output_size
- = 64,}
+struct hash_vectors_st {
+ const char *name;
+ int algorithm;
+ const uint8_t *key; /* if hmac */
+ unsigned int key_size;
+ const uint8_t *plaintext;
+ unsigned int plaintext_size;
+ const uint8_t *output;
+ unsigned int output_size;
+} hash_vectors[] = {
+ {
+ .name = "SHA1",.algorithm = GNUTLS_MAC_SHA1,.key =
+ NULL,.plaintext =
+ (uint8_t *) "what do ya want for nothing?",.
+ plaintext_size =
+ sizeof("what do ya want for nothing?") - 1,.output =
+ (uint8_t *)
+ "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32",.
+ output_size = 20,}
+ , {
+ .name = "SHA1",.algorithm = GNUTLS_MAC_SHA1,.key =
+ NULL,.plaintext = (uint8_t *)
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",.
+ plaintext_size =
+ sizeof
+ ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
+ - 1,.output = (uint8_t *)
+ "\xbe\xae\xd1\x6d\x65\x8e\xc7\x92\x9e\xdf\xd6\x2b\xfa\xfe\xac\x29\x9f\x0d\x74\x4d",.
+ output_size = 20,}
+ , {
+ .name = "SHA256",.algorithm = GNUTLS_MAC_SHA256,.key =
+ NULL,.plaintext = (uint8_t *)
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",.
+ plaintext_size =
+ sizeof
+ ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
+ - 1,.output = (uint8_t *)
+ "\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1",.
+ output_size = 32,}
+ , {
+ .name = "SHA256",.algorithm = GNUTLS_MAC_SHA256,.key =
+ NULL,.plaintext = (uint8_t *)
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",.
+ plaintext_size =
+ sizeof
+ ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
+ - 1,.output = (uint8_t *)
+ "\x50\xea\x82\x5d\x96\x84\xf4\x22\x9c\xa2\x9f\x1f\xec\x51\x15\x93\xe2\x81\xe4\x6a\x14\x0d\x81\xe0\x00\x5f\x8f\x68\x86\x69\xa0\x6c",.
+ output_size = 32,}
+ , {
+ .name = "SHA512",.algorithm = GNUTLS_MAC_SHA512,.key =
+ NULL,.plaintext = (uint8_t *)
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",.
+ plaintext_size =
+ sizeof
+ ("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")
+ - 1,.output = (uint8_t *)
+ "\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14\x3f\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88\x90\x18\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4\xb5\x43\x3a\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b\x87\x4b\xe9\x09",.
+ output_size = 64,}
+ , {
+ .name = "HMAC-MD5",.algorithm = GNUTLS_MAC_MD5,.key =
+ (uint8_t *) "Jefe",.key_size = 4,.plaintext =
+ (uint8_t *)
+ "what do ya want for nothing?",.plaintext_size =
+ sizeof("what do ya want for nothing?") - 1,.output =
+ (uint8_t *)
+ "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38",.
+ output_size = 16,}
+ ,
+ /* from rfc4231 */
+ {
+ .name = "HMAC-SHA2-224",.algorithm =
+ GNUTLS_MAC_SHA224,.key = (uint8_t *)
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.
+ key_size = 20,.plaintext =
+ (uint8_t *) "Hi There",.plaintext_size =
+ sizeof("Hi There") - 1,.output = (uint8_t *)
+ "\x89\x6f\xb1\x12\x8a\xbb\xdf\x19\x68\x32\x10\x7c\xd4\x9d\xf3\x3f\x47\xb4\xb1\x16\x99\x12\xba\x4f\x53\x68\x4b\x22",.
+ output_size = 28,}
+ , {
+ .name = "HMAC-SHA2-256",.algorithm =
+ GNUTLS_MAC_SHA256,.key = (uint8_t *)
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.
+ key_size = 20,.plaintext =
+ (uint8_t *) "Hi There",.plaintext_size =
+ sizeof("Hi There") - 1,.output = (uint8_t *)
+ "\xb0\x34\x4c\x61\xd8\xdb\x38\x53\x5c\xa8\xaf\xce\xaf\x0b\xf1\x2b\x88\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32\xcf\xf7",.
+ output_size = 32,}
+ , {
+ .name = "HMAC-SHA2-384",.algorithm =
+ GNUTLS_MAC_SHA384,.key = (uint8_t *)
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.
+ key_size = 20,.plaintext =
+ (uint8_t *) "Hi There",.plaintext_size =
+ sizeof("Hi There") - 1,.output = (uint8_t *)
+ "\xaf\xd0\x39\x44\xd8\x48\x95\x62\x6b\x08\x25\xf4\xab\x46\x90\x7f\x15\xf9\xda\xdb\xe4\x10\x1e\xc6\x82\xaa\x03\x4c\x7c\xeb\xc5\x9c\xfa\xea\x9e\xa9\x07\x6e\xde\x7f\x4a\xf1\x52\xe8\xb2\xfa\x9c\xb6",.
+ output_size = 48,}
+ , {
+ .name = "HMAC-SHA2-512",.algorithm =
+ GNUTLS_MAC_SHA512,.key = (uint8_t *)
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",.
+ key_size = 20,.plaintext =
+ (uint8_t *) "Hi There",.plaintext_size =
+ sizeof("Hi There") - 1,.output = (uint8_t *)
+ "\x87\xaa\x7c\xde\xa5\xef\x61\x9d\x4f\xf0\xb4\x24\x1a\x1d\x6c\xb0\x23\x79\xf4\xe2\xce\x4e\xc2\x78\x7a\xd0\xb3\x05\x45\xe1\x7c\xde\xda\xa8\x33\xb7\xd6\xb8\xa7\x02\x03\x8b\x27\x4e\xae\xa3\xf4\xe4\xbe\x9d\x91\x4e\xeb\x61\xf1\x70\x2e\x69\x6c\x20\x3a\x12\x68\x54",.
+ output_size = 64,}
,};
#define HASH_DATA_SIZE 64
/* SHA1 and other hashes */
-static int
-test_hash (void)
+static int test_hash(void)
{
- uint8_t data[HASH_DATA_SIZE];
- unsigned int i, j;
- int ret;
- size_t data_size;
-
- fprintf (stdout, "Tests on Hashes\n");
- for (i = 0; i < sizeof (hash_vectors) / sizeof (hash_vectors[0]); i++)
- {
-
- fprintf (stdout, "\t%s: ", hash_vectors[i].name);
- /* import key */
- if (hash_vectors[i].key != NULL)
- {
+ uint8_t data[HASH_DATA_SIZE];
+ unsigned int i, j;
+ int ret;
+ size_t data_size;
+
+ fprintf(stdout, "Tests on Hashes\n");
+ for (i = 0; i < sizeof(hash_vectors) / sizeof(hash_vectors[0]);
+ i++) {
+
+ fprintf(stdout, "\t%s: ", hash_vectors[i].name);
+ /* import key */
+ if (hash_vectors[i].key != NULL) {
#if 0
- ret = gnutls_hmac_fast(hash_vectors[i].algorithm, hash_vectors[i].key, hash_vectors[i].key_size,
- hash_vectors[i].plaintext, hash_vectors[i].plaintext_size, data);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
+ ret =
+ gnutls_hmac_fast(hash_vectors[i].algorithm,
+ hash_vectors[i].key,
+ hash_vectors[i].key_size,
+ hash_vectors[i].plaintext,
+ hash_vectors[i].
+ plaintext_size, data);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
#else
- gnutls_hmac_hd_t hd;
-
- ret = gnutls_hmac_init( &hd, hash_vectors[i].algorithm, hash_vectors[i].key, hash_vectors[i].key_size);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
-
- ret = gnutls_hmac(hd, hash_vectors[i].plaintext, hash_vectors[i].plaintext_size-1);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
-
- ret = gnutls_hmac(hd, &hash_vectors[i].plaintext[hash_vectors[i].plaintext_size-1], 1);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
-
- gnutls_hmac_output(hd, data);
- gnutls_hmac_deinit(hd, NULL);
+ gnutls_hmac_hd_t hd;
+
+ ret =
+ gnutls_hmac_init(&hd,
+ hash_vectors[i].algorithm,
+ hash_vectors[i].key,
+ hash_vectors[i].key_size);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+
+ ret =
+ gnutls_hmac(hd, hash_vectors[i].plaintext,
+ hash_vectors[i].plaintext_size -
+ 1);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+
+ ret =
+ gnutls_hmac(hd,
+ &hash_vectors[i].
+ plaintext[hash_vectors[i].
+ plaintext_size - 1], 1);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+
+ gnutls_hmac_output(hd, data);
+ gnutls_hmac_deinit(hd, NULL);
#endif
- data_size =
- gnutls_hmac_get_len (hash_vectors[i].algorithm);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
- }
- else
- {
- gnutls_hash_hd_t hd;
- ret = gnutls_hash_init( &hd, hash_vectors[i].algorithm);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
-
- ret = gnutls_hash (hd,
- hash_vectors[i].plaintext,
- 1);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
-
- ret = gnutls_hash (hd,
- &hash_vectors[i].plaintext[1],
- hash_vectors[i].plaintext_size-1);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
-
- gnutls_hash_output(hd, data);
- gnutls_hash_deinit(hd, NULL);
-
- data_size =
- gnutls_hash_get_len (hash_vectors[i].algorithm);
- if (ret < 0)
- {
- fprintf (stderr, "Error: %s:%d\n", __func__,
- __LINE__);
- return 1;
- }
- }
-
- if (data_size != hash_vectors[i].output_size ||
- memcmp (data, hash_vectors[i].output,
- hash_vectors[i].output_size) != 0)
- {
- fprintf (stderr, "HASH test vector %d failed!\n", i);
-
- fprintf (stderr, "Output[%d]: ", (int) data_size);
- for (j = 0; j < data_size; j++)
- fprintf (stderr, "%.2x:", (int) data[j]);
- fprintf (stderr, "\n");
-
- fprintf (stderr, "Expected[%d]: ",
- hash_vectors[i].output_size);
- for (j = 0; j < hash_vectors[i].output_size; j++)
- fprintf (stderr, "%.2x:",
- (int) hash_vectors[i].output[j]);
- fprintf (stderr, "\n");
- return 1;
- }
-
- fprintf (stdout, "ok\n");
- }
-
- fprintf (stdout, "\n");
-
- return 0;
+ data_size =
+ gnutls_hmac_get_len(hash_vectors[i].algorithm);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+ } else {
+ gnutls_hash_hd_t hd;
+ ret =
+ gnutls_hash_init(&hd,
+ hash_vectors[i].algorithm);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+
+ ret = gnutls_hash(hd,
+ hash_vectors[i].plaintext, 1);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+
+ ret = gnutls_hash(hd,
+ &hash_vectors[i].plaintext[1],
+ hash_vectors[i].plaintext_size -
+ 1);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+
+ gnutls_hash_output(hd, data);
+ gnutls_hash_deinit(hd, NULL);
+
+ data_size =
+ gnutls_hash_get_len(hash_vectors[i].algorithm);
+ if (ret < 0) {
+ fprintf(stderr, "Error: %s:%d\n", __func__,
+ __LINE__);
+ return 1;
+ }
+ }
+
+ if (data_size != hash_vectors[i].output_size ||
+ memcmp(data, hash_vectors[i].output,
+ hash_vectors[i].output_size) != 0) {
+ fprintf(stderr, "HASH test vector %d failed!\n",
+ i);
+
+ fprintf(stderr, "Output[%d]: ", (int) data_size);
+ for (j = 0; j < data_size; j++)
+ fprintf(stderr, "%.2x:", (int) data[j]);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "Expected[%d]: ",
+ hash_vectors[i].output_size);
+ for (j = 0; j < hash_vectors[i].output_size; j++)
+ fprintf(stderr, "%.2x:",
+ (int) hash_vectors[i].output[j]);
+ fprintf(stderr, "\n");
+ return 1;
+ }
+
+ fprintf(stdout, "ok\n");
+ }
+
+ fprintf(stdout, "\n");
+
+ return 0;
}
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "<%d>| %s", level, str);
+ fprintf(stderr, "<%d>| %s", level, str);
}
-int
-main (int argc, char **argv)
+int main(int argc, char **argv)
{
- gnutls_global_set_log_function (tls_log_func);
- if (argc > 1)
- gnutls_global_set_log_level (4711);
+ gnutls_global_set_log_function(tls_log_func);
+ if (argc > 1)
+ gnutls_global_set_log_level(4711);
- global_init ();
+ global_init();
- if (test_aes ())
- return 1;
+ if (test_aes())
+ return 1;
- if (test_hash ())
- return 1;
+ if (test_hash())
+ return 1;
- gnutls_global_deinit ();
- return 0;
+ gnutls_global_deinit();
+ return 0;
}
diff --git a/tests/slow/gendh.c b/tests/slow/gendh.c
index b108a05dc0..155cf23d64 100644
--- a/tests/slow/gendh.c
+++ b/tests/slow/gendh.c
@@ -28,25 +28,25 @@
#include "utils.h"
-void
-doit (void)
+void doit(void)
{
- gnutls_dh_params_t dh_params = NULL;
- int rc;
+ gnutls_dh_params_t dh_params = NULL;
+ int rc;
- rc = global_init ();
- if (rc)
- fail ("global_init\n");
+ rc = global_init();
+ if (rc)
+ fail("global_init\n");
- if (gnutls_dh_params_init (&dh_params) < 0)
- fail ("Error in dh parameter initialization\n");
+ if (gnutls_dh_params_init(&dh_params) < 0)
+ fail("Error in dh parameter initialization\n");
- if (gnutls_dh_params_generate2 (dh_params, 1024) < 0)
- fail ("Error in prime generation\n");
-
- gnutls_dh_params_deinit(dh_params);
-
- gnutls_global_deinit();
+ if (gnutls_dh_params_generate2(dh_params, 1024) < 0)
+ fail("Error in prime generation\n");
- if (debug) success ("generated DH params OK\n");
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("generated DH params OK\n");
}
diff --git a/tests/slow/keygen.c b/tests/slow/keygen.c
index 4e02ed4e84..19f7676afe 100644
--- a/tests/slow/keygen.c
+++ b/tests/slow/keygen.c
@@ -35,72 +35,61 @@
#define MAX_TRIES 2
-static int sec_param[MAX_TRIES] = {GNUTLS_SEC_PARAM_LOW, GNUTLS_SEC_PARAM_NORMAL};
+static int sec_param[MAX_TRIES] =
+ { GNUTLS_SEC_PARAM_LOW, GNUTLS_SEC_PARAM_NORMAL };
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", "crq_key_id", level, str);
+ fprintf(stderr, "%s |<%d>| %s", "crq_key_id", level, str);
}
-void
-doit (void)
+void doit(void)
{
- gnutls_x509_privkey_t pkey;
- int ret, algorithm, i;
+ gnutls_x509_privkey_t pkey;
+ int ret, algorithm, i;
- ret = global_init ();
- if (ret < 0)
- fail ("global_init: %d\n", ret);
+ ret = global_init();
+ if (ret < 0)
+ fail("global_init: %d\n", ret);
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
- for (i = 0; i < MAX_TRIES; i++)
- {
- for (algorithm = GNUTLS_PK_RSA; algorithm <= GNUTLS_PK_EC;
- algorithm++)
- {
- if (algorithm == GNUTLS_PK_DH)
- continue;
+ for (i = 0; i < MAX_TRIES; i++) {
+ for (algorithm = GNUTLS_PK_RSA; algorithm <= GNUTLS_PK_EC;
+ algorithm++) {
+ if (algorithm == GNUTLS_PK_DH)
+ continue;
- ret = gnutls_x509_privkey_init (&pkey);
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_init: %d\n", ret);
- }
+ ret = gnutls_x509_privkey_init(&pkey);
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_init: %d\n",
+ ret);
+ }
- ret =
- gnutls_x509_privkey_generate (pkey, algorithm,
- gnutls_sec_param_to_pk_bits
- (algorithm,
- sec_param[i]),
- 0);
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_generate (%s): %s (%d)\n",
- gnutls_pk_algorithm_get_name (algorithm),
- gnutls_strerror (ret), ret);
- }
- else if (debug)
- {
- success ("Key[%s] generation ok: %d\n",
- gnutls_pk_algorithm_get_name (algorithm),
- ret);
- }
+ ret =
+ gnutls_x509_privkey_generate(pkey, algorithm,
+ gnutls_sec_param_to_pk_bits
+ (algorithm,
+ sec_param[i]),
+ 0);
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_generate (%s): %s (%d)\n", gnutls_pk_algorithm_get_name(algorithm), gnutls_strerror(ret), ret);
+ } else if (debug) {
+ success("Key[%s] generation ok: %d\n",
+ gnutls_pk_algorithm_get_name
+ (algorithm), ret);
+ }
- ret = gnutls_x509_privkey_verify_params (pkey);
- if (ret < 0)
- {
- fail ("gnutls_x509_privkey_generate (%s): %s (%d)\n",
- gnutls_pk_algorithm_get_name (algorithm),
- gnutls_strerror (ret), ret);
- }
+ ret = gnutls_x509_privkey_verify_params(pkey);
+ if (ret < 0) {
+ fail("gnutls_x509_privkey_generate (%s): %s (%d)\n", gnutls_pk_algorithm_get_name(algorithm), gnutls_strerror(ret), ret);
+ }
- gnutls_x509_privkey_deinit (pkey);
- }
- }
+ gnutls_x509_privkey_deinit(pkey);
+ }
+ }
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
diff --git a/tests/srp/mini-srp.c b/tests/srp/mini-srp.c
index 70a684f0d9..35b42e0631 100644
--- a/tests/srp/mini-srp.c
+++ b/tests/srp/mini-srp.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -52,131 +52,123 @@ static void terminate(void);
/* This program tests the SRP and SRP-RSA ciphersuites.
*/
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ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pPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6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"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
-static void
-client (int fd, const char* prio)
+static void client(int fd, const char *prio)
{
- int ret;
- gnutls_session_t session;
- gnutls_srp_client_credentials_t srp_cred;
- gnutls_certificate_credentials_t x509_cred;
- /* Need to enable anonymous KX specifically. */
-
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_srp_allocate_client_credentials (&srp_cred);
- gnutls_certificate_allocate_credentials (&x509_cred);
-
- gnutls_srp_set_client_credentials (srp_cred, "test", "test");
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_priority_set_direct (session, prio, NULL);
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_SRP, srp_cred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
-
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_srp_free_client_credentials (srp_cred);
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ int ret;
+ gnutls_session_t session;
+ gnutls_srp_client_credentials_t srp_cred;
+ gnutls_certificate_credentials_t x509_cred;
+ /* Need to enable anonymous KX specifically. */
+
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_srp_allocate_client_credentials(&srp_cred);
+ gnutls_certificate_allocate_credentials(&x509_cred);
+
+ gnutls_srp_set_client_credentials(srp_cred, "test", "test");
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_priority_set_direct(session, prio, NULL);
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_SRP, srp_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_srp_free_client_credentials(srp_cred);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
@@ -185,166 +177,160 @@ gnutls_srp_server_credentials_t s_srp_cred;
gnutls_certificate_credentials_t s_x509_cred;
pid_t child;
-static gnutls_session_t
-initialize_tls_session (const char* prio)
+static gnutls_session_t initialize_tls_session(const char *prio)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_priority_set_direct (session, prio, NULL);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_priority_set_direct(session, prio, NULL);
- gnutls_credentials_set (session, GNUTLS_CRD_SRP, s_srp_cred);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, s_x509_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_SRP, s_srp_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ s_x509_cred);
- return session;
+ return session;
}
static void terminate(void)
{
-int status;
+ int status;
- kill(child, SIGTERM);
- wait(&status);
- exit(1);
+ kill(child, SIGTERM);
+ wait(&status);
+ exit(1);
}
-static void
-server (int fd, const char* prio)
+static void server(int fd, const char *prio)
{
-int ret;
-gnutls_session_t session;
-
- /* this must be called once in the program
- */
- global_init ();
-
- if (debug)
- {
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (4711);
- }
-
- gnutls_srp_allocate_server_credentials (&s_srp_cred);
- gnutls_srp_set_server_credentials_file (s_srp_cred, "tpasswd",
- "tpasswd.conf");
-
- gnutls_certificate_allocate_credentials (&s_x509_cred);
- gnutls_certificate_set_x509_key_mem (s_x509_cred,
- &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- session = initialize_tls_session (prio);
-
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
- close (fd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- terminate();
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (fd);
- gnutls_deinit (session);
-
- gnutls_srp_free_server_credentials (s_srp_cred);
- gnutls_certificate_free_credentials (s_x509_cred);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ int ret;
+ gnutls_session_t session;
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ if (debug) {
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(4711);
+ }
+
+ gnutls_srp_allocate_server_credentials(&s_srp_cred);
+ gnutls_srp_set_server_credentials_file(s_srp_cred, "tpasswd",
+ "tpasswd.conf");
+
+ gnutls_certificate_allocate_credentials(&s_x509_cred);
+ gnutls_certificate_set_x509_key_mem(s_x509_cred,
+ &server_cert, &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ session = initialize_tls_session(prio);
+
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
+ close(fd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ terminate();
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(fd);
+ gnutls_deinit(session);
+
+ gnutls_srp_free_server_credentials(s_srp_cred);
+ gnutls_certificate_free_credentials(s_x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-static void start (const char* prio)
+static void start(const char *prio)
{
- int fd[2];
- int ret;
-
- ret = socketpair(AF_LOCAL, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- exit(1);
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (fd[0], prio);
- wait (&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
- }
- else
- {
- client (fd[1], prio);
- exit(0);
- }
+ int fd[2];
+ int ret;
+
+ ret = socketpair(AF_LOCAL, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ exit(1);
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(fd[0], prio);
+ wait(&status);
+ if (WEXITSTATUS(status) != 0)
+ fail("Child died with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ client(fd[1], prio);
+ exit(0);
+ }
}
-const char* tpasswd_file = "test:CsrY0PxYlYCAa8UuWUrcjpqBvG6ImlAdGwEUh3tN2DSDBbMWTvnUl7A8Hw7l0zFHwyLH5rh0llrmu/v.Df2FjDEGy0s0rYR5ARE2XlXPl66xhevHj5vitD0Qvq/J0x1v0zMWJSgq/Ah2MoOrw9aBEsQUgf9MddiHQKjE3Vetoq3:3h3cfS0WrBgPUsldDASSK0:1\n"
- "test2:1J14yVX4iBa97cySs2/SduwnSbHxiz7WieE761psJQDxkc5flpumEwXbAgK5PrSZ0aZ6q7zyrAN1apJR1QQPAdyScJ6Jw4zjDP7AnezUVGbUNMJXhsI0NPwSc0c/415XfrnM1139yjWCr1qkcYMoN4bALppMMLB8glJkxy7t.3cmH9MkRRAjXXdUgAvHw2ZFLmB/8TlZDhnDS78xCSgLQs.oubZEEIgOWl7BT2.aW76fW3yKWdVrrHQDYPtR4hKx:11rUG9wSMLHe2Cu2p7dmFY:2\n"
- "test3:LVJZDDuElMHuRt5/fcx64AhJ4erhFvbIhv/XCtD0tJI3OC6yEBzthZ1FSqblri9qtsvboPApbFHwP9WEluGtCOuzOON4LS8sSeQDBO.PaqjTnsmXKPYMKa.SuLXFuRTtdiFRwX2ZRy3GIWoCvxJtPDWCEYGBWfnjjGEYmQWvo534JVtVDyMaFItYlMTOtBSgsg488oJ5hIAU6jVyIQZGPVv8OHsPCpEt2UlTixzI9nAgQ0WL5ShKaAq0dksF/AY7UMKm0oHbtZeqAx6YcBzLbBhNvcEqYzH95ONpr.cUh91iRhVzdVscsFweSCtWsQrVT4z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ZEH2SqhtpBUkWtmcIkEflhX/YY/fkBKfBbe27/zUaKUUZEUYZ2H2nlCL60.JIPeZJSzsu/xHDVcx:2\n"
+ "3:2iQzj1CagQc/5ctbuJYLWlhtAsPHc7xWVyCPAKFRLWKADpASkqe9djWPFWTNTdeJtL8nAhImCn3Sr/IAdQ1FrGw0WvQUstPx3FO9KNcXOwisOQ1VlL.gheAHYfbYyBaxXL.NcJx9TUwgWDT0hRzFzqSrdGGTN3FgSTA1v4QnHtEygNj3eZ.u0MThqWUaDiP87nqha7XnT66bkTCkQ8.7T8L4KZjIImrNrUftedTTBi.WCi.zlrBxDuOM0da0JbUkQlXqvp0yvJAPpC11nxmmZOAbQOywZGmu9nhZNuwTlxjfIro0FOdthaDTuZRL9VL7MRPUDo/DQEyW.d4H.UIlzp:2\n";
-void
-doit (void)
+void doit(void)
{
-FILE * fd;
-
- fd = fopen("tpasswd.conf", "w");
- if (fd == NULL)
- exit(1);
-
- fwrite(tpasswd_conf_file, 1, strlen(tpasswd_conf_file), fd);
- fclose(fd);
-
- fd = fopen("tpasswd", "w");
- if (fd == NULL)
- exit(1);
-
- fwrite(tpasswd_file, 1, strlen(tpasswd_file), fd);
- fclose(fd);
-
- start("NORMAL:-KX-ALL:+SRP");
- start("NORMAL:-KX-ALL:+SRP-RSA");
-
- remove("tpasswd");
- remove("tpasswd.conf");
+ FILE *fd;
+
+ fd = fopen("tpasswd.conf", "w");
+ if (fd == NULL)
+ exit(1);
+
+ fwrite(tpasswd_conf_file, 1, strlen(tpasswd_conf_file), fd);
+ fclose(fd);
+
+ fd = fopen("tpasswd", "w");
+ if (fd == NULL)
+ exit(1);
+
+ fwrite(tpasswd_file, 1, strlen(tpasswd_file), fd);
+ fclose(fd);
+
+ start("NORMAL:-KX-ALL:+SRP");
+ start("NORMAL:-KX-ALL:+SRP-RSA");
+
+ remove("tpasswd");
+ remove("tpasswd.conf");
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/suite/ecore/eina_config.h b/tests/suite/ecore/eina_config.h
index f89327d6a6..14ba859a29 100644
--- a/tests/suite/ecore/eina_config.h
+++ b/tests/suite/ecore/eina_config.h
@@ -20,33 +20,33 @@
#define EINA_CONFIG_H_
#ifdef EINA_MAGIC_DEBUG
-# undef EINA_MAGIC_DEBUG
+#undef EINA_MAGIC_DEBUG
#endif
#define EINA_MAGIC_DEBUG
#ifdef EINA_DEFAULT_MEMPOOL
-# undef EINA_DEFAULT_MEMPOOL
+#undef EINA_DEFAULT_MEMPOOL
#endif
#ifdef EINA_SAFETY_CHECKS
-# undef EINA_SAFETY_CHECKS
+#undef EINA_SAFETY_CHECKS
#endif
#define EINA_SAFETY_CHECKS
#ifdef EINA_HAVE_INTTYPES_H
-# undef EINA_HAVE_INTTYPES_H
+#undef EINA_HAVE_INTTYPES_H
#endif
#define EINA_HAVE_INTTYPES_H
#ifdef EINA_HAVE_STDINT_H
-# undef EINA_HAVE_STDINT_H
+#undef EINA_HAVE_STDINT_H
#endif
#define EINA_HAVE_STDINT_H
#ifdef EINA_SIZEOF_WCHAR_T
-# undef EINA_SIZEOF_WCHAR_T
+#undef EINA_SIZEOF_WCHAR_T
#endif
#define EINA_SIZEOF_WCHAR_T 4
-#endif /* EINA_CONFIG_H_ */
+#endif /* EINA_CONFIG_H_ */
diff --git a/tests/suite/ecore/src/include/Eina.h b/tests/suite/ecore/src/include/Eina.h
index eb0263f6c2..a7bda06aa8 100644
--- a/tests/suite/ecore/src/include/Eina.h
+++ b/tests/suite/ecore/src/include/Eina.h
@@ -114,7 +114,7 @@
#include <dirent.h>
#ifdef _WIN32
-# include <Evil.h>
+#include <Evil.h>
#endif
#ifdef __cplusplus
@@ -161,5 +161,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* EINA_H */
+#endif /* EINA_H */
diff --git a/tests/suite/ecore/src/include/eina_accessor.h b/tests/suite/ecore/src/include/eina_accessor.h
index 4d2f92e0a1..f3f29a4849 100644
--- a/tests/suite/ecore/src/include/eina_accessor.h
+++ b/tests/suite/ecore/src/include/eina_accessor.h
@@ -42,46 +42,49 @@
*/
typedef struct _Eina_Accessor Eina_Accessor;
-typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it,
- unsigned int index,
- void **data);
-typedef void *(*Eina_Accessor_Get_Container_Callback)(Eina_Accessor *it);
-typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
-typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it);
-
-struct _Eina_Accessor
-{
+typedef Eina_Bool(*Eina_Accessor_Get_At_Callback) (Eina_Accessor * it,
+ unsigned int index,
+ void **data);
+typedef void *(*Eina_Accessor_Get_Container_Callback) (Eina_Accessor * it);
+typedef void (*Eina_Accessor_Free_Callback) (Eina_Accessor * it);
+typedef Eina_Bool(*Eina_Accessor_Lock_Callback) (Eina_Accessor * it);
+
+struct _Eina_Accessor {
#define EINA_ACCESSOR_VERSION 1
- int version;
+ int version;
- Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
- Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1);
+ Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1,
+ 3)
+ EINA_WARN_UNUSED_RESULT;
+ Eina_Accessor_Get_Container_Callback get_container
+ EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1);
- Eina_Accessor_Lock_Callback lock EINA_WARN_UNUSED_RESULT;
- Eina_Accessor_Lock_Callback unlock EINA_WARN_UNUSED_RESULT;
+ Eina_Accessor_Lock_Callback lock EINA_WARN_UNUSED_RESULT;
+ Eina_Accessor_Lock_Callback unlock EINA_WARN_UNUSED_RESULT;
#define EINA_MAGIC_ACCESSOR 0x98761232
- EINA_MAGIC
-};
+ EINA_MAGIC};
#define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function)
#define FUNC_ACCESSOR_GET_CONTAINER(Function) ((Eina_Accessor_Get_Container_Callback)Function)
#define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback)Function)
#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function)
-EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor,
- unsigned int position,
- void **data) EINA_ARG_NONNULL(1);
-EAPI void * eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE;
-EAPI void eina_accessor_over(Eina_Accessor *accessor,
- Eina_Each_Cb cb,
- unsigned int start,
- unsigned int end,
- const void *fdata) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
+EAPI void eina_accessor_free(Eina_Accessor * accessor) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor * accessor,
+ unsigned int position,
+ void **data) EINA_ARG_NONNULL(1);
+EAPI void *eina_accessor_container_get(Eina_Accessor *
+ accessor) EINA_ARG_NONNULL(1)
+ EINA_PURE;
+EAPI void eina_accessor_over(Eina_Accessor * accessor, Eina_Each_Cb cb,
+ unsigned int start, unsigned int end,
+ const void *fdata) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *
+ accessor) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *
+ accessor) EINA_ARG_NONNULL(1);
/**
* @def EINA_ACCESSOR_FOREACH
diff --git a/tests/suite/ecore/src/include/eina_array.h b/tests/suite/ecore/src/include/eina_array.h
index cb0d12a1a8..fa647dcef3 100644
--- a/tests/suite/ecore/src/include/eina_array.h
+++ b/tests/suite/ecore/src/include/eina_array.h
@@ -63,42 +63,52 @@ typedef void **Eina_Array_Iterator;
* @struct _Eina_Array
* Type for an array of data.
*/
-struct _Eina_Array
-{
+struct _Eina_Array {
#define EINA_ARRAY_VERSION 1
- int version; /**< Should match EINA_ARRAY_VERSION used when compiled your apps, provided for ABI compatibility */
-
- void **data; /**< Pointer to a vector of pointer to payload */
- unsigned int total; /**< Total number of slots in the vector */
- unsigned int count; /**< Number of active slots in the vector */
- unsigned int step; /**< How much must we grow the vector when it is full */
- EINA_MAGIC
-};
-
-EAPI Eina_Array * eina_array_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI void eina_array_step_set(Eina_Array *array,
- unsigned int sizeof_eina_array,
- unsigned int step) EINA_ARG_NONNULL(1);
-EAPI void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_array_remove(Eina_Array *array,
- Eina_Bool(*keep)(void *data, void *gdata),
- void *gdata) EINA_ARG_NONNULL(1, 2);
-static inline Eina_Bool eina_array_push(Eina_Array *array,
- const void *data) EINA_ARG_NONNULL(1, 2);
-static inline void * eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL(1);
-static inline void * eina_array_data_get(const Eina_Array *array,
- unsigned int idx) EINA_ARG_NONNULL(1);
-static inline void eina_array_data_set(const Eina_Array *array,
- unsigned int idx,
- const void *data) EINA_ARG_NONNULL(1, 3);
-static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI Eina_Iterator * eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor * eina_array_accessor_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_array_foreach(Eina_Array *array,
- Eina_Each_Cb cb,
- void *data);
+ int version;
+ /**< Should match EINA_ARRAY_VERSION used when compiled your apps, provided for ABI compatibility */
+
+ void **data;
+ /**< Pointer to a vector of pointer to payload */
+ unsigned int total;
+ /**< Total number of slots in the vector */
+ unsigned int count;
+ /**< Number of active slots in the vector */
+ unsigned int step;
+ /**< How much must we grow the vector when it is full */
+ EINA_MAGIC};
+
+EAPI Eina_Array *eina_array_new(unsigned int step)
+EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI void eina_array_free(Eina_Array * array) EINA_ARG_NONNULL(1);
+EAPI void eina_array_step_set(Eina_Array * array,
+ unsigned int sizeof_eina_array,
+ unsigned int step) EINA_ARG_NONNULL(1);
+EAPI void eina_array_clean(Eina_Array * array) EINA_ARG_NONNULL(1);
+EAPI void eina_array_flush(Eina_Array * array) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_array_remove(Eina_Array * array,
+ Eina_Bool(*keep) (void *data,
+ void *gdata),
+ void *gdata) EINA_ARG_NONNULL(1, 2);
+static inline Eina_Bool eina_array_push(Eina_Array * array,
+ const void *data)
+EINA_ARG_NONNULL(1, 2);
+static inline void *eina_array_pop(Eina_Array * array) EINA_ARG_NONNULL(1);
+static inline void *eina_array_data_get(const Eina_Array * array,
+ unsigned int idx)
+EINA_ARG_NONNULL(1);
+static inline void eina_array_data_set(const Eina_Array * array,
+ unsigned int idx,
+ const void *data)
+EINA_ARG_NONNULL(1, 3);
+static inline unsigned int eina_array_count_get(const Eina_Array *
+ array) EINA_ARG_NONNULL(1);
+EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array * array)
+EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array * array)
+EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool eina_array_foreach(Eina_Array * array,
+ Eina_Each_Cb cb, void *data);
/**
* @def EINA_ARRAY_ITER_NEXT
* @brief Macro to iterate over an array easily.
diff --git a/tests/suite/ecore/src/include/eina_benchmark.h b/tests/suite/ecore/src/include/eina_benchmark.h
index e0faa722df..2fd7b8cf50 100644
--- a/tests/suite/ecore/src/include/eina_benchmark.h
+++ b/tests/suite/ecore/src/include/eina_benchmark.h
@@ -43,7 +43,7 @@ typedef struct _Eina_Benchmark Eina_Benchmark;
* @typedef Eina_Benchmark_Specimens
* Type for a test function to be called when running a benchmark.
*/
-typedef void (*Eina_Benchmark_Specimens)(int request);
+typedef void (*Eina_Benchmark_Specimens) (int request);
/**
* @def EINA_BENCHMARK
@@ -55,16 +55,14 @@ typedef void (*Eina_Benchmark_Specimens)(int request);
*/
#define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function)
-EAPI Eina_Benchmark * eina_benchmark_new(const char *name,
- const char *run);
-EAPI void eina_benchmark_free(Eina_Benchmark *bench);
-EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench,
- const char *name,
- Eina_Benchmark_Specimens bench_cb,
- int count_start,
- int count_end,
- int count_set);
-EAPI Eina_Array * eina_benchmark_run(Eina_Benchmark *bench);
+EAPI Eina_Benchmark *eina_benchmark_new(const char *name, const char *run);
+EAPI void eina_benchmark_free(Eina_Benchmark * bench);
+EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark * bench,
+ const char *name,
+ Eina_Benchmark_Specimens bench_cb,
+ int count_start,
+ int count_end, int count_set);
+EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark * bench);
/**
* @}
@@ -74,4 +72,4 @@ EAPI Eina_Array * eina_benchmark_run(Eina_Benchmark *bench);
* @}
*/
-#endif /* EINA_BENCHMARK_H_ */
+#endif /* EINA_BENCHMARK_H_ */
diff --git a/tests/suite/ecore/src/include/eina_binshare.h b/tests/suite/ecore/src/include/eina_binshare.h
index e785ed0137..471665ad30 100644
--- a/tests/suite/ecore/src/include/eina_binshare.h
+++ b/tests/suite/ecore/src/include/eina_binshare.h
@@ -65,14 +65,15 @@
* @{
*/
-EAPI Eina_Bool eina_binshare_init(void);
-EAPI Eina_Bool eina_binshare_shutdown(void);
-EAPI const void * eina_binshare_add_length(const void *obj,
- unsigned int olen) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI const void * eina_binshare_ref(const void *obj);
-EAPI void eina_binshare_del(const void *obj);
-EAPI int eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_binshare_dump(void);
+EAPI Eina_Bool eina_binshare_init(void);
+EAPI Eina_Bool eina_binshare_shutdown(void);
+EAPI const void *eina_binshare_add_length(const void *obj,
+ unsigned int olen)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI const void *eina_binshare_ref(const void *obj);
+EAPI void eina_binshare_del(const void *obj);
+EAPI int eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RESULT;
+EAPI void eina_binshare_dump(void);
/**
* @brief Retrieve an instance of a blob for use in a program.
@@ -102,4 +103,4 @@ EAPI void eina_binshare_dump(void);
* @}
*/
-#endif /* EINA_STRINGSHARE_H_ */
+#endif /* EINA_STRINGSHARE_H_ */
diff --git a/tests/suite/ecore/src/include/eina_config.h b/tests/suite/ecore/src/include/eina_config.h
index f89327d6a6..14ba859a29 100644
--- a/tests/suite/ecore/src/include/eina_config.h
+++ b/tests/suite/ecore/src/include/eina_config.h
@@ -20,33 +20,33 @@
#define EINA_CONFIG_H_
#ifdef EINA_MAGIC_DEBUG
-# undef EINA_MAGIC_DEBUG
+#undef EINA_MAGIC_DEBUG
#endif
#define EINA_MAGIC_DEBUG
#ifdef EINA_DEFAULT_MEMPOOL
-# undef EINA_DEFAULT_MEMPOOL
+#undef EINA_DEFAULT_MEMPOOL
#endif
#ifdef EINA_SAFETY_CHECKS
-# undef EINA_SAFETY_CHECKS
+#undef EINA_SAFETY_CHECKS
#endif
#define EINA_SAFETY_CHECKS
#ifdef EINA_HAVE_INTTYPES_H
-# undef EINA_HAVE_INTTYPES_H
+#undef EINA_HAVE_INTTYPES_H
#endif
#define EINA_HAVE_INTTYPES_H
#ifdef EINA_HAVE_STDINT_H
-# undef EINA_HAVE_STDINT_H
+#undef EINA_HAVE_STDINT_H
#endif
#define EINA_HAVE_STDINT_H
#ifdef EINA_SIZEOF_WCHAR_T
-# undef EINA_SIZEOF_WCHAR_T
+#undef EINA_SIZEOF_WCHAR_T
#endif
#define EINA_SIZEOF_WCHAR_T 4
-#endif /* EINA_CONFIG_H_ */
+#endif /* EINA_CONFIG_H_ */
diff --git a/tests/suite/ecore/src/include/eina_convert.h b/tests/suite/ecore/src/include/eina_convert.h
index 8cd64334f5..e4a56d6d00 100644
--- a/tests/suite/ecore/src/include/eina_convert.h
+++ b/tests/suite/ecore/src/include/eina_convert.h
@@ -54,20 +54,19 @@ EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND;
*/
EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
-EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2);
-EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
+EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2);
+EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
-EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
+EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
EAPI Eina_Bool eina_convert_atod(const char *src,
- int length,
- long long *m,
- long *e) EINA_ARG_NONNULL(1,3,4);
+ int length,
+ long long *m,
+ long *e) EINA_ARG_NONNULL(1, 3, 4);
-EAPI int eina_convert_fptoa(Eina_F32p32 fp,
- char *des) EINA_ARG_NONNULL(2);
+EAPI int eina_convert_fptoa(Eina_F32p32 fp, char *des) EINA_ARG_NONNULL(2);
EAPI Eina_Bool eina_convert_atofp(const char *src,
- int length,
- Eina_F32p32 *fp) EINA_ARG_NONNULL(1,3);
+ int length,
+ Eina_F32p32 * fp) EINA_ARG_NONNULL(1, 3);
/**
* @}
@@ -77,4 +76,4 @@ EAPI Eina_Bool eina_convert_atofp(const char *src,
* @}
*/
-#endif /* EINA_CONVERT_H_ */
+#endif /* EINA_CONVERT_H_ */
diff --git a/tests/suite/ecore/src/include/eina_counter.h b/tests/suite/ecore/src/include/eina_counter.h
index fc7b23f533..443586a7bb 100644
--- a/tests/suite/ecore/src/include/eina_counter.h
+++ b/tests/suite/ecore/src/include/eina_counter.h
@@ -39,12 +39,13 @@
*/
typedef struct _Eina_Counter Eina_Counter;
-EAPI Eina_Counter * eina_counter_new(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNULL(1);
-EAPI void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNULL(1);
-EAPI void eina_counter_stop(Eina_Counter *counter,
- int specimen) EINA_ARG_NONNULL(1);
-EAPI char * eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1);
+EAPI Eina_Counter *eina_counter_new(const char *name)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI void eina_counter_free(Eina_Counter * counter) EINA_ARG_NONNULL(1);
+EAPI void eina_counter_start(Eina_Counter * counter) EINA_ARG_NONNULL(1);
+EAPI void eina_counter_stop(Eina_Counter * counter,
+ int specimen) EINA_ARG_NONNULL(1);
+EAPI char *eina_counter_dump(Eina_Counter * counter) EINA_ARG_NONNULL(1);
/**
* @}
@@ -54,4 +55,4 @@ EAPI char * eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1)
* @}
*/
-#endif /* EINA_COUNTER_H_ */
+#endif /* EINA_COUNTER_H_ */
diff --git a/tests/suite/ecore/src/include/eina_cpu.h b/tests/suite/ecore/src/include/eina_cpu.h
index ac32e1db9b..3fb293af66 100644
--- a/tests/suite/ecore/src/include/eina_cpu.h
+++ b/tests/suite/ecore/src/include/eina_cpu.h
@@ -21,19 +21,18 @@
#include "eina_types.h"
-typedef enum _Eina_Cpu_Features
-{
- EINA_CPU_MMX = 0x00000001,
- EINA_CPU_SSE = 0x00000002,
- EINA_CPU_SSE2 = 0x00000004,
- EINA_CPU_SSE3 = 0x00000008,
- /* TODO 3DNow! */
- EINA_CPU_ALTIVEC = 0x00000010,
- EINA_CPU_VIS = 0x00000020,
- EINA_CPU_NEON = 0x00000040,
+typedef enum _Eina_Cpu_Features {
+ EINA_CPU_MMX = 0x00000001,
+ EINA_CPU_SSE = 0x00000002,
+ EINA_CPU_SSE2 = 0x00000004,
+ EINA_CPU_SSE3 = 0x00000008,
+ /* TODO 3DNow! */
+ EINA_CPU_ALTIVEC = 0x00000010,
+ EINA_CPU_VIS = 0x00000020,
+ EINA_CPU_NEON = 0x00000040,
} Eina_Cpu_Features;
EAPI Eina_Cpu_Features eina_cpu_features_get(void);
-EAPI int eina_cpu_count(void);
+EAPI int eina_cpu_count(void);
-#endif /* EINA_CPU_H_ */
+#endif /* EINA_CPU_H_ */
diff --git a/tests/suite/ecore/src/include/eina_error.h b/tests/suite/ecore/src/include/eina_error.h
index 8c74b66f0f..f654c4b1ea 100644
--- a/tests/suite/ecore/src/include/eina_error.h
+++ b/tests/suite/ecore/src/include/eina_error.h
@@ -47,13 +47,15 @@ typedef int Eina_Error;
*/
EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY;
-EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_error_msg_modify(Eina_Error error,
- const char *msg) EINA_ARG_NONNULL(2);
-EAPI Eina_Error eina_error_get(void);
-EAPI void eina_error_set(Eina_Error err);
-EAPI const char * eina_error_msg_get(Eina_Error error) EINA_PURE;
+EAPI Eina_Error eina_error_msg_register(const char *msg)
+EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Error eina_error_msg_static_register(const char *msg)
+EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_error_msg_modify(Eina_Error error,
+ const char *msg) EINA_ARG_NONNULL(2);
+EAPI Eina_Error eina_error_get(void);
+EAPI void eina_error_set(Eina_Error err);
+EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE;
/**
* @}
@@ -63,4 +65,4 @@ EAPI const char * eina_error_msg_get(Eina_Error error) EINA_PURE;
* @}
*/
-#endif /* EINA_ERROR_H_ */
+#endif /* EINA_ERROR_H_ */
diff --git a/tests/suite/ecore/src/include/eina_file.h b/tests/suite/ecore/src/include/eina_file.h
index 4c3740ffa0..40fb4c4adf 100644
--- a/tests/suite/ecore/src/include/eina_file.h
+++ b/tests/suite/ecore/src/include/eina_file.h
@@ -48,19 +48,24 @@ typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
* Type for a callback to be called when iterating over the files of a
* directory.
*/
-typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data);
+typedef void (*Eina_File_Dir_List_Cb) (const char *name, const char *path,
+ void *data);
/**
* @struct _Eina_File_Direct_Info
* A structure to store informations of a path.
*/
-struct _Eina_File_Direct_Info
-{
- size_t path_length; /**< size of the whole path */
- size_t name_length; /**< size of the filename/basename component */
- size_t name_start; /**< where the filename/basename component starts */
- char path[PATH_MAX]; /**< the path */
- const struct dirent *dirent; /**< the dirent structure of the path */
+struct _Eina_File_Direct_Info {
+ size_t path_length;
+ /**< size of the whole path */
+ size_t name_length;
+ /**< size of the filename/basename component */
+ size_t name_start;
+ /**< where the filename/basename component starts */
+ char path[PATH_MAX];
+ /**< the path */
+ const struct dirent *dirent;
+ /**< the dirent structure of the path */
};
/**
@@ -73,13 +78,16 @@ struct _Eina_File_Direct_Info
*/
#define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function)
-EAPI Eina_Bool eina_file_dir_list(const char *dir,
- Eina_Bool recursive,
- Eina_File_Dir_List_Cb cb,
- void *data) EINA_ARG_NONNULL(1, 3);
-EAPI Eina_Array * eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
-EAPI Eina_Iterator * eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
-EAPI Eina_Iterator * eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Bool eina_file_dir_list(const char *dir,
+ Eina_Bool recursive,
+ Eina_File_Dir_List_Cb cb,
+ void *data) EINA_ARG_NONNULL(1, 3);
+EAPI Eina_Array *eina_file_split(char *path)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Iterator *eina_file_ls(const char *dir)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Iterator *eina_file_direct_ls(const char *dir)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/**
* @}
@@ -89,4 +97,4 @@ EAPI Eina_Iterator * eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESUL
* @}
*/
-#endif /* EINA_FILE_H_ */
+#endif /* EINA_FILE_H_ */
diff --git a/tests/suite/ecore/src/include/eina_fp.h b/tests/suite/ecore/src/include/eina_fp.h
index 47dbaa486d..5aba5ef96f 100644
--- a/tests/suite/ecore/src/include/eina_fp.h
+++ b/tests/suite/ecore/src/include/eina_fp.h
@@ -18,7 +18,7 @@
*/
#ifndef EINA_FP_H_
-# define EINA_FP_H_
+#define EINA_FP_H_
#include "eina_types.h"
@@ -27,7 +27,7 @@ typedef unsigned __int64 uint64_t;
typedef signed __int64 int64_t;
typedef signed int int32_t;
#else
-# include <stdint.h>
+#include <stdint.h>
#endif
#define EINA_F32P32_PI 0x00000003243f6a89
@@ -36,72 +36,57 @@ typedef int64_t Eina_F32p32;
typedef int32_t Eina_F16p16;
typedef int32_t Eina_F8p24;
-static inline Eina_F32p32 eina_f32p32_int_from(int32_t v);
-static inline int32_t eina_f32p32_int_to(Eina_F32p32 v);
-static inline Eina_F32p32 eina_f32p32_double_from(double v);
-static inline double eina_f32p32_double_to(Eina_F32p32 v);
-
-static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a,
- Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a,
- Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a,
- Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a,
- int b);
-static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a,
- Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a);
+static inline Eina_F32p32 eina_f32p32_int_from(int32_t v);
+static inline int32_t eina_f32p32_int_to(Eina_F32p32 v);
+static inline Eina_F32p32 eina_f32p32_double_from(double v);
+static inline double eina_f32p32_double_to(Eina_F32p32 v);
+
+static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a, int b);
+static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b);
+static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a);
static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v);
// dont use llabs - issues if not on 64bit
#define eina_fp32p32_llabs(a) ((a < 0) ? -(a) : (a))
-EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
-EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
-
-static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
-static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
-static inline Eina_F16p16 eina_f16p16_float_from(float v);
-static inline float eina_f16p16_float_to(Eina_F16p16 v);
-
-static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a,
- Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a,
- Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a,
- Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a,
- int b);
-static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a,
- Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a);
+EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
+EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
+
+static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
+static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
+static inline Eina_F16p16 eina_f16p16_float_from(float v);
+static inline float eina_f16p16_float_to(Eina_F16p16 v);
+
+static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a, int b);
+static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b);
+static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a);
static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v);
-static inline Eina_F8p24 eina_f8p24_int_from(int32_t v);
-static inline int32_t eina_f8p24_int_to(Eina_F8p24 v);
-static inline Eina_F8p24 eina_f8p24_float_from(float v);
-static inline float eina_f8p24_float_to(Eina_F8p24 v);
-
-static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a,
- Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a,
- Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a,
- Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a,
- int b);
-static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a,
- Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a);
+static inline Eina_F8p24 eina_f8p24_int_from(int32_t v);
+static inline int32_t eina_f8p24_int_to(Eina_F8p24 v);
+static inline Eina_F8p24 eina_f8p24_float_from(float v);
+static inline float eina_f8p24_float_to(Eina_F8p24 v);
+
+static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a, int b);
+static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b);
+static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a);
static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v);
-static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a);
-static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a);
-static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a);
-static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a);
-static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a);
-static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a);
+static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a);
+static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a);
+static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a);
+static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a);
+static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a);
+static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a);
#include "eina_inline_f32p32.x"
#include "eina_inline_f16p16.x"
diff --git a/tests/suite/ecore/src/include/eina_hamster.h b/tests/suite/ecore/src/include/eina_hamster.h
index 0818b15616..5b160994fd 100644
--- a/tests/suite/ecore/src/include/eina_hamster.h
+++ b/tests/suite/ecore/src/include/eina_hamster.h
@@ -41,4 +41,4 @@ EAPI int eina_hamster_count(void);
* @}
*/
-#endif /* EINA_HAMSTER_H_ */
+#endif /* EINA_HAMSTER_H_ */
diff --git a/tests/suite/ecore/src/include/eina_hash.h b/tests/suite/ecore/src/include/eina_hash.h
index 03451339a9..d1fc8b13aa 100644
--- a/tests/suite/ecore/src/include/eina_hash.h
+++ b/tests/suite/ecore/src/include/eina_hash.h
@@ -49,107 +49,115 @@ typedef struct _Eina_Hash Eina_Hash;
typedef struct _Eina_Hash_Tuple Eina_Hash_Tuple;
-struct _Eina_Hash_Tuple
-{
- const void *key; /**< The key */
- void *data; /**< The data associated to the key */
- unsigned int key_length; /**< The length of the key */
+struct _Eina_Hash_Tuple {
+ const void *key;
+ /**< The key */
+ void *data;
+ /**< The data associated to the key */
+ unsigned int key_length;
+ /**< The length of the key */
};
-typedef unsigned int (*Eina_Key_Length)(const void *key);
+typedef unsigned int (*Eina_Key_Length) (const void *key);
#define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function)
-typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length, const void *key2, int key2_length);
+typedef int (*Eina_Key_Cmp) (const void *key1, int key1_length,
+ const void *key2, int key2_length);
#define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function)
-typedef int (*Eina_Key_Hash)(const void *key, int key_length);
+typedef int (*Eina_Key_Hash) (const void *key, int key_length);
#define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
-typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
+typedef Eina_Bool(*Eina_Hash_Foreach) (const Eina_Hash * hash,
+ const void *key, void *data,
+ void *fdata);
-EAPI Eina_Hash * eina_hash_new(Eina_Key_Length key_length_cb,
- Eina_Key_Cmp key_cmp_cb,
- Eina_Key_Hash key_hash_cb,
- Eina_Free_Cb data_free_cb,
- int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
-EAPI Eina_Hash * eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_int32_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_int64_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Bool eina_hash_add(Eina_Hash *hash,
- const void *key,
- const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash,
- const void *key,
- const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI Eina_Bool eina_hash_del(Eina_Hash *hash,
- const void *key,
- const void *data) EINA_ARG_NONNULL(1);
-EAPI void * eina_hash_find(const Eina_Hash *hash,
- const void *key) EINA_ARG_NONNULL(1, 2);
-EAPI void * eina_hash_modify(Eina_Hash *hash,
- const void *key,
- const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI void * eina_hash_set(Eina_Hash *hash,
- const void *key,
- const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI Eina_Bool eina_hash_move(Eina_Hash *hash,
- const void *old_key,
- const void *new_key) EINA_ARG_NONNULL(1, 2, 3);
-EAPI void eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1);
-EAPI void eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1);
-EAPI int eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data) EINA_ARG_NONNULL(1, 2, 5);
-EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data) EINA_ARG_NONNULL(1, 2, 5);
-EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash *hash,
- const void *key) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash *hash,
- const void *data) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data) EINA_ARG_NONNULL(1);
-EAPI void * eina_hash_find_by_hash(const Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash) EINA_ARG_NONNULL(1, 2);
-EAPI void * eina_hash_modify_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data) EINA_ARG_NONNULL(1, 2, 5);
-EAPI Eina_Iterator * eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator * eina_hash_iterator_data_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator * eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_hash_foreach(const Eina_Hash *hash,
- Eina_Hash_Foreach cb,
- const void *fdata) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Hash *eina_hash_new(Eina_Key_Length key_length_cb,
+ Eina_Key_Cmp key_cmp_cb,
+ Eina_Key_Hash key_hash_cb,
+ Eina_Free_Cb data_free_cb,
+ int buckets_power_size)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
+EAPI Eina_Hash *eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *eina_hash_int32_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Bool eina_hash_add(Eina_Hash * hash,
+ const void *key,
+ const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool eina_hash_direct_add(Eina_Hash * hash,
+ const void *key,
+ const void *data) EINA_ARG_NONNULL(1,
+ 2,
+ 3);
+EAPI Eina_Bool eina_hash_del(Eina_Hash * hash, const void *key,
+ const void *data) EINA_ARG_NONNULL(1);
+EAPI void *eina_hash_find(const Eina_Hash * hash,
+ const void *key) EINA_ARG_NONNULL(1, 2);
+EAPI void *eina_hash_modify(Eina_Hash * hash, const void *key,
+ const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI void *eina_hash_set(Eina_Hash * hash, const void *key,
+ const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool eina_hash_move(Eina_Hash * hash, const void *old_key,
+ const void *new_key) EINA_ARG_NONNULL(1, 2,
+ 3);
+EAPI void eina_hash_free(Eina_Hash * hash) EINA_ARG_NONNULL(1);
+EAPI void eina_hash_free_buckets(Eina_Hash * hash) EINA_ARG_NONNULL(1);
+EAPI int eina_hash_population(const Eina_Hash * hash) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash * hash,
+ const void *key,
+ int key_length,
+ int key_hash,
+ const void *data) EINA_ARG_NONNULL(1,
+ 2,
+ 5);
+EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash * hash,
+ const void *key,
+ int key_length, int key_hash,
+ const void *data)
+EINA_ARG_NONNULL(1, 2, 5);
+EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash * hash, const void *key,
+ int key_length,
+ int key_hash) EINA_ARG_NONNULL(1,
+ 2);
+EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash * hash,
+ const void *key) EINA_ARG_NONNULL(1,
+ 2);
+EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash * hash,
+ const void *data) EINA_ARG_NONNULL(1,
+ 2);
+EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash * hash, const void *key,
+ int key_length, int key_hash,
+ const void *data) EINA_ARG_NONNULL(1);
+EAPI void *eina_hash_find_by_hash(const Eina_Hash * hash, const void *key,
+ int key_length,
+ int key_hash) EINA_ARG_NONNULL(1, 2);
+EAPI void *eina_hash_modify_by_hash(Eina_Hash * hash, const void *key,
+ int key_length, int key_hash,
+ const void *data) EINA_ARG_NONNULL(1,
+ 2,
+ 5);
+EAPI Eina_Iterator *eina_hash_iterator_key_new(const Eina_Hash * hash)
+EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *eina_hash_iterator_data_new(const Eina_Hash * hash)
+EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash * hash)
+EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI void eina_hash_foreach(const Eina_Hash * hash,
+ Eina_Hash_Foreach cb,
+ const void *fdata) EINA_ARG_NONNULL(1, 2);
/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
-EAPI int eina_hash_superfast(const char *key,
- int len) EINA_ARG_NONNULL(1);
+EAPI int eina_hash_superfast(const char *key, int len) EINA_ARG_NONNULL(1);
/* Hash function first reported by dan bernstein many years ago in comp.lang.c */
-static inline int eina_hash_djb2(const char *key,
- int len) EINA_ARG_NONNULL(1);
-static inline int eina_hash_djb2_len(const char *key,
- int *plen) EINA_ARG_NONNULL(1, 2);
+static inline int eina_hash_djb2(const char *key,
+ int len) EINA_ARG_NONNULL(1);
+static inline int eina_hash_djb2_len(const char *key,
+ int *plen) EINA_ARG_NONNULL(1, 2);
/* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */
-static inline int eina_hash_int32(const unsigned int *pkey,
- int len) EINA_ARG_NONNULL(1);
-static inline int eina_hash_int64(const unsigned long int *pkey,
- int len) EINA_ARG_NONNULL(1);
+static inline int eina_hash_int32(const unsigned int *pkey,
+ int len) EINA_ARG_NONNULL(1);
+static inline int eina_hash_int64(const unsigned long int *pkey,
+ int len) EINA_ARG_NONNULL(1);
#include "eina_inline_hash.x"
@@ -165,4 +173,4 @@ static inline int eina_hash_int64(const unsigned long int *pkey,
* @}
*/
-#endif /*EINA_HASH_H_*/
+#endif /*EINA_HASH_H_ */
diff --git a/tests/suite/ecore/src/include/eina_inlist.h b/tests/suite/ecore/src/include/eina_inlist.h
index 34ee0ed522..6e55de38ea 100644
--- a/tests/suite/ecore/src/include/eina_inlist.h
+++ b/tests/suite/ecore/src/include/eina_inlist.h
@@ -52,11 +52,13 @@ typedef struct _Eina_Inlist Eina_Inlist;
* @struct _Eina_Inlist
* Inlined list type.
*/
-struct _Eina_Inlist
-{
- Eina_Inlist *next; /**< next node */
- Eina_Inlist *prev; /**< previous node */
- Eina_Inlist *last; /**< last node */
+struct _Eina_Inlist {
+ Eina_Inlist *next;
+ /**< next node */
+ Eina_Inlist *prev;
+ /**< previous node */
+ Eina_Inlist *last;
+ /**< last node */
};
#define EINA_INLIST Eina_Inlist __in_list
@@ -65,28 +67,50 @@ struct _Eina_Inlist
type) ((type *)((char *)ptr - \
offsetof(type, __in_list)))
-EAPI Eina_Inlist * eina_inlist_append(Eina_Inlist *in_list,
- Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_prepend(Eina_Inlist *in_list,
- Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_append_relative(Eina_Inlist *in_list,
- Eina_Inlist *in_item,
- Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_prepend_relative(Eina_Inlist *in_list,
- Eina_Inlist *in_item,
- Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_remove(Eina_Inlist *in_list,
- Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_find(Eina_Inlist *in_list,
- Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_promote(Eina_Inlist *list,
- Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_demote(Eina_Inlist *list,
- Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_RESULT;
-
-EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist * in_list,
+ Eina_Inlist *
+ in_item) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist * in_list,
+ Eina_Inlist *
+ in_item) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist * in_list,
+ Eina_Inlist * in_item,
+ Eina_Inlist *
+ in_relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist * in_list,
+ Eina_Inlist * in_item,
+ Eina_Inlist *
+ in_relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist * in_list,
+ Eina_Inlist *
+ in_item) EINA_ARG_NONNULL(1,
+ 2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist * in_list,
+ Eina_Inlist *
+ in_item) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_promote(Eina_Inlist * list,
+ Eina_Inlist *
+ item) EINA_ARG_NONNULL(1,
+ 2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *eina_inlist_demote(Eina_Inlist * list,
+ Eina_Inlist *
+ item) EINA_ARG_NONNULL(1,
+ 2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI unsigned int eina_inlist_count(const Eina_Inlist *
+ list) EINA_WARN_UNUSED_RESULT;
+
+EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist * in_list)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist * in_list)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/* This two macros are helpers for the _FOREACH ones, don't use them */
#define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref))
@@ -112,4 +136,4 @@ EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MA
* @}
*/
-#endif /*EINA_INLIST_H_*/
+#endif /*EINA_INLIST_H_ */
diff --git a/tests/suite/ecore/src/include/eina_iterator.h b/tests/suite/ecore/src/include/eina_iterator.h
index 15188be0fa..5db0809911 100644
--- a/tests/suite/ecore/src/include/eina_iterator.h
+++ b/tests/suite/ecore/src/include/eina_iterator.h
@@ -42,26 +42,28 @@
*/
typedef struct _Eina_Iterator Eina_Iterator;
-typedef Eina_Bool (*Eina_Iterator_Next_Callback)(Eina_Iterator *it, void **data);
-typedef void *(*Eina_Iterator_Get_Container_Callback)(Eina_Iterator *it);
-typedef void (*Eina_Iterator_Free_Callback)(Eina_Iterator *it);
-typedef Eina_Bool (*Eina_Iterator_Lock_Callback)(Eina_Iterator *it);
+typedef Eina_Bool(*Eina_Iterator_Next_Callback) (Eina_Iterator * it,
+ void **data);
+typedef void *(*Eina_Iterator_Get_Container_Callback) (Eina_Iterator * it);
+typedef void (*Eina_Iterator_Free_Callback) (Eina_Iterator * it);
+typedef Eina_Bool(*Eina_Iterator_Lock_Callback) (Eina_Iterator * it);
-struct _Eina_Iterator
-{
+struct _Eina_Iterator {
#define EINA_ITERATOR_VERSION 1
- int version;
+ int version;
- Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
- Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1);
+ Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1,
+ 2)
+ EINA_WARN_UNUSED_RESULT;
+ Eina_Iterator_Get_Container_Callback get_container
+ EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1);
- Eina_Iterator_Lock_Callback lock EINA_WARN_UNUSED_RESULT;
- Eina_Iterator_Lock_Callback unlock EINA_WARN_UNUSED_RESULT;
+ Eina_Iterator_Lock_Callback lock EINA_WARN_UNUSED_RESULT;
+ Eina_Iterator_Lock_Callback unlock EINA_WARN_UNUSED_RESULT;
#define EINA_MAGIC_ITERATOR 0x98761233
- EINA_MAGIC
-};
+ EINA_MAGIC};
#define FUNC_ITERATOR_NEXT(Function) ((Eina_Iterator_Next_Callback)Function)
@@ -71,18 +73,24 @@ struct _Eina_Iterator
#define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback)Function)
#define FUNC_ITERATOR_LOCK(Function) ((Eina_Iterator_Lock_Callback)Function)
-EAPI void eina_iterator_free (Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
+EAPI void eina_iterator_free(Eina_Iterator * iterator) EINA_ARG_NONNULL(1);
-EAPI void * eina_iterator_container_get (Eina_Iterator *iterator) EINA_ARG_NONNULL(1) EINA_PURE;
-EAPI Eina_Bool eina_iterator_next (Eina_Iterator *iterator,
- void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI void *eina_iterator_container_get(Eina_Iterator *
+ iterator) EINA_ARG_NONNULL(1)
+ EINA_PURE;
+EAPI Eina_Bool eina_iterator_next(Eina_Iterator * iterator,
+ void **data) EINA_ARG_NONNULL(1,
+ 2)
+ EINA_WARN_UNUSED_RESULT;
-EAPI void eina_iterator_foreach (Eina_Iterator *iterator,
- Eina_Each_Cb callback,
- const void *fdata) EINA_ARG_NONNULL(1, 2);
+EAPI void eina_iterator_foreach(Eina_Iterator * iterator,
+ Eina_Each_Cb callback,
+ const void *fdata) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *
+ iterator) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *
+ iterator) EINA_ARG_NONNULL(1);
/**
* @def EINA_ITERATOR_FOREACH
diff --git a/tests/suite/ecore/src/include/eina_lalloc.h b/tests/suite/ecore/src/include/eina_lalloc.h
index d41a9edb83..69ccba8653 100644
--- a/tests/suite/ecore/src/include/eina_lalloc.h
+++ b/tests/suite/ecore/src/include/eina_lalloc.h
@@ -33,21 +33,22 @@
* @{
*/
-typedef Eina_Bool (*Eina_Lalloc_Alloc)(void *user_data, int num);
+typedef Eina_Bool(*Eina_Lalloc_Alloc) (void *user_data, int num);
#define EINA_LALLOC_ALLOC(function) ((Eina_Lalloc_Alloc)function)
-typedef void (*Eina_Lalloc_Free)(void *user_data);
+typedef void (*Eina_Lalloc_Free) (void *user_data);
#define EINA_LALLOC_FREE(function) ((Eina_Lalloc_Free)function)
typedef struct _Eina_Lalloc Eina_Lalloc;
EAPI Eina_Lalloc *eina_lalloc_new(void *data,
- Eina_Lalloc_Alloc alloc_cb,
- Eina_Lalloc_Free free_cb,
- int num_init) EINA_ARG_NONNULL(2, 3);
-EAPI void eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a,
- int num) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
+ Eina_Lalloc_Alloc alloc_cb,
+ Eina_Lalloc_Free free_cb,
+ int num_init) EINA_ARG_NONNULL(2, 3);
+EAPI void eina_lalloc_free(Eina_Lalloc * a) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc * a,
+ int num) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *
+ a) EINA_ARG_NONNULL(1);
/**
* @}
@@ -57,4 +58,4 @@ EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
* @}
*/
-#endif /* EINA_LALLOC_H_ */
+#endif /* EINA_LALLOC_H_ */
diff --git a/tests/suite/ecore/src/include/eina_list.h b/tests/suite/ecore/src/include/eina_list.h
index 835422d418..63219f7cda 100644
--- a/tests/suite/ecore/src/include/eina_list.h
+++ b/tests/suite/ecore/src/include/eina_list.h
@@ -58,63 +58,127 @@ typedef struct _Eina_List_Accounting Eina_List_Accounting;
* @struct _Eina_List
* Type for a generic double linked list.
*/
-struct _Eina_List
-{
- void *data; /**< Pointer to list element payload */
- Eina_List *next; /**< Next member in the list */
- Eina_List *prev; /**< Previous member in the list */
- Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */
+struct _Eina_List {
+ void *data;
+ /**< Pointer to list element payload */
+ Eina_List *next;
+ /**< Next member in the list */
+ Eina_List *prev;
+ /**< Previous member in the list */
+ Eina_List_Accounting *accounting;
+ /**< Private list accounting info - don't touch */
- EINA_MAGIC
-};
+ EINA_MAGIC};
-struct _Eina_List_Accounting
-{
- Eina_List *last;
- unsigned int count;
- EINA_MAGIC
-};
+struct _Eina_List_Accounting {
+ Eina_List *last;
+ unsigned int count;
+ EINA_MAGIC};
-EAPI Eina_List * eina_list_append (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_prepend (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_append_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_remove (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_remove_list (Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL( 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_promote_list (Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL( 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_demote_list (Eina_List *list, Eina_List *move_list);
-EAPI void * eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_data_find_list (const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_free (Eina_List *list);
-EAPI void * eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_nth_list (const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_reverse (Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_reverse_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_sort (Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_merge (Eina_List *left, Eina_List *right) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_append(Eina_List * list,
+ const void *data) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_prepend(Eina_List * list,
+ const void *data) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_append_relative(Eina_List * list,
+ const void *data,
+ const void *relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_append_relative_list(Eina_List * list,
+ const void *data,
+ Eina_List *
+ relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_prepend_relative(Eina_List * list,
+ const void *data,
+ const void *relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_prepend_relative_list(Eina_List * list,
+ const void *data,
+ Eina_List *
+ relative)
+EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_sorted_insert(Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data)
+EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_remove(Eina_List * list,
+ const void *data) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_remove_list(Eina_List * list,
+ Eina_List *
+ remove_list) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_promote_list(Eina_List * list,
+ Eina_List *
+ move_list) EINA_ARG_NONNULL(2)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_demote_list(Eina_List * list,
+ Eina_List * move_list);
+EAPI void *eina_list_data_find(const Eina_List * list, const void *data)
+EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_data_find_list(const Eina_List * list,
+ const void *data)
+EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_free(Eina_List * list);
+EAPI void *eina_list_nth(const Eina_List * list, unsigned int n)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_nth_list(const Eina_List * list, unsigned int n)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_reverse(Eina_List *
+ list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_reverse_clone(const Eina_List *
+ list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_clone(const Eina_List *
+ list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_sort(Eina_List * list, unsigned int size,
+ Eina_Compare_Cb func) EINA_ARG_NONNULL(3)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_merge(Eina_List * left,
+ Eina_List * right) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_sorted_merge(Eina_List * left, Eina_List * right,
+ Eina_Compare_Cb func)
+EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *eina_list_split_list(Eina_List * list,
+ Eina_List * relative,
+ Eina_List **
+ right) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List * eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp);
-EAPI Eina_List * eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI void * eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI Eina_List * eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI void * eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
+EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data,
+ int *result_cmp);
+EAPI Eina_List *eina_list_search_sorted_list(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data);
+EAPI void *eina_list_search_sorted(const Eina_List * list,
+ Eina_Compare_Cb func, const void *data);
+EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data);
+EAPI void *eina_list_search_unsorted(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data);
-static inline Eina_List * eina_list_last (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline Eina_List * eina_list_next (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline Eina_List * eina_list_prev (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline void * eina_list_data_get(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE;
+static inline Eina_List *eina_list_last(const Eina_List * list)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline Eina_List *eina_list_next(const Eina_List * list)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline Eina_List *eina_list_prev(const Eina_List * list)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline void *eina_list_data_get(const Eina_List * list)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline unsigned int eina_list_count(const Eina_List *
+ list) EINA_PURE;
-EAPI Eina_Iterator * eina_list_iterator_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator * eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor * eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List * list)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List * list)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List * list)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @def EINA_LIST_FOREACH
@@ -346,4 +410,4 @@ EAPI Eina_Accessor * eina_list_accessor_new(const Eina_List *list)
* @}
*/
-#endif /* EINA_LIST_H_ */
+#endif /* EINA_LIST_H_ */
diff --git a/tests/suite/ecore/src/include/eina_log.h b/tests/suite/ecore/src/include/eina_log.h
index d0fd1594d0..3e39bc5e8a 100644
--- a/tests/suite/ecore/src/include/eina_log.h
+++ b/tests/suite/ecore/src/include/eina_log.h
@@ -104,9 +104,9 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
* @endcode
*
*/
-# define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL
+#define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL
-#endif /* EINA_LOG_DOMAIN_DEFAULT */
+#endif /* EINA_LOG_DOMAIN_DEFAULT */
/**
@@ -229,15 +229,19 @@ typedef struct _Eina_Log_Domain Eina_Log_Domain;
* @struct _Eina_Log_Domain
* The domain used for logging.
*/
-struct _Eina_Log_Domain
-{
- int level; /**< Max level to log */
- const char *domain_str; /**< Formatted string with color to print */
- const char *name; /**< Domain name */
- size_t namelen; /**< strlen(name) */
-
- /* Private */
- Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */
+struct _Eina_Log_Domain {
+ int level;
+ /**< Max level to log */
+ const char *domain_str;
+ /**< Formatted string with color to print */
+ const char *name;
+ /**< Domain name */
+ size_t namelen;
+ /**< strlen(name) */
+
+ /* Private */
+ Eina_Bool deleted:1;
+ /**< Flags deletion of domain, a free slot */
};
EAPI void eina_log_threads_enable(void);
@@ -246,133 +250,123 @@ EAPI void eina_log_threads_enable(void);
* @enum _Eina_Log_Level
* List of available logging levels.
*/
-typedef enum _Eina_Log_Level
-{
- EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */
- EINA_LOG_LEVEL_ERR, /**< Error log level */
- EINA_LOG_LEVEL_WARN, /**< Warning log level */
- EINA_LOG_LEVEL_INFO, /**< Information log level */
- EINA_LOG_LEVEL_DBG, /**< Debug log level */
- EINA_LOG_LEVELS, /**< Count of default log levels */
- EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1) /**< Unknown level */
+typedef enum _Eina_Log_Level {
+ EINA_LOG_LEVEL_CRITICAL,
+ /**< Critical log level */
+ EINA_LOG_LEVEL_ERR,
+ /**< Error log level */
+ EINA_LOG_LEVEL_WARN,
+ /**< Warning log level */
+ EINA_LOG_LEVEL_INFO,
+ /**< Information log level */
+ EINA_LOG_LEVEL_DBG,
+ /**< Debug log level */
+ EINA_LOG_LEVELS,
+ /**< Count of default log levels */
+ EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1)/**< Unknown level */
} Eina_Log_Level;
/**
* @typedef Eina_Log_Print_Cb
* Type for print callbacks.
*/
-typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file, const char *fnc, int line,
- const char *fmt, void *data, va_list args);
+typedef void (*Eina_Log_Print_Cb) (const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file, const char *fnc,
+ int line, const char *fmt, void *data,
+ va_list args);
/*
* Customization
*/
EAPI void
-eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1);
+eina_log_print_cb_set(Eina_Log_Print_Cb cb,
+ void *data) EINA_ARG_NONNULL(1);
-EAPI void
-eina_log_level_set(int level);
-EAPI int
-eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void eina_log_level_set(int level);
+EAPI int eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool
-eina_log_level_check(int level);
+static inline Eina_Bool eina_log_level_check(int level);
-EAPI Eina_Bool
-eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_log_main_thread_check(void)
+EINA_CONST EINA_WARN_UNUSED_RESULT;
-EAPI void
-eina_log_color_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool
-eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void
-eina_log_file_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool
-eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void
-eina_log_function_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool
-eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void
-eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
+EAPI void eina_log_color_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void eina_log_file_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void eina_log_function_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
EAPI Eina_Bool
eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void
-eina_log_abort_on_critical_level_set(int critical_level);
+EAPI void eina_log_abort_on_critical_level_set(int critical_level);
EAPI int
eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT;
EAPI void
-eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1);
-EAPI int
-eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+eina_log_domain_level_set(const char *domain_name,
+ int level) EINA_ARG_NONNULL(1);
+EAPI int eina_log_domain_level_get(const char *domain_name)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
EAPI int
eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool
-eina_log_domain_level_check(int domain, int level);
+static inline Eina_Bool eina_log_domain_level_check(int domain, int level);
/*
* Logging domains
*/
EAPI int
-eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(1);
-EAPI void
-eina_log_domain_unregister(int domain);
+eina_log_domain_register(const char *name,
+ const char *color) EINA_ARG_NONNULL(1);
+EAPI void eina_log_domain_unregister(int domain);
/*
* Logging functions.
*/
EAPI void
eina_log_print(int domain,
- Eina_Log_Level level,
- const char *file,
- const char *function,
- int line,
- const char *fmt,
- ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) EINA_NOINSTRUMENT;
-EAPI void
-eina_log_vprint(int domain,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT;
+ Eina_Log_Level level,
+ const char *file,
+ const char *function,
+ int line,
+ const char *fmt,
+ ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6,
+ 7)
+EINA_NOINSTRUMENT;
+EAPI void eina_log_vprint(int domain, Eina_Log_Level level,
+ const char *file, const char *fnc, int line,
+ const char *fmt,
+ va_list args) EINA_ARG_NONNULL(3, 4,
+ 6)
+ EINA_NOINSTRUMENT;
/*
* Logging methods (change how logging is done).
*/
EAPI void
-eina_log_print_cb_stdout(const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- void *data,
- va_list args);
+eina_log_print_cb_stdout(const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt, void *data, va_list args);
EAPI void
-eina_log_print_cb_stderr(const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- void *data,
- va_list args);
+eina_log_print_cb_stderr(const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt, void *data, va_list args);
EAPI void
-eina_log_print_cb_file(const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- void *data,
- va_list args);
+eina_log_print_cb_file(const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt, void *data, va_list args);
#include "eina_inline_log.x"
@@ -384,4 +378,4 @@ eina_log_print_cb_file(const Eina_Log_Domain *d,
* @}
*/
-#endif /* EINA_LOG_H_ */
+#endif /* EINA_LOG_H_ */
diff --git a/tests/suite/ecore/src/include/eina_magic.h b/tests/suite/ecore/src/include/eina_magic.h
index dd1a9f3a56..1f703932ad 100644
--- a/tests/suite/ecore/src/include/eina_magic.h
+++ b/tests/suite/ecore/src/include/eina_magic.h
@@ -41,11 +41,14 @@ typedef unsigned int Eina_Magic;
* @typedef Eina_Magic
* An abstract type for a magic number.
*/
-EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic,
- const char *magic_name) EINA_ARG_NONNULL(2);
-EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
- const char *magic_name) EINA_ARG_NONNULL(2);
+EAPI const char *eina_magic_string_get(Eina_Magic magic)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic,
+ const char *magic_name)
+EINA_ARG_NONNULL(2);
+EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
+ const char *magic_name)
+EINA_ARG_NONNULL(2);
/**
* @def EINA_MAGIC_NONE
@@ -120,8 +123,8 @@ EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
__LINE__);
EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
- const char *file, const char *fnc,
- int line) EINA_ARG_NONNULL(4, 5);
+ const char *file, const char *fnc,
+ int line) EINA_ARG_NONNULL(4, 5);
#else
@@ -150,4 +153,4 @@ EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
* @}
*/
-#endif /* EINA_MAGIC_H_ */
+#endif /* EINA_MAGIC_H_ */
diff --git a/tests/suite/ecore/src/include/eina_main.h b/tests/suite/ecore/src/include/eina_main.h
index db80042465..06e64d9813 100644
--- a/tests/suite/ecore/src/include/eina_main.h
+++ b/tests/suite/ecore/src/include/eina_main.h
@@ -49,12 +49,15 @@
* @typedef Eina_Version
* The version of Eina.
*/
-typedef struct _Eina_Version
-{
- int major; /**< Major component of the version */
- int minor; /**< Minor component of the version */
- int micro; /**< Micro component of the version */
- int revision; /**< Revision component of the version */
+typedef struct _Eina_Version {
+ int major;
+ /**< Major component of the version */
+ int minor;
+ /**< Minor component of the version */
+ int micro;
+ /**< Micro component of the version */
+ int revision;
+ /**< Revision component of the version */
} Eina_Version;
EAPI extern Eina_Version *eina_version;
@@ -72,4 +75,4 @@ EAPI int eina_threads_shutdown(void);
* @}
*/
-#endif /* EINA_MAIN_H_ */
+#endif /* EINA_MAIN_H_ */
diff --git a/tests/suite/ecore/src/include/eina_matrixsparse.h b/tests/suite/ecore/src/include/eina_matrixsparse.h
index cbf29ccb7e..561ff1a6ba 100644
--- a/tests/suite/ecore/src/include/eina_matrixsparse.h
+++ b/tests/suite/ecore/src/include/eina_matrixsparse.h
@@ -69,41 +69,71 @@ typedef struct _Eina_Matrixsparse_Item_Row Eina_Matrixsparse_Item_Row;
/* constructors and destructors */
EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows,
- unsigned long cols,
- void (*free_func)(void *user_data,
- void *cell_data),
- const void *user_data);
-EAPI void eina_matrixsparse_free(Eina_Matrixsparse *m);
+ unsigned long cols,
+ void (*free_func) (void
+ *user_data,
+ void
+ *cell_data),
+ const void *user_data);
+EAPI void eina_matrixsparse_free(Eina_Matrixsparse * m);
/* size manipulation */
-EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
- unsigned long *rows,
- unsigned long *cols);
-EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m,
- unsigned long rows,
- unsigned long cols);
+EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse * m,
+ unsigned long *rows,
+ unsigned long *cols);
+EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse * m,
+ unsigned long rows,
+ unsigned long cols);
/* data getting */
-EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell);
-EAPI void * eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell);
-EAPI void * eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col);
-EAPI Eina_Bool eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col);
+EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col,
+ Eina_Matrixsparse_Cell **
+ cell);
+EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *
+ cell);
+EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col);
+EAPI Eina_Bool eina_matrixsparse_cell_position_get(const
+ Eina_Matrixsparse_Cell *
+ cell,
+ unsigned long *row,
+ unsigned long *col);
/* data setting */
-EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old);
-EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data);
-EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old);
-EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data);
+EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *
+ cell, const void *data,
+ void **p_old);
+EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *
+ cell, const void *data);
+EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col,
+ const void *data,
+ void **p_old);
+EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col,
+ const void *data);
/* data deleting */
-EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row);
-EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col);
-EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col);
-EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell);
+EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse * m,
+ unsigned long row);
+EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse * m,
+ unsigned long col);
+EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col);
+EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell * cell);
/* iterators */
-EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m);
-EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m);
+EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse
+ * m);
+EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const
+ Eina_Matrixsparse
+ * m);
/**
* @}
@@ -117,4 +147,4 @@ EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matrixspa
* @}
*/
-#endif /* EINA_MATRIXSPARSE_H_ */
+#endif /* EINA_MATRIXSPARSE_H_ */
diff --git a/tests/suite/ecore/src/include/eina_mempool.h b/tests/suite/ecore/src/include/eina_mempool.h
index cc19e94018..b8004eb143 100644
--- a/tests/suite/ecore/src/include/eina_mempool.h
+++ b/tests/suite/ecore/src/include/eina_mempool.h
@@ -49,20 +49,30 @@ typedef struct _Eina_Mempool_Backend Eina_Mempool_Backend;
EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
-EAPI Eina_Mempool * eina_mempool_add(const char *module,const char *context,const char *options,...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
-
-static inline void * eina_mempool_realloc(Eina_Mempool *mp,void *element,unsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void * eina_mempool_malloc(Eina_Mempool *mp,unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void eina_mempool_free(Eina_Mempool *mp,void *element) EINA_ARG_NONNULL(1);
-
-EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
-
-EAPI unsigned int eina_mempool_alignof(unsigned int size);
+EAPI Eina_Mempool *eina_mempool_add(const char *module,
+ const char *context,
+ const char *options, ...)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI void eina_mempool_del(Eina_Mempool * mp) EINA_ARG_NONNULL(1);
+
+static inline void *eina_mempool_realloc(Eina_Mempool * mp, void *element,
+ unsigned int size)
+EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void *eina_mempool_malloc(Eina_Mempool * mp,
+ unsigned int size)
+EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void eina_mempool_free(Eina_Mempool * mp,
+ void *element) EINA_ARG_NONNULL(1);
+
+EAPI void eina_mempool_gc(Eina_Mempool * mp) EINA_ARG_NONNULL(1);
+EAPI void eina_mempool_statistics(Eina_Mempool * mp) EINA_ARG_NONNULL(1);
+
+EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *
+ be) EINA_ARG_NONNULL(1);
+EAPI void eina_mempool_unregister(Eina_Mempool_Backend *
+ be) EINA_ARG_NONNULL(1);
+
+EAPI unsigned int eina_mempool_alignof(unsigned int size);
#include "eina_inline_mempool.x"
@@ -74,4 +84,4 @@ EAPI unsigned int eina_mempool_alignof(unsigned int size);
* @}
*/
-#endif /* EINA_MEMPOOL_H_ */
+#endif /* EINA_MEMPOOL_H_ */
diff --git a/tests/suite/ecore/src/include/eina_module.h b/tests/suite/ecore/src/include/eina_module.h
index 6618381c30..4b856c8bf2 100644
--- a/tests/suite/ecore/src/include/eina_module.h
+++ b/tests/suite/ecore/src/include/eina_module.h
@@ -61,7 +61,7 @@
*/
typedef struct _Eina_Module Eina_Module;
-typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data);
+typedef Eina_Bool(*Eina_Module_Cb) (Eina_Module * m, void *data);
/**
* @typedef Eina_Module_Init
@@ -71,7 +71,7 @@ typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data);
* means the module was successfully initialized.
* @see Eina_Module_Shutdown
*/
-typedef Eina_Bool (*Eina_Module_Init)(void);
+typedef Eina_Bool(*Eina_Module_Init) (void);
/**
* @typedef Eina_Module_Shutdown
@@ -79,7 +79,7 @@ typedef Eina_Bool (*Eina_Module_Init)(void);
* __eina_module_shutdown, it will be called before calling dlclose()
* @see Eina_Module_Init
*/
-typedef void (*Eina_Module_Shutdown)(void);
+typedef void (*Eina_Module_Shutdown) (void);
/**
* @def EINA_MODULE_INIT
@@ -108,36 +108,37 @@ extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE;
*/
extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED;
-EAPI Eina_Module *
-eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI Eina_Bool
-eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool
-eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool
-eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1);
-EAPI void *
-eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI const char *
-eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-
-EAPI char *
-eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
-EAPI char *
-eina_module_environment_path_get(const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Array *
-eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch);
-EAPI Eina_Array *
-eina_module_list_get(Eina_Array *array, const char *path, Eina_Bool recursive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void
-eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI void
-eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI void
-eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI Eina_Module *
-eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Module *eina_module_new(const char *file)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_module_free(Eina_Module * m) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_module_load(Eina_Module * module) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_module_unload(Eina_Module * m) EINA_ARG_NONNULL(1);
+EAPI void *eina_module_symbol_get(const Eina_Module * module,
+ const char *symbol)
+EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI const char *eina_module_file_get(const Eina_Module * m)
+EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+
+EAPI char *eina_module_symbol_path_get(const void *symbol,
+ const char *sub_dir)
+EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
+EAPI char *eina_module_environment_path_get(const char *env,
+ const char *sub_dir)
+EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Array *eina_module_arch_list_get(Eina_Array * array,
+ const char *path,
+ const char *arch);
+EAPI Eina_Array *eina_module_list_get(Eina_Array * array, const char *path,
+ Eina_Bool recursive,
+ Eina_Module_Cb cb, void *data)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI void eina_module_list_load(Eina_Array * list) EINA_ARG_NONNULL(1);
+EAPI void eina_module_list_unload(Eina_Array * list) EINA_ARG_NONNULL(1);
+EAPI void eina_module_list_free(Eina_Array * list) EINA_ARG_NONNULL(1);
+EAPI Eina_Module *eina_module_find(const Eina_Array * array,
+ const char *module) EINA_ARG_NONNULL(1,
+ 2);
/**
* @}
@@ -147,4 +148,4 @@ eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1
* @}
*/
-#endif /*EINA_MODULE_H_*/
+#endif /*EINA_MODULE_H_ */
diff --git a/tests/suite/ecore/src/include/eina_quadtree.h b/tests/suite/ecore/src/include/eina_quadtree.h
index ad24c3ebb3..f77b21c954 100644
--- a/tests/suite/ecore/src/include/eina_quadtree.h
+++ b/tests/suite/ecore/src/include/eina_quadtree.h
@@ -27,27 +27,32 @@ typedef struct _Eina_QuadTree Eina_QuadTree;
typedef struct _Eina_QuadTree_Item Eina_QuadTree_Item;
typedef enum {
- EINA_QUAD_LEFT,
- EINA_QUAD_RIGHT,
- EINA_QUAD_BOTH
+ EINA_QUAD_LEFT,
+ EINA_QUAD_RIGHT,
+ EINA_QUAD_BOTH
} Eina_Quad_Direction;
-typedef Eina_Quad_Direction (*Eina_Quad_Callback)(const void *object, size_t middle);
+typedef Eina_Quad_Direction(*Eina_Quad_Callback) (const void *object,
+ size_t middle);
-EAPI Eina_QuadTree * eina_quadtree_new(size_t w, size_t h, Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal);
-EAPI void eina_quadtree_free(Eina_QuadTree *q);
-EAPI void eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h);
+EAPI Eina_QuadTree *eina_quadtree_new(size_t w, size_t h,
+ Eina_Quad_Callback vertical,
+ Eina_Quad_Callback horizontal);
+EAPI void eina_quadtree_free(Eina_QuadTree * q);
+EAPI void eina_quadtree_resize(Eina_QuadTree * q, size_t w, size_t h);
-EAPI void eina_quadtree_cycle(Eina_QuadTree *q);
-EAPI void eina_quadtree_increase(Eina_QuadTree_Item *object);
+EAPI void eina_quadtree_cycle(Eina_QuadTree * q);
+EAPI void eina_quadtree_increase(Eina_QuadTree_Item * object);
-EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree *q, const void *object);
-EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item *object);
+EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree * q,
+ const void *object);
+EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item * object);
+EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item * object);
+EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item * object);
+EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item * object);
-EAPI Eina_Inlist * eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h);
-EAPI void * eina_quadtree_object(Eina_Inlist *list);
+EAPI Eina_Inlist *eina_quadtree_collide(Eina_QuadTree * q, int x, int y,
+ int w, int h);
+EAPI void *eina_quadtree_object(Eina_Inlist * list);
#endif
diff --git a/tests/suite/ecore/src/include/eina_rbtree.h b/tests/suite/ecore/src/include/eina_rbtree.h
index 026db41ca1..f2b0e987bb 100644
--- a/tests/suite/ecore/src/include/eina_rbtree.h
+++ b/tests/suite/ecore/src/include/eina_rbtree.h
@@ -48,8 +48,8 @@
* node color.
*/
typedef enum {
- EINA_RBTREE_RED,
- EINA_RBTREE_BLACK
+ EINA_RBTREE_RED,
+ EINA_RBTREE_BLACK
} Eina_Rbtree_Color;
/**
@@ -57,8 +57,8 @@ typedef enum {
* walk direction.
*/
typedef enum {
- EINA_RBTREE_LEFT = 0,
- EINA_RBTREE_RIGHT = 1
+ EINA_RBTREE_LEFT = 0,
+ EINA_RBTREE_RIGHT = 1
} Eina_Rbtree_Direction;
/**
@@ -66,11 +66,10 @@ typedef enum {
* Type for a Red-Black tree node. It should be inlined into user's type.
*/
typedef struct _Eina_Rbtree Eina_Rbtree;
-struct _Eina_Rbtree
-{
- Eina_Rbtree *son[2];
+struct _Eina_Rbtree {
+ Eina_Rbtree *son[2];
- Eina_Rbtree_Color color : 1;
+ Eina_Rbtree_Color color:1;
};
/**
@@ -99,7 +98,11 @@ struct _Eina_Rbtree
* @typedef Eina_Rbtree_Cmp_Node_Cb
* Function used compare two nodes and see which direction to navigate.
*/
-typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data);
+typedef Eina_Rbtree_Direction(*Eina_Rbtree_Cmp_Node_Cb) (const Eina_Rbtree
+ * left,
+ const Eina_Rbtree
+ * right,
+ void *data);
/**
* @def EINA_RBTREE_CMP_NODE_CB
@@ -111,7 +114,9 @@ typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left
* @typedef Eina_Rbtree_Cmp_Key_Cb
* Function used compare node with a given key of specified length.
*/
-typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key, int length, void *data);
+typedef int (*Eina_Rbtree_Cmp_Key_Cb) (const Eina_Rbtree * node,
+ const void *key, int length,
+ void *data);
/**
* @def EINA_RBTREE_CMP_KEY_CB
* Cast using #Eina_Rbtree_Cmp_Key_Cb
@@ -122,22 +127,39 @@ typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key,
* @typedef Eina_Rbtree_Free_Cb
* Function used free a node.
*/
-typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data);
+typedef void (*Eina_Rbtree_Free_Cb) (Eina_Rbtree * node, void *data);
/**
* @def EINA_RBTREE_FREE_CB
* Cast using #Eina_Rbtree_Free_Cb
*/
#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function)
-EAPI Eina_Rbtree * eina_rbtree_inline_insert(Eina_Rbtree *root,Eina_Rbtree *node,Eina_Rbtree_Cmp_Node_Cb cmp,const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rbtree * eina_rbtree_inline_remove(Eina_Rbtree *root,Eina_Rbtree *node,Eina_Rbtree_Cmp_Node_Cb cmp,const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_rbtree_delete(Eina_Rbtree *root,Eina_Rbtree_Free_Cb func,void *data) EINA_ARG_NONNULL(2);
-
-static inline Eina_Rbtree * eina_rbtree_inline_lookup(const Eina_Rbtree *root,const void *key,int length,Eina_Rbtree_Cmp_Key_Cb cmp,const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
-
-EAPI Eina_Iterator * eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator * eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator * eina_rbtree_iterator_postfix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree * root,
+ Eina_Rbtree * node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data)
+EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree * root,
+ Eina_Rbtree * node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data)
+EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
+EAPI void eina_rbtree_delete(Eina_Rbtree * root, Eina_Rbtree_Free_Cb func,
+ void *data) EINA_ARG_NONNULL(2);
+
+static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *
+ root, const void *key,
+ int length,
+ Eina_Rbtree_Cmp_Key_Cb
+ cmp, const void *data)
+EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
+
+EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree * root)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree * root)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree * root)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
#include "eina_inline_rbtree.x"
diff --git a/tests/suite/ecore/src/include/eina_rectangle.h b/tests/suite/ecore/src/include/eina_rectangle.h
index a9daf66672..71a4e70c28 100644
--- a/tests/suite/ecore/src/include/eina_rectangle.h
+++ b/tests/suite/ecore/src/include/eina_rectangle.h
@@ -37,12 +37,15 @@
* @typedef Eina_Rectangle
* Simple rectangle structure.
*/
-typedef struct _Eina_Rectangle
-{
- int x; /**< top-left x co-ordinate of rectangle */
- int y; /**< top-left y co-ordinate of rectangle */
- int w; /**< width of rectangle */
- int h; /**< height of rectangle */
+typedef struct _Eina_Rectangle {
+ int x;
+ /**< top-left x co-ordinate of rectangle */
+ int y;
+ /**< top-left y co-ordinate of rectangle */
+ int w;
+ /**< width of rectangle */
+ int h;
+ /**< height of rectangle */
} Eina_Rectangle;
/**
@@ -51,27 +54,72 @@ typedef struct _Eina_Rectangle
*/
typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool;
-static inline int eina_spans_intersect(int c1, int l1, int c2, int l2) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_is_empty(const Eina_Rectangle *r) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1);
-static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2);
-static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-static inline void eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
-static inline void eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
+static inline int eina_spans_intersect(int c1, int l1, int c2,
+ int l2) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool eina_rectangle_is_empty(const Eina_Rectangle *
+ r) EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
+static inline void eina_rectangle_coords_from(Eina_Rectangle * r, int x,
+ int y, int w,
+ int h) EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *
+ r1,
+ const Eina_Rectangle *
+ r2) EINA_ARG_NONNULL(1,
+ 2)
+ EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *
+ r,
+ int x)
+EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *
+ r,
+ int y)
+EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *
+ r, int x,
+ int y)
+EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void eina_rectangle_union(Eina_Rectangle * dst,
+ const Eina_Rectangle *
+ src) EINA_ARG_NONNULL(1, 2);
+static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle * dst,
+ const Eina_Rectangle *
+ src)
+EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+static inline void eina_rectangle_rescale_in(const Eina_Rectangle * out,
+ const Eina_Rectangle * in,
+ Eina_Rectangle *
+ res) EINA_ARG_NONNULL(1, 2,
+ 3);
+static inline void eina_rectangle_rescale_out(const Eina_Rectangle * out,
+ const Eina_Rectangle * in,
+ Eina_Rectangle *
+ res) EINA_ARG_NONNULL(1, 2,
+ 3);
-EAPI Eina_Rectangle_Pool * eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rectangle_Pool * eina_rectangle_pool_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI void * eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1);
-EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1);
-EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rectangle * eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
+EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle * rect)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool * pool,
+ int *w, int *h)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool * pool)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool * pool,
+ const void *data)
+EINA_ARG_NONNULL(1);
+EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *
+ pool) EINA_ARG_NONNULL(1);
+EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *
+ pool) EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *
+ pool, int w, int h)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI void eina_rectangle_pool_release(Eina_Rectangle *
+ rect) EINA_ARG_NONNULL(1);
/**
* @def EINA_RECTANGLE_SET
@@ -93,8 +141,9 @@ EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
(Rectangle)->w = W; \
(Rectangle)->h = H;
-EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
+EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI void eina_rectangle_free(Eina_Rectangle * rect) EINA_ARG_NONNULL(1);
#include "eina_inline_rectangle.x"
diff --git a/tests/suite/ecore/src/include/eina_safety_checks.h b/tests/suite/ecore/src/include/eina_safety_checks.h
index 29ebba07d3..43bb86e6b8 100644
--- a/tests/suite/ecore/src/include/eina_safety_checks.h
+++ b/tests/suite/ecore/src/include/eina_safety_checks.h
@@ -193,7 +193,7 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
#endif
-#else /* no safety checks */
+#else /* no safety checks */
#define EINA_SAFETY_ON_NULL_RETURN(exp) \
do { (void)(!(exp)); } while (0)
@@ -222,8 +222,8 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
do { if (0 && !(exp)) { goto label; } } while (0)
-#endif /* safety checks macros */
-#endif /* EINA_SAFETY_CHECKS_H_ */
+#endif /* safety checks macros */
+#endif /* EINA_SAFETY_CHECKS_H_ */
/**
* @}
diff --git a/tests/suite/ecore/src/include/eina_sched.h b/tests/suite/ecore/src/include/eina_sched.h
index 607b9f5b85..89d0d9eaf0 100644
--- a/tests/suite/ecore/src/include/eina_sched.h
+++ b/tests/suite/ecore/src/include/eina_sched.h
@@ -23,4 +23,4 @@
EAPI void eina_sched_prio_drop(void);
-#endif /* EINA_SCHED_H_ */
+#endif /* EINA_SCHED_H_ */
diff --git a/tests/suite/ecore/src/include/eina_str.h b/tests/suite/ecore/src/include/eina_str.h
index 1d12615e5a..736fa6a7a4 100644
--- a/tests/suite/ecore/src/include/eina_str.h
+++ b/tests/suite/ecore/src/include/eina_str.h
@@ -19,26 +19,46 @@
*/
/* strlcpy implementation for libc's lacking it */
-EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
-EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-
-EAPI char ** eina_str_split(const char *string, const char *delimiter, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI char ** eina_str_split_full(const char *string, const char *delimiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-
-EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
-
-EAPI char * eina_str_convert(const char *enc_from, const char *enc_to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3);
-
-EAPI char * eina_str_escape(const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
-
-EAPI void eina_str_tolower(char **str);
-EAPI void eina_str_toupper(char **str);
-
-static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5);
+EAPI size_t eina_strlcpy(char *dst, const char *src,
+ size_t siz) EINA_ARG_NONNULL(1, 2);
+EAPI size_t eina_strlcat(char *dst, const char *src,
+ size_t siz) EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix)
+EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix)
+EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext)
+EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+
+EAPI char **eina_str_split(const char *string, const char *delimiter,
+ int max_tokens) EINA_ARG_NONNULL(1, 2)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI char **eina_str_split_full(const char *string, const char *delimiter,
+ int max_tokens,
+ unsigned int *elements) EINA_ARG_NONNULL(1,
+ 2,
+ 4)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+
+EAPI size_t eina_str_join_len(char *dst, size_t size, char sep,
+ const char *a, size_t a_len, const char *b,
+ size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
+
+EAPI char *eina_str_convert(const char *enc_from, const char *enc_to,
+ const char *text)
+EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3);
+
+EAPI char *eina_str_escape(const char *str)
+EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
+
+EAPI void eina_str_tolower(char **str);
+EAPI void eina_str_toupper(char **str);
+
+static inline size_t eina_str_join(char *dst, size_t size, char sep,
+ const char *a,
+ const char *b) EINA_ARG_NONNULL(1, 4,
+ 5);
/**
* @def eina_str_join_static(dst, sep, a, b)
@@ -58,7 +78,8 @@ static inline size_t eina_str_join(char *dst, size_t size, char sep, const char
*/
#define eina_str_join_static(dst, sep, a, b) eina_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0)
-static inline size_t eina_strlen_bounded(const char *str, size_t maxlen) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+static inline size_t eina_strlen_bounded(const char *str, size_t maxlen)
+EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
#include "eina_inline_str.x"
@@ -70,4 +91,4 @@ static inline size_t eina_strlen_bounded(const char *str, size_t maxlen) EINA_PU
* @}
*/
-#endif /* EINA_STR_H */
+#endif /* EINA_STR_H */
diff --git a/tests/suite/ecore/src/include/eina_strbuf.h b/tests/suite/ecore/src/include/eina_strbuf.h
index 4424eb4852..432fe5f179 100644
--- a/tests/suite/ecore/src/include/eina_strbuf.h
+++ b/tests/suite/ecore/src/include/eina_strbuf.h
@@ -37,7 +37,8 @@ typedef struct _Eina_Strbuf Eina_Strbuf;
* @see eina_strbuf_append()
* @see eina_strbuf_string_get()
*/
-EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Strbuf *eina_strbuf_new(void)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Free a string buffer.
@@ -47,7 +48,7 @@ EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
* This function frees the memory of @p buf. @p buf must have been
* created by eina_strbuf_new().
*/
-EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_strbuf_free(Eina_Strbuf * buf) EINA_ARG_NONNULL(1);
/**
* @brief Reset a string buffer.
@@ -57,7 +58,7 @@ EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
* This function reset @p buf: the buffer len is set to 0, and the
* string is set to '\\0'. No memory is free'd.
*/
-EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_strbuf_reset(Eina_Strbuf * buf) EINA_ARG_NONNULL(1);
/**
* @brief Append a string to a buffer, reallocating as necessary.
@@ -75,7 +76,8 @@ EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
* @see eina_strbuf_append()
* @see eina_strbuf_append_length()
*/
-EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf * buf,
+ const char *str) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append an escaped string to a buffer, reallocating as necessary.
@@ -88,7 +90,9 @@ EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG
* str can not be appended, #EINA_FALSE is returned, otherwise,
* #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf * buf,
+ const char *str)
+EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a string to a buffer, reallocating as necessary,
@@ -111,7 +115,8 @@ EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str)
* @see eina_strbuf_append()
* @see eina_strbuf_append_length()
*/
-EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf * buf, const char *str,
+ size_t maxlen) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a string of exact length to a buffer, reallocating as necessary.
@@ -132,7 +137,10 @@ EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t
* @see eina_strbuf_append()
* @see eina_strbuf_append_n()
*/
-EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf * buf,
+ const char *str,
+ size_t length) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Append a character to a string buffer, reallocating as
@@ -145,7 +153,8 @@ EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, s
* This function inserts @p c to @p buf. If it can not insert it,
* #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf * buf,
+ char c) EINA_ARG_NONNULL(1);
/**
* @brief Append a string to a buffer, reallocating as necessary.
@@ -156,7 +165,11 @@ EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NON
*
* @see eina_strbuf_append()
*/
-EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
+EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf * buf,
+ const char *fmt,
+ ...) EINA_ARG_NONNULL(1,
+ 2)
+EINA_PRINTF(2, 3);
/**
* @brief Append a string to a buffer, reallocating as necessary.
@@ -168,7 +181,10 @@ EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, .
*
* @see eina_strbuf_append()
*/
-EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf * buf,
+ const char *fmt,
+ va_list args) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
@@ -184,7 +200,8 @@ EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt,
* consider using that variant. If @p buf can't insert it, #EINA_FALSE
* is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf * buf, const char *str,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert an escaped string to a buffer, reallocating as
@@ -199,7 +216,10 @@ EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t p
* position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
* returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf * buf,
+ const char *str,
+ size_t pos) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
@@ -219,7 +239,9 @@ EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str,
* @p str). If @p str can not be inserted, #EINA_FALSE is returned,
* otherwise, #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf * buf, const char *str,
+ size_t maxlen,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert a string of exact length to a buffer, reallocating as necessary.
@@ -241,7 +263,10 @@ EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t
* @see eina_strbuf_insert()
* @see eina_strbuf_insert_n()
*/
-EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf * buf,
+ const char *str, size_t length,
+ size_t pos) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Insert a character to a string buffer, reallocating as
@@ -256,7 +281,8 @@ EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, s
* can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf * buf, char c,
+ size_t pos) EINA_ARG_NONNULL(1);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
@@ -266,7 +292,11 @@ EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos)
* @param pos The position to insert the string.
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
-EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4);
+EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf * buf,
+ const char *fmt, size_t pos,
+ ...) EINA_ARG_NONNULL(1,
+ 2)
+EINA_PRINTF(2, 4);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
@@ -277,7 +307,10 @@ EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, s
* @param args The variable arguments.
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
-EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf * buf,
+ const char *fmt, size_t pos,
+ va_list args) EINA_ARG_NONNULL(1,
+ 2);
/**
* @def eina_strbuf_prepend(buf, str)
@@ -395,7 +428,8 @@ EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt,
* in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
-EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf * buf, size_t start,
+ size_t end) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve a pointer to the contents of a string buffer
@@ -410,7 +444,9 @@ EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EI
*
* @see eina_strbuf_string_steal()
*/
-EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *
+ buf) EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
/**
* @brief Steal the contents of a string buffer.
@@ -425,7 +461,8 @@ EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL
*
* @see eina_strbuf_string_get()
*/
-EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI char *eina_strbuf_string_steal(Eina_Strbuf * buf)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* @brief Free the contents of a string buffer but not the buffer.
@@ -435,7 +472,7 @@ EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUS
* This function frees the string contained in @p buf without freeing
* @p buf.
*/
-EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_strbuf_string_free(Eina_Strbuf * buf) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve the length of the string buffer content.
@@ -445,9 +482,14 @@ EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
*
* This function returns the length of @p buf.
*/
-EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *
+ buf) EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf * buf, const char *str,
+ const char *with,
+ unsigned int n) EINA_ARG_NONNULL(1, 2,
+ 3);
/**
* @def eina_strbuf_replace_first(buf, str, with)
@@ -464,7 +506,9 @@ EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char
*/
#define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1)
-EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with) EINA_ARG_NONNULL(1, 2, 3);
+EAPI int eina_strbuf_replace_all(Eina_Strbuf * buf, const char *str,
+ const char *with) EINA_ARG_NONNULL(1, 2,
+ 3);
/**
* @}
@@ -474,4 +518,4 @@ EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *
* @}
*/
-#endif /* EINA_STRBUF_H */
+#endif /* EINA_STRBUF_H */
diff --git a/tests/suite/ecore/src/include/eina_stringshare.h b/tests/suite/ecore/src/include/eina_stringshare.h
index 4df5b40ab9..cc9f46cd6a 100644
--- a/tests/suite/ecore/src/include/eina_stringshare.h
+++ b/tests/suite/ecore/src/include/eina_stringshare.h
@@ -67,18 +67,32 @@
* @{
*/
-EAPI const char * eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
-EAPI const char * eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
-EAPI const char * eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
-EAPI const char * eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT;
-EAPI const char * eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
-EAPI const char * eina_stringshare_ref(const char *str);
-EAPI void eina_stringshare_del(const char *str);
-EAPI int eina_stringshare_strlen(const char *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI void eina_stringshare_dump(void);
+EAPI const char *eina_stringshare_add_length(const char *str,
+ unsigned int slen)
+ EINA_WARN_UNUSED_RESULT;
+EAPI const char *eina_stringshare_add(const char *str)
+ EINA_WARN_UNUSED_RESULT;
+EAPI const char *eina_stringshare_printf(const char *fmt, ...)
+EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
+EAPI const char *eina_stringshare_vprintf(const char *fmt,
+ va_list args)
+ EINA_WARN_UNUSED_RESULT;
+EAPI const char *eina_stringshare_nprintf(unsigned int len,
+ const char *fmt, ...)
+EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
+EAPI const char *eina_stringshare_ref(const char *str);
+EAPI void eina_stringshare_del(const char *str);
+EAPI int eina_stringshare_strlen(const char *str)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI void eina_stringshare_dump(void);
-static inline Eina_Bool eina_stringshare_replace(const char **p_str, const char *news) EINA_ARG_NONNULL(1);
-static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_stringshare_replace(const char **p_str,
+ const char *news)
+EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_stringshare_replace_length(const char **p_str,
+ const char *news,
+ unsigned int slen)
+EINA_ARG_NONNULL(1);
#include "eina_inline_stringshare.x"
@@ -90,4 +104,4 @@ static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, cons
* @}
*/
-#endif /* EINA_STRINGSHARE_H_ */
+#endif /* EINA_STRINGSHARE_H_ */
diff --git a/tests/suite/ecore/src/include/eina_tiler.h b/tests/suite/ecore/src/include/eina_tiler.h
index 19762a5cf8..b671b11d78 100644
--- a/tests/suite/ecore/src/include/eina_tiler.h
+++ b/tests/suite/ecore/src/include/eina_tiler.h
@@ -51,26 +51,40 @@ typedef struct Eina_Tile_Grid_Info Eina_Tile_Grid_Info;
* @struct Eina_Tile_Grid_Info
* Grid type of a tiler.
*/
-struct Eina_Tile_Grid_Info
-{
- unsigned long col; /**< column of the tiler grid */
- unsigned long row; /**< row of the tiler grid*/
- Eina_Rectangle rect; /**< rectangle of the tiler grid*/
- Eina_Bool full; /**< whether the grid is full or not */
+struct Eina_Tile_Grid_Info {
+ unsigned long col;
+ /**< column of the tiler grid */
+ unsigned long row;
+ /**< row of the tiler grid*/
+ Eina_Rectangle rect;
+ /**< rectangle of the tiler grid*/
+ Eina_Bool full;
+ /**< whether the grid is full or not */
};
typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer;
-EAPI Eina_Tiler * eina_tiler_new(int w, int h);
-EAPI void eina_tiler_free(Eina_Tiler *t);
-EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
-EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r);
-EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r);
-EAPI void eina_tiler_clear(Eina_Tiler *t);
-EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t);
-EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h);
-static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect);
-static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h);
+EAPI Eina_Tiler *eina_tiler_new(int w, int h);
+EAPI void eina_tiler_free(Eina_Tiler * t);
+EAPI void eina_tiler_tile_size_set(Eina_Tiler * t, int w, int h);
+EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler * t,
+ const Eina_Rectangle * r);
+EAPI void eina_tiler_rect_del(Eina_Tiler * t, const Eina_Rectangle * r);
+EAPI void eina_tiler_clear(Eina_Tiler * t);
+EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler * t);
+EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, int w,
+ int h, int tile_w,
+ int tile_h);
+static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *
+ slc,
+ const
+ Eina_Tile_Grid_Info **
+ rect);
+static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *
+ slc, int x, int y,
+ int w, int h,
+ int tile_w,
+ int tile_h);
#include "eina_inline_tiler.x"
@@ -83,4 +97,4 @@ static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc,
* @}
*/
-#endif /* EINA_TILER_H_ */
+#endif /* EINA_TILER_H_ */
diff --git a/tests/suite/ecore/src/include/eina_trash.h b/tests/suite/ecore/src/include/eina_trash.h
index 0d165f1931..c7088e4f8a 100644
--- a/tests/suite/ecore/src/include/eina_trash.h
+++ b/tests/suite/ecore/src/include/eina_trash.h
@@ -47,14 +47,18 @@ typedef struct _Eina_Trash Eina_Trash;
* @struct _Eina_Trash
* Type for a generic container of unused allocated pointer.
*/
-struct _Eina_Trash
-{
- Eina_Trash *next; /**< next item in trash. */
+struct _Eina_Trash {
+ Eina_Trash *next;
+ /**< next item in trash. */
};
-static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
-static inline void eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1);
-static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void eina_trash_init(Eina_Trash **
+ trash) EINA_ARG_NONNULL(1);
+static inline void eina_trash_push(Eina_Trash ** trash,
+ void *data) EINA_ARG_NONNULL(1);
+static inline void *eina_trash_pop(Eina_Trash **
+ trash) EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
/**
* @def EINA_TRASH_CLEAN
@@ -97,4 +101,4 @@ static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_
* @}
*/
-#endif /* EINA_TRASH_H_ */
+#endif /* EINA_TRASH_H_ */
diff --git a/tests/suite/ecore/src/include/eina_types.h b/tests/suite/ecore/src/include/eina_types.h
index c94983f618..bb20a23138 100644
--- a/tests/suite/ecore/src/include/eina_types.h
+++ b/tests/suite/ecore/src/include/eina_types.h
@@ -32,186 +32,186 @@
*/
#ifdef EAPI
-# undef EAPI
+#undef EAPI
#endif
#ifdef _WIN32
-# ifdef EFL_EINA_BUILD
-# ifdef DLL_EXPORT
-# define EAPI __declspec(dllexport)
-# else
-# define EAPI
-# endif /* ! DLL_EXPORT */
-# else
-# define EAPI __declspec(dllimport)
-# endif /* ! EFL_EINA_BUILD */
+#ifdef EFL_EINA_BUILD
+#ifdef DLL_EXPORT
+#define EAPI __declspec(dllexport)
#else
-# ifdef __GNUC__
-# if __GNUC__ >= 4
-# define EAPI __attribute__ ((visibility("default")))
-# else
-# define EAPI
-# endif
-# else
-# define EAPI
-# endif
+#define EAPI
+#endif /* ! DLL_EXPORT */
+#else
+#define EAPI __declspec(dllimport)
+#endif /* ! EFL_EINA_BUILD */
+#else
+#ifdef __GNUC__
+#if __GNUC__ >= 4
+#define EAPI __attribute__ ((visibility("default")))
+#else
+#define EAPI
+#endif
+#else
+#define EAPI
+#endif
#endif
#include "eina_config.h"
#ifdef EINA_WARN_UNUSED_RESULT
-# undef EINA_WARN_UNUSED_RESULT
+#undef EINA_WARN_UNUSED_RESULT
#endif
#ifdef EINA_ARG_NONNULL
-# undef EINA_ARG_NONNULL
+#undef EINA_ARG_NONNULL
#endif
#ifdef EINA_DEPRECATED
-# undef EINA_DEPRECATED
+#undef EINA_DEPRECATED
#endif
#ifdef EINA_MALLOC
-# undef EINA_MALLOC
+#undef EINA_MALLOC
#endif
#ifdef EINA_PURE
-# undef EINA_PURE
+#undef EINA_PURE
#endif
#ifdef EINA_PRINTF
-# undef EINA_PRINTF
+#undef EINA_PRINTF
#endif
#ifdef EINA_SCANF
-# undef EINA_SCANF
+#undef EINA_SCANF
#endif
#ifdef EINA_FORMAT
-# undef EINA_FORMAT
+#undef EINA_FORMAT
#endif
#ifdef EINA_CONST
-# undef EINA_CONST
+#undef EINA_CONST
#endif
#ifdef EINA_NOINSTRUMENT
-# undef EINA_NOINSTRUMENT
+#undef EINA_NOINSTRUMENT
#endif
#ifdef EINA_UNLIKELY
-# undef EINA_UNLIKELY
+#undef EINA_UNLIKELY
#endif
#ifdef EINA_LIKELY
-# undef EINA_LIKELY
+#undef EINA_LIKELY
#endif
#ifdef __GNUC__
-# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-# define EINA_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
-# else
-# define EINA_WARN_UNUSED_RESULT
-# endif
-
-# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
-# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((nonnull(idx, ## __VA_ARGS__)))
-# else
-# define EINA_ARG_NONNULL(idx, ...)
-# endif
-
-# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-# define EINA_DEPRECATED __attribute__ ((__deprecated__))
-# else
-# define EINA_DEPRECATED
-# endif
-
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-# define EINA_MALLOC __attribute__ ((malloc))
-# define EINA_PURE __attribute__ ((pure))
-# else
-# define EINA_MALLOC
-# define EINA_PURE
-# endif
-
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-# define EINA_PRINTF(fmt, arg) __attribute__((format (printf, fmt, arg)))
-# define EINA_SCANF(fmt, arg) __attribute__((format (scanf, fmt, arg)))
-# define EINA_FORMAT(fmt) __attribute__((format_arg(fmt)))
-# define EINA_CONST __attribute__((const))
-# define EINA_NOINSTRUMENT __attribute__((no_instrument_function))
-# define EINA_UNLIKELY(exp) __builtin_expect((exp), 0)
-# define EINA_LIKELY(exp) __builtin_expect((exp), 1)
-# else
-# define EINA_PRINTF(fmt, arg)
-# define EINA_SCANF(fmt, arg)
-# define EINA_FORMAT(fmt)
-# define EINA_CONST
-# define EINA_NOINSTRUMENT
-# define EINA_UNLIKELY(exp) exp
-# define EINA_LIKELY(exp) exp
-# endif
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#define EINA_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
+#else
+#define EINA_WARN_UNUSED_RESULT
+#endif
+
+#if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+#define EINA_ARG_NONNULL(idx, ...) __attribute__ ((nonnull(idx, ## __VA_ARGS__)))
+#else
+#define EINA_ARG_NONNULL(idx, ...)
+#endif
+
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#define EINA_DEPRECATED __attribute__ ((__deprecated__))
+#else
+#define EINA_DEPRECATED
+#endif
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+#define EINA_MALLOC __attribute__ ((malloc))
+#define EINA_PURE __attribute__ ((pure))
+#else
+#define EINA_MALLOC
+#define EINA_PURE
+#endif
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define EINA_PRINTF(fmt, arg) __attribute__((format (printf, fmt, arg)))
+#define EINA_SCANF(fmt, arg) __attribute__((format (scanf, fmt, arg)))
+#define EINA_FORMAT(fmt) __attribute__((format_arg(fmt)))
+#define EINA_CONST __attribute__((const))
+#define EINA_NOINSTRUMENT __attribute__((no_instrument_function))
+#define EINA_UNLIKELY(exp) __builtin_expect((exp), 0)
+#define EINA_LIKELY(exp) __builtin_expect((exp), 1)
+#else
+#define EINA_PRINTF(fmt, arg)
+#define EINA_SCANF(fmt, arg)
+#define EINA_FORMAT(fmt)
+#define EINA_CONST
+#define EINA_NOINSTRUMENT
+#define EINA_UNLIKELY(exp) exp
+#define EINA_LIKELY(exp) exp
+#endif
#elif defined(_WIN32)
-# define EINA_WARN_UNUSED_RESULT
-# define EINA_ARG_NONNULL(idx, ...)
-# if defined(_MSC_VER) && _MSC_VER >= 1300
-# define EINA_DEPRECATED __declspec(deprecated)
-# else
-# define EINA_DEPRECATED
-# endif
-# define EINA_MALLOC
-# define EINA_PURE
-# define EINA_PRINTF(fmt, arg)
-# define EINA_SCANF(fmt, arg)
-# define EINA_FORMAT(fmt)
-# define EINA_CONST
-# define EINA_NOINSTRUMENT
-# define EINA_UNLIKELY(exp) exp
-# define EINA_LIKELY(exp) exp
+#define EINA_WARN_UNUSED_RESULT
+#define EINA_ARG_NONNULL(idx, ...)
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+#define EINA_DEPRECATED __declspec(deprecated)
+#else
+#define EINA_DEPRECATED
+#endif
+#define EINA_MALLOC
+#define EINA_PURE
+#define EINA_PRINTF(fmt, arg)
+#define EINA_SCANF(fmt, arg)
+#define EINA_FORMAT(fmt)
+#define EINA_CONST
+#define EINA_NOINSTRUMENT
+#define EINA_UNLIKELY(exp) exp
+#define EINA_LIKELY(exp) exp
#elif defined(__SUNPRO_C)
-# define EINA_WARN_UNUSED_RESULT
-# define EINA_ARG_NONNULL(...)
-# define EINA_DEPRECATED
-# if __SUNPRO_C >= 0x590
-# define EINA_MALLOC __attribute__ ((malloc))
-# define EINA_PURE __attribute__ ((pure))
-# else
-# define EINA_MALLOC
-# define EINA_PURE
-# endif
-# define EINA_PRINTF(fmt, arg)
-# define EINA_SCANF(fmt, arg)
-# define EINA_FORMAT(fmt)
-# if __SUNPRO_C >= 0x590
-# define EINA_CONST __attribute__ ((const))
-# else
-# define EINA_CONST
-# endif
-# define EINA_NOINSTRUMENT
-# define EINA_UNLIKELY(exp) exp
-# define EINA_LIKELY(exp) exp
-
-#else /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
+#define EINA_WARN_UNUSED_RESULT
+#define EINA_ARG_NONNULL(...)
+#define EINA_DEPRECATED
+#if __SUNPRO_C >= 0x590
+#define EINA_MALLOC __attribute__ ((malloc))
+#define EINA_PURE __attribute__ ((pure))
+#else
+#define EINA_MALLOC
+#define EINA_PURE
+#endif
+#define EINA_PRINTF(fmt, arg)
+#define EINA_SCANF(fmt, arg)
+#define EINA_FORMAT(fmt)
+#if __SUNPRO_C >= 0x590
+#define EINA_CONST __attribute__ ((const))
+#else
+#define EINA_CONST
+#endif
+#define EINA_NOINSTRUMENT
+#define EINA_UNLIKELY(exp) exp
+#define EINA_LIKELY(exp) exp
+
+#else /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
/**
* @def EINA_WARN_UNUSED_RESULT
* Used to warn when the returned value of the function is not used.
*/
-# define EINA_WARN_UNUSED_RESULT
+#define EINA_WARN_UNUSED_RESULT
/**
* @def EINA_ARG_NONNULL
* Used to warn when the specified arguments of the function are @c NULL.
*/
-# define EINA_ARG_NONNULL(idx, ...)
+#define EINA_ARG_NONNULL(idx, ...)
/**
* @def EINA_DEPRECATED
* Used to warn when the function is considered as deprecated.
*/
-# define EINA_DEPRECATED
-# define EINA_MALLOC
-# define EINA_PURE
-# define EINA_PRINTF(fmt, arg)
-# define EINA_SCANF(fmt, arg)
-# define EINA_FORMAT(fmt)
-# define EINA_CONST
-# define EINA_NOINSTRUMENT
-# define EINA_UNLIKELY(exp) exp
-# define EINA_LIKELY(exp) exp
-#endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
+#define EINA_DEPRECATED
+#define EINA_MALLOC
+#define EINA_PURE
+#define EINA_PRINTF(fmt, arg)
+#define EINA_SCANF(fmt, arg)
+#define EINA_FORMAT(fmt)
+#define EINA_CONST
+#define EINA_NOINSTRUMENT
+#define EINA_UNLIKELY(exp) exp
+#define EINA_LIKELY(exp) exp
+#endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
/**
@@ -245,7 +245,7 @@ EAPI extern const unsigned int eina_prime_table[];
* if it is 'greater', 1 must be returned, and if they are equal, 0
* must be returned.
*/
-typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2);
+typedef int (*Eina_Compare_Cb) (const void *data1, const void *data2);
/**
* @def EINA_COMPARE_CB
@@ -253,7 +253,8 @@ typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2);
*/
#define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function)
-typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata);
+typedef Eina_Bool(*Eina_Each_Cb) (const void *container, void *data,
+ void *fdata);
/**
* @def EINA_EACH_CB
@@ -265,7 +266,7 @@ typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata
* @typedef Eina_Free_Cb
* A callback type used to free data when iterating over a container.
*/
-typedef void (*Eina_Free_Cb)(void *data);
+typedef void (*Eina_Free_Cb) (void *data);
/**
* @def EINA_FREE_CB
@@ -281,4 +282,4 @@ typedef void (*Eina_Free_Cb)(void *data);
* @}
*/
-#endif /* EINA_TYPES_H_ */
+#endif /* EINA_TYPES_H_ */
diff --git a/tests/suite/ecore/src/include/eina_unicode.h b/tests/suite/ecore/src/include/eina_unicode.h
index 06a2af1752..4cd362fcb5 100644
--- a/tests/suite/ecore/src/include/eina_unicode.h
+++ b/tests/suite/ecore/src/include/eina_unicode.h
@@ -26,13 +26,13 @@
* A type that holds Unicode codepoints.
*/
#if EINA_SIZEOF_WCHAR_T >= 4
-# include <wchar.h>
+#include <wchar.h>
typedef wchar_t Eina_Unicode;
#elif defined(EINA_HAVE_INTTYPES_H)
-# include <inttypes.h>
+#include <inttypes.h>
typedef uint32_t Eina_Unicode;
#elif defined(EINA_HAVE_STDINT_H)
-# include <stdint.h>
+#include <stdint.h>
typedef uint32_t Eina_Unicode;
#else
/* Hope that int is big enough */
@@ -41,21 +41,36 @@ typedef unsigned int Eina_Unicode;
EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING;
-EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
-EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
+EAPI size_t eina_unicode_strlen(const Eina_Unicode *
+ ustr) EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT EINA_PURE;
+EAPI size_t eina_unicode_strnlen(const Eina_Unicode * ustr,
+ int n) EINA_ARG_NONNULL(1)
+EINA_WARN_UNUSED_RESULT EINA_PURE;
-EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode * text)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
-EAPI int eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
+EAPI int eina_unicode_strcmp(const Eina_Unicode * a,
+ const Eina_Unicode * b)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
-EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode * dest,
+ const Eina_Unicode *
+ source) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
+EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode * haystack,
+ const Eina_Unicode * needle)
+EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
-EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode * dest,
+ const Eina_Unicode * source,
+ size_t n) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *
+ str) EINA_ARG_NONNULL(1)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @}
diff --git a/tests/suite/ecore/src/include/eina_ustrbuf.h b/tests/suite/ecore/src/include/eina_ustrbuf.h
index e042b5df9d..5a24ccda67 100644
--- a/tests/suite/ecore/src/include/eina_ustrbuf.h
+++ b/tests/suite/ecore/src/include/eina_ustrbuf.h
@@ -37,7 +37,8 @@ typedef struct _Eina_Strbuf Eina_UStrbuf;
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_string_get()
*/
-EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_UStrbuf *eina_ustrbuf_new(void)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Free a string buffer.
@@ -47,7 +48,7 @@ EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
* This function frees the memory of @p buf. @p buf must have been
* created by eina_ustrbuf_new().
*/
-EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_ustrbuf_free(Eina_UStrbuf * buf) EINA_ARG_NONNULL(1);
/**
* @brief Reset a string buffer.
@@ -57,7 +58,7 @@ EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
* This function reset @p buf: the buffer len is set to 0, and the
* string is set to '\\0'. No memory is free'd.
*/
-EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_ustrbuf_reset(Eina_UStrbuf * buf) EINA_ARG_NONNULL(1);
/**
* @brief Append a string to a buffer, reallocating as necessary.
@@ -75,7 +76,9 @@ EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_append_length()
*/
-EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf * buf,
+ const Eina_Unicode *
+ str) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append an escaped string to a buffer, reallocating as necessary.
@@ -88,7 +91,9 @@ EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *st
* str can not be appended, #EINA_FALSE is returned, otherwise,
* #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf * buf,
+ const Eina_Unicode *
+ str) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a string to a buffer, reallocating as necessary,
@@ -111,7 +116,9 @@ EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Uni
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_append_length()
*/
-EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf * buf,
+ const Eina_Unicode * str,
+ size_t maxlen) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a string of exact length to a buffer, reallocating as necessary.
@@ -132,7 +139,10 @@ EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *
* @see eina_ustrbuf_append()
* @see eina_ustrbuf_append_n()
*/
-EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf * buf,
+ const Eina_Unicode * str,
+ size_t length)
+EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a character to a string buffer, reallocating as
@@ -145,7 +155,9 @@ EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unic
* This function inserts @p c to @p buf. If it can not insert it,
* #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf * buf,
+ Eina_Unicode c)
+EINA_ARG_NONNULL(1);
/**
* @brief Insert a string to a buffer, reallocating as necessary.
@@ -161,7 +173,9 @@ EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) E
* consider using that variant. If @p buf can't insert it, #EINA_FALSE
* is returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf * buf,
+ const Eina_Unicode * str,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert an escaped string to a buffer, reallocating as
@@ -176,7 +190,10 @@ EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *st
* position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
* returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf * buf,
+ const Eina_Unicode * str,
+ size_t pos) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
@@ -196,7 +213,10 @@ EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Uni
* @p str). If @p str can not be inserted, #EINA_FALSE is returned,
* otherwise, #EINA_TRUE is returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf * buf,
+ const Eina_Unicode * str,
+ size_t maxlen,
+ size_t pos) EINA_ARG_NONNULL(1, 2);
/**
* @brief Insert a string of exact length to a buffer, reallocating as necessary.
@@ -218,7 +238,11 @@ EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *
* @see eina_ustrbuf_insert()
* @see eina_ustrbuf_insert_n()
*/
-EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf * buf,
+ const Eina_Unicode * str,
+ size_t length,
+ size_t pos) EINA_ARG_NONNULL(1,
+ 2);
/**
* @brief Insert a character to a string buffer, reallocating as
@@ -233,7 +257,8 @@ EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unic
* can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
* returned.
*/
-EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_t pos) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf * buf, Eina_Unicode c,
+ size_t pos) EINA_ARG_NONNULL(1);
/**
* @def eina_ustrbuf_prepend(buf, str)
@@ -351,7 +376,8 @@ EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, s
* in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool
-eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
+eina_ustrbuf_remove(Eina_UStrbuf * buf, size_t start,
+ size_t end) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve a pointer to the contents of a string buffer
@@ -366,8 +392,9 @@ eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNUL
*
* @see eina_ustrbuf_string_steal()
*/
-EAPI const Eina_Unicode *
-eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI const Eina_Unicode *eina_ustrbuf_string_get(const Eina_UStrbuf *
+ buf) EINA_ARG_NONNULL(1)
+ EINA_WARN_UNUSED_RESULT;
/**
* @brief Steal the contents of a string buffer.
@@ -382,8 +409,8 @@ eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_U
*
* @see eina_ustrbuf_string_get()
*/
-EAPI Eina_Unicode *
-eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Unicode *eina_ustrbuf_string_steal(Eina_UStrbuf * buf)
+EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
* @brief Free the contents of a string buffer but not the buffer.
@@ -393,8 +420,7 @@ eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT
* This function frees the string contained in @p buf without freeing
* @p buf.
*/
-EAPI void
-eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+EAPI void eina_ustrbuf_string_free(Eina_UStrbuf * buf) EINA_ARG_NONNULL(1);
/**
* @brief Retrieve the length of the string buffer content.
@@ -405,7 +431,8 @@ eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
* This function returns the length of @p buf.
*/
EAPI size_t
-eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+eina_ustrbuf_length_get(const Eina_UStrbuf *
+ buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @}
@@ -415,4 +442,4 @@ eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_U
* @}
*/
-#endif /* EINA_STRBUF_H */
+#endif /* EINA_STRBUF_H */
diff --git a/tests/suite/ecore/src/include/eina_ustringshare.h b/tests/suite/ecore/src/include/eina_ustringshare.h
index ac8c8896e2..2db5aa9002 100644
--- a/tests/suite/ecore/src/include/eina_ustringshare.h
+++ b/tests/suite/ecore/src/include/eina_ustringshare.h
@@ -66,15 +66,30 @@
* @{
*/
-EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
-EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EINA_WARN_UNUSED_RESULT;
-EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str);
-EAPI void eina_ustringshare_del(const Eina_Unicode *str);
-EAPI int eina_ustringshare_strlen(const Eina_Unicode *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI void eina_ustringshare_dump(void);
+EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *
+ str,
+ unsigned int slen)
+ EINA_WARN_UNUSED_RESULT;
+EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *
+ str)
+ EINA_WARN_UNUSED_RESULT;
+EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode * str);
+EAPI void eina_ustringshare_del(const Eina_Unicode * str);
+EAPI int eina_ustringshare_strlen(const Eina_Unicode * str)
+EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI void eina_ustringshare_dump(void);
-static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) EINA_ARG_NONNULL(1);
-static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **
+ p_str,
+ const Eina_Unicode *
+ news)
+EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicode
+ ** p_str,
+ const Eina_Unicode
+ * news,
+ unsigned int slen)
+EINA_ARG_NONNULL(1);
#include "eina_inline_ustringshare.x"
@@ -86,4 +101,4 @@ static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicode **p
* @}
*/
-#endif /* EINA_STRINGSHARE_H_ */
+#endif /* EINA_STRINGSHARE_H_ */
diff --git a/tests/suite/ecore/src/lib/Ecore.h b/tests/suite/ecore/src/lib/Ecore.h
index c3347e8a63..2c939a688b 100644
--- a/tests/suite/ecore/src/lib/Ecore.h
+++ b/tests/suite/ecore/src/lib/Ecore.h
@@ -2,36 +2,36 @@
#define _ECORE_H
#ifdef _MSC_VER
-# include <Evil.h>
+#include <Evil.h>
#endif
#include <Eina.h>
#ifdef EAPI
-# undef EAPI
+#undef EAPI
#endif
#ifdef _WIN32
-# ifdef EFL_ECORE_BUILD
-# ifdef DLL_EXPORT
-# define EAPI __declspec(dllexport)
-# else
-# define EAPI
-# endif /* ! DLL_EXPORT */
-# else
-# define EAPI __declspec(dllimport)
-# endif /* ! EFL_ECORE_BUILD */
+#ifdef EFL_ECORE_BUILD
+#ifdef DLL_EXPORT
+#define EAPI __declspec(dllexport)
#else
-# ifdef __GNUC__
-# if __GNUC__ >= 4
-# define EAPI __attribute__ ((visibility("default")))
-# else
-# define EAPI
-# endif
-# else
-# define EAPI
-# endif
-#endif /* ! _WIN32 */
+#define EAPI
+#endif /* ! DLL_EXPORT */
+#else
+#define EAPI __declspec(dllimport)
+#endif /* ! EFL_ECORE_BUILD */
+#else
+#ifdef __GNUC__
+#if __GNUC__ >= 4
+#define EAPI __attribute__ ((visibility("default")))
+#else
+#define EAPI
+#endif
+#else
+#define EAPI
+#endif
+#endif /* ! _WIN32 */
/**
* @file Ecore.h
@@ -56,12 +56,12 @@
*/
#ifdef _WIN32
-# include <winsock2.h>
+#include <winsock2.h>
#else
-# include <sys/select.h>
-# include <signal.h>
+#include <sys/select.h>
+#include <signal.h>
#endif
-
+
#include <sys/types.h>
#ifdef __cplusplus
@@ -71,18 +71,17 @@ extern "C" {
#define ECORE_VERSION_MAJOR 1
#define ECORE_VERSION_MINOR 0
- typedef struct _Ecore_Version
- {
- int major;
- int minor;
- int micro;
- int revision;
- } Ecore_Version;
-
- EAPI extern Ecore_Version *ecore_version;
+ typedef struct _Ecore_Version {
+ int major;
+ int minor;
+ int micro;
+ int revision;
+ } Ecore_Version;
+
+ EAPI extern Ecore_Version *ecore_version;
#define ECORE_CALLBACK_CANCEL EINA_FALSE /**< Return value to remove a callback */
-#define ECORE_CALLBACK_RENEW EINA_TRUE /**< Return value to keep a callback */
+#define ECORE_CALLBACK_RENEW EINA_TRUE /**< Return value to keep a callback */
#define ECORE_CALLBACK_PASS_ON EINA_TRUE /**< Return value to pass event to next handler */
#define ECORE_CALLBACK_DONE EINA_FALSE /**< Return value to stop event handling */
@@ -96,384 +95,525 @@ extern "C" {
#define ECORE_EVENT_COUNT 6
#define ECORE_EXE_PRIORITY_INHERIT 9999
-
- EAPI extern int ECORE_EXE_EVENT_ADD; /**< A child process has been added */
- EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistent with the rest of ecore). */
- EAPI extern int ECORE_EXE_EVENT_DATA; /**< Data from a child process. */
- EAPI extern int ECORE_EXE_EVENT_ERROR; /**< Errors from a child process. */
-
- enum _Ecore_Fd_Handler_Flags
- {
- ECORE_FD_READ = 1, /**< Fd Read mask */
- ECORE_FD_WRITE = 2, /**< Fd Write mask */
- ECORE_FD_ERROR = 4 /**< Fd Error mask */
- };
- typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
-
- enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */
- {
- ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */
- ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */
- ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */
- ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */
- ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */
- ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */
- ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */
- ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */
- ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */
- };
- typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags;
-
- enum _Ecore_Exe_Win32_Priority
- {
- ECORE_EXE_WIN32_PRIORITY_IDLE, /**< Idle priority, for monitoring the system */
- ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL, /**< Below default priority */
- ECORE_EXE_WIN32_PRIORITY_NORMAL, /**< Default priority */
- ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL, /**< Above default priority */
- ECORE_EXE_WIN32_PRIORITY_HIGH, /**< High priority, use with care as other threads in the system will not get processor time */
- ECORE_EXE_WIN32_PRIORITY_REALTIME /**< Realtime priority, should be almost never used as it can interrupt system threads that manage mouse input, keyboard input, and background disk flushing */
- };
- typedef enum _Ecore_Exe_Win32_Priority Ecore_Exe_Win32_Priority;
-
- enum _Ecore_Poller_Type /* Poller types */
- {
- ECORE_POLLER_CORE = 0 /**< The core poller interval */
- };
- typedef enum _Ecore_Poller_Type Ecore_Poller_Type;
-
- typedef struct _Ecore_Exe Ecore_Exe; /**< A handle for spawned processes */
- typedef struct _Ecore_Timer Ecore_Timer; /**< A handle for timers */
- typedef struct _Ecore_Idler Ecore_Idler; /**< A handle for idlers */
- typedef struct _Ecore_Idle_Enterer Ecore_Idle_Enterer; /**< A handle for idle enterers */
- typedef struct _Ecore_Idle_Exiter Ecore_Idle_Exiter; /**< A handle for idle exiters */
- typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler; /**< A handle for Fd handlers */
- typedef struct _Ecore_Win32_Handler Ecore_Win32_Handler; /**< A handle for HANDLE handlers on Windows */
- typedef struct _Ecore_Event_Handler Ecore_Event_Handler; /**< A handle for an event handler */
- typedef struct _Ecore_Event_Filter Ecore_Event_Filter; /**< A handle for an event filter */
- typedef struct _Ecore_Event Ecore_Event; /**< A handle for an event */
- typedef struct _Ecore_Animator Ecore_Animator; /**< A handle for animators */
- typedef struct _Ecore_Pipe Ecore_Pipe; /**< A handle for pipes */
- typedef struct _Ecore_Poller Ecore_Poller; /**< A handle for pollers */
- typedef struct _Ecore_Event_Signal_User Ecore_Event_Signal_User; /**< User signal event */
- typedef struct _Ecore_Event_Signal_Hup Ecore_Event_Signal_Hup; /**< Hup signal event */
- typedef struct _Ecore_Event_Signal_Exit Ecore_Event_Signal_Exit; /**< Exit signal event */
- typedef struct _Ecore_Event_Signal_Power Ecore_Event_Signal_Power; /**< Power signal event */
- typedef struct _Ecore_Event_Signal_Realtime Ecore_Event_Signal_Realtime; /**< Realtime signal event */
- typedef struct _Ecore_Exe_Event_Add Ecore_Exe_Event_Add; /**< Spawned Exe add event */
- typedef struct _Ecore_Exe_Event_Del Ecore_Exe_Event_Del; /**< Spawned Exe exit event */
- typedef struct _Ecore_Exe_Event_Data_Line Ecore_Exe_Event_Data_Line; /**< Lines from a child process */
- typedef struct _Ecore_Exe_Event_Data Ecore_Exe_Event_Data; /**< Data from a child process */
- typedef struct _Ecore_Thread Ecore_Thread;
+
+ EAPI extern int ECORE_EXE_EVENT_ADD;
+ /**< A child process has been added */
+ EAPI extern int ECORE_EXE_EVENT_DEL;
+ /**< A child process has been deleted (it exited, naming consistent with the rest of ecore). */
+ EAPI extern int ECORE_EXE_EVENT_DATA;
+ /**< Data from a child process. */
+ EAPI extern int ECORE_EXE_EVENT_ERROR;
+ /**< Errors from a child process. */
+
+ enum _Ecore_Fd_Handler_Flags {
+ ECORE_FD_READ = 1,
+ /**< Fd Read mask */
+ ECORE_FD_WRITE = 2,
+ /**< Fd Write mask */
+ ECORE_FD_ERROR = 4
+ /**< Fd Error mask */
+ };
+ typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
+
+ enum _Ecore_Exe_Flags { /* flags for executing a child with its stdin and/or stdout piped back */
+ ECORE_EXE_PIPE_READ = 1,
+ /**< Exe Pipe Read mask */
+ ECORE_EXE_PIPE_WRITE = 2,
+ /**< Exe Pipe Write mask */
+ ECORE_EXE_PIPE_ERROR = 4,
+ /**< Exe Pipe error mask */
+ ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8,
+ /**< Reads are buffered until a newline and delivered 1 event per line */
+ ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16,
+ /**< Errors are buffered until a newline and delivered 1 event per line */
+ ECORE_EXE_PIPE_AUTO = 32,
+ /**< stdout and stderr are buffered automatically */
+ ECORE_EXE_RESPAWN = 64,
+ /**< FIXME: Exe is restarted if it dies */
+ ECORE_EXE_USE_SH = 128,
+ /**< Use /bin/sh to run the command. */
+ ECORE_EXE_NOT_LEADER = 256
+ /**< Do not use setsid() to have the executed process be its own session leader */
+ };
+ typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags;
+
+ enum _Ecore_Exe_Win32_Priority {
+ ECORE_EXE_WIN32_PRIORITY_IDLE,
+ /**< Idle priority, for monitoring the system */
+ ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL,
+ /**< Below default priority */
+ ECORE_EXE_WIN32_PRIORITY_NORMAL,
+ /**< Default priority */
+ ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL,
+ /**< Above default priority */
+ ECORE_EXE_WIN32_PRIORITY_HIGH,
+ /**< High priority, use with care as other threads in the system will not get processor time */
+ ECORE_EXE_WIN32_PRIORITY_REALTIME
+ /**< Realtime priority, should be almost never used as it can interrupt system threads that manage mouse input, keyboard input, and background disk flushing */
+ };
+ typedef enum _Ecore_Exe_Win32_Priority Ecore_Exe_Win32_Priority;
+
+ enum _Ecore_Poller_Type { /* Poller types */
+ ECORE_POLLER_CORE = 0
+ /**< The core poller interval */
+ };
+ typedef enum _Ecore_Poller_Type Ecore_Poller_Type;
+
+ typedef struct _Ecore_Exe Ecore_Exe; /**< A handle for spawned processes */
+ typedef struct _Ecore_Timer Ecore_Timer; /**< A handle for timers */
+ typedef struct _Ecore_Idler Ecore_Idler; /**< A handle for idlers */
+ typedef struct _Ecore_Idle_Enterer Ecore_Idle_Enterer; /**< A handle for idle enterers */
+ typedef struct _Ecore_Idle_Exiter Ecore_Idle_Exiter; /**< A handle for idle exiters */
+ typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler; /**< A handle for Fd handlers */
+ typedef struct _Ecore_Win32_Handler Ecore_Win32_Handler; /**< A handle for HANDLE handlers on Windows */
+ typedef struct _Ecore_Event_Handler Ecore_Event_Handler; /**< A handle for an event handler */
+ typedef struct _Ecore_Event_Filter Ecore_Event_Filter; /**< A handle for an event filter */
+ typedef struct _Ecore_Event Ecore_Event; /**< A handle for an event */
+ typedef struct _Ecore_Animator Ecore_Animator; /**< A handle for animators */
+ typedef struct _Ecore_Pipe Ecore_Pipe; /**< A handle for pipes */
+ typedef struct _Ecore_Poller Ecore_Poller; /**< A handle for pollers */
+ typedef struct _Ecore_Event_Signal_User Ecore_Event_Signal_User;/**< User signal event */
+ typedef struct _Ecore_Event_Signal_Hup Ecore_Event_Signal_Hup; /**< Hup signal event */
+ typedef struct _Ecore_Event_Signal_Exit Ecore_Event_Signal_Exit;/**< Exit signal event */
+ typedef struct _Ecore_Event_Signal_Power Ecore_Event_Signal_Power;
+ /**< Power signal event */
+ typedef struct _Ecore_Event_Signal_Realtime Ecore_Event_Signal_Realtime;
+ /**< Realtime signal event */
+ typedef struct _Ecore_Exe_Event_Add Ecore_Exe_Event_Add; /**< Spawned Exe add event */
+ typedef struct _Ecore_Exe_Event_Del Ecore_Exe_Event_Del; /**< Spawned Exe exit event */
+ typedef struct _Ecore_Exe_Event_Data_Line Ecore_Exe_Event_Data_Line;
+ /**< Lines from a child process */
+ typedef struct _Ecore_Exe_Event_Data Ecore_Exe_Event_Data; /**< Data from a child process */
+ typedef struct _Ecore_Thread Ecore_Thread;
/**
* @typedef Ecore_Data_Cb Ecore_Data_Cb
* A callback which is used to return data to the main function
*/
- typedef void *(*Ecore_Data_Cb) (void *data);
+ typedef void *(*Ecore_Data_Cb) (void *data);
/**
* @typedef Ecore_Filter_Cb
* A callback used for filtering events from the main loop.
*/
- typedef Eina_Bool (*Ecore_Filter_Cb) (void *data, void *loop_data, int type, void *event);
+ typedef Eina_Bool(*Ecore_Filter_Cb) (void *data, void *loop_data,
+ int type, void *event);
/**
* @typedef Ecore_Eselect_Function Ecore_Eselect_Function
* A function which can be used to replace select() in the main loop
*/
- typedef int (*Ecore_Select_Function)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+ typedef int (*Ecore_Select_Function) (int nfds, fd_set * readfds,
+ fd_set * writefds,
+ fd_set * exceptfds,
+ struct timeval * timeout);
/**
* @typedef Ecore_End_Cb Ecore_End_Cb
* This is the callback which is called at the end of a function, usually for cleanup purposes.
*/
- typedef void (*Ecore_End_Cb) (void *user_data, void *func_data);
+ typedef void (*Ecore_End_Cb) (void *user_data, void *func_data);
/**
* @typedef Ecore_Pipe_Cb Ecore_Pipe_Cb
* The callback that data written to the pipe is sent to.
*/
- typedef void (*Ecore_Pipe_Cb) (void *data, void *buffer, unsigned int nbyte);
+ typedef void (*Ecore_Pipe_Cb) (void *data, void *buffer,
+ unsigned int nbyte);
/**
* @typedef Ecore_Exe_Cb Ecore_Exe_Cb
* A callback to run with the associated @ref Ecore_Exe, usually for cleanup purposes.
*/
- typedef void (*Ecore_Exe_Cb)(void *data, const Ecore_Exe *exe);
+ typedef void (*Ecore_Exe_Cb) (void *data, const Ecore_Exe * exe);
/**
* @typedef Ecore_Event_Handler_Cb Ecore_Event_Handler_Cb
* A callback used by the main loop to handle events of a specified type.
*/
- typedef Eina_Bool (*Ecore_Event_Handler_Cb) (void *data, int type, void *event);
+ typedef Eina_Bool(*Ecore_Event_Handler_Cb) (void *data, int type,
+ void *event);
/**
* @typedef Ecore_Thread_Heavy_Cb Ecore_Thread_Heavy_Cb
* A callback used to run cpu intensive or blocking I/O operations.
*/
- typedef void (*Ecore_Thread_Heavy_Cb) (Ecore_Thread *thread, void *data);
+ typedef void (*Ecore_Thread_Heavy_Cb) (Ecore_Thread * thread,
+ void *data);
/**
* @typedef Ecore_Thread_Notify_Cb Ecore_Thread_Notify_Cb
* A callback used by the main loop to receive data sent by an @ref Ecore_Thread.
*/
- typedef void (*Ecore_Thread_Notify_Cb) (Ecore_Thread *thread, void *msg_data, void *data);
+ typedef void (*Ecore_Thread_Notify_Cb) (Ecore_Thread * thread,
+ void *msg_data,
+ void *data);
/**
* @typedef Ecore_Task_Cb Ecore_Task_Cb
* A callback run for a task (timer, idler, poller, animater, etc)
*/
- typedef Eina_Bool (*Ecore_Task_Cb) (void *data);
+ typedef Eina_Bool(*Ecore_Task_Cb) (void *data);
/**
* @typedef Ecore_Cb Ecore_Cb
* A generic callback called as a hook when a certain point in execution is reached.
*/
- typedef void (*Ecore_Cb) (void *data);
+ typedef void (*Ecore_Cb) (void *data);
/**
* @typedef Ecore_Fd_Cb Ecore_Fd_Cb
* A callback used by an @ref Ecore_Fd_Handler.
*/
- typedef Eina_Bool (*Ecore_Fd_Cb) (void *data, Ecore_Fd_Handler *fd_handler);
+ typedef Eina_Bool(*Ecore_Fd_Cb) (void *data,
+ Ecore_Fd_Handler * fd_handler);
/**
* @typedef Ecore_Fd_Prep_Cb Ecore_Fd_Prep_Cb
* A callback used by an @ref Ecore_Fd_Handler.
*/
- typedef void (*Ecore_Fd_Prep_Cb) (void *data, Ecore_Fd_Handler *fd_handler);
+ typedef void (*Ecore_Fd_Prep_Cb) (void *data,
+ Ecore_Fd_Handler * fd_handler);
/**
* @typedef Ecore_Fd_Win32_Cb Ecore_Fd_Win32_Cb
* A callback used by an @ref Ecore_Win32_Handler.
*/
- typedef Eina_Bool (*Ecore_Fd_Win32_Cb) (void *data, Ecore_Win32_Handler *wh);
+ typedef Eina_Bool(*Ecore_Fd_Win32_Cb) (void *data,
+ Ecore_Win32_Handler * wh);
- typedef struct _Ecore_Job Ecore_Job; /**< A job handle */
+ typedef struct _Ecore_Job Ecore_Job;
+ /**< A job handle */
- struct _Ecore_Event_Signal_User /** User signal event */
- {
- int number; /**< The signal number. Either 1 or 2 */
- void *ext_data; /**< Extension data - not used */
+ struct _Ecore_Event_Signal_User {
+/** User signal event */
+ int number;
+ /**< The signal number. Either 1 or 2 */
+ void *ext_data;
+ /**< Extension data - not used */
#ifndef _WIN32
- siginfo_t data; /**< Signal info */
+ siginfo_t data;
+ /**< Signal info */
#endif
- };
+ };
- struct _Ecore_Event_Signal_Hup /** Hup signal event */
- {
- void *ext_data; /**< Extension data - not used */
+ struct _Ecore_Event_Signal_Hup {
+/** Hup signal event */
+ void *ext_data;
+ /**< Extension data - not used */
#ifndef _WIN32
- siginfo_t data; /**< Signal info */
+ siginfo_t data;
+ /**< Signal info */
#endif
- };
+ };
- struct _Ecore_Event_Signal_Exit /** Exit request event */
- {
- unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/
- unsigned int quit : 1; /**< set if the exit request was a quit signal */
- unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */
- void *ext_data; /**< Extension data - not used */
+ struct _Ecore_Event_Signal_Exit {
+/** Exit request event */
+ unsigned int interrupt:1;
+ /**< Set if the exit request was an interrupt signal*/
+ unsigned int quit:1; /**< set if the exit request was a quit signal */
+ unsigned int terminate:1;
+ /**< Set if the exit request was a terminate singal */
+ void *ext_data; /**< Extension data - not used */
#ifndef _WIN32
- siginfo_t data; /**< Signal info */
+ siginfo_t data;
+ /**< Signal info */
#endif
- };
+ };
- struct _Ecore_Event_Signal_Power /** Power event */
- {
- void *ext_data; /**< Extension data - not used */
+ struct _Ecore_Event_Signal_Power {
+/** Power event */
+ void *ext_data;
+ /**< Extension data - not used */
#ifndef _WIN32
- siginfo_t data; /**< Signal info */
+ siginfo_t data;
+ /**< Signal info */
#endif
- };
+ };
- struct _Ecore_Event_Signal_Realtime /** Realtime event */
- {
- int num; /**< The realtime signal's number */
+ struct _Ecore_Event_Signal_Realtime {
+/** Realtime event */
+ int num;
+ /**< The realtime signal's number */
#ifndef _WIN32
- siginfo_t data; /**< Signal info */
+ siginfo_t data;
+ /**< Signal info */
#endif
- };
-
- struct _Ecore_Exe_Event_Add /** Process add event */
- {
- Ecore_Exe *exe; /**< The handle to the added process */
- void *ext_data; /**< Extension data - not used */
- };
-
- struct _Ecore_Exe_Event_Del /** Process exit event */
- {
- pid_t pid; /**< The process ID of the process that exited */
- int exit_code; /**< The exit code of the process */
- Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */
- int exit_signal; /** < The signal that caused the process to exit */
- unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */
- unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */
- void *ext_data; /**< Extension data - not used */
+ };
+
+ struct _Ecore_Exe_Event_Add {
+/** Process add event */
+ Ecore_Exe *exe;
+ /**< The handle to the added process */
+ void *ext_data;
+ /**< Extension data - not used */
+ };
+
+ struct _Ecore_Exe_Event_Del {
+/** Process exit event */
+ pid_t pid; /**< The process ID of the process that exited */
+ int exit_code; /**< The exit code of the process */
+ Ecore_Exe *exe;
+ /**< The handle to the exited process, or NULL if not found */
+ int exit_signal; /** < The signal that caused the process to exit */
+ unsigned int exited:1;
+ /** < set to 1 if the process exited of its own accord */
+ unsigned int signalled:1;
+ /** < set to 1 id the process exited due to uncaught signal */
+ void *ext_data; /**< Extension data - not used */
#ifndef _WIN32
- siginfo_t data; /**< Signal info */
+ siginfo_t data;
+ /**< Signal info */
#endif
- };
-
- struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */
- {
- char *line;
- int size;
- };
-
- struct _Ecore_Exe_Event_Data /** Data from a child process event */
- {
- Ecore_Exe *exe; /**< The handle to the process */
- void *data; /**< the raw binary data from the child process that was received */
- int size; /**< the size of this data in bytes */
- Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to NULL */
- };
-
- EAPI int ecore_init(void);
- EAPI int ecore_shutdown(void);
-
- EAPI void ecore_app_args_set(int argc, const char **argv);
- EAPI void ecore_app_args_get(int *argc, char ***argv);
- EAPI void ecore_app_restart(void);
-
- EAPI Ecore_Event_Handler *ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data);
- EAPI void *ecore_event_handler_del(Ecore_Event_Handler *event_handler);
- EAPI Ecore_Event *ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data);
- EAPI void *ecore_event_del(Ecore_Event *event);
- EAPI int ecore_event_type_new(void);
- EAPI Ecore_Event_Filter *ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ecore_End_Cb func_end, const void *data);
- EAPI void *ecore_event_filter_del(Ecore_Event_Filter *ef);
- EAPI int ecore_event_current_type_get(void);
- EAPI void *ecore_event_current_event_get(void);
-
-
- EAPI void ecore_exe_run_priority_set(int pri);
- EAPI int ecore_exe_run_priority_get(void);
- EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data);
- EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data);
- EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func);
- EAPI Eina_Bool ecore_exe_send(Ecore_Exe *exe, const void *data, int size);
- EAPI void ecore_exe_close_stdin(Ecore_Exe *exe);
- EAPI void ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines);
- EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags);
- EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data *data);
- EAPI void *ecore_exe_free(Ecore_Exe *exe);
- EAPI pid_t ecore_exe_pid_get(const Ecore_Exe *exe);
- EAPI void ecore_exe_tag_set(Ecore_Exe *exe, const char *tag);
- EAPI const char *ecore_exe_tag_get(const Ecore_Exe *exe);
- EAPI const char *ecore_exe_cmd_get(const Ecore_Exe *exe);
- EAPI void *ecore_exe_data_get(const Ecore_Exe *exe);
- EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe *exe);
- EAPI void ecore_exe_pause(Ecore_Exe *exe);
- EAPI void ecore_exe_continue(Ecore_Exe *exe);
- EAPI void ecore_exe_interrupt(Ecore_Exe *exe);
- EAPI void ecore_exe_quit(Ecore_Exe *exe);
- EAPI void ecore_exe_terminate(Ecore_Exe *exe);
- EAPI void ecore_exe_kill(Ecore_Exe *exe);
- EAPI void ecore_exe_signal(Ecore_Exe *exe, int num);
- EAPI void ecore_exe_hup(Ecore_Exe *exe);
-
- EAPI Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func, const void *data);
- EAPI void *ecore_idler_del(Ecore_Idler *idler);
-
- EAPI Ecore_Idle_Enterer *ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data);
- EAPI Ecore_Idle_Enterer *ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data);
- EAPI void *ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
-
- EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data);
- EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
-
- EAPI void ecore_main_loop_iterate(void);
-
- EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function func);
- EAPI void *ecore_main_loop_select_func_get(void);
-
- EAPI Eina_Bool ecore_main_loop_glib_integrate(void);
- EAPI void ecore_main_loop_glib_always_integrate_disable(void);
-
- EAPI void ecore_main_loop_begin(void);
- EAPI void ecore_main_loop_quit(void);
- EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func, const void *data,
- Ecore_Fd_Cb buf_func, const void *buf_data);
- EAPI void ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data);
- EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
- EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler);
- EAPI Eina_Bool ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
- EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
-
- EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h, Ecore_Fd_Win32_Cb func, const void *data);
- EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler);
-
- EAPI Ecore_Pipe *ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data);
- EAPI void *ecore_pipe_del(Ecore_Pipe *p);
- EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes);
- EAPI void ecore_pipe_write_close(Ecore_Pipe *p);
- EAPI void ecore_pipe_read_close(Ecore_Pipe *p);
-
-
-
- EAPI Ecore_Thread *ecore_thread_run(Ecore_Cb,
- Ecore_Cb,
- Ecore_Cb,
- const void *data);
- EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb,
- Ecore_Thread_Notify_Cb,
- Ecore_Cb,
- Ecore_Cb,
- const void *data,
- Eina_Bool try_no_queue);
- EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread);
- EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread);
- EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data);
- EAPI int ecore_thread_active_get(void);
- EAPI int ecore_thread_pending_get(void);
- EAPI int ecore_thread_pending_feedback_get(void);
- EAPI int ecore_thread_pending_total_get(void);
- EAPI int ecore_thread_max_get(void);
- EAPI void ecore_thread_max_set(int num);
- EAPI void ecore_thread_max_reset(void);
- EAPI int ecore_thread_available_get(void);
-
- EAPI Eina_Bool ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
- EAPI void *ecore_thread_local_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb);
- EAPI void *ecore_thread_local_data_find(Ecore_Thread *thread, const char *key);
- EAPI Eina_Bool ecore_thread_local_data_del(Ecore_Thread *thread, const char *key);
-
- EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
- EAPI void *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb);
- EAPI void *ecore_thread_global_data_find(const char *key);
- EAPI Eina_Bool ecore_thread_global_data_del(const char *key);
- EAPI void *ecore_thread_global_data_wait(const char *key, double seconds);
-
-
-
-
- EAPI double ecore_time_get(void);
- EAPI double ecore_time_unix_get(void);
- EAPI double ecore_loop_time_get(void);
-
- EAPI Ecore_Timer *ecore_timer_add(double in, Ecore_Task_Cb func, const void *data);
- EAPI Ecore_Timer *ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data);
- EAPI void *ecore_timer_del(Ecore_Timer *timer);
- EAPI void ecore_timer_interval_set(Ecore_Timer *timer, double in);
- EAPI double ecore_timer_interval_get(Ecore_Timer *timer);
- EAPI void ecore_timer_freeze(Ecore_Timer *timer);
- EAPI void ecore_timer_thaw(Ecore_Timer *timer);
- EAPI void ecore_timer_delay(Ecore_Timer *timer, double add);
- EAPI double ecore_timer_pending_get(Ecore_Timer *timer);
-
- EAPI double ecore_timer_precision_get(void);
- EAPI void ecore_timer_precision_set(double precision);
-
- EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data);
- EAPI void *ecore_animator_del(Ecore_Animator *animator);
- EAPI void ecore_animator_freeze(Ecore_Animator *animator);
- EAPI void ecore_animator_thaw(Ecore_Animator *animator);
- EAPI void ecore_animator_frametime_set(double frametime);
- EAPI double ecore_animator_frametime_get(void);
-
- EAPI void ecore_poller_poll_interval_set(Ecore_Poller_Type type, double poll_time);
- EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type);
- EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval);
- EAPI int ecore_poller_poller_interval_get(Ecore_Poller *poller);
- EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data);
- EAPI void *ecore_poller_del(Ecore_Poller *poller);
-
- EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data);
- EAPI void *ecore_job_del(Ecore_Job *job);
+ };
+
+ struct _Ecore_Exe_Event_Data_Line {
+/**< Lines from a child process */
+ char *line;
+ int size;
+ };
+
+ struct _Ecore_Exe_Event_Data {
+/** Data from a child process event */
+ Ecore_Exe *exe;
+ /**< The handle to the process */
+ void *data;
+ /**< the raw binary data from the child process that was received */
+ int size;
+ /**< the size of this data in bytes */
+ Ecore_Exe_Event_Data_Line *lines;
+ /**< an array of line data if line buffered, the last one has it's line member set to NULL */
+ };
+
+ EAPI int ecore_init(void);
+ EAPI int ecore_shutdown(void);
+
+ EAPI void ecore_app_args_set(int argc, const char **argv);
+ EAPI void ecore_app_args_get(int *argc, char ***argv);
+ EAPI void ecore_app_restart(void);
+
+ EAPI Ecore_Event_Handler *ecore_event_handler_add(int type,
+ Ecore_Event_Handler_Cb
+ func,
+ const void
+ *data);
+ EAPI void *ecore_event_handler_del(Ecore_Event_Handler *
+ event_handler);
+ EAPI Ecore_Event *ecore_event_add(int type, void *ev,
+ Ecore_End_Cb func_free,
+ void *data);
+ EAPI void *ecore_event_del(Ecore_Event * event);
+ EAPI int ecore_event_type_new(void);
+ EAPI Ecore_Event_Filter *ecore_event_filter_add(Ecore_Data_Cb
+ func_start,
+ Ecore_Filter_Cb
+ func_filter,
+ Ecore_End_Cb
+ func_end,
+ const void *data);
+ EAPI void *ecore_event_filter_del(Ecore_Event_Filter * ef);
+ EAPI int ecore_event_current_type_get(void);
+ EAPI void *ecore_event_current_event_get(void);
+
+
+ EAPI void ecore_exe_run_priority_set(int pri);
+ EAPI int ecore_exe_run_priority_get(void);
+ EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd,
+ const void *data);
+ EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd,
+ Ecore_Exe_Flags flags,
+ const void *data);
+ EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe * exe,
+ Ecore_Exe_Cb func);
+ EAPI Eina_Bool ecore_exe_send(Ecore_Exe * exe, const void *data,
+ int size);
+ EAPI void ecore_exe_close_stdin(Ecore_Exe * exe);
+ EAPI void ecore_exe_auto_limits_set(Ecore_Exe * exe,
+ int start_bytes, int end_bytes,
+ int start_lines,
+ int end_lines);
+ EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *
+ exe,
+ Ecore_Exe_Flags
+ flags);
+ EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data * data);
+ EAPI void *ecore_exe_free(Ecore_Exe * exe);
+ EAPI pid_t ecore_exe_pid_get(const Ecore_Exe * exe);
+ EAPI void ecore_exe_tag_set(Ecore_Exe * exe, const char *tag);
+ EAPI const char *ecore_exe_tag_get(const Ecore_Exe * exe);
+ EAPI const char *ecore_exe_cmd_get(const Ecore_Exe * exe);
+ EAPI void *ecore_exe_data_get(const Ecore_Exe * exe);
+ EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe * exe);
+ EAPI void ecore_exe_pause(Ecore_Exe * exe);
+ EAPI void ecore_exe_continue(Ecore_Exe * exe);
+ EAPI void ecore_exe_interrupt(Ecore_Exe * exe);
+ EAPI void ecore_exe_quit(Ecore_Exe * exe);
+ EAPI void ecore_exe_terminate(Ecore_Exe * exe);
+ EAPI void ecore_exe_kill(Ecore_Exe * exe);
+ EAPI void ecore_exe_signal(Ecore_Exe * exe, int num);
+ EAPI void ecore_exe_hup(Ecore_Exe * exe);
+
+ EAPI Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func,
+ const void *data);
+ EAPI void *ecore_idler_del(Ecore_Idler * idler);
+
+ EAPI Ecore_Idle_Enterer *ecore_idle_enterer_add(Ecore_Task_Cb func,
+ const void *data);
+ EAPI Ecore_Idle_Enterer
+ *ecore_idle_enterer_before_add(Ecore_Task_Cb func,
+ const void *data);
+ EAPI void *ecore_idle_enterer_del(Ecore_Idle_Enterer *
+ idle_enterer);
+
+ EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Ecore_Task_Cb func,
+ const void *data);
+ EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter * idle_exiter);
+
+ EAPI void ecore_main_loop_iterate(void);
+
+ EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function
+ func);
+ EAPI void *ecore_main_loop_select_func_get(void);
+
+ EAPI Eina_Bool ecore_main_loop_glib_integrate(void);
+ EAPI void ecore_main_loop_glib_always_integrate_disable(void);
+
+ EAPI void ecore_main_loop_begin(void);
+ EAPI void ecore_main_loop_quit(void);
+ EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd,
+ Ecore_Fd_Handler_Flags
+ flags,
+ Ecore_Fd_Cb func,
+ const void *data,
+ Ecore_Fd_Cb
+ buf_func,
+ const void
+ *buf_data);
+ EAPI void
+ ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *
+ fd_handler,
+ Ecore_Fd_Prep_Cb
+ func,
+ const void *data);
+ EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler *
+ fd_handler);
+ EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *
+ fd_handler);
+ EAPI Eina_Bool ecore_main_fd_handler_active_get(Ecore_Fd_Handler *
+ fd_handler,
+ Ecore_Fd_Handler_Flags
+ flags);
+ EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *
+ fd_handler,
+ Ecore_Fd_Handler_Flags
+ flags);
+
+ EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h,
+ Ecore_Fd_Win32_Cb
+ func,
+ const void
+ *data);
+ EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *
+ win32_handler);
+
+ EAPI Ecore_Pipe *ecore_pipe_add(Ecore_Pipe_Cb handler,
+ const void *data);
+ EAPI void *ecore_pipe_del(Ecore_Pipe * p);
+ EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe * p, const void *buffer,
+ unsigned int nbytes);
+ EAPI void ecore_pipe_write_close(Ecore_Pipe * p);
+ EAPI void ecore_pipe_read_close(Ecore_Pipe * p);
+
+
+
+ EAPI Ecore_Thread *ecore_thread_run(Ecore_Cb,
+ Ecore_Cb,
+ Ecore_Cb, const void *data);
+ EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb,
+ Ecore_Thread_Notify_Cb,
+ Ecore_Cb,
+ Ecore_Cb,
+ const void *data,
+ Eina_Bool
+ try_no_queue);
+ EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread * thread);
+ EAPI Eina_Bool ecore_thread_check(Ecore_Thread * thread);
+ EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread * thread,
+ const void *msg_data);
+ EAPI int ecore_thread_active_get(void);
+ EAPI int ecore_thread_pending_get(void);
+ EAPI int ecore_thread_pending_feedback_get(void);
+ EAPI int ecore_thread_pending_total_get(void);
+ EAPI int ecore_thread_max_get(void);
+ EAPI void ecore_thread_max_set(int num);
+ EAPI void ecore_thread_max_reset(void);
+ EAPI int ecore_thread_available_get(void);
+
+ EAPI Eina_Bool ecore_thread_local_data_add(Ecore_Thread * thread,
+ const char *key,
+ void *value,
+ Eina_Free_Cb cb,
+ Eina_Bool direct);
+ EAPI void *ecore_thread_local_data_set(Ecore_Thread * thread,
+ const char *key,
+ void *value,
+ Eina_Free_Cb cb);
+ EAPI void *ecore_thread_local_data_find(Ecore_Thread * thread,
+ const char *key);
+ EAPI Eina_Bool ecore_thread_local_data_del(Ecore_Thread * thread,
+ const char *key);
+
+ EAPI Eina_Bool ecore_thread_global_data_add(const char *key,
+ void *value,
+ Eina_Free_Cb cb,
+ Eina_Bool direct);
+ EAPI void *ecore_thread_global_data_set(const char *key,
+ void *value,
+ Eina_Free_Cb cb);
+ EAPI void *ecore_thread_global_data_find(const char *key);
+ EAPI Eina_Bool ecore_thread_global_data_del(const char *key);
+ EAPI void *ecore_thread_global_data_wait(const char *key,
+ double seconds);
+
+
+
+
+ EAPI double ecore_time_get(void);
+ EAPI double ecore_time_unix_get(void);
+ EAPI double ecore_loop_time_get(void);
+
+ EAPI Ecore_Timer *ecore_timer_add(double in, Ecore_Task_Cb func,
+ const void *data);
+ EAPI Ecore_Timer *ecore_timer_loop_add(double in,
+ Ecore_Task_Cb func,
+ const void *data);
+ EAPI void *ecore_timer_del(Ecore_Timer * timer);
+ EAPI void ecore_timer_interval_set(Ecore_Timer * timer, double in);
+ EAPI double ecore_timer_interval_get(Ecore_Timer * timer);
+ EAPI void ecore_timer_freeze(Ecore_Timer * timer);
+ EAPI void ecore_timer_thaw(Ecore_Timer * timer);
+ EAPI void ecore_timer_delay(Ecore_Timer * timer, double add);
+ EAPI double ecore_timer_pending_get(Ecore_Timer * timer);
+
+ EAPI double ecore_timer_precision_get(void);
+ EAPI void ecore_timer_precision_set(double precision);
+
+ EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func,
+ const void *data);
+ EAPI void *ecore_animator_del(Ecore_Animator * animator);
+ EAPI void ecore_animator_freeze(Ecore_Animator * animator);
+ EAPI void ecore_animator_thaw(Ecore_Animator * animator);
+ EAPI void ecore_animator_frametime_set(double frametime);
+ EAPI double ecore_animator_frametime_get(void);
+
+ EAPI void ecore_poller_poll_interval_set(Ecore_Poller_Type type,
+ double poll_time);
+ EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type);
+ EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *
+ poller,
+ int interval);
+ EAPI int ecore_poller_poller_interval_get(Ecore_Poller * poller);
+ EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type,
+ int interval,
+ Ecore_Task_Cb func,
+ const void *data);
+ EAPI void *ecore_poller_del(Ecore_Poller * poller);
+
+ EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data);
+ EAPI void *ecore_job_del(Ecore_Job * job);
#ifdef __cplusplus
}
diff --git a/tests/suite/ecore/src/lib/Ecore_Getopt.h b/tests/suite/ecore/src/lib/Ecore_Getopt.h
index 18a8459bfc..d3dc5688a3 100644
--- a/tests/suite/ecore/src/lib/Ecore_Getopt.h
+++ b/tests/suite/ecore/src/lib/Ecore_Getopt.h
@@ -5,30 +5,30 @@
#include <Eina.h>
#ifdef EAPI
-# undef EAPI
+#undef EAPI
#endif
#ifdef _WIN32
-# ifdef EFL_ECORE_BUILD
-# ifdef DLL_EXPORT
-# define EAPI __declspec(dllexport)
-# else
-# define EAPI
-# endif /* ! DLL_EXPORT */
-# else
-# define EAPI __declspec(dllimport)
-# endif /* ! EFL_ECORE_BUILD */
+#ifdef EFL_ECORE_BUILD
+#ifdef DLL_EXPORT
+#define EAPI __declspec(dllexport)
#else
-# ifdef __GNUC__
-# if __GNUC__ >= 4
-# define EAPI __attribute__ ((visibility("default")))
-# else
-# define EAPI
-# endif
-# else
-# define EAPI
-# endif
-#endif /* ! _WIN32 */
+#define EAPI
+#endif /* ! DLL_EXPORT */
+#else
+#define EAPI __declspec(dllimport)
+#endif /* ! EFL_ECORE_BUILD */
+#else
+#ifdef __GNUC__
+#if __GNUC__ >= 4
+#define EAPI __attribute__ ((visibility("default")))
+#else
+#define EAPI
+#endif
+#else
+#define EAPI
+#endif
+#endif /* ! _WIN32 */
/**
* @file Ecore_Getopt.h
@@ -53,117 +53,126 @@
extern "C" {
#endif
- typedef enum {
- ECORE_GETOPT_ACTION_STORE,
- ECORE_GETOPT_ACTION_STORE_CONST,
- ECORE_GETOPT_ACTION_STORE_TRUE,
- ECORE_GETOPT_ACTION_STORE_FALSE,
- ECORE_GETOPT_ACTION_CHOICE,
- ECORE_GETOPT_ACTION_APPEND,
- ECORE_GETOPT_ACTION_COUNT,
- ECORE_GETOPT_ACTION_CALLBACK,
- ECORE_GETOPT_ACTION_HELP,
- ECORE_GETOPT_ACTION_VERSION,
- ECORE_GETOPT_ACTION_COPYRIGHT,
- ECORE_GETOPT_ACTION_LICENSE
- } Ecore_Getopt_Action;
-
- typedef enum {
- ECORE_GETOPT_TYPE_STR,
- ECORE_GETOPT_TYPE_BOOL,
- ECORE_GETOPT_TYPE_SHORT,
- ECORE_GETOPT_TYPE_INT,
- ECORE_GETOPT_TYPE_LONG,
- ECORE_GETOPT_TYPE_USHORT,
- ECORE_GETOPT_TYPE_UINT,
- ECORE_GETOPT_TYPE_ULONG,
- ECORE_GETOPT_TYPE_DOUBLE
- } Ecore_Getopt_Type;
-
- typedef enum {
- ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO = 0,
- ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES = 1,
- ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL = 3
- } Ecore_Getopt_Desc_Arg_Requirement;
-
- typedef union _Ecore_Getopt_Value Ecore_Getopt_Value;
-
- typedef struct _Ecore_Getopt_Desc_Store Ecore_Getopt_Desc_Store;
- typedef struct _Ecore_Getopt_Desc_Callback Ecore_Getopt_Desc_Callback;
- typedef struct _Ecore_Getopt_Desc Ecore_Getopt_Desc;
- typedef struct _Ecore_Getopt Ecore_Getopt;
-
- union _Ecore_Getopt_Value
- {
- char **strp;
- unsigned char *boolp;
- short *shortp;
- int *intp;
- long *longp;
- unsigned short *ushortp;
- unsigned int *uintp;
- unsigned long *ulongp;
- double *doublep;
- Eina_List **listp;
- void **ptrp;
- };
-
- struct _Ecore_Getopt_Desc_Store
- {
- Ecore_Getopt_Type type; /**< type of data being handled */
- Ecore_Getopt_Desc_Arg_Requirement arg_req;
- union
- {
- const char *strv;
- unsigned char boolv;
- short shortv;
- int intv;
- long longv;
- unsigned short ushortv;
- unsigned int uintv;
- unsigned long ulongv;
- double doublev;
- } def;
- };
-
- struct _Ecore_Getopt_Desc_Callback
- {
- unsigned char (*func)(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
- const void *data;
- Ecore_Getopt_Desc_Arg_Requirement arg_req;
- const char *def;
- };
-
- struct _Ecore_Getopt_Desc
- {
- char shortname; /**< used with a single dash */
- const char *longname; /**< used with double dashes */
- const char *help; /**< used by --help/ecore_getopt_help() */
- const char *metavar; /**< used by ecore_getopt_help() with nargs > 0 */
-
- Ecore_Getopt_Action action; /**< define how to handle it */
- union
- {
- const Ecore_Getopt_Desc_Store store;
- const void *store_const;
- const char *const *choices; /* NULL terminated. */
- const Ecore_Getopt_Type append_type;
- const Ecore_Getopt_Desc_Callback callback;
- const void *dummy;
- } action_param;
- };
-
- struct _Ecore_Getopt
- {
- const char *prog; /**< to be used when ecore_app_args_get() fails */
- const char *usage; /**< usage example, %prog is replaced */
- const char *version; /**< if exists, --version will work */
- const char *copyright; /**< if exists, --copyright will work */
- const char *license; /**< if exists, --license will work */
- const char *description; /**< long description, possible multiline */
- unsigned char strict : 1; /**< fail on errors */
- const Ecore_Getopt_Desc descs[]; /* NULL terminated. */
- };
+ typedef enum {
+ ECORE_GETOPT_ACTION_STORE,
+ ECORE_GETOPT_ACTION_STORE_CONST,
+ ECORE_GETOPT_ACTION_STORE_TRUE,
+ ECORE_GETOPT_ACTION_STORE_FALSE,
+ ECORE_GETOPT_ACTION_CHOICE,
+ ECORE_GETOPT_ACTION_APPEND,
+ ECORE_GETOPT_ACTION_COUNT,
+ ECORE_GETOPT_ACTION_CALLBACK,
+ ECORE_GETOPT_ACTION_HELP,
+ ECORE_GETOPT_ACTION_VERSION,
+ ECORE_GETOPT_ACTION_COPYRIGHT,
+ ECORE_GETOPT_ACTION_LICENSE
+ } Ecore_Getopt_Action;
+
+ typedef enum {
+ ECORE_GETOPT_TYPE_STR,
+ ECORE_GETOPT_TYPE_BOOL,
+ ECORE_GETOPT_TYPE_SHORT,
+ ECORE_GETOPT_TYPE_INT,
+ ECORE_GETOPT_TYPE_LONG,
+ ECORE_GETOPT_TYPE_USHORT,
+ ECORE_GETOPT_TYPE_UINT,
+ ECORE_GETOPT_TYPE_ULONG,
+ ECORE_GETOPT_TYPE_DOUBLE
+ } Ecore_Getopt_Type;
+
+ typedef enum {
+ ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO = 0,
+ ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES = 1,
+ ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL = 3
+ } Ecore_Getopt_Desc_Arg_Requirement;
+
+ typedef union _Ecore_Getopt_Value Ecore_Getopt_Value;
+
+ typedef struct _Ecore_Getopt_Desc_Store Ecore_Getopt_Desc_Store;
+ typedef struct _Ecore_Getopt_Desc_Callback
+ Ecore_Getopt_Desc_Callback;
+ typedef struct _Ecore_Getopt_Desc Ecore_Getopt_Desc;
+ typedef struct _Ecore_Getopt Ecore_Getopt;
+
+ union _Ecore_Getopt_Value {
+ char **strp;
+ unsigned char *boolp;
+ short *shortp;
+ int *intp;
+ long *longp;
+ unsigned short *ushortp;
+ unsigned int *uintp;
+ unsigned long *ulongp;
+ double *doublep;
+ Eina_List **listp;
+ void **ptrp;
+ };
+
+ struct _Ecore_Getopt_Desc_Store {
+ Ecore_Getopt_Type type;/**< type of data being handled */
+ Ecore_Getopt_Desc_Arg_Requirement arg_req;
+ union {
+ const char *strv;
+ unsigned char boolv;
+ short shortv;
+ int intv;
+ long longv;
+ unsigned short ushortv;
+ unsigned int uintv;
+ unsigned long ulongv;
+ double doublev;
+ } def;
+ };
+
+ struct _Ecore_Getopt_Desc_Callback {
+ unsigned char (*func) (const Ecore_Getopt * parser,
+ const Ecore_Getopt_Desc * desc,
+ const char *str, void *data,
+ Ecore_Getopt_Value * storage);
+ const void *data;
+ Ecore_Getopt_Desc_Arg_Requirement arg_req;
+ const char *def;
+ };
+
+ struct _Ecore_Getopt_Desc {
+ char shortname;
+ /**< used with a single dash */
+ const char *longname;
+ /**< used with double dashes */
+ const char *help;
+ /**< used by --help/ecore_getopt_help() */
+ const char *metavar;
+ /**< used by ecore_getopt_help() with nargs > 0 */
+
+ Ecore_Getopt_Action action;
+ /**< define how to handle it */
+ union {
+ const Ecore_Getopt_Desc_Store store;
+ const void *store_const;
+ const char *const *choices; /* NULL terminated. */
+ const Ecore_Getopt_Type append_type;
+ const Ecore_Getopt_Desc_Callback callback;
+ const void *dummy;
+ } action_param;
+ };
+
+ struct _Ecore_Getopt {
+ const char *prog;
+ /**< to be used when ecore_app_args_get() fails */
+ const char *usage;
+ /**< usage example, %prog is replaced */
+ const char *version;
+ /**< if exists, --version will work */
+ const char *copyright;
+ /**< if exists, --copyright will work */
+ const char *license;
+ /**< if exists, --license will work */
+ const char *description;
+ /**< long description, possible multiline */
+ unsigned char strict:1;
+ /**< fail on errors */
+ const Ecore_Getopt_Desc descs[]; /* NULL terminated. */
+ };
#define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value) \
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \
@@ -385,19 +394,43 @@ extern "C" {
#define ECORE_GETOPT_VALUE_LIST(val) {.listp = &(val)}
#define ECORE_GETOPT_VALUE_NONE {.ptrp = NULL}
- EAPI void ecore_getopt_help(FILE *fp, const Ecore_Getopt *info);
-
- EAPI unsigned char ecore_getopt_parser_has_duplicates(const Ecore_Getopt *parser);
- EAPI int ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc, char **argv);
-
- EAPI Eina_List *ecore_getopt_list_free(Eina_List *list);
-
- /* helper functions to be used with ECORE_GETOPT_CALLBACK_*() */
- EAPI unsigned char ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
- EAPI unsigned char ecore_getopt_callback_size_parse(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
+ EAPI void ecore_getopt_help(FILE * fp, const Ecore_Getopt * info);
+
+ EAPI unsigned char ecore_getopt_parser_has_duplicates(const
+ Ecore_Getopt
+ * parser);
+ EAPI int ecore_getopt_parse(const Ecore_Getopt * parser,
+ Ecore_Getopt_Value * values, int argc,
+ char **argv);
+
+ EAPI Eina_List *ecore_getopt_list_free(Eina_List * list);
+
+ /* helper functions to be used with ECORE_GETOPT_CALLBACK_*() */
+ EAPI unsigned char ecore_getopt_callback_geometry_parse(const
+ Ecore_Getopt
+ * parser,
+ const
+ Ecore_Getopt_Desc
+ * desc,
+ const char
+ *str,
+ void *data,
+ Ecore_Getopt_Value
+ * storage);
+ EAPI unsigned char ecore_getopt_callback_size_parse(const
+ Ecore_Getopt *
+ parser,
+ const
+ Ecore_Getopt_Desc
+ * desc,
+ const char
+ *str,
+ void *data,
+ Ecore_Getopt_Value
+ * storage);
#ifdef __cplusplus
}
#endif
-#endif /* _ECORE_GETOPT_H */
+#endif /* _ECORE_GETOPT_H */
diff --git a/tests/suite/ecore/src/lib/ecore.c b/tests/suite/ecore/src/lib/ecore.c
index 5b0789c029..09842d1807 100644
--- a/tests/suite/ecore/src/lib/ecore.c
+++ b/tests/suite/ecore/src/lib/ecore.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdio.h>
@@ -9,23 +9,23 @@
#include <errno.h>
#ifndef _MSC_VER
-# include <unistd.h>
+#include <unistd.h>
#endif
#ifdef HAVE_LOCALE_H
-# include <locale.h>
+#include <locale.h>
#endif
#ifdef HAVE_LANGINFO_H
-# include <langinfo.h>
+#include <langinfo.h>
#endif
#ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
+#include <sys/mman.h>
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include <Eina.h>
@@ -36,6 +36,7 @@
#include <malloc.h>
static Ecore_Version _version = { VERS_MAJ, VERS_MIN, VERS_MIC, VERS_REV };
+
EAPI Ecore_Version *ecore_version = &_version;
#define KEEP_MAX(Global, Local) \
@@ -58,7 +59,7 @@ int _ecore_fps_debug = 0;
*/
#ifndef CODESET
-# define CODESET "INVALID"
+#define CODESET "INVALID"
#endif
/**
@@ -83,63 +84,65 @@ int _ecore_fps_debug = 0;
* }
* @endcode
*/
-EAPI int
-ecore_init(void)
+EAPI int ecore_init(void)
{
- if (++_ecore_init_count != 1)
- return _ecore_init_count;
+ if (++_ecore_init_count != 1)
+ return _ecore_init_count;
#ifdef HAVE_LOCALE_H
- setlocale(LC_CTYPE, "");
+ setlocale(LC_CTYPE, "");
#endif
- /*
- if (strcmp(nl_langinfo(CODESET), "UTF-8"))
- {
- WRN("Not a utf8 locale!");
- }
- */
+ /*
+ if (strcmp(nl_langinfo(CODESET), "UTF-8"))
+ {
+ WRN("Not a utf8 locale!");
+ }
+ */
#ifdef HAVE_EVIL
- if (!evil_init())
- return --_ecore_init_count;
+ if (!evil_init())
+ return --_ecore_init_count;
#endif
- if (!eina_init())
- goto shutdown_evil;
- _ecore_log_dom = eina_log_domain_register("Ecore",ECORE_DEFAULT_LOG_COLOR);
- if (_ecore_log_dom < 0) {
- EINA_LOG_ERR("Ecore was unable to create a log domain.");
- goto shutdown_log_dom;
- }
- if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1;
- if (_ecore_fps_debug) _ecore_fps_debug_init();
- _ecore_main_loop_init();
- _ecore_signal_init();
- _ecore_exe_init();
- _ecore_thread_init();
- _ecore_glib_init();
- _ecore_job_init();
- _ecore_time_init();
+ if (!eina_init())
+ goto shutdown_evil;
+ _ecore_log_dom =
+ eina_log_domain_register("Ecore", ECORE_DEFAULT_LOG_COLOR);
+ if (_ecore_log_dom < 0) {
+ EINA_LOG_ERR("Ecore was unable to create a log domain.");
+ goto shutdown_log_dom;
+ }
+ if (getenv("ECORE_FPS_DEBUG"))
+ _ecore_fps_debug = 1;
+ if (_ecore_fps_debug)
+ _ecore_fps_debug_init();
+ _ecore_main_loop_init();
+ _ecore_signal_init();
+ _ecore_exe_init();
+ _ecore_thread_init();
+ _ecore_glib_init();
+ _ecore_job_init();
+ _ecore_time_init();
#if HAVE_MALLINFO
- if (getenv("ECORE_MEM_STAT"))
- {
- _ecore_memory_pid = getpid();
- ecore_animator_add(_ecore_memory_statistic, NULL);
- }
+ if (getenv("ECORE_MEM_STAT")) {
+ _ecore_memory_pid = getpid();
+ ecore_animator_add(_ecore_memory_statistic, NULL);
+ }
#endif
#if defined(GLIB_INTEGRATION_ALWAYS)
- if (_ecore_glib_always_integrate) ecore_main_loop_glib_integrate();
+ if (_ecore_glib_always_integrate)
+ ecore_main_loop_glib_integrate();
#endif
-
- return _ecore_init_count;
- shutdown_log_dom:
- eina_shutdown();
- shutdown_evil:
+ return _ecore_init_count;
+
+ shutdown_log_dom:
+ eina_shutdown();
+ shutdown_evil:
#ifdef HAVE_EVIL
- evil_shutdown();
+ evil_shutdown();
#endif
- return --_ecore_init_count;
+ return --_ecore_init_count;
}
/**
@@ -152,122 +155,120 @@ ecore_init(void)
* Do not call this function from any callback that may be called from the main
* loop, as the main loop will then fall over and not function properly.
*/
-EAPI int
-ecore_shutdown(void)
+EAPI int ecore_shutdown(void)
{
- if (--_ecore_init_count != 0)
- return _ecore_init_count;
-
- if (_ecore_fps_debug) _ecore_fps_debug_shutdown();
- _ecore_poller_shutdown();
- _ecore_animator_shutdown();
- _ecore_glib_shutdown();
- _ecore_job_shutdown();
- _ecore_thread_shutdown();
- _ecore_exe_shutdown();
- _ecore_idle_enterer_shutdown();
- _ecore_idle_exiter_shutdown();
- _ecore_idler_shutdown();
- _ecore_timer_shutdown();
- _ecore_event_shutdown();
- _ecore_main_shutdown();
- _ecore_signal_shutdown();
- _ecore_main_loop_shutdown();
+ if (--_ecore_init_count != 0)
+ return _ecore_init_count;
+
+ if (_ecore_fps_debug)
+ _ecore_fps_debug_shutdown();
+ _ecore_poller_shutdown();
+ _ecore_animator_shutdown();
+ _ecore_glib_shutdown();
+ _ecore_job_shutdown();
+ _ecore_thread_shutdown();
+ _ecore_exe_shutdown();
+ _ecore_idle_enterer_shutdown();
+ _ecore_idle_exiter_shutdown();
+ _ecore_idler_shutdown();
+ _ecore_timer_shutdown();
+ _ecore_event_shutdown();
+ _ecore_main_shutdown();
+ _ecore_signal_shutdown();
+ _ecore_main_loop_shutdown();
#if HAVE_MALLINFO
- if (getenv("ECORE_MEM_STAT"))
- {
- _ecore_memory_statistic(NULL);
-
- ERR("[%i] Memory MAX total: %i, free: %i",
- _ecore_memory_pid,
- _ecore_memory_max_total,
- _ecore_memory_max_free);
- }
+ if (getenv("ECORE_MEM_STAT")) {
+ _ecore_memory_statistic(NULL);
+
+ ERR("[%i] Memory MAX total: %i, free: %i",
+ _ecore_memory_pid,
+ _ecore_memory_max_total, _ecore_memory_max_free);
+ }
#endif
- eina_log_domain_unregister(_ecore_log_dom);
- _ecore_log_dom = -1;
- eina_shutdown();
+ eina_log_domain_unregister(_ecore_log_dom);
+ _ecore_log_dom = -1;
+ eina_shutdown();
#ifdef HAVE_EVIL
- evil_shutdown();
+ evil_shutdown();
#endif
- return _ecore_init_count;
+ return _ecore_init_count;
}
-EAPI void
-ecore_print_warning(const char *function, const char *sparam)
+EAPI void ecore_print_warning(const char *function, const char *sparam)
{
- WRN("***** Developer Warning ***** :\n"
- "\tThis program is calling:\n\n"
- "\t%s();\n\n"
- "\tWith the parameter:\n\n"
- "\t%s\n\n"
- "\tbeing NULL. Please fix your program.", function, sparam);
- if (getenv("ECORE_ERROR_ABORT")) abort();
+ WRN("***** Developer Warning ***** :\n"
+ "\tThis program is calling:\n\n"
+ "\t%s();\n\n"
+ "\tWith the parameter:\n\n"
+ "\t%s\n\n"
+ "\tbeing NULL. Please fix your program.", function, sparam);
+ if (getenv("ECORE_ERROR_ABORT"))
+ abort();
}
EAPI void
-_ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname)
+_ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m,
+ const char *fname)
{
- ERR("\n"
- "*** ECORE ERROR: Ecore Magic Check Failed!!!\n"
- "*** IN FUNCTION: %s()", fname);
- if (!d)
- ERR(" Input handle pointer is NULL!");
- else if (m == ECORE_MAGIC_NONE)
- ERR(" Input handle has already been freed!");
- else if (m != req_m)
- ERR(" Input handle is wrong type\n"
- " Expected: %08x - %s\n"
- " Supplied: %08x - %s",
- (unsigned int)req_m, _ecore_magic_string_get(req_m),
- (unsigned int)m, _ecore_magic_string_get(m));
- ERR("*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!");
- if (getenv("ECORE_ERROR_ABORT")) abort();
+ ERR("\n"
+ "*** ECORE ERROR: Ecore Magic Check Failed!!!\n"
+ "*** IN FUNCTION: %s()", fname);
+ if (!d)
+ ERR(" Input handle pointer is NULL!");
+ else if (m == ECORE_MAGIC_NONE)
+ ERR(" Input handle has already been freed!");
+ else if (m != req_m)
+ ERR(" Input handle is wrong type\n"
+ " Expected: %08x - %s\n"
+ " Supplied: %08x - %s",
+ (unsigned int) req_m, _ecore_magic_string_get(req_m),
+ (unsigned int) m, _ecore_magic_string_get(m));
+ ERR("*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!");
+ if (getenv("ECORE_ERROR_ABORT"))
+ abort();
}
-static const char *
-_ecore_magic_string_get(Ecore_Magic m)
+static const char *_ecore_magic_string_get(Ecore_Magic m)
{
- switch (m)
- {
- case ECORE_MAGIC_NONE:
- return "None (Freed Object)";
- break;
- case ECORE_MAGIC_EXE:
- return "Ecore_Exe (Executable)";
- break;
- case ECORE_MAGIC_TIMER:
- return "Ecore_Timer (Timer)";
- break;
- case ECORE_MAGIC_IDLER:
- return "Ecore_Idler (Idler)";
- break;
- case ECORE_MAGIC_IDLE_ENTERER:
- return "Ecore_Idle_Enterer (Idler Enterer)";
- break;
- case ECORE_MAGIC_IDLE_EXITER:
- return "Ecore_Idle_Exiter (Idler Exiter)";
- break;
- case ECORE_MAGIC_FD_HANDLER:
- return "Ecore_Fd_Handler (Fd Handler)";
- break;
- case ECORE_MAGIC_WIN32_HANDLER:
- return "Ecore_Win32_Handler (Win32 Handler)";
- break;
- case ECORE_MAGIC_EVENT_HANDLER:
- return "Ecore_Event_Handler (Event Handler)";
- break;
- case ECORE_MAGIC_EVENT:
- return "Ecore_Event (Event)";
- break;
- default:
- return "<UNKNOWN>";
- };
+ switch (m) {
+ case ECORE_MAGIC_NONE:
+ return "None (Freed Object)";
+ break;
+ case ECORE_MAGIC_EXE:
+ return "Ecore_Exe (Executable)";
+ break;
+ case ECORE_MAGIC_TIMER:
+ return "Ecore_Timer (Timer)";
+ break;
+ case ECORE_MAGIC_IDLER:
+ return "Ecore_Idler (Idler)";
+ break;
+ case ECORE_MAGIC_IDLE_ENTERER:
+ return "Ecore_Idle_Enterer (Idler Enterer)";
+ break;
+ case ECORE_MAGIC_IDLE_EXITER:
+ return "Ecore_Idle_Exiter (Idler Exiter)";
+ break;
+ case ECORE_MAGIC_FD_HANDLER:
+ return "Ecore_Fd_Handler (Fd Handler)";
+ break;
+ case ECORE_MAGIC_WIN32_HANDLER:
+ return "Ecore_Win32_Handler (Win32 Handler)";
+ break;
+ case ECORE_MAGIC_EVENT_HANDLER:
+ return "Ecore_Event_Handler (Event Handler)";
+ break;
+ case ECORE_MAGIC_EVENT:
+ return "Ecore_Event (Event)";
+ break;
+ default:
+ return "<UNKNOWN>";
+ };
}
/* fps debug calls - for debugging how much time your app actually spends */
@@ -278,121 +279,110 @@ static int _ecore_fps_debug_init_count = 0;
static int _ecore_fps_debug_fd = -1;
unsigned int *_ecore_fps_runtime_mmap = NULL;
-void
-_ecore_fps_debug_init(void)
+void _ecore_fps_debug_init(void)
{
- char buf[4096];
- const char *tmp;
- int pid;
+ char buf[4096];
+ const char *tmp;
+ int pid;
- _ecore_fps_debug_init_count++;
- if (_ecore_fps_debug_init_count > 1) return;
+ _ecore_fps_debug_init_count++;
+ if (_ecore_fps_debug_init_count > 1)
+ return;
#ifndef HAVE_EVIL
- tmp = "/tmp";
+ tmp = "/tmp";
#else
- tmp = (char *)evil_tmpdir_get ();
-#endif /* HAVE_EVIL */
- pid = (int)getpid();
- snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid);
- _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
- if (_ecore_fps_debug_fd < 0)
- {
- unlink(buf);
- _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
- }
- if (_ecore_fps_debug_fd >= 0)
- {
- unsigned int zero = 0;
- char *buf = (char *)&zero;
- ssize_t todo = sizeof(unsigned int);
-
- while (todo > 0)
- {
- ssize_t r = write(_ecore_fps_debug_fd, buf, todo);
- if (r > 0)
- {
- todo -= r;
- buf += r;
- }
- else if ((r < 0) && (errno == EINTR))
- continue;
- else
- {
- ERR("could not write to file '%s' fd %d: %s",
- tmp, _ecore_fps_debug_fd, strerror(errno));
- close(_ecore_fps_debug_fd);
- _ecore_fps_debug_fd = -1;
- return;
- }
- }
- _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int),
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- _ecore_fps_debug_fd, 0);
- if (_ecore_fps_runtime_mmap == MAP_FAILED)
- _ecore_fps_runtime_mmap = NULL;
- }
+ tmp = (char *) evil_tmpdir_get();
+#endif /* HAVE_EVIL */
+ pid = (int) getpid();
+ snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid);
+ _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
+ if (_ecore_fps_debug_fd < 0) {
+ unlink(buf);
+ _ecore_fps_debug_fd =
+ open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
+ }
+ if (_ecore_fps_debug_fd >= 0) {
+ unsigned int zero = 0;
+ char *buf = (char *) &zero;
+ ssize_t todo = sizeof(unsigned int);
+
+ while (todo > 0) {
+ ssize_t r = write(_ecore_fps_debug_fd, buf, todo);
+ if (r > 0) {
+ todo -= r;
+ buf += r;
+ } else if ((r < 0) && (errno == EINTR))
+ continue;
+ else {
+ ERR("could not write to file '%s' fd %d: %s", tmp, _ecore_fps_debug_fd, strerror(errno));
+ close(_ecore_fps_debug_fd);
+ _ecore_fps_debug_fd = -1;
+ return;
+ }
+ }
+ _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int),
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ _ecore_fps_debug_fd, 0);
+ if (_ecore_fps_runtime_mmap == MAP_FAILED)
+ _ecore_fps_runtime_mmap = NULL;
+ }
}
-void
-_ecore_fps_debug_shutdown(void)
+void _ecore_fps_debug_shutdown(void)
{
- _ecore_fps_debug_init_count--;
- if (_ecore_fps_debug_init_count > 0) return;
- if (_ecore_fps_debug_fd >= 0)
- {
- char buf[4096];
- const char *tmp;
- int pid;
+ _ecore_fps_debug_init_count--;
+ if (_ecore_fps_debug_init_count > 0)
+ return;
+ if (_ecore_fps_debug_fd >= 0) {
+ char buf[4096];
+ const char *tmp;
+ int pid;
#ifndef HAVE_EVIL
- tmp = "/tmp";
+ tmp = "/tmp";
#else
- tmp = (char *)evil_tmpdir_get ();
-#endif /* HAVE_EVIL */
- pid = (int)getpid();
- snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid);
- unlink(buf);
- if (_ecore_fps_runtime_mmap)
- {
- munmap(_ecore_fps_runtime_mmap, sizeof(int));
- _ecore_fps_runtime_mmap = NULL;
- }
- close(_ecore_fps_debug_fd);
- _ecore_fps_debug_fd = -1;
- }
+ tmp = (char *) evil_tmpdir_get();
+#endif /* HAVE_EVIL */
+ pid = (int) getpid();
+ snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp,
+ pid);
+ unlink(buf);
+ if (_ecore_fps_runtime_mmap) {
+ munmap(_ecore_fps_runtime_mmap, sizeof(int));
+ _ecore_fps_runtime_mmap = NULL;
+ }
+ close(_ecore_fps_debug_fd);
+ _ecore_fps_debug_fd = -1;
+ }
}
-void
-_ecore_fps_debug_runtime_add(double t)
+void _ecore_fps_debug_runtime_add(double t)
{
- if ((_ecore_fps_debug_fd >= 0) &&
- (_ecore_fps_runtime_mmap))
- {
- unsigned int tm;
-
- tm = (unsigned int)(t * 1000000.0);
- /* i know its not 100% theoretically guaranteed, but i'd say a write */
- /* of an int could be considered atomic for all practical purposes */
- /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */
- /* this can run for about 4294 seconds becore looping. if you are */
- /* doing performance testing in one run for over an hour... well */
- /* time to restart or handle a loop condition :) */
- *(_ecore_fps_runtime_mmap) += tm;
- }
+ if ((_ecore_fps_debug_fd >= 0) && (_ecore_fps_runtime_mmap)) {
+ unsigned int tm;
+
+ tm = (unsigned int) (t * 1000000.0);
+ /* i know its not 100% theoretically guaranteed, but i'd say a write */
+ /* of an int could be considered atomic for all practical purposes */
+ /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */
+ /* this can run for about 4294 seconds becore looping. if you are */
+ /* doing performance testing in one run for over an hour... well */
+ /* time to restart or handle a loop condition :) */
+ *(_ecore_fps_runtime_mmap) += tm;
+ }
}
#if HAVE_MALLINFO
-static Eina_Bool
-_ecore_memory_statistic(__UNUSED__ void *data)
+static Eina_Bool _ecore_memory_statistic(__UNUSED__ void *data)
{
- struct mallinfo mi;
- static int uordblks = 0;
- static int fordblks = 0;
- Eina_Bool changed = EINA_FALSE;
+ struct mallinfo mi;
+ static int uordblks = 0;
+ static int fordblks = 0;
+ Eina_Bool changed = EINA_FALSE;
- mi = mallinfo();
+ mi = mallinfo();
#define HAS_CHANGED(Global, Local) \
if (Global != Local) \
@@ -401,18 +391,16 @@ _ecore_memory_statistic(__UNUSED__ void *data)
changed = EINA_TRUE; \
}
- HAS_CHANGED(uordblks, mi.uordblks);
- HAS_CHANGED(fordblks, mi.fordblks);
+ HAS_CHANGED(uordblks, mi.uordblks);
+ HAS_CHANGED(fordblks, mi.fordblks);
- if (changed)
- ERR("[%i] Memory total: %i, free: %i",
- _ecore_memory_pid,
- mi.uordblks,
- mi.fordblks);
+ if (changed)
+ ERR("[%i] Memory total: %i, free: %i",
+ _ecore_memory_pid, mi.uordblks, mi.fordblks);
- KEEP_MAX(_ecore_memory_max_total, mi.uordblks);
- KEEP_MAX(_ecore_memory_max_free, mi.fordblks);
+ KEEP_MAX(_ecore_memory_max_total, mi.uordblks);
+ KEEP_MAX(_ecore_memory_max_free, mi.fordblks);
- return ECORE_CALLBACK_RENEW;
+ return ECORE_CALLBACK_RENEW;
}
#endif
diff --git a/tests/suite/ecore/src/lib/ecore_anim.c b/tests/suite/ecore/src/lib/ecore_anim.c
index 921071e347..ff37e393e9 100644
--- a/tests/suite/ecore/src/lib/ecore_anim.c
+++ b/tests/suite/ecore/src/lib/ecore_anim.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -9,25 +9,24 @@
#include "ecore_private.h"
-struct _Ecore_Animator
-{
- EINA_INLIST;
- ECORE_MAGIC;
+struct _Ecore_Animator {
+ EINA_INLIST;
+ ECORE_MAGIC;
- Ecore_Task_Cb func;
- void *data;
+ Ecore_Task_Cb func;
+ void *data;
- Eina_Bool delete_me : 1;
- Eina_Bool suspended : 1;
+ Eina_Bool delete_me:1;
+ Eina_Bool suspended:1;
};
static Eina_Bool _ecore_animator(void *data);
-static Ecore_Timer *timer = NULL;
-static int animators_delete_me = 0;
+static Ecore_Timer *timer = NULL;
+static int animators_delete_me = 0;
static Ecore_Animator *animators = NULL;
-static double animators_frametime = 1.0 / 30.0;
+static double animators_frametime = 1.0 / 30.0;
/**
* Add a animator to tick off at every animaton tick during main loop execution.
@@ -46,28 +45,34 @@ static double animators_frametime = 1.0 / 30.0;
* next tick, or if it returns 0 (or ECORE_CALLBACK_CANCEL) it will be deleted
* automatically making any references/handles for it invalid.
*/
-EAPI Ecore_Animator *
-ecore_animator_add(Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func,
+ const void *data)
{
- Ecore_Animator *animator;
-
- if (!func) return NULL;
- animator = calloc(1, sizeof(Ecore_Animator));
- if (!animator) return NULL;
- ECORE_MAGIC_SET(animator, ECORE_MAGIC_ANIMATOR);
- animator->func = func;
- animator->data = (void *)data;
- animators = (Ecore_Animator *)eina_inlist_append(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator));
- if (!timer)
- {
- double t_loop = ecore_loop_time_get();
- double sync_0 = 0.0;
- double d = -fmod(t_loop - sync_0, animators_frametime);
-
- timer = ecore_timer_loop_add(animators_frametime, _ecore_animator, NULL);
- ecore_timer_delay(timer, d);
- }
- return animator;
+ Ecore_Animator *animator;
+
+ if (!func)
+ return NULL;
+ animator = calloc(1, sizeof(Ecore_Animator));
+ if (!animator)
+ return NULL;
+ ECORE_MAGIC_SET(animator, ECORE_MAGIC_ANIMATOR);
+ animator->func = func;
+ animator->data = (void *) data;
+ animators =
+ (Ecore_Animator *)
+ eina_inlist_append(EINA_INLIST_GET(animators),
+ EINA_INLIST_GET(animator));
+ if (!timer) {
+ double t_loop = ecore_loop_time_get();
+ double sync_0 = 0.0;
+ double d = -fmod(t_loop - sync_0, animators_frametime);
+
+ timer =
+ ecore_timer_loop_add(animators_frametime,
+ _ecore_animator, NULL);
+ ecore_timer_delay(timer, d);
+ }
+ return animator;
}
/**
@@ -82,19 +87,18 @@ ecore_animator_add(Ecore_Task_Cb func, const void *data)
* call returns the specified animator object @p animator is invalid and should not
* be used again. It will not get called again after deletion.
*/
-EAPI void *
-ecore_animator_del(Ecore_Animator *animator)
+EAPI void *ecore_animator_del(Ecore_Animator * animator)
{
- if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR))
- {
- ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
- "ecore_animator_del");
- return NULL;
- }
- if (animator->delete_me) return animator->data;
- animator->delete_me = EINA_TRUE;
- animators_delete_me++;
- return animator->data;
+ if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) {
+ ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
+ "ecore_animator_del");
+ return NULL;
+ }
+ if (animator->delete_me)
+ return animator->data;
+ animator->delete_me = EINA_TRUE;
+ animators_delete_me++;
+ return animator->data;
}
/**
@@ -103,19 +107,21 @@ ecore_animator_del(Ecore_Animator *animator)
*
* This function sets the time interval (in seconds) between animator ticks.
*/
-EAPI void
-ecore_animator_frametime_set(double frametime)
+EAPI void ecore_animator_frametime_set(double frametime)
{
- if (frametime < 0.0) frametime = 0.0;
- if (animators_frametime == frametime) return;
- animators_frametime = frametime;
- if (timer)
- {
- ecore_timer_del(timer);
- timer = NULL;
- }
- if (animators)
- timer = ecore_timer_add(animators_frametime, _ecore_animator, NULL);
+ if (frametime < 0.0)
+ frametime = 0.0;
+ if (animators_frametime == frametime)
+ return;
+ animators_frametime = frametime;
+ if (timer) {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+ if (animators)
+ timer =
+ ecore_timer_add(animators_frametime, _ecore_animator,
+ NULL);
}
/**
@@ -124,10 +130,9 @@ ecore_animator_frametime_set(double frametime)
*
* this function retrieves the time between animator ticks, in seconds.
*/
-EAPI double
-ecore_animator_frametime_get(void)
+EAPI double ecore_animator_frametime_get(void)
{
- return animators_frametime;
+ return animators_frametime;
}
/**
@@ -138,17 +143,16 @@ ecore_animator_frametime_get(void)
* The specified @p animator will be temporarly removed from the set of animators
* that are executed during main loop execution.
*/
-EAPI void
-ecore_animator_freeze(Ecore_Animator *animator)
+EAPI void ecore_animator_freeze(Ecore_Animator * animator)
{
- if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR))
- {
- ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
- "ecore_animator_del");
- return;
- }
- if (animator->delete_me) return;
- animator->suspended = EINA_TRUE;
+ if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) {
+ ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
+ "ecore_animator_del");
+ return;
+ }
+ if (animator->delete_me)
+ return;
+ animator->suspended = EINA_TRUE;
}
/**
@@ -159,75 +163,73 @@ ecore_animator_freeze(Ecore_Animator *animator)
* The specified @p animator will be put back in the set of animators
* that are executed during main loop execution.
*/
-EAPI void
-ecore_animator_thaw(Ecore_Animator *animator)
+EAPI void ecore_animator_thaw(Ecore_Animator * animator)
{
- if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR))
- {
- ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
- "ecore_animator_del");
- return;
- }
- if (animator->delete_me) return;
- animator->suspended = EINA_FALSE;
+ if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) {
+ ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR,
+ "ecore_animator_del");
+ return;
+ }
+ if (animator->delete_me)
+ return;
+ animator->suspended = EINA_FALSE;
}
-void
-_ecore_animator_shutdown(void)
+void _ecore_animator_shutdown(void)
{
- if (timer)
- {
- ecore_timer_del(timer);
- timer = NULL;
- }
- while (animators)
- {
- Ecore_Animator *animator;
-
- animator = animators;
- animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators));
- ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
- free(animator);
- }
+ if (timer) {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+ while (animators) {
+ Ecore_Animator *animator;
+
+ animator = animators;
+ animators =
+ (Ecore_Animator *)
+ eina_inlist_remove(EINA_INLIST_GET(animators),
+ EINA_INLIST_GET(animators));
+ ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
+ free(animator);
+ }
}
-static Eina_Bool
-_ecore_animator(void *data __UNUSED__)
+static Eina_Bool _ecore_animator(void *data __UNUSED__)
{
- Ecore_Animator *animator;
-
- EINA_INLIST_FOREACH(animators, animator)
- {
- if (!animator->delete_me && !animator->suspended)
- {
- if (!animator->func(animator->data))
- {
- animator->delete_me = EINA_TRUE;
- animators_delete_me++;
- }
- }
- }
- if (animators_delete_me)
- {
- Ecore_Animator *l;
- for(l = animators; l;)
- {
- animator = l;
- l = (Ecore_Animator *) EINA_INLIST_GET(l)->next;
- if (animator->delete_me)
- {
- animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator));
- ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
- free(animator);
- animators_delete_me--;
- if (animators_delete_me == 0) break;
- }
- }
- }
- if (!animators)
- {
- timer = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
- return ECORE_CALLBACK_RENEW;
+ Ecore_Animator *animator;
+
+ EINA_INLIST_FOREACH(animators, animator) {
+ if (!animator->delete_me && !animator->suspended) {
+ if (!animator->func(animator->data)) {
+ animator->delete_me = EINA_TRUE;
+ animators_delete_me++;
+ }
+ }
+ }
+ if (animators_delete_me) {
+ Ecore_Animator *l;
+ for (l = animators; l;) {
+ animator = l;
+ l = (Ecore_Animator *) EINA_INLIST_GET(l)->next;
+ if (animator->delete_me) {
+ animators =
+ (Ecore_Animator *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (animators),
+ EINA_INLIST_GET
+ (animator));
+ ECORE_MAGIC_SET(animator,
+ ECORE_MAGIC_NONE);
+ free(animator);
+ animators_delete_me--;
+ if (animators_delete_me == 0)
+ break;
+ }
+ }
+ }
+ if (!animators) {
+ timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ return ECORE_CALLBACK_RENEW;
}
diff --git a/tests/suite/ecore/src/lib/ecore_app.c b/tests/suite/ecore/src/lib/ecore_app.c
index f9663a50bb..b83e5b2958 100644
--- a/tests/suite/ecore/src/lib/ecore_app.c
+++ b/tests/suite/ecore/src/lib/ecore_app.c
@@ -1,17 +1,17 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
#ifndef _MSC_VER
-# include <unistd.h>
+#include <unistd.h>
#else
-# include <process.h>
+#include <process.h>
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "Ecore.h"
@@ -28,13 +28,12 @@ static char **app_argv = NULL;
* A call to this function will store the programs command-line arguments
* for later use by ecore_app_restart() or ecore_app_args_get().
*/
-EAPI void
-ecore_app_args_set(int argc, const char **argv)
+EAPI void ecore_app_args_set(int argc, const char **argv)
{
- if ((argc < 1) ||
- (!argv)) return;
- app_argc = argc;
- app_argv = (char **)argv;
+ if ((argc < 1) || (!argv))
+ return;
+ app_argc = argc;
+ app_argv = (char **) argv;
}
/**
@@ -48,11 +47,12 @@ ecore_app_args_set(int argc, const char **argv)
* also if the pointer is not NULL. The values they are filled with will be the
* same set by ecore_app_args_set().
*/
-EAPI void
-ecore_app_args_get(int *argc, char ***argv)
+EAPI void ecore_app_args_get(int *argc, char ***argv)
{
- if (argc) *argc = app_argc;
- if (argv) *argv = app_argv;
+ if (argc)
+ *argc = app_argc;
+ if (argv)
+ *argv = app_argv;
}
/**
@@ -63,15 +63,17 @@ ecore_app_args_get(int *argc, char ***argv)
* an easy way for a program to restart itself for cleanup purposes,
* configuration reasons or in the event of a crash.
*/
-EAPI void
-ecore_app_restart(void)
+EAPI void ecore_app_restart(void)
{
- char *args[4096];
- int i;
+ char *args[4096];
+ int i;
- if ((app_argc < 1) || (!app_argv)) return;
- if (app_argc >= 4096) return;
- for (i = 0; i < app_argc; i++) args[i] = app_argv[i];
- args[i] = NULL;
- execvp(app_argv[0], args);
+ if ((app_argc < 1) || (!app_argv))
+ return;
+ if (app_argc >= 4096)
+ return;
+ for (i = 0; i < app_argc; i++)
+ args[i] = app_argv[i];
+ args[i] = NULL;
+ execvp(app_argv[0], args);
}
diff --git a/tests/suite/ecore/src/lib/ecore_events.c b/tests/suite/ecore/src/lib/ecore_events.c
index 470838cb9a..ebe22219d3 100644
--- a/tests/suite/ecore/src/lib/ecore_events.c
+++ b/tests/suite/ecore/src/lib/ecore_events.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -9,40 +9,37 @@
static int inpurge = 0;
-struct _Ecore_Event_Handler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- int type;
- Ecore_Event_Handler_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
+struct _Ecore_Event_Handler {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ int type;
+ Ecore_Event_Handler_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me:1;
};
-struct _Ecore_Event_Filter
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Data_Cb func_start;
- Ecore_Filter_Cb func_filter;
- Ecore_End_Cb func_end;
- void *loop_data;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
+struct _Ecore_Event_Filter {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Data_Cb func_start;
+ Ecore_Filter_Cb func_filter;
+ Ecore_End_Cb func_end;
+ void *loop_data;
+ void *data;
+ int references;
+ Eina_Bool delete_me:1;
};
-struct _Ecore_Event
-{
- EINA_INLIST;
- ECORE_MAGIC;
- int type;
- void *event;
- Ecore_End_Cb func_free;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
+struct _Ecore_Event {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ int type;
+ void *event;
+ Ecore_End_Cb func_free;
+ void *data;
+ int references;
+ Eina_Bool delete_me:1;
};
@@ -63,11 +60,11 @@ static Ecore_Event *event_filter_event_current = NULL;
static int event_filters_delete_me = 0;
static int event_id_max = ECORE_EVENT_COUNT;
static int ecore_raw_event_type = ECORE_EVENT_NONE;
-static void *ecore_raw_event_event = NULL;
+static void *ecore_raw_event_event = NULL;
static void _ecore_event_purge_deleted(void);
-static void *_ecore_event_del(Ecore_Event *event);
+static void *_ecore_event_del(Ecore_Event * event);
/**
@@ -93,44 +90,53 @@ static void *_ecore_event_del(Ecore_Event *event);
* event, so all handler set to handle that event type that have not already
* been called, will not be.
*/
-EAPI Ecore_Event_Handler *
-ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data)
+EAPI Ecore_Event_Handler *ecore_event_handler_add(int type,
+ Ecore_Event_Handler_Cb
+ func, const void *data)
{
- Ecore_Event_Handler *eh;
-
- if (!func) return NULL;
- if ((type <= ECORE_EVENT_NONE) || (type >= event_id_max)) return NULL;
- eh = calloc(1, sizeof(Ecore_Event_Handler));
- if (!eh) return NULL;
- ECORE_MAGIC_SET(eh, ECORE_MAGIC_EVENT_HANDLER);
- eh->type = type;
- eh->func = func;
- eh->data = (void *)data;
- if (type >= (event_handlers_num - 1))
- {
- int p_alloc_num;
-
- p_alloc_num = event_handlers_alloc_num;
- event_handlers_num = type + 1;
- if (event_handlers_num > event_handlers_alloc_num)
- {
- Ecore_Event_Handler **new_handlers;
- int i;
-
- event_handlers_alloc_num = ((event_handlers_num + 16) / 16) * 16;
- new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *));
- if (!new_handlers)
- {
- free(eh);
- return NULL;
- }
- event_handlers = new_handlers;
- for (i = p_alloc_num; i < event_handlers_alloc_num; i++)
- event_handlers[i] = NULL;
- }
- }
- event_handlers[type] = (Ecore_Event_Handler *) eina_inlist_append(EINA_INLIST_GET(event_handlers[type]), EINA_INLIST_GET(eh));
- return eh;
+ Ecore_Event_Handler *eh;
+
+ if (!func)
+ return NULL;
+ if ((type <= ECORE_EVENT_NONE) || (type >= event_id_max))
+ return NULL;
+ eh = calloc(1, sizeof(Ecore_Event_Handler));
+ if (!eh)
+ return NULL;
+ ECORE_MAGIC_SET(eh, ECORE_MAGIC_EVENT_HANDLER);
+ eh->type = type;
+ eh->func = func;
+ eh->data = (void *) data;
+ if (type >= (event_handlers_num - 1)) {
+ int p_alloc_num;
+
+ p_alloc_num = event_handlers_alloc_num;
+ event_handlers_num = type + 1;
+ if (event_handlers_num > event_handlers_alloc_num) {
+ Ecore_Event_Handler **new_handlers;
+ int i;
+
+ event_handlers_alloc_num =
+ ((event_handlers_num + 16) / 16) * 16;
+ new_handlers =
+ realloc(event_handlers,
+ event_handlers_alloc_num *
+ sizeof(Ecore_Event_Handler *));
+ if (!new_handlers) {
+ free(eh);
+ return NULL;
+ }
+ event_handlers = new_handlers;
+ for (i = p_alloc_num; i < event_handlers_alloc_num;
+ i++)
+ event_handlers[i] = NULL;
+ }
+ }
+ event_handlers[type] =
+ (Ecore_Event_Handler *)
+ eina_inlist_append(EINA_INLIST_GET(event_handlers[type]),
+ EINA_INLIST_GET(eh));
+ return eh;
}
/**
@@ -143,25 +149,23 @@ ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data)
* handler was added by ecore_event_handler_add(). On failure NULL will be
* returned. Once a handler is deleted it will no longer be called.
*/
-EAPI void *
-ecore_event_handler_del(Ecore_Event_Handler *event_handler)
+EAPI void *ecore_event_handler_del(Ecore_Event_Handler * event_handler)
{
- if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER))
- {
- ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER,
- "ecore_event_handler_del");
- return NULL;
- }
- EINA_SAFETY_ON_TRUE_RETURN_VAL(event_handler->delete_me, NULL);
- event_handler->delete_me = 1;
- event_handlers_delete_list = eina_list_append(event_handlers_delete_list, event_handler);
- return event_handler->data;
+ if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER)) {
+ ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER,
+ "ecore_event_handler_del");
+ return NULL;
+ }
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(event_handler->delete_me, NULL);
+ event_handler->delete_me = 1;
+ event_handlers_delete_list =
+ eina_list_append(event_handlers_delete_list, event_handler);
+ return event_handler->data;
}
-static void
-_ecore_event_generic_free (void *data __UNUSED__, void *event)
+static void _ecore_event_generic_free(void *data __UNUSED__, void *event)
{
- free (event);
+ free(event);
}
/**
@@ -182,14 +186,17 @@ _ecore_event_generic_free (void *data __UNUSED__, void *event)
* with the private structure pointer.
* func_free is passed @p data as its data parameter.
*/
-EAPI Ecore_Event *
-ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data)
+EAPI Ecore_Event *ecore_event_add(int type, void *ev,
+ Ecore_End_Cb func_free, void *data)
{
/* if (!ev) return NULL;*/
- if (type <= ECORE_EVENT_NONE) return NULL;
- if (type >= event_id_max) return NULL;
- if ((ev) && (!func_free)) func_free = _ecore_event_generic_free;
- return _ecore_event_add(type, ev, func_free, data);
+ if (type <= ECORE_EVENT_NONE)
+ return NULL;
+ if (type >= event_id_max)
+ return NULL;
+ if ((ev) && (!func_free))
+ func_free = _ecore_event_generic_free;
+ return _ecore_event_add(type, ev, func_free, data);
}
/**
@@ -203,17 +210,16 @@ ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data)
* cleanup, and so if the free function depends on the data pointer to work,
* you should defer cleaning of this till the free function is called later.
*/
-EAPI void *
-ecore_event_del(Ecore_Event *event)
+EAPI void *ecore_event_del(Ecore_Event * event)
{
- if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT))
- {
- ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del");
- return NULL;
- }
- EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL);
- event->delete_me = 1;
- return event->data;
+ if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT)) {
+ ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT,
+ "ecore_event_del");
+ return NULL;
+ }
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL);
+ event->delete_me = 1;
+ return event->data;
}
/**
@@ -226,11 +232,10 @@ ecore_event_del(Ecore_Event *event)
* it is calculated, except that the ID will be unique to the current instance
* of the process.
*/
-EAPI int
-ecore_event_type_new(void)
+EAPI int ecore_event_type_new(void)
{
- event_id_max++;
- return event_id_max - 1;
+ event_id_max++;
+ return event_id_max - 1;
}
/**
@@ -253,21 +258,29 @@ ecore_event_type_new(void)
* processing is finished @p func_end is called and is passed the loop_data
* and @p data pointer to clean up.
*/
-EAPI Ecore_Event_Filter *
-ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ecore_End_Cb func_end, const void *data)
+EAPI Ecore_Event_Filter *ecore_event_filter_add(Ecore_Data_Cb func_start,
+ Ecore_Filter_Cb
+ func_filter,
+ Ecore_End_Cb func_end,
+ const void *data)
{
- Ecore_Event_Filter *ef;
-
- if (!func_filter) return NULL;
- ef = calloc(1, sizeof(Ecore_Event_Filter));
- if (!ef) return NULL;
- ECORE_MAGIC_SET(ef, ECORE_MAGIC_EVENT_FILTER);
- ef->func_start = func_start;
- ef->func_filter = func_filter;
- ef->func_end = func_end;
- ef->data = (void *)data;
- event_filters = (Ecore_Event_Filter *) eina_inlist_append(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
- return ef;
+ Ecore_Event_Filter *ef;
+
+ if (!func_filter)
+ return NULL;
+ ef = calloc(1, sizeof(Ecore_Event_Filter));
+ if (!ef)
+ return NULL;
+ ECORE_MAGIC_SET(ef, ECORE_MAGIC_EVENT_FILTER);
+ ef->func_start = func_start;
+ ef->func_filter = func_filter;
+ ef->func_end = func_end;
+ ef->data = (void *) data;
+ event_filters =
+ (Ecore_Event_Filter *)
+ eina_inlist_append(EINA_INLIST_GET(event_filters),
+ EINA_INLIST_GET(ef));
+ return ef;
}
/**
@@ -279,18 +292,17 @@ ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ec
* will return the data pointer set when this filter was added. On failure
* NULL is returned.
*/
-EAPI void *
-ecore_event_filter_del(Ecore_Event_Filter *ef)
+EAPI void *ecore_event_filter_del(Ecore_Event_Filter * ef)
{
- if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER))
- {
- ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del");
- return NULL;
- }
- EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL);
- ef->delete_me = 1;
- event_filters_delete_me = 1;
- return ef->data;
+ if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER)) {
+ ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER,
+ "ecore_event_filter_del");
+ return NULL;
+ }
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL);
+ ef->delete_me = 1;
+ event_filters_delete_me = 1;
+ return ef->data;
}
/**
@@ -307,10 +319,9 @@ ecore_event_filter_del(Ecore_Event_Filter *ef)
* the program know if the event type being handled is one it wants to get more
* information about.
*/
-EAPI int
-ecore_event_current_type_get(void)
+EAPI int ecore_event_current_type_get(void)
{
- return ecore_raw_event_type;
+ return ecore_raw_event_type;
}
/**
@@ -327,333 +338,359 @@ ecore_event_current_type_get(void)
* the program access the event data if the type of the event is handled by
* the program.
*/
-EAPI void *
-ecore_event_current_event_get(void)
+EAPI void *ecore_event_current_event_get(void)
{
- return ecore_raw_event_event;
+ return ecore_raw_event_event;
}
-void
-_ecore_event_shutdown(void)
+void _ecore_event_shutdown(void)
{
- int i;
- Ecore_Event_Handler *eh;
- Ecore_Event_Filter *ef;
-
- while (events) _ecore_event_del(events);
- event_current = NULL;
- for (i = 0; i < event_handlers_num; i++)
- {
- while ((eh = event_handlers[i]))
- {
- event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i]));
- ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
- if (!eh->delete_me) free(eh);
- }
- }
- EINA_LIST_FREE(event_handlers_delete_list, eh)
- free(eh);
- if (event_handlers) free(event_handlers);
- event_handlers = NULL;
- event_handlers_num = 0;
- event_handlers_alloc_num = 0;
- while ((ef = event_filters))
- {
- event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters));
- ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
- free(ef);
- }
- event_filters_delete_me = 0;
- event_filter_current = NULL;
- event_filter_event_current = NULL;
+ int i;
+ Ecore_Event_Handler *eh;
+ Ecore_Event_Filter *ef;
+
+ while (events)
+ _ecore_event_del(events);
+ event_current = NULL;
+ for (i = 0; i < event_handlers_num; i++) {
+ while ((eh = event_handlers[i])) {
+ event_handlers[i] =
+ (Ecore_Event_Handler *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (event_handlers[i]),
+ EINA_INLIST_GET
+ (event_handlers[i]));
+ ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
+ if (!eh->delete_me)
+ free(eh);
+ }
+ }
+ EINA_LIST_FREE(event_handlers_delete_list, eh)
+ free(eh);
+ if (event_handlers)
+ free(event_handlers);
+ event_handlers = NULL;
+ event_handlers_num = 0;
+ event_handlers_alloc_num = 0;
+ while ((ef = event_filters)) {
+ event_filters =
+ (Ecore_Event_Filter *)
+ eina_inlist_remove(EINA_INLIST_GET(event_filters),
+ EINA_INLIST_GET(event_filters));
+ ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
+ free(ef);
+ }
+ event_filters_delete_me = 0;
+ event_filter_current = NULL;
+ event_filter_event_current = NULL;
}
-int
-_ecore_event_exist(void)
+int _ecore_event_exist(void)
{
- Ecore_Event *e;
- EINA_INLIST_FOREACH(events, e)
- if (!e->delete_me) return 1;
- return 0;
+ Ecore_Event *e;
+ EINA_INLIST_FOREACH(events, e)
+ if (!e->delete_me)
+ return 1;
+ return 0;
}
-Ecore_Event *
-_ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data)
+Ecore_Event *_ecore_event_add(int type, void *ev, Ecore_End_Cb func_free,
+ void *data)
{
- Ecore_Event *e;
-
- e = calloc(1, sizeof(Ecore_Event));
- if (!e) return NULL;
- ECORE_MAGIC_SET(e, ECORE_MAGIC_EVENT);
- e->type = type;
- e->event = ev;
- e->func_free = func_free;
- e->data = data;
- if (inpurge > 0)
- {
- purge_events = (Ecore_Event *)eina_inlist_append(EINA_INLIST_GET(purge_events), EINA_INLIST_GET(e));
- events_num++;
- }
- else
- {
- events = (Ecore_Event *)eina_inlist_append(EINA_INLIST_GET(events), EINA_INLIST_GET(e));
- events_num++;
- }
- return e;
+ Ecore_Event *e;
+
+ e = calloc(1, sizeof(Ecore_Event));
+ if (!e)
+ return NULL;
+ ECORE_MAGIC_SET(e, ECORE_MAGIC_EVENT);
+ e->type = type;
+ e->event = ev;
+ e->func_free = func_free;
+ e->data = data;
+ if (inpurge > 0) {
+ purge_events =
+ (Ecore_Event *)
+ eina_inlist_append(EINA_INLIST_GET(purge_events),
+ EINA_INLIST_GET(e));
+ events_num++;
+ } else {
+ events =
+ (Ecore_Event *)
+ eina_inlist_append(EINA_INLIST_GET(events),
+ EINA_INLIST_GET(e));
+ events_num++;
+ }
+ return e;
}
-void *
-_ecore_event_del(Ecore_Event *event)
+void *_ecore_event_del(Ecore_Event * event)
{
- void *data;
-
- data = event->data;
- if (event->func_free) event->func_free(event->data, event->event);
- events = (Ecore_Event *) eina_inlist_remove(EINA_INLIST_GET(events), EINA_INLIST_GET(event));
- ECORE_MAGIC_SET(event, ECORE_MAGIC_NONE);
- free(event);
- events_num--;
- return data;
+ void *data;
+
+ data = event->data;
+ if (event->func_free)
+ event->func_free(event->data, event->event);
+ events =
+ (Ecore_Event *) eina_inlist_remove(EINA_INLIST_GET(events),
+ EINA_INLIST_GET(event));
+ ECORE_MAGIC_SET(event, ECORE_MAGIC_NONE);
+ free(event);
+ events_num--;
+ return data;
}
-static void
-_ecore_event_purge_deleted(void)
+static void _ecore_event_purge_deleted(void)
{
- Ecore_Event *itr = events;
-
- inpurge++;
- while (itr)
- {
- Ecore_Event *next = (Ecore_Event *)EINA_INLIST_GET(itr)->next;
- if ((!itr->references) && (itr->delete_me))
- _ecore_event_del(itr);
- itr = next;
- }
- inpurge--;
- while (purge_events)
- {
- Ecore_Event *e = purge_events;
- purge_events = (Ecore_Event *)eina_inlist_remove(EINA_INLIST_GET(purge_events), EINA_INLIST_GET(purge_events));
- events = (Ecore_Event *)eina_inlist_append(EINA_INLIST_GET(events), EINA_INLIST_GET(e));
- }
+ Ecore_Event *itr = events;
+
+ inpurge++;
+ while (itr) {
+ Ecore_Event *next =
+ (Ecore_Event *) EINA_INLIST_GET(itr)->next;
+ if ((!itr->references) && (itr->delete_me))
+ _ecore_event_del(itr);
+ itr = next;
+ }
+ inpurge--;
+ while (purge_events) {
+ Ecore_Event *e = purge_events;
+ purge_events =
+ (Ecore_Event *)
+ eina_inlist_remove(EINA_INLIST_GET(purge_events),
+ EINA_INLIST_GET(purge_events));
+ events =
+ (Ecore_Event *)
+ eina_inlist_append(EINA_INLIST_GET(events),
+ EINA_INLIST_GET(e));
+ }
}
-static inline void
-_ecore_event_filters_apply()
+static inline void _ecore_event_filters_apply()
{
- if (!event_filter_current)
- {
- /* regular main loop, start from head */
- event_filter_current = event_filters;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next;
- }
-
- while (event_filter_current)
- {
- Ecore_Event_Filter *ef = event_filter_current;
-
- if (!ef->delete_me)
- {
- ef->references++;
-
- if (ef->func_start)
- ef->loop_data = ef->func_start(ef->data);
-
- if (!event_filter_event_current)
- {
- /* regular main loop, start from head */
- event_filter_event_current = events;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
- }
-
- while (event_filter_event_current)
- {
- Ecore_Event *e = event_filter_event_current;
-
- if (!ef->func_filter(ef->data, ef->loop_data,
- e->type, e->event))
- {
- ecore_event_del(e);
- }
-
- if (event_filter_event_current) /* may have changed in recursive main loops */
- event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
- }
- if (ef->func_end)
- ef->func_end(ef->data, ef->loop_data);
-
- ef->references--;
- }
-
- if (event_filter_current) /* may have changed in recursive main loops */
- event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next;
- }
- if (event_filters_delete_me)
- {
- int deleted_in_use = 0;
- Ecore_Event_Filter *l;
- for (l = event_filters; l;)
- {
- Ecore_Event_Filter *ef = l;
- l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next;
- if (ef->delete_me)
- {
- if (ef->references)
- {
- deleted_in_use++;
- continue;
- }
-
- event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
- ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
- free(ef);
- }
- }
- if (!deleted_in_use)
- event_filters_delete_me = 0;
- }
+ if (!event_filter_current) {
+ /* regular main loop, start from head */
+ event_filter_current = event_filters;
+ } else {
+ /* recursive main loop, continue from where we were */
+ event_filter_current =
+ (Ecore_Event_Filter *)
+ EINA_INLIST_GET(event_filter_current)->next;
+ }
+
+ while (event_filter_current) {
+ Ecore_Event_Filter *ef = event_filter_current;
+
+ if (!ef->delete_me) {
+ ef->references++;
+
+ if (ef->func_start)
+ ef->loop_data = ef->func_start(ef->data);
+
+ if (!event_filter_event_current) {
+ /* regular main loop, start from head */
+ event_filter_event_current = events;
+ } else {
+ /* recursive main loop, continue from where we were */
+ event_filter_event_current =
+ (Ecore_Event *)
+ EINA_INLIST_GET
+ (event_filter_event_current)->next;
+ }
+
+ while (event_filter_event_current) {
+ Ecore_Event *e =
+ event_filter_event_current;
+
+ if (!ef->
+ func_filter(ef->data, ef->loop_data,
+ e->type, e->event)) {
+ ecore_event_del(e);
+ }
+
+ if (event_filter_event_current) /* may have changed in recursive main loops */
+ event_filter_event_current =
+ (Ecore_Event *)
+ EINA_INLIST_GET
+ (event_filter_event_current)->
+ next;
+ }
+ if (ef->func_end)
+ ef->func_end(ef->data, ef->loop_data);
+
+ ef->references--;
+ }
+
+ if (event_filter_current) /* may have changed in recursive main loops */
+ event_filter_current =
+ (Ecore_Event_Filter *)
+ EINA_INLIST_GET(event_filter_current)->next;
+ }
+ if (event_filters_delete_me) {
+ int deleted_in_use = 0;
+ Ecore_Event_Filter *l;
+ for (l = event_filters; l;) {
+ Ecore_Event_Filter *ef = l;
+ l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->
+ next;
+ if (ef->delete_me) {
+ if (ef->references) {
+ deleted_in_use++;
+ continue;
+ }
+
+ event_filters =
+ (Ecore_Event_Filter *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (event_filters),
+ EINA_INLIST_GET
+ (ef));
+ ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
+ free(ef);
+ }
+ }
+ if (!deleted_in_use)
+ event_filters_delete_me = 0;
+ }
}
-void
-_ecore_event_call(void)
+
+void _ecore_event_call(void)
{
- Eina_List *l, *l_next;
- Ecore_Event_Handler *eh;
-
- _ecore_event_filters_apply();
-
- if (!event_current)
- {
- /* regular main loop, start from head */
- event_current = events;
- event_handler_current = NULL;
- }
-
- while (event_current)
- {
- Ecore_Event *e = event_current;
- int handle_count = 0;
-
- if (e->delete_me)
- {
- event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next;
- continue;
- }
-
- ecore_raw_event_type = e->type;
- ecore_raw_event_event = e->event;
- e->references++;
- if ((e->type >= 0) && (e->type < event_handlers_num))
- {
- if (!event_handler_current)
- {
- /* regular main loop, start from head */
- event_handler_current = event_handlers[e->type];
- }
- else
- {
- /* recursive main loop, continue from where we were */
- event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next;
- }
-
- while ((event_handler_current) && (!e->delete_me))
- {
- Ecore_Event_Handler *eh = event_handler_current;
- if (!eh->delete_me)
- {
- Eina_Bool ret;
-
- handle_count++;
-
- eh->references++;
- ret = eh->func(eh->data, e->type, e->event);
- eh->references--;
-
- if (!ret)
- {
- event_handler_current = NULL;
- break; /* 0 == "call no further handlers" */
- }
- }
-
- if (event_handler_current) /* may have changed in recursive main loops */
- event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next;
- }
- }
- /* if no handlers were set for EXIT signal - then default is */
- /* to quit the main loop */
- if ((e->type == ECORE_EVENT_SIGNAL_EXIT) && (handle_count == 0))
- ecore_main_loop_quit();
- e->references--;
- e->delete_me = 1;
-
- if (event_current) /* may have changed in recursive main loops */
- event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next;
- }
-
- ecore_raw_event_type = ECORE_EVENT_NONE;
- ecore_raw_event_event = NULL;
-
- _ecore_event_purge_deleted();
-
- EINA_LIST_FOREACH_SAFE(event_handlers_delete_list, l, l_next, eh)
- {
- if (eh->references) continue;
-
- event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l);
-
- event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh));
- ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
- free(eh);
- }
+ Eina_List *l, *l_next;
+ Ecore_Event_Handler *eh;
+
+ _ecore_event_filters_apply();
+
+ if (!event_current) {
+ /* regular main loop, start from head */
+ event_current = events;
+ event_handler_current = NULL;
+ }
+
+ while (event_current) {
+ Ecore_Event *e = event_current;
+ int handle_count = 0;
+
+ if (e->delete_me) {
+ event_current =
+ (Ecore_Event *)
+ EINA_INLIST_GET(event_current)->next;
+ continue;
+ }
+
+ ecore_raw_event_type = e->type;
+ ecore_raw_event_event = e->event;
+ e->references++;
+ if ((e->type >= 0) && (e->type < event_handlers_num)) {
+ if (!event_handler_current) {
+ /* regular main loop, start from head */
+ event_handler_current =
+ event_handlers[e->type];
+ } else {
+ /* recursive main loop, continue from where we were */
+ event_handler_current =
+ (Ecore_Event_Handler *)
+ EINA_INLIST_GET
+ (event_handler_current)->next;
+ }
+
+ while ((event_handler_current) && (!e->delete_me)) {
+ Ecore_Event_Handler *eh =
+ event_handler_current;
+ if (!eh->delete_me) {
+ Eina_Bool ret;
+
+ handle_count++;
+
+ eh->references++;
+ ret =
+ eh->func(eh->data, e->type,
+ e->event);
+ eh->references--;
+
+ if (!ret) {
+ event_handler_current =
+ NULL;
+ break; /* 0 == "call no further handlers" */
+ }
+ }
+
+ if (event_handler_current) /* may have changed in recursive main loops */
+ event_handler_current =
+ (Ecore_Event_Handler *)
+ EINA_INLIST_GET
+ (event_handler_current)->next;
+ }
+ }
+ /* if no handlers were set for EXIT signal - then default is */
+ /* to quit the main loop */
+ if ((e->type == ECORE_EVENT_SIGNAL_EXIT)
+ && (handle_count == 0))
+ ecore_main_loop_quit();
+ e->references--;
+ e->delete_me = 1;
+
+ if (event_current) /* may have changed in recursive main loops */
+ event_current =
+ (Ecore_Event *)
+ EINA_INLIST_GET(event_current)->next;
+ }
+
+ ecore_raw_event_type = ECORE_EVENT_NONE;
+ ecore_raw_event_event = NULL;
+
+ _ecore_event_purge_deleted();
+
+ EINA_LIST_FOREACH_SAFE(event_handlers_delete_list, l, l_next, eh) {
+ if (eh->references)
+ continue;
+
+ event_handlers_delete_list =
+ eina_list_remove_list(event_handlers_delete_list, l);
+
+ event_handlers[eh->type] =
+ (Ecore_Event_Handler *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (event_handlers[eh->type]),
+ EINA_INLIST_GET(eh));
+ ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
+ free(eh);
+ }
}
-EAPI void *
-_ecore_event_signal_user_new(void)
+EAPI void *_ecore_event_signal_user_new(void)
{
- Ecore_Event_Signal_User *e;
+ Ecore_Event_Signal_User *e;
- e = calloc(1, sizeof(Ecore_Event_Signal_User));
- return e;
+ e = calloc(1, sizeof(Ecore_Event_Signal_User));
+ return e;
}
-void *
-_ecore_event_signal_hup_new(void)
+void *_ecore_event_signal_hup_new(void)
{
- Ecore_Event_Signal_Hup *e;
+ Ecore_Event_Signal_Hup *e;
- e = calloc(1, sizeof(Ecore_Event_Signal_Hup));
- return e;
+ e = calloc(1, sizeof(Ecore_Event_Signal_Hup));
+ return e;
}
-void *
-_ecore_event_signal_exit_new(void)
+void *_ecore_event_signal_exit_new(void)
{
- Ecore_Event_Signal_Exit *e;
+ Ecore_Event_Signal_Exit *e;
- e = calloc(1, sizeof(Ecore_Event_Signal_Exit));
- return e;
+ e = calloc(1, sizeof(Ecore_Event_Signal_Exit));
+ return e;
}
-void *
-_ecore_event_signal_power_new(void)
+void *_ecore_event_signal_power_new(void)
{
- Ecore_Event_Signal_Power *e;
+ Ecore_Event_Signal_Power *e;
- e = calloc(1, sizeof(Ecore_Event_Signal_Power));
- return e;
+ e = calloc(1, sizeof(Ecore_Event_Signal_Power));
+ return e;
}
-void *
-_ecore_event_signal_realtime_new(void)
+void *_ecore_event_signal_realtime_new(void)
{
- return calloc(1, sizeof(Ecore_Event_Signal_Realtime));
+ return calloc(1, sizeof(Ecore_Event_Signal_Realtime));
}
diff --git a/tests/suite/ecore/src/lib/ecore_exe.c b/tests/suite/ecore/src/lib/ecore_exe.c
index e83dfe9c91..883243a923 100644
--- a/tests/suite/ecore/src/lib/ecore_exe.c
+++ b/tests/suite/ecore/src/lib/ecore_exe.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <sys/time.h>
@@ -14,7 +14,7 @@
#include <fcntl.h>
#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
+#include <sys/wait.h>
#endif
#include "Ecore.h"
@@ -82,40 +82,39 @@
* hurt. The user code may need to be informed that a timeout is in progress.
*/
-struct _Ecore_Exe
-{
- EINA_INLIST;
- ECORE_MAGIC;
- pid_t pid;
- void *data;
- char *tag, *cmd;
- Ecore_Exe_Flags flags;
- Ecore_Fd_Handler *write_fd_handler; /* the fd_handler to handle write to child - if this was used, or NULL if not */
- Ecore_Fd_Handler *read_fd_handler; /* the fd_handler to handle read from child - if this was used, or NULL if not */
- Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */
- void *write_data_buf; /* a data buffer for data to write to the child -
- * realloced as needed for more data and flushed when the fd handler says writes are possible
- */
- int write_data_size; /* the size in bytes of the data buffer */
- int write_data_offset; /* the offset in bytes in the data buffer */
- void *read_data_buf; /* data read from the child awating delivery to an event */
- int read_data_size; /* data read from child in bytes */
- void *error_data_buf; /* errors read from the child awating delivery to an event */
- int error_data_size; /* errors read from child in bytes */
- int child_fd_write; /* fd to write TO to send data to the child */
- int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */
- int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */
- int child_fd_write_x; /* fd to write TO to send data to the child */
- int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */
- int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */
- Eina_Bool close_stdin : 1;
-
- int start_bytes, end_bytes, start_lines, end_lines; /* Number of bytes/lines to auto pipe at start/end of stdout/stderr. */
-
- Ecore_Timer *doomsday_clock; /* The Timer of Death. Muahahahaha. */
- void *doomsday_clock_dead; /* data for the doomsday clock */
-
- Ecore_Exe_Cb pre_free_cb;
+struct _Ecore_Exe {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ pid_t pid;
+ void *data;
+ char *tag, *cmd;
+ Ecore_Exe_Flags flags;
+ Ecore_Fd_Handler *write_fd_handler; /* the fd_handler to handle write to child - if this was used, or NULL if not */
+ Ecore_Fd_Handler *read_fd_handler; /* the fd_handler to handle read from child - if this was used, or NULL if not */
+ Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */
+ void *write_data_buf; /* a data buffer for data to write to the child -
+ * realloced as needed for more data and flushed when the fd handler says writes are possible
+ */
+ int write_data_size; /* the size in bytes of the data buffer */
+ int write_data_offset; /* the offset in bytes in the data buffer */
+ void *read_data_buf; /* data read from the child awating delivery to an event */
+ int read_data_size; /* data read from child in bytes */
+ void *error_data_buf; /* errors read from the child awating delivery to an event */
+ int error_data_size; /* errors read from child in bytes */
+ int child_fd_write; /* fd to write TO to send data to the child */
+ int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */
+ int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */
+ int child_fd_write_x; /* fd to write TO to send data to the child */
+ int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */
+ int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */
+ Eina_Bool close_stdin:1;
+
+ int start_bytes, end_bytes, start_lines, end_lines; /* Number of bytes/lines to auto pipe at start/end of stdout/stderr. */
+
+ Ecore_Timer *doomsday_clock; /* The Timer of Death. Muahahahaha. */
+ void *doomsday_clock_dead; /* data for the doomsday clock */
+
+ Ecore_Exe_Cb pre_free_cb;
};
@@ -131,25 +130,35 @@ struct _Ecore_Exe
* appended with a preceding space. The first is the command off course.
*/
-struct _ecore_exe_dead_exe
-{
- pid_t pid;
- char *cmd;
+struct _ecore_exe_dead_exe {
+ pid_t pid;
+ char *cmd;
};
-static inline void _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags);
-static Eina_Bool _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, Ecore_Exe_Flags flags);
-static Eina_Bool _ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler *fd_handler);
-static Eina_Bool _ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler *fd_handler);
-static Eina_Bool _ecore_exe_data_write_handler(void *data, Ecore_Fd_Handler *fd_handler);
+static inline void _ecore_exe_exec_it(const char *exe_cmd,
+ Ecore_Exe_Flags flags);
+static Eina_Bool _ecore_exe_data_generic_handler(void *data,
+ Ecore_Fd_Handler *
+ fd_handler,
+ Ecore_Exe_Flags flags);
+static Eina_Bool _ecore_exe_data_error_handler(void *data,
+ Ecore_Fd_Handler *
+ fd_handler);
+static Eina_Bool _ecore_exe_data_read_handler(void *data,
+ Ecore_Fd_Handler *
+ fd_handler);
+static Eina_Bool _ecore_exe_data_write_handler(void *data,
+ Ecore_Fd_Handler *
+ fd_handler);
static void _ecore_exe_flush(Ecore_Exe * exe);
-static void _ecore_exe_event_exe_data_free(void *data __UNUSED__, void *ev);
+static void _ecore_exe_event_exe_data_free(void *data __UNUSED__,
+ void *ev);
static Ecore_Exe *_ecore_exe_is_it_alive(pid_t pid);
static Eina_Bool _ecore_exe_make_sure_its_dead(void *data);
static Eina_Bool _ecore_exe_make_sure_its_really_dead(void *data);
static Ecore_Exe_Event_Add *_ecore_exe_event_add_new(void);
static void _ecore_exe_event_add_free(void *data, void *ev);
-static void _ecore_exe_dead_attach(Ecore_Exe *exe);
+static void _ecore_exe_dead_attach(Ecore_Exe * exe);
EAPI int ECORE_EXE_EVENT_ADD = 0;
EAPI int ECORE_EXE_EVENT_DEL = 0;
@@ -174,14 +183,12 @@ static int _ecore_exe_check_errno(int result, const char *file, int line);
#define E_IF_NO_ERRNO_NOLOOP(result, foo, ok) \
if (((ok) = _ecore_exe_check_errno( (result) = (foo), __FILE__, __LINE__)))
-static int
-_ecore_exe_check_errno(int result, const char *file, int line)
+static int _ecore_exe_check_errno(int result, const char *file, int line)
{
- int saved_errno = errno;
+ int saved_errno = errno;
- if (result == -1)
- {
- perror("*** errno reports ");
+ if (result == -1) {
+ perror("*** errno reports ");
/* What is currently supported -
*
* pipe
@@ -237,64 +244,65 @@ _ecore_exe_check_errno(int result, const char *file, int line)
* // Something failed, cleanup.
* }
*/
- switch (saved_errno)
- {
- case EACCES:
- case EAGAIN:
- case EINTR:
- { /* Not now, try later. */
- ERR("*** Must try again in %s @%u.", file, line);
- result = -1;
- break;
- }
- case EMFILE:
- case ENFILE:
- case ENOLCK:
- { /* Low on resources. */
- ERR("*** Low on resources in %s @%u.", file,
- line);
- result = 0;
- break;
- }
- case EIO:
- { /* I/O error. */
- ERR("*** I/O error in %s @%u.", file, line);
- result = 0;
- break;
- }
- case EFAULT:
- case EBADF:
- case EINVAL:
- case EROFS:
- case EISDIR:
- case EDEADLK:
- case EPERM:
- case EBUSY:
- { /* Programmer fucked up. */
- ERR("*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code in %s @%u. Tut tut tut!",
- file, line);
- result = 0;
- break;
- }
- default:
- { /* Unsupported errno code, please add this one. */
- ERR("*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Unsupported errno code %d, please add this one.\n"
- "*** Now go fix your code in %s @%u, from %s @%u. Tut tut tut!",
- saved_errno, __FILE__, __LINE__, file, line);
- result = 0;
- break;
- }
- }
- }
- else /* Everything is fine. */
- result = 1;
-
- errno = saved_errno;
- return result;
+ switch (saved_errno) {
+ case EACCES:
+ case EAGAIN:
+ case EINTR:
+ { /* Not now, try later. */
+ ERR("*** Must try again in %s @%u.", file,
+ line);
+ result = -1;
+ break;
+ }
+ case EMFILE:
+ case ENFILE:
+ case ENOLCK:
+ { /* Low on resources. */
+ ERR("*** Low on resources in %s @%u.",
+ file, line);
+ result = 0;
+ break;
+ }
+ case EIO:
+ { /* I/O error. */
+ ERR("*** I/O error in %s @%u.", file,
+ line);
+ result = 0;
+ break;
+ }
+ case EFAULT:
+ case EBADF:
+ case EINVAL:
+ case EROFS:
+ case EISDIR:
+ case EDEADLK:
+ case EPERM:
+ case EBUSY:
+ { /* Programmer fucked up. */
+ ERR("*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code in %s @%u. Tut tut tut!",
+ file, line);
+ result = 0;
+ break;
+ }
+ default:
+ { /* Unsupported errno code, please add this one. */
+ ERR("*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Unsupported errno code %d, please add this one.\n"
+ "*** Now go fix your code in %s @%u, from %s @%u. Tut tut tut!",
+ saved_errno, __FILE__, __LINE__, file,
+ line);
+ result = 0;
+ break;
+ }
+ }
+ } else /* Everything is fine. */
+ result = 1;
+
+ errno = saved_errno;
+ return result;
}
/**
@@ -322,10 +330,9 @@ static int run_pri = ECORE_EXE_PRIORITY_INHERIT;
* to 19 or ECORE_EXE_PRIORITY_INHERIT on other OS.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI void
-ecore_exe_run_priority_set(int pri)
+EAPI void ecore_exe_run_priority_set(int pri)
{
- run_pri = pri;
+ run_pri = pri;
}
/**
@@ -338,10 +345,9 @@ ecore_exe_run_priority_set(int pri)
* @return the value set by ecore_exe_run_priority_set()
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI int
-ecore_exe_run_priority_get(void)
+EAPI int ecore_exe_run_priority_get(void)
{
- return run_pri;
+ return run_pri;
}
/**
@@ -354,37 +360,34 @@ ecore_exe_run_priority_get(void)
* @return A process handle to the spawned process.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI Ecore_Exe *
-ecore_exe_run(const char *exe_cmd, const void *data)
+EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data)
{
/* I'm just being paranoid again, leaving in the original code in case there is a problem. */
#if 0
- Ecore_Exe *exe;
- pid_t pid;
-
- if (!exe_cmd)
- return NULL;
- pid = fork();
- if (pid)
- {
- exe = calloc(1, sizeof(Ecore_Exe));
- if (!exe)
- {
- kill(pid, SIGKILL);
- return NULL;
- }
- ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
- exe->pid = pid;
- exe->data = (void *)data;
- exe->cmd = strdup(exe_cmd);
- exes = _ecore_list2_append(exes, exe);
- return exe;
- }
- _ecore_exe_exec_it(exe_cmd, 0);
- exit(127);
- return NULL;
+ Ecore_Exe *exe;
+ pid_t pid;
+
+ if (!exe_cmd)
+ return NULL;
+ pid = fork();
+ if (pid) {
+ exe = calloc(1, sizeof(Ecore_Exe));
+ if (!exe) {
+ kill(pid, SIGKILL);
+ return NULL;
+ }
+ ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
+ exe->pid = pid;
+ exe->data = (void *) data;
+ exe->cmd = strdup(exe_cmd);
+ exes = _ecore_list2_append(exes, exe);
+ return exe;
+ }
+ _ecore_exe_exec_it(exe_cmd, 0);
+ exit(127);
+ return NULL;
#else
- return ecore_exe_pipe_run(exe_cmd, 0, data);
+ return ecore_exe_pipe_run(exe_cmd, 0, data);
#endif
}
@@ -414,282 +417,313 @@ ecore_exe_run(const char *exe_cmd, const void *data)
* @return A process handle to the spawned process.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI Ecore_Exe *
-ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
+EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd,
+ Ecore_Exe_Flags flags, const void *data)
{
- Ecore_Exe *exe = NULL;
- int statusPipe[2] = { -1, -1 };
- int errorPipe[2] = { -1, -1 };
- int readPipe[2] = { -1, -1 };
- int writePipe[2] = { -1, -1 };
- int n = 0;
- int ok = 1;
- int result;
-
- if (!exe_cmd) return NULL;
- exe = calloc(1, sizeof(Ecore_Exe));
- if (!exe) return NULL;
-
- if ((flags & ECORE_EXE_PIPE_AUTO) && (!(flags & ECORE_EXE_PIPE_ERROR))
- && (!(flags & ECORE_EXE_PIPE_READ)))
- /* We need something to auto pipe. */
- flags |= ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR;
-
- exe->child_fd_error = -1;
- exe->child_fd_read = -1;
- exe->child_fd_write = -1;
- exe->child_fd_error_x = -1;
- exe->child_fd_read_x = -1;
- exe->child_fd_write_x = -1;
-
- /* Create some pipes. */
- if (ok)
- {
- E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok)
- {
- }
- }
- if (ok && (flags & ECORE_EXE_PIPE_ERROR))
- {
- E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok)
- {
- exe->child_fd_error = errorPipe[0];
- exe->child_fd_error_x = errorPipe[1];
- }
- }
- if (ok && (flags & ECORE_EXE_PIPE_READ))
- {
- E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok)
- {
- exe->child_fd_read = readPipe[0];
- exe->child_fd_read_x = readPipe[1];
- }
- }
- if (ok && (flags & ECORE_EXE_PIPE_WRITE))
- {
- E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok)
- {
- exe->child_fd_write = writePipe[1];
- exe->child_fd_write_x = writePipe[0];
- }
- }
- if (ok)
- {
- pid_t pid = 0;
- volatile int vfork_exec_errno = 0;
-
- /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */
- /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */
- pid = fork();
-
- if (pid == -1)
- {
- ERR("Failed to fork process");
- pid = 0;
- }
- else if (pid == 0) /* child */
- {
- if (run_pri != ECORE_EXE_PRIORITY_INHERIT)
- {
- if ((run_pri >= -20) && (run_pri <= 19))
- setpriority(PRIO_PROCESS, 0, run_pri);
- }
- /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the
- * second pipe if it's open. On the other hand, there was the
- * Great FD Leak Scare of '06, so let's be paranoid. */
- if (ok && (flags & ECORE_EXE_PIPE_ERROR))
- {
- E_NO_ERRNO(result, close(STDERR_FILENO), ok);
- E_NO_ERRNO(result, dup2(errorPipe[1], STDERR_FILENO), ok);
- }
- if (ok && (flags & ECORE_EXE_PIPE_READ))
- {
- E_NO_ERRNO(result, close(STDOUT_FILENO), ok);
- E_NO_ERRNO(result, dup2(readPipe[1], STDOUT_FILENO), ok);
- }
- if (ok && (flags & ECORE_EXE_PIPE_WRITE))
- {
- E_NO_ERRNO(result, close(STDIN_FILENO), ok);
- E_NO_ERRNO(result, dup2(writePipe[0], STDIN_FILENO), ok);
- }
-
- if (ok)
- {
- /* Setup the status pipe. */
- E_NO_ERRNO(result, close(statusPipe[0]), ok);
- E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows success */
- {
- /* Run the actual command. */
- _ecore_exe_exec_it(exe_cmd, flags); /* no return */
- }
- }
-
- /* Something went 'orribly wrong. */
- vfork_exec_errno = errno;
-
- /* Close the pipes. */
- if (flags & ECORE_EXE_PIPE_ERROR)
- E_NO_ERRNO(result, close(errorPipe[1]), ok);
- if (flags & ECORE_EXE_PIPE_READ)
- E_NO_ERRNO(result, close(readPipe[1]), ok);
- if (flags & ECORE_EXE_PIPE_WRITE)
- E_NO_ERRNO(result, close(writePipe[0]), ok);
- E_NO_ERRNO(result, close(statusPipe[1]), ok);
-
- _exit(-1);
- }
- else /* parent */
- {
- /* Close the unused pipes. */
- E_NO_ERRNO(result, close(statusPipe[1]), ok);
-
- /* FIXME: after having a good look at the current e fd
- * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */
- /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO
- * which is also linux specific so we probably don't want to
- * do this as long as select() is working fine. the only time
- * we really want to think of SIGIO async IO is when it all
- * actually works basically everywhere and we can turn all
- * IO into DMA async activities (i.e. you do a read() then
- * the read is complete not on return but when you get a
- * SIGIO - the read() just starts the transfer and it is
- * completed in the background by DMA (or whatever mechanism
- * the kernel choses)) */
-
- /* Wait for it to start executing. */
- /* FIXME: this doesn't seem very nice - we sit and block
- * waiting on a child process... even though it's just
- * the segment between the fork() and the exec) it just feels
- * wrong */
- for (;;)
- {
- char buf;
-
- E_NO_ERRNO(result, read(statusPipe[0], &buf, 1), ok);
- if (result == 0)
- {
- if (vfork_exec_errno != 0)
- {
- n = vfork_exec_errno;
- ERR("Could not start \"%s\"", exe_cmd);
- pid = 0;
- }
- break;
- }
- }
-
- /* Close the status pipe. */
- E_NO_ERRNO(result, close(statusPipe[0]), ok);
- }
-
- if (pid)
- {
- /* Setup the exe structure. */
- ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
- exe->start_bytes = -1;
- exe->end_bytes = -1;
- exe->start_lines = -1;
- exe->end_lines = -1;
- exe->pid = pid;
- exe->flags = flags;
- exe->data = (void *)data;
- if ((exe->cmd = strdup(exe_cmd)))
- {
- if (flags & ECORE_EXE_PIPE_ERROR)
- { /* Setup the error stuff. */
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_error, F_SETFL,
- O_NONBLOCK), ok) {}
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_error, F_SETFD,
- FD_CLOEXEC), ok) {}
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_error_x, F_SETFD,
- FD_CLOEXEC), ok) {}
- {
- exe->error_fd_handler =
- ecore_main_fd_handler_add(exe->child_fd_error,
- ECORE_FD_READ,
- _ecore_exe_data_error_handler,
- exe, NULL, NULL);
- if (!exe->error_fd_handler)
- ok = 0;
- }
- }
- if (ok && (flags & ECORE_EXE_PIPE_READ))
- { /* Setup the read stuff. */
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_read, F_SETFL,
- O_NONBLOCK), ok) {}
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_read, F_SETFD,
- FD_CLOEXEC), ok) {}
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_read_x, F_SETFD,
- FD_CLOEXEC), ok) {}
- {
- exe->read_fd_handler =
- ecore_main_fd_handler_add(exe->child_fd_read,
- ECORE_FD_READ,
- _ecore_exe_data_read_handler,
- exe, NULL, NULL);
- if (!exe->read_fd_handler)
- ok = 0;
- }
- }
- if (ok && (flags & ECORE_EXE_PIPE_WRITE))
- { /* Setup the write stuff. */
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_write, F_SETFL,
- O_NONBLOCK), ok) {}
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_write, F_SETFD,
- FD_CLOEXEC), ok) {}
- E_IF_NO_ERRNO(result,
- fcntl(exe->child_fd_write_x, F_SETFD,
- FD_CLOEXEC), ok) {}
- {
- exe->write_fd_handler =
- ecore_main_fd_handler_add(exe->child_fd_write,
- ECORE_FD_WRITE,
- _ecore_exe_data_write_handler,
- exe, NULL, NULL);
- if (exe->write_fd_handler)
- ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */
- else
- ok = 0;
- }
- }
-
- exes = (Ecore_Exe *) eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe));
- n = 0;
- }
- else
- ok = 0;
- }
- else
- ok = 0;
- }
-
- if (!ok)
- { /* Something went wrong, so pull down everything. */
- if (exe->pid) ecore_exe_terminate(exe);
- IF_FN_DEL(ecore_exe_free, exe);
- }
- else
- {
- Ecore_Exe_Event_Add *e;
-
- e = _ecore_exe_event_add_new();
- e->exe = exe;
- if (e) /* Send the event. */
- ecore_event_add(ECORE_EXE_EVENT_ADD, e,
- _ecore_exe_event_add_free, NULL);
- /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */
- }
-
- errno = n;
- return exe;
+ Ecore_Exe *exe = NULL;
+ int statusPipe[2] = { -1, -1 };
+ int errorPipe[2] = { -1, -1 };
+ int readPipe[2] = { -1, -1 };
+ int writePipe[2] = { -1, -1 };
+ int n = 0;
+ int ok = 1;
+ int result;
+
+ if (!exe_cmd)
+ return NULL;
+ exe = calloc(1, sizeof(Ecore_Exe));
+ if (!exe)
+ return NULL;
+
+ if ((flags & ECORE_EXE_PIPE_AUTO)
+ && (!(flags & ECORE_EXE_PIPE_ERROR))
+ && (!(flags & ECORE_EXE_PIPE_READ)))
+ /* We need something to auto pipe. */
+ flags |= ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR;
+
+ exe->child_fd_error = -1;
+ exe->child_fd_read = -1;
+ exe->child_fd_write = -1;
+ exe->child_fd_error_x = -1;
+ exe->child_fd_read_x = -1;
+ exe->child_fd_write_x = -1;
+
+ /* Create some pipes. */
+ if (ok) {
+ E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok) {
+ }
+ }
+ if (ok && (flags & ECORE_EXE_PIPE_ERROR)) {
+ E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok) {
+ exe->child_fd_error = errorPipe[0];
+ exe->child_fd_error_x = errorPipe[1];
+ }
+ }
+ if (ok && (flags & ECORE_EXE_PIPE_READ)) {
+ E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok) {
+ exe->child_fd_read = readPipe[0];
+ exe->child_fd_read_x = readPipe[1];
+ }
+ }
+ if (ok && (flags & ECORE_EXE_PIPE_WRITE)) {
+ E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok) {
+ exe->child_fd_write = writePipe[1];
+ exe->child_fd_write_x = writePipe[0];
+ }
+ }
+ if (ok) {
+ pid_t pid = 0;
+ volatile int vfork_exec_errno = 0;
+
+ /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */
+ /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */
+ pid = fork();
+
+ if (pid == -1) {
+ ERR("Failed to fork process");
+ pid = 0;
+ } else if (pid == 0) { /* child */
+ if (run_pri != ECORE_EXE_PRIORITY_INHERIT) {
+ if ((run_pri >= -20) && (run_pri <= 19))
+ setpriority(PRIO_PROCESS, 0,
+ run_pri);
+ }
+ /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the
+ * second pipe if it's open. On the other hand, there was the
+ * Great FD Leak Scare of '06, so let's be paranoid. */
+ if (ok && (flags & ECORE_EXE_PIPE_ERROR)) {
+ E_NO_ERRNO(result, close(STDERR_FILENO),
+ ok);
+ E_NO_ERRNO(result,
+ dup2(errorPipe[1],
+ STDERR_FILENO), ok);
+ }
+ if (ok && (flags & ECORE_EXE_PIPE_READ)) {
+ E_NO_ERRNO(result, close(STDOUT_FILENO),
+ ok);
+ E_NO_ERRNO(result,
+ dup2(readPipe[1],
+ STDOUT_FILENO), ok);
+ }
+ if (ok && (flags & ECORE_EXE_PIPE_WRITE)) {
+ E_NO_ERRNO(result, close(STDIN_FILENO),
+ ok);
+ E_NO_ERRNO(result,
+ dup2(writePipe[0],
+ STDIN_FILENO), ok);
+ }
+
+ if (ok) {
+ /* Setup the status pipe. */
+ E_NO_ERRNO(result, close(statusPipe[0]),
+ ok);
+ E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) { /* close on exec shows success */
+ /* Run the actual command. */
+ _ecore_exe_exec_it(exe_cmd, flags); /* no return */
+ }
+ }
+
+ /* Something went 'orribly wrong. */
+ vfork_exec_errno = errno;
+
+ /* Close the pipes. */
+ if (flags & ECORE_EXE_PIPE_ERROR)
+ E_NO_ERRNO(result, close(errorPipe[1]),
+ ok);
+ if (flags & ECORE_EXE_PIPE_READ)
+ E_NO_ERRNO(result, close(readPipe[1]), ok);
+ if (flags & ECORE_EXE_PIPE_WRITE)
+ E_NO_ERRNO(result, close(writePipe[0]),
+ ok);
+ E_NO_ERRNO(result, close(statusPipe[1]), ok);
+
+ _exit(-1);
+ } else { /* parent */
+
+ /* Close the unused pipes. */
+ E_NO_ERRNO(result, close(statusPipe[1]), ok);
+
+ /* FIXME: after having a good look at the current e fd
+ * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */
+ /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO
+ * which is also linux specific so we probably don't want to
+ * do this as long as select() is working fine. the only time
+ * we really want to think of SIGIO async IO is when it all
+ * actually works basically everywhere and we can turn all
+ * IO into DMA async activities (i.e. you do a read() then
+ * the read is complete not on return but when you get a
+ * SIGIO - the read() just starts the transfer and it is
+ * completed in the background by DMA (or whatever mechanism
+ * the kernel choses)) */
+
+ /* Wait for it to start executing. */
+ /* FIXME: this doesn't seem very nice - we sit and block
+ * waiting on a child process... even though it's just
+ * the segment between the fork() and the exec) it just feels
+ * wrong */
+ for (;;) {
+ char buf;
+
+ E_NO_ERRNO(result,
+ read(statusPipe[0], &buf, 1),
+ ok);
+ if (result == 0) {
+ if (vfork_exec_errno != 0) {
+ n = vfork_exec_errno;
+ ERR("Could not start \"%s\"", exe_cmd);
+ pid = 0;
+ }
+ break;
+ }
+ }
+
+ /* Close the status pipe. */
+ E_NO_ERRNO(result, close(statusPipe[0]), ok);
+ }
+
+ if (pid) {
+ /* Setup the exe structure. */
+ ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
+ exe->start_bytes = -1;
+ exe->end_bytes = -1;
+ exe->start_lines = -1;
+ exe->end_lines = -1;
+ exe->pid = pid;
+ exe->flags = flags;
+ exe->data = (void *) data;
+ if ((exe->cmd = strdup(exe_cmd))) {
+ if (flags & ECORE_EXE_PIPE_ERROR) { /* Setup the error stuff. */
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_error,
+ F_SETFL,
+ O_NONBLOCK),
+ ok) {
+ }
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_error,
+ F_SETFD,
+ FD_CLOEXEC),
+ ok) {
+ }
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_error_x,
+ F_SETFD,
+ FD_CLOEXEC),
+ ok) {
+ }
+ {
+ exe->error_fd_handler =
+ ecore_main_fd_handler_add
+ (exe->child_fd_error,
+ ECORE_FD_READ,
+ _ecore_exe_data_error_handler,
+ exe, NULL, NULL);
+ if (!exe->error_fd_handler)
+ ok = 0;
+ }
+ }
+ if (ok && (flags & ECORE_EXE_PIPE_READ)) { /* Setup the read stuff. */
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_read,
+ F_SETFL,
+ O_NONBLOCK),
+ ok) {
+ }
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_read,
+ F_SETFD,
+ FD_CLOEXEC),
+ ok) {
+ }
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_read_x,
+ F_SETFD,
+ FD_CLOEXEC),
+ ok) {
+ }
+ {
+ exe->read_fd_handler =
+ ecore_main_fd_handler_add
+ (exe->child_fd_read,
+ ECORE_FD_READ,
+ _ecore_exe_data_read_handler,
+ exe, NULL, NULL);
+ if (!exe->read_fd_handler)
+ ok = 0;
+ }
+ }
+ if (ok && (flags & ECORE_EXE_PIPE_WRITE)) { /* Setup the write stuff. */
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_write,
+ F_SETFL,
+ O_NONBLOCK),
+ ok) {
+ }
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_write,
+ F_SETFD,
+ FD_CLOEXEC),
+ ok) {
+ }
+ E_IF_NO_ERRNO(result,
+ fcntl(exe->
+ child_fd_write_x,
+ F_SETFD,
+ FD_CLOEXEC),
+ ok) {
+ }
+ {
+ exe->write_fd_handler =
+ ecore_main_fd_handler_add
+ (exe->child_fd_write,
+ ECORE_FD_WRITE,
+ _ecore_exe_data_write_handler,
+ exe, NULL, NULL);
+ if (exe->write_fd_handler)
+ ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */
+ else
+ ok = 0;
+ }
+ }
+
+ exes =
+ (Ecore_Exe *)
+ eina_inlist_append(EINA_INLIST_GET
+ (exes),
+ EINA_INLIST_GET
+ (exe));
+ n = 0;
+ } else
+ ok = 0;
+ } else
+ ok = 0;
+ }
+
+ if (!ok) { /* Something went wrong, so pull down everything. */
+ if (exe->pid)
+ ecore_exe_terminate(exe);
+ IF_FN_DEL(ecore_exe_free, exe);
+ } else {
+ Ecore_Exe_Event_Add *e;
+
+ e = _ecore_exe_event_add_new();
+ e->exe = exe;
+ if (e) /* Send the event. */
+ ecore_event_add(ECORE_EXE_EVENT_ADD, e,
+ _ecore_exe_event_add_free, NULL);
+ /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */
+ }
+
+ errno = n;
+ return exe;
}
/**
@@ -706,15 +740,14 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
* @param func The function to call before @a exe is freed.
*/
EAPI void
-ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func)
+ecore_exe_callback_pre_free_set(Ecore_Exe * exe, Ecore_Exe_Cb func)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
- "ecore_exe_callback_pre_free_set");
- return;
- }
- exe->pre_free_cb = func;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_callback_pre_free_set");
+ return;
+ }
+ exe->pre_free_cb = func;
}
/**
@@ -730,42 +763,40 @@ ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func)
* @return EINA_TRUE if successful, EINA_FALSE on failure.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI Eina_Bool
-ecore_exe_send(Ecore_Exe * exe, const void *data, int size)
+EAPI Eina_Bool ecore_exe_send(Ecore_Exe * exe, const void *data, int size)
{
- void *buf;
-
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send");
- return EINA_FALSE;
- }
-
- if (exe->close_stdin)
- {
- ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p",
- exe, size, data);
- return EINA_FALSE;
- }
-
- if (exe->child_fd_write == -1)
- {
- ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! "
- "Cannot send %d bytes from %p", exe, size, data);
- return EINA_FALSE;
- }
-
- buf = realloc(exe->write_data_buf, exe->write_data_size + size);
- if (!buf) return EINA_FALSE;
-
- exe->write_data_buf = buf;
- memcpy((char *)exe->write_data_buf + exe->write_data_size, data, size);
- exe->write_data_size += size;
-
- if (exe->write_fd_handler)
- ecore_main_fd_handler_active_set(exe->write_fd_handler, ECORE_FD_WRITE);
-
- return EINA_TRUE;
+ void *buf;
+
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send");
+ return EINA_FALSE;
+ }
+
+ if (exe->close_stdin) {
+ ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p", exe, size, data);
+ return EINA_FALSE;
+ }
+
+ if (exe->child_fd_write == -1) {
+ ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! "
+ "Cannot send %d bytes from %p", exe, size, data);
+ return EINA_FALSE;
+ }
+
+ buf = realloc(exe->write_data_buf, exe->write_data_size + size);
+ if (!buf)
+ return EINA_FALSE;
+
+ exe->write_data_buf = buf;
+ memcpy((char *) exe->write_data_buf + exe->write_data_size, data,
+ size);
+ exe->write_data_size += size;
+
+ if (exe->write_fd_handler)
+ ecore_main_fd_handler_active_set(exe->write_fd_handler,
+ ECORE_FD_WRITE);
+
+ return EINA_TRUE;
}
/**
@@ -774,15 +805,14 @@ ecore_exe_send(Ecore_Exe * exe, const void *data, int size)
* @param exe The child process
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI void
-ecore_exe_close_stdin(Ecore_Exe *exe)
+EAPI void ecore_exe_close_stdin(Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin");
- return;
- }
- exe->close_stdin = 1;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_close_stdin");
+ return;
+ }
+ exe->close_stdin = 1;
}
/**
@@ -797,57 +827,58 @@ ecore_exe_close_stdin(Ecore_Exe *exe)
* @ingroup Ecore_Exe_Basic_Group
*/
EAPI void
-ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines)
+ecore_exe_auto_limits_set(Ecore_Exe * exe, int start_bytes, int end_bytes,
+ int start_lines, int end_lines)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_auto_limits_set");
- return;
- }
- /* FIXME: sanitize the input. */
- exe->start_bytes = start_bytes;
- exe->end_bytes = end_bytes;
- exe->start_lines = start_lines;
- exe->end_lines = end_lines;
-
- /* FIXME: get this can of worms working.
- *
- * capture stderr & stdout internally
- *
- * raster and onefang keep moving the goal posts on this one. It started out as
- * "show users the error output if an exe fails" and is rapidly approaching
- * "alternative method of getting the data, poll vs event driven". Some serious
- * thinking needs to be applied to this. Do we really want to go that far? If
- * so, we should change the names. The basic design will probably remain the
- * same which ever way we go. The constant goal post moving is probably due to
- * generic design methods leading to feature creep as we inspired each other to
- * more generic designs. It does seem like the closer we get to poll driven,
- * the more issues and corner cases there are.
- *
- * Instead of doing the usual register an event handler thing, we are ecore_exe,
- * we can take some short cuts. Don't send the events, just leave the exe buffers
- * as is until the user asks for them, then return the event.
- *
- * start = 0, end = 0; clogged arteries get flushed, everything is ignored.
- * start = -1, end = -1; clogged arteries get transferred to internal buffers. Actually, either == -1 means buffer everything.
- * start = X, end = 0; buffer first X out of clogged arteries, flush and ignore rest.
- * start = 0, end = X; circular buffer X
- * start = X, end = Y; buffer first X out of clogged arteries, circular buffer Y from beginning.
- *
- * bytes vs lines, which ever one reaches the limit first.
- * Before we go beyond the start+end limit, leave the end buffer empty, and store both in the start buffer, coz they overlap.
- * After we pass the the start+end limit, insert "\n...\n" at the end of the start buffer, copy the rest to the end buffer, then store in the end buffer.
- *
- * Other issues -
- * Spank programmer for polling data if polling is not turned on.
- * Spank programmer for setting up event callbacks if polling is turned on.
- * Spank programmer for freeing the event data if it came from the event system, as that autofrees.
- * Spank the programmer if they try to set the limits bigger than what has been gathered & ignored already, coz they just lost data.
- * Spank onefang and raster for opening this can of worms.
- * Should we have separate out/err limits?
- * Should we remove from the internal buffer the data that was delivered already?
- * If so, what to do about limits, start, and end? They could loose their meaning.
- */
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_auto_limits_set");
+ return;
+ }
+ /* FIXME: sanitize the input. */
+ exe->start_bytes = start_bytes;
+ exe->end_bytes = end_bytes;
+ exe->start_lines = start_lines;
+ exe->end_lines = end_lines;
+
+ /* FIXME: get this can of worms working.
+ *
+ * capture stderr & stdout internally
+ *
+ * raster and onefang keep moving the goal posts on this one. It started out as
+ * "show users the error output if an exe fails" and is rapidly approaching
+ * "alternative method of getting the data, poll vs event driven". Some serious
+ * thinking needs to be applied to this. Do we really want to go that far? If
+ * so, we should change the names. The basic design will probably remain the
+ * same which ever way we go. The constant goal post moving is probably due to
+ * generic design methods leading to feature creep as we inspired each other to
+ * more generic designs. It does seem like the closer we get to poll driven,
+ * the more issues and corner cases there are.
+ *
+ * Instead of doing the usual register an event handler thing, we are ecore_exe,
+ * we can take some short cuts. Don't send the events, just leave the exe buffers
+ * as is until the user asks for them, then return the event.
+ *
+ * start = 0, end = 0; clogged arteries get flushed, everything is ignored.
+ * start = -1, end = -1; clogged arteries get transferred to internal buffers. Actually, either == -1 means buffer everything.
+ * start = X, end = 0; buffer first X out of clogged arteries, flush and ignore rest.
+ * start = 0, end = X; circular buffer X
+ * start = X, end = Y; buffer first X out of clogged arteries, circular buffer Y from beginning.
+ *
+ * bytes vs lines, which ever one reaches the limit first.
+ * Before we go beyond the start+end limit, leave the end buffer empty, and store both in the start buffer, coz they overlap.
+ * After we pass the the start+end limit, insert "\n...\n" at the end of the start buffer, copy the rest to the end buffer, then store in the end buffer.
+ *
+ * Other issues -
+ * Spank programmer for polling data if polling is not turned on.
+ * Spank programmer for setting up event callbacks if polling is turned on.
+ * Spank programmer for freeing the event data if it came from the event system, as that autofrees.
+ * Spank the programmer if they try to set the limits bigger than what has been gathered & ignored already, coz they just lost data.
+ * Spank onefang and raster for opening this can of worms.
+ * Should we have separate out/err limits?
+ * Should we remove from the internal buffer the data that was delivered already?
+ * If so, what to do about limits, start, and end? They could loose their meaning.
+ */
}
/**
@@ -857,128 +888,116 @@ ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int st
* @param flags Is this a ECORE_EXE_PIPE_READ or ECORE_EXE_PIPE_ERROR?
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI Ecore_Exe_Event_Data *
-ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
+EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe * exe,
+ Ecore_Exe_Flags flags)
{
- Ecore_Exe_Event_Data *e = NULL;
- int is_buffered = 0;
- unsigned char *inbuf;
- int inbuf_num;
-
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get");
- return NULL;
- }
-
- /* Sort out what sort of event we are. */
- if (flags & ECORE_EXE_PIPE_READ)
- {
- flags = ECORE_EXE_PIPE_READ;
- if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED)
- is_buffered = 1;
- }
- else
- {
- flags = ECORE_EXE_PIPE_ERROR;
- if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED)
- is_buffered = 1;
- }
-
- /* Get the data. */
- if (flags & ECORE_EXE_PIPE_READ)
- {
- inbuf = exe->read_data_buf;
- inbuf_num = exe->read_data_size;
- exe->read_data_buf = NULL;
- exe->read_data_size = 0;
- }
- else
- {
- inbuf = exe->error_data_buf;
- inbuf_num = exe->error_data_size;
- exe->error_data_buf = NULL;
- exe->error_data_size = 0;
- }
-
- e = calloc(1, sizeof(Ecore_Exe_Event_Data));
- if (e)
- {
- e->exe = exe;
- e->data = inbuf;
- e->size = inbuf_num;
-
- if (is_buffered)
- { /* Deal with line buffering. */
- int max = 0;
- int count = 0;
- int i;
- int last = 0;
- char *c;
-
- c = (char *)inbuf;
- for (i = 0; i < inbuf_num; i++) /* Find the lines. */
- {
- if (inbuf[i] == '\n')
- {
- if (count >= max)
- {
- /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */
- max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */
- e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */
- }
- /* raster said to leave the line endings as line endings, however -
- * This is line buffered mode, we are not dealing with binary here, but lines.
- * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format.
- * Thus the user is most likely gonna deal with this text as strings.
- * Thus the user is most likely gonna pass this data to str functions.
- * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0'
- * We are handing them the string length as a convenience.
- * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough.
- * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer.
- * Let's make it easy on them to use these as standard C strings.
- *
- * onefang is proud to announce that he has just set a new personal record for the
- * most over documentation of a simple assignment statement. B-)
- */
- inbuf[i] = '\0';
- e->lines[count].line = c;
- e->lines[count].size = i - last;
- last = i + 1;
- c = (char *)&inbuf[last];
- count++;
- }
- }
- if (count == 0) /* No lines to send, cancel the event. */
- {
- _ecore_exe_event_exe_data_free(NULL, e);
- e = NULL;
- }
- else /* NULL terminate the array, so that people know where the end is. */
- {
- e->lines[count].line = NULL;
- e->lines[count].size = 0;
- }
- if (i > last) /* Partial line left over, save it for next time. */
- {
- if (e) e->size = last;
- if (flags & ECORE_EXE_PIPE_READ)
- {
- exe->read_data_size = i - last;
- exe->read_data_buf = malloc(exe->read_data_size);
- memcpy(exe->read_data_buf, c, exe->read_data_size);
- }
- else
- {
- exe->error_data_size = i - last;
- exe->error_data_buf = malloc(exe->error_data_size);
- memcpy(exe->error_data_buf, c, exe->error_data_size);
- }
- }
- }
- }
-
- return e;
+ Ecore_Exe_Event_Data *e = NULL;
+ int is_buffered = 0;
+ unsigned char *inbuf;
+ int inbuf_num;
+
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_event_data_get");
+ return NULL;
+ }
+
+ /* Sort out what sort of event we are. */
+ if (flags & ECORE_EXE_PIPE_READ) {
+ flags = ECORE_EXE_PIPE_READ;
+ if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED)
+ is_buffered = 1;
+ } else {
+ flags = ECORE_EXE_PIPE_ERROR;
+ if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED)
+ is_buffered = 1;
+ }
+
+ /* Get the data. */
+ if (flags & ECORE_EXE_PIPE_READ) {
+ inbuf = exe->read_data_buf;
+ inbuf_num = exe->read_data_size;
+ exe->read_data_buf = NULL;
+ exe->read_data_size = 0;
+ } else {
+ inbuf = exe->error_data_buf;
+ inbuf_num = exe->error_data_size;
+ exe->error_data_buf = NULL;
+ exe->error_data_size = 0;
+ }
+
+ e = calloc(1, sizeof(Ecore_Exe_Event_Data));
+ if (e) {
+ e->exe = exe;
+ e->data = inbuf;
+ e->size = inbuf_num;
+
+ if (is_buffered) { /* Deal with line buffering. */
+ int max = 0;
+ int count = 0;
+ int i;
+ int last = 0;
+ char *c;
+
+ c = (char *) inbuf;
+ for (i = 0; i < inbuf_num; i++) { /* Find the lines. */
+ if (inbuf[i] == '\n') {
+ if (count >= max) {
+ /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */
+ max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */
+ e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */
+ }
+ /* raster said to leave the line endings as line endings, however -
+ * This is line buffered mode, we are not dealing with binary here, but lines.
+ * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format.
+ * Thus the user is most likely gonna deal with this text as strings.
+ * Thus the user is most likely gonna pass this data to str functions.
+ * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0'
+ * We are handing them the string length as a convenience.
+ * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough.
+ * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer.
+ * Let's make it easy on them to use these as standard C strings.
+ *
+ * onefang is proud to announce that he has just set a new personal record for the
+ * most over documentation of a simple assignment statement. B-)
+ */
+ inbuf[i] = '\0';
+ e->lines[count].line = c;
+ e->lines[count].size = i - last;
+ last = i + 1;
+ c = (char *) &inbuf[last];
+ count++;
+ }
+ }
+ if (count == 0) { /* No lines to send, cancel the event. */
+ _ecore_exe_event_exe_data_free(NULL, e);
+ e = NULL;
+ } else { /* NULL terminate the array, so that people know where the end is. */
+
+ e->lines[count].line = NULL;
+ e->lines[count].size = 0;
+ }
+ if (i > last) { /* Partial line left over, save it for next time. */
+ if (e)
+ e->size = last;
+ if (flags & ECORE_EXE_PIPE_READ) {
+ exe->read_data_size = i - last;
+ exe->read_data_buf =
+ malloc(exe->read_data_size);
+ memcpy(exe->read_data_buf, c,
+ exe->read_data_size);
+ } else {
+ exe->error_data_size = i - last;
+ exe->error_data_buf =
+ malloc(exe->error_data_size);
+ memcpy(exe->error_data_buf, c,
+ exe->error_data_size);
+ }
+ }
+ }
+ }
+
+ return e;
}
/**
@@ -988,19 +1007,18 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
* @param tag The string tag to set on the process handle.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI void
-ecore_exe_tag_set(Ecore_Exe *exe, const char *tag)
+EAPI void ecore_exe_tag_set(Ecore_Exe * exe, const char *tag)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set");
- return;
- }
- IF_FREE(exe->tag);
- if (tag)
- exe->tag = strdup(tag);
- else
- exe->tag = NULL;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_tag_set");
+ return;
+ }
+ IF_FREE(exe->tag);
+ if (tag)
+ exe->tag = strdup(tag);
+ else
+ exe->tag = NULL;
}
/**
@@ -1015,15 +1033,14 @@ ecore_exe_tag_set(Ecore_Exe *exe, const char *tag)
* ecore_exe_tag_set() to change it. It might be @c NULL.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI const char *
-ecore_exe_tag_get(const Ecore_Exe *exe)
+EAPI const char *ecore_exe_tag_get(const Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get");
- return NULL;
- }
- return exe->tag;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_tag_get");
+ return NULL;
+ }
+ return exe->tag;
}
/**
@@ -1037,63 +1054,61 @@ ecore_exe_tag_get(const Ecore_Exe *exe)
* called.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI void *
-ecore_exe_free(Ecore_Exe *exe)
+EAPI void *ecore_exe_free(Ecore_Exe * exe)
{
- void *data;
- int ok = 0;
- int result;
-
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free");
- return NULL;
- }
-
- data = exe->data;
-
- if (exe->pre_free_cb)
- exe->pre_free_cb(data, exe);
-
- if (exe->doomsday_clock)
- {
- struct _ecore_exe_dead_exe *dead;
-
- ecore_timer_del(exe->doomsday_clock);
- exe->doomsday_clock = NULL;
- dead = exe->doomsday_clock_dead;
- if (dead)
- {
- IF_FREE(dead->cmd);
- free(dead);
- exe->doomsday_clock_dead = NULL;
- }
- }
- IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler);
- IF_FN_DEL(ecore_main_fd_handler_del, exe->read_fd_handler);
- IF_FN_DEL(ecore_main_fd_handler_del, exe->error_fd_handler);
- if (exe->child_fd_write_x != -1)
- E_NO_ERRNO(result, close(exe->child_fd_write_x), ok);
- if (exe->child_fd_read_x != -1)
- E_NO_ERRNO(result, close(exe->child_fd_read_x), ok);
- if (exe->child_fd_error_x != -1)
- E_NO_ERRNO(result, close(exe->child_fd_error_x), ok);
- if (exe->child_fd_write != -1)
- E_NO_ERRNO(result, close(exe->child_fd_write), ok);
- if (exe->child_fd_read != -1)
- E_NO_ERRNO(result, close(exe->child_fd_read), ok);
- if (exe->child_fd_error != -1)
- E_NO_ERRNO(result, close(exe->child_fd_error), ok);
- IF_FREE(exe->write_data_buf);
- IF_FREE(exe->read_data_buf);
- IF_FREE(exe->error_data_buf);
- IF_FREE(exe->cmd);
-
- exes = (Ecore_Exe *) eina_inlist_remove(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe));
- ECORE_MAGIC_SET(exe, ECORE_MAGIC_NONE);
- IF_FREE(exe->tag);
- free(exe);
- return data;
+ void *data;
+ int ok = 0;
+ int result;
+
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free");
+ return NULL;
+ }
+
+ data = exe->data;
+
+ if (exe->pre_free_cb)
+ exe->pre_free_cb(data, exe);
+
+ if (exe->doomsday_clock) {
+ struct _ecore_exe_dead_exe *dead;
+
+ ecore_timer_del(exe->doomsday_clock);
+ exe->doomsday_clock = NULL;
+ dead = exe->doomsday_clock_dead;
+ if (dead) {
+ IF_FREE(dead->cmd);
+ free(dead);
+ exe->doomsday_clock_dead = NULL;
+ }
+ }
+ IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler);
+ IF_FN_DEL(ecore_main_fd_handler_del, exe->read_fd_handler);
+ IF_FN_DEL(ecore_main_fd_handler_del, exe->error_fd_handler);
+ if (exe->child_fd_write_x != -1)
+ E_NO_ERRNO(result, close(exe->child_fd_write_x), ok);
+ if (exe->child_fd_read_x != -1)
+ E_NO_ERRNO(result, close(exe->child_fd_read_x), ok);
+ if (exe->child_fd_error_x != -1)
+ E_NO_ERRNO(result, close(exe->child_fd_error_x), ok);
+ if (exe->child_fd_write != -1)
+ E_NO_ERRNO(result, close(exe->child_fd_write), ok);
+ if (exe->child_fd_read != -1)
+ E_NO_ERRNO(result, close(exe->child_fd_read), ok);
+ if (exe->child_fd_error != -1)
+ E_NO_ERRNO(result, close(exe->child_fd_error), ok);
+ IF_FREE(exe->write_data_buf);
+ IF_FREE(exe->read_data_buf);
+ IF_FREE(exe->error_data_buf);
+ IF_FREE(exe->cmd);
+
+ exes =
+ (Ecore_Exe *) eina_inlist_remove(EINA_INLIST_GET(exes),
+ EINA_INLIST_GET(exe));
+ ECORE_MAGIC_SET(exe, ECORE_MAGIC_NONE);
+ IF_FREE(exe->tag);
+ free(exe);
+ return data;
}
/**
@@ -1102,13 +1117,13 @@ ecore_exe_free(Ecore_Exe *exe)
* @param e The given event data.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI void
-ecore_exe_event_data_free(Ecore_Exe_Event_Data *e)
+EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data * e)
{
- if (!e) return;
- IF_FREE(e->lines);
- IF_FREE(e->data);
- free(e);
+ if (!e)
+ return;
+ IF_FREE(e->lines);
+ IF_FREE(e->data);
+ free(e);
}
/**
@@ -1117,15 +1132,14 @@ ecore_exe_event_data_free(Ecore_Exe_Event_Data *e)
* @return The process ID on success. @c -1 otherwise.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI pid_t
-ecore_exe_pid_get(const Ecore_Exe *exe)
+EAPI pid_t ecore_exe_pid_get(const Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get");
- return -1;
- }
- return exe->pid;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_pid_get");
+ return -1;
+ }
+ return exe->pid;
}
/**
@@ -1136,15 +1150,14 @@ ecore_exe_pid_get(const Ecore_Exe *exe)
* any way.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI const char *
-ecore_exe_cmd_get(const Ecore_Exe *exe)
+EAPI const char *ecore_exe_cmd_get(const Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get");
- return NULL;
- }
- return exe->cmd;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_cmd_get");
+ return NULL;
+ }
+ return exe->cmd;
}
/**
@@ -1154,15 +1167,14 @@ ecore_exe_cmd_get(const Ecore_Exe *exe)
* ecore_exe_run() or ecore_exe_pipe_run()
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI void *
-ecore_exe_data_get(const Ecore_Exe *exe)
+EAPI void *ecore_exe_data_get(const Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get");
- return NULL;
- }
- return exe->data;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_data_get");
+ return NULL;
+ }
+ return exe->data;
}
/**
@@ -1171,15 +1183,14 @@ ecore_exe_data_get(const Ecore_Exe *exe)
* @return The flags attached to @p exe.
* @ingroup Ecore_Exe_Basic_Group
*/
-EAPI Ecore_Exe_Flags
-ecore_exe_flags_get(const Ecore_Exe *exe)
+EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get");
- return 0;
- }
- return exe->flags;
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_data_get");
+ return 0;
+ }
+ return exe->flags;
}
/**
@@ -1193,15 +1204,13 @@ ecore_exe_flags_get(const Ecore_Exe *exe)
* @param exe Process handle to the given process.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_pause(Ecore_Exe *exe)
+EAPI void ecore_exe_pause(Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause");
- return;
- }
- kill(exe->pid, SIGSTOP);
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause");
+ return;
+ }
+ kill(exe->pid, SIGSTOP);
}
/**
@@ -1209,15 +1218,14 @@ ecore_exe_pause(Ecore_Exe *exe)
* @param exe Process handle to the given process.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_continue(Ecore_Exe *exe)
+EAPI void ecore_exe_continue(Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue");
- return;
- }
- kill(exe->pid, SIGCONT);
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_continue");
+ return;
+ }
+ kill(exe->pid, SIGCONT);
}
/**
@@ -1225,16 +1233,15 @@ ecore_exe_continue(Ecore_Exe *exe)
* @param exe Process handle to the given process.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_interrupt(Ecore_Exe *exe)
+EAPI void ecore_exe_interrupt(Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt");
- return;
- }
- _ecore_exe_dead_attach(exe);
- kill(exe->pid, SIGINT);
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_interrupt");
+ return;
+ }
+ _ecore_exe_dead_attach(exe);
+ kill(exe->pid, SIGINT);
}
/**
@@ -1242,16 +1249,14 @@ ecore_exe_interrupt(Ecore_Exe *exe)
* @param exe Process handle to the given process.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_quit(Ecore_Exe *exe)
+EAPI void ecore_exe_quit(Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit");
- return;
- }
- _ecore_exe_dead_attach(exe);
- kill(exe->pid, SIGQUIT);
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit");
+ return;
+ }
+ _ecore_exe_dead_attach(exe);
+ kill(exe->pid, SIGQUIT);
}
/**
@@ -1259,17 +1264,16 @@ ecore_exe_quit(Ecore_Exe *exe)
* @param exe Process handle to the given process.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_terminate(Ecore_Exe *exe)
+EAPI void ecore_exe_terminate(Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate");
- return;
- }
- _ecore_exe_dead_attach(exe);
- INF("Sending TERM signal to %s (%d).", exe->cmd, exe->pid);
- kill(exe->pid, SIGTERM);
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
+ "ecore_exe_terminate");
+ return;
+ }
+ _ecore_exe_dead_attach(exe);
+ INF("Sending TERM signal to %s (%d).", exe->cmd, exe->pid);
+ kill(exe->pid, SIGTERM);
}
/**
@@ -1277,29 +1281,28 @@ ecore_exe_terminate(Ecore_Exe *exe)
* @param exe Process handle to the given process.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_kill(Ecore_Exe *exe)
+EAPI void ecore_exe_kill(Ecore_Exe * exe)
{
- struct _ecore_exe_dead_exe *dead;
-
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill");
- return;
- }
-
- dead = calloc(1, sizeof(struct _ecore_exe_dead_exe));
- if (dead)
- {
- dead->pid = exe->pid;
- dead->cmd = strdup(exe->cmd);
- IF_FN_DEL(ecore_timer_del, exe->doomsday_clock);
- exe->doomsday_clock =
- ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, dead);
- }
-
- INF("Sending KILL signal to %s (%d).", exe->cmd, exe->pid);
- kill(exe->pid, SIGKILL);
+ struct _ecore_exe_dead_exe *dead;
+
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill");
+ return;
+ }
+
+ dead = calloc(1, sizeof(struct _ecore_exe_dead_exe));
+ if (dead) {
+ dead->pid = exe->pid;
+ dead->cmd = strdup(exe->cmd);
+ IF_FN_DEL(ecore_timer_del, exe->doomsday_clock);
+ exe->doomsday_clock =
+ ecore_timer_add(10.0,
+ _ecore_exe_make_sure_its_really_dead,
+ dead);
+ }
+
+ INF("Sending KILL signal to %s (%d).", exe->cmd, exe->pid);
+ kill(exe->pid, SIGKILL);
}
/**
@@ -1309,18 +1312,16 @@ ecore_exe_kill(Ecore_Exe *exe)
* the signal will be ignored.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_signal(Ecore_Exe *exe, int num)
+EAPI void ecore_exe_signal(Ecore_Exe * exe, int num)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal");
- return;
- }
- if (num == 1)
- kill(exe->pid, SIGUSR1);
- else if (num == 2)
- kill(exe->pid, SIGUSR2);
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal");
+ return;
+ }
+ if (num == 1)
+ kill(exe->pid, SIGUSR1);
+ else if (num == 2)
+ kill(exe->pid, SIGUSR2);
}
/**
@@ -1328,517 +1329,477 @@ ecore_exe_signal(Ecore_Exe *exe, int num)
* @param exe Process handle to the given process.
* @ingroup Ecore_Exe_Signal_Group
*/
-EAPI void
-ecore_exe_hup(Ecore_Exe *exe)
+EAPI void ecore_exe_hup(Ecore_Exe * exe)
{
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- {
- ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup");
- return;
- }
- kill(exe->pid, SIGHUP);
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) {
+ ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup");
+ return;
+ }
+ kill(exe->pid, SIGHUP);
}
-static Ecore_Exe *
-_ecore_exe_is_it_alive(pid_t pid)
+static Ecore_Exe *_ecore_exe_is_it_alive(pid_t pid)
{
- Ecore_Exe *exe = NULL;
-
- /* FIXME: There is no nice, safe, OS independent way to tell if a
- * particular PID is still alive. I have written code to do so
- * for my urunlevel busybox applet (http://urunlevel.sourceforge.net/),
- * but it's for linux only, and still not guaranteed.
- *
- * So for now, we just check that a valid Ecore_Exe structure
- * exists for it. Even that is not a guarantee, as the structure
- * can be freed without killing the process.
- *
- * I think we can safely put exe's into two categories, those users
- * that care about the life of the exe, and the run and forget type.
- * The run and forget type starts up the exe, then free's the
- * Ecore_Exe structure straight away. They can never call any of
- * the functions that can call this, so we don't worry about them.
- *
- * Those user's that care about the life of exe's will keep the
- * Ecore_Exe structure around, terminate them eventually, or
- * register for exit events. For these ones the assumption
- * that valid Ecore_Exe struct == live exe is almost valid.
- *
- * I will probably copy my urunlevel code into here someday.
- */
- exe = _ecore_exe_find(pid);
- if (exe)
- {
- if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
- exe = NULL;
- }
-
- return exe;
+ Ecore_Exe *exe = NULL;
+
+ /* FIXME: There is no nice, safe, OS independent way to tell if a
+ * particular PID is still alive. I have written code to do so
+ * for my urunlevel busybox applet (http://urunlevel.sourceforge.net/),
+ * but it's for linux only, and still not guaranteed.
+ *
+ * So for now, we just check that a valid Ecore_Exe structure
+ * exists for it. Even that is not a guarantee, as the structure
+ * can be freed without killing the process.
+ *
+ * I think we can safely put exe's into two categories, those users
+ * that care about the life of the exe, and the run and forget type.
+ * The run and forget type starts up the exe, then free's the
+ * Ecore_Exe structure straight away. They can never call any of
+ * the functions that can call this, so we don't worry about them.
+ *
+ * Those user's that care about the life of exe's will keep the
+ * Ecore_Exe structure around, terminate them eventually, or
+ * register for exit events. For these ones the assumption
+ * that valid Ecore_Exe struct == live exe is almost valid.
+ *
+ * I will probably copy my urunlevel code into here someday.
+ */
+ exe = _ecore_exe_find(pid);
+ if (exe) {
+ if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
+ exe = NULL;
+ }
+
+ return exe;
}
-static Eina_Bool
-_ecore_exe_make_sure_its_dead(void *data)
+static Eina_Bool _ecore_exe_make_sure_its_dead(void *data)
{
- struct _ecore_exe_dead_exe *dead;
-
- dead = data;
- if (dead)
- {
- Ecore_Exe *exe = NULL;
-
- if ((exe = _ecore_exe_is_it_alive(dead->pid)))
- {
- if (dead->cmd)
- INF("Sending KILL signal to allegedly dead %s (%d).",
- dead->cmd, dead->pid);
- else
- INF("Sending KILL signal to allegedly dead PID %d.",
- dead->pid);
- exe->doomsday_clock =
- ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead,
- dead);
- kill(dead->pid, SIGKILL);
- }
- else
- {
- IF_FREE(dead->cmd);
- free(dead);
- }
- }
- return ECORE_CALLBACK_CANCEL;
+ struct _ecore_exe_dead_exe *dead;
+
+ dead = data;
+ if (dead) {
+ Ecore_Exe *exe = NULL;
+
+ if ((exe = _ecore_exe_is_it_alive(dead->pid))) {
+ if (dead->cmd)
+ INF("Sending KILL signal to allegedly dead %s (%d).", dead->cmd, dead->pid);
+ else
+ INF("Sending KILL signal to allegedly dead PID %d.", dead->pid);
+ exe->doomsday_clock =
+ ecore_timer_add(10.0,
+ _ecore_exe_make_sure_its_really_dead,
+ dead);
+ kill(dead->pid, SIGKILL);
+ } else {
+ IF_FREE(dead->cmd);
+ free(dead);
+ }
+ }
+ return ECORE_CALLBACK_CANCEL;
}
-static Eina_Bool
-_ecore_exe_make_sure_its_really_dead(void *data)
+static Eina_Bool _ecore_exe_make_sure_its_really_dead(void *data)
{
- struct _ecore_exe_dead_exe *dead;
-
- dead = data;
- if (dead)
- {
- Ecore_Exe *exe = NULL;
-
- if ((exe = _ecore_exe_is_it_alive(dead->pid)))
- {
- ERR("RUN! The zombie wants to eat your brains! And your CPU!");
- if (dead->cmd)
- INF("%s (%d) is not really dead.", dead->cmd, dead->pid);
- else
- INF("PID %d is not really dead.", dead->pid);
- exe->doomsday_clock = NULL;
- }
- IF_FREE(dead->cmd);
- free(dead);
- }
- return ECORE_CALLBACK_CANCEL;
+ struct _ecore_exe_dead_exe *dead;
+
+ dead = data;
+ if (dead) {
+ Ecore_Exe *exe = NULL;
+
+ if ((exe = _ecore_exe_is_it_alive(dead->pid))) {
+ ERR("RUN! The zombie wants to eat your brains! And your CPU!");
+ if (dead->cmd)
+ INF("%s (%d) is not really dead.",
+ dead->cmd, dead->pid);
+ else
+ INF("PID %d is not really dead.",
+ dead->pid);
+ exe->doomsday_clock = NULL;
+ }
+ IF_FREE(dead->cmd);
+ free(dead);
+ }
+ return ECORE_CALLBACK_CANCEL;
}
-void
-_ecore_exe_init(void)
+void _ecore_exe_init(void)
{
- ECORE_EXE_EVENT_ADD = ecore_event_type_new();
- ECORE_EXE_EVENT_DEL = ecore_event_type_new();
- ECORE_EXE_EVENT_DATA = ecore_event_type_new();
- ECORE_EXE_EVENT_ERROR = ecore_event_type_new();
+ ECORE_EXE_EVENT_ADD = ecore_event_type_new();
+ ECORE_EXE_EVENT_DEL = ecore_event_type_new();
+ ECORE_EXE_EVENT_DATA = ecore_event_type_new();
+ ECORE_EXE_EVENT_ERROR = ecore_event_type_new();
}
-void
-_ecore_exe_shutdown(void)
+void _ecore_exe_shutdown(void)
{
- while (exes)
- ecore_exe_free(exes);
+ while (exes)
+ ecore_exe_free(exes);
}
-Ecore_Exe *
-_ecore_exe_find(pid_t pid)
+Ecore_Exe *_ecore_exe_find(pid_t pid)
{
- Ecore_Exe *exe;
-
- EINA_INLIST_FOREACH(exes, exe)
- {
- if (exe->pid == pid)
- return exe;
- }
- return NULL;
+ Ecore_Exe *exe;
+
+ EINA_INLIST_FOREACH(exes, exe) {
+ if (exe->pid == pid)
+ return exe;
+ }
+ return NULL;
}
-Ecore_Timer *
-_ecore_exe_doomsday_clock_get(Ecore_Exe *exe)
+Ecore_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe * exe)
{
- return exe->doomsday_clock;
+ return exe->doomsday_clock;
}
-void
-_ecore_exe_doomsday_clock_set(Ecore_Exe *exe, Ecore_Timer *dc)
+void _ecore_exe_doomsday_clock_set(Ecore_Exe * exe, Ecore_Timer * dc)
{
- exe->doomsday_clock = dc;
+ exe->doomsday_clock = dc;
}
static inline void
_ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags)
{
- char use_sh = 1;
- char *buf = NULL;
- char **args = NULL;
- int save_errno = 0;
-
- /* So what is this doing?
- *
- * We are trying to avoid wrapping the exe call with /bin/sh -c.
- * We conservatively search for certain shell meta characters,
- * If we don't find them, we can call the exe directly.
- */
- if (!strpbrk(exe_cmd, "|&;<>()$`\\\"'*?#"))
- {
- char *token;
- char pre_command = 1;
- int num_tokens = 0;
-
- if (!(buf = strdup(exe_cmd)))
- return;
-
- token = strtok(buf, " \t\n\v");
- while (token)
- {
- if (token[0] == '~')
- break;
- if (pre_command)
- {
- if (token[0] == '[')
- break;
- if (strchr(token, '='))
- break;
- else
- pre_command = 0;
- }
- num_tokens++;
- token = strtok(NULL, " \t\n\v");
- }
- IF_FREE(buf);
- if ((!token) && (num_tokens))
- {
- int i = 0;
-
- if (!(buf = strdup(exe_cmd)))
- return;
-
- token = strtok(buf, " \t\n\v");
- use_sh = 0;
- if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *))))
- {
- IF_FREE(buf);
- return;
- }
- for (i = 0; i < num_tokens; i++)
- {
- if (token)
- args[i] = token;
- token = strtok(NULL, " \t\n\v");
- }
- args[num_tokens] = NULL;
- }
- }
-
- if (!(flags & ECORE_EXE_NOT_LEADER)) setsid();
- if ((flags & ECORE_EXE_USE_SH))
- {
- errno = 0;
- execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *)NULL);
- }
- else if (use_sh)
- { /* We have to use a shell to run this. */
- if (!shell)
- { /* Find users preferred shell. */
- shell = getenv("SHELL");
- if (!shell)
- shell = "/bin/sh";
- }
- errno = 0;
- execl(shell, shell, "-c", exe_cmd, (char *)NULL);
- }
- else
- { /* We can run this directly. */
- errno = 0;
- execvp(args[0], args);
- }
-
- save_errno = errno;
- IF_FREE(buf);
- IF_FREE(args);
- errno = save_errno;
- return;
+ char use_sh = 1;
+ char *buf = NULL;
+ char **args = NULL;
+ int save_errno = 0;
+
+ /* So what is this doing?
+ *
+ * We are trying to avoid wrapping the exe call with /bin/sh -c.
+ * We conservatively search for certain shell meta characters,
+ * If we don't find them, we can call the exe directly.
+ */
+ if (!strpbrk(exe_cmd, "|&;<>()$`\\\"'*?#")) {
+ char *token;
+ char pre_command = 1;
+ int num_tokens = 0;
+
+ if (!(buf = strdup(exe_cmd)))
+ return;
+
+ token = strtok(buf, " \t\n\v");
+ while (token) {
+ if (token[0] == '~')
+ break;
+ if (pre_command) {
+ if (token[0] == '[')
+ break;
+ if (strchr(token, '='))
+ break;
+ else
+ pre_command = 0;
+ }
+ num_tokens++;
+ token = strtok(NULL, " \t\n\v");
+ }
+ IF_FREE(buf);
+ if ((!token) && (num_tokens)) {
+ int i = 0;
+
+ if (!(buf = strdup(exe_cmd)))
+ return;
+
+ token = strtok(buf, " \t\n\v");
+ use_sh = 0;
+ if (!
+ (args =
+ (char **) calloc(num_tokens + 1,
+ sizeof(char *)))) {
+ IF_FREE(buf);
+ return;
+ }
+ for (i = 0; i < num_tokens; i++) {
+ if (token)
+ args[i] = token;
+ token = strtok(NULL, " \t\n\v");
+ }
+ args[num_tokens] = NULL;
+ }
+ }
+
+ if (!(flags & ECORE_EXE_NOT_LEADER))
+ setsid();
+ if ((flags & ECORE_EXE_USE_SH)) {
+ errno = 0;
+ execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *) NULL);
+ } else if (use_sh) { /* We have to use a shell to run this. */
+ if (!shell) { /* Find users preferred shell. */
+ shell = getenv("SHELL");
+ if (!shell)
+ shell = "/bin/sh";
+ }
+ errno = 0;
+ execl(shell, shell, "-c", exe_cmd, (char *) NULL);
+ } else { /* We can run this directly. */
+ errno = 0;
+ execvp(args[0], args);
+ }
+
+ save_errno = errno;
+ IF_FREE(buf);
+ IF_FREE(args);
+ errno = save_errno;
+ return;
}
static Eina_Bool
-_ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, Ecore_Exe_Flags flags)
+_ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler * fd_handler,
+ Ecore_Exe_Flags flags)
{
- Ecore_Exe *exe;
- int child_fd;
- int event_type;
-
- exe = data;
-
- /* Sort out what sort of handler we are. */
- if (flags & ECORE_EXE_PIPE_READ)
- {
- flags = ECORE_EXE_PIPE_READ;
- event_type = ECORE_EXE_EVENT_DATA;
- child_fd = exe->child_fd_read;
- }
- else
- {
- flags = ECORE_EXE_PIPE_ERROR;
- event_type = ECORE_EXE_EVENT_ERROR;
- child_fd = exe->child_fd_error;
- }
-
- if ((fd_handler)
- && (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)))
- {
- unsigned char *inbuf;
- int inbuf_num;
-
- /* Get any left over data from last time. */
- if (flags & ECORE_EXE_PIPE_READ)
- {
- inbuf = exe->read_data_buf;
- inbuf_num = exe->read_data_size;
- exe->read_data_buf = NULL;
- exe->read_data_size = 0;
- }
- else
- {
- inbuf = exe->error_data_buf;
- inbuf_num = exe->error_data_size;
- exe->error_data_buf = NULL;
- exe->error_data_size = 0;
- }
-
- for (;;)
- {
- int num, lost_exe;
- char buf[READBUFSIZ];
-
- lost_exe = 0;
- errno = 0;
- if ((num = read(child_fd, buf, READBUFSIZ)) < 1)
- /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE
- * (currently 64k) to inbuf, use that instead of buf, and
- * save ourselves a memcpy(). */
- {
- lost_exe = ((errno == EIO) ||
- (errno == EBADF) ||
- (errno == EPIPE) ||
- (errno == EINVAL) || (errno == ENOSPC));
- if ((errno != EAGAIN) && (errno != EINTR))
- perror("_ecore_exe_generic_handler() read problem ");
- }
- if (num > 0)
- { /* data got read. */
- inbuf = realloc(inbuf, inbuf_num + num);
- memcpy(inbuf + inbuf_num, buf, num);
- inbuf_num += num;
- }
- else
- { /* No more data to read. */
- if (inbuf)
- {
- Ecore_Exe_Event_Data *e;
-
- /* Stash the data away for later. */
- if (flags & ECORE_EXE_PIPE_READ)
- {
- exe->read_data_buf = inbuf;
- exe->read_data_size = inbuf_num;
- }
- else
- {
- exe->error_data_buf = inbuf;
- exe->error_data_size = inbuf_num;
- }
-
- if (!(exe->flags & ECORE_EXE_PIPE_AUTO))
- {
- e = ecore_exe_event_data_get(exe, flags);
- if (e) /* Send the event. */
- ecore_event_add(event_type, e,
- _ecore_exe_event_exe_data_free,
- NULL);
- }
- }
- if (lost_exe)
- {
- if (flags & ECORE_EXE_PIPE_READ)
- {
- if (exe->read_data_size)
- INF("There are %d bytes left unsent from the dead exe %s.",
- exe->read_data_size, exe->cmd);
- }
- else
- {
- if (exe->error_data_size)
- INF("There are %d bytes left unsent from the dead exe %s.",
- exe->error_data_size, exe->cmd);
- }
- /* Thought about this a bit. If the exe has actually
- * died, this won't do any harm as it must have died
- * recently and the pid has not had a chance to recycle.
- * It is also a paranoid catchall, coz the usual ecore_signal
- * mechenism should kick in. But let's give it a good
- * kick in the head anyway.
- */
- ecore_exe_terminate(exe);
- }
- break;
- }
- }
- }
-
- return ECORE_CALLBACK_RENEW;
+ Ecore_Exe *exe;
+ int child_fd;
+ int event_type;
+
+ exe = data;
+
+ /* Sort out what sort of handler we are. */
+ if (flags & ECORE_EXE_PIPE_READ) {
+ flags = ECORE_EXE_PIPE_READ;
+ event_type = ECORE_EXE_EVENT_DATA;
+ child_fd = exe->child_fd_read;
+ } else {
+ flags = ECORE_EXE_PIPE_ERROR;
+ event_type = ECORE_EXE_EVENT_ERROR;
+ child_fd = exe->child_fd_error;
+ }
+
+ if ((fd_handler)
+ &&
+ (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)))
+ {
+ unsigned char *inbuf;
+ int inbuf_num;
+
+ /* Get any left over data from last time. */
+ if (flags & ECORE_EXE_PIPE_READ) {
+ inbuf = exe->read_data_buf;
+ inbuf_num = exe->read_data_size;
+ exe->read_data_buf = NULL;
+ exe->read_data_size = 0;
+ } else {
+ inbuf = exe->error_data_buf;
+ inbuf_num = exe->error_data_size;
+ exe->error_data_buf = NULL;
+ exe->error_data_size = 0;
+ }
+
+ for (;;) {
+ int num, lost_exe;
+ char buf[READBUFSIZ];
+
+ lost_exe = 0;
+ errno = 0;
+ if ((num = read(child_fd, buf, READBUFSIZ)) < 1)
+ /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE
+ * (currently 64k) to inbuf, use that instead of buf, and
+ * save ourselves a memcpy(). */
+ {
+ lost_exe = ((errno == EIO) ||
+ (errno == EBADF) ||
+ (errno == EPIPE) ||
+ (errno == EINVAL)
+ || (errno == ENOSPC));
+ if ((errno != EAGAIN) && (errno != EINTR))
+ perror
+ ("_ecore_exe_generic_handler() read problem ");
+ }
+ if (num > 0) { /* data got read. */
+ inbuf = realloc(inbuf, inbuf_num + num);
+ memcpy(inbuf + inbuf_num, buf, num);
+ inbuf_num += num;
+ } else { /* No more data to read. */
+ if (inbuf) {
+ Ecore_Exe_Event_Data *e;
+
+ /* Stash the data away for later. */
+ if (flags & ECORE_EXE_PIPE_READ) {
+ exe->read_data_buf = inbuf;
+ exe->read_data_size =
+ inbuf_num;
+ } else {
+ exe->error_data_buf =
+ inbuf;
+ exe->error_data_size =
+ inbuf_num;
+ }
+
+ if (!
+ (exe->
+ flags & ECORE_EXE_PIPE_AUTO))
+ {
+ e = ecore_exe_event_data_get(exe, flags);
+ if (e) /* Send the event. */
+ ecore_event_add
+ (event_type, e,
+ _ecore_exe_event_exe_data_free,
+ NULL);
+ }
+ }
+ if (lost_exe) {
+ if (flags & ECORE_EXE_PIPE_READ) {
+ if (exe->read_data_size)
+ INF("There are %d bytes left unsent from the dead exe %s.", exe->read_data_size, exe->cmd);
+ } else {
+ if (exe->error_data_size)
+ INF("There are %d bytes left unsent from the dead exe %s.", exe->error_data_size, exe->cmd);
+ }
+ /* Thought about this a bit. If the exe has actually
+ * died, this won't do any harm as it must have died
+ * recently and the pid has not had a chance to recycle.
+ * It is also a paranoid catchall, coz the usual ecore_signal
+ * mechenism should kick in. But let's give it a good
+ * kick in the head anyway.
+ */
+ ecore_exe_terminate(exe);
+ }
+ break;
+ }
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
}
static Eina_Bool
-_ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler *fd_handler)
+_ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler * fd_handler)
{
- return _ecore_exe_data_generic_handler(data, fd_handler,
- ECORE_EXE_PIPE_ERROR);
+ return _ecore_exe_data_generic_handler(data, fd_handler,
+ ECORE_EXE_PIPE_ERROR);
}
static Eina_Bool
-_ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler *fd_handler)
+_ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler * fd_handler)
{
- return _ecore_exe_data_generic_handler(data, fd_handler,
- ECORE_EXE_PIPE_READ);
+ return _ecore_exe_data_generic_handler(data, fd_handler,
+ ECORE_EXE_PIPE_READ);
}
static Eina_Bool
-_ecore_exe_data_write_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
+_ecore_exe_data_write_handler(void *data,
+ Ecore_Fd_Handler * fd_handler __UNUSED__)
{
- Ecore_Exe *exe;
-
- exe = data;
- if ((exe->write_fd_handler) &&
- (ecore_main_fd_handler_active_get
- (exe->write_fd_handler, ECORE_FD_WRITE)))
- _ecore_exe_flush(exe);
-
- /* If we have sent all there is to send, and we need to close the pipe, then close it. */
- if ((exe->close_stdin == 1)
- && (exe->write_data_size == exe->write_data_offset))
- {
- int ok = 0;
- int result;
-
- INF("Closing stdin for %s", exe->cmd);
- /* if (exe->child_fd_write != -1) E_NO_ERRNO(result, fsync(exe->child_fd_write), ok); This a) doesn't work, and b) isn't needed. */
- IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler);
- if (exe->child_fd_write != -1)
- E_NO_ERRNO(result, close(exe->child_fd_write), ok);
- exe->child_fd_write = -1;
- IF_FREE(exe->write_data_buf);
- }
-
- return ECORE_CALLBACK_RENEW;
+ Ecore_Exe *exe;
+
+ exe = data;
+ if ((exe->write_fd_handler) &&
+ (ecore_main_fd_handler_active_get
+ (exe->write_fd_handler, ECORE_FD_WRITE)))
+ _ecore_exe_flush(exe);
+
+ /* If we have sent all there is to send, and we need to close the pipe, then close it. */
+ if ((exe->close_stdin == 1)
+ && (exe->write_data_size == exe->write_data_offset)) {
+ int ok = 0;
+ int result;
+
+ INF("Closing stdin for %s", exe->cmd);
+ /* if (exe->child_fd_write != -1) E_NO_ERRNO(result, fsync(exe->child_fd_write), ok); This a) doesn't work, and b) isn't needed. */
+ IF_FN_DEL(ecore_main_fd_handler_del,
+ exe->write_fd_handler);
+ if (exe->child_fd_write != -1)
+ E_NO_ERRNO(result, close(exe->child_fd_write), ok);
+ exe->child_fd_write = -1;
+ IF_FREE(exe->write_data_buf);
+ }
+
+ return ECORE_CALLBACK_RENEW;
}
-static void
-_ecore_exe_flush(Ecore_Exe *exe)
+static void _ecore_exe_flush(Ecore_Exe * exe)
{
- int count;
-
- /* check whether we need to write anything at all. */
- if ((exe->child_fd_write == -1) || (!exe->write_data_buf))
- return;
- if (exe->write_data_size == exe->write_data_offset)
- return;
-
- count = write(exe->child_fd_write,
- (char *)exe->write_data_buf + exe->write_data_offset,
- exe->write_data_size - exe->write_data_offset);
- if (count < 1)
- {
- if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) /* we lost our exe! */
- {
- ecore_exe_terminate(exe);
- if (exe->write_fd_handler)
- ecore_main_fd_handler_active_set(exe->write_fd_handler, 0);
- }
- }
- else
- {
- exe->write_data_offset += count;
- if (exe->write_data_offset >= exe->write_data_size)
- { /* Nothing left to write, clean up. */
- exe->write_data_size = 0;
- exe->write_data_offset = 0;
- IF_FREE(exe->write_data_buf);
- if (exe->write_fd_handler)
- ecore_main_fd_handler_active_set(exe->write_fd_handler, 0);
- }
- }
+ int count;
+
+ /* check whether we need to write anything at all. */
+ if ((exe->child_fd_write == -1) || (!exe->write_data_buf))
+ return;
+ if (exe->write_data_size == exe->write_data_offset)
+ return;
+
+ count = write(exe->child_fd_write,
+ (char *) exe->write_data_buf +
+ exe->write_data_offset,
+ exe->write_data_size - exe->write_data_offset);
+ if (count < 1) {
+ if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) { /* we lost our exe! */
+ ecore_exe_terminate(exe);
+ if (exe->write_fd_handler)
+ ecore_main_fd_handler_active_set(exe->
+ write_fd_handler,
+ 0);
+ }
+ } else {
+ exe->write_data_offset += count;
+ if (exe->write_data_offset >= exe->write_data_size) { /* Nothing left to write, clean up. */
+ exe->write_data_size = 0;
+ exe->write_data_offset = 0;
+ IF_FREE(exe->write_data_buf);
+ if (exe->write_fd_handler)
+ ecore_main_fd_handler_active_set(exe->
+ write_fd_handler,
+ 0);
+ }
+ }
}
-static void
-_ecore_exe_event_exe_data_free(void *data __UNUSED__, void *ev)
+static void _ecore_exe_event_exe_data_free(void *data __UNUSED__, void *ev)
{
- Ecore_Exe_Event_Data *e;
+ Ecore_Exe_Event_Data *e;
- e = ev;
- ecore_exe_event_data_free(e);
+ e = ev;
+ ecore_exe_event_data_free(e);
}
-static Ecore_Exe_Event_Add *
-_ecore_exe_event_add_new(void)
+static Ecore_Exe_Event_Add *_ecore_exe_event_add_new(void)
{
- Ecore_Exe_Event_Add *e;
+ Ecore_Exe_Event_Add *e;
- e = calloc(1, sizeof(Ecore_Exe_Event_Add));
- return e;
+ e = calloc(1, sizeof(Ecore_Exe_Event_Add));
+ return e;
}
-static void
-_ecore_exe_event_add_free(void *data __UNUSED__, void *ev)
+static void _ecore_exe_event_add_free(void *data __UNUSED__, void *ev)
{
- Ecore_Exe_Event_Add *e;
+ Ecore_Exe_Event_Add *e;
- e = ev;
- free(e);
+ e = ev;
+ free(e);
}
-void *
-_ecore_exe_event_del_new(void)
+void *_ecore_exe_event_del_new(void)
{
- Ecore_Exe_Event_Del *e;
+ Ecore_Exe_Event_Del *e;
- e = calloc(1, sizeof(Ecore_Exe_Event_Del));
- return e;
+ e = calloc(1, sizeof(Ecore_Exe_Event_Del));
+ return e;
}
-void
-_ecore_exe_event_del_free(void *data __UNUSED__, void *ev)
+void _ecore_exe_event_del_free(void *data __UNUSED__, void *ev)
{
- Ecore_Exe_Event_Del *e;
+ Ecore_Exe_Event_Del *e;
- e = ev;
- if (e->exe)
- ecore_exe_free(e->exe);
- free(e);
+ e = ev;
+ if (e->exe)
+ ecore_exe_free(e->exe);
+ free(e);
}
-static void
-_ecore_exe_dead_attach(Ecore_Exe *exe)
+static void _ecore_exe_dead_attach(Ecore_Exe * exe)
{
- struct _ecore_exe_dead_exe *dead;
-
- if (exe->doomsday_clock_dead) return;
- dead = calloc(1, sizeof(struct _ecore_exe_dead_exe));
- if (dead)
- {
- dead->pid = exe->pid;
- dead->cmd = strdup(exe->cmd);
- IF_FN_DEL(ecore_timer_del, exe->doomsday_clock);
- exe->doomsday_clock =
- ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead, dead);
- exe->doomsday_clock_dead = dead;
- }
+ struct _ecore_exe_dead_exe *dead;
+
+ if (exe->doomsday_clock_dead)
+ return;
+ dead = calloc(1, sizeof(struct _ecore_exe_dead_exe));
+ if (dead) {
+ dead->pid = exe->pid;
+ dead->cmd = strdup(exe->cmd);
+ IF_FN_DEL(ecore_timer_del, exe->doomsday_clock);
+ exe->doomsday_clock =
+ ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead,
+ dead);
+ exe->doomsday_clock_dead = dead;
+ }
}
diff --git a/tests/suite/ecore/src/lib/ecore_getopt.c b/tests/suite/ecore/src/lib/ecore_getopt.c
index 5b1c7bf9ea..1fdd233693 100644
--- a/tests/suite/ecore/src/lib/ecore_getopt.c
+++ b/tests/suite/ecore/src/lib/ecore_getopt.c
@@ -1,22 +1,22 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
+#include <alloca.h>
#elif defined __GNUC__
-# define alloca __builtin_alloca
+#define alloca __builtin_alloca
#elif defined _AIX
-# define alloca __alloca
+#define alloca __alloca
#elif defined _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
+#include <malloc.h>
+#define alloca _alloca
#else
-# include <stddef.h>
-# ifdef __cplusplus
+#include <stddef.h>
+#ifdef __cplusplus
extern "C"
-# endif
-void *alloca (size_t);
+#endif
+void *alloca(size_t);
#endif
#include <stdio.h>
@@ -25,16 +25,16 @@ void *alloca (size_t);
#include <ctype.h>
#ifdef ENABLE_NLS
-# include <libintl.h>
+#include <libintl.h>
#else
-# define gettext(x) (x)
-# define dgettext(domain, x) (x)
+#define gettext(x) (x)
+#define dgettext(domain, x) (x)
#endif
#define _(x) dgettext("ecore", x)
#ifdef _WIN32_WCE
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "Ecore.h"
@@ -47,560 +47,544 @@ static int cols = 80;
static int helpcol = 80 / 3;
static void
-_ecore_getopt_help_print_replace_program(FILE *fp, const Ecore_Getopt *parser __UNUSED__, const char *text)
+_ecore_getopt_help_print_replace_program(FILE * fp,
+ const Ecore_Getopt *
+ parser __UNUSED__,
+ const char *text)
{
- do
- {
- const char *d = strchr(text, '%');
-
- if (!d)
- {
- fputs(text, fp);
- break;
- }
-
- if (fwrite(text, 1, d - text, fp) != (size_t)(d - text))
- return;
- d++;
- if (strncmp(d, "prog", sizeof("prog") - 1) == 0)
- {
- fputs(prog ? prog : "???", fp);
- d += sizeof("prog") - 1;
- }
- else
- {
- if (d[0] == '%')
- d++;
- fputc('%', fp);
- }
-
- text = d;
- }
- while (text[0] != '\0');
-
- fputc('\n', fp);
+ do {
+ const char *d = strchr(text, '%');
+
+ if (!d) {
+ fputs(text, fp);
+ break;
+ }
+
+ if (fwrite(text, 1, d - text, fp) != (size_t) (d - text))
+ return;
+ d++;
+ if (strncmp(d, "prog", sizeof("prog") - 1) == 0) {
+ fputs(prog ? prog : "???", fp);
+ d += sizeof("prog") - 1;
+ } else {
+ if (d[0] == '%')
+ d++;
+ fputc('%', fp);
+ }
+
+ text = d;
+ }
+ while (text[0] != '\0');
+
+ fputc('\n', fp);
}
-static void
-_ecore_getopt_version(FILE *fp, const Ecore_Getopt *parser)
+static void _ecore_getopt_version(FILE * fp, const Ecore_Getopt * parser)
{
- fputs(_("Version:"), fp);
- fputc(' ', fp);
- _ecore_getopt_help_print_replace_program(fp, parser, parser->version);
+ fputs(_("Version:"), fp);
+ fputc(' ', fp);
+ _ecore_getopt_help_print_replace_program(fp, parser,
+ parser->version);
}
static void
-_ecore_getopt_help_usage(FILE *fp, const Ecore_Getopt *parser)
+_ecore_getopt_help_usage(FILE * fp, const Ecore_Getopt * parser)
{
- fputs(_("Usage:"), fp);
- fputc(' ', fp);
+ fputs(_("Usage:"), fp);
+ fputc(' ', fp);
- if (!parser->usage)
- {
- fprintf(fp, _("%s [options]\n"), prog);
- return;
- }
+ if (!parser->usage) {
+ fprintf(fp, _("%s [options]\n"), prog);
+ return;
+ }
- _ecore_getopt_help_print_replace_program(fp, parser, gettext(parser->usage));
+ _ecore_getopt_help_print_replace_program(fp, parser,
+ gettext(parser->usage));
}
static int
-_ecore_getopt_help_line(FILE *fp, const int base, const int total, int used, const char *text, int len)
+_ecore_getopt_help_line(FILE * fp, const int base, const int total,
+ int used, const char *text, int len)
{
- int linebreak = 0;
- do
- {
- /* process line considering spaces (new line and tabs are spaces!) */
- while ((used < total) && (len > 0))
- {
- const char *space = NULL;
- int i, todo;
-
- todo = total - used;
- if (todo > len)
- todo = len;
-
- for (i = 0; i < todo; i++)
- if (isspace(text[i]))
- {
- space = text + i;
- break;
- }
-
- if (space)
- {
- i = fwrite(text, 1, i, fp);
- i++;
- text += i;
- len -= i;
- used += i;
-
- if (linebreak)
- {
- linebreak = 0;
- continue;
- }
-
- if (space[0] == '\n')
- break;
- else if (space[0] == '\t')
- {
- int c;
-
- used--;
- c = ((used / 8) + 1) * 8;
- if (c < total)
- {
- for (; used < c; used++)
- fputc(' ', fp);
- }
- else
- {
- text--;
- len++;
- break;
- }
- }
- else if (used < total)
- fputc(space[0], fp);
- }
- else
- {
- i = fwrite(text, 1, i, fp);
- text += i;
- len -= i;
- used += i;
- }
- linebreak = 0;
- }
- if (len <= 0)
- break;
- linebreak = 1;
- fputc('\n', fp);
- for (used = 0; used < base; used++)
- fputc(' ', fp);
- }
- while (1);
-
- return used;
+ int linebreak = 0;
+ do {
+ /* process line considering spaces (new line and tabs are spaces!) */
+ while ((used < total) && (len > 0)) {
+ const char *space = NULL;
+ int i, todo;
+
+ todo = total - used;
+ if (todo > len)
+ todo = len;
+
+ for (i = 0; i < todo; i++)
+ if (isspace(text[i])) {
+ space = text + i;
+ break;
+ }
+
+ if (space) {
+ i = fwrite(text, 1, i, fp);
+ i++;
+ text += i;
+ len -= i;
+ used += i;
+
+ if (linebreak) {
+ linebreak = 0;
+ continue;
+ }
+
+ if (space[0] == '\n')
+ break;
+ else if (space[0] == '\t') {
+ int c;
+
+ used--;
+ c = ((used / 8) + 1) * 8;
+ if (c < total) {
+ for (; used < c; used++)
+ fputc(' ', fp);
+ } else {
+ text--;
+ len++;
+ break;
+ }
+ } else if (used < total)
+ fputc(space[0], fp);
+ } else {
+ i = fwrite(text, 1, i, fp);
+ text += i;
+ len -= i;
+ used += i;
+ }
+ linebreak = 0;
+ }
+ if (len <= 0)
+ break;
+ linebreak = 1;
+ fputc('\n', fp);
+ for (used = 0; used < base; used++)
+ fputc(' ', fp);
+ }
+ while (1);
+
+ return used;
}
static void
-_ecore_getopt_help_description(FILE *fp, const Ecore_Getopt *parser)
+_ecore_getopt_help_description(FILE * fp, const Ecore_Getopt * parser)
{
- const char *p, *prg, *ver;
- int used, prglen, verlen;
-
- p = gettext(parser->description);
- if (!p)
- return;
-
- fputc('\n', fp);
-
- prg = prog ? prog : "???";
- ver = parser->version ? parser->version : "???";
-
- prglen = strlen(prg);
- verlen = strlen(ver);
-
- used = 0;
-
- do
- {
- const char *d = strchr(p, '%');
-
- if (!d)
- {
- _ecore_getopt_help_line(fp, 0, cols, used, p, strlen(p));
- break;
- }
-
- used = _ecore_getopt_help_line(fp, 0, cols, used, p, d - p);
- d++;
- if (strncmp(d, "prog", sizeof("prog") - 1) == 0)
- {
- used = _ecore_getopt_help_line(fp, 0, cols, used, prg, prglen);
- d += sizeof("prog") - 1;
- }
- else if (strncmp(d, "version", sizeof("version") - 1) == 0)
- {
- used = _ecore_getopt_help_line(fp, 0, cols, used, ver, verlen);
- d += sizeof("version") - 1;
- }
- else
- {
- if (d[0] == '%')
- d++;
- used = _ecore_getopt_help_line(fp, 0, cols, used, "%", 1);
- }
-
- p = d;
- }
- while (p[0] != '\0');
-
- fputs("\n\n", fp);
+ const char *p, *prg, *ver;
+ int used, prglen, verlen;
+
+ p = gettext(parser->description);
+ if (!p)
+ return;
+
+ fputc('\n', fp);
+
+ prg = prog ? prog : "???";
+ ver = parser->version ? parser->version : "???";
+
+ prglen = strlen(prg);
+ verlen = strlen(ver);
+
+ used = 0;
+
+ do {
+ const char *d = strchr(p, '%');
+
+ if (!d) {
+ _ecore_getopt_help_line(fp, 0, cols, used, p,
+ strlen(p));
+ break;
+ }
+
+ used =
+ _ecore_getopt_help_line(fp, 0, cols, used, p, d - p);
+ d++;
+ if (strncmp(d, "prog", sizeof("prog") - 1) == 0) {
+ used =
+ _ecore_getopt_help_line(fp, 0, cols, used, prg,
+ prglen);
+ d += sizeof("prog") - 1;
+ } else if (strncmp(d, "version", sizeof("version") - 1) ==
+ 0) {
+ used =
+ _ecore_getopt_help_line(fp, 0, cols, used, ver,
+ verlen);
+ d += sizeof("version") - 1;
+ } else {
+ if (d[0] == '%')
+ d++;
+ used =
+ _ecore_getopt_help_line(fp, 0, cols, used, "%",
+ 1);
+ }
+
+ p = d;
+ }
+ while (p[0] != '\0');
+
+ fputs("\n\n", fp);
}
-static void
-_ecore_getopt_copyright(FILE *fp, const Ecore_Getopt *parser)
+static void _ecore_getopt_copyright(FILE * fp, const Ecore_Getopt * parser)
{
- const char *txt = gettext(parser->copyright);
- fputs(_("Copyright:"), fp);
- fputs("\n ", fp);
- _ecore_getopt_help_line
- (fp, 3, cols, 3, txt, strlen(txt));
- fputc('\n', fp);
+ const char *txt = gettext(parser->copyright);
+ fputs(_("Copyright:"), fp);
+ fputs("\n ", fp);
+ _ecore_getopt_help_line(fp, 3, cols, 3, txt, strlen(txt));
+ fputc('\n', fp);
}
-static void
-_ecore_getopt_license(FILE *fp, const Ecore_Getopt *parser)
+static void _ecore_getopt_license(FILE * fp, const Ecore_Getopt * parser)
{
- const char *txt = gettext(parser->license);
- fputs(_("License:"), fp);
- fputs("\n ", fp);
- _ecore_getopt_help_line
- (fp, 3, cols, 3, txt, strlen(txt));
- fputc('\n', fp);
+ const char *txt = gettext(parser->license);
+ fputs(_("License:"), fp);
+ fputs("\n ", fp);
+ _ecore_getopt_help_line(fp, 3, cols, 3, txt, strlen(txt));
+ fputc('\n', fp);
}
static Ecore_Getopt_Desc_Arg_Requirement
-_ecore_getopt_desc_arg_requirement(const Ecore_Getopt_Desc *desc)
+_ecore_getopt_desc_arg_requirement(const Ecore_Getopt_Desc * desc)
{
- switch (desc->action)
- {
- case ECORE_GETOPT_ACTION_STORE:
- return desc->action_param.store.arg_req;
- case ECORE_GETOPT_ACTION_STORE_CONST:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
- case ECORE_GETOPT_ACTION_STORE_TRUE:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
- case ECORE_GETOPT_ACTION_STORE_FALSE:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
- case ECORE_GETOPT_ACTION_CHOICE:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES;
- case ECORE_GETOPT_ACTION_APPEND:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES;
- case ECORE_GETOPT_ACTION_COUNT:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
- case ECORE_GETOPT_ACTION_CALLBACK:
- return desc->action_param.callback.arg_req;
- case ECORE_GETOPT_ACTION_HELP:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
- case ECORE_GETOPT_ACTION_VERSION:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
- default:
- return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
- }
+ switch (desc->action) {
+ case ECORE_GETOPT_ACTION_STORE:
+ return desc->action_param.store.arg_req;
+ case ECORE_GETOPT_ACTION_STORE_CONST:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
+ case ECORE_GETOPT_ACTION_STORE_TRUE:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
+ case ECORE_GETOPT_ACTION_STORE_FALSE:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
+ case ECORE_GETOPT_ACTION_CHOICE:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES;
+ case ECORE_GETOPT_ACTION_APPEND:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES;
+ case ECORE_GETOPT_ACTION_COUNT:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
+ case ECORE_GETOPT_ACTION_CALLBACK:
+ return desc->action_param.callback.arg_req;
+ case ECORE_GETOPT_ACTION_HELP:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
+ case ECORE_GETOPT_ACTION_VERSION:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
+ default:
+ return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO;
+ }
}
static void
-_ecore_getopt_help_desc_setup_metavar(const Ecore_Getopt_Desc *desc, char *metavar, int *metavarlen, int maxsize)
+_ecore_getopt_help_desc_setup_metavar(const Ecore_Getopt_Desc * desc,
+ char *metavar, int *metavarlen,
+ int maxsize)
{
- if (desc->metavar)
- {
- const char *txt = gettext(desc->metavar);
- *metavarlen = strlen(txt);
- if (*metavarlen > maxsize - 1)
- *metavarlen = maxsize - 1;
-
- memcpy(metavar, txt, *metavarlen);
- metavar[*metavarlen] = '\0';
- }
- else if (desc->longname)
- {
- int i;
-
- *metavarlen = strlen(desc->longname);
- if (*metavarlen > maxsize - 1)
- *metavarlen = maxsize - 1;
-
- for (i = 0; i < *metavarlen; i++)
- metavar[i] = toupper(desc->longname[i]);
- metavar[i] = '\0';
- }
+ if (desc->metavar) {
+ const char *txt = gettext(desc->metavar);
+ *metavarlen = strlen(txt);
+ if (*metavarlen > maxsize - 1)
+ *metavarlen = maxsize - 1;
+
+ memcpy(metavar, txt, *metavarlen);
+ metavar[*metavarlen] = '\0';
+ } else if (desc->longname) {
+ int i;
+
+ *metavarlen = strlen(desc->longname);
+ if (*metavarlen > maxsize - 1)
+ *metavarlen = maxsize - 1;
+
+ for (i = 0; i < *metavarlen; i++)
+ metavar[i] = toupper(desc->longname[i]);
+ metavar[i] = '\0';
+ }
}
static int
-_ecore_getopt_help_desc_show_arg(FILE *fp, Ecore_Getopt_Desc_Arg_Requirement requirement, const char *metavar, int metavarlen)
+_ecore_getopt_help_desc_show_arg(FILE * fp,
+ Ecore_Getopt_Desc_Arg_Requirement
+ requirement, const char *metavar,
+ int metavarlen)
{
- int used;
+ int used;
- if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
- return 0;
+ if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
+ return 0;
- used = 0;
+ used = 0;
- if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL)
- {
- fputc('[', fp);
- used++;
- }
+ if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) {
+ fputc('[', fp);
+ used++;
+ }
- if (requirement != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
- {
- fputc('=', fp);
- fputs(metavar, fp);
- used += metavarlen + 1;
- }
+ if (requirement != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) {
+ fputc('=', fp);
+ fputs(metavar, fp);
+ used += metavarlen + 1;
+ }
- if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL)
- {
- fputc(']', fp);
- used++;
- }
+ if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) {
+ fputc(']', fp);
+ used++;
+ }
- return used;
+ return used;
}
static int
-_ecore_getopt_help_desc_store(FILE *fp, const int base, const int total, int used, const Ecore_Getopt_Desc *desc)
+_ecore_getopt_help_desc_store(FILE * fp, const int base, const int total,
+ int used, const Ecore_Getopt_Desc * desc)
{
- const Ecore_Getopt_Desc_Store *store = &desc->action_param.store;
- char buf[64];
- const char *str;
- size_t len;
-
- fputc('\n', fp);
- for (used = 0; used < base; used++)
- fputc(' ', fp);
-
- switch (store->type)
- {
- case ECORE_GETOPT_TYPE_STR:
- str = "STR";
- len = sizeof("STR") - 1;
- break;
- case ECORE_GETOPT_TYPE_BOOL:
- str = "BOOL";
- len = sizeof("BOOL") - 1;
- break;
- case ECORE_GETOPT_TYPE_SHORT:
- str = "SHORT";
- len = sizeof("SHORT") - 1;
- break;
- case ECORE_GETOPT_TYPE_INT:
- str = "INT";
- len = sizeof("INT") - 1;
- break;
- case ECORE_GETOPT_TYPE_LONG:
- str = "LONG";
- len = sizeof("LONG") - 1;
- break;
- case ECORE_GETOPT_TYPE_USHORT:
- str = "USHORT";
- len = sizeof("USHORT") - 1;
- break;
- case ECORE_GETOPT_TYPE_UINT:
- str = "UINT";
- len = sizeof("UINT") - 1;
- break;
- case ECORE_GETOPT_TYPE_ULONG:
- str = "ULONG";
- len = sizeof("ULONG") - 1;
- break;
- case ECORE_GETOPT_TYPE_DOUBLE:
- str = "DOUBLE";
- len = sizeof("DOUBLE") - 1;
- break;
- default:
- str = "???";
- len = sizeof("???") - 1;
- }
-
- used = _ecore_getopt_help_line
- (fp, base, total, used, _("Type: "), strlen(_("Type: ")));
- used = _ecore_getopt_help_line(fp, base, total, used, str, len);
-
- if (store->arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)
- goto end;
-
- used = _ecore_getopt_help_line
- (fp, base, total, used, ". ", sizeof(". ") - 1);
-
- switch (store->type)
- {
- case ECORE_GETOPT_TYPE_STR:
- str = store->def.strv;
- len = str ? strlen(str) : 0;
- break;
- case ECORE_GETOPT_TYPE_BOOL:
- str = store->def.boolv ? "true" : "false";
- len = strlen(str);
- break;
- case ECORE_GETOPT_TYPE_SHORT:
- str = buf;
- len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv);
- if (len > sizeof(buf) - 1)
- len = sizeof(buf) - 1;
- break;
- case ECORE_GETOPT_TYPE_INT:
- str = buf;
- len = snprintf(buf, sizeof(buf), "%d", store->def.intv);
- if (len > sizeof(buf) - 1)
- len = sizeof(buf) - 1;
- break;
- case ECORE_GETOPT_TYPE_LONG:
- str = buf;
- len = snprintf(buf, sizeof(buf), "%ld", store->def.longv);
- if (len > sizeof(buf) - 1)
- len = sizeof(buf) - 1;
- break;
- case ECORE_GETOPT_TYPE_USHORT:
- str = buf;
- len = snprintf(buf, sizeof(buf), "%hu", store->def.ushortv);
- if (len > sizeof(buf) - 1)
- len = sizeof(buf) - 1;
- break;
- case ECORE_GETOPT_TYPE_UINT:
- str = buf;
- len = snprintf(buf, sizeof(buf), "%u", store->def.uintv);
- if (len > sizeof(buf) - 1)
- len = sizeof(buf) - 1;
- break;
- case ECORE_GETOPT_TYPE_ULONG:
- str = buf;
- len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv);
- if (len > sizeof(buf) - 1)
- len = sizeof(buf) - 1;
- break;
- case ECORE_GETOPT_TYPE_DOUBLE:
- str = buf;
- len = snprintf(buf, sizeof(buf), "%f", store->def.doublev);
- if (len > sizeof(buf) - 1)
- len = sizeof(buf) - 1;
- break;
- default:
- str = "???";
- len = sizeof("???") - 1;
- }
-
- used = _ecore_getopt_help_line
- (fp, base, total, used, _("Default: "), strlen(_("Default: ")));
- used = _ecore_getopt_help_line(fp, base, total, used, str, len);
-
- end:
- return _ecore_getopt_help_line(fp, base, total, used, ".", 1);
+ const Ecore_Getopt_Desc_Store *store = &desc->action_param.store;
+ char buf[64];
+ const char *str;
+ size_t len;
+
+ fputc('\n', fp);
+ for (used = 0; used < base; used++)
+ fputc(' ', fp);
+
+ switch (store->type) {
+ case ECORE_GETOPT_TYPE_STR:
+ str = "STR";
+ len = sizeof("STR") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_BOOL:
+ str = "BOOL";
+ len = sizeof("BOOL") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_SHORT:
+ str = "SHORT";
+ len = sizeof("SHORT") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_INT:
+ str = "INT";
+ len = sizeof("INT") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_LONG:
+ str = "LONG";
+ len = sizeof("LONG") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_USHORT:
+ str = "USHORT";
+ len = sizeof("USHORT") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_UINT:
+ str = "UINT";
+ len = sizeof("UINT") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_ULONG:
+ str = "ULONG";
+ len = sizeof("ULONG") - 1;
+ break;
+ case ECORE_GETOPT_TYPE_DOUBLE:
+ str = "DOUBLE";
+ len = sizeof("DOUBLE") - 1;
+ break;
+ default:
+ str = "???";
+ len = sizeof("???") - 1;
+ }
+
+ used = _ecore_getopt_help_line
+ (fp, base, total, used, _("Type: "), strlen(_("Type: ")));
+ used = _ecore_getopt_help_line(fp, base, total, used, str, len);
+
+ if (store->arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)
+ goto end;
+
+ used = _ecore_getopt_help_line
+ (fp, base, total, used, ". ", sizeof(". ") - 1);
+
+ switch (store->type) {
+ case ECORE_GETOPT_TYPE_STR:
+ str = store->def.strv;
+ len = str ? strlen(str) : 0;
+ break;
+ case ECORE_GETOPT_TYPE_BOOL:
+ str = store->def.boolv ? "true" : "false";
+ len = strlen(str);
+ break;
+ case ECORE_GETOPT_TYPE_SHORT:
+ str = buf;
+ len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ break;
+ case ECORE_GETOPT_TYPE_INT:
+ str = buf;
+ len = snprintf(buf, sizeof(buf), "%d", store->def.intv);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ break;
+ case ECORE_GETOPT_TYPE_LONG:
+ str = buf;
+ len = snprintf(buf, sizeof(buf), "%ld", store->def.longv);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ break;
+ case ECORE_GETOPT_TYPE_USHORT:
+ str = buf;
+ len =
+ snprintf(buf, sizeof(buf), "%hu", store->def.ushortv);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ break;
+ case ECORE_GETOPT_TYPE_UINT:
+ str = buf;
+ len = snprintf(buf, sizeof(buf), "%u", store->def.uintv);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ break;
+ case ECORE_GETOPT_TYPE_ULONG:
+ str = buf;
+ len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ break;
+ case ECORE_GETOPT_TYPE_DOUBLE:
+ str = buf;
+ len = snprintf(buf, sizeof(buf), "%f", store->def.doublev);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ break;
+ default:
+ str = "???";
+ len = sizeof("???") - 1;
+ }
+
+ used = _ecore_getopt_help_line
+ (fp, base, total, used, _("Default: "),
+ strlen(_("Default: ")));
+ used = _ecore_getopt_help_line(fp, base, total, used, str, len);
+
+ end:
+ return _ecore_getopt_help_line(fp, base, total, used, ".", 1);
}
static int
-_ecore_getopt_help_desc_choices(FILE *fp, const int base, const int total, int used, const Ecore_Getopt_Desc *desc)
+_ecore_getopt_help_desc_choices(FILE * fp, const int base, const int total,
+ int used, const Ecore_Getopt_Desc * desc)
{
- const char *const *itr;
- const char sep[] = ", ";
- const int seplen = sizeof(sep) - 1;
-
- if (used > 0)
- {
- fputc('\n', fp);
- used = 0;
- }
- for (; used < base; used++)
- fputc(' ', fp);
-
- used = _ecore_getopt_help_line
- (fp, base, total, used, _("Choices: "), strlen(_("Choices: ")));
-
- for (itr = desc->action_param.choices; *itr; itr++)
- {
- used = _ecore_getopt_help_line
- (fp, base, total, used, *itr, strlen(*itr));
- if (itr[1])
- used = _ecore_getopt_help_line(fp, base, total, used, sep, seplen);
- }
-
- return _ecore_getopt_help_line(fp, base, total, used, ".", 1);
+ const char *const *itr;
+ const char sep[] = ", ";
+ const int seplen = sizeof(sep) - 1;
+
+ if (used > 0) {
+ fputc('\n', fp);
+ used = 0;
+ }
+ for (; used < base; used++)
+ fputc(' ', fp);
+
+ used = _ecore_getopt_help_line
+ (fp, base, total, used, _("Choices: "),
+ strlen(_("Choices: ")));
+
+ for (itr = desc->action_param.choices; *itr; itr++) {
+ used = _ecore_getopt_help_line
+ (fp, base, total, used, *itr, strlen(*itr));
+ if (itr[1])
+ used =
+ _ecore_getopt_help_line(fp, base, total, used,
+ sep, seplen);
+ }
+
+ return _ecore_getopt_help_line(fp, base, total, used, ".", 1);
}
static void
-_ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc)
+_ecore_getopt_help_desc(FILE * fp, const Ecore_Getopt_Desc * desc)
{
- Ecore_Getopt_Desc_Arg_Requirement arg_req;
- char metavar[32] = "ARG";
- int metavarlen = 3;
- int used;
-
- arg_req = _ecore_getopt_desc_arg_requirement(desc);
- if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
- _ecore_getopt_help_desc_setup_metavar
- (desc, metavar, &metavarlen, sizeof(metavar));
-
- fputs(" ", fp);
- used = 2;
-
- if (desc->shortname)
- {
- fputc('-', fp);
- fputc(desc->shortname, fp);
- used += 2;
- used += _ecore_getopt_help_desc_show_arg
- (fp, arg_req, metavar, metavarlen);
- }
-
- if (desc->shortname && desc->longname)
- {
- fputs(", ", fp);
- used += 2;
- }
-
- if (desc->longname)
- {
- int namelen = strlen(desc->longname);
-
- fputs("--", fp);
- fputs(desc->longname, fp);
- used += 2 + namelen;
- used += _ecore_getopt_help_desc_show_arg
- (fp, arg_req, metavar, metavarlen);
- }
-
- if (!desc->help)
- goto end;
-
- if (used + 3 >= helpcol)
- {
- fputc('\n', fp);
- used = 0;
- }
-
- for (; used < helpcol; used++)
- fputc(' ', fp);
-
- used = _ecore_getopt_help_line
- (fp, helpcol, cols, used, desc->help, strlen(desc->help));
-
- switch (desc->action)
- {
- case ECORE_GETOPT_ACTION_STORE:
- _ecore_getopt_help_desc_store(fp, helpcol, cols, used, desc);
- break;
- case ECORE_GETOPT_ACTION_CHOICE:
- _ecore_getopt_help_desc_choices(fp, helpcol, cols, used, desc);
- break;
- default:
- break;
- }
-
- end:
- fputc('\n', fp);
+ Ecore_Getopt_Desc_Arg_Requirement arg_req;
+ char metavar[32] = "ARG";
+ int metavarlen = 3;
+ int used;
+
+ arg_req = _ecore_getopt_desc_arg_requirement(desc);
+ if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
+ _ecore_getopt_help_desc_setup_metavar
+ (desc, metavar, &metavarlen, sizeof(metavar));
+
+ fputs(" ", fp);
+ used = 2;
+
+ if (desc->shortname) {
+ fputc('-', fp);
+ fputc(desc->shortname, fp);
+ used += 2;
+ used += _ecore_getopt_help_desc_show_arg
+ (fp, arg_req, metavar, metavarlen);
+ }
+
+ if (desc->shortname && desc->longname) {
+ fputs(", ", fp);
+ used += 2;
+ }
+
+ if (desc->longname) {
+ int namelen = strlen(desc->longname);
+
+ fputs("--", fp);
+ fputs(desc->longname, fp);
+ used += 2 + namelen;
+ used += _ecore_getopt_help_desc_show_arg
+ (fp, arg_req, metavar, metavarlen);
+ }
+
+ if (!desc->help)
+ goto end;
+
+ if (used + 3 >= helpcol) {
+ fputc('\n', fp);
+ used = 0;
+ }
+
+ for (; used < helpcol; used++)
+ fputc(' ', fp);
+
+ used = _ecore_getopt_help_line
+ (fp, helpcol, cols, used, desc->help, strlen(desc->help));
+
+ switch (desc->action) {
+ case ECORE_GETOPT_ACTION_STORE:
+ _ecore_getopt_help_desc_store(fp, helpcol, cols, used,
+ desc);
+ break;
+ case ECORE_GETOPT_ACTION_CHOICE:
+ _ecore_getopt_help_desc_choices(fp, helpcol, cols, used,
+ desc);
+ break;
+ default:
+ break;
+ }
+
+ end:
+ fputc('\n', fp);
}
static unsigned char
-_ecore_getopt_desc_is_sentinel(const Ecore_Getopt_Desc *desc)
+_ecore_getopt_desc_is_sentinel(const Ecore_Getopt_Desc * desc)
{
- return (desc->shortname == '\0') && (!desc->longname);
+ return (desc->shortname == '\0') && (!desc->longname);
}
static void
-_ecore_getopt_help_options(FILE *fp, const Ecore_Getopt *parser)
+_ecore_getopt_help_options(FILE * fp, const Ecore_Getopt * parser)
{
- const Ecore_Getopt_Desc *desc;
+ const Ecore_Getopt_Desc *desc;
- fputs(_("Options:\n"), fp);
+ fputs(_("Options:\n"), fp);
- for (desc = parser->descs; !_ecore_getopt_desc_is_sentinel(desc); desc++)
- _ecore_getopt_help_desc(fp, desc);
+ for (desc = parser->descs; !_ecore_getopt_desc_is_sentinel(desc);
+ desc++)
+ _ecore_getopt_help_desc(fp, desc);
- fputc('\n', fp);
+ fputc('\n', fp);
}
/**
@@ -608,898 +592,952 @@ _ecore_getopt_help_options(FILE *fp, const Ecore_Getopt *parser)
*
* Message will be print to stderr.
*/
-void
-ecore_getopt_help(FILE *fp, const Ecore_Getopt *parser)
+void ecore_getopt_help(FILE * fp, const Ecore_Getopt * parser)
{
- const char *var;
-
- if (!parser) return;
-
- if (argc < 1)
- {
- ecore_app_args_get(&argc, &argv);
- if ((argc > 0) && (argv[0]))
- prog = argv[0];
- else
- prog = parser->prog;
- }
-
- var = getenv("COLUMNS");
- if (var)
- {
- cols = atoi(var);
- if (cols < 20)
- cols = 20;
-
- helpcol = cols / 3;
- }
-
- _ecore_getopt_help_usage(fp, parser);
- _ecore_getopt_help_description(fp, parser);
- _ecore_getopt_help_options(fp, parser);
+ const char *var;
+
+ if (!parser)
+ return;
+
+ if (argc < 1) {
+ ecore_app_args_get(&argc, &argv);
+ if ((argc > 0) && (argv[0]))
+ prog = argv[0];
+ else
+ prog = parser->prog;
+ }
+
+ var = getenv("COLUMNS");
+ if (var) {
+ cols = atoi(var);
+ if (cols < 20)
+ cols = 20;
+
+ helpcol = cols / 3;
+ }
+
+ _ecore_getopt_help_usage(fp, parser);
+ _ecore_getopt_help_description(fp, parser);
+ _ecore_getopt_help_options(fp, parser);
}
-static const Ecore_Getopt_Desc *
-_ecore_getopt_parse_find_long(const Ecore_Getopt *parser, const char *name)
+static const Ecore_Getopt_Desc *_ecore_getopt_parse_find_long(const
+ Ecore_Getopt
+ * parser,
+ const char
+ *name)
{
- const Ecore_Getopt_Desc *desc = parser->descs;
- const char *p = strchr(name, '=');
- int len = 0;
-
- if (p)
- len = p - name;
-
- for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
- {
- if (!desc->longname)
- continue;
-
- if (p)
- {
- if ((strncmp(name, desc->longname, len) == 0) &&
- (desc->longname[len] == '\0'))
- return desc;
- }
- else
- {
- if (strcmp(name, desc->longname) == 0)
- return desc;
- }
- }
-
- return NULL;
+ const Ecore_Getopt_Desc *desc = parser->descs;
+ const char *p = strchr(name, '=');
+ int len = 0;
+
+ if (p)
+ len = p - name;
+
+ for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) {
+ if (!desc->longname)
+ continue;
+
+ if (p) {
+ if ((strncmp(name, desc->longname, len) == 0) &&
+ (desc->longname[len] == '\0'))
+ return desc;
+ } else {
+ if (strcmp(name, desc->longname) == 0)
+ return desc;
+ }
+ }
+
+ return NULL;
}
-static const Ecore_Getopt_Desc *
-_ecore_getopt_parse_find_short(const Ecore_Getopt *parser, char name)
+static const Ecore_Getopt_Desc *_ecore_getopt_parse_find_short(const
+ Ecore_Getopt
+ * parser,
+ char name)
{
- const Ecore_Getopt_Desc *desc = parser->descs;
- for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
- if (name == desc->shortname)
- return desc;
- return NULL;
+ const Ecore_Getopt_Desc *desc = parser->descs;
+ for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
+ if (name == desc->shortname)
+ return desc;
+ return NULL;
}
static int
-_ecore_getopt_parse_find_nonargs_base(const Ecore_Getopt *parser, int argc, char **argv)
+_ecore_getopt_parse_find_nonargs_base(const Ecore_Getopt * parser,
+ int argc, char **argv)
{
- char **nonargs;
- int src, dst, used, base;
-
- nonargs = alloca(sizeof(char*) * argc);
- src = 1;
- dst = 1;
- used = 0;
- base = 0;
- while (src < argc)
- {
- const Ecore_Getopt_Desc *desc;
- Ecore_Getopt_Desc_Arg_Requirement arg_req;
- char *arg = argv[src];
-
- if (arg[0] != '-')
- goto found_nonarg;
-
- if (arg[1] == '-')
- {
- if (arg[2] == '\0') /* explicit end of options, "--" */
- {
- base = 1;
- break;
- }
- desc = _ecore_getopt_parse_find_long(parser, arg + 2);
- }
- else
- desc = _ecore_getopt_parse_find_short(parser, arg[1]);
-
- if (!desc)
- {
- if (arg[1] == '-')
- fprintf(stderr, _("ERROR: unknown option --%s.\n"), arg + 2);
- else
- fprintf(stderr, _("ERROR: unknown option -%c.\n"), arg[1]);
- if (parser->strict)
- {
- memmove(argv + dst, nonargs, used * sizeof(char *));
- return -1;
- }
- else
- goto found_nonarg;
- }
-
- if (src != dst)
- argv[dst] = argv[src];
- src++;
- dst++;
-
- arg_req = _ecore_getopt_desc_arg_requirement(desc);
- if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
- continue;
-
- if (strchr(arg, '='))
- continue;
-
- if ((src >= argc) || (argv[src][0] == '-'))
- continue;
-
- if (src != dst)
- argv[dst] = argv[src];
- src++;
- dst++;
- continue;
-
- found_nonarg:
- nonargs[used] = arg;
- used++;
- src++;
- }
-
- if (!base) /* '--' not found */
- base = dst;
- else
- {
- base = dst;
- if (src != dst)
- argv[dst] = argv[src];
- dst++;
- }
-
- memmove(argv + dst, nonargs, used * sizeof(char *));
- return base;
+ char **nonargs;
+ int src, dst, used, base;
+
+ nonargs = alloca(sizeof(char *) * argc);
+ src = 1;
+ dst = 1;
+ used = 0;
+ base = 0;
+ while (src < argc) {
+ const Ecore_Getopt_Desc *desc;
+ Ecore_Getopt_Desc_Arg_Requirement arg_req;
+ char *arg = argv[src];
+
+ if (arg[0] != '-')
+ goto found_nonarg;
+
+ if (arg[1] == '-') {
+ if (arg[2] == '\0') { /* explicit end of options, "--" */
+ base = 1;
+ break;
+ }
+ desc =
+ _ecore_getopt_parse_find_long(parser, arg + 2);
+ } else
+ desc =
+ _ecore_getopt_parse_find_short(parser, arg[1]);
+
+ if (!desc) {
+ if (arg[1] == '-')
+ fprintf(stderr,
+ _("ERROR: unknown option --%s.\n"),
+ arg + 2);
+ else
+ fprintf(stderr,
+ _("ERROR: unknown option -%c.\n"),
+ arg[1]);
+ if (parser->strict) {
+ memmove(argv + dst, nonargs,
+ used * sizeof(char *));
+ return -1;
+ } else
+ goto found_nonarg;
+ }
+
+ if (src != dst)
+ argv[dst] = argv[src];
+ src++;
+ dst++;
+
+ arg_req = _ecore_getopt_desc_arg_requirement(desc);
+ if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
+ continue;
+
+ if (strchr(arg, '='))
+ continue;
+
+ if ((src >= argc) || (argv[src][0] == '-'))
+ continue;
+
+ if (src != dst)
+ argv[dst] = argv[src];
+ src++;
+ dst++;
+ continue;
+
+ found_nonarg:
+ nonargs[used] = arg;
+ used++;
+ src++;
+ }
+
+ if (!base) /* '--' not found */
+ base = dst;
+ else {
+ base = dst;
+ if (src != dst)
+ argv[dst] = argv[src];
+ dst++;
+ }
+
+ memmove(argv + dst, nonargs, used * sizeof(char *));
+ return base;
}
static void
-_ecore_getopt_desc_print_error(const Ecore_Getopt_Desc *desc, const char *fmt, ...)
+_ecore_getopt_desc_print_error(const Ecore_Getopt_Desc * desc,
+ const char *fmt, ...)
{
- va_list ap;
+ va_list ap;
- fputs(_("ERROR: "), stderr);
+ fputs(_("ERROR: "), stderr);
- if (desc->shortname)
- {
- fputc('-', stderr);
- fputc(desc->shortname, stderr);
- }
+ if (desc->shortname) {
+ fputc('-', stderr);
+ fputc(desc->shortname, stderr);
+ }
- if (desc->shortname && desc->longname)
- fputs(", ", stderr);
+ if (desc->shortname && desc->longname)
+ fputs(", ", stderr);
- if (desc->longname)
- {
- fputs("--", stderr);
- fputs(desc->longname, stderr);
- }
+ if (desc->longname) {
+ fputs("--", stderr);
+ fputs(desc->longname, stderr);
+ }
- fputs(": ", stderr);
+ fputs(": ", stderr);
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
}
static unsigned char
_ecore_getopt_parse_bool(const char *str, unsigned char *v)
{
- if ((strcmp(str, "0") == 0) ||
- (strcasecmp(str, "f") == 0) ||
- (strcasecmp(str, "false") == 0) ||
- (strcasecmp(str, "no") == 0) ||
- (strcasecmp(str, "off") == 0)
- )
- {
- *v = 0;
- return 1;
- }
- else if ((strcmp(str, "1") == 0) ||
- (strcasecmp(str, "t") == 0) ||
- (strcasecmp(str, "true") == 0) ||
- (strcasecmp(str, "yes") == 0) ||
- (strcasecmp(str, "on") == 0)
- )
- {
- *v = 1;
- return 1;
- }
-
- return 0;
+ if ((strcmp(str, "0") == 0) ||
+ (strcasecmp(str, "f") == 0) ||
+ (strcasecmp(str, "false") == 0) ||
+ (strcasecmp(str, "no") == 0) || (strcasecmp(str, "off") == 0)
+ ) {
+ *v = 0;
+ return 1;
+ } else if ((strcmp(str, "1") == 0) ||
+ (strcasecmp(str, "t") == 0) ||
+ (strcasecmp(str, "true") == 0) ||
+ (strcasecmp(str, "yes") == 0) ||
+ (strcasecmp(str, "on") == 0)
+ ) {
+ *v = 1;
+ return 1;
+ }
+
+ return 0;
}
-static unsigned char
-_ecore_getopt_parse_long(const char *str, long int *v)
+static unsigned char _ecore_getopt_parse_long(const char *str, long int *v)
{
- char *endptr = NULL;
- *v = strtol(str, &endptr, 0);
- return endptr > str;
+ char *endptr = NULL;
+ *v = strtol(str, &endptr, 0);
+ return endptr > str;
}
-static unsigned char
-_ecore_getopt_parse_double(const char *str, double *v)
+static unsigned char _ecore_getopt_parse_double(const char *str, double *v)
{
- char *endptr = NULL;
- *v = strtod(str, &endptr);
- return endptr > str;
+ char *endptr = NULL;
+ *v = strtod(str, &endptr);
+ return endptr > str;
}
static unsigned char
-_ecore_getopt_parse_store(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *value, const char *arg_val)
+_ecore_getopt_parse_store(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * value, const char *arg_val)
{
- const Ecore_Getopt_Desc_Store *store = &desc->action_param.store;
- long int v;
- double d;
- unsigned char b;
-
- if (!value->ptrp)
- {
- _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n"));
- return 0;
- }
-
- switch (store->arg_req)
- {
- case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO:
- goto use_optional;
- case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL:
- if (!arg_val)
- goto use_optional;
- case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES:
- break;
- }
-
- switch (store->type)
- {
- case ECORE_GETOPT_TYPE_STR:
- *value->strp = (char *)arg_val;
- return 1;
- case ECORE_GETOPT_TYPE_BOOL:
- if (_ecore_getopt_parse_bool(arg_val, &b))
- {
- *value->boolp = b;
- return 1;
- }
- else
- {
- _ecore_getopt_desc_print_error
- (desc, _("unknown boolean value %s.\n"), arg_val);
- return 0;
- }
- case ECORE_GETOPT_TYPE_SHORT:
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- *value->shortp = v;
- return 1;
- case ECORE_GETOPT_TYPE_INT:
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- *value->intp = v;
- return 1;
- case ECORE_GETOPT_TYPE_LONG:
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- *value->longp = v;
- return 1;
- case ECORE_GETOPT_TYPE_USHORT:
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- *value->ushortp = v;
- return 1;
- case ECORE_GETOPT_TYPE_UINT:
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- *value->uintp = v;
- return 1;
- case ECORE_GETOPT_TYPE_ULONG:
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- *value->ulongp = v;
- return 1;
- case ECORE_GETOPT_TYPE_DOUBLE:
- if (!_ecore_getopt_parse_double(arg_val, &d))
- goto error;
- *value->doublep = d;
- break;
- }
-
- return 1;
-
- error:
- _ecore_getopt_desc_print_error
- (desc, _("invalid number format %s\n"), arg_val);
- return 0;
-
- use_optional:
- switch (store->type)
- {
- case ECORE_GETOPT_TYPE_STR:
- *value->strp = (char *)store->def.strv;
- break;
- case ECORE_GETOPT_TYPE_BOOL:
- *value->boolp = store->def.boolv;
- break;
- case ECORE_GETOPT_TYPE_SHORT:
- *value->shortp = store->def.shortv;
- break;
- case ECORE_GETOPT_TYPE_INT:
- *value->intp = store->def.intv;
- break;
- case ECORE_GETOPT_TYPE_LONG:
- *value->longp = store->def.longv;
- break;
- case ECORE_GETOPT_TYPE_USHORT:
- *value->ushortp = store->def.ushortv;
- break;
- case ECORE_GETOPT_TYPE_UINT:
- *value->uintp = store->def.uintv;
- break;
- case ECORE_GETOPT_TYPE_ULONG:
- *value->ulongp = store->def.ulongv;
- break;
- case ECORE_GETOPT_TYPE_DOUBLE:
- *value->doublep = store->def.doublev;
- break;
- }
-
- return 1;
+ const Ecore_Getopt_Desc_Store *store = &desc->action_param.store;
+ long int v;
+ double d;
+ unsigned char b;
+
+ if (!value->ptrp) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("value has no pointer set.\n"));
+ return 0;
+ }
+
+ switch (store->arg_req) {
+ case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO:
+ goto use_optional;
+ case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL:
+ if (!arg_val)
+ goto use_optional;
+ case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES:
+ break;
+ }
+
+ switch (store->type) {
+ case ECORE_GETOPT_TYPE_STR:
+ *value->strp = (char *) arg_val;
+ return 1;
+ case ECORE_GETOPT_TYPE_BOOL:
+ if (_ecore_getopt_parse_bool(arg_val, &b)) {
+ *value->boolp = b;
+ return 1;
+ } else {
+ _ecore_getopt_desc_print_error
+ (desc, _("unknown boolean value %s.\n"),
+ arg_val);
+ return 0;
+ }
+ case ECORE_GETOPT_TYPE_SHORT:
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ *value->shortp = v;
+ return 1;
+ case ECORE_GETOPT_TYPE_INT:
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ *value->intp = v;
+ return 1;
+ case ECORE_GETOPT_TYPE_LONG:
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ *value->longp = v;
+ return 1;
+ case ECORE_GETOPT_TYPE_USHORT:
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ *value->ushortp = v;
+ return 1;
+ case ECORE_GETOPT_TYPE_UINT:
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ *value->uintp = v;
+ return 1;
+ case ECORE_GETOPT_TYPE_ULONG:
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ *value->ulongp = v;
+ return 1;
+ case ECORE_GETOPT_TYPE_DOUBLE:
+ if (!_ecore_getopt_parse_double(arg_val, &d))
+ goto error;
+ *value->doublep = d;
+ break;
+ }
+
+ return 1;
+
+ error:
+ _ecore_getopt_desc_print_error
+ (desc, _("invalid number format %s\n"), arg_val);
+ return 0;
+
+ use_optional:
+ switch (store->type) {
+ case ECORE_GETOPT_TYPE_STR:
+ *value->strp = (char *) store->def.strv;
+ break;
+ case ECORE_GETOPT_TYPE_BOOL:
+ *value->boolp = store->def.boolv;
+ break;
+ case ECORE_GETOPT_TYPE_SHORT:
+ *value->shortp = store->def.shortv;
+ break;
+ case ECORE_GETOPT_TYPE_INT:
+ *value->intp = store->def.intv;
+ break;
+ case ECORE_GETOPT_TYPE_LONG:
+ *value->longp = store->def.longv;
+ break;
+ case ECORE_GETOPT_TYPE_USHORT:
+ *value->ushortp = store->def.ushortv;
+ break;
+ case ECORE_GETOPT_TYPE_UINT:
+ *value->uintp = store->def.uintv;
+ break;
+ case ECORE_GETOPT_TYPE_ULONG:
+ *value->ulongp = store->def.ulongv;
+ break;
+ case ECORE_GETOPT_TYPE_DOUBLE:
+ *value->doublep = store->def.doublev;
+ break;
+ }
+
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_store_const(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_store_const(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (!val->ptrp)
- {
- _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n"));
- return 0;
- }
-
- *val->ptrp = (void *)desc->action_param.store_const;
- return 1;
+ if (!val->ptrp) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("value has no pointer set.\n"));
+ return 0;
+ }
+
+ *val->ptrp = (void *) desc->action_param.store_const;
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_store_true(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_store_true(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (!val->boolp)
- {
- _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n"));
- return 0;
- }
- *val->boolp = 1;
- return 1;
+ if (!val->boolp) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("value has no pointer set.\n"));
+ return 0;
+ }
+ *val->boolp = 1;
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_store_false(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_store_false(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (!val->boolp)
- {
- _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n"));
- return 0;
- }
- *val->boolp = 0;
- return 1;
+ if (!val->boolp) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("value has no pointer set.\n"));
+ return 0;
+ }
+ *val->boolp = 0;
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_choice(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val)
+_ecore_getopt_parse_choice(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val, const char *arg_val)
{
- const char * const *pchoice;
-
- if (!val->strp)
- {
- _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n"));
- return 0;
- }
-
- pchoice = desc->action_param.choices;
- for (; *pchoice; pchoice++)
- if (strcmp(*pchoice, arg_val) == 0)
- {
- *val->strp = (char *)*pchoice;
- return 1;
- }
-
- _ecore_getopt_desc_print_error
- (desc, _("invalid choice \"%s\". Valid values are: "), arg_val);
-
- pchoice = desc->action_param.choices;
- for (; *pchoice; pchoice++)
- {
- fputs(*pchoice, stderr);
- if (pchoice[1])
- fputs(", ", stderr);
- }
-
- fputs(".\n", stderr);
- return 0;
+ const char *const *pchoice;
+
+ if (!val->strp) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("value has no pointer set.\n"));
+ return 0;
+ }
+
+ pchoice = desc->action_param.choices;
+ for (; *pchoice; pchoice++)
+ if (strcmp(*pchoice, arg_val) == 0) {
+ *val->strp = (char *) *pchoice;
+ return 1;
+ }
+
+ _ecore_getopt_desc_print_error
+ (desc, _("invalid choice \"%s\". Valid values are: "),
+ arg_val);
+
+ pchoice = desc->action_param.choices;
+ for (; *pchoice; pchoice++) {
+ fputs(*pchoice, stderr);
+ if (pchoice[1])
+ fputs(", ", stderr);
+ }
+
+ fputs(".\n", stderr);
+ return 0;
}
static unsigned char
-_ecore_getopt_parse_append(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val)
+_ecore_getopt_parse_append(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val, const char *arg_val)
{
- void *data;
- long int v;
- double d;
- unsigned char b;
-
- if (!arg_val)
- {
- _ecore_getopt_desc_print_error
- (desc, _("missing parameter to append.\n"));
- return 0;
- }
-
- if (!val->listp)
- {
- _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n"));
- return 0;
- }
-
- switch (desc->action_param.append_type)
- {
- case ECORE_GETOPT_TYPE_STR:
- data = strdup(arg_val);
- break;
- case ECORE_GETOPT_TYPE_BOOL:
- {
- if (_ecore_getopt_parse_bool(arg_val, &b))
- {
- data = malloc(sizeof(unsigned char));
- if (data)
- *(unsigned char *)data = b;
- }
- else
- {
- _ecore_getopt_desc_print_error
- (desc, _("unknown boolean value %s.\n"), arg_val);
- return 0;
- }
- }
- break;
- case ECORE_GETOPT_TYPE_SHORT:
- {
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- data = malloc(sizeof(short));
- if (data)
- *(short *)data = (short)v;
- }
- break;
- case ECORE_GETOPT_TYPE_INT:
- {
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- data = malloc(sizeof(int));
- if (data)
- *(int *)data = (int)v;
- }
- break;
- case ECORE_GETOPT_TYPE_LONG:
- {
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- data = malloc(sizeof(long));
- if (data)
- *(long *)data = v;
- }
- break;
- case ECORE_GETOPT_TYPE_USHORT:
- {
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- data = malloc(sizeof(unsigned short));
- if (data)
- *(unsigned short *)data = (unsigned short)v;
- }
- break;
- case ECORE_GETOPT_TYPE_UINT:
- {
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- data = malloc(sizeof(unsigned int));
- if (data)
- *(unsigned int *)data = (unsigned int)v;
- }
- break;
- case ECORE_GETOPT_TYPE_ULONG:
- {
- if (!_ecore_getopt_parse_long(arg_val, &v))
- goto error;
- data = malloc(sizeof(unsigned long));
- if (data)
- *(unsigned long *)data = v;
- }
- break;
- case ECORE_GETOPT_TYPE_DOUBLE:
- {
- if (!_ecore_getopt_parse_double(arg_val, &d))
- goto error;
- data = malloc(sizeof(double));
- if (data)
- *(double *)data = d;
- }
- break;
- default:
- {
- _ecore_getopt_desc_print_error(desc, _("could not parse value.\n"));
- return 0;
- }
- }
-
- *val->listp = eina_list_append(*val->listp, data);
- return 1;
-
- error:
- _ecore_getopt_desc_print_error
- (desc, _("invalid number format %s\n"), arg_val);
- return 0;
+ void *data;
+ long int v;
+ double d;
+ unsigned char b;
+
+ if (!arg_val) {
+ _ecore_getopt_desc_print_error
+ (desc, _("missing parameter to append.\n"));
+ return 0;
+ }
+
+ if (!val->listp) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("value has no pointer set.\n"));
+ return 0;
+ }
+
+ switch (desc->action_param.append_type) {
+ case ECORE_GETOPT_TYPE_STR:
+ data = strdup(arg_val);
+ break;
+ case ECORE_GETOPT_TYPE_BOOL:
+ {
+ if (_ecore_getopt_parse_bool(arg_val, &b)) {
+ data = malloc(sizeof(unsigned char));
+ if (data)
+ *(unsigned char *) data = b;
+ } else {
+ _ecore_getopt_desc_print_error
+ (desc,
+ _("unknown boolean value %s.\n"),
+ arg_val);
+ return 0;
+ }
+ }
+ break;
+ case ECORE_GETOPT_TYPE_SHORT:
+ {
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ data = malloc(sizeof(short));
+ if (data)
+ *(short *) data = (short) v;
+ }
+ break;
+ case ECORE_GETOPT_TYPE_INT:
+ {
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ data = malloc(sizeof(int));
+ if (data)
+ *(int *) data = (int) v;
+ }
+ break;
+ case ECORE_GETOPT_TYPE_LONG:
+ {
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ data = malloc(sizeof(long));
+ if (data)
+ *(long *) data = v;
+ }
+ break;
+ case ECORE_GETOPT_TYPE_USHORT:
+ {
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ data = malloc(sizeof(unsigned short));
+ if (data)
+ *(unsigned short *) data =
+ (unsigned short) v;
+ }
+ break;
+ case ECORE_GETOPT_TYPE_UINT:
+ {
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ data = malloc(sizeof(unsigned int));
+ if (data)
+ *(unsigned int *) data = (unsigned int) v;
+ }
+ break;
+ case ECORE_GETOPT_TYPE_ULONG:
+ {
+ if (!_ecore_getopt_parse_long(arg_val, &v))
+ goto error;
+ data = malloc(sizeof(unsigned long));
+ if (data)
+ *(unsigned long *) data = v;
+ }
+ break;
+ case ECORE_GETOPT_TYPE_DOUBLE:
+ {
+ if (!_ecore_getopt_parse_double(arg_val, &d))
+ goto error;
+ data = malloc(sizeof(double));
+ if (data)
+ *(double *) data = d;
+ }
+ break;
+ default:
+ {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("could not parse value.\n"));
+ return 0;
+ }
+ }
+
+ *val->listp = eina_list_append(*val->listp, data);
+ return 1;
+
+ error:
+ _ecore_getopt_desc_print_error
+ (desc, _("invalid number format %s\n"), arg_val);
+ return 0;
}
static unsigned char
-_ecore_getopt_parse_count(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_count(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (!val->intp)
- {
- _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n"));
- return 0;
- }
-
- (*val->intp)++;
- return 1;
+ if (!val->intp) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("value has no pointer set.\n"));
+ return 0;
+ }
+
+ (*val->intp)++;
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_callback(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val)
+_ecore_getopt_parse_callback(const Ecore_Getopt * parser,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val, const char *arg_val)
{
- const Ecore_Getopt_Desc_Callback *cb = &desc->action_param.callback;
-
- switch (cb->arg_req)
- {
- case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO:
- arg_val = cb->def;
- break;
- case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL:
- if (!arg_val)
- arg_val = cb->def;
- break;
- case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES:
- break;
- }
-
- if (cb->arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
- {
- if ((!arg_val) || (arg_val[0] == '\0'))
- {
- _ecore_getopt_desc_print_error(desc, _("missing parameter.\n"));
- return 0;
- }
-
- if (!val->ptrp)
- {
- _ecore_getopt_desc_print_error
- (desc, _("value has no pointer set.\n"));
- return 0;
- }
- }
-
- if (!cb->func)
- {
- _ecore_getopt_desc_print_error(desc, _("missing callback function!\n"));
- return 0;
- }
-
- return cb->func(parser, desc, arg_val, (void *)cb->data, val);
+ const Ecore_Getopt_Desc_Callback *cb =
+ &desc->action_param.callback;
+
+ switch (cb->arg_req) {
+ case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO:
+ arg_val = cb->def;
+ break;
+ case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL:
+ if (!arg_val)
+ arg_val = cb->def;
+ break;
+ case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES:
+ break;
+ }
+
+ if (cb->arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) {
+ if ((!arg_val) || (arg_val[0] == '\0')) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("missing parameter.\n"));
+ return 0;
+ }
+
+ if (!val->ptrp) {
+ _ecore_getopt_desc_print_error
+ (desc, _("value has no pointer set.\n"));
+ return 0;
+ }
+ }
+
+ if (!cb->func) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("missing callback function!\n"));
+ return 0;
+ }
+
+ return cb->func(parser, desc, arg_val, (void *) cb->data, val);
}
static unsigned char
-_ecore_getopt_parse_help(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc __UNUSED__, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_help(const Ecore_Getopt * parser,
+ const Ecore_Getopt_Desc * desc __UNUSED__,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (val->boolp)
- (*val->boolp) = 1;
- ecore_getopt_help(stdout, parser);
- return 1;
+ if (val->boolp)
+ (*val->boolp) = 1;
+ ecore_getopt_help(stdout, parser);
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_version(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_version(const Ecore_Getopt * parser,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (val->boolp)
- (*val->boolp) = 1;
- if (!parser->version)
- {
- _ecore_getopt_desc_print_error(desc, _("no version was defined.\n"));
- return 0;
- }
- _ecore_getopt_version(stdout, parser);
- return 1;
+ if (val->boolp)
+ (*val->boolp) = 1;
+ if (!parser->version) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("no version was defined.\n"));
+ return 0;
+ }
+ _ecore_getopt_version(stdout, parser);
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_copyright(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_copyright(const Ecore_Getopt * parser,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (val->boolp)
- (*val->boolp) = 1;
- if (!parser->copyright)
- {
- _ecore_getopt_desc_print_error(desc, _("no copyright was defined.\n"));
- return 0;
- }
- _ecore_getopt_copyright(stdout, parser);
- return 1;
+ if (val->boolp)
+ (*val->boolp) = 1;
+ if (!parser->copyright) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("no copyright was defined.\n"));
+ return 0;
+ }
+ _ecore_getopt_copyright(stdout, parser);
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_license(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *val, const char *arg_val __UNUSED__)
+_ecore_getopt_parse_license(const Ecore_Getopt * parser,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * val,
+ const char *arg_val __UNUSED__)
{
- if (val->boolp)
- (*val->boolp) = 1;
- if (!parser->license)
- {
- _ecore_getopt_desc_print_error(desc, _("no license was defined.\n"));
- return 0;
- }
- _ecore_getopt_license(stdout, parser);
- return 1;
+ if (val->boolp)
+ (*val->boolp) = 1;
+ if (!parser->license) {
+ _ecore_getopt_desc_print_error(desc,
+ _
+ ("no license was defined.\n"));
+ return 0;
+ }
+ _ecore_getopt_license(stdout, parser);
+ return 1;
}
static unsigned char
-_ecore_getopt_desc_handle(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, Ecore_Getopt_Value *value, const char *arg_val)
+_ecore_getopt_desc_handle(const Ecore_Getopt * parser,
+ const Ecore_Getopt_Desc * desc,
+ Ecore_Getopt_Value * value, const char *arg_val)
{
- switch (desc->action)
- {
- case ECORE_GETOPT_ACTION_STORE:
- return _ecore_getopt_parse_store(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_STORE_CONST:
- return _ecore_getopt_parse_store_const(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_STORE_TRUE:
- return _ecore_getopt_parse_store_true(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_STORE_FALSE:
- return _ecore_getopt_parse_store_false(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_CHOICE:
- return _ecore_getopt_parse_choice(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_APPEND:
- return _ecore_getopt_parse_append(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_COUNT:
- return _ecore_getopt_parse_count(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_CALLBACK:
- return _ecore_getopt_parse_callback(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_HELP:
- return _ecore_getopt_parse_help(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_VERSION:
- return _ecore_getopt_parse_version(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_COPYRIGHT:
- return _ecore_getopt_parse_copyright(parser, desc, value, arg_val);
- case ECORE_GETOPT_ACTION_LICENSE:
- return _ecore_getopt_parse_license(parser, desc, value, arg_val);
- default:
- return 0;
- }
+ switch (desc->action) {
+ case ECORE_GETOPT_ACTION_STORE:
+ return _ecore_getopt_parse_store(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_STORE_CONST:
+ return _ecore_getopt_parse_store_const(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_STORE_TRUE:
+ return _ecore_getopt_parse_store_true(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_STORE_FALSE:
+ return _ecore_getopt_parse_store_false(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_CHOICE:
+ return _ecore_getopt_parse_choice(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_APPEND:
+ return _ecore_getopt_parse_append(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_COUNT:
+ return _ecore_getopt_parse_count(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_CALLBACK:
+ return _ecore_getopt_parse_callback(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_HELP:
+ return _ecore_getopt_parse_help(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_VERSION:
+ return _ecore_getopt_parse_version(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_COPYRIGHT:
+ return _ecore_getopt_parse_copyright(parser, desc, value,
+ arg_val);
+ case ECORE_GETOPT_ACTION_LICENSE:
+ return _ecore_getopt_parse_license(parser, desc, value,
+ arg_val);
+ default:
+ return 0;
+ }
}
static unsigned char
-_ecore_getopt_parse_arg_long(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc __UNUSED__, char **argv, int *idx, int *nonargs, const char *arg)
+_ecore_getopt_parse_arg_long(const Ecore_Getopt * parser,
+ Ecore_Getopt_Value * values,
+ int argc __UNUSED__, char **argv, int *idx,
+ int *nonargs, const char *arg)
{
- const Ecore_Getopt_Desc *desc;
- Ecore_Getopt_Desc_Arg_Requirement arg_req;
- const char *arg_val;
- int desc_idx;
- Ecore_Getopt_Value *value;
- unsigned char ret;
-
- desc = _ecore_getopt_parse_find_long(parser, arg);
- if (!desc)
- {
- fprintf(stderr, _("ERROR: unknown option --%s, ignored.\n"), arg);
- if (parser->strict)
- return 0;
-
- (*idx)++;
- return 1;
- }
-
- (*idx)++;
-
- arg_req = _ecore_getopt_desc_arg_requirement(desc);
- if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
- {
- arg_val = strchr(arg, '=');
- if (arg_val)
- arg_val++;
- else
- {
- if ((*idx < *nonargs) && (argv[*idx][0] != '-'))
- {
- arg_val = argv[*idx];
- (*idx)++;
- }
- else
- arg_val = NULL;
- }
-
- if (arg_val && arg_val[0] == '\0')
- arg_val = NULL;
-
- if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES))
- {
- fprintf
- (stderr, _("ERROR: option --%s requires an argument!\n"), arg);
- if (parser->strict)
- return 0;
- return 1;
- }
- }
- else
- arg_val = NULL;
-
- desc_idx = desc - parser->descs;
- value = values + desc_idx;
- ret = _ecore_getopt_desc_handle(parser, desc, value, arg_val);
- if ((!ret) && parser->strict)
- return 0;
-
- return 1;
+ const Ecore_Getopt_Desc *desc;
+ Ecore_Getopt_Desc_Arg_Requirement arg_req;
+ const char *arg_val;
+ int desc_idx;
+ Ecore_Getopt_Value *value;
+ unsigned char ret;
+
+ desc = _ecore_getopt_parse_find_long(parser, arg);
+ if (!desc) {
+ fprintf(stderr,
+ _("ERROR: unknown option --%s, ignored.\n"), arg);
+ if (parser->strict)
+ return 0;
+
+ (*idx)++;
+ return 1;
+ }
+
+ (*idx)++;
+
+ arg_req = _ecore_getopt_desc_arg_requirement(desc);
+ if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) {
+ arg_val = strchr(arg, '=');
+ if (arg_val)
+ arg_val++;
+ else {
+ if ((*idx < *nonargs) && (argv[*idx][0] != '-')) {
+ arg_val = argv[*idx];
+ (*idx)++;
+ } else
+ arg_val = NULL;
+ }
+
+ if (arg_val && arg_val[0] == '\0')
+ arg_val = NULL;
+
+ if ((!arg_val)
+ && (arg_req ==
+ ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) {
+ fprintf(stderr,
+ _
+ ("ERROR: option --%s requires an argument!\n"),
+ arg);
+ if (parser->strict)
+ return 0;
+ return 1;
+ }
+ } else
+ arg_val = NULL;
+
+ desc_idx = desc - parser->descs;
+ value = values + desc_idx;
+ ret = _ecore_getopt_desc_handle(parser, desc, value, arg_val);
+ if ((!ret) && parser->strict)
+ return 0;
+
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_arg_short(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc __UNUSED__, char **argv, int *idx, int *nonargs, const char *arg)
+_ecore_getopt_parse_arg_short(const Ecore_Getopt * parser,
+ Ecore_Getopt_Value * values,
+ int argc __UNUSED__, char **argv, int *idx,
+ int *nonargs, const char *arg)
{
- int run = 1;
- while (run && (arg[0] != '\0'))
- {
- int opt = arg[0];
- const Ecore_Getopt_Desc *desc;
- Ecore_Getopt_Desc_Arg_Requirement arg_req;
- const char *arg_val;
- int desc_idx;
- Ecore_Getopt_Value *value;
- unsigned char ret;
-
- desc = _ecore_getopt_parse_find_short(parser, arg[0]);
- if (!desc)
- {
- fprintf
- (stderr, _("ERROR: unknown option -%c, ignored.\n"), arg[0]);
- if (parser->strict)
- return 0;
-
- arg++;
- continue;
- }
-
- arg++;
-
- arg_req = _ecore_getopt_desc_arg_requirement(desc);
- if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO)
- {
- (*idx)++;
- run = 0;
-
- if (arg[0] == '=')
- arg_val = arg + 1;
- else if (arg[0] != '\0')
- arg_val = arg;
- else
- {
- if ((*idx < *nonargs) && (argv[*idx][0] != '-'))
- {
- arg_val = argv[*idx];
- (*idx)++;
- }
- else
- arg_val = NULL;
- }
-
- if (arg_val && arg_val[0] == '\0')
- arg_val = NULL;
-
- if ((!arg_val) &&
- (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES))
- {
- fprintf
- (stderr, _("ERROR: option -%c requires an argument!\n"),
- opt);
- if (parser->strict)
- return 0;
- return 1;
- }
- }
- else
- arg_val = NULL;
-
- desc_idx = desc - parser->descs;
- value = values + desc_idx;
- ret = _ecore_getopt_desc_handle(parser, desc, value, arg_val);
- if ((!ret) && parser->strict)
- return 0;
- }
-
- if (run)
- (*idx)++;
-
- return 1;
+ int run = 1;
+ while (run && (arg[0] != '\0')) {
+ int opt = arg[0];
+ const Ecore_Getopt_Desc *desc;
+ Ecore_Getopt_Desc_Arg_Requirement arg_req;
+ const char *arg_val;
+ int desc_idx;
+ Ecore_Getopt_Value *value;
+ unsigned char ret;
+
+ desc = _ecore_getopt_parse_find_short(parser, arg[0]);
+ if (!desc) {
+ fprintf
+ (stderr,
+ _("ERROR: unknown option -%c, ignored.\n"),
+ arg[0]);
+ if (parser->strict)
+ return 0;
+
+ arg++;
+ continue;
+ }
+
+ arg++;
+
+ arg_req = _ecore_getopt_desc_arg_requirement(desc);
+ if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) {
+ (*idx)++;
+ run = 0;
+
+ if (arg[0] == '=')
+ arg_val = arg + 1;
+ else if (arg[0] != '\0')
+ arg_val = arg;
+ else {
+ if ((*idx < *nonargs)
+ && (argv[*idx][0] != '-')) {
+ arg_val = argv[*idx];
+ (*idx)++;
+ } else
+ arg_val = NULL;
+ }
+
+ if (arg_val && arg_val[0] == '\0')
+ arg_val = NULL;
+
+ if ((!arg_val) &&
+ (arg_req ==
+ ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) {
+ fprintf(stderr,
+ _
+ ("ERROR: option -%c requires an argument!\n"),
+ opt);
+ if (parser->strict)
+ return 0;
+ return 1;
+ }
+ } else
+ arg_val = NULL;
+
+ desc_idx = desc - parser->descs;
+ value = values + desc_idx;
+ ret =
+ _ecore_getopt_desc_handle(parser, desc, value,
+ arg_val);
+ if ((!ret) && parser->strict)
+ return 0;
+ }
+
+ if (run)
+ (*idx)++;
+
+ return 1;
}
static unsigned char
-_ecore_getopt_parse_arg(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc, char **argv, int *idx, int *nonargs)
+_ecore_getopt_parse_arg(const Ecore_Getopt * parser,
+ Ecore_Getopt_Value * values, int argc, char **argv,
+ int *idx, int *nonargs)
{
- char *arg = argv[*idx];
-
- if (arg[0] != '-')
- {
- char **dst, **src, **src_end;
-
- dst = argv + *idx;
- src = dst + 1;
- src_end = src + *nonargs - *idx - 1;
-
- for (; src < src_end; src++, dst++)
- *dst = *src;
-
- *dst = arg;
- (*nonargs)--;
- return 1;
- }
-
- if (arg[1] == '-')
- return _ecore_getopt_parse_arg_long
- (parser, values, argc, argv, idx, nonargs, arg + 2);
- else
- return _ecore_getopt_parse_arg_short
- (parser, values, argc, argv, idx, nonargs, arg + 1);
+ char *arg = argv[*idx];
+
+ if (arg[0] != '-') {
+ char **dst, **src, **src_end;
+
+ dst = argv + *idx;
+ src = dst + 1;
+ src_end = src + *nonargs - *idx - 1;
+
+ for (; src < src_end; src++, dst++)
+ *dst = *src;
+
+ *dst = arg;
+ (*nonargs)--;
+ return 1;
+ }
+
+ if (arg[1] == '-')
+ return _ecore_getopt_parse_arg_long
+ (parser, values, argc, argv, idx, nonargs, arg + 2);
+ else
+ return _ecore_getopt_parse_arg_short
+ (parser, values, argc, argv, idx, nonargs, arg + 1);
}
-static const Ecore_Getopt_Desc *
-_ecore_getopt_parse_find_short_other(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *orig)
+static const Ecore_Getopt_Desc *_ecore_getopt_parse_find_short_other(const
+ Ecore_Getopt
+ *
+ parser,
+ const
+ Ecore_Getopt_Desc
+ *
+ orig)
{
- const Ecore_Getopt_Desc *desc = parser->descs;
- const char c = orig->shortname;
+ const Ecore_Getopt_Desc *desc = parser->descs;
+ const char c = orig->shortname;
- for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
- {
- if (desc == orig)
- return NULL;
+ for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) {
+ if (desc == orig)
+ return NULL;
- if (c == desc->shortname)
- return desc;
- }
+ if (c == desc->shortname)
+ return desc;
+ }
- return NULL;
+ return NULL;
}
-static const Ecore_Getopt_Desc *
-_ecore_getopt_parse_find_long_other(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *orig)
+static const Ecore_Getopt_Desc *_ecore_getopt_parse_find_long_other(const
+ Ecore_Getopt
+ *
+ parser,
+ const
+ Ecore_Getopt_Desc
+ * orig)
{
- const Ecore_Getopt_Desc *desc = parser->descs;
- const char *name = orig->longname;
+ const Ecore_Getopt_Desc *desc = parser->descs;
+ const char *name = orig->longname;
- for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
- {
- if (desc == orig)
- return NULL;
+ for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) {
+ if (desc == orig)
+ return NULL;
- if (desc->longname && (strcmp(name, desc->longname) == 0))
- return desc;
- }
+ if (desc->longname && (strcmp(name, desc->longname) == 0))
+ return desc;
+ }
- return NULL;
+ return NULL;
}
/**
@@ -1508,56 +1546,62 @@ _ecore_getopt_parse_find_long_other(const Ecore_Getopt *parser, const Ecore_Geto
* @return 1 if there are duplicates, 0 otherwise.
*/
unsigned char
-ecore_getopt_parser_has_duplicates(const Ecore_Getopt *parser)
+ecore_getopt_parser_has_duplicates(const Ecore_Getopt * parser)
{
- const Ecore_Getopt_Desc *desc = parser->descs;
- for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
- {
- if (desc->shortname)
- {
- const Ecore_Getopt_Desc *other;
- other = _ecore_getopt_parse_find_short_other(parser, desc);
- if (other)
- {
- _ecore_getopt_desc_print_error
- (desc, "short name -%c already exists.", desc->shortname);
-
- if (other->longname)
- fprintf(stderr, " Other is --%s.\n", other->longname);
- else
- fputc('\n', stderr);
- return 1;
- }
- }
-
- if (desc->longname)
- {
- const Ecore_Getopt_Desc *other;
- other = _ecore_getopt_parse_find_long_other(parser, desc);
- if (other)
- {
- _ecore_getopt_desc_print_error
- (desc, "long name --%s already exists.", desc->longname);
-
- if (other->shortname)
- fprintf(stderr, " Other is -%c.\n", other->shortname);
- else
- fputc('\n', stderr);
- return 1;
- }
- }
- }
- return 0;
+ const Ecore_Getopt_Desc *desc = parser->descs;
+ for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) {
+ if (desc->shortname) {
+ const Ecore_Getopt_Desc *other;
+ other =
+ _ecore_getopt_parse_find_short_other(parser,
+ desc);
+ if (other) {
+ _ecore_getopt_desc_print_error
+ (desc,
+ "short name -%c already exists.",
+ desc->shortname);
+
+ if (other->longname)
+ fprintf(stderr,
+ " Other is --%s.\n",
+ other->longname);
+ else
+ fputc('\n', stderr);
+ return 1;
+ }
+ }
+
+ if (desc->longname) {
+ const Ecore_Getopt_Desc *other;
+ other =
+ _ecore_getopt_parse_find_long_other(parser,
+ desc);
+ if (other) {
+ _ecore_getopt_desc_print_error
+ (desc,
+ "long name --%s already exists.",
+ desc->longname);
+
+ if (other->shortname)
+ fprintf(stderr, " Other is -%c.\n",
+ other->shortname);
+ else
+ fputc('\n', stderr);
+ return 1;
+ }
+ }
+ }
+ return 0;
}
-static const Ecore_Getopt_Desc *
-_ecore_getopt_find_help(const Ecore_Getopt *parser)
+static const Ecore_Getopt_Desc *_ecore_getopt_find_help(const Ecore_Getopt
+ * parser)
{
- const Ecore_Getopt_Desc *desc = parser->descs;
- for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
- if (desc->action == ECORE_GETOPT_ACTION_HELP)
- return desc;
- return NULL;
+ const Ecore_Getopt_Desc *desc = parser->descs;
+ for (; !_ecore_getopt_desc_is_sentinel(desc); desc++)
+ if (desc->action == ECORE_GETOPT_ACTION_HELP)
+ return desc;
+ return NULL;
}
/**
@@ -1611,64 +1655,64 @@ _ecore_getopt_find_help(const Ecore_Getopt *parser)
* @return index of first non-option parameter or -1 on error.
*/
int
-ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc, char **argv)
+ecore_getopt_parse(const Ecore_Getopt * parser,
+ Ecore_Getopt_Value * values, int argc, char **argv)
{
- int i, nonargs;
-
- if (!parser)
- {
- fputs(_("ERROR: no parser provided.\n"), stderr);
- return -1;
- }
- if (!values)
- {
- fputs(_("ERROR: no values provided.\n"), stderr);
- return -1;
- }
-
- if ((argc < 1) || (!argv))
- ecore_app_args_get(&argc, &argv);
-
- if (argc < 1)
- {
- fputs(_("ERROR: no arguments provided.\n"), stderr);
- return -1;
- }
-
- if (argv[0])
- prog = argv[0];
- else
- prog = parser->prog;
-
- nonargs = _ecore_getopt_parse_find_nonargs_base(parser, argc, argv);
- if (nonargs < 0)
- goto error;
-
- if (nonargs > argc)
- nonargs = argc;
-
- i = 1;
- while (i < nonargs)
- if (!_ecore_getopt_parse_arg(parser, values, argc, argv, &i, &nonargs))
- goto error;
-
- return nonargs;
-
- error:
- {
- const Ecore_Getopt_Desc *help;
- fputs(_("ERROR: invalid options found."), stderr);
-
- help = _ecore_getopt_find_help(parser);
- if (!help)
- fputc('\n', stderr);
- else if (help->longname)
- fprintf(stderr, _(" See --%s.\n"), help->longname);
- else
- fprintf(stderr, _(" See -%c.\n"), help->shortname);
- }
-
- return -1;
+ int i, nonargs;
+
+ if (!parser) {
+ fputs(_("ERROR: no parser provided.\n"), stderr);
+ return -1;
+ }
+ if (!values) {
+ fputs(_("ERROR: no values provided.\n"), stderr);
+ return -1;
+ }
+
+ if ((argc < 1) || (!argv))
+ ecore_app_args_get(&argc, &argv);
+
+ if (argc < 1) {
+ fputs(_("ERROR: no arguments provided.\n"), stderr);
+ return -1;
+ }
+
+ if (argv[0])
+ prog = argv[0];
+ else
+ prog = parser->prog;
+
+ nonargs =
+ _ecore_getopt_parse_find_nonargs_base(parser, argc, argv);
+ if (nonargs < 0)
+ goto error;
+
+ if (nonargs > argc)
+ nonargs = argc;
+
+ i = 1;
+ while (i < nonargs)
+ if (!_ecore_getopt_parse_arg
+ (parser, values, argc, argv, &i, &nonargs))
+ goto error;
+
+ return nonargs;
+
+ error:
+ {
+ const Ecore_Getopt_Desc *help;
+ fputs(_("ERROR: invalid options found."), stderr);
+
+ help = _ecore_getopt_find_help(parser);
+ if (!help)
+ fputc('\n', stderr);
+ else if (help->longname)
+ fprintf(stderr, _(" See --%s.\n"), help->longname);
+ else
+ fprintf(stderr, _(" See -%c.\n"), help->shortname);
+ }
+
+ return -1;
}
/**
@@ -1677,14 +1721,13 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a
* @param list pointer to list to be freed.
* @return always NULL, so you can easily make your list head NULL.
*/
-Eina_List *
-ecore_getopt_list_free(Eina_List *list)
+Eina_List *ecore_getopt_list_free(Eina_List * list)
{
- void *data;
+ void *data;
- EINA_LIST_FREE(list, data)
- free(data);
- return NULL;
+ EINA_LIST_FREE(list, data)
+ free(data);
+ return NULL;
}
/**
@@ -1696,17 +1739,22 @@ ecore_getopt_list_free(Eina_List *list)
* @c callback_data value is ignored, you can safely use @c NULL.
*/
unsigned char
-ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc __UNUSED__, const char *str, void *data __UNUSED__, Ecore_Getopt_Value *storage)
+ecore_getopt_callback_geometry_parse(const Ecore_Getopt *
+ parser __UNUSED__,
+ const Ecore_Getopt_Desc *
+ desc __UNUSED__, const char *str,
+ void *data __UNUSED__,
+ Ecore_Getopt_Value * storage)
{
- Eina_Rectangle *v = (Eina_Rectangle *)storage->ptrp;
+ Eina_Rectangle *v = (Eina_Rectangle *) storage->ptrp;
- if (sscanf(str, "%d:%d:%d:%d", &v->x, &v->y, &v->w, &v->h) != 4)
- {
- fprintf(stderr, _("ERROR: incorrect geometry value '%s'\n"), str);
- return 0;
- }
+ if (sscanf(str, "%d:%d:%d:%d", &v->x, &v->y, &v->w, &v->h) != 4) {
+ fprintf(stderr,
+ _("ERROR: incorrect geometry value '%s'\n"), str);
+ return 0;
+ }
- return 1;
+ return 1;
}
/**
@@ -1719,17 +1767,20 @@ ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser __UNUSED__, cons
* @c callback_data value is ignored, you can safely use @c NULL.
*/
unsigned char
-ecore_getopt_callback_size_parse(const Ecore_Getopt *parser __UNUSED__, const Ecore_Getopt_Desc *desc __UNUSED__, const char *str, void *data __UNUSED__, Ecore_Getopt_Value *storage)
+ecore_getopt_callback_size_parse(const Ecore_Getopt * parser __UNUSED__,
+ const Ecore_Getopt_Desc * desc __UNUSED__,
+ const char *str, void *data __UNUSED__,
+ Ecore_Getopt_Value * storage)
{
- Eina_Rectangle *v = (Eina_Rectangle *)storage->ptrp;
+ Eina_Rectangle *v = (Eina_Rectangle *) storage->ptrp;
- if (sscanf(str, "%dx%d", &v->w, &v->h) != 2)
- {
- fprintf(stderr, _("ERROR: incorrect size value '%s'\n"), str);
- return 0;
- }
- v->x = 0;
- v->y = 0;
+ if (sscanf(str, "%dx%d", &v->w, &v->h) != 2) {
+ fprintf(stderr, _("ERROR: incorrect size value '%s'\n"),
+ str);
+ return 0;
+ }
+ v->x = 0;
+ v->y = 0;
- return 1;
+ return 1;
}
diff --git a/tests/suite/ecore/src/lib/ecore_glib.c b/tests/suite/ecore/src/lib/ecore_glib.c
index 0972776ef0..d986d221cf 100644
--- a/tests/suite/ecore/src/lib/ecore_glib.c
+++ b/tests/suite/ecore/src/lib/ecore_glib.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdio.h>
@@ -19,203 +19,207 @@ static const size_t ECORE_GLIB_FDS_INITIAL = 128;
static const size_t ECORE_GLIB_FDS_STEP = 8;
static const size_t ECORE_GLIB_FDS_MAX_FREE = 256;
-static Eina_Bool
-_ecore_glib_fds_resize(size_t size)
+static Eina_Bool _ecore_glib_fds_resize(size_t size)
{
- void *tmp = realloc(_ecore_glib_fds, sizeof(GPollFD) * size);
-
- if (!tmp)
- {
- ERR("Could not realloc from %zu to %zu buckets.",
- _ecore_glib_fds_size, size);
- return EINA_FALSE;
- }
-
- _ecore_glib_fds = tmp;
- _ecore_glib_fds_size = size;
- return EINA_TRUE;
+ void *tmp = realloc(_ecore_glib_fds, sizeof(GPollFD) * size);
+
+ if (!tmp) {
+ ERR("Could not realloc from %zu to %zu buckets.",
+ _ecore_glib_fds_size, size);
+ return EINA_FALSE;
+ }
+
+ _ecore_glib_fds = tmp;
+ _ecore_glib_fds_size = size;
+ return EINA_TRUE;
}
static int
-_ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer)
+_ecore_glib_context_query(GMainContext * ctx, int priority, int *p_timer)
{
- int reqfds;
-
- if (_ecore_glib_fds_size == 0)
- {
- if (!_ecore_glib_fds_resize(ECORE_GLIB_FDS_INITIAL)) return -1;
- }
-
- while (1)
- {
- size_t size;
-
- reqfds = g_main_context_query
- (ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size);
- if (reqfds <= (int)_ecore_glib_fds_size) break;
-
- size = (1 + reqfds / ECORE_GLIB_FDS_STEP) * ECORE_GLIB_FDS_STEP;
- if (!_ecore_glib_fds_resize(size)) return -1;
- }
-
- if (reqfds + ECORE_GLIB_FDS_MAX_FREE < _ecore_glib_fds_size)
- {
- size_t size;
-
- size = (1 + reqfds / ECORE_GLIB_FDS_MAX_FREE) * ECORE_GLIB_FDS_MAX_FREE;
- _ecore_glib_fds_resize(size);
- }
-
- return reqfds;
+ int reqfds;
+
+ if (_ecore_glib_fds_size == 0) {
+ if (!_ecore_glib_fds_resize(ECORE_GLIB_FDS_INITIAL))
+ return -1;
+ }
+
+ while (1) {
+ size_t size;
+
+ reqfds = g_main_context_query
+ (ctx, priority, p_timer, _ecore_glib_fds,
+ _ecore_glib_fds_size);
+ if (reqfds <= (int) _ecore_glib_fds_size)
+ break;
+
+ size =
+ (1 +
+ reqfds / ECORE_GLIB_FDS_STEP) * ECORE_GLIB_FDS_STEP;
+ if (!_ecore_glib_fds_resize(size))
+ return -1;
+ }
+
+ if (reqfds + ECORE_GLIB_FDS_MAX_FREE < _ecore_glib_fds_size) {
+ size_t size;
+
+ size =
+ (1 +
+ reqfds / ECORE_GLIB_FDS_MAX_FREE) *
+ ECORE_GLIB_FDS_MAX_FREE;
+ _ecore_glib_fds_resize(size);
+ }
+
+ return reqfds;
}
static int
-_ecore_glib_context_poll_from(const GPollFD *pfds, int count, fd_set *rfds, fd_set *wfds, fd_set *efds)
+_ecore_glib_context_poll_from(const GPollFD * pfds, int count,
+ fd_set * rfds, fd_set * wfds, fd_set * efds)
{
- const GPollFD *itr = pfds, *itr_end = pfds + count;
- int glib_fds = -1;
-
- for (; itr < itr_end; itr++)
- {
- if (glib_fds < itr->fd)
- glib_fds = itr->fd;
-
- if (itr->events & G_IO_IN)
- FD_SET(itr->fd, rfds);
- if (itr->events & G_IO_OUT)
- FD_SET(itr->fd, wfds);
- if (itr->events & (G_IO_HUP | G_IO_ERR))
- FD_SET(itr->fd, efds);
- }
-
- return glib_fds + 1;
+ const GPollFD *itr = pfds, *itr_end = pfds + count;
+ int glib_fds = -1;
+
+ for (; itr < itr_end; itr++) {
+ if (glib_fds < itr->fd)
+ glib_fds = itr->fd;
+
+ if (itr->events & G_IO_IN)
+ FD_SET(itr->fd, rfds);
+ if (itr->events & G_IO_OUT)
+ FD_SET(itr->fd, wfds);
+ if (itr->events & (G_IO_HUP | G_IO_ERR))
+ FD_SET(itr->fd, efds);
+ }
+
+ return glib_fds + 1;
}
static int
-_ecore_glib_context_poll_to(GPollFD *pfds, int count, const fd_set *rfds, const fd_set *wfds, const fd_set *efds, int ready)
+_ecore_glib_context_poll_to(GPollFD * pfds, int count, const fd_set * rfds,
+ const fd_set * wfds, const fd_set * efds,
+ int ready)
{
- GPollFD *itr = pfds, *itr_end = pfds + count;
-
- for (; itr < itr_end && ready > 0; itr++)
- {
- itr->revents = 0;
- if (FD_ISSET(itr->fd, rfds))
- {
- itr->revents |= G_IO_IN;
- ready--;
- }
- if (FD_ISSET(itr->fd, wfds))
- {
- itr->revents |= G_IO_OUT;
- ready--;
- }
- if (FD_ISSET(itr->fd, efds))
- {
- itr->revents |= G_IO_ERR;
- ready--;
- }
- }
- return ready;
+ GPollFD *itr = pfds, *itr_end = pfds + count;
+
+ for (; itr < itr_end && ready > 0; itr++) {
+ itr->revents = 0;
+ if (FD_ISSET(itr->fd, rfds)) {
+ itr->revents |= G_IO_IN;
+ ready--;
+ }
+ if (FD_ISSET(itr->fd, wfds)) {
+ itr->revents |= G_IO_OUT;
+ ready--;
+ }
+ if (FD_ISSET(itr->fd, efds)) {
+ itr->revents |= G_IO_ERR;
+ ready--;
+ }
+ }
+ return ready;
}
static int
-_ecore_glib_select__locked(GMainContext *ctx, int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *ecore_timeout)
+_ecore_glib_select__locked(GMainContext * ctx, int ecore_fds,
+ fd_set * rfds, fd_set * wfds, fd_set * efds,
+ struct timeval *ecore_timeout)
{
- int priority, maxfds, glib_fds, reqfds, reqtimeout, ret;
- struct timeval *timeout, glib_timeout;
-
- g_main_context_prepare(ctx, &priority);
- reqfds = _ecore_glib_context_query(ctx, priority, &reqtimeout);
- if (reqfds < 0) goto error;
-
- glib_fds = _ecore_glib_context_poll_from
- (_ecore_glib_fds, reqfds, rfds, wfds, efds);
-
- if (reqtimeout == -1)
- timeout = ecore_timeout;
- else
- {
- glib_timeout.tv_sec = reqtimeout / 1000;
- glib_timeout.tv_usec = (reqtimeout % 1000) * 1000;
-
- if (!ecore_timeout || timercmp(ecore_timeout, &glib_timeout, >))
- timeout = &glib_timeout;
- else
- timeout = ecore_timeout;
- }
-
- maxfds = (ecore_fds >= glib_fds) ? ecore_fds : glib_fds;
- ret = _ecore_glib_select_original(maxfds, rfds, wfds, efds, timeout);
-
- ret = _ecore_glib_context_poll_to
- (_ecore_glib_fds, reqfds, rfds, wfds, efds, ret);
-
- if (g_main_context_check(ctx, priority, _ecore_glib_fds, reqfds))
- g_main_context_dispatch(ctx);
-
- return ret;
-
- error:
- return _ecore_glib_select_original
- (ecore_fds, rfds, wfds, efds, ecore_timeout);
+ int priority, maxfds, glib_fds, reqfds, reqtimeout, ret;
+ struct timeval *timeout, glib_timeout;
+
+ g_main_context_prepare(ctx, &priority);
+ reqfds = _ecore_glib_context_query(ctx, priority, &reqtimeout);
+ if (reqfds < 0)
+ goto error;
+
+ glib_fds = _ecore_glib_context_poll_from
+ (_ecore_glib_fds, reqfds, rfds, wfds, efds);
+
+ if (reqtimeout == -1)
+ timeout = ecore_timeout;
+ else {
+ glib_timeout.tv_sec = reqtimeout / 1000;
+ glib_timeout.tv_usec = (reqtimeout % 1000) * 1000;
+
+ if (!ecore_timeout
+ || timercmp(ecore_timeout, &glib_timeout, >))
+ timeout = &glib_timeout;
+ else
+ timeout = ecore_timeout;
+ }
+
+ maxfds = (ecore_fds >= glib_fds) ? ecore_fds : glib_fds;
+ ret =
+ _ecore_glib_select_original(maxfds, rfds, wfds, efds, timeout);
+
+ ret = _ecore_glib_context_poll_to
+ (_ecore_glib_fds, reqfds, rfds, wfds, efds, ret);
+
+ if (g_main_context_check(ctx, priority, _ecore_glib_fds, reqfds))
+ g_main_context_dispatch(ctx);
+
+ return ret;
+
+ error:
+ return _ecore_glib_select_original
+ (ecore_fds, rfds, wfds, efds, ecore_timeout);
}
static int
-_ecore_glib_select(int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *ecore_timeout)
+_ecore_glib_select(int ecore_fds, fd_set * rfds, fd_set * wfds,
+ fd_set * efds, struct timeval *ecore_timeout)
{
- GStaticMutex lock = G_STATIC_MUTEX_INIT;
- GMutex *mutex = g_static_mutex_get_mutex(&lock);
- GMainContext *ctx = g_main_context_default();
- int ret;
+ GStaticMutex lock = G_STATIC_MUTEX_INIT;
+ GMutex *mutex = g_static_mutex_get_mutex(&lock);
+ GMainContext *ctx = g_main_context_default();
+ int ret;
- if (g_main_context_acquire(ctx))
- g_mutex_lock(mutex);
- else
- {
- if (!_ecore_glib_cond)
- _ecore_glib_cond = g_cond_new();
+ if (g_main_context_acquire(ctx))
+ g_mutex_lock(mutex);
+ else {
+ if (!_ecore_glib_cond)
+ _ecore_glib_cond = g_cond_new();
- while (!g_main_context_wait(ctx, _ecore_glib_cond, mutex))
- g_thread_yield();
- }
+ while (!g_main_context_wait(ctx, _ecore_glib_cond, mutex))
+ g_thread_yield();
+ }
- ret = _ecore_glib_select__locked
- (ctx, ecore_fds, rfds, wfds, efds, ecore_timeout);
+ ret = _ecore_glib_select__locked
+ (ctx, ecore_fds, rfds, wfds, efds, ecore_timeout);
- g_mutex_unlock(mutex);
- g_main_context_release(ctx);
+ g_mutex_unlock(mutex);
+ g_main_context_release(ctx);
- return ret;
+ return ret;
}
#endif
-void
-_ecore_glib_init(void)
+void _ecore_glib_init(void)
{
}
-void
-_ecore_glib_shutdown(void)
+void _ecore_glib_shutdown(void)
{
#ifdef HAVE_GLIB
- if (!_ecore_glib_active) return;
- _ecore_glib_active = EINA_FALSE;
-
- if (ecore_main_loop_select_func_get() == _ecore_glib_select)
- ecore_main_loop_select_func_set(_ecore_glib_select_original);
-
- if (_ecore_glib_fds)
- {
- free(_ecore_glib_fds);
- _ecore_glib_fds = NULL;
- }
- _ecore_glib_fds_size = 0;
-
- if (_ecore_glib_cond)
- {
- g_cond_free(_ecore_glib_cond);
- _ecore_glib_cond = NULL;
- }
+ if (!_ecore_glib_active)
+ return;
+ _ecore_glib_active = EINA_FALSE;
+
+ if (ecore_main_loop_select_func_get() == _ecore_glib_select)
+ ecore_main_loop_select_func_set
+ (_ecore_glib_select_original);
+
+ if (_ecore_glib_fds) {
+ free(_ecore_glib_fds);
+ _ecore_glib_fds = NULL;
+ }
+ _ecore_glib_fds_size = 0;
+
+ if (_ecore_glib_cond) {
+ g_cond_free(_ecore_glib_cond);
+ _ecore_glib_cond = NULL;
+ }
#endif
}
@@ -249,22 +253,23 @@ _ecore_glib_shutdown(void)
* @return @c EINA_TRUE on success of @c EINA_FALSE if it failed,
* likely no GLib support in Ecore.
*/
-EAPI Eina_Bool
-ecore_main_loop_glib_integrate(void)
+EAPI Eina_Bool ecore_main_loop_glib_integrate(void)
{
#ifdef HAVE_GLIB
- void *func;
-
- if (_ecore_glib_active) return EINA_TRUE;
- func = ecore_main_loop_select_func_get();
- if (func == _ecore_glib_select) return EINA_TRUE;
- _ecore_glib_select_original = func;
- ecore_main_loop_select_func_set(_ecore_glib_select);
- _ecore_glib_active = EINA_TRUE;
- return EINA_TRUE;
+ void *func;
+
+ if (_ecore_glib_active)
+ return EINA_TRUE;
+ func = ecore_main_loop_select_func_get();
+ if (func == _ecore_glib_select)
+ return EINA_TRUE;
+ _ecore_glib_select_original = func;
+ ecore_main_loop_select_func_set(_ecore_glib_select);
+ _ecore_glib_active = EINA_TRUE;
+ return EINA_TRUE;
#else
- fputs("ERROR: no glib support in ecore.\n", stderr);
- return EINA_FALSE;
+ fputs("ERROR: no glib support in ecore.\n", stderr);
+ return EINA_FALSE;
#endif
}
@@ -279,8 +284,7 @@ Eina_Bool _ecore_glib_always_integrate = 1;
* This is for apps that explicitly do not want this to happen for whatever
* reasons they may have.
*/
-EAPI void
-ecore_main_loop_glib_always_integrate_disable(void)
+EAPI void ecore_main_loop_glib_always_integrate_disable(void)
{
- _ecore_glib_always_integrate = 0;
+ _ecore_glib_always_integrate = 0;
}
diff --git a/tests/suite/ecore/src/lib/ecore_idle_enterer.c b/tests/suite/ecore/src/lib/ecore_idle_enterer.c
index 2b827ce93e..62c340f109 100644
--- a/tests/suite/ecore/src/lib/ecore_idle_enterer.c
+++ b/tests/suite/ecore/src/lib/ecore_idle_enterer.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -8,20 +8,19 @@
#include "ecore_private.h"
-struct _Ecore_Idle_Enterer
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Task_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
+struct _Ecore_Idle_Enterer {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Task_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me:1;
};
static Ecore_Idle_Enterer *idle_enterers = NULL;
static Ecore_Idle_Enterer *idle_enterer_current = NULL;
-static int idle_enterers_delete_me = 0;
+static int idle_enterers_delete_me = 0;
/**
* Add an idle enterer handler.
@@ -31,19 +30,24 @@ static int idle_enterers_delete_me = 0;
* NULL is returned.
* @ingroup Idle_Group
*/
-EAPI Ecore_Idle_Enterer *
-ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Idle_Enterer *ecore_idle_enterer_add(Ecore_Task_Cb func,
+ const void *data)
{
- Ecore_Idle_Enterer *ie;
-
- if (!func) return NULL;
- ie = calloc(1, sizeof(Ecore_Idle_Enterer));
- if (!ie) return NULL;
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
- ie->func = func;
- ie->data = (void *)data;
- idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_append(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
- return ie;
+ Ecore_Idle_Enterer *ie;
+
+ if (!func)
+ return NULL;
+ ie = calloc(1, sizeof(Ecore_Idle_Enterer));
+ if (!ie)
+ return NULL;
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
+ ie->func = func;
+ ie->data = (void *) data;
+ idle_enterers =
+ (Ecore_Idle_Enterer *)
+ eina_inlist_append(EINA_INLIST_GET(idle_enterers),
+ EINA_INLIST_GET(ie));
+ return ie;
}
/**
@@ -54,19 +58,24 @@ ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data)
* NULL is returned.
* @ingroup Idle_Group
*/
-EAPI Ecore_Idle_Enterer *
-ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Idle_Enterer *ecore_idle_enterer_before_add(Ecore_Task_Cb func,
+ const void *data)
{
- Ecore_Idle_Enterer *ie;
-
- if (!func) return NULL;
- ie = calloc(1, sizeof(Ecore_Idle_Enterer));
- if (!ie) return NULL;
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
- ie->func = func;
- ie->data = (void *)data;
- idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_prepend(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
- return ie;
+ Ecore_Idle_Enterer *ie;
+
+ if (!func)
+ return NULL;
+ ie = calloc(1, sizeof(Ecore_Idle_Enterer));
+ if (!ie)
+ return NULL;
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
+ ie->func = func;
+ ie->data = (void *) data;
+ idle_enterers =
+ (Ecore_Idle_Enterer *)
+ eina_inlist_prepend(EINA_INLIST_GET(idle_enterers),
+ EINA_INLIST_GET(ie));
+ return ie;
}
/**
@@ -76,96 +85,94 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data)
* NULL otherwise.
* @ingroup Idle_Group
*/
-EAPI void *
-ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer)
+EAPI void *ecore_idle_enterer_del(Ecore_Idle_Enterer * idle_enterer)
{
- if (!ECORE_MAGIC_CHECK(idle_enterer, ECORE_MAGIC_IDLE_ENTERER))
- {
- ECORE_MAGIC_FAIL(idle_enterer, ECORE_MAGIC_IDLE_ENTERER,
- "ecore_idle_enterer_del");
- return NULL;
- }
- EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL);
- idle_enterer->delete_me = 1;
- idle_enterers_delete_me = 1;
- return idle_enterer->data;
+ if (!ECORE_MAGIC_CHECK(idle_enterer, ECORE_MAGIC_IDLE_ENTERER)) {
+ ECORE_MAGIC_FAIL(idle_enterer, ECORE_MAGIC_IDLE_ENTERER,
+ "ecore_idle_enterer_del");
+ return NULL;
+ }
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL);
+ idle_enterer->delete_me = 1;
+ idle_enterers_delete_me = 1;
+ return idle_enterer->data;
}
-void
-_ecore_idle_enterer_shutdown(void)
+void _ecore_idle_enterer_shutdown(void)
{
- Ecore_Idle_Enterer *ie;
- while ((ie = idle_enterers))
- {
- idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers));
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
- }
- idle_enterers_delete_me = 0;
- idle_enterer_current = NULL;
+ Ecore_Idle_Enterer *ie;
+ while ((ie = idle_enterers)) {
+ idle_enterers =
+ (Ecore_Idle_Enterer *)
+ eina_inlist_remove(EINA_INLIST_GET(idle_enterers),
+ EINA_INLIST_GET(idle_enterers));
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
+ free(ie);
+ }
+ idle_enterers_delete_me = 0;
+ idle_enterer_current = NULL;
}
-void
-_ecore_idle_enterer_call(void)
+void _ecore_idle_enterer_call(void)
{
- if (!idle_enterer_current)
- {
- /* regular main loop, start from head */
- idle_enterer_current = idle_enterers;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- idle_enterer_current =
- (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next;
- }
-
- while (idle_enterer_current)
- {
- Ecore_Idle_Enterer *ie = (Ecore_Idle_Enterer *)idle_enterer_current;
- if (!ie->delete_me)
- {
- ie->references++;
- if (!ie->func(ie->data))
- {
- if (!ie->delete_me) ecore_idle_enterer_del(ie);
- }
- ie->references--;
- }
- if (idle_enterer_current) /* may have changed in recursive main loops */
- idle_enterer_current =
- (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next;
- }
- if (idle_enterers_delete_me)
- {
- Ecore_Idle_Enterer *l;
- int deleted_idler_enterers_in_use = 0;
-
- for (l = idle_enterers; l;)
- {
- Ecore_Idle_Enterer *ie = l;
- l = (Ecore_Idle_Enterer *) EINA_INLIST_GET(l)->next;
- if (ie->delete_me)
- {
- if (ie->references)
- {
- deleted_idler_enterers_in_use++;
- continue;
- }
-
- idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
- }
- }
- if (!deleted_idler_enterers_in_use)
- idle_enterers_delete_me = 0;
- }
+ if (!idle_enterer_current) {
+ /* regular main loop, start from head */
+ idle_enterer_current = idle_enterers;
+ } else {
+ /* recursive main loop, continue from where we were */
+ idle_enterer_current =
+ (Ecore_Idle_Enterer *)
+ EINA_INLIST_GET(idle_enterer_current)->next;
+ }
+
+ while (idle_enterer_current) {
+ Ecore_Idle_Enterer *ie =
+ (Ecore_Idle_Enterer *) idle_enterer_current;
+ if (!ie->delete_me) {
+ ie->references++;
+ if (!ie->func(ie->data)) {
+ if (!ie->delete_me)
+ ecore_idle_enterer_del(ie);
+ }
+ ie->references--;
+ }
+ if (idle_enterer_current) /* may have changed in recursive main loops */
+ idle_enterer_current =
+ (Ecore_Idle_Enterer *)
+ EINA_INLIST_GET(idle_enterer_current)->next;
+ }
+ if (idle_enterers_delete_me) {
+ Ecore_Idle_Enterer *l;
+ int deleted_idler_enterers_in_use = 0;
+
+ for (l = idle_enterers; l;) {
+ Ecore_Idle_Enterer *ie = l;
+ l = (Ecore_Idle_Enterer *) EINA_INLIST_GET(l)->
+ next;
+ if (ie->delete_me) {
+ if (ie->references) {
+ deleted_idler_enterers_in_use++;
+ continue;
+ }
+
+ idle_enterers =
+ (Ecore_Idle_Enterer *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (idle_enterers),
+ EINA_INLIST_GET
+ (ie));
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
+ free(ie);
+ }
+ }
+ if (!deleted_idler_enterers_in_use)
+ idle_enterers_delete_me = 0;
+ }
}
-int
-_ecore_idle_enterer_exist(void)
+int _ecore_idle_enterer_exist(void)
{
- if (idle_enterers) return 1;
- return 0;
+ if (idle_enterers)
+ return 1;
+ return 0;
}
diff --git a/tests/suite/ecore/src/lib/ecore_idle_exiter.c b/tests/suite/ecore/src/lib/ecore_idle_exiter.c
index d8234e3001..0e9dbaf622 100644
--- a/tests/suite/ecore/src/lib/ecore_idle_exiter.c
+++ b/tests/suite/ecore/src/lib/ecore_idle_exiter.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -8,20 +8,19 @@
#include "ecore_private.h"
-struct _Ecore_Idle_Exiter
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Task_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
+struct _Ecore_Idle_Exiter {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Task_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me:1;
};
static Ecore_Idle_Exiter *idle_exiters = NULL;
static Ecore_Idle_Exiter *idle_exiter_current = NULL;
-static int idle_exiters_delete_me = 0;
+static int idle_exiters_delete_me = 0;
/**
* Add an idle exiter handler.
@@ -30,19 +29,24 @@ static int idle_exiters_delete_me = 0;
* @return A handle to the idle exiter callback on success. NULL otherwise.
* @ingroup Idle_Group
*/
-EAPI Ecore_Idle_Exiter *
-ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Ecore_Task_Cb func,
+ const void *data)
{
- Ecore_Idle_Exiter *ie;
-
- if (!func) return NULL;
- ie = calloc(1, sizeof(Ecore_Idle_Exiter));
- if (!ie) return NULL;
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_EXITER);
- ie->func = func;
- ie->data = (void *)data;
- idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_append(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
- return ie;
+ Ecore_Idle_Exiter *ie;
+
+ if (!func)
+ return NULL;
+ ie = calloc(1, sizeof(Ecore_Idle_Exiter));
+ if (!ie)
+ return NULL;
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_EXITER);
+ ie->func = func;
+ ie->data = (void *) data;
+ idle_exiters =
+ (Ecore_Idle_Exiter *)
+ eina_inlist_append(EINA_INLIST_GET(idle_exiters),
+ EINA_INLIST_GET(ie));
+ return ie;
}
/**
@@ -52,97 +56,94 @@ ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data)
* successful. NULL otherwise.
* @ingroup Idle_Group
*/
-EAPI void *
-ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter)
+EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter * idle_exiter)
{
- if (!ECORE_MAGIC_CHECK(idle_exiter, ECORE_MAGIC_IDLE_EXITER))
- {
- ECORE_MAGIC_FAIL(idle_exiter, ECORE_MAGIC_IDLE_EXITER,
- "ecore_idle_exiter_del");
- return NULL;
- }
- EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_exiter->delete_me, NULL);
- idle_exiter->delete_me = 1;
- idle_exiters_delete_me = 1;
- return idle_exiter->data;
+ if (!ECORE_MAGIC_CHECK(idle_exiter, ECORE_MAGIC_IDLE_EXITER)) {
+ ECORE_MAGIC_FAIL(idle_exiter, ECORE_MAGIC_IDLE_EXITER,
+ "ecore_idle_exiter_del");
+ return NULL;
+ }
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_exiter->delete_me, NULL);
+ idle_exiter->delete_me = 1;
+ idle_exiters_delete_me = 1;
+ return idle_exiter->data;
}
-void
-_ecore_idle_exiter_shutdown(void)
+void _ecore_idle_exiter_shutdown(void)
{
- Ecore_Idle_Exiter *ie;
- while ((ie = idle_exiters))
- {
- idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters));
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
- }
- idle_exiters_delete_me = 0;
- idle_exiter_current = NULL;
+ Ecore_Idle_Exiter *ie;
+ while ((ie = idle_exiters)) {
+ idle_exiters =
+ (Ecore_Idle_Exiter *)
+ eina_inlist_remove(EINA_INLIST_GET(idle_exiters),
+ EINA_INLIST_GET(idle_exiters));
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
+ free(ie);
+ }
+ idle_exiters_delete_me = 0;
+ idle_exiter_current = NULL;
}
-void
-_ecore_idle_exiter_call(void)
+void _ecore_idle_exiter_call(void)
{
- if (!idle_exiter_current)
- {
- /* regular main loop, start from head */
- idle_exiter_current = idle_exiters;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- idle_exiter_current =
- (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next;
- }
-
- while (idle_exiter_current)
- {
- Ecore_Idle_Exiter *ie = (Ecore_Idle_Exiter *)idle_exiter_current;
- if (!ie->delete_me)
- {
- ie->references++;
- if (!ie->func(ie->data))
- {
- if (!ie->delete_me) ecore_idle_exiter_del(ie);
- }
- ie->references--;
- }
- if (idle_exiter_current) /* may have changed in recursive main loops */
- idle_exiter_current =
- (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next;
- }
- if (idle_exiters_delete_me)
- {
- Ecore_Idle_Exiter *l;
- int deleted_idler_exiters_in_use = 0;
-
- for (l = idle_exiters; l;)
- {
- Ecore_Idle_Exiter *ie = l;
-
- l = (Ecore_Idle_Exiter *) EINA_INLIST_GET(l)->next;
- if (ie->delete_me)
- {
- if (ie->references)
- {
- deleted_idler_exiters_in_use++;
- continue;
- }
-
- idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
- }
- }
- if (!deleted_idler_exiters_in_use)
- idle_exiters_delete_me = 0;
- }
+ if (!idle_exiter_current) {
+ /* regular main loop, start from head */
+ idle_exiter_current = idle_exiters;
+ } else {
+ /* recursive main loop, continue from where we were */
+ idle_exiter_current =
+ (Ecore_Idle_Exiter *)
+ EINA_INLIST_GET(idle_exiter_current)->next;
+ }
+
+ while (idle_exiter_current) {
+ Ecore_Idle_Exiter *ie =
+ (Ecore_Idle_Exiter *) idle_exiter_current;
+ if (!ie->delete_me) {
+ ie->references++;
+ if (!ie->func(ie->data)) {
+ if (!ie->delete_me)
+ ecore_idle_exiter_del(ie);
+ }
+ ie->references--;
+ }
+ if (idle_exiter_current) /* may have changed in recursive main loops */
+ idle_exiter_current =
+ (Ecore_Idle_Exiter *)
+ EINA_INLIST_GET(idle_exiter_current)->next;
+ }
+ if (idle_exiters_delete_me) {
+ Ecore_Idle_Exiter *l;
+ int deleted_idler_exiters_in_use = 0;
+
+ for (l = idle_exiters; l;) {
+ Ecore_Idle_Exiter *ie = l;
+
+ l = (Ecore_Idle_Exiter *) EINA_INLIST_GET(l)->next;
+ if (ie->delete_me) {
+ if (ie->references) {
+ deleted_idler_exiters_in_use++;
+ continue;
+ }
+
+ idle_exiters =
+ (Ecore_Idle_Exiter *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (idle_exiters),
+ EINA_INLIST_GET
+ (ie));
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
+ free(ie);
+ }
+ }
+ if (!deleted_idler_exiters_in_use)
+ idle_exiters_delete_me = 0;
+ }
}
-int
-_ecore_idle_exiter_exist(void)
+int _ecore_idle_exiter_exist(void)
{
- if (idle_exiters) return 1;
- return 0;
+ if (idle_exiters)
+ return 1;
+ return 0;
}
diff --git a/tests/suite/ecore/src/lib/ecore_idler.c b/tests/suite/ecore/src/lib/ecore_idler.c
index 8f1c8206b6..d5cd74c760 100644
--- a/tests/suite/ecore/src/lib/ecore_idler.c
+++ b/tests/suite/ecore/src/lib/ecore_idler.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -8,20 +8,19 @@
#include "ecore_private.h"
-struct _Ecore_Idler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Task_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
+struct _Ecore_Idler {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Task_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me:1;
};
static Ecore_Idler *idlers = NULL;
static Ecore_Idler *idler_current = NULL;
-static int idlers_delete_me = 0;
+static int idlers_delete_me = 0;
/**
* Add an idler handler.
@@ -38,19 +37,22 @@ static int idlers_delete_me = 0;
*
* Idlers are useful for progressively prossessing data without blocking.
*/
-EAPI Ecore_Idler *
-ecore_idler_add(Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func, const void *data)
{
- Ecore_Idler *ie;
+ Ecore_Idler *ie;
- if (!func) return NULL;
- ie = calloc(1, sizeof(Ecore_Idler));
- if (!ie) return NULL;
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLER);
- ie->func = func;
- ie->data = (void *)data;
- idlers = (Ecore_Idler *) eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
- return ie;
+ if (!func)
+ return NULL;
+ ie = calloc(1, sizeof(Ecore_Idler));
+ if (!ie)
+ return NULL;
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLER);
+ ie->func = func;
+ ie->data = (void *) data;
+ idlers =
+ (Ecore_Idler *) eina_inlist_append(EINA_INLIST_GET(idlers),
+ EINA_INLIST_GET(ie));
+ return ie;
}
/**
@@ -60,95 +62,93 @@ ecore_idler_add(Ecore_Task_Cb func, const void *data)
* otherwise.
* @ingroup Idle_Group
*/
-EAPI void *
-ecore_idler_del(Ecore_Idler *idler)
+EAPI void *ecore_idler_del(Ecore_Idler * idler)
{
- if (!ECORE_MAGIC_CHECK(idler, ECORE_MAGIC_IDLER))
- {
- ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER,
- "ecore_idler_del");
- return NULL;
- }
- EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL);
- idler->delete_me = 1;
- idlers_delete_me = 1;
- return idler->data;
+ if (!ECORE_MAGIC_CHECK(idler, ECORE_MAGIC_IDLER)) {
+ ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER,
+ "ecore_idler_del");
+ return NULL;
+ }
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL);
+ idler->delete_me = 1;
+ idlers_delete_me = 1;
+ return idler->data;
}
-void
-_ecore_idler_shutdown(void)
+void _ecore_idler_shutdown(void)
{
- Ecore_Idler *ie;
- while ((ie = idlers))
- {
- idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers));
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
- }
- idlers_delete_me = 0;
- idler_current = NULL;
+ Ecore_Idler *ie;
+ while ((ie = idlers)) {
+ idlers =
+ (Ecore_Idler *)
+ eina_inlist_remove(EINA_INLIST_GET(idlers),
+ EINA_INLIST_GET(idlers));
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
+ free(ie);
+ }
+ idlers_delete_me = 0;
+ idler_current = NULL;
}
-int
-_ecore_idler_call(void)
+int _ecore_idler_call(void)
{
- if (!idler_current)
- {
- /* regular main loop, start from head */
- idler_current = idlers;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next;
- }
+ if (!idler_current) {
+ /* regular main loop, start from head */
+ idler_current = idlers;
+ } else {
+ /* recursive main loop, continue from where we were */
+ idler_current =
+ (Ecore_Idler *) EINA_INLIST_GET(idler_current)->next;
+ }
- while (idler_current)
- {
- Ecore_Idler *ie = (Ecore_Idler *)idler_current;
- if (!ie->delete_me)
- {
- ie->references++;
- if (!ie->func(ie->data))
- {
- if (!ie->delete_me) ecore_idler_del(ie);
- }
- ie->references--;
- }
- if (idler_current) /* may have changed in recursive main loops */
- idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next;
- }
- if (idlers_delete_me)
- {
- Ecore_Idler *l;
- int deleted_idlers_in_use = 0;
- for (l = idlers; l;)
- {
- Ecore_Idler *ie = l;
- l = (Ecore_Idler *) EINA_INLIST_GET(l)->next;
- if (ie->delete_me)
- {
- if (ie->references)
- {
- deleted_idlers_in_use++;
- continue;
- }
+ while (idler_current) {
+ Ecore_Idler *ie = (Ecore_Idler *) idler_current;
+ if (!ie->delete_me) {
+ ie->references++;
+ if (!ie->func(ie->data)) {
+ if (!ie->delete_me)
+ ecore_idler_del(ie);
+ }
+ ie->references--;
+ }
+ if (idler_current) /* may have changed in recursive main loops */
+ idler_current =
+ (Ecore_Idler *)
+ EINA_INLIST_GET(idler_current)->next;
+ }
+ if (idlers_delete_me) {
+ Ecore_Idler *l;
+ int deleted_idlers_in_use = 0;
+ for (l = idlers; l;) {
+ Ecore_Idler *ie = l;
+ l = (Ecore_Idler *) EINA_INLIST_GET(l)->next;
+ if (ie->delete_me) {
+ if (ie->references) {
+ deleted_idlers_in_use++;
+ continue;
+ }
- idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
- ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
- }
- }
- if (!deleted_idlers_in_use)
- idlers_delete_me = 0;
- }
- if (idlers) return 1;
- return 0;
+ idlers =
+ (Ecore_Idler *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (idlers),
+ EINA_INLIST_GET
+ (ie));
+ ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
+ free(ie);
+ }
+ }
+ if (!deleted_idlers_in_use)
+ idlers_delete_me = 0;
+ }
+ if (idlers)
+ return 1;
+ return 0;
}
-int
-_ecore_idler_exist(void)
+int _ecore_idler_exist(void)
{
- if (idlers) return 1;
- return 0;
+ if (idlers)
+ return 1;
+ return 0;
}
diff --git a/tests/suite/ecore/src/lib/ecore_job.c b/tests/suite/ecore/src/lib/ecore_job.c
index cd519f732c..e9a8de169e 100644
--- a/tests/suite/ecore/src/lib/ecore_job.c
+++ b/tests/suite/ecore/src/lib/ecore_job.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -11,28 +11,27 @@ static Eina_Bool _ecore_job_event_handler(void *data, int type, void *ev);
static void _ecore_job_event_free(void *data, void *ev);
static int ecore_event_job_type = 0;
-static Ecore_Event_Handler* _ecore_job_handler = NULL;
+static Ecore_Event_Handler *_ecore_job_handler = NULL;
-struct _Ecore_Job
-{
- ECORE_MAGIC;
- Ecore_Event *event;
- Ecore_Cb func;
- void *data;
+struct _Ecore_Job {
+ ECORE_MAGIC;
+ Ecore_Event *event;
+ Ecore_Cb func;
+ void *data;
};
-void
-_ecore_job_init(void)
+void _ecore_job_init(void)
{
- ecore_event_job_type = ecore_event_type_new();
- _ecore_job_handler = ecore_event_handler_add(ecore_event_job_type, _ecore_job_event_handler, NULL);
+ ecore_event_job_type = ecore_event_type_new();
+ _ecore_job_handler =
+ ecore_event_handler_add(ecore_event_job_type,
+ _ecore_job_event_handler, NULL);
}
-void
-_ecore_job_shutdown(void)
+void _ecore_job_shutdown(void)
{
- ecore_event_handler_del(_ecore_job_handler);
- _ecore_job_handler = NULL;
+ ecore_event_handler_del(_ecore_job_handler);
+ _ecore_job_handler = NULL;
}
/**
@@ -45,25 +44,27 @@ _ecore_job_shutdown(void)
* @ingroup Ecore_Job_Group
* @note Once the job has been executed, the job handle is invalid.
*/
-EAPI Ecore_Job *
-ecore_job_add(Ecore_Cb func, const void *data)
+EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data)
{
- Ecore_Job *job;
-
- if (!func) return NULL;
+ Ecore_Job *job;
+
+ if (!func)
+ return NULL;
- job = calloc(1, sizeof(Ecore_Job));
- if (!job) return NULL;
- ECORE_MAGIC_SET(job, ECORE_MAGIC_JOB);
- job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, NULL);
- if (!job->event)
- {
- free(job);
- return NULL;
- }
- job->func = func;
- job->data = (void *)data;
- return job;
+ job = calloc(1, sizeof(Ecore_Job));
+ if (!job)
+ return NULL;
+ ECORE_MAGIC_SET(job, ECORE_MAGIC_JOB);
+ job->event =
+ ecore_event_add(ecore_event_job_type, job,
+ _ecore_job_event_free, NULL);
+ if (!job->event) {
+ free(job);
+ return NULL;
+ }
+ job->func = func;
+ job->data = (void *) data;
+ return job;
}
/**
@@ -72,35 +73,32 @@ ecore_job_add(Ecore_Cb func, const void *data)
* @return The data pointer that was to be passed to the job.
* @ingroup Ecore_Job_Group
*/
-EAPI void *
-ecore_job_del(Ecore_Job *job)
+EAPI void *ecore_job_del(Ecore_Job * job)
{
- void *data;
-
- if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_JOB))
- {
- ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB,
- "ecore_job_del");
- return NULL;
- }
- data = job->data;
- ECORE_MAGIC_SET(job, ECORE_MAGIC_NONE);
- ecore_event_del(job->event);
- return data;
+ void *data;
+
+ if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_JOB)) {
+ ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB, "ecore_job_del");
+ return NULL;
+ }
+ data = job->data;
+ ECORE_MAGIC_SET(job, ECORE_MAGIC_NONE);
+ ecore_event_del(job->event);
+ return data;
}
static Eina_Bool
-_ecore_job_event_handler(void *data __UNUSED__, int type __UNUSED__, void *ev)
+_ecore_job_event_handler(void *data __UNUSED__, int type __UNUSED__,
+ void *ev)
{
- Ecore_Job *job;
-
- job = ev;
- job->func(job->data);
- return ECORE_CALLBACK_CANCEL;
+ Ecore_Job *job;
+
+ job = ev;
+ job->func(job->data);
+ return ECORE_CALLBACK_CANCEL;
}
-static void
-_ecore_job_event_free(void *data __UNUSED__, void *ev)
+static void _ecore_job_event_free(void *data __UNUSED__, void *ev)
{
- free(ev);
+ free(ev);
}
diff --git a/tests/suite/ecore/src/lib/ecore_main.c b/tests/suite/ecore/src/lib/ecore_main.c
index de507dae0d..6c22589114 100644
--- a/tests/suite/ecore/src/lib/ecore_main.c
+++ b/tests/suite/ecore/src/lib/ecore_main.c
@@ -1,19 +1,19 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#ifdef _WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <winsock2.h>
-# undef WIN32_LEAN_AND_MEAN
-# ifndef USER_TIMER_MINIMUM
-# define USER_TIMER_MINIMUM 0x0a
-# endif
+#define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+#undef WIN32_LEAN_AND_MEAN
+#ifndef USER_TIMER_MINIMUM
+#define USER_TIMER_MINIMUM 0x0a
+#endif
#endif
#ifdef __SUNPRO_C
-# include <ieeefp.h>
-# include <string.h>
+#include <ieeefp.h>
+#include <string.h>
#endif
#include <stdlib.h>
@@ -25,98 +25,97 @@
#ifndef _MSC_VER
#include <sys/time.h>
-# include <unistd.h>
+#include <unistd.h>
#else
-# include <float.h>
+#include <float.h>
#endif
#define FIX_HZ 1
#ifdef FIX_HZ
-# ifndef _MSC_VER
-# include <sys/param.h>
-# endif
-# ifndef HZ
-# define HZ 100
-# endif
+#ifndef _MSC_VER
+#include <sys/param.h>
+#endif
+#ifndef HZ
+#define HZ 100
+#endif
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "Ecore.h"
#include "ecore_private.h"
#ifdef HAVE_SYS_EPOLL_H
-# define HAVE_EPOLL
-# include <sys/epoll.h>
+#define HAVE_EPOLL
+#include <sys/epoll.h>
#endif
#ifdef USE_G_MAIN_LOOP
#include <glib.h>
#endif
-struct _Ecore_Fd_Handler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- int fd;
- Ecore_Fd_Handler_Flags flags;
- Ecore_Fd_Cb func;
- void *data;
- Ecore_Fd_Cb buf_func;
- void *buf_data;
- Ecore_Fd_Prep_Cb prep_func;
- void *prep_data;
- int references;
- Eina_Bool read_active : 1;
- Eina_Bool write_active : 1;
- Eina_Bool error_active : 1;
- Eina_Bool delete_me : 1;
+struct _Ecore_Fd_Handler {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ int fd;
+ Ecore_Fd_Handler_Flags flags;
+ Ecore_Fd_Cb func;
+ void *data;
+ Ecore_Fd_Cb buf_func;
+ void *buf_data;
+ Ecore_Fd_Prep_Cb prep_func;
+ void *prep_data;
+ int references;
+ Eina_Bool read_active:1;
+ Eina_Bool write_active:1;
+ Eina_Bool error_active:1;
+ Eina_Bool delete_me:1;
};
#ifdef _WIN32
-struct _Ecore_Win32_Handler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- HANDLE h;
- Ecore_Fd_Win32_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
+struct _Ecore_Win32_Handler {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ HANDLE h;
+ Ecore_Fd_Win32_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me:1;
};
#endif
-static int _ecore_main_select(double timeout);
+static int _ecore_main_select(double timeout);
static void _ecore_main_prepare_handlers(void);
static void _ecore_main_fd_handlers_cleanup(void);
#ifndef _WIN32
static void _ecore_main_fd_handlers_bads_rem(void);
#endif
static void _ecore_main_fd_handlers_call(void);
-static int _ecore_main_fd_handlers_buf_call(void);
+static int _ecore_main_fd_handlers_buf_call(void);
#ifndef USE_G_MAIN_LOOP
static void _ecore_main_loop_iterate_internal(int once_only);
#endif
#ifdef _WIN32
-static int _ecore_main_win32_select(int nfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout);
+static int _ecore_main_win32_select(int nfds, fd_set * readfds,
+ fd_set * writefds, fd_set * exceptfds,
+ struct timeval *timeout);
static void _ecore_main_win32_handlers_cleanup(void);
#endif
-static int in_main_loop = 0;
-static int do_quit = 0;
+static int in_main_loop = 0;
+static int do_quit = 0;
static Ecore_Fd_Handler *fd_handlers = NULL;
static Ecore_Fd_Handler *fd_handler_current = NULL;
-static int fd_handlers_delete_me = 0;
+static int fd_handlers_delete_me = 0;
#ifdef _WIN32
static Ecore_Win32_Handler *win32_handlers = NULL;
static Ecore_Win32_Handler *win32_handler_current = NULL;
-static int win32_handlers_delete_me = 0;
+static int win32_handlers_delete_me = 0;
#endif
#ifdef _WIN32
@@ -125,8 +124,8 @@ static Ecore_Select_Function main_loop_select = _ecore_main_win32_select;
static Ecore_Select_Function main_loop_select = select;
#endif
-static double t1 = 0.0;
-static double t2 = 0.0;
+static double t1 = 0.0;
+static double t2 = 0.0;
#ifdef HAVE_EPOLL
static int epoll_fd = -1;
@@ -136,127 +135,133 @@ static int epoll_fd = -1;
static GSource *ecore_epoll_source;
static GPollFD ecore_epoll_fd;
static guint ecore_epoll_id;
-static GMainLoop* ecore_main_loop;
+static GMainLoop *ecore_main_loop;
static gboolean ecore_idling;
static gboolean ecore_fds_ready;
#endif
#ifdef HAVE_EPOLL
-static inline int _ecore_poll_events_from_fdh(Ecore_Fd_Handler *fdh)
+static inline int _ecore_poll_events_from_fdh(Ecore_Fd_Handler * fdh)
{
- int events = 0;
- if (fdh->flags & ECORE_FD_READ) events |= EPOLLIN;
- if (fdh->flags & ECORE_FD_WRITE) events |= EPOLLOUT;
- if (fdh->flags & ECORE_FD_ERROR) events |= EPOLLERR;
- return events;
+ int events = 0;
+ if (fdh->flags & ECORE_FD_READ)
+ events |= EPOLLIN;
+ if (fdh->flags & ECORE_FD_WRITE)
+ events |= EPOLLOUT;
+ if (fdh->flags & ECORE_FD_ERROR)
+ events |= EPOLLERR;
+ return events;
}
#else
-static inline int _ecore_poll_events_from_fdh(Ecore_Fd_Handler *fdh __UNUSED__)
+static inline int _ecore_poll_events_from_fdh(Ecore_Fd_Handler *
+ fdh __UNUSED__)
{
- return 0;
+ return 0;
}
#endif
#ifdef HAVE_EPOLL
-static inline int _ecore_main_fdh_epoll_add(Ecore_Fd_Handler *fdh)
+static inline int _ecore_main_fdh_epoll_add(Ecore_Fd_Handler * fdh)
{
- int r = 0;
- struct epoll_event ev;
-
- memset(&ev, 0, sizeof (ev));
- ev.events = _ecore_poll_events_from_fdh(fdh);
- ev.data.ptr = fdh;
- INF("adding poll on %d %08x", fdh->fd, ev.events);
- r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fdh->fd, &ev);
- return r;
+ int r = 0;
+ struct epoll_event ev;
+
+ memset(&ev, 0, sizeof(ev));
+ ev.events = _ecore_poll_events_from_fdh(fdh);
+ ev.data.ptr = fdh;
+ INF("adding poll on %d %08x", fdh->fd, ev.events);
+ r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fdh->fd, &ev);
+ return r;
}
#else
-static inline int _ecore_main_fdh_epoll_add(Ecore_Fd_Handler *fdh __UNUSED__)
+static inline int _ecore_main_fdh_epoll_add(Ecore_Fd_Handler *
+ fdh __UNUSED__)
{
- return 0;
+ return 0;
}
#endif
#ifdef HAVE_EPOLL
-static inline void _ecore_main_fdh_epoll_del(Ecore_Fd_Handler *fdh)
+static inline void _ecore_main_fdh_epoll_del(Ecore_Fd_Handler * fdh)
{
- struct epoll_event ev;
-
- memset(&ev, 0, sizeof (ev));
- INF("removing poll on %d", fdh->fd);
- /* could get an EBADF if somebody closed the FD before removing it */
- if ((epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fdh->fd, &ev) < 0) &&
- (errno != EBADF))
- {
- ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd, errno);
- }
+ struct epoll_event ev;
+
+ memset(&ev, 0, sizeof(ev));
+ INF("removing poll on %d", fdh->fd);
+ /* could get an EBADF if somebody closed the FD before removing it */
+ if ((epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fdh->fd, &ev) < 0) &&
+ (errno != EBADF)) {
+ ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd,
+ errno);
+ }
}
#else
-static inline void _ecore_main_fdh_epoll_del(Ecore_Fd_Handler *fdh __UNUSED__)
+static inline void _ecore_main_fdh_epoll_del(Ecore_Fd_Handler *
+ fdh __UNUSED__)
{
}
#endif
#ifdef HAVE_EPOLL
-static inline int _ecore_main_fdh_epoll_modify(Ecore_Fd_Handler *fdh)
+static inline int _ecore_main_fdh_epoll_modify(Ecore_Fd_Handler * fdh)
{
- int r = 0;
- struct epoll_event ev;
-
- memset(&ev, 0, sizeof (ev));
- ev.events = _ecore_poll_events_from_fdh(fdh);
- ev.data.ptr = fdh;
- INF("modifing epoll on %d to %08x", fdh->fd, ev.events);
- r = epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fdh->fd, &ev);
- return r;
+ int r = 0;
+ struct epoll_event ev;
+
+ memset(&ev, 0, sizeof(ev));
+ ev.events = _ecore_poll_events_from_fdh(fdh);
+ ev.data.ptr = fdh;
+ INF("modifing epoll on %d to %08x", fdh->fd, ev.events);
+ r = epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fdh->fd, &ev);
+ return r;
}
#else
-static inline int _ecore_main_fdh_epoll_modify(Ecore_Fd_Handler *fdh __UNUSED__)
+static inline int _ecore_main_fdh_epoll_modify(Ecore_Fd_Handler *
+ fdh __UNUSED__)
{
- return 0;
+ return 0;
}
#endif
#ifdef HAVE_EPOLL
static inline int _ecore_main_fdh_epoll_mark_active(void)
{
- struct epoll_event ev[32];
- int i, ret;
-
- memset(&ev, 0, sizeof (ev));
- ret = epoll_wait(epoll_fd, ev, sizeof(ev) / sizeof(struct epoll_event), 0);
- if (ret < 0)
- {
- if (errno == EINTR) return -1;
- ERR("epoll_wait failed %d", errno);
- return -1;
- }
-
- for (i = 0; i < ret; i++)
- {
- Ecore_Fd_Handler *fdh;
-
- fdh = ev[i].data.ptr;
- if (!ECORE_MAGIC_CHECK(fdh, ECORE_MAGIC_FD_HANDLER))
- {
- ECORE_MAGIC_FAIL(fdh, ECORE_MAGIC_FD_HANDLER,
- "_ecore_main_fdh_epoll_mark_active");
- continue;
- }
- if (fdh->delete_me)
- {
- ERR("deleted fd in epoll");
- continue;
- }
- if (ev->events & EPOLLIN)
- fdh->read_active = 1;
- if (ev->events & EPOLLOUT)
- fdh->write_active = 1;
- if (ev->events & EPOLLERR)
- fdh->error_active = 1;
- }
-
- return ret;
+ struct epoll_event ev[32];
+ int i, ret;
+
+ memset(&ev, 0, sizeof(ev));
+ ret =
+ epoll_wait(epoll_fd, ev,
+ sizeof(ev) / sizeof(struct epoll_event), 0);
+ if (ret < 0) {
+ if (errno == EINTR)
+ return -1;
+ ERR("epoll_wait failed %d", errno);
+ return -1;
+ }
+
+ for (i = 0; i < ret; i++) {
+ Ecore_Fd_Handler *fdh;
+
+ fdh = ev[i].data.ptr;
+ if (!ECORE_MAGIC_CHECK(fdh, ECORE_MAGIC_FD_HANDLER)) {
+ ECORE_MAGIC_FAIL(fdh, ECORE_MAGIC_FD_HANDLER,
+ "_ecore_main_fdh_epoll_mark_active");
+ continue;
+ }
+ if (fdh->delete_me) {
+ ERR("deleted fd in epoll");
+ continue;
+ }
+ if (ev->events & EPOLLIN)
+ fdh->read_active = 1;
+ if (ev->events & EPOLLOUT)
+ fdh->write_active = 1;
+ if (ev->events & EPOLLERR)
+ fdh->error_active = 1;
+ }
+
+ return ret;
}
#endif
@@ -264,194 +269,178 @@ static inline int _ecore_main_fdh_epoll_mark_active(void)
/* like we are about to enter main_loop_select in _ecore_main_select */
static gboolean
-_ecore_main_gsource_prepare(GSource *source, gint *next_time)
+_ecore_main_gsource_prepare(GSource * source, gint * next_time)
{
- double t = _ecore_timer_next_get();
- gboolean running;
-
- INF("enter, next timeout in %.1f", t);
- in_main_loop++;
-
- if (!ecore_idling)
- {
- while (_ecore_timer_call(_ecore_time_loop_time));
- _ecore_timer_cleanup();
-
- /* when idling, busy loop checking the fds only */
- if (!ecore_idling) _ecore_idle_enterer_call();
- }
-
- /* don't check fds if somebody quit */
- running = g_main_loop_is_running(ecore_main_loop);
- if (running)
- {
- /* only set idling state in dispatch */
- if (ecore_idling && !_ecore_idler_exist())
- {
- if (_ecore_timers_exists())
- {
- double t = _ecore_timer_next_get();
- *next_time = (t / 1000.0);
- }
- else
- *next_time = -1;
- }
- else
- *next_time = 0;
-
- _ecore_main_prepare_handlers();
- }
-
- in_main_loop--;
- INF("leave, timeout = %d", *next_time);
-
- /* ready if we're not running (about to quit) */
- return !running;
+ double t = _ecore_timer_next_get();
+ gboolean running;
+
+ INF("enter, next timeout in %.1f", t);
+ in_main_loop++;
+
+ if (!ecore_idling) {
+ while (_ecore_timer_call(_ecore_time_loop_time));
+ _ecore_timer_cleanup();
+
+ /* when idling, busy loop checking the fds only */
+ if (!ecore_idling)
+ _ecore_idle_enterer_call();
+ }
+
+ /* don't check fds if somebody quit */
+ running = g_main_loop_is_running(ecore_main_loop);
+ if (running) {
+ /* only set idling state in dispatch */
+ if (ecore_idling && !_ecore_idler_exist()) {
+ if (_ecore_timers_exists()) {
+ double t = _ecore_timer_next_get();
+ *next_time = (t / 1000.0);
+ } else
+ *next_time = -1;
+ } else
+ *next_time = 0;
+
+ _ecore_main_prepare_handlers();
+ }
+
+ in_main_loop--;
+ INF("leave, timeout = %d", *next_time);
+
+ /* ready if we're not running (about to quit) */
+ return !running;
}
-static gboolean
-_ecore_main_gsource_check(GSource *source)
+static gboolean _ecore_main_gsource_check(GSource * source)
{
- INF("enter");
- in_main_loop++;
+ INF("enter");
+ in_main_loop++;
- ecore_fds_ready = (_ecore_main_fdh_epoll_mark_active() > 0);
- _ecore_main_fd_handlers_cleanup();
+ ecore_fds_ready = (_ecore_main_fdh_epoll_mark_active() > 0);
+ _ecore_main_fd_handlers_cleanup();
- _ecore_time_loop_time = ecore_time_get();
- _ecore_timer_enable_new();
+ _ecore_time_loop_time = ecore_time_get();
+ _ecore_timer_enable_new();
- in_main_loop--;
- INF("leave");
+ in_main_loop--;
+ INF("leave");
- return TRUE; /* always dispatch */
+ return TRUE; /* always dispatch */
}
/* like we just came out of main_loop_select in _ecore_main_select */
static gboolean
-_ecore_main_gsource_dispatch(GSource *source, GSourceFunc callback, gpointer user_data)
+_ecore_main_gsource_dispatch(GSource * source, GSourceFunc callback,
+ gpointer user_data)
{
- gboolean events_ready, timers_ready, idlers_ready, signals_ready;
- double next_time = _ecore_timer_next_get();
-
- events_ready = _ecore_event_exist();
- timers_ready = _ecore_timers_exists() && (0.0 <= next_time);
- idlers_ready = _ecore_idler_exist();
- signals_ready = (_ecore_signal_count_get() > 0);
-
- in_main_loop++;
- INF("enter idling=%d fds=%d events=%d signals=%d timers=%d (next=%.2f) idlers=%d",
- ecore_idling, ecore_fds_ready, events_ready, signals_ready,
- _ecore_timers_exists(), next_time, idlers_ready);
-
- if (ecore_idling && events_ready)
- {
- INF("calling idle exiters");
- _ecore_idle_exiter_call();
- ecore_idling = 0;
- }
- else if (!ecore_idling && !events_ready)
- {
- INF("start idling");
- ecore_idling = 1;
- }
-
- if (ecore_idling)
- {
- INF("calling idler");
- _ecore_idler_call();
-
- events_ready = _ecore_event_exist();
- timers_ready = _ecore_timers_exists() && (0.0 <= next_time);
- idlers_ready = _ecore_idler_exist();
-
- if ((ecore_fds_ready || events_ready || timers_ready || idlers_ready || signals_ready))
- {
- INF("calling idle exiters");
- _ecore_idle_exiter_call();
- ecore_idling = 0;
- }
- }
-
- /* process events */
- if (!ecore_idling)
- {
- INF("work");
- _ecore_main_fd_handlers_call();
- _ecore_main_fd_handlers_buf_call();
- while (_ecore_signal_count_get()) _ecore_signal_call();
- _ecore_event_call();
- _ecore_main_fd_handlers_cleanup();
- }
-
- in_main_loop--;
-
- INF("leave");
-
- return TRUE; /* what should be returned here? */
+ gboolean events_ready, timers_ready, idlers_ready, signals_ready;
+ double next_time = _ecore_timer_next_get();
+
+ events_ready = _ecore_event_exist();
+ timers_ready = _ecore_timers_exists() && (0.0 <= next_time);
+ idlers_ready = _ecore_idler_exist();
+ signals_ready = (_ecore_signal_count_get() > 0);
+
+ in_main_loop++;
+ INF("enter idling=%d fds=%d events=%d signals=%d timers=%d (next=%.2f) idlers=%d", ecore_idling, ecore_fds_ready, events_ready, signals_ready, _ecore_timers_exists(), next_time, idlers_ready);
+
+ if (ecore_idling && events_ready) {
+ INF("calling idle exiters");
+ _ecore_idle_exiter_call();
+ ecore_idling = 0;
+ } else if (!ecore_idling && !events_ready) {
+ INF("start idling");
+ ecore_idling = 1;
+ }
+
+ if (ecore_idling) {
+ INF("calling idler");
+ _ecore_idler_call();
+
+ events_ready = _ecore_event_exist();
+ timers_ready = _ecore_timers_exists()
+ && (0.0 <= next_time);
+ idlers_ready = _ecore_idler_exist();
+
+ if ((ecore_fds_ready || events_ready || timers_ready
+ || idlers_ready || signals_ready)) {
+ INF("calling idle exiters");
+ _ecore_idle_exiter_call();
+ ecore_idling = 0;
+ }
+ }
+
+ /* process events */
+ if (!ecore_idling) {
+ INF("work");
+ _ecore_main_fd_handlers_call();
+ _ecore_main_fd_handlers_buf_call();
+ while (_ecore_signal_count_get())
+ _ecore_signal_call();
+ _ecore_event_call();
+ _ecore_main_fd_handlers_cleanup();
+ }
+
+ in_main_loop--;
+
+ INF("leave");
+
+ return TRUE; /* what should be returned here? */
}
-static void
-_ecore_main_gsource_finalize(GSource *source)
+static void _ecore_main_gsource_finalize(GSource * source)
{
- INF("finalize");
+ INF("finalize");
}
-static GSourceFuncs ecore_gsource_funcs =
-{
- .prepare = _ecore_main_gsource_prepare,
- .check = _ecore_main_gsource_check,
- .dispatch = _ecore_main_gsource_dispatch,
- .finalize = _ecore_main_gsource_finalize,
+static GSourceFuncs ecore_gsource_funcs = {
+ .prepare = _ecore_main_gsource_prepare,
+ .check = _ecore_main_gsource_check,
+ .dispatch = _ecore_main_gsource_dispatch,
+ .finalize = _ecore_main_gsource_finalize,
};
#endif
-void
-_ecore_main_loop_init(void)
+void _ecore_main_loop_init(void)
{
- INF("enter");
+ INF("enter");
#ifdef HAVE_EPOLL
- epoll_fd = epoll_create(1);
- if (epoll_fd < 0)
- CRIT("Failed to create epoll fd!");
+ epoll_fd = epoll_create(1);
+ if (epoll_fd < 0)
+ CRIT("Failed to create epoll fd!");
#endif
#ifdef USE_G_MAIN_LOOP
- ecore_epoll_source = g_source_new(&ecore_gsource_funcs, sizeof (GSource));
- if (!ecore_epoll_source)
- CRIT("Failed to create glib source for epoll!");
- else
- {
- ecore_epoll_fd.fd = epoll_fd;
- ecore_epoll_fd.events = G_IO_IN;
- ecore_epoll_fd.revents = 0;
- g_source_add_poll(ecore_epoll_source, &ecore_epoll_fd);
- ecore_epoll_id = g_source_attach(ecore_epoll_source, NULL);
- if (ecore_epoll_id <= 0)
- CRIT("Failed to attach glib source to default context");
- }
+ ecore_epoll_source =
+ g_source_new(&ecore_gsource_funcs, sizeof(GSource));
+ if (!ecore_epoll_source)
+ CRIT("Failed to create glib source for epoll!");
+ else {
+ ecore_epoll_fd.fd = epoll_fd;
+ ecore_epoll_fd.events = G_IO_IN;
+ ecore_epoll_fd.revents = 0;
+ g_source_add_poll(ecore_epoll_source, &ecore_epoll_fd);
+ ecore_epoll_id = g_source_attach(ecore_epoll_source, NULL);
+ if (ecore_epoll_id <= 0)
+ CRIT("Failed to attach glib source to default context");
+ }
#endif
- INF("leave");
+ INF("leave");
}
-void
-_ecore_main_loop_shutdown(void)
+void _ecore_main_loop_shutdown(void)
{
#ifdef USE_G_MAIN_LOOP
- if (ecore_epoll_source)
- {
- g_source_destroy(ecore_epoll_source);
- ecore_epoll_source = NULL;
- }
+ if (ecore_epoll_source) {
+ g_source_destroy(ecore_epoll_source);
+ ecore_epoll_source = NULL;
+ }
#endif
#ifdef HAVE_EPOLL
- if (epoll_fd >= 0)
- {
- close(epoll_fd);
- epoll_fd = -1;
- }
+ if (epoll_fd >= 0) {
+ close(epoll_fd);
+ epoll_fd = -1;
+ }
#endif
}
@@ -481,13 +470,12 @@ _ecore_main_loop_shutdown(void)
* queue.
* @ingroup Ecore_Main_Loop_Group
*/
-EAPI void
-ecore_main_loop_iterate(void)
+EAPI void ecore_main_loop_iterate(void)
{
#ifndef USE_G_MAIN_LOOP
- _ecore_main_loop_iterate_internal(1);
+ _ecore_main_loop_iterate_internal(1);
#else
- g_main_context_iteration(NULL, 1);
+ g_main_context_iteration(NULL, 1);
#endif
}
@@ -498,17 +486,17 @@ ecore_main_loop_iterate(void)
*
* @ingroup Ecore_Main_Loop_Group
*/
-EAPI void
-ecore_main_loop_begin(void)
+EAPI void ecore_main_loop_begin(void)
{
#ifndef USE_G_MAIN_LOOP
- in_main_loop++;
- while (do_quit == 0) _ecore_main_loop_iterate_internal(0);
- do_quit = 0;
- in_main_loop--;
+ in_main_loop++;
+ while (do_quit == 0)
+ _ecore_main_loop_iterate_internal(0);
+ do_quit = 0;
+ in_main_loop--;
#else
- ecore_main_loop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(ecore_main_loop);
+ ecore_main_loop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(ecore_main_loop);
#endif
}
@@ -517,15 +505,14 @@ ecore_main_loop_begin(void)
* been processed.
* @ingroup Ecore_Main_Loop_Group
*/
-EAPI void
-ecore_main_loop_quit(void)
+EAPI void ecore_main_loop_quit(void)
{
#ifndef USE_G_MAIN_LOOP
- do_quit = 1;
+ do_quit = 1;
#else
- INF("enter");
- g_main_loop_quit(ecore_main_loop);
- INF("leave");
+ INF("enter");
+ g_main_loop_quit(ecore_main_loop);
+ INF("leave");
#endif
}
@@ -542,10 +529,9 @@ ecore_main_loop_quit(void)
*
* @ingroup Ecore_Main_Loop_Group
*/
-EAPI void
-ecore_main_loop_select_func_set(Ecore_Select_Function func)
+EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function func)
{
- main_loop_select = func;
+ main_loop_select = func;
}
/**
@@ -554,10 +540,9 @@ ecore_main_loop_select_func_set(Ecore_Select_Function func)
*
* @ingroup Ecore_Main_Loop_Group
*/
-EAPI void *
-ecore_main_loop_select_func_get(void)
+EAPI void *ecore_main_loop_select_func_get(void)
{
- return main_loop_select;
+ return main_loop_select;
}
/**
@@ -598,65 +583,75 @@ ecore_main_loop_select_func_get(void)
* @return A fd handler handle if successful. @c NULL otherwise.
* @ingroup Ecore_FD_Handler_Group
*/
-EAPI Ecore_Fd_Handler *
-ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func, const void *data,
- Ecore_Fd_Cb buf_func, const void *buf_data)
+EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd,
+ Ecore_Fd_Handler_Flags
+ flags, Ecore_Fd_Cb func,
+ const void *data,
+ Ecore_Fd_Cb buf_func,
+ const void *buf_data)
{
- Ecore_Fd_Handler *fdh;
-
- if ((fd < 0) || (flags == 0) || (!func)) return NULL;
-
- fdh = calloc(1, sizeof(Ecore_Fd_Handler));
- if (!fdh) return NULL;
- ECORE_MAGIC_SET(fdh, ECORE_MAGIC_FD_HANDLER);
- fdh->fd = fd;
- fdh->flags = flags;
- if (0 > _ecore_main_fdh_epoll_add(fdh))
- {
- ERR("Failed to add epoll fd %d (errno = %d)!", fd, errno);
- free(fdh);
- return NULL;
- }
- fdh->read_active = 0;
- fdh->write_active = 0;
- fdh->error_active = 0;
- fdh->delete_me = 0;
- fdh->func = func;
- fdh->data = (void *)data;
- fdh->buf_func = buf_func;
- fdh->buf_data = (void *)buf_data;
- fd_handlers = (Ecore_Fd_Handler *)
- eina_inlist_append(EINA_INLIST_GET(fd_handlers),
- EINA_INLIST_GET(fdh));
- return fdh;
+ Ecore_Fd_Handler *fdh;
+
+ if ((fd < 0) || (flags == 0) || (!func))
+ return NULL;
+
+ fdh = calloc(1, sizeof(Ecore_Fd_Handler));
+ if (!fdh)
+ return NULL;
+ ECORE_MAGIC_SET(fdh, ECORE_MAGIC_FD_HANDLER);
+ fdh->fd = fd;
+ fdh->flags = flags;
+ if (0 > _ecore_main_fdh_epoll_add(fdh)) {
+ ERR("Failed to add epoll fd %d (errno = %d)!", fd, errno);
+ free(fdh);
+ return NULL;
+ }
+ fdh->read_active = 0;
+ fdh->write_active = 0;
+ fdh->error_active = 0;
+ fdh->delete_me = 0;
+ fdh->func = func;
+ fdh->data = (void *) data;
+ fdh->buf_func = buf_func;
+ fdh->buf_data = (void *) buf_data;
+ fd_handlers = (Ecore_Fd_Handler *)
+ eina_inlist_append(EINA_INLIST_GET(fd_handlers),
+ EINA_INLIST_GET(fdh));
+ return fdh;
}
#ifdef _WIN32
-EAPI Ecore_Win32_Handler *
-ecore_main_win32_handler_add(void *h, Ecore_Fd_Win32_Cb func, const void *data)
+EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h,
+ Ecore_Fd_Win32_Cb
+ func,
+ const void *data)
{
- Ecore_Win32_Handler *wh;
-
- if (!h || !func) return NULL;
-
- wh = calloc(1, sizeof(Ecore_Win32_Handler));
- if (!wh) return NULL;
- ECORE_MAGIC_SET(wh, ECORE_MAGIC_WIN32_HANDLER);
- wh->h = (HANDLE)h;
- wh->delete_me = 0;
- wh->func = func;
- wh->data = (void *)data;
- win32_handlers = (Ecore_Win32_Handler *)
- eina_inlist_append(EINA_INLIST_GET(win32_handlers),
- EINA_INLIST_GET(wh));
- return wh;
+ Ecore_Win32_Handler *wh;
+
+ if (!h || !func)
+ return NULL;
+
+ wh = calloc(1, sizeof(Ecore_Win32_Handler));
+ if (!wh)
+ return NULL;
+ ECORE_MAGIC_SET(wh, ECORE_MAGIC_WIN32_HANDLER);
+ wh->h = (HANDLE) h;
+ wh->delete_me = 0;
+ wh->func = func;
+ wh->data = (void *) data;
+ win32_handlers = (Ecore_Win32_Handler *)
+ eina_inlist_append(EINA_INLIST_GET(win32_handlers),
+ EINA_INLIST_GET(wh));
+ return wh;
}
#else
-EAPI Ecore_Win32_Handler *
-ecore_main_win32_handler_add(void *h __UNUSED__, Ecore_Fd_Win32_Cb func __UNUSED__,
- const void *data __UNUSED__)
+EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h __UNUSED__,
+ Ecore_Fd_Win32_Cb
+ func __UNUSED__,
+ const void *data
+ __UNUSED__)
{
- return NULL;
+ return NULL;
}
#endif
@@ -672,54 +667,52 @@ ecore_main_win32_handler_add(void *h __UNUSED__, Ecore_Fd_Win32_Cb func __UNUSED
* crashes and instability. Remember to delete your fd handlers before the
* fd's they listen to are closed.
*/
-EAPI void *
-ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
+EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler * fd_handler)
{
- if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
- {
- ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
- "ecore_main_fd_handler_del");
- return NULL;
- }
- fd_handler->delete_me = 1;
- fd_handlers_delete_me = 1;
- _ecore_main_fdh_epoll_del(fd_handler);
- return fd_handler->data;
+ if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) {
+ ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
+ "ecore_main_fd_handler_del");
+ return NULL;
+ }
+ fd_handler->delete_me = 1;
+ fd_handlers_delete_me = 1;
+ _ecore_main_fdh_epoll_del(fd_handler);
+ return fd_handler->data;
}
#ifdef _WIN32
-EAPI void *
-ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler)
+EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *
+ win32_handler)
{
- if (!ECORE_MAGIC_CHECK(win32_handler, ECORE_MAGIC_WIN32_HANDLER))
- {
- ECORE_MAGIC_FAIL(win32_handler, ECORE_MAGIC_WIN32_HANDLER,
- "ecore_main_win32_handler_del");
- return NULL;
- }
- win32_handler->delete_me = 1;
- win32_handlers_delete_me = 1;
- return win32_handler->data;
+ if (!ECORE_MAGIC_CHECK(win32_handler, ECORE_MAGIC_WIN32_HANDLER)) {
+ ECORE_MAGIC_FAIL(win32_handler, ECORE_MAGIC_WIN32_HANDLER,
+ "ecore_main_win32_handler_del");
+ return NULL;
+ }
+ win32_handler->delete_me = 1;
+ win32_handlers_delete_me = 1;
+ return win32_handler->data;
}
#else
-EAPI void *
-ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler __UNUSED__)
+EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *
+ win32_handler __UNUSED__)
{
- return NULL;
+ return NULL;
}
#endif
EAPI void
-ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data)
+ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler * fd_handler,
+ Ecore_Fd_Prep_Cb func,
+ const void *data)
{
- if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
- {
- ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
- "ecore_main_fd_handler_prepare_callback_set");
- return;
- }
- fd_handler->prep_func = func;
- fd_handler->prep_data = (void *) data;
+ if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) {
+ ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
+ "ecore_main_fd_handler_prepare_callback_set");
+ return;
+ }
+ fd_handler->prep_func = func;
+ fd_handler->prep_data = (void *) data;
}
/**
@@ -728,16 +721,14 @@ ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_F
* @return The file descriptor the handler is watching.
* @ingroup Ecore_FD_Handler_Group
*/
-EAPI int
-ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler)
+EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler * fd_handler)
{
- if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
- {
- ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
- "ecore_main_fd_handler_fd_get");
- return -1;
- }
- return fd_handler->fd;
+ if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) {
+ ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
+ "ecore_main_fd_handler_fd_get");
+ return -1;
+ }
+ return fd_handler->fd;
}
/**
@@ -750,20 +741,23 @@ ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler)
* @ingroup Ecore_FD_Handler_Group
*/
EAPI Eina_Bool
-ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
+ecore_main_fd_handler_active_get(Ecore_Fd_Handler * fd_handler,
+ Ecore_Fd_Handler_Flags flags)
{
- int ret = EINA_FALSE;
-
- if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
- {
- ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
- "ecore_main_fd_handler_active_get");
- return EINA_FALSE;
- }
- if ((flags & ECORE_FD_READ) && (fd_handler->read_active)) ret = EINA_TRUE;
- if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active)) ret = EINA_TRUE;
- if ((flags & ECORE_FD_ERROR) && (fd_handler->error_active)) ret = EINA_TRUE;
- return ret;
+ int ret = EINA_FALSE;
+
+ if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) {
+ ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
+ "ecore_main_fd_handler_active_get");
+ return EINA_FALSE;
+ }
+ if ((flags & ECORE_FD_READ) && (fd_handler->read_active))
+ ret = EINA_TRUE;
+ if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active))
+ ret = EINA_TRUE;
+ if ((flags & ECORE_FD_ERROR) && (fd_handler->error_active))
+ ret = EINA_TRUE;
+ return ret;
}
/**
@@ -773,681 +767,649 @@ ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_
* @ingroup Ecore_FD_Handler_Group
*/
EAPI void
-ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
+ecore_main_fd_handler_active_set(Ecore_Fd_Handler * fd_handler,
+ Ecore_Fd_Handler_Flags flags)
{
- if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
- {
- ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
- "ecore_main_fd_handler_active_set");
- return;
- }
- fd_handler->flags = flags;
- if (0 > _ecore_main_fdh_epoll_modify(fd_handler))
- {
- ERR("Failed to mod epoll fd %d!", fd_handler->fd);
- }
+ if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) {
+ ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
+ "ecore_main_fd_handler_active_set");
+ return;
+ }
+ fd_handler->flags = flags;
+ if (0 > _ecore_main_fdh_epoll_modify(fd_handler)) {
+ ERR("Failed to mod epoll fd %d!", fd_handler->fd);
+ }
}
-void
-_ecore_main_shutdown(void)
+void _ecore_main_shutdown(void)
{
- if (in_main_loop)
- {
- ERR("\n"
- "*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n"
- "*** Program may crash or behave strangely now.");
- return;
- }
- while (fd_handlers)
- {
- Ecore_Fd_Handler *fdh;
-
- fdh = fd_handlers;
- fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers),
- EINA_INLIST_GET(fdh));
- ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
- free(fdh);
- }
- fd_handlers_delete_me = 0;
- fd_handler_current = NULL;
+ if (in_main_loop) {
+ ERR("\n"
+ "*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n"
+ "*** Program may crash or behave strangely now.");
+ return;
+ }
+ while (fd_handlers) {
+ Ecore_Fd_Handler *fdh;
+
+ fdh = fd_handlers;
+ fd_handlers =
+ (Ecore_Fd_Handler *)
+ eina_inlist_remove(EINA_INLIST_GET(fd_handlers),
+ EINA_INLIST_GET(fdh));
+ ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
+ free(fdh);
+ }
+ fd_handlers_delete_me = 0;
+ fd_handler_current = NULL;
#ifdef _WIN32
- while (win32_handlers)
- {
- Ecore_Win32_Handler *wh;
-
- wh = win32_handlers;
- win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
- EINA_INLIST_GET(wh));
- ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
- free(wh);
- }
- win32_handlers_delete_me = 0;
- win32_handler_current = NULL;
+ while (win32_handlers) {
+ Ecore_Win32_Handler *wh;
+
+ wh = win32_handlers;
+ win32_handlers =
+ (Ecore_Win32_Handler *)
+ eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
+ EINA_INLIST_GET(wh));
+ ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
+ free(wh);
+ }
+ win32_handlers_delete_me = 0;
+ win32_handler_current = NULL;
#endif
}
-static void
-_ecore_main_prepare_handlers(void)
+static void _ecore_main_prepare_handlers(void)
{
- Ecore_Fd_Handler *fdh;
-
- /* call the prepare callback for all handlers */
- EINA_INLIST_FOREACH(fd_handlers, fdh)
- {
- if (!fdh->delete_me && fdh->prep_func)
- {
- fdh->references++;
- fdh->prep_func (fdh->prep_data, fdh);
- fdh->references--;
- }
- }
+ Ecore_Fd_Handler *fdh;
+
+ /* call the prepare callback for all handlers */
+ EINA_INLIST_FOREACH(fd_handlers, fdh) {
+ if (!fdh->delete_me && fdh->prep_func) {
+ fdh->references++;
+ fdh->prep_func(fdh->prep_data, fdh);
+ fdh->references--;
+ }
+ }
}
-static int
-_ecore_main_select(double timeout)
+static int _ecore_main_select(double timeout)
{
- struct timeval tv, *t;
- fd_set rfds, wfds, exfds;
- int max_fd;
- int ret;
-
- t = NULL;
- if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity. */
- {
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- t = &tv;
- }
- else if (timeout > 0.0)
- {
- int sec, usec;
+ struct timeval tv, *t;
+ fd_set rfds, wfds, exfds;
+ int max_fd;
+ int ret;
+
+ t = NULL;
+ if ((!finite(timeout)) || (timeout == 0.0)) { /* finite() tests for NaN, too big, too small, and infinity. */
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ t = &tv;
+ } else if (timeout > 0.0) {
+ int sec, usec;
#ifdef FIX_HZ
- timeout += (0.5 / HZ);
- sec = (int)timeout;
- usec = (int)((timeout - (double)sec) * 1000000);
+ timeout += (0.5 / HZ);
+ sec = (int) timeout;
+ usec = (int) ((timeout - (double) sec) * 1000000);
#else
- sec = (int)timeout;
- usec = (int)((timeout - (double)sec) * 1000000);
+ sec = (int) timeout;
+ usec = (int) ((timeout - (double) sec) * 1000000);
#endif
- tv.tv_sec = sec;
- tv.tv_usec = usec;
- t = &tv;
- }
- max_fd = 0;
- FD_ZERO(&rfds);
- FD_ZERO(&wfds);
- FD_ZERO(&exfds);
-
- /* call the prepare callback for all handlers */
- _ecore_main_prepare_handlers();
+ tv.tv_sec = sec;
+ tv.tv_usec = usec;
+ t = &tv;
+ }
+ max_fd = 0;
+ FD_ZERO(&rfds);
+ FD_ZERO(&wfds);
+ FD_ZERO(&exfds);
+
+ /* call the prepare callback for all handlers */
+ _ecore_main_prepare_handlers();
#ifndef HAVE_EPOLL
- Ecore_Fd_Handler *fdh;
-
- EINA_INLIST_FOREACH(fd_handlers, fdh)
- {
- if (!fdh->delete_me)
- {
- if (fdh->flags & ECORE_FD_READ)
- {
- FD_SET(fdh->fd, &rfds);
- if (fdh->fd > max_fd) max_fd = fdh->fd;
- }
- if (fdh->flags & ECORE_FD_WRITE)
- {
- FD_SET(fdh->fd, &wfds);
- if (fdh->fd > max_fd) max_fd = fdh->fd;
- }
- if (fdh->flags & ECORE_FD_ERROR)
- {
- FD_SET(fdh->fd, &exfds);
- if (fdh->fd > max_fd) max_fd = fdh->fd;
- }
- }
- }
-#else /* HAVE_EPOLL */
- /* polling on the epoll fd will wake when an fd in the epoll set is active */
- FD_SET(epoll_fd, &rfds);
- max_fd = epoll_fd;
-#endif /* HAVE_EPOLL */
-
- if (_ecore_signal_count_get()) return -1;
-
- ret = main_loop_select(max_fd + 1, &rfds, &wfds, &exfds, t);
-
- _ecore_time_loop_time = ecore_time_get();
- if (ret < 0)
- {
+ Ecore_Fd_Handler *fdh;
+
+ EINA_INLIST_FOREACH(fd_handlers, fdh) {
+ if (!fdh->delete_me) {
+ if (fdh->flags & ECORE_FD_READ) {
+ FD_SET(fdh->fd, &rfds);
+ if (fdh->fd > max_fd)
+ max_fd = fdh->fd;
+ }
+ if (fdh->flags & ECORE_FD_WRITE) {
+ FD_SET(fdh->fd, &wfds);
+ if (fdh->fd > max_fd)
+ max_fd = fdh->fd;
+ }
+ if (fdh->flags & ECORE_FD_ERROR) {
+ FD_SET(fdh->fd, &exfds);
+ if (fdh->fd > max_fd)
+ max_fd = fdh->fd;
+ }
+ }
+ }
+#else /* HAVE_EPOLL */
+ /* polling on the epoll fd will wake when an fd in the epoll set is active */
+ FD_SET(epoll_fd, &rfds);
+ max_fd = epoll_fd;
+#endif /* HAVE_EPOLL */
+
+ if (_ecore_signal_count_get())
+ return -1;
+
+ ret = main_loop_select(max_fd + 1, &rfds, &wfds, &exfds, t);
+
+ _ecore_time_loop_time = ecore_time_get();
+ if (ret < 0) {
#ifndef _WIN32
- if (errno == EINTR) return -1;
- else if (errno == EBADF) _ecore_main_fd_handlers_bads_rem();
+ if (errno == EINTR)
+ return -1;
+ else if (errno == EBADF)
+ _ecore_main_fd_handlers_bads_rem();
#endif
- }
- if (ret > 0)
- {
+ }
+ if (ret > 0) {
#ifdef HAVE_EPOLL
- _ecore_main_fdh_epoll_mark_active();
-#else /* HAVE_EPOLL */
- Ecore_Fd_Handler *fdh;
-
- EINA_INLIST_FOREACH(fd_handlers, fdh)
- {
- if (!fdh->delete_me)
- {
- if (FD_ISSET(fdh->fd, &rfds))
- fdh->read_active = 1;
- if (FD_ISSET(fdh->fd, &wfds))
- fdh->write_active = 1;
- if (FD_ISSET(fdh->fd, &exfds))
- fdh->error_active = 1;
- }
- }
-#endif /* HAVE_EPOLL */
- _ecore_main_fd_handlers_cleanup();
+ _ecore_main_fdh_epoll_mark_active();
+#else /* HAVE_EPOLL */
+ Ecore_Fd_Handler *fdh;
+
+ EINA_INLIST_FOREACH(fd_handlers, fdh) {
+ if (!fdh->delete_me) {
+ if (FD_ISSET(fdh->fd, &rfds))
+ fdh->read_active = 1;
+ if (FD_ISSET(fdh->fd, &wfds))
+ fdh->write_active = 1;
+ if (FD_ISSET(fdh->fd, &exfds))
+ fdh->error_active = 1;
+ }
+ }
+#endif /* HAVE_EPOLL */
+ _ecore_main_fd_handlers_cleanup();
#ifdef _WIN32
- _ecore_main_win32_handlers_cleanup();
+ _ecore_main_win32_handlers_cleanup();
#endif
- return 1;
- }
- return 0;
+ return 1;
+ }
+ return 0;
}
#ifndef _WIN32
-static void
-_ecore_main_fd_handlers_bads_rem(void)
+static void _ecore_main_fd_handlers_bads_rem(void)
{
- Ecore_Fd_Handler *fdh;
- Eina_Inlist *l;
- int found = 0;
-
- ERR("Removing bad fds");
- for (l = EINA_INLIST_GET(fd_handlers); l; )
- {
- fdh = (Ecore_Fd_Handler *) l;
- l = l->next;
- errno = 0;
-
- if ((fcntl(fdh->fd, F_GETFD) < 0) && (errno == EBADF))
- {
- ERR("Found bad fd at index %d", fdh->fd);
- if (fdh->flags & ECORE_FD_ERROR)
- {
- ERR("Fd set for error! calling user");
- fdh->references++;
- if (!fdh->func(fdh->data, fdh))
- {
- ERR("Fd function err returned 0, remove it");
- fdh->delete_me = 1;
- fd_handlers_delete_me = 1;
- found++;
- }
- fdh->references--;
- }
- else
- {
- ERR("Problematic fd found at %d! setting it for delete", fdh->fd);
- fdh->delete_me = 1;
- fd_handlers_delete_me = 1;
- found++;
- }
- }
- }
- if (found == 0)
- {
+ Ecore_Fd_Handler *fdh;
+ Eina_Inlist *l;
+ int found = 0;
+
+ ERR("Removing bad fds");
+ for (l = EINA_INLIST_GET(fd_handlers); l;) {
+ fdh = (Ecore_Fd_Handler *) l;
+ l = l->next;
+ errno = 0;
+
+ if ((fcntl(fdh->fd, F_GETFD) < 0) && (errno == EBADF)) {
+ ERR("Found bad fd at index %d", fdh->fd);
+ if (fdh->flags & ECORE_FD_ERROR) {
+ ERR("Fd set for error! calling user");
+ fdh->references++;
+ if (!fdh->func(fdh->data, fdh)) {
+ ERR("Fd function err returned 0, remove it");
+ fdh->delete_me = 1;
+ fd_handlers_delete_me = 1;
+ found++;
+ }
+ fdh->references--;
+ } else {
+ ERR("Problematic fd found at %d! setting it for delete", fdh->fd);
+ fdh->delete_me = 1;
+ fd_handlers_delete_me = 1;
+ found++;
+ }
+ }
+ }
+ if (found == 0) {
#ifdef HAVE_GLIB
- ERR("No bad fd found. Maybe a foreign fd from glib?");
-#else
- ERR("No bad fd found. EEEK!");
-#endif
- }
- _ecore_main_fd_handlers_cleanup();
+ ERR("No bad fd found. Maybe a foreign fd from glib?");
+#else
+ ERR("No bad fd found. EEEK!");
+#endif
+ }
+ _ecore_main_fd_handlers_cleanup();
}
#endif
-static void
-_ecore_main_fd_handlers_cleanup(void)
+static void _ecore_main_fd_handlers_cleanup(void)
{
- Ecore_Fd_Handler *fdh;
- Eina_Inlist *l;
- int deleted_in_use = 0;
-
- if (!fd_handlers_delete_me) return;
- for (l = EINA_INLIST_GET(fd_handlers); l; )
- {
- fdh = (Ecore_Fd_Handler *) l;
-
- l = l->next;
- if (fdh->delete_me)
- {
- if (fdh->references)
- {
- deleted_in_use++;
- continue;
- }
-
- fd_handlers = (Ecore_Fd_Handler *)
- eina_inlist_remove(EINA_INLIST_GET(fd_handlers),
- EINA_INLIST_GET(fdh));
- ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
- free(fdh);
- }
- }
- if (!deleted_in_use) fd_handlers_delete_me = 0;
+ Ecore_Fd_Handler *fdh;
+ Eina_Inlist *l;
+ int deleted_in_use = 0;
+
+ if (!fd_handlers_delete_me)
+ return;
+ for (l = EINA_INLIST_GET(fd_handlers); l;) {
+ fdh = (Ecore_Fd_Handler *) l;
+
+ l = l->next;
+ if (fdh->delete_me) {
+ if (fdh->references) {
+ deleted_in_use++;
+ continue;
+ }
+
+ fd_handlers = (Ecore_Fd_Handler *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (fd_handlers),
+ EINA_INLIST_GET(fdh));
+ ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
+ free(fdh);
+ }
+ }
+ if (!deleted_in_use)
+ fd_handlers_delete_me = 0;
}
#ifdef _WIN32
-static void
-_ecore_main_win32_handlers_cleanup(void)
+static void _ecore_main_win32_handlers_cleanup(void)
{
- Ecore_Win32_Handler *wh;
- Eina_Inlist *l;
- int deleted_in_use = 0;
-
- if (!win32_handlers_delete_me) return;
- for (l = EINA_INLIST_GET(win32_handlers); l; )
- {
- wh = (Ecore_Win32_Handler *)l;
-
- l = l->next;
- if (wh->delete_me)
- {
- if (wh->references)
- {
- deleted_in_use++;
- continue;
- }
-
- win32_handlers = (Ecore_Win32_Handler *)
- eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
- EINA_INLIST_GET(wh));
- ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
- free(wh);
- }
- }
- if (!deleted_in_use) win32_handlers_delete_me = 0;
+ Ecore_Win32_Handler *wh;
+ Eina_Inlist *l;
+ int deleted_in_use = 0;
+
+ if (!win32_handlers_delete_me)
+ return;
+ for (l = EINA_INLIST_GET(win32_handlers); l;) {
+ wh = (Ecore_Win32_Handler *) l;
+
+ l = l->next;
+ if (wh->delete_me) {
+ if (wh->references) {
+ deleted_in_use++;
+ continue;
+ }
+
+ win32_handlers = (Ecore_Win32_Handler *)
+ eina_inlist_remove(EINA_INLIST_GET
+ (win32_handlers),
+ EINA_INLIST_GET(wh));
+ ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
+ free(wh);
+ }
+ }
+ if (!deleted_in_use)
+ win32_handlers_delete_me = 0;
}
#endif
-static void
-_ecore_main_fd_handlers_call(void)
+static void _ecore_main_fd_handlers_call(void)
{
- if (!fd_handler_current)
- {
- /* regular main loop, start from head */
- fd_handler_current = fd_handlers;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next;
- }
-
- while (fd_handler_current)
- {
- Ecore_Fd_Handler *fdh = fd_handler_current;
-
- if (!fdh->delete_me)
- {
- if ((fdh->read_active) ||
- (fdh->write_active) ||
- (fdh->error_active))
- {
- fdh->references++;
- if (!fdh->func(fdh->data, fdh))
- {
- fdh->delete_me = 1;
- fd_handlers_delete_me = 1;
- }
- fdh->references--;
-
- fdh->read_active = 0;
- fdh->write_active = 0;
- fdh->error_active = 0;
- }
- }
-
- if (fd_handler_current) /* may have changed in recursive main loops */
- fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next;
- }
+ if (!fd_handler_current) {
+ /* regular main loop, start from head */
+ fd_handler_current = fd_handlers;
+ } else {
+ /* recursive main loop, continue from where we were */
+ fd_handler_current =
+ (Ecore_Fd_Handler *)
+ EINA_INLIST_GET(fd_handler_current)->next;
+ }
+
+ while (fd_handler_current) {
+ Ecore_Fd_Handler *fdh = fd_handler_current;
+
+ if (!fdh->delete_me) {
+ if ((fdh->read_active) ||
+ (fdh->write_active) || (fdh->error_active)) {
+ fdh->references++;
+ if (!fdh->func(fdh->data, fdh)) {
+ fdh->delete_me = 1;
+ fd_handlers_delete_me = 1;
+ }
+ fdh->references--;
+
+ fdh->read_active = 0;
+ fdh->write_active = 0;
+ fdh->error_active = 0;
+ }
+ }
+
+ if (fd_handler_current) /* may have changed in recursive main loops */
+ fd_handler_current =
+ (Ecore_Fd_Handler *)
+ EINA_INLIST_GET(fd_handler_current)->next;
+ }
}
-static int
-_ecore_main_fd_handlers_buf_call(void)
+static int _ecore_main_fd_handlers_buf_call(void)
{
- Ecore_Fd_Handler *fdh;
- int ret;
-
- ret = 0;
- EINA_INLIST_FOREACH(fd_handlers, fdh)
- {
- if (!fdh->delete_me)
- {
- if (fdh->buf_func)
- {
- fdh->references++;
- if (fdh->buf_func(fdh->buf_data, fdh))
- {
- ret |= fdh->func(fdh->data, fdh);
- fdh->read_active = 1;
- }
- fdh->references--;
- }
- }
- }
- return ret;
+ Ecore_Fd_Handler *fdh;
+ int ret;
+
+ ret = 0;
+ EINA_INLIST_FOREACH(fd_handlers, fdh) {
+ if (!fdh->delete_me) {
+ if (fdh->buf_func) {
+ fdh->references++;
+ if (fdh->buf_func(fdh->buf_data, fdh)) {
+ ret |= fdh->func(fdh->data, fdh);
+ fdh->read_active = 1;
+ }
+ fdh->references--;
+ }
+ }
+ }
+ return ret;
}
#ifndef USE_G_MAIN_LOOP
-static void
-_ecore_main_loop_iterate_internal(int once_only)
+static void _ecore_main_loop_iterate_internal(int once_only)
{
- double next_time = -1.0;
- int have_event = 0;
- int have_signal;
-
- in_main_loop++;
- /* expire any timers */
- while (_ecore_timer_call(_ecore_time_loop_time));
- _ecore_timer_cleanup();
-
- /* process signals into events .... */
- while (_ecore_signal_count_get()) _ecore_signal_call();
- if (_ecore_event_exist())
- {
- _ecore_idle_enterer_call();
- have_event = 1;
- _ecore_main_select(0.0);
- _ecore_time_loop_time = ecore_time_get();
- _ecore_timer_enable_new();
- goto process_events;
- }
- /* call idle enterers ... */
- if (!once_only) _ecore_idle_enterer_call();
- else
- {
- have_event = have_signal = 0;
-
- if (_ecore_main_select(0.0) > 0) have_event = 1;
- if (_ecore_signal_count_get() > 0) have_signal = 1;
- if (have_signal || have_event)
- {
- _ecore_time_loop_time = ecore_time_get();
- _ecore_timer_enable_new();
- goto process_events;
- }
- }
-
- /* if these calls caused any buffered events to appear - deal with them */
- _ecore_main_fd_handlers_buf_call();
-
- /* if there are any - jump to processing them */
- if (_ecore_event_exist())
- {
- have_event = 1;
- _ecore_main_select(0.0);
- _ecore_time_loop_time = ecore_time_get();
- _ecore_timer_enable_new();
- goto process_events;
- }
- if (once_only)
- {
- _ecore_idle_enterer_call();
- in_main_loop--;
- _ecore_time_loop_time = ecore_time_get();
- _ecore_timer_enable_new();
- return;
- }
-
- if (_ecore_fps_debug)
- {
- t2 = ecore_time_get();
- if ((t1 > 0.0) && (t2 > 0.0))
- _ecore_fps_debug_runtime_add(t2 - t1);
- }
- start_loop:
- /* any timers re-added as a result of these are allowed to go */
- _ecore_timer_enable_new();
- if (do_quit)
- {
- _ecore_time_loop_time = ecore_time_get();
- in_main_loop--;
- _ecore_timer_enable_new();
- return;
- }
- if (!_ecore_event_exist())
- {
- /* init flags */
- have_event = have_signal = 0;
- next_time = _ecore_timer_next_get();
- /* no timers */
- if (next_time < 0)
- {
- /* no idlers */
- if (!_ecore_idler_exist())
- {
- if (_ecore_main_select(-1.0) > 0) have_event = 1;
- }
- /* idlers */
- else
- {
- for (;;)
- {
- if (!_ecore_idler_call()) goto start_loop;
- if (_ecore_event_exist()) break;
- if (_ecore_main_select(0.0) > 0) have_event = 1;
- if (_ecore_signal_count_get() > 0) have_signal = 1;
- if (have_event || have_signal) break;
- if (_ecore_timers_exists()) goto start_loop;
- if (do_quit) break;
- }
- }
- }
- /* timers */
- else
- {
- /* no idlers */
- if (!_ecore_idler_exist())
- {
- if (_ecore_main_select(next_time) > 0) have_event = 1;
- }
- /* idlers */
- else
- {
- for (;;)
- {
- if (!_ecore_idler_call()) goto start_loop;
- if (_ecore_event_exist()) break;
- if (_ecore_main_select(0.0) > 0) have_event = 1;
- if (_ecore_signal_count_get() > 0) have_signal = 1;
- if (have_event || have_signal) break;
- next_time = _ecore_timer_next_get();
- if (next_time <= 0) break;
- if (do_quit) break;
- }
- }
- }
- _ecore_time_loop_time = ecore_time_get();
- }
- if (_ecore_fps_debug) t1 = ecore_time_get();
- /* we came out of our "wait state" so idle has exited */
- if (!once_only) _ecore_idle_exiter_call();
- /* call the fd handler per fd that became alive... */
- /* this should read or write any data to the monitored fd and then */
- /* post events onto the ecore event pipe if necessary */
- process_events:
- _ecore_main_fd_handlers_call();
- _ecore_main_fd_handlers_buf_call();
- /* process signals into events .... */
- while (_ecore_signal_count_get()) _ecore_signal_call();
- /* handle events ... */
- _ecore_event_call();
- _ecore_main_fd_handlers_cleanup();
-
- if (once_only) _ecore_idle_enterer_call();
- in_main_loop--;
+ double next_time = -1.0;
+ int have_event = 0;
+ int have_signal;
+
+ in_main_loop++;
+ /* expire any timers */
+ while (_ecore_timer_call(_ecore_time_loop_time));
+ _ecore_timer_cleanup();
+
+ /* process signals into events .... */
+ while (_ecore_signal_count_get())
+ _ecore_signal_call();
+ if (_ecore_event_exist()) {
+ _ecore_idle_enterer_call();
+ have_event = 1;
+ _ecore_main_select(0.0);
+ _ecore_time_loop_time = ecore_time_get();
+ _ecore_timer_enable_new();
+ goto process_events;
+ }
+ /* call idle enterers ... */
+ if (!once_only)
+ _ecore_idle_enterer_call();
+ else {
+ have_event = have_signal = 0;
+
+ if (_ecore_main_select(0.0) > 0)
+ have_event = 1;
+ if (_ecore_signal_count_get() > 0)
+ have_signal = 1;
+ if (have_signal || have_event) {
+ _ecore_time_loop_time = ecore_time_get();
+ _ecore_timer_enable_new();
+ goto process_events;
+ }
+ }
+
+ /* if these calls caused any buffered events to appear - deal with them */
+ _ecore_main_fd_handlers_buf_call();
+
+ /* if there are any - jump to processing them */
+ if (_ecore_event_exist()) {
+ have_event = 1;
+ _ecore_main_select(0.0);
+ _ecore_time_loop_time = ecore_time_get();
+ _ecore_timer_enable_new();
+ goto process_events;
+ }
+ if (once_only) {
+ _ecore_idle_enterer_call();
+ in_main_loop--;
+ _ecore_time_loop_time = ecore_time_get();
+ _ecore_timer_enable_new();
+ return;
+ }
+
+ if (_ecore_fps_debug) {
+ t2 = ecore_time_get();
+ if ((t1 > 0.0) && (t2 > 0.0))
+ _ecore_fps_debug_runtime_add(t2 - t1);
+ }
+ start_loop:
+ /* any timers re-added as a result of these are allowed to go */
+ _ecore_timer_enable_new();
+ if (do_quit) {
+ _ecore_time_loop_time = ecore_time_get();
+ in_main_loop--;
+ _ecore_timer_enable_new();
+ return;
+ }
+ if (!_ecore_event_exist()) {
+ /* init flags */
+ have_event = have_signal = 0;
+ next_time = _ecore_timer_next_get();
+ /* no timers */
+ if (next_time < 0) {
+ /* no idlers */
+ if (!_ecore_idler_exist()) {
+ if (_ecore_main_select(-1.0) > 0)
+ have_event = 1;
+ }
+ /* idlers */
+ else {
+ for (;;) {
+ if (!_ecore_idler_call())
+ goto start_loop;
+ if (_ecore_event_exist())
+ break;
+ if (_ecore_main_select(0.0) > 0)
+ have_event = 1;
+ if (_ecore_signal_count_get() > 0)
+ have_signal = 1;
+ if (have_event || have_signal)
+ break;
+ if (_ecore_timers_exists())
+ goto start_loop;
+ if (do_quit)
+ break;
+ }
+ }
+ }
+ /* timers */
+ else {
+ /* no idlers */
+ if (!_ecore_idler_exist()) {
+ if (_ecore_main_select(next_time) > 0)
+ have_event = 1;
+ }
+ /* idlers */
+ else {
+ for (;;) {
+ if (!_ecore_idler_call())
+ goto start_loop;
+ if (_ecore_event_exist())
+ break;
+ if (_ecore_main_select(0.0) > 0)
+ have_event = 1;
+ if (_ecore_signal_count_get() > 0)
+ have_signal = 1;
+ if (have_event || have_signal)
+ break;
+ next_time =
+ _ecore_timer_next_get();
+ if (next_time <= 0)
+ break;
+ if (do_quit)
+ break;
+ }
+ }
+ }
+ _ecore_time_loop_time = ecore_time_get();
+ }
+ if (_ecore_fps_debug)
+ t1 = ecore_time_get();
+ /* we came out of our "wait state" so idle has exited */
+ if (!once_only)
+ _ecore_idle_exiter_call();
+ /* call the fd handler per fd that became alive... */
+ /* this should read or write any data to the monitored fd and then */
+ /* post events onto the ecore event pipe if necessary */
+ process_events:
+ _ecore_main_fd_handlers_call();
+ _ecore_main_fd_handlers_buf_call();
+ /* process signals into events .... */
+ while (_ecore_signal_count_get())
+ _ecore_signal_call();
+ /* handle events ... */
+ _ecore_event_call();
+ _ecore_main_fd_handlers_cleanup();
+
+ if (once_only)
+ _ecore_idle_enterer_call();
+ in_main_loop--;
}
#endif
#ifdef _WIN32
static int
-_ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *tv)
+_ecore_main_win32_select(int nfds __UNUSED__, fd_set * readfds,
+ fd_set * writefds, fd_set * exceptfds,
+ struct timeval *tv)
{
- HANDLE objects[MAXIMUM_WAIT_OBJECTS];
- int sockets[MAXIMUM_WAIT_OBJECTS];
- Ecore_Fd_Handler *fdh;
- Ecore_Win32_Handler *wh;
- unsigned int objects_nbr = 0;
- unsigned int handles_nbr = 0;
- unsigned int events_nbr = 0;
- DWORD result;
- DWORD timeout;
- MSG msg;
- unsigned int i;
- int res;
-
- /* Create an event object per socket */
- EINA_INLIST_FOREACH(fd_handlers, fdh)
- {
- WSAEVENT event;
- long network_event;
-
- network_event = 0;
- if (FD_ISSET(fdh->fd, readfds))
- network_event |= FD_READ;
- if (FD_ISSET(fdh->fd, writefds))
- network_event |= FD_WRITE;
- if (FD_ISSET(fdh->fd, exceptfds))
- network_event |= FD_OOB;
-
- if (network_event)
- {
- event = WSACreateEvent();
- WSAEventSelect(fdh->fd, event, network_event);
- objects[objects_nbr] = event;
- sockets[events_nbr] = fdh->fd;
- events_nbr++;
- objects_nbr++;
- }
- }
-
- /* store the HANDLEs in the objects to wait for */
- EINA_INLIST_FOREACH(win32_handlers, wh)
- {
- objects[objects_nbr] = wh->h;
- handles_nbr++;
- objects_nbr++;
- }
-
- /* Empty the queue before waiting */
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- /* Wait for any message sent or posted to this queue */
- /* or for one of the passed handles be set to signaled. */
- if (!tv)
- timeout = INFINITE;
- else
- timeout = (DWORD)((tv->tv_sec * 1000.0) + (tv->tv_usec / 1000.0));
-
- if (timeout == 0) return 0;
-
- result = MsgWaitForMultipleObjects(objects_nbr, (const HANDLE *)objects, EINA_FALSE,
- timeout, QS_ALLINPUT);
-
- FD_ZERO(readfds);
- FD_ZERO(writefds);
- FD_ZERO(exceptfds);
-
- /* The result tells us the type of event we have. */
- if (result == WAIT_FAILED)
- {
- char *msg;
-
- msg = evil_last_error_get();
- ERR(" * %s\n", msg);
- free(msg);
- res = -1;
- }
- else if (result == WAIT_TIMEOUT)
- {
- /* ERR("time out\n"); */
- res = 0;
- }
- else if (result == (WAIT_OBJECT_0 + objects_nbr))
- {
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- res = 0;
- }
- else if ((result >= 0) && (result < WAIT_OBJECT_0 + events_nbr))
- {
- WSANETWORKEVENTS network_event;
-
- WSAEnumNetworkEvents(sockets[result], objects[result], &network_event);
-
- if (network_event.lNetworkEvents & FD_READ)
- FD_SET(sockets[result], readfds);
- if (network_event.lNetworkEvents & FD_WRITE)
- FD_SET(sockets[result], writefds);
- if (network_event.lNetworkEvents & FD_OOB)
- FD_SET(sockets[result], exceptfds);
-
- res = 1;
- }
- else if ((result >= (WAIT_OBJECT_0 + events_nbr)) &&
- (result < (WAIT_OBJECT_0 + objects_nbr)))
- {
- if (!win32_handler_current)
- {
- /* regular main loop, start from head */
- win32_handler_current = win32_handlers;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- win32_handler_current = (Ecore_Win32_Handler *)EINA_INLIST_GET(win32_handler_current)->next;
- }
-
- while (win32_handler_current)
- {
- wh = win32_handler_current;
-
- if (objects[result - WAIT_OBJECT_0] == wh->h)
- {
- if (!wh->delete_me)
- {
- wh->references++;
- if (!wh->func(wh->data, wh))
- {
- wh->delete_me = 1;
- win32_handlers_delete_me = 1;
- }
- wh->references--;
- }
- }
- if (win32_handler_current) /* may have changed in recursive main loops */
- win32_handler_current = (Ecore_Win32_Handler *)EINA_INLIST_GET(win32_handler_current)->next;
- }
- res = 1;
- }
- else
- {
- ERR("unknown result...\n");
- res = -1;
- }
-
- /* Remove event objects again */
- for (i = 0; i < events_nbr; i++) WSACloseEvent(objects[i]);
-
- return res;
+ HANDLE objects[MAXIMUM_WAIT_OBJECTS];
+ int sockets[MAXIMUM_WAIT_OBJECTS];
+ Ecore_Fd_Handler *fdh;
+ Ecore_Win32_Handler *wh;
+ unsigned int objects_nbr = 0;
+ unsigned int handles_nbr = 0;
+ unsigned int events_nbr = 0;
+ DWORD result;
+ DWORD timeout;
+ MSG msg;
+ unsigned int i;
+ int res;
+
+ /* Create an event object per socket */
+ EINA_INLIST_FOREACH(fd_handlers, fdh) {
+ WSAEVENT event;
+ long network_event;
+
+ network_event = 0;
+ if (FD_ISSET(fdh->fd, readfds))
+ network_event |= FD_READ;
+ if (FD_ISSET(fdh->fd, writefds))
+ network_event |= FD_WRITE;
+ if (FD_ISSET(fdh->fd, exceptfds))
+ network_event |= FD_OOB;
+
+ if (network_event) {
+ event = WSACreateEvent();
+ WSAEventSelect(fdh->fd, event, network_event);
+ objects[objects_nbr] = event;
+ sockets[events_nbr] = fdh->fd;
+ events_nbr++;
+ objects_nbr++;
+ }
+ }
+
+ /* store the HANDLEs in the objects to wait for */
+ EINA_INLIST_FOREACH(win32_handlers, wh) {
+ objects[objects_nbr] = wh->h;
+ handles_nbr++;
+ objects_nbr++;
+ }
+
+ /* Empty the queue before waiting */
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ /* Wait for any message sent or posted to this queue */
+ /* or for one of the passed handles be set to signaled. */
+ if (!tv)
+ timeout = INFINITE;
+ else
+ timeout =
+ (DWORD) ((tv->tv_sec * 1000.0) +
+ (tv->tv_usec / 1000.0));
+
+ if (timeout == 0)
+ return 0;
+
+ result =
+ MsgWaitForMultipleObjects(objects_nbr,
+ (const HANDLE *) objects, EINA_FALSE,
+ timeout, QS_ALLINPUT);
+
+ FD_ZERO(readfds);
+ FD_ZERO(writefds);
+ FD_ZERO(exceptfds);
+
+ /* The result tells us the type of event we have. */
+ if (result == WAIT_FAILED) {
+ char *msg;
+
+ msg = evil_last_error_get();
+ ERR(" * %s\n", msg);
+ free(msg);
+ res = -1;
+ } else if (result == WAIT_TIMEOUT) {
+ /* ERR("time out\n"); */
+ res = 0;
+ } else if (result == (WAIT_OBJECT_0 + objects_nbr)) {
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ res = 0;
+ } else if ((result >= 0) && (result < WAIT_OBJECT_0 + events_nbr)) {
+ WSANETWORKEVENTS network_event;
+
+ WSAEnumNetworkEvents(sockets[result], objects[result],
+ &network_event);
+
+ if (network_event.lNetworkEvents & FD_READ)
+ FD_SET(sockets[result], readfds);
+ if (network_event.lNetworkEvents & FD_WRITE)
+ FD_SET(sockets[result], writefds);
+ if (network_event.lNetworkEvents & FD_OOB)
+ FD_SET(sockets[result], exceptfds);
+
+ res = 1;
+ } else if ((result >= (WAIT_OBJECT_0 + events_nbr)) &&
+ (result < (WAIT_OBJECT_0 + objects_nbr))) {
+ if (!win32_handler_current) {
+ /* regular main loop, start from head */
+ win32_handler_current = win32_handlers;
+ } else {
+ /* recursive main loop, continue from where we were */
+ win32_handler_current =
+ (Ecore_Win32_Handler *)
+ EINA_INLIST_GET(win32_handler_current)->next;
+ }
+
+ while (win32_handler_current) {
+ wh = win32_handler_current;
+
+ if (objects[result - WAIT_OBJECT_0] == wh->h) {
+ if (!wh->delete_me) {
+ wh->references++;
+ if (!wh->func(wh->data, wh)) {
+ wh->delete_me = 1;
+ win32_handlers_delete_me =
+ 1;
+ }
+ wh->references--;
+ }
+ }
+ if (win32_handler_current) /* may have changed in recursive main loops */
+ win32_handler_current =
+ (Ecore_Win32_Handler *)
+ EINA_INLIST_GET
+ (win32_handler_current)->next;
+ }
+ res = 1;
+ } else {
+ ERR("unknown result...\n");
+ res = -1;
+ }
+
+ /* Remove event objects again */
+ for (i = 0; i < events_nbr; i++)
+ WSACloseEvent(objects[i]);
+
+ return res;
}
#endif
diff --git a/tests/suite/ecore/src/lib/ecore_pipe.c b/tests/suite/ecore/src/lib/ecore_pipe.c
index 8a8aca5ffe..123cab681b 100644
--- a/tests/suite/ecore/src/lib/ecore_pipe.c
+++ b/tests/suite/ecore/src/lib/ecore_pipe.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -7,7 +7,7 @@
#include <errno.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "Ecore.h"
@@ -27,42 +27,42 @@
#ifdef _WIN32
-# include <winsock2.h>
+#include <winsock2.h>
-# define pipe_write(fd, buffer, size) send((fd), (char *)(buffer), size, 0)
-# define pipe_read(fd, buffer, size) recv((fd), (char *)(buffer), size, 0)
-# define pipe_close(fd) closesocket(fd)
-# define PIPE_FD_INVALID INVALID_SOCKET
-# define PIPE_FD_ERROR SOCKET_ERROR
+#define pipe_write(fd, buffer, size) send((fd), (char *)(buffer), size, 0)
+#define pipe_read(fd, buffer, size) recv((fd), (char *)(buffer), size, 0)
+#define pipe_close(fd) closesocket(fd)
+#define PIPE_FD_INVALID INVALID_SOCKET
+#define PIPE_FD_ERROR SOCKET_ERROR
#else
-# include <unistd.h>
-# include <fcntl.h>
-
-# define pipe_write(fd, buffer, size) write((fd), buffer, size)
-# define pipe_read(fd, buffer, size) read((fd), buffer, size)
-# define pipe_close(fd) close(fd)
-# define PIPE_FD_INVALID -1
-# define PIPE_FD_ERROR -1
-
-#endif /* ! _WIN32 */
-
-struct _Ecore_Pipe
-{
- ECORE_MAGIC;
- int fd_read;
- int fd_write;
- Ecore_Fd_Handler *fd_handler;
- const void *data;
- Ecore_Pipe_Cb handler;
- unsigned int len;
- size_t already_read;
- void *passed_data;
+#include <unistd.h>
+#include <fcntl.h>
+
+#define pipe_write(fd, buffer, size) write((fd), buffer, size)
+#define pipe_read(fd, buffer, size) read((fd), buffer, size)
+#define pipe_close(fd) close(fd)
+#define PIPE_FD_INVALID -1
+#define PIPE_FD_ERROR -1
+
+#endif /* ! _WIN32 */
+
+struct _Ecore_Pipe {
+ ECORE_MAGIC;
+ int fd_read;
+ int fd_write;
+ Ecore_Fd_Handler *fd_handler;
+ const void *data;
+ Ecore_Pipe_Cb handler;
+ unsigned int len;
+ size_t already_read;
+ void *passed_data;
};
-static Eina_Bool _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler);
+static Eina_Bool _ecore_pipe_read(void *data,
+ Ecore_Fd_Handler * fd_handler);
/**
* @defgroup Ecore_Pipe_Group Pipe wrapper
@@ -277,36 +277,35 @@ static Eina_Bool _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler);
* @c NULL otherwise.
* @ingroup Ecore_Pipe_Group
*/
-EAPI Ecore_Pipe *
-ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data)
+EAPI Ecore_Pipe *ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data)
{
- Ecore_Pipe *p;
- int fds[2];
-
- if (!handler) return NULL;
-
- p = (Ecore_Pipe *)calloc(1, sizeof(Ecore_Pipe));
- if (!p) return NULL;
-
- if (pipe(fds))
- {
- free(p);
- return NULL;
- }
-
- ECORE_MAGIC_SET(p, ECORE_MAGIC_PIPE);
- p->fd_read = fds[0];
- p->fd_write = fds[1];
- p->handler = handler;
- p->data = data;
-
- fcntl(p->fd_read, F_SETFL, O_NONBLOCK);
- p->fd_handler = ecore_main_fd_handler_add(p->fd_read,
- ECORE_FD_READ,
- _ecore_pipe_read,
- p,
- NULL, NULL);
- return p;
+ Ecore_Pipe *p;
+ int fds[2];
+
+ if (!handler)
+ return NULL;
+
+ p = (Ecore_Pipe *) calloc(1, sizeof(Ecore_Pipe));
+ if (!p)
+ return NULL;
+
+ if (pipe(fds)) {
+ free(p);
+ return NULL;
+ }
+
+ ECORE_MAGIC_SET(p, ECORE_MAGIC_PIPE);
+ p->fd_read = fds[0];
+ p->fd_write = fds[1];
+ p->handler = handler;
+ p->data = data;
+
+ fcntl(p->fd_read, F_SETFL, O_NONBLOCK);
+ p->fd_handler = ecore_main_fd_handler_add(p->fd_read,
+ ECORE_FD_READ,
+ _ecore_pipe_read,
+ p, NULL, NULL);
+ return p;
}
/**
@@ -316,22 +315,23 @@ ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data)
* @return The pointer to the private data
* @ingroup Ecore_Pipe_Group
*/
-EAPI void *
-ecore_pipe_del(Ecore_Pipe *p)
+EAPI void *ecore_pipe_del(Ecore_Pipe * p)
{
- void *data;
-
- if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
- {
- ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del");
- return NULL;
- }
- if (p->fd_handler) ecore_main_fd_handler_del(p->fd_handler);
- if (p->fd_read != PIPE_FD_INVALID) pipe_close(p->fd_read);
- if (p->fd_write != PIPE_FD_INVALID) pipe_close(p->fd_write);
- data = (void *)p->data;
- free(p);
- return data;
+ void *data;
+
+ if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) {
+ ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del");
+ return NULL;
+ }
+ if (p->fd_handler)
+ ecore_main_fd_handler_del(p->fd_handler);
+ if (p->fd_read != PIPE_FD_INVALID)
+ pipe_close(p->fd_read);
+ if (p->fd_write != PIPE_FD_INVALID)
+ pipe_close(p->fd_write);
+ data = (void *) p->data;
+ free(p);
+ return data;
}
/**
@@ -340,18 +340,17 @@ ecore_pipe_del(Ecore_Pipe *p)
* @param p The Ecore_Pipe object.
* @ingroup Ecore_Pipe_Group
*/
-EAPI void
-ecore_pipe_read_close(Ecore_Pipe *p)
+EAPI void ecore_pipe_read_close(Ecore_Pipe * p)
{
- if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
- {
- ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close");
- return;
- }
- ecore_main_fd_handler_del(p->fd_handler);
- p->fd_handler = NULL;
- pipe_close(p->fd_read);
- p->fd_read = PIPE_FD_INVALID;
+ if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) {
+ ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
+ "ecore_pipe_read_close");
+ return;
+ }
+ ecore_main_fd_handler_del(p->fd_handler);
+ p->fd_handler = NULL;
+ pipe_close(p->fd_read);
+ p->fd_read = PIPE_FD_INVALID;
}
/**
@@ -360,16 +359,15 @@ ecore_pipe_read_close(Ecore_Pipe *p)
* @param p The Ecore_Pipe object.
* @ingroup Ecore_Pipe_Group
*/
-EAPI void
-ecore_pipe_write_close(Ecore_Pipe *p)
+EAPI void ecore_pipe_write_close(Ecore_Pipe * p)
{
- if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
- {
- ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write_close");
- return;
- }
- pipe_close(p->fd_write);
- p->fd_write = PIPE_FD_INVALID;
+ if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) {
+ ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
+ "ecore_pipe_write_close");
+ return;
+ }
+ pipe_close(p->fd_write);
+ p->fd_write = PIPE_FD_INVALID;
}
/**
@@ -382,214 +380,189 @@ ecore_pipe_write_close(Ecore_Pipe *p)
* @ingroup Ecore_Pipe_Group
*/
EAPI Eina_Bool
-ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes)
+ecore_pipe_write(Ecore_Pipe * p, const void *buffer, unsigned int nbytes)
{
- ssize_t ret;
- size_t already_written = 0;
- int retry = ECORE_PIPE_WRITE_RETRY;
-
- if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
- {
- ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write");
- return EINA_FALSE;
- }
-
- if (p->fd_write == PIPE_FD_INVALID) return EINA_FALSE;
-
- /* First write the len into the pipe */
- do
- {
- ret = pipe_write(p->fd_write, &nbytes, sizeof(nbytes));
- if (ret == sizeof(nbytes))
- {
- retry = ECORE_PIPE_WRITE_RETRY;
- break;
- }
- else if (ret > 0)
- {
- /* XXX What should we do here? */
- ERR("The length of the data was not written complete"
- " to the pipe");
- return EINA_FALSE;
- }
- else if (ret == PIPE_FD_ERROR && errno == EPIPE)
- {
- pipe_close(p->fd_write);
- p->fd_write = PIPE_FD_INVALID;
- return EINA_FALSE;
- }
- else if (ret == PIPE_FD_ERROR && errno == EINTR)
- /* try it again */
- ;
- else
- {
- ERR("An unhandled error (ret: %zd errno: %d)"
- "occurred while writing to the pipe the length",
- ret, errno);
- }
- }
- while (retry--);
-
- if (retry != ECORE_PIPE_WRITE_RETRY) return EINA_FALSE;
-
- /* and now pass the data to the pipe */
- do
- {
- ret = pipe_write(p->fd_write,
- ((unsigned char *)buffer) + already_written,
- nbytes - already_written);
-
- if (ret == (ssize_t)(nbytes - already_written))
- return EINA_TRUE;
- else if (ret >= 0)
- {
- already_written -= ret;
- continue;
- }
- else if (ret == PIPE_FD_ERROR && errno == EPIPE)
- {
- pipe_close(p->fd_write);
- p->fd_write = PIPE_FD_INVALID;
- return EINA_FALSE;
- }
- else if (ret == PIPE_FD_ERROR && errno == EINTR)
- /* try it again */
- ;
- else
- {
- ERR("An unhandled error (ret: %zd errno: %d)"
- "occurred while writing to the pipe the length",
- ret, errno);
- }
- }
- while (retry--);
-
- return EINA_FALSE;
+ ssize_t ret;
+ size_t already_written = 0;
+ int retry = ECORE_PIPE_WRITE_RETRY;
+
+ if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) {
+ ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write");
+ return EINA_FALSE;
+ }
+
+ if (p->fd_write == PIPE_FD_INVALID)
+ return EINA_FALSE;
+
+ /* First write the len into the pipe */
+ do {
+ ret = pipe_write(p->fd_write, &nbytes, sizeof(nbytes));
+ if (ret == sizeof(nbytes)) {
+ retry = ECORE_PIPE_WRITE_RETRY;
+ break;
+ } else if (ret > 0) {
+ /* XXX What should we do here? */
+ ERR("The length of the data was not written complete" " to the pipe");
+ return EINA_FALSE;
+ } else if (ret == PIPE_FD_ERROR && errno == EPIPE) {
+ pipe_close(p->fd_write);
+ p->fd_write = PIPE_FD_INVALID;
+ return EINA_FALSE;
+ } else if (ret == PIPE_FD_ERROR && errno == EINTR)
+ /* try it again */
+ ;
+ else {
+ ERR("An unhandled error (ret: %zd errno: %d)"
+ "occurred while writing to the pipe the length",
+ ret, errno);
+ }
+ }
+ while (retry--);
+
+ if (retry != ECORE_PIPE_WRITE_RETRY)
+ return EINA_FALSE;
+
+ /* and now pass the data to the pipe */
+ do {
+ ret = pipe_write(p->fd_write,
+ ((unsigned char *) buffer) +
+ already_written,
+ nbytes - already_written);
+
+ if (ret == (ssize_t) (nbytes - already_written))
+ return EINA_TRUE;
+ else if (ret >= 0) {
+ already_written -= ret;
+ continue;
+ } else if (ret == PIPE_FD_ERROR && errno == EPIPE) {
+ pipe_close(p->fd_write);
+ p->fd_write = PIPE_FD_INVALID;
+ return EINA_FALSE;
+ } else if (ret == PIPE_FD_ERROR && errno == EINTR)
+ /* try it again */
+ ;
+ else {
+ ERR("An unhandled error (ret: %zd errno: %d)"
+ "occurred while writing to the pipe the length",
+ ret, errno);
+ }
+ }
+ while (retry--);
+
+ return EINA_FALSE;
}
/* Private function */
static Eina_Bool
-_ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
+_ecore_pipe_read(void *data, Ecore_Fd_Handler * fd_handler __UNUSED__)
{
- Ecore_Pipe *p;
- double start_time;
-
- p = (Ecore_Pipe *)data;
- start_time = ecore_time_get();
-
- do
- {
- ssize_t ret;
-
- /* if we already have read some data we don't need to read the len
- * but to finish the already started job
- */
- if (p->len == 0)
- {
- /* read the len of the passed data */
- ret = pipe_read(p->fd_read, &p->len, sizeof(p->len));
-
- /* catch the non error case first */
- if (ret == sizeof(p->len))
- ;
- else if (ret > 0)
- {
- /* XXX What should we do here? */
- ERR("Only read %zd bytes from the pipe, although"
- " we need to read %zd bytes.", ret, sizeof(p->len));
- }
- else if (ret == 0)
- {
- p->handler((void *)p->data, NULL, 0);
- pipe_close(p->fd_read);
- p->fd_read = PIPE_FD_INVALID;
- p->fd_handler = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
+ Ecore_Pipe *p;
+ double start_time;
+
+ p = (Ecore_Pipe *) data;
+ start_time = ecore_time_get();
+
+ do {
+ ssize_t ret;
+
+ /* if we already have read some data we don't need to read the len
+ * but to finish the already started job
+ */
+ if (p->len == 0) {
+ /* read the len of the passed data */
+ ret =
+ pipe_read(p->fd_read, &p->len, sizeof(p->len));
+
+ /* catch the non error case first */
+ if (ret == sizeof(p->len));
+ else if (ret > 0) {
+ /* XXX What should we do here? */
+ ERR("Only read %zd bytes from the pipe, although" " we need to read %zd bytes.", ret, sizeof(p->len));
+ } else if (ret == 0) {
+ p->handler((void *) p->data, NULL, 0);
+ pipe_close(p->fd_read);
+ p->fd_read = PIPE_FD_INVALID;
+ p->fd_handler = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
#ifndef _WIN32
- else if ((ret == PIPE_FD_ERROR) && ((errno == EINTR) || (errno == EAGAIN)))
- return ECORE_CALLBACK_RENEW;
- else
- {
- ERR("An unhandled error (ret: %zd errno: %d)"
- "occurred while reading from the pipe the length",
- ret, errno);
- return ECORE_CALLBACK_RENEW;
- }
+ else if ((ret == PIPE_FD_ERROR)
+ && ((errno == EINTR)
+ || (errno == EAGAIN)))
+ return ECORE_CALLBACK_RENEW;
+ else {
+ ERR("An unhandled error (ret: %zd errno: %d)" "occurred while reading from the pipe the length", ret, errno);
+ return ECORE_CALLBACK_RENEW;
+ }
#else
- else /* ret == PIPE_FD_ERROR is the only other case on Windows */
- {
- if (WSAGetLastError() != WSAEWOULDBLOCK)
- {
- p->handler((void *)p->data, NULL, 0);
- pipe_close(p->fd_read);
- p->fd_read = PIPE_FD_INVALID;
- p->fd_handler = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
- }
+ else { /* ret == PIPE_FD_ERROR is the only other case on Windows */
+
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
+ p->handler((void *) p->data, NULL,
+ 0);
+ pipe_close(p->fd_read);
+ p->fd_read = PIPE_FD_INVALID;
+ p->fd_handler = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ }
#endif
- }
-
- if (!p->passed_data)
- p->passed_data = malloc(p->len);
-
- /* and read the passed data */
- ret = pipe_read(p->fd_read,
- ((unsigned char *)p->passed_data) + p->already_read,
- p->len - p->already_read);
-
- /* catch the non error case first */
- if (ret == (ssize_t)(p->len - p->already_read))
- {
- p->handler((void *)p->data, p->passed_data, p->len);
- free(p->passed_data);
- /* reset all values to 0 */
- p->passed_data = NULL;
- p->already_read = 0;
- p->len = 0;
- }
- else if (ret >= 0)
- {
- p->already_read += ret;
- return ECORE_CALLBACK_RENEW;
- }
- else if (ret == 0)
- {
- p->handler((void *)p->data, NULL, 0);
- pipe_close(p->fd_read);
- p->fd_read = PIPE_FD_INVALID;
- p->fd_handler = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
+ }
+
+ if (!p->passed_data)
+ p->passed_data = malloc(p->len);
+
+ /* and read the passed data */
+ ret = pipe_read(p->fd_read,
+ ((unsigned char *) p->passed_data) +
+ p->already_read, p->len - p->already_read);
+
+ /* catch the non error case first */
+ if (ret == (ssize_t) (p->len - p->already_read)) {
+ p->handler((void *) p->data, p->passed_data,
+ p->len);
+ free(p->passed_data);
+ /* reset all values to 0 */
+ p->passed_data = NULL;
+ p->already_read = 0;
+ p->len = 0;
+ } else if (ret >= 0) {
+ p->already_read += ret;
+ return ECORE_CALLBACK_RENEW;
+ } else if (ret == 0) {
+ p->handler((void *) p->data, NULL, 0);
+ pipe_close(p->fd_read);
+ p->fd_read = PIPE_FD_INVALID;
+ p->fd_handler = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
#ifndef _WIN32
- else if (ret == PIPE_FD_ERROR && (errno == EINTR || errno == EAGAIN))
- return ECORE_CALLBACK_RENEW;
- else
- {
- ERR("An unhandled error (ret: %zd errno: %d)"
- "occurred while reading from the pipe the data",
- ret, errno);
- return ECORE_CALLBACK_RENEW;
- }
+ else if (ret == PIPE_FD_ERROR
+ && (errno == EINTR || errno == EAGAIN))
+ return ECORE_CALLBACK_RENEW;
+ else {
+ ERR("An unhandled error (ret: %zd errno: %d)"
+ "occurred while reading from the pipe the data",
+ ret, errno);
+ return ECORE_CALLBACK_RENEW;
+ }
#else
- else /* ret == PIPE_FD_ERROR is the only other case on Windows */
- {
- if (WSAGetLastError() != WSAEWOULDBLOCK)
- {
- p->handler((void *)p->data, NULL, 0);
- pipe_close(p->fd_read);
- p->fd_read = PIPE_FD_INVALID;
- p->fd_handler = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
- else
- break;
- }
+ else { /* ret == PIPE_FD_ERROR is the only other case on Windows */
+
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
+ p->handler((void *) p->data, NULL, 0);
+ pipe_close(p->fd_read);
+ p->fd_read = PIPE_FD_INVALID;
+ p->fd_handler = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ } else
+ break;
+ }
#endif
- }
- while (ecore_time_get() - start_time < ecore_animator_frametime_get());
-
- return ECORE_CALLBACK_RENEW;
+ }
+ while (ecore_time_get() - start_time <
+ ecore_animator_frametime_get());
+
+ return ECORE_CALLBACK_RENEW;
}
diff --git a/tests/suite/ecore/src/lib/ecore_poll.c b/tests/suite/ecore/src/lib/ecore_poll.c
index d5bc6badf5..0c3c208692 100644
--- a/tests/suite/ecore/src/lib/ecore_poll.c
+++ b/tests/suite/ecore/src/lib/ecore_poll.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -8,186 +8,177 @@
#include "ecore_private.h"
-struct _Ecore_Poller
-{
- EINA_INLIST;
- ECORE_MAGIC;
- int ibit;
- unsigned char delete_me : 1;
- Ecore_Task_Cb func;
- void *data;
+struct _Ecore_Poller {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ int ibit;
+ unsigned char delete_me:1;
+ Ecore_Task_Cb func;
+ void *data;
};
-static Ecore_Timer *timer = NULL;
-static int min_interval = -1;
-static int interval_incr = 0;
-static int at_tick = 0;
-static int just_added_poller = 0;
-static int poller_delete_count = 0;
-static int poller_walking = 0;
-static double poll_interval = 0.125;
-static double poll_cur_interval = 0.0;
-static double last_tick = 0.0;
-static Ecore_Poller *pollers[16] =
-{
- NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
- NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
+static Ecore_Timer *timer = NULL;
+static int min_interval = -1;
+static int interval_incr = 0;
+static int at_tick = 0;
+static int just_added_poller = 0;
+static int poller_delete_count = 0;
+static int poller_walking = 0;
+static double poll_interval = 0.125;
+static double poll_cur_interval = 0.0;
+static double last_tick = 0.0;
+static Ecore_Poller *pollers[16] = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
-static unsigned short poller_counters[16] =
-{
- 0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0
+
+static unsigned short poller_counters[16] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
};
static void _ecore_poller_next_tick_eval(void);
static Eina_Bool _ecore_poller_cb_timer(void *data);
-static void
-_ecore_poller_next_tick_eval(void)
+static void _ecore_poller_next_tick_eval(void)
{
- int i;
- double interval;
-
- min_interval = -1;
- for (i = 0; i < 15; i++)
- {
- if (pollers[i])
- {
- min_interval = i;
- break;
- }
- }
- if (min_interval < 0)
- {
- /* no pollers */
- if (timer)
- {
- ecore_timer_del(timer);
- timer = NULL;
- }
- return;
- }
- interval_incr = (1 << min_interval);
- interval = interval_incr * poll_interval;
- /* we are at the tick callback - so no need to do inter-tick adjustments
- * so we can fasttrack this as t -= last_tick in theory is 0.0 (though
- * in practice it will be a very very very small value. also the tick
- * callback will adjust the timer interval at the end anyway */
- if (at_tick)
- {
- if (!timer)
- timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL);
- }
- else
- {
- double t;
-
- if (!timer)
- timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL);
- else
- {
- t = ecore_time_get();
- if (interval != poll_cur_interval)
- {
- t -= last_tick; /* time since we last ticked */
- /* delete the timer and reset it to tick off in the new
- * time interval. at the tick this will be adjusted */
- ecore_timer_del(timer);
- timer = ecore_timer_add(interval - t,
- _ecore_poller_cb_timer, NULL);
- }
- }
- }
- poll_cur_interval = interval;
+ int i;
+ double interval;
+
+ min_interval = -1;
+ for (i = 0; i < 15; i++) {
+ if (pollers[i]) {
+ min_interval = i;
+ break;
+ }
+ }
+ if (min_interval < 0) {
+ /* no pollers */
+ if (timer) {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+ return;
+ }
+ interval_incr = (1 << min_interval);
+ interval = interval_incr * poll_interval;
+ /* we are at the tick callback - so no need to do inter-tick adjustments
+ * so we can fasttrack this as t -= last_tick in theory is 0.0 (though
+ * in practice it will be a very very very small value. also the tick
+ * callback will adjust the timer interval at the end anyway */
+ if (at_tick) {
+ if (!timer)
+ timer =
+ ecore_timer_add(interval,
+ _ecore_poller_cb_timer, NULL);
+ } else {
+ double t;
+
+ if (!timer)
+ timer =
+ ecore_timer_add(interval,
+ _ecore_poller_cb_timer, NULL);
+ else {
+ t = ecore_time_get();
+ if (interval != poll_cur_interval) {
+ t -= last_tick; /* time since we last ticked */
+ /* delete the timer and reset it to tick off in the new
+ * time interval. at the tick this will be adjusted */
+ ecore_timer_del(timer);
+ timer = ecore_timer_add(interval - t,
+ _ecore_poller_cb_timer,
+ NULL);
+ }
+ }
+ }
+ poll_cur_interval = interval;
}
-static Eina_Bool
-_ecore_poller_cb_timer(void *data __UNUSED__)
+static Eina_Bool _ecore_poller_cb_timer(void *data __UNUSED__)
{
- int i;
- Ecore_Poller *poller, *l;
- int changes = 0;
-
- at_tick++;
- last_tick = ecore_time_get();
- /* we have 16 counters - each incriments every time the poller counter
- * "ticks". it incriments by the minimum interval (which can be 1, 2, 4,
- * 7, 16 etc. up to 32768) */
- for (i = 0; i < 15; i++)
- {
- poller_counters[i] += interval_incr;
- /* wrap back to 0 if we exceed out loop count for the counter */
- if (poller_counters[i] >= (1 << i)) poller_counters[i] = 0;
- }
-
- just_added_poller = 0;
- /* walk the pollers now */
- poller_walking++;
- for (i = 0; i < 15; i++)
- {
- /* if the counter is @ 0 - this means that counter "went off" this
- * tick interval, so run all pollers hooked to that counter */
- if (poller_counters[i] == 0)
- {
- EINA_INLIST_FOREACH(pollers[i], poller)
- {
- if (!poller->delete_me)
- {
- if (!poller->func(poller->data))
- {
- if (!poller->delete_me)
- {
- poller->delete_me = 1;
- poller_delete_count++;
- }
- }
- }
- }
- }
- }
- poller_walking--;
-
- /* handle deletes afterwards */
- if (poller_delete_count > 0)
- {
- /* FIXME: walk all pollers and remove deleted ones */
- for (i = 0; i < 15; i++)
- {
- for (l = pollers[i]; l;)
- {
- poller = l;
- l = (Ecore_Poller *) EINA_INLIST_GET(l)->next;
- if (poller->delete_me)
- {
- pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller));
- free(poller);
- poller_delete_count--;
- changes++;
- if (poller_delete_count <= 0) break;
- }
- }
- if (poller_delete_count <= 0) break;
- }
- }
- /* if we deleted or added any pollers, then we need to re-evaluate our
- * minimum poll interval */
- if ((changes > 0) || (just_added_poller > 0))
- _ecore_poller_next_tick_eval();
-
- just_added_poller = 0;
- poller_delete_count = 0;
-
- at_tick--;
-
- /* if the timer was deleted then there is no point returning 1 - ambiguous
- * if we do as it im plies "keep running me" but we have been deleted
- * anyway */
- if (!timer) return ECORE_CALLBACK_CANCEL;
-
- /* adjust interval */
- ecore_timer_interval_set(timer, poll_cur_interval);
- return ECORE_CALLBACK_RENEW;
+ int i;
+ Ecore_Poller *poller, *l;
+ int changes = 0;
+
+ at_tick++;
+ last_tick = ecore_time_get();
+ /* we have 16 counters - each incriments every time the poller counter
+ * "ticks". it incriments by the minimum interval (which can be 1, 2, 4,
+ * 7, 16 etc. up to 32768) */
+ for (i = 0; i < 15; i++) {
+ poller_counters[i] += interval_incr;
+ /* wrap back to 0 if we exceed out loop count for the counter */
+ if (poller_counters[i] >= (1 << i))
+ poller_counters[i] = 0;
+ }
+
+ just_added_poller = 0;
+ /* walk the pollers now */
+ poller_walking++;
+ for (i = 0; i < 15; i++) {
+ /* if the counter is @ 0 - this means that counter "went off" this
+ * tick interval, so run all pollers hooked to that counter */
+ if (poller_counters[i] == 0) {
+ EINA_INLIST_FOREACH(pollers[i], poller) {
+ if (!poller->delete_me) {
+ if (!poller->func(poller->data)) {
+ if (!poller->delete_me) {
+ poller->delete_me =
+ 1;
+ poller_delete_count++;
+ }
+ }
+ }
+ }
+ }
+ }
+ poller_walking--;
+
+ /* handle deletes afterwards */
+ if (poller_delete_count > 0) {
+ /* FIXME: walk all pollers and remove deleted ones */
+ for (i = 0; i < 15; i++) {
+ for (l = pollers[i]; l;) {
+ poller = l;
+ l = (Ecore_Poller *) EINA_INLIST_GET(l)->
+ next;
+ if (poller->delete_me) {
+ pollers[i] =
+ (Ecore_Poller *)
+ eina_inlist_remove
+ (EINA_INLIST_GET(pollers[i]),
+ EINA_INLIST_GET(poller));
+ free(poller);
+ poller_delete_count--;
+ changes++;
+ if (poller_delete_count <= 0)
+ break;
+ }
+ }
+ if (poller_delete_count <= 0)
+ break;
+ }
+ }
+ /* if we deleted or added any pollers, then we need to re-evaluate our
+ * minimum poll interval */
+ if ((changes > 0) || (just_added_poller > 0))
+ _ecore_poller_next_tick_eval();
+
+ just_added_poller = 0;
+ poller_delete_count = 0;
+
+ at_tick--;
+
+ /* if the timer was deleted then there is no point returning 1 - ambiguous
+ * if we do as it im plies "keep running me" but we have been deleted
+ * anyway */
+ if (!timer)
+ return ECORE_CALLBACK_CANCEL;
+
+ /* adjust interval */
+ ecore_timer_interval_set(timer, poll_cur_interval);
+ return ECORE_CALLBACK_RENEW;
}
/**
@@ -210,10 +201,11 @@ _ecore_poller_cb_timer(void *data __UNUSED__)
* by @p type to the time period defined by @p poll_time.
*/
EAPI void
-ecore_poller_poll_interval_set(Ecore_Poller_Type type __UNUSED__, double poll_time)
+ecore_poller_poll_interval_set(Ecore_Poller_Type type __UNUSED__,
+ double poll_time)
{
- poll_interval = poll_time;
- _ecore_poller_next_tick_eval();
+ poll_interval = poll_time;
+ _ecore_poller_next_tick_eval();
}
/**
@@ -227,7 +219,7 @@ ecore_poller_poll_interval_set(Ecore_Poller_Type type __UNUSED__, double poll_ti
EAPI double
ecore_poller_poll_interval_get(Ecore_Poller_Type type __UNUSED__)
{
- return poll_interval;
+ return poll_interval;
}
/**
@@ -277,38 +269,46 @@ ecore_poller_poll_interval_get(Ecore_Poller_Type type __UNUSED__)
* 0 it will be deleted automatically making any references/handles for it
* invalid.
*/
-EAPI Ecore_Poller *
-ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type __UNUSED__,
+ int interval, Ecore_Task_Cb func,
+ const void *data)
{
- Ecore_Poller *poller;
- int ibit;
-
- if (!func) return NULL;
- if (interval < 1) interval = 1;
-
- poller = calloc(1, sizeof(Ecore_Poller));
- if (!poller) return NULL;
- ECORE_MAGIC_SET(poller, ECORE_MAGIC_POLLER);
- /* interval MUST be a power of 2, so enforce it */
- if (interval < 1) interval = 1;
- ibit = -1;
- while (interval != 0)
- {
- ibit++;
- interval >>= 1;
- }
- /* only allow up to 32768 - i.e. ibit == 15, so limit it */
- if (ibit > 15) ibit = 15;
-
- poller->ibit = ibit;
- poller->func = func;
- poller->data = (void *)data;
- pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
- if (poller_walking)
- just_added_poller++;
- else
- _ecore_poller_next_tick_eval();
- return poller;
+ Ecore_Poller *poller;
+ int ibit;
+
+ if (!func)
+ return NULL;
+ if (interval < 1)
+ interval = 1;
+
+ poller = calloc(1, sizeof(Ecore_Poller));
+ if (!poller)
+ return NULL;
+ ECORE_MAGIC_SET(poller, ECORE_MAGIC_POLLER);
+ /* interval MUST be a power of 2, so enforce it */
+ if (interval < 1)
+ interval = 1;
+ ibit = -1;
+ while (interval != 0) {
+ ibit++;
+ interval >>= 1;
+ }
+ /* only allow up to 32768 - i.e. ibit == 15, so limit it */
+ if (ibit > 15)
+ ibit = 15;
+
+ poller->ibit = ibit;
+ poller->func = func;
+ poller->data = (void *) data;
+ pollers[poller->ibit] =
+ (Ecore_Poller *)
+ eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]),
+ EINA_INLIST_GET(poller));
+ if (poller_walking)
+ just_added_poller++;
+ else
+ _ecore_poller_next_tick_eval();
+ return poller;
}
/**
@@ -323,38 +323,44 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb
* @ingroup Ecore_Poller_Group
*/
EAPI Eina_Bool
-ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval)
+ecore_poller_poller_interval_set(Ecore_Poller * poller, int interval)
{
- int ibit;
-
- if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
- {
- ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
- "ecore_poller_poller_interval_set");
- return EINA_FALSE;
- }
-
- /* interval MUST be a power of 2, so enforce it */
- if (interval < 1) interval = 1;
- ibit = -1;
- while (interval != 0)
- {
- ibit++;
- interval >>= 1;
- }
- /* only allow up to 32768 - i.e. ibit == 15, so limit it */
- if (ibit > 15) ibit = 15;
- /* if interval specified is the same as interval set, return true without wasting time */
- if (poller->ibit == ibit)
- return EINA_TRUE;
- pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
- poller->ibit = ibit;
- pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
- if (poller_walking)
- just_added_poller++;
- else
- _ecore_poller_next_tick_eval();
- return EINA_TRUE;
+ int ibit;
+
+ if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER)) {
+ ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
+ "ecore_poller_poller_interval_set");
+ return EINA_FALSE;
+ }
+
+ /* interval MUST be a power of 2, so enforce it */
+ if (interval < 1)
+ interval = 1;
+ ibit = -1;
+ while (interval != 0) {
+ ibit++;
+ interval >>= 1;
+ }
+ /* only allow up to 32768 - i.e. ibit == 15, so limit it */
+ if (ibit > 15)
+ ibit = 15;
+ /* if interval specified is the same as interval set, return true without wasting time */
+ if (poller->ibit == ibit)
+ return EINA_TRUE;
+ pollers[poller->ibit] =
+ (Ecore_Poller *)
+ eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]),
+ EINA_INLIST_GET(poller));
+ poller->ibit = ibit;
+ pollers[poller->ibit] =
+ (Ecore_Poller *)
+ eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]),
+ EINA_INLIST_GET(poller));
+ if (poller_walking)
+ just_added_poller++;
+ else
+ _ecore_poller_next_tick_eval();
+ return EINA_TRUE;
}
/**
@@ -366,25 +372,22 @@ ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval)
* This returns a poller's polling interval, or 0 on error.
* @ingroup Ecore_Poller_Group
*/
-EAPI int
-ecore_poller_poller_interval_get(Ecore_Poller *poller)
+EAPI int ecore_poller_poller_interval_get(Ecore_Poller * poller)
{
- int ibit, interval = 1;
-
- if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
- {
- ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
- "ecore_poller_poller_interval_get");
- return 0;
- }
-
- ibit = poller->ibit;
- while (ibit != 0)
- {
- ibit--;
- interval <<= 1;
- }
- return interval;
+ int ibit, interval = 1;
+
+ if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER)) {
+ ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
+ "ecore_poller_poller_interval_get");
+ return 0;
+ }
+
+ ibit = poller->ibit;
+ while (ibit != 0) {
+ ibit--;
+ interval <<= 1;
+ }
+ return interval;
}
/**
@@ -397,46 +400,47 @@ ecore_poller_poller_interval_get(Ecore_Poller *poller)
* Note: @p poller must be a valid handle. If the poller function has already
* returned 0, the handle is no longer valid (and does not need to be delete).
*/
-EAPI void *
-ecore_poller_del(Ecore_Poller *poller)
+EAPI void *ecore_poller_del(Ecore_Poller * poller)
{
- void *data;
-
- if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
- {
- ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
- "ecore_poller_del");
- return NULL;
- }
- /* we are walking the poller list - a bad idea to remove from it while
- * walking it, so just flag it as delete_me and come back to it after
- * the loop has finished */
- if (poller_walking > 0)
- {
- poller_delete_count++;
- poller->delete_me = 1;
- return poller->data;
- }
- /* not in loop so safe - delete immediately */
- data = poller->data;
- pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
- free(poller);
- _ecore_poller_next_tick_eval();
- return data;
+ void *data;
+
+ if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER)) {
+ ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
+ "ecore_poller_del");
+ return NULL;
+ }
+ /* we are walking the poller list - a bad idea to remove from it while
+ * walking it, so just flag it as delete_me and come back to it after
+ * the loop has finished */
+ if (poller_walking > 0) {
+ poller_delete_count++;
+ poller->delete_me = 1;
+ return poller->data;
+ }
+ /* not in loop so safe - delete immediately */
+ data = poller->data;
+ pollers[poller->ibit] =
+ (Ecore_Poller *)
+ eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]),
+ EINA_INLIST_GET(poller));
+ free(poller);
+ _ecore_poller_next_tick_eval();
+ return data;
}
-void
-_ecore_poller_shutdown(void)
+void _ecore_poller_shutdown(void)
{
- int i;
- Ecore_Poller *poller;
-
- for (i = 0; i < 15; i++)
- {
- while ((poller = pollers[i]))
- {
- pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i]));
- free(poller);
- }
- }
+ int i;
+ Ecore_Poller *poller;
+
+ for (i = 0; i < 15; i++) {
+ while ((poller = pollers[i])) {
+ pollers[i] =
+ (Ecore_Poller *)
+ eina_inlist_remove(EINA_INLIST_GET(pollers[i]),
+ EINA_INLIST_GET(pollers
+ [i]));
+ free(poller);
+ }
+ }
}
diff --git a/tests/suite/ecore/src/lib/ecore_private.h b/tests/suite/ecore/src/lib/ecore_private.h
index 5f08f8ab51..d487739679 100644
--- a/tests/suite/ecore/src/lib/ecore_private.h
+++ b/tests/suite/ecore/src/lib/ecore_private.h
@@ -1,63 +1,63 @@
#ifndef _ECORE_PRIVATE_H
#define _ECORE_PRIVATE_H
-extern int _ecore_log_dom ;
+extern int _ecore_log_dom;
#ifdef _ECORE_DEFAULT_LOG_DOM
-# undef _ECORE_DEFAULT_LOG_DOM
+#undef _ECORE_DEFAULT_LOG_DOM
#endif
#define _ECORE_DEFAULT_LOG_DOM _ecore_log_dom
#ifdef ECORE_DEFAULT_LOG_COLOR
-# undef ECORE_DEFAULT_LOG_COLOR
+#undef ECORE_DEFAULT_LOG_COLOR
#endif
#define ECORE_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
#ifdef ERR
-# undef ERR
+#undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_ECORE_DEFAULT_LOG_DOM, __VA_ARGS__)
#ifdef DBG
-# undef DBG
+#undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_ECORE_DEFAULT_LOG_DOM, __VA_ARGS__)
#ifdef INF
-# undef INF
+#undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_ECORE_DEFAULT_LOG_DOM, __VA_ARGS__)
#ifdef WRN
-# undef WRN
+#undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_ECORE_DEFAULT_LOG_DOM, __VA_ARGS__)
#ifdef CRIT
-# undef CRIT
+#undef CRIT
#endif
#define CRIT(...) EINA_LOG_DOM_CRIT(_ECORE_DEFAULT_LOG_DOM, __VA_ARGS__)
#ifndef PATH_MAX
-# define PATH_MAX 4096
+#define PATH_MAX 4096
#endif
#ifndef MIN
-# define MIN(x, y) (((x) > (y)) ? (y) : (x))
+#define MIN(x, y) (((x) > (y)) ? (y) : (x))
#endif
#ifndef MAX
-# define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef ABS
-# define ABS(x) ((x) < 0 ? -(x) : (x))
+#define ABS(x) ((x) < 0 ? -(x) : (x))
#endif
#ifndef CLAMP
-# define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
+#define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
#endif
-#define EVAS_FRAME_QUEUING 1 /* for test */
+#define EVAS_FRAME_QUEUING 1 /* for test */
#define READBUFSIZ 65536
@@ -113,81 +113,97 @@ EAPI void ecore_print_warning(const char *function, const char *sparam);
return; \
}
-typedef unsigned int Ecore_Magic;
+typedef unsigned int Ecore_Magic;
-EAPI void _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname);
+EAPI void _ecore_magic_fail(const void *d, Ecore_Magic m,
+ Ecore_Magic req_m, const char *fname);
-void _ecore_time_init(void);
+void _ecore_time_init(void);
-void _ecore_timer_shutdown(void);
-void _ecore_timer_cleanup(void);
-void _ecore_timer_enable_new(void);
-double _ecore_timer_next_get(void);
-int _ecore_timers_exists(void);
-int _ecore_timer_call(double when);
+void _ecore_timer_shutdown(void);
+void _ecore_timer_cleanup(void);
+void _ecore_timer_enable_new(void);
+double _ecore_timer_next_get(void);
+int _ecore_timers_exists(void);
+int _ecore_timer_call(double when);
-void _ecore_idler_shutdown(void);
-int _ecore_idler_call(void);
-int _ecore_idler_exist(void);
+void _ecore_idler_shutdown(void);
+int _ecore_idler_call(void);
+int _ecore_idler_exist(void);
-void _ecore_idle_enterer_shutdown(void);
-void _ecore_idle_enterer_call(void);
-int _ecore_idle_enterer_exist(void);
+void _ecore_idle_enterer_shutdown(void);
+void _ecore_idle_enterer_call(void);
+int _ecore_idle_enterer_exist(void);
-void _ecore_idle_exiter_shutdown(void);
-void _ecore_idle_exiter_call(void);
-int _ecore_idle_exiter_exist(void);
+void _ecore_idle_exiter_shutdown(void);
+void _ecore_idle_exiter_call(void);
+int _ecore_idle_exiter_exist(void);
-void _ecore_event_shutdown(void);
-int _ecore_event_exist(void);
-Ecore_Event *_ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data);
-void _ecore_event_call(void);
+void _ecore_event_shutdown(void);
+int _ecore_event_exist(void);
+Ecore_Event *_ecore_event_add(int type, void *ev, Ecore_End_Cb func_free,
+ void *data);
+void _ecore_event_call(void);
-Ecore_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe *exe);
-void _ecore_exe_doomsday_clock_set(Ecore_Exe *exe, Ecore_Timer *dc);
+Ecore_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe * exe);
+void _ecore_exe_doomsday_clock_set(Ecore_Exe * exe, Ecore_Timer * dc);
-EAPI void *_ecore_event_signal_user_new(void);
-void *_ecore_event_signal_hup_new(void);
-void *_ecore_event_signal_exit_new(void);
-void *_ecore_event_signal_power_new(void);
-void *_ecore_event_signal_realtime_new(void);
+EAPI void *_ecore_event_signal_user_new(void);
+void *_ecore_event_signal_hup_new(void);
+void *_ecore_event_signal_exit_new(void);
+void *_ecore_event_signal_power_new(void);
+void *_ecore_event_signal_realtime_new(void);
-void _ecore_main_shutdown(void);
+void _ecore_main_shutdown(void);
#ifdef _WIN32
-static inline void _ecore_signal_shutdown(void) { }
-static inline void _ecore_signal_init(void) { }
-static inline int _ecore_signal_count_get(void) { return 0; }
-static inline void _ecore_signal_call(void) { }
+static inline void _ecore_signal_shutdown(void)
+{
+}
+
+static inline void _ecore_signal_init(void)
+{
+}
+
+static inline int _ecore_signal_count_get(void)
+{
+ return 0;
+}
+
+static inline void _ecore_signal_call(void)
+{
+}
#else
-void _ecore_signal_shutdown(void);
-void _ecore_signal_init(void);
-int _ecore_signal_count_get(void);
-void _ecore_signal_call(void);
+void _ecore_signal_shutdown(void);
+void _ecore_signal_init(void);
+int _ecore_signal_count_get(void);
+void _ecore_signal_call(void);
#endif
-void _ecore_exe_init(void);
-void _ecore_exe_shutdown(void);
+void _ecore_exe_init(void);
+void _ecore_exe_shutdown(void);
#ifndef _WIN32
-Ecore_Exe *_ecore_exe_find(pid_t pid);
-void *_ecore_exe_event_del_new(void);
-void _ecore_exe_event_del_free(void *data, void *ev);
+Ecore_Exe *_ecore_exe_find(pid_t pid);
+void *_ecore_exe_event_del_new(void);
+void _ecore_exe_event_del_free(void *data, void *ev);
#endif
-void _ecore_animator_shutdown(void);
+void _ecore_animator_shutdown(void);
-void _ecore_poller_shutdown(void);
+void _ecore_poller_shutdown(void);
-EAPI void *_ecore_list2_append (void *in_list, void *in_item);
-EAPI void *_ecore_list2_prepend (void *in_list, void *in_item);
-EAPI void *_ecore_list2_append_relative (void *in_list, void *in_item, void *in_relative);
-EAPI void *_ecore_list2_prepend_relative (void *in_list, void *in_item, void *in_relative);
-EAPI void *_ecore_list2_remove (void *in_list, void *in_item);
-EAPI void *_ecore_list2_find (void *in_list, void *in_item);
+EAPI void *_ecore_list2_append(void *in_list, void *in_item);
+EAPI void *_ecore_list2_prepend(void *in_list, void *in_item);
+EAPI void *_ecore_list2_append_relative(void *in_list, void *in_item,
+ void *in_relative);
+EAPI void *_ecore_list2_prepend_relative(void *in_list, void *in_item,
+ void *in_relative);
+EAPI void *_ecore_list2_remove(void *in_list, void *in_item);
+EAPI void *_ecore_list2_find(void *in_list, void *in_item);
-void _ecore_fps_debug_init(void);
-void _ecore_fps_debug_shutdown(void);
-void _ecore_fps_debug_runtime_add(double t);
+void _ecore_fps_debug_init(void);
+void _ecore_fps_debug_shutdown(void);
+void _ecore_fps_debug_runtime_add(double t);
void _ecore_thread_init(void);
void _ecore_thread_shutdown(void);
@@ -201,7 +217,7 @@ void _ecore_job_shutdown(void);
void _ecore_main_loop_init(void);
void _ecore_main_loop_shutdown(void);
-extern int _ecore_fps_debug;
+extern int _ecore_fps_debug;
extern double _ecore_time_loop_time;
extern Eina_Bool _ecore_glib_always_integrate;
diff --git a/tests/suite/ecore/src/lib/ecore_signal.c b/tests/suite/ecore/src/lib/ecore_signal.c
index 10a4711bed..a3ef01e53a 100644
--- a/tests/suite/ecore/src/lib/ecore_signal.c
+++ b/tests/suite/ecore/src/lib/ecore_signal.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdio.h>
@@ -17,29 +17,39 @@
/* valgrind in some versions/setups uses SIGRT's... hmmm */
#undef SIGRTMIN
-typedef void (*Signal_Handler)(int sig, siginfo_t *si, void *foo);
+typedef void (*Signal_Handler) (int sig, siginfo_t * si, void *foo);
static void _ecore_signal_callback_set(int sig, Signal_Handler func);
-static void _ecore_signal_callback_ignore(int sig, siginfo_t *si, void *foo);
-static void _ecore_signal_callback_sigchld(int sig, siginfo_t *si, void *foo);
-static void _ecore_signal_callback_sigusr1(int sig, siginfo_t *si, void *foo);
-static void _ecore_signal_callback_sigusr2(int sig, siginfo_t *si, void *foo);
-static void _ecore_signal_callback_sighup(int sig, siginfo_t *si, void *foo);
-static void _ecore_signal_callback_sigquit(int sig, siginfo_t *si, void *foo);
-static void _ecore_signal_callback_sigint(int sig, siginfo_t *si, void *foo);
-static void _ecore_signal_callback_sigterm(int sig, siginfo_t *si, void *foo);
+static void _ecore_signal_callback_ignore(int sig, siginfo_t * si,
+ void *foo);
+static void _ecore_signal_callback_sigchld(int sig, siginfo_t * si,
+ void *foo);
+static void _ecore_signal_callback_sigusr1(int sig, siginfo_t * si,
+ void *foo);
+static void _ecore_signal_callback_sigusr2(int sig, siginfo_t * si,
+ void *foo);
+static void _ecore_signal_callback_sighup(int sig, siginfo_t * si,
+ void *foo);
+static void _ecore_signal_callback_sigquit(int sig, siginfo_t * si,
+ void *foo);
+static void _ecore_signal_callback_sigint(int sig, siginfo_t * si,
+ void *foo);
+static void _ecore_signal_callback_sigterm(int sig, siginfo_t * si,
+ void *foo);
#ifdef SIGPWR
-static void _ecore_signal_callback_sigpwr(int sig, siginfo_t *si, void *foo);
+static void _ecore_signal_callback_sigpwr(int sig, siginfo_t * si,
+ void *foo);
#endif
#ifdef SIGRTMIN
-static void _ecore_signal_callback_sigrt(int sig, siginfo_t *si, void *foo);
+static void _ecore_signal_callback_sigrt(int sig, siginfo_t * si,
+ void *foo);
#endif
static Eina_Bool _ecore_signal_exe_exit_delay(void *data);
//#define MAXSIGQ 256 // 32k
-#define MAXSIGQ 64 // 8k
+#define MAXSIGQ 64 // 8k
static volatile sig_atomic_t sig_count = 0;
static volatile sig_atomic_t sigchld_count = 0;
@@ -70,551 +80,545 @@ static volatile siginfo_t sigpwr_info[MAXSIGQ];
static volatile siginfo_t *sigrt_info[MAXSIGQ];
#endif
-void
-_ecore_signal_shutdown(void)
+void _ecore_signal_shutdown(void)
{
#ifdef SIGRTMIN
- int i, num = SIGRTMAX - SIGRTMIN;
+ int i, num = SIGRTMAX - SIGRTMIN;
#endif
- _ecore_signal_callback_set(SIGPIPE, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGALRM, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGCHLD, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGUSR1, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGUSR2, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGHUP, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGQUIT, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGINT, (Signal_Handler) SIG_DFL);
- _ecore_signal_callback_set(SIGTERM, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGPIPE, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGALRM, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGCHLD, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGUSR1, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGUSR2, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGHUP, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGQUIT, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGINT, (Signal_Handler) SIG_DFL);
+ _ecore_signal_callback_set(SIGTERM, (Signal_Handler) SIG_DFL);
#ifdef SIGPWR
- _ecore_signal_callback_set(SIGPWR, (Signal_Handler) SIG_DFL);
- sigpwr_count = 0;
+ _ecore_signal_callback_set(SIGPWR, (Signal_Handler) SIG_DFL);
+ sigpwr_count = 0;
#endif
- sigchld_count = 0;
- sigusr1_count = 0;
- sigusr2_count = 0;
- sighup_count = 0;
- sigquit_count = 0;
- sigint_count = 0;
- sigterm_count = 0;
- sig_count = 0;
+ sigchld_count = 0;
+ sigusr1_count = 0;
+ sigusr2_count = 0;
+ sighup_count = 0;
+ sigquit_count = 0;
+ sigint_count = 0;
+ sigterm_count = 0;
+ sig_count = 0;
#ifdef SIGRTMIN
- for (i = 0; i < num; i++)
- {
- _ecore_signal_callback_set(SIGRTMIN + i, (Signal_Handler) SIG_DFL);
- sigrt_count[i] = 0;
- }
-
- if (sigrt_count)
- {
- free((sig_atomic_t *) sigrt_count);
- sigrt_count = NULL;
- }
-
- for (i = 0; i < MAXSIGQ; i++)
- {
- if (sigrt_info[i])
- {
- free((siginfo_t *) sigrt_info[i]);
- sigrt_info[i] = NULL;
- }
- }
+ for (i = 0; i < num; i++) {
+ _ecore_signal_callback_set(SIGRTMIN + i,
+ (Signal_Handler) SIG_DFL);
+ sigrt_count[i] = 0;
+ }
+
+ if (sigrt_count) {
+ free((sig_atomic_t *) sigrt_count);
+ sigrt_count = NULL;
+ }
+
+ for (i = 0; i < MAXSIGQ; i++) {
+ if (sigrt_info[i]) {
+ free((siginfo_t *) sigrt_info[i]);
+ sigrt_info[i] = NULL;
+ }
+ }
#endif
}
-void
-_ecore_signal_init(void)
+void _ecore_signal_init(void)
{
#ifdef SIGRTMIN
- int i, num = SIGRTMAX - SIGRTMIN;
+ int i, num = SIGRTMAX - SIGRTMIN;
#endif
- _ecore_signal_callback_set(SIGPIPE, _ecore_signal_callback_ignore);
- _ecore_signal_callback_set(SIGALRM, _ecore_signal_callback_ignore);
- _ecore_signal_callback_set(SIGCHLD, _ecore_signal_callback_sigchld);
- _ecore_signal_callback_set(SIGUSR1, _ecore_signal_callback_sigusr1);
- _ecore_signal_callback_set(SIGUSR2, _ecore_signal_callback_sigusr2);
- _ecore_signal_callback_set(SIGHUP, _ecore_signal_callback_sighup);
- _ecore_signal_callback_set(SIGQUIT, _ecore_signal_callback_sigquit);
- _ecore_signal_callback_set(SIGINT, _ecore_signal_callback_sigint);
- _ecore_signal_callback_set(SIGTERM, _ecore_signal_callback_sigterm);
+ _ecore_signal_callback_set(SIGPIPE, _ecore_signal_callback_ignore);
+ _ecore_signal_callback_set(SIGALRM, _ecore_signal_callback_ignore);
+ _ecore_signal_callback_set(SIGCHLD,
+ _ecore_signal_callback_sigchld);
+ _ecore_signal_callback_set(SIGUSR1,
+ _ecore_signal_callback_sigusr1);
+ _ecore_signal_callback_set(SIGUSR2,
+ _ecore_signal_callback_sigusr2);
+ _ecore_signal_callback_set(SIGHUP, _ecore_signal_callback_sighup);
+ _ecore_signal_callback_set(SIGQUIT,
+ _ecore_signal_callback_sigquit);
+ _ecore_signal_callback_set(SIGINT, _ecore_signal_callback_sigint);
+ _ecore_signal_callback_set(SIGTERM,
+ _ecore_signal_callback_sigterm);
#ifdef SIGPWR
- _ecore_signal_callback_set(SIGPWR, _ecore_signal_callback_sigpwr);
+ _ecore_signal_callback_set(SIGPWR, _ecore_signal_callback_sigpwr);
#endif
#ifdef SIGRTMIN
- sigrt_count = calloc(1, sizeof(sig_atomic_t) * num);
- assert(sigrt_count);
+ sigrt_count = calloc(1, sizeof(sig_atomic_t) * num);
+ assert(sigrt_count);
- for (i = 0; i < MAXSIGQ; i++)
- {
- sigrt_info[i] = calloc(1, sizeof(siginfo_t) * num);
- assert(sigrt_info[i]);
- }
+ for (i = 0; i < MAXSIGQ; i++) {
+ sigrt_info[i] = calloc(1, sizeof(siginfo_t) * num);
+ assert(sigrt_info[i]);
+ }
- for (i = 0; i < num; i++)
- _ecore_signal_callback_set(SIGRTMIN + i, _ecore_signal_callback_sigrt);
+ for (i = 0; i < num; i++)
+ _ecore_signal_callback_set(SIGRTMIN + i,
+ _ecore_signal_callback_sigrt);
#endif
}
-int
-_ecore_signal_count_get(void)
+int _ecore_signal_count_get(void)
{
- return sig_count;
+ return sig_count;
}
-void
-_ecore_signal_call(void)
+void _ecore_signal_call(void)
{
#ifdef SIGRTMIN
- int i, num = SIGRTMAX - SIGRTMIN;
+ int i, num = SIGRTMAX - SIGRTMIN;
#endif
- volatile sig_atomic_t n;
- sigset_t oldset, newset;
-
- if (sig_count == 0) return;
- sigemptyset(&newset);
- sigaddset(&newset, SIGPIPE);
- sigaddset(&newset, SIGALRM);
- sigaddset(&newset, SIGCHLD);
- sigaddset(&newset, SIGUSR1);
- sigaddset(&newset, SIGUSR2);
- sigaddset(&newset, SIGHUP);
- sigaddset(&newset, SIGQUIT);
- sigaddset(&newset, SIGINT);
- sigaddset(&newset, SIGTERM);
+ volatile sig_atomic_t n;
+ sigset_t oldset, newset;
+
+ if (sig_count == 0)
+ return;
+ sigemptyset(&newset);
+ sigaddset(&newset, SIGPIPE);
+ sigaddset(&newset, SIGALRM);
+ sigaddset(&newset, SIGCHLD);
+ sigaddset(&newset, SIGUSR1);
+ sigaddset(&newset, SIGUSR2);
+ sigaddset(&newset, SIGHUP);
+ sigaddset(&newset, SIGQUIT);
+ sigaddset(&newset, SIGINT);
+ sigaddset(&newset, SIGTERM);
#ifdef SIGPWR
- sigaddset(&newset, SIGPWR);
+ sigaddset(&newset, SIGPWR);
#endif
#ifdef SIGRTMIN
- for (i = 0; i < num; i++)
- sigaddset(&newset, SIGRTMIN + i);
+ for (i = 0; i < num; i++)
+ sigaddset(&newset, SIGRTMIN + i);
#endif
- sigprocmask(SIG_BLOCK, &newset, &oldset);
- if (sigchld_count > MAXSIGQ)
- WRN("%i SIGCHLD in queue. max queue size %i. losing "
- "siginfo for extra signals.", sigchld_count, MAXSIGQ);
- for (n = 0; n < sigchld_count; n++)
- {
- pid_t pid;
- int status;
-
- while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
- {
- Ecore_Exe_Event_Del *e;
-
- /* FIXME: If this process is set respawn, respawn with a suitable backoff
- * period for those that need too much respawning.
- */
- e = _ecore_exe_event_del_new();
- if (e)
- {
- if (WIFEXITED(status))
- {
- e->exit_code = WEXITSTATUS(status);
- e->exited = 1;
- }
- else if (WIFSIGNALED(status))
- {
- e->exit_signal = WTERMSIG(status);
- e->signalled = 1;
- }
- e->pid = pid;
- e->exe = _ecore_exe_find(pid);
-
- if ((n < MAXSIGQ) && (sigchld_info[n].si_signo))
- e->data = sigchld_info[n]; /* No need to clone this. */
-
- if ((e->exe) && (ecore_exe_flags_get(e->exe) & (ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR)))
- {
- /* We want to report the Last Words of the exe, so delay this event.
- * This is twice as relevant for stderr.
- * There are three possibilities here -
- * 1 There are no Last Words.
- * 2 There are Last Words, they are not ready to be read.
- * 3 There are Last Words, they are ready to be read.
- *
- * For 1 we don't want to delay, for 3 we want to delay.
- * 2 is the problem. If we check for data now and there
- * is none, then there is no way to differentiate 1 and 2.
- * If we don't delay, we may loose data, but if we do delay,
- * there may not be data and the exit event never gets sent.
- *
- * Any way you look at it, there has to be some time passed
- * before the exit event gets sent. So the strategy here is
- * to setup a timer event that will send the exit event after
- * an arbitrary, but brief, time.
- *
- * This is probably paranoid, for the less paraniod, we could
- * check to see for Last Words, and only delay if there are any.
- * This has it's own set of problems.
- */
- Ecore_Timer *doomsday_clock;
-
- doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe);
- IF_FN_DEL(ecore_timer_del, doomsday_clock);
- _ecore_exe_doomsday_clock_set(e->exe, ecore_timer_add(0.1, _ecore_signal_exe_exit_delay, e));
- }
- else
- {
- _ecore_event_add(ECORE_EXE_EVENT_DEL, e,
- _ecore_exe_event_del_free, NULL);
- }
- }
- }
- sig_count--;
- }
- sigchld_count = 0;
-
- if (sigusr1_count > MAXSIGQ)
- WRN("%i SIGUSR1 in queue. max queue size %i. losing "
- "siginfo for extra signals.", sigusr1_count, MAXSIGQ);
- for (n = 0; n < sigusr1_count; n++)
- {
- Ecore_Event_Signal_User *e;
-
- e = _ecore_event_signal_user_new();
- if (e)
- {
- e->number = 1;
-
- if ((n < MAXSIGQ) && (sigusr1_info[n].si_signo))
- e->data = sigusr1_info[n];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL);
- }
- sig_count--;
- }
- sigusr1_count = 0;
-
- if (sigusr2_count > MAXSIGQ)
- WRN("%i SIGUSR2 in queue. max queue size %i. losing "
- "siginfo for extra signals.", sigusr2_count, MAXSIGQ);
- for (n = 0; n < sigusr2_count; n++)
- {
- Ecore_Event_Signal_User *e;
-
- e = _ecore_event_signal_user_new();
- if (e)
- {
- e->number = 2;
-
- if ((n < MAXSIGQ) && (sigusr2_info[n].si_signo))
- e->data = sigusr2_info[n];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL);
- }
- sig_count--;
- }
- sigusr2_count = 0;
-
- if (sighup_count > MAXSIGQ)
- WRN("%i SIGHUP in queue. max queue size %i. losing "
- "siginfo for extra signals.", sighup_count, MAXSIGQ);
- for (n = 0; n < sighup_count; n++)
- {
- Ecore_Event_Signal_Hup *e;
-
- e = _ecore_event_signal_hup_new();
- if (e)
- {
- if ((n < MAXSIGQ) && (sighup_info[n].si_signo))
- e->data = sighup_info[n];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_HUP, e, NULL, NULL);
- }
- sig_count--;
- }
- sighup_count = 0;
-
- if (sigquit_count > MAXSIGQ)
- WRN("%i SIGQUIT in queue. max queue size %i. losing "
- "siginfo for extra signals.", sigquit_count, MAXSIGQ);
- for (n = 0; n < sigquit_count; n++)
- {
- Ecore_Event_Signal_Exit *e;
-
- e = _ecore_event_signal_exit_new();
- if (e)
- {
- e->quit = 1;
-
- if ((n < MAXSIGQ) && (sigquit_info[n].si_signo))
- e->data = sigquit_info[n];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL);
- }
- sig_count--;
- }
- sigquit_count = 0;
-
- if (sigint_count > MAXSIGQ)
- WRN("%i SIGINT in queue. max queue size %i. losing "
- "siginfo for extra signals.", sigint_count, MAXSIGQ);
- for (n = 0; n < sigint_count; n++)
- {
- Ecore_Event_Signal_Exit *e;
-
- e = _ecore_event_signal_exit_new();
- if (e)
- {
- e->interrupt = 1;
-
- if ((n < MAXSIGQ) && (sigint_info[n].si_signo))
- e->data = sigint_info[n];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL);
- }
- sig_count--;
- }
- sigint_count = 0;
-
- if (sigterm_count > MAXSIGQ)
- WRN("%i SIGTERM in queue. max queue size %i. losing "
- "siginfo for extra signals.", sigterm_count, MAXSIGQ);
- for (n = 0; n < sigterm_count; n++)
- {
- Ecore_Event_Signal_Exit *e;
-
- e = _ecore_event_signal_exit_new();
- if (e)
- {
- e->terminate = 1;
-
- if ((n < MAXSIGQ) && (sigterm_info[n].si_signo))
- e->data = sigterm_info[n];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL);
- }
- sig_count--;
- }
- sigterm_count = 0;
+ sigprocmask(SIG_BLOCK, &newset, &oldset);
+ if (sigchld_count > MAXSIGQ)
+ WRN("%i SIGCHLD in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sigchld_count, MAXSIGQ);
+ for (n = 0; n < sigchld_count; n++) {
+ pid_t pid;
+ int status;
+
+ while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
+ Ecore_Exe_Event_Del *e;
+
+ /* FIXME: If this process is set respawn, respawn with a suitable backoff
+ * period for those that need too much respawning.
+ */
+ e = _ecore_exe_event_del_new();
+ if (e) {
+ if (WIFEXITED(status)) {
+ e->exit_code = WEXITSTATUS(status);
+ e->exited = 1;
+ } else if (WIFSIGNALED(status)) {
+ e->exit_signal = WTERMSIG(status);
+ e->signalled = 1;
+ }
+ e->pid = pid;
+ e->exe = _ecore_exe_find(pid);
+
+ if ((n < MAXSIGQ)
+ && (sigchld_info[n].si_signo))
+ e->data = sigchld_info[n]; /* No need to clone this. */
+
+ if ((e->exe)
+ && (ecore_exe_flags_get(e->exe) &
+ (ECORE_EXE_PIPE_READ |
+ ECORE_EXE_PIPE_ERROR))) {
+ /* We want to report the Last Words of the exe, so delay this event.
+ * This is twice as relevant for stderr.
+ * There are three possibilities here -
+ * 1 There are no Last Words.
+ * 2 There are Last Words, they are not ready to be read.
+ * 3 There are Last Words, they are ready to be read.
+ *
+ * For 1 we don't want to delay, for 3 we want to delay.
+ * 2 is the problem. If we check for data now and there
+ * is none, then there is no way to differentiate 1 and 2.
+ * If we don't delay, we may loose data, but if we do delay,
+ * there may not be data and the exit event never gets sent.
+ *
+ * Any way you look at it, there has to be some time passed
+ * before the exit event gets sent. So the strategy here is
+ * to setup a timer event that will send the exit event after
+ * an arbitrary, but brief, time.
+ *
+ * This is probably paranoid, for the less paraniod, we could
+ * check to see for Last Words, and only delay if there are any.
+ * This has it's own set of problems.
+ */
+ Ecore_Timer *doomsday_clock;
+
+ doomsday_clock =
+ _ecore_exe_doomsday_clock_get
+ (e->exe);
+ IF_FN_DEL(ecore_timer_del,
+ doomsday_clock);
+ _ecore_exe_doomsday_clock_set(e->
+ exe,
+ ecore_timer_add
+ (0.1,
+ _ecore_signal_exe_exit_delay,
+ e));
+ } else {
+ _ecore_event_add
+ (ECORE_EXE_EVENT_DEL, e,
+ _ecore_exe_event_del_free,
+ NULL);
+ }
+ }
+ }
+ sig_count--;
+ }
+ sigchld_count = 0;
+
+ if (sigusr1_count > MAXSIGQ)
+ WRN("%i SIGUSR1 in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sigusr1_count, MAXSIGQ);
+ for (n = 0; n < sigusr1_count; n++) {
+ Ecore_Event_Signal_User *e;
+
+ e = _ecore_event_signal_user_new();
+ if (e) {
+ e->number = 1;
+
+ if ((n < MAXSIGQ) && (sigusr1_info[n].si_signo))
+ e->data = sigusr1_info[n];
+
+ ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sigusr1_count = 0;
+
+ if (sigusr2_count > MAXSIGQ)
+ WRN("%i SIGUSR2 in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sigusr2_count, MAXSIGQ);
+ for (n = 0; n < sigusr2_count; n++) {
+ Ecore_Event_Signal_User *e;
+
+ e = _ecore_event_signal_user_new();
+ if (e) {
+ e->number = 2;
+
+ if ((n < MAXSIGQ) && (sigusr2_info[n].si_signo))
+ e->data = sigusr2_info[n];
+
+ ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sigusr2_count = 0;
+
+ if (sighup_count > MAXSIGQ)
+ WRN("%i SIGHUP in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sighup_count, MAXSIGQ);
+ for (n = 0; n < sighup_count; n++) {
+ Ecore_Event_Signal_Hup *e;
+
+ e = _ecore_event_signal_hup_new();
+ if (e) {
+ if ((n < MAXSIGQ) && (sighup_info[n].si_signo))
+ e->data = sighup_info[n];
+
+ ecore_event_add(ECORE_EVENT_SIGNAL_HUP, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sighup_count = 0;
+
+ if (sigquit_count > MAXSIGQ)
+ WRN("%i SIGQUIT in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sigquit_count, MAXSIGQ);
+ for (n = 0; n < sigquit_count; n++) {
+ Ecore_Event_Signal_Exit *e;
+
+ e = _ecore_event_signal_exit_new();
+ if (e) {
+ e->quit = 1;
+
+ if ((n < MAXSIGQ) && (sigquit_info[n].si_signo))
+ e->data = sigquit_info[n];
+
+ ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sigquit_count = 0;
+
+ if (sigint_count > MAXSIGQ)
+ WRN("%i SIGINT in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sigint_count, MAXSIGQ);
+ for (n = 0; n < sigint_count; n++) {
+ Ecore_Event_Signal_Exit *e;
+
+ e = _ecore_event_signal_exit_new();
+ if (e) {
+ e->interrupt = 1;
+
+ if ((n < MAXSIGQ) && (sigint_info[n].si_signo))
+ e->data = sigint_info[n];
+
+ ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sigint_count = 0;
+
+ if (sigterm_count > MAXSIGQ)
+ WRN("%i SIGTERM in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sigterm_count, MAXSIGQ);
+ for (n = 0; n < sigterm_count; n++) {
+ Ecore_Event_Signal_Exit *e;
+
+ e = _ecore_event_signal_exit_new();
+ if (e) {
+ e->terminate = 1;
+
+ if ((n < MAXSIGQ) && (sigterm_info[n].si_signo))
+ e->data = sigterm_info[n];
+
+ ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sigterm_count = 0;
#ifdef SIGPWR
- if (sigpwr_count > MAXSIGQ)
- WRN("%i SIGPWR in queue. max queue size %i. losing "
- "siginfo for extra signals.", sigpwr_count, MAXSIGQ);
- for (n = 0; n < sigpwr_count; n++)
- {
- Ecore_Event_Signal_Power *e;
-
- e = _ecore_event_signal_power_new();
- if (e)
- {
- if ((n < MAXSIGQ) && (sigpwr_info[n].si_signo))
- e->data = sigpwr_info[n];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_POWER, e, NULL, NULL);
- }
- sig_count--;
- }
- sigpwr_count = 0;
+ if (sigpwr_count > MAXSIGQ)
+ WRN("%i SIGPWR in queue. max queue size %i. losing "
+ "siginfo for extra signals.", sigpwr_count, MAXSIGQ);
+ for (n = 0; n < sigpwr_count; n++) {
+ Ecore_Event_Signal_Power *e;
+
+ e = _ecore_event_signal_power_new();
+ if (e) {
+ if ((n < MAXSIGQ) && (sigpwr_info[n].si_signo))
+ e->data = sigpwr_info[n];
+
+ ecore_event_add(ECORE_EVENT_SIGNAL_POWER, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sigpwr_count = 0;
#endif
#ifdef SIGRTMIN
- for (i = 0; i < num; i++)
- {
- if (sigrt_count[i] > MAXSIGQ)
- WRN("%i SIGRT%i in queue. max queue size %i. losing "
- "siginfo for extra signals.", i + 1, sigrt_count[i], MAXSIGQ);
- for (n = 0; n < sigrt_count[i]; n++)
- {
- Ecore_Event_Signal_Realtime *e;
-
- if ((e = _ecore_event_signal_realtime_new()))
- {
- e->num = i;
-
- if ((n < MAXSIGQ) && (sigrt_info[n][i].si_signo))
- e->data = sigrt_info[n][i];
-
- ecore_event_add(ECORE_EVENT_SIGNAL_REALTIME, e, NULL, NULL);
- }
- sig_count--;
- }
- sigrt_count[i] = 0;
- }
+ for (i = 0; i < num; i++) {
+ if (sigrt_count[i] > MAXSIGQ)
+ WRN("%i SIGRT%i in queue. max queue size %i. losing " "siginfo for extra signals.", i + 1, sigrt_count[i], MAXSIGQ);
+ for (n = 0; n < sigrt_count[i]; n++) {
+ Ecore_Event_Signal_Realtime *e;
+
+ if ((e = _ecore_event_signal_realtime_new())) {
+ e->num = i;
+
+ if ((n < MAXSIGQ)
+ && (sigrt_info[n][i].si_signo))
+ e->data = sigrt_info[n][i];
+
+ ecore_event_add
+ (ECORE_EVENT_SIGNAL_REALTIME, e, NULL,
+ NULL);
+ }
+ sig_count--;
+ }
+ sigrt_count[i] = 0;
+ }
#endif
- sigprocmask(SIG_SETMASK, &oldset, NULL);
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
}
-static void
-_ecore_signal_callback_set(int sig, Signal_Handler func)
+static void _ecore_signal_callback_set(int sig, Signal_Handler func)
{
- struct sigaction sa;
+ struct sigaction sa;
- sa.sa_sigaction = func;
- sa.sa_flags = SA_RESTART | SA_SIGINFO;
- sigemptyset(&sa.sa_mask);
- sigaction(sig, &sa, NULL);
+ sa.sa_sigaction = func;
+ sa.sa_flags = SA_RESTART | SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+ sigaction(sig, &sa, NULL);
}
static void
-_ecore_signal_callback_ignore(int sig __UNUSED__, siginfo_t *si __UNUSED__, void *foo __UNUSED__)
+_ecore_signal_callback_ignore(int sig __UNUSED__,
+ siginfo_t * si __UNUSED__,
+ void *foo __UNUSED__)
{
}
static void
-_ecore_signal_callback_sigchld(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigchld(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigchld_info[n] = *si;
- else
- sigchld_info[n].si_signo = 0;
- }
-
- sigchld_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigchld_info[n] = *si;
+ else
+ sigchld_info[n].si_signo = 0;
+ }
+
+ sigchld_count++;
+ sig_count++;
}
static void
-_ecore_signal_callback_sigusr1(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigusr1(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigusr1_info[n] = *si;
- else
- sigusr1_info[n].si_signo = 0;
- }
- sigusr1_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigusr1_info[n] = *si;
+ else
+ sigusr1_info[n].si_signo = 0;
+ }
+ sigusr1_count++;
+ sig_count++;
}
static void
-_ecore_signal_callback_sigusr2(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigusr2(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigusr2_info[n] = *si;
- else
- sigusr2_info[n].si_signo = 0;
- }
- sigusr2_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigusr2_info[n] = *si;
+ else
+ sigusr2_info[n].si_signo = 0;
+ }
+ sigusr2_count++;
+ sig_count++;
}
static void
-_ecore_signal_callback_sighup(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sighup(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sighup_info[n] = *si;
- else
- sighup_info[n].si_signo = 0;
- }
- sighup_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sighup_info[n] = *si;
+ else
+ sighup_info[n].si_signo = 0;
+ }
+ sighup_count++;
+ sig_count++;
}
static void
-_ecore_signal_callback_sigquit(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigquit(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigquit_info[n] = *si;
- else
- sigquit_info[n].si_signo = 0;
- }
- sigquit_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigquit_info[n] = *si;
+ else
+ sigquit_info[n].si_signo = 0;
+ }
+ sigquit_count++;
+ sig_count++;
}
static void
-_ecore_signal_callback_sigint(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigint(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigint_info[n] = *si;
- else
- sigint_info[n].si_signo = 0;
- }
- sigint_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigint_info[n] = *si;
+ else
+ sigint_info[n].si_signo = 0;
+ }
+ sigint_count++;
+ sig_count++;
}
static void
-_ecore_signal_callback_sigterm(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigterm(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigterm_info[n] = *si;
- else
- sigterm_info[n].si_signo = 0;
- }
- sigterm_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigterm_info[n] = *si;
+ else
+ sigterm_info[n].si_signo = 0;
+ }
+ sigterm_count++;
+ sig_count++;
}
#ifdef SIGPWR
static void
-_ecore_signal_callback_sigpwr(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigpwr(int sig __UNUSED__, siginfo_t * si,
+ void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigpwr_info[n] = *si;
- else
- sigpwr_info[n].si_signo = 0;
- }
- sigpwr_count++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigpwr_info[n] = *si;
+ else
+ sigpwr_info[n].si_signo = 0;
+ }
+ sigpwr_count++;
+ sig_count++;
}
#endif
#ifdef SIGRTMIN
static void
-_ecore_signal_callback_sigrt(int sig, siginfo_t *si, void *foo __UNUSED__)
+_ecore_signal_callback_sigrt(int sig, siginfo_t * si, void *foo __UNUSED__)
{
- volatile sig_atomic_t n;
- n = sigchld_count;
- if (n < MAXSIGQ)
- {
- if (si)
- sigrt_info[n][sig - SIGRTMIN] = *si;
- else
- sigrt_info[n][sig - SIGRTMIN].si_signo = 0;
- }
- sigrt_count[sig - SIGRTMIN]++;
- sig_count++;
+ volatile sig_atomic_t n;
+ n = sigchld_count;
+ if (n < MAXSIGQ) {
+ if (si)
+ sigrt_info[n][sig - SIGRTMIN] = *si;
+ else
+ sigrt_info[n][sig - SIGRTMIN].si_signo = 0;
+ }
+ sigrt_count[sig - SIGRTMIN]++;
+ sig_count++;
}
#endif
-static Eina_Bool
-_ecore_signal_exe_exit_delay(void *data)
+static Eina_Bool _ecore_signal_exe_exit_delay(void *data)
{
- Ecore_Exe_Event_Del *e;
-
- e = data;
- if (e)
- {
- _ecore_exe_doomsday_clock_set(e->exe, NULL);
- _ecore_event_add(ECORE_EXE_EVENT_DEL, e,
- _ecore_exe_event_del_free, NULL);
- }
- return ECORE_CALLBACK_CANCEL;
+ Ecore_Exe_Event_Del *e;
+
+ e = data;
+ if (e) {
+ _ecore_exe_doomsday_clock_set(e->exe, NULL);
+ _ecore_event_add(ECORE_EXE_EVENT_DEL, e,
+ _ecore_exe_event_del_free, NULL);
+ }
+ return ECORE_CALLBACK_CANCEL;
}
diff --git a/tests/suite/ecore/src/lib/ecore_thread.c b/tests/suite/ecore/src/lib/ecore_thread.c
index c8a5daf190..27a924f7e5 100644
--- a/tests/suite/ecore/src/lib/ecore_thread.c
+++ b/tests/suite/ecore/src/lib/ecore_thread.c
@@ -1,24 +1,24 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#ifdef EFL_HAVE_PTHREAD
-# include <pthread.h>
-# ifdef __linux__
-# ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-# endif
-# include <sched.h>
-# include <sys/time.h>
-# include <sys/resource.h>
-# include <unistd.h>
-# include <sys/syscall.h>
-# include <errno.h>
-# endif
+#include <pthread.h>
+#ifdef __linux__
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#include <sched.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <errno.h>
+#endif
#endif
#include "Ecore.h"
@@ -26,50 +26,47 @@
typedef struct _Ecore_Pthread_Worker Ecore_Pthread_Worker;
typedef struct _Ecore_Pthread Ecore_Pthread;
-typedef struct _Ecore_Thread_Data Ecore_Thread_Data;
+typedef struct _Ecore_Thread_Data Ecore_Thread_Data;
-struct _Ecore_Thread_Data
-{
- void *data;
- Eina_Free_Cb cb;
+struct _Ecore_Thread_Data {
+ void *data;
+ Eina_Free_Cb cb;
};
-struct _Ecore_Pthread_Worker
-{
- union {
- struct {
- Ecore_Cb func_blocking;
- } short_run;
- struct {
- Ecore_Thread_Heavy_Cb func_heavy;
- Ecore_Thread_Notify_Cb func_notify;
- Ecore_Pipe *notify;
- } feedback_run;
- } u;
-
- Ecore_Cb func_cancel;
- Ecore_Cb func_end;
+struct _Ecore_Pthread_Worker {
+ union {
+ struct {
+ Ecore_Cb func_blocking;
+ } short_run;
+ struct {
+ Ecore_Thread_Heavy_Cb func_heavy;
+ Ecore_Thread_Notify_Cb func_notify;
+ Ecore_Pipe *notify;
+ } feedback_run;
+ } u;
+
+ Ecore_Cb func_cancel;
+ Ecore_Cb func_end;
#ifdef EFL_HAVE_PTHREAD
- pthread_t self;
- Eina_Hash *hash;
- pthread_cond_t cond;
- pthread_mutex_t mutex;
+ pthread_t self;
+ Eina_Hash *hash;
+ pthread_cond_t cond;
+ pthread_mutex_t mutex;
#endif
-
- const void *data;
-
- Eina_Bool cancel : 1;
- Eina_Bool feedback_run : 1;
+
+ const void *data;
+
+ Eina_Bool cancel:1;
+ Eina_Bool feedback_run:1;
};
#ifdef EFL_HAVE_PTHREAD
typedef struct _Ecore_Pthread_Data Ecore_Pthread_Data;
-struct _Ecore_Pthread_Data
-{
- Ecore_Pipe *p;
- void *data;
- pthread_t thread;
+struct _Ecore_Pthread_Data {
+ Ecore_Pipe *p;
+ void *data;
+ pthread_t thread;
};
#endif
@@ -83,303 +80,316 @@ static Eina_List *_ecore_active_job_threads = NULL;
static Eina_List *_ecore_pending_job_threads = NULL;
static Eina_List *_ecore_pending_job_threads_feedback = NULL;
static Ecore_Event_Handler *del_handler = NULL;
-static pthread_mutex_t _ecore_pending_job_threads_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t _ecore_pending_job_threads_mutex =
+ PTHREAD_MUTEX_INITIALIZER;
static Eina_Hash *_ecore_thread_global_hash = NULL;
-static pthread_rwlock_t _ecore_thread_global_hash_lock = PTHREAD_RWLOCK_INITIALIZER;
-static pthread_mutex_t _ecore_thread_global_hash_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t _ecore_thread_global_hash_cond = PTHREAD_COND_INITIALIZER;
+static pthread_rwlock_t _ecore_thread_global_hash_lock =
+ PTHREAD_RWLOCK_INITIALIZER;
+static pthread_mutex_t _ecore_thread_global_hash_mutex =
+ PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t _ecore_thread_global_hash_cond =
+ PTHREAD_COND_INITIALIZER;
static pthread_t main_loop_thread;
static Eina_Bool have_main_loop_thread = 0;
-static void
-_ecore_thread_data_free(void *data)
+static void _ecore_thread_data_free(void *data)
{
- Ecore_Thread_Data *d = data;
+ Ecore_Thread_Data *d = data;
- if (d->cb) d->cb(d->data);
- free(d);
+ if (d->cb)
+ d->cb(d->data);
+ free(d);
}
-static void
-_ecore_thread_pipe_free(void *data __UNUSED__, void *event)
+static void _ecore_thread_pipe_free(void *data __UNUSED__, void *event)
{
- Ecore_Pipe *p = event;
+ Ecore_Pipe *p = event;
- ecore_pipe_del(p);
+ ecore_pipe_del(p);
}
static Eina_Bool
-_ecore_thread_pipe_del(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
+_ecore_thread_pipe_del(void *data __UNUSED__, int type __UNUSED__,
+ void *event __UNUSED__)
{
- /* This is a hack to delay pipe destruction until we are out of its internal loop. */
- return ECORE_CALLBACK_CANCEL;
+ /* This is a hack to delay pipe destruction until we are out of its internal loop. */
+ return ECORE_CALLBACK_CANCEL;
}
-static void
-_ecore_thread_end(Ecore_Pthread_Data *pth)
+static void _ecore_thread_end(Ecore_Pthread_Data * pth)
{
- Ecore_Pipe *p;
+ Ecore_Pipe *p;
- if (pthread_join(pth->thread, (void **) &p) != 0)
- return ;
+ if (pthread_join(pth->thread, (void **) &p) != 0)
+ return;
- _ecore_active_job_threads = eina_list_remove(_ecore_active_job_threads, pth);
+ _ecore_active_job_threads =
+ eina_list_remove(_ecore_active_job_threads, pth);
- ecore_event_add(ECORE_THREAD_PIPE_DEL, pth->p, _ecore_thread_pipe_free, NULL);
- free(pth);
+ ecore_event_add(ECORE_THREAD_PIPE_DEL, pth->p,
+ _ecore_thread_pipe_free, NULL);
+ free(pth);
}
static void
-_ecore_thread_handler(void *data __UNUSED__, void *buffer, unsigned int nbyte)
+_ecore_thread_handler(void *data __UNUSED__, void *buffer,
+ unsigned int nbyte)
{
- Ecore_Pthread_Worker *work;
-
- if (nbyte != sizeof (Ecore_Pthread_Worker *)) return ;
-
- work = *(Ecore_Pthread_Worker **)buffer;
-
- if (work->cancel)
- {
- if (work->func_cancel)
- work->func_cancel((void *) work->data);
- }
- else
- {
- if (work->func_end)
- work->func_end((void *) work->data);
- }
-
- if (work->feedback_run)
- ecore_pipe_del(work->u.feedback_run.notify);
- pthread_cond_destroy(&work->cond);
- pthread_mutex_destroy(&work->mutex);
- if (work->hash)
- eina_hash_free(work->hash);
- free(work);
+ Ecore_Pthread_Worker *work;
+
+ if (nbyte != sizeof(Ecore_Pthread_Worker *))
+ return;
+
+ work = *(Ecore_Pthread_Worker **) buffer;
+
+ if (work->cancel) {
+ if (work->func_cancel)
+ work->func_cancel((void *) work->data);
+ } else {
+ if (work->func_end)
+ work->func_end((void *) work->data);
+ }
+
+ if (work->feedback_run)
+ ecore_pipe_del(work->u.feedback_run.notify);
+ pthread_cond_destroy(&work->cond);
+ pthread_mutex_destroy(&work->mutex);
+ if (work->hash)
+ eina_hash_free(work->hash);
+ free(work);
}
static void
_ecore_notify_handler(void *data, void *buffer, unsigned int nbyte)
{
- Ecore_Pthread_Worker *work = data;
- void *user_data;
+ Ecore_Pthread_Worker *work = data;
+ void *user_data;
- if (nbyte != sizeof (Ecore_Pthread_Worker *)) return ;
+ if (nbyte != sizeof(Ecore_Pthread_Worker *))
+ return;
- user_data = *(void **)buffer;
+ user_data = *(void **) buffer;
- if (work->u.feedback_run.func_notify)
- work->u.feedback_run.func_notify((Ecore_Thread *) work, user_data, (void *) work->data);
+ if (work->u.feedback_run.func_notify)
+ work->u.feedback_run.func_notify((Ecore_Thread *) work,
+ user_data,
+ (void *) work->data);
}
-static void
-_ecore_short_job(Ecore_Pipe *end_pipe)
+static void _ecore_short_job(Ecore_Pipe * end_pipe)
{
- Ecore_Pthread_Worker *work;
+ Ecore_Pthread_Worker *work;
- while (_ecore_pending_job_threads)
- {
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ while (_ecore_pending_job_threads) {
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- if (!_ecore_pending_job_threads)
- {
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- break;
- }
+ if (!_ecore_pending_job_threads) {
+ pthread_mutex_unlock
+ (&_ecore_pending_job_threads_mutex);
+ break;
+ }
- work = eina_list_data_get(_ecore_pending_job_threads);
- _ecore_pending_job_threads = eina_list_remove_list(_ecore_pending_job_threads, _ecore_pending_job_threads);
+ work = eina_list_data_get(_ecore_pending_job_threads);
+ _ecore_pending_job_threads =
+ eina_list_remove_list(_ecore_pending_job_threads,
+ _ecore_pending_job_threads);
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- if (!work->cancel)
- work->u.short_run.func_blocking((void *) work->data);
+ if (!work->cancel)
+ work->u.short_run.func_blocking((void *) work->
+ data);
- ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *));
- }
+ ecore_pipe_write(end_pipe, &work,
+ sizeof(Ecore_Pthread_Worker *));
+ }
}
-static void
-_ecore_feedback_job(Ecore_Pipe *end_pipe, pthread_t thread)
+static void _ecore_feedback_job(Ecore_Pipe * end_pipe, pthread_t thread)
{
- Ecore_Pthread_Worker *work;
-
- while (_ecore_pending_job_threads_feedback)
- {
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
-
- if (!_ecore_pending_job_threads_feedback)
- {
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- break;
- }
-
- work = eina_list_data_get(_ecore_pending_job_threads_feedback);
- _ecore_pending_job_threads_feedback = eina_list_remove_list(_ecore_pending_job_threads_feedback, _ecore_pending_job_threads_feedback);
-
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- work->self = thread;
- if (!work->cancel)
- work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data);
-
- ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *));
- }
+ Ecore_Pthread_Worker *work;
+
+ while (_ecore_pending_job_threads_feedback) {
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+
+ if (!_ecore_pending_job_threads_feedback) {
+ pthread_mutex_unlock
+ (&_ecore_pending_job_threads_mutex);
+ break;
+ }
+
+ work =
+ eina_list_data_get
+ (_ecore_pending_job_threads_feedback);
+ _ecore_pending_job_threads_feedback =
+ eina_list_remove_list
+ (_ecore_pending_job_threads_feedback,
+ _ecore_pending_job_threads_feedback);
+
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+
+ work->self = thread;
+ if (!work->cancel)
+ work->u.feedback_run.
+ func_heavy((Ecore_Thread *) work,
+ (void *) work->data);
+
+ ecore_pipe_write(end_pipe, &work,
+ sizeof(Ecore_Pthread_Worker *));
+ }
}
-static void *
-_ecore_direct_worker(Ecore_Pthread_Worker *work)
+static void *_ecore_direct_worker(Ecore_Pthread_Worker * work)
{
- Ecore_Pthread_Data *pth;
-
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- eina_sched_prio_drop();
-
- pth = malloc(sizeof (Ecore_Pthread_Data));
- if (!pth) return NULL;
-
- pth->p = ecore_pipe_add(_ecore_thread_handler, NULL);
- if (!pth->p)
- {
- free(pth);
- return NULL;
- }
- pth->thread = pthread_self();
-
- work->self = pth->thread;
- work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data);
-
- ecore_pipe_write(pth->p, &work, sizeof (Ecore_Pthread_Worker *));
-
- work = malloc(sizeof (Ecore_Pthread_Worker));
- if (!work)
- {
- ecore_pipe_del(pth->p);
- free(pth);
- return NULL;
- }
-
- work->data = pth;
- work->u.short_run.func_blocking = NULL;
- work->func_end = (void *) _ecore_thread_end;
- work->func_cancel = NULL;
- work->cancel = EINA_FALSE;
- work->feedback_run = EINA_FALSE;
- work->hash = NULL;
- pthread_cond_init(&work->cond, NULL);
- pthread_mutex_init(&work->mutex, NULL);
-
- ecore_pipe_write(pth->p, &work, sizeof (Ecore_Pthread_Worker *));
-
- return pth->p;
+ Ecore_Pthread_Data *pth;
+
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ eina_sched_prio_drop();
+
+ pth = malloc(sizeof(Ecore_Pthread_Data));
+ if (!pth)
+ return NULL;
+
+ pth->p = ecore_pipe_add(_ecore_thread_handler, NULL);
+ if (!pth->p) {
+ free(pth);
+ return NULL;
+ }
+ pth->thread = pthread_self();
+
+ work->self = pth->thread;
+ work->u.feedback_run.func_heavy((Ecore_Thread *) work,
+ (void *) work->data);
+
+ ecore_pipe_write(pth->p, &work, sizeof(Ecore_Pthread_Worker *));
+
+ work = malloc(sizeof(Ecore_Pthread_Worker));
+ if (!work) {
+ ecore_pipe_del(pth->p);
+ free(pth);
+ return NULL;
+ }
+
+ work->data = pth;
+ work->u.short_run.func_blocking = NULL;
+ work->func_end = (void *) _ecore_thread_end;
+ work->func_cancel = NULL;
+ work->cancel = EINA_FALSE;
+ work->feedback_run = EINA_FALSE;
+ work->hash = NULL;
+ pthread_cond_init(&work->cond, NULL);
+ pthread_mutex_init(&work->mutex, NULL);
+
+ ecore_pipe_write(pth->p, &work, sizeof(Ecore_Pthread_Worker *));
+
+ return pth->p;
}
-static void *
-_ecore_thread_worker(Ecore_Pthread_Data *pth)
+static void *_ecore_thread_worker(Ecore_Pthread_Data * pth)
{
- Ecore_Pthread_Worker *work;
-
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- eina_sched_prio_drop();
-
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- _ecore_thread_count++;
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- on_error:
- if (_ecore_pending_job_threads) _ecore_short_job(pth->p);
- if (_ecore_pending_job_threads_feedback) _ecore_feedback_job(pth->p, pth->thread);
-
- /* FIXME: Check if there is feedback running task todo, and switch to feedback run handler. */
-
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- if (_ecore_pending_job_threads)
- {
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- goto on_error;
- }
- if (_ecore_pending_job_threads_feedback)
- {
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- goto on_error;
- }
-
- _ecore_thread_count--;
-
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- work = malloc(sizeof (Ecore_Pthread_Worker));
- if (!work) return NULL;
-
- work->data = pth;
- work->u.short_run.func_blocking = NULL;
- work->func_end = (void *) _ecore_thread_end;
- work->func_cancel = NULL;
- work->cancel = EINA_FALSE;
- work->feedback_run = EINA_FALSE;
- work->hash = NULL;
- pthread_cond_init(&work->cond, NULL);
- pthread_mutex_init(&work->mutex, NULL);
-
- ecore_pipe_write(pth->p, &work, sizeof (Ecore_Pthread_Worker *));
-
- return pth->p;
+ Ecore_Pthread_Worker *work;
+
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ eina_sched_prio_drop();
+
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ _ecore_thread_count++;
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+
+ on_error:
+ if (_ecore_pending_job_threads)
+ _ecore_short_job(pth->p);
+ if (_ecore_pending_job_threads_feedback)
+ _ecore_feedback_job(pth->p, pth->thread);
+
+ /* FIXME: Check if there is feedback running task todo, and switch to feedback run handler. */
+
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ if (_ecore_pending_job_threads) {
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ goto on_error;
+ }
+ if (_ecore_pending_job_threads_feedback) {
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ goto on_error;
+ }
+
+ _ecore_thread_count--;
+
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+
+ work = malloc(sizeof(Ecore_Pthread_Worker));
+ if (!work)
+ return NULL;
+
+ work->data = pth;
+ work->u.short_run.func_blocking = NULL;
+ work->func_end = (void *) _ecore_thread_end;
+ work->func_cancel = NULL;
+ work->cancel = EINA_FALSE;
+ work->feedback_run = EINA_FALSE;
+ work->hash = NULL;
+ pthread_cond_init(&work->cond, NULL);
+ pthread_mutex_init(&work->mutex, NULL);
+
+ ecore_pipe_write(pth->p, &work, sizeof(Ecore_Pthread_Worker *));
+
+ return pth->p;
}
#endif
-void
-_ecore_thread_init(void)
+void _ecore_thread_init(void)
{
- _ecore_thread_count_max = eina_cpu_count();
- if (_ecore_thread_count_max <= 0)
- _ecore_thread_count_max = 1;
+ _ecore_thread_count_max = eina_cpu_count();
+ if (_ecore_thread_count_max <= 0)
+ _ecore_thread_count_max = 1;
- ECORE_THREAD_PIPE_DEL = ecore_event_type_new();
+ ECORE_THREAD_PIPE_DEL = ecore_event_type_new();
#ifdef EFL_HAVE_PTHREAD
- del_handler = ecore_event_handler_add(ECORE_THREAD_PIPE_DEL, _ecore_thread_pipe_del, NULL);
- main_loop_thread = pthread_self();
- have_main_loop_thread = 1;
+ del_handler =
+ ecore_event_handler_add(ECORE_THREAD_PIPE_DEL,
+ _ecore_thread_pipe_del, NULL);
+ main_loop_thread = pthread_self();
+ have_main_loop_thread = 1;
#endif
}
-void
-_ecore_thread_shutdown(void)
+void _ecore_thread_shutdown(void)
{
- /* FIXME: If function are still running in the background, should we kill them ? */
+ /* FIXME: If function are still running in the background, should we kill them ? */
#ifdef EFL_HAVE_PTHREAD
- Ecore_Pthread_Worker *work;
- Ecore_Pthread_Data *pth;
-
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
-
- EINA_LIST_FREE(_ecore_pending_job_threads, work)
- {
- if (work->func_cancel)
- work->func_cancel((void *)work->data);
- free(work);
- }
-
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- EINA_LIST_FREE(_ecore_active_job_threads, pth)
- {
- Ecore_Pipe *p;
-
- pthread_cancel(pth->thread);
- pthread_join(pth->thread, (void **) &p);
-
- ecore_pipe_del(pth->p);
- }
- if (_ecore_thread_global_hash)
- eina_hash_free(_ecore_thread_global_hash);
- ecore_event_handler_del(del_handler);
- have_main_loop_thread = 0;
- del_handler = NULL;
+ Ecore_Pthread_Worker *work;
+ Ecore_Pthread_Data *pth;
+
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+
+ EINA_LIST_FREE(_ecore_pending_job_threads, work) {
+ if (work->func_cancel)
+ work->func_cancel((void *) work->data);
+ free(work);
+ }
+
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+
+ EINA_LIST_FREE(_ecore_active_job_threads, pth) {
+ Ecore_Pipe *p;
+
+ pthread_cancel(pth->thread);
+ pthread_join(pth->thread, (void **) &p);
+
+ ecore_pipe_del(pth->p);
+ }
+ if (_ecore_thread_global_hash)
+ eina_hash_free(_ecore_thread_global_hash);
+ ecore_event_handler_del(del_handler);
+ have_main_loop_thread = 0;
+ del_handler = NULL;
#endif
}
+
/**
* @addtogroup Ecore_Thread Ecore Thread Functions
* These functions allow for ecore-managed threads which integrate with ecore's main loop.
@@ -406,80 +416,80 @@ _ecore_thread_shutdown(void)
* after many call to ecore_thread_run, as we start as much thread as the
* host CPU can handle.
*/
-EAPI Ecore_Thread *
-ecore_thread_run(Ecore_Cb func_blocking,
- Ecore_Cb func_end,
- Ecore_Cb func_cancel,
- const void *data)
+EAPI Ecore_Thread *ecore_thread_run(Ecore_Cb func_blocking,
+ Ecore_Cb func_end,
+ Ecore_Cb func_cancel, const void *data)
{
#ifdef EFL_HAVE_PTHREAD
- Ecore_Pthread_Worker *work;
- Ecore_Pthread_Data *pth = NULL;
-
- if (!func_blocking) return NULL;
-
- work = malloc(sizeof (Ecore_Pthread_Worker));
- if (!work)
- {
- func_cancel((void *) data);
- return NULL;
- }
-
- work->u.short_run.func_blocking = func_blocking;
- work->hash = NULL;
- pthread_cond_init(&work->cond, NULL);
- pthread_mutex_init(&work->mutex, NULL);
- work->func_end = func_end;
- work->func_cancel = func_cancel;
- work->cancel = EINA_FALSE;
- work->feedback_run = EINA_FALSE;
- work->data = data;
-
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- _ecore_pending_job_threads = eina_list_append(_ecore_pending_job_threads, work);
-
- if (_ecore_thread_count == _ecore_thread_count_max)
- {
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- return (Ecore_Thread *) work;
- }
-
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- /* One more thread could be created. */
- pth = malloc(sizeof (Ecore_Pthread_Data));
- if (!pth) goto on_error;
-
- pth->p = ecore_pipe_add(_ecore_thread_handler, NULL);
- if (!pth->p) goto on_error;
-
- if (pthread_create(&pth->thread, NULL, (void *) _ecore_thread_worker, pth) == 0)
- return (Ecore_Thread *) work;
-
- on_error:
- if (pth)
- {
- if (pth->p) ecore_pipe_del(pth->p);
- free(pth);
- }
-
- if (_ecore_thread_count == 0)
- {
- if (work->func_cancel)
- work->func_cancel((void *) work->data);
- free(work);
- work = NULL;
- }
- return (Ecore_Thread *) work;
+ Ecore_Pthread_Worker *work;
+ Ecore_Pthread_Data *pth = NULL;
+
+ if (!func_blocking)
+ return NULL;
+
+ work = malloc(sizeof(Ecore_Pthread_Worker));
+ if (!work) {
+ func_cancel((void *) data);
+ return NULL;
+ }
+
+ work->u.short_run.func_blocking = func_blocking;
+ work->hash = NULL;
+ pthread_cond_init(&work->cond, NULL);
+ pthread_mutex_init(&work->mutex, NULL);
+ work->func_end = func_end;
+ work->func_cancel = func_cancel;
+ work->cancel = EINA_FALSE;
+ work->feedback_run = EINA_FALSE;
+ work->data = data;
+
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ _ecore_pending_job_threads =
+ eina_list_append(_ecore_pending_job_threads, work);
+
+ if (_ecore_thread_count == _ecore_thread_count_max) {
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ return (Ecore_Thread *) work;
+ }
+
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+
+ /* One more thread could be created. */
+ pth = malloc(sizeof(Ecore_Pthread_Data));
+ if (!pth)
+ goto on_error;
+
+ pth->p = ecore_pipe_add(_ecore_thread_handler, NULL);
+ if (!pth->p)
+ goto on_error;
+
+ if (pthread_create
+ (&pth->thread, NULL, (void *) _ecore_thread_worker, pth) == 0)
+ return (Ecore_Thread *) work;
+
+ on_error:
+ if (pth) {
+ if (pth->p)
+ ecore_pipe_del(pth->p);
+ free(pth);
+ }
+
+ if (_ecore_thread_count == 0) {
+ if (work->func_cancel)
+ work->func_cancel((void *) work->data);
+ free(work);
+ work = NULL;
+ }
+ return (Ecore_Thread *) work;
#else
- /*
- If no thread and as we don't want to break app that rely on this
- facility, we will lock the interface until we are done.
- */
- func_blocking((void *)data);
- func_end((void *)data);
-
- return NULL;
+ /*
+ If no thread and as we don't want to break app that rely on this
+ facility, we will lock the interface until we are done.
+ */
+ func_blocking((void *) data);
+ func_end((void *) data);
+
+ return NULL;
#endif
}
@@ -498,45 +508,45 @@ ecore_thread_run(Ecore_Cb func_blocking,
* func_end, func_cancel will destroy the handler, so don't use it after.
* And if ecore_thread_cancel return EINA_TRUE, you should not use Ecore_Thread also.
*/
-EAPI Eina_Bool
-ecore_thread_cancel(Ecore_Thread *thread)
+EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread * thread)
{
#ifdef EFL_HAVE_PTHREAD
- Ecore_Pthread_Worker *work = (Ecore_Pthread_Worker *)thread;
- Eina_List *l;
-
- if (!work)
- return EINA_TRUE;
-
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
-
- if ((have_main_loop_thread) &&
- (pthread_equal(main_loop_thread, pthread_self())))
- {
- EINA_LIST_FOREACH(_ecore_pending_job_threads, l, work)
- {
- if ((void *) work == (void *) thread)
- {
- _ecore_pending_job_threads = eina_list_remove_list(_ecore_pending_job_threads, l);
-
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- if (work->func_cancel)
- work->func_cancel((void *) work->data);
- free(work);
-
- return EINA_TRUE;
- }
- }
- }
-
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- /* Delay the destruction */
- ((Ecore_Pthread_Worker *)thread)->cancel = EINA_TRUE;
- return EINA_FALSE;
+ Ecore_Pthread_Worker *work = (Ecore_Pthread_Worker *) thread;
+ Eina_List *l;
+
+ if (!work)
+ return EINA_TRUE;
+
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+
+ if ((have_main_loop_thread) &&
+ (pthread_equal(main_loop_thread, pthread_self()))) {
+ EINA_LIST_FOREACH(_ecore_pending_job_threads, l, work) {
+ if ((void *) work == (void *) thread) {
+ _ecore_pending_job_threads =
+ eina_list_remove_list
+ (_ecore_pending_job_threads, l);
+
+ pthread_mutex_unlock
+ (&_ecore_pending_job_threads_mutex);
+
+ if (work->func_cancel)
+ work->func_cancel((void *) work->
+ data);
+ free(work);
+
+ return EINA_TRUE;
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+
+ /* Delay the destruction */
+ ((Ecore_Pthread_Worker *) thread)->cancel = EINA_TRUE;
+ return EINA_FALSE;
#else
- return EINA_TRUE;
+ return EINA_TRUE;
#endif
}
@@ -548,13 +558,13 @@ ecore_thread_cancel(Ecore_Thread *thread)
*
* You can use this function in main loop and in the thread.
*/
-EAPI Eina_Bool
-ecore_thread_check(Ecore_Thread *thread)
+EAPI Eina_Bool ecore_thread_check(Ecore_Thread * thread)
{
- Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
+ Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
- if (!worker) return EINA_TRUE;
- return worker->cancel;
+ if (!worker)
+ return EINA_TRUE;
+ return worker->cancel;
}
/**
@@ -585,109 +595,118 @@ ecore_thread_check(Ecore_Thread *thread)
* the CPU down, so be careful with that. Of course if it can't start a new thread, it will
* try to use one from the pool.
*/
-EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb func_heavy,
- Ecore_Thread_Notify_Cb func_notify,
- Ecore_Cb func_end,
- Ecore_Cb func_cancel,
- const void *data,
- Eina_Bool try_no_queue)
+EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb
+ func_heavy,
+ Ecore_Thread_Notify_Cb
+ func_notify,
+ Ecore_Cb func_end,
+ Ecore_Cb func_cancel,
+ const void *data,
+ Eina_Bool try_no_queue)
{
#ifdef EFL_HAVE_PTHREAD
- Ecore_Pthread_Worker *worker;
- Ecore_Pthread_Data *pth = NULL;
-
- if (!func_heavy) return NULL;
-
- worker = malloc(sizeof (Ecore_Pthread_Worker));
- if (!worker) goto on_error;
-
- worker->u.feedback_run.func_heavy = func_heavy;
- worker->u.feedback_run.func_notify = func_notify;
- worker->hash = NULL;
- pthread_cond_init(&worker->cond, NULL);
- pthread_mutex_init(&worker->mutex, NULL);
- worker->func_cancel = func_cancel;
- worker->func_end = func_end;
- worker->data = data;
- worker->cancel = EINA_FALSE;
- worker->feedback_run = EINA_TRUE;
-
- worker->u.feedback_run.notify = ecore_pipe_add(_ecore_notify_handler, worker);
-
- if (!try_no_queue)
- {
- pthread_t t;
-
- if (pthread_create(&t, NULL, (void *) _ecore_direct_worker, worker) == 0)
- return (Ecore_Thread *) worker;
- }
-
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- _ecore_pending_job_threads_feedback = eina_list_append(_ecore_pending_job_threads_feedback, worker);
-
- if (_ecore_thread_count == _ecore_thread_count_max)
- {
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- return (Ecore_Thread *) worker;
- }
-
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
-
- /* One more thread could be created. */
- pth = malloc(sizeof (Ecore_Pthread_Data));
- if (!pth) goto on_error;
-
- pth->p = ecore_pipe_add(_ecore_thread_handler, NULL);
- if (!pth->p) goto on_error;
-
- if (pthread_create(&pth->thread, NULL, (void *) _ecore_thread_worker, pth) == 0)
- return (Ecore_Thread *) worker;
-
- on_error:
- if (pth)
- {
- if (pth->p) ecore_pipe_del(pth->p);
- free(pth);
- }
-
- if (_ecore_thread_count == 0)
- {
- if (func_cancel) func_cancel((void *) data);
-
- if (worker)
- {
- ecore_pipe_del(worker->u.feedback_run.notify);
- free(worker);
- worker = NULL;
- }
- }
-
- return (Ecore_Thread *) worker;
+ Ecore_Pthread_Worker *worker;
+ Ecore_Pthread_Data *pth = NULL;
+
+ if (!func_heavy)
+ return NULL;
+
+ worker = malloc(sizeof(Ecore_Pthread_Worker));
+ if (!worker)
+ goto on_error;
+
+ worker->u.feedback_run.func_heavy = func_heavy;
+ worker->u.feedback_run.func_notify = func_notify;
+ worker->hash = NULL;
+ pthread_cond_init(&worker->cond, NULL);
+ pthread_mutex_init(&worker->mutex, NULL);
+ worker->func_cancel = func_cancel;
+ worker->func_end = func_end;
+ worker->data = data;
+ worker->cancel = EINA_FALSE;
+ worker->feedback_run = EINA_TRUE;
+
+ worker->u.feedback_run.notify =
+ ecore_pipe_add(_ecore_notify_handler, worker);
+
+ if (!try_no_queue) {
+ pthread_t t;
+
+ if (pthread_create
+ (&t, NULL, (void *) _ecore_direct_worker, worker) == 0)
+ return (Ecore_Thread *) worker;
+ }
+
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ _ecore_pending_job_threads_feedback =
+ eina_list_append(_ecore_pending_job_threads_feedback, worker);
+
+ if (_ecore_thread_count == _ecore_thread_count_max) {
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ return (Ecore_Thread *) worker;
+ }
+
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+
+ /* One more thread could be created. */
+ pth = malloc(sizeof(Ecore_Pthread_Data));
+ if (!pth)
+ goto on_error;
+
+ pth->p = ecore_pipe_add(_ecore_thread_handler, NULL);
+ if (!pth->p)
+ goto on_error;
+
+ if (pthread_create
+ (&pth->thread, NULL, (void *) _ecore_thread_worker, pth) == 0)
+ return (Ecore_Thread *) worker;
+
+ on_error:
+ if (pth) {
+ if (pth->p)
+ ecore_pipe_del(pth->p);
+ free(pth);
+ }
+
+ if (_ecore_thread_count == 0) {
+ if (func_cancel)
+ func_cancel((void *) data);
+
+ if (worker) {
+ ecore_pipe_del(worker->u.feedback_run.notify);
+ free(worker);
+ worker = NULL;
+ }
+ }
+
+ return (Ecore_Thread *) worker;
#else
- Ecore_Pthread_Worker worker;
-
- (void) try_no_queue;
-
- /*
- If no thread and as we don't want to break app that rely on this
- facility, we will lock the interface until we are done.
- */
- worker.u.feedback_run.func_heavy = func_heavy;
- worker.u.feedback_run.func_notify = func_notify;
- worker.u.feedback_run.notify = NULL;
- worker.func_cancel = func_cancel;
- worker.func_end = func_end;
- worker.data = data;
- worker.cancel = EINA_FALSE;
- worker.feedback_run = EINA_TRUE;
-
- func_heavy((Ecore_Thread *) &worker, (void *)data);
-
- if (worker.cancel) func_cancel((void *)data);
- else func_end((void *)data);
-
- return NULL;
+ Ecore_Pthread_Worker worker;
+
+ (void) try_no_queue;
+
+ /*
+ If no thread and as we don't want to break app that rely on this
+ facility, we will lock the interface until we are done.
+ */
+ worker.u.feedback_run.func_heavy = func_heavy;
+ worker.u.feedback_run.func_notify = func_notify;
+ worker.u.feedback_run.notify = NULL;
+ worker.func_cancel = func_cancel;
+ worker.func_end = func_end;
+ worker.data = data;
+ worker.cancel = EINA_FALSE;
+ worker.feedback_run = EINA_TRUE;
+
+ func_heavy((Ecore_Thread *) & worker, (void *) data);
+
+ if (worker.cancel)
+ func_cancel((void *) data);
+ else
+ func_end((void *) data);
+
+ return NULL;
#endif
}
@@ -704,23 +723,28 @@ EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb func_heavy,
* You should use this function only in the func_heavy call.
*/
EAPI Eina_Bool
-ecore_thread_feedback(Ecore_Thread *thread, const void *data)
+ecore_thread_feedback(Ecore_Thread * thread, const void *data)
{
- Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
+ Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
- if (!worker) return EINA_FALSE;
- if (!worker->feedback_run) return EINA_FALSE;
+ if (!worker)
+ return EINA_FALSE;
+ if (!worker->feedback_run)
+ return EINA_FALSE;
#ifdef EFL_HAVE_PTHREAD
- if (!pthread_equal(worker->self, pthread_self())) return EINA_FALSE;
+ if (!pthread_equal(worker->self, pthread_self()))
+ return EINA_FALSE;
- ecore_pipe_write(worker->u.feedback_run.notify, &data, sizeof (void *));
+ ecore_pipe_write(worker->u.feedback_run.notify, &data,
+ sizeof(void *));
- return EINA_TRUE;
+ return EINA_TRUE;
#else
- worker->u.feedback_run.func_notify(thread, (void*) data, (void*) worker->data);
+ worker->u.feedback_run.func_notify(thread, (void *) data,
+ (void *) worker->data);
- return EINA_TRUE;
+ return EINA_TRUE;
#endif
}
@@ -730,13 +754,12 @@ ecore_thread_feedback(Ecore_Thread *thread, const void *data)
* This returns the number of threads currently running jobs through the
* ecore_thread api.
*/
-EAPI int
-ecore_thread_active_get(void)
+EAPI int ecore_thread_active_get(void)
{
#ifdef EFL_HAVE_PTHREAD
- return _ecore_thread_count;
+ return _ecore_thread_count;
#else
- return 0;
+ return 0;
#endif
}
@@ -746,17 +769,16 @@ ecore_thread_active_get(void)
* This returns the number of threads currently running jobs through the
* ecore_thread_run api call.
*/
-EAPI int
-ecore_thread_pending_get(void)
+EAPI int ecore_thread_pending_get(void)
{
- int ret;
+ int ret;
#ifdef EFL_HAVE_PTHREAD
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- ret = eina_list_count(_ecore_pending_job_threads);
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- return ret;
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ ret = eina_list_count(_ecore_pending_job_threads);
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
@@ -766,17 +788,16 @@ ecore_thread_pending_get(void)
* This returns the number of threads currently running jobs through the
* ecore_thread_feedback_run api call.
*/
-EAPI int
-ecore_thread_pending_feedback_get(void)
+EAPI int ecore_thread_pending_feedback_get(void)
{
- int ret;
+ int ret;
#ifdef EFL_HAVE_PTHREAD
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- ret = eina_list_count(_ecore_pending_job_threads_feedback);
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- return ret;
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ ret = eina_list_count(_ecore_pending_job_threads_feedback);
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
@@ -786,17 +807,18 @@ ecore_thread_pending_feedback_get(void)
* This returns the number of threads currently running jobs through the
* ecore_thread_run and ecore_thread_feedback_run api calls combined.
*/
-EAPI int
-ecore_thread_pending_total_get(void)
+EAPI int ecore_thread_pending_total_get(void)
{
- int ret;
+ int ret;
#ifdef EFL_HAVE_PTHREAD
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- ret = eina_list_count(_ecore_pending_job_threads) + eina_list_count(_ecore_pending_job_threads_feedback);
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- return ret;
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ ret =
+ eina_list_count(_ecore_pending_job_threads) +
+ eina_list_count(_ecore_pending_job_threads_feedback);
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
@@ -806,10 +828,9 @@ ecore_thread_pending_total_get(void)
* This returns the total number of threads that ecore will attempt to run
* simultaneously.
*/
-EAPI int
-ecore_thread_max_get(void)
+EAPI int ecore_thread_max_get(void)
{
- return _ecore_thread_count_max;
+ return _ecore_thread_count_max;
}
/**
@@ -818,14 +839,15 @@ ecore_thread_max_get(void)
* This sets the maximum number of threads that ecore will try to run
* simultaneously. This number cannot be < 1 or >= 2x the number of active cpus.
*/
-EAPI void
-ecore_thread_max_set(int num)
+EAPI void ecore_thread_max_set(int num)
{
- if (num < 1) return;
- /* avoid doing something hilarious by blocking dumb users */
- if (num >= (2 * eina_cpu_count())) return;
+ if (num < 1)
+ return;
+ /* avoid doing something hilarious by blocking dumb users */
+ if (num >= (2 * eina_cpu_count()))
+ return;
- _ecore_thread_count_max = num;
+ _ecore_thread_count_max = num;
}
/**
@@ -833,10 +855,9 @@ ecore_thread_max_set(int num)
* This resets the maximum number of threads that ecore will try to run
* simultaneously to the number of active cpus.
*/
-EAPI void
-ecore_thread_max_reset(void)
+EAPI void ecore_thread_max_reset(void)
{
- _ecore_thread_count_max = eina_cpu_count();
+ _ecore_thread_count_max = eina_cpu_count();
}
/**
@@ -846,17 +867,16 @@ ecore_thread_max_reset(void)
* Assuming that you haven't changed the max number of threads with @ref ecore_thread_max_set
* this should be equal to (num_cpus - (active_running + active_feedback_running))
*/
-EAPI int
-ecore_thread_available_get(void)
+EAPI int ecore_thread_available_get(void)
{
- int ret;
+ int ret;
#ifdef EFL_HAVE_PTHREAD
- pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
- ret = _ecore_thread_count_max - _ecore_thread_count;
- pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- return ret;
+ pthread_mutex_lock(&_ecore_pending_job_threads_mutex);
+ ret = _ecore_thread_count_max - _ecore_thread_count;
+ pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
@@ -876,37 +896,40 @@ ecore_thread_available_get(void)
* data, but this is most likely not what you want.
*/
EAPI Eina_Bool
-ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct)
+ecore_thread_local_data_add(Ecore_Thread * thread, const char *key,
+ void *value, Eina_Free_Cb cb, Eina_Bool direct)
{
- Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
- Ecore_Thread_Data *d;
- Eina_Bool ret;
+ Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
+ Ecore_Thread_Data *d;
+ Eina_Bool ret;
- if ((!thread) || (!key) || (!value))
- return EINA_FALSE;
+ if ((!thread) || (!key) || (!value))
+ return EINA_FALSE;
#ifdef EFL_HAVE_PTHREAD
- if (!pthread_equal(worker->self, pthread_self())) return EINA_FALSE;
+ if (!pthread_equal(worker->self, pthread_self()))
+ return EINA_FALSE;
- if (!worker->hash)
- worker->hash = eina_hash_string_small_new(_ecore_thread_data_free);
+ if (!worker->hash)
+ worker->hash =
+ eina_hash_string_small_new(_ecore_thread_data_free);
- if (!worker->hash)
- return EINA_FALSE;
+ if (!worker->hash)
+ return EINA_FALSE;
- if (!(d = malloc(sizeof(Ecore_Thread_Data))))
- return EINA_FALSE;
+ if (!(d = malloc(sizeof(Ecore_Thread_Data))))
+ return EINA_FALSE;
- d->data = value;
- d->cb = cb;
+ d->data = value;
+ d->cb = cb;
- if (direct)
- ret = eina_hash_direct_add(worker->hash, key, d);
- else
- ret = eina_hash_add(worker->hash, key, d);
- pthread_cond_broadcast(&worker->cond);
- return ret;
+ if (direct)
+ ret = eina_hash_direct_add(worker->hash, key, d);
+ else
+ ret = eina_hash_add(worker->hash, key, d);
+ pthread_cond_broadcast(&worker->cond);
+ return ret;
#else
- return EINA_TRUE;
+ return EINA_TRUE;
#endif
}
@@ -923,36 +946,39 @@ ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value,
* upon thread termination. If no callback is specified, it is expected that the user will free the
* data, but this is most likely not what you want.
*/
-EAPI void *
-ecore_thread_local_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb)
+EAPI void *ecore_thread_local_data_set(Ecore_Thread * thread,
+ const char *key, void *value,
+ Eina_Free_Cb cb)
{
- Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
- Ecore_Thread_Data *d, *r;
- void *ret;
- if ((!thread) || (!key) || (!value))
- return NULL;
+ Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
+ Ecore_Thread_Data *d, *r;
+ void *ret;
+ if ((!thread) || (!key) || (!value))
+ return NULL;
#ifdef EFL_HAVE_PTHREAD
- if (!pthread_equal(worker->self, pthread_self())) return NULL;
+ if (!pthread_equal(worker->self, pthread_self()))
+ return NULL;
- if (!worker->hash)
- worker->hash = eina_hash_string_small_new(_ecore_thread_data_free);
+ if (!worker->hash)
+ worker->hash =
+ eina_hash_string_small_new(_ecore_thread_data_free);
- if (!worker->hash)
- return NULL;
+ if (!worker->hash)
+ return NULL;
- if (!(d = malloc(sizeof(Ecore_Thread_Data))))
- return NULL;
+ if (!(d = malloc(sizeof(Ecore_Thread_Data))))
+ return NULL;
- d->data = value;
- d->cb = cb;
+ d->data = value;
+ d->cb = cb;
- r = eina_hash_set(worker->hash, key, d);
- pthread_cond_broadcast(&worker->cond);
- ret = r->data;
- free(r);
- return ret;
+ r = eina_hash_set(worker->hash, key, d);
+ pthread_cond_broadcast(&worker->cond);
+ ret = r->data;
+ free(r);
+ return ret;
#else
- return NULL;
+ return NULL;
#endif
}
@@ -966,24 +992,25 @@ ecore_thread_local_data_set(Ecore_Thread *thread, const char *key, void *value,
* in any case but success.
*/
-EAPI void *
-ecore_thread_local_data_find(Ecore_Thread *thread, const char *key)
+EAPI void *ecore_thread_local_data_find(Ecore_Thread * thread,
+ const char *key)
{
- Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
- Ecore_Thread_Data *d;
+ Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
+ Ecore_Thread_Data *d;
- if ((!thread) || (!key))
- return NULL;
+ if ((!thread) || (!key))
+ return NULL;
#ifdef EFL_HAVE_PTHREAD
- if (!pthread_equal(worker->self, pthread_self())) return NULL;
+ if (!pthread_equal(worker->self, pthread_self()))
+ return NULL;
- if (!worker->hash)
- return NULL;
+ if (!worker->hash)
+ return NULL;
- d = eina_hash_find(worker->hash, key);
- return d->data;
+ d = eina_hash_find(worker->hash, key);
+ return d->data;
#else
- return NULL;
+ return NULL;
#endif
}
@@ -997,22 +1024,23 @@ ecore_thread_local_data_find(Ecore_Thread *thread, const char *key)
* in any case but success. Note that this WILL free the data if a callback was specified.
*/
EAPI Eina_Bool
-ecore_thread_local_data_del(Ecore_Thread *thread, const char *key)
+ecore_thread_local_data_del(Ecore_Thread * thread, const char *key)
{
- Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
- Ecore_Thread_Data *d;
- if ((!thread) || (!key))
- return EINA_FALSE;
+ Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread;
+ Ecore_Thread_Data *d;
+ if ((!thread) || (!key))
+ return EINA_FALSE;
#ifdef EFL_HAVE_PTHREAD
- if (!pthread_equal(worker->self, pthread_self())) return EINA_FALSE;
-
- if (!worker->hash)
- return EINA_FALSE;
- if ((d = eina_hash_find(worker->hash, key)))
- _ecore_thread_data_free(d);
- return eina_hash_del_by_key(worker->hash, key);
+ if (!pthread_equal(worker->self, pthread_self()))
+ return EINA_FALSE;
+
+ if (!worker->hash)
+ return EINA_FALSE;
+ if ((d = eina_hash_find(worker->hash, key)))
+ _ecore_thread_data_free(d);
+ return eina_hash_del_by_key(worker->hash, key);
#else
- return EINA_TRUE;
+ return EINA_TRUE;
#endif
}
@@ -1029,37 +1057,41 @@ ecore_thread_local_data_del(Ecore_Thread *thread, const char *key)
* was specified for, you will most likely encounter a segv later on.
*/
EAPI Eina_Bool
-ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct)
+ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb,
+ Eina_Bool direct)
{
- Eina_Bool ret;
- Ecore_Thread_Data *d;
+ Eina_Bool ret;
+ Ecore_Thread_Data *d;
- if ((!key) || (!value))
- return EINA_FALSE;
+ if ((!key) || (!value))
+ return EINA_FALSE;
#ifdef EFL_HAVE_PTHREAD
- pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
- if (!_ecore_thread_global_hash)
- _ecore_thread_global_hash = eina_hash_string_small_new(_ecore_thread_data_free);
- pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
-
- if (!(d = malloc(sizeof(Ecore_Thread_Data))))
- return EINA_FALSE;
-
- d->data = value;
- d->cb = cb;
-
- if (!_ecore_thread_global_hash)
- return EINA_FALSE;
- pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
- if (direct)
- ret = eina_hash_direct_add(_ecore_thread_global_hash, key, d);
- else
- ret = eina_hash_add(_ecore_thread_global_hash, key, d);
- pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
- pthread_cond_broadcast(&_ecore_thread_global_hash_cond);
- return ret;
+ pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
+ if (!_ecore_thread_global_hash)
+ _ecore_thread_global_hash =
+ eina_hash_string_small_new(_ecore_thread_data_free);
+ pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
+
+ if (!(d = malloc(sizeof(Ecore_Thread_Data))))
+ return EINA_FALSE;
+
+ d->data = value;
+ d->cb = cb;
+
+ if (!_ecore_thread_global_hash)
+ return EINA_FALSE;
+ pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
+ if (direct)
+ ret =
+ eina_hash_direct_add(_ecore_thread_global_hash, key,
+ d);
+ else
+ ret = eina_hash_add(_ecore_thread_global_hash, key, d);
+ pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
+ pthread_cond_broadcast(&_ecore_thread_global_hash_cond);
+ return ret;
#else
- return EINA_TRUE;
+ return EINA_TRUE;
#endif
}
@@ -1076,39 +1108,40 @@ ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina
* be called upon ecore_thread shutting down. Note that if you have manually freed data that a callback
* was specified for, you will most likely encounter a segv later on.
*/
-EAPI void *
-ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb)
+EAPI void *ecore_thread_global_data_set(const char *key, void *value,
+ Eina_Free_Cb cb)
{
- Ecore_Thread_Data *d, *r;
- void *ret;
+ Ecore_Thread_Data *d, *r;
+ void *ret;
- if ((!key) || (!value))
- return NULL;
+ if ((!key) || (!value))
+ return NULL;
#ifdef EFL_HAVE_PTHREAD
- pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
- if (!_ecore_thread_global_hash)
- _ecore_thread_global_hash = eina_hash_string_small_new(_ecore_thread_data_free);
- pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
+ pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
+ if (!_ecore_thread_global_hash)
+ _ecore_thread_global_hash =
+ eina_hash_string_small_new(_ecore_thread_data_free);
+ pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
- if (!_ecore_thread_global_hash)
- return NULL;
+ if (!_ecore_thread_global_hash)
+ return NULL;
- if (!(d = malloc(sizeof(Ecore_Thread_Data))))
- return NULL;
+ if (!(d = malloc(sizeof(Ecore_Thread_Data))))
+ return NULL;
- d->data = value;
- d->cb = cb;
+ d->data = value;
+ d->cb = cb;
- pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
- r = eina_hash_set(_ecore_thread_global_hash, key, d);
- pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
- pthread_cond_broadcast(&_ecore_thread_global_hash_cond);
+ pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
+ r = eina_hash_set(_ecore_thread_global_hash, key, d);
+ pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
+ pthread_cond_broadcast(&_ecore_thread_global_hash_cond);
- ret = r->data;
- free(r);
- return ret;
+ ret = r->data;
+ free(r);
+ return ret;
#else
- return NULL;
+ return NULL;
#endif
}
@@ -1125,21 +1158,21 @@ ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb)
* if you will be doing anything with it.
*/
-EAPI void *
-ecore_thread_global_data_find(const char *key)
+EAPI void *ecore_thread_global_data_find(const char *key)
{
- Ecore_Thread_Data *ret;
- if (!key)
- return NULL;
+ Ecore_Thread_Data *ret;
+ if (!key)
+ return NULL;
#ifdef EFL_HAVE_PTHREAD
- if (!_ecore_thread_global_hash) return NULL;
+ if (!_ecore_thread_global_hash)
+ return NULL;
- pthread_rwlock_rdlock(&_ecore_thread_global_hash_lock);
- ret = eina_hash_find(_ecore_thread_global_hash, key);
- pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
- return ret->data;
+ pthread_rwlock_rdlock(&_ecore_thread_global_hash_lock);
+ ret = eina_hash_find(_ecore_thread_global_hash, key);
+ pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
+ return ret->data;
#else
- return NULL;
+ return NULL;
#endif
}
@@ -1151,26 +1184,25 @@ ecore_thread_global_data_find(const char *key)
* This function will return EINA_FALSE in any case but success.
* Note that this WILL free the data if an @c Eina_Free_Cb was specified when the data was added.
*/
-EAPI Eina_Bool
-ecore_thread_global_data_del(const char *key)
+EAPI Eina_Bool ecore_thread_global_data_del(const char *key)
{
- Eina_Bool ret;
- Ecore_Thread_Data *d;
+ Eina_Bool ret;
+ Ecore_Thread_Data *d;
- if (!key)
- return EINA_FALSE;
+ if (!key)
+ return EINA_FALSE;
#ifdef EFL_HAVE_PTHREAD
- if (!_ecore_thread_global_hash)
- return EINA_FALSE;
-
- pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
- if ((d = eina_hash_find(_ecore_thread_global_hash, key)))
- _ecore_thread_data_free(d);
- ret = eina_hash_del_by_key(_ecore_thread_global_hash, key);
- pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
- return ret;
+ if (!_ecore_thread_global_hash)
+ return EINA_FALSE;
+
+ pthread_rwlock_wrlock(&_ecore_thread_global_hash_lock);
+ if ((d = eina_hash_find(_ecore_thread_global_hash, key)))
+ _ecore_thread_data_free(d);
+ ret = eina_hash_del_by_key(_ecore_thread_global_hash, key);
+ pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
+ return ret;
#else
- return EINA_TRUE;
+ return EINA_TRUE;
#endif
}
@@ -1186,38 +1218,41 @@ ecore_thread_global_data_del(const char *key)
* @note Keep in mind that the data returned can be used by multiple threads at a time, so you will most likely want to mutex
* if you will be doing anything with it.
*/
-EAPI void *
-ecore_thread_global_data_wait(const char *key, double seconds)
+EAPI void *ecore_thread_global_data_wait(const char *key, double seconds)
{
- double time = 0;
- Ecore_Thread_Data *ret = NULL;
- if (!key)
- return NULL;
+ double time = 0;
+ Ecore_Thread_Data *ret = NULL;
+ if (!key)
+ return NULL;
#ifdef EFL_HAVE_PTHREAD
- if (!_ecore_thread_global_hash)
- return NULL;
- if (seconds > 0)
- time = ecore_time_get() + seconds;
-
- while (1)
- {
- struct timespec t = { 0, 0 };
-
- t.tv_sec = (long int)time;
- t.tv_nsec = (long int)((time - (double)t.tv_sec) * 1000000000);
- pthread_rwlock_rdlock(&_ecore_thread_global_hash_lock);
- ret = eina_hash_find(_ecore_thread_global_hash, key);
- pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
- if ((ret) || (!seconds) || ((seconds > 0) && (time <= ecore_time_get())))
- break;
- pthread_mutex_lock(&_ecore_thread_global_hash_mutex);
- pthread_cond_timedwait(&_ecore_thread_global_hash_cond, &_ecore_thread_global_hash_mutex, &t);
- pthread_mutex_unlock(&_ecore_thread_global_hash_mutex);
- }
- if (ret) return ret->data;
- return NULL;
+ if (!_ecore_thread_global_hash)
+ return NULL;
+ if (seconds > 0)
+ time = ecore_time_get() + seconds;
+
+ while (1) {
+ struct timespec t = { 0, 0 };
+
+ t.tv_sec = (long int) time;
+ t.tv_nsec =
+ (long int) ((time - (double) t.tv_sec) * 1000000000);
+ pthread_rwlock_rdlock(&_ecore_thread_global_hash_lock);
+ ret = eina_hash_find(_ecore_thread_global_hash, key);
+ pthread_rwlock_unlock(&_ecore_thread_global_hash_lock);
+ if ((ret) || (!seconds)
+ || ((seconds > 0) && (time <= ecore_time_get())))
+ break;
+ pthread_mutex_lock(&_ecore_thread_global_hash_mutex);
+ pthread_cond_timedwait(&_ecore_thread_global_hash_cond,
+ &_ecore_thread_global_hash_mutex,
+ &t);
+ pthread_mutex_unlock(&_ecore_thread_global_hash_mutex);
+ }
+ if (ret)
+ return ret->data;
+ return NULL;
#else
- return NULL;
+ return NULL;
#endif
}
diff --git a/tests/suite/ecore/src/lib/ecore_time.c b/tests/suite/ecore/src/lib/ecore_time.c
index 1fbb4781f4..837aa8bbb5 100644
--- a/tests/suite/ecore/src/lib/ecore_time.c
+++ b/tests/suite/ecore/src/lib/ecore_time.c
@@ -1,15 +1,15 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
+#include <sys/time.h>
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "Ecore.h"
@@ -38,25 +38,23 @@ double _ecore_time_loop_time = -1.0;
* messages when the application started).
* @ingroup Ecore_Time_Group
*/
-EAPI double
-ecore_time_get(void)
+EAPI double ecore_time_get(void)
{
#ifdef HAVE_CLOCK_GETTIME
- struct timespec t;
+ struct timespec t;
- if (EINA_UNLIKELY(_ecore_time_clock_id < 0))
- return ecore_time_unix_get();
+ if (EINA_UNLIKELY(_ecore_time_clock_id < 0))
+ return ecore_time_unix_get();
- if (EINA_UNLIKELY(clock_gettime(_ecore_time_clock_id, &t)))
- {
- CRIT("Cannot get current time.");
- /* Try to at least return the latest value retrieved*/
- return _ecore_time_loop_time;
- }
+ if (EINA_UNLIKELY(clock_gettime(_ecore_time_clock_id, &t))) {
+ CRIT("Cannot get current time.");
+ /* Try to at least return the latest value retrieved */
+ return _ecore_time_loop_time;
+ }
- return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0);
+ return (double) t.tv_sec + (((double) t.tv_nsec) / 1000000000.0);
#else
- return ecore_time_unix_get();
+ return ecore_time_unix_get();
#endif
}
@@ -69,20 +67,20 @@ ecore_time_get(void)
* @return The number of seconds since 12.00AM 1st January 1970.
* @ingroup Ecore_Time_Group
*/
-EAPI double
-ecore_time_unix_get(void)
+EAPI double ecore_time_unix_get(void)
{
#ifdef HAVE_EVIL
- return evil_time_get();
+ return evil_time_get();
#else
-# ifdef HAVE_GETTIMEOFDAY
- struct timeval timev;
-
- gettimeofday(&timev, NULL);
- return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
-# else
-# error "Your platform isn't supported yet"
-# endif
+#ifdef HAVE_GETTIMEOFDAY
+ struct timeval timev;
+
+ gettimeofday(&timev, NULL);
+ return (double) timev.tv_sec +
+ (((double) timev.tv_usec) / 1000000);
+#else
+#error "Your platform isn't supported yet"
+#endif
#endif
}
@@ -108,10 +106,9 @@ ecore_time_unix_get(void)
* messages when the application started).
* @ingroup Ecore_Time_Group
*/
-EAPI double
-ecore_loop_time_get(void)
+EAPI double ecore_loop_time_get(void)
{
- return _ecore_time_loop_time;
+ return _ecore_time_loop_time;
}
@@ -121,36 +118,31 @@ ecore_loop_time_get(void)
* real-time clock, which is identified by CLOCK_REALTIME. Check if the fallback
* to unix time (without specifying the resolution) might be removed
*/
-void
-_ecore_time_init(void)
+void _ecore_time_init(void)
{
#ifdef HAVE_CLOCK_GETTIME
- struct timespec t;
-
- if (_ecore_time_clock_id != -1) return;
-
- if (!clock_gettime(CLOCK_MONOTONIC, &t))
- {
- _ecore_time_clock_id = CLOCK_MONOTONIC;
- DBG("using CLOCK_MONOTONIC.");
- }
- else if (!clock_gettime(CLOCK_REALTIME, &t))
- {
- /* may go backwards */
- _ecore_time_clock_id = CLOCK_REALTIME;
- WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME.");
- }
- else
- {
- _ecore_time_clock_id = -2;
- CRIT("Cannot get a valid clock_gettime() clock id! "
- "Fallback to unix time.");
- }
+ struct timespec t;
+
+ if (_ecore_time_clock_id != -1)
+ return;
+
+ if (!clock_gettime(CLOCK_MONOTONIC, &t)) {
+ _ecore_time_clock_id = CLOCK_MONOTONIC;
+ DBG("using CLOCK_MONOTONIC.");
+ } else if (!clock_gettime(CLOCK_REALTIME, &t)) {
+ /* may go backwards */
+ _ecore_time_clock_id = CLOCK_REALTIME;
+ WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME.");
+ } else {
+ _ecore_time_clock_id = -2;
+ CRIT("Cannot get a valid clock_gettime() clock id! "
+ "Fallback to unix time.");
+ }
#else
-# warning "Your platform isn't supported yet"
- CRIT("Platform does not support clock_gettime. "
- "Fallback to unix time.");
+#warning "Your platform isn't supported yet"
+ CRIT("Platform does not support clock_gettime. "
+ "Fallback to unix time.");
#endif
- _ecore_time_loop_time = ecore_time_get();
+ _ecore_time_loop_time = ecore_time_get();
}
diff --git a/tests/suite/ecore/src/lib/ecore_timer.c b/tests/suite/ecore/src/lib/ecore_timer.c
index fd6c64e42d..5c4cecb10f 100644
--- a/tests/suite/ecore/src/lib/ecore_timer.c
+++ b/tests/suite/ecore/src/lib/ecore_timer.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -9,32 +9,32 @@
#include "ecore_private.h"
-struct _Ecore_Timer
-{
- EINA_INLIST;
- ECORE_MAGIC;
- double in;
- double at;
- double pending;
- Ecore_Task_Cb func;
- void *data;
-
- int references;
- unsigned char delete_me : 1;
- unsigned char just_added : 1;
- unsigned char frozen : 1;
+struct _Ecore_Timer {
+ EINA_INLIST;
+ ECORE_MAGIC;
+ double in;
+ double at;
+ double pending;
+ Ecore_Task_Cb func;
+ void *data;
+
+ int references;
+ unsigned char delete_me:1;
+ unsigned char just_added:1;
+ unsigned char frozen:1;
};
-static void _ecore_timer_set(Ecore_Timer *timer, double at, double in, Ecore_Task_Cb func, void *data);
+static void _ecore_timer_set(Ecore_Timer * timer, double at, double in,
+ Ecore_Task_Cb func, void *data);
-static int timers_added = 0;
-static int timers_delete_me = 0;
+static int timers_added = 0;
+static int timers_delete_me = 0;
static Ecore_Timer *timers = NULL;
static Ecore_Timer *timer_current = NULL;
static Ecore_Timer *suspended = NULL;
-static double last_check = 0.0;
-static double precision = 10.0 / 1000000.0;
+static double last_check = 0.0;
+static double precision = 10.0 / 1000000.0;
/**
* @defgroup Ecore_Time_Group Ecore Time Functions
@@ -48,10 +48,9 @@ static double precision = 10.0 / 1000000.0;
*
* @see ecore_timer_precision_set()
*/
-EAPI double
-ecore_timer_precision_get(void)
+EAPI double ecore_timer_precision_get(void)
{
- return precision;
+ return precision;
}
/**
@@ -78,15 +77,13 @@ ecore_timer_precision_get(void)
*
* @param value allowed introduced timeout delay, in seconds.
*/
-EAPI void
-ecore_timer_precision_set(double value)
+EAPI void ecore_timer_precision_set(double value)
{
- if (value < 0.0)
- {
- ERR("Precision %f less than zero, ignored", value);
- return;
- }
- precision = value;
+ if (value < 0.0) {
+ ERR("Precision %f less than zero, ignored", value);
+ return;
+ }
+ precision = value;
}
/**
@@ -108,20 +105,23 @@ ecore_timer_precision_set(double value)
* 0 it will be deleted automatically making any references/handles for it
* invalid.
*/
-EAPI Ecore_Timer *
-ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Timer *ecore_timer_add(double in, Ecore_Task_Cb func,
+ const void *data)
{
- double now;
- Ecore_Timer *timer;
-
- if (!func) return NULL;
- if (in < 0.0) in = 0.0;
- timer = calloc(1, sizeof(Ecore_Timer));
- if (!timer) return NULL;
- ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
- now = ecore_time_get();
- _ecore_timer_set(timer, now + in, in, func, (void *)data);
- return timer;
+ double now;
+ Ecore_Timer *timer;
+
+ if (!func)
+ return NULL;
+ if (in < 0.0)
+ in = 0.0;
+ timer = calloc(1, sizeof(Ecore_Timer));
+ if (!timer)
+ return NULL;
+ ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
+ now = ecore_time_get();
+ _ecore_timer_set(timer, now + in, in, func, (void *) data);
+ return timer;
}
/**
@@ -137,20 +137,23 @@ ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
* ecore_loop_time_get() not ecore_time_get() as ecore_timer_add() uses. See
* ecore_timer_add() for more details.
*/
-EAPI Ecore_Timer *
-ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
+EAPI Ecore_Timer *ecore_timer_loop_add(double in, Ecore_Task_Cb func,
+ const void *data)
{
- double now;
- Ecore_Timer *timer;
-
- if (!func) return NULL;
- if (in < 0.0) in = 0.0;
- timer = calloc(1, sizeof(Ecore_Timer));
- if (!timer) return NULL;
- ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
- now = ecore_loop_time_get();
- _ecore_timer_set(timer, now + in, in, func, (void *)data);
- return timer;
+ double now;
+ Ecore_Timer *timer;
+
+ if (!func)
+ return NULL;
+ if (in < 0.0)
+ in = 0.0;
+ timer = calloc(1, sizeof(Ecore_Timer));
+ if (!timer)
+ return NULL;
+ ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
+ now = ecore_loop_time_get();
+ _ecore_timer_set(timer, now + in, in, func, (void *) data);
+ return timer;
}
/**
@@ -163,33 +166,33 @@ ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
* Note: @p timer must be a valid handle. If the timer function has already
* returned 0, the handle is no longer valid (and does not need to be delete).
*/
-EAPI void *
-ecore_timer_del(Ecore_Timer *timer)
+EAPI void *ecore_timer_del(Ecore_Timer * timer)
{
- if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
- {
- ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
- "ecore_timer_del");
- return NULL;
- }
-
- if (timer->frozen && !timer->references)
- {
- void *data = timer->data;
-
- suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
-
- if (timer->delete_me)
- timers_delete_me--;
-
- free(timer);
- return data;
- }
-
- EINA_SAFETY_ON_TRUE_RETURN_VAL(timer->delete_me, NULL);
- timer->delete_me = 1;
- timers_delete_me++;
- return timer->data;
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_del");
+ return NULL;
+ }
+
+ if (timer->frozen && !timer->references) {
+ void *data = timer->data;
+
+ suspended =
+ (Ecore_Timer *)
+ eina_inlist_remove(EINA_INLIST_GET(suspended),
+ EINA_INLIST_GET(timer));
+
+ if (timer->delete_me)
+ timers_delete_me--;
+
+ free(timer);
+ return data;
+ }
+
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(timer->delete_me, NULL);
+ timer->delete_me = 1;
+ timers_delete_me++;
+ return timer->data;
}
/**
@@ -200,16 +203,14 @@ ecore_timer_del(Ecore_Timer *timer)
* @param in The interval in seconds.
* @ingroup Ecore_Time_Group
*/
-EAPI void
-ecore_timer_interval_set(Ecore_Timer *timer, double in)
+EAPI void ecore_timer_interval_set(Ecore_Timer * timer, double in)
{
- if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
- {
- ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
- "ecore_timer_interval_set");
- return;
- }
- timer->in = in;
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_interval_set");
+ return;
+ }
+ timer->in = in;
}
/**
@@ -219,17 +220,15 @@ ecore_timer_interval_set(Ecore_Timer *timer, double in)
* @return The interval on success. -1 on failure.
* @ingroup Ecore_Time_Group
*/
-EAPI double
-ecore_timer_interval_get(Ecore_Timer *timer)
+EAPI double ecore_timer_interval_get(Ecore_Timer * timer)
{
- if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
- {
- ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
- "ecore_timer_interval_get");
- return -1.0;
- }
-
- return timer->in;
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_interval_get");
+ return -1.0;
+ }
+
+ return timer->in;
}
/**
@@ -240,25 +239,24 @@ ecore_timer_interval_get(Ecore_Timer *timer)
* @param add The dalay to add to the next iteration.
* @ingroup Ecore_Time_Group
*/
-EAPI void
-ecore_timer_delay(Ecore_Timer *timer, double add)
+EAPI void ecore_timer_delay(Ecore_Timer * timer, double add)
{
- if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
- {
- ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
- "ecore_timer_delay");
- return;
- }
-
- if (timer->frozen)
- {
- timer->pending += add;
- }
- else
- {
- timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
- _ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data);
- }
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_delay");
+ return;
+ }
+
+ if (timer->frozen) {
+ timer->pending += add;
+ } else {
+ timers =
+ (Ecore_Timer *)
+ eina_inlist_remove(EINA_INLIST_GET(timers),
+ EINA_INLIST_GET(timer));
+ _ecore_timer_set(timer, timer->at + add, timer->in,
+ timer->func, timer->data);
+ }
}
/**
@@ -267,325 +265,338 @@ ecore_timer_delay(Ecore_Timer *timer, double add)
* @param timer The timer to learn from.
* @ingroup Ecore_Time_Group
*/
-EAPI double
-ecore_timer_pending_get(Ecore_Timer *timer)
+EAPI double ecore_timer_pending_get(Ecore_Timer * timer)
{
- double now;
+ double now;
- if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
- {
- ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
- "ecore_timer_pending_get");
- return 0;
- }
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_pending_get");
+ return 0;
+ }
- now = ecore_time_get();
+ now = ecore_time_get();
- if (timer->frozen)
- return timer->pending;
- return timer->at - now;
+ if (timer->frozen)
+ return timer->pending;
+ return timer->at - now;
}
/**
*
*
*/
-EAPI void
-ecore_timer_freeze(Ecore_Timer *timer)
+EAPI void ecore_timer_freeze(Ecore_Timer * timer)
{
- double now;
-
- if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
- {
- ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
- "ecore_timer_freeze");
- return ;
- }
-
- /* Timer already frozen */
- if (timer->frozen)
- return ;
-
- timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
- suspended = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
-
- now = ecore_time_get();
-
- timer->pending = timer->at - now;
- timer->at = 0.0;
- timer->frozen = 1;
+ double now;
+
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_freeze");
+ return;
+ }
+
+ /* Timer already frozen */
+ if (timer->frozen)
+ return;
+
+ timers =
+ (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers),
+ EINA_INLIST_GET(timer));
+ suspended =
+ (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(suspended),
+ EINA_INLIST_GET(timer));
+
+ now = ecore_time_get();
+
+ timer->pending = timer->at - now;
+ timer->at = 0.0;
+ timer->frozen = 1;
}
-EAPI void
-ecore_timer_thaw(Ecore_Timer *timer)
+EAPI void ecore_timer_thaw(Ecore_Timer * timer)
{
- double now;
+ double now;
- if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
- {
- ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
- "ecore_timer_thaw");
- return ;
- }
+ if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) {
+ ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
+ "ecore_timer_thaw");
+ return;
+ }
- /* Timer not frozen */
- if (!timer->frozen)
- return ;
+ /* Timer not frozen */
+ if (!timer->frozen)
+ return;
- suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
- now = ecore_time_get();
+ suspended =
+ (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended),
+ EINA_INLIST_GET(timer));
+ now = ecore_time_get();
- _ecore_timer_set(timer, timer->pending + now, timer->in, timer->func, timer->data);
+ _ecore_timer_set(timer, timer->pending + now, timer->in,
+ timer->func, timer->data);
}
-void
-_ecore_timer_shutdown(void)
+void _ecore_timer_shutdown(void)
{
- Ecore_Timer *timer;
-
- while ((timer = timers))
- {
- timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers));
- ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
- }
-
- while ((timer = suspended))
- {
- suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(suspended));
- ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
- }
-
- timer_current = NULL;
+ Ecore_Timer *timer;
+
+ while ((timer = timers)) {
+ timers =
+ (Ecore_Timer *)
+ eina_inlist_remove(EINA_INLIST_GET(timers),
+ EINA_INLIST_GET(timers));
+ ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
+ free(timer);
+ }
+
+ while ((timer = suspended)) {
+ suspended =
+ (Ecore_Timer *)
+ eina_inlist_remove(EINA_INLIST_GET(suspended),
+ EINA_INLIST_GET(suspended));
+ ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
+ free(timer);
+ }
+
+ timer_current = NULL;
}
-void
-_ecore_timer_cleanup(void)
+void _ecore_timer_cleanup(void)
{
- Ecore_Timer *l;
- int in_use = 0, todo = timers_delete_me, done = 0;
-
- if (!timers_delete_me) return;
- for (l = timers; l;)
- {
- Ecore_Timer *timer = l;
-
- l = (Ecore_Timer *) EINA_INLIST_GET(l)->next;
- if (timer->delete_me)
- {
- if (timer->references)
- {
- in_use++;
- continue;
- }
- timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
- ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
- timers_delete_me--;
- done++;
- if (timers_delete_me == 0) return;
- }
- }
- for (l = suspended; l;)
- {
- Ecore_Timer *timer = l;
-
- l = (Ecore_Timer *) EINA_INLIST_GET(l)->next;
- if (timer->delete_me)
- {
- if (timer->references)
- {
- in_use++;
- continue;
- }
- suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
- ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
- timers_delete_me--;
- done++;
- if (timers_delete_me == 0) return;
- }
- }
-
- if ((!in_use) && (timers_delete_me))
- {
- ERR("%d timers to delete, but they were not found!"
- "Stats: todo=%d, done=%d, pending=%d, in_use=%d. "
- "reset counter.",
- timers_delete_me, todo, done, todo - done, in_use);
- timers_delete_me = 0;
- }
+ Ecore_Timer *l;
+ int in_use = 0, todo = timers_delete_me, done = 0;
+
+ if (!timers_delete_me)
+ return;
+ for (l = timers; l;) {
+ Ecore_Timer *timer = l;
+
+ l = (Ecore_Timer *) EINA_INLIST_GET(l)->next;
+ if (timer->delete_me) {
+ if (timer->references) {
+ in_use++;
+ continue;
+ }
+ timers =
+ (Ecore_Timer *)
+ eina_inlist_remove(EINA_INLIST_GET(timers),
+ EINA_INLIST_GET(timer));
+ ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
+ free(timer);
+ timers_delete_me--;
+ done++;
+ if (timers_delete_me == 0)
+ return;
+ }
+ }
+ for (l = suspended; l;) {
+ Ecore_Timer *timer = l;
+
+ l = (Ecore_Timer *) EINA_INLIST_GET(l)->next;
+ if (timer->delete_me) {
+ if (timer->references) {
+ in_use++;
+ continue;
+ }
+ suspended =
+ (Ecore_Timer *)
+ eina_inlist_remove(EINA_INLIST_GET(suspended),
+ EINA_INLIST_GET(timer));
+ ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
+ free(timer);
+ timers_delete_me--;
+ done++;
+ if (timers_delete_me == 0)
+ return;
+ }
+ }
+
+ if ((!in_use) && (timers_delete_me)) {
+ ERR("%d timers to delete, but they were not found!"
+ "Stats: todo=%d, done=%d, pending=%d, in_use=%d. "
+ "reset counter.",
+ timers_delete_me, todo, done, todo - done, in_use);
+ timers_delete_me = 0;
+ }
}
-void
-_ecore_timer_enable_new(void)
+void _ecore_timer_enable_new(void)
{
- Ecore_Timer *timer;
+ Ecore_Timer *timer;
- if (!timers_added) return;
- timers_added = 0;
- EINA_INLIST_FOREACH(timers, timer) timer->just_added = 0;
+ if (!timers_added)
+ return;
+ timers_added = 0;
+ EINA_INLIST_FOREACH(timers, timer) timer->just_added = 0;
}
-int
-_ecore_timers_exists(void)
+int _ecore_timers_exists(void)
{
- Ecore_Timer *timer = timers;
+ Ecore_Timer *timer = timers;
- while ((timer) && (timer->delete_me))
- timer = (Ecore_Timer *)EINA_INLIST_GET(timer)->next;
+ while ((timer) && (timer->delete_me))
+ timer = (Ecore_Timer *) EINA_INLIST_GET(timer)->next;
- return !!timer;
+ return ! !timer;
}
-static inline Ecore_Timer *
-_ecore_timer_first_get(void)
+static inline Ecore_Timer *_ecore_timer_first_get(void)
{
- Ecore_Timer *timer = timers;
+ Ecore_Timer *timer = timers;
- while ((timer) && ((timer->delete_me) || (timer->just_added)))
- timer = (Ecore_Timer *) EINA_INLIST_GET(timer)->next;
+ while ((timer) && ((timer->delete_me) || (timer->just_added)))
+ timer = (Ecore_Timer *) EINA_INLIST_GET(timer)->next;
- return timer;
+ return timer;
}
-static inline Ecore_Timer *
-_ecore_timer_after_get(Ecore_Timer *base)
+static inline Ecore_Timer *_ecore_timer_after_get(Ecore_Timer * base)
{
- Ecore_Timer *timer = (Ecore_Timer *) EINA_INLIST_GET(base)->next;
- double maxtime = base->at + precision;
+ Ecore_Timer *timer = (Ecore_Timer *) EINA_INLIST_GET(base)->next;
+ double maxtime = base->at + precision;
- while ((timer) && ((timer->delete_me) || (timer->just_added)) && (timer->at <= maxtime))
- timer = (Ecore_Timer *) EINA_INLIST_GET(timer)->next;
+ while ((timer) && ((timer->delete_me) || (timer->just_added))
+ && (timer->at <= maxtime))
+ timer = (Ecore_Timer *) EINA_INLIST_GET(timer)->next;
- if ((!timer) || (timer->at > maxtime))
- return NULL;
+ if ((!timer) || (timer->at > maxtime))
+ return NULL;
- return timer;
+ return timer;
}
-double
-_ecore_timer_next_get(void)
+double _ecore_timer_next_get(void)
{
- double now;
- double in;
- Ecore_Timer *first, *second;
-
- first = _ecore_timer_first_get();
- if (!first) return -1;
-
- second = _ecore_timer_after_get(first);
- if (second)
- first = second;
-
- now = ecore_loop_time_get();
- in = first->at - now;
- if (in < 0) in = 0;
- return in;
+ double now;
+ double in;
+ Ecore_Timer *first, *second;
+
+ first = _ecore_timer_first_get();
+ if (!first)
+ return -1;
+
+ second = _ecore_timer_after_get(first);
+ if (second)
+ first = second;
+
+ now = ecore_loop_time_get();
+ in = first->at - now;
+ if (in < 0)
+ in = 0;
+ return in;
}
static inline void
-_ecore_timer_reschedule(Ecore_Timer *timer, double when)
+_ecore_timer_reschedule(Ecore_Timer * timer, double when)
{
- if ((timer->delete_me) || (timer->frozen)) return;
-
- timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
-
- /* if the timer would have gone off more than 15 seconds ago,
- * assume that the system hung and set the timer to go off
- * timer->in from now. this handles system hangs, suspends
- * and more, so ecore will only "replay" the timers while
- * the system is suspended if it is suspended for less than
- * 15 seconds (basically). this also handles if the process
- * is stopped in a debugger or IO and other handling gets
- * really slow within the main loop.
- */
- if ((timer->at + timer->in) < (when - 15.0))
- _ecore_timer_set(timer, when + timer->in, timer->in, timer->func, timer->data);
- else
- _ecore_timer_set(timer, timer->at + timer->in, timer->in, timer->func, timer->data);
+ if ((timer->delete_me) || (timer->frozen))
+ return;
+
+ timers =
+ (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers),
+ EINA_INLIST_GET(timer));
+
+ /* if the timer would have gone off more than 15 seconds ago,
+ * assume that the system hung and set the timer to go off
+ * timer->in from now. this handles system hangs, suspends
+ * and more, so ecore will only "replay" the timers while
+ * the system is suspended if it is suspended for less than
+ * 15 seconds (basically). this also handles if the process
+ * is stopped in a debugger or IO and other handling gets
+ * really slow within the main loop.
+ */
+ if ((timer->at + timer->in) < (when - 15.0))
+ _ecore_timer_set(timer, when + timer->in, timer->in,
+ timer->func, timer->data);
+ else
+ _ecore_timer_set(timer, timer->at + timer->in, timer->in,
+ timer->func, timer->data);
}
-int
-_ecore_timer_call(double when)
+int _ecore_timer_call(double when)
{
- if (!timers) return 0;
- if (last_check > when)
- {
- Ecore_Timer *timer;
- /* User set time backwards */
- EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when);
- }
- last_check = when;
-
- if (!timer_current)
- {
- /* regular main loop, start from head */
- timer_current = timers;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- Ecore_Timer *timer_old = timer_current;
- timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next;
- _ecore_timer_reschedule(timer_old, when);
- }
-
- while (timer_current)
- {
- Ecore_Timer *timer = timer_current;
-
- if (timer->at > when)
- {
- timer_current = NULL; /* ended walk, next should restart. */
- return 0;
- }
-
- if ((timer->just_added) || (timer->delete_me))
- {
- timer_current = (Ecore_Timer*)EINA_INLIST_GET(timer_current)->next;
- continue;
- }
-
- timer->references++;
- if (!timer->func(timer->data))
- {
- if (!timer->delete_me) ecore_timer_del(timer);
- }
- timer->references--;
-
- if (timer_current) /* may have changed in recursive main loops */
- timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next;
-
- _ecore_timer_reschedule(timer, when);
- }
- return 0;
+ if (!timers)
+ return 0;
+ if (last_check > when) {
+ Ecore_Timer *timer;
+ /* User set time backwards */
+ EINA_INLIST_FOREACH(timers, timer) timer->at -=
+ (last_check - when);
+ }
+ last_check = when;
+
+ if (!timer_current) {
+ /* regular main loop, start from head */
+ timer_current = timers;
+ } else {
+ /* recursive main loop, continue from where we were */
+ Ecore_Timer *timer_old = timer_current;
+ timer_current =
+ (Ecore_Timer *) EINA_INLIST_GET(timer_current)->next;
+ _ecore_timer_reschedule(timer_old, when);
+ }
+
+ while (timer_current) {
+ Ecore_Timer *timer = timer_current;
+
+ if (timer->at > when) {
+ timer_current = NULL; /* ended walk, next should restart. */
+ return 0;
+ }
+
+ if ((timer->just_added) || (timer->delete_me)) {
+ timer_current =
+ (Ecore_Timer *)
+ EINA_INLIST_GET(timer_current)->next;
+ continue;
+ }
+
+ timer->references++;
+ if (!timer->func(timer->data)) {
+ if (!timer->delete_me)
+ ecore_timer_del(timer);
+ }
+ timer->references--;
+
+ if (timer_current) /* may have changed in recursive main loops */
+ timer_current =
+ (Ecore_Timer *)
+ EINA_INLIST_GET(timer_current)->next;
+
+ _ecore_timer_reschedule(timer, when);
+ }
+ return 0;
}
static void
-_ecore_timer_set(Ecore_Timer *timer, double at, double in, Ecore_Task_Cb func, void *data)
+_ecore_timer_set(Ecore_Timer * timer, double at, double in,
+ Ecore_Task_Cb func, void *data)
{
- Ecore_Timer *t2;
-
- timers_added = 1;
- timer->at = at;
- timer->in = in;
- timer->func = func;
- timer->data = data;
- timer->just_added = 1;
- timer->frozen = 0;
- timer->pending = 0.0;
- if (timers)
- {
- EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(timers), t2)
- {
- if (timer->at > t2->at)
- {
- timers = (Ecore_Timer *) eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2));
- return;
- }
- }
- }
- timers = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
+ Ecore_Timer *t2;
+
+ timers_added = 1;
+ timer->at = at;
+ timer->in = in;
+ timer->func = func;
+ timer->data = data;
+ timer->just_added = 1;
+ timer->frozen = 0;
+ timer->pending = 0.0;
+ if (timers) {
+ EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(timers), t2) {
+ if (timer->at > t2->at) {
+ timers =
+ (Ecore_Timer *)
+ eina_inlist_append_relative
+ (EINA_INLIST_GET(timers),
+ EINA_INLIST_GET(timer),
+ EINA_INLIST_GET(t2));
+ return;
+ }
+ }
+ }
+ timers =
+ (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(timers),
+ EINA_INLIST_GET(timer));
}
diff --git a/tests/suite/ecore/src/lib/eina_accessor.c b/tests/suite/ecore/src/lib/eina_accessor.c
index cb20cab184..ade870a935 100644
--- a/tests/suite/ecore/src/lib/eina_accessor.c
+++ b/tests/suite/ecore/src/lib/eina_accessor.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -64,10 +64,10 @@ static const char EINA_MAGIC_ACCESSOR_STR[] = "Eina Accessor";
*
* @see eina_init()
*/
-Eina_Bool
-eina_accessor_init(void)
+Eina_Bool eina_accessor_init(void)
{
- return eina_magic_string_set(EINA_MAGIC_ACCESSOR, EINA_MAGIC_ACCESSOR_STR);
+ return eina_magic_string_set(EINA_MAGIC_ACCESSOR,
+ EINA_MAGIC_ACCESSOR_STR);
}
/**
@@ -81,10 +81,9 @@ eina_accessor_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_accessor_shutdown(void)
+Eina_Bool eina_accessor_shutdown(void)
{
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -118,13 +117,12 @@ eina_accessor_shutdown(void)
*
* This function frees @p accessor if it is not @c NULL;
*/
-EAPI void
-eina_accessor_free(Eina_Accessor *accessor)
+EAPI void eina_accessor_free(Eina_Accessor * accessor)
{
- EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN(accessor);
- EINA_SAFETY_ON_NULL_RETURN(accessor->free);
- accessor->free(accessor);
+ EINA_MAGIC_CHECK_ACCESSOR(accessor);
+ EINA_SAFETY_ON_NULL_RETURN(accessor);
+ EINA_SAFETY_ON_NULL_RETURN(accessor->free);
+ accessor->free(accessor);
}
/**
@@ -136,13 +134,12 @@ eina_accessor_free(Eina_Accessor *accessor)
* This function returns the container which created @p accessor. If
* @p accessor is @c NULL, this function returns @c NULL.
*/
-EAPI void *
-eina_accessor_container_get(Eina_Accessor *accessor)
+EAPI void *eina_accessor_container_get(Eina_Accessor * accessor)
{
- EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_container, NULL);
- return accessor->get_container(accessor);
+ EINA_MAGIC_CHECK_ACCESSOR(accessor);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_container, NULL);
+ return accessor->get_container(accessor);
}
/**
@@ -159,15 +156,14 @@ eina_accessor_container_get(Eina_Accessor *accessor)
* #EINA_FALSE is returned, otherwise EINA_TRUE is returned.
*/
EAPI Eina_Bool
-eina_accessor_data_get(Eina_Accessor *accessor,
- unsigned int position,
- void **data)
+eina_accessor_data_get(Eina_Accessor * accessor,
+ unsigned int position, void **data)
{
- EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_at, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
- return accessor->get_at(accessor, position, data);
+ EINA_MAGIC_CHECK_ACCESSOR(accessor);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_at, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ return accessor->get_at(accessor, position, data);
}
/**
@@ -187,34 +183,33 @@ eina_accessor_data_get(Eina_Accessor *accessor,
* immediately.
*/
EAPI void
-eina_accessor_over(Eina_Accessor *accessor,
- Eina_Each_Cb cb,
- unsigned int start,
- unsigned int end,
- const void *fdata)
+eina_accessor_over(Eina_Accessor * accessor,
+ Eina_Each_Cb cb,
+ unsigned int start, unsigned int end, const void *fdata)
{
- const void *container;
- void *data;
- unsigned int i;
+ const void *container;
+ void *data;
+ unsigned int i;
- EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN(accessor);
- EINA_SAFETY_ON_NULL_RETURN(accessor->get_container);
- EINA_SAFETY_ON_NULL_RETURN(accessor->get_at);
- EINA_SAFETY_ON_NULL_RETURN(cb);
- EINA_SAFETY_ON_FALSE_RETURN(start < end);
+ EINA_MAGIC_CHECK_ACCESSOR(accessor);
+ EINA_SAFETY_ON_NULL_RETURN(accessor);
+ EINA_SAFETY_ON_NULL_RETURN(accessor->get_container);
+ EINA_SAFETY_ON_NULL_RETURN(accessor->get_at);
+ EINA_SAFETY_ON_NULL_RETURN(cb);
+ EINA_SAFETY_ON_FALSE_RETURN(start < end);
- if (!eina_accessor_lock(accessor))
- return ;
+ if (!eina_accessor_lock(accessor))
+ return;
- container = accessor->get_container(accessor);
- for (i = start; i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE;
- ++i)
- if (cb(container, data, (void *)fdata) != EINA_TRUE)
- goto on_exit;
+ container = accessor->get_container(accessor);
+ for (i = start;
+ i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE;
+ ++i)
+ if (cb(container, data, (void *) fdata) != EINA_TRUE)
+ goto on_exit;
- on_exit:
- (void) eina_accessor_unlock(accessor);
+ on_exit:
+ (void) eina_accessor_unlock(accessor);
}
/**
@@ -228,15 +223,14 @@ eina_accessor_over(Eina_Accessor *accessor,
* returned, otherwise #EINA_TRUE is returned. If the container
* is not lockable, it will return EINA_TRUE.
*/
-EAPI Eina_Bool
-eina_accessor_lock(Eina_Accessor *accessor)
+EAPI Eina_Bool eina_accessor_lock(Eina_Accessor * accessor)
{
- EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
+ EINA_MAGIC_CHECK_ACCESSOR(accessor);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
- if (accessor->lock)
- return accessor->lock(accessor);
- return EINA_TRUE;
+ if (accessor->lock)
+ return accessor->lock(accessor);
+ return EINA_TRUE;
}
/**
@@ -251,15 +245,14 @@ eina_accessor_lock(Eina_Accessor *accessor)
* is returned. If the container is not lockable, it will return
* EINA_TRUE.
*/
-EAPI Eina_Bool
-eina_accessor_unlock(Eina_Accessor *accessor)
+EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor * accessor)
{
- EINA_MAGIC_CHECK_ACCESSOR(accessor);
- EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
+ EINA_MAGIC_CHECK_ACCESSOR(accessor);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
- if (accessor->unlock)
- return accessor->unlock(accessor);
- return EINA_TRUE;
+ if (accessor->unlock)
+ return accessor->unlock(accessor);
+ return EINA_TRUE;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_array.c b/tests/suite/ecore/src/lib/eina_array.c
index bd71fc9782..e6bb0493df 100644
--- a/tests/suite/ecore/src/lib/eina_array.c
+++ b/tests/suite/ecore/src/lib/eina_array.c
@@ -107,7 +107,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <assert.h>
@@ -162,23 +162,19 @@ static const char EINA_MAGIC_ARRAY_ACCESSOR_STR[] = "Eina Array Accessor";
typedef struct _Eina_Iterator_Array Eina_Iterator_Array;
-struct _Eina_Iterator_Array
-{
- Eina_Iterator iterator;
+struct _Eina_Iterator_Array {
+ Eina_Iterator iterator;
- const Eina_Array *array;
- unsigned int index;
+ const Eina_Array *array;
+ unsigned int index;
- EINA_MAGIC
-};
+ EINA_MAGIC};
typedef struct _Eina_Accessor_Array Eina_Accessor_Array;
-struct _Eina_Accessor_Array
-{
- Eina_Accessor accessor;
- const Eina_Array *array;
- EINA_MAGIC
-};
+struct _Eina_Accessor_Array {
+ Eina_Accessor accessor;
+ const Eina_Array *array;
+ EINA_MAGIC};
static int _eina_array_log_dom = -1;
@@ -192,99 +188,101 @@ static int _eina_array_log_dom = -1;
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eina_array_log_dom, __VA_ARGS__)
-static void eina_array_iterator_free(Eina_Iterator_Array *it) EINA_ARG_NONNULL(1);
-static Eina_Array *eina_array_iterator_get_container(Eina_Iterator_Array *it) EINA_ARG_NONNULL(1);
-static Eina_Bool eina_array_iterator_next(Eina_Iterator_Array *it,
- void **data) EINA_ARG_NONNULL(1);
-
-static Eina_Bool eina_array_accessor_get_at(Eina_Accessor_Array *it,
- unsigned int idx,
- void **data) EINA_ARG_NONNULL(1);
-static Eina_Array *eina_array_accessor_get_container(Eina_Accessor_Array *it) EINA_ARG_NONNULL(1);
-static void eina_array_accessor_free(Eina_Accessor_Array *it) EINA_ARG_NONNULL(1);
+static void eina_array_iterator_free(Eina_Iterator_Array *
+ it) EINA_ARG_NONNULL(1);
+static Eina_Array *eina_array_iterator_get_container(Eina_Iterator_Array *
+ it)
+EINA_ARG_NONNULL(1);
+static Eina_Bool eina_array_iterator_next(Eina_Iterator_Array * it,
+ void **data) EINA_ARG_NONNULL(1);
+
+static Eina_Bool eina_array_accessor_get_at(Eina_Accessor_Array * it,
+ unsigned int idx,
+ void **data)
+EINA_ARG_NONNULL(1);
+static Eina_Array *eina_array_accessor_get_container(Eina_Accessor_Array *
+ it)
+EINA_ARG_NONNULL(1);
+static void eina_array_accessor_free(Eina_Accessor_Array *
+ it) EINA_ARG_NONNULL(1);
static Eina_Bool
-eina_array_iterator_next(Eina_Iterator_Array *it, void **data)
+eina_array_iterator_next(Eina_Iterator_Array * it, void **data)
{
- EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, EINA_FALSE);
+ EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, EINA_FALSE);
- if (!(it->index < eina_array_count_get(it->array)))
- return EINA_FALSE;
+ if (!(it->index < eina_array_count_get(it->array)))
+ return EINA_FALSE;
- if (data)
- *data = eina_array_data_get(it->array, it->index);
+ if (data)
+ *data = eina_array_data_get(it->array, it->index);
- it->index++;
- return EINA_TRUE;
+ it->index++;
+ return EINA_TRUE;
}
-static Eina_Array *
-eina_array_iterator_get_container(Eina_Iterator_Array *it)
+static Eina_Array *eina_array_iterator_get_container(Eina_Iterator_Array *
+ it)
{
- EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, NULL);
- return (Eina_Array *)it->array;
+ EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, NULL);
+ return (Eina_Array *) it->array;
}
-static void
-eina_array_iterator_free(Eina_Iterator_Array *it)
+static void eina_array_iterator_free(Eina_Iterator_Array * it)
{
- EINA_MAGIC_CHECK_ARRAY_ITERATOR(it);
- MAGIC_FREE(it);
+ EINA_MAGIC_CHECK_ARRAY_ITERATOR(it);
+ MAGIC_FREE(it);
}
static Eina_Bool
-eina_array_accessor_get_at(Eina_Accessor_Array *it,
- unsigned int idx,
- void **data)
+eina_array_accessor_get_at(Eina_Accessor_Array * it,
+ unsigned int idx, void **data)
{
- EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, EINA_FALSE);
+ EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, EINA_FALSE);
- if (!(idx < eina_array_count_get(it->array)))
- return EINA_FALSE;
+ if (!(idx < eina_array_count_get(it->array)))
+ return EINA_FALSE;
- if (data)
- *data = eina_array_data_get(it->array, idx);
+ if (data)
+ *data = eina_array_data_get(it->array, idx);
- return EINA_TRUE;
+ return EINA_TRUE;
}
-static Eina_Array *
-eina_array_accessor_get_container(Eina_Accessor_Array *it)
+static Eina_Array *eina_array_accessor_get_container(Eina_Accessor_Array *
+ it)
{
- EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, NULL);
- return (Eina_Array *)it->array;
+ EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, NULL);
+ return (Eina_Array *) it->array;
}
-static void
-eina_array_accessor_free(Eina_Accessor_Array *it)
+static void eina_array_accessor_free(Eina_Accessor_Array * it)
{
- EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it);
- MAGIC_FREE(it);
+ EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it);
+ MAGIC_FREE(it);
}
-EAPI Eina_Bool
-eina_array_grow(Eina_Array *array)
+EAPI Eina_Bool eina_array_grow(Eina_Array * array)
{
- void **tmp;
- unsigned int total;
+ void **tmp;
+ unsigned int total;
- EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
- EINA_MAGIC_CHECK_ARRAY(array);
+ EINA_MAGIC_CHECK_ARRAY(array);
- total = array->total + array->step;
- eina_error_set(0);
- tmp = realloc(array->data, sizeof (void *) * total);
- if (EINA_UNLIKELY(!tmp))
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
- }
+ total = array->total + array->step;
+ eina_error_set(0);
+ tmp = realloc(array->data, sizeof(void *) * total);
+ if (EINA_UNLIKELY(!tmp)) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
+ }
- array->total = total;
- array->data = tmp;
+ array->total = total;
+ array->data = tmp;
- return 1;
+ return 1;
}
/**
@@ -307,23 +305,20 @@ eina_array_grow(Eina_Array *array)
*
* @see eina_init()
*/
-Eina_Bool
-eina_array_init(void)
+Eina_Bool eina_array_init(void)
{
- _eina_array_log_dom = eina_log_domain_register("eina_array",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_array_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_array");
- return EINA_FALSE;
- }
-
+ _eina_array_log_dom = eina_log_domain_register("eina_array",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_array_log_dom < 0) {
+ EINA_LOG_ERR("Could not register log domain: eina_array");
+ return EINA_FALSE;
+ }
#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
- EMS(EINA_MAGIC_ARRAY);
- EMS(EINA_MAGIC_ARRAY_ITERATOR);
- EMS(EINA_MAGIC_ARRAY_ACCESSOR);
+ EMS(EINA_MAGIC_ARRAY);
+ EMS(EINA_MAGIC_ARRAY_ITERATOR);
+ EMS(EINA_MAGIC_ARRAY_ACCESSOR);
#undef EMS
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -337,12 +332,11 @@ eina_array_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_array_shutdown(void)
+Eina_Bool eina_array_shutdown(void)
{
- eina_log_domain_unregister(_eina_array_log_dom);
- _eina_array_log_dom = -1;
- return EINA_TRUE;
+ eina_log_domain_unregister(_eina_array_log_dom);
+ _eina_array_log_dom = -1;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -401,28 +395,26 @@ eina_array_shutdown(void)
* allocation fails. In that case, the error is set to
* #EINA_ERROR_OUT_OF_MEMORY.
*/
-EAPI Eina_Array *
-eina_array_new(unsigned int step)
+EAPI Eina_Array *eina_array_new(unsigned int step)
{
- Eina_Array *array;
+ Eina_Array *array;
- eina_error_set(0);
- array = malloc(sizeof (Eina_Array));
- if (!array)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ array = malloc(sizeof(Eina_Array));
+ if (!array) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
+ EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
- array->version = EINA_ARRAY_VERSION;
- array->data = NULL;
- array->total = 0;
- array->count = 0;
- array->step = step;
+ array->version = EINA_ARRAY_VERSION;
+ array->data = NULL;
+ array->total = 0;
+ array->count = 0;
+ array->step = step;
- return array;
+ return array;
}
/**
@@ -436,14 +428,13 @@ eina_array_new(unsigned int step)
* #EINA_ARRAY_ITER_NEXT. For performance reasons, there is no check
* of @p array.
*/
-EAPI void
-eina_array_free(Eina_Array *array)
+EAPI void eina_array_free(Eina_Array * array)
{
- eina_array_flush(array);
+ eina_array_flush(array);
- EINA_SAFETY_ON_NULL_RETURN(array);
- EINA_MAGIC_CHECK_ARRAY(array);
- MAGIC_FREE(array);
+ EINA_SAFETY_ON_NULL_RETURN(array);
+ EINA_MAGIC_CHECK_ARRAY(array);
+ MAGIC_FREE(array);
}
/**
@@ -459,28 +450,25 @@ eina_array_free(Eina_Array *array)
* the array is not initialized.
*/
EAPI void
-eina_array_step_set(Eina_Array *array,
- unsigned int sizeof_eina_array,
- unsigned int step)
+eina_array_step_set(Eina_Array * array,
+ unsigned int sizeof_eina_array, unsigned int step)
{
- EINA_SAFETY_ON_NULL_RETURN(array);
-
- if (sizeof (Eina_Array) != sizeof_eina_array)
- {
- ERR("Unknow Eina_Array size ! Got %i, expected %i !\n",
- sizeof_eina_array,
- (int) sizeof (Eina_Array));
- /* Force memory to zero to provide a small layer of security */
- memset(array, 0, sizeof_eina_array);
- return ;
- }
-
- array->version = EINA_ARRAY_VERSION;
- array->data = NULL;
- array->total = 0;
- array->count = 0;
- array->step = step;
- EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
+ EINA_SAFETY_ON_NULL_RETURN(array);
+
+ if (sizeof(Eina_Array) != sizeof_eina_array) {
+ ERR("Unknow Eina_Array size ! Got %i, expected %i !\n",
+ sizeof_eina_array, (int) sizeof(Eina_Array));
+ /* Force memory to zero to provide a small layer of security */
+ memset(array, 0, sizeof_eina_array);
+ return;
+ }
+
+ array->version = EINA_ARRAY_VERSION;
+ array->data = NULL;
+ array->total = 0;
+ array->count = 0;
+ array->step = step;
+ EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
}
/**
@@ -492,13 +480,12 @@ eina_array_step_set(Eina_Array *array,
* performance reasons, there is no check of @p array. If it is
* @c NULL or invalid, the program may crash.
*/
-EAPI void
-eina_array_clean(Eina_Array *array)
+EAPI void eina_array_clean(Eina_Array * array)
{
- EINA_SAFETY_ON_NULL_RETURN(array);
- EINA_MAGIC_CHECK_ARRAY(array);
+ EINA_SAFETY_ON_NULL_RETURN(array);
+ EINA_MAGIC_CHECK_ARRAY(array);
- array->count = 0;
+ array->count = 0;
}
/**
@@ -511,20 +498,19 @@ eina_array_clean(Eina_Array *array)
* there is no check of @p array. If it is @c NULL or invalid, the
* program may crash.
*/
-EAPI void
-eina_array_flush(Eina_Array *array)
+EAPI void eina_array_flush(Eina_Array * array)
{
- EINA_SAFETY_ON_NULL_RETURN(array);
- EINA_MAGIC_CHECK_ARRAY(array);
+ EINA_SAFETY_ON_NULL_RETURN(array);
+ EINA_MAGIC_CHECK_ARRAY(array);
- array->count = 0;
- array->total = 0;
+ array->count = 0;
+ array->total = 0;
- if (!array->data)
- return;
+ if (!array->data)
+ return;
- free(array->data);
- array->data = NULL;
+ free(array->data);
+ array->data = NULL;
}
/**
@@ -545,97 +531,89 @@ eina_array_flush(Eina_Array *array)
* and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
*/
EAPI Eina_Bool
-eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data,
- void *gdata),
- void *gdata)
+eina_array_remove(Eina_Array * array, Eina_Bool(*keep) (void *data,
+ void *gdata),
+ void *gdata)
{
- void **tmp;
- /* WARNING:
- The algorithm does exit before using unitialized data. So compiler is
- giving you a false positiv here too.
- */
- void *data = NULL;
- unsigned int total = 0;
- unsigned int limit;
- unsigned int i;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(keep, EINA_FALSE);
- EINA_MAGIC_CHECK_ARRAY(array);
-
- if (array->total == 0)
- return EINA_TRUE;
-
- for (i = 0; i < array->count; ++i)
- {
- data = eina_array_data_get(array, i);
-
- if (keep(data, gdata) == EINA_FALSE)
- break;
- }
- limit = i;
- if (i < array->count)
- ++i;
-
- for (; i < array->count; ++i)
- {
- data = eina_array_data_get(array, i);
-
- if (keep(data, gdata) == EINA_TRUE)
- break;
- }
- /* Special case all objects that need to stay are at the beginning of the array. */
- if (i == array->count)
- {
- array->count = limit;
- if (array->count == 0)
- {
- free(array->data);
- array->total = 0;
- array->data = NULL;
- }
-
- return EINA_TRUE;
- }
-
- eina_error_set(0);
- tmp = malloc(sizeof (void *) * array->total);
- if (!tmp)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
- }
-
- memcpy(tmp, array->data, limit * sizeof(void *));
- total = limit;
-
- if (i < array->count)
- {
- tmp[total] = data;
- total++;
- ++i;
- }
-
- for (; i < array->count; ++i)
- {
- data = eina_array_data_get(array, i);
-
- if (keep(data, gdata))
- {
- tmp[total] = data;
- total++;
- }
- }
-
- free(array->data);
-
- /* If we do not keep any object in the array, we should have exited
- earlier in test (i == array->count). */
- assert(total != 0);
-
- array->data = tmp;
- array->count = total;
- return EINA_TRUE;
+ void **tmp;
+ /* WARNING:
+ The algorithm does exit before using unitialized data. So compiler is
+ giving you a false positiv here too.
+ */
+ void *data = NULL;
+ unsigned int total = 0;
+ unsigned int limit;
+ unsigned int i;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(keep, EINA_FALSE);
+ EINA_MAGIC_CHECK_ARRAY(array);
+
+ if (array->total == 0)
+ return EINA_TRUE;
+
+ for (i = 0; i < array->count; ++i) {
+ data = eina_array_data_get(array, i);
+
+ if (keep(data, gdata) == EINA_FALSE)
+ break;
+ }
+ limit = i;
+ if (i < array->count)
+ ++i;
+
+ for (; i < array->count; ++i) {
+ data = eina_array_data_get(array, i);
+
+ if (keep(data, gdata) == EINA_TRUE)
+ break;
+ }
+ /* Special case all objects that need to stay are at the beginning of the array. */
+ if (i == array->count) {
+ array->count = limit;
+ if (array->count == 0) {
+ free(array->data);
+ array->total = 0;
+ array->data = NULL;
+ }
+
+ return EINA_TRUE;
+ }
+
+ eina_error_set(0);
+ tmp = malloc(sizeof(void *) * array->total);
+ if (!tmp) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
+ }
+
+ memcpy(tmp, array->data, limit * sizeof(void *));
+ total = limit;
+
+ if (i < array->count) {
+ tmp[total] = data;
+ total++;
+ ++i;
+ }
+
+ for (; i < array->count; ++i) {
+ data = eina_array_data_get(array, i);
+
+ if (keep(data, gdata)) {
+ tmp[total] = data;
+ total++;
+ }
+ }
+
+ free(array->data);
+
+ /* If we do not keep any object in the array, we should have exited
+ earlier in test (i == array->count). */
+ assert(total != 0);
+
+ array->data = tmp;
+ array->count = total;
+ return EINA_TRUE;
}
/**
@@ -650,34 +628,32 @@ eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data,
* not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
* set. Otherwise, a valid iterator is returned.
*/
-EAPI Eina_Iterator *
-eina_array_iterator_new(const Eina_Array *array)
+EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array * array)
{
- Eina_Iterator_Array *it;
+ Eina_Iterator_Array *it;
- EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
- EINA_MAGIC_CHECK_ARRAY(array);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
+ EINA_MAGIC_CHECK_ARRAY(array);
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_Array));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_Array));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ITERATOR);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- it->array = array;
+ it->array = array;
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(eina_array_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- eina_array_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(eina_array_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(eina_array_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(eina_array_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(eina_array_iterator_free);
- return &it->iterator;
+ return &it->iterator;
}
/**
@@ -692,34 +668,33 @@ eina_array_iterator_new(const Eina_Array *array)
* not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
* set. Otherwise, a valid accessor is returned.
*/
-EAPI Eina_Accessor *
-eina_array_accessor_new(const Eina_Array *array)
+EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array * array)
{
- Eina_Accessor_Array *ac;
+ Eina_Accessor_Array *ac;
- EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
- EINA_MAGIC_CHECK_ARRAY(array);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
+ EINA_MAGIC_CHECK_ARRAY(array);
- eina_error_set(0);
- ac = calloc(1, sizeof (Eina_Accessor_Array));
- if (!ac)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ ac = calloc(1, sizeof(Eina_Accessor_Array));
+ if (!ac) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(ac, EINA_MAGIC_ARRAY_ACCESSOR);
- EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
+ EINA_MAGIC_SET(ac, EINA_MAGIC_ARRAY_ACCESSOR);
+ EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
- ac->array = array;
+ ac->array = array;
- ac->accessor.version = EINA_ACCESSOR_VERSION;
- ac->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_array_accessor_get_at);
- ac->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
- eina_array_accessor_get_container);
- ac->accessor.free = FUNC_ACCESSOR_FREE(eina_array_accessor_free);
+ ac->accessor.version = EINA_ACCESSOR_VERSION;
+ ac->accessor.get_at =
+ FUNC_ACCESSOR_GET_AT(eina_array_accessor_get_at);
+ ac->accessor.get_container =
+ FUNC_ACCESSOR_GET_CONTAINER(eina_array_accessor_get_container);
+ ac->accessor.free = FUNC_ACCESSOR_FREE(eina_array_accessor_free);
- return &ac->accessor;
+ return &ac->accessor;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_benchmark.c b/tests/suite/ecore/src/lib/eina_benchmark.c
index 5cd3fd36e1..83ead5ee5a 100644
--- a/tests/suite/ecore/src/lib/eina_benchmark.c
+++ b/tests/suite/ecore/src/lib/eina_benchmark.c
@@ -288,24 +288,24 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
+#include <alloca.h>
#elif defined __GNUC__
-# define alloca __builtin_alloca
+#define alloca __builtin_alloca
#elif defined _AIX
-# define alloca __alloca
+#define alloca __alloca
#elif defined _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
+#include <malloc.h>
+#define alloca _alloca
#else
-# include <stddef.h>
-# ifdef __cplusplus
+#include <stddef.h>
+#ifdef __cplusplus
extern "C"
-# endif
-void *alloca (size_t);
+#endif
+void *alloca(size_t);
#endif
#include <stdlib.h>
@@ -313,7 +313,7 @@ void *alloca (size_t);
#include <string.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -336,24 +336,22 @@ void *alloca (size_t);
#define EINA_BENCHMARK_DATA_MASK "bench_%s_%s.%s.data"
typedef struct _Eina_Run Eina_Run;
-struct _Eina_Run
-{
- EINA_INLIST;
-
- Eina_Benchmark_Specimens cb;
- const char *name;
- int start;
- int end;
- int step;
+struct _Eina_Run {
+ EINA_INLIST;
+
+ Eina_Benchmark_Specimens cb;
+ const char *name;
+ int start;
+ int end;
+ int step;
};
-struct _Eina_Benchmark
-{
- const char *name;
- const char *run;
+struct _Eina_Benchmark {
+ const char *name;
+ const char *run;
- Eina_Inlist *runs;
- Eina_List *names;
+ Eina_Inlist *runs;
+ Eina_List *names;
};
static int _eina_benchmark_log_dom = -1;
@@ -387,18 +385,18 @@ static int _eina_benchmark_log_dom = -1;
*
* @see eina_init()
*/
-Eina_Bool
-eina_benchmark_init(void)
+Eina_Bool eina_benchmark_init(void)
{
- _eina_benchmark_log_dom = eina_log_domain_register("eina_benchmark",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_benchmark_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_benchmark");
- return EINA_FALSE;
- }
-
- return EINA_TRUE;
+ _eina_benchmark_log_dom =
+ eina_log_domain_register("eina_benchmark",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_benchmark_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_benchmark");
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
}
/**
@@ -412,12 +410,11 @@ eina_benchmark_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_benchmark_shutdown(void)
+Eina_Bool eina_benchmark_shutdown(void)
{
- eina_log_domain_unregister(_eina_benchmark_log_dom);
- _eina_benchmark_log_dom = -1;
- return EINA_TRUE;
+ eina_log_domain_unregister(_eina_benchmark_log_dom);
+ _eina_benchmark_log_dom = -1;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -468,23 +465,21 @@ eina_benchmark_shutdown(void)
* When the new module is not needed anymore, use
* eina_benchmark_free() to free the allocated memory.
*/
-EAPI Eina_Benchmark *
-eina_benchmark_new(const char *name, const char *run)
+EAPI Eina_Benchmark *eina_benchmark_new(const char *name, const char *run)
{
- Eina_Benchmark *new;
+ Eina_Benchmark *new;
- eina_error_set(0);
- new = calloc(1, sizeof (Eina_Benchmark));
- if (!new)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ new = calloc(1, sizeof(Eina_Benchmark));
+ if (!new) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- new->name = name;
- new->run = run;
+ new->name = name;
+ new->run = run;
- return new;
+ return new;
}
/**
@@ -496,35 +491,32 @@ eina_benchmark_new(const char *name, const char *run)
* registered and frees @p bench. If @p bench is @c NULL, this
* function returns immediately.
*/
-EAPI void
-eina_benchmark_free(Eina_Benchmark *bench)
+EAPI void eina_benchmark_free(Eina_Benchmark * bench)
{
- Eina_Array *names;
+ Eina_Array *names;
- if (!bench)
- return;
+ if (!bench)
+ return;
- while (bench->runs)
- {
- Eina_Run *run = (Eina_Run *)bench->runs;
+ while (bench->runs) {
+ Eina_Run *run = (Eina_Run *) bench->runs;
- bench->runs = eina_inlist_remove(bench->runs, bench->runs);
- free(run);
- }
+ bench->runs = eina_inlist_remove(bench->runs, bench->runs);
+ free(run);
+ }
- EINA_LIST_FREE(bench->names, names)
- {
- Eina_Array_Iterator it;
- char *tmp;
- unsigned int i;
+ EINA_LIST_FREE(bench->names, names) {
+ Eina_Array_Iterator it;
+ char *tmp;
+ unsigned int i;
- EINA_ARRAY_ITER_NEXT(names, i, tmp, it)
- free(tmp);
+ EINA_ARRAY_ITER_NEXT(names, i, tmp, it)
+ free(tmp);
- eina_array_free(names);
- }
+ eina_array_free(names);
+ }
- free(bench);
+ free(bench);
}
/**
@@ -549,38 +541,36 @@ eina_benchmark_free(Eina_Benchmark *bench)
* to #EINA_ERROR_OUT_OF_MEMORY.
*/
EAPI Eina_Bool
-eina_benchmark_register(Eina_Benchmark *bench,
- const char *name,
- Eina_Benchmark_Specimens bench_cb,
- int count_start,
- int count_end,
- int count_step)
+eina_benchmark_register(Eina_Benchmark * bench,
+ const char *name,
+ Eina_Benchmark_Specimens bench_cb,
+ int count_start, int count_end, int count_step)
{
- Eina_Run *run;
+ Eina_Run *run;
- if (!bench)
- return EINA_FALSE;
+ if (!bench)
+ return EINA_FALSE;
- if (count_step == 0)
- return EINA_FALSE;
+ if (count_step == 0)
+ return EINA_FALSE;
- eina_error_set(0);
- run = calloc(1, sizeof (Eina_Run));
- if (!run)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
- }
+ eina_error_set(0);
+ run = calloc(1, sizeof(Eina_Run));
+ if (!run) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
+ }
- run->cb = bench_cb;
- run->name = name;
- run->start = count_start;
- run->end = count_end;
- run->step = count_step;
+ run->cb = bench_cb;
+ run->name = name;
+ run->start = count_start;
+ run->end = count_end;
+ run->step = count_step;
- bench->runs = eina_inlist_append(bench->runs, EINA_INLIST_GET(run));
+ bench->runs =
+ eina_inlist_append(bench->runs, EINA_INLIST_GET(run));
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -608,133 +598,121 @@ eina_benchmark_register(Eina_Benchmark *bench,
* immediately. Otherwise, it returns the list of the names of each
* test.
*/
-EAPI Eina_Array *
-eina_benchmark_run(Eina_Benchmark *bench)
+EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark * bench)
{
- FILE *main_script;
- FILE *current_data;
- Eina_Array *ea;
- Eina_Run *run;
- char *buffer;
- Eina_Bool first = EINA_FALSE;
- size_t length;
-
- if (!bench)
- return NULL;
-
- length = strlen(EINA_BENCHMARK_FILENAME_MASK) + strlen(bench->name) + strlen(
- bench->run);
-
- buffer = alloca(sizeof (char) * length);
- if (!buffer)
- return NULL;
-
- snprintf(buffer,
- length,
- EINA_BENCHMARK_FILENAME_MASK,
- bench->name,
- bench->run);
-
- main_script = fopen(buffer, "w");
- if (!main_script)
- return NULL;
-
- ea = eina_array_new(16);
- if (!ea)
- {
- fclose(main_script);
- return NULL;
- }
-
- eina_array_push(ea, strdup(buffer));
-
- fprintf(
- main_script,
- "set autoscale # scale axes automatically\n"
- "unset log # remove any log-scaling\n"
- "unset label # remove any previous labels\n"
- "set xtic auto # set xtics automatically\n"
- "set ytic auto # set ytics automatically\n"
+ FILE *main_script;
+ FILE *current_data;
+ Eina_Array *ea;
+ Eina_Run *run;
+ char *buffer;
+ Eina_Bool first = EINA_FALSE;
+ size_t length;
+
+ if (!bench)
+ return NULL;
+
+ length =
+ strlen(EINA_BENCHMARK_FILENAME_MASK) + strlen(bench->name) +
+ strlen(bench->run);
+
+ buffer = alloca(sizeof(char) * length);
+ if (!buffer)
+ return NULL;
+
+ snprintf(buffer,
+ length,
+ EINA_BENCHMARK_FILENAME_MASK, bench->name, bench->run);
+
+ main_script = fopen(buffer, "w");
+ if (!main_script)
+ return NULL;
+
+ ea = eina_array_new(16);
+ if (!ea) {
+ fclose(main_script);
+ return NULL;
+ }
+
+ eina_array_push(ea, strdup(buffer));
+
+ fprintf(main_script,
+ "set autoscale # scale axes automatically\n"
+ "unset log # remove any log-scaling\n"
+ "unset label # remove any previous labels\n"
+ "set xtic auto # set xtics automatically\n"
+ "set ytic auto # set ytics automatically\n"
/* "set logscale y\n" */
- "set terminal png size 1024,768\n"
- "set output \"output_%s_%s.png\"\n"
- "set title \"%s %s\n"
- "set xlabel \"tests\"\n"
- "set ylabel \"time\"\n"
- "plot ",
- bench->name,
- bench->run,
- bench->name,
- bench->run);
-
- EINA_INLIST_FOREACH(bench->runs, run)
- {
- Eina_Counter *counter;
- char *result;
- size_t tmp;
- int i;
-
- tmp = strlen(EINA_BENCHMARK_DATA_MASK) + strlen(bench->name) + strlen(
- bench->run) + strlen(run->name);
- if (tmp > length)
- {
- buffer = alloca(sizeof (char) * tmp);
- length = tmp;
- }
-
- snprintf(buffer,
- length,
- EINA_BENCHMARK_DATA_MASK,
- bench->name,
- bench->run,
- run->name);
-
- current_data = fopen(buffer, "w");
- if (!current_data)
- continue;
-
- eina_array_push(ea, strdup(buffer));
-
- counter = eina_counter_new(run->name);
-
- for (i = run->start; i < run->end; i += run->step)
- {
- fprintf(stderr, "Run %s: %i\n", run->name, i);
- eina_counter_start(counter);
-
- run->cb(i);
-
- eina_counter_stop(counter, i);
- }
-
- result = eina_counter_dump(counter);
- if (result)
- {
- fprintf(current_data, "%s", result);
- free(result);
- }
-
- eina_counter_free(counter);
-
- fclose(current_data);
-
- if (first == EINA_FALSE)
- first = EINA_TRUE;
- else
- fprintf(main_script, ", \\\n");
-
- fprintf(main_script,
- "\"%s\" using 1:2 title \'%s\' with line",
- buffer, run->name);
- }
-
- fprintf(main_script, "\n");
-
- fclose(main_script);
-
- bench->names = eina_list_append(bench->names, ea);
-
- return ea;
+ "set terminal png size 1024,768\n"
+ "set output \"output_%s_%s.png\"\n"
+ "set title \"%s %s\n"
+ "set xlabel \"tests\"\n"
+ "set ylabel \"time\"\n"
+ "plot ", bench->name, bench->run, bench->name, bench->run);
+
+ EINA_INLIST_FOREACH(bench->runs, run) {
+ Eina_Counter *counter;
+ char *result;
+ size_t tmp;
+ int i;
+
+ tmp =
+ strlen(EINA_BENCHMARK_DATA_MASK) +
+ strlen(bench->name) + strlen(bench->run) +
+ strlen(run->name);
+ if (tmp > length) {
+ buffer = alloca(sizeof(char) * tmp);
+ length = tmp;
+ }
+
+ snprintf(buffer,
+ length,
+ EINA_BENCHMARK_DATA_MASK,
+ bench->name, bench->run, run->name);
+
+ current_data = fopen(buffer, "w");
+ if (!current_data)
+ continue;
+
+ eina_array_push(ea, strdup(buffer));
+
+ counter = eina_counter_new(run->name);
+
+ for (i = run->start; i < run->end; i += run->step) {
+ fprintf(stderr, "Run %s: %i\n", run->name, i);
+ eina_counter_start(counter);
+
+ run->cb(i);
+
+ eina_counter_stop(counter, i);
+ }
+
+ result = eina_counter_dump(counter);
+ if (result) {
+ fprintf(current_data, "%s", result);
+ free(result);
+ }
+
+ eina_counter_free(counter);
+
+ fclose(current_data);
+
+ if (first == EINA_FALSE)
+ first = EINA_TRUE;
+ else
+ fprintf(main_script, ", \\\n");
+
+ fprintf(main_script,
+ "\"%s\" using 1:2 title \'%s\' with line",
+ buffer, run->name);
+ }
+
+ fprintf(main_script, "\n");
+
+ fclose(main_script);
+
+ bench->names = eina_list_append(bench->names, ea);
+
+ return ea;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_binshare.c b/tests/suite/ecore/src/lib/eina_binshare.c
index 3973357deb..f6946379ab 100644
--- a/tests/suite/ecore/src/lib/eina_binshare.c
+++ b/tests/suite/ecore/src/lib/eina_binshare.c
@@ -52,12 +52,11 @@ static const char EINA_MAGIC_BINSHARE_NODE_STR[] = "Eina Binshare Node";
*
* @see eina_init()
*/
-EAPI Eina_Bool
-eina_binshare_init(void)
+EAPI Eina_Bool eina_binshare_init(void)
{
- return eina_share_common_init(&binshare_share,
- EINA_MAGIC_BINSHARE_NODE,
- EINA_MAGIC_BINSHARE_NODE_STR);
+ return eina_share_common_init(&binshare_share,
+ EINA_MAGIC_BINSHARE_NODE,
+ EINA_MAGIC_BINSHARE_NODE_STR);
}
/**
@@ -71,12 +70,11 @@ eina_binshare_init(void)
*
* @see eina_shutdown()
*/
-EAPI Eina_Bool
-eina_binshare_shutdown(void)
+EAPI Eina_Bool eina_binshare_shutdown(void)
{
- Eina_Bool ret;
- ret = eina_share_common_shutdown(&binshare_share);
- return ret;
+ Eina_Bool ret;
+ ret = eina_share_common_shutdown(&binshare_share);
+ return ret;
}
/*============================================================================*
@@ -109,13 +107,12 @@ eina_binshare_shutdown(void)
* Note that if the given pointer is not shared or NULL, bad things
* will happen, likely a segmentation fault.
*/
-EAPI void
-eina_binshare_del(const void *obj)
+EAPI void eina_binshare_del(const void *obj)
{
- if (!obj)
- return;
+ if (!obj)
+ return;
- eina_share_common_del(binshare_share, obj);
+ eina_share_common_del(binshare_share, obj);
}
/**
@@ -138,13 +135,11 @@ eina_binshare_del(const void *obj)
*
* @see eina_binshare_add()
*/
-EAPI const void *
-eina_binshare_add_length(const void *obj, unsigned int olen)
+EAPI const void *eina_binshare_add_length(const void *obj,
+ unsigned int olen)
{
- return eina_share_common_add_length(binshare_share,
- obj,
- (olen) * sizeof(char),
- 0);
+ return eina_share_common_add_length(binshare_share,
+ obj, (olen) * sizeof(char), 0);
}
/**
@@ -161,10 +156,9 @@ eina_binshare_add_length(const void *obj, unsigned int olen)
*
* There is no unref since this is the work of eina_binshare_del().
*/
-EAPI const void *
-eina_binshare_ref(const void *obj)
+EAPI const void *eina_binshare_ref(const void *obj)
{
- return eina_share_common_ref(binshare_share, obj);
+ return eina_share_common_ref(binshare_share, obj);
}
/**
@@ -178,10 +172,9 @@ eina_binshare_ref(const void *obj)
* things will happen, likely a segmentation fault. If in doubt, try
* strlen().
*/
-EAPI int
-eina_binshare_length(const void *obj)
+EAPI int eina_binshare_length(const void *obj)
{
- return eina_share_common_length(binshare_share, obj);
+ return eina_share_common_length(binshare_share, obj);
}
/**
@@ -190,13 +183,11 @@ eina_binshare_length(const void *obj)
* This function dumps all objects in the share_common to stdout with a
* DDD: prefix per line and a memory usage summary.
*/
-EAPI void
-eina_binshare_dump(void)
+EAPI void eina_binshare_dump(void)
{
- eina_share_common_dump(binshare_share, NULL, 0);
+ eina_share_common_dump(binshare_share, NULL, 0);
}
/**
* @}
*/
-
diff --git a/tests/suite/ecore/src/lib/eina_chained_mempool.c b/tests/suite/ecore/src/lib/eina_chained_mempool.c
index f178cac01d..2fd5152a24 100644
--- a/tests/suite/ecore/src/lib/eina_chained_mempool.c
+++ b/tests/suite/ecore/src/lib/eina_chained_mempool.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -28,9 +28,9 @@
#endif
#ifdef EFL_HAVE_WIN32_THREADS
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# undef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
#endif
#include "eina_inlist.h"
@@ -53,293 +53,287 @@ static int _eina_mempool_log_dom = -1;
#endif
typedef struct _Chained_Mempool Chained_Mempool;
-struct _Chained_Mempool
-{
- Eina_Inlist *first;
- const char *name;
- int item_alloc;
- int pool_size;
- int alloc_size;
- int group_size;
- int usage;
+struct _Chained_Mempool {
+ Eina_Inlist *first;
+ const char *name;
+ int item_alloc;
+ int pool_size;
+ int alloc_size;
+ int group_size;
+ int usage;
#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_t mutex;
-# else
- HANDLE mutex;
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_t mutex;
+#else
+ HANDLE mutex;
+#endif
#endif
};
typedef struct _Chained_Pool Chained_Pool;
-struct _Chained_Pool
-{
- EINA_INLIST;
- Eina_Trash *base;
- int usage;
+struct _Chained_Pool {
+ EINA_INLIST;
+ Eina_Trash *base;
+ int usage;
};
-static inline Chained_Pool *
-_eina_chained_mp_pool_new(Chained_Mempool *pool)
+static inline Chained_Pool *_eina_chained_mp_pool_new(Chained_Mempool *
+ pool)
{
- Chained_Pool *p;
- unsigned char *ptr;
- int i;
-
- eina_error_set(0);
- p = malloc(pool->alloc_size);
- if (!p)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- ptr = (unsigned char *)p + eina_mempool_alignof(sizeof(Chained_Pool));
- p->usage = 0;
- p->base = NULL;
- for (i = 0; i < pool->pool_size; ++i, ptr += pool->item_alloc)
- eina_trash_push(&p->base, ptr);
- return p;
+ Chained_Pool *p;
+ unsigned char *ptr;
+ int i;
+
+ eina_error_set(0);
+ p = malloc(pool->alloc_size);
+ if (!p) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ ptr =
+ (unsigned char *) p +
+ eina_mempool_alignof(sizeof(Chained_Pool));
+ p->usage = 0;
+ p->base = NULL;
+ for (i = 0; i < pool->pool_size; ++i, ptr += pool->item_alloc)
+ eina_trash_push(&p->base, ptr);
+ return p;
}
-static inline void
-_eina_chained_mp_pool_free(Chained_Pool *p)
+static inline void _eina_chained_mp_pool_free(Chained_Pool * p)
{
- free(p);
+ free(p);
}
-static void *
-eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
+static void *eina_chained_mempool_malloc(void *data,
+ __UNUSED__ unsigned int size)
{
- Chained_Mempool *pool = data;
- Chained_Pool *p = NULL;
- void *mem;
+ Chained_Mempool *pool = data;
+ Chained_Pool *p = NULL;
+ void *mem;
#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_lock(&pool->mutex);
-# else
- WaitForSingleObject(pool->mutex, INFINITE);
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_lock(&pool->mutex);
+#else
+ WaitForSingleObject(pool->mutex, INFINITE);
+#endif
#endif
- // look 4 pool from 2nd bucket on
- EINA_INLIST_FOREACH(pool->first, p)
- {
- // base is not NULL - has a free slot
- if (p->base)
- {
- pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
- break;
- }
- }
-
- // we have reached the end of the list - no free pools
- if (!p)
- {
- p = _eina_chained_mp_pool_new(pool);
- if (!p)
- {
+ // look 4 pool from 2nd bucket on
+ EINA_INLIST_FOREACH(pool->first, p) {
+ // base is not NULL - has a free slot
+ if (p->base) {
+ pool->first =
+ eina_inlist_demote(pool->first,
+ EINA_INLIST_GET(p));
+ break;
+ }
+ }
+
+ // we have reached the end of the list - no free pools
+ if (!p) {
+ p = _eina_chained_mp_pool_new(pool);
+ if (!p) {
#ifdef EFL_HAVE_PTHREAD
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_unlock(&pool->mutex);
-# else
- ReleaseMutex(pool->mutex);
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_unlock(&pool->mutex);
+#else
+ ReleaseMutex(pool->mutex);
#endif
- return NULL;
- }
-
- pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
- }
-
- // Request a free pointer
- mem = eina_trash_pop(&p->base);
- // move to end - it just filled up
- if (!p->base)
- pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
-
- p->usage++;
- pool->usage++;
+#endif
+ return NULL;
+ }
+
+ pool->first =
+ eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
+ }
+ // Request a free pointer
+ mem = eina_trash_pop(&p->base);
+ // move to end - it just filled up
+ if (!p->base)
+ pool->first =
+ eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
+
+ p->usage++;
+ pool->usage++;
#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_unlock(&pool->mutex);
-# else
- ReleaseMutex(pool->mutex);
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_unlock(&pool->mutex);
+#else
+ ReleaseMutex(pool->mutex);
+#endif
#endif
- return mem;
+ return mem;
}
-static void
-eina_chained_mempool_free(void *data, void *ptr)
+static void eina_chained_mempool_free(void *data, void *ptr)
{
- Chained_Mempool *pool = data;
- Chained_Pool *p;
- void *pmem;
- int psize;
+ Chained_Mempool *pool = data;
+ Chained_Pool *p;
+ void *pmem;
+ int psize;
- psize = pool->group_size;
- // look 4 pool
+ psize = pool->group_size;
+ // look 4 pool
#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_lock(&pool->mutex);
-# else
- WaitForSingleObject(pool->mutex, INFINITE);
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_lock(&pool->mutex);
+#else
+ WaitForSingleObject(pool->mutex, INFINITE);
+#endif
#endif
- EINA_INLIST_FOREACH(pool->first, p)
- {
- // pool mem base
- pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
- // is it in pool mem?
- if ((ptr >= pmem) &&
- ((unsigned char *)ptr < (((unsigned char *)pmem) + psize)))
- {
- // freed node points to prev free node
- eina_trash_push(&p->base, ptr);
- // next free node is now the one we freed
- p->usage--;
- pool->usage--;
- if (p->usage == 0)
- {
- // free bucket
- pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
- _eina_chained_mp_pool_free(p);
- }
- else
- // move to front
- pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p));
-
- break;
- }
- }
+ EINA_INLIST_FOREACH(pool->first, p) {
+ // pool mem base
+ pmem =
+ (void *) (((unsigned char *) p) +
+ sizeof(Chained_Pool));
+ // is it in pool mem?
+ if ((ptr >= pmem) &&
+ ((unsigned char *) ptr <
+ (((unsigned char *) pmem) + psize))) {
+ // freed node points to prev free node
+ eina_trash_push(&p->base, ptr);
+ // next free node is now the one we freed
+ p->usage--;
+ pool->usage--;
+ if (p->usage == 0) {
+ // free bucket
+ pool->first =
+ eina_inlist_remove(pool->first,
+ EINA_INLIST_GET(p));
+ _eina_chained_mp_pool_free(p);
+ } else
+ // move to front
+ pool->first =
+ eina_inlist_promote(pool->first,
+ EINA_INLIST_GET
+ (p));
+
+ break;
+ }
+ }
#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_unlock(&pool->mutex);
-# else
- ReleaseMutex(pool->mutex);
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_unlock(&pool->mutex);
+#else
+ ReleaseMutex(pool->mutex);
+#endif
#endif
}
-static void *
-eina_chained_mempool_realloc(__UNUSED__ void *data,
- __UNUSED__ void *element,
- __UNUSED__ unsigned int size)
+static void *eina_chained_mempool_realloc(__UNUSED__ void *data,
+ __UNUSED__ void *element,
+ __UNUSED__ unsigned int size)
{
- return NULL;
+ return NULL;
}
-static void *
-eina_chained_mempool_init(const char *context,
- __UNUSED__ const char *option,
- va_list args)
+static void *eina_chained_mempool_init(const char *context,
+ __UNUSED__ const char *option,
+ va_list args)
{
- Chained_Mempool *mp;
- int item_size;
- size_t length;
+ Chained_Mempool *mp;
+ int item_size;
+ size_t length;
- length = context ? strlen(context) + 1 : 0;
+ length = context ? strlen(context) + 1 : 0;
- mp = calloc(1, sizeof(Chained_Mempool) + length);
- if (!mp)
- return NULL;
+ mp = calloc(1, sizeof(Chained_Mempool) + length);
+ if (!mp)
+ return NULL;
- item_size = va_arg(args, int);
- mp->pool_size = va_arg(args, int);
+ item_size = va_arg(args, int);
+ mp->pool_size = va_arg(args, int);
- if (length)
- {
- mp->name = (const char *)(mp + 1);
- memcpy((char *)mp->name, context, length);
- }
+ if (length) {
+ mp->name = (const char *) (mp + 1);
+ memcpy((char *) mp->name, context, length);
+ }
- mp->item_alloc = eina_mempool_alignof(item_size);
- mp->group_size = mp->item_alloc * mp->pool_size;
- mp->alloc_size = mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool));
+ mp->item_alloc = eina_mempool_alignof(item_size);
+ mp->group_size = mp->item_alloc * mp->pool_size;
+ mp->alloc_size =
+ mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool));
#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_init(&mp->mutex, NULL);
-# else
- mp->mutex = CreateMutex(NULL, FALSE, NULL);
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_init(&mp->mutex, NULL);
+#else
+ mp->mutex = CreateMutex(NULL, FALSE, NULL);
+#endif
#endif
- return mp;
+ return mp;
}
-static void
-eina_chained_mempool_shutdown(void *data)
+static void eina_chained_mempool_shutdown(void *data)
{
- Chained_Mempool *mp;
+ Chained_Mempool *mp;
- mp = (Chained_Mempool *)data;
+ mp = (Chained_Mempool *) data;
- while (mp->first)
- {
- Chained_Pool *p = (Chained_Pool *)mp->first;
+ while (mp->first) {
+ Chained_Pool *p = (Chained_Pool *) mp->first;
#ifdef DEBUG
- if (p->usage > 0)
- INF("Bad news we are destroying not an empty mempool [%s]\n",
- mp->name);
+ if (p->usage > 0)
+ INF("Bad news we are destroying not an empty mempool [%s]\n", mp->name);
#endif
- mp->first = eina_inlist_remove(mp->first, mp->first);
- _eina_chained_mp_pool_free(p);
- }
+ mp->first = eina_inlist_remove(mp->first, mp->first);
+ _eina_chained_mp_pool_free(p);
+ }
#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_destroy(&mp->mutex);
-# else
- CloseHandle(mp->mutex);
-# endif
+#ifdef EFL_HAVE_POSIX_THREADS
+ pthread_mutex_destroy(&mp->mutex);
+#else
+ CloseHandle(mp->mutex);
+#endif
#endif
- free(mp);
+ free(mp);
}
static Eina_Mempool_Backend _eina_chained_mp_backend = {
- "chained_mempool",
- &eina_chained_mempool_init,
- &eina_chained_mempool_free,
- &eina_chained_mempool_malloc,
- &eina_chained_mempool_realloc,
- NULL,
- NULL,
- &eina_chained_mempool_shutdown
+ "chained_mempool",
+ &eina_chained_mempool_init,
+ &eina_chained_mempool_free,
+ &eina_chained_mempool_malloc,
+ &eina_chained_mempool_realloc,
+ NULL,
+ NULL,
+ &eina_chained_mempool_shutdown
};
Eina_Bool chained_init(void)
{
#ifdef DEBUG
- _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_mempool_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_mempool");
- return EINA_FALSE;
- }
-
+ _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_mempool_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_mempool");
+ return EINA_FALSE;
+ }
#endif
- return eina_mempool_register(&_eina_chained_mp_backend);
+ return eina_mempool_register(&_eina_chained_mp_backend);
}
void chained_shutdown(void)
{
- eina_mempool_unregister(&_eina_chained_mp_backend);
+ eina_mempool_unregister(&_eina_chained_mp_backend);
#ifdef DEBUG
- eina_log_domain_unregister(_eina_mempool_log_dom);
- _eina_mempool_log_dom = -1;
+ eina_log_domain_unregister(_eina_mempool_log_dom);
+ _eina_mempool_log_dom = -1;
#endif
}
@@ -348,4 +342,4 @@ void chained_shutdown(void)
EINA_MODULE_INIT(chained_init);
EINA_MODULE_SHUTDOWN(chained_shutdown);
-#endif /* ! EINA_STATIC_BUILD_CHAINED_POOL */
+#endif /* ! EINA_STATIC_BUILD_CHAINED_POOL */
diff --git a/tests/suite/ecore/src/lib/eina_convert.c b/tests/suite/ecore/src/lib/eina_convert.c
index 0d75469ca0..d949723c28 100644
--- a/tests/suite/ecore/src/lib/eina_convert.c
+++ b/tests/suite/ecore/src/lib/eina_convert.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <math.h>
@@ -26,7 +26,7 @@
#include <stdio.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -46,9 +46,11 @@
* @cond LOCAL
*/
-static const char look_up_table[] = {'0', '1', '2', '3', '4',
- '5', '6', '7', '8', '9',
- 'a', 'b', 'c', 'd', 'e', 'f'};
+static const char look_up_table[] = { '0', '1', '2', '3', '4',
+ '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f'
+};
+
static int _eina_convert_log_dom = -1;
#ifdef ERR
@@ -65,15 +67,14 @@ static int _eina_convert_log_dom = -1;
static inline void reverse(char s[], int length)
{
- int i, j;
- char c;
-
- for (i = 0, j = length - 1; i < j; i++, j--)
- {
- c = s[i];
- s[i] = s[j];
- s[j] = c;
- }
+ int i, j;
+ char c;
+
+ for (i = 0, j = length - 1; i < j; i++, j--) {
+ c = s[i];
+ s[i] = s[j];
+ s[j] = c;
+ }
}
/**
@@ -93,11 +94,11 @@ EAPI Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND = 0;
EAPI Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH = 0;
static const char EINA_ERROR_CONVERT_0X_NOT_FOUND_STR[] =
- "Error during string conversion to float, First '0x' was not found.";
+ "Error during string conversion to float, First '0x' was not found.";
static const char EINA_ERROR_CONVERT_P_NOT_FOUND_STR[] =
- "Error during string conversion to float, First 'p' was not found.";
+ "Error during string conversion to float, First 'p' was not found.";
static const char EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH_STR[] =
- "Error outrun string limit during conversion string conversion to float.";
+ "Error outrun string limit during conversion string conversion to float.";
/**
* @endcond
@@ -119,24 +120,22 @@ static const char EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH_STR[] =
*
* @see eina_init()
*/
-Eina_Bool
-eina_convert_init(void)
+Eina_Bool eina_convert_init(void)
{
- _eina_convert_log_dom = eina_log_domain_register("eina_convert",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_convert_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_convert");
- return EINA_FALSE;
- }
-
+ _eina_convert_log_dom = eina_log_domain_register("eina_convert",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_convert_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_convert");
+ return EINA_FALSE;
+ }
#define EEMR(n) n = eina_error_msg_static_register(n ## _STR)
- EEMR(EINA_ERROR_CONVERT_0X_NOT_FOUND);
- EEMR(EINA_ERROR_CONVERT_P_NOT_FOUND);
- EEMR(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
+ EEMR(EINA_ERROR_CONVERT_0X_NOT_FOUND);
+ EEMR(EINA_ERROR_CONVERT_P_NOT_FOUND);
+ EEMR(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
#undef EEMR
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -150,12 +149,11 @@ eina_convert_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_convert_shutdown(void)
+Eina_Bool eina_convert_shutdown(void)
{
- eina_log_domain_unregister(_eina_convert_log_dom);
- _eina_convert_log_dom = -1;
- return EINA_TRUE;
+ eina_log_domain_unregister(_eina_convert_log_dom);
+ _eina_convert_log_dom = -1;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -305,30 +303,28 @@ eina_convert_shutdown(void)
* The returned value is the length of the string, including the nul
* terminated character.
*/
-EAPI int
-eina_convert_itoa(int n, char *s)
+EAPI int eina_convert_itoa(int n, char *s)
{
- int i = 0;
- int r = 0;
+ int i = 0;
+ int r = 0;
- EINA_SAFETY_ON_NULL_RETURN_VAL(s, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(s, 0);
- if (n < 0)
- {
- n = -n;
- *s++ = '-';
- r = 1;
- }
+ if (n < 0) {
+ n = -n;
+ *s++ = '-';
+ r = 1;
+ }
- do {
- s[i++] = n % 10 + '0';
- } while ((n /= 10) > 0);
+ do {
+ s[i++] = n % 10 + '0';
+ } while ((n /= 10) > 0);
- s[i] = '\0';
+ s[i] = '\0';
- reverse(s, i);
+ reverse(s, i);
- return i + r;
+ return i + r;
}
/**
@@ -347,23 +343,22 @@ eina_convert_itoa(int n, char *s)
* The returned value is the length of the string, including the nul
* terminated character.
*/
-EAPI int
-eina_convert_xtoa(unsigned int n, char *s)
+EAPI int eina_convert_xtoa(unsigned int n, char *s)
{
- int i;
+ int i;
- EINA_SAFETY_ON_NULL_RETURN_VAL(s, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(s, 0);
- i = 0;
- do {
- s[i++] = look_up_table[n & 0xF];
- } while ((n >>= 4) > 0);
+ i = 0;
+ do {
+ s[i++] = look_up_table[n & 0xF];
+ } while ((n >>= 4) > 0);
- s[i] = '\0';
+ s[i] = '\0';
- reverse(s, i);
+ reverse(s, i);
- return i;
+ return i;
}
/**
@@ -411,99 +406,96 @@ eina_convert_xtoa(unsigned int n, char *s)
EAPI Eina_Bool
eina_convert_atod(const char *src, int length, long long *m, long *e)
{
- const char *str = src;
- long long mantisse;
- long exponent;
- int nbr_decimals = 0;
- int sign = 1;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(e, EINA_FALSE);
-
- if (length <= 0)
- goto on_length_error;
-
- /* Compute the mantisse. */
- if (*str == '-')
- {
- sign = -1;
- str++;
- length--;
- }
-
- if (length <= 2)
- goto on_length_error;
-
- if (strncmp(str, "0x", 2))
- {
- eina_error_set(EINA_ERROR_CONVERT_0X_NOT_FOUND);
- DBG("'0x' not found in '%s'", src);
- return EINA_FALSE;
- }
-
- str += 2;
- length -= 2;
-
- mantisse = HEXA_TO_INT(*str);
-
- str++;
- length--; if (length <= 0)
- goto on_length_error;
-
- if (*str == '.')
- for (str++, length--;
- length > 0 && *str != 'p';
- ++str, --length, ++nbr_decimals)
- {
- mantisse <<= 4;
- mantisse += HEXA_TO_INT(*str);
- }
-
- if (sign < 0)
- mantisse = -mantisse;
-
- /* Compute the exponent. */
- if (*str != 'p')
- {
- eina_error_set(EINA_ERROR_CONVERT_P_NOT_FOUND);
- DBG("'p' not found in '%s'", src);
- return EINA_FALSE;
- }
-
- sign = +1;
-
- str++;
- length--; if (length <= 0)
- goto on_length_error;
-
- if (strchr("-+", *str))
- {
- sign = (*str == '-') ? -1 : +1;
-
- str++; length--;
- }
-
- for (exponent = 0; length > 0 && *str != '\0'; ++str, --length)
- {
- exponent *= 10;
- exponent += *str - '0';
- }
-
- if (length < 0)
- goto on_length_error;
-
- if (sign < 0)
- exponent = -exponent;
-
- *m = mantisse;
- *e = exponent - (nbr_decimals << 2);
-
- return EINA_TRUE;
-
-on_length_error:
- eina_error_set(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
- return EINA_FALSE;
+ const char *str = src;
+ long long mantisse;
+ long exponent;
+ int nbr_decimals = 0;
+ int sign = 1;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(e, EINA_FALSE);
+
+ if (length <= 0)
+ goto on_length_error;
+
+ /* Compute the mantisse. */
+ if (*str == '-') {
+ sign = -1;
+ str++;
+ length--;
+ }
+
+ if (length <= 2)
+ goto on_length_error;
+
+ if (strncmp(str, "0x", 2)) {
+ eina_error_set(EINA_ERROR_CONVERT_0X_NOT_FOUND);
+ DBG("'0x' not found in '%s'", src);
+ return EINA_FALSE;
+ }
+
+ str += 2;
+ length -= 2;
+
+ mantisse = HEXA_TO_INT(*str);
+
+ str++;
+ length--;
+ if (length <= 0)
+ goto on_length_error;
+
+ if (*str == '.')
+ for (str++, length--;
+ length > 0 && *str != 'p';
+ ++str, --length, ++nbr_decimals) {
+ mantisse <<= 4;
+ mantisse += HEXA_TO_INT(*str);
+ }
+
+ if (sign < 0)
+ mantisse = -mantisse;
+
+ /* Compute the exponent. */
+ if (*str != 'p') {
+ eina_error_set(EINA_ERROR_CONVERT_P_NOT_FOUND);
+ DBG("'p' not found in '%s'", src);
+ return EINA_FALSE;
+ }
+
+ sign = +1;
+
+ str++;
+ length--;
+ if (length <= 0)
+ goto on_length_error;
+
+ if (strchr("-+", *str)) {
+ sign = (*str == '-') ? -1 : +1;
+
+ str++;
+ length--;
+ }
+
+ for (exponent = 0; length > 0 && *str != '\0'; ++str, --length) {
+ exponent *= 10;
+ exponent += *str - '0';
+ }
+
+ if (length < 0)
+ goto on_length_error;
+
+ if (sign < 0)
+ exponent = -exponent;
+
+ *m = mantisse;
+ *e = exponent - (nbr_decimals << 2);
+
+ return EINA_TRUE;
+
+ on_length_error:
+ eina_error_set(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
+ return EINA_FALSE;
}
/**
@@ -528,67 +520,59 @@ on_length_error:
* The returned value is the length of the string, including the nul
* character.
*/
-EAPI int
-eina_convert_dtoa(double d, char *des)
+EAPI int eina_convert_dtoa(double d, char *des)
{
- int length = 0;
- int p;
- int i;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(des, EINA_FALSE);
-
- if (d < 0.0)
- {
- *(des++) = '-';
- d = -d;
- length++;
- }
-
- d = frexp(d, &p);
-
- if (p)
- {
- d *= 2;
- p -= 1;
- }
-
- *(des++) = '0';
- *(des++) = 'x';
- *(des++) = look_up_table[(size_t)d];
- *(des++) = '.';
- length += 4;
-
- for (i = 0; i < 16; i++, length++)
- {
- d -= floor(d);
- d *= 16;
- *(des++) = look_up_table[(size_t)d];
- }
-
- while (*(des - 1) == '0')
- {
- des--;
- length--;
- }
-
- if (*(des - 1) == '.')
- {
- des--;
- length--;
- }
-
- *(des++) = 'p';
- if (p < 0)
- {
- *(des++) = '-';
- p = -p;
- }
- else
- *(des++) = '+';
-
- length += 2;
-
- return length + eina_convert_itoa(p, des);
+ int length = 0;
+ int p;
+ int i;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(des, EINA_FALSE);
+
+ if (d < 0.0) {
+ *(des++) = '-';
+ d = -d;
+ length++;
+ }
+
+ d = frexp(d, &p);
+
+ if (p) {
+ d *= 2;
+ p -= 1;
+ }
+
+ *(des++) = '0';
+ *(des++) = 'x';
+ *(des++) = look_up_table[(size_t) d];
+ *(des++) = '.';
+ length += 4;
+
+ for (i = 0; i < 16; i++, length++) {
+ d -= floor(d);
+ d *= 16;
+ *(des++) = look_up_table[(size_t) d];
+ }
+
+ while (*(des - 1) == '0') {
+ des--;
+ length--;
+ }
+
+ if (*(des - 1) == '.') {
+ des--;
+ length--;
+ }
+
+ *(des++) = 'p';
+ if (p < 0) {
+ *(des++) = '-';
+ p = -p;
+ } else
+ *(des++) = '+';
+
+ length += 2;
+
+ return length + eina_convert_itoa(p, des);
}
/**
@@ -618,88 +602,77 @@ eina_convert_dtoa(double d, char *des)
* implements the frexp() function for fixed point numbers and does
* some optimisations.
*/
-EAPI int
-eina_convert_fptoa(Eina_F32p32 fp, char *des)
+EAPI int eina_convert_fptoa(Eina_F32p32 fp, char *des)
{
- int length = 0;
- int p = 0;
- int i;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(des, EINA_FALSE);
-
- if (fp == 0)
- {
- memcpy(des, "0x0p+0", 7);
- return 7;
- }
-
- if (fp < 0)
- {
- *(des++) = '-';
- fp = -fp;
- length++;
- }
-
- /* fp >= 1 */
- if (fp >= 0x0000000100000000LL)
- while (fp >= 0x0000000100000000LL)
- {
- p++;
- /* fp /= 2 */
- fp >>= 1;
- } /* fp < 0.5 */
- else if (fp < 0x80000000)
- while (fp < 0x80000000)
- {
- p--;
- /* fp *= 2 */
- fp <<= 1;
- }
-
- if (p)
- {
- p--;
- /* fp *= 2 */
- fp <<= 1;
- }
-
- *(des++) = '0';
- *(des++) = 'x';
- *(des++) = look_up_table[fp >> 32];
- *(des++) = '.';
- length += 4;
-
- for (i = 0; i < 16; i++, length++)
- {
- fp &= 0x00000000ffffffffLL;
- fp <<= 4; /* fp *= 16 */
- *(des++) = look_up_table[fp >> 32];
- }
-
- while (*(des - 1) == '0')
- {
- des--;
- length--;
- }
-
- if (*(des - 1) == '.')
- {
- des--;
- length--;
- }
-
- *(des++) = 'p';
- if (p < 0)
- {
- *(des++) = '-';
- p = -p;
- }
- else
- *(des++) = '+';
-
- length += 2;
-
- return length + eina_convert_itoa(p, des);
+ int length = 0;
+ int p = 0;
+ int i;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(des, EINA_FALSE);
+
+ if (fp == 0) {
+ memcpy(des, "0x0p+0", 7);
+ return 7;
+ }
+
+ if (fp < 0) {
+ *(des++) = '-';
+ fp = -fp;
+ length++;
+ }
+
+ /* fp >= 1 */
+ if (fp >= 0x0000000100000000LL)
+ while (fp >= 0x0000000100000000LL) {
+ p++;
+ /* fp /= 2 */
+ fp >>= 1;
+ } /* fp < 0.5 */
+ else if (fp < 0x80000000)
+ while (fp < 0x80000000) {
+ p--;
+ /* fp *= 2 */
+ fp <<= 1;
+ }
+
+ if (p) {
+ p--;
+ /* fp *= 2 */
+ fp <<= 1;
+ }
+
+ *(des++) = '0';
+ *(des++) = 'x';
+ *(des++) = look_up_table[fp >> 32];
+ *(des++) = '.';
+ length += 4;
+
+ for (i = 0; i < 16; i++, length++) {
+ fp &= 0x00000000ffffffffLL;
+ fp <<= 4; /* fp *= 16 */
+ *(des++) = look_up_table[fp >> 32];
+ }
+
+ while (*(des - 1) == '0') {
+ des--;
+ length--;
+ }
+
+ if (*(des - 1) == '.') {
+ des--;
+ length--;
+ }
+
+ *(des++) = 'p';
+ if (p < 0) {
+ *(des++) = '-';
+ p = -p;
+ } else
+ *(des++) = '+';
+
+ length += 2;
+
+ return length + eina_convert_itoa(p, des);
}
/**
@@ -747,25 +720,25 @@ eina_convert_fptoa(Eina_F32p32 fp, char *des)
* shift to compute the fixed point number.
*/
EAPI Eina_Bool
-eina_convert_atofp(const char *src, int length, Eina_F32p32 *fp)
+eina_convert_atofp(const char *src, int length, Eina_F32p32 * fp)
{
- long long m;
- long e;
+ long long m;
+ long e;
- if (!eina_convert_atod(src, length, &m, &e))
- return EINA_FALSE;
+ if (!eina_convert_atod(src, length, &m, &e))
+ return EINA_FALSE;
- if (!fp)
- return EINA_TRUE;
+ if (!fp)
+ return EINA_TRUE;
- e += 32;
+ e += 32;
- if (e > 0)
- *fp = m << e;
- else
- *fp = m >> -e;
+ if (e > 0)
+ *fp = m << e;
+ else
+ *fp = m >> -e;
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_counter.c b/tests/suite/ecore/src/lib/eina_counter.c
index 8c430dc162..b22c8ac067 100644
--- a/tests/suite/ecore/src/lib/eina_counter.c
+++ b/tests/suite/ecore/src/lib/eina_counter.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -25,12 +25,12 @@
#include <string.h>
#include <stdarg.h>
#ifndef _WIN32
-# include <time.h>
+#include <time.h>
#else
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# undef WIN32_LEAN_AND_MEAN
-#endif /* _WIN2 */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+#endif /* _WIN2 */
#include "eina_config.h"
#include "eina_private.h"
@@ -57,90 +57,84 @@ typedef LARGE_INTEGER Eina_Nano_Time;
typedef struct _Eina_Clock Eina_Clock;
-struct _Eina_Counter
-{
- EINA_INLIST;
+struct _Eina_Counter {
+ EINA_INLIST;
- Eina_Inlist *clocks;
- const char *name;
+ Eina_Inlist *clocks;
+ const char *name;
};
-struct _Eina_Clock
-{
- EINA_INLIST;
+struct _Eina_Clock {
+ EINA_INLIST;
- Eina_Nano_Time start;
- Eina_Nano_Time end;
- int specimen;
+ Eina_Nano_Time start;
+ Eina_Nano_Time end;
+ int specimen;
- Eina_Bool valid;
+ Eina_Bool valid;
};
#ifndef _WIN32
-static inline int
-_eina_counter_time_get(Eina_Nano_Time *tp)
+static inline int _eina_counter_time_get(Eina_Nano_Time * tp)
{
-# if defined(CLOCK_PROCESS_CPUTIME_ID)
- return clock_gettime(CLOCK_PROCESS_CPUTIME_ID, tp);
-# elif defined(CLOCK_PROF)
- return clock_gettime(CLOCK_PROF, tp);
-# elif defined(CLOCK_REALTIME)
- return clock_gettime(CLOCK_REALTIME, tp);
-# else
- return gettimeofday(tp, NULL);
-# endif
+#if defined(CLOCK_PROCESS_CPUTIME_ID)
+ return clock_gettime(CLOCK_PROCESS_CPUTIME_ID, tp);
+#elif defined(CLOCK_PROF)
+ return clock_gettime(CLOCK_PROF, tp);
+#elif defined(CLOCK_REALTIME)
+ return clock_gettime(CLOCK_REALTIME, tp);
+#else
+ return gettimeofday(tp, NULL);
+#endif
}
#else
static const char EINA_ERROR_COUNTER_WINDOWS_STR[] =
- "Change your OS, you moron !";
+ "Change your OS, you moron !";
static int EINA_ERROR_COUNTER_WINDOWS = 0;
static LARGE_INTEGER _eina_counter_frequency;
-static inline int
-_eina_counter_time_get(Eina_Nano_Time *tp)
+static inline int _eina_counter_time_get(Eina_Nano_Time * tp)
{
- return QueryPerformanceCounter(tp);
+ return QueryPerformanceCounter(tp);
}
-#endif /* _WIN2 */
+#endif /* _WIN2 */
-static char *
-_eina_counter_asiprintf(char *base, int *position, const char *format, ...)
+static char *_eina_counter_asiprintf(char *base, int *position,
+ const char *format, ...)
{
- char *tmp, *result;
- int size = 32;
- int n;
- va_list ap;
-
- tmp = realloc(base, sizeof (char) * (*position + size));
- if (!tmp)
- return base;
-
- result = tmp;
-
- while (1)
- {
- va_start(ap, format);
- n = vsnprintf(result + *position, size, format, ap);
- va_end(ap);
-
- if (n > -1 && n < size)
- {
- /* If we always have glibc > 2.2, we could just return *position += n. */
- *position += strlen(result + *position);
- return result;
- }
-
- if (n > -1)
- size = n + 1;
- else
- size <<= 1;
-
- tmp = realloc(result, sizeof (char) * (*position + size));
- if (!tmp)
- return result;
-
- result = tmp;
- }
+ char *tmp, *result;
+ int size = 32;
+ int n;
+ va_list ap;
+
+ tmp = realloc(base, sizeof(char) * (*position + size));
+ if (!tmp)
+ return base;
+
+ result = tmp;
+
+ while (1) {
+ va_start(ap, format);
+ n = vsnprintf(result + *position, size, format, ap);
+ va_end(ap);
+
+ if (n > -1 && n < size) {
+ /* If we always have glibc > 2.2, we could just return *position += n. */
+ *position += strlen(result + *position);
+ return result;
+ }
+
+ if (n > -1)
+ size = n + 1;
+ else
+ size <<= 1;
+
+ tmp = realloc(result, sizeof(char) * (*position + size));
+ if (!tmp)
+ return result;
+
+ result = tmp;
+ }
}
/**
@@ -168,20 +162,17 @@ _eina_counter_asiprintf(char *base, int *position, const char *format, ...)
*
* @see eina_init()
*/
-Eina_Bool
-eina_counter_init(void)
+Eina_Bool eina_counter_init(void)
{
#ifdef _WIN32
- EINA_ERROR_COUNTER_WINDOWS = eina_error_msg_static_register(
- EINA_ERROR_COUNTER_WINDOWS_STR);
- if (!QueryPerformanceFrequency(&_eina_counter_frequency))
- {
- eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
- return EINA_FALSE;
- }
-
-#endif /* _WIN2 */
- return EINA_TRUE;
+ EINA_ERROR_COUNTER_WINDOWS =
+ eina_error_msg_static_register(EINA_ERROR_COUNTER_WINDOWS_STR);
+ if (!QueryPerformanceFrequency(&_eina_counter_frequency)) {
+ eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
+ return EINA_FALSE;
+ }
+#endif /* _WIN2 */
+ return EINA_TRUE;
}
/**
@@ -195,10 +186,9 @@ eina_counter_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_counter_shutdown(void)
+Eina_Bool eina_counter_shutdown(void)
{
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -301,28 +291,26 @@ eina_counter_shutdown(void)
* Whe the new counter is not needed anymore, use eina_counter_free() to
* free the allocated memory.
*/
-EAPI Eina_Counter *
-eina_counter_new(const char *name)
+EAPI Eina_Counter *eina_counter_new(const char *name)
{
- Eina_Counter *counter;
- size_t length;
+ Eina_Counter *counter;
+ size_t length;
- EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
- length = strlen(name) + 1;
+ length = strlen(name) + 1;
- eina_error_set(0);
- counter = calloc(1, sizeof (Eina_Counter) + length);
- if (!counter)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ counter = calloc(1, sizeof(Eina_Counter) + length);
+ if (!counter) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- counter->name = (char *)(counter + 1);
- memcpy((char *)counter->name, name, length);
+ counter->name = (char *) (counter + 1);
+ memcpy((char *) counter->name, name, length);
- return counter;
+ return counter;
}
/**
@@ -335,20 +323,19 @@ eina_counter_new(const char *name)
* @p counter. If @p counter is @c NULL, the function returns
* immediately.
*/
-EAPI void
-eina_counter_free(Eina_Counter *counter)
+EAPI void eina_counter_free(Eina_Counter * counter)
{
- EINA_SAFETY_ON_NULL_RETURN(counter);
+ EINA_SAFETY_ON_NULL_RETURN(counter);
- while (counter->clocks)
- {
- Eina_Clock *clk = (Eina_Clock *)counter->clocks;
+ while (counter->clocks) {
+ Eina_Clock *clk = (Eina_Clock *) counter->clocks;
- counter->clocks = eina_inlist_remove(counter->clocks, counter->clocks);
- free(clk);
- }
+ counter->clocks =
+ eina_inlist_remove(counter->clocks, counter->clocks);
+ free(clk);
+ }
- free(counter);
+ free(counter);
}
/**
@@ -367,28 +354,27 @@ eina_counter_free(Eina_Counter *counter)
* To stop the timing, eina_counter_stop() must be called with the
* same counter.
*/
-EAPI void
-eina_counter_start(Eina_Counter *counter)
+EAPI void eina_counter_start(Eina_Counter * counter)
{
- Eina_Clock *clk;
- Eina_Nano_Time tp;
+ Eina_Clock *clk;
+ Eina_Nano_Time tp;
- EINA_SAFETY_ON_NULL_RETURN(counter);
- if (_eina_counter_time_get(&tp) != 0)
- return;
+ EINA_SAFETY_ON_NULL_RETURN(counter);
+ if (_eina_counter_time_get(&tp) != 0)
+ return;
- eina_error_set(0);
- clk = calloc(1, sizeof (Eina_Clock));
- if (!clk)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return;
- }
+ eina_error_set(0);
+ clk = calloc(1, sizeof(Eina_Clock));
+ if (!clk) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return;
+ }
- counter->clocks = eina_inlist_prepend(counter->clocks, EINA_INLIST_GET(clk));
+ counter->clocks =
+ eina_inlist_prepend(counter->clocks, EINA_INLIST_GET(clk));
- clk->valid = EINA_FALSE;
- clk->start = tp;
+ clk->valid = EINA_FALSE;
+ clk->start = tp;
}
/**
@@ -403,24 +389,23 @@ eina_counter_start(Eina_Counter *counter)
* test. If @p counter or its associated clock are @c NULL, or if the
* time can't be retrieved the function exits.
*/
-EAPI void
-eina_counter_stop(Eina_Counter *counter, int specimen)
+EAPI void eina_counter_stop(Eina_Counter * counter, int specimen)
{
- Eina_Clock *clk;
- Eina_Nano_Time tp;
+ Eina_Clock *clk;
+ Eina_Nano_Time tp;
- EINA_SAFETY_ON_NULL_RETURN(counter);
- if (_eina_counter_time_get(&tp) != 0)
- return;
+ EINA_SAFETY_ON_NULL_RETURN(counter);
+ if (_eina_counter_time_get(&tp) != 0)
+ return;
- clk = (Eina_Clock *)counter->clocks;
+ clk = (Eina_Clock *) counter->clocks;
- if (!clk || clk->valid == EINA_TRUE)
- return;
+ if (!clk || clk->valid == EINA_TRUE)
+ return;
- clk->end = tp;
- clk->specimen = specimen;
- clk->valid = EINA_TRUE;
+ clk->end = tp;
+ clk->specimen = specimen;
+ clk->valid = EINA_TRUE;
}
/**
@@ -441,63 +426,64 @@ eina_counter_stop(Eina_Counter *counter, int specimen)
*
* The unit of time is the nanosecond.
*/
-EAPI char *
-eina_counter_dump(Eina_Counter *counter)
+EAPI char *eina_counter_dump(Eina_Counter * counter)
{
- Eina_Clock *clk;
- char *result = NULL;
- int position = 0;
+ Eina_Clock *clk;
+ char *result = NULL;
+ int position = 0;
- EINA_SAFETY_ON_NULL_RETURN_VAL(counter, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(counter, NULL);
- result = _eina_counter_asiprintf(
- result,
- &position,
- "# specimen\texperiment time\tstarting time\tending time\n");
- if (!result)
- return NULL;
+ result = _eina_counter_asiprintf(result,
+ &position,
+ "# specimen\texperiment time\tstarting time\tending time\n");
+ if (!result)
+ return NULL;
- EINA_INLIST_REVERSE_FOREACH(counter->clocks, clk)
- {
- long int start;
- long int end;
- long int diff;
+ EINA_INLIST_REVERSE_FOREACH(counter->clocks, clk) {
+ long int start;
+ long int end;
+ long int diff;
- if (clk->valid == EINA_FALSE)
- continue;
+ if (clk->valid == EINA_FALSE)
+ continue;
#ifndef _WIN32
- start = clk->start.tv_sec * 1000000000 + clk->start.tv_nsec;
- end = clk->end.tv_sec * 1000000000 + clk->end.tv_nsec;
- diff =
- (clk->end.tv_sec -
- clk->start.tv_sec) * 1000000000 + clk->end.tv_nsec -
- clk->start.tv_nsec;
+ start =
+ clk->start.tv_sec * 1000000000 + clk->start.tv_nsec;
+ end = clk->end.tv_sec * 1000000000 + clk->end.tv_nsec;
+ diff =
+ (clk->end.tv_sec -
+ clk->start.tv_sec) * 1000000000 + clk->end.tv_nsec -
+ clk->start.tv_nsec;
#else
- start =
- (long int)(((long long int)clk->start.QuadPart *
- 1000000000ll) /
- (long long int)_eina_counter_frequency.QuadPart);
- end =
- (long int)(((long long int)clk->end.QuadPart *
- 1000000000LL) /
- (long long int)_eina_counter_frequency.QuadPart);
- diff =
- (long int)(((long long int)(clk->end.QuadPart -
- clk->start.QuadPart) *
- 1000000000LL) /
- (long long int)_eina_counter_frequency.QuadPart);
-#endif /* _WIN2 */
-
- result = _eina_counter_asiprintf(result, &position,
- "%i\t%li\t%li\t%li\n",
- clk->specimen,
- diff,
- start,
- end);
- }
-
- return result;
+ start =
+ (long int) (((long long int) clk->start.QuadPart *
+ 1000000000ll) /
+ (long long int) _eina_counter_frequency.
+ QuadPart);
+ end =
+ (long
+ int) (((long long int) clk->end.QuadPart *
+ 1000000000LL) /
+ (long long int) _eina_counter_frequency.
+ QuadPart);
+ diff =
+ (long
+ int) (((long long int) (clk->end.QuadPart -
+ clk->start.QuadPart) *
+ 1000000000LL) /
+ (long long int) _eina_counter_frequency.
+ QuadPart);
+#endif /* _WIN2 */
+
+ result = _eina_counter_asiprintf(result, &position,
+ "%i\t%li\t%li\t%li\n",
+ clk->specimen,
+ diff, start, end);
+ }
+
+ return result;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_cpu.c b/tests/suite/ecore/src/lib/eina_cpu.c
index 1ee411fac6..ab8686fa2d 100644
--- a/tests/suite/ecore/src/lib/eina_cpu.c
+++ b/tests/suite/ecore/src/lib/eina_cpu.c
@@ -17,30 +17,30 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#ifdef EFL_HAVE_THREADS
-# ifdef _WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# elif defined (__SUNPRO_C) || defined(__GNU__)
-# include <unistd.h>
-# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#elif defined (__SUNPRO_C) || defined(__GNU__)
+#include <unistd.h>
+#elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \
(defined (__MACH__) && defined (__APPLE__))
-# include <unistd.h>
-# include <sys/param.h>
-# include <sys/sysctl.h>
-# elif defined (__linux__) || defined(__GLIBC__)
-# define _GNU_SOURCE
-# include <sched.h>
-# endif
-# ifdef EFL_HAVE_POSIX_THREADS
-# include <pthread.h>
-# endif
-
-# define TH_MAX 8
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#elif defined (__linux__) || defined(__GLIBC__)
+#define _GNU_SOURCE
+#include <sched.h>
+#endif
+#ifdef EFL_HAVE_POSIX_THREADS
+#include <pthread.h>
+#endif
+
+#define TH_MAX 8
#endif
#include <stdio.h>
@@ -58,52 +58,51 @@
/* We save ebx and restore it to be PIC compatible */
static inline void _x86_cpuid(int op, int *a, int *b, int *c, int *d)
{
- asm volatile (
+ asm volatile (
#if defined(__x86_64__)
- "pushq %%rbx \n\t" /* save %ebx */
+ "pushq %%rbx \n\t" /* save %ebx */
#else
- "pushl %%ebx \n\t" /* save %ebx */
+ "pushl %%ebx \n\t" /* save %ebx */
#endif
- "cpuid \n\t"
- "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
+ "cpuid \n\t" "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
#if defined(__x86_64__)
- "popq %%rbx \n\t" /* restore the old %ebx */
+ "popq %%rbx \n\t" /* restore the old %ebx */
#else
- "popl %%ebx \n\t" /* restore the old %ebx */
+ "popl %%ebx \n\t" /* restore the old %ebx */
#endif
- : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d)
- : "a" (op)
- : "cc");
+ :"=a" (*a), "=r"(*b), "=c"(*c), "=d"(*d)
+ :"a"(op)
+ :"cc");
}
static
-void _x86_simd(Eina_Cpu_Features *features)
+void _x86_simd(Eina_Cpu_Features * features)
{
- int a, b, c, d;
-
- _x86_cpuid(1, &a, &b, &c, &d);
- /*
- * edx
- * 18 = PN (Processor Number)
- * 19 = CLFlush (Cache Line Flush)
- * 23 = MMX
- * 25 = SSE
- * 26 = SSE2
- * 28 = HTT (Hyper Threading)
- * ecx
- * 0 = SSE3
- */
- if ((d >> 23) & 1)
- *features |= EINA_CPU_MMX;
-
- if ((d >> 25) & 1)
- *features |= EINA_CPU_SSE;
-
- if ((d >> 26) & 1)
- *features |= EINA_CPU_SSE2;
-
- if (c & 1)
- *features |= EINA_CPU_SSE3;
+ int a, b, c, d;
+
+ _x86_cpuid(1, &a, &b, &c, &d);
+ /*
+ * edx
+ * 18 = PN (Processor Number)
+ * 19 = CLFlush (Cache Line Flush)
+ * 23 = MMX
+ * 25 = SSE
+ * 26 = SSE2
+ * 28 = HTT (Hyper Threading)
+ * ecx
+ * 0 = SSE3
+ */
+ if ((d >> 23) & 1)
+ *features |= EINA_CPU_MMX;
+
+ if ((d >> 25) & 1)
+ *features |= EINA_CPU_SSE;
+
+ if ((d >> 26) & 1)
+ *features |= EINA_CPU_SSE2;
+
+ if (c & 1)
+ *features |= EINA_CPU_SSE3;
}
#endif
@@ -124,85 +123,83 @@ void _x86_simd(Eina_Cpu_Features *features)
*/
EAPI Eina_Cpu_Features eina_cpu_features_get(void)
{
- Eina_Cpu_Features ecf = 0;
+ Eina_Cpu_Features ecf = 0;
#if defined(__i386__) || defined(__x86_64__)
- _x86_simd(&ecf);
+ _x86_simd(&ecf);
#endif
- return ecf;
+ return ecf;
}
EAPI int eina_cpu_count(void)
{
#ifdef EFL_HAVE_THREADS
-# if defined (_WIN32)
- SYSTEM_INFO sysinfo;
-
- GetSystemInfo(&sysinfo);
- return sysinfo.dwNumberOfProcessors;
-
-# elif defined (__SUNPRO_C) || defined(__GNU__)
- /*
- * _SC_NPROCESSORS_ONLN: number of processors that are online, that
- is available when sysconf is called. The number
- of cpu can change by admins.
- * _SC_NPROCESSORS_CONF: maximum number of processors that are available
- to the current OS instance. That number can be
- change after a reboot.
- * _SC_NPROCESSORS_MAX : maximum number of processors that are on the
- motherboard.
- */
- return sysconf(_SC_NPROCESSORS_ONLN);
-
-# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
+#if defined (_WIN32)
+ SYSTEM_INFO sysinfo;
+
+ GetSystemInfo(&sysinfo);
+ return sysinfo.dwNumberOfProcessors;
+
+#elif defined (__SUNPRO_C) || defined(__GNU__)
+ /*
+ * _SC_NPROCESSORS_ONLN: number of processors that are online, that
+ is available when sysconf is called. The number
+ of cpu can change by admins.
+ * _SC_NPROCESSORS_CONF: maximum number of processors that are available
+ to the current OS instance. That number can be
+ change after a reboot.
+ * _SC_NPROCESSORS_MAX : maximum number of processors that are on the
+ motherboard.
+ */
+ return sysconf(_SC_NPROCESSORS_ONLN);
+
+#elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \
(defined (__MACH__) && defined (__APPLE__))
- int mib[4];
- int cpus;
- size_t len = sizeof(cpus);
+ int mib[4];
+ int cpus;
+ size_t len = sizeof(cpus);
- mib[0] = CTL_HW;
+ mib[0] = CTL_HW;
#ifdef HW_AVAILCPU
- mib[1] = HW_AVAILCPU;
+ mib[1] = HW_AVAILCPU;
+#else
+ mib[1] = HW_NCPU;
+#endif
+ sysctl(mib, 2, &cpus, &len, NULL, 0);
+ if (cpus < 1)
+ cpus = 1;
+
+ return cpus;
+
+#elif defined (__linux__) || defined(__GLIBC__)
+ cpu_set_t cpu;
+ int i;
+ static int cpus = 0;
+
+ if (cpus != 0)
+ return cpus;
+
+ CPU_ZERO(&cpu);
+ if (sched_getaffinity(0, sizeof(cpu), &cpu) != 0) {
+ fprintf(stderr, "[Eina] could not get cpu affinity: %s\n",
+ strerror(errno));
+ return 1;
+ }
+
+ for (i = 0; i < TH_MAX; i++) {
+ if (CPU_ISSET(i, &cpu))
+ cpus = i + 1;
+ else
+ break;
+ }
+ return cpus;
+
#else
- mib[1] = HW_NCPU;
+#error "eina_cpu_count() error: Platform not supported"
#endif
- sysctl(mib, 2, &cpus, &len, NULL, 0);
- if (cpus < 1)
- cpus = 1;
-
- return cpus;
-
-# elif defined (__linux__) || defined(__GLIBC__)
- cpu_set_t cpu;
- int i;
- static int cpus = 0;
-
- if (cpus != 0)
- return cpus;
-
- CPU_ZERO(&cpu);
- if (sched_getaffinity(0, sizeof(cpu), &cpu) != 0)
- {
- fprintf(stderr, "[Eina] could not get cpu affinity: %s\n",
- strerror(errno));
- return 1;
- }
-
- for (i = 0; i < TH_MAX; i++)
- {
- if (CPU_ISSET(i, &cpu))
- cpus = i + 1;
- else
- break;
- }
- return cpus;
-
-# else
-# error "eina_cpu_count() error: Platform not supported"
-# endif
#else
- return 1;
+ return 1;
#endif
}
diff --git a/tests/suite/ecore/src/lib/eina_error.c b/tests/suite/ecore/src/lib/eina_error.c
index f273ca51c1..17ec74d904 100644
--- a/tests/suite/ecore/src/lib/eina_error.c
+++ b/tests/suite/ecore/src/lib/eina_error.c
@@ -131,7 +131,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -139,7 +139,7 @@
#include <stdlib.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -166,10 +166,9 @@
*/
typedef struct _Eina_Error_Message Eina_Error_Message;
-struct _Eina_Error_Message
-{
- Eina_Bool string_allocated;
- const char *string;
+struct _Eina_Error_Message {
+ Eina_Bool string_allocated;
+ const char *string;
};
static Eina_Error_Message *_eina_errors = NULL;
@@ -177,32 +176,32 @@ static size_t _eina_errors_count = 0;
static size_t _eina_errors_allocated = 0;
static Eina_Error _eina_last_error;
-static Eina_Error_Message *
-_eina_error_msg_alloc(void)
+static Eina_Error_Message *_eina_error_msg_alloc(void)
{
- size_t idx;
-
- if (_eina_errors_count == _eina_errors_allocated)
- {
- void *tmp;
- size_t size;
-
- if (EINA_UNLIKELY(_eina_errors_allocated == 0))
- size = 24;
- else
- size = _eina_errors_allocated + 8;
-
- tmp = realloc(_eina_errors, sizeof(Eina_Error_Message) * size);
- if (!tmp)
- return NULL;
-
- _eina_errors = tmp;
- _eina_errors_allocated = size;
- }
-
- idx = _eina_errors_count;
- _eina_errors_count++;
- return _eina_errors + idx;
+ size_t idx;
+
+ if (_eina_errors_count == _eina_errors_allocated) {
+ void *tmp;
+ size_t size;
+
+ if (EINA_UNLIKELY(_eina_errors_allocated == 0))
+ size = 24;
+ else
+ size = _eina_errors_allocated + 8;
+
+ tmp =
+ realloc(_eina_errors,
+ sizeof(Eina_Error_Message) * size);
+ if (!tmp)
+ return NULL;
+
+ _eina_errors = tmp;
+ _eina_errors_allocated = size;
+ }
+
+ idx = _eina_errors_count;
+ _eina_errors_count++;
+ return _eina_errors + idx;
}
/**
@@ -239,13 +238,12 @@ static const char EINA_ERROR_OUT_OF_MEMORY_STR[] = "Out of memory";
*
* @see eina_init()
*/
-Eina_Bool
-eina_error_init(void)
+Eina_Bool eina_error_init(void)
{
- /* TODO register the eina's basic errors */
- EINA_ERROR_OUT_OF_MEMORY = eina_error_msg_static_register(
- EINA_ERROR_OUT_OF_MEMORY_STR);
- return EINA_TRUE;
+ /* TODO register the eina's basic errors */
+ EINA_ERROR_OUT_OF_MEMORY =
+ eina_error_msg_static_register(EINA_ERROR_OUT_OF_MEMORY_STR);
+ return EINA_TRUE;
}
/**
@@ -259,24 +257,23 @@ eina_error_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_error_shutdown(void)
+Eina_Bool eina_error_shutdown(void)
{
- Eina_Error_Message *eem, *eem_end;
+ Eina_Error_Message *eem, *eem_end;
- eem = _eina_errors;
- eem_end = eem + _eina_errors_count;
+ eem = _eina_errors;
+ eem_end = eem + _eina_errors_count;
- for (; eem < eem_end; eem++)
- if (eem->string_allocated)
- free((char *)eem->string);
+ for (; eem < eem_end; eem++)
+ if (eem->string_allocated)
+ free((char *) eem->string);
- free(_eina_errors);
- _eina_errors = NULL;
- _eina_errors_count = 0;
- _eina_errors_allocated = 0;
+ free(_eina_errors);
+ _eina_errors = NULL;
+ _eina_errors_count = 0;
+ _eina_errors_allocated = 0;
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -313,26 +310,24 @@ eina_error_shutdown(void)
*
* @see eina_error_msg_static_register()
*/
-EAPI Eina_Error
-eina_error_msg_register(const char *msg)
+EAPI Eina_Error eina_error_msg_register(const char *msg)
{
- Eina_Error_Message *eem;
+ Eina_Error_Message *eem;
- EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0);
- eem = _eina_error_msg_alloc();
- if (!eem)
- return 0;
+ eem = _eina_error_msg_alloc();
+ if (!eem)
+ return 0;
- eem->string_allocated = EINA_TRUE;
- eem->string = strdup(msg);
- if (!eem->string)
- {
- _eina_errors_count--;
- return 0;
- }
+ eem->string_allocated = EINA_TRUE;
+ eem->string = strdup(msg);
+ if (!eem->string) {
+ _eina_errors_count--;
+ return 0;
+ }
- return _eina_errors_count; /* identifier = index + 1 (== _count). */
+ return _eina_errors_count; /* identifier = index + 1 (== _count). */
}
/**
@@ -350,20 +345,19 @@ eina_error_msg_register(const char *msg)
*
* @see eina_error_msg_register()
*/
-EAPI Eina_Error
-eina_error_msg_static_register(const char *msg)
+EAPI Eina_Error eina_error_msg_static_register(const char *msg)
{
- Eina_Error_Message *eem;
+ Eina_Error_Message *eem;
- EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0);
- eem = _eina_error_msg_alloc();
- if (!eem)
- return 0;
+ eem = _eina_error_msg_alloc();
+ if (!eem)
+ return 0;
- eem->string_allocated = EINA_FALSE;
- eem->string = msg;
- return _eina_errors_count; /* identifier = index + 1 (== _count). */
+ eem->string_allocated = EINA_FALSE;
+ eem->string = msg;
+ return _eina_errors_count; /* identifier = index + 1 (== _count). */
}
/**
@@ -382,30 +376,28 @@ eina_error_msg_static_register(const char *msg)
*
* @see eina_error_msg_register()
*/
-EAPI Eina_Bool
-eina_error_msg_modify(Eina_Error error, const char *msg)
+EAPI Eina_Bool eina_error_msg_modify(Eina_Error error, const char *msg)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(msg, EINA_FALSE);
- if (error < 1)
- return EINA_FALSE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(msg, EINA_FALSE);
+ if (error < 1)
+ return EINA_FALSE;
- if ((size_t)error > _eina_errors_count)
- return EINA_FALSE;
+ if ((size_t) error > _eina_errors_count)
+ return EINA_FALSE;
- if (_eina_errors[error - 1].string_allocated)
- {
- const char *tmp;
+ if (_eina_errors[error - 1].string_allocated) {
+ const char *tmp;
- if (!(tmp = strdup(msg)))
- return EINA_FALSE;
+ if (!(tmp = strdup(msg)))
+ return EINA_FALSE;
- free((void *)_eina_errors[error - 1].string);
- _eina_errors[error - 1].string = tmp;
- return EINA_TRUE;
- }
+ free((void *) _eina_errors[error - 1].string);
+ _eina_errors[error - 1].string = tmp;
+ return EINA_TRUE;
+ }
- _eina_errors[error - 1].string = msg;
- return EINA_TRUE;
+ _eina_errors[error - 1].string = msg;
+ return EINA_TRUE;
}
/**
@@ -418,16 +410,15 @@ eina_error_msg_modify(Eina_Error error, const char *msg)
* registered with eina_error_msg_register(). If an incorrect error is
* given, then @c NULL is returned.
*/
-EAPI const char *
-eina_error_msg_get(Eina_Error error)
+EAPI const char *eina_error_msg_get(Eina_Error error)
{
- if (error < 1)
- return NULL;
+ if (error < 1)
+ return NULL;
- if ((size_t)error > _eina_errors_count)
- return NULL;
+ if ((size_t) error > _eina_errors_count)
+ return NULL;
- return _eina_errors[error - 1].string;
+ return _eina_errors[error - 1].string;
}
/**
@@ -438,10 +429,9 @@ eina_error_msg_get(Eina_Error error)
* This function returns the last error set by eina_error_set(). The
* description of the message is returned by eina_error_msg_get().
*/
-EAPI Eina_Error
-eina_error_get(void)
+EAPI Eina_Error eina_error_get(void)
{
- return _eina_last_error;
+ return _eina_last_error;
}
/**
@@ -452,10 +442,9 @@ eina_error_get(void)
* This function sets the last error identifier. The last error can be
* retrieved with eina_error_get().
*/
-EAPI void
-eina_error_set(Eina_Error err)
+EAPI void eina_error_set(Eina_Error err)
{
- _eina_last_error = err;
+ _eina_last_error = err;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_file.c b/tests/suite/ecore/src/lib/eina_file.c
index a5c95720b6..ca1cb35969 100644
--- a/tests/suite/ecore/src/lib/eina_file.c
+++ b/tests/suite/ecore/src/lib/eina_file.c
@@ -17,52 +17,52 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#ifndef _WIN32
-# define _GNU_SOURCE
+#define _GNU_SOURCE
#endif
#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
+#include <alloca.h>
#elif defined __GNUC__
-# define alloca __builtin_alloca
+#define alloca __builtin_alloca
#elif defined _AIX
-# define alloca __alloca
+#define alloca __alloca
#elif defined _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
+#include <malloc.h>
+#define alloca _alloca
#else
-# include <stddef.h>
-# ifdef __cplusplus
+#include <stddef.h>
+#ifdef __cplusplus
extern "C"
-# endif
-void *alloca (size_t);
+#endif
+void *alloca(size_t);
#endif
#include <string.h>
#include <dirent.h>
#ifndef _WIN32
-# include <sys/types.h>
-# include <sys/stat.h>
-# include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#else
-# include <Evil.h>
-#endif /* _WIN2 */
+#include <Evil.h>
+#endif /* _WIN2 */
#ifndef _WIN32
-# define PATH_DELIM '/'
+#define PATH_DELIM '/'
#else
-# define PATH_DELIM '\\'
-# define NAME_MAX MAX_PATH
+#define PATH_DELIM '\\'
+#define NAME_MAX MAX_PATH
#endif
#ifdef __sun
-# ifndef NAME_MAX
-# define NAME_MAX 255
-# endif
+#ifndef NAME_MAX
+#define NAME_MAX 255
+#endif
#endif
#include "eina_config.h"
@@ -74,115 +74,111 @@ void *alloca (size_t);
#include "eina_stringshare.h"
typedef struct _Eina_File_Iterator Eina_File_Iterator;
-struct _Eina_File_Iterator
-{
- Eina_Iterator iterator;
+struct _Eina_File_Iterator {
+ Eina_Iterator iterator;
- DIR *dirp;
- int length;
+ DIR *dirp;
+ int length;
- char dir[1];
+ char dir[1];
};
static Eina_Bool
-_eina_file_ls_iterator_next(Eina_File_Iterator *it, void **data)
+_eina_file_ls_iterator_next(Eina_File_Iterator * it, void **data)
{
- struct dirent *dp;
- char *name;
- size_t length;
-
- do
- {
- dp = readdir(it->dirp);
- if (!dp)
- return EINA_FALSE;
- }
- while ((dp->d_name[0] == '.') &&
- ((dp->d_name[1] == '\0') ||
- ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
-
- length = strlen(dp->d_name);
- name = alloca(length + 2 + it->length);
-
- memcpy(name, it->dir, it->length);
- memcpy(name + it->length, "/", 1);
- memcpy(name + it->length + 1, dp->d_name, length + 1);
-
- *data = (char *)eina_stringshare_add(name);
- return EINA_TRUE;
+ struct dirent *dp;
+ char *name;
+ size_t length;
+
+ do {
+ dp = readdir(it->dirp);
+ if (!dp)
+ return EINA_FALSE;
+ }
+ while ((dp->d_name[0] == '.') &&
+ ((dp->d_name[1] == '\0') ||
+ ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
+
+ length = strlen(dp->d_name);
+ name = alloca(length + 2 + it->length);
+
+ memcpy(name, it->dir, it->length);
+ memcpy(name + it->length, "/", 1);
+ memcpy(name + it->length + 1, dp->d_name, length + 1);
+
+ *data = (char *) eina_stringshare_add(name);
+ return EINA_TRUE;
}
-static char *
-_eina_file_ls_iterator_container(Eina_File_Iterator *it)
+static char *_eina_file_ls_iterator_container(Eina_File_Iterator * it)
{
- return it->dir;
+ return it->dir;
}
-static void
-_eina_file_ls_iterator_free(Eina_File_Iterator *it)
+static void _eina_file_ls_iterator_free(Eina_File_Iterator * it)
{
- closedir(it->dirp);
+ closedir(it->dirp);
- EINA_MAGIC_SET(&it->iterator, 0);
- free(it);
+ EINA_MAGIC_SET(&it->iterator, 0);
+ free(it);
}
typedef struct _Eina_File_Direct_Iterator Eina_File_Direct_Iterator;
-struct _Eina_File_Direct_Iterator
-{
- Eina_Iterator iterator;
+struct _Eina_File_Direct_Iterator {
+ Eina_Iterator iterator;
- DIR *dirp;
- int length;
+ DIR *dirp;
+ int length;
- Eina_File_Direct_Info info;
+ Eina_File_Direct_Info info;
- char dir[1];
+ char dir[1];
};
static Eina_Bool
-_eina_file_direct_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
+_eina_file_direct_ls_iterator_next(Eina_File_Direct_Iterator * it,
+ void **data)
{
- struct dirent *dp;
- size_t length;
-
- do
- {
- dp = readdir(it->dirp);
- if (!dp)
- return EINA_FALSE;
-
- length = strlen(dp->d_name);
- if (it->info.name_start + length + 1 >= PATH_MAX)
- continue;
- }
- while ((dp->d_name[0] == '.') &&
- ((dp->d_name[1] == '\0') ||
- ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
-
- memcpy(it->info.path + it->info.name_start, dp->d_name, length);
- it->info.name_length = length;
- it->info.path_length = it->info.name_start + length;
- it->info.path[it->info.path_length] = '\0';
- it->info.dirent = dp;
-
- *data = &it->info;
- return EINA_TRUE;
+ struct dirent *dp;
+ size_t length;
+
+ do {
+ dp = readdir(it->dirp);
+ if (!dp)
+ return EINA_FALSE;
+
+ length = strlen(dp->d_name);
+ if (it->info.name_start + length + 1 >= PATH_MAX)
+ continue;
+ }
+ while ((dp->d_name[0] == '.') &&
+ ((dp->d_name[1] == '\0') ||
+ ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
+
+ memcpy(it->info.path + it->info.name_start, dp->d_name, length);
+ it->info.name_length = length;
+ it->info.path_length = it->info.name_start + length;
+ it->info.path[it->info.path_length] = '\0';
+ it->info.dirent = dp;
+
+ *data = &it->info;
+ return EINA_TRUE;
}
-static char *
-_eina_file_direct_ls_iterator_container(Eina_File_Direct_Iterator *it)
+static char
+ *_eina_file_direct_ls_iterator_container(Eina_File_Direct_Iterator *
+ it)
{
- return it->dir;
+ return it->dir;
}
static void
-_eina_file_direct_ls_iterator_free(Eina_File_Direct_Iterator *it)
+_eina_file_direct_ls_iterator_free(Eina_File_Direct_Iterator * it)
{
- closedir(it->dirp);
+ closedir(it->dirp);
- EINA_MAGIC_SET(&it->iterator, 0);
- free(it);
+ EINA_MAGIC_SET(&it->iterator, 0);
+ free(it);
}
/*============================================================================*
@@ -227,132 +223,127 @@ _eina_file_direct_ls_iterator_free(Eina_File_Direct_Iterator *it)
*/
EAPI Eina_Bool
eina_file_dir_list(const char *dir,
- Eina_Bool recursive,
- Eina_File_Dir_List_Cb cb,
- void *data)
+ Eina_Bool recursive,
+ Eina_File_Dir_List_Cb cb, void *data)
{
#ifndef _WIN32
- struct dirent *de;
- DIR *d;
+ struct dirent *de;
+ DIR *d;
- EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
- d = opendir(dir);
- if (!d)
- return EINA_FALSE;
+ d = opendir(dir);
+ if (!d)
+ return EINA_FALSE;
- while ((de = readdir(d)))
- {
- if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
- continue;
+ while ((de = readdir(d))) {
+ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
+ continue;
- cb(de->d_name, dir, data);
- /* d_type is only available on linux and bsd (_BSD_SOURCE) */
+ cb(de->d_name, dir, data);
+ /* d_type is only available on linux and bsd (_BSD_SOURCE) */
- if (recursive == EINA_TRUE)
- {
- char *path;
+ if (recursive == EINA_TRUE) {
+ char *path;
- path = alloca(strlen(dir) + strlen(de->d_name) + 2);
- strcpy(path, dir);
- strcat(path, "/");
- strcat(path, de->d_name);
+ path =
+ alloca(strlen(dir) + strlen(de->d_name) + 2);
+ strcpy(path, dir);
+ strcat(path, "/");
+ strcat(path, de->d_name);
#ifndef sun
- if (de->d_type == DT_UNKNOWN)
- {
+ if (de->d_type == DT_UNKNOWN) {
#endif
- struct stat st;
+ struct stat st;
- if (stat(path, &st))
- continue;
+ if (stat(path, &st))
+ continue;
- if (!S_ISDIR(st.st_mode))
- continue;
+ if (!S_ISDIR(st.st_mode))
+ continue;
#ifndef sun
- }
- else if (de->d_type != DT_DIR)
- continue;
+ } else if (de->d_type != DT_DIR)
+ continue;
#endif
- eina_file_dir_list(path, recursive, cb, data);
- }
- }
+ eina_file_dir_list(path, recursive, cb, data);
+ }
+ }
- closedir(d);
+ closedir(d);
#else
- WIN32_FIND_DATA file;
- HANDLE hSearch;
- char *new_dir;
- TCHAR *tdir;
- size_t length_dir;
+ WIN32_FIND_DATA file;
+ HANDLE hSearch;
+ char *new_dir;
+ TCHAR *tdir;
+ size_t length_dir;
- EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
- length_dir = strlen(dir);
- new_dir = (char *)alloca(length_dir + 5);
- if (!new_dir)
- return EINA_FALSE;
+ length_dir = strlen(dir);
+ new_dir = (char *) alloca(length_dir + 5);
+ if (!new_dir)
+ return EINA_FALSE;
- memcpy(new_dir, dir, length_dir);
- memcpy(new_dir + length_dir, "/*.*", 5);
+ memcpy(new_dir, dir, length_dir);
+ memcpy(new_dir + length_dir, "/*.*", 5);
#ifdef UNICODE
- tdir = evil_char_to_wchar(new_dir);
+ tdir = evil_char_to_wchar(new_dir);
#else
- tdir = new_dir;
-#endif /* ! UNICODE */
- hSearch = FindFirstFile(tdir, &file);
+ tdir = new_dir;
+#endif /* ! UNICODE */
+ hSearch = FindFirstFile(tdir, &file);
#ifdef UNICODE
- free(tdir);
-#endif /* UNICODE */
+ free(tdir);
+#endif /* UNICODE */
- if (hSearch == INVALID_HANDLE_VALUE)
- return EINA_FALSE;
+ if (hSearch == INVALID_HANDLE_VALUE)
+ return EINA_FALSE;
- do
- {
- char *filename;
+ do {
+ char *filename;
#ifdef UNICODE
- filename = evil_wchar_to_char(file.cFileName);
+ filename = evil_wchar_to_char(file.cFileName);
#else
- filename = file.cFileName;
-#endif /* ! UNICODE */
- if (!strcmp(filename, ".") || !strcmp(filename, ".."))
- continue;
-
- cb(filename, dir, data);
+ filename = file.cFileName;
+#endif /* ! UNICODE */
+ if (!strcmp(filename, ".") || !strcmp(filename, ".."))
+ continue;
- if (recursive == EINA_TRUE)
- {
- char *path;
+ cb(filename, dir, data);
- path = alloca(strlen(dir) + strlen(filename) + 2);
- strcpy(path, dir);
- strcat(path, "/");
- strcat(path, filename);
+ if (recursive == EINA_TRUE) {
+ char *path;
- if (!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- continue;
+ path = alloca(strlen(dir) + strlen(filename) + 2);
+ strcpy(path, dir);
+ strcat(path, "/");
+ strcat(path, filename);
- eina_file_dir_list(path, recursive, cb, data);
- }
+ if (!
+ (file.
+ dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ continue;
+ eina_file_dir_list(path, recursive, cb, data);
+ }
#ifdef UNICODE
- free(filename);
-#endif /* UNICODE */
+ free(filename);
+#endif /* UNICODE */
- } while (FindNextFile(hSearch, &file));
- FindClose(hSearch);
-#endif /* _WIN32 */
+ } while (FindNextFile(hSearch, &file));
+ FindClose(hSearch);
+#endif /* _WIN32 */
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -366,37 +357,35 @@ eina_file_dir_list(const char *dir,
* created, @c NULL is returned, otherwise, an array with the
* different parts of @p path is returned.
*/
-EAPI Eina_Array *
-eina_file_split(char *path)
+EAPI Eina_Array *eina_file_split(char *path)
{
- Eina_Array *ea;
- char *current;
- size_t length;
+ Eina_Array *ea;
+ char *current;
+ size_t length;
- EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
- ea = eina_array_new(16);
+ ea = eina_array_new(16);
- if (!ea)
- return NULL;
+ if (!ea)
+ return NULL;
- for (current = strchr(path, PATH_DELIM);
- current;
- path = current + 1, current = strchr(path, PATH_DELIM))
- {
- length = current - path;
+ for (current = strchr(path, PATH_DELIM);
+ current;
+ path = current + 1, current = strchr(path, PATH_DELIM)) {
+ length = current - path;
- if (length <= 0)
- continue;
+ if (length <= 0)
+ continue;
- eina_array_push(ea, path);
- *current = '\0';
- }
+ eina_array_push(ea, path);
+ *current = '\0';
+ }
- if (*path != '\0')
- eina_array_push(ea, path);
+ if (*path != '\0')
+ eina_array_push(ea, path);
- return ea;
+ return ea;
}
/**
@@ -424,45 +413,45 @@ eina_file_split(char *path)
*
* @see eina_file_direct_ls()
*/
-EAPI Eina_Iterator *
-eina_file_ls(const char *dir)
+EAPI Eina_Iterator *eina_file_ls(const char *dir)
{
- Eina_File_Iterator *it;
- size_t length;
-
- if (!dir)
- return NULL;
-
- length = strlen(dir);
- if (length < 1)
- return NULL;
-
- it = calloc(1, sizeof (Eina_File_Iterator) + length);
- if (!it)
- return NULL;
-
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-
- it->dirp = opendir(dir);
- if (!it->dirp)
- {
- free(it);
- return NULL;
- }
-
- memcpy(it->dir, dir, length + 1);
- if (dir[length - 1] != '/')
- it->length = length;
- else
- it->length = length - 1;
-
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_ls_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_file_ls_iterator_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_ls_iterator_free);
-
- return &it->iterator;
+ Eina_File_Iterator *it;
+ size_t length;
+
+ if (!dir)
+ return NULL;
+
+ length = strlen(dir);
+ if (length < 1)
+ return NULL;
+
+ it = calloc(1, sizeof(Eina_File_Iterator) + length);
+ if (!it)
+ return NULL;
+
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+ it->dirp = opendir(dir);
+ if (!it->dirp) {
+ free(it);
+ return NULL;
+ }
+
+ memcpy(it->dir, dir, length + 1);
+ if (dir[length - 1] != '/')
+ it->length = length;
+ else
+ it->length = length - 1;
+
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next =
+ FUNC_ITERATOR_NEXT(_eina_file_ls_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(_eina_file_ls_iterator_container);
+ it->iterator.free =
+ FUNC_ITERATOR_FREE(_eina_file_ls_iterator_free);
+
+ return &it->iterator;
}
/**
@@ -489,54 +478,54 @@ eina_file_ls(const char *dir)
*
* @see eina_file_ls()
*/
-EAPI Eina_Iterator *
-eina_file_direct_ls(const char *dir)
+EAPI Eina_Iterator *eina_file_direct_ls(const char *dir)
{
- Eina_File_Direct_Iterator *it;
- size_t length;
-
- if (!dir)
- return NULL;
-
- length = strlen(dir);
- if (length < 1)
- return NULL;
-
- if (length + NAME_MAX + 2 >= PATH_MAX)
- return NULL;
-
- it = calloc(1, sizeof(Eina_File_Direct_Iterator) + length);
- if (!it)
- return NULL;
-
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-
- it->dirp = opendir(dir);
- if (!it->dirp)
- {
- free(it);
- return NULL;
- }
-
- memcpy(it->dir, dir, length + 1);
- it->length = length;
-
- memcpy(it->info.path, dir, length);
- if (dir[length - 1] == '/')
- it->info.name_start = length;
- else
- {
- it->info.path[length] = '/';
- it->info.name_start = length + 1;
- }
-
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_direct_ls_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_file_direct_ls_iterator_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free);
-
- return &it->iterator;
+ Eina_File_Direct_Iterator *it;
+ size_t length;
+
+ if (!dir)
+ return NULL;
+
+ length = strlen(dir);
+ if (length < 1)
+ return NULL;
+
+ if (length + NAME_MAX + 2 >= PATH_MAX)
+ return NULL;
+
+ it = calloc(1, sizeof(Eina_File_Direct_Iterator) + length);
+ if (!it)
+ return NULL;
+
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+ it->dirp = opendir(dir);
+ if (!it->dirp) {
+ free(it);
+ return NULL;
+ }
+
+ memcpy(it->dir, dir, length + 1);
+ it->length = length;
+
+ memcpy(it->info.path, dir, length);
+ if (dir[length - 1] == '/')
+ it->info.name_start = length;
+ else {
+ it->info.path[length] = '/';
+ it->info.name_start = length + 1;
+ }
+
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next =
+ FUNC_ITERATOR_NEXT(_eina_file_direct_ls_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER
+ (_eina_file_direct_ls_iterator_container);
+ it->iterator.free =
+ FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free);
+
+ return &it->iterator;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_fp.c b/tests/suite/ecore/src/lib/eina_fp.c
index 73a2df0eb7..890c58ca88 100644
--- a/tests/suite/ecore/src/lib/eina_fp.c
+++ b/tests/suite/ecore/src/lib/eina_fp.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -9,524 +9,530 @@
#include "eina_fp.h"
#define MAX_PREC 1025
-static const Eina_F32p32 eina_trigo[MAX_PREC] =
-{
- 0x0000000100000000, 0x00000000ffffec43, 0x00000000ffffb10b,
- 0x00000000ffff4e5a, 0x00000000fffec42e, 0x00000000fffe1287,
- 0x00000000fffd3967, 0x00000000fffc38cd, 0x00000000fffb10b9,
- 0x00000000fff9c12c,
- 0x00000000fff84a25, 0x00000000fff6aba5, 0x00000000fff4e5ac,
- 0x00000000fff2f83b, 0x00000000fff0e351, 0x00000000ffeea6ef,
- 0x00000000ffec4316, 0x00000000ffe9b7c5, 0x00000000ffe704fe,
- 0x00000000ffe42ac0,
- 0x00000000ffe1290b, 0x00000000ffddffe2, 0x00000000ffdaaf43,
- 0x00000000ffd7372f, 0x00000000ffd397a8, 0x00000000ffcfd0ad,
- 0x00000000ffcbe23f, 0x00000000ffc7cc5f, 0x00000000ffc38f0d,
- 0x00000000ffbf2a4b,
- 0x00000000ffba9e17, 0x00000000ffb5ea75, 0x00000000ffb10f63,
- 0x00000000ffac0ce3, 0x00000000ffa6e2f6, 0x00000000ffa1919c,
- 0x00000000ff9c18d6, 0x00000000ff9678a6, 0x00000000ff90b10b,
- 0x00000000ff8ac208,
- 0x00000000ff84ab9c, 0x00000000ff7e6dc8, 0x00000000ff78088f,
- 0x00000000ff717bf0, 0x00000000ff6ac7ec, 0x00000000ff63ec85,
- 0x00000000ff5ce9bc, 0x00000000ff55bf92, 0x00000000ff4e6e08,
- 0x00000000ff46f51f,
- 0x00000000ff3f54d8, 0x00000000ff378d34, 0x00000000ff2f9e35,
- 0x00000000ff2787dc, 0x00000000ff1f4a2a, 0x00000000ff16e520,
- 0x00000000ff0e58c0, 0x00000000ff05a50a, 0x00000000fefcca01,
- 0x00000000fef3c7a6,
- 0x00000000feea9df9, 0x00000000fee14cfe, 0x00000000fed7d4b3,
- 0x00000000fece351d, 0x00000000fec46e3b, 0x00000000feba800f,
- 0x00000000feb06a9c, 0x00000000fea62de1, 0x00000000fe9bc9e2,
- 0x00000000fe913e9f,
- 0x00000000fe868c1b, 0x00000000fe7bb256, 0x00000000fe70b153,
- 0x00000000fe658913, 0x00000000fe5a3998, 0x00000000fe4ec2e4,
- 0x00000000fe4324f9, 0x00000000fe375fd7, 0x00000000fe2b7382,
- 0x00000000fe1f5ffa,
- 0x00000000fe132543, 0x00000000fe06c35d, 0x00000000fdfa3a4b,
- 0x00000000fded8a0e, 0x00000000fde0b2a8, 0x00000000fdd3b41c,
- 0x00000000fdc68e6c, 0x00000000fdb94199, 0x00000000fdabcda5,
- 0x00000000fd9e3294,
- 0x00000000fd907065, 0x00000000fd82871d, 0x00000000fd7476bd,
- 0x00000000fd663f46, 0x00000000fd57e0bd, 0x00000000fd495b21,
- 0x00000000fd3aae77, 0x00000000fd2bdabf, 0x00000000fd1cdffd,
- 0x00000000fd0dbe32,
- 0x00000000fcfe7562, 0x00000000fcef058e, 0x00000000fcdf6eb8,
- 0x00000000fccfb0e4, 0x00000000fcbfcc13, 0x00000000fcafc048,
- 0x00000000fc9f8d86, 0x00000000fc8f33ce, 0x00000000fc7eb325,
- 0x00000000fc6e0b8b,
- 0x00000000fc5d3d03, 0x00000000fc4c4791, 0x00000000fc3b2b37,
- 0x00000000fc29e7f7, 0x00000000fc187dd5, 0x00000000fc06ecd2,
- 0x00000000fbf534f2, 0x00000000fbe35637, 0x00000000fbd150a3,
- 0x00000000fbbf243b,
- 0x00000000fbacd100, 0x00000000fb9a56f6, 0x00000000fb87b61f,
- 0x00000000fb74ee7e, 0x00000000fb620016, 0x00000000fb4eeaea,
- 0x00000000fb3baefd, 0x00000000fb284c52, 0x00000000fb14c2eb,
- 0x00000000fb0112cd,
- 0x00000000faed3bf9, 0x00000000fad93e73, 0x00000000fac51a3f,
- 0x00000000fab0cf5e, 0x00000000fa9c5dd5, 0x00000000fa87c5a6,
- 0x00000000fa7306d5, 0x00000000fa5e2164, 0x00000000fa491558,
- 0x00000000fa33e2b3,
- 0x00000000fa1e8978, 0x00000000fa0909ab, 0x00000000f9f36350,
- 0x00000000f9dd9668, 0x00000000f9c7a2f9, 0x00000000f9b18905,
- 0x00000000f99b488f, 0x00000000f984e19c, 0x00000000f96e542e,
- 0x00000000f957a049,
- 0x00000000f940c5f1, 0x00000000f929c528, 0x00000000f9129df3,
- 0x00000000f8fb5056, 0x00000000f8e3dc53, 0x00000000f8cc41ee,
- 0x00000000f8b4812b, 0x00000000f89c9a0e, 0x00000000f8848c9b,
- 0x00000000f86c58d4,
- 0x00000000f853febe, 0x00000000f83b7e5d, 0x00000000f822d7b4,
- 0x00000000f80a0ac7, 0x00000000f7f1179a, 0x00000000f7d7fe31,
- 0x00000000f7bebe90, 0x00000000f7a558ba, 0x00000000f78bccb3,
- 0x00000000f7721a80,
- 0x00000000f7584225, 0x00000000f73e43a5, 0x00000000f7241f04,
- 0x00000000f709d446, 0x00000000f6ef6370, 0x00000000f6d4cc85,
- 0x00000000f6ba0f8a, 0x00000000f69f2c83, 0x00000000f6842374,
- 0x00000000f668f461,
- 0x00000000f64d9f4e, 0x00000000f632243f, 0x00000000f616833a,
- 0x00000000f5fabc41, 0x00000000f5decf59, 0x00000000f5c2bc87,
- 0x00000000f5a683cf, 0x00000000f58a2535, 0x00000000f56da0be,
- 0x00000000f550f66e,
- 0x00000000f5342649, 0x00000000f5173054, 0x00000000f4fa1494,
- 0x00000000f4dcd30c, 0x00000000f4bf6bc2, 0x00000000f4a1deb9,
- 0x00000000f4842bf7, 0x00000000f4665380, 0x00000000f4485559,
- 0x00000000f42a3186,
- 0x00000000f40be80c, 0x00000000f3ed78ef, 0x00000000f3cee434,
- 0x00000000f3b029e1, 0x00000000f39149f9, 0x00000000f3724482,
- 0x00000000f3531980, 0x00000000f333c8f8, 0x00000000f31452ef,
- 0x00000000f2f4b76a,
- 0x00000000f2d4f66d, 0x00000000f2b50ffe, 0x00000000f2950421,
- 0x00000000f274d2dc, 0x00000000f2547c33, 0x00000000f234002b,
- 0x00000000f2135eca, 0x00000000f1f29814, 0x00000000f1d1ac0e,
- 0x00000000f1b09abe,
- 0x00000000f18f6429, 0x00000000f16e0853, 0x00000000f14c8742,
- 0x00000000f12ae0fb, 0x00000000f1091583, 0x00000000f0e724e0,
- 0x00000000f0c50f17, 0x00000000f0a2d42c, 0x00000000f0807426,
- 0x00000000f05def09,
- 0x00000000f03b44db, 0x00000000f01875a1, 0x00000000eff58161,
- 0x00000000efd2681f, 0x00000000efaf29e2, 0x00000000ef8bc6af,
- 0x00000000ef683e8b, 0x00000000ef44917b, 0x00000000ef20bf86,
- 0x00000000eefcc8b1,
- 0x00000000eed8ad01, 0x00000000eeb46c7b, 0x00000000ee900727,
- 0x00000000ee6b7d08, 0x00000000ee46ce25, 0x00000000ee21fa83,
- 0x00000000edfd0228, 0x00000000edd7e51a, 0x00000000edb2a35f,
- 0x00000000ed8d3cfc,
- 0x00000000ed67b1f6, 0x00000000ed420255, 0x00000000ed1c2e1d,
- 0x00000000ecf63554, 0x00000000ecd01801, 0x00000000eca9d628,
- 0x00000000ec836fd1, 0x00000000ec5ce501, 0x00000000ec3635bd,
- 0x00000000ec0f620d,
- 0x00000000ebe869f5, 0x00000000ebc14d7d, 0x00000000eb9a0ca9,
- 0x00000000eb72a780, 0x00000000eb4b1e08, 0x00000000eb237047,
- 0x00000000eafb9e43, 0x00000000ead3a803, 0x00000000eaab8d8d,
- 0x00000000ea834ee6,
- 0x00000000ea5aec15, 0x00000000ea326520, 0x00000000ea09ba0d,
- 0x00000000e9e0eae4, 0x00000000e9b7f7a9, 0x00000000e98ee063,
- 0x00000000e965a51a, 0x00000000e93c45d2, 0x00000000e912c292,
- 0x00000000e8e91b61,
- 0x00000000e8bf5046, 0x00000000e8956146, 0x00000000e86b4e68,
- 0x00000000e84117b3, 0x00000000e816bd2d, 0x00000000e7ec3edc,
- 0x00000000e7c19cc8, 0x00000000e796d6f6, 0x00000000e76bed6e,
- 0x00000000e740e036,
- 0x00000000e715af54, 0x00000000e6ea5ad0, 0x00000000e6bee2af,
- 0x00000000e69346f9, 0x00000000e66787b5, 0x00000000e63ba4e9,
- 0x00000000e60f9e9b, 0x00000000e5e374d4, 0x00000000e5b72798,
- 0x00000000e58ab6f1,
- 0x00000000e55e22e3, 0x00000000e5316b76, 0x00000000e50490b1,
- 0x00000000e4d7929c, 0x00000000e4aa713c, 0x00000000e47d2c98,
- 0x00000000e44fc4b9, 0x00000000e42239a4, 0x00000000e3f48b61,
- 0x00000000e3c6b9f7,
- 0x00000000e398c56c, 0x00000000e36aadc9, 0x00000000e33c7314,
- 0x00000000e30e1554, 0x00000000e2df9490, 0x00000000e2b0f0d0,
- 0x00000000e2822a1a, 0x00000000e2534077, 0x00000000e22433ec,
- 0x00000000e1f50482,
- 0x00000000e1c5b240, 0x00000000e1963d2d, 0x00000000e166a550,
- 0x00000000e136eab0, 0x00000000e1070d56, 0x00000000e0d70d48,
- 0x00000000e0a6ea8e, 0x00000000e076a52f, 0x00000000e0463d33,
- 0x00000000e015b2a1,
- 0x00000000dfe50580, 0x00000000dfb435d9, 0x00000000df8343b2,
- 0x00000000df522f13, 0x00000000df20f804, 0x00000000deef9e8d,
- 0x00000000debe22b5, 0x00000000de8c8483, 0x00000000de5ac3ff,
- 0x00000000de28e131,
- 0x00000000ddf6dc21, 0x00000000ddc4b4d6, 0x00000000dd926b59,
- 0x00000000dd5fffb0, 0x00000000dd2d71e3, 0x00000000dcfac1fb,
- 0x00000000dcc7f000, 0x00000000dc94fbf8, 0x00000000dc61e5ec,
- 0x00000000dc2eade4,
- 0x00000000dbfb53e8, 0x00000000dbc7d7ff, 0x00000000db943a31,
- 0x00000000db607a88, 0x00000000db2c9909, 0x00000000daf895bf,
- 0x00000000dac470af, 0x00000000da9029e3, 0x00000000da5bc163,
- 0x00000000da273737,
- 0x00000000d9f28b66, 0x00000000d9bdbdf9, 0x00000000d988cef8,
- 0x00000000d953be6b, 0x00000000d91e8c5b, 0x00000000d8e938d0,
- 0x00000000d8b3c3d1, 0x00000000d87e2d67, 0x00000000d848759b,
- 0x00000000d8129c74,
- 0x00000000d7dca1fb, 0x00000000d7a68638, 0x00000000d7704934,
- 0x00000000d739eaf7, 0x00000000d7036b89, 0x00000000d6cccaf3,
- 0x00000000d696093d, 0x00000000d65f266f, 0x00000000d6282293,
- 0x00000000d5f0fdb0,
- 0x00000000d5b9b7d0, 0x00000000d58250fa, 0x00000000d54ac937,
- 0x00000000d513208f, 0x00000000d4db570c, 0x00000000d4a36cb6,
- 0x00000000d46b6195, 0x00000000d43335b3, 0x00000000d3fae917,
- 0x00000000d3c27bcb,
- 0x00000000d389edd7, 0x00000000d3513f43, 0x00000000d318701a,
- 0x00000000d2df8063, 0x00000000d2a67027, 0x00000000d26d3f6f,
- 0x00000000d233ee43, 0x00000000d1fa7cae, 0x00000000d1c0eab7,
- 0x00000000d1873867,
- 0x00000000d14d65c8, 0x00000000d11372e1, 0x00000000d0d95fbd,
- 0x00000000d09f2c64, 0x00000000d064d8df, 0x00000000d02a6537,
- 0x00000000cfefd176, 0x00000000cfb51da3, 0x00000000cf7a49c8,
- 0x00000000cf3f55ef,
- 0x00000000cf044220, 0x00000000cec90e64, 0x00000000ce8dbac5,
- 0x00000000ce52474c, 0x00000000ce16b401, 0x00000000cddb00ef,
- 0x00000000cd9f2e1e, 0x00000000cd633b97, 0x00000000cd272964,
- 0x00000000cceaf78e,
- 0x00000000ccaea61e, 0x00000000cc72351e, 0x00000000cc35a497,
- 0x00000000cbf8f492, 0x00000000cbbc2519, 0x00000000cb7f3634,
- 0x00000000cb4227ee, 0x00000000cb04fa50, 0x00000000cac7ad63,
- 0x00000000ca8a4131,
- 0x00000000ca4cb5c3, 0x00000000ca0f0b22, 0x00000000c9d14159,
- 0x00000000c9935870, 0x00000000c9555072, 0x00000000c9172967,
- 0x00000000c8d8e35a, 0x00000000c89a7e53, 0x00000000c85bfa5e,
- 0x00000000c81d5782,
- 0x00000000c7de95cb, 0x00000000c79fb541, 0x00000000c760b5ee,
- 0x00000000c72197dc, 0x00000000c6e25b15, 0x00000000c6a2ffa3,
- 0x00000000c663858f, 0x00000000c623ece2, 0x00000000c5e435a8,
- 0x00000000c5a45fe9,
- 0x00000000c5646bb0, 0x00000000c5245906, 0x00000000c4e427f6,
- 0x00000000c4a3d888, 0x00000000c4636ac8, 0x00000000c422debf,
- 0x00000000c3e23476, 0x00000000c3a16bf9, 0x00000000c3608550,
- 0x00000000c31f8087,
- 0x00000000c2de5da6, 0x00000000c29d1cb8, 0x00000000c25bbdc8,
- 0x00000000c21a40de, 0x00000000c1d8a606, 0x00000000c196ed49,
- 0x00000000c15516b2, 0x00000000c113224a, 0x00000000c0d1101d,
- 0x00000000c08ee033,
- 0x00000000c04c9297, 0x00000000c00a2754, 0x00000000bfc79e73,
- 0x00000000bf84f800, 0x00000000bf423404, 0x00000000beff5289,
- 0x00000000bebc539a, 0x00000000be793741, 0x00000000be35fd89,
- 0x00000000bdf2a67b,
- 0x00000000bdaf3223, 0x00000000bd6ba08b, 0x00000000bd27f1bc,
- 0x00000000bce425c2, 0x00000000bca03ca7, 0x00000000bc5c3676,
- 0x00000000bc181338, 0x00000000bbd3d2f9, 0x00000000bb8f75c3,
- 0x00000000bb4afba1,
- 0x00000000bb06649c, 0x00000000bac1b0c0, 0x00000000ba7ce018,
- 0x00000000ba37f2ad, 0x00000000b9f2e88b, 0x00000000b9adc1bc,
- 0x00000000b9687e4a, 0x00000000b9231e41, 0x00000000b8dda1ac,
- 0x00000000b8980894,
- 0x00000000b8525305, 0x00000000b80c8109, 0x00000000b7c692ac,
- 0x00000000b78087f7, 0x00000000b73a60f6, 0x00000000b6f41db4,
- 0x00000000b6adbe3a, 0x00000000b6674296, 0x00000000b620aad0,
- 0x00000000b5d9f6f4,
- 0x00000000b593270e, 0x00000000b54c3b27, 0x00000000b505334a,
- 0x00000000b4be0f84, 0x00000000b476cfde, 0x00000000b42f7464,
- 0x00000000b3e7fd20, 0x00000000b3a06a1e, 0x00000000b358bb69,
- 0x00000000b310f10c,
- 0x00000000b2c90b11, 0x00000000b2810985, 0x00000000b238ec71,
- 0x00000000b1f0b3e2, 0x00000000b1a85fe2, 0x00000000b15ff07c,
- 0x00000000b11765bc, 0x00000000b0cebfad, 0x00000000b085fe5a,
- 0x00000000b03d21ce,
- 0x00000000aff42a15, 0x00000000afab1739, 0x00000000af61e946,
- 0x00000000af18a048, 0x00000000aecf3c49, 0x00000000ae85bd55,
- 0x00000000ae3c2377, 0x00000000adf26ebb, 0x00000000ada89f2c,
- 0x00000000ad5eb4d5,
- 0x00000000ad14afc2, 0x00000000acca8ffd, 0x00000000ac805594,
- 0x00000000ac360090, 0x00000000abeb90fe, 0x00000000aba106e9,
- 0x00000000ab56625d, 0x00000000ab0ba364, 0x00000000aac0ca0b,
- 0x00000000aa75d65d,
- 0x00000000aa2ac865, 0x00000000a9dfa030, 0x00000000a9945dc9,
- 0x00000000a949013a, 0x00000000a8fd8a91, 0x00000000a8b1f9d8,
- 0x00000000a8664f1c, 0x00000000a81a8a68, 0x00000000a7ceabc7,
- 0x00000000a782b345,
- 0x00000000a736a0ef, 0x00000000a6ea74cf, 0x00000000a69e2ef2,
- 0x00000000a651cf63, 0x00000000a605562f, 0x00000000a5b8c360,
- 0x00000000a56c1702, 0x00000000a51f5123, 0x00000000a4d271cc,
- 0x00000000a485790b,
- 0x00000000a43866eb, 0x00000000a3eb3b77, 0x00000000a39df6bd,
- 0x00000000a35098c7, 0x00000000a30321a2, 0x00000000a2b5915a,
- 0x00000000a267e7fa, 0x00000000a21a258e, 0x00000000a1cc4a24,
- 0x00000000a17e55c5,
- 0x00000000a1304880, 0x00000000a0e2225f, 0x00000000a093e36f,
- 0x00000000a0458bbb, 0x000000009ff71b50, 0x000000009fa8923a,
- 0x000000009f59f086, 0x000000009f0b363e, 0x000000009ebc6370,
- 0x000000009e6d7827,
- 0x000000009e1e746f, 0x000000009dcf5856, 0x000000009d8023e6,
- 0x000000009d30d72d, 0x000000009ce17236, 0x000000009c91f50e,
- 0x000000009c425fc1, 0x000000009bf2b25b, 0x000000009ba2ece8,
- 0x000000009b530f76,
- 0x000000009b031a0f, 0x000000009ab30cc1, 0x000000009a62e797,
- 0x000000009a12aa9f, 0x0000000099c255e5, 0x000000009971e974,
- 0x000000009921655a, 0x0000000098d0c9a2, 0x0000000098801659,
- 0x00000000982f4b8d,
- 0x0000000097de6948, 0x00000000978d6f97, 0x00000000973c5e88,
- 0x0000000096eb3626, 0x000000009699f67f, 0x0000000096489f9e,
- 0x0000000095f73190, 0x0000000095a5ac61, 0x000000009554101f,
- 0x0000000095025cd6,
- 0x0000000094b09292, 0x00000000945eb161, 0x00000000940cb94e,
- 0x0000000093baaa66, 0x00000000936884b6, 0x000000009316484b,
- 0x0000000092c3f531, 0x0000000092718b75, 0x00000000921f0b24,
- 0x0000000091cc744b,
- 0x000000009179c6f5, 0x0000000091270331, 0x0000000090d4290a,
- 0x000000009081388e, 0x00000000902e31c8, 0x000000008fdb14c7,
- 0x000000008f87e197, 0x000000008f349845, 0x000000008ee138dd,
- 0x000000008e8dc36c,
- 0x000000008e3a3800, 0x000000008de696a5, 0x000000008d92df68,
- 0x000000008d3f1256, 0x000000008ceb2f7c, 0x000000008c9736e7,
- 0x000000008c4328a3, 0x000000008bef04bf, 0x000000008b9acb46,
- 0x000000008b467c45,
- 0x000000008af217cb, 0x000000008a9d9de3, 0x000000008a490e9b,
- 0x0000000089f469ff, 0x00000000899fb01e, 0x00000000894ae103,
- 0x0000000088f5fcbc, 0x0000000088a10357, 0x00000000884bf4df,
- 0x0000000087f6d163,
- 0x0000000087a198f0, 0x00000000874c4b92, 0x0000000086f6e956,
- 0x0000000086a1724b, 0x00000000864be67c, 0x0000000085f645f8,
- 0x0000000085a090cc, 0x00000000854ac704, 0x0000000084f4e8ad,
- 0x00000000849ef5d7,
- 0x000000008448ee8c, 0x0000000083f2d2db, 0x00000000839ca2d1,
- 0x0000000083465e7c, 0x0000000082f005e8, 0x0000000082999922,
- 0x0000000082431839, 0x0000000081ec833a, 0x000000008195da31,
- 0x00000000813f1d2d,
- 0x0000000080e84c3a, 0x0000000080916766, 0x00000000803a6ebf,
- 0x000000007fe36251, 0x000000007f8c422b, 0x000000007f350e59,
- 0x000000007eddc6ea, 0x000000007e866bea, 0x000000007e2efd67,
- 0x000000007dd77b6f,
- 0x000000007d7fe60f, 0x000000007d283d54, 0x000000007cd0814c,
- 0x000000007c78b205, 0x000000007c20cf8c, 0x000000007bc8d9ef,
- 0x000000007b70d13b, 0x000000007b18b57e, 0x000000007ac086c5,
- 0x000000007a68451f,
- 0x000000007a0ff098, 0x0000000079b7893e, 0x00000000795f0f1f,
- 0x0000000079068248, 0x0000000078ade2c8, 0x00000000785530ab,
- 0x0000000077fc6c01, 0x0000000077a394d5, 0x00000000774aab36,
- 0x0000000076f1af32,
- 0x000000007698a0d6, 0x00000000763f8030, 0x0000000075e64d4e,
- 0x00000000758d083e, 0x000000007533b10d, 0x0000000074da47c9,
- 0x000000007480cc80, 0x0000000074273f3f, 0x0000000073cda016,
- 0x000000007373ef10,
- 0x00000000731a2c3d, 0x0000000072c057aa, 0x0000000072667164,
- 0x00000000720c797a, 0x0000000071b26ffa, 0x00000000715854f2,
- 0x0000000070fe286e, 0x0000000070a3ea7e, 0x0000000070499b30,
- 0x000000006fef3a90,
- 0x000000006f94c8ae, 0x000000006f3a4596, 0x000000006edfb157,
- 0x000000006e850c00, 0x000000006e2a559d, 0x000000006dcf8e3d,
- 0x000000006d74b5ee, 0x000000006d19ccbe, 0x000000006cbed2bb,
- 0x000000006c63c7f3,
- 0x000000006c08ac74, 0x000000006bad804c, 0x000000006b524389,
- 0x000000006af6f639, 0x000000006a9b986b, 0x000000006a402a2c,
- 0x0000000069e4ab8a, 0x0000000069891c94, 0x00000000692d7d57,
- 0x0000000068d1cde3,
- 0x0000000068760e44, 0x00000000681a3e89, 0x0000000067be5ec1,
- 0x0000000067626ef9, 0x0000000067066f40, 0x0000000066aa5fa3,
- 0x00000000664e4032, 0x0000000065f210f9, 0x000000006595d209,
- 0x000000006539836d,
- 0x0000000064dd2536, 0x000000006480b770, 0x0000000064243a2b,
- 0x0000000063c7ad75, 0x00000000636b115c, 0x00000000630e65ed,
- 0x0000000062b1ab39, 0x000000006254e14c, 0x0000000061f80835,
- 0x00000000619b2002,
- 0x00000000613e28c2, 0x0000000060e12283, 0x0000000060840d54,
- 0x000000006026e943, 0x000000005fc9b65d, 0x000000005f6c74b2,
- 0x000000005f0f2450, 0x000000005eb1c545, 0x000000005e5457a0,
- 0x000000005df6db6f,
- 0x000000005d9950c0, 0x000000005d3bb7a3, 0x000000005cde1024,
- 0x000000005c805a54, 0x000000005c22963f, 0x000000005bc4c3f6,
- 0x000000005b66e385, 0x000000005b08f4fd, 0x000000005aaaf86a,
- 0x000000005a4ceddc,
- 0x0000000059eed561, 0x000000005990af08, 0x0000000059327adf,
- 0x0000000058d438f4, 0x000000005875e957, 0x0000000058178c16,
- 0x0000000057b9213f, 0x00000000575aa8e0, 0x0000000056fc230a,
- 0x00000000569d8fc9,
- 0x00000000563eef2d, 0x0000000055e04144, 0x000000005581861d,
- 0x000000005522bdc6, 0x0000000054c3e84e, 0x00000000546505c4,
- 0x0000000054061636, 0x0000000053a719b3, 0x000000005348104a,
- 0x0000000052e8fa09,
- 0x000000005289d6ff, 0x00000000522aa73a, 0x0000000051cb6aca,
- 0x00000000516c21bc, 0x00000000510ccc20, 0x0000000050ad6a05,
- 0x00000000504dfb78, 0x000000004fee808a, 0x000000004f8ef947,
- 0x000000004f2f65c0,
- 0x000000004ecfc603, 0x000000004e701a1f, 0x000000004e106222,
- 0x000000004db09e1b, 0x000000004d50ce19, 0x000000004cf0f22b,
- 0x000000004c910a5f, 0x000000004c3116c5, 0x000000004bd1176b,
- 0x000000004b710c5f,
- 0x000000004b10f5b2, 0x000000004ab0d371, 0x000000004a50a5ab,
- 0x0000000049f06c70, 0x00000000499027cd, 0x00000000492fd7d3,
- 0x0000000048cf7c8f, 0x00000000486f1611, 0x00000000480ea467,
- 0x0000000047ae27a1,
- 0x00000000474d9fcd, 0x0000000046ed0cfa, 0x00000000468c6f37,
- 0x00000000462bc693, 0x0000000045cb131c, 0x00000000456a54e3,
- 0x0000000045098bf5, 0x0000000044a8b861, 0x000000004447da37,
- 0x0000000043e6f186,
- 0x000000004385fe5c, 0x00000000432500c8, 0x0000000042c3f8d9,
- 0x000000004262e69f, 0x000000004201ca28, 0x0000000041a0a383,
- 0x00000000413f72bf, 0x0000000040de37eb, 0x00000000407cf317,
- 0x00000000401ba450,
- 0x000000003fba4ba7, 0x000000003f58e92a, 0x000000003ef77ce8,
- 0x000000003e9606f1, 0x000000003e348752, 0x000000003dd2fe1c,
- 0x000000003d716b5e, 0x000000003d0fcf25, 0x000000003cae2982,
- 0x000000003c4c7a83,
- 0x000000003beac238, 0x000000003b8900b0, 0x000000003b2735f9,
- 0x000000003ac56223, 0x000000003a63853d, 0x000000003a019f56,
- 0x00000000399fb07d, 0x00000000393db8c1, 0x0000000038dbb831,
- 0x000000003879aedd,
- 0x0000000038179cd3, 0x0000000037b58222, 0x0000000037535edb,
- 0x0000000036f1330b, 0x00000000368efec2, 0x00000000362cc20f,
- 0x0000000035ca7d02, 0x0000000035682fa9, 0x000000003505da14,
- 0x0000000034a37c51,
- 0x0000000034411671, 0x0000000033dea881, 0x00000000337c3292,
- 0x000000003319b4b3, 0x0000000032b72ef2, 0x000000003254a15e,
- 0x0000000031f20c08, 0x00000000318f6efe, 0x00000000312cca50,
- 0x0000000030ca1e0c,
- 0x0000000030676a43, 0x000000003004af02, 0x000000002fa1ec5a,
- 0x000000002f3f2259, 0x000000002edc510f, 0x000000002e79788b,
- 0x000000002e1698dc, 0x000000002db3b212, 0x000000002d50c43c,
- 0x000000002cedcf68,
- 0x000000002c8ad3a7, 0x000000002c27d108, 0x000000002bc4c799,
- 0x000000002b61b76b, 0x000000002afea08c, 0x000000002a9b830b,
- 0x000000002a385ef9, 0x0000000029d53464, 0x000000002972035b,
- 0x00000000290ecbee,
- 0x0000000028ab8e2c, 0x0000000028484a25, 0x0000000027e4ffe7,
- 0x000000002781af83, 0x00000000271e5906, 0x0000000026bafc82,
- 0x0000000026579a04, 0x0000000025f4319d, 0x000000002590c35c,
- 0x00000000252d4f4f,
- 0x0000000024c9d587, 0x0000000024665613, 0x000000002402d101,
- 0x00000000239f4662, 0x00000000233bb644, 0x0000000022d820b8,
- 0x00000000227485cc, 0x000000002210e590, 0x0000000021ad4013,
- 0x0000000021499565,
- 0x0000000020e5e594, 0x00000000208230b1, 0x00000000201e76ca,
- 0x000000001fbab7ef, 0x000000001f56f430, 0x000000001ef32b9b,
- 0x000000001e8f5e41, 0x000000001e2b8c30, 0x000000001dc7b578,
- 0x000000001d63da29,
- 0x000000001cfffa51, 0x000000001c9c1600, 0x000000001c382d46,
- 0x000000001bd44032, 0x000000001b704ed3, 0x000000001b0c5939,
- 0x000000001aa85f74, 0x000000001a446191, 0x0000000019e05fa2,
- 0x00000000197c59b5,
- 0x0000000019184fdb, 0x0000000018b44221, 0x0000000018503098,
- 0x0000000017ec1b50, 0x0000000017880257, 0x000000001723e5bd,
- 0x0000000016bfc591, 0x00000000165ba1e4, 0x0000000015f77ac3,
- 0x0000000015935040,
- 0x00000000152f2269, 0x0000000014caf14d, 0x000000001466bcfd,
- 0x0000000014028587, 0x00000000139e4afb, 0x00000000133a0d69,
- 0x0000000012d5cce0, 0x000000001271896f, 0x00000000120d4326,
- 0x0000000011a8fa15,
- 0x000000001144ae4a, 0x0000000010e05fd6, 0x00000000107c0ec7,
- 0x000000001017bb2d, 0x000000000fb36519, 0x000000000f4f0c98,
- 0x000000000eeab1bb, 0x000000000e865491, 0x000000000e21f52a,
- 0x000000000dbd9395,
- 0x000000000d592fe1, 0x000000000cf4ca1f, 0x000000000c90625c,
- 0x000000000c2bf8aa, 0x000000000bc78d18, 0x000000000b631fb4,
- 0x000000000afeb08f, 0x000000000a9a3fb8, 0x000000000a35cd3e,
- 0x0000000009d15931,
- 0x00000000096ce3a1, 0x0000000009086c9c, 0x0000000008a3f433,
- 0x00000000083f7a75, 0x0000000007daff71, 0x0000000007768337,
- 0x00000000071205d6, 0x0000000006ad875f, 0x00000000064907df,
- 0x0000000005e48768,
- 0x0000000005800608, 0x00000000051b83cf, 0x0000000004b700cc,
- 0x0000000004527d0f, 0x0000000003edf8a7, 0x00000000038973a4,
- 0x000000000324ee16, 0x0000000002c0680b, 0x00000000025be194,
- 0x0000000001f75ac0,
- 0x000000000192d39e, 0x00000000012e4c3e, 0x0000000000c9c4af,
- 0x0000000000653d02, 0x0000000000000000
+static const Eina_F32p32 eina_trigo[MAX_PREC] = {
+ 0x0000000100000000, 0x00000000ffffec43, 0x00000000ffffb10b,
+ 0x00000000ffff4e5a, 0x00000000fffec42e, 0x00000000fffe1287,
+ 0x00000000fffd3967, 0x00000000fffc38cd, 0x00000000fffb10b9,
+ 0x00000000fff9c12c,
+ 0x00000000fff84a25, 0x00000000fff6aba5, 0x00000000fff4e5ac,
+ 0x00000000fff2f83b, 0x00000000fff0e351, 0x00000000ffeea6ef,
+ 0x00000000ffec4316, 0x00000000ffe9b7c5, 0x00000000ffe704fe,
+ 0x00000000ffe42ac0,
+ 0x00000000ffe1290b, 0x00000000ffddffe2, 0x00000000ffdaaf43,
+ 0x00000000ffd7372f, 0x00000000ffd397a8, 0x00000000ffcfd0ad,
+ 0x00000000ffcbe23f, 0x00000000ffc7cc5f, 0x00000000ffc38f0d,
+ 0x00000000ffbf2a4b,
+ 0x00000000ffba9e17, 0x00000000ffb5ea75, 0x00000000ffb10f63,
+ 0x00000000ffac0ce3, 0x00000000ffa6e2f6, 0x00000000ffa1919c,
+ 0x00000000ff9c18d6, 0x00000000ff9678a6, 0x00000000ff90b10b,
+ 0x00000000ff8ac208,
+ 0x00000000ff84ab9c, 0x00000000ff7e6dc8, 0x00000000ff78088f,
+ 0x00000000ff717bf0, 0x00000000ff6ac7ec, 0x00000000ff63ec85,
+ 0x00000000ff5ce9bc, 0x00000000ff55bf92, 0x00000000ff4e6e08,
+ 0x00000000ff46f51f,
+ 0x00000000ff3f54d8, 0x00000000ff378d34, 0x00000000ff2f9e35,
+ 0x00000000ff2787dc, 0x00000000ff1f4a2a, 0x00000000ff16e520,
+ 0x00000000ff0e58c0, 0x00000000ff05a50a, 0x00000000fefcca01,
+ 0x00000000fef3c7a6,
+ 0x00000000feea9df9, 0x00000000fee14cfe, 0x00000000fed7d4b3,
+ 0x00000000fece351d, 0x00000000fec46e3b, 0x00000000feba800f,
+ 0x00000000feb06a9c, 0x00000000fea62de1, 0x00000000fe9bc9e2,
+ 0x00000000fe913e9f,
+ 0x00000000fe868c1b, 0x00000000fe7bb256, 0x00000000fe70b153,
+ 0x00000000fe658913, 0x00000000fe5a3998, 0x00000000fe4ec2e4,
+ 0x00000000fe4324f9, 0x00000000fe375fd7, 0x00000000fe2b7382,
+ 0x00000000fe1f5ffa,
+ 0x00000000fe132543, 0x00000000fe06c35d, 0x00000000fdfa3a4b,
+ 0x00000000fded8a0e, 0x00000000fde0b2a8, 0x00000000fdd3b41c,
+ 0x00000000fdc68e6c, 0x00000000fdb94199, 0x00000000fdabcda5,
+ 0x00000000fd9e3294,
+ 0x00000000fd907065, 0x00000000fd82871d, 0x00000000fd7476bd,
+ 0x00000000fd663f46, 0x00000000fd57e0bd, 0x00000000fd495b21,
+ 0x00000000fd3aae77, 0x00000000fd2bdabf, 0x00000000fd1cdffd,
+ 0x00000000fd0dbe32,
+ 0x00000000fcfe7562, 0x00000000fcef058e, 0x00000000fcdf6eb8,
+ 0x00000000fccfb0e4, 0x00000000fcbfcc13, 0x00000000fcafc048,
+ 0x00000000fc9f8d86, 0x00000000fc8f33ce, 0x00000000fc7eb325,
+ 0x00000000fc6e0b8b,
+ 0x00000000fc5d3d03, 0x00000000fc4c4791, 0x00000000fc3b2b37,
+ 0x00000000fc29e7f7, 0x00000000fc187dd5, 0x00000000fc06ecd2,
+ 0x00000000fbf534f2, 0x00000000fbe35637, 0x00000000fbd150a3,
+ 0x00000000fbbf243b,
+ 0x00000000fbacd100, 0x00000000fb9a56f6, 0x00000000fb87b61f,
+ 0x00000000fb74ee7e, 0x00000000fb620016, 0x00000000fb4eeaea,
+ 0x00000000fb3baefd, 0x00000000fb284c52, 0x00000000fb14c2eb,
+ 0x00000000fb0112cd,
+ 0x00000000faed3bf9, 0x00000000fad93e73, 0x00000000fac51a3f,
+ 0x00000000fab0cf5e, 0x00000000fa9c5dd5, 0x00000000fa87c5a6,
+ 0x00000000fa7306d5, 0x00000000fa5e2164, 0x00000000fa491558,
+ 0x00000000fa33e2b3,
+ 0x00000000fa1e8978, 0x00000000fa0909ab, 0x00000000f9f36350,
+ 0x00000000f9dd9668, 0x00000000f9c7a2f9, 0x00000000f9b18905,
+ 0x00000000f99b488f, 0x00000000f984e19c, 0x00000000f96e542e,
+ 0x00000000f957a049,
+ 0x00000000f940c5f1, 0x00000000f929c528, 0x00000000f9129df3,
+ 0x00000000f8fb5056, 0x00000000f8e3dc53, 0x00000000f8cc41ee,
+ 0x00000000f8b4812b, 0x00000000f89c9a0e, 0x00000000f8848c9b,
+ 0x00000000f86c58d4,
+ 0x00000000f853febe, 0x00000000f83b7e5d, 0x00000000f822d7b4,
+ 0x00000000f80a0ac7, 0x00000000f7f1179a, 0x00000000f7d7fe31,
+ 0x00000000f7bebe90, 0x00000000f7a558ba, 0x00000000f78bccb3,
+ 0x00000000f7721a80,
+ 0x00000000f7584225, 0x00000000f73e43a5, 0x00000000f7241f04,
+ 0x00000000f709d446, 0x00000000f6ef6370, 0x00000000f6d4cc85,
+ 0x00000000f6ba0f8a, 0x00000000f69f2c83, 0x00000000f6842374,
+ 0x00000000f668f461,
+ 0x00000000f64d9f4e, 0x00000000f632243f, 0x00000000f616833a,
+ 0x00000000f5fabc41, 0x00000000f5decf59, 0x00000000f5c2bc87,
+ 0x00000000f5a683cf, 0x00000000f58a2535, 0x00000000f56da0be,
+ 0x00000000f550f66e,
+ 0x00000000f5342649, 0x00000000f5173054, 0x00000000f4fa1494,
+ 0x00000000f4dcd30c, 0x00000000f4bf6bc2, 0x00000000f4a1deb9,
+ 0x00000000f4842bf7, 0x00000000f4665380, 0x00000000f4485559,
+ 0x00000000f42a3186,
+ 0x00000000f40be80c, 0x00000000f3ed78ef, 0x00000000f3cee434,
+ 0x00000000f3b029e1, 0x00000000f39149f9, 0x00000000f3724482,
+ 0x00000000f3531980, 0x00000000f333c8f8, 0x00000000f31452ef,
+ 0x00000000f2f4b76a,
+ 0x00000000f2d4f66d, 0x00000000f2b50ffe, 0x00000000f2950421,
+ 0x00000000f274d2dc, 0x00000000f2547c33, 0x00000000f234002b,
+ 0x00000000f2135eca, 0x00000000f1f29814, 0x00000000f1d1ac0e,
+ 0x00000000f1b09abe,
+ 0x00000000f18f6429, 0x00000000f16e0853, 0x00000000f14c8742,
+ 0x00000000f12ae0fb, 0x00000000f1091583, 0x00000000f0e724e0,
+ 0x00000000f0c50f17, 0x00000000f0a2d42c, 0x00000000f0807426,
+ 0x00000000f05def09,
+ 0x00000000f03b44db, 0x00000000f01875a1, 0x00000000eff58161,
+ 0x00000000efd2681f, 0x00000000efaf29e2, 0x00000000ef8bc6af,
+ 0x00000000ef683e8b, 0x00000000ef44917b, 0x00000000ef20bf86,
+ 0x00000000eefcc8b1,
+ 0x00000000eed8ad01, 0x00000000eeb46c7b, 0x00000000ee900727,
+ 0x00000000ee6b7d08, 0x00000000ee46ce25, 0x00000000ee21fa83,
+ 0x00000000edfd0228, 0x00000000edd7e51a, 0x00000000edb2a35f,
+ 0x00000000ed8d3cfc,
+ 0x00000000ed67b1f6, 0x00000000ed420255, 0x00000000ed1c2e1d,
+ 0x00000000ecf63554, 0x00000000ecd01801, 0x00000000eca9d628,
+ 0x00000000ec836fd1, 0x00000000ec5ce501, 0x00000000ec3635bd,
+ 0x00000000ec0f620d,
+ 0x00000000ebe869f5, 0x00000000ebc14d7d, 0x00000000eb9a0ca9,
+ 0x00000000eb72a780, 0x00000000eb4b1e08, 0x00000000eb237047,
+ 0x00000000eafb9e43, 0x00000000ead3a803, 0x00000000eaab8d8d,
+ 0x00000000ea834ee6,
+ 0x00000000ea5aec15, 0x00000000ea326520, 0x00000000ea09ba0d,
+ 0x00000000e9e0eae4, 0x00000000e9b7f7a9, 0x00000000e98ee063,
+ 0x00000000e965a51a, 0x00000000e93c45d2, 0x00000000e912c292,
+ 0x00000000e8e91b61,
+ 0x00000000e8bf5046, 0x00000000e8956146, 0x00000000e86b4e68,
+ 0x00000000e84117b3, 0x00000000e816bd2d, 0x00000000e7ec3edc,
+ 0x00000000e7c19cc8, 0x00000000e796d6f6, 0x00000000e76bed6e,
+ 0x00000000e740e036,
+ 0x00000000e715af54, 0x00000000e6ea5ad0, 0x00000000e6bee2af,
+ 0x00000000e69346f9, 0x00000000e66787b5, 0x00000000e63ba4e9,
+ 0x00000000e60f9e9b, 0x00000000e5e374d4, 0x00000000e5b72798,
+ 0x00000000e58ab6f1,
+ 0x00000000e55e22e3, 0x00000000e5316b76, 0x00000000e50490b1,
+ 0x00000000e4d7929c, 0x00000000e4aa713c, 0x00000000e47d2c98,
+ 0x00000000e44fc4b9, 0x00000000e42239a4, 0x00000000e3f48b61,
+ 0x00000000e3c6b9f7,
+ 0x00000000e398c56c, 0x00000000e36aadc9, 0x00000000e33c7314,
+ 0x00000000e30e1554, 0x00000000e2df9490, 0x00000000e2b0f0d0,
+ 0x00000000e2822a1a, 0x00000000e2534077, 0x00000000e22433ec,
+ 0x00000000e1f50482,
+ 0x00000000e1c5b240, 0x00000000e1963d2d, 0x00000000e166a550,
+ 0x00000000e136eab0, 0x00000000e1070d56, 0x00000000e0d70d48,
+ 0x00000000e0a6ea8e, 0x00000000e076a52f, 0x00000000e0463d33,
+ 0x00000000e015b2a1,
+ 0x00000000dfe50580, 0x00000000dfb435d9, 0x00000000df8343b2,
+ 0x00000000df522f13, 0x00000000df20f804, 0x00000000deef9e8d,
+ 0x00000000debe22b5, 0x00000000de8c8483, 0x00000000de5ac3ff,
+ 0x00000000de28e131,
+ 0x00000000ddf6dc21, 0x00000000ddc4b4d6, 0x00000000dd926b59,
+ 0x00000000dd5fffb0, 0x00000000dd2d71e3, 0x00000000dcfac1fb,
+ 0x00000000dcc7f000, 0x00000000dc94fbf8, 0x00000000dc61e5ec,
+ 0x00000000dc2eade4,
+ 0x00000000dbfb53e8, 0x00000000dbc7d7ff, 0x00000000db943a31,
+ 0x00000000db607a88, 0x00000000db2c9909, 0x00000000daf895bf,
+ 0x00000000dac470af, 0x00000000da9029e3, 0x00000000da5bc163,
+ 0x00000000da273737,
+ 0x00000000d9f28b66, 0x00000000d9bdbdf9, 0x00000000d988cef8,
+ 0x00000000d953be6b, 0x00000000d91e8c5b, 0x00000000d8e938d0,
+ 0x00000000d8b3c3d1, 0x00000000d87e2d67, 0x00000000d848759b,
+ 0x00000000d8129c74,
+ 0x00000000d7dca1fb, 0x00000000d7a68638, 0x00000000d7704934,
+ 0x00000000d739eaf7, 0x00000000d7036b89, 0x00000000d6cccaf3,
+ 0x00000000d696093d, 0x00000000d65f266f, 0x00000000d6282293,
+ 0x00000000d5f0fdb0,
+ 0x00000000d5b9b7d0, 0x00000000d58250fa, 0x00000000d54ac937,
+ 0x00000000d513208f, 0x00000000d4db570c, 0x00000000d4a36cb6,
+ 0x00000000d46b6195, 0x00000000d43335b3, 0x00000000d3fae917,
+ 0x00000000d3c27bcb,
+ 0x00000000d389edd7, 0x00000000d3513f43, 0x00000000d318701a,
+ 0x00000000d2df8063, 0x00000000d2a67027, 0x00000000d26d3f6f,
+ 0x00000000d233ee43, 0x00000000d1fa7cae, 0x00000000d1c0eab7,
+ 0x00000000d1873867,
+ 0x00000000d14d65c8, 0x00000000d11372e1, 0x00000000d0d95fbd,
+ 0x00000000d09f2c64, 0x00000000d064d8df, 0x00000000d02a6537,
+ 0x00000000cfefd176, 0x00000000cfb51da3, 0x00000000cf7a49c8,
+ 0x00000000cf3f55ef,
+ 0x00000000cf044220, 0x00000000cec90e64, 0x00000000ce8dbac5,
+ 0x00000000ce52474c, 0x00000000ce16b401, 0x00000000cddb00ef,
+ 0x00000000cd9f2e1e, 0x00000000cd633b97, 0x00000000cd272964,
+ 0x00000000cceaf78e,
+ 0x00000000ccaea61e, 0x00000000cc72351e, 0x00000000cc35a497,
+ 0x00000000cbf8f492, 0x00000000cbbc2519, 0x00000000cb7f3634,
+ 0x00000000cb4227ee, 0x00000000cb04fa50, 0x00000000cac7ad63,
+ 0x00000000ca8a4131,
+ 0x00000000ca4cb5c3, 0x00000000ca0f0b22, 0x00000000c9d14159,
+ 0x00000000c9935870, 0x00000000c9555072, 0x00000000c9172967,
+ 0x00000000c8d8e35a, 0x00000000c89a7e53, 0x00000000c85bfa5e,
+ 0x00000000c81d5782,
+ 0x00000000c7de95cb, 0x00000000c79fb541, 0x00000000c760b5ee,
+ 0x00000000c72197dc, 0x00000000c6e25b15, 0x00000000c6a2ffa3,
+ 0x00000000c663858f, 0x00000000c623ece2, 0x00000000c5e435a8,
+ 0x00000000c5a45fe9,
+ 0x00000000c5646bb0, 0x00000000c5245906, 0x00000000c4e427f6,
+ 0x00000000c4a3d888, 0x00000000c4636ac8, 0x00000000c422debf,
+ 0x00000000c3e23476, 0x00000000c3a16bf9, 0x00000000c3608550,
+ 0x00000000c31f8087,
+ 0x00000000c2de5da6, 0x00000000c29d1cb8, 0x00000000c25bbdc8,
+ 0x00000000c21a40de, 0x00000000c1d8a606, 0x00000000c196ed49,
+ 0x00000000c15516b2, 0x00000000c113224a, 0x00000000c0d1101d,
+ 0x00000000c08ee033,
+ 0x00000000c04c9297, 0x00000000c00a2754, 0x00000000bfc79e73,
+ 0x00000000bf84f800, 0x00000000bf423404, 0x00000000beff5289,
+ 0x00000000bebc539a, 0x00000000be793741, 0x00000000be35fd89,
+ 0x00000000bdf2a67b,
+ 0x00000000bdaf3223, 0x00000000bd6ba08b, 0x00000000bd27f1bc,
+ 0x00000000bce425c2, 0x00000000bca03ca7, 0x00000000bc5c3676,
+ 0x00000000bc181338, 0x00000000bbd3d2f9, 0x00000000bb8f75c3,
+ 0x00000000bb4afba1,
+ 0x00000000bb06649c, 0x00000000bac1b0c0, 0x00000000ba7ce018,
+ 0x00000000ba37f2ad, 0x00000000b9f2e88b, 0x00000000b9adc1bc,
+ 0x00000000b9687e4a, 0x00000000b9231e41, 0x00000000b8dda1ac,
+ 0x00000000b8980894,
+ 0x00000000b8525305, 0x00000000b80c8109, 0x00000000b7c692ac,
+ 0x00000000b78087f7, 0x00000000b73a60f6, 0x00000000b6f41db4,
+ 0x00000000b6adbe3a, 0x00000000b6674296, 0x00000000b620aad0,
+ 0x00000000b5d9f6f4,
+ 0x00000000b593270e, 0x00000000b54c3b27, 0x00000000b505334a,
+ 0x00000000b4be0f84, 0x00000000b476cfde, 0x00000000b42f7464,
+ 0x00000000b3e7fd20, 0x00000000b3a06a1e, 0x00000000b358bb69,
+ 0x00000000b310f10c,
+ 0x00000000b2c90b11, 0x00000000b2810985, 0x00000000b238ec71,
+ 0x00000000b1f0b3e2, 0x00000000b1a85fe2, 0x00000000b15ff07c,
+ 0x00000000b11765bc, 0x00000000b0cebfad, 0x00000000b085fe5a,
+ 0x00000000b03d21ce,
+ 0x00000000aff42a15, 0x00000000afab1739, 0x00000000af61e946,
+ 0x00000000af18a048, 0x00000000aecf3c49, 0x00000000ae85bd55,
+ 0x00000000ae3c2377, 0x00000000adf26ebb, 0x00000000ada89f2c,
+ 0x00000000ad5eb4d5,
+ 0x00000000ad14afc2, 0x00000000acca8ffd, 0x00000000ac805594,
+ 0x00000000ac360090, 0x00000000abeb90fe, 0x00000000aba106e9,
+ 0x00000000ab56625d, 0x00000000ab0ba364, 0x00000000aac0ca0b,
+ 0x00000000aa75d65d,
+ 0x00000000aa2ac865, 0x00000000a9dfa030, 0x00000000a9945dc9,
+ 0x00000000a949013a, 0x00000000a8fd8a91, 0x00000000a8b1f9d8,
+ 0x00000000a8664f1c, 0x00000000a81a8a68, 0x00000000a7ceabc7,
+ 0x00000000a782b345,
+ 0x00000000a736a0ef, 0x00000000a6ea74cf, 0x00000000a69e2ef2,
+ 0x00000000a651cf63, 0x00000000a605562f, 0x00000000a5b8c360,
+ 0x00000000a56c1702, 0x00000000a51f5123, 0x00000000a4d271cc,
+ 0x00000000a485790b,
+ 0x00000000a43866eb, 0x00000000a3eb3b77, 0x00000000a39df6bd,
+ 0x00000000a35098c7, 0x00000000a30321a2, 0x00000000a2b5915a,
+ 0x00000000a267e7fa, 0x00000000a21a258e, 0x00000000a1cc4a24,
+ 0x00000000a17e55c5,
+ 0x00000000a1304880, 0x00000000a0e2225f, 0x00000000a093e36f,
+ 0x00000000a0458bbb, 0x000000009ff71b50, 0x000000009fa8923a,
+ 0x000000009f59f086, 0x000000009f0b363e, 0x000000009ebc6370,
+ 0x000000009e6d7827,
+ 0x000000009e1e746f, 0x000000009dcf5856, 0x000000009d8023e6,
+ 0x000000009d30d72d, 0x000000009ce17236, 0x000000009c91f50e,
+ 0x000000009c425fc1, 0x000000009bf2b25b, 0x000000009ba2ece8,
+ 0x000000009b530f76,
+ 0x000000009b031a0f, 0x000000009ab30cc1, 0x000000009a62e797,
+ 0x000000009a12aa9f, 0x0000000099c255e5, 0x000000009971e974,
+ 0x000000009921655a, 0x0000000098d0c9a2, 0x0000000098801659,
+ 0x00000000982f4b8d,
+ 0x0000000097de6948, 0x00000000978d6f97, 0x00000000973c5e88,
+ 0x0000000096eb3626, 0x000000009699f67f, 0x0000000096489f9e,
+ 0x0000000095f73190, 0x0000000095a5ac61, 0x000000009554101f,
+ 0x0000000095025cd6,
+ 0x0000000094b09292, 0x00000000945eb161, 0x00000000940cb94e,
+ 0x0000000093baaa66, 0x00000000936884b6, 0x000000009316484b,
+ 0x0000000092c3f531, 0x0000000092718b75, 0x00000000921f0b24,
+ 0x0000000091cc744b,
+ 0x000000009179c6f5, 0x0000000091270331, 0x0000000090d4290a,
+ 0x000000009081388e, 0x00000000902e31c8, 0x000000008fdb14c7,
+ 0x000000008f87e197, 0x000000008f349845, 0x000000008ee138dd,
+ 0x000000008e8dc36c,
+ 0x000000008e3a3800, 0x000000008de696a5, 0x000000008d92df68,
+ 0x000000008d3f1256, 0x000000008ceb2f7c, 0x000000008c9736e7,
+ 0x000000008c4328a3, 0x000000008bef04bf, 0x000000008b9acb46,
+ 0x000000008b467c45,
+ 0x000000008af217cb, 0x000000008a9d9de3, 0x000000008a490e9b,
+ 0x0000000089f469ff, 0x00000000899fb01e, 0x00000000894ae103,
+ 0x0000000088f5fcbc, 0x0000000088a10357, 0x00000000884bf4df,
+ 0x0000000087f6d163,
+ 0x0000000087a198f0, 0x00000000874c4b92, 0x0000000086f6e956,
+ 0x0000000086a1724b, 0x00000000864be67c, 0x0000000085f645f8,
+ 0x0000000085a090cc, 0x00000000854ac704, 0x0000000084f4e8ad,
+ 0x00000000849ef5d7,
+ 0x000000008448ee8c, 0x0000000083f2d2db, 0x00000000839ca2d1,
+ 0x0000000083465e7c, 0x0000000082f005e8, 0x0000000082999922,
+ 0x0000000082431839, 0x0000000081ec833a, 0x000000008195da31,
+ 0x00000000813f1d2d,
+ 0x0000000080e84c3a, 0x0000000080916766, 0x00000000803a6ebf,
+ 0x000000007fe36251, 0x000000007f8c422b, 0x000000007f350e59,
+ 0x000000007eddc6ea, 0x000000007e866bea, 0x000000007e2efd67,
+ 0x000000007dd77b6f,
+ 0x000000007d7fe60f, 0x000000007d283d54, 0x000000007cd0814c,
+ 0x000000007c78b205, 0x000000007c20cf8c, 0x000000007bc8d9ef,
+ 0x000000007b70d13b, 0x000000007b18b57e, 0x000000007ac086c5,
+ 0x000000007a68451f,
+ 0x000000007a0ff098, 0x0000000079b7893e, 0x00000000795f0f1f,
+ 0x0000000079068248, 0x0000000078ade2c8, 0x00000000785530ab,
+ 0x0000000077fc6c01, 0x0000000077a394d5, 0x00000000774aab36,
+ 0x0000000076f1af32,
+ 0x000000007698a0d6, 0x00000000763f8030, 0x0000000075e64d4e,
+ 0x00000000758d083e, 0x000000007533b10d, 0x0000000074da47c9,
+ 0x000000007480cc80, 0x0000000074273f3f, 0x0000000073cda016,
+ 0x000000007373ef10,
+ 0x00000000731a2c3d, 0x0000000072c057aa, 0x0000000072667164,
+ 0x00000000720c797a, 0x0000000071b26ffa, 0x00000000715854f2,
+ 0x0000000070fe286e, 0x0000000070a3ea7e, 0x0000000070499b30,
+ 0x000000006fef3a90,
+ 0x000000006f94c8ae, 0x000000006f3a4596, 0x000000006edfb157,
+ 0x000000006e850c00, 0x000000006e2a559d, 0x000000006dcf8e3d,
+ 0x000000006d74b5ee, 0x000000006d19ccbe, 0x000000006cbed2bb,
+ 0x000000006c63c7f3,
+ 0x000000006c08ac74, 0x000000006bad804c, 0x000000006b524389,
+ 0x000000006af6f639, 0x000000006a9b986b, 0x000000006a402a2c,
+ 0x0000000069e4ab8a, 0x0000000069891c94, 0x00000000692d7d57,
+ 0x0000000068d1cde3,
+ 0x0000000068760e44, 0x00000000681a3e89, 0x0000000067be5ec1,
+ 0x0000000067626ef9, 0x0000000067066f40, 0x0000000066aa5fa3,
+ 0x00000000664e4032, 0x0000000065f210f9, 0x000000006595d209,
+ 0x000000006539836d,
+ 0x0000000064dd2536, 0x000000006480b770, 0x0000000064243a2b,
+ 0x0000000063c7ad75, 0x00000000636b115c, 0x00000000630e65ed,
+ 0x0000000062b1ab39, 0x000000006254e14c, 0x0000000061f80835,
+ 0x00000000619b2002,
+ 0x00000000613e28c2, 0x0000000060e12283, 0x0000000060840d54,
+ 0x000000006026e943, 0x000000005fc9b65d, 0x000000005f6c74b2,
+ 0x000000005f0f2450, 0x000000005eb1c545, 0x000000005e5457a0,
+ 0x000000005df6db6f,
+ 0x000000005d9950c0, 0x000000005d3bb7a3, 0x000000005cde1024,
+ 0x000000005c805a54, 0x000000005c22963f, 0x000000005bc4c3f6,
+ 0x000000005b66e385, 0x000000005b08f4fd, 0x000000005aaaf86a,
+ 0x000000005a4ceddc,
+ 0x0000000059eed561, 0x000000005990af08, 0x0000000059327adf,
+ 0x0000000058d438f4, 0x000000005875e957, 0x0000000058178c16,
+ 0x0000000057b9213f, 0x00000000575aa8e0, 0x0000000056fc230a,
+ 0x00000000569d8fc9,
+ 0x00000000563eef2d, 0x0000000055e04144, 0x000000005581861d,
+ 0x000000005522bdc6, 0x0000000054c3e84e, 0x00000000546505c4,
+ 0x0000000054061636, 0x0000000053a719b3, 0x000000005348104a,
+ 0x0000000052e8fa09,
+ 0x000000005289d6ff, 0x00000000522aa73a, 0x0000000051cb6aca,
+ 0x00000000516c21bc, 0x00000000510ccc20, 0x0000000050ad6a05,
+ 0x00000000504dfb78, 0x000000004fee808a, 0x000000004f8ef947,
+ 0x000000004f2f65c0,
+ 0x000000004ecfc603, 0x000000004e701a1f, 0x000000004e106222,
+ 0x000000004db09e1b, 0x000000004d50ce19, 0x000000004cf0f22b,
+ 0x000000004c910a5f, 0x000000004c3116c5, 0x000000004bd1176b,
+ 0x000000004b710c5f,
+ 0x000000004b10f5b2, 0x000000004ab0d371, 0x000000004a50a5ab,
+ 0x0000000049f06c70, 0x00000000499027cd, 0x00000000492fd7d3,
+ 0x0000000048cf7c8f, 0x00000000486f1611, 0x00000000480ea467,
+ 0x0000000047ae27a1,
+ 0x00000000474d9fcd, 0x0000000046ed0cfa, 0x00000000468c6f37,
+ 0x00000000462bc693, 0x0000000045cb131c, 0x00000000456a54e3,
+ 0x0000000045098bf5, 0x0000000044a8b861, 0x000000004447da37,
+ 0x0000000043e6f186,
+ 0x000000004385fe5c, 0x00000000432500c8, 0x0000000042c3f8d9,
+ 0x000000004262e69f, 0x000000004201ca28, 0x0000000041a0a383,
+ 0x00000000413f72bf, 0x0000000040de37eb, 0x00000000407cf317,
+ 0x00000000401ba450,
+ 0x000000003fba4ba7, 0x000000003f58e92a, 0x000000003ef77ce8,
+ 0x000000003e9606f1, 0x000000003e348752, 0x000000003dd2fe1c,
+ 0x000000003d716b5e, 0x000000003d0fcf25, 0x000000003cae2982,
+ 0x000000003c4c7a83,
+ 0x000000003beac238, 0x000000003b8900b0, 0x000000003b2735f9,
+ 0x000000003ac56223, 0x000000003a63853d, 0x000000003a019f56,
+ 0x00000000399fb07d, 0x00000000393db8c1, 0x0000000038dbb831,
+ 0x000000003879aedd,
+ 0x0000000038179cd3, 0x0000000037b58222, 0x0000000037535edb,
+ 0x0000000036f1330b, 0x00000000368efec2, 0x00000000362cc20f,
+ 0x0000000035ca7d02, 0x0000000035682fa9, 0x000000003505da14,
+ 0x0000000034a37c51,
+ 0x0000000034411671, 0x0000000033dea881, 0x00000000337c3292,
+ 0x000000003319b4b3, 0x0000000032b72ef2, 0x000000003254a15e,
+ 0x0000000031f20c08, 0x00000000318f6efe, 0x00000000312cca50,
+ 0x0000000030ca1e0c,
+ 0x0000000030676a43, 0x000000003004af02, 0x000000002fa1ec5a,
+ 0x000000002f3f2259, 0x000000002edc510f, 0x000000002e79788b,
+ 0x000000002e1698dc, 0x000000002db3b212, 0x000000002d50c43c,
+ 0x000000002cedcf68,
+ 0x000000002c8ad3a7, 0x000000002c27d108, 0x000000002bc4c799,
+ 0x000000002b61b76b, 0x000000002afea08c, 0x000000002a9b830b,
+ 0x000000002a385ef9, 0x0000000029d53464, 0x000000002972035b,
+ 0x00000000290ecbee,
+ 0x0000000028ab8e2c, 0x0000000028484a25, 0x0000000027e4ffe7,
+ 0x000000002781af83, 0x00000000271e5906, 0x0000000026bafc82,
+ 0x0000000026579a04, 0x0000000025f4319d, 0x000000002590c35c,
+ 0x00000000252d4f4f,
+ 0x0000000024c9d587, 0x0000000024665613, 0x000000002402d101,
+ 0x00000000239f4662, 0x00000000233bb644, 0x0000000022d820b8,
+ 0x00000000227485cc, 0x000000002210e590, 0x0000000021ad4013,
+ 0x0000000021499565,
+ 0x0000000020e5e594, 0x00000000208230b1, 0x00000000201e76ca,
+ 0x000000001fbab7ef, 0x000000001f56f430, 0x000000001ef32b9b,
+ 0x000000001e8f5e41, 0x000000001e2b8c30, 0x000000001dc7b578,
+ 0x000000001d63da29,
+ 0x000000001cfffa51, 0x000000001c9c1600, 0x000000001c382d46,
+ 0x000000001bd44032, 0x000000001b704ed3, 0x000000001b0c5939,
+ 0x000000001aa85f74, 0x000000001a446191, 0x0000000019e05fa2,
+ 0x00000000197c59b5,
+ 0x0000000019184fdb, 0x0000000018b44221, 0x0000000018503098,
+ 0x0000000017ec1b50, 0x0000000017880257, 0x000000001723e5bd,
+ 0x0000000016bfc591, 0x00000000165ba1e4, 0x0000000015f77ac3,
+ 0x0000000015935040,
+ 0x00000000152f2269, 0x0000000014caf14d, 0x000000001466bcfd,
+ 0x0000000014028587, 0x00000000139e4afb, 0x00000000133a0d69,
+ 0x0000000012d5cce0, 0x000000001271896f, 0x00000000120d4326,
+ 0x0000000011a8fa15,
+ 0x000000001144ae4a, 0x0000000010e05fd6, 0x00000000107c0ec7,
+ 0x000000001017bb2d, 0x000000000fb36519, 0x000000000f4f0c98,
+ 0x000000000eeab1bb, 0x000000000e865491, 0x000000000e21f52a,
+ 0x000000000dbd9395,
+ 0x000000000d592fe1, 0x000000000cf4ca1f, 0x000000000c90625c,
+ 0x000000000c2bf8aa, 0x000000000bc78d18, 0x000000000b631fb4,
+ 0x000000000afeb08f, 0x000000000a9a3fb8, 0x000000000a35cd3e,
+ 0x0000000009d15931,
+ 0x00000000096ce3a1, 0x0000000009086c9c, 0x0000000008a3f433,
+ 0x00000000083f7a75, 0x0000000007daff71, 0x0000000007768337,
+ 0x00000000071205d6, 0x0000000006ad875f, 0x00000000064907df,
+ 0x0000000005e48768,
+ 0x0000000005800608, 0x00000000051b83cf, 0x0000000004b700cc,
+ 0x0000000004527d0f, 0x0000000003edf8a7, 0x00000000038973a4,
+ 0x000000000324ee16, 0x0000000002c0680b, 0x00000000025be194,
+ 0x0000000001f75ac0,
+ 0x000000000192d39e, 0x00000000012e4c3e, 0x0000000000c9c4af,
+ 0x0000000000653d02, 0x0000000000000000
};
-EAPI Eina_F32p32
-eina_f32p32_cos(Eina_F32p32 a)
+EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a)
{
- Eina_F32p32 F32P32_2PI;
- Eina_F32p32 F32P32_PI2;
- Eina_F32p32 F32P32_3PI2;
- Eina_F32p32 remainder_2PI;
- Eina_F32p32 remainder_PI;
- Eina_F32p32 interpol;
- Eina_F32p32 result;
- int idx;
- int index2;
+ Eina_F32p32 F32P32_2PI;
+ Eina_F32p32 F32P32_PI2;
+ Eina_F32p32 F32P32_3PI2;
+ Eina_F32p32 remainder_2PI;
+ Eina_F32p32 remainder_PI;
+ Eina_F32p32 interpol;
+ Eina_F32p32 result;
+ int idx;
+ int index2;
- F32P32_2PI = EINA_F32P32_PI << 1;
- F32P32_PI2 = EINA_F32P32_PI >> 1;
- F32P32_3PI2 = EINA_F32P32_PI + F32P32_PI2;
+ F32P32_2PI = EINA_F32P32_PI << 1;
+ F32P32_PI2 = EINA_F32P32_PI >> 1;
+ F32P32_3PI2 = EINA_F32P32_PI + F32P32_PI2;
- /* Take advantage of cosinus symetrie. */
- a = eina_fp32p32_llabs(a);
+ /* Take advantage of cosinus symetrie. */
+ a = eina_fp32p32_llabs(a);
- /* Find table entry in 0 to PI / 2 */
- remainder_PI = a - (a / EINA_F32P32_PI) * EINA_F32P32_PI;
+ /* Find table entry in 0 to PI / 2 */
+ remainder_PI = a - (a / EINA_F32P32_PI) * EINA_F32P32_PI;
- /* Find which case from 0 to 2 * PI */
- remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
+ /* Find which case from 0 to 2 * PI */
+ remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
- interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
- EINA_F32P32_PI);
- idx = eina_f32p32_int_to(interpol);
- if (idx >= MAX_PREC)
- idx = 2 * MAX_PREC - (idx - 1);
+ interpol =
+ eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
+ EINA_F32P32_PI);
+ idx = eina_f32p32_int_to(interpol);
+ if (idx >= MAX_PREC)
+ idx = 2 * MAX_PREC - (idx - 1);
- index2 = idx + 1;
- if (index2 == MAX_PREC)
- index2 = idx - 1;
+ index2 = idx + 1;
+ if (index2 == MAX_PREC)
+ index2 = idx - 1;
- result = eina_f32p32_add(eina_trigo[idx],
- eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
- eina_trigo[index2]),
- (Eina_F32p32)eina_f32p32_fracc_get(
- interpol)));
+ result = eina_f32p32_add(eina_trigo[idx],
+ eina_f32p32_mul(eina_f32p32_sub
+ (eina_trigo[idx],
+ eina_trigo[index2]),
+ (Eina_F32p32)
+ eina_f32p32_fracc_get
+ (interpol)));
- if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
- return result;
- else if (F32P32_PI2 <= remainder_2PI && remainder_2PI < EINA_F32P32_PI)
- return -result;
- else if (EINA_F32P32_PI <= remainder_2PI && remainder_2PI < F32P32_3PI2)
- return -result;
- else /* if (F32P32_3PI2 <= remainder_2PI) */
- return result;
+ if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
+ return result;
+ else if (F32P32_PI2 <= remainder_2PI
+ && remainder_2PI < EINA_F32P32_PI)
+ return -result;
+ else if (EINA_F32P32_PI <= remainder_2PI
+ && remainder_2PI < F32P32_3PI2)
+ return -result;
+ else /* if (F32P32_3PI2 <= remainder_2PI) */
+ return result;
}
-EAPI Eina_F32p32
-eina_f32p32_sin(Eina_F32p32 a)
+EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a)
{
- Eina_F32p32 F32P32_2PI;
- Eina_F32p32 F32P32_PI2;
- Eina_F32p32 F32P32_3PI2;
- Eina_F32p32 remainder_2PI;
- Eina_F32p32 remainder_PI;
- Eina_F32p32 interpol;
- Eina_F32p32 result;
- int idx;
- int index2;
+ Eina_F32p32 F32P32_2PI;
+ Eina_F32p32 F32P32_PI2;
+ Eina_F32p32 F32P32_3PI2;
+ Eina_F32p32 remainder_2PI;
+ Eina_F32p32 remainder_PI;
+ Eina_F32p32 interpol;
+ Eina_F32p32 result;
+ int idx;
+ int index2;
- F32P32_2PI = EINA_F32P32_PI << 1;
- F32P32_PI2 = EINA_F32P32_PI >> 1;
- F32P32_3PI2 = EINA_F32P32_PI + F32P32_PI2;
+ F32P32_2PI = EINA_F32P32_PI << 1;
+ F32P32_PI2 = EINA_F32P32_PI >> 1;
+ F32P32_3PI2 = EINA_F32P32_PI + F32P32_PI2;
- /* We only have a table for cosinus, but sin(a) = cos(pi / 2 - a) */
- a = eina_f32p32_sub(F32P32_PI2, a);
+ /* We only have a table for cosinus, but sin(a) = cos(pi / 2 - a) */
+ a = eina_f32p32_sub(F32P32_PI2, a);
- /* Take advantage of cosinus symetrie. */
- a = eina_fp32p32_llabs(a);
+ /* Take advantage of cosinus symetrie. */
+ a = eina_fp32p32_llabs(a);
- /* Find table entry in 0 to PI / 2 */
- remainder_PI = a - (a / EINA_F32P32_PI) * EINA_F32P32_PI;
+ /* Find table entry in 0 to PI / 2 */
+ remainder_PI = a - (a / EINA_F32P32_PI) * EINA_F32P32_PI;
- /* Find which case from 0 to 2 * PI */
- remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
+ /* Find which case from 0 to 2 * PI */
+ remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
- interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
- EINA_F32P32_PI);
- idx = eina_f32p32_int_to(interpol);
- if (idx >= MAX_PREC)
- idx = 2 * MAX_PREC - (idx + 1);
+ interpol =
+ eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
+ EINA_F32P32_PI);
+ idx = eina_f32p32_int_to(interpol);
+ if (idx >= MAX_PREC)
+ idx = 2 * MAX_PREC - (idx + 1);
- index2 = idx + 1;
- if (index2 == MAX_PREC)
- index2 = idx - 1;
+ index2 = idx + 1;
+ if (index2 == MAX_PREC)
+ index2 = idx - 1;
- result = eina_f32p32_add(eina_trigo[idx],
- eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
- eina_trigo[index2]),
- (Eina_F32p32)eina_f32p32_fracc_get(
- interpol)));
+ result = eina_f32p32_add(eina_trigo[idx],
+ eina_f32p32_mul(eina_f32p32_sub
+ (eina_trigo[idx],
+ eina_trigo[index2]),
+ (Eina_F32p32)
+ eina_f32p32_fracc_get
+ (interpol)));
- if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
- return result;
- else if (F32P32_PI2 <= remainder_2PI && remainder_2PI < EINA_F32P32_PI)
- return -result;
- else if (EINA_F32P32_PI <= remainder_2PI && remainder_2PI < F32P32_3PI2)
- return -result;
- else /* if (F32P32_3PI2 <= remainder_2PI) */
- return result;
+ if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
+ return result;
+ else if (F32P32_PI2 <= remainder_2PI
+ && remainder_2PI < EINA_F32P32_PI)
+ return -result;
+ else if (EINA_F32P32_PI <= remainder_2PI
+ && remainder_2PI < F32P32_3PI2)
+ return -result;
+ else /* if (F32P32_3PI2 <= remainder_2PI) */
+ return result;
}
-
diff --git a/tests/suite/ecore/src/lib/eina_hamster.c b/tests/suite/ecore/src/lib/eina_hamster.c
index 2f68777cc6..4390430e8e 100644
--- a/tests/suite/ecore/src/lib/eina_hamster.c
+++ b/tests/suite/ecore/src/lib/eina_hamster.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -66,61 +66,58 @@ static int _eina_hamsters = -1;
*
* This function returns how many hamsters you have.
*/
-EAPI int
-eina_hamster_count(void)
+EAPI int eina_hamster_count(void)
{
- if (_eina_hamsters < 0)
- {
- int hrs = 0, min = 0, sec = 0;
- char mon[8] = "";
- int monnum = 0, day = 0, year = 0;
- int fields;
+ if (_eina_hamsters < 0) {
+ int hrs = 0, min = 0, sec = 0;
+ char mon[8] = "";
+ int monnum = 0, day = 0, year = 0;
+ int fields;
- fields = sscanf(_eina_hamster_time, "%02i:%02i:%02i", &hrs, &min, &sec);
- if (fields == 3)
- {
- _eina_hamsters = (hrs * 60) + min;
- fields = sscanf(_eina_hamster_date, "%s %i %i", mon, &day, &year);
- if (fields == 3)
- {
- int i;
- const char *mons[] =
- {
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
- };
+ fields =
+ sscanf(_eina_hamster_time, "%02i:%02i:%02i", &hrs,
+ &min, &sec);
+ if (fields == 3) {
+ _eina_hamsters = (hrs * 60) + min;
+ fields =
+ sscanf(_eina_hamster_date, "%s %i %i", mon,
+ &day, &year);
+ if (fields == 3) {
+ int i;
+ const char *mons[] = {
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec"
+ };
- for (i = 0; i < 12; i++)
- {
- if (!strcmp(mon, mons[i]))
- {
- monnum = i + 1;
- break;
- }
- }
- // alloc 60 for mins, 24 for hrs
- // alloc 1-31 (32) for days, 1-12 (13) for months
- // use year as-is, for 31 bits (signed) this gives us up to
- // 3584 years, which is good enough imho. - 1500 years from
- // now or so. :)
- _eina_hamsters +=
- (day + (monnum * 32) + (13 * 32 * year)) * (24 * 60);
- }
- }
- }
-
- // format: [rest - year][0-12 - month][0-31 - day][0-23 - hrs][0-59 - sec]
- return _eina_hamsters;
+ for (i = 0; i < 12; i++) {
+ if (!strcmp(mon, mons[i])) {
+ monnum = i + 1;
+ break;
+ }
+ }
+ // alloc 60 for mins, 24 for hrs
+ // alloc 1-31 (32) for days, 1-12 (13) for months
+ // use year as-is, for 31 bits (signed) this gives us up to
+ // 3584 years, which is good enough imho. - 1500 years from
+ // now or so. :)
+ _eina_hamsters +=
+ (day + (monnum * 32) +
+ (13 * 32 * year)) * (24 * 60);
+ }
+ }
+ }
+ // format: [rest - year][0-12 - month][0-31 - day][0-23 - hrs][0-59 - sec]
+ return _eina_hamsters;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_hash.c b/tests/suite/ecore/src/lib/eina_hash.c
index 4c5f533b55..e6a440baa6 100644
--- a/tests/suite/ecore/src/lib/eina_hash.c
+++ b/tests/suite/ecore/src/lib/eina_hash.c
@@ -18,16 +18,16 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
-# include <Evil.h>
+#include <Evil.h>
#else
-# include <stdint.h>
+#include <stdint.h>
#endif
#include "eina_config.h"
@@ -73,621 +73,622 @@ typedef struct _Eina_Hash_Foreach_Data Eina_Hash_Foreach_Data;
typedef struct _Eina_Iterator_Hash Eina_Iterator_Hash;
typedef struct _Eina_Hash_Each Eina_Hash_Each;
-struct _Eina_Hash
-{
- Eina_Key_Length key_length_cb;
- Eina_Key_Cmp key_cmp_cb;
- Eina_Key_Hash key_hash_cb;
- Eina_Free_Cb data_free_cb;
+struct _Eina_Hash {
+ Eina_Key_Length key_length_cb;
+ Eina_Key_Cmp key_cmp_cb;
+ Eina_Key_Hash key_hash_cb;
+ Eina_Free_Cb data_free_cb;
- Eina_Rbtree **buckets;
- int size;
- int mask;
+ Eina_Rbtree **buckets;
+ int size;
+ int mask;
- int population;
+ int population;
- EINA_MAGIC
-};
+ EINA_MAGIC};
-struct _Eina_Hash_Head
-{
- EINA_RBTREE;
- int hash;
+struct _Eina_Hash_Head {
+ EINA_RBTREE;
+ int hash;
- Eina_Rbtree *head;
+ Eina_Rbtree *head;
};
-struct _Eina_Hash_Element
-{
- EINA_RBTREE;
- Eina_Hash_Tuple tuple;
- Eina_Bool begin : 1;
+struct _Eina_Hash_Element {
+ EINA_RBTREE;
+ Eina_Hash_Tuple tuple;
+ Eina_Bool begin:1;
};
-struct _Eina_Hash_Foreach_Data
-{
- Eina_Hash_Foreach cb;
- const void *fdata;
+struct _Eina_Hash_Foreach_Data {
+ Eina_Hash_Foreach cb;
+ const void *fdata;
};
-typedef void *(*Eina_Iterator_Get_Content_Callback)(Eina_Iterator_Hash *it);
+typedef void *(*Eina_Iterator_Get_Content_Callback) (Eina_Iterator_Hash *
+ it);
#define FUNC_ITERATOR_GET_CONTENT(Function) ((Eina_Iterator_Get_Content_Callback)Function)
-struct _Eina_Iterator_Hash
-{
- Eina_Iterator iterator;
+struct _Eina_Iterator_Hash {
+ Eina_Iterator iterator;
- Eina_Iterator_Get_Content_Callback get_content;
- const Eina_Hash *hash;
+ Eina_Iterator_Get_Content_Callback get_content;
+ const Eina_Hash *hash;
- Eina_Iterator *current;
- Eina_Iterator *list;
- Eina_Hash_Head *hash_head;
- Eina_Hash_Element *hash_element;
- int bucket;
+ Eina_Iterator *current;
+ Eina_Iterator *list;
+ Eina_Hash_Head *hash_head;
+ Eina_Hash_Element *hash_element;
+ int bucket;
- int index;
+ int index;
- EINA_MAGIC
-};
+ EINA_MAGIC};
-struct _Eina_Hash_Each
-{
- Eina_Hash_Head *hash_head;
- const Eina_Hash_Element *hash_element;
- const void *data;
+struct _Eina_Hash_Each {
+ Eina_Hash_Head *hash_head;
+ const Eina_Hash_Element *hash_element;
+ const void *data;
};
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
-# define get16bits(d) (*((const uint16_t *)(d)))
+#define get16bits(d) (*((const uint16_t *)(d)))
#endif
#if !defined (get16bits)
-# define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+ (uint32_t)(((const uint8_t *)(d))[0]))
#endif
static inline int
-_eina_hash_hash_rbtree_cmp_hash(const Eina_Hash_Head *hash_head,
- const int *hash,
- __UNUSED__ int key_length,
- __UNUSED__ void *data)
+_eina_hash_hash_rbtree_cmp_hash(const Eina_Hash_Head * hash_head,
+ const int *hash,
+ __UNUSED__ int key_length,
+ __UNUSED__ void *data)
{
- return hash_head->hash - *hash;
+ return hash_head->hash - *hash;
}
static Eina_Rbtree_Direction
-_eina_hash_hash_rbtree_cmp_node(const Eina_Hash_Head *left,
- const Eina_Hash_Head *right,
- __UNUSED__ void *data)
+_eina_hash_hash_rbtree_cmp_node(const Eina_Hash_Head * left,
+ const Eina_Hash_Head * right,
+ __UNUSED__ void *data)
{
- if (left->hash - right->hash < 0)
- return EINA_RBTREE_LEFT;
+ if (left->hash - right->hash < 0)
+ return EINA_RBTREE_LEFT;
- return EINA_RBTREE_RIGHT;
+ return EINA_RBTREE_RIGHT;
}
static inline int
-_eina_hash_key_rbtree_cmp_key_data(const Eina_Hash_Element *hash_element,
- const Eina_Hash_Tuple *tuple,
- __UNUSED__ unsigned int key_length,
- Eina_Key_Cmp cmp)
+_eina_hash_key_rbtree_cmp_key_data(const Eina_Hash_Element * hash_element,
+ const Eina_Hash_Tuple * tuple,
+ __UNUSED__ unsigned int key_length,
+ Eina_Key_Cmp cmp)
{
- int result;
+ int result;
- result = cmp(hash_element->tuple.key,
- hash_element->tuple.key_length,
- tuple->key,
- tuple->key_length);
+ result = cmp(hash_element->tuple.key,
+ hash_element->tuple.key_length,
+ tuple->key, tuple->key_length);
- if (result == 0 && tuple->data && tuple->data != hash_element->tuple.data)
- return 1;
+ if (result == 0 && tuple->data
+ && tuple->data != hash_element->tuple.data)
+ return 1;
- return result;
+ return result;
}
static Eina_Rbtree_Direction
-_eina_hash_key_rbtree_cmp_node(const Eina_Hash_Element *left,
- const Eina_Hash_Element *right,
- Eina_Key_Cmp cmp)
+_eina_hash_key_rbtree_cmp_node(const Eina_Hash_Element * left,
+ const Eina_Hash_Element * right,
+ Eina_Key_Cmp cmp)
{
- int result;
+ int result;
- result = cmp(left->tuple.key, left->tuple.key_length,
- right->tuple.key, right->tuple.key_length);
+ result = cmp(left->tuple.key, left->tuple.key_length,
+ right->tuple.key, right->tuple.key_length);
- if (result < 0)
- return EINA_RBTREE_LEFT;
+ if (result < 0)
+ return EINA_RBTREE_LEFT;
- return EINA_RBTREE_RIGHT;
+ return EINA_RBTREE_RIGHT;
}
static inline Eina_Bool
-eina_hash_add_alloc_by_hash(Eina_Hash *hash,
- const void *key, int key_length, int alloc_length,
- int key_hash,
- const void *data)
-{
- Eina_Hash_Element *new_hash_element = NULL;
- Eina_Hash_Head *hash_head;
- Eina_Error error = 0;
- int hash_num;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
- EINA_MAGIC_CHECK_HASH(hash);
-
- error = EINA_ERROR_OUT_OF_MEMORY;
-
- /* Apply eina mask to hash. */
- hash_num = key_hash & hash->mask;
- key_hash &= EINA_HASH_RBTREE_MASK;
-
- if (!hash->buckets)
- {
- hash->buckets = calloc(sizeof (Eina_Rbtree *), hash->size);
- if (!hash->buckets) goto on_error;
-
- hash_head = NULL;
- }
- else
- /* Look up for head node. */
- hash_head = (Eina_Hash_Head *)eina_rbtree_inline_lookup(hash->buckets[hash_num],
- &key_hash, 0,
- EINA_RBTREE_CMP_KEY_CB(_eina_hash_hash_rbtree_cmp_hash),
- NULL);
-
- if (!hash_head)
- {
- /* If not found allocate it and an element. */
- hash_head = malloc(sizeof(Eina_Hash_Head) + sizeof(Eina_Hash_Element) + alloc_length);
- if (!hash_head)
- goto on_error;
-
- hash_head->hash = key_hash;
- hash_head->head = NULL;
-
- hash->buckets[hash_num] =
- eina_rbtree_inline_insert(hash->buckets[hash_num], EINA_RBTREE_GET(hash_head),
- EINA_RBTREE_CMP_NODE_CB(
- _eina_hash_hash_rbtree_cmp_node), NULL);
-
- new_hash_element = (Eina_Hash_Element *)(hash_head + 1);
- new_hash_element->begin = EINA_TRUE;
- }
-
- if (!new_hash_element)
- {
- /*
- Alloc a new element
- (No more lookup as we expect to support more than one item for one key).
- */
- new_hash_element = malloc(sizeof (Eina_Hash_Element) + alloc_length);
- if (!new_hash_element)
- goto on_error;
-
- new_hash_element->begin = EINA_FALSE;
- }
-
- /* Setup the element */
- new_hash_element->tuple.key_length = key_length;
- new_hash_element->tuple.data = (void *)data;
- if (alloc_length > 0)
- {
- new_hash_element->tuple.key = (char *)(new_hash_element + 1);
- memcpy((char *)new_hash_element->tuple.key, key, alloc_length);
- }
- else
- new_hash_element->tuple.key = key;
-
- /* add the new element to the hash. */
- hash_head->head = eina_rbtree_inline_insert(hash_head->head, EINA_RBTREE_GET(new_hash_element),
- EINA_RBTREE_CMP_NODE_CB(
- _eina_hash_key_rbtree_cmp_node),
- (const void *)hash->key_cmp_cb);
- hash->population++;
- return EINA_TRUE;
-
-on_error:
- eina_error_set(error);
- return EINA_FALSE;
+eina_hash_add_alloc_by_hash(Eina_Hash * hash,
+ const void *key, int key_length,
+ int alloc_length, int key_hash,
+ const void *data)
+{
+ Eina_Hash_Element *new_hash_element = NULL;
+ Eina_Hash_Head *hash_head;
+ Eina_Error error = 0;
+ int hash_num;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
+
+ error = EINA_ERROR_OUT_OF_MEMORY;
+
+ /* Apply eina mask to hash. */
+ hash_num = key_hash & hash->mask;
+ key_hash &= EINA_HASH_RBTREE_MASK;
+
+ if (!hash->buckets) {
+ hash->buckets = calloc(sizeof(Eina_Rbtree *), hash->size);
+ if (!hash->buckets)
+ goto on_error;
+
+ hash_head = NULL;
+ } else
+ /* Look up for head node. */
+ hash_head =
+ (Eina_Hash_Head *) eina_rbtree_inline_lookup(hash->
+ buckets
+ [hash_num],
+ &key_hash,
+ 0,
+ EINA_RBTREE_CMP_KEY_CB
+ (_eina_hash_hash_rbtree_cmp_hash),
+ NULL);
+
+ if (!hash_head) {
+ /* If not found allocate it and an element. */
+ hash_head =
+ malloc(sizeof(Eina_Hash_Head) +
+ sizeof(Eina_Hash_Element) + alloc_length);
+ if (!hash_head)
+ goto on_error;
+
+ hash_head->hash = key_hash;
+ hash_head->head = NULL;
+
+ hash->buckets[hash_num] =
+ eina_rbtree_inline_insert(hash->buckets[hash_num],
+ EINA_RBTREE_GET(hash_head),
+ EINA_RBTREE_CMP_NODE_CB
+ (_eina_hash_hash_rbtree_cmp_node),
+ NULL);
+
+ new_hash_element = (Eina_Hash_Element *) (hash_head + 1);
+ new_hash_element->begin = EINA_TRUE;
+ }
+
+ if (!new_hash_element) {
+ /*
+ Alloc a new element
+ (No more lookup as we expect to support more than one item for one key).
+ */
+ new_hash_element =
+ malloc(sizeof(Eina_Hash_Element) + alloc_length);
+ if (!new_hash_element)
+ goto on_error;
+
+ new_hash_element->begin = EINA_FALSE;
+ }
+
+ /* Setup the element */
+ new_hash_element->tuple.key_length = key_length;
+ new_hash_element->tuple.data = (void *) data;
+ if (alloc_length > 0) {
+ new_hash_element->tuple.key =
+ (char *) (new_hash_element + 1);
+ memcpy((char *) new_hash_element->tuple.key, key,
+ alloc_length);
+ } else
+ new_hash_element->tuple.key = key;
+
+ /* add the new element to the hash. */
+ hash_head->head =
+ eina_rbtree_inline_insert(hash_head->head,
+ EINA_RBTREE_GET(new_hash_element),
+ EINA_RBTREE_CMP_NODE_CB
+ (_eina_hash_key_rbtree_cmp_node),
+ (const void *) hash->key_cmp_cb);
+ hash->population++;
+ return EINA_TRUE;
+
+ on_error:
+ eina_error_set(error);
+ return EINA_FALSE;
}
static Eina_Bool
-_eina_hash_rbtree_each(__UNUSED__ const Eina_Rbtree *container,
- const Eina_Hash_Head *hash_head,
- Eina_Hash_Each *data)
-{
- Eina_Iterator *it;
- Eina_Hash_Element *hash_element;
- Eina_Bool found = EINA_TRUE;
-
- it = eina_rbtree_iterator_prefix(hash_head->head);
- EINA_ITERATOR_FOREACH(it, hash_element)
- {
- if (hash_element->tuple.data == data->data)
- {
- data->hash_element = hash_element;
- data->hash_head = (Eina_Hash_Head *)hash_head;
- found = EINA_FALSE;
- break;
- }
- }
-
- eina_iterator_free(it);
- return found;
+_eina_hash_rbtree_each(__UNUSED__ const Eina_Rbtree * container,
+ const Eina_Hash_Head * hash_head,
+ Eina_Hash_Each * data)
+{
+ Eina_Iterator *it;
+ Eina_Hash_Element *hash_element;
+ Eina_Bool found = EINA_TRUE;
+
+ it = eina_rbtree_iterator_prefix(hash_head->head);
+ EINA_ITERATOR_FOREACH(it, hash_element) {
+ if (hash_element->tuple.data == data->data) {
+ data->hash_element = hash_element;
+ data->hash_head = (Eina_Hash_Head *) hash_head;
+ found = EINA_FALSE;
+ break;
+ }
+ }
+
+ eina_iterator_free(it);
+ return found;
}
-static inline Eina_Hash_Element *
-_eina_hash_find_by_hash(const Eina_Hash *hash,
- Eina_Hash_Tuple *tuple,
- int key_hash,
- Eina_Hash_Head **hash_head)
-{
- Eina_Hash_Element *hash_element;
- int rb_hash = key_hash & EINA_HASH_RBTREE_MASK;
-
- key_hash &= hash->mask;
-
- if (!hash->buckets)
- return NULL;
-
- *hash_head = (Eina_Hash_Head *)eina_rbtree_inline_lookup(hash->buckets[key_hash],
- &rb_hash, 0,
- EINA_RBTREE_CMP_KEY_CB(
- _eina_hash_hash_rbtree_cmp_hash),
- NULL);
- if (!*hash_head)
- return NULL;
-
- hash_element = (Eina_Hash_Element *)eina_rbtree_inline_lookup((*hash_head)->head,
- tuple, 0,
- EINA_RBTREE_CMP_KEY_CB(
- _eina_hash_key_rbtree_cmp_key_data),
- (const void *)hash->
- key_cmp_cb);
-
- return hash_element;
+static inline Eina_Hash_Element *_eina_hash_find_by_hash(const Eina_Hash *
+ hash,
+ Eina_Hash_Tuple *
+ tuple,
+ int key_hash,
+ Eina_Hash_Head **
+ hash_head)
+{
+ Eina_Hash_Element *hash_element;
+ int rb_hash = key_hash & EINA_HASH_RBTREE_MASK;
+
+ key_hash &= hash->mask;
+
+ if (!hash->buckets)
+ return NULL;
+
+ *hash_head =
+ (Eina_Hash_Head *) eina_rbtree_inline_lookup(hash->
+ buckets[key_hash],
+ &rb_hash, 0,
+ EINA_RBTREE_CMP_KEY_CB
+ (_eina_hash_hash_rbtree_cmp_hash),
+ NULL);
+ if (!*hash_head)
+ return NULL;
+
+ hash_element =
+ (Eina_Hash_Element *) eina_rbtree_inline_lookup((*hash_head)->
+ head, tuple, 0,
+ EINA_RBTREE_CMP_KEY_CB
+ (_eina_hash_key_rbtree_cmp_key_data),
+ (const void *)
+ hash->key_cmp_cb);
+
+ return hash_element;
}
-static inline Eina_Hash_Element *
-_eina_hash_find_by_data(const Eina_Hash *hash,
- const void *data,
- int *key_hash,
- Eina_Hash_Head **hash_head)
-{
- Eina_Hash_Each each;
- Eina_Iterator *it;
- int hash_num;
-
- if (!hash->buckets)
- return NULL;
-
- each.hash_element = NULL;
- each.data = data;
-
- for (hash_num = 0; hash_num < hash->size; hash_num++)
- {
- if (!hash->buckets[hash_num])
- continue;
-
- it = eina_rbtree_iterator_prefix(hash->buckets[hash_num]);
- eina_iterator_foreach(it, EINA_EACH_CB(_eina_hash_rbtree_each), &each);
- eina_iterator_free(it);
-
- if (each.hash_element)
- {
- *key_hash = hash_num;
- *hash_head = each.hash_head;
- return (Eina_Hash_Element *)each.hash_element;
- }
- }
-
- return NULL;
+static inline Eina_Hash_Element *_eina_hash_find_by_data(const Eina_Hash *
+ hash,
+ const void *data,
+ int *key_hash,
+ Eina_Hash_Head **
+ hash_head)
+{
+ Eina_Hash_Each each;
+ Eina_Iterator *it;
+ int hash_num;
+
+ if (!hash->buckets)
+ return NULL;
+
+ each.hash_element = NULL;
+ each.data = data;
+
+ for (hash_num = 0; hash_num < hash->size; hash_num++) {
+ if (!hash->buckets[hash_num])
+ continue;
+
+ it = eina_rbtree_iterator_prefix(hash->buckets[hash_num]);
+ eina_iterator_foreach(it,
+ EINA_EACH_CB(_eina_hash_rbtree_each),
+ &each);
+ eina_iterator_free(it);
+
+ if (each.hash_element) {
+ *key_hash = hash_num;
+ *hash_head = each.hash_head;
+ return (Eina_Hash_Element *) each.hash_element;
+ }
+ }
+
+ return NULL;
}
static void
-_eina_hash_el_free(Eina_Hash_Element *hash_element, Eina_Hash *hash)
+_eina_hash_el_free(Eina_Hash_Element * hash_element, Eina_Hash * hash)
{
- if (hash->data_free_cb)
- hash->data_free_cb(hash_element->tuple.data);
+ if (hash->data_free_cb)
+ hash->data_free_cb(hash_element->tuple.data);
- if (hash_element->begin == EINA_FALSE)
- free(hash_element);
+ if (hash_element->begin == EINA_FALSE)
+ free(hash_element);
}
static void
-_eina_hash_head_free(Eina_Hash_Head *hash_head, Eina_Hash *hash)
+_eina_hash_head_free(Eina_Hash_Head * hash_head, Eina_Hash * hash)
{
- eina_rbtree_delete(hash_head->head, EINA_RBTREE_FREE_CB(_eina_hash_el_free), hash);
- free(hash_head);
+ eina_rbtree_delete(hash_head->head,
+ EINA_RBTREE_FREE_CB(_eina_hash_el_free), hash);
+ free(hash_head);
}
static Eina_Bool
-_eina_hash_del_by_hash_el(Eina_Hash *hash,
- Eina_Hash_Element *hash_element,
- Eina_Hash_Head *hash_head,
- int key_hash)
-{
- hash_head->head = eina_rbtree_inline_remove(hash_head->head, EINA_RBTREE_GET(
- hash_element), EINA_RBTREE_CMP_NODE_CB(
- _eina_hash_key_rbtree_cmp_node),
- (const void *)hash->key_cmp_cb);
- _eina_hash_el_free(hash_element, hash);
-
- if (!hash_head->head)
- {
- key_hash &= hash->mask;
-
- hash->buckets[key_hash] =
- eina_rbtree_inline_remove(hash->buckets[key_hash], EINA_RBTREE_GET(
- hash_head),
- EINA_RBTREE_CMP_NODE_CB(
- _eina_hash_hash_rbtree_cmp_node), NULL);
- free(hash_head);
- }
-
- hash->population--;
- if (hash->population == 0)
- {
- free(hash->buckets);
- hash->buckets = NULL;
- }
-
- return EINA_TRUE;
+_eina_hash_del_by_hash_el(Eina_Hash * hash,
+ Eina_Hash_Element * hash_element,
+ Eina_Hash_Head * hash_head, int key_hash)
+{
+ hash_head->head =
+ eina_rbtree_inline_remove(hash_head->head,
+ EINA_RBTREE_GET(hash_element),
+ EINA_RBTREE_CMP_NODE_CB
+ (_eina_hash_key_rbtree_cmp_node),
+ (const void *) hash->key_cmp_cb);
+ _eina_hash_el_free(hash_element, hash);
+
+ if (!hash_head->head) {
+ key_hash &= hash->mask;
+
+ hash->buckets[key_hash] =
+ eina_rbtree_inline_remove(hash->buckets[key_hash],
+ EINA_RBTREE_GET(hash_head),
+ EINA_RBTREE_CMP_NODE_CB
+ (_eina_hash_hash_rbtree_cmp_node),
+ NULL);
+ free(hash_head);
+ }
+
+ hash->population--;
+ if (hash->population == 0) {
+ free(hash->buckets);
+ hash->buckets = NULL;
+ }
+
+ return EINA_TRUE;
}
static Eina_Bool
-_eina_hash_del_by_key_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data)
+_eina_hash_del_by_key_hash(Eina_Hash * hash,
+ const void *key,
+ int key_length, int key_hash, const void *data)
{
- Eina_Hash_Element *hash_element;
- Eina_Hash_Head *hash_head;
- Eina_Hash_Tuple tuple;
+ Eina_Hash_Element *hash_element;
+ Eina_Hash_Head *hash_head;
+ Eina_Hash_Tuple tuple;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
- if (!hash->buckets)
- return EINA_FALSE;
+ if (!hash->buckets)
+ return EINA_FALSE;
- tuple.key = (void *)key;
- tuple.key_length = key_length;
- tuple.data = (void *)data;
+ tuple.key = (void *) key;
+ tuple.key_length = key_length;
+ tuple.data = (void *) data;
- hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
- if (!hash_element)
- return EINA_FALSE;
+ hash_element =
+ _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+ if (!hash_element)
+ return EINA_FALSE;
- return _eina_hash_del_by_hash_el(hash, hash_element, hash_head, key_hash);
+ return _eina_hash_del_by_hash_el(hash, hash_element, hash_head,
+ key_hash);
}
static Eina_Bool
-_eina_hash_del_by_key(Eina_Hash *hash, const void *key, const void *data)
+_eina_hash_del_by_key(Eina_Hash * hash, const void *key, const void *data)
{
- int key_length, key_hash;
+ int key_length, key_hash;
- EINA_MAGIC_CHECK_HASH(hash);
- if (!hash)
- return EINA_FALSE;
+ EINA_MAGIC_CHECK_HASH(hash);
+ if (!hash)
+ return EINA_FALSE;
- if (!key)
- return EINA_FALSE;
+ if (!key)
+ return EINA_FALSE;
- if (!hash->buckets)
- return EINA_FALSE;
+ if (!hash->buckets)
+ return EINA_FALSE;
- key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
- key_hash = hash->key_hash_cb(key, key_length);
- return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
+ key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
+ key_hash = hash->key_hash_cb(key, key_length);
+ return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash,
+ data);
}
-static unsigned int
-_eina_string_key_length(const char *key)
+static unsigned int _eina_string_key_length(const char *key)
{
- if (!key)
- return 0;
+ if (!key)
+ return 0;
- return (int)strlen(key) + 1;
+ return (int) strlen(key) + 1;
}
static int
_eina_string_key_cmp(const char *key1, __UNUSED__ int key1_length,
- const char *key2, __UNUSED__ int key2_length)
+ const char *key2, __UNUSED__ int key2_length)
{
- return strcmp(key1, key2);
+ return strcmp(key1, key2);
}
static int
_eina_stringshared_key_cmp(const char *key1, __UNUSED__ int key1_length,
- const char *key2, __UNUSED__ int key2_length)
+ const char *key2, __UNUSED__ int key2_length)
{
- return key1 - key2;
+ return key1 - key2;
}
-static unsigned int
-_eina_int32_key_length(__UNUSED__ const uint32_t *key)
+static unsigned int _eina_int32_key_length(__UNUSED__ const uint32_t * key)
{
- return 4;
+ return 4;
}
static int
-_eina_int32_key_cmp(const uint32_t *key1, __UNUSED__ int key1_length,
- const uint32_t *key2, __UNUSED__ int key2_length)
+_eina_int32_key_cmp(const uint32_t * key1, __UNUSED__ int key1_length,
+ const uint32_t * key2, __UNUSED__ int key2_length)
{
- return *key1 - *key2;
+ return *key1 - *key2;
}
-static unsigned int
-_eina_int64_key_length(__UNUSED__ const uint32_t *key)
+static unsigned int _eina_int64_key_length(__UNUSED__ const uint32_t * key)
{
- return 8;
+ return 8;
}
static int
-_eina_int64_key_cmp(const uint64_t *key1, __UNUSED__ int key1_length,
- const uint64_t *key2, __UNUSED__ int key2_length)
+_eina_int64_key_cmp(const uint64_t * key1, __UNUSED__ int key1_length,
+ const uint64_t * key2, __UNUSED__ int key2_length)
{
- return *key1 - *key2;
+ return *key1 - *key2;
}
static Eina_Bool
-_eina_foreach_cb(const Eina_Hash *hash,
- Eina_Hash_Tuple *data,
- Eina_Hash_Foreach_Data *fdata)
+_eina_foreach_cb(const Eina_Hash * hash,
+ Eina_Hash_Tuple * data, Eina_Hash_Foreach_Data * fdata)
{
- return fdata->cb((Eina_Hash *)hash,
- data->key,
- data->data,
- (void *)fdata->fdata);
+ return fdata->cb((Eina_Hash *) hash,
+ data->key, data->data, (void *) fdata->fdata);
}
-static void *
-_eina_hash_iterator_data_get_content(Eina_Iterator_Hash *it)
+static void *_eina_hash_iterator_data_get_content(Eina_Iterator_Hash * it)
{
- Eina_Hash_Element *stuff;
+ Eina_Hash_Element *stuff;
- EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
+ EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
- stuff = it->hash_element;
+ stuff = it->hash_element;
- if (!stuff)
- return NULL;
+ if (!stuff)
+ return NULL;
- return stuff->tuple.data;
+ return stuff->tuple.data;
}
-static void *
-_eina_hash_iterator_key_get_content(Eina_Iterator_Hash *it)
+static void *_eina_hash_iterator_key_get_content(Eina_Iterator_Hash * it)
{
- Eina_Hash_Element *stuff;
+ Eina_Hash_Element *stuff;
- EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
+ EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
- stuff = it->hash_element;
+ stuff = it->hash_element;
- if (!stuff)
- return NULL;
+ if (!stuff)
+ return NULL;
- return (void *)stuff->tuple.key;
+ return (void *) stuff->tuple.key;
}
-static Eina_Hash_Tuple *
-_eina_hash_iterator_tuple_get_content(Eina_Iterator_Hash *it)
+static Eina_Hash_Tuple
+ *_eina_hash_iterator_tuple_get_content(Eina_Iterator_Hash * it)
{
- Eina_Hash_Element *stuff;
+ Eina_Hash_Element *stuff;
- EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
+ EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
- stuff = it->hash_element;
+ stuff = it->hash_element;
- if (!stuff)
- return NULL;
+ if (!stuff)
+ return NULL;
- return &stuff->tuple;
+ return &stuff->tuple;
}
static Eina_Bool
-_eina_hash_iterator_next(Eina_Iterator_Hash *it, void **data)
-{
- Eina_Bool ok;
- int bucket;
-
- if (!(it->index < it->hash->population))
- return EINA_FALSE;
-
- if (!it->current)
- {
- ok = EINA_FALSE;
- bucket = 0;
- it->index = -1;
- }
- else
- {
- ok = eina_iterator_next(it->list, (void **)&it->hash_element);
- if (!ok)
- {
- eina_iterator_free(it->list);
- it->list = NULL;
-
- ok = eina_iterator_next(it->current, (void **)&it->hash_head);
- if (!ok)
- {
- eina_iterator_free(it->current);
- it->current = NULL;
- it->bucket++;
- }
- else
- {
- it->list = eina_rbtree_iterator_prefix(it->hash_head->head);
- ok = eina_iterator_next(it->list, (void **)&it->hash_element);
- }
- }
-
- bucket = it->bucket;
- }
-
- if (ok == EINA_FALSE)
- {
- while (bucket < it->hash->size)
- {
- if (it->hash->buckets[bucket])
- {
- it->current =
- eina_rbtree_iterator_prefix(it->hash->buckets[bucket]);
- ok = eina_iterator_next(it->current, (void **)&it->hash_head);
- if (ok)
- break;
-
- eina_iterator_free(it->current);
- it->current = NULL;
- }
-
- ++bucket;
- }
- if (it->list)
- eina_iterator_free(it->list);
-
- it->list = eina_rbtree_iterator_prefix(it->hash_head->head);
- ok = eina_iterator_next(it->list, (void **)&it->hash_element);
- if (bucket == it->hash->size)
- ok = EINA_FALSE;
- }
-
- it->index++;
- it->bucket = bucket;
-
- if (ok)
- *data = it->get_content(it);
-
- return ok;
+_eina_hash_iterator_next(Eina_Iterator_Hash * it, void **data)
+{
+ Eina_Bool ok;
+ int bucket;
+
+ if (!(it->index < it->hash->population))
+ return EINA_FALSE;
+
+ if (!it->current) {
+ ok = EINA_FALSE;
+ bucket = 0;
+ it->index = -1;
+ } else {
+ ok = eina_iterator_next(it->list,
+ (void **) &it->hash_element);
+ if (!ok) {
+ eina_iterator_free(it->list);
+ it->list = NULL;
+
+ ok = eina_iterator_next(it->current,
+ (void **) &it->hash_head);
+ if (!ok) {
+ eina_iterator_free(it->current);
+ it->current = NULL;
+ it->bucket++;
+ } else {
+ it->list =
+ eina_rbtree_iterator_prefix(it->
+ hash_head->
+ head);
+ ok = eina_iterator_next(it->list,
+ (void **) &it->
+ hash_element);
+ }
+ }
+
+ bucket = it->bucket;
+ }
+
+ if (ok == EINA_FALSE) {
+ while (bucket < it->hash->size) {
+ if (it->hash->buckets[bucket]) {
+ it->current =
+ eina_rbtree_iterator_prefix(it->hash->
+ buckets
+ [bucket]);
+ ok = eina_iterator_next(it->current,
+ (void **) &it->
+ hash_head);
+ if (ok)
+ break;
+
+ eina_iterator_free(it->current);
+ it->current = NULL;
+ }
+
+ ++bucket;
+ }
+ if (it->list)
+ eina_iterator_free(it->list);
+
+ it->list =
+ eina_rbtree_iterator_prefix(it->hash_head->head);
+ ok = eina_iterator_next(it->list,
+ (void **) &it->hash_element);
+ if (bucket == it->hash->size)
+ ok = EINA_FALSE;
+ }
+
+ it->index++;
+ it->bucket = bucket;
+
+ if (ok)
+ *data = it->get_content(it);
+
+ return ok;
}
-static void *
-_eina_hash_iterator_get_container(Eina_Iterator_Hash *it)
+static void *_eina_hash_iterator_get_container(Eina_Iterator_Hash * it)
{
- EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
- return (void *)it->hash;
+ EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
+ return (void *) it->hash;
}
-static void
-_eina_hash_iterator_free(Eina_Iterator_Hash *it)
+static void _eina_hash_iterator_free(Eina_Iterator_Hash * it)
{
- EINA_MAGIC_CHECK_HASH_ITERATOR(it);
- if (it->current)
- eina_iterator_free(it->current);
+ EINA_MAGIC_CHECK_HASH_ITERATOR(it);
+ if (it->current)
+ eina_iterator_free(it->current);
- if (it->list)
- eina_iterator_free(it->list);
+ if (it->list)
+ eina_iterator_free(it->list);
- free(it);
+ free(it);
}
/**
@@ -750,43 +751,42 @@ _eina_hash_iterator_free(Eina_Iterator_Hash *it)
* eina_hash_int64_new(), eina_hash_pointer_new() and
* eina_hash_stringshared_new().
*/
-EAPI Eina_Hash *
-eina_hash_new(Eina_Key_Length key_length_cb,
- Eina_Key_Cmp key_cmp_cb,
- Eina_Key_Hash key_hash_cb,
- Eina_Free_Cb data_free_cb,
- int buckets_power_size)
-{
- /* FIXME: Use mempool. */
- Eina_Hash *new;
-
- eina_error_set(0);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key_cmp_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key_hash_cb, NULL);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size < 3, NULL);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size > 16, NULL);
-
- new = malloc(sizeof (Eina_Hash));
- if (!new)
- goto on_error;
-
- EINA_MAGIC_SET(new, EINA_MAGIC_HASH);
-
- new->key_length_cb = key_length_cb;
- new->key_cmp_cb = key_cmp_cb;
- new->key_hash_cb = key_hash_cb;
- new->data_free_cb = data_free_cb;
- new->buckets = NULL;
- new->population = 0;
-
- new->size = 1 << buckets_power_size;
- new->mask = new->size - 1;
-
- return new;
-
-on_error:
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
+EAPI Eina_Hash *eina_hash_new(Eina_Key_Length key_length_cb,
+ Eina_Key_Cmp key_cmp_cb,
+ Eina_Key_Hash key_hash_cb,
+ Eina_Free_Cb data_free_cb,
+ int buckets_power_size)
+{
+ /* FIXME: Use mempool. */
+ Eina_Hash *new;
+
+ eina_error_set(0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key_cmp_cb, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key_hash_cb, NULL);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size < 3, NULL);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size > 16, NULL);
+
+ new = malloc(sizeof(Eina_Hash));
+ if (!new)
+ goto on_error;
+
+ EINA_MAGIC_SET(new, EINA_MAGIC_HASH);
+
+ new->key_length_cb = key_length_cb;
+ new->key_cmp_cb = key_cmp_cb;
+ new->key_hash_cb = key_hash_cb;
+ new->data_free_cb = data_free_cb;
+ new->buckets = NULL;
+ new->population = 0;
+
+ new->size = 1 << buckets_power_size;
+ new->mask = new->size - 1;
+
+ return new;
+
+ on_error:
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
}
/**
@@ -802,14 +802,12 @@ on_error:
* @p data_free_cb is a callback called when the hash table is
* freed. @c NULL can be passed as callback.
*/
-EAPI Eina_Hash *
-eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb)
+EAPI Eina_Hash *eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb)
{
- return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
- EINA_KEY_CMP(_eina_string_key_cmp),
- EINA_KEY_HASH(eina_hash_djb2),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
+ EINA_KEY_CMP(_eina_string_key_cmp),
+ EINA_KEY_HASH(eina_hash_djb2),
+ data_free_cb, EINA_HASH_BUCKET_SIZE);
}
/**
@@ -825,14 +823,12 @@ eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb)
* @c NULL. @p data_free_cb is a callback called when the hash table is
* freed. @c NULL can be passed as callback.
*/
-EAPI Eina_Hash *
-eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb)
+EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb)
{
- return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
- EINA_KEY_CMP(_eina_string_key_cmp),
- EINA_KEY_HASH(eina_hash_superfast),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
+ EINA_KEY_CMP(_eina_string_key_cmp),
+ EINA_KEY_HASH(eina_hash_superfast),
+ data_free_cb, EINA_HASH_BUCKET_SIZE);
}
/**
@@ -850,14 +846,12 @@ eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb)
* function returns @c NULL. @p data_free_cb is a callback called when
* the hash table is freed. @c NULL can be passed as callback.
*/
-EAPI Eina_Hash *
-eina_hash_string_small_new(Eina_Free_Cb data_free_cb)
+EAPI Eina_Hash *eina_hash_string_small_new(Eina_Free_Cb data_free_cb)
{
- return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
- EINA_KEY_CMP(_eina_string_key_cmp),
- EINA_KEY_HASH(eina_hash_superfast),
- data_free_cb,
- EINA_HASH_SMALL_BUCKET_SIZE);
+ return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
+ EINA_KEY_CMP(_eina_string_key_cmp),
+ EINA_KEY_HASH(eina_hash_superfast),
+ data_free_cb, EINA_HASH_SMALL_BUCKET_SIZE);
}
/**
@@ -875,14 +869,12 @@ eina_hash_string_small_new(Eina_Free_Cb data_free_cb)
* @p data_free_cb is a callback called when the hash table is freed.
* @c NULL can be passed as callback.
*/
-EAPI Eina_Hash *
-eina_hash_int32_new(Eina_Free_Cb data_free_cb)
+EAPI Eina_Hash *eina_hash_int32_new(Eina_Free_Cb data_free_cb)
{
- return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
- EINA_KEY_CMP(_eina_int32_key_cmp),
- EINA_KEY_HASH(eina_hash_int32),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
+ EINA_KEY_CMP(_eina_int32_key_cmp),
+ EINA_KEY_HASH(eina_hash_int32),
+ data_free_cb, EINA_HASH_BUCKET_SIZE);
}
/**
@@ -900,14 +892,12 @@ eina_hash_int32_new(Eina_Free_Cb data_free_cb)
* @p data_free_cb is a callback called when the hash table is freed.
* @c NULL can be passed as callback.
*/
-EAPI Eina_Hash *
-eina_hash_int64_new(Eina_Free_Cb data_free_cb)
+EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb)
{
- return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
- EINA_KEY_CMP(_eina_int64_key_cmp),
- EINA_KEY_HASH(eina_hash_int64),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
+ EINA_KEY_CMP(_eina_int64_key_cmp),
+ EINA_KEY_HASH(eina_hash_int64),
+ data_free_cb, EINA_HASH_BUCKET_SIZE);
}
/**
@@ -925,21 +915,18 @@ eina_hash_int64_new(Eina_Free_Cb data_free_cb)
* @p data_free_cb is a callback called when the hash table is freed.
* @c NULL can be passed as callback.
*/
-EAPI Eina_Hash *
-eina_hash_pointer_new(Eina_Free_Cb data_free_cb)
+EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb)
{
#ifdef __LP64__
- return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
- EINA_KEY_CMP(_eina_int64_key_cmp),
- EINA_KEY_HASH(eina_hash_int64),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
+ EINA_KEY_CMP(_eina_int64_key_cmp),
+ EINA_KEY_HASH(eina_hash_int64),
+ data_free_cb, EINA_HASH_BUCKET_SIZE);
#else
- return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
- EINA_KEY_CMP(_eina_int32_key_cmp),
- EINA_KEY_HASH(eina_hash_int32),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
+ EINA_KEY_CMP(_eina_int32_key_cmp),
+ EINA_KEY_HASH(eina_hash_int32),
+ data_free_cb, EINA_HASH_BUCKET_SIZE);
#endif
}
@@ -966,14 +953,12 @@ eina_hash_pointer_new(Eina_Free_Cb data_free_cb)
* eina_hash_find(hash, "key")
* @endcode
*/
-EAPI Eina_Hash *
-eina_hash_stringshared_new(Eina_Free_Cb data_free_cb)
+EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb)
{
- return eina_hash_new(NULL,
- EINA_KEY_CMP(_eina_stringshared_key_cmp),
- EINA_KEY_HASH(eina_hash_superfast),
- data_free_cb,
- EINA_HASH_BUCKET_SIZE);
+ return eina_hash_new(NULL,
+ EINA_KEY_CMP(_eina_stringshared_key_cmp),
+ EINA_KEY_HASH(eina_hash_superfast),
+ data_free_cb, EINA_HASH_BUCKET_SIZE);
}
/**
@@ -985,14 +970,13 @@ eina_hash_stringshared_new(Eina_Free_Cb data_free_cb)
* This function returns the number of entries in @p hash, or 0 on
* error. If @p hash is @c NULL, 0 is returned.
*/
-EAPI int
-eina_hash_population(const Eina_Hash *hash)
+EAPI int eina_hash_population(const Eina_Hash * hash)
{
- if (!hash)
- return 0;
+ if (!hash)
+ return 0;
- EINA_MAGIC_CHECK_HASH(hash);
- return hash->population;
+ EINA_MAGIC_CHECK_HASH(hash);
+ return hash->population;
}
/**
@@ -1017,21 +1001,21 @@ eina_hash_population(const Eina_Hash *hash)
* hash = NULL;
* @endcode
*/
-EAPI void
-eina_hash_free(Eina_Hash *hash)
+EAPI void eina_hash_free(Eina_Hash * hash)
{
- int i;
-
- EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN(hash);
-
- if (hash->buckets)
- {
- for (i = 0; i < hash->size; i++)
- eina_rbtree_delete(hash->buckets[i], EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
- free(hash->buckets);
- }
- free(hash);
+ int i;
+
+ EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN(hash);
+
+ if (hash->buckets) {
+ for (i = 0; i < hash->size; i++)
+ eina_rbtree_delete(hash->buckets[i],
+ EINA_RBTREE_FREE_CB
+ (_eina_hash_head_free), hash);
+ free(hash->buckets);
+ }
+ free(hash);
}
/**
@@ -1046,23 +1030,22 @@ eina_hash_free(Eina_Hash *hash)
* buckets value will be freed. If @p hash is @c NULL, the function
* returns immediately.
*/
-EAPI void
-eina_hash_free_buckets(Eina_Hash *hash)
-{
- int i;
-
- EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN(hash);
-
- if (hash->buckets)
- {
- for (i = 0; i < hash->size; i++)
- eina_rbtree_delete(hash->buckets[i],
- EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
- free(hash->buckets);
- hash->buckets = NULL;
- hash->population = 0;
- }
+EAPI void eina_hash_free_buckets(Eina_Hash * hash)
+{
+ int i;
+
+ EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN(hash);
+
+ if (hash->buckets) {
+ for (i = 0; i < hash->size; i++)
+ eina_rbtree_delete(hash->buckets[i],
+ EINA_RBTREE_FREE_CB
+ (_eina_hash_head_free), hash);
+ free(hash->buckets);
+ hash->buckets = NULL;
+ hash->population = 0;
+ }
}
/**
@@ -1089,18 +1072,14 @@ eina_hash_free_buckets(Eina_Hash *hash)
* returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool
-eina_hash_add_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data)
-{
- return eina_hash_add_alloc_by_hash(hash,
- key,
- key_length,
- key_length,
- key_hash,
- data);
+eina_hash_add_by_hash(Eina_Hash * hash,
+ const void *key,
+ int key_length, int key_hash, const void *data)
+{
+ return eina_hash_add_alloc_by_hash(hash,
+ key,
+ key_length,
+ key_length, key_hash, data);
}
/**
@@ -1129,13 +1108,13 @@ eina_hash_add_by_hash(Eina_Hash *hash,
* returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool
-eina_hash_direct_add_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data)
+eina_hash_direct_add_by_hash(Eina_Hash * hash,
+ const void *key,
+ int key_length,
+ int key_hash, const void *data)
{
- return eina_hash_add_alloc_by_hash(hash, key, key_length, 0, key_hash, data);
+ return eina_hash_add_alloc_by_hash(hash, key, key_length, 0,
+ key_hash, data);
}
/**
@@ -1161,21 +1140,22 @@ eina_hash_direct_add_by_hash(Eina_Hash *hash,
* occurred, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool
-eina_hash_add(Eina_Hash *hash, const void *key, const void *data)
+eina_hash_add(Eina_Hash * hash, const void *key, const void *data)
{
- unsigned int key_length;
- int key_hash;
+ unsigned int key_length;
+ int key_hash;
- EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
- key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
- key_hash = hash->key_hash_cb(key, key_length);
+ key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
+ key_hash = hash->key_hash_cb(key, key_length);
- return eina_hash_add_alloc_by_hash(hash, key, key_length, key_length, key_hash, data);
+ return eina_hash_add_alloc_by_hash(hash, key, key_length,
+ key_length, key_hash, data);
}
/**
@@ -1203,21 +1183,22 @@ eina_hash_add(Eina_Hash *hash, const void *key, const void *data)
* occurred, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool
-eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
+eina_hash_direct_add(Eina_Hash * hash, const void *key, const void *data)
{
- int key_length;
- int key_hash;
+ int key_length;
+ int key_hash;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
- key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
- key_hash = hash->key_hash_cb(key, key_length);
+ key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
+ key_hash = hash->key_hash_cb(key, key_length);
- return eina_hash_add_alloc_by_hash(hash, key, key_length, 0, key_hash, data);
+ return eina_hash_add_alloc_by_hash(hash, key, key_length, 0,
+ key_hash, data);
}
/**
@@ -1241,15 +1222,14 @@ eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
* @note if you don't have the key, use eina_hash_del_by_data() instead.
*/
EAPI Eina_Bool
-eina_hash_del_by_key_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash)
+eina_hash_del_by_key_hash(Eina_Hash * hash,
+ const void *key, int key_length, int key_hash)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, NULL);
+ return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash,
+ NULL);
}
/**
@@ -1273,13 +1253,12 @@ eina_hash_del_by_key_hash(Eina_Hash *hash,
* @note if you already have the key_hash, use eina_hash_del_by_key_hash() instead.
* @note if you don't have the key, use eina_hash_del_by_data() instead.
*/
-EAPI Eina_Bool
-eina_hash_del_by_key(Eina_Hash *hash, const void *key)
+EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash * hash, const void *key)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
- return _eina_hash_del_by_key(hash, key, NULL);
+ return _eina_hash_del_by_key(hash, key, NULL);
}
/**
@@ -1301,28 +1280,29 @@ eina_hash_del_by_key(Eina_Hash *hash, const void *key)
*
* @note if you already have the key, use eina_hash_del_by_key() or eina_hash_del_by_key_hash() instead.
*/
-EAPI Eina_Bool
-eina_hash_del_by_data(Eina_Hash *hash, const void *data)
+EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash * hash, const void *data)
{
- Eina_Hash_Element *hash_element;
- Eina_Hash_Head *hash_head;
- int key_hash;
+ Eina_Hash_Element *hash_element;
+ Eina_Hash_Head *hash_head;
+ int key_hash;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
- hash_element = _eina_hash_find_by_data(hash, data, &key_hash, &hash_head);
- if (!hash_element)
- goto error;
+ hash_element =
+ _eina_hash_find_by_data(hash, data, &key_hash, &hash_head);
+ if (!hash_element)
+ goto error;
- if (hash_element->tuple.data != data)
- goto error;
+ if (hash_element->tuple.data != data)
+ goto error;
- return _eina_hash_del_by_hash_el(hash, hash_element, hash_head, key_hash);
+ return _eina_hash_del_by_hash_el(hash, hash_element, hash_head,
+ key_hash);
-error:
- return EINA_FALSE;
+ error:
+ return EINA_FALSE;
}
/**
@@ -1355,23 +1335,23 @@ error:
* directly.
*/
EAPI Eina_Bool
-eina_hash_del_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data)
+eina_hash_del_by_hash(Eina_Hash * hash,
+ const void *key,
+ int key_length, int key_hash, const void *data)
{
- Eina_Bool ret;
+ Eina_Bool ret;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
- if (key)
- ret = _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
- else
- ret = eina_hash_del_by_data(hash, data);
+ if (key)
+ ret =
+ _eina_hash_del_by_key_hash(hash, key, key_length,
+ key_hash, data);
+ else
+ ret = eina_hash_del_by_data(hash, data);
- return ret;
+ return ret;
}
/**
@@ -1398,15 +1378,15 @@ eina_hash_del_by_hash(Eina_Hash *hash,
* directly.
*/
EAPI Eina_Bool
-eina_hash_del(Eina_Hash *hash, const void *key, const void *data)
+eina_hash_del(Eina_Hash * hash, const void *key, const void *data)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
- if (!key)
- return eina_hash_del_by_data(hash, data);
+ if (!key)
+ return eina_hash_del_by_data(hash, data);
- return _eina_hash_del_by_key(hash, key, data);
+ return _eina_hash_del_by_key(hash, key, data);
}
/**
@@ -1426,31 +1406,30 @@ eina_hash_del(Eina_Hash *hash, const void *key, const void *data)
* @p hash is @c NULL, this function returns immediately @c NULL. This
* function returns the data pointer on success, @c NULL otherwise.
*/
-EAPI void *
-eina_hash_find_by_hash(const Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash)
+EAPI void *eina_hash_find_by_hash(const Eina_Hash * hash,
+ const void *key,
+ int key_length, int key_hash)
{
- Eina_Hash_Head *hash_head;
- Eina_Hash_Element *hash_element;
- Eina_Hash_Tuple tuple;
+ Eina_Hash_Head *hash_head;
+ Eina_Hash_Element *hash_element;
+ Eina_Hash_Tuple tuple;
- if (!hash)
- return NULL;
+ if (!hash)
+ return NULL;
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
- tuple.key = key;
- tuple.key_length = key_length;
- tuple.data = NULL;
+ tuple.key = key;
+ tuple.key_length = key_length;
+ tuple.data = NULL;
- hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
- if (hash_element)
- return hash_element->tuple.data;
+ hash_element =
+ _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+ if (hash_element)
+ return hash_element->tuple.data;
- return NULL;
+ return NULL;
}
/**
@@ -1466,23 +1445,22 @@ eina_hash_find_by_hash(const Eina_Hash *hash,
* @c NULL. This function returns the data pointer on success, @c NULL
* otherwise.
*/
-EAPI void *
-eina_hash_find(const Eina_Hash *hash, const void *key)
+EAPI void *eina_hash_find(const Eina_Hash * hash, const void *key)
{
- int key_length;
- int hash_num;
+ int key_length;
+ int hash_num;
- if (!hash)
- return NULL;
+ if (!hash)
+ return NULL;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
- key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
- hash_num = hash->key_hash_cb(key, key_length);
+ key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
+ hash_num = hash->key_hash_cb(key, key_length);
- return eina_hash_find_by_hash(hash, key, key_length, hash_num);
+ return eina_hash_find_by_hash(hash, key, key_length, hash_num);
}
/**
@@ -1498,35 +1476,33 @@ eina_hash_find(const Eina_Hash *hash, const void *key)
* found. If an existing entry is not found, nothing is added to the
* hash.
*/
-EAPI void *
-eina_hash_modify_by_hash(Eina_Hash *hash,
- const void *key,
- int key_length,
- int key_hash,
- const void *data)
-{
- Eina_Hash_Head *hash_head;
- Eina_Hash_Element *hash_element;
- void *old_data = NULL;
- Eina_Hash_Tuple tuple;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
-
- tuple.key = key;
- tuple.key_length = key_length;
- tuple.data = NULL;
-
- hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
- if (hash_element)
- {
- old_data = hash_element->tuple.data;
- hash_element->tuple.data = (void *)data;
- }
-
- return old_data;
+EAPI void *eina_hash_modify_by_hash(Eina_Hash * hash,
+ const void *key,
+ int key_length,
+ int key_hash, const void *data)
+{
+ Eina_Hash_Head *hash_head;
+ Eina_Hash_Element *hash_element;
+ void *old_data = NULL;
+ Eina_Hash_Tuple tuple;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
+
+ tuple.key = key;
+ tuple.key_length = key_length;
+ tuple.data = NULL;
+
+ hash_element =
+ _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+ if (hash_element) {
+ old_data = hash_element->tuple.data;
+ hash_element->tuple.data = (void *) data;
+ }
+
+ return old_data;
}
/**
@@ -1545,46 +1521,45 @@ eina_hash_modify_by_hash(Eina_Hash *hash,
* otherwise it returns @c NULL. To check for errors, use
* eina_error_get().
*/
-EAPI void *
-eina_hash_set(Eina_Hash *hash, const void *key, const void *data)
-{
- Eina_Hash_Tuple tuple;
- Eina_Hash_Head *hash_head;
- Eina_Hash_Element *hash_element;
- int key_length;
- int key_hash;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
-
- key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
- key_hash = hash->key_hash_cb(key, key_length);
-
- tuple.key = key;
- tuple.key_length = key_length;
- tuple.data = NULL;
-
- hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
- if (hash_element)
- {
- void *old_data = NULL;
-
- old_data = hash_element->tuple.data;
- hash_element->tuple.data = (void *)data;
- return old_data;
- }
-
- eina_hash_add_alloc_by_hash(hash,
- key,
- key_length,
- key_length,
- key_hash,
- data);
- return NULL;
+EAPI void *eina_hash_set(Eina_Hash * hash, const void *key,
+ const void *data)
+{
+ Eina_Hash_Tuple tuple;
+ Eina_Hash_Head *hash_head;
+ Eina_Hash_Element *hash_element;
+ int key_length;
+ int key_hash;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
+
+ key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
+ key_hash = hash->key_hash_cb(key, key_length);
+
+ tuple.key = key;
+ tuple.key_length = key_length;
+ tuple.data = NULL;
+
+ hash_element =
+ _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+ if (hash_element) {
+ void *old_data = NULL;
+
+ old_data = hash_element->tuple.data;
+ hash_element->tuple.data = (void *) data;
+ return old_data;
+ }
+
+ eina_hash_add_alloc_by_hash(hash,
+ key,
+ key_length,
+ key_length, key_hash, data);
+ return NULL;
}
+
/**
* @brief Modify the entry pointer at the specified key and return the old entry.
* @param hash The given hash table.
@@ -1597,22 +1572,23 @@ eina_hash_set(Eina_Hash *hash, const void *key, const void *data)
* hash. If no entry is found, nothing is added to @p hash. On success
* this function returns the old entry, otherwise it returns @c NULL.
*/
-EAPI void *
-eina_hash_modify(Eina_Hash *hash, const void *key, const void *data)
+EAPI void *eina_hash_modify(Eina_Hash * hash, const void *key,
+ const void *data)
{
- int key_length;
- int hash_num;
+ int key_length;
+ int hash_num;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
- key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
- hash_num = hash->key_hash_cb(key, key_length);
+ key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
+ hash_num = hash->key_hash_cb(key, key_length);
- return eina_hash_modify_by_hash(hash, key, key_length, hash_num, data);
+ return eina_hash_modify_by_hash(hash, key, key_length, hash_num,
+ data);
}
/**
@@ -1629,31 +1605,32 @@ eina_hash_modify(Eina_Hash *hash, const void *key, const void *data)
* when destroying the old key.
*/
EAPI Eina_Bool
-eina_hash_move(Eina_Hash *hash, const void *old_key, const void *new_key)
+eina_hash_move(Eina_Hash * hash, const void *old_key, const void *new_key)
{
- Eina_Free_Cb hash_free_cb;
- const void *data;
- Eina_Bool result = EINA_FALSE;
+ Eina_Free_Cb hash_free_cb;
+ const void *data;
+ Eina_Bool result = EINA_FALSE;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(old_key, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(new_key, EINA_FALSE);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(old_key, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(new_key, EINA_FALSE);
+ EINA_MAGIC_CHECK_HASH(hash);
- data = eina_hash_find(hash, old_key);
- if (!data) goto error;
+ data = eina_hash_find(hash, old_key);
+ if (!data)
+ goto error;
- hash_free_cb = hash->data_free_cb;
- hash->data_free_cb = NULL;
+ hash_free_cb = hash->data_free_cb;
+ hash->data_free_cb = NULL;
- eina_hash_del(hash, old_key, data);
- result = eina_hash_add(hash, new_key, data);
+ eina_hash_del(hash, old_key, data);
+ result = eina_hash_add(hash, new_key, data);
- hash->data_free_cb = hash_free_cb;
+ hash->data_free_cb = hash_free_cb;
-error:
- return result;
+ error:
+ return result;
}
/*============================================================================*
@@ -1694,26 +1671,26 @@ error:
* @endcode
*/
EAPI void
-eina_hash_foreach(const Eina_Hash *hash,
- Eina_Hash_Foreach func,
- const void *fdata)
+eina_hash_foreach(const Eina_Hash * hash,
+ Eina_Hash_Foreach func, const void *fdata)
{
- Eina_Iterator *it;
- Eina_Hash_Foreach_Data foreach;
+ Eina_Iterator *it;
+ Eina_Hash_Foreach_Data foreach;
- EINA_MAGIC_CHECK_HASH(hash);
- EINA_SAFETY_ON_NULL_RETURN(hash);
- EINA_SAFETY_ON_NULL_RETURN(func);
+ EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN(hash);
+ EINA_SAFETY_ON_NULL_RETURN(func);
- foreach.cb = func;
- foreach.fdata = fdata;
+ foreach.cb = func;
+ foreach.fdata = fdata;
- it = eina_hash_iterator_tuple_new(hash);
- if (!it)
- return;
- eina_iterator_foreach(it, EINA_EACH_CB(_eina_foreach_cb), &foreach);
+ it = eina_hash_iterator_tuple_new(hash);
+ if (!it)
+ return;
+ eina_iterator_foreach(it, EINA_EACH_CB(_eina_foreach_cb),
+ &foreach);
- eina_iterator_free(it);
+ eina_iterator_free(it);
}
/**
@@ -1735,35 +1712,35 @@ eina_hash_foreach(const Eina_Hash *hash,
* invalid. That is, if you add or remove items this iterator behavior
* is undefined and your program may crash.
*/
-EAPI Eina_Iterator *
-eina_hash_iterator_data_new(const Eina_Hash *hash)
+EAPI Eina_Iterator *eina_hash_iterator_data_new(const Eina_Hash * hash)
{
- Eina_Iterator_Hash *it;
+ Eina_Iterator_Hash *it;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_Hash));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_Hash));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- it->hash = hash;
- it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_data_get_content);
+ it->hash = hash;
+ it->get_content =
+ FUNC_ITERATOR_GET_CONTENT
+ (_eina_hash_iterator_data_get_content);
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_hash_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
- return &it->iterator;
+ return &it->iterator;
}
/**
@@ -1785,36 +1762,34 @@ eina_hash_iterator_data_new(const Eina_Hash *hash)
* invalid! That is, if you add or remove items this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_hash_iterator_key_new(const Eina_Hash *hash)
+EAPI Eina_Iterator *eina_hash_iterator_key_new(const Eina_Hash * hash)
{
- Eina_Iterator_Hash *it;
+ Eina_Iterator_Hash *it;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_Hash));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_Hash));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- it->hash = hash;
- it->get_content = FUNC_ITERATOR_GET_CONTENT(
- _eina_hash_iterator_key_get_content);
+ it->hash = hash;
+ it->get_content =
+ FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_key_get_content);
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_hash_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
- return &it->iterator;
+ return &it->iterator;
}
/**
@@ -1839,92 +1814,88 @@ eina_hash_iterator_key_new(const Eina_Hash *hash)
* invalid! That is, if you add or remove items this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_hash_iterator_tuple_new(const Eina_Hash *hash)
+EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash * hash)
{
- Eina_Iterator_Hash *it;
+ Eina_Iterator_Hash *it;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
- EINA_MAGIC_CHECK_HASH(hash);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+ EINA_MAGIC_CHECK_HASH(hash);
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_Hash));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_Hash));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- it->hash = hash;
- it->get_content = FUNC_ITERATOR_GET_CONTENT(
- _eina_hash_iterator_tuple_get_content);
+ it->hash = hash;
+ it->get_content =
+ FUNC_ITERATOR_GET_CONTENT
+ (_eina_hash_iterator_tuple_get_content);
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_hash_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
- return &it->iterator;
+ return &it->iterator;
}
/* Common hash functions */
/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html)
used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
-EAPI int
-eina_hash_superfast(const char *key, int len)
-{
- int hash = len, tmp;
- int rem;
-
- rem = len & 3;
- len >>= 2;
-
- /* Main loop */
- for (; len > 0; len--)
- {
- hash += get16bits(key);
- tmp = (get16bits(key + 2) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- key += 2 * sizeof (uint16_t);
- hash += hash >> 11;
- }
-
- /* Handle end cases */
- switch (rem)
- {
- case 3:
- hash += get16bits(key);
- hash ^= hash << 16;
- hash ^= key[sizeof (uint16_t)] << 18;
- hash += hash >> 11;
- break;
-
- case 2:
- hash += get16bits(key);
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
-
- case 1:
- hash += *key;
- hash ^= hash << 10;
- hash += hash >> 1;
- }
-
- /* Force "avalanching" of final 127 bits */
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 4;
- hash += hash >> 17;
- hash ^= hash << 25;
- hash += hash >> 6;
-
- return hash;
+EAPI int eina_hash_superfast(const char *key, int len)
+{
+ int hash = len, tmp;
+ int rem;
+
+ rem = len & 3;
+ len >>= 2;
+
+ /* Main loop */
+ for (; len > 0; len--) {
+ hash += get16bits(key);
+ tmp = (get16bits(key + 2) << 11) ^ hash;
+ hash = (hash << 16) ^ tmp;
+ key += 2 * sizeof(uint16_t);
+ hash += hash >> 11;
+ }
+
+ /* Handle end cases */
+ switch (rem) {
+ case 3:
+ hash += get16bits(key);
+ hash ^= hash << 16;
+ hash ^= key[sizeof(uint16_t)] << 18;
+ hash += hash >> 11;
+ break;
+
+ case 2:
+ hash += get16bits(key);
+ hash ^= hash << 11;
+ hash += hash >> 17;
+ break;
+
+ case 1:
+ hash += *key;
+ hash ^= hash << 10;
+ hash += hash >> 1;
+ }
+
+ /* Force "avalanching" of final 127 bits */
+ hash ^= hash << 3;
+ hash += hash >> 5;
+ hash ^= hash << 4;
+ hash += hash >> 17;
+ hash ^= hash << 25;
+ hash += hash >> 6;
+
+ return hash;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_inlist.c b/tests/suite/ecore/src/lib/eina_inlist.c
index 9ebc6233c4..a8f65ce624 100644
--- a/tests/suite/ecore/src/lib/eina_inlist.c
+++ b/tests/suite/ecore/src/lib/eina_inlist.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -44,100 +44,94 @@
typedef struct _Eina_Iterator_Inlist Eina_Iterator_Inlist;
typedef struct _Eina_Accessor_Inlist Eina_Accessor_Inlist;
-struct _Eina_Iterator_Inlist
-{
- Eina_Iterator iterator;
- const Eina_Inlist *head;
- const Eina_Inlist *current;
+struct _Eina_Iterator_Inlist {
+ Eina_Iterator iterator;
+ const Eina_Inlist *head;
+ const Eina_Inlist *current;
};
-struct _Eina_Accessor_Inlist
-{
- Eina_Accessor accessor;
+struct _Eina_Accessor_Inlist {
+ Eina_Accessor accessor;
- const Eina_Inlist *head;
- const Eina_Inlist *current;
+ const Eina_Inlist *head;
+ const Eina_Inlist *current;
- unsigned int index;
+ unsigned int index;
};
static Eina_Bool
-eina_inlist_iterator_next(Eina_Iterator_Inlist *it, void **data) {
- if (!it->current)
- return EINA_FALSE;
+eina_inlist_iterator_next(Eina_Iterator_Inlist * it, void **data)
+{
+ if (!it->current)
+ return EINA_FALSE;
- if (data)
- *data = (void *)it->current;
+ if (data)
+ *data = (void *) it->current;
- it->current = it->current->next;
+ it->current = it->current->next;
- return EINA_TRUE;
+ return EINA_TRUE;
}
-static Eina_Inlist *
-eina_inlist_iterator_get_container(Eina_Iterator_Inlist *it) {
- return (Eina_Inlist *)it->head;
+static Eina_Inlist *eina_inlist_iterator_get_container(Eina_Iterator_Inlist
+ * it)
+{
+ return (Eina_Inlist *) it->head;
}
-static void
-eina_inlist_iterator_free(Eina_Iterator_Inlist *it) {
- free(it);
+static void eina_inlist_iterator_free(Eina_Iterator_Inlist * it)
+{
+ free(it);
}
static Eina_Bool
-eina_inlist_accessor_get_at(Eina_Accessor_Inlist *it,
- unsigned int idx,
- void **data) {
- const Eina_Inlist *over;
- unsigned int middle;
- unsigned int i;
-
- if (it->index == idx)
- over = it->current;
- else if (idx > it->index)
- /* Looking after current. */
- for (i = it->index, over = it->current;
- i < idx && over;
- ++i, over = over->next)
- ;
- else
- {
- middle = it->index >> 1;
-
- if (idx > middle)
- /* Looking backward from current. */
- for (i = it->index, over = it->current;
- i > idx && over;
- --i, over = over->prev)
- ;
- else
- /* Looking from the start. */
- for (i = 0, over = it->head;
- i < idx && over;
- ++i, over = over->next)
- ;
- }
-
- if (!over)
- return EINA_FALSE;
-
- it->current = over;
- it->index = idx;
-
- if (data)
- *data = (void *)over;
-
- return EINA_TRUE;
+eina_inlist_accessor_get_at(Eina_Accessor_Inlist * it,
+ unsigned int idx, void **data)
+{
+ const Eina_Inlist *over;
+ unsigned int middle;
+ unsigned int i;
+
+ if (it->index == idx)
+ over = it->current;
+ else if (idx > it->index)
+ /* Looking after current. */
+ for (i = it->index, over = it->current;
+ i < idx && over; ++i, over = over->next);
+ else {
+ middle = it->index >> 1;
+
+ if (idx > middle)
+ /* Looking backward from current. */
+ for (i = it->index, over = it->current;
+ i > idx && over; --i, over = over->prev);
+ else
+ /* Looking from the start. */
+ for (i = 0, over = it->head;
+ i < idx && over; ++i, over = over->next);
+ }
+
+ if (!over)
+ return EINA_FALSE;
+
+ it->current = over;
+ it->index = idx;
+
+ if (data)
+ *data = (void *) over;
+
+ return EINA_TRUE;
}
-static Eina_Inlist *
-eina_inlist_accessor_get_container(Eina_Accessor_Inlist *it) {
- return (Eina_Inlist *)it->head;
+static Eina_Inlist *eina_inlist_accessor_get_container(Eina_Accessor_Inlist
+ * it)
+{
+ return (Eina_Inlist *) it->head;
}
-static void
-eina_inlist_accessor_free(Eina_Accessor_Inlist *it) {
- free(it);
+static void eina_inlist_accessor_free(Eina_Accessor_Inlist * it)
+{
+ free(it);
}
/**
@@ -243,31 +237,29 @@ eina_inlist_accessor_free(Eina_Accessor_Inlist *it) {
*
* @return the new list head. Use it and not given @a list anymore.
*/
-EAPI Eina_Inlist *
-eina_inlist_append(Eina_Inlist *list, Eina_Inlist *new_l)
+EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist * list,
+ Eina_Inlist * new_l)
{
- Eina_Inlist *l;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
-
- new_l->next = NULL;
- if (!list)
- {
- new_l->prev = NULL;
- new_l->last = new_l;
- return new_l;
- }
-
- if (list->last)
- l = list->last;
- else
- for (l = list; (l) && (l->next); l = l->next)
- ;
-
- l->next = new_l;
- new_l->prev = l;
- list->last = new_l;
- return list;
+ Eina_Inlist *l;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
+
+ new_l->next = NULL;
+ if (!list) {
+ new_l->prev = NULL;
+ new_l->last = new_l;
+ return new_l;
+ }
+
+ if (list->last)
+ l = list->last;
+ else
+ for (l = list; (l) && (l->next); l = l->next);
+
+ l->next = new_l;
+ new_l->prev = l;
+ list->last = new_l;
+ return list;
}
/**
@@ -286,24 +278,23 @@ eina_inlist_append(Eina_Inlist *list, Eina_Inlist *new_l)
*
* @return the new list head. Use it and not given @a list anymore.
*/
-EAPI Eina_Inlist *
-eina_inlist_prepend(Eina_Inlist *list, Eina_Inlist *new_l)
+EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist * list,
+ Eina_Inlist * new_l)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
-
- new_l->prev = NULL;
- if (!list)
- {
- new_l->next = NULL;
- new_l->last = new_l;
- return new_l;
- }
-
- new_l->next = list;
- list->prev = new_l;
- new_l->last = list->last;
- list->last = NULL;
- return new_l;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
+
+ new_l->prev = NULL;
+ if (!list) {
+ new_l->next = NULL;
+ new_l->last = new_l;
+ return new_l;
+ }
+
+ new_l->next = list;
+ list->prev = new_l;
+ new_l->last = list->last;
+ list->last = NULL;
+ return new_l;
}
/**
@@ -328,32 +319,28 @@ eina_inlist_prepend(Eina_Inlist *list, Eina_Inlist *new_l)
*
* @return the new list head. Use it and not given @a list anymore.
*/
-EAPI Eina_Inlist *
-eina_inlist_append_relative(Eina_Inlist *list,
- Eina_Inlist *new_l,
- Eina_Inlist *relative)
+EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist * list,
+ Eina_Inlist * new_l,
+ Eina_Inlist * relative)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
-
- if (relative)
- {
- if (relative->next)
- {
- new_l->next = relative->next;
- relative->next->prev = new_l;
- }
- else
- new_l->next = NULL;
-
- relative->next = new_l;
- new_l->prev = relative;
- if (!new_l->next)
- list->last = new_l;
-
- return list;
- }
-
- return eina_inlist_append(list, new_l);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
+
+ if (relative) {
+ if (relative->next) {
+ new_l->next = relative->next;
+ relative->next->prev = new_l;
+ } else
+ new_l->next = NULL;
+
+ relative->next = new_l;
+ new_l->prev = relative;
+ if (!new_l->next)
+ list->last = new_l;
+
+ return list;
+ }
+
+ return eina_inlist_append(list, new_l);
}
/**
@@ -378,37 +365,32 @@ eina_inlist_append_relative(Eina_Inlist *list,
*
* @return the new list head. Use it and not given @a list anymore.
*/
-EAPI Eina_Inlist *
-eina_inlist_prepend_relative(Eina_Inlist *list,
- Eina_Inlist *new_l,
- Eina_Inlist *relative)
+EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist * list,
+ Eina_Inlist * new_l,
+ Eina_Inlist * relative)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
-
- if (relative)
- {
- new_l->prev = relative->prev;
- new_l->next = relative;
- relative->prev = new_l;
- if (new_l->prev)
- {
- new_l->prev->next = new_l;
- /* new_l->next could not be NULL, as it was set to 'relative' */
- assert(new_l->next);
- return list;
- }
- else
- {
- /* new_l->next could not be NULL, as it was set to 'relative' */
- assert(new_l->next);
-
- new_l->last = list->last;
- list->last = NULL;
- return new_l;
- }
- }
-
- return eina_inlist_prepend(list, new_l);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
+
+ if (relative) {
+ new_l->prev = relative->prev;
+ new_l->next = relative;
+ relative->prev = new_l;
+ if (new_l->prev) {
+ new_l->prev->next = new_l;
+ /* new_l->next could not be NULL, as it was set to 'relative' */
+ assert(new_l->next);
+ return list;
+ } else {
+ /* new_l->next could not be NULL, as it was set to 'relative' */
+ assert(new_l->next);
+
+ new_l->last = list->last;
+ list->last = NULL;
+ return new_l;
+ }
+ }
+
+ return eina_inlist_prepend(list, new_l);
}
/**
@@ -428,38 +410,35 @@ eina_inlist_prepend_relative(Eina_Inlist *list,
*
* @return the new list head. Use it and not given @a list anymore.
*/
-EAPI Eina_Inlist *
-eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item)
+EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist * list,
+ Eina_Inlist * item)
{
- Eina_Inlist *return_l;
-
- /* checkme */
- EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
- EINA_SAFETY_ON_TRUE_RETURN_VAL
- ((item != list) && (!item->prev) && (!item->next), list);
-
- if (item->next)
- item->next->prev = item->prev;
-
- if (item->prev)
- {
- item->prev->next = item->next;
- return_l = list;
- }
- else
- {
- return_l = item->next;
- if (return_l)
- return_l->last = list->last;
- }
-
- if (item == list->last)
- list->last = item->prev;
-
- item->next = NULL;
- item->prev = NULL;
- return return_l;
+ Eina_Inlist *return_l;
+
+ /* checkme */
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL
+ ((item != list) && (!item->prev) && (!item->next), list);
+
+ if (item->next)
+ item->next->prev = item->prev;
+
+ if (item->prev) {
+ item->prev->next = item->next;
+ return_l = list;
+ } else {
+ return_l = item->next;
+ if (return_l)
+ return_l->last = list->last;
+ }
+
+ if (item == list->last)
+ list->last = item->prev;
+
+ item->next = NULL;
+ item->prev = NULL;
+ return return_l;
}
/**
@@ -477,31 +456,31 @@ eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item)
*
* @return the new list head. Use it and not given @a list anymore.
*/
-EAPI Eina_Inlist *
-eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item)
+EAPI Eina_Inlist *eina_inlist_promote(Eina_Inlist * list,
+ Eina_Inlist * item)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
- if (item == list)
- return list;
+ if (item == list)
+ return list;
- if (item->next)
- item->next->prev = item->prev;
+ if (item->next)
+ item->next->prev = item->prev;
- item->prev->next = item->next;
+ item->prev->next = item->next;
- if (list->last == item)
- list->last = item->prev;
+ if (list->last == item)
+ list->last = item->prev;
- item->next = list;
- item->prev = NULL;
- item->last = list->last;
+ item->next = list;
+ item->prev = NULL;
+ item->last = list->last;
- list->prev = item;
- list->last = NULL;
+ list->prev = item;
+ list->last = NULL;
- return item;
+ return item;
}
/**
@@ -519,38 +498,36 @@ eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item)
*
* @return the new list head. Use it and not given @a list anymore.
*/
-EAPI Eina_Inlist *
-eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item)
+EAPI Eina_Inlist *eina_inlist_demote(Eina_Inlist * list,
+ Eina_Inlist * item)
{
- Eina_Inlist *l;
+ Eina_Inlist *l;
- EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
- if (list->last == item)
- return list;
+ if (list->last == item)
+ return list;
- if (!list->last)
- {
- for (l = list; l->next; l = l->next)
- ;
- list->last = l;
- }
+ if (!list->last) {
+ for (l = list; l->next; l = l->next);
+ list->last = l;
+ }
- l = list;
- if (item->prev)
- item->prev->next = item->next;
- else
- l = item->next;
+ l = list;
+ if (item->prev)
+ item->prev->next = item->next;
+ else
+ l = item->next;
- item->next->prev = item->prev;
+ item->next->prev = item->prev;
- list->last->next = item;
- item->prev = list->last;
- item->next = NULL;
+ list->last->next = item;
+ item->prev = list->last;
+ item->next = NULL;
- l->last = item;
- return l;
+ l->last = item;
+ return l;
}
/**
@@ -564,16 +541,15 @@ eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item)
*
* @return @a item if found, NULL if not.
*/
-EAPI Eina_Inlist *
-eina_inlist_find(Eina_Inlist *list, Eina_Inlist *item)
+EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist * list, Eina_Inlist * item)
{
- Eina_Inlist *l;
+ Eina_Inlist *l;
- for (l = list; l; l = l->next) {
- if (l == item)
- return item;
- }
- return NULL;
+ for (l = list; l; l = l->next) {
+ if (l == item)
+ return item;
+ }
+ return NULL;
}
/**
@@ -589,16 +565,15 @@ eina_inlist_find(Eina_Inlist *list, Eina_Inlist *item)
* on the number of elements on the list, that is, it might become
* slow for big lists!
*/
-EAPI unsigned int
-eina_inlist_count(const Eina_Inlist *list)
+EAPI unsigned int eina_inlist_count(const Eina_Inlist * list)
{
- const Eina_Inlist *l;
- unsigned int i = 0;
+ const Eina_Inlist *l;
+ unsigned int i = 0;
- for (l = list; l; l = l->next)
- i++;
+ for (l = list; l; l = l->next)
+ i++;
- return i;
+ return i;
}
/**
@@ -621,31 +596,30 @@ eina_inlist_count(const Eina_Inlist *list)
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_inlist_iterator_new(const Eina_Inlist *list)
+EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist * list)
{
- Eina_Iterator_Inlist *it;
+ Eina_Iterator_Inlist *it;
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_Inlist));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_Inlist));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- it->head = list;
- it->current = list;
+ it->head = list;
+ it->current = list;
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- eina_inlist_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(eina_inlist_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER
+ (eina_inlist_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(eina_inlist_iterator_free);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- return &it->iterator;
+ return &it->iterator;
}
/**
@@ -660,32 +634,32 @@ eina_inlist_iterator_new(const Eina_Inlist *list)
* not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
* set. Otherwise, a valid accessor is returned.
*/
-EAPI Eina_Accessor *
-eina_inlist_accessor_new(const Eina_Inlist *list)
+EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist * list)
{
- Eina_Accessor_Inlist *ac;
-
- eina_error_set(0);
- ac = calloc(1, sizeof (Eina_Accessor_Inlist));
- if (!ac)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- ac->head = list;
- ac->current = list;
- ac->index = 0;
-
- ac->accessor.version = EINA_ACCESSOR_VERSION;
- ac->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at);
- ac->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
- eina_inlist_accessor_get_container);
- ac->accessor.free = FUNC_ACCESSOR_FREE(eina_inlist_accessor_free);
-
- EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
-
- return &ac->accessor;
+ Eina_Accessor_Inlist *ac;
+
+ eina_error_set(0);
+ ac = calloc(1, sizeof(Eina_Accessor_Inlist));
+ if (!ac) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ ac->head = list;
+ ac->current = list;
+ ac->index = 0;
+
+ ac->accessor.version = EINA_ACCESSOR_VERSION;
+ ac->accessor.get_at =
+ FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at);
+ ac->accessor.get_container =
+ FUNC_ACCESSOR_GET_CONTAINER
+ (eina_inlist_accessor_get_container);
+ ac->accessor.free = FUNC_ACCESSOR_FREE(eina_inlist_accessor_free);
+
+ EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
+
+ return &ac->accessor;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_iterator.c b/tests/suite/ecore/src/lib/eina_iterator.c
index 66dbbf4ee7..7389319519 100644
--- a/tests/suite/ecore/src/lib/eina_iterator.c
+++ b/tests/suite/ecore/src/lib/eina_iterator.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -65,10 +65,10 @@ static const char EINA_MAGIC_ITERATOR_STR[] = "Eina Iterator";
*
* @see eina_init()
*/
-Eina_Bool
-eina_iterator_init(void)
+Eina_Bool eina_iterator_init(void)
{
- return eina_magic_string_set(EINA_MAGIC_ITERATOR, EINA_MAGIC_ITERATOR_STR);
+ return eina_magic_string_set(EINA_MAGIC_ITERATOR,
+ EINA_MAGIC_ITERATOR_STR);
}
/**
@@ -82,10 +82,9 @@ eina_iterator_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_iterator_shutdown(void)
+Eina_Bool eina_iterator_shutdown(void)
{
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -119,13 +118,12 @@ eina_iterator_shutdown(void)
*
* This function frees @p iterator if it is not @c NULL;
*/
-EAPI void
-eina_iterator_free(Eina_Iterator *iterator)
+EAPI void eina_iterator_free(Eina_Iterator * iterator)
{
- EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN(iterator);
- EINA_SAFETY_ON_NULL_RETURN(iterator->free);
- iterator->free(iterator);
+ EINA_MAGIC_CHECK_ITERATOR(iterator);
+ EINA_SAFETY_ON_NULL_RETURN(iterator);
+ EINA_SAFETY_ON_NULL_RETURN(iterator->free);
+ iterator->free(iterator);
}
/**
@@ -137,13 +135,12 @@ eina_iterator_free(Eina_Iterator *iterator)
* This function returns the container which created @p iterator. If
* @p iterator is @c NULL, this function returns @c NULL.
*/
-EAPI void *
-eina_iterator_container_get(Eina_Iterator *iterator)
+EAPI void *eina_iterator_container_get(Eina_Iterator * iterator)
{
- EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->get_container, NULL);
- return iterator->get_container(iterator);
+ EINA_MAGIC_CHECK_ITERATOR(iterator);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->get_container, NULL);
+ return iterator->get_container(iterator);
}
/**
@@ -158,17 +155,16 @@ eina_iterator_container_get(Eina_Iterator *iterator)
* iterator is @c NULL or if a problem occurred, #EINA_FALSE is
* returned, otherwise #EINA_TRUE is returned.
*/
-EAPI Eina_Bool
-eina_iterator_next(Eina_Iterator *iterator, void **data)
+EAPI Eina_Bool eina_iterator_next(Eina_Iterator * iterator, void **data)
{
- if (!iterator)
- return EINA_FALSE;
-
- EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->next, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
- return iterator->next(iterator, data);
+ if (!iterator)
+ return EINA_FALSE;
+
+ EINA_MAGIC_CHECK_ITERATOR(iterator);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->next, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+ return iterator->next(iterator, data);
}
/**
@@ -185,29 +181,29 @@ eina_iterator_next(Eina_Iterator *iterator, void **data)
* EINA_FALSE, the iteration stops at that point.
*/
EAPI void
-eina_iterator_foreach(Eina_Iterator *iterator,
- Eina_Each_Cb cb,
- const void *fdata)
+eina_iterator_foreach(Eina_Iterator * iterator,
+ Eina_Each_Cb cb, const void *fdata)
{
- const void *container;
- void *data;
-
- EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN(iterator);
- EINA_SAFETY_ON_NULL_RETURN(iterator->get_container);
- EINA_SAFETY_ON_NULL_RETURN(iterator->next);
- EINA_SAFETY_ON_NULL_RETURN(cb);
-
- if (!eina_iterator_lock(iterator)) return ;
-
- container = iterator->get_container(iterator);
- while (iterator->next(iterator, &data) == EINA_TRUE) {
- if (cb(container, data, (void *)fdata) != EINA_TRUE)
- goto on_exit;
- }
-
- on_exit:
- (void) eina_iterator_unlock(iterator);
+ const void *container;
+ void *data;
+
+ EINA_MAGIC_CHECK_ITERATOR(iterator);
+ EINA_SAFETY_ON_NULL_RETURN(iterator);
+ EINA_SAFETY_ON_NULL_RETURN(iterator->get_container);
+ EINA_SAFETY_ON_NULL_RETURN(iterator->next);
+ EINA_SAFETY_ON_NULL_RETURN(cb);
+
+ if (!eina_iterator_lock(iterator))
+ return;
+
+ container = iterator->get_container(iterator);
+ while (iterator->next(iterator, &data) == EINA_TRUE) {
+ if (cb(container, data, (void *) fdata) != EINA_TRUE)
+ goto on_exit;
+ }
+
+ on_exit:
+ (void) eina_iterator_unlock(iterator);
}
/**
@@ -221,15 +217,14 @@ eina_iterator_foreach(Eina_Iterator *iterator,
* returned, otherwise #EINA_TRUE is returned. If the container
* is not lockable, it will return EINA_TRUE.
*/
-EAPI Eina_Bool
-eina_iterator_lock(Eina_Iterator *iterator)
+EAPI Eina_Bool eina_iterator_lock(Eina_Iterator * iterator)
{
- EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
+ EINA_MAGIC_CHECK_ITERATOR(iterator);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
- if (iterator->lock)
- return iterator->lock(iterator);
- return EINA_TRUE;
+ if (iterator->lock)
+ return iterator->lock(iterator);
+ return EINA_TRUE;
}
/**
@@ -244,15 +239,14 @@ eina_iterator_lock(Eina_Iterator *iterator)
* is returned. If the container is not lockable, it will return
* EINA_TRUE.
*/
-EAPI Eina_Bool
-eina_iterator_unlock(Eina_Iterator *iterator)
+EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator * iterator)
{
- EINA_MAGIC_CHECK_ITERATOR(iterator);
- EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
+ EINA_MAGIC_CHECK_ITERATOR(iterator);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
- if (iterator->unlock)
- return iterator->unlock(iterator);
- return EINA_TRUE;
+ if (iterator->unlock)
+ return iterator->unlock(iterator);
+ return EINA_TRUE;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_lalloc.c b/tests/suite/ecore/src/lib/eina_lalloc.c
index b1e62b7420..a902d7623d 100644
--- a/tests/suite/ecore/src/lib/eina_lalloc.c
+++ b/tests/suite/ecore/src/lib/eina_lalloc.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -37,14 +37,13 @@
* @cond LOCAL
*/
-struct _Eina_Lalloc
-{
- void *data;
- int num_allocated;
- int num_elements;
- int acc;
- Eina_Lalloc_Alloc alloc_cb;
- Eina_Lalloc_Free free_cb;
+struct _Eina_Lalloc {
+ void *data;
+ int num_allocated;
+ int num_elements;
+ int acc;
+ Eina_Lalloc_Alloc alloc_cb;
+ Eina_Lalloc_Free free_cb;
};
/**
@@ -66,91 +65,82 @@ struct _Eina_Lalloc
*/
EAPI Eina_Lalloc *eina_lalloc_new(void *data,
- Eina_Lalloc_Alloc alloc_cb,
- Eina_Lalloc_Free free_cb,
- int num_init)
+ Eina_Lalloc_Alloc alloc_cb,
+ Eina_Lalloc_Free free_cb, int num_init)
{
- Eina_Lalloc *a;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_cb, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(free_cb, NULL);
-
- a = calloc(1, sizeof(Eina_Lalloc));
- a->data = data;
- a->alloc_cb = alloc_cb;
- a->free_cb = free_cb;
- if (num_init > 0)
- {
- a->num_allocated = num_init;
- a->alloc_cb(a->data, a->num_allocated);
- }
-
- return a;
+ Eina_Lalloc *a;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_cb, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(free_cb, NULL);
+
+ a = calloc(1, sizeof(Eina_Lalloc));
+ a->data = data;
+ a->alloc_cb = alloc_cb;
+ a->free_cb = free_cb;
+ if (num_init > 0) {
+ a->num_allocated = num_init;
+ a->alloc_cb(a->data, a->num_allocated);
+ }
+
+ return a;
}
-EAPI void eina_lalloc_free(Eina_Lalloc *a)
+EAPI void eina_lalloc_free(Eina_Lalloc * a)
{
- EINA_SAFETY_ON_NULL_RETURN(a);
- EINA_SAFETY_ON_NULL_RETURN(a->free_cb);
- a->free_cb(a->data);
- free(a);
+ EINA_SAFETY_ON_NULL_RETURN(a);
+ EINA_SAFETY_ON_NULL_RETURN(a->free_cb);
+ a->free_cb(a->data);
+ free(a);
}
-EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a)
+EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc * a)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
-
- if (a->num_elements == a->num_allocated)
- {
- if (a->alloc_cb(a->data, (1 << a->acc)) == EINA_TRUE)
- {
- a->num_allocated = (1 << a->acc);
- a->acc++;
- }
- else
- return EINA_FALSE;
- }
-
- a->num_elements++;
-
- return EINA_TRUE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
+
+ if (a->num_elements == a->num_allocated) {
+ if (a->alloc_cb(a->data, (1 << a->acc)) == EINA_TRUE) {
+ a->num_allocated = (1 << a->acc);
+ a->acc++;
+ } else
+ return EINA_FALSE;
+ }
+
+ a->num_elements++;
+
+ return EINA_TRUE;
}
-EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, int num)
+EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc * a, int num)
{
- int tmp;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
-
- tmp = a->num_elements + num;
- if (tmp > a->num_allocated)
- {
- int allocated;
- int acc;
-
- allocated = a->num_allocated;
- acc = a->acc;
-
- while (tmp > allocated)
- {
- allocated = (1 << acc);
- acc++;
- }
-
- if (a->alloc_cb(a->data, allocated) == EINA_TRUE)
- {
- a->num_allocated = allocated;
- a->acc = acc;
- }
- else
- return EINA_FALSE;
- }
-
- a->num_elements += num;
-
- return EINA_TRUE;
+ int tmp;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
+
+ tmp = a->num_elements + num;
+ if (tmp > a->num_allocated) {
+ int allocated;
+ int acc;
+
+ allocated = a->num_allocated;
+ acc = a->acc;
+
+ while (tmp > allocated) {
+ allocated = (1 << acc);
+ acc++;
+ }
+
+ if (a->alloc_cb(a->data, allocated) == EINA_TRUE) {
+ a->num_allocated = allocated;
+ a->acc = acc;
+ } else
+ return EINA_FALSE;
+ }
+
+ a->num_elements += num;
+
+ return EINA_TRUE;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_list.c b/tests/suite/ecore/src/lib/eina_list.c
index e301476f27..b8901c6644 100644
--- a/tests/suite/ecore/src/lib/eina_list.c
+++ b/tests/suite/ecore/src/lib/eina_list.c
@@ -61,7 +61,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -69,7 +69,7 @@
#include <string.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -94,7 +94,8 @@
static const char EINA_MAGIC_LIST_STR[] = "Eina List";
static const char EINA_MAGIC_LIST_ITERATOR_STR[] = "Eina List Iterator";
static const char EINA_MAGIC_LIST_ACCESSOR_STR[] = "Eina List Accessor";
-static const char EINA_MAGIC_LIST_ACCOUNTING_STR[] = "Eina List Accounting";
+static const char EINA_MAGIC_LIST_ACCOUNTING_STR[] =
+ "Eina List Accounting";
#define EINA_MAGIC_CHECK_LIST(d, ...) \
@@ -138,27 +139,23 @@ static const char EINA_MAGIC_LIST_ACCOUNTING_STR[] = "Eina List Accounting";
typedef struct _Eina_Iterator_List Eina_Iterator_List;
typedef struct _Eina_Accessor_List Eina_Accessor_List;
-struct _Eina_Iterator_List
-{
- Eina_Iterator iterator;
+struct _Eina_Iterator_List {
+ Eina_Iterator iterator;
- const Eina_List *head;
- const Eina_List *current;
+ const Eina_List *head;
+ const Eina_List *current;
- EINA_MAGIC
-};
+ EINA_MAGIC};
-struct _Eina_Accessor_List
-{
- Eina_Accessor accessor;
+struct _Eina_Accessor_List {
+ Eina_Accessor accessor;
- const Eina_List *head;
- const Eina_List *current;
+ const Eina_List *head;
+ const Eina_List *current;
- unsigned int index;
+ unsigned int index;
- EINA_MAGIC
-};
+ EINA_MAGIC};
static Eina_Mempool *_eina_list_mp = NULL;
static Eina_Mempool *_eina_list_accounting_mp = NULL;
@@ -174,259 +171,248 @@ static int _eina_list_log_dom = -1;
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eina_list_log_dom, __VA_ARGS__)
-static inline Eina_List_Accounting *
-_eina_list_mempool_accounting_new(__UNUSED__ Eina_List *list)
+static inline Eina_List_Accounting
+ *_eina_list_mempool_accounting_new(__UNUSED__ Eina_List * list)
{
- Eina_List_Accounting *tmp;
+ Eina_List_Accounting *tmp;
- tmp =
- eina_mempool_malloc(_eina_list_accounting_mp,
- sizeof (Eina_List_Accounting));
- if (!tmp)
- return NULL;
+ tmp =
+ eina_mempool_malloc(_eina_list_accounting_mp,
+ sizeof(Eina_List_Accounting));
+ if (!tmp)
+ return NULL;
- EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST_ACCOUNTING);
+ EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST_ACCOUNTING);
- return tmp;
+ return tmp;
}
+
static inline void
-_eina_list_mempool_accounting_free(Eina_List_Accounting *accounting)
+_eina_list_mempool_accounting_free(Eina_List_Accounting * accounting)
{
- EINA_MAGIC_CHECK_LIST_ACCOUNTING(accounting);
+ EINA_MAGIC_CHECK_LIST_ACCOUNTING(accounting);
- EINA_MAGIC_SET(accounting, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_list_accounting_mp, accounting);
+ EINA_MAGIC_SET(accounting, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_list_accounting_mp, accounting);
}
-static inline Eina_List *
-_eina_list_mempool_list_new(__UNUSED__ Eina_List *list)
+static inline Eina_List *_eina_list_mempool_list_new(__UNUSED__ Eina_List *
+ list)
{
- Eina_List *tmp;
+ Eina_List *tmp;
- tmp = eina_mempool_malloc(_eina_list_mp, sizeof (Eina_List));
- if (!tmp)
- return NULL;
+ tmp = eina_mempool_malloc(_eina_list_mp, sizeof(Eina_List));
+ if (!tmp)
+ return NULL;
- EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST);
+ EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST);
- return tmp;
+ return tmp;
}
-static inline void
-_eina_list_mempool_list_free(Eina_List *list)
+
+static inline void _eina_list_mempool_list_free(Eina_List * list)
{
- EINA_MAGIC_CHECK_LIST(list);
+ EINA_MAGIC_CHECK_LIST(list);
- list->accounting->count--;
- if (list->accounting->count == 0)
- _eina_list_mempool_accounting_free(list->accounting);
+ list->accounting->count--;
+ if (list->accounting->count == 0)
+ _eina_list_mempool_accounting_free(list->accounting);
- EINA_MAGIC_SET(list, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_list_mp, list);
+ EINA_MAGIC_SET(list, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_list_mp, list);
}
-static Eina_List *
-_eina_list_setup_accounting(Eina_List *list)
+static Eina_List *_eina_list_setup_accounting(Eina_List * list)
{
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- list->accounting = _eina_list_mempool_accounting_new(list);
- if (!list->accounting)
- goto on_error;
+ list->accounting = _eina_list_mempool_accounting_new(list);
+ if (!list->accounting)
+ goto on_error;
- list->accounting->last = list;
- list->accounting->count = 1;
+ list->accounting->last = list;
+ list->accounting->count = 1;
- return list;
+ return list;
-on_error:
- _eina_list_mempool_list_free(list);
- return NULL;
+ on_error:
+ _eina_list_mempool_list_free(list);
+ return NULL;
}
static inline void
-_eina_list_update_accounting(Eina_List *list, Eina_List *new_list)
+_eina_list_update_accounting(Eina_List * list, Eina_List * new_list)
{
- EINA_MAGIC_CHECK_LIST(list);
- EINA_MAGIC_CHECK_LIST(new_list);
+ EINA_MAGIC_CHECK_LIST(list);
+ EINA_MAGIC_CHECK_LIST(new_list);
- list->accounting->count++;
- new_list->accounting = list->accounting;
+ list->accounting->count++;
+ new_list->accounting = list->accounting;
}
#if 0
-static Eina_Mempool2 _eina_list_mempool =
-{
- sizeof(Eina_List),
- 320,
- 0, NULL, NULL
+static Eina_Mempool2 _eina_list_mempool = {
+ sizeof(Eina_List),
+ 320,
+ 0, NULL, NULL
};
-static Eina_Mempool2 _eina_list_accounting_mempool =
-{
- sizeof(Eina_List_Accounting),
- 80,
- 0, NULL, NULL
+
+static Eina_Mempool2 _eina_list_accounting_mempool = {
+ sizeof(Eina_List_Accounting),
+ 80,
+ 0, NULL, NULL
};
#endif
static Eina_Bool
-eina_list_iterator_next(Eina_Iterator_List *it, void **data)
+eina_list_iterator_next(Eina_Iterator_List * it, void **data)
{
- EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
+ EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
- if (!it->current)
- return EINA_FALSE;
+ if (!it->current)
+ return EINA_FALSE;
- *data = eina_list_data_get(it->current);
+ *data = eina_list_data_get(it->current);
- it->current = eina_list_next(it->current);
+ it->current = eina_list_next(it->current);
- return EINA_TRUE;
+ return EINA_TRUE;
}
static Eina_Bool
-eina_list_iterator_prev(Eina_Iterator_List *it, void **data)
+eina_list_iterator_prev(Eina_Iterator_List * it, void **data)
{
- EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
+ EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
- if (!it->current)
- return EINA_FALSE;
+ if (!it->current)
+ return EINA_FALSE;
- *data = eina_list_data_get(it->current);
+ *data = eina_list_data_get(it->current);
- it->current = eina_list_prev(it->current);
+ it->current = eina_list_prev(it->current);
- return EINA_TRUE;
+ return EINA_TRUE;
}
-static Eina_List *
-eina_list_iterator_get_container(Eina_Iterator_List *it)
+static Eina_List *eina_list_iterator_get_container(Eina_Iterator_List * it)
{
- EINA_MAGIC_CHECK_LIST_ITERATOR(it, NULL);
+ EINA_MAGIC_CHECK_LIST_ITERATOR(it, NULL);
- return (Eina_List *)it->head;
+ return (Eina_List *) it->head;
}
-static void
-eina_list_iterator_free(Eina_Iterator_List *it)
+static void eina_list_iterator_free(Eina_Iterator_List * it)
{
- EINA_MAGIC_CHECK_LIST_ITERATOR(it);
+ EINA_MAGIC_CHECK_LIST_ITERATOR(it);
- MAGIC_FREE(it);
+ MAGIC_FREE(it);
}
static Eina_Bool
-eina_list_accessor_get_at(Eina_Accessor_List *it, unsigned int idx, void **data)
+eina_list_accessor_get_at(Eina_Accessor_List * it, unsigned int idx,
+ void **data)
{
- const Eina_List *over;
- unsigned int middle;
- unsigned int i;
-
- EINA_MAGIC_CHECK_LIST_ACCESSOR(it, EINA_FALSE);
-
- if (idx >= eina_list_count(it->head))
- return EINA_FALSE;
-
- if (it->index == idx)
- over = it->current;
- else if (idx > it->index)
- {
- /* After current position. */
- middle = ((eina_list_count(it->head) - it->index) >> 1) + it->index;
-
- if (idx > middle)
- /* Go backward from the end. */
- for (i = eina_list_count(it->head) - 1,
- over = eina_list_last(it->head);
- i > idx && over;
- --i, over = eina_list_prev(over))
- ;
- else
- /* Go forward from current. */
- for (i = it->index, over = it->current;
- i < idx && over;
- ++i, over = eina_list_next(over))
- ;
- }
- else
- {
- /* Before current position. */
- middle = it->index >> 1;
-
- if (idx > middle)
- /* Go backward from current. */
- for (i = it->index, over = it->current;
- i > idx && over;
- --i, over = eina_list_prev(over))
- ;
- else
- /* Go forward from start. */
- for (i = 0, over = it->head;
- i < idx && over;
- ++i, over = eina_list_next(over))
- ;
- }
-
- if (!over)
- return EINA_FALSE;
-
- it->current = over;
- it->index = idx;
-
- *data = eina_list_data_get(it->current);
- return EINA_TRUE;
+ const Eina_List *over;
+ unsigned int middle;
+ unsigned int i;
+
+ EINA_MAGIC_CHECK_LIST_ACCESSOR(it, EINA_FALSE);
+
+ if (idx >= eina_list_count(it->head))
+ return EINA_FALSE;
+
+ if (it->index == idx)
+ over = it->current;
+ else if (idx > it->index) {
+ /* After current position. */
+ middle =
+ ((eina_list_count(it->head) - it->index) >> 1) +
+ it->index;
+
+ if (idx > middle)
+ /* Go backward from the end. */
+ for (i = eina_list_count(it->head) - 1,
+ over = eina_list_last(it->head);
+ i > idx && over;
+ --i, over = eina_list_prev(over));
+ else
+ /* Go forward from current. */
+ for (i = it->index, over = it->current;
+ i < idx && over;
+ ++i, over = eina_list_next(over));
+ } else {
+ /* Before current position. */
+ middle = it->index >> 1;
+
+ if (idx > middle)
+ /* Go backward from current. */
+ for (i = it->index, over = it->current;
+ i > idx && over;
+ --i, over = eina_list_prev(over));
+ else
+ /* Go forward from start. */
+ for (i = 0, over = it->head;
+ i < idx && over;
+ ++i, over = eina_list_next(over));
+ }
+
+ if (!over)
+ return EINA_FALSE;
+
+ it->current = over;
+ it->index = idx;
+
+ *data = eina_list_data_get(it->current);
+ return EINA_TRUE;
}
-static Eina_List *
-eina_list_accessor_get_container(Eina_Accessor_List *it)
+static Eina_List *eina_list_accessor_get_container(Eina_Accessor_List * it)
{
- EINA_MAGIC_CHECK_LIST_ACCESSOR(it, NULL);
+ EINA_MAGIC_CHECK_LIST_ACCESSOR(it, NULL);
- return (Eina_List *)it->head;
+ return (Eina_List *) it->head;
}
-static void
-eina_list_accessor_free(Eina_Accessor_List *it)
+static void eina_list_accessor_free(Eina_Accessor_List * it)
{
- EINA_MAGIC_CHECK_LIST_ACCESSOR(it);
+ EINA_MAGIC_CHECK_LIST_ACCESSOR(it);
- MAGIC_FREE(it);
+ MAGIC_FREE(it);
}
-static Eina_List *
-eina_list_sort_rebuild_prev(Eina_List *list)
+static Eina_List *eina_list_sort_rebuild_prev(Eina_List * list)
{
- Eina_List *prev = NULL;
+ Eina_List *prev = NULL;
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- for (; list; list = list->next)
- {
- list->prev = prev;
- prev = list;
- }
+ for (; list; list = list->next) {
+ list->prev = prev;
+ prev = list;
+ }
- return prev;
+ return prev;
}
-static Eina_List *
-eina_list_sort_merge(Eina_List *a, Eina_List *b, Eina_Compare_Cb func)
+static Eina_List *eina_list_sort_merge(Eina_List * a, Eina_List * b,
+ Eina_Compare_Cb func)
{
- Eina_List *first, *last;
+ Eina_List *first, *last;
- if (func(a->data, b->data) < 0)
- a = (last = first = a)->next;
- else
- b = (last = first = b)->next;
+ if (func(a->data, b->data) < 0)
+ a = (last = first = a)->next;
+ else
+ b = (last = first = b)->next;
- while (a && b)
- if (func(a->data, b->data) < 0)
- a = (last = last->next = a)->next;
- else
- b = (last = last->next = b)->next;
+ while (a && b)
+ if (func(a->data, b->data) < 0)
+ a = (last = last->next = a)->next;
+ else
+ b = (last = last->next = b)->next;
- last->next = a ? a : b;
+ last->next = a ? a : b;
- return first;
+ return first;
}
/**
@@ -452,59 +438,53 @@ eina_list_sort_merge(Eina_List *a, Eina_List *b, Eina_Compare_Cb func)
*
* @see eina_init()
*/
-Eina_Bool
-eina_list_init(void)
+Eina_Bool eina_list_init(void)
{
- const char *choice, *tmp;
-
- _eina_list_log_dom = eina_log_domain_register("eina_list",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_list_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_list");
- return EINA_FALSE;
- }
-
+ const char *choice, *tmp;
+
+ _eina_list_log_dom = eina_log_domain_register("eina_list",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_list_log_dom < 0) {
+ EINA_LOG_ERR("Could not register log domain: eina_list");
+ return EINA_FALSE;
+ }
#ifdef EINA_DEFAULT_MEMPOOL
- choice = "pass_through";
+ choice = "pass_through";
#else
- choice = "chained_mempool";
+ choice = "chained_mempool";
#endif
- tmp = getenv("EINA_MEMPOOL");
- if (tmp && tmp[0])
- choice = tmp;
-
- _eina_list_mp = eina_mempool_add
- (choice, "list", NULL, sizeof(Eina_List), 320);
- if (!_eina_list_mp)
- {
- ERR("ERROR: Mempool for list cannot be allocated in list init.");
- goto on_init_fail;
- }
-
- _eina_list_accounting_mp = eina_mempool_add
- (choice, "list_accounting", NULL, sizeof(Eina_List_Accounting), 80);
- if (!_eina_list_accounting_mp)
- {
- ERR(
- "ERROR: Mempool for list accounting cannot be allocated in list init.");
- eina_mempool_del(_eina_list_mp);
- goto on_init_fail;
- }
-
+ tmp = getenv("EINA_MEMPOOL");
+ if (tmp && tmp[0])
+ choice = tmp;
+
+ _eina_list_mp = eina_mempool_add
+ (choice, "list", NULL, sizeof(Eina_List), 320);
+ if (!_eina_list_mp) {
+ ERR("ERROR: Mempool for list cannot be allocated in list init.");
+ goto on_init_fail;
+ }
+
+ _eina_list_accounting_mp = eina_mempool_add
+ (choice, "list_accounting", NULL, sizeof(Eina_List_Accounting),
+ 80);
+ if (!_eina_list_accounting_mp) {
+ ERR("ERROR: Mempool for list accounting cannot be allocated in list init.");
+ eina_mempool_del(_eina_list_mp);
+ goto on_init_fail;
+ }
#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
- EMS(EINA_MAGIC_LIST);
- EMS(EINA_MAGIC_LIST_ITERATOR);
- EMS(EINA_MAGIC_LIST_ACCESSOR);
- EMS(EINA_MAGIC_LIST_ACCOUNTING);
+ EMS(EINA_MAGIC_LIST);
+ EMS(EINA_MAGIC_LIST_ITERATOR);
+ EMS(EINA_MAGIC_LIST_ACCESSOR);
+ EMS(EINA_MAGIC_LIST_ACCOUNTING);
#undef EMS
- return EINA_TRUE;
+ return EINA_TRUE;
-on_init_fail:
- eina_log_domain_unregister(_eina_list_log_dom);
- _eina_list_log_dom = -1;
- return EINA_FALSE;
+ on_init_fail:
+ eina_log_domain_unregister(_eina_list_log_dom);
+ _eina_list_log_dom = -1;
+ return EINA_FALSE;
}
/**
@@ -518,15 +498,14 @@ on_init_fail:
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_list_shutdown(void)
+Eina_Bool eina_list_shutdown(void)
{
- eina_mempool_del(_eina_list_accounting_mp);
- eina_mempool_del(_eina_list_mp);
+ eina_mempool_del(_eina_list_accounting_mp);
+ eina_mempool_del(_eina_list_mp);
- eina_log_domain_unregister(_eina_list_log_dom);
- _eina_list_log_dom = -1;
- return EINA_TRUE;
+ eina_log_domain_unregister(_eina_list_log_dom);
+ _eina_list_log_dom = -1;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -570,34 +549,32 @@ eina_list_shutdown(void)
* }
* @endcode
*/
-EAPI Eina_List *
-eina_list_append(Eina_List *list, const void *data)
+EAPI Eina_List *eina_list_append(Eina_List * list, const void *data)
{
- Eina_List *l, *new_l;
+ Eina_List *l, *new_l;
- eina_error_set(0);
- new_l = _eina_list_mempool_list_new(list);
- if (!new_l)
- return list;
+ eina_error_set(0);
+ new_l = _eina_list_mempool_list_new(list);
+ if (!new_l)
+ return list;
- new_l->next = NULL;
- new_l->data = (void *)data;
- if (!list)
- {
- new_l->prev = NULL;
- return _eina_list_setup_accounting(new_l);
- }
+ new_l->next = NULL;
+ new_l->data = (void *) data;
+ if (!list) {
+ new_l->prev = NULL;
+ return _eina_list_setup_accounting(new_l);
+ }
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- l = list->accounting->last;
- list->accounting->last = new_l;
+ l = list->accounting->last;
+ list->accounting->last = new_l;
- l->next = new_l;
- new_l->prev = l;
+ l->next = new_l;
+ new_l->prev = l;
- _eina_list_update_accounting(list, new_l);
- return list;
+ _eina_list_update_accounting(list, new_l);
+ return list;
}
/**
@@ -628,30 +605,29 @@ eina_list_append(Eina_List *list, const void *data)
* }
* @endcode
*/
-EAPI Eina_List *
-eina_list_prepend(Eina_List *list, const void *data)
+EAPI Eina_List *eina_list_prepend(Eina_List * list, const void *data)
{
- Eina_List *new_l;
+ Eina_List *new_l;
- eina_error_set(0);
- new_l = _eina_list_mempool_list_new(list);
- if (!new_l)
- return list;
+ eina_error_set(0);
+ new_l = _eina_list_mempool_list_new(list);
+ if (!new_l)
+ return list;
- new_l->prev = NULL;
- new_l->next = list;
- new_l->data = (void *)data;
+ new_l->prev = NULL;
+ new_l->next = list;
+ new_l->data = (void *) data;
- if (!list)
- return _eina_list_setup_accounting(new_l);
+ if (!list)
+ return _eina_list_setup_accounting(new_l);
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- list->prev = new_l;
+ list->prev = new_l;
- _eina_list_update_accounting(list, new_l);
+ _eina_list_update_accounting(list, new_l);
- return new_l;
+ return new_l;
}
/**
@@ -692,24 +668,23 @@ eina_list_prepend(Eina_List *list, const void *data)
* }
* @endcode
*/
-EAPI Eina_List *
-eina_list_append_relative(Eina_List *list,
- const void *data,
- const void *relative)
+EAPI Eina_List *eina_list_append_relative(Eina_List * list,
+ const void *data,
+ const void *relative)
{
- Eina_List *l;
- void *list_data;
+ Eina_List *l;
+ void *list_data;
- if (list)
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- EINA_LIST_FOREACH(list, l, list_data)
- {
- if (list_data == relative)
- return eina_list_append_relative_list(list, data, l);
- }
+ EINA_LIST_FOREACH(list, l, list_data) {
+ if (list_data == relative)
+ return eina_list_append_relative_list(list, data,
+ l);
+ }
- return eina_list_append(list, data);
+ return eina_list_append(list, data);
}
/**
@@ -729,37 +704,36 @@ eina_list_append_relative(Eina_List *list,
* place of the one given to this function is returned. Otherwise, the
* old pointer is returned.
*/
-EAPI Eina_List *
-eina_list_append_relative_list(Eina_List *list,
- const void *data,
- Eina_List *relative)
+EAPI Eina_List *eina_list_append_relative_list(Eina_List * list,
+ const void *data,
+ Eina_List * relative)
{
- Eina_List *new_l;
+ Eina_List *new_l;
- if ((!list) || (!relative))
- return eina_list_append(list, data);
+ if ((!list) || (!relative))
+ return eina_list_append(list, data);
- eina_error_set(0);
- new_l = _eina_list_mempool_list_new(list);
- if (!new_l)
- return list;
+ eina_error_set(0);
+ new_l = _eina_list_mempool_list_new(list);
+ if (!new_l)
+ return list;
- EINA_MAGIC_CHECK_LIST(relative, NULL);
- new_l->next = relative->next;
- new_l->data = (void *)data;
+ EINA_MAGIC_CHECK_LIST(relative, NULL);
+ new_l->next = relative->next;
+ new_l->data = (void *) data;
- if (relative->next)
- relative->next->prev = new_l;
+ if (relative->next)
+ relative->next->prev = new_l;
- relative->next = new_l;
- new_l->prev = relative;
+ relative->next = new_l;
+ new_l->prev = relative;
- _eina_list_update_accounting(list, new_l);
+ _eina_list_update_accounting(list, new_l);
- if (!new_l->next)
- new_l->accounting->last = new_l;
+ if (!new_l->next)
+ new_l->accounting->last = new_l;
- return list;
+ return list;
}
/**
@@ -800,23 +774,22 @@ eina_list_append_relative_list(Eina_List *list,
* }
* @endcode
*/
-EAPI Eina_List *
-eina_list_prepend_relative(Eina_List *list,
- const void *data,
- const void *relative)
+EAPI Eina_List *eina_list_prepend_relative(Eina_List * list,
+ const void *data,
+ const void *relative)
{
- Eina_List *l;
- void *list_data;
-
- if (list)
- EINA_MAGIC_CHECK_LIST(list, NULL);
-
- EINA_LIST_FOREACH(list, l, list_data)
- {
- if (list_data == relative)
- return eina_list_prepend_relative_list(list, data, l);
- }
- return eina_list_prepend(list, data);
+ Eina_List *l;
+ void *list_data;
+
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+
+ EINA_LIST_FOREACH(list, l, list_data) {
+ if (list_data == relative)
+ return eina_list_prepend_relative_list(list, data,
+ l);
+ }
+ return eina_list_prepend(list, data);
}
/**
@@ -836,38 +809,37 @@ eina_list_prepend_relative(Eina_List *list,
* place of the one given to this function is returned. Otherwise, the
* old pointer is returned.
*/
-EAPI Eina_List *
-eina_list_prepend_relative_list(Eina_List *list,
- const void *data,
- Eina_List *relative)
+EAPI Eina_List *eina_list_prepend_relative_list(Eina_List * list,
+ const void *data,
+ Eina_List * relative)
{
- Eina_List *new_l;
+ Eina_List *new_l;
- if ((!list) || (!relative))
- return eina_list_prepend(list, data);
+ if ((!list) || (!relative))
+ return eina_list_prepend(list, data);
- eina_error_set(0);
- new_l = _eina_list_mempool_list_new(list);
- if (!new_l)
- return list;
+ eina_error_set(0);
+ new_l = _eina_list_mempool_list_new(list);
+ if (!new_l)
+ return list;
- EINA_MAGIC_CHECK_LIST(relative, NULL);
+ EINA_MAGIC_CHECK_LIST(relative, NULL);
- new_l->prev = relative->prev;
- new_l->next = relative;
- new_l->data = (void *)data;
+ new_l->prev = relative->prev;
+ new_l->next = relative;
+ new_l->data = (void *) data;
- if (relative->prev)
- relative->prev->next = new_l;
+ if (relative->prev)
+ relative->prev->next = new_l;
- relative->prev = new_l;
+ relative->prev = new_l;
- _eina_list_update_accounting(list, new_l);
+ _eina_list_update_accounting(list, new_l);
- if (new_l->prev)
- return list;
+ if (new_l->prev)
+ return list;
- return new_l;
+ return new_l;
}
/**
@@ -891,20 +863,21 @@ eina_list_prepend_relative_list(Eina_List *list,
* can be costly, consider worst case to be almost O(n) pointer
* dereference (list walk).
*/
-EAPI Eina_List *
-eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data)
+EAPI Eina_List *eina_list_sorted_insert(Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data)
{
- Eina_List *lnear;
- int cmp;
+ Eina_List *lnear;
+ int cmp;
- if (!list)
- return eina_list_append(NULL, data);
+ if (!list)
+ return eina_list_append(NULL, data);
- lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
- if (cmp < 0)
- return eina_list_append_relative_list(list, data, lnear);
- else
- return eina_list_prepend_relative_list(list, data, lnear);
+ lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
+ if (cmp < 0)
+ return eina_list_append_relative_list(list, data, lnear);
+ else
+ return eina_list_prepend_relative_list(list, data, lnear);
}
/**
@@ -921,16 +894,15 @@ eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data)
* pointer that should be used in place of the one passed to this
* function.
*/
-EAPI Eina_List *
-eina_list_remove(Eina_List *list, const void *data)
+EAPI Eina_List *eina_list_remove(Eina_List * list, const void *data)
{
- Eina_List *l;
+ Eina_List *l;
- if (list)
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- l = eina_list_data_find_list(list, data);
- return eina_list_remove_list(list, l);
+ l = eina_list_data_find_list(list, data);
+ return eina_list_remove_list(list, l);
}
/**
@@ -966,38 +938,35 @@ eina_list_remove(Eina_List *list, const void *data)
* }
* @endcode
*/
-EAPI Eina_List *
-eina_list_remove_list(Eina_List *list, Eina_List *remove_list)
+EAPI Eina_List *eina_list_remove_list(Eina_List * list,
+ Eina_List * remove_list)
{
- Eina_List *return_l;
+ Eina_List *return_l;
- if (!list)
- return NULL;
+ if (!list)
+ return NULL;
- if (!remove_list)
- return list;
+ if (!remove_list)
+ return list;
- EINA_MAGIC_CHECK_LIST(remove_list, NULL);
+ EINA_MAGIC_CHECK_LIST(remove_list, NULL);
- if (remove_list->next)
- remove_list->next->prev = remove_list->prev;
+ if (remove_list->next)
+ remove_list->next->prev = remove_list->prev;
- if (remove_list->prev)
- {
- remove_list->prev->next = remove_list->next;
- return_l = list;
- }
- else
- return_l = remove_list->next;
+ if (remove_list->prev) {
+ remove_list->prev->next = remove_list->next;
+ return_l = list;
+ } else
+ return_l = remove_list->next;
- if (remove_list == remove_list->accounting->last)
- {
- EINA_MAGIC_CHECK_LIST(list, NULL);
- list->accounting->last = remove_list->prev;
- }
+ if (remove_list == remove_list->accounting->last) {
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+ list->accounting->last = remove_list->prev;
+ }
- _eina_list_mempool_list_free(remove_list);
- return return_l;
+ _eina_list_mempool_list_free(remove_list);
+ return return_l;
}
/**
@@ -1009,25 +978,23 @@ eina_list_remove_list(Eina_List *list, Eina_List *remove_list)
* This function frees all the nodes of @p list. It does not free the
* data of the nodes. To free them, use #EINA_LIST_FREE.
*/
-EAPI Eina_List *
-eina_list_free(Eina_List *list)
+EAPI Eina_List *eina_list_free(Eina_List * list)
{
- Eina_List *l, *free_l;
+ Eina_List *l, *free_l;
- if (!list)
- return NULL;
+ if (!list)
+ return NULL;
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- for (l = list; l; )
- {
- free_l = l;
- l = l->next;
+ for (l = list; l;) {
+ free_l = l;
+ l = l->next;
- _eina_list_mempool_list_free(free_l);
- }
+ _eina_list_mempool_list_free(free_l);
+ }
- return NULL;
+ return NULL;
}
/**
@@ -1059,47 +1026,45 @@ eina_list_free(Eina_List *list)
* }
* @endcode
*/
-EAPI Eina_List *
-eina_list_promote_list(Eina_List *list, Eina_List *move_list)
+EAPI Eina_List *eina_list_promote_list(Eina_List * list,
+ Eina_List * move_list)
{
- if (!list)
- return NULL;
-
- if (!move_list)
- {
- return list; /* Promoting head to be head. */
-
- }
-
- if (move_list == list)
- return list;
-
- if (move_list->next == list)
- return move_list;
-
- EINA_MAGIC_CHECK_LIST(list, NULL);
- EINA_MAGIC_CHECK_LIST(move_list, NULL);
-
- /* Remove the promoted item from the list. */
- if (!move_list->prev)
- move_list->next->prev = NULL;
- else
- {
- move_list->prev->next = move_list->next;
- if (move_list == list->accounting->last)
- list->accounting->last = move_list->prev;
- else
- move_list->next->prev = move_list->prev;
- }
-
- /* Add the promoted item in the list. */
- move_list->next = list;
- move_list->prev = list->prev;
- list->prev = move_list;
- if (move_list->prev)
- move_list->prev->next = move_list;
-
- return move_list;
+ if (!list)
+ return NULL;
+
+ if (!move_list) {
+ return list; /* Promoting head to be head. */
+
+ }
+
+ if (move_list == list)
+ return list;
+
+ if (move_list->next == list)
+ return move_list;
+
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(move_list, NULL);
+
+ /* Remove the promoted item from the list. */
+ if (!move_list->prev)
+ move_list->next->prev = NULL;
+ else {
+ move_list->prev->next = move_list->next;
+ if (move_list == list->accounting->last)
+ list->accounting->last = move_list->prev;
+ else
+ move_list->next->prev = move_list->prev;
+ }
+
+ /* Add the promoted item in the list. */
+ move_list->next = list;
+ move_list->prev = list->prev;
+ list->prev = move_list;
+ if (move_list->prev)
+ move_list->prev->next = move_list;
+
+ return move_list;
}
/**
@@ -1131,42 +1096,40 @@ eina_list_promote_list(Eina_List *list, Eina_List *move_list)
* }
* @endcode
*/
-EAPI Eina_List *
-eina_list_demote_list(Eina_List *list, Eina_List *move_list)
+EAPI Eina_List *eina_list_demote_list(Eina_List * list,
+ Eina_List * move_list)
{
- if (!list)
- return NULL;
+ if (!list)
+ return NULL;
- if (!move_list)
- {
- return list; /* Demoting tail to be tail. */
+ if (!move_list) {
+ return list; /* Demoting tail to be tail. */
- }
+ }
- if (move_list == list->accounting->last)
- return list;
+ if (move_list == list->accounting->last)
+ return list;
- EINA_MAGIC_CHECK_LIST(list, NULL);
- EINA_MAGIC_CHECK_LIST(move_list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(move_list, NULL);
- /* Update pointer list if necessary. */
- if (list == move_list)
- {
- list = move_list->next; /* Remove the demoted item from the list. */
+ /* Update pointer list if necessary. */
+ if (list == move_list) {
+ list = move_list->next; /* Remove the demoted item from the list. */
- }
+ }
- if (move_list->prev)
- move_list->prev->next = move_list->next;
+ if (move_list->prev)
+ move_list->prev->next = move_list->next;
- move_list->next->prev = move_list->prev;
- /* Add the demoted item in the list. */
- move_list->prev = list->accounting->last;
- move_list->prev->next = move_list;
- move_list->next = NULL;
- list->accounting->last = move_list;
+ move_list->next->prev = move_list->prev;
+ /* Add the demoted item in the list. */
+ move_list->prev = list->accounting->last;
+ move_list->prev->next = move_list;
+ move_list->next = NULL;
+ list->accounting->last = move_list;
- return list;
+ return list;
}
/**
@@ -1191,13 +1154,12 @@ eina_list_demote_list(Eina_List *list, Eina_List *move_list)
* }
* @endcode
*/
-EAPI void *
-eina_list_data_find(const Eina_List *list, const void *data)
+EAPI void *eina_list_data_find(const Eina_List * list, const void *data)
{
- if (eina_list_data_find_list(list, data))
- return (void *)data;
+ if (eina_list_data_find_list(list, data))
+ return (void *) data;
- return NULL;
+ return NULL;
}
/**
@@ -1212,22 +1174,21 @@ eina_list_data_find(const Eina_List *list, const void *data)
* list node containing the specified member is returned, otherwise
* @c NULL is returned.
*/
-EAPI Eina_List *
-eina_list_data_find_list(const Eina_List *list, const void *data)
+EAPI Eina_List *eina_list_data_find_list(const Eina_List * list,
+ const void *data)
{
- const Eina_List *l;
- void *list_data;
+ const Eina_List *l;
+ void *list_data;
- if (list)
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- EINA_LIST_FOREACH(list, l, list_data)
- {
- if (list_data == data)
- return (Eina_List *)l;
- }
+ EINA_LIST_FOREACH(list, l, list_data) {
+ if (list_data == data)
+ return (Eina_List *) l;
+ }
- return NULL;
+ return NULL;
}
/**
@@ -1242,13 +1203,12 @@ eina_list_data_find_list(const Eina_List *list, const void *data)
* the element number @p n does not exist, @c NULL is
* returned. Otherwise, the data of the found element is returned.
*/
-EAPI void *
-eina_list_nth(const Eina_List *list, unsigned int n)
+EAPI void *eina_list_nth(const Eina_List * list, unsigned int n)
{
- Eina_List *l;
+ Eina_List *l;
- l = eina_list_nth_list(list, n);
- return l ? l->data : NULL;
+ l = eina_list_nth_list(list, n);
+ return l ? l->data : NULL;
}
/**
@@ -1265,39 +1225,33 @@ eina_list_nth(const Eina_List *list, unsigned int n)
* returned. Otherwise the list node stored in the numbered element is
* returned.
*/
-EAPI Eina_List *
-eina_list_nth_list(const Eina_List *list, unsigned int n)
+EAPI Eina_List *eina_list_nth_list(const Eina_List * list, unsigned int n)
{
- const Eina_List *l;
- unsigned int i;
-
- if (list)
- EINA_MAGIC_CHECK_LIST(list, NULL);
-
- /* check for non-existing nodes */
- if ((!list) || (n > (list->accounting->count - 1)))
- return NULL;
-
- /* if the node is in the 2nd half of the list, search from the end
- * else, search from the beginning.
- */
- if (n > (list->accounting->count / 2))
- for (i = list->accounting->count - 1,
- l = list->accounting->last;
- l;
- l = l->prev, i--)
- {
- if (i == n)
- return (Eina_List *)l;
- }
- else
- for (i = 0, l = list; l; l = l->next, i++)
- {
- if (i == n)
- return (Eina_List *)l;
- }
-
- abort();
+ const Eina_List *l;
+ unsigned int i;
+
+ if (list)
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+
+ /* check for non-existing nodes */
+ if ((!list) || (n > (list->accounting->count - 1)))
+ return NULL;
+
+ /* if the node is in the 2nd half of the list, search from the end
+ * else, search from the beginning.
+ */
+ if (n > (list->accounting->count / 2))
+ for (i = list->accounting->count - 1,
+ l = list->accounting->last; l; l = l->prev, i--) {
+ if (i == n)
+ return (Eina_List *) l;
+ } else
+ for (i = 0, l = list; l; l = l->next, i++) {
+ if (i == n)
+ return (Eina_List *) l;
+ }
+
+ abort();
}
/**
@@ -1316,33 +1270,31 @@ eina_list_nth_list(const Eina_List *list, unsigned int n)
* @see eina_list_reverse_clone()
* @see eina_list_iterator_reversed_new()
*/
-EAPI Eina_List *
-eina_list_reverse(Eina_List *list)
+EAPI Eina_List *eina_list_reverse(Eina_List * list)
{
- Eina_List *l1, *l2;
+ Eina_List *l1, *l2;
- if (!list)
- return NULL;
+ if (!list)
+ return NULL;
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- l1 = list;
- l2 = list->accounting->last;
- while (l1 != l2)
- {
- void *data;
+ l1 = list;
+ l2 = list->accounting->last;
+ while (l1 != l2) {
+ void *data;
- data = l1->data;
- l1->data = l2->data;
- l2->data = data;
- l1 = l1->next;
- if (l1 == l2)
- break;
+ data = l1->data;
+ l1->data = l2->data;
+ l2->data = data;
+ l1 = l1->next;
+ if (l1 == l2)
+ break;
- l2 = l2->prev;
- }
+ l2 = l2->prev;
+ }
- return list;
+ return list;
}
/**
@@ -1361,23 +1313,22 @@ eina_list_reverse(Eina_List *list)
* @see eina_list_reverse()
* @see eina_list_clone()
*/
-EAPI Eina_List *
-eina_list_reverse_clone(const Eina_List *list)
+EAPI Eina_List *eina_list_reverse_clone(const Eina_List * list)
{
- const Eina_List *l;
- Eina_List *lclone;
- void *data;
+ const Eina_List *l;
+ Eina_List *lclone;
+ void *data;
- if (!list)
- return NULL;
+ if (!list)
+ return NULL;
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- lclone = NULL;
- EINA_LIST_FOREACH(list, l, data)
- lclone = eina_list_prepend(lclone, data);
+ lclone = NULL;
+ EINA_LIST_FOREACH(list, l, data)
+ lclone = eina_list_prepend(lclone, data);
- return lclone;
+ return lclone;
}
/**
@@ -1395,23 +1346,22 @@ eina_list_reverse_clone(const Eina_List *list)
*
* @see eina_list_reverse_clone()
*/
-EAPI Eina_List *
-eina_list_clone(const Eina_List *list)
+EAPI Eina_List *eina_list_clone(const Eina_List * list)
{
- const Eina_List *l;
- Eina_List *lclone;
- void *data;
+ const Eina_List *l;
+ Eina_List *lclone;
+ void *data;
- if (!list)
- return NULL;
+ if (!list)
+ return NULL;
- EINA_MAGIC_CHECK_LIST(list, NULL);
+ EINA_MAGIC_CHECK_LIST(list, NULL);
- lclone = NULL;
- EINA_LIST_FOREACH(list, l, data)
- lclone = eina_list_append(lclone, data);
+ lclone = NULL;
+ EINA_LIST_FOREACH(list, l, data)
+ lclone = eina_list_append(lclone, data);
- return lclone;
+ return lclone;
}
/**
@@ -1455,73 +1405,70 @@ eina_list_clone(const Eina_List *list)
* list = eina_list_sort(list, eina_list_count(list), sort_cb);
* @endcode
*/
-EAPI Eina_List *
-eina_list_sort(Eina_List *list, unsigned int size, Eina_Compare_Cb func)
+EAPI Eina_List *eina_list_sort(Eina_List * list, unsigned int size,
+ Eina_Compare_Cb func)
{
- unsigned int i = 0;
- unsigned int n = 0;
- Eina_List *tail = list;
- Eina_List *unsort = NULL;
- Eina_List *stack[EINA_LIST_SORT_STACK_SIZE];
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(func, list);
- if (!list)
- return NULL;
-
- EINA_MAGIC_CHECK_LIST(list, NULL);
-
- /* if the caller specified an invalid size, sort the whole list */
- if ((size == 0) ||
- (size > list->accounting->count))
- size = list->accounting->count;
-
- if (size != list->accounting->count)
- {
- unsort = eina_list_nth_list(list, size);
- if (unsort)
- unsort->prev->next = NULL;
- }
-
- while (tail)
- {
- unsigned int idx, tmp;
-
- Eina_List *a = tail;
- Eina_List *b = tail->next;
-
- if (!b)
- {
- stack[i++] = a;
- break;
- }
-
- tail = b->next;
-
- if (func(a->data, b->data) < 0)
- ((stack[i++] = a)->next = b)->next = 0;
- else
- ((stack[i++] = b)->next = a)->next = 0;
-
- tmp = n++;
- for (idx = n ^ tmp; idx &= idx - 1; i--)
- stack[i - 2] = eina_list_sort_merge(stack[i - 2], stack[i - 1], func);
- }
-
- while (i-- > 1)
- stack[i - 1] = eina_list_sort_merge(stack[i - 1], stack[i], func);
-
- list = stack[0];
- tail = eina_list_sort_rebuild_prev(list);
-
- if (unsort)
- {
- tail->next = unsort;
- unsort->prev = tail;
- }
- else
- list->accounting->last = tail;
-
- return list;
+ unsigned int i = 0;
+ unsigned int n = 0;
+ Eina_List *tail = list;
+ Eina_List *unsort = NULL;
+ Eina_List *stack[EINA_LIST_SORT_STACK_SIZE];
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(func, list);
+ if (!list)
+ return NULL;
+
+ EINA_MAGIC_CHECK_LIST(list, NULL);
+
+ /* if the caller specified an invalid size, sort the whole list */
+ if ((size == 0) || (size > list->accounting->count))
+ size = list->accounting->count;
+
+ if (size != list->accounting->count) {
+ unsort = eina_list_nth_list(list, size);
+ if (unsort)
+ unsort->prev->next = NULL;
+ }
+
+ while (tail) {
+ unsigned int idx, tmp;
+
+ Eina_List *a = tail;
+ Eina_List *b = tail->next;
+
+ if (!b) {
+ stack[i++] = a;
+ break;
+ }
+
+ tail = b->next;
+
+ if (func(a->data, b->data) < 0)
+ ((stack[i++] = a)->next = b)->next = 0;
+ else
+ ((stack[i++] = b)->next = a)->next = 0;
+
+ tmp = n++;
+ for (idx = n ^ tmp; idx &= idx - 1; i--)
+ stack[i - 2] =
+ eina_list_sort_merge(stack[i - 2],
+ stack[i - 1], func);
+ }
+
+ while (i-- > 1)
+ stack[i - 1] =
+ eina_list_sort_merge(stack[i - 1], stack[i], func);
+
+ list = stack[0];
+ tail = eina_list_sort_rebuild_prev(list);
+
+ if (unsort) {
+ tail->next = unsort;
+ unsort->prev = tail;
+ } else
+ list->accounting->last = tail;
+
+ return list;
}
/**
@@ -1539,54 +1486,48 @@ eina_list_sort(Eina_List *list, unsigned int size, Eina_Compare_Cb func)
* list. This is due the need to fix accounting of that segment,
* making count and last access O(1).
*/
-EAPI Eina_List *
-eina_list_merge(Eina_List *left, Eina_List *right)
+EAPI Eina_List *eina_list_merge(Eina_List * left, Eina_List * right)
{
- unsigned int n_left, n_right;
-
- if (!left)
- return right;
-
- if (!right)
- return left;
-
- left->accounting->last->next = right;
- right->prev = left->accounting->last;
-
- n_left = left->accounting->count;
- n_right = right->accounting->count;
-
- if (n_left >= n_right)
- {
- Eina_List *itr = right;
- left->accounting->last = right->accounting->last;
- left->accounting->count += n_right;
-
- _eina_list_mempool_accounting_free(right->accounting);
-
- do
- {
- itr->accounting = left->accounting;
- itr = itr->next;
- }
- while (itr);
- }
- else
- {
- Eina_List *itr = left->accounting->last;
- right->accounting->count += n_left;
-
- _eina_list_mempool_accounting_free(left->accounting);
-
- do
- {
- itr->accounting = right->accounting;
- itr = itr->prev;
- }
- while (itr);
- }
-
- return left;
+ unsigned int n_left, n_right;
+
+ if (!left)
+ return right;
+
+ if (!right)
+ return left;
+
+ left->accounting->last->next = right;
+ right->prev = left->accounting->last;
+
+ n_left = left->accounting->count;
+ n_right = right->accounting->count;
+
+ if (n_left >= n_right) {
+ Eina_List *itr = right;
+ left->accounting->last = right->accounting->last;
+ left->accounting->count += n_right;
+
+ _eina_list_mempool_accounting_free(right->accounting);
+
+ do {
+ itr->accounting = left->accounting;
+ itr = itr->next;
+ }
+ while (itr);
+ } else {
+ Eina_List *itr = left->accounting->last;
+ right->accounting->count += n_left;
+
+ _eina_list_mempool_accounting_free(left->accounting);
+
+ do {
+ itr->accounting = right->accounting;
+ itr = itr->prev;
+ }
+ while (itr);
+ }
+
+ return left;
}
@@ -1606,49 +1547,49 @@ eina_list_merge(Eina_List *left, Eina_List *right)
* list does not exist anymore after the split.
*
*/
-EAPI Eina_List *
-eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right)
+EAPI Eina_List *eina_list_split_list(Eina_List * list,
+ Eina_List * relative,
+ Eina_List ** right)
{
- Eina_List *next;
- Eina_List *itr;
-
- if(!right)
- return list;
-
- *right = NULL;
-
- if (!list)
- return NULL;
-
- if (!relative)
- {
- *right = list;
- return NULL;
- }
-
- if (relative == eina_list_last(list))
- return list;
-
- next = eina_list_next(relative);
- next->prev = NULL;
- next->accounting = _eina_list_mempool_accounting_new(next);
- next->accounting->last = list->accounting->last;
- *right = next;
-
- itr = next;
- do
- {
- itr->accounting = next->accounting;
- next->accounting->count++;
- itr = itr->next;
- }
- while (itr);
-
- relative->next = NULL;
- list->accounting->last = relative;
- list->accounting->count = list->accounting->count - next->accounting->count;
-
- return list;
+ Eina_List *next;
+ Eina_List *itr;
+
+ if (!right)
+ return list;
+
+ *right = NULL;
+
+ if (!list)
+ return NULL;
+
+ if (!relative) {
+ *right = list;
+ return NULL;
+ }
+
+ if (relative == eina_list_last(list))
+ return list;
+
+ next = eina_list_next(relative);
+ next->prev = NULL;
+ next->accounting = _eina_list_mempool_accounting_new(next);
+ next->accounting->last = list->accounting->last;
+ *right = next;
+
+ itr = next;
+ do {
+ itr->accounting = next->accounting;
+ next->accounting->count++;
+ itr = itr->next;
+ }
+ while (itr);
+
+ relative->next = NULL;
+ list->accounting->last = relative;
+ list->accounting->count =
+ list->accounting->count - next->accounting->count;
+
+ return list;
}
/**
@@ -1686,81 +1627,71 @@ eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right)
* list = eina_list_sorted_merge(sorted1, sorted2, sort_cb);
* @endcode
*/
-EAPI Eina_List *
-eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func)
+EAPI Eina_List *eina_list_sorted_merge(Eina_List * left, Eina_List * right,
+ Eina_Compare_Cb func)
{
- Eina_List *ret;
- Eina_List *current;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
-
- if (!left)
- return right;
-
- if (!right)
- return left;
-
- if (func(left->data, right->data) < 0)
- {
- ret = left;
- current = left;
- left = left->next;
- ret->accounting->count += right->accounting->count;
-
- _eina_list_mempool_accounting_free(right->accounting);
- }
- else
- {
- ret = right;
- current = right;
- right = right->next;
- ret->accounting->count += left->accounting->count;
-
- _eina_list_mempool_accounting_free(left->accounting);
- }
-
- while (left && right)
- {
- if (func(left->data, right->data) < 0)
- {
- current->next = left;
- left->prev = current;
- left = left->next;
- }
- else
- {
- current->next = right;
- right->prev = current;
- right = right->next;
- }
-
- current = current->next;
- current->accounting = ret->accounting;
- }
-
- if (left)
- {
- current->next = left;
- left->prev = current;
- current->accounting = ret->accounting;
- }
-
- if (right)
- {
- current->next = right;
- right->prev = current;
- current->accounting = ret->accounting;
- }
-
- while (current->next)
- {
- current = current->next;
- current->accounting = ret->accounting;
- }
-
- ret->accounting->last = current;
-
- return ret;
+ Eina_List *ret;
+ Eina_List *current;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
+
+ if (!left)
+ return right;
+
+ if (!right)
+ return left;
+
+ if (func(left->data, right->data) < 0) {
+ ret = left;
+ current = left;
+ left = left->next;
+ ret->accounting->count += right->accounting->count;
+
+ _eina_list_mempool_accounting_free(right->accounting);
+ } else {
+ ret = right;
+ current = right;
+ right = right->next;
+ ret->accounting->count += left->accounting->count;
+
+ _eina_list_mempool_accounting_free(left->accounting);
+ }
+
+ while (left && right) {
+ if (func(left->data, right->data) < 0) {
+ current->next = left;
+ left->prev = current;
+ left = left->next;
+ } else {
+ current->next = right;
+ right->prev = current;
+ right = right->next;
+ }
+
+ current = current->next;
+ current->accounting = ret->accounting;
+ }
+
+ if (left) {
+ current->next = left;
+ left->prev = current;
+ current->accounting = ret->accounting;
+ }
+
+ if (right) {
+ current->next = right;
+ right->prev = current;
+ current->accounting = ret->accounting;
+ }
+
+ while (current->next) {
+ current = current->next;
+ current->accounting = ret->accounting;
+ }
+
+ ret->accounting->last = current;
+
+ return ret;
}
/**
@@ -1798,89 +1729,82 @@ eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func)
* @see eina_list_sort()
* @see eina_list_sorted_merge()
*/
-EAPI Eina_List *
-eina_list_search_sorted_near_list(const Eina_List *list,
- Eina_Compare_Cb func,
- const void *data,
- int *result_cmp)
+EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data,
+ int *result_cmp)
{
- const Eina_List *ct;
- unsigned int inf, sup, cur;
- int cmp;
-
- if (!list)
- {
- if (result_cmp)
- *result_cmp = 0;
-
- return NULL;
- }
-
- if (list->accounting->count == 1)
- {
- if (result_cmp)
- *result_cmp = func(list->data, data);
-
- return (Eina_List *)list;
- }
-
- /* list walk is expensive, do quick check: tail */
- ct = list->accounting->last;
- cmp = func(ct->data, data);
- if (cmp <= 0)
- goto end;
-
- /* list walk is expensive, do quick check: head */
- ct = list;
- cmp = func(ct->data, data);
- if (cmp >= 0)
- goto end;
-
- /* inclusive bounds */
- inf = 1;
- sup = list->accounting->count - 2;
- cur = 1;
- ct = list->next;
-
- /* no loop, just compare if comparison value is important to caller */
- if (inf > sup)
- {
- if (result_cmp)
- cmp = func(ct->data, data);
-
- goto end;
- }
-
- while (inf <= sup)
- {
- unsigned int tmp = cur;
- cur = inf + ((sup - inf) >> 1);
- if (tmp < cur)
- for (; tmp != cur; tmp++, ct = ct->next) ;
- else if (tmp > cur)
- for (; tmp != cur; tmp--, ct = ct->prev) ;
-
- cmp = func(ct->data, data);
- if (cmp == 0)
- break;
- else if (cmp < 0)
- inf = cur + 1;
- else if (cmp > 0)
- {
- if (cur > 0)
- sup = cur - 1;
- else
- break;
- }
- else
- break;
- }
-
-end:
- if (result_cmp)
- *result_cmp = cmp;
-
- return (Eina_List *)ct;
+ const Eina_List *ct;
+ unsigned int inf, sup, cur;
+ int cmp;
+
+ if (!list) {
+ if (result_cmp)
+ *result_cmp = 0;
+
+ return NULL;
+ }
+
+ if (list->accounting->count == 1) {
+ if (result_cmp)
+ *result_cmp = func(list->data, data);
+
+ return (Eina_List *) list;
+ }
+
+ /* list walk is expensive, do quick check: tail */
+ ct = list->accounting->last;
+ cmp = func(ct->data, data);
+ if (cmp <= 0)
+ goto end;
+
+ /* list walk is expensive, do quick check: head */
+ ct = list;
+ cmp = func(ct->data, data);
+ if (cmp >= 0)
+ goto end;
+
+ /* inclusive bounds */
+ inf = 1;
+ sup = list->accounting->count - 2;
+ cur = 1;
+ ct = list->next;
+
+ /* no loop, just compare if comparison value is important to caller */
+ if (inf > sup) {
+ if (result_cmp)
+ cmp = func(ct->data, data);
+
+ goto end;
+ }
+
+ while (inf <= sup) {
+ unsigned int tmp = cur;
+ cur = inf + ((sup - inf) >> 1);
+ if (tmp < cur)
+ for (; tmp != cur; tmp++, ct = ct->next);
+ else if (tmp > cur)
+ for (; tmp != cur; tmp--, ct = ct->prev);
+
+ cmp = func(ct->data, data);
+ if (cmp == 0)
+ break;
+ else if (cmp < 0)
+ inf = cur + 1;
+ else if (cmp > 0) {
+ if (cur > 0)
+ sup = cur - 1;
+ else
+ break;
+ } else
+ break;
+ }
+
+ end:
+ if (result_cmp)
+ *result_cmp = cmp;
+
+ return (Eina_List *) ct;
}
/**
@@ -1914,22 +1838,21 @@ end:
* @see eina_list_search_unsorted_list()
* @see eina_list_search_sorted_near_list()
*/
-EAPI Eina_List *
-eina_list_search_sorted_list(const Eina_List *list,
- Eina_Compare_Cb func,
- const void *data)
+EAPI Eina_List *eina_list_search_sorted_list(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data)
{
- Eina_List *lnear;
- int cmp;
+ Eina_List *lnear;
+ int cmp;
- lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
- if (!lnear)
- return NULL;
+ lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
+ if (!lnear)
+ return NULL;
- if (cmp == 0)
- return lnear;
+ if (cmp == 0)
+ return lnear;
- return NULL;
+ return NULL;
}
@@ -1964,12 +1887,12 @@ eina_list_search_sorted_list(const Eina_List *list,
* @see eina_list_sorted_merge()
* @see eina_list_search_unsorted_list()
*/
-EAPI void *
-eina_list_search_sorted(const Eina_List *list,
- Eina_Compare_Cb func,
- const void *data)
+EAPI void *eina_list_search_sorted(const Eina_List * list,
+ Eina_Compare_Cb func, const void *data)
{
- return eina_list_data_get(eina_list_search_sorted_list(list, func, data));
+ return
+ eina_list_data_get(eina_list_search_sorted_list
+ (list, func, data));
}
/**
@@ -1993,20 +1916,18 @@ eina_list_search_sorted(const Eina_List *list,
* @see eina_list_search_sorted_list()
* @see eina_list_search_unsorted()
*/
-EAPI Eina_List *
-eina_list_search_unsorted_list(const Eina_List *list,
- Eina_Compare_Cb func,
- const void *data)
+EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data)
{
- const Eina_List *l;
- void *d;
-
- EINA_LIST_FOREACH(list, l, d)
- {
- if (!func(d, data))
- return (Eina_List *)l;
- }
- return NULL;
+ const Eina_List *l;
+ void *d;
+
+ EINA_LIST_FOREACH(list, l, d) {
+ if (!func(d, data))
+ return (Eina_List *) l;
+ }
+ return NULL;
}
/**
@@ -2031,12 +1952,13 @@ eina_list_search_unsorted_list(const Eina_List *list,
* @see eina_list_search_sorted()
* @see eina_list_search_unsorted_list()
*/
-EAPI void *
-eina_list_search_unsorted(const Eina_List *list,
- Eina_Compare_Cb func,
- const void *data)
+EAPI void *eina_list_search_unsorted(const Eina_List * list,
+ Eina_Compare_Cb func,
+ const void *data)
{
- return eina_list_data_get(eina_list_search_unsorted_list(list, func, data));
+ return
+ eina_list_data_get(eina_list_search_unsorted_list
+ (list, func, data));
}
@@ -2060,32 +1982,30 @@ eina_list_search_unsorted(const Eina_List *list,
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_list_iterator_new(const Eina_List *list)
+EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List * list)
{
- Eina_Iterator_List *it;
+ Eina_Iterator_List *it;
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_List));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_List));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- it->head = list;
- it->current = list;
+ it->head = list;
+ it->current = list;
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- eina_list_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(eina_list_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
- return &it->iterator;
+ return &it->iterator;
}
/**
@@ -2110,32 +2030,30 @@ eina_list_iterator_new(const Eina_List *list)
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_list_iterator_reversed_new(const Eina_List *list)
+EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List * list)
{
- Eina_Iterator_List *it;
+ Eina_Iterator_List *it;
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_List));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_List));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- it->head = eina_list_last(list);
- it->current = it->head;
+ it->head = eina_list_last(list);
+ it->current = it->head;
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_prev);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- eina_list_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_prev);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(eina_list_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
- return &it->iterator;
+ return &it->iterator;
}
/**
@@ -2150,33 +2068,32 @@ eina_list_iterator_reversed_new(const Eina_List *list)
* not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
* set. Otherwise, a valid accessor is returned.
*/
-EAPI Eina_Accessor *
-eina_list_accessor_new(const Eina_List *list)
+EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List * list)
{
- Eina_Accessor_List *ac;
-
- eina_error_set(0);
- ac = calloc(1, sizeof (Eina_Accessor_List));
- if (!ac)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- EINA_MAGIC_SET(ac, EINA_MAGIC_LIST_ACCESSOR);
- EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
-
- ac->head = list;
- ac->current = list;
- ac->index = 0;
-
- ac->accessor.version = EINA_ACCESSOR_VERSION;
- ac->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_list_accessor_get_at);
- ac->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
- eina_list_accessor_get_container);
- ac->accessor.free = FUNC_ACCESSOR_FREE(eina_list_accessor_free);
-
- return &ac->accessor;
+ Eina_Accessor_List *ac;
+
+ eina_error_set(0);
+ ac = calloc(1, sizeof(Eina_Accessor_List));
+ if (!ac) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ EINA_MAGIC_SET(ac, EINA_MAGIC_LIST_ACCESSOR);
+ EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
+
+ ac->head = list;
+ ac->current = list;
+ ac->index = 0;
+
+ ac->accessor.version = EINA_ACCESSOR_VERSION;
+ ac->accessor.get_at =
+ FUNC_ACCESSOR_GET_AT(eina_list_accessor_get_at);
+ ac->accessor.get_container =
+ FUNC_ACCESSOR_GET_CONTAINER(eina_list_accessor_get_container);
+ ac->accessor.free = FUNC_ACCESSOR_FREE(eina_list_accessor_free);
+
+ return &ac->accessor;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_log.c b/tests/suite/ecore/src/lib/eina_log.c
index aa9b7819ac..5b5aca839f 100644
--- a/tests/suite/ecore/src/lib/eina_log.c
+++ b/tests/suite/ecore/src/lib/eina_log.c
@@ -258,7 +258,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -268,15 +268,15 @@
#include <assert.h>
#ifndef _MSC_VER
-# include <unistd.h>
+#include <unistd.h>
#endif
#ifdef EFL_HAVE_POSIX_THREADS
-# include <pthread.h>
+#include <pthread.h>
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -313,13 +313,13 @@
// Structure for storing domain level settings passed from the command line
// that will be matched with application-defined domains.
-typedef struct _Eina_Log_Domain_Level_Pending Eina_Log_Domain_Level_Pending;
-struct _Eina_Log_Domain_Level_Pending
-{
- EINA_INLIST;
- unsigned int level;
- size_t namelen;
- char name[];
+typedef struct _Eina_Log_Domain_Level_Pending
+ Eina_Log_Domain_Level_Pending;
+struct _Eina_Log_Domain_Level_Pending {
+ EINA_INLIST;
+ unsigned int level;
+ size_t namelen;
+ char name[];
};
/*
@@ -341,16 +341,16 @@ static int _abort_level_on_critical = EINA_LOG_LEVEL_CRITICAL;
static Eina_Bool _threads_enabled = EINA_FALSE;
-# ifdef EFL_HAVE_POSIX_THREADS
+#ifdef EFL_HAVE_POSIX_THREADS
typedef pthread_t Thread;
static pthread_t _main_thread;
-# define SELF() pthread_self()
-# define IS_MAIN(t) pthread_equal(t, _main_thread)
-# define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
-# define CHECK_MAIN(...) \
+#define SELF() pthread_self()
+#define IS_MAIN(t) pthread_equal(t, _main_thread)
+#define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
+#define CHECK_MAIN(...) \
do { \
if (!IS_MAIN(pthread_self())) { \
fprintf(stderr, \
@@ -361,10 +361,10 @@ static pthread_t _main_thread;
} \
} while (0)
-# ifdef EFL_HAVE_POSIX_THREADS_SPINLOCK
+#ifdef EFL_HAVE_POSIX_THREADS_SPINLOCK
static pthread_spinlock_t _log_lock;
-# define LOG_LOCK() \
+#define LOG_LOCK() \
if (_threads_enabled) \
do { \
if (0) { \
@@ -373,7 +373,7 @@ static pthread_spinlock_t _log_lock;
if (EINA_UNLIKELY(_threads_enabled)) { \
pthread_spin_lock(&_log_lock); } \
} while (0)
-# define LOG_UNLOCK() \
+#define LOG_UNLOCK() \
if (_threads_enabled) \
do { \
if (EINA_UNLIKELY(_threads_enabled)) { \
@@ -383,29 +383,29 @@ static pthread_spinlock_t _log_lock;
"---LOG LOG_UNLOCKED! [%s, %lu]\n", \
__FUNCTION__, (unsigned long)pthread_self()); } \
} while (0)
-# define INIT() pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE)
-# define SHUTDOWN() pthread_spin_destroy(&_log_lock)
+#define INIT() pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE)
+#define SHUTDOWN() pthread_spin_destroy(&_log_lock)
-# else /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
+#else /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
static pthread_mutex_t _log_mutex = PTHREAD_MUTEX_INITIALIZER;
-# define LOG_LOCK() if(_threads_enabled) {pthread_mutex_lock(&_log_mutex); }
-# define LOG_UNLOCK() if(_threads_enabled) {pthread_mutex_unlock(&_log_mutex); }
-# define INIT() (1)
-# define SHUTDOWN() do {} while (0)
+#define LOG_LOCK() if(_threads_enabled) {pthread_mutex_lock(&_log_mutex); }
+#define LOG_UNLOCK() if(_threads_enabled) {pthread_mutex_unlock(&_log_mutex); }
+#define INIT() (1)
+#define SHUTDOWN() do {} while (0)
-# endif /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
+#endif /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
-# else /* EFL_HAVE_WIN32_THREADS */
+#else /* EFL_HAVE_WIN32_THREADS */
typedef DWORD Thread;
static DWORD _main_thread;
-# define SELF() GetCurrentThreadId()
-# define IS_MAIN(t) (t == _main_thread)
-# define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
-# define CHECK_MAIN(...) \
+#define SELF() GetCurrentThreadId()
+#define IS_MAIN(t) (t == _main_thread)
+#define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
+#define CHECK_MAIN(...) \
do { \
if (!IS_MAIN(GetCurrentThreadId())) { \
fprintf(stderr, \
@@ -417,24 +417,24 @@ static DWORD _main_thread;
static HANDLE _log_mutex = NULL;
-# define LOG_LOCK() if(_threads_enabled) WaitForSingleObject(_log_mutex, INFINITE)
-# define LOG_UNLOCK() if(_threads_enabled) ReleaseMutex(_log_mutex)
-# define INIT() ((_log_mutex = CreateMutex(NULL, FALSE, NULL)) ? 1 : 0)
-# define SHUTDOWN() if (_log_mutex) CloseHandle(_log_mutex)
+#define LOG_LOCK() if(_threads_enabled) WaitForSingleObject(_log_mutex, INFINITE)
+#define LOG_UNLOCK() if(_threads_enabled) ReleaseMutex(_log_mutex)
+#define INIT() ((_log_mutex = CreateMutex(NULL, FALSE, NULL)) ? 1 : 0)
+#define SHUTDOWN() if (_log_mutex) CloseHandle(_log_mutex)
-# endif /* EFL_HAVE_WIN32_THREADS */
+#endif /* EFL_HAVE_WIN32_THREADS */
-#else /* ! EFL_HAVE_THREADS */
+#else /* ! EFL_HAVE_THREADS */
-# define LOG_LOCK() do {} while (0)
-# define LOG_UNLOCK() do {} while (0)
-# define IS_MAIN(t) (1)
-# define IS_OTHER(t) (0)
-# define CHECK_MAIN(...) do {} while (0)
-# define INIT() (1)
-# define SHUTDOWN() do {} while (0)
+#define LOG_LOCK() do {} while (0)
+#define LOG_UNLOCK() do {} while (0)
+#define IS_MAIN(t) (1)
+#define IS_OTHER(t) (0)
+#define CHECK_MAIN(...) do {} while (0)
+#define INIT() (1)
+#define SHUTDOWN() do {} while (0)
-#endif /* ! EFL_HAVE_THREADS */
+#endif /* ! EFL_HAVE_THREADS */
// List of domains registered
@@ -459,600 +459,569 @@ static Eina_Log_Level _log_level = EINA_LOG_LEVEL_ERR;
* eina_log_print_level_name_color_get()
*/
static const char *_names[] = {
- "CRI",
- "ERR",
- "WRN",
- "INF",
- "DBG",
+ "CRI",
+ "ERR",
+ "WRN",
+ "INF",
+ "DBG",
};
#ifdef _WIN32
-static int
-eina_log_win32_color_get(const char *domain_str)
+static int eina_log_win32_color_get(const char *domain_str)
{
- char *str;
- char *tmp;
- char *tmp2;
- int code = -1;
- int lighted = 0;
- int ret = 0;
-
- str = strdup(domain_str);
- if (!str)
- return 0;
-
- /* this should not append */
- if (str[0] != '\033')
- {
- free(str);
- return 0;
- }
-
- /* we skip the first char and the [ */
- tmp = tmp2 = str + 2;
- while (*tmp != 'm')
- {
- if (*tmp == ';')
- {
- *tmp = '\0';
- code = atol(tmp2);
- tmp++;
- tmp2 = tmp;
- }
-
- tmp++;
- }
- *tmp = '\0';
- if (code < 0)
- code = atol(tmp2);
- else
- lighted = atol(tmp2);
-
- free(str);
-
- if (code < lighted)
- {
- int c;
-
- c = code;
- code = lighted;
- lighted = c;
- }
-
- if (lighted)
- ret = FOREGROUND_INTENSITY;
-
- if (code == 31)
- ret |= FOREGROUND_RED;
- else if (code == 32)
- ret |= FOREGROUND_GREEN;
- else if (code == 33)
- ret |= FOREGROUND_RED | FOREGROUND_GREEN;
- else if (code == 34)
- ret |= FOREGROUND_BLUE;
- else if (code == 36)
- ret |= FOREGROUND_GREEN | FOREGROUND_BLUE;
- else if (code == 37)
- ret |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
-
- return ret;
+ char *str;
+ char *tmp;
+ char *tmp2;
+ int code = -1;
+ int lighted = 0;
+ int ret = 0;
+
+ str = strdup(domain_str);
+ if (!str)
+ return 0;
+
+ /* this should not append */
+ if (str[0] != '\033') {
+ free(str);
+ return 0;
+ }
+
+ /* we skip the first char and the [ */
+ tmp = tmp2 = str + 2;
+ while (*tmp != 'm') {
+ if (*tmp == ';') {
+ *tmp = '\0';
+ code = atol(tmp2);
+ tmp++;
+ tmp2 = tmp;
+ }
+
+ tmp++;
+ }
+ *tmp = '\0';
+ if (code < 0)
+ code = atol(tmp2);
+ else
+ lighted = atol(tmp2);
+
+ free(str);
+
+ if (code < lighted) {
+ int c;
+
+ c = code;
+ code = lighted;
+ lighted = c;
+ }
+
+ if (lighted)
+ ret = FOREGROUND_INTENSITY;
+
+ if (code == 31)
+ ret |= FOREGROUND_RED;
+ else if (code == 32)
+ ret |= FOREGROUND_GREEN;
+ else if (code == 33)
+ ret |= FOREGROUND_RED | FOREGROUND_GREEN;
+ else if (code == 34)
+ ret |= FOREGROUND_BLUE;
+ else if (code == 36)
+ ret |= FOREGROUND_GREEN | FOREGROUND_BLUE;
+ else if (code == 37)
+ ret |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
+
+ return ret;
}
#endif
static inline void
eina_log_print_level_name_get(int level, const char **p_name)
{
- static char buf[4];
- /* NOTE: if you change this, also change
- * eina_log_print_level_name_color_get()
- * eina_log_level_name_get() (at eina_inline_log.x)
- */
- if (EINA_UNLIKELY(level < 0))
- {
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
- }
- else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
- {
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
- }
- else
- *p_name = _names[level];
+ static char buf[4];
+ /* NOTE: if you change this, also change
+ * eina_log_print_level_name_color_get()
+ * eina_log_level_name_get() (at eina_inline_log.x)
+ */
+ if (EINA_UNLIKELY(level < 0)) {
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
+ } else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS)) {
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
+ } else
+ *p_name = _names[level];
}
#ifdef _WIN32
static inline void
eina_log_print_level_name_color_get(int level,
- const char **p_name,
- int *p_color)
+ const char **p_name, int *p_color)
{
- static char buf[4];
- /* NOTE: if you change this, also change:
- * eina_log_print_level_name_get()
- */
- if (EINA_UNLIKELY(level < 0))
- {
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
- }
- else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
- {
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
- }
- else
- *p_name = _names[level];
-
- *p_color = eina_log_win32_color_get(eina_log_level_color_get(level));
+ static char buf[4];
+ /* NOTE: if you change this, also change:
+ * eina_log_print_level_name_get()
+ */
+ if (EINA_UNLIKELY(level < 0)) {
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
+ } else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS)) {
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
+ } else
+ *p_name = _names[level];
+
+ *p_color =
+ eina_log_win32_color_get(eina_log_level_color_get(level));
}
#else
static inline void
eina_log_print_level_name_color_get(int level,
- const char **p_name,
- const char **p_color)
+ const char **p_name,
+ const char **p_color)
{
- static char buf[4];
- /* NOTE: if you change this, also change:
- * eina_log_print_level_name_get()
- */
- if (EINA_UNLIKELY(level < 0))
- {
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
- }
- else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
- {
- snprintf(buf, sizeof(buf), "%03d", level);
- *p_name = buf;
- }
- else
- *p_name = _names[level];
-
- *p_color = eina_log_level_color_get(level);
+ static char buf[4];
+ /* NOTE: if you change this, also change:
+ * eina_log_print_level_name_get()
+ */
+ if (EINA_UNLIKELY(level < 0)) {
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
+ } else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS)) {
+ snprintf(buf, sizeof(buf), "%03d", level);
+ *p_name = buf;
+ } else
+ *p_name = _names[level];
+
+ *p_color = eina_log_level_color_get(level);
}
#endif
#define DECLARE_LEVEL_NAME(level) const char *name; \
eina_log_print_level_name_get(level, &name)
#ifdef _WIN32
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; \
+#define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; \
eina_log_print_level_name_color_get(level, &name, &color)
#else
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; \
+#define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; \
eina_log_print_level_name_color_get(level, &name, &color)
#endif
/** No threads, No color */
static void
-eina_log_print_prefix_NOthreads_NOcolor_file_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line)
+eina_log_print_prefix_NOthreads_NOcolor_file_func(FILE * fp,
+ const Eina_Log_Domain *
+ d, Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
{
- DECLARE_LEVEL_NAME(level);
- fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
+ DECLARE_LEVEL_NAME(level);
+ fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line,
+ fnc);
}
static void
-eina_log_print_prefix_NOthreads_NOcolor_NOfile_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file __UNUSED__,
- const char *fnc,
- int line __UNUSED__)
+eina_log_print_prefix_NOthreads_NOcolor_NOfile_func(FILE * fp,
+ const Eina_Log_Domain *
+ d,
+ Eina_Log_Level level,
+ const char *file
+ __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
- DECLARE_LEVEL_NAME(level);
- fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
+ DECLARE_LEVEL_NAME(level);
+ fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
}
static void
-eina_log_print_prefix_NOthreads_NOcolor_file_NOfunc(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc __UNUSED__,
- int line)
+eina_log_print_prefix_NOthreads_NOcolor_file_NOfunc(FILE * fp,
+ const Eina_Log_Domain *
+ d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc
+ __UNUSED__, int line)
{
- DECLARE_LEVEL_NAME(level);
- fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
+ DECLARE_LEVEL_NAME(level);
+ fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
}
/* No threads, color */
static void
-eina_log_print_prefix_NOthreads_color_file_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line)
+eina_log_print_prefix_NOthreads_color_file_func(FILE * fp,
+ const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc, int line)
{
- DECLARE_LEVEL_NAME_COLOR(level);
+ DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s", d->name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, " %s:%d ", file, line);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED |
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, " ");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " %s:%d ", file, line);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
#else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, file, line, fnc);
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, file, line, fnc);
#endif
}
static void
-eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file __UNUSED__,
- const char *fnc,
- int line __UNUSED__)
+eina_log_print_prefix_NOthreads_color_NOfile_func(FILE * fp,
+ const Eina_Log_Domain *
+ d, Eina_Log_Level level,
+ const char *file
+ __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
- DECLARE_LEVEL_NAME_COLOR(level);
+ DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED |
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, " ");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
#else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, fnc);
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, fnc);
#endif
}
static void
-eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc __UNUSED__,
- int line)
+eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE * fp,
+ const Eina_Log_Domain *
+ d, Eina_Log_Level level,
+ const char *file,
+ const char *fnc
+ __UNUSED__, int line)
{
- DECLARE_LEVEL_NAME_COLOR(level);
+ DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s", d->name);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, " %s:%d ", file, line);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " %s:%d ", file, line);
#else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
- color, name, d->domain_str, file, line);
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
+ color, name, d->domain_str, file, line);
#endif
}
/** threads, No color */
#ifdef EFL_HAVE_THREADS
static void
-eina_log_print_prefix_threads_NOcolor_file_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line)
+eina_log_print_prefix_threads_NOcolor_file_func(FILE * fp,
+ const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc, int line)
{
- Thread cur;
-
- DECLARE_LEVEL_NAME(level);
- cur = SELF();
- if (IS_OTHER(cur))
- {
- fprintf(fp, "%s:%s[T:%lu] %s:%d %s() ",
- name, d->domain_str, (unsigned long)cur, file, line, fnc);
- return;
- }
-
- fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
+ Thread cur;
+
+ DECLARE_LEVEL_NAME(level);
+ cur = SELF();
+ if (IS_OTHER(cur)) {
+ fprintf(fp, "%s:%s[T:%lu] %s:%d %s() ",
+ name, d->domain_str, (unsigned long) cur, file,
+ line, fnc);
+ return;
+ }
+
+ fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line,
+ fnc);
}
static void
-eina_log_print_prefix_threads_NOcolor_NOfile_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file __UNUSED__,
- const char *fnc,
- int line __UNUSED__)
+eina_log_print_prefix_threads_NOcolor_NOfile_func(FILE * fp,
+ const Eina_Log_Domain *
+ d, Eina_Log_Level level,
+ const char *file
+ __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
- Thread cur;
-
- DECLARE_LEVEL_NAME(level);
- cur = SELF();
- if (IS_OTHER(cur))
- {
- fprintf(fp, "%s:%s[T:%lu] %s() ",
- name, d->domain_str, (unsigned long)cur, fnc);
- return;
- }
-
- fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
+ Thread cur;
+
+ DECLARE_LEVEL_NAME(level);
+ cur = SELF();
+ if (IS_OTHER(cur)) {
+ fprintf(fp, "%s:%s[T:%lu] %s() ",
+ name, d->domain_str, (unsigned long) cur, fnc);
+ return;
+ }
+
+ fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
}
static void
-eina_log_print_prefix_threads_NOcolor_file_NOfunc(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc __UNUSED__,
- int line)
+eina_log_print_prefix_threads_NOcolor_file_NOfunc(FILE * fp,
+ const Eina_Log_Domain *
+ d, Eina_Log_Level level,
+ const char *file,
+ const char *fnc
+ __UNUSED__, int line)
{
- Thread cur;
-
- DECLARE_LEVEL_NAME(level);
- cur = SELF();
- if (IS_OTHER(cur))
- {
- fprintf(fp, "%s:%s[T:%lu] %s:%d ",
- name, d->domain_str, (unsigned long)cur, file, line);
- return;
- }
-
- fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
+ Thread cur;
+
+ DECLARE_LEVEL_NAME(level);
+ cur = SELF();
+ if (IS_OTHER(cur)) {
+ fprintf(fp, "%s:%s[T:%lu] %s:%d ",
+ name, d->domain_str, (unsigned long) cur, file,
+ line);
+ return;
+ }
+
+ fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
}
/* threads, color */
static void
-eina_log_print_prefix_threads_color_file_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line)
+eina_log_print_prefix_threads_color_file_func(FILE * fp,
+ const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc, int line)
{
- Thread cur;
-
- DECLARE_LEVEL_NAME_COLOR(level);
- cur = SELF();
- if (IS_OTHER(cur))
- {
-# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "] %s:%d ", file, line);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED |
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, " ");
-# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, (unsigned long)cur, file,
- line, fnc);
-# endif
- return;
- }
-
-# ifdef _WIN32
- eina_log_print_prefix_NOthreads_color_file_func(fp,
- d,
- level,
- file,
- fnc,
- line);
-# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, file, line, fnc);
-# endif
+ Thread cur;
+
+ DECLARE_LEVEL_NAME_COLOR(level);
+ cur = SELF();
+ if (IS_OTHER(cur)) {
+#ifdef _WIN32
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->
+ domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long) cur);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "] %s:%d ", file, line);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY |
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
+#else
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, (unsigned long) cur,
+ file, line, fnc);
+#endif
+ return;
+ }
+#ifdef _WIN32
+ eina_log_print_prefix_NOthreads_color_file_func(fp,
+ d,
+ level,
+ file, fnc, line);
+#else
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, file, line, fnc);
+#endif
}
static void
-eina_log_print_prefix_threads_color_NOfile_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file __UNUSED__,
- const char *fnc,
- int line __UNUSED__)
+eina_log_print_prefix_threads_color_NOfile_func(FILE * fp,
+ const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file
+ __UNUSED__,
+ const char *fnc,
+ int line __UNUSED__)
{
- Thread cur;
-
- DECLARE_LEVEL_NAME_COLOR(level);
- cur = SELF();
- if (IS_OTHER(cur))
- {
-# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED |
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, " ");
-# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, (unsigned long)cur, fnc);
-# endif
- return;
- }
-
-# ifdef _WIN32
- eina_log_print_prefix_NOthreads_color_NOfile_func(fp,
- d,
- level,
- file,
- fnc,
- line);
-# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, d->domain_str, fnc);
-# endif
+ Thread cur;
+
+ DECLARE_LEVEL_NAME_COLOR(level);
+ cur = SELF();
+ if (IS_OTHER(cur)) {
+#ifdef _WIN32
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->
+ domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long) cur);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY |
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
+#else
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, (unsigned long) cur,
+ fnc);
+#endif
+ return;
+ }
+#ifdef _WIN32
+ eina_log_print_prefix_NOthreads_color_NOfile_func(fp,
+ d,
+ level,
+ file, fnc, line);
+#else
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, d->domain_str, fnc);
+#endif
}
static void
-eina_log_print_prefix_threads_color_file_NOfunc(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc __UNUSED__,
- int line)
+eina_log_print_prefix_threads_color_file_NOfunc(FILE * fp,
+ const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc __UNUSED__,
+ int line)
{
- Thread cur;
-
- DECLARE_LEVEL_NAME_COLOR(level);
- cur = SELF();
- if (IS_OTHER(cur))
- {
-# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "] %s:%d ", file, line);
-# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ",
- color, name, d->domain_str, (unsigned long)cur, file, line);
-# endif
- return;
- }
-
-# ifdef _WIN32
- eina_log_print_prefix_NOthreads_color_file_NOfunc(fp,
- d,
- level,
- file,
- fnc,
- line);
-# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
- color, name, d->domain_str, file, line);
-# endif
+ Thread cur;
+
+ DECLARE_LEVEL_NAME_COLOR(level);
+ cur = SELF();
+ if (IS_OTHER(cur)) {
+#ifdef _WIN32
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->
+ domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long) cur);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "] %s:%d ", file, line);
+#else
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET
+ "] %s:%d ", color, name, d->domain_str,
+ (unsigned long) cur, file, line);
+#endif
+ return;
+ }
+#ifdef _WIN32
+ eina_log_print_prefix_NOthreads_color_file_NOfunc(fp,
+ d,
+ level,
+ file, fnc, line);
+#else
+ fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
+ color, name, d->domain_str, file, line);
+#endif
}
-#endif /* EFL_HAVE_THREADS */
+#endif /* EFL_HAVE_THREADS */
-static void (*_eina_log_print_prefix)(FILE *fp, const Eina_Log_Domain *d,
- Eina_Log_Level level, const char *file,
- const char *fnc,
- int line) =
- eina_log_print_prefix_NOthreads_color_file_func;
+static void (*_eina_log_print_prefix) (FILE * fp,
+ const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file, const char *fnc,
+ int line) =
+ eina_log_print_prefix_NOthreads_color_file_func;
-static inline void
-eina_log_print_prefix_update(void)
+static inline void eina_log_print_prefix_update(void)
{
- if (_disable_file && _disable_function)
- {
- fprintf(stderr, "ERROR: cannot have " EINA_LOG_ENV_FILE_DISABLE " and "
- EINA_LOG_ENV_FUNCTION_DISABLE " set at the same time, will "
- "just disable function.\n");
- _disable_file = 0;
- }
-
+ if (_disable_file && _disable_function) {
+ fprintf(stderr,
+ "ERROR: cannot have " EINA_LOG_ENV_FILE_DISABLE
+ " and " EINA_LOG_ENV_FUNCTION_DISABLE
+ " set at the same time, will "
+ "just disable function.\n");
+ _disable_file = 0;
+ }
#define S(NOthread, NOcolor, NOfile, NOfunc) \
_eina_log_print_prefix = \
eina_log_print_prefix_ ## NOthread ## threads_ ## NOcolor ## color_ ## \
@@ -1060,50 +1029,42 @@ eina_log_print_prefix_update(void)
## file_ ## NOfunc ## func
#ifdef EFL_HAVE_THREADS
- if (_threads_enabled)
- {
- if (_disable_color)
- {
- if (_disable_file)
- S(,NO,NO,);
- else if (_disable_function)
- S(,NO,,NO);
- else
- S(,NO,,);
- }
- else
- {
- if (_disable_file)
- S(,,NO,);
- else if (_disable_function)
- S(,,,NO);
- else
- S(,,,);
- }
-
- return;
- }
-
+ if (_threads_enabled) {
+ if (_disable_color) {
+ if (_disable_file)
+ S(, NO, NO,);
+ else if (_disable_function)
+ S(, NO,, NO);
+ else
+ S(, NO,,);
+ } else {
+ if (_disable_file)
+ S(,, NO,);
+ else if (_disable_function)
+ S(,,, NO);
+ else
+ S(,,,);
+ }
+
+ return;
+ }
#endif
- if (_disable_color)
- {
- if (_disable_file)
- S(NO,NO,NO,);
- else if (_disable_function)
- S(NO,NO,,NO);
- else
- S(NO,NO,,);
- }
- else
- {
- if (_disable_file)
- S(NO,,NO,);
- else if (_disable_function)
- S(NO,,,NO);
- else
- S(NO,,,);
- }
+ if (_disable_color) {
+ if (_disable_file)
+ S(NO, NO, NO,);
+ else if (_disable_function)
+ S(NO, NO,, NO);
+ else
+ S(NO, NO,,);
+ } else {
+ if (_disable_file)
+ S(NO,, NO,);
+ else if (_disable_function)
+ S(NO,,, NO);
+ else
+ S(NO,,,);
+ }
#undef S
}
@@ -1111,398 +1072,374 @@ eina_log_print_prefix_update(void)
/*
* Creates a colored domain name string.
*/
-static const char *
-eina_log_domain_str_get(const char *name, const char *color)
+static const char *eina_log_domain_str_get(const char *name,
+ const char *color)
{
- const char *d;
-
- if (color)
- {
- size_t name_len;
- size_t color_len;
-
- name_len = strlen(name);
- color_len = strlen(color);
- d =
- malloc(sizeof(char) *
- (color_len + name_len + strlen(EINA_COLOR_RESET) + 1));
- if (!d)
- return NULL;
-
- memcpy((char *)d, color, color_len);
- memcpy((char *)(d + color_len), name, name_len);
- memcpy((char *)(d + color_len + name_len), EINA_COLOR_RESET,
- strlen(EINA_COLOR_RESET));
- ((char *)d)[color_len + name_len + strlen(EINA_COLOR_RESET)] = '\0';
- }
- else
- d = strdup(name);
-
- return d;
+ const char *d;
+
+ if (color) {
+ size_t name_len;
+ size_t color_len;
+
+ name_len = strlen(name);
+ color_len = strlen(color);
+ d = malloc(sizeof(char) *
+ (color_len + name_len +
+ strlen(EINA_COLOR_RESET) + 1));
+ if (!d)
+ return NULL;
+
+ memcpy((char *) d, color, color_len);
+ memcpy((char *) (d + color_len), name, name_len);
+ memcpy((char *) (d + color_len + name_len),
+ EINA_COLOR_RESET, strlen(EINA_COLOR_RESET));
+ ((char *) d)[color_len + name_len +
+ strlen(EINA_COLOR_RESET)] = '\0';
+ } else
+ d = strdup(name);
+
+ return d;
}
/*
* Setups a new logging domain to the name and color specified. Note that this
* constructor acts upon an pre-allocated object.
*/
-static Eina_Log_Domain *
-eina_log_domain_new(Eina_Log_Domain *d, const char *name, const char *color)
+static Eina_Log_Domain *eina_log_domain_new(Eina_Log_Domain * d,
+ const char *name,
+ const char *color)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
-
- d->level = EINA_LOG_LEVEL_UNKNOWN;
- d->deleted = EINA_FALSE;
-
- if (name)
- {
- if ((color) && (!_disable_color))
- d->domain_str = eina_log_domain_str_get(name, color);
- else
- d->domain_str = eina_log_domain_str_get(name, NULL);
-
- d->name = strdup(name);
- d->namelen = strlen(name);
- }
- else
- {
- d->domain_str = NULL;
- d->name = NULL;
- d->namelen = 0;
- }
-
- return d;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+
+ d->level = EINA_LOG_LEVEL_UNKNOWN;
+ d->deleted = EINA_FALSE;
+
+ if (name) {
+ if ((color) && (!_disable_color))
+ d->domain_str =
+ eina_log_domain_str_get(name, color);
+ else
+ d->domain_str =
+ eina_log_domain_str_get(name, NULL);
+
+ d->name = strdup(name);
+ d->namelen = strlen(name);
+ } else {
+ d->domain_str = NULL;
+ d->name = NULL;
+ d->namelen = 0;
+ }
+
+ return d;
}
/*
* Frees internal strings of a log domain, keeping the log domain itself as a
* slot for next domain registers.
*/
-static void
-eina_log_domain_free(Eina_Log_Domain *d)
+static void eina_log_domain_free(Eina_Log_Domain * d)
{
- EINA_SAFETY_ON_NULL_RETURN(d);
+ EINA_SAFETY_ON_NULL_RETURN(d);
- if (d->domain_str)
- free((char *)d->domain_str);
+ if (d->domain_str)
+ free((char *) d->domain_str);
- if (d->name)
- free((char *)d->name);
+ if (d->name)
+ free((char *) d->name);
}
/*
* Parses domain levels passed through the env var.
*/
-static void
-eina_log_domain_parse_pendings(void)
+static void eina_log_domain_parse_pendings(void)
{
- const char *start;
-
- if (!(start = getenv(EINA_LOG_ENV_LEVELS)))
- return;
-
- // name1:level1,name2:level2,name3:level3,...
- while (1)
- {
- Eina_Log_Domain_Level_Pending *p;
- char *end = NULL;
- char *tmp = NULL;
- long int level;
-
- end = strchr(start, ':');
- if (!end)
- break;
-
- // Parse level, keep going if failed
- level = strtol((char *)(end + 1), &tmp, 10);
- if (tmp == (end + 1))
- goto parse_end;
-
- // Parse name
- p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
- if (!p)
- break;
-
- p->namelen = end - start;
- memcpy((char *)p->name, start, end - start);
- ((char *)p->name)[end - start] = '\0';
- p->level = level;
-
- _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(p));
-
-parse_end:
- start = strchr(tmp, ',');
- if (start)
- start++;
- else
- break;
- }
+ const char *start;
+
+ if (!(start = getenv(EINA_LOG_ENV_LEVELS)))
+ return;
+
+ // name1:level1,name2:level2,name3:level3,...
+ while (1) {
+ Eina_Log_Domain_Level_Pending *p;
+ char *end = NULL;
+ char *tmp = NULL;
+ long int level;
+
+ end = strchr(start, ':');
+ if (!end)
+ break;
+
+ // Parse level, keep going if failed
+ level = strtol((char *) (end + 1), &tmp, 10);
+ if (tmp == (end + 1))
+ goto parse_end;
+
+ // Parse name
+ p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end -
+ start + 1);
+ if (!p)
+ break;
+
+ p->namelen = end - start;
+ memcpy((char *) p->name, start, end - start);
+ ((char *) p->name)[end - start] = '\0';
+ p->level = level;
+
+ _pending_list =
+ eina_inlist_append(_pending_list, EINA_INLIST_GET(p));
+
+ parse_end:
+ start = strchr(tmp, ',');
+ if (start)
+ start++;
+ else
+ break;
+ }
}
-static void
-eina_log_domain_parse_pending_globs(void)
+static void eina_log_domain_parse_pending_globs(void)
{
- const char *start;
-
- if (!(start = getenv(EINA_LOG_ENV_LEVELS_GLOB)))
- return;
-
- // name1:level1,name2:level2,name3:level3,...
- while (1)
- {
- Eina_Log_Domain_Level_Pending *p;
- char *end = NULL;
- char *tmp = NULL;
- long int level;
-
- end = strchr(start, ':');
- if (!end)
- break;
-
- // Parse level, keep going if failed
- level = strtol((char *)(end + 1), &tmp, 10);
- if (tmp == (end + 1))
- goto parse_end;
-
- // Parse name
- p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
- if (!p)
- break;
-
- p->namelen = 0; /* not that useful */
- memcpy((char *)p->name, start, end - start);
- ((char *)p->name)[end - start] = '\0';
- p->level = level;
-
- _glob_list = eina_inlist_append(_glob_list, EINA_INLIST_GET(p));
-
-parse_end:
- start = strchr(tmp, ',');
- if (start)
- start++;
- else
- break;
- }
+ const char *start;
+
+ if (!(start = getenv(EINA_LOG_ENV_LEVELS_GLOB)))
+ return;
+
+ // name1:level1,name2:level2,name3:level3,...
+ while (1) {
+ Eina_Log_Domain_Level_Pending *p;
+ char *end = NULL;
+ char *tmp = NULL;
+ long int level;
+
+ end = strchr(start, ':');
+ if (!end)
+ break;
+
+ // Parse level, keep going if failed
+ level = strtol((char *) (end + 1), &tmp, 10);
+ if (tmp == (end + 1))
+ goto parse_end;
+
+ // Parse name
+ p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end -
+ start + 1);
+ if (!p)
+ break;
+
+ p->namelen = 0; /* not that useful */
+ memcpy((char *) p->name, start, end - start);
+ ((char *) p->name)[end - start] = '\0';
+ p->level = level;
+
+ _glob_list =
+ eina_inlist_append(_glob_list, EINA_INLIST_GET(p));
+
+ parse_end:
+ start = strchr(tmp, ',');
+ if (start)
+ start++;
+ else
+ break;
+ }
}
static inline int
eina_log_domain_register_unlocked(const char *name, const char *color)
{
- Eina_Log_Domain_Level_Pending *pending = NULL;
- size_t namelen;
- unsigned int i;
-
- for (i = 0; i < _log_domains_count; i++)
- {
- if (_log_domains[i].deleted)
- {
- // Found a flagged slot, free domain_str and replace slot
- eina_log_domain_new(&_log_domains[i], name, color);
- goto finish_register;
- }
- }
-
- if (_log_domains_count >= _log_domains_allocated)
- {
- Eina_Log_Domain *tmp;
- size_t size;
-
- if (!_log_domains)
- // special case for init, eina itself will allocate a dozen of domains
- size = 24;
- else
- // grow 8 buckets to minimize reallocs
- size = _log_domains_allocated + 8;
-
- tmp = realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
-
- if (tmp)
- {
- // Success!
- _log_domains = tmp;
- _log_domains_allocated = size;
- }
- else
- return -1;
- }
-
- // Use an allocated slot
- eina_log_domain_new(&_log_domains[i], name, color);
- _log_domains_count++;
-
-finish_register:
- namelen = _log_domains[i].namelen;
-
- EINA_INLIST_FOREACH(_pending_list, pending)
- {
- if ((namelen == pending->namelen) && (strcmp(pending->name, name) == 0))
- {
- _log_domains[i].level = pending->level;
- _pending_list =
- eina_inlist_remove(_pending_list, EINA_INLIST_GET(pending));
- free(pending);
- break;
- }
- }
-
- if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN)
- {
- EINA_INLIST_FOREACH(_glob_list, pending)
- {
- if (!fnmatch(pending->name, name, 0))
- {
- _log_domains[i].level = pending->level;
- break;
- }
- }
- }
-
- // Check if level is still UNKNOWN, set it to global
- if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN)
- _log_domains[i].level = _log_level;
-
- return i;
+ Eina_Log_Domain_Level_Pending *pending = NULL;
+ size_t namelen;
+ unsigned int i;
+
+ for (i = 0; i < _log_domains_count; i++) {
+ if (_log_domains[i].deleted) {
+ // Found a flagged slot, free domain_str and replace slot
+ eina_log_domain_new(&_log_domains[i], name, color);
+ goto finish_register;
+ }
+ }
+
+ if (_log_domains_count >= _log_domains_allocated) {
+ Eina_Log_Domain *tmp;
+ size_t size;
+
+ if (!_log_domains)
+ // special case for init, eina itself will allocate a dozen of domains
+ size = 24;
+ else
+ // grow 8 buckets to minimize reallocs
+ size = _log_domains_allocated + 8;
+
+ tmp =
+ realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
+
+ if (tmp) {
+ // Success!
+ _log_domains = tmp;
+ _log_domains_allocated = size;
+ } else
+ return -1;
+ }
+ // Use an allocated slot
+ eina_log_domain_new(&_log_domains[i], name, color);
+ _log_domains_count++;
+
+ finish_register:
+ namelen = _log_domains[i].namelen;
+
+ EINA_INLIST_FOREACH(_pending_list, pending) {
+ if ((namelen == pending->namelen)
+ && (strcmp(pending->name, name) == 0)) {
+ _log_domains[i].level = pending->level;
+ _pending_list =
+ eina_inlist_remove(_pending_list,
+ EINA_INLIST_GET(pending));
+ free(pending);
+ break;
+ }
+ }
+
+ if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN) {
+ EINA_INLIST_FOREACH(_glob_list, pending) {
+ if (!fnmatch(pending->name, name, 0)) {
+ _log_domains[i].level = pending->level;
+ break;
+ }
+ }
+ }
+ // Check if level is still UNKNOWN, set it to global
+ if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN)
+ _log_domains[i].level = _log_level;
+
+ return i;
}
-static inline Eina_Bool
-eina_log_term_color_supported(const char *term)
+static inline Eina_Bool eina_log_term_color_supported(const char *term)
{
- const char *tail;
-
- if (!term)
- return EINA_FALSE;
-
- tail = term + 1;
- switch (term[0])
- {
- /* list of known to support color terminals,
- * take from gentoo's portage.
- */
-
- case 'x': /* xterm and xterm-color */
- return ((strncmp(tail, "term", sizeof("term") - 1) == 0) &&
- ((tail[sizeof("term") - 1] == '\0') ||
- (strcmp(tail + sizeof("term") - 1, "-color") == 0)));
-
- case 'E': /* Eterm */
- case 'a': /* aterm */
- case 'k': /* kterm */
- return (strcmp(tail, "term") == 0);
-
- case 'r': /* xrvt or rxvt-unicode */
- return ((strncmp(tail, "xvt", sizeof("xvt") - 1) == 0) &&
- ((tail[sizeof("xvt") - 1] == '\0') ||
- (strcmp(tail + sizeof("xvt") - 1, "-unicode") == 0)));
-
- case 's': /* screen */
- return (strcmp(tail, "creen") == 0);
-
- case 'g': /* gnome */
- return (strcmp(tail, "nome") == 0);
-
- case 'i': /* interix */
- return (strcmp(tail, "nterix") == 0);
-
- default:
- return EINA_FALSE;
- }
+ const char *tail;
+
+ if (!term)
+ return EINA_FALSE;
+
+ tail = term + 1;
+ switch (term[0]) {
+ /* list of known to support color terminals,
+ * take from gentoo's portage.
+ */
+
+ case 'x': /* xterm and xterm-color */
+ return ((strncmp(tail, "term", sizeof("term") - 1) == 0) &&
+ ((tail[sizeof("term") - 1] == '\0') ||
+ (strcmp(tail + sizeof("term") - 1, "-color") ==
+ 0)));
+
+ case 'E': /* Eterm */
+ case 'a': /* aterm */
+ case 'k': /* kterm */
+ return (strcmp(tail, "term") == 0);
+
+ case 'r': /* xrvt or rxvt-unicode */
+ return ((strncmp(tail, "xvt", sizeof("xvt") - 1) == 0) &&
+ ((tail[sizeof("xvt") - 1] == '\0') ||
+ (strcmp(tail + sizeof("xvt") - 1, "-unicode") ==
+ 0)));
+
+ case 's': /* screen */
+ return (strcmp(tail, "creen") == 0);
+
+ case 'g': /* gnome */
+ return (strcmp(tail, "nome") == 0);
+
+ case 'i': /* interix */
+ return (strcmp(tail, "nterix") == 0);
+
+ default:
+ return EINA_FALSE;
+ }
}
-static inline void
-eina_log_domain_unregister_unlocked(int domain)
+static inline void eina_log_domain_unregister_unlocked(int domain)
{
- Eina_Log_Domain *d;
+ Eina_Log_Domain *d;
- if ((unsigned int)domain >= _log_domains_count)
- return;
+ if ((unsigned int) domain >= _log_domains_count)
+ return;
- d = &_log_domains[domain];
- eina_log_domain_free(d);
- d->deleted = 1;
+ d = &_log_domains[domain];
+ eina_log_domain_free(d);
+ d->deleted = 1;
}
static inline void
eina_log_print_unlocked(int domain,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- va_list args)
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line, const char *fmt, va_list args)
{
- Eina_Log_Domain *d;
+ Eina_Log_Domain *d;
#ifdef EINA_SAFETY_CHECKS
- if (EINA_UNLIKELY((unsigned int)domain >= _log_domains_count) ||
- EINA_UNLIKELY(domain < 0))
- {
- if (file && fnc && fmt)
- fprintf(
- stderr,
- "CRI: %s:%d %s() eina_log_print() unknown domain %d, original message format '%s'\n",
- file,
- line,
- fnc,
- domain,
- fmt);
- else
- fprintf(
- stderr,
- "CRI: eina_log_print() unknown domain %d, original message format '%s'\n",
- domain,
- fmt ? fmt : "");
-
- if (_abort_on_critical)
- abort();
-
- return;
- }
-
+ if (EINA_UNLIKELY((unsigned int) domain >= _log_domains_count) ||
+ EINA_UNLIKELY(domain < 0)) {
+ if (file && fnc && fmt)
+ fprintf(stderr,
+ "CRI: %s:%d %s() eina_log_print() unknown domain %d, original message format '%s'\n",
+ file, line, fnc, domain, fmt);
+ else
+ fprintf(stderr,
+ "CRI: eina_log_print() unknown domain %d, original message format '%s'\n",
+ domain, fmt ? fmt : "");
+
+ if (_abort_on_critical)
+ abort();
+
+ return;
+ }
#endif
- d = _log_domains + domain;
+ d = _log_domains + domain;
#ifdef EINA_SAFETY_CHECKS
- if (EINA_UNLIKELY(d->deleted))
- {
- fprintf(stderr,
- "ERR: eina_log_print() domain %d is deleted\n",
- domain);
- return;
- }
-
+ if (EINA_UNLIKELY(d->deleted)) {
+ fprintf(stderr,
+ "ERR: eina_log_print() domain %d is deleted\n",
+ domain);
+ return;
+ }
#endif
- if (level > d->level)
- return;
+ if (level > d->level)
+ return;
#ifdef _WIN32
- {
- char *wfmt;
- char *tmp;
-
- wfmt = strdup(fmt);
- if (!wfmt)
- {
- fprintf(stderr, "ERR: %s: can not allocate memory\n", __FUNCTION__);
- return;
- }
-
- tmp = wfmt;
- while (strchr(tmp, "%"))
- {
- tmp++;
- if (*tmp == 'z')
- *tmp = 'I';
- }
- _print_cb(d, level, file, fnc, line, wfmt, _print_cb_data, args);
- free(wfmt);
- }
+ {
+ char *wfmt;
+ char *tmp;
+
+ wfmt = strdup(fmt);
+ if (!wfmt) {
+ fprintf(stderr,
+ "ERR: %s: can not allocate memory\n",
+ __FUNCTION__);
+ return;
+ }
+
+ tmp = wfmt;
+ while (strchr(tmp, "%")) {
+ tmp++;
+ if (*tmp == 'z')
+ *tmp = 'I';
+ }
+ _print_cb(d, level, file, fnc, line, wfmt, _print_cb_data,
+ args);
+ free(wfmt);
+ }
#else
- _print_cb(d, level, file, fnc, line, fmt, _print_cb_data, args);
+ _print_cb(d, level, file, fnc, line, fmt, _print_cb_data, args);
#endif
- if (EINA_UNLIKELY(_abort_on_critical) &&
- EINA_UNLIKELY(level <= _abort_level_on_critical))
- abort();
+ if (EINA_UNLIKELY(_abort_on_critical) &&
+ EINA_UNLIKELY(level <= _abort_level_on_critical))
+ abort();
}
/**
@@ -1529,81 +1466,78 @@ eina_log_print_unlocked(int domain,
* place where this function was called the first time is
* considered the main thread.
*/
-Eina_Bool
-eina_log_init(void)
+Eina_Bool eina_log_init(void)
{
- const char *level, *tmp;
- int color_disable;
+ const char *level, *tmp;
+ int color_disable;
- assert((sizeof(_names) / sizeof(_names[0])) == EINA_LOG_LEVELS);
+ assert((sizeof(_names) / sizeof(_names[0])) == EINA_LOG_LEVELS);
- if ((tmp = getenv(EINA_LOG_ENV_COLOR_DISABLE)))
- color_disable = atoi(tmp);
- else
- color_disable = -1;
+ if ((tmp = getenv(EINA_LOG_ENV_COLOR_DISABLE)))
+ color_disable = atoi(tmp);
+ else
+ color_disable = -1;
- /* Check if color is explicitly disabled */
- if (color_disable == 1)
- _disable_color = EINA_TRUE;
+ /* Check if color is explicitly disabled */
+ if (color_disable == 1)
+ _disable_color = EINA_TRUE;
#ifndef _WIN32
- /* color was not explicitly disabled or enabled, guess it */
- else if (color_disable == -1)
- {
- if (!eina_log_term_color_supported(getenv("TERM")))
- _disable_color = EINA_TRUE;
- else
- {
- /* if not a terminal, but redirected to a file, disable color */
- int fd;
-
- if (_print_cb == eina_log_print_cb_stderr)
- fd = STDERR_FILENO;
- else if (_print_cb == eina_log_print_cb_stdout)
- fd = STDOUT_FILENO;
- else
- fd = -1;
-
- if ((fd >= 0) && (!isatty(fd)))
- _disable_color = EINA_TRUE;
- }
- }
+ /* color was not explicitly disabled or enabled, guess it */
+ else if (color_disable == -1) {
+ if (!eina_log_term_color_supported(getenv("TERM")))
+ _disable_color = EINA_TRUE;
+ else {
+ /* if not a terminal, but redirected to a file, disable color */
+ int fd;
+
+ if (_print_cb == eina_log_print_cb_stderr)
+ fd = STDERR_FILENO;
+ else if (_print_cb == eina_log_print_cb_stdout)
+ fd = STDOUT_FILENO;
+ else
+ fd = -1;
+
+ if ((fd >= 0) && (!isatty(fd)))
+ _disable_color = EINA_TRUE;
+ }
+ }
#endif
- if ((tmp = getenv(EINA_LOG_ENV_FILE_DISABLE)) && (atoi(tmp) == 1))
- _disable_file = EINA_TRUE;
-
- if ((tmp = getenv(EINA_LOG_ENV_FUNCTION_DISABLE)) && (atoi(tmp) == 1))
- _disable_function = EINA_TRUE;
+ if ((tmp = getenv(EINA_LOG_ENV_FILE_DISABLE)) && (atoi(tmp) == 1))
+ _disable_file = EINA_TRUE;
- if ((tmp = getenv(EINA_LOG_ENV_ABORT)) && (atoi(tmp) == 1))
- _abort_on_critical = EINA_TRUE;
+ if ((tmp = getenv(EINA_LOG_ENV_FUNCTION_DISABLE))
+ && (atoi(tmp) == 1))
+ _disable_function = EINA_TRUE;
- if ((tmp = getenv(EINA_LOG_ENV_ABORT_LEVEL)))
- _abort_level_on_critical = atoi(tmp);
+ if ((tmp = getenv(EINA_LOG_ENV_ABORT)) && (atoi(tmp) == 1))
+ _abort_on_critical = EINA_TRUE;
- eina_log_print_prefix_update();
+ if ((tmp = getenv(EINA_LOG_ENV_ABORT_LEVEL)))
+ _abort_level_on_critical = atoi(tmp);
- // Global log level
- if ((level = getenv(EINA_LOG_ENV_LEVEL)))
- _log_level = atoi(level);
+ eina_log_print_prefix_update();
- // Register UNKNOWN domain, the default logger
- EINA_LOG_DOMAIN_GLOBAL = eina_log_domain_register("", NULL);
+ // Global log level
+ if ((level = getenv(EINA_LOG_ENV_LEVEL)))
+ _log_level = atoi(level);
- if (EINA_LOG_DOMAIN_GLOBAL < 0)
- {
- fprintf(stderr, "Failed to create global logging domain.\n");
- return EINA_FALSE;
- }
+ // Register UNKNOWN domain, the default logger
+ EINA_LOG_DOMAIN_GLOBAL = eina_log_domain_register("", NULL);
- // Parse pending domains passed through EINA_LOG_LEVELS_GLOB
- eina_log_domain_parse_pending_globs();
+ if (EINA_LOG_DOMAIN_GLOBAL < 0) {
+ fprintf(stderr,
+ "Failed to create global logging domain.\n");
+ return EINA_FALSE;
+ }
+ // Parse pending domains passed through EINA_LOG_LEVELS_GLOB
+ eina_log_domain_parse_pending_globs();
- // Parse pending domains passed through EINA_LOG_LEVELS
- eina_log_domain_parse_pendings();
+ // Parse pending domains passed through EINA_LOG_LEVELS
+ eina_log_domain_parse_pendings();
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -1621,40 +1555,36 @@ eina_log_init(void)
* place where eina_log_init() (eina_init()) was called the
* first time is considered the main thread.
*/
-Eina_Bool
-eina_log_shutdown(void)
+Eina_Bool eina_log_shutdown(void)
{
- Eina_Inlist *tmp;
+ Eina_Inlist *tmp;
- while (_log_domains_count--)
- {
- if (_log_domains[_log_domains_count].deleted)
- continue;
+ while (_log_domains_count--) {
+ if (_log_domains[_log_domains_count].deleted)
+ continue;
- eina_log_domain_free(&_log_domains[_log_domains_count]);
- }
+ eina_log_domain_free(&_log_domains[_log_domains_count]);
+ }
- free(_log_domains);
+ free(_log_domains);
- _log_domains = NULL;
- _log_domains_count = 0;
- _log_domains_allocated = 0;
+ _log_domains = NULL;
+ _log_domains_count = 0;
+ _log_domains_allocated = 0;
- while (_glob_list)
- {
- tmp = _glob_list;
- _glob_list = _glob_list->next;
- free(tmp);
- }
+ while (_glob_list) {
+ tmp = _glob_list;
+ _glob_list = _glob_list->next;
+ free(tmp);
+ }
- while (_pending_list)
- {
- tmp = _pending_list;
- _pending_list = _pending_list->next;
- free(tmp);
- }
+ while (_pending_list) {
+ tmp = _pending_list;
+ _pending_list = _pending_list->next;
+ free(tmp);
+ }
- return EINA_TRUE;
+ return EINA_TRUE;
}
#ifdef EFL_HAVE_THREADS
@@ -1668,12 +1598,11 @@ eina_log_shutdown(void)
*
* @see eina_threads_init()
*/
-void
-eina_log_threads_init(void)
+void eina_log_threads_init(void)
{
- _main_thread = SELF();
- if (INIT())
- _threads_enabled = EINA_TRUE;
+ _main_thread = SELF();
+ if (INIT())
+ _threads_enabled = EINA_TRUE;
}
/**
@@ -1685,12 +1614,11 @@ eina_log_threads_init(void)
*
* @see eina_threads_shutdown()
*/
-void
-eina_log_threads_shutdown(void)
+void eina_log_threads_shutdown(void)
{
- CHECK_MAIN();
- SHUTDOWN();
- _threads_enabled = EINA_FALSE;
+ CHECK_MAIN();
+ SHUTDOWN();
+ _threads_enabled = EINA_FALSE;
}
#endif
@@ -1817,12 +1745,11 @@ EAPI int EINA_LOG_DOMAIN_GLOBAL = 0;
* The main thread is considered the thread where the first
* eina_init() was called.
*/
-EAPI void
-eina_log_threads_enable(void)
+EAPI void eina_log_threads_enable(void)
{
#ifdef EFL_HAVE_THREADS
- _threads_enabled = 1;
- eina_log_print_prefix_update();
+ _threads_enabled = 1;
+ eina_log_print_prefix_update();
#endif
}
@@ -1840,14 +1767,13 @@ eina_log_threads_enable(void)
* This means you're safe from other calls but you should never
* call eina_log_print(), directly or indirectly.
*/
-EAPI void
-eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data)
+EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data)
{
- LOG_LOCK();
- _print_cb = cb;
- _print_cb_data = data;
- eina_log_print_prefix_update();
- LOG_UNLOCK();
+ LOG_LOCK();
+ _print_cb = cb;
+ _print_cb_data = data;
+ eina_log_print_prefix_update();
+ LOG_UNLOCK();
}
/**
@@ -1862,13 +1788,13 @@ eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data)
*
* @see eina_log_level_get()
*/
-EAPI void
-eina_log_level_set(int level)
+EAPI void eina_log_level_set(int level)
{
- _log_level = level;
- if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) &&
- ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count)))
- _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
+ _log_level = level;
+ if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) &&
+ ((unsigned int) EINA_LOG_DOMAIN_GLOBAL <
+ _log_domains_count)))
+ _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
}
/**
@@ -1878,10 +1804,9 @@ eina_log_level_set(int level)
*
* @see eina_log_level_set()
*/
-EAPI int
-eina_log_level_get(void)
+EAPI int eina_log_level_get(void)
{
- return _log_level;
+ return _log_level;
}
/**
@@ -1896,13 +1821,12 @@ eina_log_level_get(void)
* thread is not the main (one that called
* eina_log_threads_init()).
*/
-EAPI Eina_Bool
-eina_log_main_thread_check(void)
+EAPI Eina_Bool eina_log_main_thread_check(void)
{
#ifdef EFL_HAVE_THREADS
- return ((!_threads_enabled) || IS_MAIN(SELF()));
+ return ((!_threads_enabled) || IS_MAIN(SELF()));
#else
- return EINA_TRUE;
+ return EINA_TRUE;
#endif
}
@@ -1915,10 +1839,9 @@ eina_log_main_thread_check(void)
*
* @see eina_log_color_disable_get()
*/
-EAPI void
-eina_log_color_disable_set(Eina_Bool disabled)
+EAPI void eina_log_color_disable_set(Eina_Bool disabled)
{
- _disable_color = disabled;
+ _disable_color = disabled;
}
/**
@@ -1928,10 +1851,9 @@ eina_log_color_disable_set(Eina_Bool disabled)
*
* @see eina_log_color_disable_set()
*/
-EAPI Eina_Bool
-eina_log_color_disable_get(void)
+EAPI Eina_Bool eina_log_color_disable_get(void)
{
- return _disable_color;
+ return _disable_color;
}
/**
@@ -1943,10 +1865,9 @@ eina_log_color_disable_get(void)
*
* @see eina_log_file_disable_get()
*/
-EAPI void
-eina_log_file_disable_set(Eina_Bool disabled)
+EAPI void eina_log_file_disable_set(Eina_Bool disabled)
{
- _disable_file = disabled;
+ _disable_file = disabled;
}
/**
@@ -1956,10 +1877,9 @@ eina_log_file_disable_set(Eina_Bool disabled)
*
* @see eina_log_file_disable_set()
*/
-EAPI Eina_Bool
-eina_log_file_disable_get(void)
+EAPI Eina_Bool eina_log_file_disable_get(void)
{
- return _disable_file;
+ return _disable_file;
}
/**
@@ -1972,10 +1892,9 @@ eina_log_file_disable_get(void)
*
* @see eina_log_function_disable_get()
*/
-EAPI void
-eina_log_function_disable_set(Eina_Bool disabled)
+EAPI void eina_log_function_disable_set(Eina_Bool disabled)
{
- _disable_function = disabled;
+ _disable_function = disabled;
}
/**
@@ -1985,10 +1904,9 @@ eina_log_function_disable_set(Eina_Bool disabled)
*
* @see eina_log_function_disable_set()
*/
-EAPI Eina_Bool
-eina_log_function_disable_get(void)
+EAPI Eina_Bool eina_log_function_disable_get(void)
{
- return _disable_function;
+ return _disable_function;
}
/**
@@ -2004,10 +1922,9 @@ eina_log_function_disable_get(void)
* @see eina_log_abort_on_critical_get()
* @see eina_log_abort_on_critical_level_set()
*/
-EAPI void
-eina_log_abort_on_critical_set(Eina_Bool abort_on_critical)
+EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_critical)
{
- _abort_on_critical = abort_on_critical;
+ _abort_on_critical = abort_on_critical;
}
/**
@@ -2020,10 +1937,9 @@ eina_log_abort_on_critical_set(Eina_Bool abort_on_critical)
* @see eina_log_abort_on_critical_set()
* @see eina_log_abort_on_critical_level_set()
*/
-EAPI Eina_Bool
-eina_log_abort_on_critical_get(void)
+EAPI Eina_Bool eina_log_abort_on_critical_get(void)
{
- return _abort_on_critical;
+ return _abort_on_critical;
}
/**
@@ -2039,10 +1955,9 @@ eina_log_abort_on_critical_get(void)
* @see eina_log_abort_on_critical_level_get()
* @see eina_log_abort_on_critical_get()
*/
-EAPI void
-eina_log_abort_on_critical_level_set(int critical_level)
+EAPI void eina_log_abort_on_critical_level_set(int critical_level)
{
- _abort_level_on_critical = critical_level;
+ _abort_level_on_critical = critical_level;
}
/**
@@ -2055,10 +1970,9 @@ eina_log_abort_on_critical_level_set(int critical_level)
* @see eina_log_abort_on_critical_level_set()
* @see eina_log_abort_on_critical_get()
*/
-EAPI int
-eina_log_abort_on_critical_level_get(void)
+EAPI int eina_log_abort_on_critical_level_get(void)
{
- return _abort_level_on_critical;
+ return _abort_level_on_critical;
}
/**
@@ -2070,17 +1984,16 @@ eina_log_abort_on_critical_level_get(void)
*
* @note MT: safe to call from any thread.
*/
-EAPI int
-eina_log_domain_register(const char *name, const char *color)
+EAPI int eina_log_domain_register(const char *name, const char *color)
{
- int r;
+ int r;
- EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1);
- LOG_LOCK();
- r = eina_log_domain_register_unlocked(name, color);
- LOG_UNLOCK();
- return r;
+ LOG_LOCK();
+ r = eina_log_domain_register_unlocked(name, color);
+ LOG_UNLOCK();
+ return r;
}
/**
@@ -2091,13 +2004,12 @@ eina_log_domain_register(const char *name, const char *color)
*
* @note MT: safe to call from any thread.
*/
-EAPI void
-eina_log_domain_unregister(int domain)
+EAPI void eina_log_domain_unregister(int domain)
{
- EINA_SAFETY_ON_FALSE_RETURN(domain >= 0);
- LOG_LOCK();
- eina_log_domain_unregister_unlocked(domain);
- LOG_UNLOCK();
+ EINA_SAFETY_ON_FALSE_RETURN(domain >= 0);
+ LOG_LOCK();
+ eina_log_domain_unregister_unlocked(domain);
+ LOG_UNLOCK();
}
/**
@@ -2112,49 +2024,47 @@ eina_log_domain_unregister(int domain)
* registration.
* @param level level to use to limit eina_log_print() for given domain.
*/
-EAPI void
-eina_log_domain_level_set(const char *domain_name, int level)
+EAPI void eina_log_domain_level_set(const char *domain_name, int level)
{
- Eina_Log_Domain_Level_Pending *pending;
- size_t namelen;
- unsigned int i;
-
- EINA_SAFETY_ON_NULL_RETURN(domain_name);
-
- namelen = strlen(domain_name);
-
- for (i = 0; i < _log_domains_count; i++)
- {
- if (_log_domains[i].deleted)
- continue;
-
- if ((namelen != _log_domains[i].namelen) ||
- (strcmp(_log_domains[i].name, domain_name) != 0))
- continue;
-
- _log_domains[i].level = level;
- return;
- }
-
- EINA_INLIST_FOREACH(_pending_list, pending)
- {
- if ((namelen == pending->namelen) &&
- (strcmp(pending->name, domain_name) == 0))
- {
- pending->level = level;
- return;
- }
- }
-
- pending = malloc(sizeof(Eina_Log_Domain_Level_Pending) + namelen + 1);
- if (!pending)
- return;
-
- pending->level = level;
- pending->namelen = namelen;
- memcpy(pending->name, domain_name, namelen + 1);
-
- _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(pending));
+ Eina_Log_Domain_Level_Pending *pending;
+ size_t namelen;
+ unsigned int i;
+
+ EINA_SAFETY_ON_NULL_RETURN(domain_name);
+
+ namelen = strlen(domain_name);
+
+ for (i = 0; i < _log_domains_count; i++) {
+ if (_log_domains[i].deleted)
+ continue;
+
+ if ((namelen != _log_domains[i].namelen) ||
+ (strcmp(_log_domains[i].name, domain_name) != 0))
+ continue;
+
+ _log_domains[i].level = level;
+ return;
+ }
+
+ EINA_INLIST_FOREACH(_pending_list, pending) {
+ if ((namelen == pending->namelen) &&
+ (strcmp(pending->name, domain_name) == 0)) {
+ pending->level = level;
+ return;
+ }
+ }
+
+ pending =
+ malloc(sizeof(Eina_Log_Domain_Level_Pending) + namelen + 1);
+ if (!pending)
+ return;
+
+ pending->level = level;
+ pending->namelen = namelen;
+ memcpy(pending->name, domain_name, namelen + 1);
+
+ _pending_list =
+ eina_inlist_append(_pending_list, EINA_INLIST_GET(pending));
}
/**
@@ -2175,43 +2085,40 @@ eina_log_domain_level_set(const char *domain_name, int level)
* @see eina_log_domain_level_set()
* @see eina_log_domain_registered_level_get()
*/
-EAPI int
-eina_log_domain_level_get(const char *domain_name)
+EAPI int eina_log_domain_level_get(const char *domain_name)
{
- Eina_Log_Domain_Level_Pending *pending;
- size_t namelen;
- unsigned int i;
+ Eina_Log_Domain_Level_Pending *pending;
+ size_t namelen;
+ unsigned int i;
- EINA_SAFETY_ON_NULL_RETURN_VAL(domain_name, EINA_LOG_LEVEL_UNKNOWN);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(domain_name,
+ EINA_LOG_LEVEL_UNKNOWN);
- namelen = strlen(domain_name);
+ namelen = strlen(domain_name);
- for (i = 0; i < _log_domains_count; i++)
- {
- if (_log_domains[i].deleted)
- continue;
+ for (i = 0; i < _log_domains_count; i++) {
+ if (_log_domains[i].deleted)
+ continue;
- if ((namelen != _log_domains[i].namelen) ||
- (strcmp(_log_domains[i].name, domain_name) != 0))
- continue;
+ if ((namelen != _log_domains[i].namelen) ||
+ (strcmp(_log_domains[i].name, domain_name) != 0))
+ continue;
- return _log_domains[i].level;
- }
+ return _log_domains[i].level;
+ }
- EINA_INLIST_FOREACH(_pending_list, pending)
- {
- if ((namelen == pending->namelen) &&
- (strcmp(pending->name, domain_name) == 0))
- return pending->level;
- }
+ EINA_INLIST_FOREACH(_pending_list, pending) {
+ if ((namelen == pending->namelen) &&
+ (strcmp(pending->name, domain_name) == 0))
+ return pending->level;
+ }
- EINA_INLIST_FOREACH(_glob_list, pending)
- {
- if (!fnmatch(pending->name, domain_name, 0))
- return pending->level;
- }
+ EINA_INLIST_FOREACH(_glob_list, pending) {
+ if (!fnmatch(pending->name, domain_name, 0))
+ return pending->level;
+ }
- return _log_level;
+ return _log_level;
}
/**
@@ -2225,15 +2132,16 @@ eina_log_domain_level_get(const char *domain_name)
* @return level to use to limit eina_log_print() for given domain. On
* error EINA_LOG_LEVEL_UNKNOWN is returned.
*/
-EAPI int
-eina_log_domain_registered_level_get(int domain)
+EAPI int eina_log_domain_registered_level_get(int domain)
{
- EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0, EINA_LOG_LEVEL_UNKNOWN);
- EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int)domain < _log_domains_count,
- EINA_LOG_LEVEL_UNKNOWN);
- EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted,
- EINA_LOG_LEVEL_UNKNOWN);
- return _log_domains[domain].level;
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0,
+ EINA_LOG_LEVEL_UNKNOWN);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int) domain <
+ _log_domains_count,
+ EINA_LOG_LEVEL_UNKNOWN);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted,
+ EINA_LOG_LEVEL_UNKNOWN);
+ return _log_domains[domain].level;
}
/**
@@ -2262,18 +2170,17 @@ eina_log_domain_registered_level_get(int domain)
* appended to domain name.
*/
EAPI void
-eina_log_print_cb_stderr(const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- __UNUSED__ void *data,
- va_list args)
+eina_log_print_cb_stderr(const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ __UNUSED__ void *data, va_list args)
{
- _eina_log_print_prefix(stderr, d, level, file, fnc, line);
- vfprintf(stderr, fmt, args);
- putc('\n', stderr);
+ _eina_log_print_prefix(stderr, d, level, file, fnc, line);
+ vfprintf(stderr, fmt, args);
+ putc('\n', stderr);
}
/**
@@ -2303,18 +2210,17 @@ eina_log_print_cb_stderr(const Eina_Log_Domain *d,
* appended to domain name.
*/
EAPI void
-eina_log_print_cb_stdout(const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- __UNUSED__ void *data,
- va_list args)
+eina_log_print_cb_stdout(const Eina_Log_Domain * d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ __UNUSED__ void *data, va_list args)
{
- _eina_log_print_prefix(stdout, d, level, file, fnc, line);
- vprintf(fmt, args);
- putchar('\n');
+ _eina_log_print_prefix(stdout, d, level, file, fnc, line);
+ vprintf(fmt, args);
+ putchar('\n');
}
/**
@@ -2336,37 +2242,31 @@ eina_log_print_cb_stdout(const Eina_Log_Domain *d,
* appended to domain name.
*/
EAPI void
-eina_log_print_cb_file(const Eina_Log_Domain *d,
- __UNUSED__ Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- void *data,
- va_list args)
+eina_log_print_cb_file(const Eina_Log_Domain * d,
+ __UNUSED__ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line, const char *fmt, void *data, va_list args)
{
- FILE *f = data;
+ FILE *f = data;
#ifdef EFL_HAVE_THREADS
- if (_threads_enabled)
- {
- Thread cur;
-
- cur = SELF();
- if (IS_OTHER(cur))
- {
- fprintf(f, "%s[T:%lu] %s:%d %s() ", d->name, (unsigned long)cur,
- file, line, fnc);
- goto end;
- }
- }
-
+ if (_threads_enabled) {
+ Thread cur;
+
+ cur = SELF();
+ if (IS_OTHER(cur)) {
+ fprintf(f, "%s[T:%lu] %s:%d %s() ", d->name,
+ (unsigned long) cur, file, line, fnc);
+ goto end;
+ }
+ }
#endif
- fprintf(f, "%s %s:%d %s() ", d->name, file, line, fnc);
+ fprintf(f, "%s %s:%d %s() ", d->name, file, line, fnc);
#ifdef EFL_HAVE_THREADS
-end:
+ end:
#endif
- vfprintf(f, fmt, args);
- putc('\n', f);
+ vfprintf(f, fmt, args);
+ putc('\n', f);
}
/**
@@ -2393,35 +2293,31 @@ end:
*/
EAPI void
eina_log_print(int domain, Eina_Log_Level level, const char *file,
- const char *fnc, int line, const char *fmt, ...)
+ const char *fnc, int line, const char *fmt, ...)
{
- va_list args;
+ va_list args;
#ifdef EINA_SAFETY_CHECKS
- if (EINA_UNLIKELY(!file))
- {
- fputs("ERR: eina_log_print() file == NULL\n", stderr);
- return;
- }
-
- if (EINA_UNLIKELY(!fnc))
- {
- fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
- return;
- }
-
- if (EINA_UNLIKELY(!fmt))
- {
- fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
- return;
- }
-
+ if (EINA_UNLIKELY(!file)) {
+ fputs("ERR: eina_log_print() file == NULL\n", stderr);
+ return;
+ }
+
+ if (EINA_UNLIKELY(!fnc)) {
+ fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
+ return;
+ }
+
+ if (EINA_UNLIKELY(!fmt)) {
+ fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
+ return;
+ }
#endif
- va_start(args, fmt);
- LOG_LOCK();
- eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
- LOG_UNLOCK();
- va_end(args);
+ va_start(args, fmt);
+ LOG_LOCK();
+ eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
+ LOG_UNLOCK();
+ va_end(args);
}
/**
@@ -2451,31 +2347,27 @@ eina_log_print(int domain, Eina_Log_Level level, const char *file,
*/
EAPI void
eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
- const char *fnc, int line, const char *fmt, va_list args)
+ const char *fnc, int line, const char *fmt, va_list args)
{
#ifdef EINA_SAFETY_CHECKS
- if (EINA_UNLIKELY(!file))
- {
- fputs("ERR: eina_log_print() file == NULL\n", stderr);
- return;
- }
-
- if (EINA_UNLIKELY(!fnc))
- {
- fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
- return;
- }
-
- if (EINA_UNLIKELY(!fmt))
- {
- fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
- return;
- }
-
+ if (EINA_UNLIKELY(!file)) {
+ fputs("ERR: eina_log_print() file == NULL\n", stderr);
+ return;
+ }
+
+ if (EINA_UNLIKELY(!fnc)) {
+ fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
+ return;
+ }
+
+ if (EINA_UNLIKELY(!fmt)) {
+ fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
+ return;
+ }
#endif
- LOG_LOCK();
- eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
- LOG_UNLOCK();
+ LOG_LOCK();
+ eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
+ LOG_UNLOCK();
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_magic.c b/tests/suite/ecore/src/lib/eina_magic.c
index 83cd247d26..cc607d0f11 100644
--- a/tests/suite/ecore/src/lib/eina_magic.c
+++ b/tests/suite/ecore/src/lib/eina_magic.c
@@ -17,14 +17,14 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -45,11 +45,10 @@
*/
typedef struct _Eina_Magic_String Eina_Magic_String;
-struct _Eina_Magic_String
-{
- Eina_Magic magic;
- Eina_Bool string_allocated;
- const char *string;
+struct _Eina_Magic_String {
+ Eina_Magic magic;
+ Eina_Bool string_allocated;
+ const char *string;
};
static int _eina_magic_string_log_dom = -1;
@@ -69,55 +68,52 @@ static size_t _eina_magic_strings_count = 0;
static size_t _eina_magic_strings_allocated = 0;
static Eina_Bool _eina_magic_strings_dirty = 0;
-static int
-_eina_magic_strings_sort_cmp(const void *p1, const void *p2)
+static int _eina_magic_strings_sort_cmp(const void *p1, const void *p2)
{
- const Eina_Magic_String *a = p1, *b = p2;
- return a->magic - b->magic;
+ const Eina_Magic_String *a = p1, *b = p2;
+ return a->magic - b->magic;
}
-static int
-_eina_magic_strings_find_cmp(const void *p1, const void *p2)
+static int _eina_magic_strings_find_cmp(const void *p1, const void *p2)
{
- Eina_Magic a = (long)p1;
- const Eina_Magic_String *b = p2;
- return a - b->magic;
+ Eina_Magic a = (long) p1;
+ const Eina_Magic_String *b = p2;
+ return a - b->magic;
}
-static Eina_Magic_String *
-_eina_magic_strings_alloc(void)
+static Eina_Magic_String *_eina_magic_strings_alloc(void)
{
- size_t idx;
+ size_t idx;
- if (_eina_magic_strings_count == _eina_magic_strings_allocated)
- {
- void *tmp;
- size_t size;
+ if (_eina_magic_strings_count == _eina_magic_strings_allocated) {
+ void *tmp;
+ size_t size;
- if (EINA_UNLIKELY(_eina_magic_strings_allocated == 0))
- size = 48;
- else
- size = _eina_magic_strings_allocated + 16;
+ if (EINA_UNLIKELY(_eina_magic_strings_allocated == 0))
+ size = 48;
+ else
+ size = _eina_magic_strings_allocated + 16;
- tmp = realloc(_eina_magic_strings, sizeof(Eina_Magic_String) * size);
- if (!tmp)
- {
+ tmp =
+ realloc(_eina_magic_strings,
+ sizeof(Eina_Magic_String) * size);
+ if (!tmp) {
#ifdef _WIN32
- ERR("could not realloc magic_strings from %Iu to %Iu buckets.",
+ ERR("could not realloc magic_strings from %Iu to %Iu buckets.",
#else
- ERR("could not realloc magic_strings from %zu to %zu buckets.",
+ ERR("could not realloc magic_strings from %zu to %zu buckets.",
#endif
- _eina_magic_strings_allocated, size);
- return NULL;
- }
+ _eina_magic_strings_allocated, size);
+ return NULL;
+ }
- _eina_magic_strings = tmp;
- _eina_magic_strings_allocated = size;
- }
+ _eina_magic_strings = tmp;
+ _eina_magic_strings_allocated = size;
+ }
- idx = _eina_magic_strings_count;
- _eina_magic_strings_count++;
- return _eina_magic_strings + idx;
+ idx = _eina_magic_strings_count;
+ _eina_magic_strings_count++;
+ return _eina_magic_strings + idx;
}
/**
@@ -139,18 +135,17 @@ _eina_magic_strings_alloc(void)
*
* @see eina_init()
*/
-Eina_Bool
-eina_magic_string_init(void)
+Eina_Bool eina_magic_string_init(void)
{
- _eina_magic_string_log_dom = eina_log_domain_register
- ("eina_magic_string", EINA_LOG_COLOR_DEFAULT);
- if (_eina_magic_string_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_magic_string");
- return EINA_FALSE;
- }
-
- return EINA_TRUE;
+ _eina_magic_string_log_dom = eina_log_domain_register
+ ("eina_magic_string", EINA_LOG_COLOR_DEFAULT);
+ if (_eina_magic_string_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_magic_string");
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
}
/**
@@ -164,27 +159,26 @@ eina_magic_string_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_magic_string_shutdown(void)
+Eina_Bool eina_magic_string_shutdown(void)
{
- Eina_Magic_String *ems, *ems_end;
+ Eina_Magic_String *ems, *ems_end;
- ems = _eina_magic_strings;
- ems_end = ems + _eina_magic_strings_count;
+ ems = _eina_magic_strings;
+ ems_end = ems + _eina_magic_strings_count;
- for (; ems < ems_end; ems++)
- if (ems->string_allocated)
- free((char *)ems->string);
+ for (; ems < ems_end; ems++)
+ if (ems->string_allocated)
+ free((char *) ems->string);
- free(_eina_magic_strings);
- _eina_magic_strings = NULL;
- _eina_magic_strings_count = 0;
- _eina_magic_strings_allocated = 0;
+ free(_eina_magic_strings);
+ _eina_magic_strings = NULL;
+ _eina_magic_strings_count = 0;
+ _eina_magic_strings_allocated = 0;
- eina_log_domain_unregister(_eina_magic_string_log_dom);
- _eina_magic_string_log_dom = -1;
+ eina_log_domain_unregister(_eina_magic_string_log_dom);
+ _eina_magic_string_log_dom = -1;
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -304,28 +298,27 @@ eina_magic_string_shutdown(void)
* - (undefined): magic was registered and found, but no string associated.
* - (unknown): magic was not found in the registry.
*/
-EAPI const char *
-eina_magic_string_get(Eina_Magic magic)
+EAPI const char *eina_magic_string_get(Eina_Magic magic)
{
- Eina_Magic_String *ems;
+ Eina_Magic_String *ems;
- if (!_eina_magic_strings)
- return "(none)";
+ if (!_eina_magic_strings)
+ return "(none)";
- if (_eina_magic_strings_dirty)
- {
- qsort(_eina_magic_strings, _eina_magic_strings_count,
- sizeof(Eina_Magic_String), _eina_magic_strings_sort_cmp);
- _eina_magic_strings_dirty = 0;
- }
+ if (_eina_magic_strings_dirty) {
+ qsort(_eina_magic_strings, _eina_magic_strings_count,
+ sizeof(Eina_Magic_String),
+ _eina_magic_strings_sort_cmp);
+ _eina_magic_strings_dirty = 0;
+ }
- ems = bsearch((void *)(long)magic, _eina_magic_strings,
- _eina_magic_strings_count, sizeof(Eina_Magic_String),
- _eina_magic_strings_find_cmp);
- if (ems)
- return ems->string ? ems->string : "(undefined)";
+ ems = bsearch((void *) (long) magic, _eina_magic_strings,
+ _eina_magic_strings_count, sizeof(Eina_Magic_String),
+ _eina_magic_strings_find_cmp);
+ if (ems)
+ return ems->string ? ems->string : "(undefined)";
- return "(unknown)";
+ return "(unknown)";
}
/**
@@ -346,26 +339,25 @@ eina_magic_string_get(Eina_Magic magic)
EAPI Eina_Bool
eina_magic_string_set(Eina_Magic magic, const char *magic_name)
{
- Eina_Magic_String *ems;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(magic_name, EINA_FALSE);
-
- ems = _eina_magic_strings_alloc();
- if (!ems)
- return EINA_FALSE;
-
- ems->magic = magic;
- ems->string_allocated = EINA_TRUE;
- ems->string = strdup(magic_name);
- if (!ems->string)
- {
- ERR("could not allocate string '%s'", magic_name);
- _eina_magic_strings_count--;
- return EINA_FALSE;
- }
-
- _eina_magic_strings_dirty = 1;
- return EINA_TRUE;
+ Eina_Magic_String *ems;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(magic_name, EINA_FALSE);
+
+ ems = _eina_magic_strings_alloc();
+ if (!ems)
+ return EINA_FALSE;
+
+ ems->magic = magic;
+ ems->string_allocated = EINA_TRUE;
+ ems->string = strdup(magic_name);
+ if (!ems->string) {
+ ERR("could not allocate string '%s'", magic_name);
+ _eina_magic_strings_count--;
+ return EINA_FALSE;
+ }
+
+ _eina_magic_strings_dirty = 1;
+ return EINA_TRUE;
}
/**
@@ -387,24 +379,24 @@ eina_magic_string_set(Eina_Magic magic, const char *magic_name)
EAPI Eina_Bool
eina_magic_string_static_set(Eina_Magic magic, const char *magic_name)
{
- Eina_Magic_String *ems;
+ Eina_Magic_String *ems;
- EINA_SAFETY_ON_NULL_RETURN_VAL(magic_name, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(magic_name, EINA_FALSE);
- ems = _eina_magic_strings_alloc();
- if (!ems)
- return EINA_FALSE;
+ ems = _eina_magic_strings_alloc();
+ if (!ems)
+ return EINA_FALSE;
- ems->magic = magic;
- ems->string_allocated = EINA_FALSE;
- ems->string = magic_name;
+ ems->magic = magic;
+ ems->string_allocated = EINA_FALSE;
+ ems->string = magic_name;
- _eina_magic_strings_dirty = 1;
- return EINA_TRUE;
+ _eina_magic_strings_dirty = 1;
+ return EINA_TRUE;
}
#ifdef eina_magic_fail
-# undef eina_magic_fail
+#undef eina_magic_fail
#endif
/**
@@ -432,54 +424,49 @@ eina_magic_string_static_set(Eina_Magic magic, const char *magic_name)
*/
EAPI void
eina_magic_fail(void *d,
- Eina_Magic m,
- Eina_Magic req_m,
- const char *file,
- const char *fnc,
- int line)
+ Eina_Magic m,
+ Eina_Magic req_m,
+ const char *file, const char *fnc, int line)
{
- if (!d)
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Input handle pointer is NULL !\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n");
- else
- if (m == EINA_MAGIC_NONE)
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Input handle has already been freed!\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n");
- else
- if (m != req_m)
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Input handle is wrong type\n"
- " Expected: %08x - %s\n"
- " Supplied: %08x - %s\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n",
- req_m, eina_magic_string_get(req_m),
- m, eina_magic_string_get(m));
- else
- eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
- file, fnc, line,
- "*** Eina Magic Check Failed !!!\n"
- " Why did you call me !\n"
- "*** NAUGHTY PROGRAMMER!!!\n"
- "*** SPANK SPANK SPANK!!!\n"
- "*** Now go fix your code. Tut tut tut!\n"
- "\n");
+ if (!d)
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL,
+ EINA_LOG_LEVEL_CRITICAL, file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Input handle pointer is NULL !\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n");
+ else if (m == EINA_MAGIC_NONE)
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL,
+ EINA_LOG_LEVEL_CRITICAL, file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Input handle has already been freed!\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n");
+ else if (m != req_m)
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL,
+ EINA_LOG_LEVEL_CRITICAL, file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Input handle is wrong type\n"
+ " Expected: %08x - %s\n"
+ " Supplied: %08x - %s\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n", req_m, eina_magic_string_get(req_m),
+ m, eina_magic_string_get(m));
+ else
+ eina_log_print(EINA_LOG_DOMAIN_GLOBAL,
+ EINA_LOG_LEVEL_CRITICAL, file, fnc, line,
+ "*** Eina Magic Check Failed !!!\n"
+ " Why did you call me !\n"
+ "*** NAUGHTY PROGRAMMER!!!\n"
+ "*** SPANK SPANK SPANK!!!\n"
+ "*** Now go fix your code. Tut tut tut!\n"
+ "\n");
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_main.c b/tests/suite/ecore/src/lib/eina_main.c
index ceae398363..32be0fe653 100644
--- a/tests/suite/ecore/src/lib/eina_main.c
+++ b/tests/suite/ecore/src/lib/eina_main.c
@@ -17,19 +17,19 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
#ifdef EFL_HAVE_POSIX_THREADS
-# include <pthread.h>
+#include <pthread.h>
#endif
#ifdef EFL_HAVE_WIN32_THREADS
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# undef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
#endif
#include "eina_config.h"
@@ -79,21 +79,21 @@ static int _eina_log_dom = -1;
#ifdef EFL_HAVE_THREADS
static Eina_Bool _threads_activated = EINA_FALSE;
-# ifdef EFL_HAVE_POSIX_THREADS
+#ifdef EFL_HAVE_POSIX_THREADS
static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK() if(_threads_activated) pthread_mutex_lock(&_mutex)
-# define UNLOCK() if(_threads_activated) pthread_mutex_unlock(&_mutex)
-# define UNLOCK_FORCE() pthread_mutex_unlock(&_mutex)
-# else /* EFL_HAVE_WIN32_THREADS */
+#define LOCK() if(_threads_activated) pthread_mutex_lock(&_mutex)
+#define UNLOCK() if(_threads_activated) pthread_mutex_unlock(&_mutex)
+#define UNLOCK_FORCE() pthread_mutex_unlock(&_mutex)
+#else /* EFL_HAVE_WIN32_THREADS */
static HANDLE _mutex = NULL;
-# define LOCK() if(_threads_activated) WaitForSingleObject(_mutex, INFINITE)
-# define UNLOCK() if(_threads_activated) ReleaseMutex(_mutex)
-# define UNLOCK_FORCE() ReleaseMutex(_mutex)
-# endif
+#define LOCK() if(_threads_activated) WaitForSingleObject(_mutex, INFINITE)
+#define UNLOCK() if(_threads_activated) ReleaseMutex(_mutex)
+#define UNLOCK_FORCE() ReleaseMutex(_mutex)
+#endif
#else
-# define LOCK() do {} while (0)
-# define UNLOCK() do {} while (0)
-# define UNLOCK_FORCE() do {} while (0)
+#define LOCK() do {} while (0)
+#define UNLOCK() do {} while (0)
+#define UNLOCK_FORCE() do {} while (0)
#endif
/* place module init/shutdown functions here to avoid other modules
@@ -101,76 +101,74 @@ static HANDLE _mutex = NULL;
*/
#define S(x) extern Eina_Bool eina_ ## x ## _init(void); \
extern Eina_Bool eina_ ## x ## _shutdown(void)
- S(log);
- S(error);
- S(safety_checks);
- S(magic_string);
- S(iterator);
- S(accessor);
- S(array);
- S(module);
- S(mempool);
- S(list);
- S(binshare);
- S(stringshare);
- S(ustringshare);
- S(matrixsparse);
- S(convert);
- S(counter);
- S(benchmark);
- S(rectangle);
- S(strbuf);
- S(ustrbuf);
- S(quadtree);
+S(log);
+S(error);
+S(safety_checks);
+S(magic_string);
+S(iterator);
+S(accessor);
+S(array);
+S(module);
+S(mempool);
+S(list);
+S(binshare);
+S(stringshare);
+S(ustringshare);
+S(matrixsparse);
+S(convert);
+S(counter);
+S(benchmark);
+S(rectangle);
+S(strbuf);
+S(ustrbuf);
+S(quadtree);
#undef S
-struct eina_desc_setup
-{
- const char *name;
- Eina_Bool (*init)(void);
- Eina_Bool (*shutdown)(void);
+struct eina_desc_setup {
+ const char *name;
+ Eina_Bool(*init) (void);
+ Eina_Bool(*shutdown) (void);
};
static const struct eina_desc_setup _eina_desc_setup[] = {
#define S(x) {# x, eina_ ## x ## _init, eina_ ## x ## _shutdown}
- /* log is a special case as it needs printf */
- S(error),
- S(safety_checks),
- S(magic_string),
- S(iterator),
- S(accessor),
- S(array),
- S(module),
- S(mempool),
- S(list),
- S(binshare),
- S(stringshare),
- S(ustringshare),
- S(matrixsparse),
- S(convert),
- S(counter),
- S(benchmark),
- S(rectangle),
- S(strbuf),
- S(ustrbuf),
- S(quadtree)
+ /* log is a special case as it needs printf */
+ S(error),
+ S(safety_checks),
+ S(magic_string),
+ S(iterator),
+ S(accessor),
+ S(array),
+ S(module),
+ S(mempool),
+ S(list),
+ S(binshare),
+ S(stringshare),
+ S(ustringshare),
+ S(matrixsparse),
+ S(convert),
+ S(counter),
+ S(benchmark),
+ S(rectangle),
+ S(strbuf),
+ S(ustrbuf),
+ S(quadtree)
#undef S
};
+
static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) /
- sizeof(_eina_desc_setup[0]);
+ sizeof(_eina_desc_setup[0]);
-static void
-_eina_shutdown_from_desc(const struct eina_desc_setup *itr)
+static void _eina_shutdown_from_desc(const struct eina_desc_setup *itr)
{
- for (itr--; itr >= _eina_desc_setup; itr--)
- {
- if (!itr->shutdown())
- ERR("Problems shutting down eina module '%s', ignored.", itr->name);
- }
-
- eina_log_domain_unregister(_eina_log_dom);
- _eina_log_dom = -1;
- eina_log_shutdown();
+ for (itr--; itr >= _eina_desc_setup; itr--) {
+ if (!itr->shutdown())
+ ERR("Problems shutting down eina module '%s', ignored.", itr->name);
+ }
+
+ eina_log_domain_unregister(_eina_log_dom);
+ _eina_log_dom = -1;
+ eina_log_shutdown();
}
/**
@@ -214,42 +212,40 @@ EAPI Eina_Version *eina_version = &_version;
* When Eina is not used anymore, call eina_shutdown() to shut down
* the Eina library.
*/
-EAPI int
-eina_init(void)
+EAPI int eina_init(void)
{
- const struct eina_desc_setup *itr, *itr_end;
-
- if (EINA_LIKELY(_eina_main_count > 0))
- return ++_eina_main_count;
-
- if (!eina_log_init())
- {
- fprintf(stderr, "Could not initialize eina logging system.\n");
- return 0;
- }
-
- _eina_log_dom = eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
- if (_eina_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina");
- eina_log_shutdown();
- return 0;
- }
-
- itr = _eina_desc_setup;
- itr_end = itr + _eina_desc_setup_len;
- for (; itr < itr_end; itr++)
- {
- if (!itr->init())
- {
- ERR("Could not initialize eina module '%s'.", itr->name);
- _eina_shutdown_from_desc(itr);
- return 0;
- }
- }
-
- _eina_main_count = 1;
- return 1;
+ const struct eina_desc_setup *itr, *itr_end;
+
+ if (EINA_LIKELY(_eina_main_count > 0))
+ return ++_eina_main_count;
+
+ if (!eina_log_init()) {
+ fprintf(stderr,
+ "Could not initialize eina logging system.\n");
+ return 0;
+ }
+
+ _eina_log_dom =
+ eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
+ if (_eina_log_dom < 0) {
+ EINA_LOG_ERR("Could not register log domain: eina");
+ eina_log_shutdown();
+ return 0;
+ }
+
+ itr = _eina_desc_setup;
+ itr_end = itr + _eina_desc_setup_len;
+ for (; itr < itr_end; itr++) {
+ if (!itr->init()) {
+ ERR("Could not initialize eina module '%s'.",
+ itr->name);
+ _eina_shutdown_from_desc(itr);
+ return 0;
+ }
+ }
+
+ _eina_main_count = 1;
+ return 1;
}
/**
@@ -266,14 +262,14 @@ eina_init(void)
* not call any of the Eina function anymore. You must call
* eina_init() again to use the Eina functions again.
*/
-EAPI int
-eina_shutdown(void)
+EAPI int eina_shutdown(void)
{
- _eina_main_count--;
- if (EINA_UNLIKELY(_eina_main_count == 0))
- _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
+ _eina_main_count--;
+ if (EINA_UNLIKELY(_eina_main_count == 0))
+ _eina_shutdown_from_desc(_eina_desc_setup +
+ _eina_desc_setup_len);
- return _eina_main_count;
+ return _eina_main_count;
}
@@ -290,38 +286,36 @@ eina_shutdown(void)
* When the mutexes are not used anymore, call eina_threads_shutdown() to shut down
* the mutexes.
*/
-EAPI int
-eina_threads_init(void)
+EAPI int eina_threads_init(void)
{
#ifdef EFL_HAVE_THREADS
- int ret;
+ int ret;
-# ifdef EFL_HAVE_WIN32_THREADS
- if (!_mutex)
- _mutex = CreateMutex(NULL, FALSE, NULL);
+#ifdef EFL_HAVE_WIN32_THREADS
+ if (!_mutex)
+ _mutex = CreateMutex(NULL, FALSE, NULL);
- if (!_mutex)
- return 0;
+ if (!_mutex)
+ return 0;
-# endif
+#endif
- LOCK();
- ++_eina_main_thread_count;
- ret = _eina_main_thread_count;
+ LOCK();
+ ++_eina_main_thread_count;
+ ret = _eina_main_thread_count;
- if(_eina_main_thread_count > 1)
- {
- UNLOCK();
- return ret;
- }
+ if (_eina_main_thread_count > 1) {
+ UNLOCK();
+ return ret;
+ }
- eina_share_common_threads_init();
- eina_log_threads_init();
- _threads_activated = EINA_TRUE;
+ eina_share_common_threads_init();
+ eina_log_threads_init();
+ _threads_activated = EINA_TRUE;
- return ret;
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
@@ -339,36 +333,34 @@ eina_threads_init(void)
* not call any of the Eina function in a thread anymore. You must call
* eina_threads_init() again to use the Eina functions in a thread again.
*/
-EAPI int
-eina_threads_shutdown(void)
+EAPI int eina_threads_shutdown(void)
{
#ifdef EFL_HAVE_THREADS
- int ret;
+ int ret;
- LOCK();
- ret = --_eina_main_thread_count;
- if(_eina_main_thread_count > 0)
- {
- UNLOCK();
- return ret;
- }
+ LOCK();
+ ret = --_eina_main_thread_count;
+ if (_eina_main_thread_count > 0) {
+ UNLOCK();
+ return ret;
+ }
- eina_share_common_threads_shutdown();
- eina_log_threads_shutdown();
+ eina_share_common_threads_shutdown();
+ eina_log_threads_shutdown();
- _threads_activated = EINA_FALSE;
+ _threads_activated = EINA_FALSE;
- UNLOCK_FORCE();
+ UNLOCK_FORCE();
-# ifdef EFL_HAVE_WIN32_THREADS
- if (_mutex)
- CloseHandle(_mutex);
+#ifdef EFL_HAVE_WIN32_THREADS
+ if (_mutex)
+ CloseHandle(_mutex);
-# endif
+#endif
- return ret;
+ return ret;
#else
- return 0;
+ return 0;
#endif
}
diff --git a/tests/suite/ecore/src/lib/eina_matrixsparse.c b/tests/suite/ecore/src/lib/eina_matrixsparse.c
index e19f24aa86..bf88cefe12 100644
--- a/tests/suite/ecore/src/lib/eina_matrixsparse.c
+++ b/tests/suite/ecore/src/lib/eina_matrixsparse.c
@@ -25,7 +25,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -34,7 +34,7 @@
#include <assert.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -58,18 +58,20 @@
*/
static const char EINA_MAGIC_MATRIXSPARSE_STR[] = "Eina Matrixsparse";
-static const char EINA_MAGIC_MATRIXSPARSE_ROW_STR[] = "Eina Matrixsparse Row";
-static const char EINA_MAGIC_MATRIXSPARSE_CELL_STR[] = "Eina Matrixsparse Cell";
+static const char EINA_MAGIC_MATRIXSPARSE_ROW_STR[] =
+ "Eina Matrixsparse Row";
+static const char EINA_MAGIC_MATRIXSPARSE_CELL_STR[] =
+ "Eina Matrixsparse Cell";
static const char EINA_MAGIC_MATRIXSPARSE_ITERATOR_STR[] =
- "Eina Matrixsparse Iterator";
+ "Eina Matrixsparse Iterator";
static const char EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR_STR[] =
- "Eina Matrixsparse Row Accessor";
+ "Eina Matrixsparse Row Accessor";
static const char EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR_STR[] =
- "Eina Matrixsparse Row Iterator";
+ "Eina Matrixsparse Row Iterator";
static const char EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR_STR[] =
- "Eina Matrixsparse Cell Accessor";
+ "Eina Matrixsparse Cell Accessor";
static const char EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR_STR[] =
- "Eina Matrixsparse Cell Iterator";
+ "Eina Matrixsparse Cell Iterator";
#define EINA_MAGIC_CHECK_MATRIXSPARSE(d, ...) \
@@ -108,97 +110,81 @@ static const char EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR_STR[] =
} \
} while(0)
-struct _Eina_Matrixsparse_Cell
-{
- Eina_Matrixsparse_Cell *next;
- Eina_Matrixsparse_Cell *prev;
+struct _Eina_Matrixsparse_Cell {
+ Eina_Matrixsparse_Cell *next;
+ Eina_Matrixsparse_Cell *prev;
- void *data;
- unsigned long col;
+ void *data;
+ unsigned long col;
- Eina_Matrixsparse_Row *parent;
+ Eina_Matrixsparse_Row *parent;
- EINA_MAGIC
-};
+ EINA_MAGIC};
-struct _Eina_Matrixsparse_Row
-{
- Eina_Matrixsparse_Row *next;
- Eina_Matrixsparse_Row *prev;
+struct _Eina_Matrixsparse_Row {
+ Eina_Matrixsparse_Row *next;
+ Eina_Matrixsparse_Row *prev;
- Eina_Matrixsparse_Cell *cols;
- Eina_Matrixsparse_Cell *last_col;
- Eina_Matrixsparse_Cell *last_used; /* fast sequential access */
- unsigned long row;
+ Eina_Matrixsparse_Cell *cols;
+ Eina_Matrixsparse_Cell *last_col;
+ Eina_Matrixsparse_Cell *last_used; /* fast sequential access */
+ unsigned long row;
- Eina_Matrixsparse *parent;
+ Eina_Matrixsparse *parent;
- EINA_MAGIC
-};
+ EINA_MAGIC};
-struct _Eina_Matrixsparse
-{
- Eina_Matrixsparse_Row *rows;
- Eina_Matrixsparse_Row *last_row;
- Eina_Matrixsparse_Row *last_used; /* fast sequential access */
+struct _Eina_Matrixsparse {
+ Eina_Matrixsparse_Row *rows;
+ Eina_Matrixsparse_Row *last_row;
+ Eina_Matrixsparse_Row *last_used; /* fast sequential access */
- struct
- {
- unsigned long rows;
- unsigned long cols;
- } size;
+ struct {
+ unsigned long rows;
+ unsigned long cols;
+ } size;
- struct
- {
- void (*func)(void *user_data, void *cell_data);
- void *user_data;
- } free;
+ struct {
+ void (*func) (void *user_data, void *cell_data);
+ void *user_data;
+ } free;
- EINA_MAGIC
-};
+ EINA_MAGIC};
typedef struct _Eina_Matrixsparse_Iterator Eina_Matrixsparse_Iterator;
typedef struct _Eina_Matrixsparse_Iterator_Complete
-Eina_Matrixsparse_Iterator_Complete;
+ Eina_Matrixsparse_Iterator_Complete;
-struct _Eina_Matrixsparse_Iterator
-{
- Eina_Iterator iterator;
+struct _Eina_Matrixsparse_Iterator {
+ Eina_Iterator iterator;
- const Eina_Matrixsparse *m;
- struct
- {
- const Eina_Matrixsparse_Row *row;
- const Eina_Matrixsparse_Cell *col;
- } ref;
+ const Eina_Matrixsparse *m;
+ struct {
+ const Eina_Matrixsparse_Row *row;
+ const Eina_Matrixsparse_Cell *col;
+ } ref;
- EINA_MAGIC
-};
+ EINA_MAGIC};
-struct _Eina_Matrixsparse_Iterator_Complete
-{
- Eina_Iterator iterator;
+struct _Eina_Matrixsparse_Iterator_Complete {
+ Eina_Iterator iterator;
- const Eina_Matrixsparse *m;
- struct
- {
- const Eina_Matrixsparse_Row *row;
- const Eina_Matrixsparse_Cell *col;
- } ref;
+ const Eina_Matrixsparse *m;
+ struct {
+ const Eina_Matrixsparse_Row *row;
+ const Eina_Matrixsparse_Cell *col;
+ } ref;
- struct
- {
- unsigned long row, col;
- } idx;
+ struct {
+ unsigned long row, col;
+ } idx;
- struct
- {
- Eina_Matrixsparse_Row row;
- Eina_Matrixsparse_Cell col;
- } dummy;
+ struct {
+ Eina_Matrixsparse_Row row;
+ Eina_Matrixsparse_Cell col;
+ } dummy;
- EINA_MAGIC
-};
+ EINA_MAGIC};
/**
* @todo Eina_Matrixsparse_Row_Iterator: iterator over rows in matrix
@@ -223,600 +209,557 @@ static Eina_Mempool *_eina_matrixsparse_cell_mp = NULL;
static Eina_Mempool *_eina_matrixsparse_row_mp = NULL;
static inline void
-_eina_matrixsparse_cell_free(Eina_Matrixsparse_Cell *c, void (*free_func)(
- void *,
- void *), void *user_data)
+_eina_matrixsparse_cell_free(Eina_Matrixsparse_Cell * c,
+ void (*free_func) (void *, void *),
+ void *user_data)
{
- if (free_func)
- free_func(user_data, c->data);
+ if (free_func)
+ free_func(user_data, c->data);
- EINA_MAGIC_SET(c, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_matrixsparse_cell_mp, c);
+ EINA_MAGIC_SET(c, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_matrixsparse_cell_mp, c);
}
static inline void
-_eina_matrixsparse_cell_unlink(Eina_Matrixsparse_Cell *c)
+_eina_matrixsparse_cell_unlink(Eina_Matrixsparse_Cell * c)
{
- Eina_Matrixsparse_Row *r = c->parent;
-
- if (r->last_used == c)
- {
- if (c->next)
- r->last_used = c->next;
- else
- r->last_used = c->prev;
- }
-
- if (r->last_col == c)
- r->last_col = c->prev;
-
- if (r->cols == c)
- r->cols = c->next;
-
- if (c->next && c->prev)
- {
- c->next->prev = c->prev;
- c->prev->next = c->next;
- }
- else if (c->next)
- c->next->prev = NULL;
- else if (c->prev)
- c->prev->next = NULL;
+ Eina_Matrixsparse_Row *r = c->parent;
+
+ if (r->last_used == c) {
+ if (c->next)
+ r->last_used = c->next;
+ else
+ r->last_used = c->prev;
+ }
+
+ if (r->last_col == c)
+ r->last_col = c->prev;
+
+ if (r->cols == c)
+ r->cols = c->next;
+
+ if (c->next && c->prev) {
+ c->next->prev = c->prev;
+ c->prev->next = c->next;
+ } else if (c->next)
+ c->next->prev = NULL;
+ else if (c->prev)
+ c->prev->next = NULL;
}
static inline void
-_eina_matrixsparse_row_cells_free(Eina_Matrixsparse_Row *r, void (*free_func)(
- void *,
- void *), void *user_data)
+_eina_matrixsparse_row_cells_free(Eina_Matrixsparse_Row * r,
+ void (*free_func) (void *, void *),
+ void *user_data)
{
- Eina_Matrixsparse_Cell *c = r->cols;
- while (c)
- {
- Eina_Matrixsparse_Cell *c_aux = c;
- c = c->next;
- _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
- }
+ Eina_Matrixsparse_Cell *c = r->cols;
+ while (c) {
+ Eina_Matrixsparse_Cell *c_aux = c;
+ c = c->next;
+ _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
+ }
}
static inline void
-_eina_matrixsparse_row_free(Eina_Matrixsparse_Row *r, void (*free_func)(void *,
- void *),
- void *user_data)
+_eina_matrixsparse_row_free(Eina_Matrixsparse_Row * r,
+ void (*free_func) (void *, void *),
+ void *user_data)
{
- _eina_matrixsparse_row_cells_free(r, free_func, user_data);
- EINA_MAGIC_SET(r, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_matrixsparse_row_mp, r);
+ _eina_matrixsparse_row_cells_free(r, free_func, user_data);
+ EINA_MAGIC_SET(r, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_matrixsparse_row_mp, r);
}
-static inline void
-_eina_matrixsparse_row_unlink(Eina_Matrixsparse_Row *r)
+static inline void _eina_matrixsparse_row_unlink(Eina_Matrixsparse_Row * r)
{
- Eina_Matrixsparse *m = r->parent;
-
- if (m->last_used == r)
- {
- if (r->next)
- m->last_used = r->next;
- else
- m->last_used = r->prev;
- }
-
- if (m->last_row == r)
- m->last_row = r->prev;
-
- if (m->rows == r)
- m->rows = r->next;
-
- if (r->next && r->prev)
- {
- r->next->prev = r->prev;
- r->prev->next = r->next;
- }
- else if (r->next)
- r->next->prev = NULL;
- else if (r->prev)
- r->prev->next = NULL;
+ Eina_Matrixsparse *m = r->parent;
+
+ if (m->last_used == r) {
+ if (r->next)
+ m->last_used = r->next;
+ else
+ m->last_used = r->prev;
+ }
+
+ if (m->last_row == r)
+ m->last_row = r->prev;
+
+ if (m->rows == r)
+ m->rows = r->next;
+
+ if (r->next && r->prev) {
+ r->next->prev = r->prev;
+ r->prev->next = r->next;
+ } else if (r->next)
+ r->next->prev = NULL;
+ else if (r->prev)
+ r->prev->next = NULL;
}
static inline void
-_eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse *m,
- unsigned long row,
- Eina_Matrixsparse_Row **p_r,
- int *p_dir)
+_eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse * m,
+ unsigned long row,
+ Eina_Matrixsparse_Row ** p_r,
+ int *p_dir)
{
- Eina_Matrixsparse_Row *r;
- unsigned long dist;
- int dir;
-
- dist = row - m->rows->row;
- r = m->rows;
- dir = 1;
- if (dist > m->last_row->row - row)
- {
- dist = m->last_row->row - row;
- r = m->last_row;
- dir = -1;
- }
-
- if (m->last_used)
- {
- if (m->last_used->row < row)
- {
- if (dist > row - m->last_used->row)
- {
+ Eina_Matrixsparse_Row *r;
+ unsigned long dist;
+ int dir;
+
+ dist = row - m->rows->row;
+ r = m->rows;
+ dir = 1;
+ if (dist > m->last_row->row - row) {
+ dist = m->last_row->row - row;
+ r = m->last_row;
+ dir = -1;
+ }
+
+ if (m->last_used) {
+ if (m->last_used->row < row) {
+ if (dist > row - m->last_used->row) {
/* dist = row = m->last_used->row; */
- r = m->last_used;
- dir = 1;
- }
- }
- else if (dist > m->last_used->row - row)
- {
+ r = m->last_used;
+ dir = 1;
+ }
+ } else if (dist > m->last_used->row - row) {
/* dist = m->last_used->row - row; */
- r = m->last_used;
- dir = -1;
- }
- }
+ r = m->last_used;
+ dir = -1;
+ }
+ }
- *p_r = r;
- *p_dir = dir;
+ *p_r = r;
+ *p_dir = dir;
}
static inline void
-_eina_matrixsparse_row_cell_find_parms_get(const Eina_Matrixsparse_Row *r,
- unsigned long col,
- Eina_Matrixsparse_Cell **p_c,
- int *p_dir)
+_eina_matrixsparse_row_cell_find_parms_get(const Eina_Matrixsparse_Row * r,
+ unsigned long col,
+ Eina_Matrixsparse_Cell ** p_c,
+ int *p_dir)
{
- Eina_Matrixsparse_Cell *c;
- unsigned long dist;
- int dir;
-
- dist = col - r->cols->col;
- c = r->cols;
- dir = 1;
- if (dist > r->last_col->col - col)
- {
- dist = r->last_col->col - col;
- c = r->last_col;
- dir = -1;
- }
-
- if (r->last_used)
- {
- if (r->last_used->col < col)
- {
- if (dist > col - r->last_used->col)
- {
+ Eina_Matrixsparse_Cell *c;
+ unsigned long dist;
+ int dir;
+
+ dist = col - r->cols->col;
+ c = r->cols;
+ dir = 1;
+ if (dist > r->last_col->col - col) {
+ dist = r->last_col->col - col;
+ c = r->last_col;
+ dir = -1;
+ }
+
+ if (r->last_used) {
+ if (r->last_used->col < col) {
+ if (dist > col - r->last_used->col) {
/* dist = col = r->last_used->col; */
- c = r->last_used;
- dir = 1;
- }
- }
- else if (dist > r->last_used->col - col)
- {
+ c = r->last_used;
+ dir = 1;
+ }
+ } else if (dist > r->last_used->col - col) {
/* dist = r->last_used->col - col; */
- c = r->last_used;
- dir = -1;
- }
- }
+ c = r->last_used;
+ dir = -1;
+ }
+ }
- *p_c = c;
- *p_dir = dir;
+ *p_c = c;
+ *p_dir = dir;
}
-static inline Eina_Matrixsparse_Row *
-_eina_matrixsparse_row_idx_get(const Eina_Matrixsparse *m, unsigned long row)
+static inline Eina_Matrixsparse_Row *_eina_matrixsparse_row_idx_get(const
+ Eina_Matrixsparse
+ * m,
+ unsigned
+ long
+ row)
{
- Eina_Matrixsparse_Row *r;
- int dir;
-
- if (!m->rows)
- return NULL;
-
- if (m->rows->row == row)
- return m->rows;
- else if (m->rows->row > row)
- return NULL;
-
- if (m->last_row->row == row)
- return m->last_row;
- else if (m->last_row->row < row)
- return NULL;
-
- if ((m->last_used) && (m->last_used->row == row))
- return m->last_used;
-
- _eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
- assert(dir != 0);
- if (dir > 0)
- {
- for (; r; r = r->next)
- if (r->row == row)
- {
- ((Eina_Matrixsparse *)m)->last_used = r;
- return r;
- }
- else if (r->row > row)
- return NULL;
-
- }
- else if (dir < 0)
- {
- for (; r; r = r->prev)
- if (r->row == row)
- {
- ((Eina_Matrixsparse *)m)->last_used = r;
- return r;
- }
- else if (r->row < row)
- return NULL;
- }
-
- return NULL;
+ Eina_Matrixsparse_Row *r;
+ int dir;
+
+ if (!m->rows)
+ return NULL;
+
+ if (m->rows->row == row)
+ return m->rows;
+ else if (m->rows->row > row)
+ return NULL;
+
+ if (m->last_row->row == row)
+ return m->last_row;
+ else if (m->last_row->row < row)
+ return NULL;
+
+ if ((m->last_used) && (m->last_used->row == row))
+ return m->last_used;
+
+ _eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
+ assert(dir != 0);
+ if (dir > 0) {
+ for (; r; r = r->next)
+ if (r->row == row) {
+ ((Eina_Matrixsparse *) m)->last_used = r;
+ return r;
+ } else if (r->row > row)
+ return NULL;
+
+ } else if (dir < 0) {
+ for (; r; r = r->prev)
+ if (r->row == row) {
+ ((Eina_Matrixsparse *) m)->last_used = r;
+ return r;
+ } else if (r->row < row)
+ return NULL;
+ }
+
+ return NULL;
}
-static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_row_cell_idx_get(const Eina_Matrixsparse_Row *r,
- unsigned long col)
+static inline Eina_Matrixsparse_Cell
+ *_eina_matrixsparse_row_cell_idx_get(const Eina_Matrixsparse_Row * r,
+ unsigned long col)
{
- Eina_Matrixsparse_Cell *c;
- int dir;
-
- if (!r->cols)
- return NULL;
-
- if (r->cols->col == col)
- return r->cols;
- else if (r->cols->col > col)
- return NULL;
-
- if (r->last_col->col == col)
- return r->last_col;
- else if (r->last_col->col < col)
- return NULL;
-
- if ((r->last_used) && (r->last_used->col == col))
- return r->last_used;
-
- _eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
- assert(dir != 0);
- if (dir > 0)
- {
- for (; r; c = c->next)
- if (c->col == col)
- {
- ((Eina_Matrixsparse_Row *)r)->last_used = c;
- return c;
- }
- else if (c->col > col)
- return NULL;
-
- }
- else if (dir < 0)
- {
- for (; r; c = c->prev)
- if (c->col == col)
- {
- ((Eina_Matrixsparse_Row *)r)->last_used = c;
- return c;
- }
- else if (c->col < col)
- return NULL;
- }
-
- return NULL;
+ Eina_Matrixsparse_Cell *c;
+ int dir;
+
+ if (!r->cols)
+ return NULL;
+
+ if (r->cols->col == col)
+ return r->cols;
+ else if (r->cols->col > col)
+ return NULL;
+
+ if (r->last_col->col == col)
+ return r->last_col;
+ else if (r->last_col->col < col)
+ return NULL;
+
+ if ((r->last_used) && (r->last_used->col == col))
+ return r->last_used;
+
+ _eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
+ assert(dir != 0);
+ if (dir > 0) {
+ for (; r; c = c->next)
+ if (c->col == col) {
+ ((Eina_Matrixsparse_Row *) r)->last_used =
+ c;
+ return c;
+ } else if (c->col > col)
+ return NULL;
+
+ } else if (dir < 0) {
+ for (; r; c = c->prev)
+ if (c->col == col) {
+ ((Eina_Matrixsparse_Row *) r)->last_used =
+ c;
+ return c;
+ } else if (c->col < col)
+ return NULL;
+ }
+
+ return NULL;
}
-static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m,
- unsigned long row,
- unsigned long col)
+static inline Eina_Matrixsparse_Cell *_eina_matrixsparse_cell_idx_get(const
+ Eina_Matrixsparse
+ * m,
+ unsigned
+ long
+ row,
+ unsigned
+ long
+ col)
{
- Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
- if (!r)
- return NULL;
+ Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
+ if (!r)
+ return NULL;
- return _eina_matrixsparse_row_cell_idx_get(r, col);
+ return _eina_matrixsparse_row_cell_idx_get(r, col);
}
static inline void
-_eina_matrixsparse_row_idx_siblings_find(const Eina_Matrixsparse *m,
- unsigned long row,
- Eina_Matrixsparse_Row **p_prev,
- Eina_Matrixsparse_Row **p_next)
+_eina_matrixsparse_row_idx_siblings_find(const Eina_Matrixsparse * m,
+ unsigned long row,
+ Eina_Matrixsparse_Row ** p_prev,
+ Eina_Matrixsparse_Row ** p_next)
{
- Eina_Matrixsparse_Row *r;
- int dir;
-
- _eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
- assert(dir != 0);
- if (dir > 0)
- {
- for (; r; r = r->next)
- if (r->row > row)
- break;
-
- assert(r != NULL);
- *p_prev = r->prev;
- *p_next = r;
- }
- else if (dir < 0)
- {
- for (; r; r = r->prev)
- if (r->row < row)
- break;
-
- assert(r != NULL);
- *p_prev = r;
- *p_next = r->next;
- }
+ Eina_Matrixsparse_Row *r;
+ int dir;
+
+ _eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
+ assert(dir != 0);
+ if (dir > 0) {
+ for (; r; r = r->next)
+ if (r->row > row)
+ break;
+
+ assert(r != NULL);
+ *p_prev = r->prev;
+ *p_next = r;
+ } else if (dir < 0) {
+ for (; r; r = r->prev)
+ if (r->row < row)
+ break;
+
+ assert(r != NULL);
+ *p_prev = r;
+ *p_next = r->next;
+ }
}
static inline void
-_eina_matrixsparse_row_cell_idx_siblings_find(const Eina_Matrixsparse_Row *r,
- unsigned long col,
- Eina_Matrixsparse_Cell **p_prev,
- Eina_Matrixsparse_Cell **p_next)
+_eina_matrixsparse_row_cell_idx_siblings_find(const Eina_Matrixsparse_Row *
+ r, unsigned long col,
+ Eina_Matrixsparse_Cell **
+ p_prev,
+ Eina_Matrixsparse_Cell **
+ p_next)
{
- Eina_Matrixsparse_Cell *c;
- int dir;
-
- _eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
- assert(dir != 0);
- if (dir > 0)
- {
- for (; c; c = c->next)
- if (c->col > col)
- break;
-
- assert(c != NULL);
- *p_prev = c->prev;
- *p_next = c;
- }
- else if (dir < 0)
- {
- for (; c; c = c->prev)
- if (c->col < col)
- break;
-
- assert(c != NULL);
- *p_prev = c;
- *p_next = c->next;
- }
+ Eina_Matrixsparse_Cell *c;
+ int dir;
+
+ _eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
+ assert(dir != 0);
+ if (dir > 0) {
+ for (; c; c = c->next)
+ if (c->col > col)
+ break;
+
+ assert(c != NULL);
+ *p_prev = c->prev;
+ *p_next = c;
+ } else if (dir < 0) {
+ for (; c; c = c->prev)
+ if (c->col < col)
+ break;
+
+ assert(c != NULL);
+ *p_prev = c;
+ *p_next = c->next;
+ }
}
-static inline Eina_Matrixsparse_Row *
-_eina_matrixsparse_row_idx_add(Eina_Matrixsparse *m, unsigned long row)
+static inline Eina_Matrixsparse_Row
+ *_eina_matrixsparse_row_idx_add(Eina_Matrixsparse * m,
+ unsigned long row)
{
- Eina_Matrixsparse_Row *r = eina_mempool_malloc
- (_eina_matrixsparse_row_mp, sizeof(Eina_Matrixsparse_Row));
- if (!r)
- return NULL;
-
- if (!m->rows)
- {
- r->prev = NULL;
- r->next = NULL;
- m->rows = r;
- m->last_row = r;
- }
- else if (row < m->rows->row)
- {
- r->prev = NULL;
- r->next = m->rows;
- m->rows->prev = r;
- m->rows = r;
- }
- else if (row > m->last_row->row)
- {
- r->prev = m->last_row;
- m->last_row->next = r;
- r->next = NULL;
- m->last_row = r;
- }
- else
- {
- Eina_Matrixsparse_Row *prev = NULL, *next = NULL;
- _eina_matrixsparse_row_idx_siblings_find(m, row, &prev, &next);
- assert(prev != NULL);
- assert(next != NULL);
- r->prev = prev;
- r->next = next;
- prev->next = r;
- next->prev = r;
- }
-
- r->cols = NULL;
- r->last_col = NULL;
- r->last_used = NULL;
- r->row = row;
- r->parent = m;
- EINA_MAGIC_SET(r, EINA_MAGIC_MATRIXSPARSE_ROW);
- m->last_used = r;
- return r;
+ Eina_Matrixsparse_Row *r = eina_mempool_malloc
+ (_eina_matrixsparse_row_mp, sizeof(Eina_Matrixsparse_Row));
+ if (!r)
+ return NULL;
+
+ if (!m->rows) {
+ r->prev = NULL;
+ r->next = NULL;
+ m->rows = r;
+ m->last_row = r;
+ } else if (row < m->rows->row) {
+ r->prev = NULL;
+ r->next = m->rows;
+ m->rows->prev = r;
+ m->rows = r;
+ } else if (row > m->last_row->row) {
+ r->prev = m->last_row;
+ m->last_row->next = r;
+ r->next = NULL;
+ m->last_row = r;
+ } else {
+ Eina_Matrixsparse_Row *prev = NULL, *next = NULL;
+ _eina_matrixsparse_row_idx_siblings_find(m, row, &prev,
+ &next);
+ assert(prev != NULL);
+ assert(next != NULL);
+ r->prev = prev;
+ r->next = next;
+ prev->next = r;
+ next->prev = r;
+ }
+
+ r->cols = NULL;
+ r->last_col = NULL;
+ r->last_used = NULL;
+ r->row = row;
+ r->parent = m;
+ EINA_MAGIC_SET(r, EINA_MAGIC_MATRIXSPARSE_ROW);
+ m->last_used = r;
+ return r;
}
-static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_row_cell_idx_add(Eina_Matrixsparse_Row *r,
- unsigned long col,
- const void *data)
+static inline Eina_Matrixsparse_Cell
+ *_eina_matrixsparse_row_cell_idx_add(Eina_Matrixsparse_Row * r,
+ unsigned long col,
+ const void *data)
{
- Eina_Matrixsparse_Cell *c = eina_mempool_malloc
- (_eina_matrixsparse_cell_mp, sizeof(Eina_Matrixsparse_Cell));
- if (!c)
- return NULL;
-
- if (!r->cols)
- {
- c->prev = NULL;
- c->next = NULL;
- r->cols = c;
- r->last_col = c;
- }
- else if (col < r->cols->col)
- {
- c->prev = NULL;
- c->next = r->cols;
- r->cols->prev = c;
- r->cols = c;
- }
- else if (col > r->last_col->col)
- {
- c->prev = r->last_col;
- r->last_col->next = c;
- c->next = NULL;
- r->last_col = c;
- }
- else
- {
- Eina_Matrixsparse_Cell *prev = NULL, *next = NULL;
- _eina_matrixsparse_row_cell_idx_siblings_find(r, col, &prev, &next);
- assert(prev != NULL);
- assert(next != NULL);
- c->prev = prev;
- c->next = next;
- prev->next = c;
- next->prev = c;
- }
-
- c->data = (void *)data;
- c->col = col;
- c->parent = r;
- EINA_MAGIC_SET(c, EINA_MAGIC_MATRIXSPARSE_CELL);
- r->last_used = c;
- return c;
+ Eina_Matrixsparse_Cell *c = eina_mempool_malloc
+ (_eina_matrixsparse_cell_mp, sizeof(Eina_Matrixsparse_Cell));
+ if (!c)
+ return NULL;
+
+ if (!r->cols) {
+ c->prev = NULL;
+ c->next = NULL;
+ r->cols = c;
+ r->last_col = c;
+ } else if (col < r->cols->col) {
+ c->prev = NULL;
+ c->next = r->cols;
+ r->cols->prev = c;
+ r->cols = c;
+ } else if (col > r->last_col->col) {
+ c->prev = r->last_col;
+ r->last_col->next = c;
+ c->next = NULL;
+ r->last_col = c;
+ } else {
+ Eina_Matrixsparse_Cell *prev = NULL, *next = NULL;
+ _eina_matrixsparse_row_cell_idx_siblings_find(r, col,
+ &prev,
+ &next);
+ assert(prev != NULL);
+ assert(next != NULL);
+ c->prev = prev;
+ c->next = next;
+ prev->next = c;
+ next->prev = c;
+ }
+
+ c->data = (void *) data;
+ c->col = col;
+ c->parent = r;
+ EINA_MAGIC_SET(c, EINA_MAGIC_MATRIXSPARSE_CELL);
+ r->last_used = c;
+ return c;
}
static inline Eina_Bool
-_eina_matrixsparse_cell_idx_add(Eina_Matrixsparse *m,
- unsigned long row,
- unsigned long col,
- const void *data)
+_eina_matrixsparse_cell_idx_add(Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col, const void *data)
{
- Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
- if (!r)
- r = _eina_matrixsparse_row_idx_add(m, row);
+ Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
+ if (!r)
+ r = _eina_matrixsparse_row_idx_add(m, row);
- if (!r)
- return 0;
+ if (!r)
+ return 0;
- if (_eina_matrixsparse_row_cell_idx_add(r, col, data))
- return 1;
+ if (_eina_matrixsparse_row_cell_idx_add(r, col, data))
+ return 1;
- if (r->cols)
- return 0;
+ if (r->cols)
+ return 0;
- _eina_matrixsparse_row_unlink(r);
- _eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
- return 0;
+ _eina_matrixsparse_row_unlink(r);
+ _eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
+ return 0;
}
/*============================================================================*
* Iterators *
*============================================================================*/
static Eina_Bool
-_eina_matrixsparse_iterator_next(Eina_Matrixsparse_Iterator *it, void **data)
+_eina_matrixsparse_iterator_next(Eina_Matrixsparse_Iterator * it,
+ void **data)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, EINA_FALSE);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, EINA_FALSE);
- /* do not touch it->idx */
+ /* do not touch it->idx */
- if (!it->ref.col)
- return 0;
+ if (!it->ref.col)
+ return 0;
- *data = (Eina_Matrixsparse_Cell *)it->ref.col;
+ *data = (Eina_Matrixsparse_Cell *) it->ref.col;
- it->ref.col = it->ref.col->next;
- if (!it->ref.col)
- {
- it->ref.row = it->ref.row->next;
- if (it->ref.row)
- it->ref.col = it->ref.row->cols;
- }
+ it->ref.col = it->ref.col->next;
+ if (!it->ref.col) {
+ it->ref.row = it->ref.row->next;
+ if (it->ref.row)
+ it->ref.col = it->ref.row->cols;
+ }
- return 1;
+ return 1;
}
-static Eina_Matrixsparse *
-_eina_matrixsparse_iterator_get_container(Eina_Matrixsparse_Iterator *it)
+static Eina_Matrixsparse
+ *_eina_matrixsparse_iterator_get_container(Eina_Matrixsparse_Iterator *
+ it)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
- return (Eina_Matrixsparse *)it->m;
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
+ return (Eina_Matrixsparse *) it->m;
}
static void
-_eina_matrixsparse_iterator_free(Eina_Matrixsparse_Iterator *it)
+_eina_matrixsparse_iterator_free(Eina_Matrixsparse_Iterator * it)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
- EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
- free(it);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
+ EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
+ free(it);
}
static Eina_Bool
-_eina_matrixsparse_iterator_complete_next(
- Eina_Matrixsparse_Iterator_Complete *it,
- void **data)
+_eina_matrixsparse_iterator_complete_next
+(Eina_Matrixsparse_Iterator_Complete * it, void **data)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, EINA_FALSE);
-
- if (it->idx.row >= it->m->size.rows)
- return 0;
-
- if (it->dummy.col.data)
- ERR("Last iterator call changed dummy cell!");
-
- if ((it->ref.col) &&
- (it->ref.col->col == it->idx.col) &&
- (it->ref.row->row == it->idx.row))
- {
- *data = (Eina_Matrixsparse_Cell *)it->ref.col;
- it->ref.col = it->ref.col->next;
- if (!it->ref.col)
- {
- it->ref.row = it->ref.row->next;
- if (it->ref.row)
- it->ref.col = it->ref.row->cols;
- }
- }
- else
- {
- it->dummy.col.data = NULL;
- it->dummy.col.col = it->idx.col;
- it->dummy.row.row = it->idx.row;
- *data = &it->dummy.col;
- }
-
- it->idx.col++;
- if (it->idx.col == it->m->size.cols)
- {
- it->idx.col = 0;
- it->idx.row++;
- }
-
- return 1;
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, EINA_FALSE);
+
+ if (it->idx.row >= it->m->size.rows)
+ return 0;
+
+ if (it->dummy.col.data)
+ ERR("Last iterator call changed dummy cell!");
+
+ if ((it->ref.col) &&
+ (it->ref.col->col == it->idx.col) &&
+ (it->ref.row->row == it->idx.row)) {
+ *data = (Eina_Matrixsparse_Cell *) it->ref.col;
+ it->ref.col = it->ref.col->next;
+ if (!it->ref.col) {
+ it->ref.row = it->ref.row->next;
+ if (it->ref.row)
+ it->ref.col = it->ref.row->cols;
+ }
+ } else {
+ it->dummy.col.data = NULL;
+ it->dummy.col.col = it->idx.col;
+ it->dummy.row.row = it->idx.row;
+ *data = &it->dummy.col;
+ }
+
+ it->idx.col++;
+ if (it->idx.col == it->m->size.cols) {
+ it->idx.col = 0;
+ it->idx.row++;
+ }
+
+ return 1;
}
-static Eina_Matrixsparse *
-_eina_matrixsparse_iterator_complete_get_container(
- Eina_Matrixsparse_Iterator_Complete *it)
+static Eina_Matrixsparse
+ *_eina_matrixsparse_iterator_complete_get_container
+ (Eina_Matrixsparse_Iterator_Complete * it)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
- return (Eina_Matrixsparse *)it->m;
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
+ return (Eina_Matrixsparse *) it->m;
}
static void
-_eina_matrixsparse_iterator_complete_free(
- Eina_Matrixsparse_Iterator_Complete *it)
+_eina_matrixsparse_iterator_complete_free
+(Eina_Matrixsparse_Iterator_Complete * it)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
- if (it->dummy.col.data)
- ERR("Last iterator call changed dummy cell!");
+ if (it->dummy.col.data)
+ ERR("Last iterator call changed dummy cell!");
- EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
- free(it);
+ EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
+ free(it);
}
@@ -843,67 +786,60 @@ _eina_matrixsparse_iterator_complete_free(
*
* @see eina_init()
*/
-Eina_Bool
-eina_matrixsparse_init(void)
+Eina_Bool eina_matrixsparse_init(void)
{
- const char *choice, *tmp;
-
- _eina_matrixsparse_log_dom = eina_log_domain_register("eina_matrixsparse",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_matrixsparse_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_matrixsparse");
- return EINA_FALSE;
- }
-
+ const char *choice, *tmp;
+
+ _eina_matrixsparse_log_dom =
+ eina_log_domain_register("eina_matrixsparse",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_matrixsparse_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_matrixsparse");
+ return EINA_FALSE;
+ }
#ifdef EINA_DEFAULT_MEMPOOL
- choice = "pass_through";
+ choice = "pass_through";
#else
- choice = "chained_mempool";
+ choice = "chained_mempool";
#endif
- tmp = getenv("EINA_MEMPOOL");
- if (tmp && tmp[0])
- choice = tmp;
-
- _eina_matrixsparse_cell_mp = eina_mempool_add
- (choice,
- "matrixsparse_cell",
- NULL,
- sizeof (Eina_Matrixsparse_Cell),
- 120);
- if (!_eina_matrixsparse_cell_mp)
- {
- ERR(
- "Mempool for matrixsparse_cell cannot be allocated in matrixsparse init.");
- goto on_init_fail;
- }
-
- _eina_matrixsparse_row_mp = eina_mempool_add
- (choice, "matrixsparse_row", NULL, sizeof (Eina_Matrixsparse_Row), 120);
- if (!_eina_matrixsparse_row_mp)
- {
- ERR(
- "Mempool for matrixsparse_row cannot be allocated in matrixsparse init.");
- goto on_init_fail;
- }
-
+ tmp = getenv("EINA_MEMPOOL");
+ if (tmp && tmp[0])
+ choice = tmp;
+
+ _eina_matrixsparse_cell_mp = eina_mempool_add
+ (choice,
+ "matrixsparse_cell",
+ NULL, sizeof(Eina_Matrixsparse_Cell), 120);
+ if (!_eina_matrixsparse_cell_mp) {
+ ERR("Mempool for matrixsparse_cell cannot be allocated in matrixsparse init.");
+ goto on_init_fail;
+ }
+
+ _eina_matrixsparse_row_mp = eina_mempool_add
+ (choice, "matrixsparse_row", NULL,
+ sizeof(Eina_Matrixsparse_Row), 120);
+ if (!_eina_matrixsparse_row_mp) {
+ ERR("Mempool for matrixsparse_row cannot be allocated in matrixsparse init.");
+ goto on_init_fail;
+ }
#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
- EMS(EINA_MAGIC_MATRIXSPARSE);
- EMS(EINA_MAGIC_MATRIXSPARSE_ROW);
- EMS(EINA_MAGIC_MATRIXSPARSE_CELL);
- EMS(EINA_MAGIC_MATRIXSPARSE_ITERATOR);
- EMS(EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR);
- EMS(EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR);
- EMS(EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR);
- EMS(EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR);
+ EMS(EINA_MAGIC_MATRIXSPARSE);
+ EMS(EINA_MAGIC_MATRIXSPARSE_ROW);
+ EMS(EINA_MAGIC_MATRIXSPARSE_CELL);
+ EMS(EINA_MAGIC_MATRIXSPARSE_ITERATOR);
+ EMS(EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR);
+ EMS(EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR);
+ EMS(EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR);
+ EMS(EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR);
#undef EMS
- return EINA_TRUE;
+ return EINA_TRUE;
-on_init_fail:
- eina_log_domain_unregister(_eina_matrixsparse_log_dom);
- _eina_matrixsparse_log_dom = -1;
- return EINA_FALSE;
+ on_init_fail:
+ eina_log_domain_unregister(_eina_matrixsparse_log_dom);
+ _eina_matrixsparse_log_dom = -1;
+ return EINA_FALSE;
}
/**
@@ -917,15 +853,14 @@ on_init_fail:
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_matrixsparse_shutdown(void)
+Eina_Bool eina_matrixsparse_shutdown(void)
{
- eina_mempool_del(_eina_matrixsparse_row_mp);
- eina_mempool_del(_eina_matrixsparse_cell_mp);
+ eina_mempool_del(_eina_matrixsparse_row_mp);
+ eina_mempool_del(_eina_matrixsparse_cell_mp);
- eina_log_domain_unregister(_eina_matrixsparse_log_dom);
- _eina_matrixsparse_log_dom = -1;
- return EINA_TRUE;
+ eina_log_domain_unregister(_eina_matrixsparse_log_dom);
+ _eina_matrixsparse_log_dom = -1;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -959,36 +894,38 @@ eina_matrixsparse_shutdown(void)
* @return newly allocated matrix or NULL if allocation failed and eina_error
* is set.
*/
-EAPI Eina_Matrixsparse *
-eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(
- void *user_data,
- void *cell_data), const void *user_data)
+EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows,
+ unsigned long cols,
+ void (*free_func) (void
+ *user_data,
+ void
+ *cell_data),
+ const void *user_data)
{
- Eina_Matrixsparse *m;
-
- EINA_SAFETY_ON_FALSE_RETURN_VAL(rows > 0, NULL);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(cols > 0, NULL);
-
- m = malloc(sizeof(Eina_Matrixsparse));
- if (!m)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- EINA_MAGIC_SET(m, EINA_MAGIC_MATRIXSPARSE);
-
- m->rows = NULL;
- m->last_row = NULL;
- m->last_used = NULL;
-
- m->size.rows = rows;
- m->size.cols = cols;
- m->free.func = free_func;
- m->free.user_data = (void *)user_data;
-
- eina_error_set(0);
- return m;
+ Eina_Matrixsparse *m;
+
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(rows > 0, NULL);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(cols > 0, NULL);
+
+ m = malloc(sizeof(Eina_Matrixsparse));
+ if (!m) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ EINA_MAGIC_SET(m, EINA_MAGIC_MATRIXSPARSE);
+
+ m->rows = NULL;
+ m->last_row = NULL;
+ m->last_used = NULL;
+
+ m->size.rows = rows;
+ m->size.cols = cols;
+ m->free.func = free_func;
+ m->free.user_data = (void *) user_data;
+
+ eina_error_set(0);
+ return m;
}
/**
@@ -996,28 +933,26 @@ eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(
*
* @param m The Sparse Matrix instance to free, must @b not be @c NULL.
*/
-EAPI void
-eina_matrixsparse_free(Eina_Matrixsparse *m)
+EAPI void eina_matrixsparse_free(Eina_Matrixsparse * m)
{
- void (*free_func)(void *, void *);
- void *user_data;
+ void (*free_func) (void *, void *);
+ void *user_data;
- Eina_Matrixsparse_Row *r;
- EINA_MAGIC_CHECK_MATRIXSPARSE(m);
+ Eina_Matrixsparse_Row *r;
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m);
- free_func = m->free.func;
- user_data = m->free.user_data;
+ free_func = m->free.func;
+ user_data = m->free.user_data;
- r = m->rows;
- while (r)
- {
- Eina_Matrixsparse_Row *r_aux = r;
- r = r->next;
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
- }
+ r = m->rows;
+ while (r) {
+ Eina_Matrixsparse_Row *r_aux = r;
+ r = r->next;
+ _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+ }
- EINA_MAGIC_SET(m, EINA_MAGIC_NONE);
- free(m);
+ EINA_MAGIC_SET(m, EINA_MAGIC_NONE);
+ free(m);
}
/**
@@ -1033,22 +968,21 @@ eina_matrixsparse_free(Eina_Matrixsparse *m)
* invalid, returned value is zero, otherwise it's a positive integer.
*/
EAPI void
-eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
- unsigned long *rows,
- unsigned long *cols)
+eina_matrixsparse_size_get(const Eina_Matrixsparse * m,
+ unsigned long *rows, unsigned long *cols)
{
- if (rows)
- *rows = 0;
+ if (rows)
+ *rows = 0;
- if (cols)
- *cols = 0;
+ if (cols)
+ *cols = 0;
- EINA_MAGIC_CHECK_MATRIXSPARSE(m);
- if (rows)
- *rows = m->size.rows;
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m);
+ if (rows)
+ *rows = m->size.rows;
- if (cols)
- *cols = m->size.cols;
+ if (cols)
+ *cols = m->size.cols;
}
/**
@@ -1067,107 +1001,100 @@ eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
* freed.
*/
EAPI Eina_Bool
-eina_matrixsparse_size_set(Eina_Matrixsparse *m,
- unsigned long rows,
- unsigned long cols)
+eina_matrixsparse_size_set(Eina_Matrixsparse * m,
+ unsigned long rows, unsigned long cols)
{
- Eina_Bool update_last_used_row;
- Eina_Matrixsparse_Row *r;
- void (*free_func)(void *, void *);
- void *user_data;
-
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(rows > 0, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(cols > 0, 0);
-
- if ((rows == m->size.rows) && (cols == m->size.cols))
- return 1;
-
- update_last_used_row = ((m->last_used) && (m->last_used->row >= rows));
- free_func = m->free.func;
- user_data = m->free.user_data;
-
- r = m->last_row;
- while (r && r->row >= rows)
- {
- Eina_Matrixsparse_Row *r_aux = r;
- r = r->prev;
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
- }
- if (!r)
- {
- m->last_row = NULL;
- m->rows = NULL;
- }
- else if (r != m->last_row)
- {
- r->next = NULL;
- m->last_row = r;
- }
-
- if (update_last_used_row)
- m->last_used = m->last_row;
-
- r = m->rows;
- while (r)
- {
- Eina_Matrixsparse_Cell *c = r->last_col;
- Eina_Bool update_last_used_col;
- update_last_used_col = ((r->last_used) && (r->last_used->col >= cols));
- while (c && c->col >= cols)
- {
- Eina_Matrixsparse_Cell *c_aux = c;
- c = c->prev;
- _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
- }
- if (!c)
- {
- Eina_Matrixsparse_Row *r_aux = r;
- r->cols = NULL;
- r->last_col = NULL;
- if (r->next)
- r->next->prev = r->prev;
- else
- m->last_row = r->prev;
-
- if (r->prev)
- r->prev->next = r->next;
- else
- m->rows = r->next;
-
- r = r->next;
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
- }
- else
- {
- if (c != r->last_col)
- {
- c->next = NULL;
- r->last_col = c;
- }
-
- if (update_last_used_col)
- r->last_used = r->last_col;
-
- r = r->next;
- }
- }
-
- update_last_used_row = 0;
- if (m->last_used)
- {
- if (m->last_row)
- update_last_used_row = m->last_used->row > m->last_row->row;
- else
- update_last_used_row = 1;
- }
-
- if (update_last_used_row)
- m->last_used = m->last_row;
-
- m->size.rows = rows;
- m->size.cols = cols;
- return 1;
+ Eina_Bool update_last_used_row;
+ Eina_Matrixsparse_Row *r;
+ void (*free_func) (void *, void *);
+ void *user_data;
+
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(rows > 0, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(cols > 0, 0);
+
+ if ((rows == m->size.rows) && (cols == m->size.cols))
+ return 1;
+
+ update_last_used_row = ((m->last_used)
+ && (m->last_used->row >= rows));
+ free_func = m->free.func;
+ user_data = m->free.user_data;
+
+ r = m->last_row;
+ while (r && r->row >= rows) {
+ Eina_Matrixsparse_Row *r_aux = r;
+ r = r->prev;
+ _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+ }
+ if (!r) {
+ m->last_row = NULL;
+ m->rows = NULL;
+ } else if (r != m->last_row) {
+ r->next = NULL;
+ m->last_row = r;
+ }
+
+ if (update_last_used_row)
+ m->last_used = m->last_row;
+
+ r = m->rows;
+ while (r) {
+ Eina_Matrixsparse_Cell *c = r->last_col;
+ Eina_Bool update_last_used_col;
+ update_last_used_col = ((r->last_used)
+ && (r->last_used->col >= cols));
+ while (c && c->col >= cols) {
+ Eina_Matrixsparse_Cell *c_aux = c;
+ c = c->prev;
+ _eina_matrixsparse_cell_free(c_aux, free_func,
+ user_data);
+ }
+ if (!c) {
+ Eina_Matrixsparse_Row *r_aux = r;
+ r->cols = NULL;
+ r->last_col = NULL;
+ if (r->next)
+ r->next->prev = r->prev;
+ else
+ m->last_row = r->prev;
+
+ if (r->prev)
+ r->prev->next = r->next;
+ else
+ m->rows = r->next;
+
+ r = r->next;
+ _eina_matrixsparse_row_free(r_aux, free_func,
+ user_data);
+ } else {
+ if (c != r->last_col) {
+ c->next = NULL;
+ r->last_col = c;
+ }
+
+ if (update_last_used_col)
+ r->last_used = r->last_col;
+
+ r = r->next;
+ }
+ }
+
+ update_last_used_row = 0;
+ if (m->last_used) {
+ if (m->last_row)
+ update_last_used_row =
+ m->last_used->row > m->last_row->row;
+ else
+ update_last_used_row = 1;
+ }
+
+ if (update_last_used_row)
+ m->last_used = m->last_row;
+
+ m->size.rows = rows;
+ m->size.cols = cols;
+ return 1;
}
/**
@@ -1185,18 +1112,18 @@ eina_matrixsparse_size_set(Eina_Matrixsparse *m,
* @see eina_matrixsparse_data_idx_get()
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m,
- unsigned long row,
- unsigned long col,
- Eina_Matrixsparse_Cell **cell)
+eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col,
+ Eina_Matrixsparse_Cell ** cell)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
- EINA_SAFETY_ON_NULL_RETURN_VAL(cell, 0);
- *cell = NULL;
- EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
- *cell = _eina_matrixsparse_cell_idx_get(m, row, col);
- return 1;
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cell, 0);
+ *cell = NULL;
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
+ *cell = _eina_matrixsparse_cell_idx_get(m, row, col);
+ return 1;
}
/**
@@ -1209,11 +1136,11 @@ eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m,
* @see eina_matrixsparse_cell_idx_get()
* @see eina_matrixsparse_data_idx_get()
*/
-EAPI void *
-eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell)
+EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *
+ cell)
{
- EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, NULL);
- return cell->data;
+ EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, NULL);
+ return cell->data;
}
/**
@@ -1228,18 +1155,17 @@ eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell)
* @see eina_matrixsparse_cell_idx_get()
* @see eina_matrixsparse_cell_data_get()
*/
-EAPI void *
-eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m,
- unsigned long row,
- unsigned long col)
+EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col)
{
- Eina_Matrixsparse_Cell *c;
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, NULL);
- c = _eina_matrixsparse_cell_idx_get(m, row, col);
- if (c)
- return c->data;
- else
- return NULL;
+ Eina_Matrixsparse_Cell *c;
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, NULL);
+ c = _eina_matrixsparse_cell_idx_get(m, row, col);
+ if (c)
+ return c->data;
+ else
+ return NULL;
}
/**
@@ -1252,25 +1178,24 @@ eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m,
* @return 1 on success, 0 otherwise (@c cell is @c NULL).
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell,
- unsigned long *row,
- unsigned long *col)
+eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell * cell,
+ unsigned long *row, unsigned long *col)
{
- if (row)
- *row = 0;
+ if (row)
+ *row = 0;
- if (col)
- *col = 0;
+ if (col)
+ *col = 0;
- EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
- EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
- if (row)
- *row = cell->parent->row;
+ EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
+ if (row)
+ *row = cell->parent->row;
- if (col)
- *col = cell->col;
+ if (col)
+ *col = cell->col;
- return 1;
+ return 1;
}
/**
@@ -1286,20 +1211,19 @@ eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell,
* @see eina_matrixsparse_data_idx_replace()
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell,
- const void *data,
- void **p_old)
+eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell * cell,
+ const void *data, void **p_old)
{
- if (p_old)
- *p_old = NULL;
+ if (p_old)
+ *p_old = NULL;
- EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
- if (p_old)
- *p_old = cell->data;
+ if (p_old)
+ *p_old = cell->data;
- cell->data = (void *)data;
- return 1;
+ cell->data = (void *) data;
+ return 1;
}
/**
@@ -1317,21 +1241,22 @@ eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell,
* @see eina_matrixsparse_data_idx_set()
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data)
+eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell * cell,
+ const void *data)
{
- Eina_Matrixsparse *m;
+ Eina_Matrixsparse *m;
- EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
- EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
- EINA_MAGIC_CHECK_MATRIXSPARSE(cell->parent->parent, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE(cell->parent->parent, 0);
- m = cell->parent->parent;
+ m = cell->parent->parent;
- if (m->free.func)
- m->free.func(m->free.user_data, cell->data);
+ if (m->free.func)
+ m->free.func(m->free.user_data, cell->data);
- cell->data = (void *)data;
- return 1;
+ cell->data = (void *) data;
+ return 1;
}
/**
@@ -1350,32 +1275,30 @@ eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data)
* @see eina_matrixsparse_data_idx_set()
*/
EAPI Eina_Bool
-eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m,
- unsigned long row,
- unsigned long col,
- const void *data,
- void **p_old)
+eina_matrixsparse_data_idx_replace(Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col,
+ const void *data, void **p_old)
{
- Eina_Matrixsparse_Cell *cell;
+ Eina_Matrixsparse_Cell *cell;
- if (p_old)
- *p_old = NULL;
+ if (p_old)
+ *p_old = NULL;
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
- cell = _eina_matrixsparse_cell_idx_get(m, row, col);
- if (cell)
- {
- if (p_old)
- *p_old = cell->data;
+ cell = _eina_matrixsparse_cell_idx_get(m, row, col);
+ if (cell) {
+ if (p_old)
+ *p_old = cell->data;
- cell->data = (void *)data;
- return 1;
- }
+ cell->data = (void *) data;
+ return 1;
+ }
- return _eina_matrixsparse_cell_idx_add(m, row, col, data);
+ return _eina_matrixsparse_cell_idx_add(m, row, col, data);
}
/**
@@ -1395,28 +1318,26 @@ eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m,
* @see eina_matrixsparse_cell_data_replace()
*/
EAPI Eina_Bool
-eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m,
- unsigned long row,
- unsigned long col,
- const void *data)
+eina_matrixsparse_data_idx_set(Eina_Matrixsparse * m,
+ unsigned long row,
+ unsigned long col, const void *data)
{
- Eina_Matrixsparse_Cell *cell;
+ Eina_Matrixsparse_Cell *cell;
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
- cell = _eina_matrixsparse_cell_idx_get(m, row, col);
- if (cell)
- {
- if (m->free.func)
- m->free.func(m->free.user_data, cell->data);
+ cell = _eina_matrixsparse_cell_idx_get(m, row, col);
+ if (cell) {
+ if (m->free.func)
+ m->free.func(m->free.user_data, cell->data);
- cell->data = (void *)data;
- return 1;
- }
+ cell->data = (void *) data;
+ return 1;
+ }
- return _eina_matrixsparse_cell_idx_add(m, row, col, data);
+ return _eina_matrixsparse_cell_idx_add(m, row, col, data);
}
/**
@@ -1437,21 +1358,21 @@ eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m,
* freed.
*/
EAPI Eina_Bool
-eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row)
+eina_matrixsparse_row_idx_clear(Eina_Matrixsparse * m, unsigned long row)
{
- Eina_Matrixsparse_Row *r;
+ Eina_Matrixsparse_Row *r;
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
- r = _eina_matrixsparse_row_idx_get(m, row);
- if (!r)
- return 1;
+ r = _eina_matrixsparse_row_idx_get(m, row);
+ if (!r)
+ return 1;
- _eina_matrixsparse_row_unlink(r);
- _eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
+ _eina_matrixsparse_row_unlink(r);
+ _eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
- return 1;
+ return 1;
}
/**
@@ -1472,42 +1393,41 @@ eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row)
* freed.
*/
EAPI Eina_Bool
-eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col)
+eina_matrixsparse_column_idx_clear(Eina_Matrixsparse * m,
+ unsigned long col)
{
- Eina_Matrixsparse_Row *r;
- void (*free_func)(void *, void *);
- void *user_data;
-
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
-
- free_func = m->free.func;
- user_data = m->free.user_data;
-
- for (r = m->rows; r; )
- {
- Eina_Matrixsparse_Row *r_aux = r;
- Eina_Matrixsparse_Cell *c;
-
- c = _eina_matrixsparse_row_cell_idx_get(r, col);
- r = r->next;
-
- if (!c)
- continue;
-
- if ((r_aux->cols != c) || (r_aux->last_col != c))
- {
- _eina_matrixsparse_cell_unlink(c);
- _eina_matrixsparse_cell_free(c, free_func, user_data);
- }
- else
- {
- _eina_matrixsparse_row_unlink(r_aux);
- _eina_matrixsparse_row_free(r_aux, free_func, user_data);
- }
- }
-
- return 1;
+ Eina_Matrixsparse_Row *r;
+ void (*free_func) (void *, void *);
+ void *user_data;
+
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
+
+ free_func = m->free.func;
+ user_data = m->free.user_data;
+
+ for (r = m->rows; r;) {
+ Eina_Matrixsparse_Row *r_aux = r;
+ Eina_Matrixsparse_Cell *c;
+
+ c = _eina_matrixsparse_row_cell_idx_get(r, col);
+ r = r->next;
+
+ if (!c)
+ continue;
+
+ if ((r_aux->cols != c) || (r_aux->last_col != c)) {
+ _eina_matrixsparse_cell_unlink(c);
+ _eina_matrixsparse_cell_free(c, free_func,
+ user_data);
+ } else {
+ _eina_matrixsparse_row_unlink(r_aux);
+ _eina_matrixsparse_row_free(r_aux, free_func,
+ user_data);
+ }
+ }
+
+ return 1;
}
/**
@@ -1529,24 +1449,23 @@ eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col)
* row if this cell was the last remainder.
*/
EAPI Eina_Bool
-eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m,
- unsigned long row,
- unsigned long col)
+eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse * m,
+ unsigned long row, unsigned long col)
{
- Eina_Matrixsparse_Cell *c;
+ Eina_Matrixsparse_Cell *c;
- EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
- c = _eina_matrixsparse_cell_idx_get(m, row, col);
- if (!c)
- return 1;
+ c = _eina_matrixsparse_cell_idx_get(m, row, col);
+ if (!c)
+ return 1;
- _eina_matrixsparse_cell_unlink(c);
- _eina_matrixsparse_cell_free(c, m->free.func, m->free.user_data);
+ _eina_matrixsparse_cell_unlink(c);
+ _eina_matrixsparse_cell_free(c, m->free.func, m->free.user_data);
- return 1;
+ return 1;
}
/**
@@ -1561,20 +1480,20 @@ eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m,
* freed. Note that this call might delete container column and
* row if this cell was the last remainder.
*/
-EAPI Eina_Bool
-eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell)
+EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell * cell)
{
- Eina_Matrixsparse *m;
+ Eina_Matrixsparse *m;
- EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
- EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
- EINA_MAGIC_CHECK_MATRIXSPARSE(cell->parent->parent, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
+ EINA_MAGIC_CHECK_MATRIXSPARSE(cell->parent->parent, 0);
- m = cell->parent->parent;
+ m = cell->parent->parent;
- _eina_matrixsparse_cell_unlink(cell);
- _eina_matrixsparse_cell_free(cell, m->free.func, m->free.user_data);
- return 1;
+ _eina_matrixsparse_cell_unlink(cell);
+ _eina_matrixsparse_cell_free(cell, m->free.func,
+ m->free.user_data);
+ return 1;
}
/**
@@ -1595,31 +1514,33 @@ eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell)
* invalid! That is, if you add or remove cells this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m)
+EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse
+ * m)
{
- Eina_Matrixsparse_Iterator *it;
-
- it = calloc(1, sizeof(*it));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-
- it->m = m;
- it->ref.row = m->rows;
- it->ref.col = m->rows ? m->rows->cols : NULL;
-
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_matrixsparse_iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_free);
- return &it->iterator;
+ Eina_Matrixsparse_Iterator *it;
+
+ it = calloc(1, sizeof(*it));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+ it->m = m;
+ it->ref.row = m->rows;
+ it->ref.col = m->rows ? m->rows->cols : NULL;
+
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next =
+ FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER
+ (_eina_matrixsparse_iterator_get_container);
+ it->iterator.free =
+ FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_free);
+ return &it->iterator;
}
/**
@@ -1646,45 +1567,47 @@ eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m)
* invalid! That is, if you add or remove cells this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m)
+EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const
+ Eina_Matrixsparse
+ * m)
{
- Eina_Matrixsparse_Iterator_Complete *it;
-
- it = calloc(1, sizeof(*it));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-
- it->m = m;
- it->idx.row = 0;
- it->idx.col = 0;
- it->ref.row = m->rows;
- it->ref.col = m->rows ? m->rows->cols : NULL;
-
- it->dummy.row.next = it->dummy.row.prev = NULL;
- it->dummy.row.cols = it->dummy.row.last_col = it->dummy.row.last_used = NULL;
- it->dummy.row.parent = (Eina_Matrixsparse *)m;
- EINA_MAGIC_SET(&it->dummy.row, EINA_MAGIC_MATRIXSPARSE_ROW);
-
- it->dummy.col.next = it->dummy.col.prev = NULL;
- it->dummy.col.data = NULL;
- it->dummy.col.parent = &it->dummy.row;
- EINA_MAGIC_SET(&it->dummy.col, EINA_MAGIC_MATRIXSPARSE_CELL);
-
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(
- _eina_matrixsparse_iterator_complete_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_matrixsparse_iterator_complete_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(
- _eina_matrixsparse_iterator_complete_free);
- return &it->iterator;
+ Eina_Matrixsparse_Iterator_Complete *it;
+
+ it = calloc(1, sizeof(*it));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+ it->m = m;
+ it->idx.row = 0;
+ it->idx.col = 0;
+ it->ref.row = m->rows;
+ it->ref.col = m->rows ? m->rows->cols : NULL;
+
+ it->dummy.row.next = it->dummy.row.prev = NULL;
+ it->dummy.row.cols = it->dummy.row.last_col =
+ it->dummy.row.last_used = NULL;
+ it->dummy.row.parent = (Eina_Matrixsparse *) m;
+ EINA_MAGIC_SET(&it->dummy.row, EINA_MAGIC_MATRIXSPARSE_ROW);
+
+ it->dummy.col.next = it->dummy.col.prev = NULL;
+ it->dummy.col.data = NULL;
+ it->dummy.col.parent = &it->dummy.row;
+ EINA_MAGIC_SET(&it->dummy.col, EINA_MAGIC_MATRIXSPARSE_CELL);
+
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next =
+ FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_complete_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER
+ (_eina_matrixsparse_iterator_complete_get_container);
+ it->iterator.free =
+ FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_complete_free);
+ return &it->iterator;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_mempool.c b/tests/suite/ecore/src/lib/eina_mempool.c
index b9062bef9a..1828e76ee6 100644
--- a/tests/suite/ecore/src/lib/eina_mempool.c
+++ b/tests/suite/ecore/src/lib/eina_mempool.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <assert.h>
@@ -59,72 +59,70 @@ static int _eina_mempool_log_dom = -1;
#define DBG(...) EINA_LOG_DOM_DBG(_eina_mempool_log_dom, __VA_ARGS__)
-static Eina_Mempool *
-_new_va(const char *name,
- const char *context,
- const char *options,
- va_list args)
+static Eina_Mempool *_new_va(const char *name,
+ const char *context,
+ const char *options, va_list args)
{
- Eina_Mempool_Backend *be;
- Eina_Mempool *mp;
+ Eina_Mempool_Backend *be;
+ Eina_Mempool *mp;
- Eina_Error err = EINA_ERROR_NOT_MEMPOOL_MODULE;
+ Eina_Error err = EINA_ERROR_NOT_MEMPOOL_MODULE;
- eina_error_set(0);
- be = eina_hash_find(_backends, name);
- if (!be)
- goto on_error;
+ eina_error_set(0);
+ be = eina_hash_find(_backends, name);
+ if (!be)
+ goto on_error;
- err = EINA_ERROR_OUT_OF_MEMORY;
- mp = calloc(1, sizeof(Eina_Mempool));
- if (!mp)
- goto on_error;
+ err = EINA_ERROR_OUT_OF_MEMORY;
+ mp = calloc(1, sizeof(Eina_Mempool));
+ if (!mp)
+ goto on_error;
- /* FIXME why backend is not a pointer? */
- mp->backend = *be;
- mp->backend_data = mp->backend.init(context, options, args);
+ /* FIXME why backend is not a pointer? */
+ mp->backend = *be;
+ mp->backend_data = mp->backend.init(context, options, args);
- return mp;
+ return mp;
-on_error:
- eina_error_set(err);
- return NULL;
+ on_error:
+ eina_error_set(err);
+ return NULL;
}
/* Built-in backend's prototypes */
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
Eina_Bool chained_init(void);
-void chained_shutdown(void);
+void chained_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
Eina_Bool pass_through_init(void);
-void pass_through_shutdown(void);
+void pass_through_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
Eina_Bool ememoa_unknown_init(void);
-void ememoa_unknown_shutdown(void);
+void ememoa_unknown_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
Eina_Bool ememoa_fixed_init(void);
-void ememoa_fixed_shutdown(void);
+void ememoa_fixed_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_FIXED_BITMAP
Eina_Bool fixed_bitmap_init(void);
-void fixed_bitmap_shutdown(void);
+void fixed_bitmap_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_BUDDY
Eina_Bool buddy_init(void);
-void buddy_shutdown(void);
+void buddy_shutdown(void);
#endif
#ifdef EINA_STATIC_BUILD_ONE_BIG
Eina_Bool one_big_init(void);
-void one_big_shutdown(void);
+void one_big_shutdown(void);
#endif
/**
@@ -142,145 +140,144 @@ void one_big_shutdown(void);
EAPI Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE = 0;
static const char EINA_ERROR_NOT_MEMPOOL_MODULE_STR[] =
- "Not a memory pool module.";
+ "Not a memory pool module.";
/**
* @endcond
*/
-EAPI Eina_Bool
-eina_mempool_register(Eina_Mempool_Backend *be)
+EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend * be)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(be, 0);
- DBG("be=%p, name=%p", be, be->name);
- return eina_hash_add(_backends, be->name, be);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(be, 0);
+ DBG("be=%p, name=%p", be, be->name);
+ return eina_hash_add(_backends, be->name, be);
}
-EAPI void
-eina_mempool_unregister(Eina_Mempool_Backend *be)
+EAPI void eina_mempool_unregister(Eina_Mempool_Backend * be)
{
- EINA_SAFETY_ON_NULL_RETURN(be);
- DBG("be=%p, name=%p", be, be->name);
- eina_hash_del(_backends, be->name, be);
+ EINA_SAFETY_ON_NULL_RETURN(be);
+ DBG("be=%p, name=%p", be, be->name);
+ eina_hash_del(_backends, be->name, be);
}
-Eina_Bool
-eina_mempool_init(void)
+Eina_Bool eina_mempool_init(void)
{
- char *path;
-
- _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_mempool_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_mempool");
- return 0;
- }
-
- EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_static_register(
- EINA_ERROR_NOT_MEMPOOL_MODULE_STR);
- _backends = eina_hash_string_superfast_new(NULL);
-
- /* dynamic backends */
- _modules = eina_module_arch_list_get(NULL,
- PACKAGE_LIB_DIR "/eina/modules/mp",
- MODULE_ARCH);
-
- path = eina_module_environment_path_get("HOME", "/.eina/mp/modules/mp");
- _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
- if (path)
- free(path);
-
- path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR",
- "/eina/modules/mp");
- _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
- if (path)
- free(path);
-
- path = eina_module_symbol_path_get((const void *)eina_init,
- "/eina/modules/mp");
- _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
- if (path)
- free(path);
-
- if (!_modules)
- {
- ERR("no mempool modules able to be loaded.");
- eina_hash_free(_backends);
- goto mempool_init_error;
- }
-
- eina_module_list_load(_modules);
-
- /* builtin backends */
+ char *path;
+
+ _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_mempool_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_mempool");
+ return 0;
+ }
+
+ EINA_ERROR_NOT_MEMPOOL_MODULE =
+ eina_error_msg_static_register
+ (EINA_ERROR_NOT_MEMPOOL_MODULE_STR);
+ _backends = eina_hash_string_superfast_new(NULL);
+
+ /* dynamic backends */
+ _modules = eina_module_arch_list_get(NULL,
+ PACKAGE_LIB_DIR
+ "/eina/modules/mp",
+ MODULE_ARCH);
+
+ path =
+ eina_module_environment_path_get("HOME",
+ "/.eina/mp/modules/mp");
+ _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
+ if (path)
+ free(path);
+
+ path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR",
+ "/eina/modules/mp");
+ _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
+ if (path)
+ free(path);
+
+ path = eina_module_symbol_path_get((const void *) eina_init,
+ "/eina/modules/mp");
+ _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
+ if (path)
+ free(path);
+
+ if (!_modules) {
+ ERR("no mempool modules able to be loaded.");
+ eina_hash_free(_backends);
+ goto mempool_init_error;
+ }
+
+ eina_module_list_load(_modules);
+
+ /* builtin backends */
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
- chained_init();
+ chained_init();
#endif
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
- pass_through_init();
+ pass_through_init();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
- ememoa_unknown_init();
+ ememoa_unknown_init();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
- ememoa_fixed_init();
+ ememoa_fixed_init();
#endif
#ifdef EINA_STATIC_BUILD_FIXED_BITMAP
- fixed_bitmap_init();
+ fixed_bitmap_init();
#endif
#ifdef EINA_STATIC_BUILD_BUDDY
- buddy_init();
+ buddy_init();
#endif
#ifdef EINA_STATIC_BUILD_ONE_BIG
- one_big_init();
+ one_big_init();
#endif
- return EINA_TRUE;
+ return EINA_TRUE;
-mempool_init_error:
- eina_log_domain_unregister(_eina_mempool_log_dom);
- _eina_mempool_log_dom = -1;
+ mempool_init_error:
+ eina_log_domain_unregister(_eina_mempool_log_dom);
+ _eina_mempool_log_dom = -1;
- return EINA_FALSE;
+ return EINA_FALSE;
}
-Eina_Bool
-eina_mempool_shutdown(void)
+Eina_Bool eina_mempool_shutdown(void)
{
- /* builtin backends */
+ /* builtin backends */
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
- chained_shutdown();
+ chained_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
- pass_through_shutdown();
+ pass_through_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
- ememoa_unknown_shutdown();
+ ememoa_unknown_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
- ememoa_fixed_shutdown();
+ ememoa_fixed_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_FIXED_BITMAP
- fixed_bitmap_shutdown();
+ fixed_bitmap_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_BUDDY
- buddy_shutdown();
+ buddy_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_ONE_BIG
- one_big_shutdown();
+ one_big_shutdown();
#endif
- /* dynamic backends */
- eina_module_list_free(_modules);
- if (_modules)
- eina_array_free(_modules);
+ /* dynamic backends */
+ eina_module_list_free(_modules);
+ if (_modules)
+ eina_array_free(_modules);
- if (_backends)
- eina_hash_free(_backends);
+ if (_backends)
+ eina_hash_free(_backends);
- eina_log_domain_unregister(_eina_mempool_log_dom);
- _eina_mempool_log_dom = -1;
+ eina_log_domain_unregister(_eina_mempool_log_dom);
+ _eina_mempool_log_dom = -1;
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -323,75 +320,72 @@ eina_mempool_shutdown(void)
* @{
*/
-EAPI Eina_Mempool *
-eina_mempool_add(const char *name,
- const char *context,
- const char *options,
- ...)
+EAPI Eina_Mempool *eina_mempool_add(const char *name,
+ const char *context,
+ const char *options, ...)
{
- Eina_Mempool *mp;
- va_list args;
+ Eina_Mempool *mp;
+ va_list args;
- EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
- DBG("name=%s, context=%s, options=%s",
- name, context ? context : "", options ? options : "");
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+ DBG("name=%s, context=%s, options=%s",
+ name, context ? context : "", options ? options : "");
- va_start(args, options);
- mp = _new_va(name, context, options, args);
- va_end(args);
+ va_start(args, options);
+ mp = _new_va(name, context, options, args);
+ va_end(args);
- DBG("name=%s, context=%s, options=%s, mp=%p",
- name, context ? context : "", options ? options : "", mp);
+ DBG("name=%s, context=%s, options=%s, mp=%p",
+ name, context ? context : "", options ? options : "", mp);
- return mp;
+ return mp;
}
-EAPI void eina_mempool_del(Eina_Mempool *mp)
+EAPI void eina_mempool_del(Eina_Mempool * mp)
{
- EINA_SAFETY_ON_NULL_RETURN(mp);
- EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
- DBG("mp=%p", mp);
- mp->backend.shutdown(mp->backend_data);
- free(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
+ DBG("mp=%p", mp);
+ mp->backend.shutdown(mp->backend_data);
+ free(mp);
}
-EAPI void eina_mempool_gc(Eina_Mempool *mp)
+EAPI void eina_mempool_gc(Eina_Mempool * mp)
{
- EINA_SAFETY_ON_NULL_RETURN(mp);
- EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
- DBG("mp=%p", mp);
- mp->backend.garbage_collect(mp->backend_data);
+ EINA_SAFETY_ON_NULL_RETURN(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
+ DBG("mp=%p", mp);
+ mp->backend.garbage_collect(mp->backend_data);
}
-EAPI void eina_mempool_statistics(Eina_Mempool *mp)
+EAPI void eina_mempool_statistics(Eina_Mempool * mp)
{
- EINA_SAFETY_ON_NULL_RETURN(mp);
- EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
- DBG("mp=%p", mp);
- mp->backend.statistics(mp->backend_data);
+ EINA_SAFETY_ON_NULL_RETURN(mp);
+ EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
+ DBG("mp=%p", mp);
+ mp->backend.statistics(mp->backend_data);
}
-EAPI unsigned int
-eina_mempool_alignof(unsigned int size)
+EAPI unsigned int eina_mempool_alignof(unsigned int size)
{
- int align;
+ int align;
- if (size <= 2)
- align = 2;
- else if (size < 8)
- align = 4;
- else
+ if (size <= 2)
+ align = 2;
+ else if (size < 8)
+ align = 4;
+ else
#if __WORDSIZE == 32
- align = 8;
+ align = 8;
#else
- if (size < 16)
- align = 8;
- else
- align = 16;
+ if (size < 16)
+ align = 8;
+ else
+ align = 16;
#endif
- return ((size / align) + 1) * align;
+ return ((size / align) + 1) * align;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_module.c b/tests/suite/ecore/src/lib/eina_module.c
index 7ae4bdbd6b..2e7301b013 100644
--- a/tests/suite/ecore/src/lib/eina_module.c
+++ b/tests/suite/ecore/src/lib/eina_module.c
@@ -17,28 +17,28 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#ifdef HAVE_DLADDR
-# define _GNU_SOURCE
+#define _GNU_SOURCE
#endif
#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
+#include <alloca.h>
#elif defined __GNUC__
-# define alloca __builtin_alloca
+#define alloca __builtin_alloca
#elif defined _AIX
-# define alloca __alloca
+#define alloca __alloca
#elif defined _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
+#include <malloc.h>
+#define alloca _alloca
#else
-# include <stddef.h>
-# ifdef __cplusplus
+#include <stddef.h>
+#ifdef __cplusplus
extern "C"
-# endif
-void *alloca (size_t);
+#endif
+void *alloca(size_t);
#endif
#include <stdio.h>
@@ -47,15 +47,15 @@ void *alloca (size_t);
#include <string.h>
#ifndef _MSC_VER
-# include <libgen.h>
+#include <libgen.h>
#else
-# include <Evil.h>
+#include <Evil.h>
#endif
#include <dlfcn.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -95,93 +95,89 @@ static int EINA_MODULE_LOG_DOM = -1;
#define EINA_MODULE_SYMBOL_INIT "__eina_module_init"
#define EINA_MODULE_SYMBOL_SHUTDOWN "__eina_module_shutdown"
-struct _Eina_Module
-{
- void *handle;
- int ref;
- const char file[];
+struct _Eina_Module {
+ void *handle;
+ int ref;
+ const char file[];
};
-typedef struct _Dir_List_Get_Cb_Data
-{
- Eina_Module_Cb cb;
- void *data;
- Eina_Array *array;
+typedef struct _Dir_List_Get_Cb_Data {
+ Eina_Module_Cb cb;
+ void *data;
+ Eina_Array *array;
} Dir_List_Get_Cb_Data;
-typedef struct _Dir_List_Cb_Data
-{
- Eina_Module_Cb cb;
- void *data;
+typedef struct _Dir_List_Cb_Data {
+ Eina_Module_Cb cb;
+ void *data;
} Dir_List_Cb_Data;
-static Eina_Bool _dir_list_get_cb(Eina_Module *m, void *data)
+static Eina_Bool _dir_list_get_cb(Eina_Module * m, void *data)
{
- Dir_List_Get_Cb_Data *cb_data = data;
- Eina_Bool ret = EINA_TRUE;
+ Dir_List_Get_Cb_Data *cb_data = data;
+ Eina_Bool ret = EINA_TRUE;
- if (cb_data->cb)
- ret = cb_data->cb(m, cb_data->data);
+ if (cb_data->cb)
+ ret = cb_data->cb(m, cb_data->data);
- if (ret)
- eina_array_push(cb_data->array, m);
+ if (ret)
+ eina_array_push(cb_data->array, m);
- return ret;
+ return ret;
}
static void _dir_list_cb(const char *name, const char *path, void *data)
{
- Dir_List_Cb_Data *cb_data = data;
- size_t length;
+ Dir_List_Cb_Data *cb_data = data;
+ size_t length;
- length = strlen(name);
- if (length < sizeof(SHARED_LIB_SUFFIX)) /* x.so */
- return;
+ length = strlen(name);
+ if (length < sizeof(SHARED_LIB_SUFFIX)) /* x.so */
+ return;
- if (!strcmp(name + length - sizeof(SHARED_LIB_SUFFIX) + 1,
- SHARED_LIB_SUFFIX))
- {
- char *file;
- Eina_Module *m;
+ if (!strcmp(name + length - sizeof(SHARED_LIB_SUFFIX) + 1,
+ SHARED_LIB_SUFFIX)) {
+ char *file;
+ Eina_Module *m;
- length = strlen(path) + strlen(name) + 2;
+ length = strlen(path) + strlen(name) + 2;
- file = alloca(sizeof (char) * length);
- if (!file)
- return;
+ file = alloca(sizeof(char) * length);
+ if (!file)
+ return;
- snprintf(file, length, "%s/%s", path, name);
- m = eina_module_new(file);
- if (!m)
- {
- return; /* call the user provided cb on this module */
+ snprintf(file, length, "%s/%s", path, name);
+ m = eina_module_new(file);
+ if (!m) {
+ return; /* call the user provided cb on this module */
- }
+ }
- if (!cb_data->cb(m, cb_data->data))
- eina_module_free(m);
- }
+ if (!cb_data->cb(m, cb_data->data))
+ eina_module_free(m);
+ }
}
-static void _dir_arch_list_cb(const char *name, const char *path, void *data)
+static void _dir_arch_list_cb(const char *name, const char *path,
+ void *data)
{
- Dir_List_Get_Cb_Data *cb_data = data;
- Eina_Module *m;
- char *file = NULL;
- size_t length;
-
- length = strlen(path) + 1 + strlen(name) + 1 +
- strlen((char *)(cb_data->data)) + 1 + sizeof("module") +
- sizeof(SHARED_LIB_SUFFIX) + 1;
-
- file = alloca(length);
- snprintf(file, length, "%s/%s/%s/module" SHARED_LIB_SUFFIX,
- path, name, (char *)(cb_data->data));
- m = eina_module_new(file);
- if (!m)
- return;
-
- eina_array_push(cb_data->array, m);
+ Dir_List_Get_Cb_Data *cb_data = data;
+ Eina_Module *m;
+ char *file = NULL;
+ size_t length;
+
+ length = strlen(path) + 1 + strlen(name) + 1 +
+ strlen((char *) (cb_data->data)) + 1 + sizeof("module") +
+ sizeof(SHARED_LIB_SUFFIX) + 1;
+
+ file = alloca(length);
+ snprintf(file, length, "%s/%s/%s/module" SHARED_LIB_SUFFIX,
+ path, name, (char *) (cb_data->data));
+ m = eina_module_new(file);
+ if (!m)
+ return;
+
+ eina_array_push(cb_data->array, m);
}
/**
@@ -198,9 +194,9 @@ static void _dir_arch_list_cb(const char *name, const char *path, void *data)
*/
static const char EINA_ERROR_WRONG_MODULE_STR[] =
- "Wrong file format or no file module found";
+ "Wrong file format or no file module found";
static const char EINA_ERROR_MODULE_INIT_FAILED_STR[] =
- "Module initialisation function failed";
+ "Module initialisation function failed";
EAPI Eina_Error EINA_ERROR_WRONG_MODULE = 0;
EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED = 0;
@@ -224,23 +220,20 @@ EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED = 0;
*
* @see eina_init()
*/
-Eina_Bool
-eina_module_init(void)
+Eina_Bool eina_module_init(void)
{
- EINA_MODULE_LOG_DOM = eina_log_domain_register
- ("eina_module", EINA_LOG_COLOR_DEFAULT);
- if (EINA_MODULE_LOG_DOM < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_module");
- return EINA_FALSE;
- }
-
+ EINA_MODULE_LOG_DOM = eina_log_domain_register
+ ("eina_module", EINA_LOG_COLOR_DEFAULT);
+ if (EINA_MODULE_LOG_DOM < 0) {
+ EINA_LOG_ERR("Could not register log domain: eina_module");
+ return EINA_FALSE;
+ }
#define EEMR(n) n = eina_error_msg_static_register(n ## _STR)
- EEMR(EINA_ERROR_WRONG_MODULE);
- EEMR(EINA_ERROR_MODULE_INIT_FAILED);
+ EEMR(EINA_ERROR_WRONG_MODULE);
+ EEMR(EINA_ERROR_MODULE_INIT_FAILED);
#undef EEMR
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -254,16 +247,15 @@ eina_module_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_module_shutdown(void)
+Eina_Bool eina_module_shutdown(void)
{
- /* TODO should we store every module when "new" is called and
- * delete the list of modules here
- */
+ /* TODO should we store every module when "new" is called and
+ * delete the list of modules here
+ */
- eina_log_domain_unregister(EINA_MODULE_LOG_DOM);
- EINA_MODULE_LOG_DOM = -1;
- return EINA_TRUE;
+ eina_log_domain_unregister(EINA_MODULE_LOG_DOM);
+ EINA_MODULE_LOG_DOM = -1;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -295,29 +287,28 @@ eina_module_shutdown(void)
*/
EAPI Eina_Module *eina_module_new(const char *file)
{
- Eina_Module *m;
- size_t len;
+ Eina_Module *m;
+ size_t len;
- EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
- /* TODO check that the file exists. Update doc too */
+ EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
+ /* TODO check that the file exists. Update doc too */
- len = strlen(file);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(len > 0, NULL);
+ len = strlen(file);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(len > 0, NULL);
- m = malloc(sizeof(Eina_Module) + len + 1);
- if (!m)
- {
- ERR("could not malloc(%lu)",
- (unsigned long)(sizeof(Eina_Module) + len + 1));
- return NULL;
- }
+ m = malloc(sizeof(Eina_Module) + len + 1);
+ if (!m) {
+ ERR("could not malloc(%lu)",
+ (unsigned long) (sizeof(Eina_Module) + len + 1));
+ return NULL;
+ }
- memcpy((char *)m->file, file, len + 1);
- m->ref = 0;
- m->handle = NULL;
- DBG("m=%p, file=%s", m, file);
+ memcpy((char *) m->file, file, len + 1);
+ m->ref = 0;
+ m->handle = NULL;
+ DBG("m=%p, file=%s", m, file);
- return m;
+ return m;
}
/**
@@ -331,18 +322,19 @@ EAPI Eina_Module *eina_module_new(const char *file)
* returns EINA_TRUE and EINA_FALSE otherwise. If @p m is @c NULL, the
* function returns immediately.
*/
-EAPI Eina_Bool eina_module_free(Eina_Module *m)
+EAPI Eina_Bool eina_module_free(Eina_Module * m)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
- DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
+ DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file,
+ m->ref);
- if (m->handle)
- if (eina_module_unload(m) == EINA_FALSE)
- return EINA_FALSE;
+ if (m->handle)
+ if (eina_module_unload(m) == EINA_FALSE)
+ return EINA_FALSE;
- free(m);
- return EINA_TRUE;
+ free(m);
+ return EINA_TRUE;
}
/**
@@ -365,47 +357,48 @@ EAPI Eina_Bool eina_module_free(Eina_Module *m)
* When the symbols of the shared file objetcts are not needed
* anymore, call eina_module_unload() to unload the module.
*/
-EAPI Eina_Bool eina_module_load(Eina_Module *m)
+EAPI Eina_Bool eina_module_load(Eina_Module * m)
{
- void *dl_handle;
- Eina_Module_Init *initcall;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
-
- DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
-
- if (m->handle)
- goto loaded;
-
- dl_handle = dlopen(m->file, RTLD_NOW);
- if (!dl_handle)
- {
- WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file, dlerror());
- eina_error_set(EINA_ERROR_WRONG_MODULE);
- return EINA_FALSE;
- }
-
- initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT);
- if ((!initcall) || (!(*initcall)))
- goto ok;
-
- if ((*initcall)() == EINA_TRUE)
- goto ok;
-
- WRN("could not find eina's entry symbol %s inside module %s",
- EINA_MODULE_SYMBOL_INIT, m->file);
- eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
- dlclose(dl_handle);
- return EINA_FALSE;
-ok:
- DBG("successfully loaded %s", m->file);
- m->handle = dl_handle;
-loaded:
- m->ref++;
- DBG("ref %d", m->ref);
-
- eina_error_set(0);
- return EINA_TRUE;
+ void *dl_handle;
+ Eina_Module_Init *initcall;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
+
+ DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file,
+ m->ref);
+
+ if (m->handle)
+ goto loaded;
+
+ dl_handle = dlopen(m->file, RTLD_NOW);
+ if (!dl_handle) {
+ WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file,
+ dlerror());
+ eina_error_set(EINA_ERROR_WRONG_MODULE);
+ return EINA_FALSE;
+ }
+
+ initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT);
+ if ((!initcall) || (!(*initcall)))
+ goto ok;
+
+ if ((*initcall) () == EINA_TRUE)
+ goto ok;
+
+ WRN("could not find eina's entry symbol %s inside module %s",
+ EINA_MODULE_SYMBOL_INIT, m->file);
+ eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
+ dlclose(dl_handle);
+ return EINA_FALSE;
+ ok:
+ DBG("successfully loaded %s", m->file);
+ m->handle = dl_handle;
+ loaded:
+ m->ref++;
+ DBG("ref %d", m->ref);
+
+ eina_error_set(0);
+ return EINA_TRUE;
}
/**
@@ -422,27 +415,27 @@ loaded:
* returned. In all case, the reference counter is decreased. If @p m
* is @c NULL, the function returns immediately #EINA_FALSE.
*/
-EAPI Eina_Bool eina_module_unload(Eina_Module *m)
+EAPI Eina_Bool eina_module_unload(Eina_Module * m)
{
- Eina_Module_Shutdown *shut;
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
+ Eina_Module_Shutdown *shut;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
- DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
+ DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file,
+ m->ref);
- m->ref--;
- if (!m->ref)
- {
- shut = dlsym(m->handle, EINA_MODULE_SYMBOL_SHUTDOWN);
- if ((shut) && (*shut))
- (*shut)();
+ m->ref--;
+ if (!m->ref) {
+ shut = dlsym(m->handle, EINA_MODULE_SYMBOL_SHUTDOWN);
+ if ((shut) && (*shut))
+ (*shut) ();
- dlclose(m->handle);
- m->handle = NULL;
- DBG("unloaded module %s", m->file);
- return EINA_TRUE;
- }
+ dlclose(m->handle);
+ m->handle = NULL;
+ DBG("unloaded module %s", m->file);
+ return EINA_TRUE;
+ }
- return EINA_FALSE;
+ return EINA_FALSE;
}
/**
@@ -457,11 +450,12 @@ EAPI Eina_Bool eina_module_unload(Eina_Module *m)
* is @c NULL, or if it has not been correctly loaded before, the
* function returns immediately @c NULL.
*/
-EAPI void *eina_module_symbol_get(const Eina_Module *m, const char *symbol)
+EAPI void *eina_module_symbol_get(const Eina_Module * m,
+ const char *symbol)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(m->handle, NULL);
- return dlsym(m->handle, symbol);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m->handle, NULL);
+ return dlsym(m->handle, symbol);
}
/**
@@ -474,10 +468,10 @@ EAPI void *eina_module_symbol_get(const Eina_Module *m, const char *symbol)
* @p m is @c NULL, the function returns immediately @c NULL. The
* returned value must no be freed.
*/
-EAPI const char *eina_module_file_get(const Eina_Module *m)
+EAPI const char *eina_module_file_get(const Eina_Module * m)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
- return m->file;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
+ return m->file;
}
/**
@@ -494,44 +488,42 @@ EAPI const char *eina_module_file_get(const Eina_Module *m)
* anymore. If the symbol is not found, or dl_addr() is not supported,
* or allocation fails, this function returns @c NULL.
*/
-EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir)
+EAPI char *eina_module_symbol_path_get(const void *symbol,
+ const char *sub_dir)
{
#ifdef HAVE_DLADDR
- Dl_info eina_dl;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
-
- if (dladdr(symbol, &eina_dl))
- {
- char *pos = strrchr(eina_dl.dli_fname, '/');
- if (pos)
- {
- char *path;
- int l0;
- int l1;
- int l2 = 0;
-
- l0 = strlen(eina_dl.dli_fname);
- l1 = strlen(pos);
- if (sub_dir && (*sub_dir != '\0'))
- l2 = strlen(sub_dir);
-
- path = malloc(l0 - l1 + l2 + 1);
- if (path)
- {
- memcpy(path, eina_dl.dli_fname, l0 - l1);
- if (sub_dir && (*sub_dir != '\0'))
- memcpy(path + l0 - l1, sub_dir, l2);
-
- path[l0 - l1 + l2] = '\0';
- return path;
- }
- }
- }
-
-#endif /* ! HAVE_DLADDR */
-
- return NULL;
+ Dl_info eina_dl;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
+
+ if (dladdr(symbol, &eina_dl)) {
+ char *pos = strrchr(eina_dl.dli_fname, '/');
+ if (pos) {
+ char *path;
+ int l0;
+ int l1;
+ int l2 = 0;
+
+ l0 = strlen(eina_dl.dli_fname);
+ l1 = strlen(pos);
+ if (sub_dir && (*sub_dir != '\0'))
+ l2 = strlen(sub_dir);
+
+ path = malloc(l0 - l1 + l2 + 1);
+ if (path) {
+ memcpy(path, eina_dl.dli_fname, l0 - l1);
+ if (sub_dir && (*sub_dir != '\0'))
+ memcpy(path + l0 - l1, sub_dir,
+ l2);
+
+ path[l0 - l1 + l2] = '\0';
+ return path;
+ }
+ }
+ }
+#endif /* ! HAVE_DLADDR */
+
+ return NULL;
}
/**
@@ -549,37 +541,35 @@ EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir)
* allocation fails, this function returns @c NULL.
*/
EAPI char *eina_module_environment_path_get(const char *env,
- const char *sub_dir)
+ const char *sub_dir)
{
- const char *env_dir;
+ const char *env_dir;
- EINA_SAFETY_ON_NULL_RETURN_VAL(env, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(env, NULL);
- env_dir = getenv(env);
- if (env_dir)
- {
- char *path;
- size_t l1;
- size_t l2 = 0;
+ env_dir = getenv(env);
+ if (env_dir) {
+ char *path;
+ size_t l1;
+ size_t l2 = 0;
- l1 = strlen(env_dir);
- if (sub_dir && (*sub_dir != '\0'))
- l2 = strlen(sub_dir);
+ l1 = strlen(env_dir);
+ if (sub_dir && (*sub_dir != '\0'))
+ l2 = strlen(sub_dir);
- path = (char *)malloc(l1 + l2 + 1);
- if (path)
- {
- memcpy(path, env_dir, l1);
- if (sub_dir && (*sub_dir != '\0'))
- memcpy(path + l1, sub_dir, l2);
+ path = (char *) malloc(l1 + l2 + 1);
+ if (path) {
+ memcpy(path, env_dir, l1);
+ if (sub_dir && (*sub_dir != '\0'))
+ memcpy(path + l1, sub_dir, l2);
- path[l1 + l2] = '\0';
+ path[l1 + l2] = '\0';
- return path;
- }
- }
+ return path;
+ }
+ }
- return NULL;
+ return NULL;
}
/**
@@ -594,22 +584,22 @@ EAPI char *eina_module_environment_path_get(const char *env,
* @c NULL, the function returns immediately @p array. @p array can be
* @c NULL. In that case, it is created with 4 elements.
*/
-EAPI Eina_Array *eina_module_arch_list_get(Eina_Array *array,
- const char *path,
- const char *arch)
+EAPI Eina_Array *eina_module_arch_list_get(Eina_Array * array,
+ const char *path,
+ const char *arch)
{
- Dir_List_Get_Cb_Data list_get_cb_data;
+ Dir_List_Get_Cb_Data list_get_cb_data;
- if ((!path) || (!arch))
- return array;
+ if ((!path) || (!arch))
+ return array;
- list_get_cb_data.array = array ? array : eina_array_new(4);
- list_get_cb_data.cb = NULL;
- list_get_cb_data.data = (void *)arch;
+ list_get_cb_data.array = array ? array : eina_array_new(4);
+ list_get_cb_data.cb = NULL;
+ list_get_cb_data.data = (void *) arch;
- eina_file_dir_list(path, 0, &_dir_arch_list_cb, &list_get_cb_data);
+ eina_file_dir_list(path, 0, &_dir_arch_list_cb, &list_get_cb_data);
- return list_get_cb_data.array;
+ return list_get_cb_data.array;
}
/**
@@ -630,28 +620,27 @@ EAPI Eina_Array *eina_module_arch_list_get(Eina_Array *array,
* @p array can be @c NULL. In that case, it is created with 4
* elements. @p cb can be @c NULL.
*/
-EAPI Eina_Array *eina_module_list_get(Eina_Array *array,
- const char *path,
- Eina_Bool recursive,
- Eina_Module_Cb cb,
- void *data)
+EAPI Eina_Array *eina_module_list_get(Eina_Array * array,
+ const char *path,
+ Eina_Bool recursive,
+ Eina_Module_Cb cb, void *data)
{
- Dir_List_Get_Cb_Data list_get_cb_data;
- Dir_List_Cb_Data list_cb_data;
+ Dir_List_Get_Cb_Data list_get_cb_data;
+ Dir_List_Cb_Data list_cb_data;
- if (!path)
- return array;
+ if (!path)
+ return array;
- list_get_cb_data.array = array ? array : eina_array_new(4);
- list_get_cb_data.cb = cb;
- list_get_cb_data.data = data;
+ list_get_cb_data.array = array ? array : eina_array_new(4);
+ list_get_cb_data.cb = cb;
+ list_get_cb_data.data = data;
- list_cb_data.cb = &_dir_list_get_cb;
- list_cb_data.data = &list_get_cb_data;
+ list_cb_data.cb = &_dir_list_get_cb;
+ list_cb_data.data = &list_get_cb_data;
- eina_file_dir_list(path, recursive, &_dir_list_cb, &list_cb_data);
+ eina_file_dir_list(path, recursive, &_dir_list_cb, &list_cb_data);
- return list_get_cb_data.array;
+ return list_get_cb_data.array;
}
/**
@@ -664,35 +653,34 @@ EAPI Eina_Array *eina_module_list_get(Eina_Array *array,
* If the element is found the function returns the module, else
* @c NULL is returned.
*/
-EAPI Eina_Module *
-eina_module_find(const Eina_Array *array, const char *module)
+EAPI Eina_Module *eina_module_find(const Eina_Array * array,
+ const char *module)
{
- unsigned int i;
- Eina_Array_Iterator iterator;
- Eina_Module *m;
-
- EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
- {
- char *file_m;
- char *tmp;
- ssize_t len;
-
- /* basename() can modify its argument, so we first get a copie */
- /* do not use strdupa, as opensolaris does not have it */
- len = strlen(eina_module_file_get(m));
- tmp = alloca(len + 1);
- memcpy(tmp, eina_module_file_get(m), len + 1);
- file_m = basename(tmp);
- len = strlen(file_m);
- len -= sizeof(SHARED_LIB_SUFFIX) - 1;
- if (len <= 0)
- continue;
-
- if (!strncmp(module, file_m, len))
- return m;;
- }
-
- return NULL;
+ unsigned int i;
+ Eina_Array_Iterator iterator;
+ Eina_Module *m;
+
+ EINA_ARRAY_ITER_NEXT(array, i, m, iterator) {
+ char *file_m;
+ char *tmp;
+ ssize_t len;
+
+ /* basename() can modify its argument, so we first get a copie */
+ /* do not use strdupa, as opensolaris does not have it */
+ len = strlen(eina_module_file_get(m));
+ tmp = alloca(len + 1);
+ memcpy(tmp, eina_module_file_get(m), len + 1);
+ file_m = basename(tmp);
+ len = strlen(file_m);
+ len -= sizeof(SHARED_LIB_SUFFIX) - 1;
+ if (len <= 0)
+ continue;
+
+ if (!strncmp(module, file_m, len))
+ return m;;
+ }
+
+ return NULL;
}
/**
@@ -703,16 +691,16 @@ eina_module_find(const Eina_Array *array, const char *module)
* This function calls eina_module_load() on each element found in
* @p array. If @p array is @c NULL, this function does nothing.
*/
-EAPI void eina_module_list_load(Eina_Array *array)
+EAPI void eina_module_list_load(Eina_Array * array)
{
- Eina_Array_Iterator iterator;
- Eina_Module *m;
- unsigned int i;
-
- EINA_SAFETY_ON_NULL_RETURN(array);
- DBG("array %p, count %u", array, array->count);
- EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
- eina_module_load(m);
+ Eina_Array_Iterator iterator;
+ Eina_Module *m;
+ unsigned int i;
+
+ EINA_SAFETY_ON_NULL_RETURN(array);
+ DBG("array %p, count %u", array, array->count);
+ EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
+ eina_module_load(m);
}
/**
@@ -723,16 +711,16 @@ EAPI void eina_module_list_load(Eina_Array *array)
* This function calls eina_module_unload() on each element found in
* @p array. If @p array is @c NULL, this function does nothing.
*/
-EAPI void eina_module_list_unload(Eina_Array *array)
+EAPI void eina_module_list_unload(Eina_Array * array)
{
- Eina_Array_Iterator iterator;
- Eina_Module *m;
- unsigned int i;
-
- EINA_SAFETY_ON_NULL_RETURN(array);
- DBG("array %p, count %u", array, array->count);
- EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
- eina_module_unload(m);
+ Eina_Array_Iterator iterator;
+ Eina_Module *m;
+ unsigned int i;
+
+ EINA_SAFETY_ON_NULL_RETURN(array);
+ DBG("array %p, count %u", array, array->count);
+ EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
+ eina_module_unload(m);
}
/**
@@ -743,18 +731,18 @@ EAPI void eina_module_list_unload(Eina_Array *array)
* This function calls eina_module_free() on each element found in
* @p array. If @p array is @c NULL, this function does nothing.
*/
-EAPI void eina_module_list_free(Eina_Array *array)
+EAPI void eina_module_list_free(Eina_Array * array)
{
- Eina_Array_Iterator iterator;
- Eina_Module *m;
- unsigned int i;
+ Eina_Array_Iterator iterator;
+ Eina_Module *m;
+ unsigned int i;
- EINA_SAFETY_ON_NULL_RETURN(array);
- DBG("array %p, count %u", array, array->count);
- EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
- eina_module_free(m);
+ EINA_SAFETY_ON_NULL_RETURN(array);
+ DBG("array %p, count %u", array, array->count);
+ EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
+ eina_module_free(m);
- eina_array_flush(array);
+ eina_array_flush(array);
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_private.h b/tests/suite/ecore/src/lib/eina_private.h
index 2f8ff8117d..30b3859a1a 100644
--- a/tests/suite/ecore/src/lib/eina_private.h
+++ b/tests/suite/ecore/src/lib/eina_private.h
@@ -22,9 +22,9 @@
#include <stdarg.h>
#if HAVE___ATTRIBUTE__
-# define __UNUSED__ __attribute__((unused))
+#define __UNUSED__ __attribute__((unused))
#else
-# define __UNUSED__
+#define __UNUSED__
#endif
#include "eina_magic.h"
@@ -32,19 +32,19 @@
#include "eina_accessor.h"
#ifndef MIN
-# define MIN(x, y) (((x) > (y)) ? (y) : (x))
+#define MIN(x, y) (((x) > (y)) ? (y) : (x))
#endif
#ifndef MAX
-# define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef ABS
-# define ABS(x) ((x) < 0 ? -(x) : (x))
+#define ABS(x) ((x) < 0 ? -(x) : (x))
#endif
#ifndef CLAMP
-# define CLAMP(x, min, \
+#define CLAMP(x, min, \
max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
#endif
@@ -131,5 +131,4 @@ void eina_log_threads_init(void);
void eina_log_threads_shutdown(void);
#endif
-#endif /* EINA_PRIVATE_H_ */
-
+#endif /* EINA_PRIVATE_H_ */
diff --git a/tests/suite/ecore/src/lib/eina_quadtree.c b/tests/suite/ecore/src/lib/eina_quadtree.c
index 251bb96faa..063b87b4c1 100644
--- a/tests/suite/ecore/src/lib/eina_quadtree.c
+++ b/tests/suite/ecore/src/lib/eina_quadtree.c
@@ -24,7 +24,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -74,71 +74,66 @@ static const char EINA_MAGIC_QUADTREE_ITEM_STR[] = "Eina QuadTree Item";
} \
} while(0);
-struct _Eina_QuadTree
-{
- EINA_MAGIC;
+struct _Eina_QuadTree {
+ EINA_MAGIC;
- Eina_QuadTree_Root *root;
+ Eina_QuadTree_Root *root;
- Eina_List *hidden;
+ Eina_List *hidden;
- size_t root_count;
- size_t items_count;
+ size_t root_count;
+ size_t items_count;
- Eina_Trash *items_trash;
- Eina_Trash *root_trash;
+ Eina_Trash *items_trash;
+ Eina_Trash *root_trash;
- Eina_Inlist *change;
- Eina_Inlist *cached;
- Eina_Rectangle target;
+ Eina_Inlist *change;
+ Eina_Inlist *cached;
+ Eina_Rectangle target;
- size_t index;
+ size_t index;
- struct
- {
- Eina_Quad_Callback v;
- Eina_Quad_Callback h;
- } func;
+ struct {
+ Eina_Quad_Callback v;
+ Eina_Quad_Callback h;
+ } func;
- struct
- {
- size_t w;
- size_t h;
- } geom;
+ struct {
+ size_t w;
+ size_t h;
+ } geom;
- Eina_Bool resize : 1;
- Eina_Bool lost : 1;
+ Eina_Bool resize:1;
+ Eina_Bool lost:1;
};
-struct _Eina_QuadTree_Root
-{
- EINA_MAGIC;
+struct _Eina_QuadTree_Root {
+ EINA_MAGIC;
- Eina_QuadTree_Root *parent;
- Eina_QuadTree_Root *left;
- Eina_QuadTree_Root *right;
+ Eina_QuadTree_Root *parent;
+ Eina_QuadTree_Root *left;
+ Eina_QuadTree_Root *right;
- Eina_List *both;
+ Eina_List *both;
- Eina_Bool sorted : 1;
+ Eina_Bool sorted:1;
};
-struct _Eina_QuadTree_Item
-{
- EINA_MAGIC;
- EINA_INLIST;
+struct _Eina_QuadTree_Item {
+ EINA_MAGIC;
+ EINA_INLIST;
- Eina_QuadTree *quad;
- Eina_QuadTree_Root *root;
+ Eina_QuadTree *quad;
+ Eina_QuadTree_Root *root;
- const void *object;
+ const void *object;
- size_t index;
+ size_t index;
- Eina_Bool change : 1;
- Eina_Bool delete_me : 1;
- Eina_Bool visible : 1;
- Eina_Bool hidden : 1;
+ Eina_Bool change:1;
+ Eina_Bool delete_me:1;
+ Eina_Bool visible:1;
+ Eina_Bool hidden:1;
};
static int _eina_log_qd_dom = -1;
@@ -156,761 +151,758 @@ static Eina_Mempool *items_mp = NULL;
#define DBG(...) EINA_LOG_DOM_DBG(_eina_log_qd_dom, __VA_ARGS__)
-static int
-_eina_quadtree_item_cmp(const void *a, const void *b)
+static int _eina_quadtree_item_cmp(const void *a, const void *b)
{
- const Eina_QuadTree_Item *i = a;
- const Eina_QuadTree_Item *j = b;
+ const Eina_QuadTree_Item *i = a;
+ const Eina_QuadTree_Item *j = b;
- return i->index - j->index;
+ return i->index - j->index;
}
-static Eina_QuadTree_Root *
-eina_quadtree_root_free(Eina_QuadTree *q, Eina_QuadTree_Root *root)
+static Eina_QuadTree_Root *eina_quadtree_root_free(Eina_QuadTree * q,
+ Eina_QuadTree_Root *
+ root)
{
- Eina_QuadTree_Item *item;
+ Eina_QuadTree_Item *item;
- if (!root)
- return NULL;
+ if (!root)
+ return NULL;
- EINA_MAGIC_CHECK_QUADTREE_ROOT(root, NULL);
+ EINA_MAGIC_CHECK_QUADTREE_ROOT(root, NULL);
- EINA_LIST_FREE(root->both, item)
- eina_mempool_free(items_mp, item);
+ EINA_LIST_FREE(root->both, item)
+ eina_mempool_free(items_mp, item);
- root->left = eina_quadtree_root_free(q, root->left);
- root->right = eina_quadtree_root_free(q, root->right);
+ root->left = eina_quadtree_root_free(q, root->left);
+ root->right = eina_quadtree_root_free(q, root->right);
- EINA_MAGIC_SET(root, 0);
- eina_mempool_free(root_mp, root);
+ EINA_MAGIC_SET(root, 0);
+ eina_mempool_free(root_mp, root);
- return NULL;
+ return NULL;
}
-static Eina_QuadTree_Root *
-eina_quadtree_root_rebuild_pre(Eina_QuadTree *q,
- Eina_Inlist **change,
- Eina_QuadTree_Root *root)
+static Eina_QuadTree_Root *eina_quadtree_root_rebuild_pre(Eina_QuadTree *
+ q,
+ Eina_Inlist **
+ change,
+ Eina_QuadTree_Root
+ * root)
{
- Eina_QuadTree_Item *item;
-
- if (!root)
- return NULL;
-
- EINA_LIST_FREE(root->both, item)
- {
- if (item->visible)
- *change = eina_inlist_append(*change, EINA_INLIST_GET(item));
- else if (!item->hidden)
- {
- q->hidden = eina_list_append(q->hidden, item);
- item->hidden = EINA_TRUE;
- item->root = NULL;
- }
- }
-
- root->left = eina_quadtree_root_rebuild_pre(q, change, root->left);
- root->right = eina_quadtree_root_rebuild_pre(q, change, root->right);
-
- EINA_MAGIC_SET(root, 0);
- if (q->root_count > 50)
- eina_mempool_free(root_mp, root);
- else
- {
- eina_trash_push(&q->root_trash, root);
- q->root_count++;
- }
-
- return NULL;
+ Eina_QuadTree_Item *item;
+
+ if (!root)
+ return NULL;
+
+ EINA_LIST_FREE(root->both, item) {
+ if (item->visible)
+ *change =
+ eina_inlist_append(*change,
+ EINA_INLIST_GET(item));
+ else if (!item->hidden) {
+ q->hidden = eina_list_append(q->hidden, item);
+ item->hidden = EINA_TRUE;
+ item->root = NULL;
+ }
+ }
+
+ root->left = eina_quadtree_root_rebuild_pre(q, change, root->left);
+ root->right =
+ eina_quadtree_root_rebuild_pre(q, change, root->right);
+
+ EINA_MAGIC_SET(root, 0);
+ if (q->root_count > 50)
+ eina_mempool_free(root_mp, root);
+ else {
+ eina_trash_push(&q->root_trash, root);
+ q->root_count++;
+ }
+
+ return NULL;
}
static size_t
-_eina_quadtree_split(Eina_Inlist *objects,
- Eina_QuadTree_Root *root,
- Eina_Inlist **left,
- Eina_Inlist **right,
- Eina_Quad_Callback func,
- int border,
- int middle)
+_eina_quadtree_split(Eina_Inlist * objects,
+ Eina_QuadTree_Root * root,
+ Eina_Inlist ** left,
+ Eina_Inlist ** right,
+ Eina_Quad_Callback func, int border, int middle)
{
- Eina_QuadTree_Item *object;
-
- middle /= 2;
-
- if (middle <= 4)
- while (objects)
- {
- object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
- objects = objects->next;
-
- object->change = EINA_FALSE;
- if (!object->visible)
- {
- if (!object->hidden)
- {
- object->hidden = EINA_TRUE;
- object->quad->hidden = eina_list_append(
- object->quad->hidden,
- object);
- }
-
- continue;
- }
-
- if (object->hidden)
- {
- object->hidden = EINA_FALSE;
- object->quad->hidden = eina_list_remove(object->quad->hidden,
- object);
- }
-
- if (!object->delete_me)
- {
- if (root->sorted)
- root->both = eina_list_sorted_insert(root->both,
- _eina_quadtree_item_cmp,
- object);
- else
- root->both = eina_list_append(root->both, object);
-
- object->root = root;
- }
- else
- eina_quadtree_del(object);
- }
- else
- while (objects)
- {
- object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
- objects = objects->next;
-
- object->change = EINA_FALSE;
- if (!object->visible)
- {
- if (!object->hidden)
- {
- object->hidden = EINA_TRUE;
- object->quad->hidden = eina_list_append(
- object->quad->hidden,
- object);
- }
-
- continue;
- }
-
- if (object->hidden)
- {
- object->hidden = EINA_FALSE;
- object->quad->hidden = eina_list_remove(object->quad->hidden,
- object);
- }
-
- if (!object->delete_me)
- {
- switch (func(object->object, border + middle))
- {
- case EINA_QUAD_LEFT:
- *left = eina_inlist_append(*left, EINA_INLIST_GET(object));
- break;
-
- case EINA_QUAD_RIGHT:
- *right =
- eina_inlist_append(*right, EINA_INLIST_GET(object));
- break;
-
- case EINA_QUAD_BOTH:
- root->both = eina_list_append(root->both, object);
- object->root = root;
- break;
-
- default:
- abort();
- }
- }
- else
- eina_quadtree_del(object);
- }
-
- return middle;
+ Eina_QuadTree_Item *object;
+
+ middle /= 2;
+
+ if (middle <= 4)
+ while (objects) {
+ object =
+ EINA_INLIST_CONTAINER_GET(objects,
+ Eina_QuadTree_Item);
+ objects = objects->next;
+
+ object->change = EINA_FALSE;
+ if (!object->visible) {
+ if (!object->hidden) {
+ object->hidden = EINA_TRUE;
+ object->quad->hidden =
+ eina_list_append(object->quad->
+ hidden,
+ object);
+ }
+
+ continue;
+ }
+
+ if (object->hidden) {
+ object->hidden = EINA_FALSE;
+ object->quad->hidden =
+ eina_list_remove(object->quad->hidden,
+ object);
+ }
+
+ if (!object->delete_me) {
+ if (root->sorted)
+ root->both =
+ eina_list_sorted_insert(root->
+ both,
+ _eina_quadtree_item_cmp,
+ object);
+ else
+ root->both =
+ eina_list_append(root->both,
+ object);
+
+ object->root = root;
+ } else
+ eina_quadtree_del(object);
+ } else
+ while (objects) {
+ object =
+ EINA_INLIST_CONTAINER_GET(objects,
+ Eina_QuadTree_Item);
+ objects = objects->next;
+
+ object->change = EINA_FALSE;
+ if (!object->visible) {
+ if (!object->hidden) {
+ object->hidden = EINA_TRUE;
+ object->quad->hidden =
+ eina_list_append(object->quad->
+ hidden,
+ object);
+ }
+
+ continue;
+ }
+
+ if (object->hidden) {
+ object->hidden = EINA_FALSE;
+ object->quad->hidden =
+ eina_list_remove(object->quad->hidden,
+ object);
+ }
+
+ if (!object->delete_me) {
+ switch (func
+ (object->object,
+ border + middle)) {
+ case EINA_QUAD_LEFT:
+ *left =
+ eina_inlist_append(*left,
+ EINA_INLIST_GET
+ (object));
+ break;
+
+ case EINA_QUAD_RIGHT:
+ *right =
+ eina_inlist_append(*right,
+ EINA_INLIST_GET
+ (object));
+ break;
+
+ case EINA_QUAD_BOTH:
+ root->both =
+ eina_list_append(root->both,
+ object);
+ object->root = root;
+ break;
+
+ default:
+ abort();
+ }
+ } else
+ eina_quadtree_del(object);
+ }
+
+ return middle;
}
-static Eina_QuadTree_Root *
-_eina_quadtree_update(Eina_QuadTree *q, Eina_QuadTree_Root *parent,
- Eina_QuadTree_Root *root, Eina_Inlist *objects,
- Eina_Bool direction, Eina_Rectangle *size)
+static Eina_QuadTree_Root *_eina_quadtree_update(Eina_QuadTree * q,
+ Eina_QuadTree_Root *
+ parent,
+ Eina_QuadTree_Root * root,
+ Eina_Inlist * objects,
+ Eina_Bool direction,
+ Eina_Rectangle * size)
{
- Eina_Inlist *right = NULL;
- Eina_Inlist *left = NULL;
- size_t w2;
- size_t h2;
-
- if (!objects)
- return root;
-
- if (!root)
- {
- root = eina_trash_pop(&q->root_trash);
- if (!root)
- root = eina_mempool_malloc(root_mp, sizeof (Eina_QuadTree_Root));
- else
- q->root_count--;
-
- if (!root)
- /* FIXME: NOT GOOD TIMING, WE ARE GOING TO LEAK MORE MEMORY */
- return NULL;
-
- root->parent = parent;
- root->both = NULL;
- root->left = NULL;
- root->right = NULL;
- root->sorted = EINA_TRUE;
-
- EINA_MAGIC_SET(root, EINA_MAGIC_QUADTREE_ROOT);
- }
-
- w2 = 0;
- h2 = 0;
-
- if (direction)
- w2 = _eina_quadtree_split(objects, root,
- &left, &right,
- q->func.h, size->x, size->w);
- else
- h2 = _eina_quadtree_split(objects, root,
- &left, &right,
- q->func.v, size->y, size->h);
-
- size->w -= w2; size->h -= h2;
- root->left = _eina_quadtree_update(q, root,
- root->left, left,
- !direction, size);
- size->x += w2; size->y += h2;
- root->right = _eina_quadtree_update(q, root,
- root->right, right,
- !direction, size);
- size->x -= w2; size->y -= h2;
- size->w += w2; size->h += h2;
-
- return root;
+ Eina_Inlist *right = NULL;
+ Eina_Inlist *left = NULL;
+ size_t w2;
+ size_t h2;
+
+ if (!objects)
+ return root;
+
+ if (!root) {
+ root = eina_trash_pop(&q->root_trash);
+ if (!root)
+ root =
+ eina_mempool_malloc(root_mp,
+ sizeof
+ (Eina_QuadTree_Root));
+ else
+ q->root_count--;
+
+ if (!root)
+ /* FIXME: NOT GOOD TIMING, WE ARE GOING TO LEAK MORE MEMORY */
+ return NULL;
+
+ root->parent = parent;
+ root->both = NULL;
+ root->left = NULL;
+ root->right = NULL;
+ root->sorted = EINA_TRUE;
+
+ EINA_MAGIC_SET(root, EINA_MAGIC_QUADTREE_ROOT);
+ }
+
+ w2 = 0;
+ h2 = 0;
+
+ if (direction)
+ w2 = _eina_quadtree_split(objects, root,
+ &left, &right,
+ q->func.h, size->x, size->w);
+ else
+ h2 = _eina_quadtree_split(objects, root,
+ &left, &right,
+ q->func.v, size->y, size->h);
+
+ size->w -= w2;
+ size->h -= h2;
+ root->left = _eina_quadtree_update(q, root,
+ root->left, left,
+ !direction, size);
+ size->x += w2;
+ size->y += h2;
+ root->right = _eina_quadtree_update(q, root,
+ root->right, right,
+ !direction, size);
+ size->x -= w2;
+ size->y -= h2;
+ size->w += w2;
+ size->h += h2;
+
+ return root;
}
-static Eina_Inlist *
-_eina_quadtree_merge(Eina_Inlist *result,
- Eina_List *both)
+static Eina_Inlist *_eina_quadtree_merge(Eina_Inlist * result,
+ Eina_List * both)
{
- Eina_QuadTree_Item *item;
- Eina_QuadTree_Item *b;
- Eina_Inlist *moving;
-
- if (!both)
- return result;
-
- if (!result)
- {
- Eina_List *l;
-
- EINA_LIST_FOREACH(both, l, item)
- if (item->visible)
- result = eina_inlist_append(result, EINA_INLIST_GET(item));
-
- return result;
- }
-
- moving = result;
-
- item = EINA_INLIST_CONTAINER_GET(moving, Eina_QuadTree_Item);
- b = eina_list_data_get(both);
-
- while (both && moving)
- {
- if (!b->visible)
- {
- both = eina_list_next(both);
- b = eina_list_data_get(both);
- continue;
- }
-
- if (_eina_quadtree_item_cmp(item, b) < 0)
- {
- /* moving is still lower than item, so we can continue to the next one. */
- moving = moving->next;
- item = EINA_INLIST_CONTAINER_GET(moving, Eina_QuadTree_Item);
- }
- else
- {
- /* we just get above the limit of both, so insert it */
- result = eina_inlist_prepend_relative(result,
- EINA_INLIST_GET(b),
- moving);
- both = eina_list_next(both);
- b = eina_list_data_get(both);
- }
- }
-
- item = EINA_INLIST_CONTAINER_GET(result->last, Eina_QuadTree_Item);
-
- while (both)
- {
- b = eina_list_data_get(both);
- if (b->visible)
- {
- if (_eina_quadtree_item_cmp(item, b) < 0)
- break;
-
- result = eina_inlist_prepend_relative(result,
- EINA_INLIST_GET(b),
- result->last);
- }
-
- both = eina_list_next(both);
- }
-
- while (both)
- {
- b = eina_list_data_get(both);
- if (b->visible)
- result = eina_inlist_append(result, EINA_INLIST_GET(b));
-
- both = eina_list_next(both);
- }
-
- return result;
+ Eina_QuadTree_Item *item;
+ Eina_QuadTree_Item *b;
+ Eina_Inlist *moving;
+
+ if (!both)
+ return result;
+
+ if (!result) {
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(both, l, item)
+ if (item->visible)
+ result =
+ eina_inlist_append(result,
+ EINA_INLIST_GET(item));
+
+ return result;
+ }
+
+ moving = result;
+
+ item = EINA_INLIST_CONTAINER_GET(moving, Eina_QuadTree_Item);
+ b = eina_list_data_get(both);
+
+ while (both && moving) {
+ if (!b->visible) {
+ both = eina_list_next(both);
+ b = eina_list_data_get(both);
+ continue;
+ }
+
+ if (_eina_quadtree_item_cmp(item, b) < 0) {
+ /* moving is still lower than item, so we can continue to the next one. */
+ moving = moving->next;
+ item =
+ EINA_INLIST_CONTAINER_GET(moving,
+ Eina_QuadTree_Item);
+ } else {
+ /* we just get above the limit of both, so insert it */
+ result = eina_inlist_prepend_relative(result,
+ EINA_INLIST_GET
+ (b), moving);
+ both = eina_list_next(both);
+ b = eina_list_data_get(both);
+ }
+ }
+
+ item = EINA_INLIST_CONTAINER_GET(result->last, Eina_QuadTree_Item);
+
+ while (both) {
+ b = eina_list_data_get(both);
+ if (b->visible) {
+ if (_eina_quadtree_item_cmp(item, b) < 0)
+ break;
+
+ result = eina_inlist_prepend_relative(result,
+ EINA_INLIST_GET
+ (b),
+ result->
+ last);
+ }
+
+ both = eina_list_next(both);
+ }
+
+ while (both) {
+ b = eina_list_data_get(both);
+ if (b->visible)
+ result =
+ eina_inlist_append(result, EINA_INLIST_GET(b));
+
+ both = eina_list_next(both);
+ }
+
+ return result;
}
-static Eina_Inlist *
-_eina_quadtree_collide(Eina_Inlist *result,
- Eina_QuadTree_Root *root,
- Eina_Bool direction, Eina_Rectangle *size,
- Eina_Rectangle *target)
+static Eina_Inlist *_eina_quadtree_collide(Eina_Inlist * result,
+ Eina_QuadTree_Root * root,
+ Eina_Bool direction,
+ Eina_Rectangle * size,
+ Eina_Rectangle * target)
{
- if (!root)
- return result;
-
- if (!root->sorted)
- {
- root->both = eina_list_sort(root->both, -1, _eina_quadtree_item_cmp);
- root->sorted = EINA_TRUE;
- }
-
- result = _eina_quadtree_merge(result, root->both);
- DBG("%p: %i in both for (%i, %i - %i, %i)",
- root, eina_list_count(root->both),
- size->x, size->y, size->w, size->h);
-
- if (direction)
- {
- int middle = size->w / 2;
-
- size->w -= middle;
- if (eina_spans_intersect(size->x, size->w, target->x, target->w))
- result = _eina_quadtree_collide(result, root->left,
- !direction, size,
- target);
-
- size->x += middle;
- if (eina_spans_intersect(size->x, size->w, target->x, target->w))
- result = _eina_quadtree_collide(result, root->right,
- !direction, size,
- target);
-
- size->x -= middle;
- size->w += middle;
- }
- else
- {
- int middle = size->h / 2;
-
- size->h -= middle;
- if (eina_spans_intersect(size->y, size->h, target->y, target->h))
- result = _eina_quadtree_collide(result, root->left,
- !direction, size,
- target);
-
- size->y += middle;
- if (eina_spans_intersect(size->y, size->h, target->y, target->h))
- result = _eina_quadtree_collide(result, root->right,
- !direction, size,
- target);
-
- size->y -= middle;
- size->h += middle;
- }
-
- return result;
+ if (!root)
+ return result;
+
+ if (!root->sorted) {
+ root->both =
+ eina_list_sort(root->both, -1,
+ _eina_quadtree_item_cmp);
+ root->sorted = EINA_TRUE;
+ }
+
+ result = _eina_quadtree_merge(result, root->both);
+ DBG("%p: %i in both for (%i, %i - %i, %i)",
+ root, eina_list_count(root->both),
+ size->x, size->y, size->w, size->h);
+
+ if (direction) {
+ int middle = size->w / 2;
+
+ size->w -= middle;
+ if (eina_spans_intersect
+ (size->x, size->w, target->x, target->w))
+ result =
+ _eina_quadtree_collide(result, root->left,
+ !direction, size,
+ target);
+
+ size->x += middle;
+ if (eina_spans_intersect
+ (size->x, size->w, target->x, target->w))
+ result =
+ _eina_quadtree_collide(result, root->right,
+ !direction, size,
+ target);
+
+ size->x -= middle;
+ size->w += middle;
+ } else {
+ int middle = size->h / 2;
+
+ size->h -= middle;
+ if (eina_spans_intersect
+ (size->y, size->h, target->y, target->h))
+ result =
+ _eina_quadtree_collide(result, root->left,
+ !direction, size,
+ target);
+
+ size->y += middle;
+ if (eina_spans_intersect
+ (size->y, size->h, target->y, target->h))
+ result =
+ _eina_quadtree_collide(result, root->right,
+ !direction, size,
+ target);
+
+ size->y -= middle;
+ size->h += middle;
+ }
+
+ return result;
}
-static void
-_eina_quadtree_remove(Eina_QuadTree_Item *object)
+static void _eina_quadtree_remove(Eina_QuadTree_Item * object)
{
- if (!object->root)
- return;
-
- object->root->both = eina_list_remove(object->root->both, object);
- if (object->root->both)
- goto end;
-
- if (object->root->left)
- goto end;
-
- if (object->root->right)
- goto end;
-
- /* The root is not useful anymore... */
- if (object->root->parent)
- {
- if (object->root->parent->left == object->root)
- object->root->parent->left = NULL;
- else
- object->root->parent->right = NULL;
-
- object->root->parent = NULL;
- }
- else
- object->quad->root = NULL;
-
- if (object->quad->root_count > 50)
- eina_mempool_free(root_mp, object->root);
- else
- {
- eina_trash_push(&object->quad->root_trash, object->root);
- object->quad->root_count++;
- }
-
-end:
- object->root = NULL;
+ if (!object->root)
+ return;
+
+ object->root->both = eina_list_remove(object->root->both, object);
+ if (object->root->both)
+ goto end;
+
+ if (object->root->left)
+ goto end;
+
+ if (object->root->right)
+ goto end;
+
+ /* The root is not useful anymore... */
+ if (object->root->parent) {
+ if (object->root->parent->left == object->root)
+ object->root->parent->left = NULL;
+ else
+ object->root->parent->right = NULL;
+
+ object->root->parent = NULL;
+ } else
+ object->quad->root = NULL;
+
+ if (object->quad->root_count > 50)
+ eina_mempool_free(root_mp, object->root);
+ else {
+ eina_trash_push(&object->quad->root_trash, object->root);
+ object->quad->root_count++;
+ }
+
+ end:
+ object->root = NULL;
}
-EAPI Eina_QuadTree *
-eina_quadtree_new(size_t w, size_t h,
- Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal)
+EAPI Eina_QuadTree *eina_quadtree_new(size_t w, size_t h,
+ Eina_Quad_Callback vertical,
+ Eina_Quad_Callback horizontal)
{
- Eina_QuadTree *result;
+ Eina_QuadTree *result;
- if (!vertical || !horizontal || h == 0 || w == 0)
- return NULL;
+ if (!vertical || !horizontal || h == 0 || w == 0)
+ return NULL;
- result = calloc(1, sizeof (Eina_QuadTree));
- if (!result)
- return NULL;
+ result = calloc(1, sizeof(Eina_QuadTree));
+ if (!result)
+ return NULL;
- result->func.v = vertical;
- result->func.h = horizontal;
+ result->func.v = vertical;
+ result->func.h = horizontal;
- result->geom.w = w;
- result->geom.h = h;
+ result->geom.w = w;
+ result->geom.h = h;
- result->change = NULL;
+ result->change = NULL;
- result->lost = EINA_TRUE;
+ result->lost = EINA_TRUE;
- EINA_MAGIC_SET(result, EINA_MAGIC_QUADTREE);
+ EINA_MAGIC_SET(result, EINA_MAGIC_QUADTREE);
- return result;
+ return result;
}
-EAPI void
-eina_quadtree_free(Eina_QuadTree *q)
+EAPI void eina_quadtree_free(Eina_QuadTree * q)
{
- Eina_QuadTree_Item *item;
+ Eina_QuadTree_Item *item;
- if (!q)
- return;
+ if (!q)
+ return;
- EINA_MAGIC_CHECK_QUADTREE(q);
+ EINA_MAGIC_CHECK_QUADTREE(q);
- while (q->change)
- {
- item = EINA_INLIST_CONTAINER_GET(q->change, Eina_QuadTree_Item);
- q->change = q->change->next;
- if (!item->hidden)
- eina_mempool_free(items_mp, item);
- }
+ while (q->change) {
+ item =
+ EINA_INLIST_CONTAINER_GET(q->change,
+ Eina_QuadTree_Item);
+ q->change = q->change->next;
+ if (!item->hidden)
+ eina_mempool_free(items_mp, item);
+ }
- EINA_LIST_FREE(q->hidden, item)
- eina_mempool_free(items_mp, item);
+ EINA_LIST_FREE(q->hidden, item)
+ eina_mempool_free(items_mp, item);
- eina_quadtree_root_free(q, q->root);
+ eina_quadtree_root_free(q, q->root);
- while (q->items_trash)
- {
- item = eina_trash_pop(&q->items_trash);
- eina_mempool_free(items_mp, item);
- }
+ while (q->items_trash) {
+ item = eina_trash_pop(&q->items_trash);
+ eina_mempool_free(items_mp, item);
+ }
- while (q->root_trash)
- {
- Eina_QuadTree_Root *root;
+ while (q->root_trash) {
+ Eina_QuadTree_Root *root;
- root = eina_trash_pop(&q->root_trash);
- eina_mempool_free(root_mp, root);
- }
+ root = eina_trash_pop(&q->root_trash);
+ eina_mempool_free(root_mp, root);
+ }
- EINA_MAGIC_SET(q, 0);
- free(q);
+ EINA_MAGIC_SET(q, 0);
+ free(q);
}
-EAPI Eina_QuadTree_Item *
-eina_quadtree_add(Eina_QuadTree *q, const void *object)
+EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree * q,
+ const void *object)
{
- Eina_QuadTree_Item *result;
+ Eina_QuadTree_Item *result;
- EINA_MAGIC_CHECK_QUADTREE(q, NULL);
+ EINA_MAGIC_CHECK_QUADTREE(q, NULL);
- if (!object)
- return NULL;
+ if (!object)
+ return NULL;
- result = eina_trash_pop(&q->items_trash);
- if (!result)
- result = eina_mempool_malloc(items_mp, sizeof (Eina_QuadTree_Item));
- else
- q->items_count--;
+ result = eina_trash_pop(&q->items_trash);
+ if (!result)
+ result =
+ eina_mempool_malloc(items_mp,
+ sizeof(Eina_QuadTree_Item));
+ else
+ q->items_count--;
- if (!result)
- return NULL;
+ if (!result)
+ return NULL;
- result->quad = q;
- result->root = NULL;
- result->object = object;
+ result->quad = q;
+ result->root = NULL;
+ result->object = object;
- result->index = q->index++;
+ result->index = q->index++;
- result->change = EINA_TRUE;
- result->delete_me = EINA_FALSE;
- result->visible = EINA_TRUE;
- result->hidden = EINA_FALSE;
+ result->change = EINA_TRUE;
+ result->delete_me = EINA_FALSE;
+ result->visible = EINA_TRUE;
+ result->hidden = EINA_FALSE;
- EINA_MAGIC_SET(result, EINA_MAGIC_QUADTREE_ITEM);
+ EINA_MAGIC_SET(result, EINA_MAGIC_QUADTREE_ITEM);
- /* Insertion is delayed until we really need to use it */
- q->change = eina_inlist_append(q->change, EINA_INLIST_GET(result));
+ /* Insertion is delayed until we really need to use it */
+ q->change = eina_inlist_append(q->change, EINA_INLIST_GET(result));
- return result;
+ return result;
}
-EAPI Eina_Bool
-eina_quadtree_del(Eina_QuadTree_Item *object)
+EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item * object)
{
- if (!object)
- return EINA_FALSE;
-
- EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
-
- _eina_quadtree_remove(object);
-
- if (object->change)
- {
- /* This object is still in the update array, delaying it's removal !*/
- object->delete_me = EINA_TRUE;
- object->visible = EINA_TRUE;
- return EINA_TRUE;
- }
-
- if (object->hidden)
- {
- object->quad->hidden = eina_list_remove(object->quad->hidden, object);
- object->hidden = EINA_TRUE;
- }
-
- /* This object is not anymore inside the tree, we can remove it now !*/
- EINA_MAGIC_SET(object, 0);
- if (object->quad->items_count > 256)
- eina_mempool_free(items_mp, object);
- else
- {
- object->quad->items_count++;
- eina_trash_push(&object->quad->items_trash, object);
- }
-
- return EINA_TRUE;
+ if (!object)
+ return EINA_FALSE;
+
+ EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
+
+ _eina_quadtree_remove(object);
+
+ if (object->change) {
+ /* This object is still in the update array, delaying it's removal ! */
+ object->delete_me = EINA_TRUE;
+ object->visible = EINA_TRUE;
+ return EINA_TRUE;
+ }
+
+ if (object->hidden) {
+ object->quad->hidden =
+ eina_list_remove(object->quad->hidden, object);
+ object->hidden = EINA_TRUE;
+ }
+
+ /* This object is not anymore inside the tree, we can remove it now ! */
+ EINA_MAGIC_SET(object, 0);
+ if (object->quad->items_count > 256)
+ eina_mempool_free(items_mp, object);
+ else {
+ object->quad->items_count++;
+ eina_trash_push(&object->quad->items_trash, object);
+ }
+
+ return EINA_TRUE;
}
-EAPI Eina_Bool
-eina_quadtree_change(Eina_QuadTree_Item *object)
+EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item * object)
{
- EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
+ EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
- if (object->delete_me || !object->visible)
- return EINA_FALSE;
+ if (object->delete_me || !object->visible)
+ return EINA_FALSE;
- if (object->quad->resize)
- return EINA_TRUE;
+ if (object->quad->resize)
+ return EINA_TRUE;
- /* Delaying change until needed */
- if (!object->change)
- object->quad->change = eina_inlist_append(object->quad->change,
- EINA_INLIST_GET(object));
+ /* Delaying change until needed */
+ if (!object->change)
+ object->quad->change =
+ eina_inlist_append(object->quad->change,
+ EINA_INLIST_GET(object));
- object->change = EINA_TRUE;
+ object->change = EINA_TRUE;
- _eina_quadtree_remove(object);
+ _eina_quadtree_remove(object);
- return EINA_TRUE;
+ return EINA_TRUE;
}
-EAPI Eina_Bool
-eina_quadtree_hide(Eina_QuadTree_Item *object)
+EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item * object)
{
- EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
+ EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
- object->visible = EINA_FALSE;
+ object->visible = EINA_FALSE;
- return EINA_TRUE;
+ return EINA_TRUE;
}
-EAPI Eina_Bool
-eina_quadtree_show(Eina_QuadTree_Item *object)
+EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item * object)
{
- EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
+ EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
- object->quad->lost = EINA_TRUE;
+ object->quad->lost = EINA_TRUE;
- if (object->visible)
- return EINA_TRUE;
+ if (object->visible)
+ return EINA_TRUE;
- object->visible = EINA_TRUE;
- if (!object->change)
- return eina_quadtree_change(object);
+ object->visible = EINA_TRUE;
+ if (!object->change)
+ return eina_quadtree_change(object);
- return EINA_TRUE;
+ return EINA_TRUE;
}
-EAPI Eina_Inlist *
-eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h)
+EAPI Eina_Inlist *eina_quadtree_collide(Eina_QuadTree * q, int x, int y,
+ int w, int h)
{
- Eina_Rectangle canvas;
-
- EINA_MAGIC_CHECK_QUADTREE(q, NULL);
-
- /* Now we need the tree to be up to date, so it's time */
- if (q->resize) /* Full rebuild needed ! */
- {
- DBG("resizing quadtree");
- q->root = eina_quadtree_root_rebuild_pre(q, &q->change, q->root);
- q->resize = EINA_FALSE;
- }
-
- EINA_RECTANGLE_SET(&canvas, 0, 0, q->geom.w, q->geom.h);
-
- if (q->change)
- {
- DBG("updating quadtree content");
- q->root = _eina_quadtree_update(q, NULL, q->root, q->change,
- EINA_FALSE, &canvas);
- q->change = NULL;
- q->lost = EINA_TRUE;
- }
-
- if (q->target.x != x
- || q->target.y != y
- || q->target.w != w
- || q->target.h != h)
- {
- DBG("new target");
- EINA_RECTANGLE_SET(&q->target, x, y, w, h);
- q->lost = EINA_TRUE;
- }
-
- if (q->lost)
- {
- DBG("computing collide");
- q->cached = _eina_quadtree_collide(NULL, q->root,
- EINA_FALSE, &canvas,
- &q->target);
- q->lost = EINA_FALSE;
- }
-
- return q->cached;
+ Eina_Rectangle canvas;
+
+ EINA_MAGIC_CHECK_QUADTREE(q, NULL);
+
+ /* Now we need the tree to be up to date, so it's time */
+ if (q->resize) { /* Full rebuild needed ! */
+ DBG("resizing quadtree");
+ q->root =
+ eina_quadtree_root_rebuild_pre(q, &q->change, q->root);
+ q->resize = EINA_FALSE;
+ }
+
+ EINA_RECTANGLE_SET(&canvas, 0, 0, q->geom.w, q->geom.h);
+
+ if (q->change) {
+ DBG("updating quadtree content");
+ q->root =
+ _eina_quadtree_update(q, NULL, q->root, q->change,
+ EINA_FALSE, &canvas);
+ q->change = NULL;
+ q->lost = EINA_TRUE;
+ }
+
+ if (q->target.x != x
+ || q->target.y != y || q->target.w != w || q->target.h != h) {
+ DBG("new target");
+ EINA_RECTANGLE_SET(&q->target, x, y, w, h);
+ q->lost = EINA_TRUE;
+ }
+
+ if (q->lost) {
+ DBG("computing collide");
+ q->cached = _eina_quadtree_collide(NULL, q->root,
+ EINA_FALSE, &canvas,
+ &q->target);
+ q->lost = EINA_FALSE;
+ }
+
+ return q->cached;
}
-EAPI void *
-eina_quadtree_object(Eina_Inlist *item)
+EAPI void *eina_quadtree_object(Eina_Inlist * item)
{
- Eina_QuadTree_Item *qi;
+ Eina_QuadTree_Item *qi;
- if (!item)
- return NULL;
+ if (!item)
+ return NULL;
- qi = EINA_INLIST_CONTAINER_GET(item, Eina_QuadTree_Item);
- if (!qi)
- return NULL;
+ qi = EINA_INLIST_CONTAINER_GET(item, Eina_QuadTree_Item);
+ if (!qi)
+ return NULL;
- EINA_MAGIC_CHECK_QUADTREE_ITEM(qi, NULL);
+ EINA_MAGIC_CHECK_QUADTREE_ITEM(qi, NULL);
- if (!qi->visible)
- return NULL;
+ if (!qi->visible)
+ return NULL;
- return (void *)qi->object;
+ return (void *) qi->object;
}
-EAPI void
-eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h)
+EAPI void eina_quadtree_resize(Eina_QuadTree * q, size_t w, size_t h)
{
- EINA_MAGIC_CHECK_QUADTREE(q);
+ EINA_MAGIC_CHECK_QUADTREE(q);
- if (q->geom.w == w
- && q->geom.h == h)
- return;
+ if (q->geom.w == w && q->geom.h == h)
+ return;
- q->resize = EINA_TRUE;
- q->geom.w = w;
- q->geom.h = h;
+ q->resize = EINA_TRUE;
+ q->geom.w = w;
+ q->geom.h = h;
}
-EAPI void
-eina_quadtree_cycle(Eina_QuadTree *q)
+EAPI void eina_quadtree_cycle(Eina_QuadTree * q)
{
- EINA_MAGIC_CHECK_QUADTREE(q);
+ EINA_MAGIC_CHECK_QUADTREE(q);
- q->index = 0;
+ q->index = 0;
}
-EAPI void
-eina_quadtree_increase(Eina_QuadTree_Item *object)
+EAPI void eina_quadtree_increase(Eina_QuadTree_Item * object)
{
- size_t tmp;
+ size_t tmp;
- tmp = object->quad->index++;
- if (object->index == tmp)
- return;
+ tmp = object->quad->index++;
+ if (object->index == tmp)
+ return;
- object->index = tmp;
- if (object->root)
- object->root->sorted = EINA_FALSE;
+ object->index = tmp;
+ if (object->root)
+ object->root->sorted = EINA_FALSE;
}
-Eina_Bool
-eina_quadtree_init(void)
+Eina_Bool eina_quadtree_init(void)
{
- _eina_log_qd_dom = eina_log_domain_register("eina_quadtree",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_log_qd_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_quadtree");
- return EINA_FALSE;
- }
-
+ _eina_log_qd_dom = eina_log_domain_register("eina_quadtree",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_log_qd_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_quadtree");
+ return EINA_FALSE;
+ }
#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
- EMS(EINA_MAGIC_QUADTREE);
- EMS(EINA_MAGIC_QUADTREE_ROOT);
- EMS(EINA_MAGIC_QUADTREE_ITEM);
+ EMS(EINA_MAGIC_QUADTREE);
+ EMS(EINA_MAGIC_QUADTREE_ROOT);
+ EMS(EINA_MAGIC_QUADTREE_ITEM);
#undef EMS
- items_mp = eina_mempool_add("chained_mempool", "QuadTree Item", NULL,
- sizeof (Eina_QuadTree_Item), 320);
- root_mp = eina_mempool_add("chained_mempool", "QuadTree Root", NULL,
- sizeof (Eina_QuadTree_Root), 32);
+ items_mp =
+ eina_mempool_add("chained_mempool", "QuadTree Item", NULL,
+ sizeof(Eina_QuadTree_Item), 320);
+ root_mp =
+ eina_mempool_add("chained_mempool", "QuadTree Root", NULL,
+ sizeof(Eina_QuadTree_Root), 32);
- return EINA_TRUE;
+ return EINA_TRUE;
}
-Eina_Bool
-eina_quadtree_shutdown(void)
+Eina_Bool eina_quadtree_shutdown(void)
{
- eina_log_domain_unregister(_eina_log_qd_dom);
- _eina_log_qd_dom = -1;
- return EINA_TRUE;
+ eina_log_domain_unregister(_eina_log_qd_dom);
+ _eina_log_qd_dom = -1;
+ return EINA_TRUE;
}
-
-
-
diff --git a/tests/suite/ecore/src/lib/eina_rbtree.c b/tests/suite/ecore/src/lib/eina_rbtree.c
index 1f03308426..905cafd302 100644
--- a/tests/suite/ecore/src/lib/eina_rbtree.c
+++ b/tests/suite/ecore/src/lib/eina_rbtree.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -43,183 +43,180 @@
typedef struct _Eina_Iterator_Rbtree Eina_Iterator_Rbtree;
typedef struct _Eina_Iterator_Rbtree_List Eina_Iterator_Rbtree_List;
-struct _Eina_Iterator_Rbtree
-{
- Eina_Iterator iterator;
+struct _Eina_Iterator_Rbtree {
+ Eina_Iterator iterator;
- Eina_Array *stack;
+ Eina_Array *stack;
- unsigned char mask;
+ unsigned char mask;
};
-struct _Eina_Iterator_Rbtree_List
-{
- Eina_Rbtree *tree;
+struct _Eina_Iterator_Rbtree_List {
+ Eina_Rbtree *tree;
- Eina_Rbtree_Direction dir : 1;
- Eina_Bool up : 1;
+ Eina_Rbtree_Direction dir:1;
+ Eina_Bool up:1;
};
-static Eina_Iterator_Rbtree_List *
-_eina_rbtree_iterator_list_new(const Eina_Rbtree *tree)
+static Eina_Iterator_Rbtree_List *_eina_rbtree_iterator_list_new(const
+ Eina_Rbtree
+ * tree)
{
- Eina_Iterator_Rbtree_List *new;
+ Eina_Iterator_Rbtree_List *new;
- eina_error_set(0);
- new = malloc(sizeof (Eina_Iterator_Rbtree_List));
- if (!new)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ new = malloc(sizeof(Eina_Iterator_Rbtree_List));
+ if (!new) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- new->tree = (Eina_Rbtree *)tree;
- new->dir = EINA_RBTREE_RIGHT;
- new->up = EINA_FALSE;
+ new->tree = (Eina_Rbtree *) tree;
+ new->dir = EINA_RBTREE_RIGHT;
+ new->up = EINA_FALSE;
- return new;
+ return new;
}
-static Eina_Rbtree *
-_eina_rbtree_iterator_get_content(Eina_Iterator_Rbtree *it)
+static Eina_Rbtree *_eina_rbtree_iterator_get_content(Eina_Iterator_Rbtree
+ * it)
{
- if (eina_array_count_get(it->stack) <= 0)
- return NULL;
+ if (eina_array_count_get(it->stack) <= 0)
+ return NULL;
- return eina_array_data_get(it->stack, 0);
+ return eina_array_data_get(it->stack, 0);
}
-static void
-_eina_rbtree_iterator_free(Eina_Iterator_Rbtree *it)
+static void _eina_rbtree_iterator_free(Eina_Iterator_Rbtree * it)
{
- Eina_Iterator_Rbtree_List *item;
- Eina_Array_Iterator et;
- unsigned int i;
+ Eina_Iterator_Rbtree_List *item;
+ Eina_Array_Iterator et;
+ unsigned int i;
- EINA_ARRAY_ITER_NEXT(it->stack, i, item, et)
- free(item);
+ EINA_ARRAY_ITER_NEXT(it->stack, i, item, et)
+ free(item);
- eina_array_free(it->stack);
- free(it);
+ eina_array_free(it->stack);
+ free(it);
}
static Eina_Bool
-_eina_rbtree_iterator_next(Eina_Iterator_Rbtree *it, void **data)
+_eina_rbtree_iterator_next(Eina_Iterator_Rbtree * it, void **data)
{
- Eina_Iterator_Rbtree_List *last;
- Eina_Iterator_Rbtree_List *new;
- Eina_Rbtree *tree;
-
- if (eina_array_count_get(it->stack) <= 0)
- return EINA_FALSE;
-
- last = eina_array_data_get(it->stack, eina_array_count_get(it->stack) - 1);
- tree = last->tree;
-
- if (!last->tree || last->up == EINA_TRUE)
- {
- last = eina_array_pop(it->stack);
- while (last->dir == EINA_RBTREE_LEFT
- || !last->tree)
- {
- if (tree)
- if ((it->mask & EINA_RBTREE_ITERATOR_POSTFIX_MASK) ==
- EINA_RBTREE_ITERATOR_POSTFIX_MASK)
- {
- free(last);
-
- if (eina_array_count_get(it->stack) > 0)
- {
- last = eina_array_data_get(it->stack,
- eina_array_count_get(
- it->
- stack)
- - 1);
- last->up = EINA_TRUE;
- }
-
- goto onfix;
- }
-
- free(last);
-
- last = eina_array_pop(it->stack);
- if (!last)
- return EINA_FALSE;
-
- tree = last->tree;
- }
-
- last->dir = EINA_RBTREE_LEFT;
- last->up = EINA_FALSE;
-
- eina_array_push(it->stack, last);
-
- if ((it->mask & EINA_RBTREE_ITERATOR_INFIX_MASK) ==
- EINA_RBTREE_ITERATOR_INFIX_MASK)
- goto onfix;
- }
-
- new = _eina_rbtree_iterator_list_new(last->tree->son[last->dir]);
- if (!new)
- return EINA_FALSE;
-
- eina_array_push(it->stack, new);
-
- if (last->dir == EINA_RBTREE_RIGHT)
- if ((it->mask & EINA_RBTREE_ITERATOR_PREFIX_MASK) ==
- EINA_RBTREE_ITERATOR_PREFIX_MASK)
- goto onfix;
-
- return _eina_rbtree_iterator_next(it, data);
-
-onfix:
- *data = tree;
- return EINA_TRUE;
+ Eina_Iterator_Rbtree_List *last;
+ Eina_Iterator_Rbtree_List *new;
+ Eina_Rbtree *tree;
+
+ if (eina_array_count_get(it->stack) <= 0)
+ return EINA_FALSE;
+
+ last =
+ eina_array_data_get(it->stack,
+ eina_array_count_get(it->stack) - 1);
+ tree = last->tree;
+
+ if (!last->tree || last->up == EINA_TRUE) {
+ last = eina_array_pop(it->stack);
+ while (last->dir == EINA_RBTREE_LEFT || !last->tree) {
+ if (tree)
+ if ((it->
+ mask &
+ EINA_RBTREE_ITERATOR_POSTFIX_MASK) ==
+ EINA_RBTREE_ITERATOR_POSTFIX_MASK) {
+ free(last);
+
+ if (eina_array_count_get(it->stack)
+ > 0) {
+ last =
+ eina_array_data_get
+ (it->stack,
+ eina_array_count_get
+ (it->stack)
+ - 1);
+ last->up = EINA_TRUE;
+ }
+
+ goto onfix;
+ }
+
+ free(last);
+
+ last = eina_array_pop(it->stack);
+ if (!last)
+ return EINA_FALSE;
+
+ tree = last->tree;
+ }
+
+ last->dir = EINA_RBTREE_LEFT;
+ last->up = EINA_FALSE;
+
+ eina_array_push(it->stack, last);
+
+ if ((it->mask & EINA_RBTREE_ITERATOR_INFIX_MASK) ==
+ EINA_RBTREE_ITERATOR_INFIX_MASK)
+ goto onfix;
+ }
+
+ new = _eina_rbtree_iterator_list_new(last->tree->son[last->dir]);
+ if (!new)
+ return EINA_FALSE;
+
+ eina_array_push(it->stack, new);
+
+ if (last->dir == EINA_RBTREE_RIGHT)
+ if ((it->mask & EINA_RBTREE_ITERATOR_PREFIX_MASK) ==
+ EINA_RBTREE_ITERATOR_PREFIX_MASK)
+ goto onfix;
+
+ return _eina_rbtree_iterator_next(it, data);
+
+ onfix:
+ *data = tree;
+ return EINA_TRUE;
}
-static Eina_Iterator *
-_eina_rbtree_iterator_build(const Eina_Rbtree *root, unsigned char mask)
+static Eina_Iterator *_eina_rbtree_iterator_build(const Eina_Rbtree * root,
+ unsigned char mask)
{
- Eina_Iterator_Rbtree_List *first;
- Eina_Iterator_Rbtree *it;
+ Eina_Iterator_Rbtree_List *first;
+ Eina_Iterator_Rbtree *it;
- eina_error_set(0);
- it = calloc(1, sizeof (Eina_Iterator_Rbtree));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ eina_error_set(0);
+ it = calloc(1, sizeof(Eina_Iterator_Rbtree));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- it->stack = eina_array_new(8);
- if (!it->stack)
- goto on_error2;
+ it->stack = eina_array_new(8);
+ if (!it->stack)
+ goto on_error2;
- first = _eina_rbtree_iterator_list_new(root);
- if (!first)
- goto on_error;
+ first = _eina_rbtree_iterator_list_new(root);
+ if (!first)
+ goto on_error;
- eina_array_push(it->stack, first);
+ eina_array_push(it->stack, first);
- it->mask = mask;
+ it->mask = mask;
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_eina_rbtree_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _eina_rbtree_iterator_get_content);
- it->iterator.free = FUNC_ITERATOR_FREE(_eina_rbtree_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(_eina_rbtree_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(_eina_rbtree_iterator_get_content);
+ it->iterator.free = FUNC_ITERATOR_FREE(_eina_rbtree_iterator_free);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- return &it->iterator;
+ return &it->iterator;
-on_error:
- eina_array_free(it->stack);
-on_error2:
- free(it);
+ on_error:
+ eina_array_free(it->stack);
+ on_error2:
+ free(it);
- return NULL;
+ return NULL;
}
/*
@@ -227,45 +224,46 @@ on_error2:
* http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx
*/
-static void
-_eina_rbtree_node_init(Eina_Rbtree *node)
+static void _eina_rbtree_node_init(Eina_Rbtree * node)
{
- if (!node)
- return;
+ if (!node)
+ return;
- node->son[0] = NULL;
- node->son[1] = NULL;
+ node->son[0] = NULL;
+ node->son[1] = NULL;
- node->color = EINA_RBTREE_RED;
+ node->color = EINA_RBTREE_RED;
}
-static inline Eina_Bool
-_eina_rbtree_is_red(Eina_Rbtree *node)
+static inline Eina_Bool _eina_rbtree_is_red(Eina_Rbtree * node)
{
- return !!node && node->color == EINA_RBTREE_RED;
+ return ! !node && node->color == EINA_RBTREE_RED;
}
-static inline Eina_Rbtree *
-_eina_rbtree_inline_single_rotation(Eina_Rbtree *node,
- Eina_Rbtree_Direction dir)
+static inline Eina_Rbtree *_eina_rbtree_inline_single_rotation(Eina_Rbtree
+ * node,
+ Eina_Rbtree_Direction
+ dir)
{
- Eina_Rbtree *save = node->son[!dir];
+ Eina_Rbtree *save = node->son[!dir];
- node->son[!dir] = save->son[dir];
- save->son[dir] = node;
+ node->son[!dir] = save->son[dir];
+ save->son[dir] = node;
- node->color = EINA_RBTREE_RED;
- save->color = EINA_RBTREE_BLACK;
+ node->color = EINA_RBTREE_RED;
+ save->color = EINA_RBTREE_BLACK;
- return save;
+ return save;
}
-static inline Eina_Rbtree *
-_eina_rbtree_inline_double_rotation(Eina_Rbtree *node,
- Eina_Rbtree_Direction dir)
+static inline Eina_Rbtree *_eina_rbtree_inline_double_rotation(Eina_Rbtree
+ * node,
+ Eina_Rbtree_Direction
+ dir)
{
- node->son[!dir] = _eina_rbtree_inline_single_rotation(node->son[!dir], !dir);
- return _eina_rbtree_inline_single_rotation(node, dir);
+ node->son[!dir] =
+ _eina_rbtree_inline_single_rotation(node->son[!dir], !dir);
+ return _eina_rbtree_inline_single_rotation(node, dir);
}
/*============================================================================*
@@ -284,219 +282,243 @@ _eina_rbtree_inline_double_rotation(Eina_Rbtree *node,
* @{
*/
-EAPI Eina_Rbtree *
-eina_rbtree_inline_insert(Eina_Rbtree *root,
- Eina_Rbtree *node,
- Eina_Rbtree_Cmp_Node_Cb cmp,
- const void *data)
+EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree * root,
+ Eina_Rbtree * node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data)
{
- Eina_Rbtree head;
- Eina_Rbtree *g, *t; /* Grandparent & parent */
- Eina_Rbtree *p, *q; /* Iterator & parent */
- /* WARNING:
- Compiler is not able to understand the underlying algorithm and don't know that
- first top node is always black, so it will never use last before running the loop
- one time.
- */
- Eina_Rbtree_Direction dir, last;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
- EINA_SAFETY_ON_NULL_RETURN_VAL( cmp, root);
-
- if (!node)
- return root;
-
- _eina_rbtree_node_init(node);
-
- if (!root)
- {
- root = node;
- goto end_add;
- }
-
- memset(&head, 0, sizeof (Eina_Rbtree));
- last = dir = EINA_RBTREE_LEFT;
-
- /* Set up helpers */
- t = &head;
- g = p = NULL;
- q = t->son[1] = root;
-
- /* Search down the tree */
- for (;; )
- {
- if (!q)
- /* Insert new node at the bottom */
- p->son[dir] = q = node;
- else if (_eina_rbtree_is_red(q->son[0])
- && _eina_rbtree_is_red(q->son[1]))
- {
- /* Color flip */
- q->color = EINA_RBTREE_RED;
- q->son[0]->color = EINA_RBTREE_BLACK;
- q->son[1]->color = EINA_RBTREE_BLACK;
- }
-
- /* Fix red violation */
- if (_eina_rbtree_is_red(q) && _eina_rbtree_is_red(p))
- {
- Eina_Rbtree_Direction dir2;
-
- dir2 = (t->son[1] == g) ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
-
- if (q == p->son[last])
- t->son[dir2] = _eina_rbtree_inline_single_rotation(g, !last);
- else
- t->son[dir2] = _eina_rbtree_inline_double_rotation(g, !last);
- }
-
- /* Stop if found */
- if (q == node)
- break;
-
- last = dir;
- dir = cmp(q, node, (void *)data);
-
- /* Update helpers */
- if ( g )
- t = g;
-
- g = p, p = q;
- q = q->son[dir];
- }
-
- root = head.son[1];
-
-end_add:
- /* Make root black */
- root->color = EINA_RBTREE_BLACK;
-
- return root;
+ Eina_Rbtree head;
+ Eina_Rbtree *g, *t; /* Grandparent & parent */
+ Eina_Rbtree *p, *q; /* Iterator & parent */
+ /* WARNING:
+ Compiler is not able to understand the underlying algorithm and don't know that
+ first top node is always black, so it will never use last before running the loop
+ one time.
+ */
+ Eina_Rbtree_Direction dir, last;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
+
+ if (!node)
+ return root;
+
+ _eina_rbtree_node_init(node);
+
+ if (!root) {
+ root = node;
+ goto end_add;
+ }
+
+ memset(&head, 0, sizeof(Eina_Rbtree));
+ last = dir = EINA_RBTREE_LEFT;
+
+ /* Set up helpers */
+ t = &head;
+ g = p = NULL;
+ q = t->son[1] = root;
+
+ /* Search down the tree */
+ for (;;) {
+ if (!q)
+ /* Insert new node at the bottom */
+ p->son[dir] = q = node;
+ else if (_eina_rbtree_is_red(q->son[0])
+ && _eina_rbtree_is_red(q->son[1])) {
+ /* Color flip */
+ q->color = EINA_RBTREE_RED;
+ q->son[0]->color = EINA_RBTREE_BLACK;
+ q->son[1]->color = EINA_RBTREE_BLACK;
+ }
+
+ /* Fix red violation */
+ if (_eina_rbtree_is_red(q) && _eina_rbtree_is_red(p)) {
+ Eina_Rbtree_Direction dir2;
+
+ dir2 =
+ (t->son[1] ==
+ g) ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
+
+ if (q == p->son[last])
+ t->son[dir2] =
+ _eina_rbtree_inline_single_rotation(g,
+ !last);
+ else
+ t->son[dir2] =
+ _eina_rbtree_inline_double_rotation(g,
+ !last);
+ }
+
+ /* Stop if found */
+ if (q == node)
+ break;
+
+ last = dir;
+ dir = cmp(q, node, (void *) data);
+
+ /* Update helpers */
+ if (g)
+ t = g;
+
+ g = p, p = q;
+ q = q->son[dir];
+ }
+
+ root = head.son[1];
+
+ end_add:
+ /* Make root black */
+ root->color = EINA_RBTREE_BLACK;
+
+ return root;
}
-EAPI Eina_Rbtree *
-eina_rbtree_inline_remove(Eina_Rbtree *root,
- Eina_Rbtree *node,
- Eina_Rbtree_Cmp_Node_Cb cmp,
- const void *data)
+EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree * root,
+ Eina_Rbtree * node,
+ Eina_Rbtree_Cmp_Node_Cb cmp,
+ const void *data)
{
- Eina_Rbtree head;
- Eina_Rbtree *q, *p;
- Eina_Rbtree *f = NULL;
- Eina_Rbtree_Direction dir;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
- EINA_SAFETY_ON_NULL_RETURN_VAL( cmp, root);
-
- if (!root || !node)
- return root;
-
- memset(&head, 0, sizeof(Eina_Rbtree));
-
- dir = EINA_RBTREE_RIGHT;
- q = &head;
- p = NULL;
- q->son[EINA_RBTREE_RIGHT] = root;
-
- /* Search and push a red down */
- while (q->son[dir])
- {
- Eina_Rbtree_Direction last = dir;
- Eina_Rbtree *g;
-
- /* Update helpers */
- g = p; p = q;
- q = q->son[dir];
- dir = cmp(q, node, (void *)data);
-
- /* Save parent node found */
- if (q == node)
- f = p;
-
- /* Push the red node down */
- if (!_eina_rbtree_is_red(q)
- && !_eina_rbtree_is_red(q->son[dir]))
- {
- if (_eina_rbtree_is_red(q->son[!dir]))
- q = p->son[last] = _eina_rbtree_inline_single_rotation(q, dir);
- else if (!_eina_rbtree_is_red(q->son[!dir]))
- {
- Eina_Rbtree *s = p->son[!last];
-
- if (s)
- {
- if (!_eina_rbtree_is_red(s->son[EINA_RBTREE_LEFT])
- && !_eina_rbtree_is_red(s->son[EINA_RBTREE_RIGHT]))
- {
+ Eina_Rbtree head;
+ Eina_Rbtree *q, *p;
+ Eina_Rbtree *f = NULL;
+ Eina_Rbtree_Direction dir;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
+
+ if (!root || !node)
+ return root;
+
+ memset(&head, 0, sizeof(Eina_Rbtree));
+
+ dir = EINA_RBTREE_RIGHT;
+ q = &head;
+ p = NULL;
+ q->son[EINA_RBTREE_RIGHT] = root;
+
+ /* Search and push a red down */
+ while (q->son[dir]) {
+ Eina_Rbtree_Direction last = dir;
+ Eina_Rbtree *g;
+
+ /* Update helpers */
+ g = p;
+ p = q;
+ q = q->son[dir];
+ dir = cmp(q, node, (void *) data);
+
+ /* Save parent node found */
+ if (q == node)
+ f = p;
+
+ /* Push the red node down */
+ if (!_eina_rbtree_is_red(q)
+ && !_eina_rbtree_is_red(q->son[dir])) {
+ if (_eina_rbtree_is_red(q->son[!dir]))
+ q = p->son[last] =
+ _eina_rbtree_inline_single_rotation(q,
+ dir);
+ else if (!_eina_rbtree_is_red(q->son[!dir])) {
+ Eina_Rbtree *s = p->son[!last];
+
+ if (s) {
+ if (!_eina_rbtree_is_red
+ (s->son[EINA_RBTREE_LEFT])
+ && !_eina_rbtree_is_red(s->
+ son
+ [EINA_RBTREE_RIGHT]))
+ {
/* Color flip */
- p->color = EINA_RBTREE_BLACK;
- p->son[EINA_RBTREE_LEFT]->color = EINA_RBTREE_RED;
- p->son[EINA_RBTREE_RIGHT]->color = EINA_RBTREE_RED;
- }
- else
- {
- Eina_Rbtree_Direction dir2;
-
- dir2 = g->son[1] ==
- p ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
-
- if (_eina_rbtree_is_red(s->son[last]))
- {
- g->son[dir2] =
- _eina_rbtree_inline_double_rotation(p, last);
- if (f == g)
- {
- p = g->son[dir2]->son[last];
- f = g->son[dir2];
- }
- }
- else if (_eina_rbtree_is_red(s->son[!last]))
- {
- g->son[dir2] =
- _eina_rbtree_inline_single_rotation(p, last);
- if (f == g)
- {
- p = g->son[dir2]->son[last];
- f = g->son[dir2];
- }
- }
+ p->color =
+ EINA_RBTREE_BLACK;
+ p->son[EINA_RBTREE_LEFT]->
+ color =
+ EINA_RBTREE_RED;
+ p->son[EINA_RBTREE_RIGHT]->
+ color =
+ EINA_RBTREE_RED;
+ } else {
+ Eina_Rbtree_Direction dir2;
+
+ dir2 = g->son[1] ==
+ p ? EINA_RBTREE_RIGHT :
+ EINA_RBTREE_LEFT;
+
+ if (_eina_rbtree_is_red
+ (s->son[last])) {
+ g->son[dir2] =
+ _eina_rbtree_inline_double_rotation
+ (p, last);
+ if (f == g) {
+ p = g->
+ son
+ [dir2]->
+ son
+ [last];
+ f = g->
+ son
+ [dir2];
+ }
+ } else
+ if (_eina_rbtree_is_red
+ (s->son[!last])) {
+ g->son[dir2] =
+ _eina_rbtree_inline_single_rotation
+ (p, last);
+ if (f == g) {
+ p = g->
+ son
+ [dir2]->
+ son
+ [last];
+ f = g->
+ son
+ [dir2];
+ }
+ }
/* Ensure correct coloring */
- q->color = g->son[dir2]->color = EINA_RBTREE_RED;
- g->son[dir2]->son[EINA_RBTREE_LEFT]->color =
- EINA_RBTREE_BLACK;
- g->son[dir2]->son[EINA_RBTREE_RIGHT]->color =
- EINA_RBTREE_BLACK;
- }
- }
- }
- }
- }
-
- /* Replace and remove if found */
- if (f)
- {
- /* 'q' should take the place of 'node' parent */
- f->son[f->son[1] == node] = q;
-
- /* Switch the link from the parent to q's son */
- p->son[p->son[1] == q] = q->son[!q->son[0]];
-
- /* Put q at the place of node */
- q->son[0] = node->son[0];
- q->son[1] = node->son[1];
- q->color = node->color;
-
- /* Reset node link */
- node->son[0] = NULL;
- node->son[1] = NULL;
- }
-
- root = head.son[1];
- if (root)
- root->color = EINA_RBTREE_BLACK;
-
- return root;
+ q->color =
+ g->son[dir2]->color =
+ EINA_RBTREE_RED;
+ g->son[dir2]->
+ son[EINA_RBTREE_LEFT]->
+ color =
+ EINA_RBTREE_BLACK;
+ g->son[dir2]->
+ son
+ [EINA_RBTREE_RIGHT]->
+ color =
+ EINA_RBTREE_BLACK;
+ }
+ }
+ }
+ }
+ }
+
+ /* Replace and remove if found */
+ if (f) {
+ /* 'q' should take the place of 'node' parent */
+ f->son[f->son[1] == node] = q;
+
+ /* Switch the link from the parent to q's son */
+ p->son[p->son[1] == q] = q->son[!q->son[0]];
+
+ /* Put q at the place of node */
+ q->son[0] = node->son[0];
+ q->son[1] = node->son[1];
+ q->color = node->color;
+
+ /* Reset node link */
+ node->son[0] = NULL;
+ node->son[1] = NULL;
+ }
+
+ root = head.son[1];
+ if (root)
+ root->color = EINA_RBTREE_BLACK;
+
+ return root;
}
/**
@@ -518,10 +540,10 @@ eina_rbtree_inline_remove(Eina_Rbtree *root,
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_rbtree_iterator_prefix(const Eina_Rbtree *root)
+EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree * root)
{
- return _eina_rbtree_iterator_build(root, EINA_RBTREE_ITERATOR_PREFIX_MASK);
+ return _eina_rbtree_iterator_build(root,
+ EINA_RBTREE_ITERATOR_PREFIX_MASK);
}
/**
@@ -543,10 +565,10 @@ eina_rbtree_iterator_prefix(const Eina_Rbtree *root)
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_rbtree_iterator_infix(const Eina_Rbtree *root)
+EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree * root)
{
- return _eina_rbtree_iterator_build(root, EINA_RBTREE_ITERATOR_INFIX_MASK);
+ return _eina_rbtree_iterator_build(root,
+ EINA_RBTREE_ITERATOR_INFIX_MASK);
}
/**
@@ -568,23 +590,24 @@ eina_rbtree_iterator_infix(const Eina_Rbtree *root)
* invalid! That is, if you add or remove nodes this iterator
* behavior is undefined and your program may crash!
*/
-EAPI Eina_Iterator *
-eina_rbtree_iterator_postfix(const Eina_Rbtree *root)
+EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree * root)
{
- return _eina_rbtree_iterator_build(root, EINA_RBTREE_ITERATOR_POSTFIX_MASK);
+ return _eina_rbtree_iterator_build(root,
+ EINA_RBTREE_ITERATOR_POSTFIX_MASK);
}
EAPI void
-eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data)
+eina_rbtree_delete(Eina_Rbtree * root, Eina_Rbtree_Free_Cb func,
+ void *data)
{
- if (!root)
- return;
+ if (!root)
+ return;
- EINA_SAFETY_ON_NULL_RETURN(func);
+ EINA_SAFETY_ON_NULL_RETURN(func);
- eina_rbtree_delete(root->son[0], func, data);
- eina_rbtree_delete(root->son[1], func, data);
- func(root, data);
+ eina_rbtree_delete(root->son[0], func, data);
+ eina_rbtree_delete(root->son[1], func, data);
+ func(root, data);
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_rectangle.c b/tests/suite/ecore/src/lib/eina_rectangle.c
index 237ca8b461..7ad8428352 100644
--- a/tests/suite/ecore/src/lib/eina_rectangle.c
+++ b/tests/suite/ecore/src/lib/eina_rectangle.c
@@ -17,14 +17,14 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -55,29 +55,25 @@
typedef struct _Eina_Rectangle_Alloc Eina_Rectangle_Alloc;
-struct _Eina_Rectangle_Pool
-{
- Eina_Inlist *head;
- Eina_List *empty;
- void *data;
+struct _Eina_Rectangle_Pool {
+ Eina_Inlist *head;
+ Eina_List *empty;
+ void *data;
- Eina_Trash *bucket;
- unsigned int bucket_count;
+ Eina_Trash *bucket;
+ unsigned int bucket_count;
- unsigned int references;
- int w;
- int h;
+ unsigned int references;
+ int w;
+ int h;
- Eina_Bool sorted;
- EINA_MAGIC
-};
+ Eina_Bool sorted;
+ EINA_MAGIC};
-struct _Eina_Rectangle_Alloc
-{
- EINA_INLIST;
- Eina_Rectangle_Pool *pool;
- EINA_MAGIC
-};
+struct _Eina_Rectangle_Alloc {
+ EINA_INLIST;
+ Eina_Rectangle_Pool *pool;
+ EINA_MAGIC};
#define EINA_MAGIC_CHECK_RECTANGLE_POOL(d) \
do { \
@@ -109,138 +105,125 @@ static int _eina_rectangle_log_dom = -1;
#define DBG(...) EINA_LOG_DOM_DBG(_eina_rectangle_log_dom, __VA_ARGS__)
static int
-_eina_rectangle_cmp(const Eina_Rectangle *r1, const Eina_Rectangle *r2)
+_eina_rectangle_cmp(const Eina_Rectangle * r1, const Eina_Rectangle * r2)
{
- return (r2->w * r2->h) - (r1->w * r1->h);
+ return (r2->w * r2->h) - (r1->w * r1->h);
}
-static Eina_List *
-_eina_rectangle_merge_list(Eina_List *empty, Eina_Rectangle *r)
+static Eina_List *_eina_rectangle_merge_list(Eina_List * empty,
+ Eina_Rectangle * r)
{
- Eina_Rectangle *match;
- Eina_List *l;
- int xw;
- int yh;
+ Eina_Rectangle *match;
+ Eina_List *l;
+ int xw;
+ int yh;
- if (r->w == 0 || r->h == 0)
- {
- eina_rectangle_free(r);
- return empty;
- }
+ if (r->w == 0 || r->h == 0) {
+ eina_rectangle_free(r);
+ return empty;
+ }
-start_again:
- xw = r->x + r->w;
- yh = r->y + r->h;
+ start_again:
+ xw = r->x + r->w;
+ yh = r->y + r->h;
- EINA_LIST_FOREACH(empty, l, match)
- {
- if (match->x == r->x && match->w == r->w
- && (match->y == yh || r->y == match->y + match->h))
- {
- if (match->y > r->y)
- match->y = r->y;
+ EINA_LIST_FOREACH(empty, l, match) {
+ if (match->x == r->x && match->w == r->w
+ && (match->y == yh || r->y == match->y + match->h)) {
+ if (match->y > r->y)
+ match->y = r->y;
- match->h += r->h;
+ match->h += r->h;
- eina_rectangle_free(r);
+ eina_rectangle_free(r);
- empty = eina_list_remove_list(empty, l);
+ empty = eina_list_remove_list(empty, l);
- r = match;
+ r = match;
- goto start_again;
- }
- else if (match->y == r->y && match->h == r->h
- && (match->x == xw || r->x == match->x + match->w))
- {
- if (match->x > r->x)
- match->x = r->x;
+ goto start_again;
+ } else if (match->y == r->y && match->h == r->h
+ && (match->x == xw
+ || r->x == match->x + match->w)) {
+ if (match->x > r->x)
+ match->x = r->x;
- match->w += r->w;
+ match->w += r->w;
- eina_rectangle_free(r);
+ eina_rectangle_free(r);
- empty = eina_list_remove_list(empty, l);
+ empty = eina_list_remove_list(empty, l);
- r = match;
+ r = match;
- goto start_again;
- }
- }
+ goto start_again;
+ }
+ }
- return eina_list_append(empty, r);
+ return eina_list_append(empty, r);
}
-static Eina_List *
-_eina_rectangle_empty_space_find(Eina_List *empty, int w, int h, int *x, int *y)
+static Eina_List *_eina_rectangle_empty_space_find(Eina_List * empty,
+ int w, int h, int *x,
+ int *y)
{
- Eina_Rectangle *r;
- Eina_List *l;
-
- EINA_LIST_FOREACH(empty, l, r)
- {
- if (r->w >= w && r->h >= h)
- {
- /* Remove l from empty */
- empty = eina_list_remove_list(empty, l);
- /* Remember x and y */
- *x = r->x;
- *y = r->y;
- /* Split r in 2 rectangle if needed (only the empty one) and insert them */
- if (r->w == w)
- {
- r->y += h;
- r->h -= h;
- }
- else if (r->h == h)
- {
- r->x += w;
- r->w -= w;
- }
- else
- {
- int rx1, ry1, rw1, rh1;
- int x2, y2, w2, h2;
-
- rx1 = r->x + w;
- ry1 = r->y;
- rw1 = r->w - w;
- /* h1 could be h or r->h */
- x2 = r->x;
- y2 = r->y + h;
- /* w2 could be w or r->w */
- h2 = r->h - h;
-
- if (rw1 * r->h > h2 * r->w)
- {
- rh1 = r->h;
- w2 = w;
- }
- else
- {
- rh1 = h;
- w2 = r->w;
- }
-
- EINA_RECTANGLE_SET(r, rx1, ry1, rw1, rh1);
- empty = _eina_rectangle_merge_list(empty, r);
-
- r = eina_rectangle_new(x2, y2, w2, h2);
- }
-
- if (r)
- {
- empty = _eina_rectangle_merge_list(empty, r); /* Return empty */
-
- }
-
- return empty;
- }
- }
-
- *x = -1;
- *y = -1;
- return empty;
+ Eina_Rectangle *r;
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(empty, l, r) {
+ if (r->w >= w && r->h >= h) {
+ /* Remove l from empty */
+ empty = eina_list_remove_list(empty, l);
+ /* Remember x and y */
+ *x = r->x;
+ *y = r->y;
+ /* Split r in 2 rectangle if needed (only the empty one) and insert them */
+ if (r->w == w) {
+ r->y += h;
+ r->h -= h;
+ } else if (r->h == h) {
+ r->x += w;
+ r->w -= w;
+ } else {
+ int rx1, ry1, rw1, rh1;
+ int x2, y2, w2, h2;
+
+ rx1 = r->x + w;
+ ry1 = r->y;
+ rw1 = r->w - w;
+ /* h1 could be h or r->h */
+ x2 = r->x;
+ y2 = r->y + h;
+ /* w2 could be w or r->w */
+ h2 = r->h - h;
+
+ if (rw1 * r->h > h2 * r->w) {
+ rh1 = r->h;
+ w2 = w;
+ } else {
+ rh1 = h;
+ w2 = r->w;
+ }
+
+ EINA_RECTANGLE_SET(r, rx1, ry1, rw1, rh1);
+ empty =
+ _eina_rectangle_merge_list(empty, r);
+
+ r = eina_rectangle_new(x2, y2, w2, h2);
+ }
+
+ if (r) {
+ empty = _eina_rectangle_merge_list(empty, r); /* Return empty */
+
+ }
+
+ return empty;
+ }
+ }
+
+ *x = -1;
+ *y = -1;
+ return empty;
}
/**
@@ -251,70 +234,66 @@ _eina_rectangle_empty_space_find(Eina_List *empty, int w, int h, int *x, int *y)
* Global *
*============================================================================*/
-Eina_Bool
-eina_rectangle_init(void)
+Eina_Bool eina_rectangle_init(void)
{
- const char *choice, *tmp;
-
- _eina_rectangle_log_dom = eina_log_domain_register("eina_rectangle",
- EINA_LOG_COLOR_DEFAULT);
- if (_eina_rectangle_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_rectangle");
- return EINA_FALSE;
- }
-
+ const char *choice, *tmp;
+
+ _eina_rectangle_log_dom =
+ eina_log_domain_register("eina_rectangle",
+ EINA_LOG_COLOR_DEFAULT);
+ if (_eina_rectangle_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_rectangle");
+ return EINA_FALSE;
+ }
#ifdef EINA_DEFAULT_MEMPOOL
- choice = "pass_through";
+ choice = "pass_through";
#else
- choice = "chained_mempool";
+ choice = "chained_mempool";
#endif
- tmp = getenv("EINA_MEMPOOL");
- if (tmp && tmp[0])
- choice = tmp;
-
- _eina_rectangle_alloc_mp = eina_mempool_add
- (choice, "rectangle-alloc", NULL,
- sizeof(Eina_Rectangle_Alloc) + sizeof(Eina_Rectangle), 1024);
- if (!_eina_rectangle_alloc_mp)
- {
- ERR("Mempool for rectangle cannot be allocated in rectangle init.");
- goto init_error;
- }
-
- _eina_rectangle_mp = eina_mempool_add
- (choice, "rectangle", NULL, sizeof(Eina_Rectangle), 256);
- if (!_eina_rectangle_mp)
- {
- ERR("Mempool for rectangle cannot be allocated in rectangle init.");
- goto init_error;
- }
-
- return EINA_TRUE;
-
-init_error:
- eina_log_domain_unregister(_eina_rectangle_log_dom);
- _eina_rectangle_log_dom = -1;
-
- return EINA_FALSE;
+ tmp = getenv("EINA_MEMPOOL");
+ if (tmp && tmp[0])
+ choice = tmp;
+
+ _eina_rectangle_alloc_mp = eina_mempool_add
+ (choice, "rectangle-alloc", NULL,
+ sizeof(Eina_Rectangle_Alloc) + sizeof(Eina_Rectangle), 1024);
+ if (!_eina_rectangle_alloc_mp) {
+ ERR("Mempool for rectangle cannot be allocated in rectangle init.");
+ goto init_error;
+ }
+
+ _eina_rectangle_mp = eina_mempool_add
+ (choice, "rectangle", NULL, sizeof(Eina_Rectangle), 256);
+ if (!_eina_rectangle_mp) {
+ ERR("Mempool for rectangle cannot be allocated in rectangle init.");
+ goto init_error;
+ }
+
+ return EINA_TRUE;
+
+ init_error:
+ eina_log_domain_unregister(_eina_rectangle_log_dom);
+ _eina_rectangle_log_dom = -1;
+
+ return EINA_FALSE;
}
-Eina_Bool
-eina_rectangle_shutdown(void)
+Eina_Bool eina_rectangle_shutdown(void)
{
- Eina_Rectangle *del;
+ Eina_Rectangle *del;
- while ((del = eina_trash_pop(&_eina_rectangles)))
- eina_mempool_free(_eina_rectangle_mp, del);
- _eina_rectangles_count = 0;
+ while ((del = eina_trash_pop(&_eina_rectangles)))
+ eina_mempool_free(_eina_rectangle_mp, del);
+ _eina_rectangles_count = 0;
- eina_mempool_del(_eina_rectangle_alloc_mp);
- eina_mempool_del(_eina_rectangle_mp);
+ eina_mempool_del(_eina_rectangle_alloc_mp);
+ eina_mempool_del(_eina_rectangle_mp);
- eina_log_domain_unregister(_eina_rectangle_log_dom);
- _eina_rectangle_log_dom = -1;
+ eina_log_domain_unregister(_eina_rectangle_log_dom);
+ _eina_rectangle_log_dom = -1;
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -343,25 +322,24 @@ eina_rectangle_shutdown(void)
* it to the rectangles pool. No check is done on @p w and @p h. This
* function returns a new rectangle on success, @c NULL otherwhise.
*/
-EAPI Eina_Rectangle *
-eina_rectangle_new(int x, int y, int w, int h)
+EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h)
{
- Eina_Rectangle *rect;
+ Eina_Rectangle *rect;
- if (_eina_rectangles)
- {
- rect = eina_trash_pop(&_eina_rectangles);
- _eina_rectangles_count--;
- }
- else
- rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
+ if (_eina_rectangles) {
+ rect = eina_trash_pop(&_eina_rectangles);
+ _eina_rectangles_count--;
+ } else
+ rect =
+ eina_mempool_malloc(_eina_rectangle_mp,
+ sizeof(Eina_Rectangle));
- if (!rect)
- return NULL;
+ if (!rect)
+ return NULL;
- EINA_RECTANGLE_SET(rect, x, y, w, h);
+ EINA_RECTANGLE_SET(rect, x, y, w, h);
- return rect;
+ return rect;
}
/**
@@ -371,18 +349,16 @@ eina_rectangle_new(int x, int y, int w, int h)
*
* This function removes @p rect from the rectangles pool.
*/
-EAPI void
-eina_rectangle_free(Eina_Rectangle *rect)
+EAPI void eina_rectangle_free(Eina_Rectangle * rect)
{
- EINA_SAFETY_ON_NULL_RETURN(rect);
-
- if (_eina_rectangles_count > BUCKET_THRESHOLD)
- eina_mempool_free(_eina_rectangle_mp, rect);
- else
- {
- eina_trash_push(&_eina_rectangles, rect);
- _eina_rectangles_count++;
- }
+ EINA_SAFETY_ON_NULL_RETURN(rect);
+
+ if (_eina_rectangles_count > BUCKET_THRESHOLD)
+ eina_mempool_free(_eina_rectangle_mp, rect);
+ else {
+ eina_trash_push(&_eina_rectangles, rect);
+ _eina_rectangles_count++;
+ }
}
/**
@@ -396,28 +372,28 @@ eina_rectangle_free(Eina_Rectangle *rect)
* new pool. If the pool can not be created, @c NULL is
* returned. Otherwise the newly allocated pool is returned.
*/
-EAPI Eina_Rectangle_Pool *
-eina_rectangle_pool_new(int w, int h)
+EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h)
{
- Eina_Rectangle_Pool *new;
-
- new = malloc(sizeof (Eina_Rectangle_Pool));
- if (!new)
- return NULL;
-
- new->head = NULL;
- new->empty = eina_list_append(NULL, eina_rectangle_new(0, 0, w, h));
- new->references = 0;
- new->sorted = EINA_FALSE;
- new->w = w;
- new->h = h;
- new->bucket = NULL;
- new->bucket_count = 0;
-
- EINA_MAGIC_SET(new, EINA_RECTANGLE_POOL_MAGIC);
- DBG("pool=%p, size=(%d, %d)", new, w, h);
-
- return new;
+ Eina_Rectangle_Pool *new;
+
+ new = malloc(sizeof(Eina_Rectangle_Pool));
+ if (!new)
+ return NULL;
+
+ new->head = NULL;
+ new->empty =
+ eina_list_append(NULL, eina_rectangle_new(0, 0, w, h));
+ new->references = 0;
+ new->sorted = EINA_FALSE;
+ new->w = w;
+ new->h = h;
+ new->bucket = NULL;
+ new->bucket_count = 0;
+
+ EINA_MAGIC_SET(new, EINA_RECTANGLE_POOL_MAGIC);
+ DBG("pool=%p, size=(%d, %d)", new, w, h);
+
+ return new;
}
/**
@@ -428,31 +404,28 @@ eina_rectangle_pool_new(int w, int h)
* This function frees the allocated data of @p pool. If @p pool is
* @c NULL, ths function returned immediately.
*/
-EAPI void
-eina_rectangle_pool_free(Eina_Rectangle_Pool *pool)
+EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool * pool)
{
- Eina_Rectangle_Alloc *del;
+ Eina_Rectangle_Alloc *del;
- EINA_SAFETY_ON_NULL_RETURN(pool);
- DBG("pool=%p, size=(%d, %d), references=%u",
- pool, pool->w, pool->h, pool->references);
- while (pool->head)
- {
- del = (Eina_Rectangle_Alloc *)pool->head;
+ EINA_SAFETY_ON_NULL_RETURN(pool);
+ DBG("pool=%p, size=(%d, %d), references=%u",
+ pool, pool->w, pool->h, pool->references);
+ while (pool->head) {
+ del = (Eina_Rectangle_Alloc *) pool->head;
- pool->head = (EINA_INLIST_GET(del))->next;
+ pool->head = (EINA_INLIST_GET(del))->next;
- EINA_MAGIC_SET(del, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_rectangle_alloc_mp, del);
- }
+ EINA_MAGIC_SET(del, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_rectangle_alloc_mp, del);
+ }
- while (pool->bucket)
- {
- del = eina_trash_pop(&pool->bucket);
- eina_mempool_free(_eina_rectangle_alloc_mp, del);
- }
+ while (pool->bucket) {
+ del = eina_trash_pop(&pool->bucket);
+ eina_mempool_free(_eina_rectangle_alloc_mp, del);
+ }
- MAGIC_FREE(pool);
+ MAGIC_FREE(pool);
}
/**
@@ -463,11 +436,10 @@ eina_rectangle_pool_free(Eina_Rectangle_Pool *pool)
*
* This function returns the number of rectangles in @p pool.
*/
-EAPI int
-eina_rectangle_pool_count(Eina_Rectangle_Pool *pool)
+EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool * pool)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(pool, 0);
- return pool->references;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pool, 0);
+ return pool->references;
}
/**
@@ -485,65 +457,64 @@ eina_rectangle_pool_count(Eina_Rectangle_Pool *pool)
* returns the rectangle which matches the size (@p w, @p h).
* Otherwise it returns @c NULL.
*/
-EAPI Eina_Rectangle *
-eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h)
+EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *
+ pool, int w, int h)
{
- Eina_Rectangle_Alloc *new;
- Eina_Rectangle *rect;
- int x;
- int y;
+ Eina_Rectangle_Alloc *new;
+ Eina_Rectangle *rect;
+ int x;
+ int y;
- EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
- DBG("pool=%p, size=(%d, %d), references=%u",
- pool, pool->w, pool->h, pool->references);
+ DBG("pool=%p, size=(%d, %d), references=%u",
+ pool, pool->w, pool->h, pool->references);
- if (w <= 0 || h <= 0)
- return NULL;
+ if (w <= 0 || h <= 0)
+ return NULL;
- if (w > pool->w || h > pool->h)
- return NULL;
+ if (w > pool->w || h > pool->h)
+ return NULL;
- /* Sort empty if dirty */
- if (pool->sorted)
- {
- pool->empty =
- eina_list_sort(pool->empty, 0, EINA_COMPARE_CB(_eina_rectangle_cmp));
- pool->sorted = EINA_TRUE;
- }
+ /* Sort empty if dirty */
+ if (pool->sorted) {
+ pool->empty =
+ eina_list_sort(pool->empty, 0,
+ EINA_COMPARE_CB(_eina_rectangle_cmp));
+ pool->sorted = EINA_TRUE;
+ }
- pool->empty = _eina_rectangle_empty_space_find(pool->empty, w, h, &x, &y);
- if (x == -1)
- return NULL;
+ pool->empty =
+ _eina_rectangle_empty_space_find(pool->empty, w, h, &x, &y);
+ if (x == -1)
+ return NULL;
- pool->sorted = EINA_FALSE;
+ pool->sorted = EINA_FALSE;
- if (pool->bucket_count > 0)
- {
- new = eina_trash_pop(&pool->bucket);
- pool->bucket_count--;
- }
- else
- new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
- sizeof (Eina_Rectangle_Alloc) +
- sizeof (Eina_Rectangle));
+ if (pool->bucket_count > 0) {
+ new = eina_trash_pop(&pool->bucket);
+ pool->bucket_count--;
+ } else
+ new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
+ sizeof(Eina_Rectangle_Alloc) +
+ sizeof(Eina_Rectangle));
- if (!new)
- return NULL;
+ if (!new)
+ return NULL;
- rect = (Eina_Rectangle *)(new + 1);
- eina_rectangle_coords_from(rect, x, y, w, h);
+ rect = (Eina_Rectangle *) (new + 1);
+ eina_rectangle_coords_from(rect, x, y, w, h);
- pool->head = eina_inlist_prepend(pool->head, EINA_INLIST_GET(new));
- pool->references++;
+ pool->head = eina_inlist_prepend(pool->head, EINA_INLIST_GET(new));
+ pool->references++;
- new->pool = pool;
+ new->pool = pool;
- EINA_MAGIC_SET(new, EINA_RECTANGLE_ALLOC_MAGIC);
- DBG("rect=%p pool=%p, size=(%d, %d), references=%u",
- rect, pool, pool->w, pool->h, pool->references);
+ EINA_MAGIC_SET(new, EINA_RECTANGLE_ALLOC_MAGIC);
+ DBG("rect=%p pool=%p, size=(%d, %d), references=%u",
+ rect, pool, pool->w, pool->h, pool->references);
- return rect;
+ return rect;
}
/**
@@ -555,44 +526,42 @@ eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h)
* @c NULL, the function returns immediately. Otherwise it remoes @p
* rect from the pool.
*/
-EAPI void
-eina_rectangle_pool_release(Eina_Rectangle *rect)
+EAPI void eina_rectangle_pool_release(Eina_Rectangle * rect)
{
- Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *)rect) - 1;
- Eina_Rectangle *r;
+ Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
+ Eina_Rectangle *r;
- EINA_SAFETY_ON_NULL_RETURN(rect);
+ EINA_SAFETY_ON_NULL_RETURN(rect);
- EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
- EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
+ EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
+ EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
- DBG("rect=%p pool=%p, size=(%d, %d), references=%u",
- rect, era->pool, era->pool->w, era->pool->h, era->pool->references);
+ DBG("rect=%p pool=%p, size=(%d, %d), references=%u",
+ rect, era->pool, era->pool->w, era->pool->h,
+ era->pool->references);
- era->pool->references--;
- era->pool->head = eina_inlist_remove(era->pool->head, EINA_INLIST_GET(era));
+ era->pool->references--;
+ era->pool->head =
+ eina_inlist_remove(era->pool->head, EINA_INLIST_GET(era));
- r = eina_rectangle_new(rect->x, rect->y, rect->w, rect->h);
- if (r)
- {
- era->pool->empty = _eina_rectangle_merge_list(era->pool->empty, r);
- era->pool->sorted = EINA_FALSE;
- }
+ r = eina_rectangle_new(rect->x, rect->y, rect->w, rect->h);
+ if (r) {
+ era->pool->empty =
+ _eina_rectangle_merge_list(era->pool->empty, r);
+ era->pool->sorted = EINA_FALSE;
+ }
- if (era->pool->bucket_count < BUCKET_THRESHOLD)
- {
- Eina_Rectangle_Pool *pool;
+ if (era->pool->bucket_count < BUCKET_THRESHOLD) {
+ Eina_Rectangle_Pool *pool;
- pool = era->pool;
+ pool = era->pool;
- pool->bucket_count++;
- eina_trash_push(&pool->bucket, era);
- }
- else
- {
- EINA_MAGIC_SET(era, EINA_MAGIC_NONE);
- eina_mempool_free(_eina_rectangle_alloc_mp, era);
- }
+ pool->bucket_count++;
+ eina_trash_push(&pool->bucket, era);
+ } else {
+ EINA_MAGIC_SET(era, EINA_MAGIC_NONE);
+ eina_mempool_free(_eina_rectangle_alloc_mp, era);
+ }
}
/**
@@ -604,17 +573,16 @@ eina_rectangle_pool_release(Eina_Rectangle *rect)
* This function returns the pool in which @p rect is. If @p rect is
* @c NULL, @c NULL is returned.
*/
-EAPI Eina_Rectangle_Pool *
-eina_rectangle_pool_get(Eina_Rectangle *rect)
+EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle * rect)
{
- Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *)rect) - 1;
+ Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
- EINA_SAFETY_ON_NULL_RETURN_VAL(rect, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(rect, NULL);
- EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
- EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
+ EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
+ EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
- return era->pool;
+ return era->pool;
}
/**
@@ -627,15 +595,15 @@ eina_rectangle_pool_get(Eina_Rectangle *rect)
* function does nothing.
*/
EAPI void
-eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data)
+eina_rectangle_pool_data_set(Eina_Rectangle_Pool * pool, const void *data)
{
- EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
- EINA_SAFETY_ON_NULL_RETURN(pool);
+ EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
+ EINA_SAFETY_ON_NULL_RETURN(pool);
- DBG("data=%p pool=%p, size=(%d, %d), references=%u",
- data, pool, pool->w, pool->h, pool->references);
+ DBG("data=%p pool=%p, size=(%d, %d), references=%u",
+ data, pool, pool->w, pool->h, pool->references);
- pool->data = (void *)data;
+ pool->data = (void *) data;
}
/**
@@ -648,13 +616,12 @@ eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data)
* eina_rectangle_pool_data_set(). If @p pool is @c NULL, this
* function returns @c NULL.
*/
-EAPI void *
-eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool)
+EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool * pool)
{
- EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
- EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
+ EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
- return pool->data;
+ return pool->data;
}
/**
@@ -671,21 +638,22 @@ eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool)
* returned.
*/
EAPI Eina_Bool
-eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h)
+eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool * pool, int *w,
+ int *h)
{
- if (!pool)
- return EINA_FALSE;
+ if (!pool)
+ return EINA_FALSE;
- EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
- EINA_SAFETY_ON_NULL_RETURN_VAL(pool, EINA_FALSE);
+ EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pool, EINA_FALSE);
- if (w)
- *w = pool->w;
+ if (w)
+ *w = pool->w;
- if (h)
- *h = pool->h;
+ if (h)
+ *h = pool->h;
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_safety_checks.c b/tests/suite/ecore/src/lib/eina_safety_checks.c
index 09aa2983b5..78f82c76ac 100644
--- a/tests/suite/ecore/src/lib/eina_safety_checks.c
+++ b/tests/suite/ecore/src/lib/eina_safety_checks.c
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include "eina_private.h"
@@ -44,10 +44,9 @@
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_safety_checks_shutdown(void)
+Eina_Bool eina_safety_checks_shutdown(void)
{
- return EINA_TRUE;
+ return EINA_TRUE;
}
/*============================================================================*
@@ -101,12 +100,11 @@ static const char EINA_ERROR_SAFETY_FAILED_STR[] = "Safety check failed.";
*
* @see eina_init()
*/
-Eina_Bool
-eina_safety_checks_init(void)
+Eina_Bool eina_safety_checks_init(void)
{
- EINA_ERROR_SAFETY_FAILED = eina_error_msg_static_register(
- EINA_ERROR_SAFETY_FAILED_STR);
- return EINA_TRUE;
+ EINA_ERROR_SAFETY_FAILED =
+ eina_error_msg_static_register(EINA_ERROR_SAFETY_FAILED_STR);
+ return EINA_TRUE;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_sched.c b/tests/suite/ecore/src/lib/eina_sched.c
index dbb3da663c..69e2d06682 100644
--- a/tests/suite/ecore/src/lib/eina_sched.c
+++ b/tests/suite/ecore/src/lib/eina_sched.c
@@ -17,17 +17,17 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#ifdef EFL_HAVE_POSIX_THREADS
-# include <pthread.h>
-# ifdef __linux__
-# include <sched.h>
-# include <sys/time.h>
-# include <sys/resource.h>
-# include <errno.h>
-# endif
+#include <pthread.h>
+#ifdef __linux__
+#include <sched.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <errno.h>
+#endif
#endif
#include "eina_sched.h"
@@ -48,48 +48,43 @@
* only one that is implemented as of now. In this case the nice level is
* incremented on this thread by @c NICENESS.
*/
-EAPI void
-eina_sched_prio_drop(void)
+EAPI void eina_sched_prio_drop(void)
{
#ifdef EFL_HAVE_POSIX_THREADS
- struct sched_param param;
- int pol, prio, ret;
- pthread_t pthread_id;
+ struct sched_param param;
+ int pol, prio, ret;
+ pthread_t pthread_id;
- pthread_id = pthread_self();
- ret = pthread_getschedparam(pthread_id, &pol, &param);
- if (ret)
- {
- EINA_LOG_ERR("Unable to query sched parameters");
- return;
- }
+ pthread_id = pthread_self();
+ ret = pthread_getschedparam(pthread_id, &pol, &param);
+ if (ret) {
+ EINA_LOG_ERR("Unable to query sched parameters");
+ return;
+ }
- if (EINA_UNLIKELY(pol == SCHED_RR || pol == SCHED_FIFO))
- {
- prio = sched_get_priority_max(pol);
- param.sched_priority += RTNICENESS;
- if (prio > 0 && param.sched_priority > prio)
- param.sched_priority = prio;
+ if (EINA_UNLIKELY(pol == SCHED_RR || pol == SCHED_FIFO)) {
+ prio = sched_get_priority_max(pol);
+ param.sched_priority += RTNICENESS;
+ if (prio > 0 && param.sched_priority > prio)
+ param.sched_priority = prio;
- pthread_setschedparam(pthread_id, pol, &param);
- }
+ pthread_setschedparam(pthread_id, pol, &param);
+ }
#ifdef __linux__
- else
- {
- errno = 0;
- prio = getpriority(PRIO_PROCESS, 0);
- if (errno == 0)
- {
- prio += NICENESS;
- if (prio > 19)
- prio = 19;
+ else {
+ errno = 0;
+ prio = getpriority(PRIO_PROCESS, 0);
+ if (errno == 0) {
+ prio += NICENESS;
+ if (prio > 19)
+ prio = 19;
- setpriority(PRIO_PROCESS, 0, prio);
- }
- }
+ setpriority(PRIO_PROCESS, 0, prio);
+ }
+ }
#endif
#else
- EINA_LOG_ERR("Eina does not have support for threads enabled"
- "or it doesn't support setting scheduler priorities");
+ EINA_LOG_ERR("Eina does not have support for threads enabled"
+ "or it doesn't support setting scheduler priorities");
#endif
}
diff --git a/tests/suite/ecore/src/lib/eina_share_common.c b/tests/suite/ecore/src/lib/eina_share_common.c
index 2302843eaa..76deb8b3ac 100644
--- a/tests/suite/ecore/src/lib/eina_share_common.c
+++ b/tests/suite/ecore/src/lib/eina_share_common.c
@@ -55,7 +55,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -64,11 +64,11 @@
#include <stddef.h>
#ifdef EFL_HAVE_POSIX_THREADS
-# include <pthread.h>
+#include <pthread.h>
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -126,468 +126,460 @@ typedef struct _Eina_Share_Common_Head Eina_Share_Common_Head;
int _eina_share_common_log_dom = -1;
-struct _Eina_Share
-{
- Eina_Share_Common *share;
- Eina_Magic node_magic;
+struct _Eina_Share {
+ Eina_Share_Common *share;
+ Eina_Magic node_magic;
#ifdef EINA_SHARE_COMMON_USAGE
- Eina_Share_Common_Population population;
- int max_node_population;
+ Eina_Share_Common_Population population;
+ int max_node_population;
#endif
};
-struct _Eina_Share_Common
-{
- Eina_Share_Common_Head *buckets[EINA_SHARE_COMMON_BUCKETS];
+struct _Eina_Share_Common {
+ Eina_Share_Common_Head *buckets[EINA_SHARE_COMMON_BUCKETS];
- EINA_MAGIC
-};
-
-struct _Eina_Share_Common_Node
-{
- Eina_Share_Common_Node *next;
+ EINA_MAGIC};
- EINA_MAGIC
+struct _Eina_Share_Common_Node {
+ Eina_Share_Common_Node *next;
- unsigned int length;
- unsigned int references;
- char str[];
+ EINA_MAGIC unsigned int length;
+ unsigned int references;
+ char str[];
};
-struct _Eina_Share_Common_Head
-{
- EINA_RBTREE;
- EINA_MAGIC
-
- int hash;
+struct _Eina_Share_Common_Head {
+ EINA_RBTREE;
+ EINA_MAGIC int hash;
#ifdef EINA_SHARE_COMMON_USAGE
- int population;
+ int population;
#endif
- Eina_Share_Common_Node *head;
- Eina_Share_Common_Node builtin_node;
+ Eina_Share_Common_Node *head;
+ Eina_Share_Common_Node builtin_node;
};
#ifdef EFL_HAVE_THREADS
Eina_Bool _share_common_threads_activated = EINA_FALSE;
-# ifdef EFL_HAVE_POSIX_THREADS
+#ifdef EFL_HAVE_POSIX_THREADS
static pthread_mutex_t _mutex_big = PTHREAD_MUTEX_INITIALIZER;
-# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
+#define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
pthread_mutex_lock(&_mutex_big)
-# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
+#define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
pthread_mutex_unlock(&_mutex_big)
-# else /* EFL_HAVE_WIN32_THREADS */
+#else /* EFL_HAVE_WIN32_THREADS */
static HANDLE _mutex_big = NULL;
-# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
+#define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
WaitForSingleObject(_mutex_big, INFINITE)
-# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
+#define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
ReleaseMutex(_mutex_big)
-# endif /* EFL_HAVE_WIN32_THREADS */
-#else /* EFL_HAVE_THREADS */
-# define SHARE_COMMON_LOCK_BIG() do {} while (0)
-# define SHARE_COMMON_UNLOCK_BIG() do {} while (0)
+#endif /* EFL_HAVE_WIN32_THREADS */
+#else /* EFL_HAVE_THREADS */
+#define SHARE_COMMON_LOCK_BIG() do {} while (0)
+#define SHARE_COMMON_UNLOCK_BIG() do {} while (0)
#endif
#ifdef EINA_SHARE_COMMON_USAGE
-struct _Eina_Share_Common_Population
-{
- int count;
- int max;
+struct _Eina_Share_Common_Population {
+ int count;
+ int max;
};
static Eina_Share_Common_Population population = { 0, 0 };
-static Eina_Share_Common_Population population_group[4] =
-{
- { 0, 0 },
- { 0, 0 },
- { 0, 0 },
- { 0, 0 }
+static Eina_Share_Common_Population population_group[4] = {
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0}
};
-static void
-_eina_share_common_population_init(Eina_Share *share)
+static void _eina_share_common_population_init(Eina_Share * share)
{
- unsigned int i;
+ unsigned int i;
- for (i = 0;
- i < sizeof (share->population_group) /
- sizeof (share->population_group[0]);
- ++i)
- {
- share->population_group[i].count = 0;
- share->population_group[i].max = 0;
- }
+ for (i = 0;
+ i < sizeof(share->population_group) /
+ sizeof(share->population_group[0]); ++i) {
+ share->population_group[i].count = 0;
+ share->population_group[i].max = 0;
+ }
}
-static void
-_eina_share_common_population_shutdown(Eina_Share *share)
+static void _eina_share_common_population_shutdown(Eina_Share * share)
{
- unsigned int i;
+ unsigned int i;
- share->max_node_population = 0;
- share->population.count = 0;
- share->population.max = 0;
+ share->max_node_population = 0;
+ share->population.count = 0;
+ share->population.max = 0;
- for (i = 0;
- i < sizeof (share->population_group) /
- sizeof (share->population_group[0]);
- ++i)
- {
- share->population_group[i].count = 0;
- share->population_group[i].max = 0;
- }
+ for (i = 0;
+ i < sizeof(share->population_group) /
+ sizeof(share->population_group[0]); ++i) {
+ share->population_group[i].count = 0;
+ share->population_group[i].max = 0;
+ }
}
-static void
-_eina_share_common_population_stats(Eina_Share *share)
+static void _eina_share_common_population_stats(Eina_Share * share)
{
- unsigned int i;
+ unsigned int i;
- fprintf(stderr, "eina share_common statistic:\n");
- fprintf(stderr,
- " * maximum shared strings : %i\n",
- share->population.max);
- fprintf(stderr,
- " * maximum shared strings per node : %i\n",
- share->max_node_population);
+ fprintf(stderr, "eina share_common statistic:\n");
+ fprintf(stderr,
+ " * maximum shared strings : %i\n", share->population.max);
+ fprintf(stderr,
+ " * maximum shared strings per node : %i\n",
+ share->max_node_population);
- for (i = 0;
- i < sizeof (share->population_group) /
- sizeof (share->population_group[0]);
- ++i)
- fprintf(stderr,
- "DDD: %i strings of length %i, max strings: %i\n",
- share->population_group[i].count,
- i,
- share->population_group[i].max);
+ for (i = 0;
+ i < sizeof(share->population_group) /
+ sizeof(share->population_group[0]); ++i)
+ fprintf(stderr,
+ "DDD: %i strings of length %i, max strings: %i\n",
+ share->population_group[i].count,
+ i, share->population_group[i].max);
}
-void
-eina_share_common_population_add(Eina_Share *share, int slen)
+void eina_share_common_population_add(Eina_Share * share, int slen)
{
- SHARE_COMMON_LOCK_BIG();
+ SHARE_COMMON_LOCK_BIG();
- share->population.count++;
- if (share->population.count > share->population.max)
- share->population.max = share->population.count;
+ share->population.count++;
+ if (share->population.count > share->population.max)
+ share->population.max = share->population.count;
- if (slen < 4)
- {
- share->population_group[slen].count++;
- if (share->population_group[slen].count >
- share->population_group[slen].max)
- share->population_group[slen].max =
- share->population_group[slen].count;
- }
+ if (slen < 4) {
+ share->population_group[slen].count++;
+ if (share->population_group[slen].count >
+ share->population_group[slen].max)
+ share->population_group[slen].max =
+ share->population_group[slen].count;
+ }
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
}
-void
-eina_share_common_population_del(Eina_Share *share, int slen)
+void eina_share_common_population_del(Eina_Share * share, int slen)
{
- SHARE_COMMON_LOCK_BIG();
+ SHARE_COMMON_LOCK_BIG();
- share->population.count--;
- if (slen < 4)
- share->population_group[slen].count--;
+ share->population.count--;
+ if (slen < 4)
+ share->population_group[slen].count--;
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
}
static void
-_eina_share_common_population_head_init(Eina_Share *share,
- Eina_Share_Common_Head *head)
+_eina_share_common_population_head_init(Eina_Share * share,
+ Eina_Share_Common_Head * head)
{
- head->population = 1;
+ head->population = 1;
}
static void
-_eina_share_common_population_head_add(Eina_Share *share,
- Eina_Share_Common_Head *head)
+_eina_share_common_population_head_add(Eina_Share * share,
+ Eina_Share_Common_Head * head)
{
- head->population++;
- if (head->population > share->max_node_population)
- share->max_node_population = head->population;
+ head->population++;
+ if (head->population > share->max_node_population)
+ share->max_node_population = head->population;
}
static void
-_eina_share_common_population_head_del(Eina_Share *share,
- Eina_Share_Common_Head *head)
+_eina_share_common_population_head_del(Eina_Share * share,
+ Eina_Share_Common_Head * head)
{
- head->population--;
+ head->population--;
}
-#else /* EINA_SHARE_COMMON_USAGE undefined */
+#else /* EINA_SHARE_COMMON_USAGE undefined */
-static void _eina_share_common_population_init(__UNUSED__ Eina_Share *share) {
+static void _eina_share_common_population_init(__UNUSED__ Eina_Share *
+ share)
+{
}
-static void _eina_share_common_population_shutdown(__UNUSED__ Eina_Share *share)
+
+static void _eina_share_common_population_shutdown(__UNUSED__ Eina_Share *
+ share)
{
}
-static void _eina_share_common_population_stats(__UNUSED__ Eina_Share *share) {
+
+static void _eina_share_common_population_stats(__UNUSED__ Eina_Share *
+ share)
+{
}
-void eina_share_common_population_add(__UNUSED__ Eina_Share *share,
- __UNUSED__ int slen) {
+
+void eina_share_common_population_add(__UNUSED__ Eina_Share * share,
+ __UNUSED__ int slen)
+{
}
-void eina_share_common_population_del(__UNUSED__ Eina_Share *share,
- __UNUSED__ int slen) {
+
+void eina_share_common_population_del(__UNUSED__ Eina_Share * share,
+ __UNUSED__ int slen)
+{
}
-static void _eina_share_common_population_head_init(
- __UNUSED__ Eina_Share *share,
- __UNUSED__ Eina_Share_Common_Head *head) {
+
+static void _eina_share_common_population_head_init(__UNUSED__ Eina_Share *
+ share,
+ __UNUSED__
+ Eina_Share_Common_Head
+ * head)
+{
}
-static void _eina_share_common_population_head_add(
- __UNUSED__ Eina_Share *share,
- __UNUSED__
- Eina_Share_Common_Head *head) {
+
+static void _eina_share_common_population_head_add(__UNUSED__ Eina_Share *
+ share,
+ __UNUSED__
+ Eina_Share_Common_Head *
+ head)
+{
}
-static void _eina_share_common_population_head_del(
- __UNUSED__ Eina_Share *share,
- __UNUSED__
- Eina_Share_Common_Head *head) {
+
+static void _eina_share_common_population_head_del(__UNUSED__ Eina_Share *
+ share,
+ __UNUSED__
+ Eina_Share_Common_Head *
+ head)
+{
}
#endif
static int
-_eina_share_common_cmp(const Eina_Share_Common_Head *ed,
- const int *hash,
- __UNUSED__ int length,
- __UNUSED__ void *data)
+_eina_share_common_cmp(const Eina_Share_Common_Head * ed,
+ const int *hash,
+ __UNUSED__ int length, __UNUSED__ void *data)
{
- EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, , 0);
+ EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed,, 0);
- return ed->hash - *hash;
+ return ed->hash - *hash;
}
static Eina_Rbtree_Direction
-_eina_share_common_node(const Eina_Share_Common_Head *left,
- const Eina_Share_Common_Head *right,
- __UNUSED__ void *data)
+_eina_share_common_node(const Eina_Share_Common_Head * left,
+ const Eina_Share_Common_Head * right,
+ __UNUSED__ void *data)
{
- EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(left, , 0);
- EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(right, , 0);
+ EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(left,, 0);
+ EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(right,, 0);
- if (left->hash - right->hash < 0)
- return EINA_RBTREE_LEFT;
+ if (left->hash - right->hash < 0)
+ return EINA_RBTREE_LEFT;
- return EINA_RBTREE_RIGHT;
+ return EINA_RBTREE_RIGHT;
}
static void
-_eina_share_common_head_free(Eina_Share_Common_Head *ed, __UNUSED__ void *data)
+_eina_share_common_head_free(Eina_Share_Common_Head * ed,
+ __UNUSED__ void *data)
{
- EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, );
+ EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed,);
- while (ed->head)
- {
- Eina_Share_Common_Node *el = ed->head;
+ while (ed->head) {
+ Eina_Share_Common_Node *el = ed->head;
- ed->head = ed->head->next;
- if (el != &ed->builtin_node)
- MAGIC_FREE(el);
- }
- MAGIC_FREE(ed);
+ ed->head = ed->head->next;
+ if (el != &ed->builtin_node)
+ MAGIC_FREE(el);
+ }
+ MAGIC_FREE(ed);
}
static void
-_eina_share_common_node_init(Eina_Share_Common_Node *node,
- const char *str,
- int slen,
- unsigned int null_size,
- Eina_Magic node_magic)
+_eina_share_common_node_init(Eina_Share_Common_Node * node,
+ const char *str,
+ int slen,
+ unsigned int null_size, Eina_Magic node_magic)
{
- EINA_MAGIC_SET(node, node_magic);
- node->references = 1;
- node->length = slen;
- memcpy(node->str, str, slen);
- memset(node->str + slen, 0, null_size); /* Nullify the null */
+ EINA_MAGIC_SET(node, node_magic);
+ node->references = 1;
+ node->length = slen;
+ memcpy(node->str, str, slen);
+ memset(node->str + slen, 0, null_size); /* Nullify the null */
- (void) node_magic; /* When magic are disable, node_magic is unused, this remove a warning. */
+ (void) node_magic; /* When magic are disable, node_magic is unused, this remove a warning. */
}
-static Eina_Share_Common_Head *
-_eina_share_common_head_alloc(int slen)
+static Eina_Share_Common_Head *_eina_share_common_head_alloc(int slen)
{
- Eina_Share_Common_Head *head;
- const size_t head_size = offsetof(Eina_Share_Common_Head, builtin_node.str);
+ Eina_Share_Common_Head *head;
+ const size_t head_size =
+ offsetof(Eina_Share_Common_Head, builtin_node.str);
- head = malloc(head_size + slen);
- if (!head)
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ head = malloc(head_size + slen);
+ if (!head)
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return head;
+ return head;
}
-static const char *
-_eina_share_common_add_head(Eina_Share *share,
- Eina_Share_Common_Head **p_bucket,
- int hash,
- const char *str,
- unsigned int slen,
- unsigned int null_size)
+static const char *_eina_share_common_add_head(Eina_Share * share,
+ Eina_Share_Common_Head **
+ p_bucket, int hash,
+ const char *str,
+ unsigned int slen,
+ unsigned int null_size)
{
- Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
- Eina_Share_Common_Head *head;
+ Eina_Rbtree **p_tree = (Eina_Rbtree **) p_bucket;
+ Eina_Share_Common_Head *head;
- head = _eina_share_common_head_alloc(slen + null_size);
- if (!head)
- return NULL;
+ head = _eina_share_common_head_alloc(slen + null_size);
+ if (!head)
+ return NULL;
- EINA_MAGIC_SET(head, EINA_MAGIC_SHARE_HEAD);
- head->hash = hash;
- head->head = &head->builtin_node;
- _eina_share_common_node_init(head->head,
- str,
- slen,
- null_size,
- share->node_magic);
- head->head->next = NULL;
+ EINA_MAGIC_SET(head, EINA_MAGIC_SHARE_HEAD);
+ head->hash = hash;
+ head->head = &head->builtin_node;
+ _eina_share_common_node_init(head->head,
+ str,
+ slen, null_size, share->node_magic);
+ head->head->next = NULL;
- _eina_share_common_population_head_init(share, head);
+ _eina_share_common_population_head_init(share, head);
- *p_tree = eina_rbtree_inline_insert
- (*p_tree, EINA_RBTREE_GET(head),
- EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
+ *p_tree = eina_rbtree_inline_insert
+ (*p_tree, EINA_RBTREE_GET(head),
+ EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
- return head->head->str;
+ return head->head->str;
}
static void
-_eina_share_common_del_head(Eina_Share_Common_Head **p_bucket,
- Eina_Share_Common_Head *head)
+_eina_share_common_del_head(Eina_Share_Common_Head ** p_bucket,
+ Eina_Share_Common_Head * head)
{
- Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
+ Eina_Rbtree **p_tree = (Eina_Rbtree **) p_bucket;
- *p_tree = eina_rbtree_inline_remove
- (*p_tree, EINA_RBTREE_GET(head),
- EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
+ *p_tree = eina_rbtree_inline_remove
+ (*p_tree, EINA_RBTREE_GET(head),
+ EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
- MAGIC_FREE(head);
+ MAGIC_FREE(head);
}
static inline Eina_Bool
-_eina_share_common_node_eq(const Eina_Share_Common_Node *node,
- const char *str,
- unsigned int slen)
+_eina_share_common_node_eq(const Eina_Share_Common_Node * node,
+ const char *str, unsigned int slen)
{
- return ((node->length == slen) &&
- (memcmp(node->str, str, slen) == 0));
+ return ((node->length == slen) &&
+ (memcmp(node->str, str, slen) == 0));
}
-static Eina_Share_Common_Node *
-_eina_share_common_head_find(Eina_Share_Common_Head *head,
- const char *str,
- unsigned int slen)
+static Eina_Share_Common_Node
+ *_eina_share_common_head_find(Eina_Share_Common_Head * head,
+ const char *str, unsigned int slen)
{
- Eina_Share_Common_Node *node, *prev;
+ Eina_Share_Common_Node *node, *prev;
- node = head->head;
- if (_eina_share_common_node_eq(node, str, slen))
- return node;
+ node = head->head;
+ if (_eina_share_common_node_eq(node, str, slen))
+ return node;
- prev = node;
- node = node->next;
- for (; node; prev = node, node = node->next)
- if (_eina_share_common_node_eq(node, str, slen))
- {
- /* promote node, make hot items be at the beginning */
- prev->next = node->next;
- node->next = head->head;
- head->head = node;
- return node;
- }
+ prev = node;
+ node = node->next;
+ for (; node; prev = node, node = node->next)
+ if (_eina_share_common_node_eq(node, str, slen)) {
+ /* promote node, make hot items be at the beginning */
+ prev->next = node->next;
+ node->next = head->head;
+ head->head = node;
+ return node;
+ }
- return NULL;
+ return NULL;
}
static Eina_Bool
-_eina_share_common_head_remove_node(Eina_Share_Common_Head *head,
- const Eina_Share_Common_Node *node)
+_eina_share_common_head_remove_node(Eina_Share_Common_Head * head,
+ const Eina_Share_Common_Node * node)
{
- Eina_Share_Common_Node *cur, *prev;
+ Eina_Share_Common_Node *cur, *prev;
- if (head->head == node)
- {
- head->head = node->next;
- return 1;
- }
+ if (head->head == node) {
+ head->head = node->next;
+ return 1;
+ }
- prev = head->head;
- cur = head->head->next;
- for (; cur; prev = cur, cur = cur->next)
- if (cur == node)
- {
- prev->next = cur->next;
- return 1;
- }
+ prev = head->head;
+ cur = head->head->next;
+ for (; cur; prev = cur, cur = cur->next)
+ if (cur == node) {
+ prev->next = cur->next;
+ return 1;
+ }
- return 0;
+ return 0;
}
-static Eina_Share_Common_Head *
-_eina_share_common_find_hash(Eina_Share_Common_Head *bucket, int hash)
+static Eina_Share_Common_Head
+ *_eina_share_common_find_hash(Eina_Share_Common_Head * bucket,
+ int hash)
{
- return (Eina_Share_Common_Head *)eina_rbtree_inline_lookup
- (EINA_RBTREE_GET(bucket), &hash, 0,
- EINA_RBTREE_CMP_KEY_CB(_eina_share_common_cmp), NULL);
+ return (Eina_Share_Common_Head *) eina_rbtree_inline_lookup
+ (EINA_RBTREE_GET(bucket), &hash, 0,
+ EINA_RBTREE_CMP_KEY_CB(_eina_share_common_cmp), NULL);
}
-static Eina_Share_Common_Node *
-_eina_share_common_node_alloc(unsigned int slen, unsigned int null_size)
+static Eina_Share_Common_Node *_eina_share_common_node_alloc(unsigned int
+ slen,
+ unsigned int
+ null_size)
{
- Eina_Share_Common_Node *node;
- const size_t node_size = offsetof(Eina_Share_Common_Node, str);
+ Eina_Share_Common_Node *node;
+ const size_t node_size = offsetof(Eina_Share_Common_Node, str);
- node = malloc(node_size + slen + null_size);
- if (!node)
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ node = malloc(node_size + slen + null_size);
+ if (!node)
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return node;
+ return node;
}
-static Eina_Share_Common_Node *
-_eina_share_common_node_from_str(const char *str, Eina_Magic node_magic)
+static Eina_Share_Common_Node *_eina_share_common_node_from_str(const char
+ *str,
+ Eina_Magic
+ node_magic)
{
- Eina_Share_Common_Node *node;
- const size_t offset = offsetof(Eina_Share_Common_Node, str);
+ Eina_Share_Common_Node *node;
+ const size_t offset = offsetof(Eina_Share_Common_Node, str);
- node = (Eina_Share_Common_Node *)(str - offset);
- EINA_MAGIC_CHECK_SHARE_COMMON_NODE(node, node_magic, );
- return node;
+ node = (Eina_Share_Common_Node *) (str - offset);
+ EINA_MAGIC_CHECK_SHARE_COMMON_NODE(node, node_magic,);
+ return node;
- (void) node_magic; /* When magic are disable, node_magic is unused, this remove a warning. */
+ (void) node_magic; /* When magic are disable, node_magic is unused, this remove a warning. */
}
static Eina_Bool
-eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__,
- Eina_Share_Common_Head *head,
- struct dumpinfo *fdata)
+eina_iterator_array_check(const Eina_Rbtree * rbtree __UNUSED__,
+ Eina_Share_Common_Head * head,
+ struct dumpinfo *fdata)
{
- Eina_Share_Common_Node *node;
+ Eina_Share_Common_Node *node;
- SHARE_COMMON_LOCK_BIG();
+ SHARE_COMMON_LOCK_BIG();
- fdata->used += sizeof(Eina_Share_Common_Head);
- for (node = head->head; node; node = node->next)
- {
- printf("DDD: %5i %5i ", node->length, node->references);
- printf("'%.*s'\n", node->length, ((char *)node) + sizeof(Eina_Share_Common_Node));
- fdata->used += sizeof(Eina_Share_Common_Node);
- fdata->used += node->length;
- fdata->saved += (node->references - 1) * node->length;
- fdata->dups += node->references - 1;
- fdata->unique++;
- }
+ fdata->used += sizeof(Eina_Share_Common_Head);
+ for (node = head->head; node; node = node->next) {
+ printf("DDD: %5i %5i ", node->length, node->references);
+ printf("'%.*s'\n", node->length,
+ ((char *) node) + sizeof(Eina_Share_Common_Node));
+ fdata->used += sizeof(Eina_Share_Common_Node);
+ fdata->used += node->length;
+ fdata->saved += (node->references - 1) * node->length;
+ fdata->dups += node->references - 1;
+ fdata->unique++;
+ }
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -611,48 +603,46 @@ eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__,
* @see eina_init()
*/
Eina_Bool
-eina_share_common_init(Eina_Share **_share,
- Eina_Magic node_magic,
- const char *node_magic_STR)
-{
- Eina_Share *share;
- share = *_share = calloc(sizeof(Eina_Share), 1);
- if (!share)
- return EINA_FALSE;
-
- if (_eina_share_common_log_dom < 0) /*Only register if not already */
- _eina_share_common_log_dom = eina_log_domain_register(
- "eina_share",
- EINA_LOG_COLOR_DEFAULT);
-
- if (_eina_share_common_log_dom < 0)
- {
- EINA_LOG_ERR("Could not register log domain: eina_share_common");
- return EINA_FALSE;
- }
-
- share->share = calloc(1, sizeof(Eina_Share_Common));
- if (!share->share)
- {
- if (_eina_share_common_log_dom > 0)
- {
- eina_log_domain_unregister(_eina_share_common_log_dom);
- _eina_share_common_log_dom = -1;
- }
-
- return EINA_FALSE;
- }
-
- share->node_magic = node_magic;
+eina_share_common_init(Eina_Share ** _share,
+ Eina_Magic node_magic, const char *node_magic_STR)
+{
+ Eina_Share *share;
+ share = *_share = calloc(sizeof(Eina_Share), 1);
+ if (!share)
+ return EINA_FALSE;
+
+ if (_eina_share_common_log_dom < 0) /*Only register if not already */
+ _eina_share_common_log_dom =
+ eina_log_domain_register("eina_share",
+ EINA_LOG_COLOR_DEFAULT);
+
+ if (_eina_share_common_log_dom < 0) {
+ EINA_LOG_ERR
+ ("Could not register log domain: eina_share_common");
+ return EINA_FALSE;
+ }
+
+ share->share = calloc(1, sizeof(Eina_Share_Common));
+ if (!share->share) {
+ if (_eina_share_common_log_dom > 0) {
+ eina_log_domain_unregister
+ (_eina_share_common_log_dom);
+ _eina_share_common_log_dom = -1;
+ }
+
+ return EINA_FALSE;
+ }
+
+ share->node_magic = node_magic;
#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
- EMS(EINA_MAGIC_SHARE);
- EMS(EINA_MAGIC_SHARE_HEAD);
- EMS(node_magic);
+ EMS(EINA_MAGIC_SHARE);
+ EMS(EINA_MAGIC_SHARE_HEAD);
+ EMS(node_magic);
#undef EMS
- EINA_MAGIC_SET(share->share, EINA_MAGIC_SHARE);
+ EINA_MAGIC_SET(share->share, EINA_MAGIC_SHARE);
- _eina_share_common_population_init(share);
- return EINA_TRUE;
+ _eina_share_common_population_init(share);
+ return EINA_TRUE;
}
/**
@@ -666,39 +656,36 @@ eina_share_common_init(Eina_Share **_share,
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_share_common_shutdown(Eina_Share **_share)
+Eina_Bool eina_share_common_shutdown(Eina_Share ** _share)
{
- unsigned int i;
- Eina_Share *share = *_share;
+ unsigned int i;
+ Eina_Share *share = *_share;
- SHARE_COMMON_LOCK_BIG();
+ SHARE_COMMON_LOCK_BIG();
- _eina_share_common_population_stats(share);
+ _eina_share_common_population_stats(share);
- /* remove any string still in the table */
- for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++)
- {
- eina_rbtree_delete(EINA_RBTREE_GET(
- share->share->buckets[i]),
- EINA_RBTREE_FREE_CB(
- _eina_share_common_head_free), NULL);
- share->share->buckets[i] = NULL;
- }
- MAGIC_FREE(share->share);
+ /* remove any string still in the table */
+ for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++) {
+ eina_rbtree_delete(EINA_RBTREE_GET
+ (share->share->buckets[i]),
+ EINA_RBTREE_FREE_CB
+ (_eina_share_common_head_free), NULL);
+ share->share->buckets[i] = NULL;
+ }
+ MAGIC_FREE(share->share);
- _eina_share_common_population_shutdown(share);
- if (_eina_share_common_log_dom > 0) /* Only free if necessary */
- {
- eina_log_domain_unregister(_eina_share_common_log_dom);
- _eina_share_common_log_dom = -1;
- }
+ _eina_share_common_population_shutdown(share);
+ if (_eina_share_common_log_dom > 0) { /* Only free if necessary */
+ eina_log_domain_unregister(_eina_share_common_log_dom);
+ _eina_share_common_log_dom = -1;
+ }
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
- free(*_share);
- *_share = NULL;
- return EINA_TRUE;
+ free(*_share);
+ *_share = NULL;
+ return EINA_TRUE;
}
#ifdef EFL_HAVE_THREADS
@@ -712,10 +699,9 @@ eina_share_common_shutdown(Eina_Share **_share)
*
* @see eina_threads_init()
*/
-void
-eina_share_common_threads_init(void)
+void eina_share_common_threads_init(void)
{
- _share_common_threads_activated = EINA_TRUE;
+ _share_common_threads_activated = EINA_TRUE;
}
/**
@@ -727,10 +713,9 @@ eina_share_common_threads_init(void)
*
* @see eina_threads_shutdown()
*/
-void
-eina_share_common_threads_shutdown(void)
+void eina_share_common_threads_shutdown(void)
{
- _share_common_threads_activated = EINA_FALSE;
+ _share_common_threads_activated = EINA_FALSE;
}
#endif
@@ -743,230 +728,225 @@ eina_share_common_threads_shutdown(void)
* @cond LOCAL
*/
-const char *
-eina_share_common_add_length(Eina_Share *share,
- const char *str,
- unsigned int slen,
- unsigned int null_size)
+const char *eina_share_common_add_length(Eina_Share * share,
+ const char *str,
+ unsigned int slen,
+ unsigned int null_size)
{
- Eina_Share_Common_Head **p_bucket, *ed;
- Eina_Share_Common_Node *el;
- int hash_num, hash;
+ Eina_Share_Common_Head **p_bucket, *ed;
+ Eina_Share_Common_Node *el;
+ int hash_num, hash;
- if (!str)
- return NULL;
+ if (!str)
+ return NULL;
- eina_share_common_population_add(share, slen);
+ eina_share_common_population_add(share, slen);
- if (slen <= 0)
- return NULL;
+ if (slen <= 0)
+ return NULL;
- hash = eina_hash_superfast(str, slen);
- hash_num = hash & 0xFF;
- hash = (hash >> 8) & EINA_SHARE_COMMON_MASK;
+ hash = eina_hash_superfast(str, slen);
+ hash_num = hash & 0xFF;
+ hash = (hash >> 8) & EINA_SHARE_COMMON_MASK;
- SHARE_COMMON_LOCK_BIG();
- p_bucket = share->share->buckets + hash_num;
+ SHARE_COMMON_LOCK_BIG();
+ p_bucket = share->share->buckets + hash_num;
- ed = _eina_share_common_find_hash(*p_bucket, hash);
- if (!ed)
- {
- const char *s = _eina_share_common_add_head(share,
- p_bucket,
- hash,
- str,
- slen,
- null_size);
- SHARE_COMMON_UNLOCK_BIG();
- return s;
- }
+ ed = _eina_share_common_find_hash(*p_bucket, hash);
+ if (!ed) {
+ const char *s = _eina_share_common_add_head(share,
+ p_bucket,
+ hash,
+ str,
+ slen,
+ null_size);
+ SHARE_COMMON_UNLOCK_BIG();
+ return s;
+ }
- EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG(), NULL);
+ EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG(),
+ NULL);
- el = _eina_share_common_head_find(ed, str, slen);
- if (el)
- {
- EINA_MAGIC_CHECK_SHARE_COMMON_NODE(el,
- share->node_magic,
- SHARE_COMMON_UNLOCK_BIG());
- el->references++;
- SHARE_COMMON_UNLOCK_BIG();
- return el->str;
- }
+ el = _eina_share_common_head_find(ed, str, slen);
+ if (el) {
+ EINA_MAGIC_CHECK_SHARE_COMMON_NODE(el,
+ share->node_magic,
+ SHARE_COMMON_UNLOCK_BIG
+ ());
+ el->references++;
+ SHARE_COMMON_UNLOCK_BIG();
+ return el->str;
+ }
- el = _eina_share_common_node_alloc(slen, null_size);
- if (!el)
- {
- SHARE_COMMON_UNLOCK_BIG();
- return NULL;
- }
+ el = _eina_share_common_node_alloc(slen, null_size);
+ if (!el) {
+ SHARE_COMMON_UNLOCK_BIG();
+ return NULL;
+ }
- _eina_share_common_node_init(el, str, slen, null_size, share->node_magic);
- el->next = ed->head;
- ed->head = el;
- _eina_share_common_population_head_add(share, ed);
+ _eina_share_common_node_init(el, str, slen, null_size,
+ share->node_magic);
+ el->next = ed->head;
+ ed->head = el;
+ _eina_share_common_population_head_add(share, ed);
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
- return el->str;
+ return el->str;
}
-const char *
-eina_share_common_ref(Eina_Share *share, const char *str)
+const char *eina_share_common_ref(Eina_Share * share, const char *str)
{
- Eina_Share_Common_Node *node;
+ Eina_Share_Common_Node *node;
- if (!str)
- return NULL;
+ if (!str)
+ return NULL;
- SHARE_COMMON_LOCK_BIG();
- node = _eina_share_common_node_from_str(str, share->node_magic);
- node->references++;
- DBG("str=%p refs=%u", str, node->references);
+ SHARE_COMMON_LOCK_BIG();
+ node = _eina_share_common_node_from_str(str, share->node_magic);
+ node->references++;
+ DBG("str=%p refs=%u", str, node->references);
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
- eina_share_common_population_add(share, node->length);
+ eina_share_common_population_add(share, node->length);
- return str;
+ return str;
}
-void
-eina_share_common_del(Eina_Share *share, const char *str)
+void eina_share_common_del(Eina_Share * share, const char *str)
{
- unsigned int slen;
- Eina_Share_Common_Head *ed;
- Eina_Share_Common_Head **p_bucket;
- Eina_Share_Common_Node *node;
- int hash_num, hash;
+ unsigned int slen;
+ Eina_Share_Common_Head *ed;
+ Eina_Share_Common_Head **p_bucket;
+ Eina_Share_Common_Node *node;
+ int hash_num, hash;
- if (!str)
- return;
+ if (!str)
+ return;
- SHARE_COMMON_LOCK_BIG();
+ SHARE_COMMON_LOCK_BIG();
- node = _eina_share_common_node_from_str(str, share->node_magic);
- slen = node->length;
- eina_share_common_population_del(share, slen);
- if (node->references > 1)
- {
- node->references--;
- DBG("str=%p refs=%u", str, node->references);
- SHARE_COMMON_UNLOCK_BIG();
- return;
- }
+ node = _eina_share_common_node_from_str(str, share->node_magic);
+ slen = node->length;
+ eina_share_common_population_del(share, slen);
+ if (node->references > 1) {
+ node->references--;
+ DBG("str=%p refs=%u", str, node->references);
+ SHARE_COMMON_UNLOCK_BIG();
+ return;
+ }
- DBG("str=%p refs=0, delete.", str);
- node->references = 0;
+ DBG("str=%p refs=0, delete.", str);
+ node->references = 0;
- hash = eina_hash_superfast(str, slen);
- hash_num = hash & 0xFF;
- hash = (hash >> 8) & EINA_SHARE_COMMON_MASK;
+ hash = eina_hash_superfast(str, slen);
+ hash_num = hash & 0xFF;
+ hash = (hash >> 8) & EINA_SHARE_COMMON_MASK;
- p_bucket = share->share->buckets + hash_num;
- ed = _eina_share_common_find_hash(*p_bucket, hash);
- if (!ed)
- goto on_error;
+ p_bucket = share->share->buckets + hash_num;
+ ed = _eina_share_common_find_hash(*p_bucket, hash);
+ if (!ed)
+ goto on_error;
- EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG());
+ EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG());
- if (!_eina_share_common_head_remove_node(ed, node))
- goto on_error;
+ if (!_eina_share_common_head_remove_node(ed, node))
+ goto on_error;
- if (node != &ed->builtin_node)
- MAGIC_FREE(node);
+ if (node != &ed->builtin_node)
+ MAGIC_FREE(node);
- if (!ed->head)
- _eina_share_common_del_head(p_bucket, ed);
- else
- _eina_share_common_population_head_del(share, ed);
+ if (!ed->head)
+ _eina_share_common_del_head(p_bucket, ed);
+ else
+ _eina_share_common_population_head_del(share, ed);
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
- return;
+ return;
-on_error:
- SHARE_COMMON_UNLOCK_BIG();
- /* possible segfault happened before here, but... */
- CRITICAL("EEEK trying to del non-shared share_common \"%s\"", str);
+ on_error:
+ SHARE_COMMON_UNLOCK_BIG();
+ /* possible segfault happened before here, but... */
+ CRITICAL("EEEK trying to del non-shared share_common \"%s\"", str);
}
int
-eina_share_common_length(__UNUSED__ Eina_Share *share, const char *str)
+eina_share_common_length(__UNUSED__ Eina_Share * share, const char *str)
{
- const Eina_Share_Common_Node *node;
+ const Eina_Share_Common_Node *node;
- if (!str)
- return -1;
+ if (!str)
+ return -1;
- node = _eina_share_common_node_from_str(str, share->node_magic);
- return node->length;
+ node = _eina_share_common_node_from_str(str, share->node_magic);
+ return node->length;
}
void
-eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
- struct dumpinfo *), int used)
-{
- Eina_Iterator *it;
- unsigned int i;
- struct dumpinfo di;
-
- if (!share)
- return;
-
- di.used = used;
- di.saved = 0;
- di.dups = 0;
- di.unique = 0;
- printf("DDD: len ref string\n");
- printf("DDD:-------------------\n");
-
- SHARE_COMMON_LOCK_BIG();
- for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++)
- {
- if (!share->share->buckets[i])
- {
- continue; // printf("DDD: BUCKET # %i (HEAD=%i, NODE=%i)\n", i,
-
- }
-
-// sizeof(Eina_Share_Common_Head), sizeof(Eina_Share_Common_Node));
- it = eina_rbtree_iterator_prefix(
- (Eina_Rbtree *)share->share->buckets[i]);
- eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_array_check), &di);
- eina_iterator_free(it);
- }
- if (additional_dump)
- additional_dump(&di);
+eina_share_common_dump(Eina_Share * share,
+ void (*additional_dump) (struct dumpinfo *),
+ int used)
+{
+ Eina_Iterator *it;
+ unsigned int i;
+ struct dumpinfo di;
+
+ if (!share)
+ return;
+
+ di.used = used;
+ di.saved = 0;
+ di.dups = 0;
+ di.unique = 0;
+ printf("DDD: len ref string\n");
+ printf("DDD:-------------------\n");
+
+ SHARE_COMMON_LOCK_BIG();
+ for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++) {
+ if (!share->share->buckets[i]) {
+ continue; // printf("DDD: BUCKET # %i (HEAD=%i, NODE=%i)\n", i,
+
+ }
+// sizeof(Eina_Share_Common_Head), sizeof(Eina_Share_Common_Node));
+ it = eina_rbtree_iterator_prefix((Eina_Rbtree *) share->
+ share->buckets[i]);
+ eina_iterator_foreach(it,
+ EINA_EACH_CB
+ (eina_iterator_array_check), &di);
+ eina_iterator_free(it);
+ }
+ if (additional_dump)
+ additional_dump(&di);
#ifdef EINA_SHARE_COMMON_USAGE
- /* One character strings are not counted in the hash. */
- di.saved += share->population_group[0].count * sizeof(char);
- di.saved += share->population_group[1].count * sizeof(char) * 2;
+ /* One character strings are not counted in the hash. */
+ di.saved += share->population_group[0].count * sizeof(char);
+ di.saved += share->population_group[1].count * sizeof(char) * 2;
#endif
- printf("DDD:-------------------\n");
- printf("DDD: usage (bytes) = %i, saved = %i (%3.0f%%)\n",
- di.used, di.saved, di.used ? (di.saved * 100.0 / di.used) : 0.0);
- printf("DDD: unique: %d, duplicates: %d (%3.0f%%)\n",
- di.unique, di.dups, di.unique ? (di.dups * 100.0 / di.unique) : 0.0);
+ printf("DDD:-------------------\n");
+ printf("DDD: usage (bytes) = %i, saved = %i (%3.0f%%)\n",
+ di.used, di.saved,
+ di.used ? (di.saved * 100.0 / di.used) : 0.0);
+ printf("DDD: unique: %d, duplicates: %d (%3.0f%%)\n", di.unique,
+ di.dups, di.unique ? (di.dups * 100.0 / di.unique) : 0.0);
#ifdef EINA_SHARE_COMMON_USAGE
- printf("DDD: Allocated strings: %i\n", share->population.count);
- printf("DDD: Max allocated strings: %i\n", share->population.max);
-
- for (i = 0;
- i < sizeof (share->population_group) /
- sizeof (share->population_group[0]);
- ++i)
- fprintf(stderr,
- "DDD: %i strings of length %i, max strings: %i\n",
- share->population_group[i].count,
- i,
- share->population_group[i].max);
+ printf("DDD: Allocated strings: %i\n", share->population.count);
+ printf("DDD: Max allocated strings: %i\n", share->population.max);
+
+ for (i = 0;
+ i < sizeof(share->population_group) /
+ sizeof(share->population_group[0]); ++i)
+ fprintf(stderr,
+ "DDD: %i strings of length %i, max strings: %i\n",
+ share->population_group[i].count,
+ i, share->population_group[i].max);
#endif
- SHARE_COMMON_UNLOCK_BIG();
+ SHARE_COMMON_UNLOCK_BIG();
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_share_common.h b/tests/suite/ecore/src/lib/eina_share_common.h
index 002c65276c..99b8481f95 100644
--- a/tests/suite/ecore/src/lib/eina_share_common.h
+++ b/tests/suite/ecore/src/lib/eina_share_common.h
@@ -56,32 +56,32 @@
typedef struct _Eina_Share Eina_Share;
-struct dumpinfo
-{
- int used, saved, dups, unique;
+struct dumpinfo {
+ int used, saved, dups, unique;
};
-Eina_Bool eina_share_common_init(Eina_Share **share,
- Eina_Magic node_magic,
- const char *node_magic_STR);
-Eina_Bool eina_share_common_shutdown(Eina_Share **share);
-const char *eina_share_common_add_length(Eina_Share *share,
- const char *str,
- unsigned int slen,
- unsigned int null_size)
-EINA_WARN_UNUSED_RESULT;
-const char *eina_share_common_ref(Eina_Share *share, const char *str);
-void eina_share_common_del(Eina_Share *share, const char *str);
-int eina_share_common_length(Eina_Share *share,
- const char *str) EINA_CONST
-EINA_WARN_UNUSED_RESULT;
-void eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
- struct dumpinfo *), int used);
+Eina_Bool eina_share_common_init(Eina_Share ** share,
+ Eina_Magic node_magic,
+ const char *node_magic_STR);
+Eina_Bool eina_share_common_shutdown(Eina_Share ** share);
+const char *eina_share_common_add_length(Eina_Share * share,
+ const char *str,
+ unsigned int slen,
+ unsigned int null_size)
+ EINA_WARN_UNUSED_RESULT;
+const char *eina_share_common_ref(Eina_Share * share, const char *str);
+void eina_share_common_del(Eina_Share * share, const char *str);
+int eina_share_common_length(Eina_Share * share,
+ const char *str) EINA_CONST
+ EINA_WARN_UNUSED_RESULT;
+void eina_share_common_dump(Eina_Share * share,
+ void (*additional_dump) (struct dumpinfo *),
+ int used);
/* Population functions */
-void eina_share_common_population_add(Eina_Share *share, int slen);
-void eina_share_common_population_del(Eina_Share *share, int slen);
+void eina_share_common_population_add(Eina_Share * share, int slen);
+void eina_share_common_population_del(Eina_Share * share, int slen);
/* Share logging */
#ifdef CRITICAL
@@ -100,4 +100,4 @@ void eina_share_common_population_del(Eina_Share *share, int slen);
#define DBG(...) EINA_LOG_DOM_DBG(_eina_share_common_log_dom, __VA_ARGS__)
extern int _eina_share_common_log_dom;
-#endif /* EINA_STRINGSHARE_H_ */
+#endif /* EINA_STRINGSHARE_H_ */
diff --git a/tests/suite/ecore/src/lib/eina_str.c b/tests/suite/ecore/src/lib/eina_str.c
index bd9badbc58..13cecfb3fc 100644
--- a/tests/suite/ecore/src/lib/eina_str.c
+++ b/tests/suite/ecore/src/lib/eina_str.c
@@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -29,8 +29,8 @@
#include <ctype.h>
#ifdef HAVE_ICONV
-# include <errno.h>
-# include <iconv.h>
+#include <errno.h>
+#include <iconv.h>
#endif
#include "eina_private.h"
@@ -50,118 +50,105 @@
*/
static inline Eina_Bool
eina_str_has_suffix_helper(const char *str,
- const char *suffix,
- int (*cmp)(const char *, const char *))
+ const char *suffix,
+ int (*cmp) (const char *, const char *))
{
- size_t str_len;
- size_t suffix_len;
+ size_t str_len;
+ size_t suffix_len;
- str_len = strlen(str);
- suffix_len = eina_strlen_bounded(suffix, str_len);
- if (suffix_len == (size_t)-1)
- return EINA_FALSE;
+ str_len = strlen(str);
+ suffix_len = eina_strlen_bounded(suffix, str_len);
+ if (suffix_len == (size_t) - 1)
+ return EINA_FALSE;
- return cmp(str + str_len - suffix_len, suffix) == 0;
+ return cmp(str + str_len - suffix_len, suffix) == 0;
}
-static inline char **
-eina_str_split_full_helper(const char *str,
- const char *delim,
- int max_tokens,
- unsigned int *elements)
+static inline char **eina_str_split_full_helper(const char *str,
+ const char *delim,
+ int max_tokens,
+ unsigned int *elements)
{
- char *s, **str_array;
- const char *src;
- size_t len, dlen;
- unsigned int tokens;
-
- dlen = strlen(delim);
- if (dlen == 0)
- {
- if (elements)
- *elements = 0;
-
- return NULL;
- }
-
- tokens = 0;
- src = str;
- /* count tokens and check strlen(str) */
- while (*src != '\0')
- {
- const char *d = delim, *d_end = d + dlen;
- const char *tmp = src;
- for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
- {
- if (EINA_LIKELY(*d != *tmp))
- break;
- }
- if (EINA_UNLIKELY(d == d_end))
- {
- src = tmp;
- tokens++;
- }
- else
- src++;
- }
- len = src - str;
-
- if ((max_tokens > 0) && (tokens > (unsigned int)max_tokens))
- tokens = max_tokens;
-
- str_array = malloc(sizeof(char *) * (tokens + 2));
- if (!str_array)
- {
- if (elements)
- *elements = 0;
-
- return NULL;
- }
-
- s = malloc(len + 1);
- if (!s)
- {
- free(str_array);
- if (elements)
- *elements = 0;
-
- return NULL;
- }
-
- /* copy tokens and string */
- tokens = 0;
- str_array[0] = s;
- src = str;
- while (*src != '\0')
- {
- const char *d = delim, *d_end = d + dlen;
- const char *tmp = src;
- for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
- {
- if (EINA_LIKELY(*d != *tmp))
- break;
- }
- if (EINA_UNLIKELY(d == d_end))
- {
- src = tmp;
- *s = '\0';
- s += dlen;
- tokens++;
- str_array[tokens] = s;
- }
- else
- {
- *s = *src;
- s++;
- src++;
- }
- }
- *s = '\0';
- str_array[tokens + 1] = NULL;
- if (elements)
- *elements = (tokens + 1);
-
- return str_array;
+ char *s, **str_array;
+ const char *src;
+ size_t len, dlen;
+ unsigned int tokens;
+
+ dlen = strlen(delim);
+ if (dlen == 0) {
+ if (elements)
+ *elements = 0;
+
+ return NULL;
+ }
+
+ tokens = 0;
+ src = str;
+ /* count tokens and check strlen(str) */
+ while (*src != '\0') {
+ const char *d = delim, *d_end = d + dlen;
+ const char *tmp = src;
+ for (; (d < d_end) && (*tmp != '\0'); d++, tmp++) {
+ if (EINA_LIKELY(*d != *tmp))
+ break;
+ }
+ if (EINA_UNLIKELY(d == d_end)) {
+ src = tmp;
+ tokens++;
+ } else
+ src++;
+ }
+ len = src - str;
+
+ if ((max_tokens > 0) && (tokens > (unsigned int) max_tokens))
+ tokens = max_tokens;
+
+ str_array = malloc(sizeof(char *) * (tokens + 2));
+ if (!str_array) {
+ if (elements)
+ *elements = 0;
+
+ return NULL;
+ }
+
+ s = malloc(len + 1);
+ if (!s) {
+ free(str_array);
+ if (elements)
+ *elements = 0;
+
+ return NULL;
+ }
+
+ /* copy tokens and string */
+ tokens = 0;
+ str_array[0] = s;
+ src = str;
+ while (*src != '\0') {
+ const char *d = delim, *d_end = d + dlen;
+ const char *tmp = src;
+ for (; (d < d_end) && (*tmp != '\0'); d++, tmp++) {
+ if (EINA_LIKELY(*d != *tmp))
+ break;
+ }
+ if (EINA_UNLIKELY(d == d_end)) {
+ src = tmp;
+ *s = '\0';
+ s += dlen;
+ tokens++;
+ str_array[tokens] = s;
+ } else {
+ *s = *src;
+ s++;
+ src++;
+ }
+ }
+ *s = '\0';
+ str_array[tokens + 1] = NULL;
+ if (elements)
+ *elements = (tokens + 1);
+
+ return str_array;
}
/**
@@ -199,35 +186,31 @@ eina_str_split_full_helper(const char *str,
* @p src. If the returned value is greater than @p siz, truncation
* occurred.
*/
-EAPI size_t
-eina_strlcpy(char *dst, const char *src, size_t siz)
+EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz)
{
#ifdef HAVE_STRLCPY
- return strlcpy(dst, src, siz);
+ return strlcpy(dst, src, siz);
#else
- char *d = dst;
- const char *s = src;
- size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0)
- while (--n != 0)
- {
- if ((*d++ = *s++) == '\0')
- break;
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0)
- {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
-
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0)
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+
+ while (*s++);
+ }
+
+ return (s - src - 1); /* count does not include NUL */
#endif
}
@@ -246,35 +229,33 @@ eina_strlcpy(char *dst, const char *src, size_t siz)
* MIN(siz, strlen(initial dst)). If the returned value is greater or
* equal than @p siz, truncation occurred.
*/
-EAPI size_t
-eina_strlcat(char *dst, const char *src, size_t siz)
+EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz)
{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
- size_t dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (n-- != 0 && *d != '\0')
- d++;
- dlen = d - dst;
- n = siz - dlen;
-
- if (n == 0)
- return(dlen + strlen(s));
-
- while (*s != '\0') {
- if (n != 1)
- {
- *d++ = *s;
- n--;
- }
-
- s++;
- }
- *d = '\0';
-
- return(dlen + (s - src)); /* count does not include NUL */
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return (dlen + strlen(s));
+
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+
+ s++;
+ }
+ *d = '\0';
+
+ return (dlen + (s - src)); /* count does not include NUL */
}
/**
@@ -288,18 +269,17 @@ eina_strlcat(char *dst, const char *src, size_t siz)
* @p prefix, #EINA_FALSE otherwise. If the length of @p prefix is
* greater than @p str, #EINA_FALSE is returned.
*/
-EAPI Eina_Bool
-eina_str_has_prefix(const char *str, const char *prefix)
+EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix)
{
- size_t str_len;
- size_t prefix_len;
+ size_t str_len;
+ size_t prefix_len;
- str_len = strlen(str);
- prefix_len = eina_strlen_bounded(prefix, str_len);
- if (prefix_len == (size_t)-1)
- return EINA_FALSE;
+ str_len = strlen(str);
+ prefix_len = eina_strlen_bounded(prefix, str_len);
+ if (prefix_len == (size_t) - 1)
+ return EINA_FALSE;
- return (strncmp(str, prefix, prefix_len) == 0);
+ return (strncmp(str, prefix, prefix_len) == 0);
}
/**
@@ -319,10 +299,9 @@ eina_str_has_prefix(const char *str, const char *prefix)
* @return true if str has the given suffix
* @brief checks if the string has the given suffix
*/
-EAPI Eina_Bool
-eina_str_has_suffix(const char *str, const char *suffix)
+EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix)
{
- return eina_str_has_suffix_helper(str, suffix, strcmp);
+ return eina_str_has_suffix_helper(str, suffix, strcmp);
}
/**
@@ -335,10 +314,9 @@ eina_str_has_suffix(const char *str, const char *suffix)
* This function does the same like eina_str_has_suffix(), but with a
* case insensitive compare.
*/
-EAPI Eina_Bool
-eina_str_has_extension(const char *str, const char *ext)
+EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext)
{
- return eina_str_has_suffix_helper(str, ext, strcasecmp);
+ return eina_str_has_suffix_helper(str, ext, strcasecmp);
}
/**
@@ -364,13 +342,12 @@ eina_str_has_extension(const char *str, const char *ext)
*
* @see eina_str_split()
*/
-EAPI char **
-eina_str_split_full(const char *str,
- const char *delim,
- int max_tokens,
- unsigned int *elements)
+EAPI char **eina_str_split_full(const char *str,
+ const char *delim,
+ int max_tokens, unsigned int *elements)
{
- return eina_str_split_full_helper(str, delim, max_tokens, elements);
+ return eina_str_split_full_helper(str, delim, max_tokens,
+ elements);
}
@@ -393,10 +370,10 @@ eina_str_split_full(const char *str,
* allocate the array. To free it, free the first element of the array and the
* array itself.
*/
-EAPI char **
-eina_str_split(const char *str, const char *delim, int max_tokens)
+EAPI char **eina_str_split(const char *str, const char *delim,
+ int max_tokens)
{
- return eina_str_split_full_helper(str, delim, max_tokens, NULL);
+ return eina_str_split_full_helper(str, delim, max_tokens, NULL);
}
/**
@@ -427,48 +404,42 @@ eina_str_split(const char *str, const char *delim, int max_tokens)
*/
EAPI size_t
eina_str_join_len(char *dst,
- size_t size,
- char sep,
- const char *a,
- size_t a_len,
- const char *b,
- size_t b_len)
+ size_t size,
+ char sep,
+ const char *a, size_t a_len, const char *b, size_t b_len)
{
- size_t ret = a_len + b_len + 1;
- size_t off;
-
- if (size < 1)
- return ret;
-
- if (size <= a_len)
- {
- memcpy(dst, a, size - 1);
- dst[size - 1] = '\0';
- return ret;
- }
-
- memcpy(dst, a, a_len);
- off = a_len;
-
- if (size <= off + 1)
- {
- dst[size - 1] = '\0';
- return ret;
- }
-
- dst[off] = sep;
- off++;
-
- if (size <= off + b_len + 1)
- {
- memcpy(dst + off, b, size - off - 1);
- dst[size - 1] = '\0';
- return ret;
- }
-
- memcpy(dst + off, b, b_len);
- dst[off + b_len] = '\0';
- return ret;
+ size_t ret = a_len + b_len + 1;
+ size_t off;
+
+ if (size < 1)
+ return ret;
+
+ if (size <= a_len) {
+ memcpy(dst, a, size - 1);
+ dst[size - 1] = '\0';
+ return ret;
+ }
+
+ memcpy(dst, a, a_len);
+ off = a_len;
+
+ if (size <= off + 1) {
+ dst[size - 1] = '\0';
+ return ret;
+ }
+
+ dst[off] = sep;
+ off++;
+
+ if (size <= off + b_len + 1) {
+ memcpy(dst + off, b, size - off - 1);
+ dst[size - 1] = '\0';
+ return ret;
+ }
+
+ memcpy(dst + off, b, b_len);
+ dst[off + b_len] = '\0';
+ return ret;
}
/**
@@ -480,89 +451,78 @@ eina_str_join_len(char *dst,
*
*/
#ifdef HAVE_ICONV
-EAPI char *
-eina_str_convert(const char *enc_from, const char *enc_to, const char *text)
+EAPI char *eina_str_convert(const char *enc_from, const char *enc_to,
+ const char *text)
{
- iconv_t ic;
- char *new_txt, *inp, *outp;
- size_t inb, outb, outlen, tob, outalloc;
-
- if (!text)
- return NULL;
-
- ic = iconv_open(enc_to, enc_from);
- if (ic == (iconv_t)(-1))
- return NULL;
-
- new_txt = malloc(64);
- inb = strlen(text);
- outb = 64;
- inp = (char *)text;
- outp = new_txt;
- outalloc = 64;
- outlen = 0;
-
- for (;; )
- {
- size_t count;
-
- tob = outb;
- count = iconv(ic, &inp, &inb, &outp, &outb);
- outlen += tob - outb;
- if (count == (size_t)(-1))
- {
- if (errno == E2BIG)
- {
- new_txt = realloc(new_txt, outalloc + 64);
- outp = new_txt + outlen;
- outalloc += 64;
- outb += 64;
- }
- else if (errno == EILSEQ)
- {
- if (new_txt)
- free(new_txt);
-
- new_txt = NULL;
- break;
- }
- else if (errno == EINVAL)
- {
- if (new_txt)
- free(new_txt);
-
- new_txt = NULL;
- break;
- }
- else
- {
- if (new_txt)
- free(new_txt);
-
- new_txt = NULL;
- break;
- }
- }
-
- if (inb == 0)
- {
- if (outalloc == outlen)
- new_txt = realloc(new_txt, outalloc + 1);
-
- new_txt[outlen] = 0;
- break;
- }
- }
- iconv_close(ic);
- return new_txt;
+ iconv_t ic;
+ char *new_txt, *inp, *outp;
+ size_t inb, outb, outlen, tob, outalloc;
+
+ if (!text)
+ return NULL;
+
+ ic = iconv_open(enc_to, enc_from);
+ if (ic == (iconv_t) (-1))
+ return NULL;
+
+ new_txt = malloc(64);
+ inb = strlen(text);
+ outb = 64;
+ inp = (char *) text;
+ outp = new_txt;
+ outalloc = 64;
+ outlen = 0;
+
+ for (;;) {
+ size_t count;
+
+ tob = outb;
+ count = iconv(ic, &inp, &inb, &outp, &outb);
+ outlen += tob - outb;
+ if (count == (size_t) (-1)) {
+ if (errno == E2BIG) {
+ new_txt = realloc(new_txt, outalloc + 64);
+ outp = new_txt + outlen;
+ outalloc += 64;
+ outb += 64;
+ } else if (errno == EILSEQ) {
+ if (new_txt)
+ free(new_txt);
+
+ new_txt = NULL;
+ break;
+ } else if (errno == EINVAL) {
+ if (new_txt)
+ free(new_txt);
+
+ new_txt = NULL;
+ break;
+ } else {
+ if (new_txt)
+ free(new_txt);
+
+ new_txt = NULL;
+ break;
+ }
+ }
+
+ if (inb == 0) {
+ if (outalloc == outlen)
+ new_txt = realloc(new_txt, outalloc + 1);
+
+ new_txt[outlen] = 0;
+ break;
+ }
+ }
+ iconv_close(ic);
+ return new_txt;
}
#else
-EAPI char *
-eina_str_convert(const char *enc_from __UNUSED__,
- const char *enc_to __UNUSED__,
- const char *text __UNUSED__)
+EAPI char *eina_str_convert(const char *enc_from __UNUSED__,
+ const char *enc_to __UNUSED__,
+ const char *text __UNUSED__)
{
- return NULL;
+ return NULL;
}
#endif
@@ -573,28 +533,25 @@ eina_str_convert(const char *enc_from __UNUSED__,
*
* A newly allocated string is returned.
*/
-EAPI char *
-eina_str_escape(const char *str)
+EAPI char *eina_str_escape(const char *str)
{
- char *s2, *d;
- const char *s;
-
- s2 = malloc((strlen(str) * 2) + 1);
- if (!s2)
- return NULL;
-
- for (s = str, d = s2; *s != 0; s++, d++)
- {
- if ((*s == ' ') || (*s == '\\') || (*s == '\''))
- {
- *d = '\\';
- d++;
- }
-
- *d = *s;
- }
- *d = 0;
- return s2;
+ char *s2, *d;
+ const char *s;
+
+ s2 = malloc((strlen(str) * 2) + 1);
+ if (!s2)
+ return NULL;
+
+ for (s = str, d = s2; *s != 0; s++, d++) {
+ if ((*s == ' ') || (*s == '\\') || (*s == '\'')) {
+ *d = '\\';
+ d++;
+ }
+
+ *d = *s;
+ }
+ *d = 0;
+ return s2;
}
/**
@@ -604,15 +561,14 @@ eina_str_escape(const char *str)
*
* This modifies the original string, changing all characters in [A-Z] to lowercase.
*/
-EAPI void
-eina_str_tolower(char **str)
+EAPI void eina_str_tolower(char **str)
{
- char *p;
- if ((!str) || (!(*str)))
- return;
+ char *p;
+ if ((!str) || (!(*str)))
+ return;
- for (p = *str; (*p); p++)
- *p = tolower((unsigned char )(*p));
+ for (p = *str; (*p); p++)
+ *p = tolower((unsigned char) (*p));
}
/**
@@ -622,15 +578,14 @@ eina_str_tolower(char **str)
*
* This modifies the original string, changing all characters in [a-z] to uppercase.
*/
-EAPI void
-eina_str_toupper(char **str)
+EAPI void eina_str_toupper(char **str)
{
- char *p;
- if ((!str) || (!(*str)))
- return;
+ char *p;
+ if ((!str) || (!(*str)))
+ return;
- for (p = *str; (*p); p++)
- *p = toupper((unsigned char)(*p));
+ for (p = *str; (*p); p++)
+ *p = toupper((unsigned char) (*p));
}
diff --git a/tests/suite/ecore/src/lib/eina_strbuf.c b/tests/suite/ecore/src/lib/eina_strbuf.c
index 3968af56ae..338d056d86 100644
--- a/tests/suite/ecore/src/lib/eina_strbuf.c
+++ b/tests/suite/ecore/src/lib/eina_strbuf.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#define _GNU_SOURCE
@@ -8,7 +8,7 @@
#include <string.h>
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_private.h"
@@ -25,35 +25,35 @@
*/
#ifdef _STRBUF_DATA_TYPE
-# undef _STRBUF_DATA_TYPE
+#undef _STRBUF_DATA_TYPE
#endif
#ifdef _STRBUF_CSIZE
-# undef _STRBUF_CSIZE
+#undef _STRBUF_CSIZE
#endif
#ifdef _STRBUF_STRUCT_NAME
-# undef _STRBUF_STRUCT_NAME
+#undef _STRBUF_STRUCT_NAME
#endif
#ifdef _STRBUF_STRLEN_FUNC
-# undef _STRBUF_STRLEN_FUNC
+#undef _STRBUF_STRLEN_FUNC
#endif
#ifdef _STRBUF_STRESCAPE_FUNC
-# undef _STRBUF_STRESCAPE_FUNC
+#undef _STRBUF_STRESCAPE_FUNC
#endif
#ifdef _STRBUF_MAGIC
-# undef _STRBUF_MAGIC
+#undef _STRBUF_MAGIC
#endif
#ifdef _STRBUF_MAGIC_STR
-# undef _STRBUF_MAGIC_STR
+#undef _STRBUF_MAGIC_STR
#endif
#ifdef _FUNC_EXPAND
-# undef _FUNC_EXPAND
+#undef _FUNC_EXPAND
#endif
@@ -95,80 +95,80 @@ static const char __STRBUF_MAGIC_STR[] = "Eina Strbuf";
*/
EAPI Eina_Bool
-eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...)
+eina_strbuf_append_printf(Eina_Strbuf * buf, const char *fmt, ...)
{
- va_list args;
- char *str;
- size_t len;
- Eina_Bool ret;
+ va_list args;
+ char *str;
+ size_t len;
+ Eina_Bool ret;
- va_start(args, fmt);
- len = vasprintf(&str, fmt, args);
- va_end(args);
+ va_start(args, fmt);
+ len = vasprintf(&str, fmt, args);
+ va_end(args);
- if (len <= 0 || !str)
- return EINA_FALSE;
+ if (len <= 0 || !str)
+ return EINA_FALSE;
- ret = eina_strbuf_append_length(buf, str, len);
- free(str);
- return ret;
+ ret = eina_strbuf_append_length(buf, str, len);
+ free(str);
+ return ret;
}
EAPI Eina_Bool
-eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args)
+eina_strbuf_append_vprintf(Eina_Strbuf * buf, const char *fmt,
+ va_list args)
{
- char *str;
- size_t len;
- Eina_Bool ret;
+ char *str;
+ size_t len;
+ Eina_Bool ret;
- len = vasprintf(&str, fmt, args);
+ len = vasprintf(&str, fmt, args);
- if (len <= 0 || !str)
- return EINA_FALSE;
+ if (len <= 0 || !str)
+ return EINA_FALSE;
- ret = eina_strbuf_append_length(buf, str, len);
- free(str);
- return ret;
+ ret = eina_strbuf_append_length(buf, str, len);
+ free(str);
+ return ret;
}
EAPI Eina_Bool
-eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...)
+eina_strbuf_insert_printf(Eina_Strbuf * buf, const char *fmt, size_t pos,
+ ...)
{
- va_list args;
- char *str;
- size_t len;
- Eina_Bool ret;
+ va_list args;
+ char *str;
+ size_t len;
+ Eina_Bool ret;
- va_start(args, pos);
- len = vasprintf(&str, fmt, args);
- va_end(args);
+ va_start(args, pos);
+ len = vasprintf(&str, fmt, args);
+ va_end(args);
- if (len <= 0 || !str)
- return EINA_FALSE;
+ if (len <= 0 || !str)
+ return EINA_FALSE;
- ret = eina_strbuf_insert(buf, str, pos);
- free(str);
- return ret;
+ ret = eina_strbuf_insert(buf, str, pos);
+ free(str);
+ return ret;
}
EAPI Eina_Bool
-eina_strbuf_insert_vprintf(Eina_Strbuf *buf,
- const char *fmt,
- size_t pos,
- va_list args)
+eina_strbuf_insert_vprintf(Eina_Strbuf * buf,
+ const char *fmt, size_t pos, va_list args)
{
- char *str;
- size_t len;
- Eina_Bool ret;
+ char *str;
+ size_t len;
+ Eina_Bool ret;
- len = vasprintf(&str, fmt, args);
+ len = vasprintf(&str, fmt, args);
- if (len <= 0 || !str)
- return EINA_FALSE;
+ if (len <= 0 || !str)
+ return EINA_FALSE;
- ret = eina_strbuf_insert(buf, str, pos);
- free(str);
- return ret;
+ ret = eina_strbuf_insert(buf, str, pos);
+ free(str);
+ return ret;
}
/* Unicode */
diff --git a/tests/suite/ecore/src/lib/eina_strbuf_common.c b/tests/suite/ecore/src/lib/eina_strbuf_common.c
index c96e70189d..9e3c09ded1 100644
--- a/tests/suite/ecore/src/lib/eina_strbuf_common.c
+++ b/tests/suite/ecore/src/lib/eina_strbuf_common.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#define _GNU_SOURCE
@@ -9,7 +9,7 @@
#include <string.h>
#ifdef _WIN32
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_private.h"
@@ -51,10 +51,9 @@
*
* @see eina_init()
*/
-Eina_Bool
-eina_strbuf_common_init(void)
+Eina_Bool eina_strbuf_common_init(void)
{
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -68,10 +67,9 @@ eina_strbuf_common_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_strbuf_common_shutdown(void)
+Eina_Bool eina_strbuf_common_shutdown(void)
{
- return EINA_TRUE;
+ return EINA_TRUE;
}
/**
@@ -82,22 +80,20 @@ eina_strbuf_common_shutdown(void)
*
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
-static Eina_Bool
-_eina_strbuf_common_init(size_t csize, Eina_Strbuf *buf)
+static Eina_Bool _eina_strbuf_common_init(size_t csize, Eina_Strbuf * buf)
{
- buf->len = 0;
- buf->size = EINA_STRBUF_INIT_SIZE;
- buf->step = EINA_STRBUF_INIT_STEP;
-
- eina_error_set(0);
- buf->buf = calloc(csize, buf->size);
- if (EINA_UNLIKELY(!buf->buf))
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
- }
-
- return EINA_TRUE;
+ buf->len = 0;
+ buf->size = EINA_STRBUF_INIT_SIZE;
+ buf->step = EINA_STRBUF_INIT_STEP;
+
+ eina_error_set(0);
+ buf->buf = calloc(csize, buf->size);
+ if (EINA_UNLIKELY(!buf->buf)) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
}
/**
@@ -110,48 +106,46 @@ _eina_strbuf_common_init(size_t csize, Eina_Strbuf *buf)
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
static inline Eina_Bool
-_eina_strbuf_common_resize(size_t csize, Eina_Strbuf *buf, size_t size)
+_eina_strbuf_common_resize(size_t csize, Eina_Strbuf * buf, size_t size)
{
- size_t new_size, new_step, delta;
- void *buffer;
-
- size += 1; // Add extra space for '\0'
-
- if (size == buf->size)
- /* nothing to do */
- return EINA_TRUE;
- else if (size > buf->size)
- delta = size - buf->size;
- else
- delta = buf->size - size;
-
- /* check if should keep the same step (just used while growing) */
- if ((delta <= buf->step) && (size > buf->size))
- new_step = buf->step;
- else
- {
- new_step = (((delta / EINA_STRBUF_INIT_STEP) + 1)
- * EINA_STRBUF_INIT_STEP);
-
- if (new_step > EINA_STRBUF_MAX_STEP)
- new_step = EINA_STRBUF_MAX_STEP;
- }
-
- new_size = (((size / new_step) + 1) * new_step);
-
- /* reallocate the buffer to the new size */
- buffer = realloc(buf->buf, new_size * csize);
- if (EINA_UNLIKELY(!buffer))
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return EINA_FALSE;
- }
-
- buf->buf = buffer;
- buf->size = new_size;
- buf->step = new_step;
- eina_error_set(0);
- return EINA_TRUE;
+ size_t new_size, new_step, delta;
+ void *buffer;
+
+ size += 1; // Add extra space for '\0'
+
+ if (size == buf->size)
+ /* nothing to do */
+ return EINA_TRUE;
+ else if (size > buf->size)
+ delta = size - buf->size;
+ else
+ delta = buf->size - size;
+
+ /* check if should keep the same step (just used while growing) */
+ if ((delta <= buf->step) && (size > buf->size))
+ new_step = buf->step;
+ else {
+ new_step = (((delta / EINA_STRBUF_INIT_STEP) + 1)
+ * EINA_STRBUF_INIT_STEP);
+
+ if (new_step > EINA_STRBUF_MAX_STEP)
+ new_step = EINA_STRBUF_MAX_STEP;
+ }
+
+ new_size = (((size / new_step) + 1) * new_step);
+
+ /* reallocate the buffer to the new size */
+ buffer = realloc(buf->buf, new_size * csize);
+ if (EINA_UNLIKELY(!buffer)) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return EINA_FALSE;
+ }
+
+ buf->buf = buffer;
+ buf->size = new_size;
+ buf->step = new_step;
+ eina_error_set(0);
+ return EINA_TRUE;
}
/**
@@ -165,12 +159,12 @@ _eina_strbuf_common_resize(size_t csize, Eina_Strbuf *buf, size_t size)
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
Eina_Bool
-_eina_strbuf_common_grow(size_t csize, Eina_Strbuf *buf, size_t size)
+_eina_strbuf_common_grow(size_t csize, Eina_Strbuf * buf, size_t size)
{
- if ((size + 1) < buf->size)
- return EINA_TRUE;
+ if ((size + 1) < buf->size)
+ return EINA_TRUE;
- return _eina_strbuf_common_resize(csize, buf, size);
+ return _eina_strbuf_common_resize(csize, buf, size);
}
/**
@@ -188,24 +182,23 @@ _eina_strbuf_common_grow(size_t csize, Eina_Strbuf *buf, size_t size)
*/
static inline Eina_Bool
_eina_strbuf_common_insert_length(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t pos)
+ Eina_Strbuf * buf,
+ const void *str, size_t len, size_t pos)
{
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
- return EINA_FALSE;
+ if (EINA_UNLIKELY
+ (!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
+ return EINA_FALSE;
- /* move the existing text */
- memmove(buf->buf + ((len + pos) * csize), buf->buf + (pos * csize),
- (buf->len - pos) * csize);
+ /* move the existing text */
+ memmove(buf->buf + ((len + pos) * csize), buf->buf + (pos * csize),
+ (buf->len - pos) * csize);
- /* and now insert the given string */
- memcpy(buf->buf + (pos * csize), str, len * csize);
+ /* and now insert the given string */
+ memcpy(buf->buf + (pos * csize), str, len * csize);
- buf->len += len;
- memset(buf->buf + (buf->len * csize), 0, csize);
- return EINA_TRUE;
+ buf->len += len;
+ memset(buf->buf + (buf->len * csize), 0, csize);
+ return EINA_TRUE;
}
/*============================================================================*
@@ -225,26 +218,23 @@ _eina_strbuf_common_insert_length(size_t csize,
* @see eina_strbuf_common_append()
* @see eina_strbuf_common_string_get()
*/
-Eina_Strbuf *
-eina_strbuf_common_new(size_t csize)
+Eina_Strbuf *eina_strbuf_common_new(size_t csize)
{
- Eina_Strbuf *buf;
-
- eina_error_set(0);
- buf = malloc(sizeof(Eina_Strbuf));
- if (EINA_UNLIKELY(!buf))
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- if (EINA_UNLIKELY(!_eina_strbuf_common_init(csize, buf)))
- {
- eina_strbuf_common_free(buf);
- return NULL;
- }
-
- return buf;
+ Eina_Strbuf *buf;
+
+ eina_error_set(0);
+ buf = malloc(sizeof(Eina_Strbuf));
+ if (EINA_UNLIKELY(!buf)) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ if (EINA_UNLIKELY(!_eina_strbuf_common_init(csize, buf))) {
+ eina_strbuf_common_free(buf);
+ return NULL;
+ }
+
+ return buf;
}
/**
@@ -255,11 +245,10 @@ eina_strbuf_common_new(size_t csize)
* This function frees the memory of @p buf. @p buf must have been
* created by eina_strbuf_common_new().
*/
-void
-eina_strbuf_common_free(Eina_Strbuf *buf)
+void eina_strbuf_common_free(Eina_Strbuf * buf)
{
- free(buf->buf);
- free(buf);
+ free(buf->buf);
+ free(buf);
}
/**
@@ -270,13 +259,12 @@ eina_strbuf_common_free(Eina_Strbuf *buf)
* This function reset @p buf: the buffer len is set to 0, and the
* string is set to '\\0'. No memory is free'd.
*/
-void
-eina_strbuf_common_reset(size_t csize, Eina_Strbuf *buf)
+void eina_strbuf_common_reset(size_t csize, Eina_Strbuf * buf)
{
- buf->len = 0;
- buf->step = EINA_STRBUF_INIT_STEP;
+ buf->len = 0;
+ buf->step = EINA_STRBUF_INIT_STEP;
- memset(buf->buf, 0, csize);
+ memset(buf->buf, 0, csize);
}
/**
@@ -297,19 +285,18 @@ eina_strbuf_common_reset(size_t csize, Eina_Strbuf *buf)
*/
Eina_Bool
eina_strbuf_common_append(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len)
+ Eina_Strbuf * buf, const void *str, size_t len)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
- return EINA_FALSE;
+ if (EINA_UNLIKELY
+ (!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
+ return EINA_FALSE;
- memcpy(buf->buf + (buf->len * csize), str, (len + 1) * csize);
- buf->len += len;
- return EINA_TRUE;
+ memcpy(buf->buf + (buf->len * csize), str, (len + 1) * csize);
+ buf->len += len;
+ return EINA_TRUE;
}
/**
@@ -335,23 +322,22 @@ eina_strbuf_common_append(size_t csize,
*/
Eina_Bool
eina_strbuf_common_append_n(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t maxlen)
+ Eina_Strbuf * buf,
+ const void *str, size_t len, size_t maxlen)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
- if (len > maxlen)
- len = maxlen;
+ if (len > maxlen)
+ len = maxlen;
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
- return EINA_FALSE;
+ if (EINA_UNLIKELY
+ (!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
+ return EINA_FALSE;
- memcpy(buf->buf + (buf->len * csize), str, len * csize);
- buf->len += len;
- memset(buf->buf + (buf->len * csize), 0, csize);
- return EINA_TRUE;
+ memcpy(buf->buf + (buf->len * csize), str, len * csize);
+ buf->len += len;
+ memset(buf->buf + (buf->len * csize), 0, csize);
+ return EINA_TRUE;
}
/**
@@ -375,19 +361,19 @@ eina_strbuf_common_append_n(size_t csize,
*/
Eina_Bool
eina_strbuf_common_append_length(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t length)
+ Eina_Strbuf * buf,
+ const void *str, size_t length)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + length)))
- return EINA_FALSE;
+ if (EINA_UNLIKELY
+ (!_eina_strbuf_common_grow(csize, buf, buf->len + length)))
+ return EINA_FALSE;
- memcpy(buf->buf + (buf->len * csize), str, length * csize);
- buf->len += length;
- memset(buf->buf + (buf->len * csize), 0, csize);
- return EINA_TRUE;
+ memcpy(buf->buf + (buf->len * csize), str, length * csize);
+ buf->len += length;
+ memset(buf->buf + (buf->len * csize), 0, csize);
+ return EINA_TRUE;
}
/**
@@ -406,17 +392,16 @@ eina_strbuf_common_append_length(size_t csize,
*/
Eina_Bool
eina_strbuf_common_insert(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t pos)
+ Eina_Strbuf * buf,
+ const void *str, size_t len, size_t pos)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
- if (pos >= buf->len)
- return eina_strbuf_common_append(csize, buf, str, len);
+ if (pos >= buf->len)
+ return eina_strbuf_common_append(csize, buf, str, len);
- return _eina_strbuf_common_insert_length(csize, buf, str, len, pos);
+ return _eina_strbuf_common_insert_length(csize, buf, str, len,
+ pos);
}
/**
@@ -439,21 +424,21 @@ eina_strbuf_common_insert(size_t csize,
*/
Eina_Bool
eina_strbuf_common_insert_n(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t maxlen,
- size_t pos)
+ Eina_Strbuf * buf,
+ const void *str,
+ size_t len, size_t maxlen, size_t pos)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
- if (pos >= buf->len)
- return eina_strbuf_common_append_n(csize, buf, str, len, maxlen);
+ if (pos >= buf->len)
+ return eina_strbuf_common_append_n(csize, buf, str, len,
+ maxlen);
- if (len > maxlen)
- len = maxlen;
+ if (len > maxlen)
+ len = maxlen;
- return _eina_strbuf_common_insert_length(csize, buf, str, len, pos);
+ return _eina_strbuf_common_insert_length(csize, buf, str, len,
+ pos);
}
/**
@@ -478,17 +463,18 @@ eina_strbuf_common_insert_n(size_t csize,
*/
Eina_Bool
eina_strbuf_common_insert_length(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t length,
- size_t pos)
+ Eina_Strbuf * buf,
+ const void *str,
+ size_t length, size_t pos)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
- if (pos >= buf->len)
- return eina_strbuf_common_append_length(csize, buf, str, length);
+ if (pos >= buf->len)
+ return eina_strbuf_common_append_length(csize, buf, str,
+ length);
- return _eina_strbuf_common_insert_length(csize, buf, str, length, pos);
+ return _eina_strbuf_common_insert_length(csize, buf, str, length,
+ pos);
}
/**
@@ -503,15 +489,17 @@ eina_strbuf_common_insert_length(size_t csize,
* #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
*/
Eina_Bool
-eina_strbuf_common_append_char(size_t csize, Eina_Strbuf *buf, const void *c)
+eina_strbuf_common_append_char(size_t csize, Eina_Strbuf * buf,
+ const void *c)
{
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + 1)))
- return EINA_FALSE;
+ if (EINA_UNLIKELY
+ (!_eina_strbuf_common_grow(csize, buf, buf->len + 1)))
+ return EINA_FALSE;
- memcpy(buf->buf + ((buf->len)++ *csize), c, csize);
- memset(buf->buf + (buf->len * csize), 0, csize);
- return EINA_TRUE;
+ memcpy(buf->buf + ((buf->len)++ * csize), c, csize);
+ memset(buf->buf + (buf->len * csize), 0, csize);
+ return EINA_TRUE;
}
/**
@@ -529,15 +517,14 @@ eina_strbuf_common_append_char(size_t csize, Eina_Strbuf *buf, const void *c)
*/
Eina_Bool
eina_strbuf_common_insert_char(size_t csize,
- Eina_Strbuf *buf,
- const void *c,
- size_t pos)
+ Eina_Strbuf * buf,
+ const void *c, size_t pos)
{
- if (pos >= buf->len)
- return eina_strbuf_common_append_char(csize, buf, c);
+ if (pos >= buf->len)
+ return eina_strbuf_common_append_char(csize, buf, c);
- return _eina_strbuf_common_insert_length(csize, buf, c, 1, pos);
+ return _eina_strbuf_common_insert_length(csize, buf, c, 1, pos);
}
/**
@@ -556,31 +543,27 @@ eina_strbuf_common_insert_char(size_t csize,
*/
Eina_Bool
eina_strbuf_common_remove(size_t csize,
- Eina_Strbuf *buf,
- size_t start,
- size_t end)
+ Eina_Strbuf * buf, size_t start, size_t end)
{
- size_t remove_len, tail_len;
-
- if (end >= buf->len)
- end = buf->len;
-
- if (end <= start)
- return EINA_TRUE;
-
- remove_len = end - start;
- if (remove_len == buf->len)
- {
- free(buf->buf);
- return _eina_strbuf_common_init(csize, buf);
- }
-
- tail_len = buf->len - end + 1; /* includes '\0' */
- memmove(buf->buf + (start * csize),
- buf->buf + (end * csize),
- tail_len * csize);
- buf->len -= remove_len;
- return _eina_strbuf_common_resize(csize, buf, buf->len);
+ size_t remove_len, tail_len;
+
+ if (end >= buf->len)
+ end = buf->len;
+
+ if (end <= start)
+ return EINA_TRUE;
+
+ remove_len = end - start;
+ if (remove_len == buf->len) {
+ free(buf->buf);
+ return _eina_strbuf_common_init(csize, buf);
+ }
+
+ tail_len = buf->len - end + 1; /* includes '\0' */
+ memmove(buf->buf + (start * csize),
+ buf->buf + (end * csize), tail_len * csize);
+ buf->len -= remove_len;
+ return _eina_strbuf_common_resize(csize, buf, buf->len);
}
/**
@@ -596,10 +579,9 @@ eina_strbuf_common_remove(size_t csize,
*
* @see eina_strbuf_common_string_steal()
*/
-const void *
-eina_strbuf_common_string_get(const Eina_Strbuf *buf)
+const void *eina_strbuf_common_string_get(const Eina_Strbuf * buf)
{
- return buf->buf;
+ return buf->buf;
}
/**
@@ -615,15 +597,14 @@ eina_strbuf_common_string_get(const Eina_Strbuf *buf)
*
* @see eina_strbuf_common_string_get()
*/
-void *
-eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf *buf)
+void *eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf * buf)
{
- void *ret;
+ void *ret;
- ret = buf->buf;
- // TODO: Check return value and do something clever
- _eina_strbuf_common_init(csize, buf);
- return ret;
+ ret = buf->buf;
+ // TODO: Check return value and do something clever
+ _eina_strbuf_common_init(csize, buf);
+ return ret;
}
/**
@@ -634,11 +615,10 @@ eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf *buf)
* This function frees the string contained in @p buf without freeing
* @p buf.
*/
-void
-eina_strbuf_common_string_free(size_t csize, Eina_Strbuf *buf)
+void eina_strbuf_common_string_free(size_t csize, Eina_Strbuf * buf)
{
- free(buf->buf);
- _eina_strbuf_common_init(csize, buf);
+ free(buf->buf);
+ _eina_strbuf_common_init(csize, buf);
}
/**
@@ -649,10 +629,9 @@ eina_strbuf_common_string_free(size_t csize, Eina_Strbuf *buf)
*
* This function returns the length of @p buf.
*/
-size_t
-eina_strbuf_common_length_get(const Eina_Strbuf *buf)
+size_t eina_strbuf_common_length_get(const Eina_Strbuf * buf)
{
- return buf->len;
+ return buf->len;
}
/**
@@ -674,15 +653,15 @@ eina_strbuf_common_length_get(const Eina_Strbuf *buf)
/*FIXME: Implementing them here is a hack! */
#ifdef _STRBUF_CSIZE
-# undef _STRBUF_CSIZE
+#undef _STRBUF_CSIZE
#endif
#ifdef _STRBUF_MAGIC
-# undef _STRBUF_MAGIC
+#undef _STRBUF_MAGIC
#endif
#ifdef _STRBUF_MAGIC_STR
-# undef _STRBUF_MAGIC_STR
+#undef _STRBUF_MAGIC_STR
#endif
#define _STRBUF_CSIZE 1
@@ -709,56 +688,52 @@ static const char __STRBUF_STR_MAGIC_STR[] = "Eina Strbuf";
* @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
*/
EAPI Eina_Bool
-eina_strbuf_replace(Eina_Strbuf *buf,
- const char *str,
- const char *with,
- unsigned int n)
+eina_strbuf_replace(Eina_Strbuf * buf,
+ const char *str, const char *with, unsigned int n)
{
- size_t len1, len2;
- char *spos;
- size_t pos;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL( str, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(with, EINA_FALSE);
- EINA_MAGIC_CHECK_STRBUF(buf, 0);
-
- if (n == 0)
- return EINA_FALSE;
-
- spos = buf->buf;
- while (n--)
- {
- spos = strstr(spos, str);
- if (!spos || *spos == '\0')
- return EINA_FALSE;
-
- if (n)
- spos++;
- }
-
- pos = spos - (const char *)buf->buf;
- len1 = strlen(str);
- len2 = strlen(with);
- if (len1 != len2)
- {
- /* resize the buffer if necessary */
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf,
- buf->len - len1 + len2)))
- {
- return EINA_FALSE; /* move the existing text */
-
- }
-
- memmove(buf->buf + pos + len2, buf->buf + pos + len1,
- buf->len - pos - len1);
- }
-
- /* and now insert the given string */
- memcpy(buf->buf + pos, with, len2);
- buf->len += len2 - len1;
- memset((char *)buf->buf + buf->len, 0, 1);
-
- return EINA_TRUE;
+ size_t len1, len2;
+ char *spos;
+ size_t pos;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(with, EINA_FALSE);
+ EINA_MAGIC_CHECK_STRBUF(buf, 0);
+
+ if (n == 0)
+ return EINA_FALSE;
+
+ spos = buf->buf;
+ while (n--) {
+ spos = strstr(spos, str);
+ if (!spos || *spos == '\0')
+ return EINA_FALSE;
+
+ if (n)
+ spos++;
+ }
+
+ pos = spos - (const char *) buf->buf;
+ len1 = strlen(str);
+ len2 = strlen(with);
+ if (len1 != len2) {
+ /* resize the buffer if necessary */
+ if (EINA_UNLIKELY
+ (!_eina_strbuf_common_grow
+ (_STRBUF_CSIZE, buf, buf->len - len1 + len2))) {
+ return EINA_FALSE; /* move the existing text */
+
+ }
+
+ memmove(buf->buf + pos + len2, buf->buf + pos + len1,
+ buf->len - pos - len1);
+ }
+
+ /* and now insert the given string */
+ memcpy(buf->buf + pos, with, len2);
+ buf->len += len2 - len1;
+ memset((char *) buf->buf + buf->len, 0, 1);
+
+ return EINA_TRUE;
}
/**
@@ -774,87 +749,84 @@ eina_strbuf_replace(Eina_Strbuf *buf,
* has been replaced. On failure, it returns 0.
*/
EAPI int
-eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with)
+eina_strbuf_replace_all(Eina_Strbuf * buf, const char *str,
+ const char *with)
{
- size_t len1, len2, len;
- char *tmp_buf = NULL;
- char *spos;
- size_t pos, start;
- size_t pos_tmp, start_tmp;
- int n = 0;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL( str, 0);
- EINA_SAFETY_ON_NULL_RETURN_VAL(with, 0);
- EINA_MAGIC_CHECK_STRBUF(buf, 0);
-
- spos = strstr(buf->buf, str);
- if (!spos || *spos == '\0')
- return 0;
-
- len1 = strlen(str);
- len2 = strlen(with);
-
- /* if the size of the two string is equal, it is fairly easy to replace them
- * we don't need to resize the buffer or doing other calculations */
- if (len1 == len2)
- {
- while (spos)
- {
- memcpy(spos, with, len2);
- spos = strstr(spos + len2, str);
- n++;
- }
- return n;
- }
-
- pos = pos_tmp = spos - (const char *)buf->buf;
- tmp_buf = buf->buf;
- buf->buf = malloc(buf->size);
- if (EINA_UNLIKELY(!buf->buf))
- {
- buf->buf = tmp_buf;
- return 0;
- }
-
- start = start_tmp = 0;
- len = buf->len;
-
- while (spos)
- {
- n++;
- len = (len + len2) - len1;
- /* resize the buffer if necessary */
- if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf, len)))
- {
- /* we have to stop replacing here, because we haven't enough
- * memory to go on */
- len = (len + len1) - len2;
- break;
- }
-
- /* copy the untouched text */
- memcpy(buf->buf + start, tmp_buf + start_tmp, pos - start);
- /* copy the new string */
- memcpy(buf->buf + pos, with, len2);
-
- /* calculate the next positions */
- start_tmp = pos_tmp + len1;
- start = pos + len2;
- spos = strstr(tmp_buf + start_tmp, str);
- /* this calculations don't make sense if spos == NULL, but the
- * calculated values won't be used, because the loop will stop
- * then */
- pos_tmp = spos - tmp_buf;
- pos = start + pos_tmp - start_tmp;
- }
- /* and now copy the rest of the text */
- memcpy(buf->buf + start, tmp_buf + start_tmp, len - start);
- buf->len = len;
- memset((char *)buf->buf + buf->len, 0, 1);
-
- free(tmp_buf);
-
- return n;
+ size_t len1, len2, len;
+ char *tmp_buf = NULL;
+ char *spos;
+ size_t pos, start;
+ size_t pos_tmp, start_tmp;
+ int n = 0;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(str, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(with, 0);
+ EINA_MAGIC_CHECK_STRBUF(buf, 0);
+
+ spos = strstr(buf->buf, str);
+ if (!spos || *spos == '\0')
+ return 0;
+
+ len1 = strlen(str);
+ len2 = strlen(with);
+
+ /* if the size of the two string is equal, it is fairly easy to replace them
+ * we don't need to resize the buffer or doing other calculations */
+ if (len1 == len2) {
+ while (spos) {
+ memcpy(spos, with, len2);
+ spos = strstr(spos + len2, str);
+ n++;
+ }
+ return n;
+ }
+
+ pos = pos_tmp = spos - (const char *) buf->buf;
+ tmp_buf = buf->buf;
+ buf->buf = malloc(buf->size);
+ if (EINA_UNLIKELY(!buf->buf)) {
+ buf->buf = tmp_buf;
+ return 0;
+ }
+
+ start = start_tmp = 0;
+ len = buf->len;
+
+ while (spos) {
+ n++;
+ len = (len + len2) - len1;
+ /* resize the buffer if necessary */
+ if (EINA_UNLIKELY
+ (!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf, len))) {
+ /* we have to stop replacing here, because we haven't enough
+ * memory to go on */
+ len = (len + len1) - len2;
+ break;
+ }
+
+ /* copy the untouched text */
+ memcpy(buf->buf + start, tmp_buf + start_tmp, pos - start);
+ /* copy the new string */
+ memcpy(buf->buf + pos, with, len2);
+
+ /* calculate the next positions */
+ start_tmp = pos_tmp + len1;
+ start = pos + len2;
+ spos = strstr(tmp_buf + start_tmp, str);
+ /* this calculations don't make sense if spos == NULL, but the
+ * calculated values won't be used, because the loop will stop
+ * then */
+ pos_tmp = spos - tmp_buf;
+ pos = start + pos_tmp - start_tmp;
+ }
+ /* and now copy the rest of the text */
+ memcpy(buf->buf + start, tmp_buf + start_tmp, len - start);
+ buf->len = len;
+ memset((char *) buf->buf + buf->len, 0, 1);
+
+ free(tmp_buf);
+
+ return n;
}
/**
diff --git a/tests/suite/ecore/src/lib/eina_strbuf_common.h b/tests/suite/ecore/src/lib/eina_strbuf_common.h
index 3713f2c48a..0c38e639b1 100644
--- a/tests/suite/ecore/src/lib/eina_strbuf_common.h
+++ b/tests/suite/ecore/src/lib/eina_strbuf_common.h
@@ -7,15 +7,13 @@
#include "eina_magic.h"
#include "eina_strbuf.h"
-struct _Eina_Strbuf
-{
- void *buf;
- size_t len;
- size_t size;
- size_t step;
+struct _Eina_Strbuf {
+ void *buf;
+ size_t len;
+ size_t size;
+ size_t step;
- EINA_MAGIC
-};
+ EINA_MAGIC};
#define EINA_MAGIC_CHECK_STRBUF(d, ...) \
do { \
@@ -26,85 +24,58 @@ struct _Eina_Strbuf
} \
} while (0)
-Eina_Bool
-eina_strbuf_common_init(void);
+Eina_Bool eina_strbuf_common_init(void);
-Eina_Bool
-eina_strbuf_common_shutdown(void);
-Eina_Strbuf *
-eina_strbuf_common_new(size_t csize);
-void
-eina_strbuf_common_free(Eina_Strbuf *buf);
-void
-eina_strbuf_common_reset(size_t csize, Eina_Strbuf *buf);
+Eina_Bool eina_strbuf_common_shutdown(void);
+Eina_Strbuf *eina_strbuf_common_new(size_t csize);
+void eina_strbuf_common_free(Eina_Strbuf * buf);
+void eina_strbuf_common_reset(size_t csize, Eina_Strbuf * buf);
Eina_Bool
eina_strbuf_common_append(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len);
+ Eina_Strbuf * buf, const void *str, size_t len);
Eina_Bool
eina_strbuf_common_append_escaped(size_t csize,
- Eina_Strbuf *buf,
- const void *str);
+ Eina_Strbuf * buf, const void *str);
Eina_Bool
eina_strbuf_common_append_n(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t maxlen);
+ Eina_Strbuf * buf,
+ const void *str, size_t len, size_t maxlen);
Eina_Bool
eina_strbuf_common_append_length(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t length);
+ Eina_Strbuf * buf,
+ const void *str, size_t length);
Eina_Bool
eina_strbuf_common_insert(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t pos);
+ Eina_Strbuf * buf,
+ const void *str, size_t len, size_t pos);
Eina_Bool
eina_strbuf_common_insert_escaped(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t pos);
+ Eina_Strbuf * buf,
+ const void *str, size_t len, size_t pos);
Eina_Bool
eina_strbuf_common_insert_n(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t len,
- size_t maxlen,
- size_t pos);
+ Eina_Strbuf * buf,
+ const void *str,
+ size_t len, size_t maxlen, size_t pos);
Eina_Bool
eina_strbuf_common_insert_length(size_t csize,
- Eina_Strbuf *buf,
- const void *str,
- size_t length,
- size_t pos);
-Eina_Bool
-eina_strbuf_common_append_char(size_t csize, Eina_Strbuf *buf, const void *c);
-Eina_Bool
-eina_strbuf_common_insert_char(size_t csize,
- Eina_Strbuf *buf,
- const void *c,
- size_t pos);
+ Eina_Strbuf * buf,
+ const void *str,
+ size_t length, size_t pos);
Eina_Bool
-eina_strbuf_common_remove(size_t csize,
- Eina_Strbuf *buf,
- size_t start,
- size_t end);
-const void *
-eina_strbuf_common_string_get(const Eina_Strbuf *buf);
-void *
-eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf *buf);
-void
-eina_strbuf_common_string_free(size_t csize, Eina_Strbuf *buf);
-size_t
-eina_strbuf_common_length_get(const Eina_Strbuf *buf);
+eina_strbuf_common_append_char(size_t csize, Eina_Strbuf * buf,
+ const void *c);
+Eina_Bool eina_strbuf_common_insert_char(size_t csize, Eina_Strbuf * buf,
+ const void *c, size_t pos);
+Eina_Bool eina_strbuf_common_remove(size_t csize, Eina_Strbuf * buf,
+ size_t start, size_t end);
+const void *eina_strbuf_common_string_get(const Eina_Strbuf * buf);
+void *eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf * buf);
+void eina_strbuf_common_string_free(size_t csize, Eina_Strbuf * buf);
+size_t eina_strbuf_common_length_get(const Eina_Strbuf * buf);
Eina_Bool
-_eina_strbuf_common_grow(size_t csize, Eina_Strbuf *buf, size_t size);
+_eina_strbuf_common_grow(size_t csize, Eina_Strbuf * buf, size_t size);
/**
* @}
*/
diff --git a/tests/suite/ecore/src/lib/eina_stringshare.c b/tests/suite/ecore/src/lib/eina_stringshare.c
index 86b461725d..9269437e9d 100644
--- a/tests/suite/ecore/src/lib/eina_stringshare.c
+++ b/tests/suite/ecore/src/lib/eina_stringshare.c
@@ -30,26 +30,26 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#define _GNU_SOURCE
#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
+#include <alloca.h>
#elif defined __GNUC__
-# define alloca __builtin_alloca
+#define alloca __builtin_alloca
#elif defined _AIX
-# define alloca __alloca
+#define alloca __alloca
#elif defined _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
+#include <malloc.h>
+#define alloca _alloca
#else
-# include <stddef.h>
-# ifdef __cplusplus
+#include <stddef.h>
+#ifdef __cplusplus
extern "C"
-# endif
-void *alloca (size_t);
+#endif
+void *alloca(size_t);
#endif
#include <stdlib.h>
@@ -57,11 +57,11 @@ void *alloca (size_t);
#include <string.h>
#ifdef EFL_HAVE_POSIX_THREADS
-# include <pthread.h>
+#include <pthread.h>
#endif
#ifdef HAVE_EVIL
-# include <Evil.h>
+#include <Evil.h>
#endif
#include "eina_config.h"
@@ -78,436 +78,440 @@ void *alloca (size_t);
/* The actual share */
static Eina_Share *stringshare_share;
-static const char EINA_MAGIC_STRINGSHARE_NODE_STR[] = "Eina Stringshare Node";
+static const char EINA_MAGIC_STRINGSHARE_NODE_STR[] =
+ "Eina Stringshare Node";
#ifdef EFL_HAVE_THREADS
extern Eina_Bool _share_common_threads_activated;
-# ifdef EFL_HAVE_POSIX_THREADS
+#ifdef EFL_HAVE_POSIX_THREADS
static pthread_mutex_t _mutex_small = PTHREAD_MUTEX_INITIALIZER;
-# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
+#define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
pthread_mutex_lock(&_mutex_small)
-# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
+#define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
pthread_mutex_unlock(&_mutex_small)
-# else /* EFL_HAVE_WIN32_THREADS */
+#else /* EFL_HAVE_WIN32_THREADS */
static HANDLE _mutex_small = NULL;
-# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
+#define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
WaitForSingleObject(_mutex_small, INFINITE)
-# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
+#define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
ReleaseMutex(_mutex_small)
-# endif /* EFL_HAVE_WIN32_THREADS */
-#else /* EFL_HAVE_THREADS */
-# define STRINGSHARE_LOCK_SMALL() do {} while (0)
-# define STRINGSHARE_UNLOCK_SMALL() do {} while (0)
+#endif /* EFL_HAVE_WIN32_THREADS */
+#else /* EFL_HAVE_THREADS */
+#define STRINGSHARE_LOCK_SMALL() do {} while (0)
+#define STRINGSHARE_UNLOCK_SMALL() do {} while (0)
#endif
/* Stringshare optimizations */
static const unsigned char _eina_stringshare_single[512] = {
- 0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,
- 16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,
- 31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,
- 46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,
- 61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,
- 76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,
- 91,0,92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,101,0,102,0,103,0,104,0,
- 105,0,
- 106,0,107,0,108,0,109,0,110,0,111,0,112,0,113,0,114,0,115,0,116,0,117,0,118,
- 0,119,0,120,0,
- 121,0,122,0,123,0,124,0,125,0,126,0,127,0,128,0,129,0,130,0,131,0,132,0,133,
- 0,134,0,135,0,
- 136,0,137,0,138,0,139,0,140,0,141,0,142,0,143,0,144,0,145,0,146,0,147,0,148,
- 0,149,0,150,0,
- 151,0,152,0,153,0,154,0,155,0,156,0,157,0,158,0,159,0,160,0,161,0,162,0,163,
- 0,164,0,165,0,
- 166,0,167,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,
- 0,179,0,180,0,
- 181,0,182,0,183,0,184,0,185,0,186,0,187,0,188,0,189,0,190,0,191,0,192,0,193,
- 0,194,0,195,0,
- 196,0,197,0,198,0,199,0,200,0,201,0,202,0,203,0,204,0,205,0,206,0,207,0,208,
- 0,209,0,210,0,
- 211,0,212,0,213,0,214,0,215,0,216,0,217,0,218,0,219,0,220,0,221,0,222,0,223,
- 0,224,0,225,0,
- 226,0,227,0,228,0,229,0,230,0,231,0,232,0,233,0,234,0,235,0,236,0,237,0,238,
- 0,239,0,240,0,
- 241,0,242,0,243,0,244,0,245,0,246,0,247,0,248,0,249,0,250,0,251,0,252,0,253,
- 0,254,0,255,0
+ 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0,
+ 11, 0, 12, 0, 13, 0, 14, 0, 15, 0,
+ 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25,
+ 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0,
+ 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40,
+ 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0,
+ 46, 0, 47, 0, 48, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55,
+ 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0,
+ 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70,
+ 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0,
+ 76, 0, 77, 0, 78, 0, 79, 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, 0, 85,
+ 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, 0,
+ 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, 0, 99, 0, 100,
+ 0, 101, 0, 102, 0, 103, 0, 104, 0,
+ 105, 0,
+ 106, 0, 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, 112, 0, 113, 0,
+ 114, 0, 115, 0, 116, 0, 117, 0, 118,
+ 0, 119, 0, 120, 0,
+ 121, 0, 122, 0, 123, 0, 124, 0, 125, 0, 126, 0, 127, 0, 128, 0,
+ 129, 0, 130, 0, 131, 0, 132, 0, 133,
+ 0, 134, 0, 135, 0,
+ 136, 0, 137, 0, 138, 0, 139, 0, 140, 0, 141, 0, 142, 0, 143, 0,
+ 144, 0, 145, 0, 146, 0, 147, 0, 148,
+ 0, 149, 0, 150, 0,
+ 151, 0, 152, 0, 153, 0, 154, 0, 155, 0, 156, 0, 157, 0, 158, 0,
+ 159, 0, 160, 0, 161, 0, 162, 0, 163,
+ 0, 164, 0, 165, 0,
+ 166, 0, 167, 0, 168, 0, 169, 0, 170, 0, 171, 0, 172, 0, 173, 0,
+ 174, 0, 175, 0, 176, 0, 177, 0, 178,
+ 0, 179, 0, 180, 0,
+ 181, 0, 182, 0, 183, 0, 184, 0, 185, 0, 186, 0, 187, 0, 188, 0,
+ 189, 0, 190, 0, 191, 0, 192, 0, 193,
+ 0, 194, 0, 195, 0,
+ 196, 0, 197, 0, 198, 0, 199, 0, 200, 0, 201, 0, 202, 0, 203, 0,
+ 204, 0, 205, 0, 206, 0, 207, 0, 208,
+ 0, 209, 0, 210, 0,
+ 211, 0, 212, 0, 213, 0, 214, 0, 215, 0, 216, 0, 217, 0, 218, 0,
+ 219, 0, 220, 0, 221, 0, 222, 0, 223,
+ 0, 224, 0, 225, 0,
+ 226, 0, 227, 0, 228, 0, 229, 0, 230, 0, 231, 0, 232, 0, 233, 0,
+ 234, 0, 235, 0, 236, 0, 237, 0, 238,
+ 0, 239, 0, 240, 0,
+ 241, 0, 242, 0, 243, 0, 244, 0, 245, 0, 246, 0, 247, 0, 248, 0,
+ 249, 0, 250, 0, 251, 0, 252, 0, 253,
+ 0, 254, 0, 255, 0
};
typedef struct _Eina_Stringshare_Small Eina_Stringshare_Small;
-typedef struct _Eina_Stringshare_Small_Bucket Eina_Stringshare_Small_Bucket;
-
-struct _Eina_Stringshare_Small_Bucket
-{
- /* separate arrays for faster lookups */
- const char **strings;
- unsigned char *lengths;
- unsigned short *references;
- int count;
- int size;
+typedef struct _Eina_Stringshare_Small_Bucket
+ Eina_Stringshare_Small_Bucket;
+
+struct _Eina_Stringshare_Small_Bucket {
+ /* separate arrays for faster lookups */
+ const char **strings;
+ unsigned char *lengths;
+ unsigned short *references;
+ int count;
+ int size;
};
-struct _Eina_Stringshare_Small
-{
- Eina_Stringshare_Small_Bucket *buckets[256];
+struct _Eina_Stringshare_Small {
+ Eina_Stringshare_Small_Bucket *buckets[256];
};
#define EINA_STRINGSHARE_SMALL_BUCKET_STEP 8
static Eina_Stringshare_Small _eina_small_share;
static inline int
-_eina_stringshare_small_cmp(const Eina_Stringshare_Small_Bucket *bucket,
- int i,
- const char *pstr,
- unsigned char plength)
+_eina_stringshare_small_cmp(const Eina_Stringshare_Small_Bucket * bucket,
+ int i, const char *pstr, unsigned char plength)
{
- /* pstr and plength are from second char and on, since the first is
- * always the same.
- *
- * First string being always the same, size being between 2 and 3
- * characters (there is a check for special case length==1 and then
- * small stringshare is applied to strings < 4), we just need to
- * compare 2 characters of both strings.
- */
- const unsigned char cur_plength = bucket->lengths[i] - 1;
- const char *cur_pstr;
-
- if (cur_plength > plength)
- return 1;
- else if (cur_plength < plength)
- return -1;
-
- cur_pstr = bucket->strings[i] + 1;
-
- if (cur_pstr[0] > pstr[0])
- return 1;
- else if (cur_pstr[0] < pstr[0])
- return -1;
-
- if (plength == 1)
- return 0;
-
- if (cur_pstr[1] > pstr[1])
- return 1;
- else if (cur_pstr[1] < pstr[1])
- return -1;
-
- return 0;
+ /* pstr and plength are from second char and on, since the first is
+ * always the same.
+ *
+ * First string being always the same, size being between 2 and 3
+ * characters (there is a check for special case length==1 and then
+ * small stringshare is applied to strings < 4), we just need to
+ * compare 2 characters of both strings.
+ */
+ const unsigned char cur_plength = bucket->lengths[i] - 1;
+ const char *cur_pstr;
+
+ if (cur_plength > plength)
+ return 1;
+ else if (cur_plength < plength)
+ return -1;
+
+ cur_pstr = bucket->strings[i] + 1;
+
+ if (cur_pstr[0] > pstr[0])
+ return 1;
+ else if (cur_pstr[0] < pstr[0])
+ return -1;
+
+ if (plength == 1)
+ return 0;
+
+ if (cur_pstr[1] > pstr[1])
+ return 1;
+ else if (cur_pstr[1] < pstr[1])
+ return -1;
+
+ return 0;
}
-static const char *
-_eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket,
- const char *str,
- unsigned char length,
- int *idx)
+static const char *_eina_stringshare_small_bucket_find(const
+ Eina_Stringshare_Small_Bucket
+ * bucket,
+ const char *str,
+ unsigned char
+ length, int *idx)
{
- const char *pstr = str + 1; /* skip first letter, it's always the same */
- unsigned char plength = length - 1;
- int i, low, high;
-
- if (bucket->count == 0)
- {
- *idx = 0;
- return NULL;
- }
-
- low = 0;
- high = bucket->count;
-
- while (low < high)
- {
- int r;
-
- i = (low + high - 1) / 2;
-
- r = _eina_stringshare_small_cmp(bucket, i, pstr, plength);
- if (r > 0)
- high = i;
- else if (r < 0)
- low = i + 1;
- else
- {
- *idx = i;
- return bucket->strings[i];
- }
- }
-
- *idx = low;
- return NULL;
+ const char *pstr = str + 1; /* skip first letter, it's always the same */
+ unsigned char plength = length - 1;
+ int i, low, high;
+
+ if (bucket->count == 0) {
+ *idx = 0;
+ return NULL;
+ }
+
+ low = 0;
+ high = bucket->count;
+
+ while (low < high) {
+ int r;
+
+ i = (low + high - 1) / 2;
+
+ r = _eina_stringshare_small_cmp(bucket, i, pstr, plength);
+ if (r > 0)
+ high = i;
+ else if (r < 0)
+ low = i + 1;
+ else {
+ *idx = i;
+ return bucket->strings[i];
+ }
+ }
+
+ *idx = low;
+ return NULL;
}
static Eina_Bool
-_eina_stringshare_small_bucket_resize(Eina_Stringshare_Small_Bucket *bucket,
- int size)
+_eina_stringshare_small_bucket_resize(Eina_Stringshare_Small_Bucket *
+ bucket, int size)
{
- void *tmp;
-
- tmp = realloc((void *)bucket->strings, size * sizeof(bucket->strings[0]));
- if (!tmp)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
- }
-
- bucket->strings = tmp;
-
- tmp = realloc(bucket->lengths, size * sizeof(bucket->lengths[0]));
- if (!tmp)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
- }
-
- bucket->lengths = tmp;
-
- tmp = realloc(bucket->references, size * sizeof(bucket->references[0]));
- if (!tmp)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return 0;
- }
-
- bucket->references = tmp;
-
- bucket->size = size;
- return 1;
+ void *tmp;
+
+ tmp =
+ realloc((void *) bucket->strings,
+ size * sizeof(bucket->strings[0]));
+ if (!tmp) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
+ }
+
+ bucket->strings = tmp;
+
+ tmp = realloc(bucket->lengths, size * sizeof(bucket->lengths[0]));
+ if (!tmp) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
+ }
+
+ bucket->lengths = tmp;
+
+ tmp =
+ realloc(bucket->references,
+ size * sizeof(bucket->references[0]));
+ if (!tmp) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return 0;
+ }
+
+ bucket->references = tmp;
+
+ bucket->size = size;
+ return 1;
}
-static const char *
-_eina_stringshare_small_bucket_insert_at(
- Eina_Stringshare_Small_Bucket **p_bucket,
- const char *str,
- unsigned char length,
- int idx)
+static const char
+ *_eina_stringshare_small_bucket_insert_at(Eina_Stringshare_Small_Bucket
+ ** p_bucket, const char *str,
+ unsigned char length,
+ int idx)
{
- Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
- int todo, off;
- char *snew;
-
- if (!bucket)
- {
- *p_bucket = bucket = calloc(1, sizeof(*bucket));
- if (!bucket)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
- }
-
- if (bucket->count + 1 >= bucket->size)
- {
- int size = bucket->size + EINA_STRINGSHARE_SMALL_BUCKET_STEP;
- if (!_eina_stringshare_small_bucket_resize(bucket, size))
- return NULL;
- }
-
- snew = malloc(length + 1);
- if (!snew)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- memcpy(snew, str, length);
- snew[length] = '\0';
-
- off = idx + 1;
- todo = bucket->count - idx;
- if (todo > 0)
- {
- memmove((void *)(bucket->strings + off), bucket->strings + idx,
- todo * sizeof(bucket->strings[0]));
- memmove(bucket->lengths + off, bucket->lengths + idx,
- todo * sizeof(bucket->lengths[0]));
- memmove(bucket->references + off, bucket->references + idx,
- todo * sizeof(bucket->references[0]));
- }
-
- bucket->strings[idx] = snew;
- bucket->lengths[idx] = length;
- bucket->references[idx] = 1;
- bucket->count++;
-
- return snew;
+ Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+ int todo, off;
+ char *snew;
+
+ if (!bucket) {
+ *p_bucket = bucket = calloc(1, sizeof(*bucket));
+ if (!bucket) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+ }
+
+ if (bucket->count + 1 >= bucket->size) {
+ int size =
+ bucket->size + EINA_STRINGSHARE_SMALL_BUCKET_STEP;
+ if (!_eina_stringshare_small_bucket_resize(bucket, size))
+ return NULL;
+ }
+
+ snew = malloc(length + 1);
+ if (!snew) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ memcpy(snew, str, length);
+ snew[length] = '\0';
+
+ off = idx + 1;
+ todo = bucket->count - idx;
+ if (todo > 0) {
+ memmove((void *) (bucket->strings + off),
+ bucket->strings + idx,
+ todo * sizeof(bucket->strings[0]));
+ memmove(bucket->lengths + off, bucket->lengths + idx,
+ todo * sizeof(bucket->lengths[0]));
+ memmove(bucket->references + off, bucket->references + idx,
+ todo * sizeof(bucket->references[0]));
+ }
+
+ bucket->strings[idx] = snew;
+ bucket->lengths[idx] = length;
+ bucket->references[idx] = 1;
+ bucket->count++;
+
+ return snew;
}
static void
-_eina_stringshare_small_bucket_remove_at(
- Eina_Stringshare_Small_Bucket **p_bucket,
- int idx)
+_eina_stringshare_small_bucket_remove_at(Eina_Stringshare_Small_Bucket **
+ p_bucket, int idx)
{
- Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
- int todo, off;
-
- if (bucket->references[idx] > 1)
- {
- bucket->references[idx]--;
- return;
- }
-
- free((char *)bucket->strings[idx]);
-
- if (bucket->count == 1)
- {
- free((void *)bucket->strings);
- free(bucket->lengths);
- free(bucket->references);
- free(bucket);
- *p_bucket = NULL;
- return;
- }
-
- bucket->count--;
- if (idx == bucket->count)
- goto end;
-
- off = idx + 1;
- todo = bucket->count - idx;
-
- memmove((void *)(bucket->strings + idx), bucket->strings + off,
- todo * sizeof(bucket->strings[0]));
- memmove(bucket->lengths + idx, bucket->lengths + off,
- todo * sizeof(bucket->lengths[0]));
- memmove(bucket->references + idx, bucket->references + off,
- todo * sizeof(bucket->references[0]));
-
-end:
- if (bucket->count + EINA_STRINGSHARE_SMALL_BUCKET_STEP < bucket->size)
- {
- int size = bucket->size - EINA_STRINGSHARE_SMALL_BUCKET_STEP;
- _eina_stringshare_small_bucket_resize(bucket, size);
- }
+ Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+ int todo, off;
+
+ if (bucket->references[idx] > 1) {
+ bucket->references[idx]--;
+ return;
+ }
+
+ free((char *) bucket->strings[idx]);
+
+ if (bucket->count == 1) {
+ free((void *) bucket->strings);
+ free(bucket->lengths);
+ free(bucket->references);
+ free(bucket);
+ *p_bucket = NULL;
+ return;
+ }
+
+ bucket->count--;
+ if (idx == bucket->count)
+ goto end;
+
+ off = idx + 1;
+ todo = bucket->count - idx;
+
+ memmove((void *) (bucket->strings + idx), bucket->strings + off,
+ todo * sizeof(bucket->strings[0]));
+ memmove(bucket->lengths + idx, bucket->lengths + off,
+ todo * sizeof(bucket->lengths[0]));
+ memmove(bucket->references + idx, bucket->references + off,
+ todo * sizeof(bucket->references[0]));
+
+ end:
+ if (bucket->count + EINA_STRINGSHARE_SMALL_BUCKET_STEP <
+ bucket->size) {
+ int size =
+ bucket->size - EINA_STRINGSHARE_SMALL_BUCKET_STEP;
+ _eina_stringshare_small_bucket_resize(bucket, size);
+ }
}
-static const char *
-_eina_stringshare_small_add(const char *str, unsigned char length)
+static const char *_eina_stringshare_small_add(const char *str,
+ unsigned char length)
{
- Eina_Stringshare_Small_Bucket **bucket;
- int i;
-
- bucket = _eina_small_share.buckets + (unsigned char)str[0];
- if (!*bucket)
- i = 0;
- else
- {
- const char *ret;
- ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
- if (ret)
- {
- (*bucket)->references[i]++;
- return ret;
- }
- }
-
- return _eina_stringshare_small_bucket_insert_at(bucket, str, length, i);
+ Eina_Stringshare_Small_Bucket **bucket;
+ int i;
+
+ bucket = _eina_small_share.buckets + (unsigned char) str[0];
+ if (!*bucket)
+ i = 0;
+ else {
+ const char *ret;
+ ret =
+ _eina_stringshare_small_bucket_find(*bucket, str,
+ length, &i);
+ if (ret) {
+ (*bucket)->references[i]++;
+ return ret;
+ }
+ }
+
+ return _eina_stringshare_small_bucket_insert_at(bucket, str,
+ length, i);
}
static void
_eina_stringshare_small_del(const char *str, unsigned char length)
{
- Eina_Stringshare_Small_Bucket **bucket;
- const char *ret;
- int i;
+ Eina_Stringshare_Small_Bucket **bucket;
+ const char *ret;
+ int i;
- bucket = _eina_small_share.buckets + (unsigned char)str[0];
- if (!*bucket)
- goto error;
+ bucket = _eina_small_share.buckets + (unsigned char) str[0];
+ if (!*bucket)
+ goto error;
- ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
- if (!ret)
- goto error;
+ ret =
+ _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
+ if (!ret)
+ goto error;
- _eina_stringshare_small_bucket_remove_at(bucket, i);
- return;
+ _eina_stringshare_small_bucket_remove_at(bucket, i);
+ return;
-error:
- CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str);
+ error:
+ CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str);
}
-static void
-_eina_stringshare_small_init(void)
+static void _eina_stringshare_small_init(void)
{
- memset(&_eina_small_share, 0, sizeof(_eina_small_share));
+ memset(&_eina_small_share, 0, sizeof(_eina_small_share));
}
-static void
-_eina_stringshare_small_shutdown(void)
+static void _eina_stringshare_small_shutdown(void)
{
- Eina_Stringshare_Small_Bucket **p_bucket, **p_bucket_end;
-
- p_bucket = _eina_small_share.buckets;
- p_bucket_end = p_bucket + 256;
-
- for (; p_bucket < p_bucket_end; p_bucket++)
- {
- Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
- char **s, **s_end;
-
- if (!bucket)
- continue;
-
- s = (char **)bucket->strings;
- s_end = s + bucket->count;
- for (; s < s_end; s++)
- free(*s);
-
- free((void *)bucket->strings);
- free(bucket->lengths);
- free(bucket->references);
- free(bucket);
- *p_bucket = NULL;
- }
+ Eina_Stringshare_Small_Bucket **p_bucket, **p_bucket_end;
+
+ p_bucket = _eina_small_share.buckets;
+ p_bucket_end = p_bucket + 256;
+
+ for (; p_bucket < p_bucket_end; p_bucket++) {
+ Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+ char **s, **s_end;
+
+ if (!bucket)
+ continue;
+
+ s = (char **) bucket->strings;
+ s_end = s + bucket->count;
+ for (; s < s_end; s++)
+ free(*s);
+
+ free((void *) bucket->strings);
+ free(bucket->lengths);
+ free(bucket->references);
+ free(bucket);
+ *p_bucket = NULL;
+ }
}
static void
-_eina_stringshare_small_bucket_dump(Eina_Stringshare_Small_Bucket *bucket,
- struct dumpinfo *di)
+_eina_stringshare_small_bucket_dump(Eina_Stringshare_Small_Bucket * bucket,
+ struct dumpinfo *di)
{
- const char **s = bucket->strings;
- unsigned char *l = bucket->lengths;
- unsigned short *r = bucket->references;
- int i;
-
- di->used += sizeof(*bucket);
- di->used += bucket->count * sizeof(*s);
- di->used += bucket->count * sizeof(*l);
- di->used += bucket->count * sizeof(*r);
- di->unique += bucket->count;
-
- for (i = 0; i < bucket->count; i++, s++, l++, r++)
- {
- int dups;
+ const char **s = bucket->strings;
+ unsigned char *l = bucket->lengths;
+ unsigned short *r = bucket->references;
+ int i;
+
+ di->used += sizeof(*bucket);
+ di->used += bucket->count * sizeof(*s);
+ di->used += bucket->count * sizeof(*l);
+ di->used += bucket->count * sizeof(*r);
+ di->unique += bucket->count;
+
+ for (i = 0; i < bucket->count; i++, s++, l++, r++) {
+ int dups;
#ifdef _WIN32
- printf("DDD: %5hu %5hu '%s'\n", *l, *r, *s);
+ printf("DDD: %5hu %5hu '%s'\n", *l, *r, *s);
#else
- printf("DDD: %5hhu %5hu '%s'\n", *l, *r, *s);
+ printf("DDD: %5hhu %5hu '%s'\n", *l, *r, *s);
#endif
- dups = (*r - 1);
+ dups = (*r - 1);
- di->used += *l;
- di->saved += *l * dups;
- di->dups += dups;
- }
+ di->used += *l;
+ di->saved += *l * dups;
+ di->dups += dups;
+ }
}
-static void
-_eina_stringshare_small_dump(struct dumpinfo *di)
+static void _eina_stringshare_small_dump(struct dumpinfo *di)
{
- Eina_Stringshare_Small_Bucket **p_bucket, **p_bucket_end;
+ Eina_Stringshare_Small_Bucket **p_bucket, **p_bucket_end;
- p_bucket = _eina_small_share.buckets;
- p_bucket_end = p_bucket + 256;
+ p_bucket = _eina_small_share.buckets;
+ p_bucket_end = p_bucket + 256;
- for (; p_bucket < p_bucket_end; p_bucket++)
- {
- Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+ for (; p_bucket < p_bucket_end; p_bucket++) {
+ Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
- if (!bucket)
- continue;
+ if (!bucket)
+ continue;
- _eina_stringshare_small_bucket_dump(bucket, di);
- }
+ _eina_stringshare_small_bucket_dump(bucket, di);
+ }
}
@@ -526,17 +530,16 @@ _eina_stringshare_small_dump(struct dumpinfo *di)
*
* @see eina_init()
*/
-Eina_Bool
-eina_stringshare_init(void)
+Eina_Bool eina_stringshare_init(void)
{
- Eina_Bool ret;
- ret = eina_share_common_init(&stringshare_share,
- EINA_MAGIC_STRINGSHARE_NODE,
- EINA_MAGIC_STRINGSHARE_NODE_STR);
- if (ret)
- _eina_stringshare_small_init();
-
- return ret;
+ Eina_Bool ret;
+ ret = eina_share_common_init(&stringshare_share,
+ EINA_MAGIC_STRINGSHARE_NODE,
+ EINA_MAGIC_STRINGSHARE_NODE_STR);
+ if (ret)
+ _eina_stringshare_small_init();
+
+ return ret;
}
/**
@@ -550,13 +553,12 @@ eina_stringshare_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_stringshare_shutdown(void)
+Eina_Bool eina_stringshare_shutdown(void)
{
- Eina_Bool ret;
- _eina_stringshare_small_shutdown();
- ret = eina_share_common_shutdown(&stringshare_share);
- return ret;
+ Eina_Bool ret;
+ _eina_stringshare_small_shutdown();
+ ret = eina_share_common_shutdown(&stringshare_share);
+ return ret;
}
/*============================================================================*
@@ -600,38 +602,36 @@ eina_stringshare_shutdown(void)
* Note that if the given pointer is not shared or NULL, bad things
* will happen, likely a segmentation fault.
*/
-EAPI void
-eina_stringshare_del(const char *str)
+EAPI void eina_stringshare_del(const char *str)
{
- int slen;
- DBG("str=%p (%s)", str, str ? str : "");
- if (!str)
- return;
-
- /* special cases */
- if (str[0] == '\0')
- slen = 0;
- else if (str[1] == '\0')
- slen = 1;
- else if (str[2] == '\0')
- slen = 2;
- else if (str[3] == '\0')
- slen = 3;
- else
- slen = 4; /* handled later */
-
- if (slen < 2)
- return;
- else if (slen < 4)
- {
- eina_share_common_population_del(stringshare_share, slen);
- STRINGSHARE_LOCK_SMALL();
- _eina_stringshare_small_del(str, slen);
- STRINGSHARE_UNLOCK_SMALL();
- return;
- }
-
- eina_share_common_del(stringshare_share, str);
+ int slen;
+ DBG("str=%p (%s)", str, str ? str : "");
+ if (!str)
+ return;
+
+ /* special cases */
+ if (str[0] == '\0')
+ slen = 0;
+ else if (str[1] == '\0')
+ slen = 1;
+ else if (str[2] == '\0')
+ slen = 2;
+ else if (str[3] == '\0')
+ slen = 3;
+ else
+ slen = 4; /* handled later */
+
+ if (slen < 2)
+ return;
+ else if (slen < 4) {
+ eina_share_common_population_del(stringshare_share, slen);
+ STRINGSHARE_LOCK_SMALL();
+ _eina_stringshare_small_del(str, slen);
+ STRINGSHARE_UNLOCK_SMALL();
+ return;
+ }
+
+ eina_share_common_del(stringshare_share, str);
}
/**
@@ -654,27 +654,27 @@ eina_stringshare_del(const char *str)
*
* @see eina_share_common_add()
*/
-EAPI const char *
-eina_stringshare_add_length(const char *str, unsigned int slen)
+EAPI const char *eina_stringshare_add_length(const char *str,
+ unsigned int slen)
{
- DBG("str=%p (%.*s), slen=%u", str, slen, str ? str : "", slen);
-
- if (slen <= 0)
- return "";
- else if (slen == 1)
- return (const char *)_eina_stringshare_single + ((*str) << 1);
- else if (slen < 4)
- {
- const char *s;
-
- STRINGSHARE_LOCK_SMALL();
- s = _eina_stringshare_small_add(str, slen);
- STRINGSHARE_UNLOCK_SMALL();
- return s;
- }
-
- return eina_share_common_add_length(stringshare_share, str, slen *
- sizeof(char), sizeof(char));
+ DBG("str=%p (%.*s), slen=%u", str, slen, str ? str : "", slen);
+
+ if (slen <= 0)
+ return "";
+ else if (slen == 1)
+ return (const char *) _eina_stringshare_single +
+ ((*str) << 1);
+ else if (slen < 4) {
+ const char *s;
+
+ STRINGSHARE_LOCK_SMALL();
+ s = _eina_stringshare_small_add(str, slen);
+ STRINGSHARE_UNLOCK_SMALL();
+ return s;
+ }
+
+ return eina_share_common_add_length(stringshare_share, str, slen *
+ sizeof(char), sizeof(char));
}
/**
@@ -696,25 +696,24 @@ eina_stringshare_add_length(const char *str, unsigned int slen)
*
* @see eina_stringshare_add_length()
*/
-EAPI const char *
-eina_stringshare_add(const char *str)
+EAPI const char *eina_stringshare_add(const char *str)
{
- int slen;
- if (!str)
- return NULL;
-
- if (str[0] == '\0')
- slen = 0;
- else if (str[1] == '\0')
- slen = 1;
- else if (str[2] == '\0')
- slen = 2;
- else if (str[3] == '\0')
- slen = 3;
- else
- slen = 3 + (int)strlen(str + 3);
-
- return eina_stringshare_add_length(str, slen);
+ int slen;
+ if (!str)
+ return NULL;
+
+ if (str[0] == '\0')
+ slen = 0;
+ else if (str[1] == '\0')
+ slen = 1;
+ else if (str[2] == '\0')
+ slen = 2;
+ else if (str[3] == '\0')
+ slen = 3;
+ else
+ slen = 3 + (int) strlen(str + 3);
+
+ return eina_stringshare_add_length(str, slen);
}
/**
@@ -737,28 +736,27 @@ eina_stringshare_add(const char *str)
*
* @see eina_stringshare_nprintf()
*/
-EAPI const char *
-eina_stringshare_printf(const char *fmt, ...)
+EAPI const char *eina_stringshare_printf(const char *fmt, ...)
{
- va_list args;
- char *tmp;
- const char *ret;
- int len;
+ va_list args;
+ char *tmp;
+ const char *ret;
+ int len;
- if (!fmt)
- return NULL;
+ if (!fmt)
+ return NULL;
- va_start(args, fmt);
- len = vasprintf(&tmp, fmt, args);
- va_end(args);
+ va_start(args, fmt);
+ len = vasprintf(&tmp, fmt, args);
+ va_end(args);
- if (len < 1)
- return NULL;
+ if (len < 1)
+ return NULL;
- ret = eina_stringshare_add_length(tmp, len);
- free(tmp);
+ ret = eina_stringshare_add_length(tmp, len);
+ free(tmp);
- return ret;
+ return ret;
}
/**
@@ -782,25 +780,24 @@ eina_stringshare_printf(const char *fmt, ...)
*
* @see eina_stringshare_nprintf()
*/
-EAPI const char *
-eina_stringshare_vprintf(const char *fmt, va_list args)
+EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list args)
{
- char *tmp;
- const char *ret;
- int len;
+ char *tmp;
+ const char *ret;
+ int len;
- if (!fmt)
- return NULL;
+ if (!fmt)
+ return NULL;
- len = vasprintf(&tmp, fmt, args);
+ len = vasprintf(&tmp, fmt, args);
- if (len < 1)
- return NULL;
+ if (len < 1)
+ return NULL;
- ret = eina_stringshare_add_length(tmp, len);
- free(tmp);
+ ret = eina_stringshare_add_length(tmp, len);
+ free(tmp);
- return ret;
+ return ret;
}
/**
@@ -822,29 +819,29 @@ eina_stringshare_vprintf(const char *fmt, va_list args)
*
* @see eina_stringshare_printf()
*/
-EAPI const char *
-eina_stringshare_nprintf(unsigned int len, const char *fmt, ...)
+EAPI const char *eina_stringshare_nprintf(unsigned int len,
+ const char *fmt, ...)
{
- va_list args;
- char *tmp;
- int size;
+ va_list args;
+ char *tmp;
+ int size;
- if (!fmt)
- return NULL;
+ if (!fmt)
+ return NULL;
- if (len < 1)
- return NULL;
+ if (len < 1)
+ return NULL;
- tmp = alloca(sizeof(char) * len + 1);
+ tmp = alloca(sizeof(char) * len + 1);
- va_start(args, fmt);
- size = vsnprintf(tmp, len, fmt, args);
- va_end(args);
+ va_start(args, fmt);
+ size = vsnprintf(tmp, len, fmt, args);
+ va_end(args);
- if (size < 1)
- return NULL;
+ if (size < 1)
+ return NULL;
- return eina_stringshare_add_length(tmp, len);
+ return eina_stringshare_add_length(tmp, len);
}
/**
@@ -861,46 +858,42 @@ eina_stringshare_nprintf(unsigned int len, const char *fmt, ...)
*
* There is no unref since this is the work of eina_share_common_del().
*/
-EAPI const char *
-eina_stringshare_ref(const char *str)
+EAPI const char *eina_stringshare_ref(const char *str)
{
- int slen;
- DBG("str=%p (%s)", str, str ? str : "");
-
- if (!str)
- return eina_share_common_ref(stringshare_share, str);
-
- /* special cases */
- if (str[0] == '\0')
- slen = 0;
- else if (str[1] == '\0')
- slen = 1;
- else if (str[2] == '\0')
- slen = 2;
- else if (str[3] == '\0')
- slen = 3;
- else
- slen = 3 + (int)strlen(str + 3);
-
- if (slen < 2)
- {
- eina_share_common_population_add(stringshare_share, slen);
-
- return str;
- }
- else if (slen < 4)
- {
- const char *s;
- eina_share_common_population_add(stringshare_share, slen);
-
- STRINGSHARE_LOCK_SMALL();
- s = _eina_stringshare_small_add(str, slen);
- STRINGSHARE_UNLOCK_SMALL();
-
- return s;
- }
-
- return eina_share_common_ref(stringshare_share, str);
+ int slen;
+ DBG("str=%p (%s)", str, str ? str : "");
+
+ if (!str)
+ return eina_share_common_ref(stringshare_share, str);
+
+ /* special cases */
+ if (str[0] == '\0')
+ slen = 0;
+ else if (str[1] == '\0')
+ slen = 1;
+ else if (str[2] == '\0')
+ slen = 2;
+ else if (str[3] == '\0')
+ slen = 3;
+ else
+ slen = 3 + (int) strlen(str + 3);
+
+ if (slen < 2) {
+ eina_share_common_population_add(stringshare_share, slen);
+
+ return str;
+ } else if (slen < 4) {
+ const char *s;
+ eina_share_common_population_add(stringshare_share, slen);
+
+ STRINGSHARE_LOCK_SMALL();
+ s = _eina_stringshare_small_add(str, slen);
+ STRINGSHARE_UNLOCK_SMALL();
+
+ return s;
+ }
+
+ return eina_share_common_ref(stringshare_share, str);
}
/**
@@ -914,26 +907,27 @@ eina_stringshare_ref(const char *str)
* things will happen, likely a segmentation fault. If in doubt, try
* strlen().
*/
-EAPI int
-eina_stringshare_strlen(const char *str)
+EAPI int eina_stringshare_strlen(const char *str)
{
- int len;
- /* special cases */
- if (str[0] == '\0')
- return 0;
+ int len;
+ /* special cases */
+ if (str[0] == '\0')
+ return 0;
- if (str[1] == '\0')
- return 1;
+ if (str[1] == '\0')
+ return 1;
- if (str[2] == '\0')
- return 2;
+ if (str[2] == '\0')
+ return 2;
- if (str[3] == '\0')
- return 3;
+ if (str[3] == '\0')
+ return 3;
- len = eina_share_common_length(stringshare_share, (const char *)str);
- len = (len > 0) ? len / (int)sizeof(char) : -1;
- return len;
+ len =
+ eina_share_common_length(stringshare_share,
+ (const char *) str);
+ len = (len > 0) ? len / (int) sizeof(char) : -1;
+ return len;
}
/**
@@ -942,15 +936,13 @@ eina_stringshare_strlen(const char *str)
* This function dumps all strings in the share_common to stdout with a
* DDD: prefix per line and a memory usage summary.
*/
-EAPI void
-eina_stringshare_dump(void)
+EAPI void eina_stringshare_dump(void)
{
- eina_share_common_dump(stringshare_share,
- _eina_stringshare_small_dump,
- sizeof(_eina_stringshare_single));
+ eina_share_common_dump(stringshare_share,
+ _eina_stringshare_small_dump,
+ sizeof(_eina_stringshare_single));
}
/**
* @}
*/
-
diff --git a/tests/suite/ecore/src/lib/eina_tiler.c b/tests/suite/ecore/src/lib/eina_tiler.c
index 2d263b7a15..5d31aba6cf 100644
--- a/tests/suite/ecore/src/lib/eina_tiler.c
+++ b/tests/suite/ecore/src/lib/eina_tiler.c
@@ -23,7 +23,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdlib.h>
@@ -44,45 +44,39 @@ typedef struct list list_t;
typedef struct rect rect_t;
typedef struct rect_node rect_node_t;
-struct list_node
-{
- struct list_node *next;
+struct list_node {
+ struct list_node *next;
};
-struct list
-{
- struct list_node *head;
- struct list_node *tail;
+struct list {
+ struct list_node *head;
+ struct list_node *tail;
};
-struct rect
-{
- short right;
- short bottom;
- short left;
- short top;
- short width;
- short height;
- int area;
+struct rect {
+ short right;
+ short bottom;
+ short left;
+ short top;
+ short width;
+ short height;
+ int area;
};
-struct rect_node
-{
- struct list_node _lst;
- struct rect rect;
+struct rect_node {
+ struct list_node _lst;
+ struct rect rect;
};
-typedef struct splitter
-{
- Eina_Bool need_merge;
- list_t rects;
+typedef struct splitter {
+ Eina_Bool need_merge;
+ list_t rects;
} splitter_t;
-typedef struct list_node_pool
-{
- list_node_t *node;
- int len;
- int max;
+typedef struct list_node_pool {
+ list_node_t *node;
+ int len;
+ int max;
} list_node_pool_t;
@@ -91,23 +85,18 @@ static const list_t list_zeroed = { NULL, NULL };
static list_node_pool_t list_node_pool = { NULL, 0, 1024 };
-typedef struct _Eina_Iterator_Tiler
-{
- Eina_Iterator iterator;
- const Eina_Tiler *tiler;
- list_node_t *curr;
- EINA_MAGIC
-} Eina_Iterator_Tiler;
+typedef struct _Eina_Iterator_Tiler {
+ Eina_Iterator iterator;
+ const Eina_Tiler *tiler;
+ list_node_t *curr;
+ EINA_MAGIC} Eina_Iterator_Tiler;
-struct _Eina_Tiler
-{
- struct
- {
- int w, h;
- } tile;
- Eina_Rectangle area;
- EINA_MAGIC
- splitter_t splitter;
+struct _Eina_Tiler {
+ struct {
+ int w, h;
+ } tile;
+ Eina_Rectangle area;
+ EINA_MAGIC splitter_t splitter;
};
#define EINA_MAGIC_CHECK_TILER(d, ...) \
@@ -130,976 +119,919 @@ struct _Eina_Tiler
} while(0)
/* The Splitter algorithm */
-static inline void rect_init(rect_t *r, int x, int y, int w, int h)
+static inline void rect_init(rect_t * r, int x, int y, int w, int h)
{
- r->area = w * h;
+ r->area = w * h;
- r->left = x;
- r->top = y;
+ r->left = x;
+ r->top = y;
- r->right = x + w;
- r->bottom = y + h;
+ r->right = x + w;
+ r->bottom = y + h;
- r->width = w;
- r->height = h;
+ r->width = w;
+ r->height = h;
}
-static inline list_node_t *
-rect_list_node_pool_get(void)
+static inline list_node_t *rect_list_node_pool_get(void)
{
- if (list_node_pool.node)
- {
- list_node_t *node;
-
- node = list_node_pool.node;
- list_node_pool.node = node->next;
- list_node_pool.len--;
-
- return node;
- }
- else
- return malloc(sizeof(rect_node_t));
+ if (list_node_pool.node) {
+ list_node_t *node;
+
+ node = list_node_pool.node;
+ list_node_pool.node = node->next;
+ list_node_pool.len--;
+
+ return node;
+ } else
+ return malloc(sizeof(rect_node_t));
}
-static inline void rect_list_concat(list_t *rects, list_t *other)
+static inline void rect_list_concat(list_t * rects, list_t * other)
{
- if (!other->head)
- return;
-
- if (rects->tail)
- {
- rects->tail->next = other->head;
- rects->tail = other->tail;
- }
- else
- {
- rects->head = other->head;
- rects->tail = other->tail;
- }
-
- *other = list_zeroed;
+ if (!other->head)
+ return;
+
+ if (rects->tail) {
+ rects->tail->next = other->head;
+ rects->tail = other->tail;
+ } else {
+ rects->head = other->head;
+ rects->tail = other->tail;
+ }
+
+ *other = list_zeroed;
}
-static inline void rect_list_append_node(list_t *rects, list_node_t *node)
+static inline void rect_list_append_node(list_t * rects,
+ list_node_t * node)
{
- if (rects->tail)
- {
- rects->tail->next = node;
- rects->tail = node;
- }
- else
- {
- rects->head = node;
- rects->tail = node;
- }
+ if (rects->tail) {
+ rects->tail->next = node;
+ rects->tail = node;
+ } else {
+ rects->head = node;
+ rects->tail = node;
+ }
}
-static inline void rect_list_append(list_t *rects, const rect_t r)
+static inline void rect_list_append(list_t * rects, const rect_t r)
{
- rect_node_t *rect_node;
+ rect_node_t *rect_node;
- rect_node = (rect_node_t *)rect_list_node_pool_get();
- rect_node->rect = r;
- rect_node->_lst = list_node_zeroed;
+ rect_node = (rect_node_t *) rect_list_node_pool_get();
+ rect_node->rect = r;
+ rect_node->_lst = list_node_zeroed;
- rect_list_append_node(rects, (list_node_t *)rect_node);
+ rect_list_append_node(rects, (list_node_t *) rect_node);
}
-static inline void rect_list_append_xywh(list_t *rects,
- int x,
- int y,
- int w,
- int h)
+static inline void rect_list_append_xywh(list_t * rects,
+ int x, int y, int w, int h)
{
- rect_t r;
+ rect_t r;
- rect_init(&r, x, y, w, h);
- rect_list_append(rects, r);
+ rect_init(&r, x, y, w, h);
+ rect_list_append(rects, r);
}
static inline void _calc_intra_rect_area(const rect_t a, const rect_t b,
- int *width, int *height)
+ int *width, int *height)
{
- int max_left, min_right, max_top, min_bottom;
+ int max_left, min_right, max_top, min_bottom;
- if (a.left < b.left)
- max_left = b.left;
- else
- max_left = a.left;
+ if (a.left < b.left)
+ max_left = b.left;
+ else
+ max_left = a.left;
- if (a.right < b.right)
- min_right = a.right;
- else
- min_right = b.right;
+ if (a.right < b.right)
+ min_right = a.right;
+ else
+ min_right = b.right;
- *width = min_right - max_left;
+ *width = min_right - max_left;
- if (a.top < b.top)
- max_top = b.top;
- else
- max_top = a.top;
+ if (a.top < b.top)
+ max_top = b.top;
+ else
+ max_top = a.top;
- if (a.bottom < b.bottom)
- min_bottom = a.bottom;
- else
- min_bottom = b.bottom;
+ if (a.bottom < b.bottom)
+ min_bottom = a.bottom;
+ else
+ min_bottom = b.bottom;
- *height = min_bottom - max_top;
+ *height = min_bottom - max_top;
}
-static inline void _split_strict(list_t *dirty, const rect_t current, rect_t r)
+static inline void _split_strict(list_t * dirty, const rect_t current,
+ rect_t r)
{
- int h_1, h_2, w_1, w_2;
-
- h_1 = current.top - r.top;
- h_2 = r.bottom - current.bottom;
- w_1 = current.left - r.left;
- w_2 = r.right - current.right;
-
- if (h_1 > 0)
- {
- /* .--.r (b) .---.r2
- * | | | |
- * .-------.cur (a) .---.r '---'
- * | | | | -> | | +
- * | `--' | `---'
- * `-------'
- */
- rect_list_append_xywh(dirty, r.left, r.top, r.width, h_1);
- r.height -= h_1;
- r.top = current.top;
- }
-
- if (h_2 > 0)
- {
- /* .-------.cur (a)
- * | .---. | .---.r
- * | | | | -> | |
- * `-------' `---' + .---.r2
- * | | | |
- * `---'r (b) `---'
- */
- rect_list_append_xywh(dirty, r.left, current.bottom, r.width,
- h_2);
- r.height -= h_2;
- }
-
- if (w_1 > 0)
- /* (b) r .----.cur (a)
- * .--|-. | .--.r2 .-.r
- * | | | | -> | | + | |
- * `--|-' | `--' `-'
- * `----'
- */
- rect_list_append_xywh(dirty, r.left, r.top, w_1, r.height); /* not necessary to keep these, r (b) will be destroyed */
-
- /* r.width -= w_1; */
- /* r.left = current.left; */
-
- if (w_2 > 0)
- /* .----.cur (a)
- * | |
- * | .-|--.r (b) .-.r .--.r2
- * | | | | -> | | + | |
- * | `-|--' `-' `--'
- * `----'
- */
- rect_list_append_xywh(dirty, current.right, r.top, w_2,
- r.height); /* not necessary to keep this, r (b) will be destroyed */
-
- /* r.width -= w_2; */
+ int h_1, h_2, w_1, w_2;
+
+ h_1 = current.top - r.top;
+ h_2 = r.bottom - current.bottom;
+ w_1 = current.left - r.left;
+ w_2 = r.right - current.right;
+
+ if (h_1 > 0) {
+ /* .--.r (b) .---.r2
+ * | | | |
+ * .-------.cur (a) .---.r '---'
+ * | | | | -> | | +
+ * | `--' | `---'
+ * `-------'
+ */
+ rect_list_append_xywh(dirty, r.left, r.top, r.width, h_1);
+ r.height -= h_1;
+ r.top = current.top;
+ }
+
+ if (h_2 > 0) {
+ /* .-------.cur (a)
+ * | .---. | .---.r
+ * | | | | -> | |
+ * `-------' `---' + .---.r2
+ * | | | |
+ * `---'r (b) `---'
+ */
+ rect_list_append_xywh(dirty, r.left, current.bottom,
+ r.width, h_2);
+ r.height -= h_2;
+ }
+
+ if (w_1 > 0)
+ /* (b) r .----.cur (a)
+ * .--|-. | .--.r2 .-.r
+ * | | | | -> | | + | |
+ * `--|-' | `--' `-'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, r.left, r.top, w_1, r.height); /* not necessary to keep these, r (b) will be destroyed */
+
+ /* r.width -= w_1; */
+ /* r.left = current.left; */
+
+ if (w_2 > 0)
+ /* .----.cur (a)
+ * | |
+ * | .-|--.r (b) .-.r .--.r2
+ * | | | | -> | | + | |
+ * | `-|--' `-' `--'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, current.right, r.top, w_2, r.height); /* not necessary to keep this, r (b) will be destroyed */
+
+ /* r.width -= w_2; */
}
-static inline void _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
- rect_t *intra, rect_t *outer)
+static inline void _calc_intra_outer_rect_area(const rect_t a,
+ const rect_t b,
+ rect_t * intra,
+ rect_t * outer)
{
- int min_left, max_left, min_right, max_right;
- int min_top, max_top, min_bottom, max_bottom;
-
- if (a.left < b.left)
- {
- max_left = b.left;
- min_left = a.left;
- }
- else
- {
- max_left = a.left;
- min_left = b.left;
- }
-
- if (a.right < b.right)
- {
- min_right = a.right;
- max_right = b.right;
- }
- else
- {
- min_right = b.right;
- max_right = a.right;
- }
-
- intra->left = max_left;
- intra->right = min_right;
- intra->width = min_right - max_left;
-
- outer->left = min_left;
- outer->right = max_right;
- outer->width = max_right - min_left;
-
- if (a.top < b.top)
- {
- max_top = b.top;
- min_top = a.top;
- }
- else
- {
- max_top = a.top;
- min_top = b.top;
- }
-
- if (a.bottom < b.bottom)
- {
- min_bottom = a.bottom;
- max_bottom = b.bottom;
- }
- else
- {
- min_bottom = b.bottom;
- max_bottom = a.bottom;
- }
-
- intra->top = max_top;
- intra->bottom = min_bottom;
- intra->height = min_bottom - max_top;
- if ((intra->width > 0) && (intra->height > 0))
- intra->area = intra->width * intra->height;
- else
- intra->area = 0;
-
- outer->top = min_top;
- outer->bottom = max_bottom;
- outer->height = max_bottom - min_top;
- outer->area = outer->width * outer->height;
+ int min_left, max_left, min_right, max_right;
+ int min_top, max_top, min_bottom, max_bottom;
+
+ if (a.left < b.left) {
+ max_left = b.left;
+ min_left = a.left;
+ } else {
+ max_left = a.left;
+ min_left = b.left;
+ }
+
+ if (a.right < b.right) {
+ min_right = a.right;
+ max_right = b.right;
+ } else {
+ min_right = b.right;
+ max_right = a.right;
+ }
+
+ intra->left = max_left;
+ intra->right = min_right;
+ intra->width = min_right - max_left;
+
+ outer->left = min_left;
+ outer->right = max_right;
+ outer->width = max_right - min_left;
+
+ if (a.top < b.top) {
+ max_top = b.top;
+ min_top = a.top;
+ } else {
+ max_top = a.top;
+ min_top = b.top;
+ }
+
+ if (a.bottom < b.bottom) {
+ min_bottom = a.bottom;
+ max_bottom = b.bottom;
+ } else {
+ min_bottom = b.bottom;
+ max_bottom = a.bottom;
+ }
+
+ intra->top = max_top;
+ intra->bottom = min_bottom;
+ intra->height = min_bottom - max_top;
+ if ((intra->width > 0) && (intra->height > 0))
+ intra->area = intra->width * intra->height;
+ else
+ intra->area = 0;
+
+ outer->top = min_top;
+ outer->bottom = max_bottom;
+ outer->height = max_bottom - min_top;
+ outer->area = outer->width * outer->height;
}
-enum
-{
- SPLIT_FUZZY_ACTION_NONE,
- SPLIT_FUZZY_ACTION_SPLIT,
- SPLIT_FUZZY_ACTION_MERGE
+enum {
+ SPLIT_FUZZY_ACTION_NONE,
+ SPLIT_FUZZY_ACTION_SPLIT,
+ SPLIT_FUZZY_ACTION_MERGE
};
-static inline int _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
+static inline int _split_fuzzy(list_t * dirty, const rect_t a, rect_t * b)
{
- int h_1, h_2, w_1, w_2, action;
-
- h_1 = a.top - b->top;
- h_2 = b->bottom - a.bottom;
- w_1 = a.left - b->left;
- w_2 = b->right - a.right;
-
- action = SPLIT_FUZZY_ACTION_NONE;
-
- if (h_1 > 0)
- {
- /* .--.r (b) .---.r2
- * | | | |
- * .-------.cur (a) .---.r '---'
- * | | | | -> | | +
- * | `--' | `---'
- * `-------'
- */
- rect_list_append_xywh(dirty, b->left, b->top, b->width, h_1);
- b->height -= h_1;
- b->top = a.top;
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- if (h_2 > 0)
- {
- /* .-------.cur (a)
- * | .---. | .---.r
- * | | | | -> | |
- * `-------' `---' + .---.r2
- * | | | |
- * `---'r (b) `---'
- */
- rect_list_append_xywh(dirty, b->left, a.bottom, b->width, h_2);
- b->height -= h_2;
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height))
- return SPLIT_FUZZY_ACTION_MERGE;
-
- if (w_1 > 0)
- {
- /* (b) r .----.cur (a)
- * .--|-. | .--.r2 .-.r
- * | | | | -> | | + | |
- * `--|-' | `--' `-'
- * `----'
- */
- rect_list_append_xywh(dirty, b->left, b->top, w_1, b->height);
- /* not necessary to keep these, r (b) will be destroyed */
- /* b->width -= w_1; */
- /* b->left = a.left; */
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- if (w_2 > 0)
- {
- /* .----.cur (a)
- * | |
- * | .-|--.r (b) .-.r .--.r2
- * | | | | -> | | + | |
- * | `-|--' `-' `--'
- * `----'
- */
- rect_list_append_xywh(dirty, a.right, b->top, w_2, b->height);
- /* not necessary to keep these, r (b) will be destroyed */
- /* b->width -= w_2; */
- action = SPLIT_FUZZY_ACTION_SPLIT;
- }
-
- return action;
+ int h_1, h_2, w_1, w_2, action;
+
+ h_1 = a.top - b->top;
+ h_2 = b->bottom - a.bottom;
+ w_1 = a.left - b->left;
+ w_2 = b->right - a.right;
+
+ action = SPLIT_FUZZY_ACTION_NONE;
+
+ if (h_1 > 0) {
+ /* .--.r (b) .---.r2
+ * | | | |
+ * .-------.cur (a) .---.r '---'
+ * | | | | -> | | +
+ * | `--' | `---'
+ * `-------'
+ */
+ rect_list_append_xywh(dirty, b->left, b->top, b->width,
+ h_1);
+ b->height -= h_1;
+ b->top = a.top;
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ if (h_2 > 0) {
+ /* .-------.cur (a)
+ * | .---. | .---.r
+ * | | | | -> | |
+ * `-------' `---' + .---.r2
+ * | | | |
+ * `---'r (b) `---'
+ */
+ rect_list_append_xywh(dirty, b->left, a.bottom, b->width,
+ h_2);
+ b->height -= h_2;
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height))
+ return SPLIT_FUZZY_ACTION_MERGE;
+
+ if (w_1 > 0) {
+ /* (b) r .----.cur (a)
+ * .--|-. | .--.r2 .-.r
+ * | | | | -> | | + | |
+ * `--|-' | `--' `-'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, b->left, b->top, w_1,
+ b->height);
+ /* not necessary to keep these, r (b) will be destroyed */
+ /* b->width -= w_1; */
+ /* b->left = a.left; */
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ if (w_2 > 0) {
+ /* .----.cur (a)
+ * | |
+ * | .-|--.r (b) .-.r .--.r2
+ * | | | | -> | | + | |
+ * | `-|--' `-' `--'
+ * `----'
+ */
+ rect_list_append_xywh(dirty, a.right, b->top, w_2,
+ b->height);
+ /* not necessary to keep these, r (b) will be destroyed */
+ /* b->width -= w_2; */
+ action = SPLIT_FUZZY_ACTION_SPLIT;
+ }
+
+ return action;
}
#if 0
static void rect_list_node_pool_set_max(int max)
{
- int diff;
+ int diff;
- diff = list_node_pool.len - max;
- for (; diff > 0 && list_node_pool.node != NULL; diff--)
- {
- list_node_t *node;
+ diff = list_node_pool.len - max;
+ for (; diff > 0 && list_node_pool.node != NULL; diff--) {
+ list_node_t *node;
- node = list_node_pool.node;
- list_node_pool.node = node->next;
- list_node_pool.len--;
+ node = list_node_pool.node;
+ list_node_pool.node = node->next;
+ list_node_pool.len--;
- free(node);
- }
+ free(node);
+ }
- list_node_pool.max = max;
+ list_node_pool.max = max;
}
#endif
static void rect_list_node_pool_flush(void)
{
- while (list_node_pool.node)
- {
- list_node_t *node;
+ while (list_node_pool.node) {
+ list_node_t *node;
- node = list_node_pool.node;
- list_node_pool.node = node->next;
- list_node_pool.len--;
+ node = list_node_pool.node;
+ list_node_pool.node = node->next;
+ list_node_pool.len--;
- free(node);
- }
+ free(node);
+ }
}
-static inline void rect_list_node_pool_put(list_node_t *node)
+static inline void rect_list_node_pool_put(list_node_t * node)
{
- if (list_node_pool.len < list_node_pool.max)
- {
- node->next = list_node_pool.node;
- list_node_pool.node = node;
- list_node_pool.len++;
- }
- else
- free(node);
+ if (list_node_pool.len < list_node_pool.max) {
+ node->next = list_node_pool.node;
+ list_node_pool.node = node;
+ list_node_pool.len++;
+ } else
+ free(node);
}
#if 0
static void rect_print(const rect_t r)
{
- printf("<rect(%d, %d, %d, %d)>", r.left, r.top, r.width, r.height);
+ printf("<rect(%d, %d, %d, %d)>", r.left, r.top, r.width, r.height);
}
static void rect_list_print(const list_t rects)
{
- list_node_t *node;
- int len;
-
- len = 0;
- for (node = rects.head; node != NULL; node = node->next)
- len++;
-
- printf("[");
- for (node = rects.head; node != NULL; node = node->next)
- {
- rect_print(((rect_node_t *)node)->rect);
- if (node->next)
- {
- putchar(',');
- if (len < 4)
- putchar(' ');
- else
- {
- putchar('\n');
- putchar(' ');
- }
- }
- }
- printf("]\n");
+ list_node_t *node;
+ int len;
+
+ len = 0;
+ for (node = rects.head; node != NULL; node = node->next)
+ len++;
+
+ printf("[");
+ for (node = rects.head; node != NULL; node = node->next) {
+ rect_print(((rect_node_t *) node)->rect);
+ if (node->next) {
+ putchar(',');
+ if (len < 4)
+ putchar(' ');
+ else {
+ putchar('\n');
+ putchar(' ');
+ }
+ }
+ }
+ printf("]\n");
}
#endif
-static inline list_node_t *
-rect_list_unlink_next(list_t *rects, list_node_t *parent_node)
+static inline list_node_t *rect_list_unlink_next(list_t * rects,
+ list_node_t * parent_node)
{
- list_node_t *node;
-
- if (parent_node)
- {
- node = parent_node->next;
- parent_node->next = node->next;
- }
- else
- {
- node = rects->head;
- rects->head = node->next;
- }
-
- if (rects->tail == node)
- rects->tail = parent_node;
-
- *node = list_node_zeroed;
- return node;
+ list_node_t *node;
+
+ if (parent_node) {
+ node = parent_node->next;
+ parent_node->next = node->next;
+ } else {
+ node = rects->head;
+ rects->head = node->next;
+ }
+
+ if (rects->tail == node)
+ rects->tail = parent_node;
+
+ *node = list_node_zeroed;
+ return node;
}
-static inline void rect_list_del_next(list_t *rects, list_node_t *parent_node)
+static inline void rect_list_del_next(list_t * rects,
+ list_node_t * parent_node)
{
- list_node_t *node;
+ list_node_t *node;
- node = rect_list_unlink_next(rects, parent_node);
- rect_list_node_pool_put(node);
+ node = rect_list_unlink_next(rects, parent_node);
+ rect_list_node_pool_put(node);
}
-static void rect_list_clear(list_t *rects)
+static void rect_list_clear(list_t * rects)
{
- list_node_t *node;
-
- node = rects->head;
- while (node)
- {
- list_node_t *aux;
-
- aux = node->next;
- rect_list_node_pool_put(node);
- node = aux;
- }
- *rects = list_zeroed;
+ list_node_t *node;
+
+ node = rects->head;
+ while (node) {
+ list_node_t *aux;
+
+ aux = node->next;
+ rect_list_node_pool_put(node);
+ node = aux;
+ }
+ *rects = list_zeroed;
}
-static void rect_list_del_split_strict(list_t *rects, const rect_t del_r)
+static void rect_list_del_split_strict(list_t * rects, const rect_t del_r)
{
- list_t modified = list_zeroed;
- list_node_t *cur_node, *prev_node;
-
- prev_node = NULL;
- cur_node = rects->head;
- while (cur_node)
- {
- int intra_width, intra_height;
- rect_t current;
-
- current = ((rect_node_t *)cur_node)->rect;
-
- _calc_intra_rect_area(del_r, current, &intra_width,
- &intra_height);
- if ((intra_width <= 0) || (intra_height <= 0))
- {
- /* .---.current .---.del_r
- * | | | |
- * `---+---.del_r `---+---.current
- * | | | |
- * `---' `---'
- * no intersection, nothing to do
- */
- prev_node = cur_node;
- cur_node = cur_node->next;
- }
- else if ((intra_width == current.width) && (intra_height
- == current.height))
- {
- /* .-------.del_r
- * | .---. |
- * | | | |
- * | `---'current
- * `-------'
- * current is contained, remove from rects
- */
- cur_node = cur_node->next;
- rect_list_del_next(rects, prev_node);
- }
- else
- {
- _split_strict(&modified, del_r, current);
- cur_node = cur_node->next;
- rect_list_del_next(rects, prev_node);
- }
- }
-
- rect_list_concat(rects, &modified);
+ list_t modified = list_zeroed;
+ list_node_t *cur_node, *prev_node;
+
+ prev_node = NULL;
+ cur_node = rects->head;
+ while (cur_node) {
+ int intra_width, intra_height;
+ rect_t current;
+
+ current = ((rect_node_t *) cur_node)->rect;
+
+ _calc_intra_rect_area(del_r, current, &intra_width,
+ &intra_height);
+ if ((intra_width <= 0) || (intra_height <= 0)) {
+ /* .---.current .---.del_r
+ * | | | |
+ * `---+---.del_r `---+---.current
+ * | | | |
+ * `---' `---'
+ * no intersection, nothing to do
+ */
+ prev_node = cur_node;
+ cur_node = cur_node->next;
+ } else if ((intra_width == current.width) && (intra_height
+ ==
+ current.
+ height)) {
+ /* .-------.del_r
+ * | .---. |
+ * | | | |
+ * | `---'current
+ * `-------'
+ * current is contained, remove from rects
+ */
+ cur_node = cur_node->next;
+ rect_list_del_next(rects, prev_node);
+ } else {
+ _split_strict(&modified, del_r, current);
+ cur_node = cur_node->next;
+ rect_list_del_next(rects, prev_node);
+ }
+ }
+
+ rect_list_concat(rects, &modified);
}
#if 0
-static void rect_list_add_split_strict(list_t *rects, list_node_t *node)
+static void rect_list_add_split_strict(list_t * rects, list_node_t * node)
{
- list_t dirty = list_zeroed;
- list_t new_dirty = list_zeroed;
- list_node_t *cur_node;
-
- if (!rects->head)
- {
- rect_list_append_node(rects, node);
- return;
- }
-
- rect_list_append_node(&dirty, node);
-
- cur_node = rects->head;
- while (dirty.head)
- {
- rect_t current;
-
- if (!cur_node)
- {
- rect_list_concat(rects, &dirty);
- break;
- }
-
- current = ((rect_node_t *)cur_node)->rect;
-
- while (dirty.head)
- {
- int intra_width, intra_height;
- rect_t r;
-
- r = ((rect_node_t *)dirty.head)->rect;
- _calc_intra_rect_area(r, current, &intra_width,
- &intra_height);
- if ((intra_width == r.width) && (intra_height
- == r.height))
- /* .-------.cur
- * | .---.r|
- * | | | |
- * | `---' |
- * `-------'
- */
- rect_list_del_next(&dirty, NULL);
- else if ((intra_width <= 0) || (intra_height <= 0))
- {
- /* .---.cur .---.r
- * | | | |
- * `---+---.r `---+---.cur
- * | | | |
- * `---' `---'
- */
- list_node_t *tmp;
- tmp = rect_list_unlink_next(&dirty, NULL);
- rect_list_append_node(&new_dirty, tmp);
- }
- else
- {
- _split_strict(&new_dirty, current, r);
- rect_list_del_next(&dirty, NULL);
- }
- }
- dirty = new_dirty;
- new_dirty = list_zeroed;
-
- cur_node = cur_node->next;
- }
+ list_t dirty = list_zeroed;
+ list_t new_dirty = list_zeroed;
+ list_node_t *cur_node;
+
+ if (!rects->head) {
+ rect_list_append_node(rects, node);
+ return;
+ }
+
+ rect_list_append_node(&dirty, node);
+
+ cur_node = rects->head;
+ while (dirty.head) {
+ rect_t current;
+
+ if (!cur_node) {
+ rect_list_concat(rects, &dirty);
+ break;
+ }
+
+ current = ((rect_node_t *) cur_node)->rect;
+
+ while (dirty.head) {
+ int intra_width, intra_height;
+ rect_t r;
+
+ r = ((rect_node_t *) dirty.head)->rect;
+ _calc_intra_rect_area(r, current, &intra_width,
+ &intra_height);
+ if ((intra_width == r.width) && (intra_height
+ == r.height))
+ /* .-------.cur
+ * | .---.r|
+ * | | | |
+ * | `---' |
+ * `-------'
+ */
+ rect_list_del_next(&dirty, NULL);
+ else if ((intra_width <= 0) || (intra_height <= 0)) {
+ /* .---.cur .---.r
+ * | | | |
+ * `---+---.r `---+---.cur
+ * | | | |
+ * `---' `---'
+ */
+ list_node_t *tmp;
+ tmp = rect_list_unlink_next(&dirty, NULL);
+ rect_list_append_node(&new_dirty, tmp);
+ } else {
+ _split_strict(&new_dirty, current, r);
+ rect_list_del_next(&dirty, NULL);
+ }
+ }
+ dirty = new_dirty;
+ new_dirty = list_zeroed;
+
+ cur_node = cur_node->next;
+ }
}
#endif
-static list_node_t *
-rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error)
+static list_node_t *rect_list_add_split_fuzzy(list_t * rects,
+ list_node_t * node,
+ int accepted_error)
{
- list_t dirty = list_zeroed;
- list_node_t *old_last;
-
- old_last = rects->tail;
-
- if (!rects->head)
- {
- rect_list_append_node(rects, node);
- return old_last;
- }
-
- rect_list_append_node(&dirty, node);
- while (dirty.head)
- {
- list_node_t *d_node, *cur_node, *prev_cur_node;
- int keep_dirty;
- rect_t r;
-
- d_node = rect_list_unlink_next(&dirty, NULL);
- r = ((rect_node_t *)d_node)->rect;
-
- prev_cur_node = NULL;
- cur_node = rects->head;
- keep_dirty = 1;
- while (cur_node)
- {
- int area, action;
- rect_t current, intra, outer;
-
- current = ((rect_node_t *)cur_node)->rect;
-
- _calc_intra_outer_rect_area(r, current, &intra, &outer);
- area = current.area + r.area - intra.area;
-
- if ((intra.width == r.width) && (intra.height
- == r.height))
- {
- /* .-------.cur
- * | .---.r|
- * | | | |
- * | `---' |
- * `-------'
- */
- keep_dirty = 0;
- break;
- }
- else if ((intra.width == current.width)
- && (intra.height == current.height))
- {
- /* .-------.r
- * | .---.cur
- * | | | |
- * | `---' |
- * `-------'
- */
- if (old_last == cur_node)
- old_last = prev_cur_node;
-
- cur_node = cur_node->next;
- rect_list_del_next(rects, prev_cur_node);
- }
- else if ((outer.area - area) <= accepted_error)
- {
- /* .-----------. bounding box (outer)
- * |.---. .---.|
- * ||cur| |r ||
- * || | | ||
- * |`---' `---'|
- * `-----------'
- * merge them, remove both and add merged
- */
- rect_node_t *n;
-
- if (old_last == cur_node)
- old_last = prev_cur_node;
-
- n = (rect_node_t *)rect_list_unlink_next(
- rects, prev_cur_node);
- n->rect = outer;
- rect_list_append_node(&dirty, (list_node_t *)n);
-
- keep_dirty = 0;
- break;
- }
- else if (intra.area <= accepted_error)
- {
- /* .---.cur .---.r
- * | | | |
- * `---+---.r `---+---.cur
- * | | | |
- * `---' `---'
- * no split, no merge
- */
- prev_cur_node = cur_node;
- cur_node = cur_node->next;
- }
- else
- {
- /* split is required */
- action = _split_fuzzy(&dirty, current, &r);
- if (action == SPLIT_FUZZY_ACTION_MERGE)
- {
+ list_t dirty = list_zeroed;
+ list_node_t *old_last;
+
+ old_last = rects->tail;
+
+ if (!rects->head) {
+ rect_list_append_node(rects, node);
+ return old_last;
+ }
+
+ rect_list_append_node(&dirty, node);
+ while (dirty.head) {
+ list_node_t *d_node, *cur_node, *prev_cur_node;
+ int keep_dirty;
+ rect_t r;
+
+ d_node = rect_list_unlink_next(&dirty, NULL);
+ r = ((rect_node_t *) d_node)->rect;
+
+ prev_cur_node = NULL;
+ cur_node = rects->head;
+ keep_dirty = 1;
+ while (cur_node) {
+ int area, action;
+ rect_t current, intra, outer;
+
+ current = ((rect_node_t *) cur_node)->rect;
+
+ _calc_intra_outer_rect_area(r, current, &intra,
+ &outer);
+ area = current.area + r.area - intra.area;
+
+ if ((intra.width == r.width) && (intra.height
+ == r.height)) {
+ /* .-------.cur
+ * | .---.r|
+ * | | | |
+ * | `---' |
+ * `-------'
+ */
+ keep_dirty = 0;
+ break;
+ } else if ((intra.width == current.width)
+ && (intra.height == current.height)) {
+ /* .-------.r
+ * | .---.cur
+ * | | | |
+ * | `---' |
+ * `-------'
+ */
+ if (old_last == cur_node)
+ old_last = prev_cur_node;
+
+ cur_node = cur_node->next;
+ rect_list_del_next(rects, prev_cur_node);
+ } else if ((outer.area - area) <= accepted_error) {
+ /* .-----------. bounding box (outer)
+ * |.---. .---.|
+ * ||cur| |r ||
+ * || | | ||
+ * |`---' `---'|
+ * `-----------'
+ * merge them, remove both and add merged
+ */
+ rect_node_t *n;
+
+ if (old_last == cur_node)
+ old_last = prev_cur_node;
+
+ n = (rect_node_t *)
+ rect_list_unlink_next(rects,
+ prev_cur_node);
+ n->rect = outer;
+ rect_list_append_node(&dirty,
+ (list_node_t *) n);
+
+ keep_dirty = 0;
+ break;
+ } else if (intra.area <= accepted_error) {
+ /* .---.cur .---.r
+ * | | | |
+ * `---+---.r `---+---.cur
+ * | | | |
+ * `---' `---'
+ * no split, no merge
+ */
+ prev_cur_node = cur_node;
+ cur_node = cur_node->next;
+ } else {
+ /* split is required */
+ action = _split_fuzzy(&dirty, current, &r);
+ if (action == SPLIT_FUZZY_ACTION_MERGE) {
/* horizontal merge is possible: remove both, add merged */
- rect_node_t *n;
-
- if (old_last == cur_node)
- old_last = prev_cur_node;
-
- n
- = (rect_node_t *)rect_list_unlink_next(
- rects,
- prev_cur_node);
-
- n->rect.left = outer.left;
- n->rect.width = outer.width;
- n->rect.right = outer.right;
- n->rect.area = outer.width * r.height;
- rect_list_append_node(&dirty,
- (list_node_t *)n);
- }
- else if (action == SPLIT_FUZZY_ACTION_NONE)
- {
+ rect_node_t *n;
+
+ if (old_last == cur_node)
+ old_last = prev_cur_node;
+
+ n = (rect_node_t *)
+ rect_list_unlink_next(rects,
+ prev_cur_node);
+
+ n->rect.left = outer.left;
+ n->rect.width = outer.width;
+ n->rect.right = outer.right;
+ n->rect.area =
+ outer.width * r.height;
+ rect_list_append_node(&dirty,
+ (list_node_t
+ *) n);
+ } else if (action ==
+ SPLIT_FUZZY_ACTION_NONE) {
/*
* this rect check was totally useless,
* should never happen
*/
/* prev_cur_node = cur_node; */
/* cur_node = cur_node->next; */
- printf("Should not get here!\n");
- abort();
- }
-
- keep_dirty = 0;
- break;
- }
- }
- if (EINA_UNLIKELY(keep_dirty))
- rect_list_append_node(rects, d_node);
- else
- rect_list_node_pool_put(d_node);
- }
-
- return old_last;
+ printf("Should not get here!\n");
+ abort();
+ }
+
+ keep_dirty = 0;
+ break;
+ }
+ }
+ if (EINA_UNLIKELY(keep_dirty))
+ rect_list_append_node(rects, d_node);
+ else
+ rect_list_node_pool_put(d_node);
+ }
+
+ return old_last;
}
static inline void _calc_outer_rect_area(const rect_t a, const rect_t b,
- rect_t *outer)
+ rect_t * outer)
{
- int min_left, max_right;
- int min_top, max_bottom;
-
- if (a.left < b.left)
- min_left = a.left;
- else
- min_left = b.left;
-
- if (a.right < b.right)
- max_right = b.right;
- else
- max_right = a.right;
-
- outer->left = min_left;
- outer->right = max_right;
- outer->width = max_right - min_left;
-
- if (a.top < b.top)
- min_top = a.top;
- else
- min_top = b.top;
-
- if (a.bottom < b.bottom)
- max_bottom = b.bottom;
- else
- max_bottom = a.bottom;
-
- outer->top = min_top;
- outer->bottom = max_bottom;
- outer->height = max_bottom - min_top;
-
- outer->area = outer->width * outer->height;
+ int min_left, max_right;
+ int min_top, max_bottom;
+
+ if (a.left < b.left)
+ min_left = a.left;
+ else
+ min_left = b.left;
+
+ if (a.right < b.right)
+ max_right = b.right;
+ else
+ max_right = a.right;
+
+ outer->left = min_left;
+ outer->right = max_right;
+ outer->width = max_right - min_left;
+
+ if (a.top < b.top)
+ min_top = a.top;
+ else
+ min_top = b.top;
+
+ if (a.bottom < b.bottom)
+ max_bottom = b.bottom;
+ else
+ max_bottom = a.bottom;
+
+ outer->top = min_top;
+ outer->bottom = max_bottom;
+ outer->height = max_bottom - min_top;
+
+ outer->area = outer->width * outer->height;
}
-static void rect_list_merge_rects(list_t *rects,
- list_t *to_merge,
- int accepted_error)
+static void rect_list_merge_rects(list_t * rects,
+ list_t * to_merge, int accepted_error)
{
- while (to_merge->head)
- {
- list_node_t *node, *parent_node;
- rect_t r1;
- int merged;
-
- r1 = ((rect_node_t *)to_merge->head)->rect;
-
- merged = 0;
- parent_node = NULL;
- node = rects->head;
- while (node)
- {
- rect_t r2, outer;
- int area;
-
- r2 = ((rect_node_t *)node)->rect;
-
- _calc_outer_rect_area(r1, r2, &outer);
- area = r1.area + r2.area; /* intra area is taken as 0 */
- if (outer.area - area <= accepted_error)
- {
- /*
- * remove both r1 and r2, create r3
- * actually r3 uses r2 instance, saves memory
- */
- rect_node_t *n;
-
- n = (rect_node_t *)rect_list_unlink_next(
- rects, parent_node);
- n->rect = outer;
- rect_list_append_node(to_merge,
- (list_node_t *)n);
- merged = 1;
- break;
- }
-
- parent_node = node;
- node = node->next;
- }
-
- if (!merged)
- {
- list_node_t *n;
- n = rect_list_unlink_next(to_merge, NULL);
- rect_list_append_node(rects, n);
- }
- else
- rect_list_del_next(to_merge, NULL);
- }
+ while (to_merge->head) {
+ list_node_t *node, *parent_node;
+ rect_t r1;
+ int merged;
+
+ r1 = ((rect_node_t *) to_merge->head)->rect;
+
+ merged = 0;
+ parent_node = NULL;
+ node = rects->head;
+ while (node) {
+ rect_t r2, outer;
+ int area;
+
+ r2 = ((rect_node_t *) node)->rect;
+
+ _calc_outer_rect_area(r1, r2, &outer);
+ area = r1.area + r2.area; /* intra area is taken as 0 */
+ if (outer.area - area <= accepted_error) {
+ /*
+ * remove both r1 and r2, create r3
+ * actually r3 uses r2 instance, saves memory
+ */
+ rect_node_t *n;
+
+ n = (rect_node_t *)
+ rect_list_unlink_next(rects,
+ parent_node);
+ n->rect = outer;
+ rect_list_append_node(to_merge,
+ (list_node_t *) n);
+ merged = 1;
+ break;
+ }
+
+ parent_node = node;
+ node = node->next;
+ }
+
+ if (!merged) {
+ list_node_t *n;
+ n = rect_list_unlink_next(to_merge, NULL);
+ rect_list_append_node(rects, n);
+ } else
+ rect_list_del_next(to_merge, NULL);
+ }
}
-static void rect_list_add_split_fuzzy_and_merge(list_t *rects,
- list_node_t *node,
- int split_accepted_error,
- int merge_accepted_error)
+static void rect_list_add_split_fuzzy_and_merge(list_t * rects,
+ list_node_t * node,
+ int split_accepted_error,
+ int merge_accepted_error)
{
- list_node_t *n;
+ list_node_t *n;
- n = rect_list_add_split_fuzzy(rects, node, split_accepted_error);
- if (n && n->next)
- {
- list_t to_merge;
+ n = rect_list_add_split_fuzzy(rects, node, split_accepted_error);
+ if (n && n->next) {
+ list_t to_merge;
- /* split list into 2 segments, already merged and to merge */
- to_merge.head = n->next;
- to_merge.tail = rects->tail;
- rects->tail = n;
- n->next = NULL;
+ /* split list into 2 segments, already merged and to merge */
+ to_merge.head = n->next;
+ to_merge.tail = rects->tail;
+ rects->tail = n;
+ n->next = NULL;
- rect_list_merge_rects(rects, &to_merge, merge_accepted_error);
- }
+ rect_list_merge_rects(rects, &to_merge,
+ merge_accepted_error);
+ }
}
-static inline void _splitter_new(Eina_Tiler *t)
+static inline void _splitter_new(Eina_Tiler * t)
{
- t->splitter.rects = list_zeroed;
- t->splitter.need_merge = EINA_FALSE;
+ t->splitter.rects = list_zeroed;
+ t->splitter.need_merge = EINA_FALSE;
}
-static inline void _splitter_del(Eina_Tiler *t)
+static inline void _splitter_del(Eina_Tiler * t)
{
- rect_list_clear(&t->splitter.rects);
- rect_list_node_pool_flush();
+ rect_list_clear(&t->splitter.rects);
+ rect_list_node_pool_flush();
}
-static inline void _splitter_tile_size_set(Eina_Tiler *t,
- int w __UNUSED__,
- int h __UNUSED__)
+static inline void _splitter_tile_size_set(Eina_Tiler * t,
+ int w __UNUSED__,
+ int h __UNUSED__)
{
- /* TODO are w and h used for something? */
- t->splitter.rects = list_zeroed;
+ /* TODO are w and h used for something? */
+ t->splitter.rects = list_zeroed;
}
-static inline Eina_Bool _splitter_rect_add(Eina_Tiler *t, Eina_Rectangle *rect)
+static inline Eina_Bool _splitter_rect_add(Eina_Tiler * t,
+ Eina_Rectangle * rect)
{
- rect_node_t *rn;
-
- //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
- rect->x >>= 1;
- rect->y >>= 1;
- rect->w += 2;
- rect->w >>= 1;
- rect->h += 2;
- rect->h >>= 1;
-
- rn = (rect_node_t *)rect_list_node_pool_get();
- rn->_lst = list_node_zeroed;
- rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
- //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
- //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
+ rect_node_t *rn;
+
+ //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+ rect->x >>= 1;
+ rect->y >>= 1;
+ rect->w += 2;
+ rect->w >>= 1;
+ rect->h += 2;
+ rect->h >>= 1;
+
+ rn = (rect_node_t *) rect_list_node_pool_get();
+ rn->_lst = list_node_zeroed;
+ rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
+ //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+ //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
#define FUZZ 32
- rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
- (list_node_t *)rn,
- FUZZ * FUZZ,
- FUZZ * FUZZ);
- return EINA_TRUE;
+ rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
+ (list_node_t *) rn,
+ FUZZ * FUZZ, FUZZ * FUZZ);
+ return EINA_TRUE;
}
-static inline void _splitter_rect_del(Eina_Tiler *t, Eina_Rectangle *rect)
+static inline void _splitter_rect_del(Eina_Tiler * t,
+ Eina_Rectangle * rect)
{
- rect_t r;
+ rect_t r;
- if (!t->splitter.rects.head)
- return;
+ if (!t->splitter.rects.head)
+ return;
- rect->x += 1;
- rect->y += 1;
- rect->x >>= 1;
- rect->y >>= 1;
- rect->w -= 1;
- rect->w >>= 1;
- rect->h -= 1;
- rect->h >>= 1;
+ rect->x += 1;
+ rect->y += 1;
+ rect->x >>= 1;
+ rect->y >>= 1;
+ rect->w -= 1;
+ rect->w >>= 1;
+ rect->h -= 1;
+ rect->h >>= 1;
- if ((rect->w <= 0) || (rect->h <= 0))
- return;
+ if ((rect->w <= 0) || (rect->h <= 0))
+ return;
- rect_init(&r, rect->x, rect->y, rect->w, rect->h);
- //fprintf(stderr, "ACCOUNTING: del_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+ rect_init(&r, rect->x, rect->y, rect->w, rect->h);
+ //fprintf(stderr, "ACCOUNTING: del_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
- rect_list_del_split_strict(&t->splitter.rects, r);
- t->splitter.need_merge = EINA_TRUE;
- return;
+ rect_list_del_split_strict(&t->splitter.rects, r);
+ t->splitter.need_merge = EINA_TRUE;
+ return;
}
-static inline void _splitter_clear(Eina_Tiler *t)
+static inline void _splitter_clear(Eina_Tiler * t)
{
- rect_list_clear(&t->splitter.rects);
- t->splitter.need_merge = EINA_FALSE;
+ rect_list_clear(&t->splitter.rects);
+ t->splitter.need_merge = EINA_FALSE;
}
+
/* end of splitter algorithm */
-static Eina_Bool _iterator_next(Eina_Iterator_Tiler *it, void **data)
+static Eina_Bool _iterator_next(Eina_Iterator_Tiler * it, void **data)
{
- Eina_Rectangle *rect = (Eina_Rectangle *)data;
- list_node_t *n;
+ Eina_Rectangle *rect = (Eina_Rectangle *) data;
+ list_node_t *n;
- for (n = it->curr; n; n = n->next)
- {
- rect_t cur;
+ for (n = it->curr; n; n = n->next) {
+ rect_t cur;
- cur = ((rect_node_t *)n)->rect;
+ cur = ((rect_node_t *) n)->rect;
- rect->x = cur.left << 1;
- rect->y = cur.top << 1;
- rect->w = cur.width << 1;
- rect->h = cur.height << 1;
+ rect->x = cur.left << 1;
+ rect->y = cur.top << 1;
+ rect->w = cur.width << 1;
+ rect->h = cur.height << 1;
- if (eina_rectangle_intersection(rect, &it->tiler->area) == EINA_FALSE)
- continue;
+ if (eina_rectangle_intersection(rect, &it->tiler->area) ==
+ EINA_FALSE)
+ continue;
- if ((rect->w <= 0) || (rect->h <= 0))
- continue;
+ if ((rect->w <= 0) || (rect->h <= 0))
+ continue;
- it->curr = n->next;
- return EINA_TRUE;
- }
- return EINA_FALSE;
+ it->curr = n->next;
+ return EINA_TRUE;
+ }
+ return EINA_FALSE;
}
-static void *_iterator_get_container(Eina_Iterator_Tiler *it)
+static void *_iterator_get_container(Eina_Iterator_Tiler * it)
{
- EINA_MAGIC_CHECK_TILER_ITERATOR(it, NULL);
- return (void *)it->tiler;
+ EINA_MAGIC_CHECK_TILER_ITERATOR(it, NULL);
+ return (void *) it->tiler;
}
-static void _iterator_free(Eina_Iterator_Tiler *it)
+static void _iterator_free(Eina_Iterator_Tiler * it)
{
- EINA_MAGIC_CHECK_TILER_ITERATOR(it);
- free(it);
+ EINA_MAGIC_CHECK_TILER_ITERATOR(it);
+ free(it);
}
/*============================================================================*
@@ -1112,138 +1044,138 @@ static void _iterator_free(Eina_Iterator_Tiler *it)
EAPI Eina_Tiler *eina_tiler_new(int w, int h)
{
- Eina_Tiler *t;
-
- t = calloc(1, sizeof(Eina_Tiler));
- t->area.w = w;
- t->area.h = h;
- t->tile.w = w;
- t->tile.h = h;
- EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
- _splitter_new(t);
- return t;
+ Eina_Tiler *t;
+
+ t = calloc(1, sizeof(Eina_Tiler));
+ t->area.w = w;
+ t->area.h = h;
+ t->tile.w = w;
+ t->tile.h = h;
+ EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
+ _splitter_new(t);
+ return t;
}
-EAPI void eina_tiler_free(Eina_Tiler *t)
+EAPI void eina_tiler_free(Eina_Tiler * t)
{
- EINA_MAGIC_CHECK_TILER(t);
- _splitter_del(t);
- free(t);
+ EINA_MAGIC_CHECK_TILER(t);
+ _splitter_del(t);
+ free(t);
}
-EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h)
+EAPI void eina_tiler_tile_size_set(Eina_Tiler * t, int w, int h)
{
- EINA_MAGIC_CHECK_TILER(t);
- if ((w <= 0) || (h <= 0))
- return;
+ EINA_MAGIC_CHECK_TILER(t);
+ if ((w <= 0) || (h <= 0))
+ return;
- t->tile.w = w;
- t->tile.h = h;
- _splitter_tile_size_set(t, w, h);
+ t->tile.w = w;
+ t->tile.h = h;
+ _splitter_tile_size_set(t, w, h);
}
-EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r)
+EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler * t,
+ const Eina_Rectangle * r)
{
- Eina_Rectangle tmp;
+ Eina_Rectangle tmp;
- EINA_MAGIC_CHECK_TILER(t, EINA_FALSE);
- if ((r->w <= 0) || (r->h <= 0))
- return EINA_FALSE;
+ EINA_MAGIC_CHECK_TILER(t, EINA_FALSE);
+ if ((r->w <= 0) || (r->h <= 0))
+ return EINA_FALSE;
- tmp = *r;
- if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
- return EINA_FALSE;
+ tmp = *r;
+ if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
+ return EINA_FALSE;
- if ((tmp.w <= 0) || (tmp.h <= 0))
- return EINA_FALSE;
+ if ((tmp.w <= 0) || (tmp.h <= 0))
+ return EINA_FALSE;
- return _splitter_rect_add(t, &tmp);
+ return _splitter_rect_add(t, &tmp);
}
-EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r)
+EAPI void eina_tiler_rect_del(Eina_Tiler * t, const Eina_Rectangle * r)
{
- Eina_Rectangle tmp;
+ Eina_Rectangle tmp;
- EINA_MAGIC_CHECK_TILER(t);
- if ((r->w <= 0) || (r->h <= 0))
- return;
+ EINA_MAGIC_CHECK_TILER(t);
+ if ((r->w <= 0) || (r->h <= 0))
+ return;
- tmp = *r;
- if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
- return;
+ tmp = *r;
+ if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
+ return;
- if ((tmp.w <= 0) || (tmp.h <= 0))
- return;
+ if ((tmp.w <= 0) || (tmp.h <= 0))
+ return;
- _splitter_rect_del(t, &tmp);
+ _splitter_rect_del(t, &tmp);
}
-EAPI void eina_tiler_clear(Eina_Tiler *t)
+EAPI void eina_tiler_clear(Eina_Tiler * t)
{
- EINA_MAGIC_CHECK_TILER(t);
- _splitter_clear(t);
+ EINA_MAGIC_CHECK_TILER(t);
+ _splitter_clear(t);
}
-EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t)
+EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler * t)
{
- Eina_Iterator_Tiler *it;
+ Eina_Iterator_Tiler *it;
- EINA_MAGIC_CHECK_TILER(t, NULL);
+ EINA_MAGIC_CHECK_TILER(t, NULL);
- it = calloc(1, sizeof (Eina_Iterator_Tiler));
- if (!it)
- return NULL;
+ it = calloc(1, sizeof(Eina_Iterator_Tiler));
+ if (!it)
+ return NULL;
- it->tiler = t;
+ it->tiler = t;
- if (t->splitter.need_merge == EINA_TRUE)
- {
- list_t to_merge;
- splitter_t *sp;
+ if (t->splitter.need_merge == EINA_TRUE) {
+ list_t to_merge;
+ splitter_t *sp;
- sp = (splitter_t *)&(t->splitter);
- to_merge = t->splitter.rects;
- sp->rects = list_zeroed;
- rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ);
- sp->need_merge = 0;
- }
+ sp = (splitter_t *) & (t->splitter);
+ to_merge = t->splitter.rects;
+ sp->rects = list_zeroed;
+ rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ);
+ sp->need_merge = 0;
+ }
- it->curr = it->tiler->splitter.rects.head;
+ it->curr = it->tiler->splitter.rects.head;
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(_iterator_next);
- it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
- _iterator_get_container);
- it->iterator.free = FUNC_ITERATOR_FREE(_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = FUNC_ITERATOR_NEXT(_iterator_next);
+ it->iterator.get_container =
+ FUNC_ITERATOR_GET_CONTAINER(_iterator_get_container);
+ it->iterator.free = FUNC_ITERATOR_FREE(_iterator_free);
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- EINA_MAGIC_SET(it, EINA_MAGIC_TILER_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(it, EINA_MAGIC_TILER_ITERATOR);
- return &it->iterator;
+ return &it->iterator;
}
-struct _Eina_Tile_Grid_Slicer_Iterator
-{
- Eina_Iterator iterator;
- Eina_Tile_Grid_Slicer priv;
+struct _Eina_Tile_Grid_Slicer_Iterator {
+ Eina_Iterator iterator;
+ Eina_Tile_Grid_Slicer priv;
};
-typedef struct _Eina_Tile_Grid_Slicer_Iterator Eina_Tile_Grid_Slicer_Iterator;
+typedef struct _Eina_Tile_Grid_Slicer_Iterator
+ Eina_Tile_Grid_Slicer_Iterator;
static void
-eina_tile_grid_slicer_iterator_free(Eina_Tile_Grid_Slicer_Iterator *it)
+eina_tile_grid_slicer_iterator_free(Eina_Tile_Grid_Slicer_Iterator * it)
{
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
- free(it);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
+ free(it);
}
static Eina_Bool
-eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator *it,
- void **data)
+eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator * it,
+ void **data)
{
- return eina_tile_grid_slicer_next
- (&it->priv, (const Eina_Tile_Grid_Info **)data);
+ return eina_tile_grid_slicer_next
+ (&it->priv, (const Eina_Tile_Grid_Info **) data);
}
/**
@@ -1266,30 +1198,30 @@ eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator *it,
* region, then @c full flag
* is set.
*/
-EAPI Eina_Iterator *
-eina_tile_grid_slicer_iterator_new(int x,
- int y,
- int w,
- int h,
- int tile_w,
- int tile_h)
+EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x,
+ int y,
+ int w,
+ int h,
+ int tile_w,
+ int tile_h)
{
- Eina_Tile_Grid_Slicer_Iterator *it;
+ Eina_Tile_Grid_Slicer_Iterator *it;
- it = calloc(1, sizeof(*it));
- if (!it)
- {
- eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
+ it = calloc(1, sizeof(*it));
+ if (!it) {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
- EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
- it->iterator.version = EINA_ITERATOR_VERSION;
- it->iterator.next = FUNC_ITERATOR_NEXT(eina_tile_grid_slicer_iterator_next);
- it->iterator.free = FUNC_ITERATOR_FREE(eina_tile_grid_slicer_iterator_free);
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next =
+ FUNC_ITERATOR_NEXT(eina_tile_grid_slicer_iterator_next);
+ it->iterator.free =
+ FUNC_ITERATOR_FREE(eina_tile_grid_slicer_iterator_free);
- eina_tile_grid_slicer_setup(&it->priv, x, y, w, h, tile_w, tile_h);
+ eina_tile_grid_slicer_setup(&it->priv, x, y, w, h, tile_w, tile_h);
- return &it->iterator;
+ return &it->iterator;
}
diff --git a/tests/suite/ecore/src/lib/eina_unicode.c b/tests/suite/ecore/src/lib/eina_unicode.c
index cef07fb4fa..d414ae9f83 100644
--- a/tests/suite/ecore/src/lib/eina_unicode.c
+++ b/tests/suite/ecore/src/lib/eina_unicode.c
@@ -25,63 +25,63 @@
* probably better to use the standard functions */
/* Maybe I'm too tired, but this is the only thing that actually worked. */
-const Eina_Unicode _EINA_UNICODE_EMPTY_STRING[1] = {0};
-EAPI const Eina_Unicode *EINA_UNICODE_EMPTY_STRING = _EINA_UNICODE_EMPTY_STRING;
+const Eina_Unicode _EINA_UNICODE_EMPTY_STRING[1] = { 0 };
+
+EAPI const Eina_Unicode *EINA_UNICODE_EMPTY_STRING =
+ _EINA_UNICODE_EMPTY_STRING;
/**
* @brief Same as the standard strcmp just with Eina_Unicode instead of char.
*/
EAPI int
-eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b)
+eina_unicode_strcmp(const Eina_Unicode * a, const Eina_Unicode * b)
{
- for (; *a && *a == *b; a++, b++)
- ;
- if (*a == *b)
- return 0;
- else if (*a < *b)
- return -1;
- else
- return 1;
+ for (; *a && *a == *b; a++, b++);
+ if (*a == *b)
+ return 0;
+ else if (*a < *b)
+ return -1;
+ else
+ return 1;
}
/**
* @brief Same as the standard strcpy just with Eina_Unicode instead of char.
*/
-EAPI Eina_Unicode *
-eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source)
+EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode * dest,
+ const Eina_Unicode * source)
{
- Eina_Unicode *ret = dest;
+ Eina_Unicode *ret = dest;
- while (*source)
- *dest++ = *source++;
- *dest = 0;
- return ret;
+ while (*source)
+ *dest++ = *source++;
+ *dest = 0;
+ return ret;
}
/**
* @brief Same as the standard strncpy just with Eina_Unicode instead of char.
*/
-EAPI Eina_Unicode *
-eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n)
+EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode * dest,
+ const Eina_Unicode * source,
+ size_t n)
{
- Eina_Unicode *ret = dest;
+ Eina_Unicode *ret = dest;
- for ( ; n && *source ; n--)
- *dest++ = *source++;
- for (; n; n--)
- *dest++ = 0;
- return ret;
+ for (; n && *source; n--)
+ *dest++ = *source++;
+ for (; n; n--)
+ *dest++ = 0;
+ return ret;
}
/**
* @brief Same as the standard strlen just with Eina_Unicode instead of char.
*/
-EAPI size_t
-eina_unicode_strlen(const Eina_Unicode *ustr)
+EAPI size_t eina_unicode_strlen(const Eina_Unicode * ustr)
{
- const Eina_Unicode *end;
- for (end = ustr; *end; end++)
- ;
- return end - ustr;
+ const Eina_Unicode *end;
+ for (end = ustr; *end; end++);
+ return end - ustr;
}
/**
@@ -95,14 +95,12 @@ eina_unicode_strlen(const Eina_Unicode *ustr)
* @param n Max length to search
* @return Number of characters or n.
*/
-EAPI size_t
-eina_unicode_strnlen(const Eina_Unicode *ustr, int n)
+EAPI size_t eina_unicode_strnlen(const Eina_Unicode * ustr, int n)
{
- const Eina_Unicode *end;
- const Eina_Unicode *last = ustr + n; /* technically not portable ;-) */
- for (end = ustr; end < last && *end; end++)
- ;
- return end - ustr;
+ const Eina_Unicode *end;
+ const Eina_Unicode *last = ustr + n; /* technically not portable ;-) */
+ for (end = ustr; end < last && *end; end++);
+ return end - ustr;
}
@@ -111,66 +109,58 @@ eina_unicode_strnlen(const Eina_Unicode *ustr, int n)
/**
* @brief Same as the standard strdup just with Eina_Unicode instead of char.
*/
-EAPI Eina_Unicode *
-eina_unicode_strdup(const Eina_Unicode *text)
+EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode * text)
{
- Eina_Unicode *ustr;
- int len;
+ Eina_Unicode *ustr;
+ int len;
- len = eina_unicode_strlen(text);
- ustr = (Eina_Unicode *)calloc(len + 1, sizeof(Eina_Unicode));
- memcpy(ustr, text, len * sizeof(Eina_Unicode));
+ len = eina_unicode_strlen(text);
+ ustr = (Eina_Unicode *) calloc(len + 1, sizeof(Eina_Unicode));
+ memcpy(ustr, text, len * sizeof(Eina_Unicode));
- return ustr;
+ return ustr;
}
/**
* @brief Same as the standard strdup just with Eina_Unicode instead of char.
*/
-EAPI Eina_Unicode *
-eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle)
+EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode * haystack,
+ const Eina_Unicode * needle)
{
- const Eina_Unicode *i, *j;
+ const Eina_Unicode *i, *j;
- for (i = haystack; *i; i++)
- {
- haystack = i; /* set this location as the base position */
- for (j = needle; *j && *i && *j == *i; j++, i++)
- ;
+ for (i = haystack; *i; i++) {
+ haystack = i; /* set this location as the base position */
+ for (j = needle; *j && *i && *j == *i; j++, i++);
- if (!*j) /*if we got to the end of j this means we got a full match */
- {
- return (Eina_Unicode *)haystack; /* return the new base position */
- }
- }
+ if (!*j) { /*if we got to the end of j this means we got a full match */
+ return (Eina_Unicode *) haystack; /* return the new base position */
+ }
+ }
- return NULL;
+ return NULL;
}
/**
* @see eina_str_escape()
*/
-EAPI Eina_Unicode *
-eina_unicode_escape(const Eina_Unicode *str)
+EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode * str)
{
- Eina_Unicode *s2, *d;
- const Eina_Unicode *s;
-
- s2 = malloc((eina_unicode_strlen(str) * 2) + 1);
- if (!s2)
- return NULL;
-
- for (s = str, d = s2; *s != 0; s++, d++)
- {
- if ((*s == ' ') || (*s == '\\') || (*s == '\''))
- {
- *d = '\\';
- d++;
- }
-
- *d = *s;
- }
- *d = 0;
- return s2;
+ Eina_Unicode *s2, *d;
+ const Eina_Unicode *s;
+
+ s2 = malloc((eina_unicode_strlen(str) * 2) + 1);
+ if (!s2)
+ return NULL;
+
+ for (s = str, d = s2; *s != 0; s++, d++) {
+ if ((*s == ' ') || (*s == '\\') || (*s == '\'')) {
+ *d = '\\';
+ d++;
+ }
+
+ *d = *s;
+ }
+ *d = 0;
+ return s2;
}
-
diff --git a/tests/suite/ecore/src/lib/eina_ustrbuf.c b/tests/suite/ecore/src/lib/eina_ustrbuf.c
index 7df5b1603b..f571ef61a6 100644
--- a/tests/suite/ecore/src/lib/eina_ustrbuf.c
+++ b/tests/suite/ecore/src/lib/eina_ustrbuf.c
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include "eina_strbuf_common.h"
@@ -15,35 +15,35 @@
*/
#ifdef _STRBUF_DATA_TYPE
-# undef _STRBUF_DATA_TYPE
+#undef _STRBUF_DATA_TYPE
#endif
#ifdef _STRBUF_CSIZE
-# undef _STRBUF_CSIZE
+#undef _STRBUF_CSIZE
#endif
#ifdef _STRBUF_STRUCT_NAME
-# undef _STRBUF_STRUCT_NAME
+#undef _STRBUF_STRUCT_NAME
#endif
#ifdef _STRBUF_STRLEN_FUNC
-# undef _STRBUF_STRLEN_FUNC
+#undef _STRBUF_STRLEN_FUNC
#endif
#ifdef _STRBUF_STRESCAPE_FUNC
-# undef _STRBUF_STRESCAPE_FUNC
+#undef _STRBUF_STRESCAPE_FUNC
#endif
#ifdef _STRBUF_MAGIC
-# undef _STRBUF_MAGIC
+#undef _STRBUF_MAGIC
#endif
#ifdef _STRBUF_MAGIC_STR
-# undef _STRBUF_MAGIC_STR
+#undef _STRBUF_MAGIC_STR
#endif
#ifdef _FUNC_EXPAND
-# undef _FUNC_EXPAND
+#undef _FUNC_EXPAND
#endif
#define _STRBUF_DATA_TYPE Eina_Unicode
diff --git a/tests/suite/ecore/src/lib/eina_ustringshare.c b/tests/suite/ecore/src/lib/eina_ustringshare.c
index 8fe18c8968..11f9f7a136 100644
--- a/tests/suite/ecore/src/lib/eina_ustringshare.c
+++ b/tests/suite/ecore/src/lib/eina_ustringshare.c
@@ -34,7 +34,8 @@
/* The actual share */
static Eina_Share *ustringshare_share;
-static const char EINA_MAGIC_USTRINGSHARE_NODE_STR[] = "Eina UStringshare Node";
+static const char EINA_MAGIC_USTRINGSHARE_NODE_STR[] =
+ "Eina UStringshare Node";
/*============================================================================*
* Global *
@@ -51,12 +52,11 @@ static const char EINA_MAGIC_USTRINGSHARE_NODE_STR[] = "Eina UStringshare Node";
*
* @see eina_init()
*/
-Eina_Bool
-eina_ustringshare_init(void)
+Eina_Bool eina_ustringshare_init(void)
{
- return eina_share_common_init(&ustringshare_share,
- EINA_MAGIC_USTRINGSHARE_NODE,
- EINA_MAGIC_USTRINGSHARE_NODE_STR);
+ return eina_share_common_init(&ustringshare_share,
+ EINA_MAGIC_USTRINGSHARE_NODE,
+ EINA_MAGIC_USTRINGSHARE_NODE_STR);
}
/**
@@ -70,12 +70,11 @@ eina_ustringshare_init(void)
*
* @see eina_shutdown()
*/
-Eina_Bool
-eina_ustringshare_shutdown(void)
+Eina_Bool eina_ustringshare_shutdown(void)
{
- Eina_Bool ret;
- ret = eina_share_common_shutdown(&ustringshare_share);
- return ret;
+ Eina_Bool ret;
+ ret = eina_share_common_shutdown(&ustringshare_share);
+ return ret;
}
/*============================================================================*
@@ -118,13 +117,12 @@ eina_ustringshare_shutdown(void)
* Note that if the given pointer is not shared or NULL, bad things
* will happen, likely a segmentation fault.
*/
-EAPI void
-eina_ustringshare_del(const Eina_Unicode *str)
+EAPI void eina_ustringshare_del(const Eina_Unicode * str)
{
- if (!str)
- return;
+ if (!str)
+ return;
- eina_share_common_del(ustringshare_share,(const char *)str);
+ eina_share_common_del(ustringshare_share, (const char *) str);
}
/**
@@ -147,16 +145,15 @@ eina_ustringshare_del(const Eina_Unicode *str)
*
* @see eina_ustringshare_add()
*/
-EAPI const Eina_Unicode *
-eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen)
+EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *
+ str,
+ unsigned int slen)
{
- return (const Eina_Unicode *)eina_share_common_add_length(ustringshare_share,
- (const char *)str,
- slen *
- sizeof(
- Eina_Unicode),
- sizeof(
- Eina_Unicode));
+ return (const Eina_Unicode *)
+ eina_share_common_add_length(ustringshare_share,
+ (const char *) str,
+ slen * sizeof(Eina_Unicode),
+ sizeof(Eina_Unicode));
}
/**
@@ -178,11 +175,10 @@ eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen)
*
* @see eina_ustringshare_add_length()
*/
-EAPI const Eina_Unicode *
-eina_ustringshare_add(const Eina_Unicode *str)
+EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode * str)
{
- int slen = (str) ? (int)eina_unicode_strlen(str) : -1;
- return eina_ustringshare_add_length(str, slen);
+ int slen = (str) ? (int) eina_unicode_strlen(str) : -1;
+ return eina_ustringshare_add_length(str, slen);
}
/**
@@ -199,11 +195,10 @@ eina_ustringshare_add(const Eina_Unicode *str)
*
* There is no unref since this is the work of eina_ustringshare_del().
*/
-EAPI const Eina_Unicode *
-eina_ustringshare_ref(const Eina_Unicode *str)
+EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode * str)
{
- return (const Eina_Unicode *)eina_share_common_ref(ustringshare_share,
- (const char *)str);
+ return (const Eina_Unicode *)
+ eina_share_common_ref(ustringshare_share, (const char *) str);
}
/**
@@ -217,12 +212,13 @@ eina_ustringshare_ref(const Eina_Unicode *str)
* things will happen, likely a segmentation fault. If in doubt, try
* strlen().
*/
-EAPI int
-eina_ustringshare_strlen(const Eina_Unicode *str)
+EAPI int eina_ustringshare_strlen(const Eina_Unicode * str)
{
- int len = eina_share_common_length(ustringshare_share, (const char *)str);
- len = (len > 0) ? len / (int)sizeof(Eina_Unicode) : -1;
- return len;
+ int len =
+ eina_share_common_length(ustringshare_share,
+ (const char *) str);
+ len = (len > 0) ? len / (int) sizeof(Eina_Unicode) : -1;
+ return len;
}
/**
@@ -231,13 +227,11 @@ eina_ustringshare_strlen(const Eina_Unicode *str)
* This function dumps all strings in the share_common to stdout with a
* DDD: prefix per line and a memory usage summary.
*/
-EAPI void
-eina_ustringshare_dump(void)
+EAPI void eina_ustringshare_dump(void)
{
- eina_share_common_dump(ustringshare_share, NULL, 0);
+ eina_share_common_dump(ustringshare_share, NULL, 0);
}
/**
* @}
*/
-
diff --git a/tests/suite/ecore/src/lib/eina_value.c b/tests/suite/ecore/src/lib/eina_value.c
index 554f907d6d..7115a3063a 100644
--- a/tests/suite/ecore/src/lib/eina_value.c
+++ b/tests/suite/ecore/src/lib/eina_value.c
@@ -25,7 +25,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include "eina_config.h"
@@ -39,9 +39,9 @@
* API *
*============================================================================*/
-EAPI const unsigned int eina_prime_table[] =
-{
- 17, 31, 61, 127, 257, 509, 1021,
- 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
- 2097143, 4194301, 8388617, 16777213
+EAPI const unsigned int eina_prime_table[] = {
+ 17, 31, 61, 127, 257, 509, 1021,
+ 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287,
+ 1048573,
+ 2097143, 4194301, 8388617, 16777213
};
diff --git a/tests/suite/mini-eagain2.c b/tests/suite/mini-eagain2.c
index 11a91a4ddb..9346041fdf 100644
--- a/tests/suite/mini-eagain2.c
+++ b/tests/suite/mini-eagain2.c
@@ -24,186 +24,194 @@
static int done = 0;
#if 0
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf(stderr, "|<%d>| %s", level, str);
+ fprintf(stderr, "|<%d>| %s", level, str);
}
#endif
-static const char*
-SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status)
+static const char
+ *SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t
+ status)
{
- switch (status)
- {
- case GNUTLS_HANDSHAKE_HELLO_REQUEST:
- return "Hello request";
- case GNUTLS_HANDSHAKE_CLIENT_HELLO:
- return "Client hello";
- case GNUTLS_HANDSHAKE_SERVER_HELLO:
- return "Server hello";
- case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
- return "Certificate packet";
- case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
- return "Server key exchange";
- case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
- return "Certificate request";
- case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
- return "Server hello done";
- case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
- return "Certificate verify";
- case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
- return "Client key exchange";
- case GNUTLS_HANDSHAKE_FINISHED:
- return "Finished";
- case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
- return "Supplemental";
- default:
- return NULL;
- }
- return NULL;
+ switch (status) {
+ case GNUTLS_HANDSHAKE_HELLO_REQUEST:
+ return "Hello request";
+ case GNUTLS_HANDSHAKE_CLIENT_HELLO:
+ return "Client hello";
+ case GNUTLS_HANDSHAKE_SERVER_HELLO:
+ return "Server hello";
+ case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
+ return "Certificate packet";
+ case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
+ return "Server key exchange";
+ case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
+ return "Certificate request";
+ case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
+ return "Server hello done";
+ case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
+ return "Certificate verify";
+ case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
+ return "Client key exchange";
+ case GNUTLS_HANDSHAKE_FINISHED:
+ return "Finished";
+ case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
+ return "Supplemental";
+ default:
+ return NULL;
+ }
+ return NULL;
}
/* Connects to the peer and returns a socket
* descriptor.
*/
-static int
-tcp_connect (void)
+static int tcp_connect(void)
{
- const char *PORT = "4445";
- const char *SERVER = "127.0.0.1"; //verisign.com
- int err, sd;
- int flag = 1, curstate = 0;
- struct sockaddr_in sa;
-
- /* sets some fd options such as nonblock */
- sd = socket (AF_INET, SOCK_STREAM, 0);
- fcntl(sd, F_SETFL, O_NONBLOCK);
- fcntl(sd, F_SETFD, FD_CLOEXEC);
- setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, sizeof(curstate));
-
- setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
-
- memset (&sa, '\0', sizeof (sa));
- sa.sin_family = AF_INET;
- sa.sin_port = htons (atoi (PORT));
- inet_pton (AF_INET, SERVER, &sa.sin_addr);
-
- /* connects to server
- */
- err = connect (sd, (struct sockaddr *) &sa, sizeof (sa));
- if ((err < 0) && (errno != EINPROGRESS))
- {
- print("Connect error\n");
- exit (1);
- }
-
- return sd;
+ const char *PORT = "4445";
+ const char *SERVER = "127.0.0.1"; //verisign.com
+ int err, sd;
+ int flag = 1, curstate = 0;
+ struct sockaddr_in sa;
+
+ /* sets some fd options such as nonblock */
+ sd = socket(AF_INET, SOCK_STREAM, 0);
+ fcntl(sd, F_SETFL, O_NONBLOCK);
+ fcntl(sd, F_SETFD, FD_CLOEXEC);
+ setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (const void *) &curstate,
+ sizeof(curstate));
+
+ setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag,
+ sizeof(int));
+
+ memset(&sa, '\0', sizeof(sa));
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(atoi(PORT));
+ inet_pton(AF_INET, SERVER, &sa.sin_addr);
+
+ /* connects to server
+ */
+ err = connect(sd, (struct sockaddr *) &sa, sizeof(sa));
+ if ((err < 0) && (errno != EINPROGRESS)) {
+ print("Connect error\n");
+ exit(1);
+ }
+
+ return sd;
}
/* closes the given socket descriptor.
*/
-static void
-tcp_close (int sd)
+static void tcp_close(int sd)
{
- shutdown (sd, SHUT_RDWR); /* no more receptions */
- close (sd);
+ shutdown(sd, SHUT_RDWR); /* no more receptions */
+ close(sd);
}
static Eina_Bool
-_process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler)
+_process_data(gnutls_session_t client, Ecore_Fd_Handler * fd_handler)
{
- static int ret, lastret;
- static unsigned int count = 0;
-
- if (!done)
- {
- lastret = ret;
- ret = gnutls_handshake (client);
- count++;
- if (gnutls_record_get_direction(client))
- ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_WRITE);
- else
- ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_READ);
- /* avoid printing messages infinity times */
- if (lastret != ret && ret != 0 && ret != GNUTLS_E_AGAIN)
- {
- print("gnutls returned with: %s - %s", gnutls_strerror_name(ret), gnutls_strerror(ret));
- if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) || (ret == GNUTLS_E_FATAL_ALERT_RECEIVED))
- print("Also received alert: %s", gnutls_alert_get_name(gnutls_alert_get(client)));
- print("last out: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_out(client)));
- print("last in: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_in(client)));
- }
-
- if (gnutls_error_is_fatal(ret))
- {
- print("yarrr this be an error!");
- exit(1);
- }
-
- }
- if (ret == GNUTLS_E_SUCCESS)
- {
- done = 1;
- //print("Handshake successful in %u handshake calls!", count);
- ecore_main_loop_quit();
- }
-
- return ECORE_CALLBACK_RENEW;
+ static int ret, lastret;
+ static unsigned int count = 0;
+
+ if (!done) {
+ lastret = ret;
+ ret = gnutls_handshake(client);
+ count++;
+ if (gnutls_record_get_direction(client))
+ ecore_main_fd_handler_active_set(fd_handler,
+ ECORE_FD_WRITE);
+ else
+ ecore_main_fd_handler_active_set(fd_handler,
+ ECORE_FD_READ);
+ /* avoid printing messages infinity times */
+ if (lastret != ret && ret != 0 && ret != GNUTLS_E_AGAIN) {
+ print("gnutls returned with: %s - %s",
+ gnutls_strerror_name(ret),
+ gnutls_strerror(ret));
+ if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED)
+ || (ret == GNUTLS_E_FATAL_ALERT_RECEIVED))
+ print("Also received alert: %s",
+ gnutls_alert_get_name
+ (gnutls_alert_get(client)));
+ print("last out: %s",
+ SSL_GNUTLS_PRINT_HANDSHAKE_STATUS
+ (gnutls_handshake_get_last_out(client)));
+ print("last in: %s",
+ SSL_GNUTLS_PRINT_HANDSHAKE_STATUS
+ (gnutls_handshake_get_last_in(client)));
+ }
+
+ if (gnutls_error_is_fatal(ret)) {
+ print("yarrr this be an error!");
+ exit(1);
+ }
+
+ }
+ if (ret == GNUTLS_E_SUCCESS) {
+ done = 1;
+ //print("Handshake successful in %u handshake calls!", count);
+ ecore_main_loop_quit();
+ }
+
+ return ECORE_CALLBACK_RENEW;
}
-int
-main (void)
+int main(void)
{
- /* credentials */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_certificate_credentials_t c_certcred;
-
- gnutls_session_t client;
- int sd, i;
-
- /* General init. */
- global_init ();
- ecore_init();
+ /* credentials */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_certificate_credentials_t c_certcred;
+
+ gnutls_session_t client;
+ int sd, i;
+
+ /* General init. */
+ global_init();
+ ecore_init();
// gnutls_global_set_log_function (tls_log_func);
// gnutls_global_set_log_level (2);
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_certificate_allocate_credentials (&c_certcred);
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_certificate_allocate_credentials(&c_certcred);
+
+ for (i = 0; i < 5; i++) {
- for (i=0;i<5;i++)
- {
+ gnutls_init(&client, GNUTLS_CLIENT);
+ /* set very specific priorities */
+ gnutls_priority_set_direct(client, "NORMAL:+ANON-DH",
+ NULL);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON,
+ c_anoncred);
+ gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE,
+ c_certcred);
+ gnutls_server_name_set(client, GNUTLS_NAME_DNS,
+ "localhost", strlen("localhost"));
- gnutls_init (&client, GNUTLS_CLIENT);
- /* set very specific priorities */
- gnutls_priority_set_direct(client, "NORMAL:+ANON-DH", NULL);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, c_certcred);
- gnutls_server_name_set(client, GNUTLS_NAME_DNS, "localhost", strlen("localhost"));
+ /* connect to the peer
+ */
+ sd = tcp_connect();
- /* connect to the peer
- */
- sd = tcp_connect ();
+ /* associate gnutls with socket */
+ gnutls_transport_set_int(client, sd);
+ /* add a callback for data being available for send/receive on socket */
+ if (!ecore_main_fd_handler_add
+ (sd, ECORE_FD_READ | ECORE_FD_WRITE,
+ (Ecore_Fd_Cb) _process_data, client, NULL, NULL)) {
+ print("could not create fd handler!");
+ exit(1);
+ }
+ /* begin main loop */
+ ecore_main_loop_begin();
- /* associate gnutls with socket */
- gnutls_transport_set_int (client, sd);
- /* add a callback for data being available for send/receive on socket */
- if (!ecore_main_fd_handler_add(sd, ECORE_FD_READ | ECORE_FD_WRITE, (Ecore_Fd_Cb)_process_data, client, NULL, NULL))
- {
- print("could not create fd handler!");
- exit(1);
- }
- /* begin main loop */
- ecore_main_loop_begin();
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
- gnutls_bye (client, GNUTLS_SHUT_RDWR);
+ gnutls_deinit(client);
- gnutls_deinit (client);
+ tcp_close(sd);
+ }
- tcp_close (sd);
- }
-
- return 0;
+ return 0;
}
diff --git a/tests/suite/mini-record-timing.c b/tests/suite/mini-record-timing.c
index 849a8c2e6c..215c0933d5 100644
--- a/tests/suite/mini-record-timing.c
+++ b/tests/suite/mini-record-timing.c
@@ -31,7 +31,7 @@
int main()
{
- exit(77);
+ exit(77);
}
#else
@@ -53,16 +53,14 @@ int main()
#include <sys/resource.h>
#ifdef DEBUG
-static void
-server_log_func (int level, const char *str)
+static void server_log_func(int level, const char *str)
{
- fprintf (stderr, "server|<%d>| %s", level, str);
+ fprintf(stderr, "server|<%d>| %s", level, str);
}
-static void
-client_log_func (int level, const char *str)
+static void client_log_func(int level, const char *str)
{
- fprintf (stderr, "client|<%d>| %s", level, str);
+ fprintf(stderr, "client|<%d>| %s", level, str);
}
#endif
@@ -73,35 +71,34 @@ client_log_func (int level, const char *str)
*/
static unsigned char server_cert_pem[] =
-"-----BEGIN CERTIFICATE-----\n"
-"MIIBeTCCASWgAwIBAgIBBzANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwROb25l\n"
-"MCIYDzIwMTMwMTE5MTA0MDAwWhgPMjA0MDA2MDUxMDQwMDBaMA8xDTALBgNVBAMT\n"
-"BE5vbmUwWTANBgkqhkiG9w0BAQEFAANIADBFAj4Bh52/b3FNXDdICg1Obqu9ivW+\n"
-"PGJ89mNsX3O9S/aclnx5Ozw9MC1UJuZ2UEHl27YVmm4xG/y3nKUNevZjKwIDAQAB\n"
-"o2swaTAMBgNVHRMBAf8EAjAAMBQGA1UdEQQNMAuCCWxvY2FsaG9zdDATBgNVHSUE\n"
-"DDAKBggrBgEFBQcDATAPBgNVHQ8BAf8EBQMDB6AAMB0GA1UdDgQWBBRhEgmVCi6c\n"
-"hhRQvMzfEXqLKTRxcTANBgkqhkiG9w0BAQsFAAM/AADMi31wr0Tp2SJUCuQjFVCb\n"
-"JDleomTayOWVS/afCyAUxYjqFfUFSZ8sYN3zAgnXt5DYO3VclIlax4n6iXOg\n"
-"-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIBeTCCASWgAwIBAgIBBzANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwROb25l\n"
+ "MCIYDzIwMTMwMTE5MTA0MDAwWhgPMjA0MDA2MDUxMDQwMDBaMA8xDTALBgNVBAMT\n"
+ "BE5vbmUwWTANBgkqhkiG9w0BAQEFAANIADBFAj4Bh52/b3FNXDdICg1Obqu9ivW+\n"
+ "PGJ89mNsX3O9S/aclnx5Ozw9MC1UJuZ2UEHl27YVmm4xG/y3nKUNevZjKwIDAQAB\n"
+ "o2swaTAMBgNVHRMBAf8EAjAAMBQGA1UdEQQNMAuCCWxvY2FsaG9zdDATBgNVHSUE\n"
+ "DDAKBggrBgEFBQcDATAPBgNVHQ8BAf8EBQMDB6AAMB0GA1UdDgQWBBRhEgmVCi6c\n"
+ "hhRQvMzfEXqLKTRxcTANBgkqhkiG9w0BAQsFAAM/AADMi31wr0Tp2SJUCuQjFVCb\n"
+ "JDleomTayOWVS/afCyAUxYjqFfUFSZ8sYN3zAgnXt5DYO3VclIlax4n6iXOg\n"
+ "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
-"-----BEGIN RSA PRIVATE KEY-----\n"
-"MIIBLAIBAAI+AYedv29xTVw3SAoNTm6rvYr1vjxifPZjbF9zvUv2nJZ8eTs8PTAt\n"
-"VCbmdlBB5du2FZpuMRv8t5ylDXr2YysCAwEAAQI9EPt8Q77sFeWn0BfHoPD9pTsG\n"
-"5uN2e9DP8Eu6l8K4AcOuEsEkqZzvxgqZPA68pw8BZ5xKINMFdRPHmrX/cQIfHsdq\n"
-"aMDYR/moqgj8MbupqOr/48iorTk/D//2lgAMnwIfDLk3UWGvPiv6fNTlEnTgVn6o\n"
-"TdL0mvpkixebQ5RR9QIfHDjkRGtXph+xXUBh50RZXE8nFfl/WV7diVE+DOq8pwIf\n"
-"BxdOwjdsAH1oLBxG0sN6qBoM2NrCYoE8edydNsu55QIfEWsrlJnO/t0GzHy7qWdV\n"
-"zi9JMPu9MTDhOGmqPQO7Xw==\n"
-"-----END RSA PRIVATE KEY-----\n";
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIIBLAIBAAI+AYedv29xTVw3SAoNTm6rvYr1vjxifPZjbF9zvUv2nJZ8eTs8PTAt\n"
+ "VCbmdlBB5du2FZpuMRv8t5ylDXr2YysCAwEAAQI9EPt8Q77sFeWn0BfHoPD9pTsG\n"
+ "5uN2e9DP8Eu6l8K4AcOuEsEkqZzvxgqZPA68pw8BZ5xKINMFdRPHmrX/cQIfHsdq\n"
+ "aMDYR/moqgj8MbupqOr/48iorTk/D//2lgAMnwIfDLk3UWGvPiv6fNTlEnTgVn6o\n"
+ "TdL0mvpkixebQ5RR9QIfHDjkRGtXph+xXUBh50RZXE8nFfl/WV7diVE+DOq8pwIf\n"
+ "BxdOwjdsAH1oLBxG0sN6qBoM2NrCYoE8edydNsu55QIfEWsrlJnO/t0GzHy7qWdV\n"
+ "zi9JMPu9MTDhOGmqPQO7Xw==\n" "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
@@ -114,20 +111,20 @@ const gnutls_datum_t server_key = { server_key_pem,
#define MAX_BUF 1024
struct point_st {
- unsigned char byte1;
- unsigned char byte2;
- unsigned midx;
- unsigned long *measurements;
- unsigned long *smeasurements;
+ unsigned char byte1;
+ unsigned char byte2;
+ unsigned midx;
+ unsigned long *measurements;
+ unsigned long *smeasurements;
};
struct test_st {
- struct point_st* points;
- unsigned int npoints;
- const char* desc;
- const char* file;
- const char* name;
- unsigned text_size;
+ struct point_st *points;
+ unsigned int npoints;
+ const char *desc;
+ const char *file;
+ const char *name;
+ unsigned text_size;
};
struct point_st *prev_point_ptr = NULL;
@@ -137,465 +134,477 @@ static gnutls_session_t cli_session = NULL;
static ssize_t
push(gnutls_transport_ptr_t tr, const void *_data, size_t len)
{
-int fd = (long int)tr;
-
- return send(fd, _data, len, 0);
+ int fd = (long int) tr;
+
+ return send(fd, _data, len, 0);
}
static ssize_t
-push_crippled (gnutls_transport_ptr_t tr, const void *_data, size_t len)
+push_crippled(gnutls_transport_ptr_t tr, const void *_data, size_t len)
{
-int fd = (long int)tr;
-unsigned char* data = (void*)_data;
-struct point_st * p;
-unsigned p_size;
-struct test_st * test = gnutls_session_get_ptr(cli_session);
-
- p = &test->points[point_idx];
- p_size = test->npoints;
+ int fd = (long int) tr;
+ unsigned char *data = (void *) _data;
+ struct point_st *p;
+ unsigned p_size;
+ struct test_st *test = gnutls_session_get_ptr(cli_session);
- memcpy(&data[len-32], data+5, 32);
+ p = &test->points[point_idx];
+ p_size = test->npoints;
+
+ memcpy(&data[len - 32], data + 5, 32);
/*fprintf(stderr, "sending: %d: %d\n", (unsigned)p->byte1, (int)len);*/
- data[len-17] ^= p->byte1;
- data[len-18] ^= p->byte2;
-
- prev_point_ptr = p;
- point_idx++;
- if (point_idx >= p_size)
- point_idx = 0;
-
- return send(fd, data, len, 0);
+ data[len - 17] ^= p->byte1;
+ data[len - 18] ^= p->byte2;
+
+ prev_point_ptr = p;
+ point_idx++;
+ if (point_idx >= p_size)
+ point_idx = 0;
+
+ return send(fd, data, len, 0);
}
-static unsigned long timespec_sub_ns(struct timespec *a, struct timespec *b)
+static unsigned long timespec_sub_ns(struct timespec *a,
+ struct timespec *b)
{
- return (a->tv_sec*1000*1000*1000 + a->tv_nsec - (b->tv_sec*1000*1000*1000 +
- b->tv_nsec));
+ return (a->tv_sec * 1000 * 1000 * 1000 + a->tv_nsec -
+ (b->tv_sec * 1000 * 1000 * 1000 + b->tv_nsec));
}
static
double calc_avg(unsigned long *diffs, unsigned int diffs_size)
{
-double avg = 0;
-unsigned int i;
-unsigned int start = diffs_size/20;
-unsigned int stop = diffs_size-diffs_size/20;
+ double avg = 0;
+ unsigned int i;
+ unsigned int start = diffs_size / 20;
+ unsigned int stop = diffs_size - diffs_size / 20;
+
+ for (i = start; i < stop; i++)
+ avg += diffs[i];
- for(i=start;i<stop;i++)
- avg += diffs[i];
-
- avg /= (stop-start);
+ avg /= (stop - start);
- return avg;
+ return avg;
}
-static int compar(const void* _a, const void* _b)
+static int compar(const void *_a, const void *_b)
{
- unsigned long a, b;
-
- a = *((unsigned long*)_a);
- b = *((unsigned long*)_b);
-
- if (a < b)
- return -1;
- else if (a==b)
- return 0;
- else
- return 1;
+ unsigned long a, b;
+
+ a = *((unsigned long *) _a);
+ b = *((unsigned long *) _b);
+
+ if (a < b)
+ return -1;
+ else if (a == b)
+ return 0;
+ else
+ return 1;
}
static
double calc_median(unsigned long *diffs, unsigned int diffs_size)
{
-double med;
+ double med;
- if (diffs_size % 2 == 1)
- med = diffs[diffs_size/2];
- else
- {
- med = diffs[diffs_size/2] + diffs[(diffs_size-1)/2];
- med /= 2;
- }
+ if (diffs_size % 2 == 1)
+ med = diffs[diffs_size / 2];
+ else {
+ med = diffs[diffs_size / 2] + diffs[(diffs_size - 1) / 2];
+ med /= 2;
+ }
- return med;
+ return med;
}
#if 0
static
unsigned long calc_min(unsigned long *diffs, unsigned int diffs_size)
{
-unsigned long min = 0, i;
-unsigned int start = diffs_size/20;
-unsigned int stop = diffs_size-diffs_size/20;
-
-
- for (i=start;i<stop;i++) {
- if (min == 0)
- min = diffs[i];
- else if (diffs[i] < min)
- min = diffs[i];
- }
- return min;
+ unsigned long min = 0, i;
+ unsigned int start = diffs_size / 20;
+ unsigned int stop = diffs_size - diffs_size / 20;
+
+
+ for (i = start; i < stop; i++) {
+ if (min == 0)
+ min = diffs[i];
+ else if (diffs[i] < min)
+ min = diffs[i];
+ }
+ return min;
}
static
double calc_var(unsigned long *diffs, unsigned int diffs_size, double avg)
{
-double sum = 0, d;
-unsigned int i;
-unsigned int start = diffs_size/20;
-unsigned int stop = diffs_size-diffs_size/20;
-
- for (i=start;i<stop;i++) {
- d = ((double)diffs[i] - avg);
- d *= d;
-
- sum += d;
- }
- sum /= diffs_size - 1;
-
- return sum;
+ double sum = 0, d;
+ unsigned int i;
+ unsigned int start = diffs_size / 20;
+ unsigned int stop = diffs_size - diffs_size / 20;
+
+ for (i = start; i < stop; i++) {
+ d = ((double) diffs[i] - avg);
+ d *= d;
+
+ sum += d;
+ }
+ sum /= diffs_size - 1;
+
+ return sum;
}
#endif
static void
-client (int fd, const char* prio, unsigned int text_size, struct test_st *test)
+client(int fd, const char *prio, unsigned int text_size,
+ struct test_st *test)
{
- int ret;
- char buffer[MAX_BUF + 1];
- char text[text_size];
- gnutls_certificate_credentials_t x509_cred;
- gnutls_session_t session;
- struct timespec start, stop;
- static unsigned long taken = 0;
- static unsigned long measurement;
- const char* err;
-
- global_init ();
-
- setpriority(PRIO_PROCESS, getpid(), -15);
-
- memset(text, 0, text_size);
+ int ret;
+ char buffer[MAX_BUF + 1];
+ char text[text_size];
+ gnutls_certificate_credentials_t x509_cred;
+ gnutls_session_t session;
+ struct timespec start, stop;
+ static unsigned long taken = 0;
+ static unsigned long measurement;
+ const char *err;
+
+ global_init();
+
+ setpriority(PRIO_PROCESS, getpid(), -15);
+
+ memset(text, 0, text_size);
#ifdef DEBUG
- gnutls_global_set_log_function (client_log_func);
- gnutls_global_set_log_level (6);
+ gnutls_global_set_log_function(client_log_func);
+ gnutls_global_set_log_level(6);
#endif
- gnutls_certificate_allocate_credentials (&x509_cred);
+ gnutls_certificate_allocate_credentials(&x509_cred);
#ifdef REHANDSHAKE
-restart:
+ restart:
#endif
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
- gnutls_session_set_ptr(session, test);
- cli_session = session;
-
- /* Use default priorities */
- if ((ret=gnutls_priority_set_direct (session, prio, &err)) < 0) {
- fprintf(stderr, "Error in priority string %s: %s\n", gnutls_strerror(ret), err);
- exit(1);
- }
-
- /* put the anonymous credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
- gnutls_transport_set_int (session, fd);
-
- /* Perform the TLS handshake
- */
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
-
- if (ret < 0)
- {
- fprintf (stderr, "client: Handshake failed\n");
- gnutls_perror (ret);
- exit(1);
- }
-
- ret = gnutls_protocol_get_version(session);
- if (ret < GNUTLS_TLS1_1)
- {
- fprintf (stderr, "client: Handshake didn't negotiate TLS 1.1 (or later)\n");
- exit(1);
- }
-
- gnutls_transport_set_push_function (session, push_crippled);
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+ gnutls_session_set_ptr(session, test);
+ cli_session = session;
+
+ /* Use default priorities */
+ if ((ret = gnutls_priority_set_direct(session, prio, &err)) < 0) {
+ fprintf(stderr, "Error in priority string %s: %s\n",
+ gnutls_strerror(ret), err);
+ exit(1);
+ }
+
+ /* put the anonymous credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+ gnutls_transport_set_int(session, fd);
+
+ /* Perform the TLS handshake
+ */
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+
+ if (ret < 0) {
+ fprintf(stderr, "client: Handshake failed\n");
+ gnutls_perror(ret);
+ exit(1);
+ }
+
+ ret = gnutls_protocol_get_version(session);
+ if (ret < GNUTLS_TLS1_1) {
+ fprintf(stderr,
+ "client: Handshake didn't negotiate TLS 1.1 (or later)\n");
+ exit(1);
+ }
+
+ gnutls_transport_set_push_function(session, push_crippled);
#ifndef REHANDSHAKE
-restart:
+ restart:
#endif
- do {
- ret = gnutls_record_send (session, text, sizeof(text));
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- /* measure peer's processing time */
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
+ do {
+ ret = gnutls_record_send(session, text, sizeof(text));
+ } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+ /* measure peer's processing time */
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
#define TLS_RECV
#ifdef TLS_RECV
- do {
- ret = gnutls_record_recv(session, buffer, sizeof(buffer));
- } while(ret < 0 && (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED));
+ do {
+ ret = gnutls_record_recv(session, buffer, sizeof(buffer));
+ } while (ret < 0
+ && (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED));
#else
- do {
- ret = recv(fd, buffer, sizeof(buffer), 0);
- } while(ret == -1 && errno == EAGAIN);
+ do {
+ ret = recv(fd, buffer, sizeof(buffer), 0);
+ } while (ret == -1 && errno == EAGAIN);
#endif
- if (taken < MAX_MEASUREMENTS(test->npoints) && ret > 0)
- {
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &stop);
- taken++;
- measurement = timespec_sub_ns(&stop, &start);
- prev_point_ptr->measurements[prev_point_ptr->midx] = measurement;
+ if (taken < MAX_MEASUREMENTS(test->npoints) && ret > 0) {
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &stop);
+ taken++;
+ measurement = timespec_sub_ns(&stop, &start);
+ prev_point_ptr->measurements[prev_point_ptr->midx] =
+ measurement;
/*fprintf(stderr, "(%u,%u): %lu\n", (unsigned) prev_point_ptr->byte1,
(unsigned) prev_point_ptr->byte2, measurements[taken]);*/
- memcpy(&measurement, buffer, sizeof(measurement));
- prev_point_ptr->smeasurements[prev_point_ptr->midx] = measurement;
- prev_point_ptr->midx++;
+ memcpy(&measurement, buffer, sizeof(measurement));
+ prev_point_ptr->smeasurements[prev_point_ptr->midx] =
+ measurement;
+ prev_point_ptr->midx++;
+
+ /* read server's measurement */
- /* read server's measurement */
-
#ifdef REHANDSHAKE
- gnutls_deinit(session);
-#endif
- goto restart;
- }
+ gnutls_deinit(session);
+#endif
+ goto restart;
+ }
#ifndef TLS_RECV
- else if (ret < 0)
- {
- fprintf(stderr, "Error in recv()\n");
- exit(1);
- }
+ else if (ret < 0) {
+ fprintf(stderr, "Error in recv()\n");
+ exit(1);
+ }
#endif
- gnutls_transport_set_push_function (session, push);
-
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- {
- double avg2, med, savg, smed;
- unsigned i;
- FILE* fp = NULL;
-
- if (test->file)
- fp = fopen(test->file, "w");
-
- if (fp) /* point, avg, median */
- fprintf(fp, "Delta,TimeAvg,TimeMedian,ServerAvg,ServerMedian\n");
-
- for (i=0;i<test->npoints;i++)
- {
- qsort( test->points[i].measurements, test->points[i].midx,
- sizeof(test->points[i].measurements[0]), compar);
-
- qsort( test->points[i].smeasurements, test->points[i].midx,
- sizeof(test->points[i].smeasurements[0]), compar);
-
- avg2 = calc_avg( test->points[i].measurements, test->points[i].midx);
- /*var = calc_var( test->points[i].measurements, test->points[i].midx, avg2);*/
- med = calc_median( test->points[i].measurements, test->points[i].midx);
-
- savg = calc_avg( test->points[i].smeasurements, test->points[i].midx);
- /*var = calc_var( test->points[i].measurements, test->points[i].midx, avg2);*/
- smed = calc_median( test->points[i].smeasurements, test->points[i].midx);
- /*min = calc_min( test->points[i].measurements, test->points[i].midx);*/
-
- if (fp) /* point, avg, median */
- fprintf(fp, "%u,%.2lf,%.2lf,%.2lf,%.2lf\n", (unsigned)test->points[i].byte1,
- avg2,med,savg, smed);
-
- /*printf("(%u) Avg: %.3f nanosec, Median: %.3f, Variance: %.3f\n", (unsigned)test->points[i].byte1,
- avg2, med, var);*/
- }
-
- if (fp)
- fclose(fp);
- }
-
- if (test->desc)
- fprintf(stderr, "Description: %s\n", test->desc);
-
- close (fd);
-
- gnutls_deinit (session);
-
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_global_deinit ();
+ gnutls_transport_set_push_function(session, push);
+
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ {
+ double avg2, med, savg, smed;
+ unsigned i;
+ FILE *fp = NULL;
+
+ if (test->file)
+ fp = fopen(test->file, "w");
+
+ if (fp) /* point, avg, median */
+ fprintf(fp,
+ "Delta,TimeAvg,TimeMedian,ServerAvg,ServerMedian\n");
+
+ for (i = 0; i < test->npoints; i++) {
+ qsort(test->points[i].measurements,
+ test->points[i].midx,
+ sizeof(test->points[i].measurements[0]),
+ compar);
+
+ qsort(test->points[i].smeasurements,
+ test->points[i].midx,
+ sizeof(test->points[i].smeasurements[0]),
+ compar);
+
+ avg2 =
+ calc_avg(test->points[i].measurements,
+ test->points[i].midx);
+ /*var = calc_var( test->points[i].measurements, test->points[i].midx, avg2); */
+ med =
+ calc_median(test->points[i].measurements,
+ test->points[i].midx);
+
+ savg =
+ calc_avg(test->points[i].smeasurements,
+ test->points[i].midx);
+ /*var = calc_var( test->points[i].measurements, test->points[i].midx, avg2); */
+ smed =
+ calc_median(test->points[i].smeasurements,
+ test->points[i].midx);
+ /*min = calc_min( test->points[i].measurements, test->points[i].midx); */
+
+ if (fp) /* point, avg, median */
+ fprintf(fp, "%u,%.2lf,%.2lf,%.2lf,%.2lf\n",
+ (unsigned) test->points[i].byte1,
+ avg2, med, savg, smed);
+
+ /*printf("(%u) Avg: %.3f nanosec, Median: %.3f, Variance: %.3f\n", (unsigned)test->points[i].byte1,
+ avg2, med, var); */
+ }
+
+ if (fp)
+ fclose(fp);
+ }
+
+ if (test->desc)
+ fprintf(stderr, "Description: %s\n", test->desc);
+
+ close(fd);
+
+ gnutls_deinit(session);
+
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
}
-static void
-server (int fd, const char* prio)
+static void server(int fd, const char *prio)
{
-int ret;
-char buffer[MAX_BUF + 1];
-gnutls_session_t session;
-gnutls_certificate_credentials_t x509_cred;
-const char* err;
-struct timespec start, stop;
-static unsigned long measurement;
+ int ret;
+ char buffer[MAX_BUF + 1];
+ gnutls_session_t session;
+ gnutls_certificate_credentials_t x509_cred;
+ const char *err;
+ struct timespec start, stop;
+ static unsigned long measurement;
- setpriority(PRIO_PROCESS, getpid(), -15);
+ setpriority(PRIO_PROCESS, getpid(), -15);
- /* this must be called once in the program
- */
- global_init ();
- memset(buffer, 0, sizeof(buffer));
+ /* this must be called once in the program
+ */
+ global_init();
+ memset(buffer, 0, sizeof(buffer));
#ifdef DEBUG
- gnutls_global_set_log_function (server_log_func);
- gnutls_global_set_log_level (6);
+ gnutls_global_set_log_function(server_log_func);
+ gnutls_global_set_log_level(6);
#endif
- gnutls_certificate_allocate_credentials (&x509_cred);
- ret = gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- {
- fprintf(stderr, "Could not set certificate\n");
- return;
- }
-
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ ret =
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0) {
+ fprintf(stderr, "Could not set certificate\n");
+ return;
+ }
#ifdef REHANDSHAKE
-restart:
+ restart:
#endif
- gnutls_init (&session, GNUTLS_SERVER);
-
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- if ((ret=gnutls_priority_set_direct (session, prio, &err)) < 0) {
- fprintf(stderr, "Error in priority string %s: %s\n", gnutls_strerror(ret), err);
- return;
- }
-
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
- gnutls_transport_set_int (session, fd);
-
- do
- {
- ret = gnutls_handshake (session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
- if (ret < 0)
- {
+ gnutls_init(&session, GNUTLS_SERVER);
+
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ if ((ret = gnutls_priority_set_direct(session, prio, &err)) < 0) {
+ fprintf(stderr, "Error in priority string %s: %s\n",
+ gnutls_strerror(ret), err);
+ return;
+ }
+
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+ gnutls_transport_set_int(session, fd);
+
+ do {
+ ret = gnutls_handshake(session);
+ }
+ while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ if (ret < 0) {
#ifdef GNUTLS_E_PREMATURE_TERMINATION
- if (ret != GNUTLS_E_PREMATURE_TERMINATION && ret != GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
+ if (ret != GNUTLS_E_PREMATURE_TERMINATION
+ && ret != GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
#else
- if (ret != GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
+ if (ret != GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
#endif
- {
- fprintf( stderr, "server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- }
- goto finish;
- }
-
+ {
+ fprintf(stderr,
+ "server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ }
+ goto finish;
+ }
#ifndef REHANDSHAKE
-restart:
+ restart:
#endif
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
-
- do {
- ret = gnutls_record_recv (session, buffer, sizeof (buffer));
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
+
+ do {
+ ret = gnutls_record_recv(session, buffer, sizeof(buffer));
+ } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &stop);
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &stop);
- if (ret == GNUTLS_E_DECRYPTION_FAILED)
- {
- gnutls_session_force_valid(session);
- measurement = timespec_sub_ns(&stop, &start);
- do {
- ret = gnutls_record_send(session, &measurement, sizeof(measurement));
- /* GNUTLS_AL_FATAL, GNUTLS_A_BAD_RECORD_MAC); */
- } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+ if (ret == GNUTLS_E_DECRYPTION_FAILED) {
+ gnutls_session_force_valid(session);
+ measurement = timespec_sub_ns(&stop, &start);
+ do {
+ ret =
+ gnutls_record_send(session, &measurement,
+ sizeof(measurement));
+ /* GNUTLS_AL_FATAL, GNUTLS_A_BAD_RECORD_MAC); */
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
#ifdef REHANDSHAKE
- gnutls_deinit(session);
+ gnutls_deinit(session);
#endif
- if (ret >= 0)
- goto restart;
- }
- else if (ret < 0)
- fprintf(stderr, "err: %s\n", gnutls_strerror(ret));
-
+ if (ret >= 0)
+ goto restart;
+ } else if (ret < 0)
+ fprintf(stderr, "err: %s\n", gnutls_strerror(ret));
+
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
-finish:
- close (fd);
- gnutls_deinit (session);
+ finish:
+ close(fd);
+ gnutls_deinit(session);
- gnutls_certificate_free_credentials (x509_cred);
+ gnutls_certificate_free_credentials(x509_cred);
- gnutls_global_deinit ();
+ gnutls_global_deinit();
}
-static void start (const char* prio, unsigned int text_size, struct test_st *p)
+static void start(const char *prio, unsigned int text_size,
+ struct test_st *p)
{
- int fd[2];
- int ret;
- pid_t child;
-
- ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
- if (ret < 0)
- {
- perror("socketpair");
- exit(1);
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fprintf( stderr, "fork");
- exit(1);
- }
-
- if (child != 0)
- {
- /* parent */
- close(fd[1]);
- server (fd[0], prio);
- kill(child, SIGTERM);
- }
- else if (child == 0)
- {
- close(fd[0]);
- client (fd[1], prio, text_size, p);
- exit(0);
- }
+ int fd[2];
+ int ret;
+ pid_t child;
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ if (ret < 0) {
+ perror("socketpair");
+ exit(1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fprintf(stderr, "fork");
+ exit(1);
+ }
+
+ if (child != 0) {
+ /* parent */
+ close(fd[1]);
+ server(fd[0], prio);
+ kill(child, SIGTERM);
+ } else if (child == 0) {
+ close(fd[0]);
+ client(fd[1], prio, text_size, p);
+ exit(0);
+ }
}
static void ch_handler(int sig)
{
-int status;
- wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- {
- if (WIFSIGNALED(status))
- fprintf(stderr, "Child died with sigsegv\n");
- else
- fprintf(stderr, "Child died with status %d\n", WEXITSTATUS(status));
- }
- return;
+ int status;
+ wait(&status);
+ if (WEXITSTATUS(status) != 0 ||
+ (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
+ if (WIFSIGNALED(status))
+ fprintf(stderr, "Child died with sigsegv\n");
+ else
+ fprintf(stderr, "Child died with status %d\n",
+ WEXITSTATUS(status));
+ }
+ return;
}
static struct point_st all_points[256];
@@ -609,12 +618,12 @@ static struct point_st all_points_one[256];
* for AES-SHA1.
*/
static struct test_st test_sha1 = {
- .points = all_points,
- .npoints = NPOINTS(all_points),
- .text_size = 18*16,
- .name = "sha1",
- .file = "out-sha1.txt",
- .desc = NULL
+ .points = all_points,
+ .npoints = NPOINTS(all_points),
+ .text_size = 18 * 16,
+ .name = "sha1",
+ .file = "out-sha1.txt",
+ .desc = NULL
};
/* Test that outputs a graph of the timings
@@ -622,12 +631,12 @@ static struct test_st test_sha1 = {
* for AES-SHA256.
*/
static struct test_st test_sha256 = {
- .points = all_points,
- .npoints = NPOINTS(all_points),
- .text_size = 17*16,
- .name = "sha256",
- .file = "out-sha256.txt",
- .desc = NULL
+ .points = all_points,
+ .npoints = NPOINTS(all_points),
+ .text_size = 17 * 16,
+ .name = "sha256",
+ .file = "out-sha256.txt",
+ .desc = NULL
};
/* Test that outputs a graph of the timings
@@ -635,12 +644,12 @@ static struct test_st test_sha256 = {
* for AES-SHA1, on a short message.
*/
static struct test_st test_sha1_short = {
- .points = all_points,
- .npoints = NPOINTS(all_points),
- .text_size = 16*2,
- .name = "sha1-short",
- .file = "out-sha1-short.txt",
- .desc = NULL
+ .points = all_points,
+ .npoints = NPOINTS(all_points),
+ .text_size = 16 * 2,
+ .name = "sha1-short",
+ .file = "out-sha1-short.txt",
+ .desc = NULL
};
/* Test that outputs a graph of the timings
@@ -648,12 +657,12 @@ static struct test_st test_sha1_short = {
* for AES-SHA256.
*/
static struct test_st test_sha256_short = {
- .points = all_points,
- .npoints = NPOINTS(all_points),
- .text_size = 16*2,
- .name = "sha256-short",
- .file = "out-sha256-short.txt",
- .desc = NULL
+ .points = all_points,
+ .npoints = NPOINTS(all_points),
+ .text_size = 16 * 2,
+ .name = "sha256-short",
+ .file = "out-sha256-short.txt",
+ .desc = NULL
};
/* Test that outputs a graph of the timings
@@ -664,146 +673,134 @@ static struct test_st test_sha256_short = {
* [1,1] shows up in the measurements)
*/
static struct test_st test_sha1_one = {
- .points = all_points_one,
- .npoints = NPOINTS(all_points_one),
- .text_size = 16*2,
- .name = "sha1-one",
- .file = "out-sha1-one.txt",
- .desc = NULL
+ .points = all_points_one,
+ .npoints = NPOINTS(all_points_one),
+ .text_size = 16 * 2,
+ .name = "sha1-one",
+ .file = "out-sha1-one.txt",
+ .desc = NULL
};
-int main(int argc, char** argv)
+int main(int argc, char **argv)
{
-unsigned int i;
-struct test_st* test;
-const char* hash;
-char prio[512];
-
- signal(SIGCHLD, ch_handler);
- signal(SIGPIPE, SIG_IGN);
-
- if (argc > 1)
- {
- if (strcmp(argv[1], "sha1")== 0)
- {
- test = &test_sha1;
- hash = "SHA1";
- }
- else if (strncmp(argv[1], "sha2", 4)== 0)
- {
- test = &test_sha256;
- hash = "SHA256";
- }
- else if (strcmp(argv[1], "sha1-short")== 0)
- {
- test = &test_sha1_short;
- hash = "SHA1";
- }
- else if (strcmp(argv[1], "sha256-short")== 0)
- {
- test = &test_sha256_short;
- hash = "SHA256";
- }
- else if (strcmp(argv[1], "sha1-one")== 0)
- {
- test = &test_sha1_one;
- hash = "SHA1";
- }
- else
- {
- fprintf(stderr, "Unknown test: %s\n", argv[1]);
- exit(1);
- }
- }
- else
- {
- fprintf(stderr, "Please specify the test, sha1, sha1-one, sha256, sha1-short, sha256-short\n");
- exit(1);
- }
-
- memset(&all_points, 0, sizeof(all_points));
- for (i=0;i<256;i++)
- {
- all_points[i].byte1 = i;
- all_points[i].measurements = malloc(MAX_PER_POINT*sizeof(all_points[i].measurements[0]));
- all_points[i].smeasurements = malloc(MAX_PER_POINT*sizeof(all_points[i].measurements[0]));
- }
-
- memset(&all_points_one, 0, sizeof(all_points_one));
- for (i=0;i<256;i++)
- {
- all_points_one[i].byte1 = i;
- all_points_one[i].byte2 = 1;
- all_points_one[i].measurements = all_points[i].measurements;
- all_points_one[i].smeasurements = all_points[i].smeasurements;
- }
-
-
- remove(test->file);
- snprintf(prio, sizeof(prio), "NONE:+COMP-NULL:+AES-128-CBC:+%s:+RSA:%%COMPAT:+VERS-TLS1.2:+VERS-TLS1.1", hash);
-
- printf("\nAES-%s (calculating different padding timings)\n", hash);
- start(prio, test->text_size, test);
-
- signal(SIGCHLD, SIG_IGN);
-
+ unsigned int i;
+ struct test_st *test;
+ const char *hash;
+ char prio[512];
+
+ signal(SIGCHLD, ch_handler);
+ signal(SIGPIPE, SIG_IGN);
+
+ if (argc > 1) {
+ if (strcmp(argv[1], "sha1") == 0) {
+ test = &test_sha1;
+ hash = "SHA1";
+ } else if (strncmp(argv[1], "sha2", 4) == 0) {
+ test = &test_sha256;
+ hash = "SHA256";
+ } else if (strcmp(argv[1], "sha1-short") == 0) {
+ test = &test_sha1_short;
+ hash = "SHA1";
+ } else if (strcmp(argv[1], "sha256-short") == 0) {
+ test = &test_sha256_short;
+ hash = "SHA256";
+ } else if (strcmp(argv[1], "sha1-one") == 0) {
+ test = &test_sha1_one;
+ hash = "SHA1";
+ } else {
+ fprintf(stderr, "Unknown test: %s\n", argv[1]);
+ exit(1);
+ }
+ } else {
+ fprintf(stderr,
+ "Please specify the test, sha1, sha1-one, sha256, sha1-short, sha256-short\n");
+ exit(1);
+ }
+
+ memset(&all_points, 0, sizeof(all_points));
+ for (i = 0; i < 256; i++) {
+ all_points[i].byte1 = i;
+ all_points[i].measurements =
+ malloc(MAX_PER_POINT *
+ sizeof(all_points[i].measurements[0]));
+ all_points[i].smeasurements =
+ malloc(MAX_PER_POINT *
+ sizeof(all_points[i].measurements[0]));
+ }
+
+ memset(&all_points_one, 0, sizeof(all_points_one));
+ for (i = 0; i < 256; i++) {
+ all_points_one[i].byte1 = i;
+ all_points_one[i].byte2 = 1;
+ all_points_one[i].measurements =
+ all_points[i].measurements;
+ all_points_one[i].smeasurements =
+ all_points[i].smeasurements;
+ }
+
+
+ remove(test->file);
+ snprintf(prio, sizeof(prio),
+ "NONE:+COMP-NULL:+AES-128-CBC:+%s:+RSA:%%COMPAT:+VERS-TLS1.2:+VERS-TLS1.1",
+ hash);
+
+ printf("\nAES-%s (calculating different padding timings)\n", hash);
+ start(prio, test->text_size, test);
+
+ signal(SIGCHLD, SIG_IGN);
+
#ifdef PDF
- snprintf(prio, sizeof(prio),
- "R -e 'pdf(file=\"%s-timings-avg.pdf\");z=read.csv(\"%s\");"
- "plot(z$Delta,z$TimeAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");"
- "dev.off();'"
- test->name, test->file);
- system(prio);
-
- snprintf(prio, sizeof(prio),
- "R -e 'pdf(file=\"%s-timings-med.pdf\");z=read.csv(\"%s\");"
- "plot(z$Delta,z$TimeMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");"
- "dev.off();'";
- test->name, test->file);
- system(prio);
-
- snprintf(prio, sizeof(prio),
- "R -e 'pdf(file=\"%s-server-timings-avg.pdf\");z=read.csv(\"%s\");"
- "plot(z$Delta,z$ServerAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");"
- "dev.off();'"
- test->name, test->file);
- system(prio);
-
- snprintf(prio, sizeof(prio),
- "R -e 'pdf(file=\"%s-server-timings-med.pdf\");z=read.csv(\"%s\");"
- "plot(z$Delta,z$ServerMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");"
- "dev.off();'";
- test->name, test->file);
- system(prio);
+ snprintf(prio, sizeof(prio),
+ "R -e 'pdf(file=\"%s-timings-avg.pdf\");z=read.csv(\"%s\");"
+ "plot(z$Delta,z$TimeAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");"
+ "dev.off();'" test->name, test->file);
+ system(prio);
+
+ snprintf(prio, sizeof(prio),
+ "R -e 'pdf(file=\"%s-timings-med.pdf\");z=read.csv(\"%s\");"
+ "plot(z$Delta,z$TimeMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");"
+ "dev.off();'"; test->name, test->file);
+ system(prio);
+
+ snprintf(prio, sizeof(prio),
+ "R -e 'pdf(file=\"%s-server-timings-avg.pdf\");z=read.csv(\"%s\");"
+ "plot(z$Delta,z$ServerAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");"
+ "dev.off();'" test->name, test->file);
+ system(prio);
+
+ snprintf(prio, sizeof(prio),
+ "R -e 'pdf(file=\"%s-server-timings-med.pdf\");z=read.csv(\"%s\");"
+ "plot(z$Delta,z$ServerMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");"
+ "dev.off();'"; test->name, test->file);
+ system(prio);
#else
- snprintf(prio, sizeof(prio),
- "R -e 'z=read.csv(\"%s\");png(filename = \"%s-timings-avg.png\",width=1024,height=1024,units=\"px\","
- "bg=\"white\");plot(z$Delta,z$TimeAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");dev.off();'",
- test->file, test->name);
- system(prio);
-
- snprintf(prio, sizeof(prio),
- "R -e 'z=read.csv(\"%s\");"
- "png(filename = \"%s-timings-med.png\",width=1024,height=1024,units=\"px\","
- "bg=\"white\");plot(z$Delta,z$TimeMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");dev.off();'",
- test->file, test->name);
- system(prio);
-
- snprintf(prio, sizeof(prio),
- "R -e 'z=read.csv(\"%s\");png(filename = \"%s-server-timings-avg.png\",width=1024,height=1024,units=\"px\","
- "bg=\"white\");plot(z$Delta,z$ServerAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");dev.off();'",
- test->file, test->name);
- system(prio);
-
- snprintf(prio, sizeof(prio),
- "R -e 'z=read.csv(\"%s\");"
- "png(filename = \"%s-server-timings-med.png\",width=1024,height=1024,units=\"px\","
- "bg=\"white\");plot(z$Delta,z$ServerMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");dev.off();'",
- test->file, test->name);
- system(prio);
+ snprintf(prio, sizeof(prio),
+ "R -e 'z=read.csv(\"%s\");png(filename = \"%s-timings-avg.png\",width=1024,height=1024,units=\"px\","
+ "bg=\"white\");plot(z$Delta,z$TimeAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");dev.off();'",
+ test->file, test->name);
+ system(prio);
+
+ snprintf(prio, sizeof(prio),
+ "R -e 'z=read.csv(\"%s\");"
+ "png(filename = \"%s-timings-med.png\",width=1024,height=1024,units=\"px\","
+ "bg=\"white\");plot(z$Delta,z$TimeMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");dev.off();'",
+ test->file, test->name);
+ system(prio);
+
+ snprintf(prio, sizeof(prio),
+ "R -e 'z=read.csv(\"%s\");png(filename = \"%s-server-timings-avg.png\",width=1024,height=1024,units=\"px\","
+ "bg=\"white\");plot(z$Delta,z$ServerAvg,xlab=\"Delta\",ylab=\"Average timings (ns)\");dev.off();'",
+ test->file, test->name);
+ system(prio);
+
+ snprintf(prio, sizeof(prio),
+ "R -e 'z=read.csv(\"%s\");"
+ "png(filename = \"%s-server-timings-med.png\",width=1024,height=1024,units=\"px\","
+ "bg=\"white\");plot(z$Delta,z$ServerMedian,xlab=\"Delta\",ylab=\"Median timings (ns)\");dev.off();'",
+ test->file, test->name);
+ system(prio);
#endif
- return 0;
+ return 0;
}
-#endif /* _WIN32 */
-
+#endif /* _WIN32 */
diff --git a/tests/utils.c b/tests/utils.c
index 490c1e2f3a..e77541bcf5 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -27,7 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
-
+
#include "utils.h"
int debug = 0;
@@ -35,127 +35,120 @@ int error_count = 0;
int break_on_error = 0;
const char *pkcs3 =
- "-----BEGIN DH PARAMETERS-----\n"
- "MIGGAoGAtkxw2jlsVCsrfLqxrN+IrF/3W8vVFvDzYbLmxi2GQv9s/PQGWP1d9i22\n"
- "P2DprfcJknWt7KhCI1SaYseOQIIIAYP78CfyIpGScW/vS8khrw0rlQiyeCvQgF3O\n"
- "GeGOEywcw+oQT4SmFOD7H0smJe2CNyjYpexBXQ/A0mbTF9QKm1cCAQU=\n"
- "-----END DH PARAMETERS-----\n";
-
-void
-fail (const char *format, ...)
+ "-----BEGIN DH PARAMETERS-----\n"
+ "MIGGAoGAtkxw2jlsVCsrfLqxrN+IrF/3W8vVFvDzYbLmxi2GQv9s/PQGWP1d9i22\n"
+ "P2DprfcJknWt7KhCI1SaYseOQIIIAYP78CfyIpGScW/vS8khrw0rlQiyeCvQgF3O\n"
+ "GeGOEywcw+oQT4SmFOD7H0smJe2CNyjYpexBXQ/A0mbTF9QKm1cCAQU=\n"
+ "-----END DH PARAMETERS-----\n";
+
+void fail(const char *format, ...)
{
- char str[1024];
- va_list arg_ptr;
-
- va_start (arg_ptr, format);
- vsnprintf ( str, sizeof(str), format, arg_ptr);
- va_end (arg_ptr);
- fputs(str, stderr);
- error_count++;
- if (break_on_error)
- exit (1);
+ char str[1024];
+ va_list arg_ptr;
+
+ va_start(arg_ptr, format);
+ vsnprintf(str, sizeof(str), format, arg_ptr);
+ va_end(arg_ptr);
+ fputs(str, stderr);
+ error_count++;
+ if (break_on_error)
+ exit(1);
}
-void
-success (const char *format, ...)
+void success(const char *format, ...)
{
- char str[1024];
- va_list arg_ptr;
+ char str[1024];
+ va_list arg_ptr;
- va_start (arg_ptr, format);
- vsnprintf ( str, sizeof(str), format, arg_ptr);
- va_end (arg_ptr);
- fputs(str, stderr);
+ va_start(arg_ptr, format);
+ vsnprintf(str, sizeof(str), format, arg_ptr);
+ va_end(arg_ptr);
+ fputs(str, stderr);
}
-void
-escapeprint (const char *str, size_t len)
+void escapeprint(const char *str, size_t len)
{
- size_t i;
-
- printf (" (length %d bytes):\n\t", (int) len);
- for (i = 0; i < len; i++)
- {
- if (((str[i] & 0xFF) >= 'A' && (str[i] & 0xFF) <= 'Z') ||
- ((str[i] & 0xFF) >= 'a' && (str[i] & 0xFF) <= 'z') ||
- ((str[i] & 0xFF) >= '0' && (str[i] & 0xFF) <= '9')
- || (str[i] & 0xFF) == ' ' || (str[i] & 0xFF) == '.')
- printf ("%c", (str[i] & 0xFF));
- else
- printf ("\\x%02X", (str[i] & 0xFF));
- if ((i + 1) % 16 == 0 && (i + 1) < len)
- printf ("'\n\t'");
- }
- printf ("\n");
+ size_t i;
+
+ printf(" (length %d bytes):\n\t", (int) len);
+ for (i = 0; i < len; i++) {
+ if (((str[i] & 0xFF) >= 'A' && (str[i] & 0xFF) <= 'Z') ||
+ ((str[i] & 0xFF) >= 'a' && (str[i] & 0xFF) <= 'z') ||
+ ((str[i] & 0xFF) >= '0' && (str[i] & 0xFF) <= '9')
+ || (str[i] & 0xFF) == ' ' || (str[i] & 0xFF) == '.')
+ printf("%c", (str[i] & 0xFF));
+ else
+ printf("\\x%02X", (str[i] & 0xFF));
+ if ((i + 1) % 16 == 0 && (i + 1) < len)
+ printf("'\n\t'");
+ }
+ printf("\n");
}
-void
-hexprint (const void *_str, size_t len)
+void hexprint(const void *_str, size_t len)
{
- size_t i;
- const char* str = _str;
-
- printf ("\t;; ");
- for (i = 0; i < len; i++)
- {
- printf ("%02x ", (str[i] & 0xFF));
- if ((i + 1) % 8 == 0)
- printf (" ");
- if ((i + 1) % 16 == 0 && i + 1 < len)
- printf ("\n\t;; ");
- }
- printf ("\n");
+ size_t i;
+ const char *str = _str;
+
+ printf("\t;; ");
+ for (i = 0; i < len; i++) {
+ printf("%02x ", (str[i] & 0xFF));
+ if ((i + 1) % 8 == 0)
+ printf(" ");
+ if ((i + 1) % 16 == 0 && i + 1 < len)
+ printf("\n\t;; ");
+ }
+ printf("\n");
}
-void
-binprint (const void *_str, size_t len)
+void binprint(const void *_str, size_t len)
{
- size_t i;
- const char* str = _str;
-
- printf ("\t;; ");
- for (i = 0; i < len; i++)
- {
- printf ("%d%d%d%d%d%d%d%d ",
- (str[i] & 0xFF) & 0x80 ? 1 : 0,
- (str[i] & 0xFF) & 0x40 ? 1 : 0,
- (str[i] & 0xFF) & 0x20 ? 1 : 0,
- (str[i] & 0xFF) & 0x10 ? 1 : 0,
- (str[i] & 0xFF) & 0x08 ? 1 : 0,
- (str[i] & 0xFF) & 0x04 ? 1 : 0,
- (str[i] & 0xFF) & 0x02 ? 1 : 0, (str[i] & 0xFF) & 0x01 ? 1 : 0);
- if ((i + 1) % 3 == 0)
- printf (" ");
- if ((i + 1) % 6 == 0 && i + 1 < len)
- printf ("\n\t;; ");
- }
- printf ("\n");
+ size_t i;
+ const char *str = _str;
+
+ printf("\t;; ");
+ for (i = 0; i < len; i++) {
+ printf("%d%d%d%d%d%d%d%d ",
+ (str[i] & 0xFF) & 0x80 ? 1 : 0,
+ (str[i] & 0xFF) & 0x40 ? 1 : 0,
+ (str[i] & 0xFF) & 0x20 ? 1 : 0,
+ (str[i] & 0xFF) & 0x10 ? 1 : 0,
+ (str[i] & 0xFF) & 0x08 ? 1 : 0,
+ (str[i] & 0xFF) & 0x04 ? 1 : 0,
+ (str[i] & 0xFF) & 0x02 ? 1 : 0,
+ (str[i] & 0xFF) & 0x01 ? 1 : 0);
+ if ((i + 1) % 3 == 0)
+ printf(" ");
+ if ((i + 1) % 6 == 0 && i + 1 < len)
+ printf("\n\t;; ");
+ }
+ printf("\n");
}
-int
-main (int argc, char *argv[])
+int main(int argc, char *argv[])
{
- do
- if (strcmp (argv[argc - 1], "-v") == 0 ||
- strcmp (argv[argc - 1], "--verbose") == 0)
- debug = 1;
- else if (strcmp (argv[argc - 1], "-b") == 0 ||
- strcmp (argv[argc - 1], "--break-on-error") == 0)
- break_on_error = 1;
- else if (strcmp (argv[argc - 1], "-h") == 0 ||
- strcmp (argv[argc - 1], "-?") == 0 ||
- strcmp (argv[argc - 1], "--help") == 0)
- {
- printf ("Usage: %s [-vbh?] [--verbose] [--break-on-error] [--help]\n",
- argv[0]);
- return 1;
- }
- while (argc-- > 1);
-
- doit ();
-
- if (debug || error_count > 0)
- printf ("Self test `%s' finished with %d errors\n", argv[0], error_count);
-
- return error_count ? 1 : 0;
+ do
+ if (strcmp(argv[argc - 1], "-v") == 0 ||
+ strcmp(argv[argc - 1], "--verbose") == 0)
+ debug = 1;
+ else if (strcmp(argv[argc - 1], "-b") == 0 ||
+ strcmp(argv[argc - 1], "--break-on-error") == 0)
+ break_on_error = 1;
+ else if (strcmp(argv[argc - 1], "-h") == 0 ||
+ strcmp(argv[argc - 1], "-?") == 0 ||
+ strcmp(argv[argc - 1], "--help") == 0) {
+ printf
+ ("Usage: %s [-vbh?] [--verbose] [--break-on-error] [--help]\n",
+ argv[0]);
+ return 1;
+ }
+ while (argc-- > 1);
+
+ doit();
+
+ if (debug || error_count > 0)
+ printf("Self test `%s' finished with %d errors\n", argv[0],
+ error_count);
+
+ return error_count ? 1 : 0;
}
diff --git a/tests/utils.h b/tests/utils.h
index d156187f20..7d89e8ce97 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -30,15 +30,16 @@
#ifndef __attribute__
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#define __attribute__(Spec) /* empty */
+#define __attribute__(Spec) /* empty */
#endif
#endif
-inline static int global_init(void) {
+inline static int global_init(void)
+{
#ifdef ENABLE_PKCS11
- gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
+ gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
#endif
- return gnutls_global_init();
+ return gnutls_global_init();
}
extern int debug;
@@ -47,16 +48,16 @@ extern int break_on_error;
extern const char *pkcs3;
-extern void fail (const char *format, ...)
- __attribute__ ((format (printf, 1, 2)));
-extern void success (const char *format, ...)
- __attribute__ ((format (printf, 1, 2)));
+extern void fail(const char *format, ...)
+ __attribute__ ((format(printf, 1, 2)));
+extern void success(const char *format, ...)
+ __attribute__ ((format(printf, 1, 2)));
-extern void escapeprint (const char *str, size_t len);
-extern void hexprint (const void *str, size_t len);
-extern void binprint (const void *str, size_t len);
+extern void escapeprint(const char *str, size_t len);
+extern void hexprint(const void *str, size_t len);
+extern void binprint(const void *str, size_t len);
/* This must be implemented elsewhere. */
-extern void doit (void);
+extern void doit(void);
-#endif /* UTILS_H */
+#endif /* UTILS_H */
diff --git a/tests/x509_altname.c b/tests/x509_altname.c
index 48ee402d79..bec6484b89 100644
--- a/tests/x509_altname.c
+++ b/tests/x509_altname.c
@@ -30,101 +30,94 @@
#include "utils.h"
static char pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIE6zCCA9OgAwIBAgIBdjANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJTRTEf\n"
- "MB0GA1UEChMWU3RvY2tob2xtcyB1bml2ZXJzaXRldDEgMB4GA1UEAxMXU3RvY2to\n"
- "b2xtIFVuaXZlcnNpdHkgQ0EwHhcNMDYwMzIyMDkxNTI4WhcNMDcwMzIyMDkxNTI4\n"
- "WjBDMQswCQYDVQQGEwJTRTEfMB0GA1UEChMWU3RvY2tob2xtcyB1bml2ZXJzaXRl\n"
- "dDETMBEGA1UEAxMKc2lwMS5zdS5zZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC\n"
- "gYEArUzXTD36ZK7CwZJH/faUNTcdaqM7JyiZsfrO703d7cT/bJ3wKxT8trOOh/Ou\n"
- "WwgGFX2+r7ykun3aIUXUuD13Yle/yHqH/4g9vWX7UeFCBlSI0tAxnlqt0QqlPgSd\n"
- "GLHcoO4PPyjon9jj0A/zpJGZHiRUCooo63YqE9MYfr5HBfkCAwEAAaOCAl8wggJb\n"
- "MAsGA1UdDwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHQYD\n"
- "VR0OBBYEFDpcXNHMLJ7fc/c72BtZseq4MDXFMH8GA1UdIwR4MHaAFJ4uMLo32VFE\n"
- "yZ2/GCHxvX7utYZIoVukWTBXMQswCQYDVQQGEwJTRTEYMBYGA1UEChMPVW1lYSBV\n"
- "bml2ZXJzaXR5MRMwEQYDVQQLEwpTd1VQS0ktUENBMRkwFwYDVQQDExBTd1VQS0kg\n"
- "UG9saWN5IENBggEQMDIGA1UdHwQrMCkwJ6AloCOGIWh0dHA6Ly9jYS5zdS5zZS8y\n"
- "MDA1LTEvY3JsLXYyLmNybDB5BgNVHSAEcjBwMG4GCCqFcCsCAQEBMGIw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BgNVHREEga8wgayC\n"
+ "F2luY29taW5ncHJveHkuc2lwLnN1LnNlghhpbmNvbWluZ3Byb3h5MS5zaXAuc3Uu\n"
+ "c2WCF291dGdvaW5ncHJveHkuc2lwLnN1LnNlghhvdXRnb2luZ3Byb3h5MS5zaXAu\n"
+ "c3Uuc2WCDW91dC5zaXAuc3Uuc2WCE2FwcHNlcnZlci5zaXAuc3Uuc2WCFGFwcHNl\n"
+ "cnZlcjEuc2lwLnN1LnNlggpzaXAxLnN1LnNlMA0GCSqGSIb3DQEBBQUAA4IBAQAR\n"
+ "FYg7ytcph0E7WmvM44AN/8qru7tRX6aSFWrjLyVr/1Wk4prCK4y5JpfNw5dh9Z8f\n"
+ "/gyFsr1iFsb6fS3nJTTd3fVlWRfcNCGIx5g8KuSb3u6f7VznkGOeiRMRESQc1G8B\n"
+ "eh0zbdZS7BYO2g9EKlbGST5PwQnc4g9K7pqPyKSNVkzb60Nujg/+qYje7MCcN+ZR\n"
+ "nUBo6U2NZ06/QEUFm+uUIhZ8IGM1gLehC7Q3G4+d4c38CDJxQnSPOgWiXuSvhhQm\n"
+ "KDsbrKzRaeBRh5eEJbTkA8Dp0Emb0UrkRVhixeg97stxUcATAjdGljJ9MLnuHXnI\n"
+ "7ihGdUfg5q/105vpsQpO\n" "-----END CERTIFICATE-----\n";
#define MAX_DATA_SIZE 1024
-void
-doit (void)
+void doit(void)
{
- int ret;
- gnutls_datum_t derCert = { (void*)pem, sizeof (pem) };
- gnutls_x509_crt_t cert;
- size_t data_len = MAX_DATA_SIZE;
- char data[MAX_DATA_SIZE];
- unsigned int critical = 0;
- int alt_name_count = 0;
+ int ret;
+ gnutls_datum_t derCert = { (void *) pem, sizeof(pem) };
+ gnutls_x509_crt_t cert;
+ size_t data_len = MAX_DATA_SIZE;
+ char data[MAX_DATA_SIZE];
+ unsigned int critical = 0;
+ int alt_name_count = 0;
- ret = global_init ();
- if (ret < 0)
- fail ("init %d\n", ret);
+ ret = global_init();
+ if (ret < 0)
+ fail("init %d\n", ret);
- ret = gnutls_x509_crt_init (&cert);
- if (ret < 0)
- fail ("crt_init %d\n", ret);
+ ret = gnutls_x509_crt_init(&cert);
+ if (ret < 0)
+ fail("crt_init %d\n", ret);
- ret = gnutls_x509_crt_import (cert, &derCert, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("crt_import %d\n", ret);
+ ret = gnutls_x509_crt_import(cert, &derCert, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("crt_import %d\n", ret);
- for (alt_name_count = 0;; ++alt_name_count)
- {
- ret =
- gnutls_x509_crt_get_issuer_alt_name (cert, alt_name_count, data,
- &data_len, &critical);
- if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- break;
+ for (alt_name_count = 0;; ++alt_name_count) {
+ ret =
+ gnutls_x509_crt_get_issuer_alt_name(cert,
+ alt_name_count,
+ data, &data_len,
+ &critical);
+ if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ break;
- if (ret < 0)
- fail ("get_issuer_alt_name: %d\n", ret);
+ if (ret < 0)
+ fail("get_issuer_alt_name: %d\n", ret);
- // TODO: print out / check results
- if (GNUTLS_SAN_URI == ret)
- {
- if (strcmp (data, "http://ca.su.se") != 0)
- {
- fail ("unexpected issuer GNUTLS_SAN_URI: %s\n", data);
- }
- }
- else if (GNUTLS_SAN_RFC822NAME == ret)
- {
- if (strcmp (data, "ca@su.se") != 0)
- {
- fail ("unexpected issuer GNUTLS_SAN_RFC822NAME: %s\n", data);
- }
- }
- else
- {
- fail ("unexpected alt name type: %d\n", ret);
- }
- data_len = MAX_DATA_SIZE;
- }
+ // TODO: print out / check results
+ if (GNUTLS_SAN_URI == ret) {
+ if (strcmp(data, "http://ca.su.se") != 0) {
+ fail("unexpected issuer GNUTLS_SAN_URI: %s\n", data);
+ }
+ } else if (GNUTLS_SAN_RFC822NAME == ret) {
+ if (strcmp(data, "ca@su.se") != 0) {
+ fail("unexpected issuer GNUTLS_SAN_RFC822NAME: %s\n", data);
+ }
+ } else {
+ fail("unexpected alt name type: %d\n", ret);
+ }
+ data_len = MAX_DATA_SIZE;
+ }
- if (alt_name_count != 2)
- {
- fail ("unexpected number of alt names: %i\n", alt_name_count);
- }
+ if (alt_name_count != 2) {
+ fail("unexpected number of alt names: %i\n",
+ alt_name_count);
+ }
- if (debug)
- success ("done\n");
+ if (debug)
+ success("done\n");
- gnutls_x509_crt_deinit (cert);
- gnutls_global_deinit ();
+ gnutls_x509_crt_deinit(cert);
+ gnutls_global_deinit();
}
diff --git a/tests/x509cert-tl.c b/tests/x509cert-tl.c
index 3f4329a670..7ba147f079 100644
--- a/tests/x509cert-tl.c
+++ b/tests/x509cert-tl.c
@@ -39,241 +39,273 @@
/* gnutls_trust_list_*().
*/
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "<%d>| %s", level, str);
+ fprintf(stderr, "<%d>| %s", level, str);
}
static unsigned char ca_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
- "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
- "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
- "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
- "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
- "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQAMB0GA1UdDgQWBBTpPBz7rZJu5gak\n"
- "Viyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAiaIRqGfp1jPpNeVhABK60SU0KIAy\n"
- "njuu7kHq5peUgYn8Jd9zNzExBOEp1VOipGsf6G66oQAhDFp2o8zkz7ZH71zR4HEW\n"
- "KoX6n5Emn6DvcEH/9pAhnGxNHJAoS7czTKv/JDZJhkqHxyrE1fuLsg5Qv25DTw7+\n"
- "PfqUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t ca = { ca_pem, sizeof (ca_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
+ "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
+ "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
+ "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
+ "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
+ "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQAMB0GA1UdDgQWBBTpPBz7rZJu5gak\n"
+ "Viyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAiaIRqGfp1jPpNeVhABK60SU0KIAy\n"
+ "njuu7kHq5peUgYn8Jd9zNzExBOEp1VOipGsf6G66oQAhDFp2o8zkz7ZH71zR4HEW\n"
+ "KoX6n5Emn6DvcEH/9pAhnGxNHJAoS7czTKv/JDZJhkqHxyrE1fuLsg5Qv25DTw7+\n"
+ "PfqUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t ca = { ca_pem, sizeof(ca_pem) };
static unsigned char cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t cert = { cert_pem, sizeof (cert_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
+ "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
+ "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
+ "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
+ "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
+ "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
+ "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
+ "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
+ "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
+ "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
+ "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t cert = { cert_pem, sizeof(cert_pem) };
static unsigned char key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
- "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
- "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
- "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
- "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+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0CQQDYy+RlTmwRD6hy\n"
+ "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
+ "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
+ "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
+ "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
+ "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
+ "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
+ "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
+ "-----END RSA PRIVATE KEY-----\n";
+const gnutls_datum_t key = { key_pem, sizeof(key_pem) };
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAj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gw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aW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OnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
static unsigned char cert_der[602] =
- "\x30\x82\x02\x56\x30\x82\x01\xc1\xa0\x03\x02\x01\x02\x02\x04\x46"
- "\x26\x1d\x31\x30\x0b\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05"
- "\x30\x19\x31\x17\x30\x15\x06\x03\x55\x04\x03\x13\x0e\x47\x6e\x75"
- "\x54\x4c\x53\x20\x74\x65\x73\x74\x20\x43\x41\x30\x1e\x17\x0d\x30"
- "\x37\x30\x34\x31\x38\x31\x33\x32\x39\x32\x31\x5a\x17\x0d\x30\x38"
- "\x30\x34\x31\x37\x31\x33\x32\x39\x32\x31\x5a\x30\x37\x31\x1b\x30"
- "\x19\x06\x03\x55\x04\x0a\x13\x12\x47\x6e\x75\x54\x4c\x53\x20\x74"
- "\x65\x73\x74\x20\x73\x65\x72\x76\x65\x72\x31\x18\x30\x16\x06\x03"
- "\x55\x04\x03\x13\x0f\x74\x65\x73\x74\x2e\x67\x6e\x75\x74\x6c\x73"
- "\x2e\x6f\x72\x67\x30\x81\x9c\x30\x0b\x06\x09\x2a\x86\x48\x86\xf7"
- "\x0d\x01\x01\x01\x03\x81\x8c\x00\x30\x81\x88\x02\x81\x80\xd7\xba"
- "\x5c\xaf\xa3\x0c\xf0\x2e\xa9\x27\x56\xaa\x53\x8e\xa8\xeb\x7f\x81"
- "\x75\x4c\x6b\x98\xbe\x4a\xea\xb7\x1e\xf8\x4b\xc3\x6a\xc4\xda\x0d"
- "\x00\xb8\xea\x4c\x13\x1f\x36\x16\x93\xde\x72\xef\xc6\xa4\x5e\xb2"
- "\x6e\xb6\xca\x0a\x88\x55\x75\x90\x96\xed\xa6\x57\xbc\x0c\x3b\x76"
- "\x0d\x97\x1e\xbd\xe9\xec\x7f\xd3\xa9\xec\xfb\x85\x64\xa0\x6b\xa0"
- "\x48\xce\x77\x7e\x73\x9c\x31\x13\xff\x3d\xc8\xae\xa5\x60\x6e\xd9"
- "\xb6\x8c\x5a\x9a\x6f\xb6\xbe\x9f\x6a\xbd\xa7\xf0\xa0\x33\x27\xf5"
- "\xb7\x1d\x92\xe5\x96\x9c\x73\x52\xd6\x9f\xd6\xc8\x8e\xb1\x02\x03"
- "\x01\x00\x01\xa3\x81\x93\x30\x81\x90\x30\x0c\x06\x03\x55\x1d\x13"
- "\x01\x01\xff\x04\x02\x30\x00\x30\x1a\x06\x03\x55\x1d\x11\x04\x13"
- "\x30\x11\x82\x0f\x74\x65\x73\x74\x2e\x67\x6e\x75\x74\x6c\x73\x2e"
- "\x6f\x72\x67\x30\x13\x06\x03\x55\x1d\x25\x04\x0c\x30\x0a\x06\x08"
- "\x2b\x06\x01\x05\x05\x07\x03\x01\x30\x0f\x06\x03\x55\x1d\x0f\x01"
- "\x01\xff\x04\x05\x03\x03\x07\xa0\x00\x30\x1d\x06\x03\x55\x1d\x0e"
- "\x04\x16\x04\x14\xeb\xc7\x45\x6e\xe5\xf8\x25\xca\x8c\x8d\x83\x0d"
- "\x74\xe9\x86\xd4\xdd\x55\xb4\x75\x30\x1f\x06\x03\x55\x1d\x23\x04"
- "\x18\x30\x16\x80\x14\xe9\x3c\x1c\xfb\xad\x92\x6e\xe6\x06\xa4\x56"
- "\x2c\xa2\xe1\xc0\x53\x27\xc8\xf2\x95\x30\x0b\x06\x09\x2a\x86\x48"
- "\x86\xf7\x0d\x01\x01\x05\x03\x81\x81\x00\x68\x51\x0f\x4e\xdf\xbb"
- "\x6f\x3b\xc1\xb8\xe7\xfb\xf9\x09\x9e\x41\xc9\xf6\xf6\x44\xfa\x06"
- "\xcc\xa1\xd5\x11\xc9\x5d\xff\x0a\x4e\x4e\x50\x45\xfc\x29\xea\x88"
- "\x1b\xa7\xde\x09\x41\x67\x0d\x43\xf4\xbb\x60\x31\x47\x82\x50\xf5"
- "\x03\x05\x0d\x05\x15\xf0\x77\x7a\xe2\x52\xc3\x27\xb3\x18\x1e\x48"
- "\x3c\x58\x05\xf2\x58\x6c\x32\xde\xa2\x13\x41\xb2\xa6\x8f\x0c\x96"
- "\xfb\x5d\xa8\xa5\x59\xb3\x10\x29\xf0\x1b\x15\x0f\x1c\x9c\xec\x60"
- "\xac\xe2\x8b\x51\x04\x56\x27\x42\xb7\x1f\x25\xd1\x32\x16\xea\x8d"
- "\xd2\xc8\x69\x08\x82\xbd\x02\xee\x8b\x3a";
+ "\x30\x82\x02\x56\x30\x82\x01\xc1\xa0\x03\x02\x01\x02\x02\x04\x46"
+ "\x26\x1d\x31\x30\x0b\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05"
+ "\x30\x19\x31\x17\x30\x15\x06\x03\x55\x04\x03\x13\x0e\x47\x6e\x75"
+ "\x54\x4c\x53\x20\x74\x65\x73\x74\x20\x43\x41\x30\x1e\x17\x0d\x30"
+ "\x37\x30\x34\x31\x38\x31\x33\x32\x39\x32\x31\x5a\x17\x0d\x30\x38"
+ "\x30\x34\x31\x37\x31\x33\x32\x39\x32\x31\x5a\x30\x37\x31\x1b\x30"
+ "\x19\x06\x03\x55\x04\x0a\x13\x12\x47\x6e\x75\x54\x4c\x53\x20\x74"
+ "\x65\x73\x74\x20\x73\x65\x72\x76\x65\x72\x31\x18\x30\x16\x06\x03"
+ "\x55\x04\x03\x13\x0f\x74\x65\x73\x74\x2e\x67\x6e\x75\x74\x6c\x73"
+ "\x2e\x6f\x72\x67\x30\x81\x9c\x30\x0b\x06\x09\x2a\x86\x48\x86\xf7"
+ "\x0d\x01\x01\x01\x03\x81\x8c\x00\x30\x81\x88\x02\x81\x80\xd7\xba"
+ "\x5c\xaf\xa3\x0c\xf0\x2e\xa9\x27\x56\xaa\x53\x8e\xa8\xeb\x7f\x81"
+ "\x75\x4c\x6b\x98\xbe\x4a\xea\xb7\x1e\xf8\x4b\xc3\x6a\xc4\xda\x0d"
+ "\x00\xb8\xea\x4c\x13\x1f\x36\x16\x93\xde\x72\xef\xc6\xa4\x5e\xb2"
+ "\x6e\xb6\xca\x0a\x88\x55\x75\x90\x96\xed\xa6\x57\xbc\x0c\x3b\x76"
+ "\x0d\x97\x1e\xbd\xe9\xec\x7f\xd3\xa9\xec\xfb\x85\x64\xa0\x6b\xa0"
+ "\x48\xce\x77\x7e\x73\x9c\x31\x13\xff\x3d\xc8\xae\xa5\x60\x6e\xd9"
+ "\xb6\x8c\x5a\x9a\x6f\xb6\xbe\x9f\x6a\xbd\xa7\xf0\xa0\x33\x27\xf5"
+ "\xb7\x1d\x92\xe5\x96\x9c\x73\x52\xd6\x9f\xd6\xc8\x8e\xb1\x02\x03"
+ "\x01\x00\x01\xa3\x81\x93\x30\x81\x90\x30\x0c\x06\x03\x55\x1d\x13"
+ "\x01\x01\xff\x04\x02\x30\x00\x30\x1a\x06\x03\x55\x1d\x11\x04\x13"
+ "\x30\x11\x82\x0f\x74\x65\x73\x74\x2e\x67\x6e\x75\x74\x6c\x73\x2e"
+ "\x6f\x72\x67\x30\x13\x06\x03\x55\x1d\x25\x04\x0c\x30\x0a\x06\x08"
+ "\x2b\x06\x01\x05\x05\x07\x03\x01\x30\x0f\x06\x03\x55\x1d\x0f\x01"
+ "\x01\xff\x04\x05\x03\x03\x07\xa0\x00\x30\x1d\x06\x03\x55\x1d\x0e"
+ "\x04\x16\x04\x14\xeb\xc7\x45\x6e\xe5\xf8\x25\xca\x8c\x8d\x83\x0d"
+ "\x74\xe9\x86\xd4\xdd\x55\xb4\x75\x30\x1f\x06\x03\x55\x1d\x23\x04"
+ "\x18\x30\x16\x80\x14\xe9\x3c\x1c\xfb\xad\x92\x6e\xe6\x06\xa4\x56"
+ "\x2c\xa2\xe1\xc0\x53\x27\xc8\xf2\x95\x30\x0b\x06\x09\x2a\x86\x48"
+ "\x86\xf7\x0d\x01\x01\x05\x03\x81\x81\x00\x68\x51\x0f\x4e\xdf\xbb"
+ "\x6f\x3b\xc1\xb8\xe7\xfb\xf9\x09\x9e\x41\xc9\xf6\xf6\x44\xfa\x06"
+ "\xcc\xa1\xd5\x11\xc9\x5d\xff\x0a\x4e\x4e\x50\x45\xfc\x29\xea\x88"
+ "\x1b\xa7\xde\x09\x41\x67\x0d\x43\xf4\xbb\x60\x31\x47\x82\x50\xf5"
+ "\x03\x05\x0d\x05\x15\xf0\x77\x7a\xe2\x52\xc3\x27\xb3\x18\x1e\x48"
+ "\x3c\x58\x05\xf2\x58\x6c\x32\xde\xa2\x13\x41\xb2\xa6\x8f\x0c\x96"
+ "\xfb\x5d\xa8\xa5\x59\xb3\x10\x29\xf0\x1b\x15\x0f\x1c\x9c\xec\x60"
+ "\xac\xe2\x8b\x51\x04\x56\x27\x42\xb7\x1f\x25\xd1\x32\x16\xea\x8d"
+ "\xd2\xc8\x69\x08\x82\xbd\x02\xee\x8b\x3a";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
-static time_t mytime (time_t * t)
+static time_t mytime(time_t * t)
{
- time_t then = 1207000800;
+ time_t then = 1207000800;
- if (t)
- *t = then;
+ if (t)
+ *t = then;
- return then;
+ return then;
}
#define NAME "localhost"
#define NAME_SIZE (sizeof(NAME)-1)
-void
-doit (void)
+void doit(void)
{
- int ret;
- gnutls_datum_t data;
- gnutls_x509_crt_t server_crt, ca_crt;
- gnutls_x509_trust_list_t tl;
- unsigned int status;
-
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_time_function (mytime);
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (6);
-
- /* test for gnutls_certificate_get_issuer() */
- gnutls_x509_trust_list_init(&tl, 0);
- gnutls_x509_crt_init(&server_crt);
- gnutls_x509_crt_init(&ca_crt);
-
- ret = gnutls_x509_crt_import(server_crt, &cert, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail("gnutls_x509_crt_import");
-
- ret = gnutls_x509_crt_import(ca_crt, &ca, GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail("gnutls_x509_crt_import");
-
- ret = gnutls_x509_trust_list_add_cas(tl, &ca_crt, 1, 0);
- if (ret < 0)
- fail("gnutls_x509_trust_list_add_cas");
-
- ret = gnutls_x509_trust_list_add_named_crt(tl, server_crt, NAME, NAME_SIZE, 0);
- if (ret < 0)
- fail("gnutls_x509_trust_list_add_named_crt");
-
- ret = gnutls_x509_trust_list_verify_crt(tl, &server_crt, 1, 0, &status, NULL);
- if (ret < 0 || status != 0)
- fail("gnutls_x509_trust_list_verify_crt\n");
-
- ret = gnutls_x509_trust_list_verify_named_crt(tl, server_crt, NAME, NAME_SIZE, 0, &status, NULL);
- if (ret < 0 || status != 0)
- fail("gnutls_x509_trust_list_verify_named_crt: %d\n", __LINE__);
-
- ret = gnutls_x509_trust_list_verify_named_crt(tl, server_crt, NAME, NAME_SIZE-1, 0, &status, NULL);
- if (ret < 0 || status == 0)
- fail("gnutls_x509_trust_list_verify_named_crt: %d\n", __LINE__);
-
- ret = gnutls_x509_trust_list_verify_named_crt(tl, server_crt, "other", 5, 0, &status, NULL);
- if (ret < 0 || status == 0)
- fail("gnutls_x509_trust_list_verify_named_crt: %d\n", __LINE__);
-
- /* test convenience functions in verify-high2.c */
- data.data = cert_pem;
- data.size = strlen((char*)cert_pem);
- ret = gnutls_x509_trust_list_add_trust_mem(tl, &data, NULL, GNUTLS_X509_FMT_PEM, 0, 0);
- if (ret < 1)
- fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n", __LINE__, gnutls_strerror(ret));
-
- ret = gnutls_x509_trust_list_remove_trust_mem(tl, &data, GNUTLS_X509_FMT_PEM);
- if (ret < 1)
- fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n", __LINE__, gnutls_strerror(ret));
-
- data.data = cert_der;
- data.size = sizeof(cert_der);
- ret = gnutls_x509_trust_list_add_trust_mem(tl, &data, NULL, GNUTLS_X509_FMT_DER, 0, 0);
- if (ret < 1)
- fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n", __LINE__, gnutls_strerror(ret));
-
- ret = gnutls_x509_trust_list_remove_trust_mem(tl, &data, GNUTLS_X509_FMT_DER);
- if (ret < 1)
- fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n", __LINE__, gnutls_strerror(ret));
-
- ret = gnutls_x509_trust_list_remove_cas(tl, &ca_crt, 1);
- if (ret < 1)
- fail("gnutls_x509_trust_list_add_cas");
-
- ret = gnutls_x509_trust_list_verify_crt(tl, &server_crt, 1, 0, &status, NULL);
- if (ret == 0 && status == 0)
- fail("gnutls_x509_trust_list_verify_crt\n");
-
- gnutls_x509_trust_list_deinit(tl, 1);
-
- gnutls_global_deinit();
-
- if (debug) success("success");
+ int ret;
+ gnutls_datum_t data;
+ gnutls_x509_crt_t server_crt, ca_crt;
+ gnutls_x509_trust_list_t tl;
+ unsigned int status;
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_time_function(mytime);
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(6);
+
+ /* test for gnutls_certificate_get_issuer() */
+ gnutls_x509_trust_list_init(&tl, 0);
+ gnutls_x509_crt_init(&server_crt);
+ gnutls_x509_crt_init(&ca_crt);
+
+ ret =
+ gnutls_x509_crt_import(server_crt, &cert, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import");
+
+ ret = gnutls_x509_crt_import(ca_crt, &ca, GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import");
+
+ ret = gnutls_x509_trust_list_add_cas(tl, &ca_crt, 1, 0);
+ if (ret < 0)
+ fail("gnutls_x509_trust_list_add_cas");
+
+ ret =
+ gnutls_x509_trust_list_add_named_crt(tl, server_crt, NAME,
+ NAME_SIZE, 0);
+ if (ret < 0)
+ fail("gnutls_x509_trust_list_add_named_crt");
+
+ ret =
+ gnutls_x509_trust_list_verify_crt(tl, &server_crt, 1, 0,
+ &status, NULL);
+ if (ret < 0 || status != 0)
+ fail("gnutls_x509_trust_list_verify_crt\n");
+
+ ret =
+ gnutls_x509_trust_list_verify_named_crt(tl, server_crt, NAME,
+ NAME_SIZE, 0, &status,
+ NULL);
+ if (ret < 0 || status != 0)
+ fail("gnutls_x509_trust_list_verify_named_crt: %d\n",
+ __LINE__);
+
+ ret =
+ gnutls_x509_trust_list_verify_named_crt(tl, server_crt, NAME,
+ NAME_SIZE - 1, 0,
+ &status, NULL);
+ if (ret < 0 || status == 0)
+ fail("gnutls_x509_trust_list_verify_named_crt: %d\n",
+ __LINE__);
+
+ ret =
+ gnutls_x509_trust_list_verify_named_crt(tl, server_crt,
+ "other", 5, 0, &status,
+ NULL);
+ if (ret < 0 || status == 0)
+ fail("gnutls_x509_trust_list_verify_named_crt: %d\n",
+ __LINE__);
+
+ /* test convenience functions in verify-high2.c */
+ data.data = cert_pem;
+ data.size = strlen((char *) cert_pem);
+ ret =
+ gnutls_x509_trust_list_add_trust_mem(tl, &data, NULL,
+ GNUTLS_X509_FMT_PEM, 0,
+ 0);
+ if (ret < 1)
+ fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n",
+ __LINE__, gnutls_strerror(ret));
+
+ ret =
+ gnutls_x509_trust_list_remove_trust_mem(tl, &data,
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 1)
+ fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n",
+ __LINE__, gnutls_strerror(ret));
+
+ data.data = cert_der;
+ data.size = sizeof(cert_der);
+ ret =
+ gnutls_x509_trust_list_add_trust_mem(tl, &data, NULL,
+ GNUTLS_X509_FMT_DER, 0,
+ 0);
+ if (ret < 1)
+ fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n",
+ __LINE__, gnutls_strerror(ret));
+
+ ret =
+ gnutls_x509_trust_list_remove_trust_mem(tl, &data,
+ GNUTLS_X509_FMT_DER);
+ if (ret < 1)
+ fail("gnutls_x509_trust_list_add_trust_mem: %d (%s)\n",
+ __LINE__, gnutls_strerror(ret));
+
+ ret = gnutls_x509_trust_list_remove_cas(tl, &ca_crt, 1);
+ if (ret < 1)
+ fail("gnutls_x509_trust_list_add_cas");
+
+ ret =
+ gnutls_x509_trust_list_verify_crt(tl, &server_crt, 1, 0,
+ &status, NULL);
+ if (ret == 0 && status == 0)
+ fail("gnutls_x509_trust_list_verify_crt\n");
+
+ gnutls_x509_trust_list_deinit(tl, 1);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("success");
}
diff --git a/tests/x509cert.c b/tests/x509cert.c
index 3e974b429e..853e7e78e7 100644
--- a/tests/x509cert.c
+++ b/tests/x509cert.c
@@ -46,164 +46,169 @@
* gnutls_trust_list_get_issuer().
*/
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "<%d>| %s", level, str);
+ fprintf(stderr, "<%d>| %s", level, str);
}
static unsigned char ca_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
- "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
- "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
- "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
- "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
- "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQAMB0GA1UdDgQWBBTpPBz7rZJu5gak\n"
- "Viyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAiaIRqGfp1jPpNeVhABK60SU0KIAy\n"
- "njuu7kHq5peUgYn8Jd9zNzExBOEp1VOipGsf6G66oQAhDFp2o8zkz7ZH71zR4HEW\n"
- "KoX6n5Emn6DvcEH/9pAhnGxNHJAoS7czTKv/JDZJhkqHxyrE1fuLsg5Qv25DTw7+\n"
- "PfqUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t ca = { ca_pem, sizeof (ca_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
+ "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
+ "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
+ "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
+ "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
+ "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQAMB0GA1UdDgQWBBTpPBz7rZJu5gak\n"
+ "Viyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAiaIRqGfp1jPpNeVhABK60SU0KIAy\n"
+ "njuu7kHq5peUgYn8Jd9zNzExBOEp1VOipGsf6G66oQAhDFp2o8zkz7ZH71zR4HEW\n"
+ "KoX6n5Emn6DvcEH/9pAhnGxNHJAoS7czTKv/JDZJhkqHxyrE1fuLsg5Qv25DTw7+\n"
+ "PfqUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t ca = { ca_pem, sizeof(ca_pem) };
static unsigned char cert_pem[] =
- "-----BEGIN CERT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\n"
+ "PfqUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t cert = { cert_pem, sizeof(cert_pem) };
static unsigned char key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
- "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
- "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
- "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
- "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+Qn6hw4x2p5rogdvhhIL1mdWo7jWeVJTF\n"
- "RKB7zLdMPs3ySdtcIQaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
- "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
- "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
- "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
- "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
- "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
- "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
- "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
- "-----END RSA PRIVATE KEY-----\n";
-const gnutls_datum_t key = { key_pem, sizeof (key_pem) };
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
+ "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
+ "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
+ "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
+ "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+Qn6hw4x2p5rogdvhhIL1mdWo7jWeVJTF\n"
+ "RKB7zLdMPs3ySdtcIQaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
+ "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
+ "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
+ "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
+ "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
+ "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
+ "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
+ "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
+ "-----END RSA PRIVATE KEY-----\n";
+const gnutls_datum_t key = { key_pem, sizeof(key_pem) };
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgk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ZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+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5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
#define LIST_SIZE 3
-void
-doit (void)
+void doit(void)
{
- gnutls_certificate_credentials_t x509_cred;
- int ret;
- unsigned int i;
- gnutls_x509_crt_t issuer;
- gnutls_x509_crt_t list[LIST_SIZE];
- char dn[128];
- size_t dn_size;
- unsigned int list_size;
-
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (6);
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_trust_mem (x509_cred, &ca, GNUTLS_X509_FMT_PEM);
-
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- /* test for gnutls_certificate_get_issuer() */
-
- list_size = LIST_SIZE;
- ret = gnutls_x509_crt_list_import(list, &list_size, &cert, GNUTLS_X509_FMT_PEM, GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED);
- if (ret < 0)
- fail("gnutls_x509_crt_list_import");
-
- ret = gnutls_certificate_get_issuer(x509_cred, list[0], &issuer, 0);
- if (ret < 0)
- fail("gnutls_certificate_get_isser");
-
- dn_size = sizeof(dn);
- ret = gnutls_x509_crt_get_dn(issuer, dn, &dn_size);
- if (ret < 0)
- fail("gnutls_certificate_get_isser");
-
- if (debug)
- fprintf(stderr, "Issuer's DN: %s\n", dn);
- for (i=0;i<list_size;i++)
- gnutls_x509_crt_deinit(list[i]);
- gnutls_certificate_free_credentials(x509_cred);
-
- gnutls_global_deinit();
-
- if (debug) success("success");
+ gnutls_certificate_credentials_t x509_cred;
+ int ret;
+ unsigned int i;
+ gnutls_x509_crt_t issuer;
+ gnutls_x509_crt_t list[LIST_SIZE];
+ char dn[128];
+ size_t dn_size;
+ unsigned int list_size;
+
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(6);
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_trust_mem(x509_cred, &ca,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ /* test for gnutls_certificate_get_issuer() */
+
+ list_size = LIST_SIZE;
+ ret =
+ gnutls_x509_crt_list_import(list, &list_size, &cert,
+ GNUTLS_X509_FMT_PEM,
+ GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED);
+ if (ret < 0)
+ fail("gnutls_x509_crt_list_import");
+
+ ret =
+ gnutls_certificate_get_issuer(x509_cred, list[0], &issuer, 0);
+ if (ret < 0)
+ fail("gnutls_certificate_get_isser");
+
+ dn_size = sizeof(dn);
+ ret = gnutls_x509_crt_get_dn(issuer, dn, &dn_size);
+ if (ret < 0)
+ fail("gnutls_certificate_get_isser");
+
+ if (debug)
+ fprintf(stderr, "Issuer's DN: %s\n", dn);
+ for (i = 0; i < list_size; i++)
+ gnutls_x509_crt_deinit(list[i]);
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("success");
}
diff --git a/tests/x509dn.c b/tests/x509dn.c
index 0af95e5c4f..8cb0eb3365 100644
--- a/tests/x509dn.c
+++ b/tests/x509dn.c
@@ -33,10 +33,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -58,10 +57,10 @@ main (int argc, char** argv)
pid_t child;
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", child ? "server" : "client", level, str);
+ fprintf(stderr, "%s |<%d>| %s", child ? "server" : "client", level,
+ str);
}
/* A very basic TLS client, with anonymous authentication.
@@ -71,221 +70,207 @@ tls_log_func (int level, const char *str)
#define MSG "Hello TLS"
static unsigned char ca_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
- "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
- "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
- "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
- "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
- "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQAMB0GA1UdDgQWBBTpPBz7rZJu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----\n";
+const gnutls_datum_t ca = { ca_pem, sizeof(ca_pem) };
static unsigned char cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t cert = { cert_pem, sizeof (cert_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
+ "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
+ "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
+ "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
+ "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
+ "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
+ "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
+ "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
+ "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
+ "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
+ "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t cert = { cert_pem, sizeof(cert_pem) };
static unsigned char key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
- "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
- "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
- "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
- "PJ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QaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
+ "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
+ "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
+ "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
+ "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
+ "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
+ "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
+ "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
+ "-----END RSA PRIVATE KEY-----\n";
+const gnutls_datum_t key = { key_pem, sizeof(key_pem) };
#define EXPECT_RDN0 "GnuTLS test CA"
static int
-cert_callback (gnutls_session_t session,
- const gnutls_datum_t * req_ca_rdn, int nreqs,
- const gnutls_pk_algorithm_t * sign_algos,
- int sign_algos_length, gnutls_pcert_st ** pcert,
- unsigned int* pcert_length, gnutls_privkey_t *pkey)
+cert_callback(gnutls_session_t session,
+ const gnutls_datum_t * req_ca_rdn, int nreqs,
+ const gnutls_pk_algorithm_t * sign_algos,
+ int sign_algos_length, gnutls_pcert_st ** pcert,
+ unsigned int *pcert_length, gnutls_privkey_t * pkey)
{
- int result;
- gnutls_x509_dn_t dn;
-
- if (nreqs != 1)
- {
- fail ("client: invoked to provide client cert, %d CA .\n", nreqs);
- return -1;
- }
-
- if (debug)
- success ("client: invoked to provide client cert.\n");
-
- result = gnutls_x509_dn_init (&dn);
- if (result < 0)
- {
- fail ("client: could not initialize DN.\n");
- return -1;
- }
-
- result = gnutls_x509_dn_import (dn, req_ca_rdn);
- if (result == 0)
- {
- gnutls_x509_ava_st val;
-
- if (debug)
- success ("client: imported DN.\n");
-
- if (gnutls_x509_dn_get_rdn_ava (dn, 0, 0, &val) == 0)
- {
- if (debug)
- success ("client: got RDN 0.\n");
-
- if (val.value.size == strlen (EXPECT_RDN0)
- && strncmp ((char*)val.value.data, EXPECT_RDN0, val.value.size) == 0)
- {
- if (debug)
- success ("client: RND 0 correct.\n");
- }
- else
- {
- fail ("client: RND 0 bad: %.*s\n",
- val.value.size, val.value.data);
- return -1;
- }
- }
- else
- {
- fail ("client: could not retrieve RDN 0.\n");
- return -1;
- }
-
- gnutls_x509_dn_deinit (dn);
- }
- else
- {
- fail ("client: failed to parse RDN: %s\n", gnutls_strerror (result));
- }
-
- return 0;
+ int result;
+ gnutls_x509_dn_t dn;
+
+ if (nreqs != 1) {
+ fail("client: invoked to provide client cert, %d CA .\n",
+ nreqs);
+ return -1;
+ }
+
+ if (debug)
+ success("client: invoked to provide client cert.\n");
+
+ result = gnutls_x509_dn_init(&dn);
+ if (result < 0) {
+ fail("client: could not initialize DN.\n");
+ return -1;
+ }
+
+ result = gnutls_x509_dn_import(dn, req_ca_rdn);
+ if (result == 0) {
+ gnutls_x509_ava_st val;
+
+ if (debug)
+ success("client: imported DN.\n");
+
+ if (gnutls_x509_dn_get_rdn_ava(dn, 0, 0, &val) == 0) {
+ if (debug)
+ success("client: got RDN 0.\n");
+
+ if (val.value.size == strlen(EXPECT_RDN0)
+ && strncmp((char *) val.value.data,
+ EXPECT_RDN0, val.value.size) == 0) {
+ if (debug)
+ success
+ ("client: RND 0 correct.\n");
+ } else {
+ fail("client: RND 0 bad: %.*s\n",
+ val.value.size, val.value.data);
+ return -1;
+ }
+ } else {
+ fail("client: could not retrieve RDN 0.\n");
+ return -1;
+ }
+
+ gnutls_x509_dn_deinit(dn);
+ } else {
+ fail("client: failed to parse RDN: %s\n",
+ gnutls_strerror(result));
+ }
+
+ return 0;
}
-static void
-client (int sd)
+static void client(int sd)
{
- int ret, ii;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_certificate_credentials_t xcred;
-
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- gnutls_certificate_allocate_credentials (&xcred);
-
- /* sets the trusted cas file
- */
- gnutls_certificate_set_x509_trust_mem (xcred, &ca, GNUTLS_X509_FMT_PEM);
-
- gnutls_certificate_set_retrieve_function2 (xcred, cert_callback);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_set_default_priority (session);
-
- /* put the x509 credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else
- {
- if (debug)
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- if (debug)
- print_info (session);
-
- gnutls_record_send (session, MSG, strlen (MSG));
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug)
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
- close (sd);
-
- gnutls_deinit (session);
-
- gnutls_certificate_free_credentials (xcred);
-
- gnutls_global_deinit ();
+ int ret, ii;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_certificate_credentials_t xcred;
+
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ gnutls_certificate_allocate_credentials(&xcred);
+
+ /* sets the trusted cas file
+ */
+ gnutls_certificate_set_x509_trust_mem(xcred, &ca,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_certificate_set_retrieve_function2(xcred, cert_callback);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_set_default_priority(session);
+
+ /* put the x509 credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else {
+ if (debug)
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ if (debug)
+ print_info(session);
+
+ gnutls_record_send(session, MSG, strlen(MSG));
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ end:
+
+ close(sd);
+
+ gnutls_deinit(session);
+
+ gnutls_certificate_free_credentials(xcred);
+
+ gnutls_global_deinit();
}
/* This is a sample TLS 1.0 echo server, using X.509 authentication.
@@ -297,42 +282,42 @@ end:
/* These are global */
gnutls_certificate_credentials_t x509_cred;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_set_default_priority (session);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_set_default_priority(session);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
- /* request client certificate if any.
- */
- gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
+ /* request client certificate if any.
+ */
+ gnutls_certificate_server_set_request(session,
+ GNUTLS_CERT_REQUEST);
- gnutls_dh_set_prime_bits (session, DH_BITS);
+ gnutls_dh_set_prime_bits(session, DH_BITS);
- return session;
+ return session;
}
static gnutls_dh_params_t dh_params;
-static int
-generate_dh_params (void)
+static int generate_dh_params(void)
{
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- /* Generate Diffie-Hellman parameters - for use with DHE
- * kx algorithms. These should be discarded and regenerated
- * once a day, once a week or once a month. Depending on the
- * security requirements.
- */
- gnutls_dh_params_init (&dh_params);
- return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ /* Generate Diffie-Hellman parameters - for use with DHE
+ * kx algorithms. These should be discarded and regenerated
+ * once a day, once a week or once a month. Depending on the
+ * security requirements.
+ */
+ gnutls_dh_params_init(&dh_params);
+ return gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
}
int err, ret;
@@ -343,181 +328,170 @@ int optval = 1;
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgI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MgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC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l+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
-static void
-server (int sd)
+static void server(int sd)
{
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (4711);
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_trust_mem (x509_cred, &ca, GNUTLS_X509_FMT_PEM);
-
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- if (debug)
- success ("Launched, generating DH parameters...\n");
-
- generate_dh_params ();
-
- gnutls_certificate_set_dh_params (x509_cred, dh_params);
-
- session = initialize_tls_session ();
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- return;
- }
- if (debug)
- success ("server: Handshake was completed\n");
-
- if (debug)
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- if (debug)
- print_info (session);
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
- gnutls_deinit (session);
-
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(4711);
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_trust_mem(x509_cred, &ca,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ if (debug)
+ success("Launched, generating DH parameters...\n");
+
+ generate_dh_params();
+
+ gnutls_certificate_set_dh_params(x509_cred, dh_params);
+
+ session = initialize_tls_session();
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug)
+ success("server: Handshake was completed\n");
+
+ if (debug)
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ if (debug)
+ print_info(session);
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+ gnutls_deinit(session);
+
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
- /* parent */
- server (sockets[0]);
- wait (&status);
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+ /* parent */
+ server(sockets[0]);
+ wait(&status);
#if defined WIFEXITED && defined WEXITSTATUS
- if (WIFEXITED (status) && WEXITSTATUS (status))
- {
- fail ("server: client failed with exit status %d\n",
- WEXITSTATUS (status));
- }
+ if (WIFEXITED(status) && WEXITSTATUS(status)) {
+ fail("server: client failed with exit status %d\n",
+ WEXITSTATUS(status));
+ }
#endif
#if defined WIFSIGNALED && defined WTERMSIG
- if (WIFSIGNALED (status))
- {
- fail ("server: client failed with fatal signal %d\n",
- WTERMSIG (status));
- }
+ if (WIFSIGNALED(status)) {
+ fail("server: client failed with fatal signal %d\n", WTERMSIG(status));
+ }
#endif
- }
- else
- client (sockets[1]);
+ } else
+ client(sockets[1]);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/x509self.c b/tests/x509self.c
index 91a696d843..9178702171 100644
--- a/tests/x509self.c
+++ b/tests/x509self.c
@@ -33,10 +33,9 @@
#if defined(_WIN32)
/* socketpair isn't supported on Win32. */
-int
-main (int argc, char** argv)
+int main(int argc, char **argv)
{
- exit (77);
+ exit(77);
}
#else
@@ -57,10 +56,10 @@ main (int argc, char** argv)
pid_t child;
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s |<%d>| %s", child ? "server" : "client", level, str);
+ fprintf(stderr, "%s |<%d>| %s", child ? "server" : "client", level,
+ str);
}
/* A very basic TLS client, with anonymous authentication.
@@ -71,182 +70,169 @@ tls_log_func (int level, const char *str)
#define MSG "Hello TLS"
static unsigned char ca_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\n"
- "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA\n"
- "vuyYeh1vfmslnuggeEKgZAVmQ5ltSdUY7H25WGSygKMUYZ0KT74v8C780qtcNt9T\n"
- "7EPH/N6RvB4BprdssgcQLsthR3XKA84jbjjxNCcaGs33lvOz8A1nf8p3hD+cKfRi\n"
- "kfYSW2JazLrtCC4yRCas/SPOUxu78of+3HiTfFm/oXUCAwEAAaNDMEEwDwYDVR0T\n"
- "AQH/BAUwAwEB/zAPBgNVHQ8BAf8EB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qUpIhz5Bbm7J4=\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t ca = { ca_pem, sizeof(ca_pem) };
static unsigned char cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
-const gnutls_datum_t cert = { cert_pem, sizeof (cert_pem) };
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
+ "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
+ "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
+ "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
+ "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
+ "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
+ "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
+ "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
+ "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
+ "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
+ "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
+const gnutls_datum_t cert = { cert_pem, sizeof(cert_pem) };
static unsigned char key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
- "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
- "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
- "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
- "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+Qn6hw4x2p5rogdvhhIL1mdWo7jWeVJTF\n"
- "RKB7zLdMPs3ySdtcIQaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
- "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
- "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
- "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
- "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
- "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
- "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
- "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
- "-----END RSA PRIVATE KEY-----\n";
-const gnutls_datum_t key = { key_pem, sizeof (key_pem) };
-
-static void
-client (int sd)
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
+ "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
+ "aP/JEeIyjc49gAuNde/YAIGPKAQDoCKNYQQH+rY3fSEHSdIJYWmYkKNYqQIDAQAB\n"
+ "AoGADpmARG5CQxS+AesNkGmpauepiCz1JBF/JwnyiX6vEzUh0Ypd39SZztwrDxvF\n"
+ "PJjQaKVljml1zkJpIDVsqvHdyVdse8M+Qn6hw4x2p5rogdvhhIL1mdWo7jWeVJTF\n"
+ "RKB7zLdMPs3ySdtcIQaF9nUAQ2KJEvldkO3m/bRJFEp54k0CQQDYy+RlTmwRD6hy\n"
+ "7UtMjR0H3CSZJeQ8svMCxHLmOluG9H1UKk55ZBYfRTsXniqUkJBZ5wuV1L+pR9EK\n"
+ "ca89a+1VAkEA3UmBelwEv2u9cAU1QjKjmwju1JgXbrjEohK+3B5y0ESEXPAwNQT9\n"
+ "TrDM1m9AyxYTWLxX93dI5QwNFJtmbtjeBQJARSCWXhsoaDRG8QZrCSjBxfzTCqZD\n"
+ "ZXtl807ymCipgJm60LiAt0JLr4LiucAsMZz6+j+quQbSakbFCACB8SLV1QJBAKZQ\n"
+ "YKf+EPNtnmta/rRKKvySsi3GQZZN+Dt3q0r094XgeTsAqrqujVNfPhTMeP4qEVBX\n"
+ "/iVX2cmMTSh3w3z8MaECQEp0XJWDVKOwcTW6Ajp9SowtmiZ3YDYo1LF9igb4iaLv\n"
+ "sWZGfbnU3ryjvkb6YuFjgtzbZDZHWQCo8/cOtOBmPdk=\n"
+ "-----END RSA PRIVATE KEY-----\n";
+const gnutls_datum_t key = { key_pem, sizeof(key_pem) };
+
+static void client(int sd)
{
- int ret, ii;
- gnutls_session_t session;
- char buffer[MAX_BUF + 1];
- gnutls_certificate_credentials_t xcred;
-
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (6);
-
- gnutls_certificate_allocate_credentials (&xcred);
-
- /* sets the trusted cas file
- */
- gnutls_certificate_set_x509_trust_mem (xcred, &ca, GNUTLS_X509_FMT_PEM);
- gnutls_certificate_set_x509_key_mem (xcred, &cert, &key,
- GNUTLS_X509_FMT_PEM);
-
- /* Initialize TLS session
- */
- gnutls_init (&session, GNUTLS_CLIENT);
-
- /* Use default priorities */
- gnutls_set_default_priority (session);
-
- /* put the x509 credentials to the current session
- */
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
-
- gnutls_transport_set_int (session, sd);
-
- /* Perform the TLS handshake
- */
- ret = gnutls_handshake (session);
-
- if (ret < 0)
- {
- fail ("client: Handshake failed\n");
- gnutls_perror (ret);
- goto end;
- }
- else if (debug)
- {
- success ("client: Handshake was completed\n");
- }
-
- if (debug)
- success ("client: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
-
- /* see the Getting peer's information example */
- if (debug)
- print_info (session);
-
- ret = gnutls_record_send (session, MSG, strlen (MSG));
-
- if (ret == strlen (MSG))
- {
- if (debug)
- success ("client: sent record.\n");
- }
- else
- {
- fail ("client: failed to send record.\n");
- gnutls_perror (ret);
- goto end;
- }
-
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (debug)
- success ("client: recv returned %d.\n", ret);
-
- if (ret == GNUTLS_E_REHANDSHAKE)
- {
- if (debug)
- success ("client: doing handshake!\n");
- ret = gnutls_handshake (session);
- if (ret == 0)
- {
- if (debug)
- success ("client: handshake complete, reading again.\n");
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
- }
- else
- {
- fail ("client: handshake failed.\n");
- }
- }
-
- if (ret == 0)
- {
- if (debug)
- success ("client: Peer has closed the TLS connection\n");
- goto end;
- }
- else if (ret < 0)
- {
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- goto end;
- }
-
- if (debug)
- {
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
- {
- fputc (buffer[ii], stdout);
- }
- fputs ("\n", stdout);
- }
-
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
- close (sd);
-
- gnutls_deinit (session);
-
- gnutls_certificate_free_credentials (xcred);
-
- gnutls_global_deinit ();
+ int ret, ii;
+ gnutls_session_t session;
+ char buffer[MAX_BUF + 1];
+ gnutls_certificate_credentials_t xcred;
+
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(6);
+
+ gnutls_certificate_allocate_credentials(&xcred);
+
+ /* sets the trusted cas file
+ */
+ gnutls_certificate_set_x509_trust_mem(xcred, &ca,
+ GNUTLS_X509_FMT_PEM);
+ gnutls_certificate_set_x509_key_mem(xcred, &cert, &key,
+ GNUTLS_X509_FMT_PEM);
+
+ /* Initialize TLS session
+ */
+ gnutls_init(&session, GNUTLS_CLIENT);
+
+ /* Use default priorities */
+ gnutls_set_default_priority(session);
+
+ /* put the x509 credentials to the current session
+ */
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
+
+ gnutls_transport_set_int(session, sd);
+
+ /* Perform the TLS handshake
+ */
+ ret = gnutls_handshake(session);
+
+ if (ret < 0) {
+ fail("client: Handshake failed\n");
+ gnutls_perror(ret);
+ goto end;
+ } else if (debug) {
+ success("client: Handshake was completed\n");
+ }
+
+ if (debug)
+ success("client: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+
+ /* see the Getting peer's information example */
+ if (debug)
+ print_info(session);
+
+ ret = gnutls_record_send(session, MSG, strlen(MSG));
+
+ if (ret == strlen(MSG)) {
+ if (debug)
+ success("client: sent record.\n");
+ } else {
+ fail("client: failed to send record.\n");
+ gnutls_perror(ret);
+ goto end;
+ }
+
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (debug)
+ success("client: recv returned %d.\n", ret);
+
+ if (ret == GNUTLS_E_REHANDSHAKE) {
+ if (debug)
+ success("client: doing handshake!\n");
+ ret = gnutls_handshake(session);
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: handshake complete, reading again.\n");
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ } else {
+ fail("client: handshake failed.\n");
+ }
+ }
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("client: Peer has closed the TLS connection\n");
+ goto end;
+ } else if (ret < 0) {
+ fail("client: Error: %s\n", gnutls_strerror(ret));
+ goto end;
+ }
+
+ if (debug) {
+ printf("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++) {
+ fputc(buffer[ii], stdout);
+ }
+ fputs("\n", stdout);
+ }
+
+ gnutls_bye(session, GNUTLS_SHUT_RDWR);
+
+ end:
+
+ close(sd);
+
+ gnutls_deinit(session);
+
+ gnutls_certificate_free_credentials(xcred);
+
+ gnutls_global_deinit();
}
/* This is a sample TLS 1.0 echo server, using X.509 authentication.
@@ -258,43 +244,42 @@ end:
/* These are global */
gnutls_certificate_credentials_t x509_cred;
-static gnutls_session_t
-initialize_tls_session (void)
+static gnutls_session_t initialize_tls_session(void)
{
- gnutls_session_t session;
+ gnutls_session_t session;
- gnutls_init (&session, GNUTLS_SERVER);
+ gnutls_init(&session, GNUTLS_SERVER);
- /* avoid calling all the priority functions, since the defaults
- * are adequate.
- */
- gnutls_set_default_priority (session);
+ /* avoid calling all the priority functions, since the defaults
+ * are adequate.
+ */
+ gnutls_set_default_priority(session);
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
- /* request client certificate if any.
- Moved to later on to be able to test re-handshakes.
- gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
- */
+ /* request client certificate if any.
+ Moved to later on to be able to test re-handshakes.
+ gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
+ */
- gnutls_dh_set_prime_bits (session, DH_BITS);
+ gnutls_dh_set_prime_bits(session, DH_BITS);
- return session;
+ return session;
}
static gnutls_dh_params_t dh_params;
-static int
-generate_dh_params (void)
+static int generate_dh_params(void)
{
- const gnutls_datum_t p3 = { (void *) pkcs3, strlen (pkcs3) };
- /* Generate Diffie-Hellman parameters - for use with DHE
- * kx algorithms. These should be discarded and regenerated
- * once a day, once a week or once a month. Depending on the
- * security requirements.
- */
- gnutls_dh_params_init (&dh_params);
- return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ const gnutls_datum_t p3 = { (void *) pkcs3, strlen(pkcs3) };
+ /* Generate Diffie-Hellman parameters - for use with DHE
+ * kx algorithms. These should be discarded and regenerated
+ * once a day, once a week or once a month. Depending on the
+ * security requirements.
+ */
+ gnutls_dh_params_init(&dh_params);
+ return gnutls_dh_params_import_pkcs3(dh_params, &p3,
+ GNUTLS_X509_FMT_PEM);
}
int err, ret;
@@ -305,189 +290,179 @@ int optval = 1;
static unsigned char server_cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
- "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
- "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
- "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
- "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
- "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
- "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
- "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
- "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
- "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
- "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
- "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n"
+ "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n"
+ "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n"
+ "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n"
+ "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n"
+ "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n"
+ "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n"
+ "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n"
+ "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n"
+ "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n"
+ "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n"
+ "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n";
const gnutls_datum_t server_cert = { server_cert_pem,
- sizeof (server_cert_pem)
+ sizeof(server_cert_pem)
};
static unsigned char server_key_pem[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
- "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
- "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
- "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
- "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
- "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
- "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
- "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
- "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
- "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
- "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
- "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
- "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
- "-----END RSA PRIVATE KEY-----\n";
+ "-----BEGIN RSA PRIVATE KEY-----\n"
+ "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n"
+ "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n"
+ "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n"
+ "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n"
+ "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n"
+ "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n"
+ "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n"
+ "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n"
+ "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n"
+ "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n"
+ "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n"
+ "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n"
+ "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n"
+ "-----END RSA PRIVATE KEY-----\n";
const gnutls_datum_t server_key = { server_key_pem,
- sizeof (server_key_pem)
+ sizeof(server_key_pem)
};
-static void
-server (int sd)
+static void server(int sd)
{
- /* this must be called once in the program
- */
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (6);
-
- gnutls_certificate_allocate_credentials (&x509_cred);
- gnutls_certificate_set_x509_trust_mem (x509_cred, &ca, GNUTLS_X509_FMT_PEM);
-
- gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
- GNUTLS_X509_FMT_PEM);
-
- if (debug)
- success ("Launched, generating DH parameters...\n");
-
- generate_dh_params ();
-
- gnutls_certificate_set_dh_params (x509_cred, dh_params);
-
- session = initialize_tls_session ();
-
- gnutls_transport_set_int (session, sd);
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- close (sd);
- gnutls_deinit (session);
- fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
- return;
- }
- if (debug)
- {
- success ("server: Handshake was completed\n");
- success ("server: TLS version is: %s\n",
- gnutls_protocol_get_name (gnutls_protocol_get_version
- (session)));
- }
-
- /* see the Getting peer's information example */
- if (debug)
- print_info (session);
-
- for (;;)
- {
- memset (buffer, 0, MAX_BUF + 1);
- ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
- if (ret == 0)
- {
- if (debug)
- success ("server: Peer has closed the GnuTLS connection\n");
- break;
- }
- else if (ret < 0)
- {
- fail ("server: Received corrupted data(%d). Closing...\n", ret);
- break;
- }
- else if (ret > 0)
- {
- gnutls_certificate_server_set_request (session,
- GNUTLS_CERT_REQUEST);
-
- if (debug)
- success ("server: got data, forcing rehandshake.\n");
-
- ret = gnutls_rehandshake (session);
- if (ret < 0)
- {
- fail ("server: rehandshake failed\n");
- gnutls_perror (ret);
- break;
- }
-
- ret = gnutls_handshake (session);
- if (ret < 0)
- {
- fail ("server: (re)handshake failed\n");
- gnutls_perror (ret);
- break;
- }
-
- if (debug)
- success ("server: rehandshake complete.\n");
-
- /* echo data back to the client
- */
- gnutls_record_send (session, buffer, strlen (buffer));
- }
- }
- /* do not wait for the peer to close the connection.
- */
- gnutls_bye (session, GNUTLS_SHUT_WR);
-
- close (sd);
- gnutls_deinit (session);
-
- gnutls_certificate_free_credentials (x509_cred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
-
- if (debug)
- success ("server: finished\n");
+ /* this must be called once in the program
+ */
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(6);
+
+ gnutls_certificate_allocate_credentials(&x509_cred);
+ gnutls_certificate_set_x509_trust_mem(x509_cred, &ca,
+ GNUTLS_X509_FMT_PEM);
+
+ gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
+ &server_key,
+ GNUTLS_X509_FMT_PEM);
+
+ if (debug)
+ success("Launched, generating DH parameters...\n");
+
+ generate_dh_params();
+
+ gnutls_certificate_set_dh_params(x509_cred, dh_params);
+
+ session = initialize_tls_session();
+
+ gnutls_transport_set_int(session, sd);
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ close(sd);
+ gnutls_deinit(session);
+ fail("server: Handshake has failed (%s)\n\n",
+ gnutls_strerror(ret));
+ return;
+ }
+ if (debug) {
+ success("server: Handshake was completed\n");
+ success("server: TLS version is: %s\n",
+ gnutls_protocol_get_name
+ (gnutls_protocol_get_version(session)));
+ }
+
+ /* see the Getting peer's information example */
+ if (debug)
+ print_info(session);
+
+ for (;;) {
+ memset(buffer, 0, MAX_BUF + 1);
+ ret = gnutls_record_recv(session, buffer, MAX_BUF);
+
+ if (ret == 0) {
+ if (debug)
+ success
+ ("server: Peer has closed the GnuTLS connection\n");
+ break;
+ } else if (ret < 0) {
+ fail("server: Received corrupted data(%d). Closing...\n", ret);
+ break;
+ } else if (ret > 0) {
+ gnutls_certificate_server_set_request(session,
+ GNUTLS_CERT_REQUEST);
+
+ if (debug)
+ success
+ ("server: got data, forcing rehandshake.\n");
+
+ ret = gnutls_rehandshake(session);
+ if (ret < 0) {
+ fail("server: rehandshake failed\n");
+ gnutls_perror(ret);
+ break;
+ }
+
+ ret = gnutls_handshake(session);
+ if (ret < 0) {
+ fail("server: (re)handshake failed\n");
+ gnutls_perror(ret);
+ break;
+ }
+
+ if (debug)
+ success("server: rehandshake complete.\n");
+
+ /* echo data back to the client
+ */
+ gnutls_record_send(session, buffer,
+ strlen(buffer));
+ }
+ }
+ /* do not wait for the peer to close the connection.
+ */
+ gnutls_bye(session, GNUTLS_SHUT_WR);
+
+ close(sd);
+ gnutls_deinit(session);
+
+ gnutls_certificate_free_credentials(x509_cred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
+
+ if (debug)
+ success("server: finished\n");
}
-void
-doit (void)
+void doit(void)
{
- int sockets[2];
-
- err = socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
- if (err == -1)
- {
- perror ("socketpair");
- fail ("socketpair failed\n");
- return;
- }
-
- child = fork ();
- if (child < 0)
- {
- perror ("fork");
- fail ("fork");
- return;
- }
-
- if (child)
- {
- int status;
-
- server (sockets[0]);
- wait (&status);
- }
- else
- client (sockets[1]);
+ int sockets[2];
+
+ err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+ if (err == -1) {
+ perror("socketpair");
+ fail("socketpair failed\n");
+ return;
+ }
+
+ child = fork();
+ if (child < 0) {
+ perror("fork");
+ fail("fork");
+ return;
+ }
+
+ if (child) {
+ int status;
+
+ server(sockets[0]);
+ wait(&status);
+ } else
+ client(sockets[1]);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */
diff --git a/tests/x509sign-verify.c b/tests/x509sign-verify.c
index 143dcd1d59..debb1fe69f 100644
--- a/tests/x509sign-verify.c
+++ b/tests/x509sign-verify.c
@@ -40,240 +40,265 @@
#include "utils.h"
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "<%d> %s", level, str);
+ fprintf(stderr, "<%d> %s", level, str);
}
/* sha1 hash of "hello" string */
const gnutls_datum_t hash_data = {
- (void *)
- "\xaa\xf4\xc6\x1d\xdc\xc5\xe8\xa2\xda\xbe"
- "\xde\x0f\x3b\x48\x2c\xd9\xae\xa9\x43\x4d",
- 20
+ (void *)
+ "\xaa\xf4\xc6\x1d\xdc\xc5\xe8\xa2\xda\xbe"
+ "\xde\x0f\x3b\x48\x2c\xd9\xae\xa9\x43\x4d",
+ 20
};
const gnutls_datum_t invalid_hash_data = {
- (void *)
- "\xaa\xf4\xc6\x1d\xdc\xca\xe8\xa2\xda\xbe"
- "\xde\x0f\x3b\x48\x2c\xb9\xae\xa9\x43\x4d",
- 20
+ (void *)
+ "\xaa\xf4\xc6\x1d\xdc\xca\xe8\xa2\xda\xbe"
+ "\xde\x0f\x3b\x48\x2c\xb9\xae\xa9\x43\x4d",
+ 20
};
const gnutls_datum_t raw_data = {
- (void *) "hello",
- 5
+ (void *) "hello",
+ 5
};
static char pem1_cert[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
+ "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
+ "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
+ "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
+ "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
+ "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
+ "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
+ "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
+ "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
+ "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
+ "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
+ "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
static char pem1_key[] =
- "-----BEGIN RSA PRIVATE KEY-----\n"
- "MIICXAIBAAKBgQC7ZkP18sXXtozMxd/1iDuxyUtqDqGtIFBACIChT1yj0Phsz+Y8\n"
- "9+wEdhMXi2SJIlvA3VN8O+18BLuAuSi+jpvGjqClEsv1Vx6i57u3M0mf47tKrmpN\n"
- "aP/JEeIyj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n"
+ "x+M0lPoX1Re5L2ElHI6DJpHYOBPwf9glwxnet2+avzgUQDUFwUSxOhodpyeaACXD\n"
+ "o0gGVpcH8sOBTQ+aTdM37hGkPxoXjtIkR/LgG5nP2H2JRd5TkW8l13JdM4MJFB4W\n"
+ "QcDzQ8REwidsfh9uKAluk1c/KQ==\n" "-----END CERTIFICATE-----\n";
static char pem2_key[] =
- "-----BEGIN DSA PRIVATE KEY-----\n"
- "MIIBugIBAAKBgQC5hPVagb4aDcWKc48Mmy+btg5Lw3Qaf2StnfMoxaBHvJtXVvGX\n"
- "1X43A+nyTPTji38wo10vu6GiN8LqNY8fsV+mol8B8SM2K+RPLy3dndU6pjmvelF8\n"
- "0iWOl3TPHsV7S3ZDgQcfBhS4blgS4ZDiN2/SG+xoxVji5jDgal4sY3jsBwIVAJ9W\n"
- "jEhkL/6NqnptltsEXRbvCKVxAoGAYgZ+5Fx2CLdGGl3Xl9QqIfsfMcnS9Po52CfR\n"
- "m/wnXacKpxr8U8EvQ8I3yIV/PUyrXYEy+x1eHlQRFiDGgFrZjJtD8N1roPTD8oqc\n"
- "OdIcew/v+iiTj9KhIuvc4IqLrSgOz+8Jhek2vYt6UNV79yUNbGARxO9wkM/WG+u7\n"
- "jsY+OpcCgYAPiodX8tHC3KzfS4sPi7op9+ED5FX6spgH1v0SsYC89bq0UNR/oA5D\n"
- "55/JeBFf5eQMLGtqpDXcvVTlYDaaMdGKWW5rHLq9LrrrfIfv2sjdoeukg+aLrfr6\n"
- "jlvXN8gyPpbCPvRD2n2RAg+3vPjvj/dBAF6W3w8IltzqsukGgq/SLwIUS5/r/2ya\n"
- "AoNBXjeBjgCGMei2m8E=\n" "-----END DSA PRIVATE KEY-----\n";
+ "-----BEGIN DSA PRIVATE KEY-----\n"
+ "MIIBugIBAAKBgQC5hPVagb4aDcWKc48Mmy+btg5Lw3Qaf2StnfMoxaBHvJtXVvGX\n"
+ "1X43A+nyTPTji38wo10vu6GiN8LqNY8fsV+mol8B8SM2K+RPLy3dndU6pjmvelF8\n"
+ "0iWOl3TPHsV7S3ZDgQcfBhS4blgS4ZDiN2/SG+xoxVji5jDgal4sY3jsBwIVAJ9W\n"
+ "jEhkL/6NqnptltsEXRbvCKVxAoGAYgZ+5Fx2CLdGGl3Xl9QqIfsfMcnS9Po52CfR\n"
+ "m/wnXacKpxr8U8EvQ8I3yIV/PUyrXYEy+x1eHlQRFiDGgFrZjJtD8N1roPTD8oqc\n"
+ "OdIcew/v+iiTj9KhIuvc4IqLrSgOz+8Jhek2vYt6UNV79yUNbGARxO9wkM/WG+u7\n"
+ "jsY+OpcCgYAPiodX8tHC3KzfS4sPi7op9+ED5FX6spgH1v0SsYC89bq0UNR/oA5D\n"
+ "55/JeBFf5eQMLGtqpDXcvVTlYDaaMdGKWW5rHLq9LrrrfIfv2sjdoeukg+aLrfr6\n"
+ "jlvXN8gyPpbCPvRD2n2RAg+3vPjvj/dBAF6W3w8IltzqsukGgq/SLwIUS5/r/2ya\n"
+ "AoNBXjeBjgCGMei2m8E=\n" "-----END DSA PRIVATE KEY-----\n";
const gnutls_datum_t cert_dat[] = {
- {(void*)pem1_cert, sizeof (pem1_cert)}
- ,
- {(void*)pem2_cert, sizeof (pem2_cert)}
+ {(void *) pem1_cert, sizeof(pem1_cert)}
+ ,
+ {(void *) pem2_cert, sizeof(pem2_cert)}
};
const gnutls_datum_t key_dat[] = {
- {(void*)pem1_key, sizeof (pem1_key)}
- ,
- {(void*)pem2_key, sizeof (pem2_key)}
+ {(void *) pem1_key, sizeof(pem1_key)}
+ ,
+ {(void *) pem2_key, sizeof(pem2_key)}
};
-void
-doit (void)
+void doit(void)
{
- gnutls_x509_privkey_t key;
- gnutls_x509_crt_t crt;
- gnutls_pubkey_t pubkey;
- gnutls_privkey_t privkey;
- gnutls_digest_algorithm_t hash_algo;
- gnutls_sign_algorithm_t sign_algo;
- gnutls_datum_t signature;
- gnutls_datum_t signature2;
- int ret;
- size_t i;
-
- global_init ();
-
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (6);
-
- for (i = 0; i < sizeof (key_dat) / sizeof (key_dat[0]); i++)
- {
- if (debug)
- success ("loop %d\n", (int) i);
-
- ret = gnutls_x509_privkey_init (&key);
- if (ret < 0)
- fail ("gnutls_x509_privkey_init\n");
-
- ret =
- gnutls_x509_privkey_import (key, &key_dat[i], GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_privkey_import\n");
-
- ret = gnutls_pubkey_init (&pubkey);
- if (ret < 0)
- fail ("gnutls_privkey_init\n");
-
- ret = gnutls_privkey_init (&privkey);
- if (ret < 0)
- fail ("gnutls_pubkey_init\n");
-
- ret = gnutls_privkey_import_x509 (privkey, key, 0);
- if (ret < 0)
- fail ("gnutls_privkey_import_x509\n");
-
- ret = gnutls_privkey_sign_hash (privkey, GNUTLS_DIG_SHA1, 0,
- &hash_data, &signature2);
- if (ret < 0)
- fail ("gnutls_privkey_sign_hash\n");
-
- ret = gnutls_privkey_sign_data (privkey, GNUTLS_DIG_SHA1, 0,
- &raw_data, &signature);
- if (ret < 0)
- fail ("gnutls_x509_privkey_sign_hash\n");
-
- ret = gnutls_x509_crt_init (&crt);
- if (ret < 0)
- fail ("gnutls_x509_crt_init\n");
-
- ret = gnutls_x509_crt_import (crt, &cert_dat[i], GNUTLS_X509_FMT_PEM);
- if (ret < 0)
- fail ("gnutls_x509_crt_import\n");
-
- ret =
- gnutls_pubkey_import_x509 (pubkey, crt, 0);
- if (ret < 0)
- fail ("gnutls_x509_pubkey_import\n");
-
- ret =
- gnutls_pubkey_get_verify_algorithm (pubkey, &signature, &hash_algo);
- if (ret < 0 || hash_algo != GNUTLS_DIG_SHA1)
- fail ("gnutls_x509_crt_get_verify_algorithm\n");
-
- ret = gnutls_pubkey_verify_hash (pubkey, 0, &hash_data, &signature);
- if (ret < 0)
- fail ("gnutls_x509_pubkey_verify_hash\n");
-
- ret =
- gnutls_pubkey_get_verify_algorithm (pubkey, &signature2, &hash_algo);
- if (ret < 0 || hash_algo != GNUTLS_DIG_SHA1)
- fail ("gnutls_x509_crt_get_verify_algorithm (hashed data)\n");
-
- ret = gnutls_pubkey_verify_hash (pubkey, 0, &hash_data, &signature2);
- if (ret < 0)
- fail ("gnutls_x509_pubkey_verify_hash-1 (hashed data)\n");
-
- /* should fail */
- ret = gnutls_pubkey_verify_hash (pubkey, 0, &invalid_hash_data, &signature2);
- if (ret != GNUTLS_E_PK_SIG_VERIFY_FAILED)
- fail ("gnutls_x509_pubkey_verify_hash-2 (hashed data)\n");
-
- sign_algo = gnutls_pk_to_sign(gnutls_pubkey_get_pk_algorithm(pubkey, NULL),
- GNUTLS_DIG_SHA1);
-
- ret = gnutls_pubkey_verify_hash2 (pubkey, sign_algo, 0, &hash_data, &signature2);
- if (ret < 0)
- fail ("gnutls_x509_pubkey_verify_hash2-1 (hashed data)\n");
-
- /* should fail */
- ret = gnutls_pubkey_verify_hash2 (pubkey, sign_algo, 0, &invalid_hash_data, &signature2);
- if (ret != GNUTLS_E_PK_SIG_VERIFY_FAILED)
- fail ("gnutls_x509_pubkey_verify_hash2-2 (hashed data)\n");
-
- /* test the raw interface */
- gnutls_free(signature.data);
- signature.data = NULL;
-
- if (gnutls_pubkey_get_pk_algorithm(pubkey, NULL) == GNUTLS_PK_RSA)
- {
- ret = gnutls_privkey_sign_hash (privkey, GNUTLS_DIG_SHA1, GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA,
- &hash_data, &signature);
- if (ret < 0)
- fail ("gnutls_privkey_sign_hash: %s\n", gnutls_strerror(ret));
-
- sign_algo = gnutls_pk_to_sign(gnutls_pubkey_get_pk_algorithm(pubkey, NULL),
- GNUTLS_DIG_SHA1);
-
- ret = gnutls_pubkey_verify_hash2 (pubkey, sign_algo, GNUTLS_PUBKEY_VERIFY_FLAG_TLS1_RSA, &hash_data, &signature);
- if (ret < 0)
- fail ("gnutls_pubkey_verify_hash-3 (raw hashed data)\n");
- }
- gnutls_free(signature.data);
- gnutls_free(signature2.data);
- gnutls_x509_privkey_deinit (key);
- gnutls_x509_crt_deinit (crt);
- gnutls_privkey_deinit (privkey);
- gnutls_pubkey_deinit (pubkey);
- }
-
- gnutls_global_deinit ();
+ gnutls_x509_privkey_t key;
+ gnutls_x509_crt_t crt;
+ gnutls_pubkey_t pubkey;
+ gnutls_privkey_t privkey;
+ gnutls_digest_algorithm_t hash_algo;
+ gnutls_sign_algorithm_t sign_algo;
+ gnutls_datum_t signature;
+ gnutls_datum_t signature2;
+ int ret;
+ size_t i;
+
+ global_init();
+
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(6);
+
+ for (i = 0; i < sizeof(key_dat) / sizeof(key_dat[0]); i++) {
+ if (debug)
+ success("loop %d\n", (int) i);
+
+ ret = gnutls_x509_privkey_init(&key);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_init\n");
+
+ ret =
+ gnutls_x509_privkey_import(key, &key_dat[i],
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_import\n");
+
+ ret = gnutls_pubkey_init(&pubkey);
+ if (ret < 0)
+ fail("gnutls_privkey_init\n");
+
+ ret = gnutls_privkey_init(&privkey);
+ if (ret < 0)
+ fail("gnutls_pubkey_init\n");
+
+ ret = gnutls_privkey_import_x509(privkey, key, 0);
+ if (ret < 0)
+ fail("gnutls_privkey_import_x509\n");
+
+ ret = gnutls_privkey_sign_hash(privkey, GNUTLS_DIG_SHA1, 0,
+ &hash_data, &signature2);
+ if (ret < 0)
+ fail("gnutls_privkey_sign_hash\n");
+
+ ret = gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA1, 0,
+ &raw_data, &signature);
+ if (ret < 0)
+ fail("gnutls_x509_privkey_sign_hash\n");
+
+ ret = gnutls_x509_crt_init(&crt);
+ if (ret < 0)
+ fail("gnutls_x509_crt_init\n");
+
+ ret =
+ gnutls_x509_crt_import(crt, &cert_dat[i],
+ GNUTLS_X509_FMT_PEM);
+ if (ret < 0)
+ fail("gnutls_x509_crt_import\n");
+
+ ret = gnutls_pubkey_import_x509(pubkey, crt, 0);
+ if (ret < 0)
+ fail("gnutls_x509_pubkey_import\n");
+
+ ret =
+ gnutls_pubkey_get_verify_algorithm(pubkey, &signature,
+ &hash_algo);
+ if (ret < 0 || hash_algo != GNUTLS_DIG_SHA1)
+ fail("gnutls_x509_crt_get_verify_algorithm\n");
+
+ ret =
+ gnutls_pubkey_verify_hash(pubkey, 0, &hash_data,
+ &signature);
+ if (ret < 0)
+ fail("gnutls_x509_pubkey_verify_hash\n");
+
+ ret =
+ gnutls_pubkey_get_verify_algorithm(pubkey, &signature2,
+ &hash_algo);
+ if (ret < 0 || hash_algo != GNUTLS_DIG_SHA1)
+ fail("gnutls_x509_crt_get_verify_algorithm (hashed data)\n");
+
+ ret =
+ gnutls_pubkey_verify_hash(pubkey, 0, &hash_data,
+ &signature2);
+ if (ret < 0)
+ fail("gnutls_x509_pubkey_verify_hash-1 (hashed data)\n");
+
+ /* should fail */
+ ret =
+ gnutls_pubkey_verify_hash(pubkey, 0,
+ &invalid_hash_data,
+ &signature2);
+ if (ret != GNUTLS_E_PK_SIG_VERIFY_FAILED)
+ fail("gnutls_x509_pubkey_verify_hash-2 (hashed data)\n");
+
+ sign_algo =
+ gnutls_pk_to_sign(gnutls_pubkey_get_pk_algorithm
+ (pubkey, NULL), GNUTLS_DIG_SHA1);
+
+ ret =
+ gnutls_pubkey_verify_hash2(pubkey, sign_algo, 0,
+ &hash_data, &signature2);
+ if (ret < 0)
+ fail("gnutls_x509_pubkey_verify_hash2-1 (hashed data)\n");
+
+ /* should fail */
+ ret =
+ gnutls_pubkey_verify_hash2(pubkey, sign_algo, 0,
+ &invalid_hash_data,
+ &signature2);
+ if (ret != GNUTLS_E_PK_SIG_VERIFY_FAILED)
+ fail("gnutls_x509_pubkey_verify_hash2-2 (hashed data)\n");
+
+ /* test the raw interface */
+ gnutls_free(signature.data);
+ signature.data = NULL;
+
+ if (gnutls_pubkey_get_pk_algorithm(pubkey, NULL) ==
+ GNUTLS_PK_RSA) {
+ ret =
+ gnutls_privkey_sign_hash(privkey,
+ GNUTLS_DIG_SHA1,
+ GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA,
+ &hash_data,
+ &signature);
+ if (ret < 0)
+ fail("gnutls_privkey_sign_hash: %s\n",
+ gnutls_strerror(ret));
+
+ sign_algo =
+ gnutls_pk_to_sign
+ (gnutls_pubkey_get_pk_algorithm(pubkey, NULL),
+ GNUTLS_DIG_SHA1);
+
+ ret =
+ gnutls_pubkey_verify_hash2(pubkey, sign_algo,
+ GNUTLS_PUBKEY_VERIFY_FLAG_TLS1_RSA,
+ &hash_data,
+ &signature);
+ if (ret < 0)
+ fail("gnutls_pubkey_verify_hash-3 (raw hashed data)\n");
+ }
+ gnutls_free(signature.data);
+ gnutls_free(signature2.data);
+ gnutls_x509_privkey_deinit(key);
+ gnutls_x509_crt_deinit(crt);
+ gnutls_privkey_deinit(privkey);
+ gnutls_pubkey_deinit(pubkey);
+ }
+
+ gnutls_global_deinit();
}