dbus-marshal-byteswap: Byte-swap Unix fd indexes if needed
[platform/upstream/dbus.git] / dbus / dbus-auth.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-auth.h Authentication
3  *
4  * Copyright (C) 2002  Red Hat Inc.
5  *
6  * Licensed under the Academic Free License version 2.1
7  * 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23 #ifndef DBUS_AUTH_H
24 #define DBUS_AUTH_H
25
26 #include <dbus/dbus-macros.h>
27 #include <dbus/dbus-errors.h>
28 #include <dbus/dbus-string.h>
29 #include <dbus/dbus-sysdeps.h>
30
31 DBUS_BEGIN_DECLS
32
33 typedef struct DBusAuth DBusAuth;
34
35 typedef enum
36 {
37   DBUS_AUTH_STATE_WAITING_FOR_INPUT,
38   DBUS_AUTH_STATE_WAITING_FOR_MEMORY,
39   DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND,
40   DBUS_AUTH_STATE_NEED_DISCONNECT,
41   DBUS_AUTH_STATE_AUTHENTICATED,
42   DBUS_AUTH_STATE_INVALID = -1
43 } DBusAuthState;
44
45 DBUS_PRIVATE_EXPORT
46 DBusAuth*     _dbus_auth_server_new          (const DBusString       *guid);
47 DBUS_PRIVATE_EXPORT
48 DBusAuth*     _dbus_auth_client_new          (void);
49 DBUS_PRIVATE_EXPORT
50 DBusAuth*         _dbus_auth_client_new_authenticated    (void);
51 DBUS_PRIVATE_EXPORT
52 DBusAuth*     _dbus_auth_ref                 (DBusAuth               *auth);
53 DBUS_PRIVATE_EXPORT
54 void          _dbus_auth_unref               (DBusAuth               *auth);
55 DBUS_PRIVATE_EXPORT
56 dbus_bool_t   _dbus_auth_set_mechanisms      (DBusAuth               *auth,
57                                               const char            **mechanisms);
58 DBUS_PRIVATE_EXPORT
59 DBusAuthState _dbus_auth_do_work             (DBusAuth               *auth);
60 DBUS_PRIVATE_EXPORT
61 dbus_bool_t   _dbus_auth_get_bytes_to_send   (DBusAuth               *auth,
62                                               const DBusString      **str);
63 DBUS_PRIVATE_EXPORT
64 void          _dbus_auth_bytes_sent          (DBusAuth               *auth,
65                                               int                     bytes_sent);
66 DBUS_PRIVATE_EXPORT
67 void          _dbus_auth_get_buffer          (DBusAuth               *auth,
68                                               DBusString            **buffer);
69 DBUS_PRIVATE_EXPORT
70 void          _dbus_auth_return_buffer       (DBusAuth               *auth,
71                                               DBusString             *buffer);
72 DBUS_PRIVATE_EXPORT
73 void          _dbus_auth_get_unused_bytes    (DBusAuth               *auth,
74                                               const DBusString      **str);
75 DBUS_PRIVATE_EXPORT
76 void          _dbus_auth_delete_unused_bytes (DBusAuth               *auth);
77 dbus_bool_t   _dbus_auth_needs_encoding      (DBusAuth               *auth);
78 dbus_bool_t   _dbus_auth_encode_data         (DBusAuth               *auth,
79                                               const DBusString       *plaintext,
80                                               DBusString             *encoded);
81 dbus_bool_t   _dbus_auth_needs_decoding      (DBusAuth               *auth);
82 dbus_bool_t   _dbus_auth_decode_data         (DBusAuth               *auth,
83                                               const DBusString       *encoded,
84                                               DBusString             *plaintext);
85 DBUS_PRIVATE_EXPORT
86 dbus_bool_t   _dbus_auth_set_credentials     (DBusAuth               *auth,
87                                               DBusCredentials        *credentials);
88 DBUS_PRIVATE_EXPORT
89 DBusCredentials* _dbus_auth_get_identity     (DBusAuth               *auth);
90 DBUS_PRIVATE_EXPORT
91 dbus_bool_t   _dbus_auth_set_context         (DBusAuth               *auth,
92                                               const DBusString       *context);
93 const char*   _dbus_auth_get_guid_from_server(DBusAuth               *auth);
94
95 void          _dbus_auth_set_unix_fd_possible(DBusAuth               *auth, dbus_bool_t b);
96 dbus_bool_t   _dbus_auth_get_unix_fd_negotiated(DBusAuth             *auth);
97 DBUS_PRIVATE_EXPORT
98 dbus_bool_t   _dbus_auth_is_supported_mechanism(DBusString           *name);
99 DBUS_PRIVATE_EXPORT
100 dbus_bool_t   _dbus_auth_dump_supported_mechanisms(DBusString        *buffer);
101
102 DBUS_END_DECLS
103
104 #endif /* DBUS_AUTH_H */