home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / INSTALL2.TD0 / SOURCES.LIF / MAIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-27  |  4.4 KB  |  192 lines

  1. /*=============================================================================
  2.  
  3.      The INSTALL program source code, object code, sample  script files,
  4.      executable  program,  and  documentation  are  subject to copyright
  5.      protection under the laws of the United States and other countries.
  6.  
  7.      This software is licensed, not sold, and may only be  redistributed
  8.      in  executable format and only in accordance with the provisions of
  9.      the INSTALL Source Code License Agreement.
  10.  
  11.         INSTALL is Copyright(C) 1987-1990 by Knowledge Dynamics Corp
  12.        Highway Contract 4 Box 185-H, Canyon Lake, TX (USA) 78133-3508
  13.               512-964-3994 (Voice)   512-964-3958 (24-hr FAX)
  14.  
  15.                       All rights reserved worldwide.
  16.  
  17. ===============================================================================
  18.  
  19. FILENAME:
  20.     main.c
  21.  
  22. AUTHOR:
  23.     eric jon heflin
  24.  
  25. PUBLIC FUNCTIONS:
  26.     main()   - Master INSTALL function
  27.  
  28. LOCAL FUNCTIONS:
  29.     catcher() - Ctrl-Break handler
  30.  
  31. DESCRIPTION:
  32.     This file contains the master function to control the installation
  33.     process.
  34.  
  35. PORTABILITY:
  36.     compiler specific
  37.  
  38. REVISION HISTORY:
  39.     DATE:    AUTHOR:            DESCRIPTION OF CHANGES:
  40.     891030    allyn jordan    Beginning of detailed documentation.
  41.     900102    ejh                Cosmetic changes.
  42.  
  43. ==============================================================================*/
  44.  
  45. #define MAIN_C
  46.  
  47. #include "install.h"
  48. #include <signal.h>
  49. #include "switches.h"
  50. #include <string.h>
  51. #if defined(__MICROSOFTC__) || defined(__TURBOC__)
  52. #include <dos.h>
  53. #endif
  54.  
  55. static void catcher(int);
  56. void get_mem(void);        /* defined in init.c */
  57.  
  58. static void catcher(sig)
  59. int sig;
  60.     {
  61.     signal(SIGINT, catcher);    /* reestablish this fun as handler */
  62.     wputs(yes_w, "Do you wish to terminate installation (Y/N)?");
  63.     if (put_yes(yes_w))
  64.         bye();
  65.     if (sig == 1)
  66.         sig = 1;        /* quiet lint */
  67.     }
  68.  
  69. #if defined(__TURBOC__)
  70. extern int handler(int, int, int, int);
  71. #elif defined(__MICROSOFTC__)
  72. extern void far handler(unsigned, unsigned, unsigned far *);
  73. #elif !defined(LATTICE)
  74. #error Critical error handler unimplemented for this compiler
  75. #endif
  76. int in = -1;
  77.  
  78. unsigned osmajor, osminor;
  79.  
  80. int main(int c, byte **v)
  81.     {                    /* main */
  82.     project_t project;
  83.     byte location[260];
  84.     
  85.     /* save location of this process */
  86.     strcpy(location, v[0]);
  87.  
  88.     /* hook for a user-defined function */
  89.     usr_1();
  90.  
  91.     /* now, install the compiler-specific critical error handler */
  92.     #if defined(__TURBOC__)
  93.         harderr(handler);
  94.     #elif defined(__MICROSOFTC__) || defined(InstantC)
  95.         _harderr(handler);
  96.     #else
  97.         #error critical error handling has not been implemented for this compiler
  98.     #endif
  99.  
  100.     /* test compile-time requirements */
  101.     validate();
  102.  
  103.     /* clear project structure to zeros */
  104.     memset(&project, 0, sizeof(project_t));
  105.  
  106.     if(c == 2)
  107.         vinit(v[1]);
  108.     else
  109.         vinit(NULL);
  110.  
  111.     /* install our Ctrl-C handler */
  112.     signal(SIGINT, catcher);
  113.  
  114.  
  115.     /* hook for a user-defined function */
  116.     usr_2();
  117.  
  118.     /* initialize vars */
  119.     init(&project);
  120.  
  121.     /* display banner */
  122.     banner();
  123.  
  124.     /* open the script file - use argv[0] if DOS >= 3.00 */
  125.     if (osmajor >= 3)
  126.         in = open_data(&project, location);
  127.     else
  128.         in = open_data(&project, NULL);
  129.  
  130.     /* interpret the script file */
  131.     compile(in, &project);
  132.  
  133.     /* allocate memory for decompression */
  134.     lz_init();
  135.  
  136.     /* allocate memory for file storage */
  137.     get_mem();
  138.  
  139.     /* actually do the installation */
  140.     if (project.terse)
  141.         {
  142.         cls();
  143.         colors(10, 17, "Installing Files - ", WHITE_F | BLUE_B | BRITE);
  144.         colors(10, 36, "Please Wait ...", WHITE_F | BLUE_B | BRITE | FLASH);
  145.         move(2, 1);
  146.         scr_nocur();
  147.         }
  148.     else
  149.         wputs(tty_w, "\nInstalling %s - Please Wait . . .\n", project.name);
  150.  
  151.     /* hook for user-defined function */
  152.     usr_9();
  153.  
  154.     install(&project);
  155.  
  156.     /* hook for user-defined function */
  157.     usr_7();
  158.  
  159.     /* modify CONFIG.SYS and AUTOEXEC.BAT files if needed */
  160.     if (project.autoexec != NULL)
  161.         modify_autoexec(&project);
  162.     if (project.config != NULL)
  163.         modify_config(&project);
  164.  
  165.     /* process the @Finish block (if any) */
  166. #    ifdef ABSORB
  167.     if(osmajor >= 3)
  168.         finish(&project, v[0]);
  169.     else
  170.         finish(&project, NULL);
  171. #    else
  172.     finish(&project, NULL);
  173. #    endif
  174.  
  175.     /* done */
  176.     usr_10();
  177.  
  178.     /*
  179.     putchar(7);
  180.     wputs(message_w, "Installation complete.");
  181.     put_message(message_w);
  182.     */
  183.  
  184.     /* hook for a user-defined function */
  185.     usr_8();
  186.     bye();
  187.     return 0;            /* quiet lint */
  188.     }                    /* main */
  189.  
  190.  
  191. /* end-of-file */
  192.