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