From 507031a6e6379c9f809a69c7acc80f6d352f5544 Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 28 May 2019 14:11:25 +0000 Subject: CPC code now loads disk image contents. Directory manipulation still to do. --- util.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 util.h (limited to 'util.h') diff --git a/util.h b/util.h new file mode 100644 index 0000000..d14f041 --- /dev/null +++ b/util.h @@ -0,0 +1,65 @@ +/* + + 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 . + + ------------------------------------------------------------------------- + + Various utilities + +*/ + +#ifndef DITOOL_UTIL_H +#define DITOOL_UTIL_H + +/* Allocate memory, quitting if it fails +*/ +void *Malloc(size_t size); + +/* Reallocate memory, quitting if it fails +*/ +void *Realloc(void *p, size_t size); + +/* Get the next line from stdin, prompting with prompt. Will only return at + EOF or when a string is entered. Returns TRUE for OK, FALSE for EOF. +*/ +int GetLine(const char *prompt, char *buff, size_t buffsize); + +/* Load the file from path into memory, returning a pointer to an allocated + block for the file. *size holds the size of the file. Returns NULL on + error. +*/ +void *Load(const char *path, size_t *size); + +/* Save the passed memory to the path. Returns TRUE for OK, FALSE for failure. +*/ +int Save(const char *path, const void *buff, size_t buffsize); + +/* Compare a lump of memory with a string. Returns as per memcmp() +*/ +int CompareMem(const void *mem, const char *str); + +/* Gets a character from the user from a list of possible choices with an + optional default value. Returns zero on EOF. +*/ +char GetOption(const char *prompt, const char *allowed, char default_val); + +#endif + +/* +vim: ai sw=4 ts=8 expandtab +*/ -- cgit v1.2.3