summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2019-05-28 14:11:25 +0000
committerIan C <ianc@noddybox.co.uk>2019-05-28 14:11:25 +0000
commit507031a6e6379c9f809a69c7acc80f6d352f5544 (patch)
treea10b86f6dba357fb1246598d9f4c4d494a9081ed /util.h
parentc6556f860ffa70d309a01bd29beb8b9203430bc2 (diff)
CPC code now loads disk image contents. Directory manipulation still to do.
Diffstat (limited to 'util.h')
-rw-r--r--util.h65
1 files changed, 65 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
+
+ -------------------------------------------------------------------------
+
+ 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
+*/