Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/lib/libmt/mtlib.h
41140 views
1
/*-
2
* Copyright (c) 2013, 2014 Spectra Logic Corporation
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions, and the following disclaimer,
10
* without modification.
11
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
12
* substantially similar to the "NO WARRANTY" disclaimer below
13
* ("Disclaimer") and any redistribution must be conditioned upon
14
* including a substantially similar Disclaimer requirement for further
15
* binary redistribution.
16
*
17
* NO WARRANTY
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
* POSSIBILITY OF SUCH DAMAGES.
29
*
30
* Authors: Ken Merry (Spectra Logic Corporation)
31
*/
32
33
#ifndef _MTLIB_H
34
#define _MTLIB_H
35
36
typedef enum {
37
MT_TYPE_NONE,
38
MT_TYPE_STRING,
39
MT_TYPE_INT,
40
MT_TYPE_UINT,
41
MT_TYPE_NODE
42
} mt_variable_type;
43
44
struct mt_status_nv {
45
char *name;
46
char *value;
47
STAILQ_ENTRY(mt_status_nv) links;
48
};
49
50
struct mt_status_entry {
51
char *entry_name;
52
char *value;
53
uint64_t value_unsigned;
54
int64_t value_signed;
55
char *fmt;
56
char *desc;
57
size_t size;
58
mt_variable_type var_type;
59
struct mt_status_entry *parent;
60
STAILQ_HEAD(, mt_status_nv) nv_list;
61
STAILQ_HEAD(, mt_status_entry) child_entries;
62
STAILQ_ENTRY(mt_status_entry) links;
63
};
64
65
struct mt_status_data {
66
int level;
67
struct sbuf *cur_sb[32];
68
struct mt_status_entry *cur_entry[32];
69
int error;
70
char error_str[128];
71
STAILQ_HEAD(, mt_status_entry) entries;
72
};
73
74
typedef enum {
75
MT_PF_NONE = 0x00,
76
MT_PF_VERBOSE = 0x01,
77
MT_PF_FULL_PATH = 0x02,
78
MT_PF_INCLUDE_ROOT = 0x04
79
} mt_print_flags;
80
81
struct mt_print_params {
82
mt_print_flags flags;
83
char root_name[64];
84
};
85
86
__BEGIN_DECLS
87
void mt_start_element(void *user_data, const char *name, const char **attr);
88
void mt_end_element(void *user_data, const char *name);
89
void mt_char_handler(void *user_data, const XML_Char *str, int len);
90
void mt_status_tree_sbuf(struct sbuf *sb, struct mt_status_entry *entry,
91
int indent, void (*sbuf_func)(struct sbuf *sb,
92
struct mt_status_entry *entry, void *arg), void *arg);
93
void mt_status_tree_print(struct mt_status_entry *entry, int indent,
94
void (*print_func)(struct mt_status_entry *entry,
95
void *arg), void *arg);
96
struct mt_status_entry *mt_entry_find(struct mt_status_entry *entry,
97
char *name);
98
struct mt_status_entry *mt_status_entry_find(struct mt_status_data *status_data,
99
char *name);
100
void mt_status_entry_free(struct mt_status_entry *entry);
101
void mt_status_free(struct mt_status_data *status_data);
102
void mt_entry_sbuf(struct sbuf *sb, struct mt_status_entry *entry, char *fmt);
103
void mt_param_parent_print(struct mt_status_entry *entry,
104
struct mt_print_params *print_params);
105
void mt_param_parent_sbuf(struct sbuf *sb, struct mt_status_entry *entry,
106
struct mt_print_params *print_params);
107
void mt_param_entry_sbuf(struct sbuf *sb, struct mt_status_entry *entry,
108
void *arg);
109
void mt_param_entry_print(struct mt_status_entry *entry, void *arg);
110
int mt_protect_print(struct mt_status_data *status_data, int verbose);
111
int mt_param_list(struct mt_status_data *status_data, char *param_name,
112
int quiet);
113
const char *mt_density_name(int density_num);
114
int mt_density_bp(int density_num, int bpi);
115
int mt_density_num(const char *density_name);
116
int mt_get_xml_str(int mtfd, unsigned long cmd, char **xml_str);
117
int mt_get_status(char *xml_str, struct mt_status_data *status_data);
118
__END_DECLS
119
120
#endif /* _MTLIB_H */
121
122