[VFATLIB]: Few "adjustments" (inspired from the code of DPRINT1) to diagnose
[reactos.git] / reactos / lib / fslib / vfatlib / check / common.h
1 /****
2 ** Platform-dependent file
3 ****/
4
5 /* common.h - Common functions
6
7 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
8 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
9
10 This program is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
22
23 The complete text of the GNU General Public License
24 can be found in /usr/share/common-licenses/GPL-3 file.
25 */
26
27 #ifndef _COMMON_H
28 #define _COMMON_H
29
30 DECLSPEC_NORETURN // __attribute((noreturn))
31 // void die(const char *msg, ...);
32 void die_func(const char *msg, ...);
33 #define die(msg, ...) \
34 do { \
35 die_func("DIE! (%s:%d) " msg "\n", __RELFILE__, __LINE__, ##__VA_ARGS__) \
36 } while (0)
37
38 /* Displays a prinf-style message and terminates the program. */
39
40 DECLSPEC_NORETURN // __attribute((noreturn))
41 // void pdie(const char *msg, ...);
42 void pdie_func(const char *msg, ...);
43 #define pdie(msg, ...) \
44 do { \
45 pdie_func("P-DIE! (%s:%d) " msg "\n", __RELFILE__, __LINE__, ##__VA_ARGS__) \
46 } while (0)
47
48 /* Like die, but appends an error message according to the state of errno. */
49
50 void *vfalloc(size_t size);
51 void *vfcalloc(size_t size, size_t count);
52 void vffree(void *ptr);
53 /* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
54 if malloc fails. */
55
56 void *qalloc(void **root, int size);
57
58 /* Like alloc, but registers the data area in a list described by ROOT. */
59
60 void qfree(void **root);
61
62 /* Deallocates all qalloc'ed data areas described by ROOT. */
63
64 //int min(int a,int b);
65
66 /* Returns the smaller integer value of a and b. */
67
68 char get_key(const char *valid, const char *prompt);
69
70 /* Displays PROMPT and waits for user input. Only characters in VALID are
71 accepted. Terminates the program on EOF. Returns the character. */
72
73 #endif