home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / t / tcu_32.zip / TCU_32.ZIP / TCUINST.C < prev    next >
C/C++ Source or Header  |  1991-03-26  |  24KB  |  640 lines

  1. /*===========================================================================
  2.  *                                                                          *
  3.  *   TCU v3.2 Installation Program                                          *
  4.  *                                                                          *
  5.  *   This program is provided to install the TCU system files into user     *
  6.  *   selected directories.  This source code is supplied as part of the     *
  7.  *   package as a demonstration of a TCU application.  It does not use      *
  8.  *   all of the TCU services & facilities, but adequate use of the major    *
  9.  *   functions is made to provide an example of TCU application coding.     *
  10.  *                                                                          *
  11.  *--------------------------------------------------------------------------*
  12.  *                                                                          *
  13.  *   Written by     : Karl Keyte            Gross-Gerauer Strasse 10        *
  14.  *   Date           : 91.03.20              6108 Weiterstadt                *
  15.  *                                          Germany                         *
  16.  *                                          Tel: +(49) 6150 2499            *
  17.  *                                                                          *
  18.  *==========================================================================*/
  19.  
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <conio.h>
  24. #include <dir.h>
  25. #include <io.h>
  26. #include <usr\tcu.h>
  27.  
  28.  
  29. extern TCU_FORM CONFIG;                        /* Linked-in form object */
  30.  
  31. static unsigned char models[5] = { 1, 0, 0, 1, 0 }; /* Memory models to use */
  32. static int           dirs[5];                  /* Field IDs of the directory */
  33.                                                /* fields in the form */
  34. void main (void)
  35. {
  36.    TCU_WINDOW      screen;
  37.    TCU_NOTICE      notice;
  38.    TCU_FORM        form;
  39.    int             do_cpp,
  40.                    fkey,
  41.                    i, j;
  42.    char            copylib[10],
  43.                    dev[3],
  44.                    dir[65],
  45.                    direct[65],
  46.                    field_name[7],
  47.                   *mmname[] = { "Small", "Compact", "Medium", "Large", "Huge" },
  48.                    tc_include[81],
  49.                    tc_lib[81];
  50.    TCU_FIELD_VALUE val;
  51.  
  52.    int         far button_handler   (TCU_FORM *, int),
  53.                far form_verify      (TCU_FORM *, int, TCU_FIELD_VALUE *),
  54.                far fn_keys          (TCU_FORM *, int, int);
  55.    int             checkout         (void),
  56.                    create_directory (char *),
  57.                    merge_libs       (char *, char *);
  58.  
  59.    void            copy_file        (char *, char *),
  60.                far help             (TCU_FORM *, int);
  61.  
  62. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  63.  
  64. /* Open the whole screen as a window to provide a background */
  65.  
  66.    tcu_open_window (&screen,
  67.                     1, 1,
  68.                     80, 25,
  69.                     "TCU 3.2 Installation",
  70.                     tcu_colour_attrib (RED, LIGHTGRAY),
  71.                     tcu_colour_attrib (WHITE, BLUE),
  72.                     tcu_colour_attrib (BLACK, LIGHTGRAY),
  73.                     TCU_BOX_DOUBLE);
  74.  
  75.  
  76. /* Check that the pre-requisites of the installation are OK */
  77.  
  78.    i = checkout ();           /* 0=OK, 1=Missing Files, 2=TLIB not found */
  79.  
  80.    if (i) {
  81.       tcu_prepare_notice (¬ice, "Installation Error",
  82.                           tcu_colour_attrib (WHITE, LIGHTGRAY),
  83.                           tcu_colour_attrib (RED, LIGHTGRAY),
  84.                           tcu_colour_attrib (WHITE, LIGHTGRAY),
  85.                           TCU_BOX_DOUBLE);
  86.       if (i == 1) {
  87.          tcu_notice_text (¬ice,
  88.                       "Some or all of the files required for installation");
  89.          tcu_notice_text (¬ice,
  90.                       "of TCU 3.2 are not present in the installation");
  91.          tcu_notice_text (¬ice,
  92.                       "directory.  Please re-copy the installation files");
  93.          tcu_notice_text (¬ice,
  94.                       "to the installation directory and try again.");
  95.       } else {
  96.          tcu_notice_text (¬ice,
  97.                       "The Turbo Librarian, TLIB.EXE, is not found in the");
  98.          tcu_notice_text (¬ice,
  99.                       "searchpath.  Please either change the path or copy");
  100.          tcu_notice_text (¬ice,
  101.                       "TLIB.EXE temporarily into the installation directory");
  102.       }
  103.       tcu_notice_text (¬ice, "");
  104.       tcu_notice_text (¬ice, "           -- Press RETURN to continue --");
  105.       tcu_display_notice (¬ice, 15, 8);
  106.       tcu_clear_notice (¬ice);
  107.       tcu_close_window (&screen);
  108.       return;
  109.    }
  110.  
  111.    tcu_position_cursor (&screen, 1, 6);
  112.    tcu_wprintf (&screen,
  113.         "               You are in the installation utility for TCU 3.2.\n");
  114.    tcu_wprintf (&screen,
  115.         "               You will be prompted for options required for\n");
  116.    tcu_wprintf (&screen,
  117.         "               the installation.");
  118.  
  119.  
  120. /* Check that the installation is really wanted */
  121.  
  122.    if (!tcu_get_confirm (24, 10, tcu_colour_attrib (BLUE, BLUE),
  123.                          tcu_colour_attrib (WHITE, BLUE),
  124.                          "Do you wish to continue (Y/N)?")) {
  125.       tcu_close_window (&screen);
  126.       return;
  127.    }
  128.  
  129.    tcu_clear_window (&screen);
  130.    tcu_wprintf (&screen,
  131.             "\n                  Please complete the following information:");
  132.  
  133.  
  134. /* Load the linked-in form into the form object */
  135.  
  136.    tcu_load_image_form (&form, &CONFIG);
  137.  
  138.    tcu_set_form_fnkey_fn (&form, fn_keys);     /* Function key handler */
  139.    tcu_set_field_verify (&form, form_verify);  /* Field verification handler */
  140.    tcu_set_button_fn (&form, button_handler);  /* Button field handler */
  141.    tcu_set_form_help (&form, help);            /* Help function */
  142.  
  143.  
  144. /* Prevent escape keys quitting form entry */
  145.  
  146.    tcu_set_form_mode (&form, TCU_FORM_NOESCS);
  147.  
  148.  
  149. /* Obtain the field IDs for the main installation directories */
  150.  
  151.    for (i=0; i<5; i++) {
  152.       sprintf (field_name, "DIR_%02d", i+1);
  153.       tcu_get_field_id (&form, field_name, &dirs[i]);
  154.    }
  155.  
  156.  
  157. /* Find the current disc */
  158.  
  159.    val.v_string = dir;
  160.    dir[0] = getdisk () + 'A';
  161.  
  162.  
  163. /* Try to locate the file 'tcinst.exe' as a clue to where the main TC root */
  164. /* might be.  If not found, we'll just suggest \TC on the current drive */
  165.  
  166.    if (!searchpath ("tcinst.exe"))
  167.       strcpy (dir+1, ":\\TC\\");
  168.    else {
  169.       strcpy (dir, searchpath ("tcinst.exe"));
  170.       fnsplit (dir, dev, direct, NULL, NULL);
  171.       fnmerge (dir, dev, direct, NULL, NULL);
  172.    }
  173.    tcu_put_field (&form, tcu_get_field_id (&form, "TC_DIR", NULL), &val);
  174.    dir[0] = getdisk () + 'A';
  175.  
  176.  
  177. /* Pre-load the installation directory names */
  178.  
  179.    strcpy (dir+1, ":\\TCU32\\");
  180.    tcu_put_field (&form, dirs[0], &val);
  181.    tcu_put_field (&form, dirs[3], &val);
  182.    tcu_put_field (&form, dirs[4], &val);
  183.    strcpy (dir+1, ":\\TCU32\\LIB\\");
  184.    tcu_put_field (&form, dirs[1], &val);
  185.    strcpy (dir+1, ":\\TCU32\\EXAMPLES\\");
  186.    tcu_put_field (&form, dirs[2], &val);
  187.  
  188.  
  189. /* Show the form and edit.  Only funtion key handler has the ability to */
  190. /* stop the edit as escape keys have been disabled. */
  191.  
  192.    tcu_display_form (&form, 4, 6);
  193.  
  194.    tcu_edit_form (&form, 1, &fkey);
  195.  
  196.  
  197. /* We can remove the form from the screen now that we've finished with it */
  198.  
  199.    tcu_remove_form (&form);
  200.  
  201.  
  202. /* If an abort was requested, shut down... */
  203.  
  204.    if (fkey == TCU_FLD_FNKEYESC) {
  205.       tcu_unload_form (&form);
  206.       tcu_close_window (&screen);
  207.       return;
  208.    }
  209.  
  210.  
  211. /* Move into real installation phase */
  212.  
  213.    tcu_clear_window (&screen);
  214.    tcu_wprintf (&screen, "\n Installing...\n\n");
  215.  
  216.  
  217. /* Form the directory names for the real TC RTL libraries and the user */
  218. /* include files */
  219.  
  220.    val.v_string = tc_lib;
  221.    tcu_get_field (&form, tcu_get_field_id (&form, "TC_DIR", NULL), &val);
  222.    if (strchr (tc_lib, ' '))
  223.       *strchr (tc_lib, ' ') = '\0';
  224.    if (tc_lib[strlen (tc_lib) - 1] != '\\')
  225.       strcat (tc_lib, "\\");
  226.    strcpy (tc_include, tc_lib);
  227.    strcat (tc_include, "include\\usr\\");
  228.    strcat (tc_lib, "lib\\");
  229.  
  230.  
  231. /* Make sure that the directories are there - will create them if they are */
  232. /* not. */
  233.  
  234.    create_directory (tc_include);
  235.    create_directory (tc_lib);
  236.  
  237.  
  238. /* Check whether installing for TC or TC++ */
  239.  
  240.    tcu_get_field (&form, tcu_get_field_id (&form, "TC_CPP", NULL), &val);
  241.    do_cpp = val.v_choice.sel;
  242.  
  243.  
  244. /* Process files destined for each of the 5 main directories, directory by */
  245. /* directory. */
  246.  
  247.    for (i=0; i<5; i++) {
  248.       val.v_string = dir;
  249.       tcu_get_field (&form, dirs[i], &val);    /* Get the directory name */
  250.       if (strchr (dir, ' '))
  251.          *strchr (dir, ' ') = '\0';            /* Strip trailing spaces */
  252.       if (!create_directory (dir)) {           /* If can't create directory */
  253.          tcu_change_colour (&screen, tcu_colour_attrib (LIGHTRED, BLUE));
  254.          tcu_wprintf (&screen, " >>> Error installing into %s\n", dir);
  255.          tcu_change_colour (&screen, tcu_colour_attrib (WHITE, BLUE));
  256.          continue;
  257.       }
  258.       switch (i) { /* Now process files according to the directory */
  259.          case 0:   tcu_wprintf (&screen, "    Installing  - Root System\n");
  260.                    copy_file ("aa-read.me!", dir);
  261.                    copy_file ("readme.1st", dir);
  262.                    copy_file ("tcu.h", tc_include);
  263.                    copy_file ("tcupre32.h", tc_include);
  264.                    break;
  265.          case 1:   tcu_wprintf (&screen, "                - Libraries\n");
  266.                    tcu_change_colour (&screen,
  267.                                       tcu_colour_attrib (LIGHTGREEN, BLUE));
  268.                    for (j=0; j<5; j++)
  269.                       if (models[j]) {
  270.                          tcu_wprintf (&screen, "                     o %s\n",
  271.                                       mmname[j]);
  272.                          sprintf (copylib, "tcu_%c.lib", mmname[j][0]);
  273.                          copy_file (copylib, dir);
  274.                       }
  275.                    if (do_cpp == 1)
  276.                       copy_file ("tcu_cpp.lib", dir);
  277.                    tcu_change_colour (&screen,
  278.                                       tcu_colour_attrib (WHITE, BLUE));
  279.                    break;
  280.          case 2:   tcu_get_field (&form,
  281.                                   tcu_get_field_id (&form, "EXAMPLES", NULL),
  282.                                   &val);
  283.                    if (!val.v_logical)
  284.                       break;
  285.                    tcu_wprintf (&screen, "                - Examples/demos\n");
  286.                    copy_file ("*.c", dir);
  287.                    copy_file ("*.cuf", dir);
  288.                    copy_file ("demo.exe", dir);
  289.                    copy_file ("pulldown.exe", dir);
  290.                    copy_file ("select.exe", dir);
  291.                    copy_file ("button.exe", dir);
  292.                    copy_file ("windows.exe", dir);
  293.                    break;
  294.          case 3:   tcu_wprintf (&screen, "                - Utilities\n");
  295.                    copy_file ("tcuinst.exe", dir);
  296.                    copy_file ("fcomp.exe", dir);
  297.                    copy_file ("fshow.exe", dir);
  298.                    break;
  299.          case 4:   tcu_wprintf (&screen, "                - Documents\n\n");
  300.                    copy_file ("*.doc", dir);
  301.                    break;
  302.          default:  break;
  303.       }
  304.    }
  305.  
  306.  
  307. /* Check whether the TCU libraries are to be merged with the RTLs */
  308.  
  309.    tcu_get_field (&form, tcu_get_field_id (&form, "MERGE", NULL), &val);
  310.    if (val.v_logical) {
  311.       tcu_wprintf (&screen, "    Merging libraries into main libraries\n");
  312.       for (i=0; i<5; i++)
  313.          if (models[i]) {
  314.             sprintf (dir, "%sc%c", tc_lib, mmname[i][0]);
  315.             sprintf (direct, "tcu_%c", mmname[i][0]);
  316.             merge_libs (dir, direct);
  317.             if (do_cpp == 1)
  318.                merge_libs (dir, "tcu_cpp");
  319.          }
  320.       sprintf (dir, "del %s*.bak", tc_lib);
  321.       system (dir);
  322.       tcu_wprintf (&screen,
  323.                    "    You may wish to delete the TCU libraries\n");
  324.       tcu_wprintf (&screen,
  325.                    "    now that they have been merged into the RTLs\n\n");
  326.    }
  327.  
  328.    tcu_wprintf (&screen,
  329.                 "\n\n Installation Complete - Press a key to continue");
  330.  
  331.    while (!kbhit()); getch();
  332.  
  333.  
  334. /* End of installation - remove form from memory and close the window */
  335.  
  336.    tcu_unload_form (&form);
  337.    tcu_close_window (&screen);
  338.  
  339.    printf ("\nGood luck!\n");
  340. }
  341.  
  342.  
  343.  
  344. /* FUNCTION KEY HANDLER */
  345.  
  346. int far fn_keys (TCU_FORM *form, int field, int key)
  347. {
  348.    switch (key) {
  349.       case 9:      tcu_save_environment ();
  350.                    if (tcu_get_confirm (24, 11,
  351.                                         tcu_colour_attrib (WHITE, MAGENTA),
  352.                                         tcu_colour_attrib (WHITE, MAGENTA),
  353.                                         "Do you really want to quit (Y/N)?")) {
  354.                       tcu_restore_environment ();
  355.                       return (2);    /* 2 = Escape request */
  356.                    } else {
  357.                       tcu_restore_environment ();
  358.                       return (0);    /* Ignore... */
  359.                    }
  360.       case 10:     return (1);       /* 1 = Save request */
  361.       default:     tcu_warnbeep();
  362.                    return (0);       /* 0 = Ignore */
  363.    }
  364. #pragma warn -par
  365. }
  366. #pragma warn .par
  367.  
  368.  
  369.  
  370. /* FIELD VERIFICATION FUNCTION */
  371.  
  372. int far form_verify (TCU_FORM *form, int field, TCU_FIELD_VALUE *val)
  373. {
  374.    int               i;
  375.    char              new[27];
  376.    TCU_FIELD_VALUE   new_val;
  377.  
  378.    new_val.v_string = new;
  379.  
  380.    for (i=0; i<5; i++)                         /* Make sure that each of the */
  381.       if (field == dirs[i]) {                  /* 5 main directories are */
  382.          strcpy (new, val->v_string);          /* terminated with a '\' and */
  383.          if (strchr (new, ' '))                /* with no trailing spaces. */
  384.             *strchr (new, ' ') = '\0';
  385.          if (new[strlen (new) - 1] != '\\')
  386.             strcat (new, "\\");
  387.          strupr (new);                            /* Force to upper case */
  388.          tcu_put_field (form, dirs[i], &new_val); /* Write the field back */
  389.          if (i)                                /* If any but the root, then */
  390.             return (1);                        /* finish with verification OK */
  391.          else
  392.             break;
  393.       }
  394.  
  395.    if (i)                 /* If not one of the directories then return OK */
  396.       return (1);
  397.  
  398.    tcu_put_field (form, dirs[3], &new_val); /* Copy root directory to utils */
  399.    tcu_put_field (form, dirs[4], &new_val); /* and documentation directories */
  400.  
  401.    strcat (new, "LIB\\");
  402.    tcu_put_field (form, dirs[1], &new_val); /* Add LIB to root for libraries */
  403.  
  404.    new[strlen (new) - 4] = '\0';
  405.    strcat (new, "EXAMPLES\\");
  406.    tcu_put_field (form, dirs[2], &new_val); /* Add EXAMPLES to root for the */
  407.                                             /* examples */
  408.    return (1);            /* Passed verification! */
  409. }
  410.  
  411.  
  412.  
  413. /* BUTTON FIELD HANDLER */
  414.  
  415. int far button_handler (TCU_FORM *form, int field)
  416. {
  417.    int           choice,
  418.                  mmodels;
  419.    char         *menu_options[] = { "Sāˆš Small" , "C  Compact", "M  Medium",
  420.                                     "Lāˆš Large" , "H  Huge", NULL };
  421.    TCU_MENU      model_menu;
  422.  
  423.  
  424.    tcu_save_environment ();    /* Save the environment because we're going */
  425.                                /* to alter the screen here */
  426.  
  427.    tcu_get_field_id (form, "MMODELS", &mmodels);  /* Get button field ID */
  428.  
  429.    if (field == mmodels) {     /* Should be because it's the only button! */
  430.  
  431.       tcu_define_menu (&model_menu, "Memory Models", /* Create the menu */
  432.                        tcu_colour_attrib (BLUE, LIGHTGRAY),
  433.                        tcu_colour_attrib (BLACK, LIGHTGRAY),
  434.                        tcu_colour_attrib (BLACK, LIGHTGRAY),
  435.                        tcu_colour_attrib (BLACK, GREEN),
  436.                        tcu_colour_attrib (GREEN, BLACK),
  437.                        TCU_ESC_ESC,
  438.                        TCU_BOX_SINGLE,
  439.                        menu_options,
  440.                        tcu_colour_attrib (RED, LIGHTGRAY));
  441.  
  442.  
  443. /* Display the menu on the screen */
  444.  
  445.       tcu_display_menu (&model_menu, 55, 16);
  446.  
  447.  
  448. /* Get selections until ESC is pressed */
  449.  
  450.       while ((choice=tcu_read_menu_selection (&model_menu)) > 0) {
  451.          models[choice-1] ^= 1;                /* Toggle selection */
  452.          if (models[choice-1])                 /* Set the selection marker */
  453.             menu_options[choice-1][1] = 'āˆš';   /* in the option line in the */
  454.          else                                  /* menu. */
  455.             menu_options[choice-1][1] = ' ';
  456.          tcu_set_menu_option (&model_menu, choice-1, 1); /* Force display now */
  457.       }
  458.  
  459.  
  460. /* Clear the menu from the screen */
  461.  
  462.       tcu_remove_menu (&model_menu);
  463.    }
  464.  
  465.    tcu_restore_environment ();                 /* Return the environment */
  466.  
  467.    return (0);
  468. }
  469.  
  470.  
  471.  
  472. /* HELP FUNCTION */
  473.  
  474. void far help (TCU_FORM *form, int field)
  475. {
  476.    TCU_NOTICE         notice;
  477.  
  478.  
  479. /* Get the notice ready */
  480.  
  481.    tcu_prepare_notice (¬ice, "Help!",
  482.                        tcu_colour_attrib (WHITE, MAGENTA),
  483.                        tcu_colour_attrib (WHITE, MAGENTA),
  484.                        tcu_colour_attrib (WHITE, MAGENTA),
  485.                        TCU_BOX_SINGLE);
  486.  
  487.  
  488. /* Write the appropriate text into the notice for the selected field */
  489.  
  490.    if (field == tcu_get_field_id (form, "DIR_01", NULL)) {
  491.       tcu_notice_text (¬ice, "The TCU directory is the root directory for");
  492.       tcu_notice_text (¬ice, "TCU files.  Other subdirectories are normally");
  493.       tcu_notice_text (¬ice, "created under this root directory.");
  494.    } else
  495.  
  496.    if (field == tcu_get_field_id (form, "DIR_02", NULL)) {
  497.       tcu_notice_text (¬ice, "This is where the TCU libraries will be copied.");
  498.       tcu_notice_text (¬ice, "If you select merged libraries then these may be");
  499.       tcu_notice_text (¬ice, "deleted if you wish.");
  500.    } else
  501.  
  502.    if (field == tcu_get_field_id (form, "DIR_03", NULL)) {
  503.       tcu_notice_text (¬ice, "The TCU example programs will be loaded into");
  504.       tcu_notice_text (¬ice, "this directory if you have selected installation");
  505.       tcu_notice_text (¬ice, "of the examples.");
  506.    } else
  507.  
  508.    if (field == tcu_get_field_id (form, "DIR_04", NULL)) {
  509.       tcu_notice_text (¬ice, "The TCU utilities such as the forms compiler and");
  510.       tcu_notice_text (¬ice, "form viewer will be copied into this directory.");
  511.       tcu_notice_text (¬ice, "You may wish to put the utilities in a general");
  512.       tcu_notice_text (¬ice, "executables directory.");
  513.    } else
  514.  
  515.    if (field == tcu_get_field_id (form, "DIR_05", NULL)) {
  516.       tcu_notice_text (¬ice, "The documentation for TCU and the forms compiler");
  517.       tcu_notice_text (¬ice, "will be copied into this directory.");
  518.    } else
  519.  
  520.    if (field == tcu_get_field_id (form, "MERGE", NULL)) {
  521.       tcu_notice_text (¬ice, "If you select merged libraries, the TCU libraries");
  522.       tcu_notice_text (¬ice, "will be merged into the standard C run-time");
  523.       tcu_notice_text (¬ice, "libraries enabling you to link with TCU without");
  524.       tcu_notice_text (¬ice, "specifying additional libraries.");
  525.    } else
  526.  
  527.    if (field == tcu_get_field_id (form, "EXAMPLES", NULL)) {
  528.       tcu_notice_text (¬ice, "If you request the loading of examples, they will");
  529.       tcu_notice_text (¬ice, "be copied into the directory you have specified");
  530.       tcu_notice_text (¬ice, "for examples.");
  531.    } else
  532.  
  533.    if (field == tcu_get_field_id (form, "TC_DIR", NULL)) {
  534.       tcu_notice_text (¬ice, "This is the Root directory of Turbo C / C++. It");
  535.       tcu_notice_text (¬ice, "is normally called TC, TCP or BC.  It is assumed");
  536.       tcu_notice_text (¬ice, "that the Turbo libraries are in a subdirectory");
  537.       tcu_notice_text (¬ice, "called LIB under this directory.");
  538.    } else
  539.  
  540.    if (field == tcu_get_field_id (form, "TC_CPP", NULL)) {
  541.       tcu_notice_text (¬ice, "This identifies whether TCU is used with Turbo");
  542.       tcu_notice_text (¬ice, "C v2.0 or for Turbo/Borland C++.  It is used to");
  543.       tcu_notice_text (¬ice, "merge the special library TCU_CPP when used with");
  544.       tcu_notice_text (¬ice, "Turbo C 2.0");
  545.    } else
  546.  
  547.    if (field == tcu_get_field_id (form, "MMODELS", NULL)) {
  548.       tcu_notice_text (¬ice, "Select this with '=' or the mouse to obtain a");
  549.       tcu_notice_text (¬ice, "menu of memory models.  Only libraries for those");
  550.       tcu_notice_text (¬ice, "selected memory models will be loaded and");
  551.       tcu_notice_text (¬ice, "merged.");
  552.    } else {
  553.  
  554.       tcu_notice_text (¬ice, "Sorry, no help available!");
  555.    }
  556.  
  557.  
  558. /* Finish off notice, display, clear and exit */
  559.  
  560.    tcu_notice_text (¬ice, "");
  561.    tcu_notice_text (¬ice, "          -- Press RETURN to continue --");
  562.    tcu_display_notice (¬ice, 16, 17);
  563.  
  564.    tcu_clear_notice (¬ice);
  565. }
  566.  
  567.  
  568.  
  569. /* Make sure directory exists, creating it if not */
  570.  
  571. int create_directory (char *d)
  572. {
  573.    char             dev[3],
  574.                     dir[65],
  575.                     path[81],
  576.                    *scan;
  577.  
  578.    strcpy (path, d);
  579.  
  580.    fnsplit (path, dev, dir, NULL, NULL);
  581.  
  582.    strcpy (path, dev);
  583.    strcat (path, "\\");
  584.  
  585.    scan = strtok (dir, "\\");
  586.    while (scan) {
  587.       strcat (path, scan);
  588.       if (access (path, 0))
  589.          if (mkdir (path))
  590.             return (0);
  591.       strcat (path, "\\");
  592.       scan = strtok (NULL, "\\");
  593.    }
  594.  
  595.    return (1);
  596. }
  597.  
  598.  
  599.  
  600. /* Copy a file to a specified directory */
  601.  
  602. void copy_file (char *file, char *dir)
  603. {
  604.    char            cmd[81];
  605.  
  606.    sprintf (cmd, "copy %s %s%s/v >nul", file, dir, file);
  607.    system (cmd);
  608. }
  609.  
  610.  
  611.  
  612. /* Check the installation can succeed. */
  613.  
  614. int checkout (void)
  615. {
  616.    char           *flist[] = { "aa-read.me!",  "tcu.doc",      "fcomp.doc",
  617.                                "tcu.h",        "tcupre32.h",   "tcu_cpp.lib",
  618.                                "tcu_s.lib",    "tcu_c.lib",    "tcu_m.lib",
  619.                                "tcu_l.lib",    "tcu_h.lib",    "demo.c",
  620.                                "demo.exe",     "sample.cuf",   "pulldown.c",
  621.                                "pulldown.exe", "pulldown.cuf", "select.c",
  622.                                "select.exe",   "windows.c",    "windows.exe",
  623.                                "fshow.exe",    "fcomp.exe",    "button.c",
  624.                                "button.exe",   "button.cuf",   "tcuinst.c",
  625.                                "mlib.c",       "tcuinst.exe",  "config.cuf",
  626.                                "readme.1st",
  627.  
  628.                                 NULL };
  629.    int             i;
  630.  
  631.    for (i=0; flist[i]; i++)        /* Check that all the files exist in */
  632.       if (access (flist[i], 0))    /* the directory */
  633.          return (1);
  634.  
  635.    if (!searchpath ("tlib.exe"))   /* Check that we can get at TLIB when we */
  636.       return (2);                  /* need it. */
  637.  
  638.    return (0);
  639. }
  640.