blob: 9b08d3a6d62ee66888d2d692fa932560e08dd5e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
DiskImageTool - Tool for manipulating disk images
Copyright (C) 2019 Ian Cowburn (ianc@noddybox.co.uk)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------
Disk Image handler definitions
*/
#ifndef DITOOL_HANDLER_H
#define DITOOL_HANDLER_H
typedef struct
{
/* The short ID of the image handler
*/
const char *id;
/* The longer descriptive name for the handler
*/
const char *name;
/* Returns a reason for the last error.
*/
const char * (*last_error)(void);
/* List the files in the image to stdout
*/
void (*list_files)(void);
/* Display info about the disk image to stdout
*/
void (*list_info)(void);
/* Return TRUE if the passed memory buffer is recognised as your image type
*/
int (*is_my_file)(const void *buff, size_t buffsize);
/* Open an image. The passed pointer is dynamically allocated and it is
the handlers responsibility to free it once done. It can be assumed
that is_my_file() was successfully called prior to this. Returns TRUE
if the image is opened OK. If the image wasn't opened OK buff should be
freed.
*/
int (*open_image)(void *buff, size_t buffsize);
/* Close the current image, saving it to the passed name if not NULL.
Returns TRUE if saved OK. The image can be freed at this point.
*/
int (*close_image)(const char *name);
/* Get a file from the disk image given the name, storing it in the passed
path. Returns TRUE if the file was fetched OK.
*/
int (*get_file)(const char *name, const char *path);
/* Put the contents of the passed path into the image with the passed name.
Returns TRUE if the file was stored OK.
*/
int (*put_file)(const char *name, const char *path);
/* Delete the passed name from the disk image. Returns TRUE for success.
*/
int (*delete_file)(const char *name);
/* Create a new disk image in the supplied path and open it for access in
the handler.
*/
int (*create)(const char *path);
} Handler;
void DITOOL_Register(const Handler *handler);
#endif
/*
vim: ai sw=4 ts=8 expandtab
*/
|