source: trunk/packages/xen-3.1/xen-3.1/tools/libxen/src/xen_on_crash_behaviour.c @ 34

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

Add xen and xen-common

File size: 2.2 KB
Line 
1/*
2 * Copyright (c) 2006-2007, 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#include <string.h>
20
21#include "xen_internal.h"
22#include <xen/api/xen_on_crash_behaviour.h>
23#include "xen_on_crash_behaviour_internal.h"
24
25
26/*
27 * Maintain this in the same order as the enum declaration!
28 */
29static const char *lookup_table[] =
30{
31    "destroy",
32    "coredump_and_destroy",
33    "restart",
34    "coredump_and_restart",
35    "preserve",
36    "rename_restart"
37};
38
39
40extern xen_on_crash_behaviour_set *
41xen_on_crash_behaviour_set_alloc(size_t size)
42{
43    return calloc(1, sizeof(xen_on_crash_behaviour_set) +
44                  size * sizeof(enum xen_on_crash_behaviour));
45}
46
47
48extern void
49xen_on_crash_behaviour_set_free(xen_on_crash_behaviour_set *set)
50{
51    free(set);
52}
53
54
55const char *
56xen_on_crash_behaviour_to_string(enum xen_on_crash_behaviour val)
57{
58    return lookup_table[val];
59}
60
61
62extern enum xen_on_crash_behaviour
63xen_on_crash_behaviour_from_string(xen_session *session, const char *str)
64{
65    return ENUM_LOOKUP(session, str, lookup_table);
66}
67
68
69const abstract_type xen_on_crash_behaviour_abstract_type_ =
70    {
71        .typename = ENUM,
72        .enum_marshaller =
73             (const char *(*)(int))&xen_on_crash_behaviour_to_string,
74        .enum_demarshaller =
75             (int (*)(xen_session *, const char *))&xen_on_crash_behaviour_from_string
76    };
77
78
79const abstract_type xen_on_crash_behaviour_set_abstract_type_ =
80    {
81        .typename = SET,
82        .child = &xen_on_crash_behaviour_abstract_type_
83    };
84
85
Note: See TracBrowser for help on using the repository browser.