source: trunk/packages/xen-3.1/xen-3.1/tools/libxen/include/xen/api/xen_common.h @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 4.8 KB
Line 
1/*
2 * Copyright (c) 2006 XenSource, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
17 */
18
19#ifndef XEN_COMMON_H
20#define XEN_COMMON_H
21
22
23#include <stdbool.h>
24#include <stddef.h>
25#include <stdint.h>
26#include <time.h>
27
28#include "xen/api/xen_host_decl.h"
29
30
31typedef bool (*xen_result_func)(const void *data, size_t len,
32                                void *result_handle);
33
34
35/**
36 * len does not include a terminating \0.
37 */
38typedef int (*xen_call_func)(const void *, size_t len, void *user_handle,
39                             void *result_handle,
40                             xen_result_func result_func);
41
42
43typedef struct
44{
45    xen_call_func call_func;
46    void *handle;
47    const char *session_id;
48    bool ok;
49    char **error_description;
50    int error_description_count;
51} xen_session;
52
53
54typedef struct xen_session_record
55{
56    char *uuid;
57    struct xen_host_record_opt *this_host;
58    char *this_user;
59    time_t last_active;
60} xen_session_record;
61
62
63/**
64 * Allocate a xen_session_record.
65 */
66extern xen_session_record *
67xen_session_record_alloc(void);
68
69
70/**
71 * Free the given xen_session_record, and all referenced values.  The
72 * given record must have been allocated by this library.
73 */
74extern void
75xen_session_record_free(xen_session_record *record);
76
77
78struct xen_task_;
79typedef struct xen_task_ * xen_task_id;
80
81
82typedef struct
83{
84    int progress;
85    long eta;
86    /* !!! RESULT */
87}  xen_task_status;
88
89
90typedef struct
91{
92    int major;
93    int minor;
94    int patch;
95    char *extraversion;
96} xen_version;
97
98
99/**
100 * Free the given xen_version, and all referenced values.
101 */
102extern void xen_version_free(xen_version *version);
103
104
105/**
106 * Return the version of this client-side library.  This will be the major,
107 * minor, and extraversion of the Xen release with which it was released,
108 * plus the library's own version as the patch.
109 */
110extern xen_version *xen_get_client_side_version();
111
112
113extern bool
114xen_uuid_string_to_bytes(char *uuid, char **bytes);
115
116
117extern bool
118xen_uuid_bytes_to_string(char *bytes, char **uuid);
119
120
121extern void
122xen_uuid_free(char *uuid);
123
124
125extern void
126xen_uuid_bytes_free(char *bytes);
127
128
129/**
130 * Initialise this library.  Call this before starting to use this library.
131 * Note that since this library depends upon libxml2, you should also call
132 * xmlInitParser as appropriate for your program.
133 */
134extern
135void xen_init(void);
136
137
138/**
139 * Clear up this library.  Call when you have finished using this library.
140 * Note that since this library depends upon libxml2, you should also call
141 * xmlCleanupParser as appropriate for your program.
142 */
143extern
144void xen_fini(void);
145
146
147/**
148 * Log in at the server, and allocate a xen_session to represent this session.
149 */
150extern xen_session *
151xen_session_login_with_password(xen_call_func call_func, void *handle,
152                                const char *uname, const char *pwd);
153
154
155/**
156 * Log out at the server, and free the xen_session.
157 */
158extern void
159xen_session_logout(xen_session *session);
160
161
162/**
163 * Clear any error condition recorded on this session.
164 */
165void
166xen_session_clear_error(xen_session *session);
167
168
169/**
170 * Get the UUID of the second given session.  Set *result to point at a
171 * string, yours to free.
172 */
173extern bool
174xen_session_get_uuid(xen_session *session, char **result,
175                     xen_session *self_session);
176
177
178/**
179 * Get the this_host field of the second given session.  Set *result to be a
180 * handle to that host.
181 */
182extern bool
183xen_session_get_this_host(xen_session *session, xen_host *result,
184                          xen_session *self_session);
185
186
187/**
188 * Get the this_user field of the second given session.  Set *result to point
189 * at a string, yours to free.
190 */
191extern bool
192xen_session_get_this_user(xen_session *session, char **result,
193                          xen_session *self_session);
194
195
196/**
197 * Get the last_active field of the given session, and place it in *result.
198 */
199extern bool
200xen_session_get_last_active(xen_session *session, time_t *result,
201                            xen_session *self_session);
202
203/**
204 * Get a record containing the current state of the second given session.
205 */
206extern bool
207xen_session_get_record(xen_session *session, xen_session_record **result,
208                       xen_session *self_session);
209
210
211#endif
Note: See TracBrowser for help on using the repository browser.