OpenCBM
d64copy.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 1999-2001 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
8 */
9 
10 #ifndef D64COPY_H
11 #define D64COPY_H
12 
13 #define LIBD64COPY_DEBUG /* enable state logging and debugging */
14 
15 #define MAX_TRACKS 70 /* for .d71 */
16 #define MAX_SECTORS 21
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /*
23  * known BAM modes
24  */
25 typedef enum
26 {
27  bm_ignore = 0, /* all sectors */
28  bm_allocated = 1, /* allocated sectors */
29  bm_save = 2 /* allocated sectors + BAM track */
30 } d64copy_bam_mode;
31 
32 typedef enum
33 {
34  em_always,
35  em_on_error,
36  em_never
37 } d64copy_error_mode;
38 
39 typedef enum
40 {
41  bs_invalid = 0,
42  bs_dont_copy = 1,
43  bs_must_copy = 2,
44  bs_error = 3,
45  bs_copied = 4
46 } d64copy_bam_status;
47 
48 typedef struct
49 {
50  int warp;
51  int retries;
52  int interleave;
53  int start_track;
54  int end_track;
55  int two_sided;
56  int transfer_mode;
57  enum cbm_device_type_e drive_type;
58  d64copy_bam_mode bam_mode;
59  d64copy_error_mode error_mode;
61 
62 typedef struct
63 {
64  int track;
65  int sector;
66  int read_result;
67  int write_result;
68  int sectors_processed;
69  int total_sectors;
70  d64copy_settings *settings;
71  char bam[MAX_TRACKS][MAX_SECTORS+1];
73 
74 typedef enum
75 {
76  sev_fatal,
77  sev_warning,
78  sev_info,
79  sev_debug
80 } d64copy_severity_e;
81 
82 typedef void (*d64copy_message_cb)(int d64copy_severity_e, const char *format, ...);
83 typedef int (*d64copy_status_cb)(d64copy_status status);
84 
85 #ifdef LIBD64COPY_DEBUG
86 /*
87  * print out the state of internal counters that are used on read
88  * and write transfers for debugging rare protocol races and hangups
89  */
90 extern void printDebugLibD64Counters(d64copy_message_cb msg_cb);
91 #endif
92 
93 /*
94  * Build '\0'-terminated list of '\0'-terminated transfer mode names.
95  * Memory should be free()'d after use.
96  */
97 extern char *d64copy_get_transfer_modes();
98 
99 /*
100  * parse transfer mode name ("serial1", "s2", "parallel"...) abbreviations
101  * are possible
102  */
103 extern int d64copy_get_transfer_mode_index(const char *name);
104 
105 /*
106  * find out if "auto" transfer mode was specified. If yet, determine
107  * the best transfer mode we can use.
108  */
109 extern int d64copy_check_auto_transfer_mode(CBM_FILE cbm_fd,
110  int auto_transfermode,
111  int drive);
112 
113 /*
114  * returns malloc()'d pointer to default settings.
115  * must be free()'d after use.
116  */
117 extern d64copy_settings *d64copy_get_default_settings(void);
118 
119 /*
120  * return number of sectors on a given track, -1 if invalid
121  */
122 extern int d64copy_sector_count(int two_sided, int track);
123 
124 extern int d64copy_read_image(CBM_FILE cbm_fd,
125  d64copy_settings *settings,
126  int src_drive,
127  const char *dst_image,
128  d64copy_message_cb msg_cb,
129  d64copy_status_cb status_cb);
130 
131 extern int d64copy_write_image(CBM_FILE cbm_fd,
132  d64copy_settings *settings,
133  const char *src_image,
134  int dst_drive,
135  d64copy_message_cb msg_cb,
136  d64copy_status_cb status_cb);
137 
138 extern void d64copy_cleanup(void);
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* D64COPY_H */
#define CBM_FILE
Definition: opencbm.h:87
cbm_device_type_e
Definition: opencbm.h:114