home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 573b.lha / AMAX_Ram_v1.1 / RamSave.c < prev    next >
C/C++ Source or Header  |  1991-04-23  |  972b  |  48 lines

  1. /* RamSave.c   (c) 1991  Clint Hastings */
  2.  
  3. #include <exec/types.h>
  4. #include <exec/memory.h>
  5. #include <dos.h>
  6. #include <string.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <proto/all.h>
  10.  
  11. BPTR    fh;
  12. char    *amaxbuf;
  13.  
  14. main( argc, argv )
  15. int argc;
  16. char *argv[];
  17. {
  18.     long    amaxbuflen=0x500000, start=0x500000, xferbytes;
  19.     char    **ptr=NULL;
  20.     int        base=0;
  21.  
  22.     if(argc != 4)  {
  23.         printf("Usage: %s startaddr length filename\n", argv[0]);
  24.         exit(10);
  25.     }
  26.  
  27.     amaxbuf = (char *) start;
  28.     start=strtol(argv[1], ptr, base);
  29.     ptr = NULL;
  30.     amaxbuflen=strtol(argv[2], ptr, base);
  31.  
  32.     printf("\nRAM Save  v1.1\n");
  33.     printf(  "~~~~~~~~~~~~~~\n");
  34.  
  35.     /* Try to open the file: */
  36.     fh = Open(argv[3], MODE_NEWFILE);
  37.  
  38.     if (fh)  {    /* file open */
  39.         printf("File open, writing...");
  40.         xferbytes = Write(fh, amaxbuf, amaxbuflen);
  41.         printf("\nFile %s written, ", argv[3]);
  42.         printf("%ld bytes.\n\n", xferbytes);
  43.         Close(fh);
  44.     } else  {
  45.         printf("\nCouldn't open file %s!  Aborting.\n\n", argv[3]);
  46.     }
  47. }
  48.