b57ec9a5eccb03a1eb4e540e57e9aa70527e652c
[debian/amanda] / server-src / taperscan.h
1 /*
2  * Copyright (c) 2005-2008 Zmanda Inc.  All Rights Reserved.
3  * 
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 as published
6  * by the Free Software Foundation.
7  * 
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * for more details.
12  * 
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16  * 
17  * Contact information: Zmanda Inc, 465 S Mathlida Ave, Suite 300
18  * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19  */
20
21 /*
22  * $Id: taperscan.h,v 1.3 2006/05/25 01:47:20 johnfranks Exp $
23  *
24  * This contains the interface to the tape-scan algorithm implementation.
25  * The interface is rather simple: Calling programs (taper, amcheck,
26  * amtape) call the function below with a desired tape label, and get back
27  * all the relevant label information, along with any other error messages.
28  */
29 #ifndef TAPERSCAN_H
30 #define TAPERSCAN_H
31
32 #include <device.h>
33
34 typedef struct taper_scan_tracker_s taper_scan_tracker_t;
35
36 /* taper_scan(): Scans the changer to find a tape to use. Reads the tape
37  *               label, or invents a new one if label_new_tapes is in use.
38  *               Note that the returned label information should not be
39  *               re-read, because there may not actually exist a label
40  *               on-tape (for WORM or newly-labeled media).
41  *
42  *               This function may be run multiple times consecutively with
43  *               the same tracker; each run will return a different elegible
44  *               tape. The 
45  *
46  * Inputs: wantlabel
47  * Outputs: Returns: -1 if an error occured or no tape was found.
48  *                    1 if the most desirable tape was found.
49  *                    2 if some other labeled tape was found.
50  *                    3 if a brand new tape was found, which we should
51  *                         label ASAP.
52  *          gotlabel: What label was actually retrieved or invented.
53  *         timestamp: What the timestamp string on-tape was. May be "X".
54  *     error_message: Debugging output.
55  *           tapedev: What device to use from now on.
56  *           tracker: Pointer to an allocated taper_scan_tracker_t, used for
57  *                    persistance between runs.
58  *
59  * All returned strings are newly-allocated. */
60
61 typedef void (*TaperscanOutputFunctor)(void * data, char * msg);
62 typedef gboolean (*TaperscanProlongFunctor)(void *data);
63
64 int taper_scan (char* wantlabel,
65                 char** gotlabel, char** timestamp,
66                 char **tapedev,
67                 taper_scan_tracker_t* tracker,
68                 TaperscanOutputFunctor output_functor,
69                 void *output_data,
70                 TaperscanProlongFunctor prolong_functor,
71                 void *prolong_data
72                 );
73 void FILE_taperscan_output_callback(void *data, char *msg);
74 void CHAR_taperscan_output_callback(void *data, char *msg);
75
76 /* Returns a newly allocated tracker object. */
77 taper_scan_tracker_t* taper_scan_tracker_new(void);
78
79 /* Frees a tracker object. */
80 void taper_scan_tracker_free(taper_scan_tracker_t*);
81
82 #endif  /* !TAPERSCAN_H */