home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_06 / 8n06138a < prev    next >
Text File  |  1990-05-13  |  1KB  |  43 lines

  1. *****Listing 1*****
  2.  
  3. #include<stdio.h>
  4.  
  5. extern alloc_memory(), open_files(), init_screen(), init_printer(),
  6.        init_vars(), init_commport();
  7.  
  8. char * memblock;
  9. #define BLOCK_SIZE              4096
  10. #define MEM_ALLOCATION_ERROR    2001
  11.  
  12. int (*init_funcs[])() = {
  13.     alloc_memory,       /* Each of these initialization functions */
  14.     open_files,         /* returns a value of 0 if it executed OK. */
  15.     init_screen,        /* If an error occurred ,it returns an error */
  16.     init_printer,       /* code that is unique to itself, such as */
  17.     init_vars,          /* MEM_ALLOCATION_ERROR. The error is */
  18.     init_commport,      /* handled by the routine that called */
  19.     NULL                /* initialize() */
  20.     };
  21.  
  22.     initialize()
  23.     {
  24.         int i,errstat;
  25.         for(i = 0 ; init_funcs[i] != NULL ; ++i){
  26.             if(errstat = (*init_funcs[i])()){
  27.                 return(errstat);
  28.             }
  29.         }
  30.         return(0);
  31.     }
  32.  
  33.     alloc_memory()
  34.     {
  35.         char * malloc();
  36.         if(!(memblock = (char *)malloc(BLOCK_SIZE))){
  37.             return(MEM_ALLOCATION_ERROR);
  38.         }
  39.         return(0);
  40.     }
  41.  
  42. /* The rest of the initialization functions are setup like alloc_memory() */
  43.