summaryrefslogtreecommitdiff
path: root/src/x-authority.h
blob: d9f0e0b24589cc61f96bb195de2daa50a8e3e16f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright (C) 2010-2011 Robert Ancell.
 * Author: Robert Ancell <robert.ancell@canonical.com>
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

#ifndef X_AUTHORITY_H_
#define X_AUTHORITY_H_

#include <glib-object.h>

G_BEGIN_DECLS

#define X_AUTHORITY_TYPE (x_authority_get_type())
#define X_AUTHORITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), X_AUTHORITY_TYPE, XAuthority));

typedef struct
{
    GObject         parent_instance;
} XAuthority;

typedef struct
{
    GObjectClass parent_class;
} XAuthorityClass;

G_DEFINE_AUTOPTR_CLEANUP_FUNC (XAuthority, g_object_unref)

#define XAUTH_FAMILY_INTERNET 0
#define XAUTH_FAMILY_DECNET 1
#define XAUTH_FAMILY_CHAOS 2
#define XAUTH_FAMILY_SERVER_INTERPRETED 5
#define XAUTH_FAMILY_INTERNET6 6
#define XAUTH_FAMILY_LOCALHOST 252
#define XAUTH_FAMILY_KRB5_PRINCIPAL 253
#define XAUTH_FAMILY_NETNAME 254
#define XAUTH_FAMILY_LOCAL 256
#define XAUTH_FAMILY_WILD 65535

typedef enum
{
   XAUTH_WRITE_MODE_REPLACE,
   XAUTH_WRITE_MODE_REMOVE,
   XAUTH_WRITE_MODE_SET
} XAuthWriteMode;

GType x_authority_get_type (void);

XAuthority *x_authority_new (guint16 family, const guint8 *address, gsize address_length, const gchar *number, const gchar *name, const guint8 *data, gsize data_length);

XAuthority *x_authority_new_cookie (guint16 family, const guint8 *address, gsize address_length, const gchar *number);

void x_authority_set_family (XAuthority *auth, guint16 family);

guint16 x_authority_get_family (XAuthority *auth);

void x_authority_set_address (XAuthority *auth, const guint8 *address, gsize address_length);

const guint8 *x_authority_get_address (XAuthority *auth);

gsize x_authority_get_address_length (XAuthority *auth);

void x_authority_set_number (XAuthority *auth, const gchar *number);

const gchar *x_authority_get_number (XAuthority *auth);

void x_authority_set_authorization_name (XAuthority *auth, const gchar *name);

const gchar *x_authority_get_authorization_name (XAuthority *auth);

void x_authority_set_authorization_data (XAuthority *auth, const guint8 *data, gsize data_length);

const guint8 *x_authority_get_authorization_data (XAuthority *auth);

guint8 *x_authority_copy_authorization_data (XAuthority *auth);

gsize x_authority_get_authorization_data_length (XAuthority *auth);

gboolean x_authority_write (XAuthority *auth, XAuthWriteMode mode, const gchar *filename, GError **error);

G_END_DECLS

#endif /* X_AUTHORITY_H_ */