home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* */
- /* INSTALL.C */
- /* */
- /* */
- /****************************************************************************/
- /*----------------------------- include files ------------------------------*/
- #include <stdio.h>
- #include <alloc.h>
- #include <ctype.h>
- #include <dir.h>
- #include "t.h" /* include the TUI header */
- #include "install.def" /* include dialog definitions */
-
- #define SH_TOP_LEFT 0 /* used by shadow window functions */
- #define SH_TOP_RIGHT 1
- #define SH_BOTTOM_RIGHT 2
- #define SH_BOTTOM_LEFT 3
-
- #define ULTRAWIN 0
- #define INTUITION 1
- #define ENCOM 2
-
- /*--------------------------------- globals --------------------------------*/
- WINDOW *Out_wnp;
-
- TUI Install_tui, *Tuip = &Install_tui;
-
- uchar Src_install[3] = { ON, ON, ON };
- uchar Hdr_install[3] = { ON, ON, ON };
- uchar Lib_install[3] = { ON, ON, ON };
- uchar Help_install[3] = { ON, ON, ON };
- uchar Example_install[3] = { ON, ON, ON };
- int Compilers[3];
- char *Compiler_names[3];
- char Src_paths[3][81];
- char Hdr_paths[3][81];
- char Lib_paths[3][81];
- char Help_paths[3][81];
- char Example_paths[3][81];
- char Others[3][21];
- char Ending_path[81];
- char Src_drive = 'a', Dests[3] = { 'c', 'c', 'c' };
-
- /*------------------- slider/image/palette globals -------------------------*/
- uchar Palette_install[16] =
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F };
-
- /*------------------------------- prototypes -------------------------------*/
- void main( int argc, char *argv[] );
- long disk_free( char drive_letter );
- int install( TUI *tuip, WINDOW *wnp );
- int do_main_dlg( TUI *tuip, int dlg_inx );
- int do_install_dlg( TUI *tuip, int dlg_inx, char *title, int product );
- void shadow_window( WINDOW *wnp, int type, int w, int h, int att );
- void unshadow_window( WINDOW *wnp );
- void change_compiler( TUI *tuip, char *compiler_name );
- void change_dest( TUI *tuip, char dest );
- void make_directory( char *p );
- void install_help( void );
- void whereto_help( void );
- WINDOW *create_message( char *msg );
- void destroy_message( WINDOW *wnp );
- int copy_file( char *src_fname, char *dest_fname );
-
- int register_install_tui( TUI *tuip );
- void register_install_dlg0( TUI *tuip );
- void register_install_dlg1( TUI *tuip );
-
-
- /*********/
- /* ~main */
- /* ********************************************************************/
- /****************************************************************************/
- void main( int argc, char *argv[] )
- {
- WINDOW *desk_wnp;
- int c, i = 0;
- char path[200], *pathp;
-
- if( (argc == 1) && (argv[0][1] == ':') ) /* run from other drive? */
- Src_drive = tolower(argv[0][0]);
- else
- Src_drive = getdisk() + 'a'; /* run from current! */
-
- /* load_tui(Tuip, "INSTALL.TUI"); */
- register_install_tui(Tuip);
-
- init_tui(Tuip);
-
- /*-------------------------- do background screen ------------------------*/
- c = (Tuip->back_att & 0xF0) >> 4; /* get background color */
- desk_wnp = Tuip->back_wnp; /* get desktop window ptr */
- desk_wnp->scroll = OFF; /* turn off desktop scroll */
- while (i++ < 45)
- { /* to show off the shadow */
- wn_color(DARKGRAY, c, desk_wnp);
- wn_st("UltraWin 2.60 ", desk_wnp);
- wn_color(WHITE, c, desk_wnp);
- wn_st("InTUItion 1.60 ", desk_wnp);
- wn_color(BLACK, c, desk_wnp);
- wn_st("EnCom 1.60 ", desk_wnp);
- }
- wn_color(WHITE, BLACK, desk_wnp);
- mv_cs(0, 24, desk_wnp);
- wn_cleol(desk_wnp);
- wn_plst(CENTERED, 24, "Welcome to EnQue Software's Install Utility", desk_wnp);
-
- /*--------------------- try to figure out their compiler! ---------------*/
- if ( (pathp = getenv("PATH")) != NULL )
- {
- strcpy(path, pathp), strupr(path);
- for (i=ULTRAWIN; i<=ENCOM; i++)
- {
- if ( strstr(path, "WATCOM") )
- Compilers[i] = WATCOM, Compiler_names[i] = "watcom";
- else
- if ( strstr(path, "BORLANDC") )
- Compilers[i] = BORLAND, Compiler_names[i] = "borlandc";
- else
- if ( strstr(path, "TURBOC") )
- Compilers[i] = TURBO, Compiler_names[i] = "turboc";
- else
- if ( strstr(path, "MSVC") )
- Compilers[i] = MICROSOFT, Compiler_names[i] = "msvc";
- else
- if ( strstr(path, "ZORTECH") )
- Compilers[i] = ZORTECH, Compiler_names[i] = "zortech";
- else
- if ( strstr(path, "POWERC") || strstr(path, "MIX") )
- Compilers[i] = MIX, Compiler_names[i] = "powerc";
- else
- Compilers[i] = BORLAND, Compiler_names[i] = "borlandc";
- }
- } else
- for (i=ULTRAWIN; i<=ENCOM; i++)
- Compilers[i] = BORLAND, Compiler_names[i] = "borlandc";
-
- /*--------------------- make some default paths --------------------------*/
- for (i=ULTRAWIN; i<=ENCOM; i++)
- {
- switch(i)
- {
- case ULTRAWIN:
- sprintf(Ending_path, "%c:\\%s", Dests[i], Compiler_names[i]);
- sprintf(Src_paths[i], "%c:\\%s\\uw260", Dests[i], Compiler_names[i]);
- break;
- case INTUITION:
- sprintf(Src_paths[i], "%c:\\%s\\tui160", Dests[i], Compiler_names[i]);
- break;
- case ENCOM:
- sprintf(Src_paths[i], "%c:\\%s\\encom160", Dests[i], Compiler_names[i]);
- break;
- }
- sprintf(Hdr_paths[i], "%c:\\%s\\include", Dests[i], Compiler_names[i]);
- sprintf(Lib_paths[i], "%c:\\%s\\lib", Dests[i], Compiler_names[i]);
- sprintf(Help_paths[i], "%c:\\%s\\enqhelp", Dests[i], Compiler_names[i]);
- sprintf(Example_paths[i],"%s\\examples", Src_paths[i]);
- }
-
- /*------------------------------- do install -----------------------------*/
- do_main_dlg(Tuip, MAIN_DLG);
-
- end_tui(Tuip);
- free_tui(Tuip);
- exit(0);
- }
- /*** end of main ***/
-
- /**************/
- /* ~disk_free */
- /* ***************************************************************/
- /* returns free space on given drive... */
- /****************************************************************************/
- long disk_free( char drive_letter )
- {
- struct dfree df;
- int drive;
- long avail = 0L;
-
- drive = toupper(drive_letter) - 'A' + 1;
- getdfree(drive, &df);
- if (df.df_sclus != 0xFFFF)
- avail = (long) df.df_avail * (long) df.df_bsec * (long) df.df_sclus;
- return(avail);
- }
- /*** end of disk_free ***/
-
- /************/
- /* ~install */
- /* *****************************************************************/
- /****************************************************************************/
- int install( TUI *tuip, WINDOW *wnp )
- {
- WINDOW *msg_wnp;
- char buffer[133], zip_src[41], zip_exe[41], *mem, *src_mem, *dest_mem,
- *src_path, *src, *dest;
- int i, num_zips = 0, show_len = 45, stat = 1;
-
- /*------------------- get memory for source/dest files -------------------*/
- if ( (mem = calloc(100, 81)) == NULL )
- return(0);
- src_mem = &mem[0];
- dest_mem = &mem[81 * 50];
-
- /*------------------------- use the regular dialog -----------------------*/
- m_hide();
- wn_clear(wnp);
- wn_color(WHITE, BLUE, wnp);
- wn_plst(CENTERED, 3, "Creating directories, one moment please...", wnp);
- m_show();
-
- /*------------------------ copy unzip.exe to root ------------------------*/
- sprintf(zip_src, "%c:\\UNZIP.EXE", Src_drive);
- sprintf(zip_exe, "%c:\\UNZIP.EXE", Dests[0]);
-
- for (i=ULTRAWIN; i<=ENCOM; i++)
- if ( is_selected(tuip, MAIN_ULTRAWIN + i) )
- {
- switch(i)
- {
- case ULTRAWIN: src_path = "uw260"; break;
- case INTUITION: src_path = "tui160"; break;
- case ENCOM: src_path = "encom160"; break;
- }
- /*---------------------- the ENQHELP.EXE engine ------------------------*/
- sprintf(buffer, "%c:\\enqhelp.zip", Src_drive);
- if ( file_exists(buffer) )
- {
- make_directory(Src_paths[i]);
- sprintf( &src_mem[num_zips * 81], buffer);
- strcpy( &dest_mem[num_zips * 81], Src_paths[i]);
- num_zips++;
- }
- /*---------------------- the ENQRBLD.EXE program -----------------------*/
- sprintf(buffer, "%c:\\enqrbld.zip", Src_drive);
- if ( file_exists(buffer) )
- {
- make_directory(Src_paths[i]);
- sprintf( &src_mem[num_zips * 81], buffer);
- strcpy( &dest_mem[num_zips * 81], Src_paths[i]);
- num_zips++;
- }
- /*--------------------------- source code ------------------------------*/
- if( Src_install[i] )
- {
- sprintf(buffer, "%c:\\%s\\source.zip", Src_drive, src_path);
- if ( file_exists(buffer) )
- {
- make_directory(Src_paths[i]);
- sprintf( &src_mem[num_zips * 81], buffer);
- strcpy( &dest_mem[num_zips * 81], Src_paths[i]);
- num_zips++;
- }
- }
- /*--------------------------- header files -----------------------------*/
- if( Hdr_install[i] )
- {
- sprintf(buffer, "%c:\\%s\\hdr.zip", Src_drive, src_path);
- if ( file_exists(buffer) )
- {
- make_directory(Hdr_paths[i]);
- sprintf( &src_mem[num_zips * 81], buffer);
- strcpy( &dest_mem[num_zips * 81], Hdr_paths[i]);
- num_zips++;
- }
- }
- /*----------------------------- lib files ------------------------------*/
- if( Lib_install[i] )
- {
- sprintf(buffer, "%c:\\%s\\lib.zip", Src_drive, src_path);
- if ( file_exists(buffer) )
- {
- make_directory(Lib_paths[i]);
- sprintf( &src_mem[num_zips * 81], buffer);
- strcpy( &dest_mem[num_zips * 81], Lib_paths[i]);
- num_zips++;
- }
- }
- /*---------------------------- help files ------------------------------*/
- if( Help_install[i] )
- {
- sprintf(buffer, "%c:\\%s\\help.zip", Src_drive, src_path);
- if ( file_exists(buffer) )
- {
- make_directory(Help_paths[i]);
- sprintf( &src_mem[num_zips * 81], buffer);
- strcpy( &dest_mem[num_zips * 81], Help_paths[i]);
- num_zips++;
- }
- }
- /*---------------------------- example files ---------------------------*/
- if( Example_install[i] )
- {
- sprintf(buffer, "%c:\\%s\\examples.zip", Src_drive, src_path);
- if ( file_exists(buffer) )
- {
- make_directory(Example_paths[i]);
- sprintf( &src_mem[num_zips * 81], buffer);
- strcpy( &dest_mem[num_zips * 81], Example_paths[i]);
- num_zips++;
- }
- }
- }
-
- copy_file(zip_src, zip_exe);
-
- /*--------------------------- show the src/dest --------------------------*/
- m_hide();
- wn_clear(wnp);
- wn_color(WHITE, BLUE, wnp);
- wn_plst(2, 1, "Source", wnp);
- wn_plst(2, 3, "Destination", wnp);
- wn_color(YELLOW, BLUE, wnp);
- mv_cs(2, 6, wnp);
- wn_qch(show_len, '▒', wnp);
- m_show();
-
- /*----------------------- do the actual install --------------------------*/
- for (i=0; i<num_zips; i++)
- {
- src = &src_mem[i * 81], strupr(src);
- dest = &dest_mem[i * 81], strupr(dest);
- m_hide();
- wn_color(YELLOW, BLUE, wnp);
- mv_cs(47, 6, wnp);
- wn_printf(wnp, " (%d of %d)", i + 1, num_zips);
- wn_plst(4, 2, src, wnp), wn_cleol(wnp);
- wn_plst(4, 4, dest, wnp), wn_cleol(wnp);
- mv_cs(2, 6, wnp);
- wn_qch(((i + 1) * show_len) / num_zips , '█', wnp);
- m_show();
-
- /*------------------------ check for free space ------------------------*/
- if ( disk_free(dest[0]) < 1500000L )
- {
- msg_wnp = create_message("Disk storage is low, please free some space!");
- wait_event();
- destroy_message(msg_wnp);
- stat = 0;
- break;
- }
- /*-------------------------- now do the unzip --------------------------*/
- setdisk(dest[0] - 'A');
- chdir(dest);
- sprintf(buffer, "%s -o -qq %s", zip_exe, src);
- system(buffer);
- }
- unlink(zip_exe);
- setdisk(Ending_path[0] - 'A');
- chdir(Ending_path);
- free(mem);
- return(stat);
- }
- /*** end of install ***/
-
- /****************/
- /* ~do_main_dlg */
- /* *************************************************************/
- /****************************************************************************/
- int do_main_dlg( TUI *tuip, int dlg_inx )
- {
- WINDOW *msg_wnp;
- int ret_inx, end_flag = OFF, stat = 0;
-
- center_dialog(tuip,dlg_inx);
- draw_dialog(tuip, dlg_inx);
- shadow_window( get_dlg_wnp(tuip, dlg_inx), SH_BOTTOM_RIGHT, 2, 1, DARKGRAY);
- while (!end_flag)
- {
- ret_inx = do_dialog(tuip, dlg_inx, DO_RETURN_EVENT);
- switch( ret_inx )
- {
- case EVENT_RETURNED:
- if ( !Event.is_mouse )
- if ( Event.key == KEY_ESC )
- end_flag = 1;
- break;
-
- case MAIN_ULTRAWIN:
- if ( is_selected(tuip, ret_inx) )
- if ( !do_install_dlg(tuip, INSTALL_DLG, "UltraWin 2.60 Installation", ULTRAWIN) )
- deselect(tuip, ret_inx), draw_item(tuip, ret_inx);
- break;
-
- case MAIN_INTUITION:
- if ( is_selected(tuip, ret_inx) )
- if ( !do_install_dlg(tuip, INSTALL_DLG, "InTUItion 1.60 Installation", INTUITION) )
- deselect(tuip, ret_inx), draw_item(tuip, ret_inx);
-
- break;
- case MAIN_ENCOM:
- if ( is_selected(tuip, ret_inx) )
- if ( !do_install_dlg(tuip, INSTALL_DLG, "EnCom 1.60 Installation", ENCOM) )
- deselect(tuip, ret_inx), draw_item(tuip, ret_inx);
- break;
-
- case MAIN_INSTALL:
- if ( !(is_selected(tuip, MAIN_ULTRAWIN) ||
- is_selected(tuip, MAIN_INTUITION) ||
- is_selected(tuip, MAIN_ENCOM)) )
- {
- msg_wnp = create_message("Please select at least one product!");
- wait_event();
- destroy_message(msg_wnp);
- deselect(tuip, MAIN_INSTALL);
- draw_item(tuip, MAIN_INSTALL);
- } else
- {
- if ( install(tuip, get_dlg_wnp(tuip, dlg_inx)) )
- stat = 1;
- end_flag = 1;
- }
- break;
-
- case MAIN_CANCEL:
- end_flag = 1;
- break;
- }
- }
- unshadow_window(get_dlg_wnp(tuip, dlg_inx));
- erase_dialog(tuip, dlg_inx);
- if ( stat )
- whereto_help();
- return(1);
- }
- /*** end of do_main_dlg ***/
-
- /*******************/
- /* ~do_install_dlg */
- /* **********************************************************/
- /****************************************************************************/
- int do_install_dlg( TUI *tuip, int dlg_inx, char *title, int product )
- {
- int ret_value, end_flag = OFF, i, compiler, stat = 0;
- char *compiler_name, dest;
-
- set_btn_text(tuip, PARM_TITLE, title);
- /*--------------------------- set the dest disk --------------------------*/
- for (i=DEST_C; i<=DEST_F; i++)
- deselect(tuip, i);
- switch(Dests[product])
- {
- case 'C': case 'c': select(tuip, DEST_C); break;
- case 'D': case 'd': select(tuip, DEST_D); break;
- case 'E': case 'e': select(tuip, DEST_E); break;
- case 'F': case 'f': select(tuip, DEST_F); break;
- }
- dest = Dests[product];
-
- /*-------------------------- set the source button -----------------------*/
- for (i=WATCOM; i<=MIX; i++)
- deselect(tuip, i);
- if ( Compilers[product] == OTHER )
- strcpy(get_inp_text(tuip, OTHER), Others[product]);
- else
- {
- strcpy(get_inp_text(tuip, OTHER), "");
- select(tuip, Compilers[product]);
- }
- compiler = Compilers[product];
- compiler_name = Compiler_names[product];
-
- /*-------------------------- copy the new paths --------------------------*/
- strcpy(get_inp_text(tuip, SRC_PATH), Src_paths[product]);
- strcpy(get_inp_text(tuip, HDR_PATH), Hdr_paths[product]);
- strcpy(get_inp_text(tuip, LIB_PATH), Lib_paths[product]);
- strcpy(get_inp_text(tuip, HELP_PATH), Help_paths[product]);
- strcpy(get_inp_text(tuip, EXAMPLE_PATH),Example_paths[product]);
-
- /*----------------------- set the install selections ---------------------*/
- if ( Src_install[product] )
- select(tuip, SRC_INSTALL);
- else
- deselect(tuip, SRC_INSTALL);
- if ( Hdr_install[product] )
- select(tuip, HDR_INSTALL);
- else
- deselect(tuip, HDR_INSTALL);
- if ( Lib_install[product] )
- select(tuip, LIB_INSTALL);
- else
- deselect(tuip, LIB_INSTALL);
- if ( Help_install[product] )
- select(tuip, HELP_INSTALL);
- else
- deselect(tuip, HELP_INSTALL);
- if ( Example_install[product] )
- select(tuip, EXAMPLE_INSTALL);
- else
- deselect(tuip, EXAMPLE_INSTALL);
-
- draw_dialog(tuip, dlg_inx);
- shadow_window( get_dlg_wnp(tuip, dlg_inx), SH_BOTTOM_RIGHT, 2, 1, DARKGRAY);
- while (!end_flag)
- {
- ret_value = do_dialog(tuip, dlg_inx, DO_RETURN_EVENT);
- if( (Event.m_button == RB) ||
- ((Event.key == KEY_ALT_H) && (ret_value == EVENT_RETURNED)) )
- install_help();
- else switch( ret_value )
- {
- /*---------------- ESC pressed or clicked off dialog -----------------*/
- case NO_SELECTION:
- end_flag = ON;
- break;
-
- case INSTALL_HELP:
- deselect(tuip, ret_value);
- detab(tuip, ret_value);
- draw_item(tuip, ret_value);
- install_help();
- break;
-
- case INSTALL_CANCEL:
- deselect(tuip, ret_value);
- detab(tuip, ret_value);
- draw_item(tuip, ret_value);
- end_flag = 2;
- break;
-
- case INSTALL_OK:
- deselect(tuip, ret_value);
- detab(tuip, ret_value);
- Src_install[product] = is_selected(Tuip, SRC_INSTALL);
- Hdr_install[product] = is_selected(Tuip, HDR_INSTALL);
- Lib_install[product] = is_selected(Tuip, LIB_INSTALL);
- Help_install[product] = is_selected(Tuip, HELP_INSTALL);
- Example_install[product]= is_selected(Tuip, EXAMPLE_INSTALL);
- Compilers[product] = compiler;
- Compiler_names[product] = compiler_name;
- strcpy(Others[product], get_inp_text(Tuip, OTHER));
- strcpy(Src_paths[product], get_inp_text(tuip, SRC_PATH));
- strcpy(Hdr_paths[product], get_inp_text(tuip, HDR_PATH));
- strcpy(Lib_paths[product], get_inp_text(tuip, LIB_PATH));
- strcpy(Help_paths[product], get_inp_text(tuip, HELP_PATH));
- strcpy(Example_paths[product],get_inp_text(tuip, EXAMPLE_PATH));
- sprintf(Ending_path, "%c:\\%s", Dests[0], Compiler_names[0]);
- Dests[product] = dest;
- end_flag = stat = ON;
- break;
-
- case WATCOM:
- strcpy(get_inp_text(Tuip, OTHER), "");
- draw_item(tuip, OTHER);
- compiler = WATCOM;
- compiler_name = "watcom";
- change_compiler(tuip, compiler_name);
- break;
- case BORLAND:
- strcpy(get_inp_text(Tuip, OTHER), "");
- draw_item(tuip, OTHER);
- compiler = BORLAND;
- compiler_name = "borlandc";
- change_compiler(tuip, compiler_name);
- break;
- case TURBO:
- strcpy(get_inp_text(Tuip, OTHER), "");
- draw_item(tuip, OTHER);
- compiler = TURBO;
- compiler_name = "turboc";
- change_compiler(tuip, compiler_name);
- break;
- case MICROSOFT:
- strcpy(get_inp_text(Tuip, OTHER), "");
- draw_item(tuip, OTHER);
- compiler = MICROSOFT;
- compiler_name = "msvc";
- change_compiler(tuip, compiler_name);
- break;
- case ZORTECH:
- strcpy(get_inp_text(Tuip, OTHER), "");
- draw_item(tuip, OTHER);
- compiler = ZORTECH;
- compiler_name = "zortech";
- change_compiler(tuip, compiler_name);
- break;
- case MIX:
- strcpy(get_inp_text(Tuip, OTHER), "");
- draw_item(tuip, OTHER);
- compiler = MIX;
- compiler_name = "powerc";
- change_compiler(tuip, compiler_name);
- break;
-
- case OTHER:
- for (i=WATCOM; i<=MIX; i++)
- deselect(tuip, i), draw_item(tuip, i);
- compiler = OTHER;
- compiler_name = get_inp_text(Tuip,OTHER);
- change_compiler(tuip, compiler_name);
- break;
-
- case DEST_C: dest = 'c'; change_dest(tuip, dest); break;
- case DEST_D: dest = 'd'; change_dest(tuip, dest); break;
- case DEST_E: dest = 'e'; change_dest(tuip, dest); break;
- case DEST_F: dest = 'f'; change_dest(tuip, dest); break;
- }
- }
- unshadow_window(get_dlg_wnp(tuip, dlg_inx));
- erase_dialog(tuip, dlg_inx);
- return(stat);
- }
- /*** end of do_install_dlg ***/
-
- /****************/
- /* ~change_dest */
- /* *************************************************************/
- /****************************************************************************/
- void change_dest( TUI *tuip, char dest )
- {
- int i;
- char *p;
-
- for( i=SRC_PATH; i<=EXAMPLE_PATH; i++ )
- {
- p = get_inp_text(Tuip, i);
- *p = dest;
- draw_item( tuip, i);
- }
- }
- /*** end of change_dest ***/
-
- /********************/
- /* ~change_compiler */
- /* *********************************************************/
- /****************************************************************************/
- void change_compiler( TUI *tuip, char *compiler_name )
- {
- int i;
- char buff[133], *p, *p1;
-
- for( i=SRC_PATH; i<=EXAMPLE_PATH; i++ )
- {
- setmem(buff, 132, 0);
- p = get_inp_text(Tuip, i);
-
- if( p[1] == ':' && p[2] == '\\' )
- strncpy( buff, p, 3 );
- else if( p[1] == ':' )
- strncpy( buff, p, 2 );
- strcat( buff, compiler_name );
-
- if( strchr(p,'\\') != NULL )
- strcat( buff, strchr(strchr(p,'\\') + 1, '\\') );
-
- strcpy( p, buff );
- draw_item( tuip, i);
- }
- }
- /*** end of change_compiler ***/
-
- /*******************/
- /* ~make_directory */
- /* **********************************************************/
- /****************************************************************************/
- void make_directory( char *p )
- {
- int i;
- char tmp[81], tmp1[81];
-
- i = 0;
- tmp[i++] = *p++;
- tmp[i++] = *p++;
- tmp[i++] = *p++;
- while( *p )
- {
- while( *p && (*p != '\\') )
- tmp[i++] = *p++;
- tmp[i] = '\0';
- mkdir(tmp);
- if( *p == '\\' )
- tmp[i++] = *p++;
- }
- }
- /*** end of make_directory ***/
-
- /*****************/
- /* ~install_help */
- /* ************************************************************/
- /****************************************************************************/
- char *Helps[] = {
- "Setting install check boxes",
- " There is a check box next to each path. Click on the check box or",
- " press the indicated key to turn the check box on/off. Only those",
- " boxes with an X will be installed.",
- "",
- "Setting up directory paths",
- " There are five directory paths that need to be created. Default paths",
- " are created if you select none. You can change each path individually",
- " by clicking on the path string or pressing 1-5. If you elect to use",
- " the standard directories, borlandc, tc, etc., simply click or select",
- " the desired compiler.",
- "",
- "Setting the destination drive",
- " Clicking or selecting (ALT C-E) a destination drive will automatically",
- " change the paths for you. You can also change them individually."
- };
- void install_help( void )
- {
- int i;
- WINDOW wn;
-
- m_hide();
- wn_create( 1, 2, V_cols-4, V_rows-4, SGL_BDR, WN_POPUP, &wn );
- wn_color( LIGHTGRAY, RED, &wn );
- wn_name("Help", &wn);
- wn_set(&wn);
- for( i = 0; i < 15; i++ )
- {
- if ( !strncmp(Helps[i], "Set", 3) )
- wn_color(WHITE, RED, &wn);
- else
- wn_color(LIGHTGRAY, RED, &wn );
- wn_plst( 1, i + 1, Helps[i], &wn );
- }
- m_show();
- wait_event();
- m_hide();
- wn_destroy(&wn);
- m_show();
- }
- /*** end of install_help ***/
-
- /*****************/
- /* ~whereto_help */
- /* ************************************************************/
- /****************************************************************************/
- char *Whelps[] = {
- "",
- " It is recommended that you first read the help files for the products",
- "that you have installed. First, set the environment variable as follows,",
- "\"SET ENQHELP=C:\\BORLANDC\\ENQHELP\" or whatever path you chose for the",
- "help files, then run the help as follows: (it is recommended that you put",
- "the set command in your AUTOEXEC.BAT file)",
- " for EnCom \"enqhelp encom.hlp\"",
- " for UltraWin \"enqhelp uw_help0.hlp\"",
- " for InTUItion \"enqhelp tui0.hlp\"",
- "",
- "ENCOM: If you installed EnCom, go into the EnCom directory and run the",
- " EnCom demo, \"COM_DEMO\". You can also run \"TD\", the terminal demo",
- " which can be used to dial the EnQue BBS.",
- "",
- "ULTRAWIN: If you installed UltraWin, go into the UltraWin directory and",
- " run the demo, \"UW_DEMO\".",
- "",
- "INTUITION: If you installed InTUItion, be sure that UltraWin in also",
- " installed, then go into the directory and run the tutorials as follows,",
- " \"TUICP -PBUTTON.TUT\". There are four tutorials; BUTTON.TUT, ENTRY.TUT,",
- " HELP.TUT, and MENU.TUT.",
- " And of course you are running an InTUItion demo right now!"
- };
- void whereto_help( void )
- {
- int i, end_flag = OFF;
- WINDOW wn;
-
- m_hide();
- wn_create( 0, 0, V_cols-1, V_rows-1, SGL_BDR, WN_POPUP, &wn );
- wn_color(WHITE, RED, &wn );
- wn_name("[Where To Go From Here]", &wn);
- wn_set(&wn);
- for( i = 0; i < 22; i++ )
- wn_plst( 0, i, Whelps[i], &wn );
- while (!end_flag)
- {
- wait_event();
- if ( !Event.is_mouse && (Event.key == KEY_ESC) )
- end_flag = ON;
- }
- wn_destroy(&wn);
- m_show();
- }
- /*** end of whereto_help ***/
-
- /******************/
- /* ~shadow_window */
- /* ***********************************************************/
- /* This routine takes the window passed by pointer and shadows it. It does */
- /* this by creating sub windows using the usr_ptr member of the window */
- /* structure. */
- /* */
- /* The contents under these sub windows are read off the screen and put */
- /* inside the windows. The attribute is then changed and the window is */
- /* placed on the screen, giving the illusion of a shadow. */
- /* */
- /* You may pass this routine a width, height and attribute (DARKGRAY on */
- /* BLACK with a width of 2 and height of 1 usually looks nice). */
- /* You may also pass a type, which is a number from 0-3 (see #defines) that */
- /* indicates the direction the shadow falls. */
- /* */
- /* The main thing to remember is be SURE that you call the unshadow_window */
- /* function BEFORE you destroy the window, or else you will have heap */
- /* problems. */
- /****************************************************************************/
- void shadow_window( WINDOW *wnp, int type, int w, int h, int att )
- {
- WINDOW *wnp1, *wnp2; /* shadow window pointers */
- int x1 = wnp->pane.x_min; /* get the screen coords */
- int y1 = wnp->pane.y_min;
- int x2 = wnp->pane.x_max;
- int y2 = wnp->pane.y_max;
- int win1_x1, win1_y1, win1_x2, win1_y2;
- int win2_x1, win2_y1, win2_x2, win2_y2;
- int i;
- uchar *dest;
-
- if (wnp->usr_ptr == NULL)
- {
- switch(type)
- {
- case SH_TOP_LEFT:
- win1_x1 = x1 - w, win1_y1 = y1 - h; /* left side of window */
- win1_x2 = x1 - 1, win1_y2 = y2 - h;
- win2_x1 = x1 , win2_y1 = y1 - h; /* top side of window */
- win2_x2 = x2 - w, win2_y2 = y1 - 1;
- break;
- case SH_TOP_RIGHT:
- win1_x1 = x2 + 1, win1_y1 = y1 - h; /* right side of window */
- win1_x2 = x2 + w, win1_y2 = y2 - h;
- win2_x1 = x1 + w, win2_y1 = y1 - h; /* top side of window */
- win2_x2 = x2 , win2_y2 = y1 - 1;
- break;
- case SH_BOTTOM_LEFT:
- win1_x1 = x1 - w, win1_y1 = y1 + h; /* left side of window */
- win1_x2 = x1 - 1, win1_y2 = y2 + h;
- win2_x1 = x1 , win2_y1 = y2 + 1; /* bottom side of window */
- win2_x2 = x2 - w, win2_y2 = y2 + h;
- break;
- default:
- win1_x1 = x2 + 1, win1_y1 = y1 + h; /* right side of window */
- win1_x2 = x2 + w, win1_y2 = y2 + h;
- win2_x1 = x1 + w, win2_y1 = y2 + 1; /* bottom side of window */
- win2_x2 = x2 , win2_y2 = y2 + h;
- break;
- }
- wnp->usr_ptr = calloc(1, sizeof(WINDOW)); /* alloc/create first win */
- wn_create(win1_x1, win1_y1, win1_x2, win1_y2,
- NO_BDR, WN_POPUP,
- (WINDOW *) wnp->usr_ptr);
- wnp1 = (WINDOW *) wnp->usr_ptr;
- wn_read(wnp1);
- dest = wnp1->buff + 1; /* set to DARKGRAY on BLACK */
- for (i=0; i<(wnp1->cols * wnp1->rows); i++)
- *dest = att, dest += 2;
-
- wnp1->usr_ptr = calloc(1, sizeof(WINDOW)); /* alloc/create second win */
- wn_create(win2_x1, win2_y1, win2_x2, win2_y2,
- NO_BDR, WN_POPUP,
- (WINDOW *) wnp1->usr_ptr);
- wnp2 = (WINDOW *) wnp1->usr_ptr;
- wn_read(wnp2);
- dest = wnp2->buff + 1; /* set to DARKGRAY on BLACK */
- for (i=0; i<(wnp2->cols * wnp2->rows); i++)
- *dest = att, dest += 2;
-
- wn_save(wnp1), wn_rfsh(wnp1); /* do the wn_set equivalent */
- wn_save(wnp2), wn_rfsh(wnp2);
- }
- }
- /*** end of shadow_window ***/
-
- /********************/
- /* ~unshadow_window */
- /* *********************************************************/
- /* This is the complement to shadow_window. You MUST call this function */
- /* before you destroy the window that has been shadowed or you will have */
- /* severe problems. If you don't it will have the same effect as not */
- /* calling wn_destroy on a created window. Your computer will lockup! */
- /****************************************************************************/
- void unshadow_window( WINDOW *wnp )
- {
- WINDOW *wnp1, *wnp2; /* shadow window pointers */
-
- if (wnp->usr_ptr) /* does it have a shadow? */
- {
- wnp1 = (WINDOW *) wnp->usr_ptr; /* get the window pointers */
- wnp2 = (WINDOW *) wnp1->usr_ptr;
- wn_destroy(wnp2), wn_destroy(wnp1);
- free(wnp2), free(wnp1); /* and free the structure */
- wnp->usr_ptr = NULL;
- }
- }
- /*** end of unshadow_window ***/
-
- /*******************/
- /* ~create_message */
- /* **********************************************************/
- /****************************************************************************/
- WINDOW *create_message( char *msg )
- {
- WINDOW *wnp = calloc(1, sizeof(WINDOW));
- int len = strlen(msg), x1 = 38 - (len / 2), x2 = x1 + len + 3;
-
- m_hide();
- wn_create(x1, 11, x2, 13, SGL_BDR, WN_POPUP, wnp);
- wn_color(WHITE, RED, wnp);
- wn_bdr_color(YELLOW, RED, wnp);
- wn_set(wnp);
- shadow_window(wnp, SH_BOTTOM_RIGHT, 2, 1, DARKGRAY);
- wn_plst(CENTERED, 0, msg, wnp);
- m_show();
- return(wnp);
- }
- /*** end of create_message ***/
-
- /********************/
- /* ~destroy_message */
- /* *********************************************************/
- /****************************************************************************/
- void destroy_message( WINDOW *wnp )
- {
- m_hide();
- unshadow_window(wnp);
- wn_destroy(wnp);
- free(wnp);
- m_show();
- }
- /*** end of destroy_message ***/
-
- /**************/
- /* ~copy_file */
- /* ***************************************************************/
- /* file copy that uses only 4k of buffer area... */
- /****************************************************************************/
- int copy_file( char *src_fname, char *dest_fname )
- {
- int read, stat = 0;
- char *buff;
- FILE *src_fp, *dest_fp;
-
- if( (buff = malloc(4096)) != NULL )
- {
- if( (src_fp = fopen(src_fname, "rb")) != NULL )
- {
- if( (dest_fp = fopen(dest_fname, "wb")) != NULL )
- {
- while( 1 )
- {
- read = fread(buff, 1, 4096, src_fp);
- if( read <= 0 )
- break;
- if( fwrite(buff, 1, read, dest_fp) != read )
- stat = -1; /* on error, set stat = - 1 */
- }
- fclose(dest_fp);
- if( !stat ) /* if no errors during copy, set stat = 1 */
- stat = 1;
- }
- fclose(src_fp);
- }
- free(buff);
- }
- return(stat);
- }
- /*** end of copy_file ***/
-
-
- /*************************/
- /* ~register_install_tui */
- /* ****************************************************/
- /* Call this function to register the TUI. This replaces load_tui! */
- /****************************************************************************/
- int register_install_tui( TUI *tuip )
- {
- Tui_error = OFF;
- setmem(tuip, sizeof(TUI), 0);
- tuip->version_num = 160L;
- tuip->blink_set = ON;
- tuip->rows = 25;
- tuip->back_att = 0x7f;
- tuip->back_bdr_att = 0x7f;
- movmem(Palette_install, tuip->palette, 16);
-
- register_install_dlg0(tuip);
- register_install_dlg1(tuip);
- set_tui_parenting(tuip);
- if (Tui_error)
- {
- free_tui(tuip);
- return(0);
- } else return(1);
- }
- /*** end of register_install_tui ***/
-
- /**************************/
- /* ~register_install_dlg0 */
- /* ***************************************************/
- /* Internally called function to register one dialog. */
- /****************************************************************************/
- void register_install_dlg0( TUI *tuip )
- {
- add_dialog(tuip, 0x0000, 9, 8, 61, 9, 0x1F, 0x1F, 1);
- add_button(tuip, 67, 0x0013, 0, 31, 6, 27, 1, 1,
- 0x71, 0x74, 0x03, 0x0e, 0x0f, 0, "Cancel");
- add_check(tuip, 85, 0x1013, 0, 3, 1, 17, 1, 1,
- 0x30, 0x3E, 0x3f, 3, 0x04, 6, " [ ] UltraWin");
- add_check(tuip, 73, 0x1013, 0, 22, 1, 17, 1, 1,
- 0x30, 0x3E, 0x3f, 3, 0x04, 6, " [ ] InTUItion");
- add_check(tuip, 69, 0x1013, 0, 41, 1, 17, 1, 1,
- 0x30, 0x3E, 0x3f, 3, 0x04, 6, " [ ] Encom");
- add_button(tuip, 0, 0x0000, 0, 3, 3, 55, 1, 0,
- 0x1F, 0x1f, 0x1f, 0x1f, 0x1f, 0, "Select the products you wish to install, and choose one");
- add_button(tuip, 0, 0x1000, 0, 3, 4, 47, 1, 0,
- 0x1F, 0x1f, 0x1f, 0x1f, 0x1f, 0, "Of the buttons below.");
- add_button(tuip, 66, 0x0013, 0, 2, 6, 27, 1, 1,
- 0x71, 0x74, 0x03, 0x0e, 0x0f, 0, "Begin Installation");
- }
- /*** end of register_install_dlg0 ***/
-
- /**************************/
- /* ~register_install_dlg1 */
- /* ***************************************************/
- /* Internally called function to register one dialog. */
- /****************************************************************************/
- void register_install_dlg1( TUI *tuip )
- {
- add_dialog(tuip, 0x0000, 1, 2, 76, 20, 0x1F, 0x1F, 1);
- add_box(tuip, 0, 0x0000, 0, 56, 7, 17, 11, 0x3F, 1);
- add_box(tuip, 0, 0x0000, 0, 58, 8, 12, 6, 0x11, 1);
- add_box(tuip, 0, 0x0000, 0, 56, 1, 17, 5, 0x3F, 1);
- add_box(tuip, 0, 0x0000, 0, 2, 3, 51, 11, 0x30, 1);
- add_button(tuip, 0, 0x0000, 0, 2, 1, 51, 1, 1,
- 0x3E, 0x3e, 0x3e, 0x3e, 0x3e, 0, "Title Goes Here");
- add_button(tuip, 0, 0x0000, 0, 56, 1, 17, 1, 0,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0, "Dest (Alt C-F)");
- add_button(tuip, 0, 0x0000, 0, 56, 7, 17, 1, 0,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0, "Compiler");
- add_button(tuip, 67, 0x0013, 0, 2, 15, 14, 3, 1,
- 0x71, 0x74, 0x03, 0x0e, 0x0f, 0, "Cancel");
- add_button(tuip, 291, 0x0013, 0, 19, 15, 22, 3, 1,
- 0x71, 0x74, 0x03, 0x0e, 0x0f, 4, "Alt-H for help");
- add_button(tuip, 75, 0x0013, 0, 44, 15, 10, 3, 1,
- 0x71, 0x74, 0x03, 0x0e, 0x0f, 1, "Ok");
- add_button(tuip, 302, 0x0017, 0, 58, 2, 5, 1, 1,
- 0x1B, 0x1e, 0x03, 0x0e, 0x0f, 0, "C");
- add_button(tuip, 288, 0x0017, 0, 58, 4, 5, 1, 1,
- 0x1B, 0x1e, 0x03, 0x0e, 0x0f, 0, "D");
- add_button(tuip, 274, 0x0017, 0, 65, 2, 5, 1, 1,
- 0x1B, 0x1e, 0x03, 0x0e, 0x0f, 0, "E");
- add_button(tuip, 289, 0x0017, 0, 65, 4, 5, 1, 1,
- 0x1B, 0x1e, 0x03, 0x0e, 0x0f, 0, "F");
- add_button(tuip, 0, 0x0000, 0, 4, 3, 14, 1, 0,
- 0x3E, 0x3e, 0x3e, 0x3e, 0x3e, 0, "Install ON/OFF");
- add_button(tuip, 0, 0x0000, 0, 31, 3, 13, 1, 0,
- 0x3E, 0x3e, 0x3e, 0x3e, 0x3e, 0, "Install Paths");
- add_check(tuip, 83, 0x1013, 0, 4, 4, 10, 1, 0,
- 0x30, 0x3E, 0x3f, 1, 0x58, 4, "[ ] Source");
- add_check(tuip, 72, 0x1013, 0, 4, 6, 11, 1, 0,
- 0x30, 0x3E, 0x3f, 1, 0x58, 4, "[ ] Headers");
- add_check(tuip, 76, 0x1013, 0, 4, 8, 13, 1, 0,
- 0x30, 0x3E, 0x3f, 1, 0x58, 4, "[ ] Libraries");
- add_check(tuip, 69, 0x1013, 0, 4, 10, 8, 1, 0,
- 0x30, 0x3E, 0x3f, 1, 0x58, 5, "[ ] Help");
- add_check(tuip, 65, 0x1013, 0, 4, 12, 11, 1, 0,
- 0x30, 0x3E, 0x3f, 1, 0x58, 6, "[ ] Example");
- add_button(tuip, 0, 0x0000, 0, 20, 4, 2, 1, 1,
- 0x1E, 0x1e, 0x1e, 0x1e, 0x1e, 0, "1)");
- add_button(tuip, 0, 0x0000, 0, 20, 6, 2, 1, 1,
- 0x1E, 0x1e, 0x1e, 0x1e, 0x1e, 0, "2)");
- add_button(tuip, 0, 0x0000, 0, 20, 8, 2, 1, 1,
- 0x1E, 0x1e, 0x1e, 0x1e, 0x1e, 0, "3)");
- add_button(tuip, 0, 0x0000, 0, 20, 10, 2, 1, 1,
- 0x1E, 0x1e, 0x1e, 0x1e, 0x1e, 0, "4)");
- add_button(tuip, 0, 0x0000, 0, 20, 12, 2, 1, 1,
- 0x1E, 0x1e, 0x1e, 0x1e, 0x1e, 0, "5)");
- add_input(tuip, 49, 0x000B, 0, 22, 4, 29, 1, 1, 0x17, 0x0f, 0x0a,
- "",
- "________________________________________________________________________________",
- "********************************************************************************");
- add_input(tuip, 50, 0x000B, 0, 22, 6, 29, 1, 1, 0x17, 0x0f, 0x0a,
- "",
- "________________________________________________________________________________",
- "********************************************************************************");
- add_input(tuip, 51, 0x000B, 0, 22, 8, 29, 1, 1, 0x17, 0x0f, 0x0a,
- "",
- "________________________________________________________________________________",
- "********************************************************************************");
- add_input(tuip, 52, 0x000B, 0, 22, 10, 29, 1, 1, 0x17, 0x0f, 0x0a,
- "",
- "________________________________________________________________________________",
- "********************************************************************************");
- add_input(tuip, 53, 0x000B, 0, 22, 12, 29, 1, 1, 0x17, 0x0f, 0x0a,
- "",
- "________________________________________________________________________________",
- "********************************************************************************");
- add_button(tuip, 66, 0x0017, 0, 58, 8, 12, 1, 0,
- 0x17, 0x1e, 0x03, 0x0e, 0x0f, 0, "Watcom C32");
- add_button(tuip, 66, 0x0017, 0, 58, 9, 12, 1, 0,
- 0x17, 0x1e, 0x03, 0x0e, 0x0f, 0, "Borland");
- add_button(tuip, 84, 0x0017, 0, 58, 10, 12, 1, 0,
- 0x17, 0x1e, 0x03, 0x0e, 0x0f, 0, "Turbo");
- add_button(tuip, 77, 0x0017, 0, 58, 11, 12, 1, 0,
- 0x17, 0x1e, 0x03, 0x0e, 0x0f, 0, "Microsoft");
- add_button(tuip, 90, 0x0017, 0, 58, 12, 12, 1, 0,
- 0x17, 0x1e, 0x03, 0x0e, 0x0f, 0, "Zortech");
- add_button(tuip, 88, 0x0017, 0, 58, 13, 12, 1, 0,
- 0x17, 0x1e, 0x03, 0x0e, 0x0f, 2, "Mix");
- add_button(tuip, 0, 0x0000, 0, 62, 15, 5, 1, 0,
- 0x31, 0x3e, 0x31, 0x3e, 0x31, 0, "Other");
- add_input(tuip, 79, 0x000B, 0, 59, 16, 11, 1, 1, 0x17, 0x0f, 0x0a,
- "",
- "________________________________________________________________________________",
- "********************************************************************************");
- }
- /*** end of register_install_dlg1 ***/
-
- /*** END OF FILE ***/
-
- /*** END OF FILE ***/