diff options
author | Ian C <ianc@noddybox.co.uk> | 2019-05-28 14:11:25 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2019-05-28 14:11:25 +0000 |
commit | 507031a6e6379c9f809a69c7acc80f6d352f5544 (patch) | |
tree | a10b86f6dba357fb1246598d9f4c4d494a9081ed /handler.h | |
parent | c6556f860ffa70d309a01bd29beb8b9203430bc2 (diff) |
CPC code now loads disk image contents. Directory manipulation still to do.
Diffstat (limited to 'handler.h')
-rw-r--r-- | handler.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/handler.h b/handler.h new file mode 100644 index 0000000..9b08d3a --- /dev/null +++ b/handler.h @@ -0,0 +1,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 +*/ |