home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / editors / mntemacs.zoo / utils / dumpemacs.c next >
Encoding:
C/C++ Source or Header  |  1991-12-02  |  2.7 KB  |  113 lines

  1. /*                             -*- Mode: Elec-C -*-
  2.  * dumpemac.c -- Automize dumping of GNU Emacs on the ST
  3.  * 
  4.  * Author          : Frank Ridderbusch T35
  5.  * Created On      : Mon Nov 18 08:58:56 1991
  6.  * Last Modified By: Frank Ridderbusch T35
  7.  * Last Modified On: Tue Nov 19 16:03:36 1991
  8.  * Update Count    : 2
  9.  * Status          : Unknown, Use with caution!
  10.  *
  11.  * COMMENTS
  12.  * 18-Nov-1991        Frank Ridderbusch T35    
  13.  *    The idea for this program is from J.R.Dunning from his port of
  14.  *    GNU Emacs 18.55 to the ST.
  15.  *
  16.  * $Locker$
  17.  * $Log$
  18.  */
  19.  
  20. #include <stdio.h>
  21. #include <unistd.h>
  22. #include <types.h>
  23. #include <stat.h>
  24. #include <time.h>
  25.  
  26.  
  27. #define TEMACS "temacs"
  28. #define XEMACS "xemacs"
  29.  
  30. #define DUMP ".\\" TEMACS " -batch -l loadup.el dump"
  31. #define EMACS ".\\dumpfix -n " XEMACS ".1 " XEMACS ".2 emacs.ttp"
  32.  
  33. extern char *malloc ();
  34.  
  35. main (argc, argv)
  36. int argc;
  37. char **argv;
  38. {
  39.   int min_avail_space;
  40.   char *ptr;
  41.   time_t current_time;
  42.   struct tm *ready;
  43.   struct stat emacs_info;
  44.   struct stat dumpfix_info;
  45.  
  46.   printf ("This is `dumpemac', the coffee break edition\n");
  47.   printf ("\twritten by Frank Ridderbusch\n\n");
  48.  
  49.   /* Check, if we have temacs and dumpfix in the current directory */
  50.   if (stat (TEMACS, &emacs_info)
  51.       || (stat ("dumpfix.ttp", &dumpfix_info)
  52.       && stat ("dumpfix", &dumpfix_info)))
  53.     {
  54.       fprintf (stderr, "Either `" TEMACS "' or `dumpfix.ttp' are missing ");
  55.       fprintf (stderr, "in the current directory\n");
  56.       exit (1);
  57.     }
  58.  
  59.   printf ("The dumping procedure takes about 13 minutes and 30 seconds\n");
  60.   printf ("on a normal ST. So, it's time to have a coffee break. You\n");
  61.   printf ("should be back at around ");
  62.  
  63.   time (¤t_time);
  64.   current_time += 13 * 60 + 30;
  65.   ready = localtime (¤t_time);
  66.   printf ("%d:%02d o'clock.\n\n", ready->tm_hour, ready->tm_min);
  67.   sleep (2);
  68.  
  69.   unlink ("emacs.ttp");
  70.   unlink (XEMACS ".1");
  71.   unlink (XEMACS ".2");
  72.  
  73.   printf ("First dump. Commandline: %s\n", DUMP);
  74.   system (DUMP);
  75.  
  76.   if (!access (XEMACS, 0600))
  77.     {
  78.       fprintf (stderr, "First dump failed!!!\n");
  79.       exit (1);
  80.     }
  81.   if (rename (XEMACS, XEMACS ".1"))
  82.     {
  83.       fprintf (stderr, "Couldn't rename first dump to " XEMACS ".1!!!\n");
  84.       exit (1);
  85.     }
  86.  
  87.   if ((ptr = malloc (1024 * 128L)) == NULL)
  88.     {
  89.       fprintf (stderr, "Malloc failed!!!\n");
  90.       exit (2);
  91.     }
  92.  
  93.   printf ("Second dump. Commandline: %s\n", DUMP);
  94.   system (DUMP);
  95.  
  96.   if (!access (XEMACS, 0600))
  97.     {
  98.       fprintf (stderr, "Second dump failed!!!\n");
  99.       exit (1);
  100.     }
  101.   if (rename (XEMACS, XEMACS ".2"))
  102.     {
  103.       fprintf (stderr, "Couldn't rename second dump to " XEMACS ".2!!!\n");
  104.       exit (1);
  105.     }
  106.  
  107.   free (ptr);
  108.  
  109.   printf ("Actually creating EMACS. Commandline: %s\n", EMACS);
  110.   system (EMACS);
  111.   exit (0);
  112. }
  113.