2 .\" Copyright (c) 2013, 2015 Spectra Logic Corporation
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
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.
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.
30 .\" Authors: Ken Merry (Spectra Logic Corporation)
36 .Nm mt_start_element ,
39 .Nm mt_status_tree_sbuf ,
40 .Nm mt_status_tree_print ,
41 .Nm mt_status_entry_free ,
44 .Nm mt_param_parent_print ,
45 .Nm mt_param_entry_print ,
46 .Nm mt_protect_print ,
53 .Nd Magnetic Tape library
63 .Fa "const char *name"
64 .Fa "const char **attr"
69 .Fa "const char *name"
74 .Fa "const XML_Char *str"
78 .Fo mt_status_tree_sbuf
80 .Fa "struct mt_status_entry *entry"
82 .Fa "void (*sbuf_func)(struct sbuf *sb, struct mt_status_entry *entry, void *arg)"
86 .Fo mt_status_tree_print
87 .Fa "struct mt_status_entry *entry"
89 .Fa "void (*print_func)(struct mt_status_entry *entry, void *arg)"
92 .Ft "struct mt_status_entry *"
94 .Fa "struct mt_status_entry *entry"
97 .Ft "struct mt_status_entry *"
98 .Fo mt_status_entry_find
99 .Fa "struct mt_status_data *status_data"
103 .Fo mt_status_entry_free
104 .Fa "struct mt_status_entry *entry)"
108 .Fa "struct mt_status_data *status_data"
112 .Fa "struct sbuf *sb"
113 .Fa "struct mt_status_entry *entry"
117 .Fo mt_param_parent_sbuf
118 .Fa "struct sbuf *sb"
119 .Fa "struct mt_status_entry *entry"
120 .Fa "struct mt_print_params *print_params"
123 .Fo mt_param_parent_print
124 .Fa "struct mt_status_entry *entry"
125 .Fa "struct mt_print_params *print_params"
128 .Fo mt_param_entry_sbuf
129 .Fa "struct sbuf *sb"
130 .Fa "struct mt_status_entry *entry"
134 .Fo mt_param_entry_print
135 .Fa "struct mt_status_entry *entry"
140 .Fa "struct mt_status_data *status_data"
145 .Fa "struct mt_status_data *status_data"
146 .Fa "char *param_name"
151 .Fa "int density_num"
155 .Fa "int density_num"
160 .Fa "const char *density_name"
165 .Fa "struct mt_status_data *status_data"
168 The MT library consists of a number of functions designed to aid in
174 driver returns some status data as XML-formatted strings, and
175 the primary purpose of this library is to make it easier for the
176 software developer to parse those strings and extract the status values.
179 .Fn mt_start_element ,
183 functions are designed to work with the
185 library, which is an XML parsing library.
186 The user data for the XML parser should be set with
189 mt_status_data with the entries list initialized.
190 The element handlers for the XML parser should be set to
195 .Fn XML_SetElementHandler .
196 The character data handler should be set to
199 .Fn XML_SetCharacterDataHandler
201 The error member of the status_data structure will be set to 0 if parsing
202 is successful, and non-zero if parsing failed.
203 In the event of a failure, the error_str member will contain an error
204 message describing the failure.
205 These functions will build a tree of tape driver status data that can be
206 searched and printed using the other functions in this library.
208 .Fn mt_status_tree_sbuf
209 takes the root node of a tree of
211 driver status information, and displays it in an
215 argument is the destination sbuf.
218 argument is the root of the tree.
221 argument is the number of characters to indent the output.
222 Each recursive call to
223 .Fn mt_status_tree_sbuf
224 will have the indent level incremented by 2.
227 argument is for a user-supplied alternate printing function.
228 If it is non-NULL, it will be called instead of the default output printing
232 argument is an argument for the
237 .Fn mt_status_tree_print
238 function is the same as the
239 .Fn mt_status_tree_sbuf
240 function, except that the tree is printed to standard out instead of to a
245 function returns the first entry in the tree starting at
249 The supplied node name can be a single level name like "foo", or it can
250 specify multiple node names that must be matched, for instance "foo.bar.baz".
251 In the case of a single level name, it will match any node beneath
255 In the case of a multi-level name like "foo.bar.baz", it will return the
256 first entry named "baz" whose immediate parent is "bar" and where the
257 parent of "bar" is named "foo".
260 .Fn mt_status_entry_find
263 except that it operates on the top level mt_status_data and all
264 mt_status_entry nodes below it instead of just an mt_status_entry
268 .Fn mt_status_entry_free
269 function frees the tree of status data underneath
274 function frees the tree of status data underneath
291 will render integer types in base 10 without special formatting and all
292 other types as they were rendered in the XML.
294 .Fn mt_param_parent_sbuf
295 prints the parents of the given
299 subject to the print parameters
301 The result will be formatted with a period between each level, like
304 .Fn mt_param_parent_print
306 .Fn mt_param_parent_sbuf
307 except that it prints the results to standard output instead of an sbuf.
309 .Fn mt_param_entry_sbuf
316 is a pointer to struct mt_print_params, which allows the caller to control
318 This function is intended to be supplied as an argument to
319 .Fn mt_status_tree_sbuf .
321 .Fn mt_param_entry_print
323 .Fn mt_param_entry_sbuf
324 except that it prints to standard output instead of an sbuf.
325 It is intended to be used as an argument to
326 .Fn mt_status_tree_print .
329 prints tape drive protection information from the supplied
331 beginning at the node name defined as the root node for protection data.
334 argument is non-zero, protection entry descriptions will be printed.
335 If it is zero, protection entry descriptions will not be printed.
338 prints tape driver parameters information from the supplied
342 is non-NULL, only the named parameter will be printed.
345 is non-zero, parameter descriptions will be omitted in the output.
348 Returns a text identifier for the supplied numeric
352 should currently be a value between 0 and 255 inclusive, since that is the
356 See below for notes on the return values.
359 Returns the bits per inch or bits per mm values for a given density entry
364 argument is non-zero, the bits per inch value is returned.
365 Otherwise, the bits per mm value is returned.
368 returns a numeric value for a text density description.
369 It does a case-insensitive comparison of density names in the density table
370 to the supplied density name.
373 gets the current XML status / parameter string from the sa(4) driver
374 instance referenced by the open file descriptor
379 to be used is supplied as the
384 function will work with the
391 will be filled in with a pointer to the complete XML status string.
392 Multiple calls to the given
394 are made and more space is malloced until all of the XML string is fetched.
395 The string returned in the
397 argument should be freed when it is no longer in use.
400 returns the first matching entry, or NULL if it fails to find a match.
402 .Fn mt_status_entry_find
403 returns the first matching entry, or NULL if it fails to find a match.
406 Returns 0 for success, and non-zero for failure.
408 can only fail if it cannot find protection information in the supplied
412 Returns 0 for success and non-zero for failure.
414 can only fail if it cannot find parameter information in the supplied
418 returns a text description of a numeric density.
419 The special density value 0 is decoded as "default".
420 The special density value 0x7f is decoded as "same".
421 If the density is not known,
423 will return "UNKNOWN".
426 returns the bits per inch value for the given density (if the
428 field is non-zero), the bits per mm value otherwise, or 0 if the supplied
430 is not in the density table or the table entry does not include bpi / bpmm
434 returns a numeric density value between 0 and 255 for the supplied density
436 It returns 0 if the density name is not recognized.
439 returns 0 for success, and -1 for failure.
445 The MT library first appeared in
448 .An Ken Merry Aq ken@FreeBSD.org
450 The library interface is not complete, and may change in the future.
451 Application authors should not rely on the library interface to be
452 consistent in the immediate future.