home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 April (Special)
/
Chip-Special_1997-04_cd.bin
/
canon
/
bj364
/
bj364d1.exe
/
BJL.BIN
/
SOURCE.ZIP
/
BJL_INST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-22
|
24KB
|
707 lines
// ========================================================================================
// Installer for BJ Printer Setup Utility Program
// DOS Base
// BJ Printer (such as the A250 and A5311)
//
// 1. Version 1.00 [August 18, '95] : Tsukasa Jackie AIBA : create new
// 2. Version 1.01 [September 21, '95] : Tsukasa Jackie AIBA : add A240
// 3. Version 1.02 [September 26, '95] : Tsukasa Jackie AIBA : mono display
// 4. Version 1.10 [April 30, '96] : Tsukasa Jackie AIBA : Added BJC-80/240/4200/4550
// 5. Version 1.11 [April 29, '96] : Srinivas Krishnamurti : Bug fixes
// 6. Version 1.12 [April 30, '96] : Srinivas Krishnamurti : Added routine myhandler() to fix bug
// 7. Version 1.13 [May 15, '96] : Srinivas Krishnamurti : Added code to remove new help file
//
// Copyright Canon Information Systems, Inc. 1995
// ========================================================================================
/*
BJL_INST.c
C-scape for DOS version 4.0.1. Software
Copyright (c) 1992 by Liant Software Corporation.
ALL RIGHTS RESERVED.
This program is installer for A250 setup utility how to use a mouse with C-scape for DOS version 4.0.1.
There are 5 windows.
Window 0 is a software title.
Window 1 is an exit, status, send, default and about menu.
Window 5 is a help menu.
You can select windows by moving the mouse over the desired window.
When you are finished you can quit by pressing ESC or by
clicking the mouse on the field that says "exit".
*/
// ***********************************************************************
// include standard headers
// ***********************************************************************
#include <stdio.h>
#include <string.h>
#include <time.h> // for popdecl.h
#include <sys\types.h>
#include <sys\stat.h>
#include <dos.h>
#include <memory.h>
#include <stdlib.h>
#include <io.h>
#include <conio.h>
#include <fcntl.h>
#include <direct.h>
#include <errno.h>
// ***********************************************************************
// include original headers
// ***********************************************************************
#include "..\h\cscape.h"
#include "..\h\ostdlib.h" // for exit(), otolower()
#include "..\h\popdecl.h" // for popups
#include "..\h\scancode.h" // for event codes
#include "..\h\cmwinobj.h" // for bcwin_Class
#include "..\h\dpref.h"
#include "..\h\ogldecl.h"
#include "bjl_let.h"
// ***********************************************************************
// function name : void __far *myhandler(unsigned, unsigned, unsigned __far *)
// function : Interrupt handler for disk usuage
// input : deverror, errcode, devhdr
// output : void
// ***********************************************************************
void __far myhandler(unsigned deverror, unsigned errcode, unsigned __far *devhdr)
{
if (deverror & 0X8000)
if ((errcode & 0XFF) == 2)
{
_hardresume(_HARDERR_FAIL);
}
}
// ***********************************************************************
// function name : int main(int argc, char **argv)
// function : BJ Printer Setup Utility
// input : int argc
// : char **argv
// output : 1 // failure
// : 0 // success
// ***********************************************************************
int main(int argc, char **argv)
{
menu_type menu_0, menu_1, menu_5; //
int fh, i, tmp_drive, current_drive;
char dir[OFILE_MAXSPEC + 1], dir_org[OFILE_MAXSPEC + 1], dir_tmp[OFILE_MAXSPEC + 10];
char search_file[] = "INSTALL.EXE";
char monitor_ng[OFILE_MAXSPEC + 9];
strcpy(dir, "C:\\BJ");
strcpy(dir_org, "A:\\");
// Get original drive and path before installation procedure started
olddrive = _getdrive();
_getdcwd(olddrive, path, _MAX_PATH);
// Check drive
if(_chdrive(3) != FILE_ERROR)
tmp_drive = 1;
else
{
if(_chdrive(1) != FILE_ERROR)
tmp_drive = 0;
}
// Start display (monitor check)
system("cls");
if((argc == 2) && (otolower(argv[1][1]) == 't'))
colors = SVGA_COLOR;
else
colors = CO_COLOR;
//
dp_SetApplName(" bjl_inst "); // Open the display
dp_SetWindowName(" Installer for BJ Printer Setup Utility ");
argc = dp_PickArgs(argc, argv);
// Use background character win to make a nice background
if(colors == CO_COLOR)
{
if(disp_Init(def_ModeGraphics, bcwin_Class))
ogl_Init(def_MiniOGL); // Initialize the Oakland Graphics Library
else
{
if(!disp_Init(def_ModeText, bcwin_Class)) // Initialize the device interface for text mode
{
printf("%s", INITFAIL_MSG); // Initialization failure
exit(1);
return(1);
}
}
}
else
{
if(disp_Init(pc_ModeVGA50, bcwin_Class))
ogl_Init(def_MiniOGL); // Initialize the Oakland Graphics Library
else
{
if(!disp_Init(def_ModeText, bcwin_Class)) // Initialize the device interface for text mode
{
printf("%s", INITFAIL_MSG); // Initialization failure
exit(1);
return(1);
}
}
}
bdcua_InitCombo(); // Initialize the text and graphics (use bd_cua in either mode)
// Display the background
bcwin_SetChar(disp_GetBackWin(), (byte)BK_CHAR); // a half-dense block char
win_SetAttr(disp_GetBackWin(), (byte)BK_COLOR1);
win_SetShadowAttr(disp_GetBackWin(), (byte)BK_COLOR2);
disp_Repaint();
if(!hard_InitMouse()) // Check the mouse driver
{
if(!opc_Verify(NULL, ERROR, 0, ERROR_MOUSE))
{
disp_Close(); // Close down the display interface
exit(1);
return(1);
}
}
else
sedwin_MouseInit(); // Turn on the mouse
if((colors == CO_COLOR) & (disp_GetColors() <= 2L)) // Map colors for 2 color video modes
{
disp_MapMono(TRUE);
colors = BW_COLOR;
}
//////////////////
//colors = BW_COLOR;
//
// create the windows 0 -- Title -------------------------------------------------------------------
menu_0 = menu_Open();
menu_Printf(menu_0, WINDOW_0, NULL);
window_0 = sed_Open(menu_0);
switch(colors)
{
case BW_COLOR: // Monochrome
sed_SetColors(window_0, WHITE_BLACK, WHITE_BLACK, WHITE_BLUE);
break;
case SVGA_COLOR: // Super VGA
sed_SetColors(window_0, RED_WHITE, RED_WHITE, WHITE_RED);
break;
default:
case CO_COLOR: // Graphics
sed_SetColors(window_0, RED_WHITE, RED_WHITE, WHITE_RED);
break;
}
sed_SetBorderFeature(window_0, BD_TOP);
sed_SetPosition(window_0, 2, 16);
sed_SetHeight(window_0, 1);
sed_SetWidth(window_0, 50);
sed_SetShadow(window_0, 0);
// create the windows 5 ----------------------------------------------------------------------------
menu_5 = menu_Open();
menu_Printf(menu_5, WINDOW_5_1, NULL);
menu_Printf(menu_5, WINDOW_5_2, NULL);
menu_Printf(menu_5, WINDOW_5_3, NULL);
menu_Printf(menu_5, WINDOW_5_4, NULL);
menu_Printf(menu_5, WINDOW_5_5, NULL);
window_5 = sed_Open(menu_5);
switch(colors)
{
case BW_COLOR: // Monochrome
sed_SetColors(window_5, BLACK_WHITE, WHITE_BLACK, WHITE_BLUE);
break;
case SVGA_COLOR: // Super VGA
sed_SetColors(window_5, BLUE_WHITE, BLUE_WHITE, WHITE_BLUE);
break;
default:
case CO_COLOR: // Graphics
sed_SetColors(window_5, BLUE_WHITE, BLUE_WHITE, WHITE_BLUE);
break;
}
sed_SetBorder(window_5, bd_cua);
sed_SetBorderFeature(window_5, BD_OUTLINE | BD_PROMPT | BD_TOP);
sed_SetPosition(window_5, 21, 11);
sed_SetHeight(window_5, 6);
sed_SetWidth(window_5, 58);
sed_SetShadow(window_5, 0);
// -------------------------------------------------------------------------------------------------
sed_Repaint(window_0);
sed_Repaint(window_5);
// ######### Main loop Start ##########
// create the windows 1 -- check source drive and directory ---------------------------------------------------------------
Reinstall:
while(1)
{
menu_1 = menu_Open();
menu_Printf(menu_1, WINDOW_s_1, dir_org, &string_funcs, WINDOW_1_2);
menu_Printf(menu_1, MENU_0_OK, NULL, &gmenu_funcs, MENU_0_OK_H, OKAY_STR);
menu_Printf(menu_1, MENU_0_CA, NULL, &gmenu_funcs, MENU_0_CA_H, CANCEL_STR);
window_1 = sed_Open(menu_1);
switch(colors)
{
case BW_COLOR: // Monochrome
sed_SetColors(window_1, BLACK_WHITE, WHITE_BLACK, WHITE_BLACK);
break;
case SVGA_COLOR: // Super VGA
sed_SetColors(window_1, BLACK_BROWN, BROWN_BLACK, BLACK_WHITE);
break;
default:
case CO_COLOR: // Graphics
sed_SetColors(window_1, YELLOW_BLACK, YELLOW_GRAY, BLACK_YELLOW);
break;
}
sed_SetBorder(window_1, bd_cua);
sed_SetBorderFeature(window_1, BD_TITLE | BD_OUTLINE | BD_TOP | BD_PROMPT | BD_MOVE);
sed_SetBorderTitle(window_1, WINDOW_1_TITLE);
sed_SetPosition(window_1, 6, 4);
sed_SetHeight(window_1, 5);
sed_SetWidth(window_1, 70);
sed_SetShadow(window_1, 1);
sed_SetShadowAttr(window_1, BK_COLOR3);
// Attach a mouse handler to the sed
win_SetMouse(window_1, winmou_All);
win_SetMouseFeature(window_1, MOUF_TRACK);
sedlist[0] = window_1;
sed_SetSpecial(window_1, spc_Jump);
sed_SetAux(window_1, aux_Top);
sed_Repaint(window_1);
if(sed_Go(window_1) == CANCEL)
{
sed_Close(window_1);
EndDisplay(); // quit = TRUE;
}
sed_Close(window_1);
// to fix ptr #217 in BJ v3.6. If the source drive is invalid (meaning there is
// no disk in drive A or B), now it pops up a message instead of letting DOS show
// its own error message (that ABORT, RETRY, FAIL message). SK; 4/30/96
_harderr(myhandler);
if(_chdrive(current_drive=(toupper(dir_org[0])-0x40)) == FILE_ERROR)
opc_Prompt(NULL, ERROR, 0, ERROR_DRIVE);
else
{
// _chdir(dir_org);
// to fix ptr #218 in BJ v3.6. If the source directory is invalid, now it pops
// a message indicating that the source directory is invalid. SK; 4/29/96
if (_chdir(dir_org) != 0)
{
opc_Prompt(NULL, ERROR, 0, ERROR_DIR);
}
else
{
_searchenv(search_file,".",dir_tmp);
if(*dir_tmp == (byte)NULL)
opc_Prompt(NULL, ERROR, 0, ERROR_FILE8);
else
break;
}
}
}
if(tmp_drive)
system("copy bjl.bin c:\\bjl.exe");
else
system("copy bjl.bin a:\\bjl.exe");
// -------------------------------------------------------------------------------------------------
while(1)
{
Retry:
disp_Repaint();
// create the windows 1 -- Installer ---------------------------------------------------------------
menu_1 = menu_Open();
menu_Printf(menu_1, WINDOW_1_1, dir, &string_funcs, WINDOW_1_2);
menu_Printf(menu_1, MENU_0_OK, NULL, &gmenu_funcs, MENU_0_OK_H, OKAY_STR);
menu_Printf(menu_1, MENU_0_CA, NULL, &gmenu_funcs, MENU_0_CA_H, CANCEL_STR);
window_1 = sed_Open(menu_1);
switch(colors)
{
case BW_COLOR: // Monochrome
sed_SetColors(window_1, BLACK_WHITE, WHITE_BLACK, WHITE_BLACK);
break;
case SVGA_COLOR: // Super VGA
sed_SetColors(window_1, BLACK_CYAN, CYAN_BLACK, BLACK_WHITE);
break;
default:
case CO_COLOR: // Graphics
sed_SetColors(window_1, CYAN_BLACK, CYAN_GRAY, BLACK_CYAN);
break;
}
sed_SetBorder(window_1, bd_cua);
sed_SetBorderFeature(window_1, BD_TITLE | BD_OUTLINE | BD_TOP | BD_PROMPT | BD_MOVE);
sed_SetBorderTitle(window_1, WINDOW_1_TITLE);
sed_SetPosition(window_1, 6, 4);
sed_SetHeight(window_1, 5);
sed_SetWidth(window_1, 70);
sed_SetShadow(window_1, 1);
sed_SetShadowAttr(window_1, BK_COLOR3);
// Attach a mouse handler to the sed
win_SetMouse(window_1, winmou_All);
win_SetMouseFeature(window_1, MOUF_TRACK);
// -------------------------------------------------------------------------------------------------
sedlist[0] = window_1;
sed_SetSpecial(window_1, spc_Jump);
sed_SetAux(window_1, aux_Top);
sed_Repaint(window_1);
if(sed_Go(window_1) == CANCEL)
{
sed_Close(window_1);
_close(fh);
_chdrive(toupper(dir[0])-0x40);
_chdir(dir);
system("cd ..");
_rmdir(dir);
if(tmp_drive)
system("del c:\\bjl.exe");
else
system("del a:\\bjl.exe");
EndDisplay(); // quit = TRUE;
}
sed_Close(window_1);
// create the windows 1 -- Make dir ---------------------------------------------------------------
for(i=0;dir[i]>' ';i++);
dir[i] = (byte)NULL;
switch(i)
{
case 0:
case 1:
opc_Prompt(NULL, ERROR, 0, ERROR_DRIVE);
goto Retry;
case 2:
if( dir[1] == ':')
{
dir[2] = '\\';
dir[3] = (byte)NULL;
++i;
}
else
{
opc_Prompt(NULL, ERROR, 0, ERROR_DRIVE);
goto Retry;
}
break;
}
if(_chdrive(toupper(dir[0])-0x40) == FILE_ERROR)
{
opc_Prompt(NULL, ERROR, 0, ERROR_DRIVE);
goto Retry;
}
system("cd \\");
if(_chdir(dir) == FILE_ERROR)
{
menu_1 = menu_Open();
menu_Printf(menu_1, WINDOW_1_3);
menu_Printf(menu_1, MENU_1_OK, NULL, &gmenu_funcs, NULL, OKAY_STR);
menu_Printf(menu_1, MENU_1_CA, NULL, &gmenu_funcs, NULL, CANCEL_STR);
window_1 = sed_Open(menu_1);
switch(colors)
{
case BW_COLOR: // Monochrome
sed_SetColors(window_1, BLACK_WHITE, BLACK_WHITE, WHITE_BLACK);
break;
case SVGA_COLOR: // Super VGA
sed_SetColors(window_1, BLACK_CYAN, CYAN_BLACK, BLACK_WHITE);
break;
default:
case CO_COLOR: // Graphics
sed_SetColors(window_1, CYAN_BLACK, CYAN_GRAY, BLACK_CYAN);
break;
}
sed_SetBorder(window_1, bd_cua);
sed_SetBorderFeature(window_1, BD_OUTLINE | BD_TOP | BD_PROMPT | BD_MOVE);
sed_SetPosition(window_1, 6, 18);
sed_SetHeight(window_1, 4);
sed_SetWidth(window_1, 42);
sed_SetShadow(window_1, 1);
sed_SetShadowAttr(window_1, BK_COLOR3);
// Attach a mouse handler to the sed
win_SetMouse(window_1, winmou_All);
win_SetMouseFeature(window_1, MOUF_TRACK);
// -------------------------------------------------------------------------------------------------
sedlist[0] = window_1;
sed_SetSpecial(window_1, spc_Jump);
sed_SetAux(window_1, aux_Top);
sed_Repaint(window_1);
if(sed_Go(window_1) == CANCEL)
{
sed_Close(window_1);
_chdrive(toupper(dir[0])-0x40);
_chdir(dir);
system("cd ..");
_rmdir(dir);
goto Retry;
}
sed_Close(window_1);
if(_mkdir(dir) == FILE_ERROR)
{
// opc_Prompt(NULL, ERROR, 0, ERROR_FILE);
opc_Prompt(NULL, ERROR, 0, ERROR_DIR); // SK, 5/22/96 - to fix ptr#241 in BJ V3.6
goto Retry;
}
else
_chdir(dir);
}
if(colors == SVGA_COLOR)
{
memcpy(monitor_ng, "monitor\n", 8);
memcpy(monitor_ng+8, dir, i);
i = i+8;
}
else
{
monitor_ng[0] = (byte)NULL;
memcpy(monitor_ng, dir, i);
}
//
_close(fh);
remove(INI_FILE);
if((fh = _open(INI_FILE, _O_WRONLY | _O_CREAT, _S_IREAD | _S_IWRITE)) == FILE_ERROR)
{
opc_Prompt(NULL, ERROR, 0, ERROR_FILE);
disp_Close(); // Close down the display interface
exit(1);
return(1);
}
if(_write(fh, monitor_ng, i) == FILE_ERROR)
{
opc_Prompt(NULL, ERROR, 0, ERROR_FILE);
_close(fh);
goto Retry;
}
_close(fh);
if(tmp_drive)
system("copy c:\\bjl.exe .");
else
system("copy a:\\bjl.exe .");
disp_Repaint();
if((fh = _open("bjl.exe", _O_RDONLY)) == FILE_ERROR)
{
opc_Prompt(NULL, ERROR, 0, ERROR_FILE7);
system("cd ..");
_rmdir(dir);
_close(fh);
}
else
break;
}
_close(fh);
system("echo off");
disp_Repaint();
remove("bjsetup.exe");
remove("bjsetup.hlp");
remove("bjsetup1.hlp");
remove("bjsetup2.hlp");
remove("bjsetup3.hlp");
remove("bjsetup4.hlp");
remove("bjsetup5.hlp");
remove("bjsetup6.hlp");
remove("bjsetup7.hlp"); // sk, 5/15/96 - new help file for B380IF
remove("bjsetup.ini");
disp_Repaint();
hard_Pause(200);
system("bjl");
disp_Repaint();
remove("bjl.exe");
if(tmp_drive)
system("del c:\\bjl.exe");
else
system("del a:\\bjl.exe");
system("echo on");
disp_Repaint();
if((fh = _open("bjsetup.exe", _O_RDONLY)) == FILE_ERROR)
{
opc_Prompt(NULL, ERROR, 0, ERROR_FILE7);
system("cd ..");
_rmdir(dir);
_close(fh);
disp_Repaint();
goto Reinstall;
}
_close(fh);
if((fh = _open("bjsetup.ini", _O_RDONLY)) == FILE_ERROR)
{
opc_Prompt(NULL, ERROR, 0, ERROR_FILE7);
system("cd ..");
_rmdir(dir);
_close(fh);
disp_Repaint();
goto Reinstall;
}
_close(fh);
// create the windows 1 -- Success Display -------------------------------------------------------------
disp_Repaint();
menu_1 = menu_Open();
menu_Printf(menu_1, WINDOW_2_1);
menu_Printf(menu_1, MENU_2_OK, NULL, &menu_funcs);
window_1 = sed_Open(menu_1);
switch(colors)
{
case BW_COLOR: // Monochrome
sed_SetColors(window_1, BLACK_WHITE, BLACK_WHITE, WHITE_BLACK);
break;
case SVGA_COLOR: // Super VGA
sed_SetColors(window_1, GREEN_WHITE, GREEN_BLACK, BLACK_WHITE);
break;
default:
case CO_COLOR: // Graphics
sed_SetColors(window_1, GREEN_BLACK, GREEN_GRAY, BLACK_GREEN);
break;
}
sed_SetBorder(window_1, bd_cua);
sed_SetBorderFeature(window_1, BD_OUTLINE | BD_TOP | BD_PROMPT | BD_MOVE);
sed_SetPosition(window_1, 6, 22);
sed_SetHeight(window_1, 4);
sed_SetWidth(window_1, 34);
sed_SetShadow(window_1, 1);
sed_SetShadowAttr(window_1, BK_COLOR3);
// Attach a mouse handler to the sed
win_SetMouse(window_1, winmou_All);
win_SetMouseFeature(window_1, MOUF_TRACK);
sed_Repaint(window_1);
sed_Go(window_1);
sed_Close(window_1);
// ######### Main loop End ##########
EndDisplay();
}
// ***********************************************************************
// function name : int EndDisplay(void)
// function : Exit this program
// input : void
// output : 0
// ***********************************************************************
int EndDisplay()
{
sed_Close(window_0); // close the windows
sed_Close(window_5);
win_Close(disp_GetBackWin()); // Close the background window
disp_SetAttr(WHITE_BLACK);
disp_Repaint();
disp_Close(); // shut down the display
_chdrive(olddrive); // change drive back to the original saved at the beginning; SK 4/30/96
_chdir(path); // change path back to the original; SK 4/30/96
exit(0);
return(0);
}
// ***********************************************************************
// function name : boolean spc_Jump(sed_type sed, int scancode)
// function : Tab key's jump next window
// input : sed_type sed
// : int scancode
// output : TRUE
// : FALSE
// ***********************************************************************
boolean spc_Jump(sed_type sed, int scancode)
{
switch(scancode)
{
case TAB:
if(sed_GetFieldNo(sed_GetWin(sedlist[0])) == 2)
sed_GotoFirstField(sed_GetWin(sedlist[0]));
else
sed_IncField(sed_GetWin(sedlist[0]));
return(TRUE);
case SHFT_TAB:
if(sed_GetFieldNo(sed_GetWin(sedlist[0])) == 0)
sed_GotoLastField(sed_GetWin(sedlist[0]));
else
sed_DecField(sed_GetWin(sedlist[0]));
return(TRUE);
// ---------------------------------------------------------------------------------
case MOU_NOFIELD:
return(TRUE); // Keep mouse events from exiting program
case ESC:
sed_GotoLastField(sed_GetWin(sedlist[0]));
kb_Stuff(ENTER);
return(TRUE);
}
return(FALSE);
}