2 * Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
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.
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
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
17 * Contact information: Zmanda Inc, 465 S Mathlida Ave, Suite 300
18 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
22 * $Id: taperscan.h,v 1.3 2006/05/25 01:47:20 johnfranks Exp $
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.
34 typedef struct taper_scan_tracker_s taper_scan_tracker_t;
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).
42 * This function may be run multiple times consecutively with
43 * the same tracker; each run will return a different elegible
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
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.
59 * All returned strings are newly-allocated. */
61 typedef void (*TaperscanOutputFunctor)(void * data, char * msg);
62 typedef gboolean (*TaperscanProlongFunctor)(void *data);
64 int taper_scan (char* wantlabel,
65 char** gotlabel, char** timestamp,
67 taper_scan_tracker_t* tracker,
68 TaperscanOutputFunctor output_functor,
70 TaperscanProlongFunctor prolong_functor,
73 void FILE_taperscan_output_callback(void *data, char *msg);
74 void CHAR_taperscan_output_callback(void *data, char *msg);
76 /* Returns a newly allocated tracker object. */
77 taper_scan_tracker_t* taper_scan_tracker_new(void);
79 /* Frees a tracker object. */
80 void taper_scan_tracker_free(taper_scan_tracker_t*);
82 #endif /* !TAPERSCAN_H */