ReactOS 0.4.15-dev-7842-g558ab78
common.c File Reference
#include "vfatlib.h"
#include <debug.h>
Include dependency graph for common.c:

Go to the source code of this file.

Classes

struct  _link
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _link LINK
 

Functions

void die (const char *msg,...)
 
void pdie (const char *msg,...)
 
voidalloc (int size)
 
voidqalloc (void **root, int size)
 
void qfree (void **root)
 
int min (int a, int b)
 
char get_key (const char *valid, const char *prompt)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 29 of file common.c.

Typedef Documentation

◆ LINK

typedef struct _link LINK

Function Documentation

◆ alloc()

void * alloc ( int  size)

Definition at line 94 of file common.c.

95{
96 void *this;
97
98 if ((this = malloc(size)))
99 return this;
100 pdie("malloc");
101 return NULL; /* for GCC */
102}
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
void pdie(const char *msg,...)
Definition: common.c:74

◆ die()

void die ( const char msg,
  ... 
)

Definition at line 51 of file common.c.

53{
55
57#ifndef __REACTOS__
59#else
60 DPRINT1("Unrecoverable problem!\n");
61 VfatPrintV((char*)msg, args);
62#endif
63 va_end(args);
64#ifndef __REACTOS__
65 fprintf(stderr, "\n");
66#endif
67 exit(1);
68}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define msg(x)
Definition: auth_time.c:54
#define DPRINT1
Definition: precomp.h:8
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
#define exit(n)
Definition: config.h:202
#define args
Definition: format.c:66
Definition: match.c:390
VOID VfatPrintV(PCHAR Format, va_list args)
Definition: vfatlib.c:342

◆ get_key()

char get_key ( const char valid,
const char prompt 
)

Definition at line 184 of file common.c.

185{
186#ifndef __REACTOS__
187 int ch, okay;
188
189 while (1) {
190 if (prompt)
191 printf("%s ", prompt);
192 fflush(stdout);
193 while (ch = getchar(), ch == ' ' || ch == '\t') ;
194 if (ch == EOF)
195 exit(1);
196 if (!strchr(valid, okay = ch))
197 okay = 0;
198 while (ch = getchar(), ch != '\n' && ch != EOF) ;
199 if (ch == EOF)
200 exit(1);
201 if (okay)
202 return okay;
203 printf("Invalid input.\n");
204 }
205#else
206 return 0;
207#endif
208}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define printf
Definition: freeldr.h:93
BOOLEAN valid
#define stdout
Definition: stdio.h:99
#define EOF
Definition: stdio.h:24
_Check_return_ _CRTIMP int __cdecl getchar(void)
Definition: file.c:3629
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)

Referenced by check_backup_boot(), check_dir(), check_file(), handle_dot(), lfn_add_slot(), lfn_check_orphaned(), lfn_get(), print_fat_dirty_state(), read_fat(), read_fsinfo(), update_free(), and VfatChkdsk().

◆ min()

int min ( int  a,
int  b 
)

Definition at line 179 of file common.c.

180{
181 return a < b ? a : b;
182}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

◆ pdie()

void pdie ( const char msg,
  ... 
)

Definition at line 74 of file common.c.

76{
78
80#ifndef __REACTOS__
82#else
83 DPRINT1("Unrecoverable problem!\n");
84 VfatPrintV((char*)msg, args);
85#endif
86 va_end(args);
87#ifndef __REACTOS__
88 fprintf(stderr, ":%s\n", strerror(errno));
89#endif
90 exit(1);
91}
const char * strerror(int err)
Definition: compat_str.c:23
#define errno
Definition: errno.h:18

Referenced by alloc(), fs_close(), fs_read(), fs_test(), and fs_write().

◆ qalloc()

void * qalloc ( void **  root,
int  size 
)

Definition at line 139 of file common.c.

140{
141 LINK *link;
142
143#ifndef __REACTOS__
144 link = alloc(sizeof(LINK));
145#else
146 link = vfalloc(sizeof(LINK));
147#endif
148 link->next = *root;
149 *root = link;
150#ifndef __REACTOS__
151 return link->data = alloc(size);
152#else
153 return link->data = vfalloc(size);
154#endif
155}
struct _root root
const WCHAR * link
Definition: db.cpp:997
#define alloc
Definition: rosglue.h:13

Referenced by add_file(), and cnv_unicode().

◆ qfree()

void qfree ( void **  root)

Definition at line 157 of file common.c.

158{
159 LINK *this;
160
161 while (*root) {
162 this = (LINK *) * root;
163 *root = this->next;
164#ifndef __REACTOS__
165 free(this->data);
166 free(this);
167#else
168 vffree(this->data);
169 vffree(this);
170#endif
171 }
172}
#define free
Definition: debug_ros.c:5
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by VfatChkdsk().