/* 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 . ------------------------------------------------------------------------- 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 */