Commit | Line | Data |
---|---|---|
8af55556 | 1 | /* GnuTLS glue for GNU Emacs. |
73b0cd50 | 2 | Copyright (C) 2010-2011 Free Software Foundation, Inc. |
8af55556 TZ |
3 | |
4 | This file is part of GNU Emacs. | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
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/>. */ | |
18 | ||
19 | #ifndef EMACS_GNUTLS_DEFINED | |
20 | #define EMACS_GNUTLS_DEFINED | |
21 | ||
22 | #ifdef HAVE_GNUTLS | |
23 | #include <gnutls/gnutls.h> | |
e061a11b | 24 | #include <gnutls/x509.h> |
8af55556 TZ |
25 | |
26 | typedef enum | |
27 | { | |
28 | /* Initialization stages. */ | |
29 | GNUTLS_STAGE_EMPTY = 0, | |
30 | GNUTLS_STAGE_CRED_ALLOC, | |
31 | GNUTLS_STAGE_FILES, | |
e061a11b | 32 | GNUTLS_STAGE_CALLBACKS, |
8af55556 TZ |
33 | GNUTLS_STAGE_INIT, |
34 | GNUTLS_STAGE_PRIORITY, | |
35 | GNUTLS_STAGE_CRED_SET, | |
36 | ||
37 | /* Handshake stages. */ | |
38 | GNUTLS_STAGE_HANDSHAKE_CANDO = GNUTLS_STAGE_CRED_SET, | |
39 | GNUTLS_STAGE_TRANSPORT_POINTERS_SET, | |
40 | GNUTLS_STAGE_HANDSHAKE_TRIED, | |
41 | ||
42 | GNUTLS_STAGE_READY, | |
43 | } gnutls_initstage_t; | |
44 | ||
0898ca10 | 45 | #define GNUTLS_EMACS_ERROR_NOT_LOADED GNUTLS_E_APPLICATION_ERROR_MIN + 1 |
8af55556 TZ |
46 | #define GNUTLS_EMACS_ERROR_INVALID_TYPE GNUTLS_E_APPLICATION_ERROR_MIN |
47 | ||
48 | #define GNUTLS_INITSTAGE(proc) (XPROCESS (proc)->gnutls_initstage) | |
49 | ||
50 | #define GNUTLS_PROCESS_USABLE(proc) (GNUTLS_INITSTAGE(proc) >= GNUTLS_STAGE_READY) | |
51 | ||
8ed70bf3 LMI |
52 | #define GNUTLS_LOG(level, max, string) if (level <= max) { gnutls_log_function (level, "(Emacs) " string); } |
53 | ||
c1ae068b LMI |
54 | #define GNUTLS_LOG2(level, max, string, extra) if (level <= max) { gnutls_log_function2 (level, "(Emacs) " string, extra); } |
55 | ||
0898ca10 | 56 | extern EMACS_INT |
e968f4f3 | 57 | emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte); |
0898ca10 | 58 | extern EMACS_INT |
e968f4f3 | 59 | emacs_gnutls_read (struct Lisp_Process *proc, char *buf, EMACS_INT nbyte); |
8af55556 | 60 | |
0898ca10 JB |
61 | extern int emacs_gnutls_record_check_pending (gnutls_session_t state); |
62 | extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err); | |
63 | ||
8af55556 TZ |
64 | extern void syms_of_gnutls (void); |
65 | ||
368f4090 | 66 | #endif |
8af55556 TZ |
67 | |
68 | #endif |