Fix typos in ChangeLogs.
[emacs.git] / src / gnutls.h
blobf1a337e7b3e655577c83f97d86a1f24d6eee75b6
1 /* GnuTLS glue for GNU Emacs.
2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef EMACS_GNUTLS_DEFINED
20 #define EMACS_GNUTLS_DEFINED
22 #ifdef HAVE_GNUTLS
23 #include <gnutls/gnutls.h>
24 #include <gnutls/x509.h>
26 /* This limits the attempts to handshake per process (connection). */
27 #define GNUTLS_EMACS_HANDSHAKES_LIMIT 100
29 typedef enum
31 /* Initialization stages. */
32 GNUTLS_STAGE_EMPTY = 0,
33 GNUTLS_STAGE_CRED_ALLOC,
34 GNUTLS_STAGE_FILES,
35 GNUTLS_STAGE_CALLBACKS,
36 GNUTLS_STAGE_INIT,
37 GNUTLS_STAGE_PRIORITY,
38 GNUTLS_STAGE_CRED_SET,
40 /* Handshake stages. */
41 GNUTLS_STAGE_HANDSHAKE_CANDO = GNUTLS_STAGE_CRED_SET,
42 GNUTLS_STAGE_TRANSPORT_POINTERS_SET,
43 GNUTLS_STAGE_HANDSHAKE_TRIED,
45 GNUTLS_STAGE_READY,
46 } gnutls_initstage_t;
48 #define GNUTLS_EMACS_ERROR_NOT_LOADED GNUTLS_E_APPLICATION_ERROR_MIN + 1
49 #define GNUTLS_EMACS_ERROR_INVALID_TYPE GNUTLS_E_APPLICATION_ERROR_MIN
51 #define GNUTLS_INITSTAGE(proc) (XPROCESS (proc)->gnutls_initstage)
53 #define GNUTLS_PROCESS_USABLE(proc) (GNUTLS_INITSTAGE(proc) >= GNUTLS_STAGE_READY)
55 #define GNUTLS_LOG(level, max, string) do { if (level <= max) { gnutls_log_function (level, "(Emacs) " string); } } while (0)
57 #define GNUTLS_LOG2(level, max, string, extra) do { if (level <= max) { gnutls_log_function2 (level, "(Emacs) " string, extra); } } while (0)
59 #define GNUTLS_LOG2i(level, max, string, extra) do { if (level <= max) { gnutls_log_function2i (level, "(Emacs) " string, extra); } } while (0)
61 extern ptrdiff_t
62 emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte);
63 extern ptrdiff_t
64 emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte);
66 extern int emacs_gnutls_record_check_pending (gnutls_session_t state);
67 extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err);
68 extern Lisp_Object emacs_gnutls_deinit (Lisp_Object);
70 extern void syms_of_gnutls (void);
72 #endif
74 #endif