declare smobs in alloc.c
[bpt/emacs.git] / src / gnutls.h
CommitLineData
8af55556 1/* GnuTLS glue for GNU Emacs.
ba318903 2 Copyright (C) 2010-2014 Free Software Foundation, Inc.
8af55556
TZ
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along 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 25
a18ecafa
TZ
26/* This limits the attempts to handshake per process (connection). */
27#define GNUTLS_EMACS_HANDSHAKES_LIMIT 100
28
8af55556
TZ
29typedef enum
30{
31 /* Initialization stages. */
32 GNUTLS_STAGE_EMPTY = 0,
33 GNUTLS_STAGE_CRED_ALLOC,
34 GNUTLS_STAGE_FILES,
e061a11b 35 GNUTLS_STAGE_CALLBACKS,
8af55556
TZ
36 GNUTLS_STAGE_INIT,
37 GNUTLS_STAGE_PRIORITY,
38 GNUTLS_STAGE_CRED_SET,
39
40 /* Handshake stages. */
41 GNUTLS_STAGE_HANDSHAKE_CANDO = GNUTLS_STAGE_CRED_SET,
42 GNUTLS_STAGE_TRANSPORT_POINTERS_SET,
43 GNUTLS_STAGE_HANDSHAKE_TRIED,
44
29abe551 45 GNUTLS_STAGE_READY
8af55556
TZ
46} gnutls_initstage_t;
47
11dde529 48#define GNUTLS_EMACS_ERROR_NOT_LOADED (GNUTLS_E_APPLICATION_ERROR_MIN + 1)
8af55556
TZ
49#define GNUTLS_EMACS_ERROR_INVALID_TYPE GNUTLS_E_APPLICATION_ERROR_MIN
50
51#define GNUTLS_INITSTAGE(proc) (XPROCESS (proc)->gnutls_initstage)
52
11dde529
PE
53#define GNUTLS_PROCESS_USABLE(proc) \
54 (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_READY)
8af55556 55
11dde529
PE
56#define GNUTLS_LOG(level, max, string) \
57 do { \
58 if ((level) <= (max)) \
59 gnutls_log_function (level, "(Emacs) " string); \
96c06863 60 } while (false)
8ed70bf3 61
11dde529
PE
62#define GNUTLS_LOG2(level, max, string, extra) \
63 do { \
64 if ((level) <= (max)) \
65 gnutls_log_function2 (level, "(Emacs) " string, extra); \
96c06863 66 } while (false)
c1ae068b 67
11dde529
PE
68#define GNUTLS_LOG2i(level, max, string, extra) \
69 do { \
70 if ((level) <= (max)) \
71 gnutls_log_function2i (level, "(Emacs) " string, extra); \
96c06863 72 } while (false)
a18ecafa 73
d311d28c
PE
74extern ptrdiff_t
75emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte);
76extern ptrdiff_t
77emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte);
8af55556 78
11dde529 79extern ptrdiff_t emacs_gnutls_record_check_pending (gnutls_session_t state);
3d798ba7 80#ifdef WINDOWSNT
0898ca10 81extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err);
3d798ba7 82#endif
9c6c6f49 83extern Lisp_Object emacs_gnutls_deinit (Lisp_Object);
0898ca10 84
8af55556
TZ
85extern void syms_of_gnutls (void);
86
368f4090 87#endif
8af55556
TZ
88
89#endif