ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

common.c
Go to the documentation of this file.
00001 /* common.c  -  Common functions */
00002 
00003 /* Written 1993 by Werner Almesberger */
00004 
00005 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
00006  * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
00007 
00008 
00009 #include "vfatlib.h"
00010 
00011 #define NDEBUG
00012 #include <debug.h>
00013 
00014 
00015 typedef struct _link {
00016     void *data;
00017     struct _link *next;
00018 } LINK;
00019 
00020 
00021 void die(char *msg,...)
00022 {
00023     va_list args;
00024 
00025     va_start(args,msg);
00026     //vfprintf(stderr,msg,args);
00027     DPRINT1("Unrecoverable problem!\n");
00028     va_end(args);
00029     //fprintf(stderr,"\n");
00030     //exit(1);
00031 }
00032 
00033 void pdie(char *msg,...)
00034 {
00035     va_list args;
00036 
00037     va_start(args,msg);
00038     //vfprintf(stderr,msg,args);
00039     DPRINT1("Unrecoverable problem!\n");
00040     va_end(args);
00041     //fprintf(stderr,":%s\n",strerror(errno));
00042     //exit(1);
00043     DbgBreakPoint();
00044 }
00045 
00046 
00047 void *vfalloc(int size)
00048 {
00049     void *ptr;
00050 
00051     ptr = RtlAllocateHeap(RtlGetProcessHeap (),
00052                            0,
00053                            size);
00054 
00055     if (ptr == NULL)
00056     {
00057         DPRINT1("Allocation failed!\n");
00058         return NULL;
00059     }
00060 
00061     return ptr;
00062 }
00063 
00064 void vffree(void *ptr)
00065 {
00066     RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
00067 }
00068 
00069 void *qalloc(void **root,int size)
00070 {
00071     LINK *link;
00072 
00073     link = vfalloc(sizeof(LINK));
00074     link->next = *root;
00075     *root = link;
00076     return link->data = vfalloc(size);
00077 }
00078 
00079 
00080 void qfree(void **root)
00081 {
00082     LINK *this;
00083 
00084     while (*root) {
00085     this = (LINK *) *root;
00086     *root = this->next;
00087     vffree(this->data);
00088     vffree(this);
00089     }
00090 }
00091 
00092 
00093 #ifdef min
00094 #undef min
00095 #endif
00096 int min(int a,int b)
00097 {
00098     return a < b ? a : b;
00099 }
00100 
00101 
00102 char get_key(char *valid,char *prompt)
00103 {
00104 #if 0
00105     int ch,okay;
00106 
00107     while (1) {
00108     if (prompt) VfatPrint("%s ",prompt);
00109     fflush(stdout);
00110     while (ch = getchar(), ch == ' ' || ch == '\t');
00111     if (ch == EOF) exit(1);
00112     if (!strchr(valid,okay = ch)) okay = 0;
00113     while (ch = getchar(), ch != '\n' && ch != EOF);
00114     if (ch == EOF) exit(1);
00115     if (okay) return okay;
00116     VfatPrint("Invalid input.\n");
00117     }
00118 #else
00119     return 0;
00120 #endif
00121 }
00122 
00123 /* Local Variables: */
00124 /* tab-width: 8     */
00125 /* End:             */

Generated on Fri May 25 2012 04:22:49 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.