1 /* 2 * Copyright (C) 2010-2011 Robert Ancell. 3 * Author: Robert Ancell <robert.ancell@canonical.com> 4 * 5 * This program is free software: you can redistribute it and/or modify it under 6 * the terms of the GNU General Public License as published by the Free Software 7 * Foundation, either version 3 of the License, or (at your option) any later 8 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the 9 * license. 10 */ 11 12 #ifndef X_AUTHORITY_H_ 13 #define X_AUTHORITY_H_ 14 15 #include <glib-object.h> 16 17 G_BEGIN_DECLS 18 19 #define X_AUTHORITY_TYPE (x_authority_get_type()) 20 #define X_AUTHORITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), X_AUTHORITY_TYPE, XAuthority)); 21 22 typedef struct 23 { 24 GObject parent_instance; 25 } XAuthority; 26 27 typedef struct 28 { 29 GObjectClass parent_class; 30 } XAuthorityClass; 31 32 G_DEFINE_AUTOPTR_CLEANUP_FUNC (XAuthority, g_object_unref) 33 34 #define XAUTH_FAMILY_INTERNET 0 35 #define XAUTH_FAMILY_DECNET 1 36 #define XAUTH_FAMILY_CHAOS 2 37 #define XAUTH_FAMILY_SERVER_INTERPRETED 5 38 #define XAUTH_FAMILY_INTERNET6 6 39 #define XAUTH_FAMILY_LOCALHOST 252 40 #define XAUTH_FAMILY_KRB5_PRINCIPAL 253 41 #define XAUTH_FAMILY_NETNAME 254 42 #define XAUTH_FAMILY_LOCAL 256 43 #define XAUTH_FAMILY_WILD 65535 44 45 typedef enum 46 { 47 XAUTH_WRITE_MODE_REPLACE, 48 XAUTH_WRITE_MODE_REMOVE, 49 XAUTH_WRITE_MODE_SET 50 } XAuthWriteMode; 51 52 GType x_authority_get_type (void); 53 54 XAuthority *x_authority_new (guint16 family, const guint8 *address, gsize address_length, const gchar *number, const gchar *name, const guint8 *data, gsize data_length); 55 56 XAuthority *x_authority_new_cookie (guint16 family, const guint8 *address, gsize address_length, const gchar *number); 57 58 XAuthority *x_authority_new_local_cookie (const gchar *number); 59 60 void x_authority_set_family (XAuthority *auth, guint16 family); 61 62 guint16 x_authority_get_family (XAuthority *auth); 63 64 void x_authority_set_address (XAuthority *auth, const guint8 *address, gsize address_length); 65 66 const guint8 *x_authority_get_address (XAuthority *auth); 67 68 gsize x_authority_get_address_length (XAuthority *auth); 69 70 void x_authority_set_number (XAuthority *auth, const gchar *number); 71 72 const gchar *x_authority_get_number (XAuthority *auth); 73 74 void x_authority_set_authorization_name (XAuthority *auth, const gchar *name); 75 76 const gchar *x_authority_get_authorization_name (XAuthority *auth); 77 78 void x_authority_set_authorization_data (XAuthority *auth, const guint8 *data, gsize data_length); 79 80 const guint8 *x_authority_get_authorization_data (XAuthority *auth); 81 82 guint8 *x_authority_copy_authorization_data (XAuthority *auth); 83 84 gsize x_authority_get_authorization_data_length (XAuthority *auth); 85 86 gboolean x_authority_write (XAuthority *auth, XAuthWriteMode mode, const gchar *filename, GError **error); 87 88 G_END_DECLS 89 90 #endif /* X_AUTHORITY_H_ */ 91