OpenCBM
cbmcopy.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 2001 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
8 */
9 
10 #ifndef CBMCOPY_H
11 #define CBMCOPY_H
12 
13 #define LIBCBMCOPY_DEBUG
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 typedef struct
20 {
21  int transfer_mode;
22  enum cbm_device_type_e drive_type;
24 
25 typedef enum
26 {
27  sev_fatal,
28  sev_warning,
29  sev_info,
30  sev_debug
31 } cbmcopy_severity_e;
32 
33 typedef void (*cbmcopy_message_cb)(cbmcopy_severity_e sev, const char *format, ...);
34 
35 typedef int (*cbmcopy_status_cb)(int blocks_processed);
36 
37 #ifdef LIBCBMCOPY_DEBUG
38 /*
39  * print out the state of internal counters that are used on read
40  * and write transfers for debugging rare protocol races and hangups
41  */
42 extern void printDebugCBMcopyCounters(cbmcopy_message_cb msg_cb);
43 #endif
44 
45 /*
46  * Build '\0'-terminated list of '\0'-terminated transfer mode names.
47  * Memory should be free()'d after use.
48  */
49 extern char *cbmcopy_get_transfer_modes();
50 
51 /*
52  * parse transfer mode name ("serial1", "s2", "parallel"...) abbreviations
53  * are possible
54  */
55 extern int cbmcopy_get_transfer_mode_index(const char *name);
56 
57 /*
58  * find out if "auto" transfer mode was specified. If yet, determine
59  * the best transfer mode we can use.
60  */
61 extern int cbmcopy_check_auto_transfer_mode(CBM_FILE cbm_fd,
62  int auto_transfermode,
63  int drive);
64 
65 /*
66  * returns malloc()'d pointer to default settings.
67  * must be free()'d after use.
68  */
69 extern cbmcopy_settings *cbmcopy_get_default_settings(void);
70 
71 extern int cbmcopy_write_file(CBM_FILE cbm_fd,
72  cbmcopy_settings *settings,
73  int drive,
74  const char *cbmname,
75  int cbmname_size,
76  const unsigned char *filedata,
77  int filedata_size,
78  cbmcopy_message_cb msg_cb,
79  cbmcopy_status_cb status_cb);
80 
81 extern int cbmcopy_read_file(CBM_FILE cbm_fd,
82  cbmcopy_settings *settings,
83  int drive,
84  const char *cbmname,
85  int cbmname_size,
86  unsigned char **filedata,
87  size_t *filedata_size,
88  cbmcopy_message_cb msg_cb,
89  cbmcopy_status_cb status_cb);
90 
91 extern int cbmcopy_read_file_ts(CBM_FILE cbm_fd,
92  cbmcopy_settings *settings,
93  int drive,
94  int track, int sector,
95  unsigned char **filedata,
96  size_t *filedata_size,
97  cbmcopy_message_cb msg_cb,
98  cbmcopy_status_cb status_cb);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* CBMCOPY_H */
#define CBM_FILE
Definition: opencbm.h:87
cbm_device_type_e
Definition: opencbm.h:114