;COPYRIGHT Hewlett-Packard Company 1987, 1988, 1989, 1990, 1991
; HP OpenView Hub Manager installation
;   Routines included:
;       install_app
;       get_netif
;       find_netif
;       get_ov
;       find_ov
;       update_winini
;       update_mskermit
;

;variables map
        array_def line 24
        array_def token 80

        macro setmsg.txt
        macro appmsg.txt                ;modify for your application
        macro breakit.txt
        macro setutl.txt

;Code Begins
        onbreak gosub break_it
        echo off

        set status 12345
        set completed 0

;This is the main application script procedure to install an application.
install_app

        gosub welcome_init
        gosub get_net_type              ;ask user if installing IP or IPX
        gosub get_windows               ;collect Windows location
        gosub get_ov                    ;collect OV location

        gosub print_welcome
        print cr cr cr

        if app_name = emulatr goto dont_get_net
        if net_type = net_netware gosub get_netifx
        if net_type = net_netware gosub get_netcfg
        if net_type = net_tcpip   gosub get_netif
     dont_get_net
        gosub check_ver                 ;check netif & OV version

        set var022 1			;Developer should set edit flag
					;   to control user's input of
					;   where OV\ or app should be
					;  	1  
					;	2 
					;	3 
 	gosub get_app

        gosub build_dirs		; build necessary directories
        gosub file_copy			; copy & expand files

        gosub install_app_symbol        ;Installs application private symbols.

        gosub clean_up_old   		;Clean up stuff from old versions 

        gosub update_win_ini   		; make changes to WIN.INI of Windows

        gosub update_progman_ini 	; add Group file to PROGMAN.INI

        if app_name = emulatr goto dont_up_files

	; if installing for IPX make changes to SYSTEM.INI of Windows
        if net_type = net_netware gosub update_system_ini

	; if installing for IPX create/modify the NET.CFG file
        if net_type = net_netware gosub update_netcfg

	; if TCP/IP make changes to MSKERMIT.INI of ARPA
	if net_type = net_tcpip gosub update_mskermit

     dont_up_files

	set completed 1
quit
	print cr cr
	use_pen title_pen
	if completed = 0 use_pen error_pen
	if completed = 0 print not_over cr
	if completed = 1 print over1 cr
	clear_pen
	print "                                                                                " cr
 	changedrive var004
 	cd \
 	changedrive var003
 	cd \
	stop

get_netcfg
	set var023 ""
	set netcfg ""
	set netcfg_file "NET.CFG"
	set ipx_file1 "IPX.COM"
	set ipx_f1_ver "3.10"
	set ipx_file2 "IPXODI.COM"
	set ipx_f2_ver "1.20"
	print cr "Checking version of NetWare . . ."cr

        set vers_prog var003
        strcat vers_prog "\install\findstr.exe"

        ; Try to find IPX.COM on the default drive
	set search_drive defdrive
	strcat search_drive colon
	set ipxcom_file ""
     find_ipx1
        ; Find the next occurance of IPX.COM
	findfile ipx_file1 search_drive ipxcom_file
	if ipxcom_file = "" goto next_ipx2
	; IPX.COM was found, check for appropriate version
	print "     " ipxcom_file cr
	set req_ipxcom ipx_f1_ver
        set version_req_token 2
	gosub check_ipx_ver
	if version_compare_result != 0 goto find_ipx1
	; A Good version of IPX.COM was found, see if NET.CFG exists here
	strlen ipx_file1 tmp_str_len
	strlen ipxcom_file tmp_dir_len
	sub tmp_str_len tmp_dir_len
	if tmp_dir_len > 3 sub 1 tmp_str_len tmp_dir_len
	mid netcfg ipxcom_file 1 tmp_dir_len
	set var023 netcfg
        strcat netcfg bslash netcfg_file
        exist netcfg status
	; if NET.CFG exists here, update this one, else try to find again
        if status = 1 goto end_getnetcfg
        goto find_ipx1

     next_ipx2
        ; Try to find IPXODI.COM on the default drive
	set search_drive defdrive
	strcat search_drive colon
	set ipxcom_file ""
     find_ipx2
        ; Find the next occurance of IPXODI.COM
	findfile ipx_file2 search_drive ipxcom_file
	if ipxcom_file = "" goto ask_netcfg
	; IPXODI.COM was found, check for appropriate version
	print "     " ipxcom_file cr
	set req_ipxcom ipx_f2_ver
        set version_req_token 4
	gosub check_ipx_ver
	if version_compare_result != 0 goto find_ipx2
	; A Good version of IPXODI.COM was found, see if NET.CFG exists here
	strlen ipx_file2 tmp_str_len
	strlen ipxcom_file tmp_dir_len
	sub tmp_str_len tmp_dir_len
	if tmp_dir_len > 3 sub 1 tmp_dir_len
	mid netcfg ipxcom_file 1 tmp_dir_len
	set var023 netcfg
        strcat netcfg bslash netcfg_file
        exist netcfg status
	; if NET.CFG exists here, update this one, else try to find again
        if status = 1 goto end_getnetcfg
        goto find_ipx2

     ask_netcfg
	if var023 != "" goto read_netcfg
	gosub ipx_vers_warn

     read_netcfg
        if var023 != "" goto def_dir_set
        set var023 defdrive
        strcat var023 colon bslash
     def_dir_set
        set var014 "This product requires a parameter be set in the NetWare"
        set var015 "configuration file "
        strcat var015 netcfg_file ".  This file should reside in"
        set var016 "the Novell NetWare 386 Clients directory (i.e where"
	set var017 "IPX.COM or IPXODI.COM reside)."

	set var018 "The directory above is where this install will edit/create"
        set var019 netcfg_file
        strcat var019 "."
        set var020 "Select Continue to accept the above value,"
        set var021 "select Edit to use another directory, or select Quit."
	set var022 1

	gosub get_info
	gosub rebuild_screen
        exist var023 status
	if status = 2 goto end_get_netcfg
	goto read_netcfg

     end_get_netcfg
	gosub rebuild_screen
	set netcfg var023
	strlen var023 tmp_str_len
	if tmp_str_len = 3 mid netcfg var023 1 2
	strcat netcfg bslash netcfg_file

     end_getnetcfg
return


update_netcfg
        ;Update the ipx_retry_count line in netcfg, add if not there
	print cr "Inserting entry in " netcfg cr
        update netcfg ipx_retry_count 1
return

check_ipx_ver
        ; This function will check the version of the IPX file passed in
        ; as ipxcom_file against the version req_ipxcom.
        ; As a result, it sets version_compare_result to 0 for a good version
        ; or 1 for a bad version
        set version_string ""                           ;check version of
        envstr version_string                           ;IPX file
        run vers_prog "-v" ipxcom_file
        strlen version_string version_string_len
        if version_string_len <= 0 set version_compare_result 1
        if version_string_len <= 0 goto end_ipx_check
        gosub get_d_dd
        set version_compare_result 0
        if extract_ver < req_ipxcom set version_compare_result 1
     end_ipx_check
return

ipx_vers_warn
        set var014 "This install has been unable to determine that your version"
        set var015 "of NetWare meets the requirements of this product."
        set var016 "See the Install Manual for version information."
        set var017 "You may Continue now or Quit to verify versions."
	set var022 2
	set var023 ""
	gosub get_info
	gosub rebuild_screen
return

backup_file 
; On Entry:
;   bk_dir   - directory where file to be backed up exists
;   bk_drive - disk drive where file to be backed up exists
;   bk_ofile - filename of original (source) file
;   bk_nfile - filename of new (backup) file
        changedrive bk_drive
        cd bk_dir
        copys bk_ofile bk_nfile status null null
	print cr bk_ofile " copied to " bk_nfile cr
        if status = 0 goto copy_ok
        print cr "Unable to backup " bk_ofile " to " bk_nfile cr
        goto quit1
     copy_ok
return

clean_up_old 
        ; Go to the drive of where the application is being installed
        set target_dir var074
        strcat target_dir var075
        changedrive target_dir

        ; remove the HUB Help file if it exists and not installing HUBMANAGER
	if app_name = hubmgr goto cleanup1
	set file_name "HUB.HLP"
        set file target_dir
        strcat file app_hlp bslash file_name
	exist file status
	if status != 1 goto cleanup1
        cd target_dir
        cd app_hlp
	delete file_name

     cleanup1
        ; remove the BRIDGE Help file if it exists
	set file_name "BRG.HLP"
        set file target_dir
        strcat file app_hlp bslash file_name
	exist file status
	if status != 1 goto cleanup2
        cd target_dir
        cd app_hlp
	delete file_name

     cleanup2
        ; remove the XLATE.INI file if it exists
	set file_name "XLATE.INI"
        set file target_dir
        strcat file app_prvhid bslash file_name
	exist file status
	if status != 1 goto cleanup_end
        cd target_dir
        cd app_prvhid
	delete file_name

     cleanup_end
return 

get_net_type 
; Purpose - to determine if user wants to install IP or IPX version
;
; KLP - created 01/14/92
;
	; print the welcome message
	gosub print_welcome

	; print the headings
	set var014 "!2 version !1 can be run"
	set var015 "using either NetWare protocols or TCP/IP protocols."
	set var016 "You must choose which version to install at this time."
	set var017 "Please Select:  NetWare, TCP/IP, or Quit "
	set var023 ""
        gosub print_ins

	; print the selection window
        set win_label " Select Network Type "
     redo_get_net_type
        gosub display_main_win
        form_entry net_netware netware_str
        form_entry net_tcpip tcpip_str
        form_entry quit_val quit_str
	form_read net_type str
	clear_pen
	if net_type = quit_val goto quit0
        if net_type = net_netware goto end_get_net_type
        if net_type = net_tcpip goto end_get_net_type
        gosub restore_edit_area
        goto redo_get_net_type
     end_get_net_type
return

get_netif 
; Purpose - to collect network transport location from user
;

        print "~Searching for " OfficeShare " on disk " defdrive ": . . ." cr

        ; See if I can find the files first
	if netif_file1 = "" goto ask_netif
	set search_drive defdrive
	strcat search_drive colon
	set curdir ""
	findfile netif_file1 search_drive curdir
	if curdir = "" goto ask_netif
	set found_dir curdir
	findfile netif_file1 search_drive curdir
	if curdir != "" goto ask_netif
	strlen netif_file1 file1_len
        strlen found_dir dir_len	; Directory starts at char 3 (drive:)
	sub file1_len dir_len		; so subtract file_name length and
	sub 3 dir_len			; 3 more for chars 1 2 and the bkslash
	mid var076 found_dir 1 2
	mid var077 found_dir 3 dir_len
	changedrive var076
	cd var077
	if netif_file2 = "" goto end_get_netif
	exists netif_file2 status
	if status = -1 goto ask_netif
	if netif_file3 = "" goto end_get_netif
	exists netif_file3 status
	if status = -1 goto ask_netif
        goto end_get_netif

     ask_netif
	set var022 1            ;need?

	set var008 OfficeShare

	set var014 box_dep1
	set var015 box_dep2
	set var016 box_dep3
	set var017 box_dep4

 	set var018 box_stitle1
 	set var019 box_stitle2
 	set var020 box_stitle3
 	set var021 box_stitle4

	set var023 defdrive
        strcat var023 colon OS_location
	gosub get_info
	mid var076 var023 1 2
	mid var077 var023 3 62

 	gosub find_netif

     end_get_netif
        print "     !76!77" cr
return

find_netif
; Purpose - to determine if transport exists
;
; Created 10/02/89 - Tamra Perez

	gosub print_welcome

	onerror gosub win_drive_error

	set status 0			;If drive exists, go to that drive.
	size var076 status
	if status = 0 goto netif_retry
	changedrive var076
	cd \

	exist var077 status		    ;If dir exists, go to that dir.
	if status != 2 goto netif_retry
	cd var077

					;Print Looking for netif message
	print cr cr cr netiflook cr

                                        ;Begin checking for file existance
	exist netif_file1 status
	if status = -1 goto netif_retry       ;file doesn't exist?

        if netif_file2 = "" goto find_netif_end  ;exit if done
        exist netif_file2 status
        if status = -1 goto netif_retry

        if netif_file3 = "" goto find_netif_end
        exist netif_file3 status
        if status = -1 goto netif_retry
        goto find_netif_end             ;successful exit


netif_retry                             ;reprint message to give user
	move 0, -3                      ;another chance

	set var022 3

        set var008 OfficeShare
        set var100 var076
        set var101 var077
 
 	set var018 box_stitle1
 	set var019 box_stitle2
 	set var020 box_stitle3
 	set var021 box_stitle4

	set var014 need_file1    
	set var015 need_file2    
	set var016 need_file3    
	set var017 need_file4    

	set var023 defdrive
        strcat var023 colon OS_location
	gosub get_info
	mid var076 var023 1 2
	mid var077 var023 3 62

	gosub rebuild_screen

	goto find_netif

find_netif_end
	changedrive var003                       ;restore drive and path
	cd app_inst
return

get_netifx
	print cr "Checking " win_name " Network values for NetWare . . ." cr
	; Build path to SYSTEM.INI file for checking values
	set sysini_file var172
	strcat sysini_file var173 bslash system.ini

	; Check for "NETWORK.DRV" entry
	set check_string "[boot]network.drv="
	set ret_value ""
	update sysini_file check_string 15 ret_value
	upshift ret_value
	if ret_value != "NETWARE.DRV" goto netware_error

	; Check for "NETWORK" entry
	set check_string "[386Enh]network="
	set ret_value ""
	update sysini_file check_string 15 ret_value
	set str_to_parse ret_value
	gosub parse_string
	set next_toke 0
     get_vnetbios
	if next_toke >= tokes goto netware_error
	if token[next_toke] = "*VNETBIOS" goto x_vnetware
	add 1 next_toke
	goto get_vnetbios
     x_vnetware
	set netx_toke 0
     get_vnetware
	if next_toke >= tokes goto netware_error
	if token[next_toke] = "VNETWARE.386" goto get_netx_end
	add 1 next_toke
	goto get_vnetware

netware_error
	cls
	pos app_err_margin,box_title
	print "ERROR - When using Novell NetWare under MS Windows" cr
	move app_err_margin,1
	print "The SYSTEM.INI file should have the following entries:" cr
	move app_err_margin,0
	print "    Section [boot] - network.drv=netware.drv" cr
	move app_err_margin,0
	print "    Section [386Enh] - network=*vnetbios, vnetware.386" cr
	move app_err_margin,1
	print "To correct this: Set your network type for " win_name " to NetWare" cr
	move app_err_margin,0
	print "                 - Get into Windows Setup" cr
	move app_err_margin,0
	print "                 - Select: Options (Change System Settings)" cr
	move app_err_margin,0
	print "                 - Select: Network" cr
	move app_err_margin,0
	print "                 - Select: Novell NetWare (or equivelent)" cr
	set status -1
	goto quit

get_netx_end
return

update_system_ini
        set bk_drive var172
        set bk_dir var173
        set bk_ofile system_ini
        set bk_nfile "SYSTEM.BAK"
	gosub backup_file
	print "Inserting entries in SYSTEM.INI . . ." cr

	; Build path to SYSTEM.INI file for checking values
	set sysini_file var172
	strcat sysini_file var173 bslash system.ini

	; add VIPX.386 to the network line if not already there
	set mod_line "[386Enh]network="
	update sysini_file mod_line 15 old_value
	set str_to_parse old_value
	gosub parse_string
	set next_toke 0
     get_vipx386
	if next_toke >= tokes goto add_vipx386
	if token[next_toke] = "VIPX.386" goto add_vpicda386
	add 1 next_toke
	goto get_vipx386
     add_vipx386
        set new_value mod_line
        strcat new_value old_value ",VIPX.386"
	update sysini_file new_value 11

     add_vpicda386
	set section "[386Enh]"
	set old_entry "device=*vpicd"
	set del_prog var003				; Build full path
	strcat del_prog "\install\delline.exe"		; to executable
	run del_prog sysini_file section old_entry
	set new_entry section
	strcat new_entry "device=vpicda.386"
	update sysini_file new_entry 14
return

; KLP - 01/20/92
; This function will parse a string and put the tokes in the array 'token'
; On Entry:
;     str_to_parse - contains the string to parse
; On Exit:
;     tokes - number of tokens found
;     token - array with 0 - (tokes-1) filled with the tokens
parse_string
	; Initialize
	set tokes 0
	strlen str_to_parse str_length 
	set toke_start 1

     wt_space
	if toke_start > str_length goto end_parse
	mid next_char str_to_parse toke_start 1	; get the next character
	if next_char = " " add 1 toke_start
	if next_char = " " goto wt_space
	if next_char = "	" add 1 toke_start
	if next_char = "	" goto wt_space
	if next_char = "," add 1 toke_start
	if next_char = "," goto wt_space

	; found first character of next token
	set toke_end toke_start
     more_token
	add 1 toke_end
	if toke_end > str_length goto end_token
	mid next_char str_to_parse toke_end 1	; get the next character
	if next_char = " " goto end_token
	if next_char = "	" goto end_token
	if next_char = "," goto end_token
	goto more_token

     end_token
	; found end of line or token seperator
	set toke_len toke_end
	sub toke_start toke_len
	mid tmpstr str_to_parse toke_start toke_len
	upshift tmpstr
	set token[tokes] tmpstr
	add 1 tokes
	set toke_start toke_end
	goto wt_space

     end_parse
return

get_windows 
; Purpose - to collect MS Windows location from user
;
; sets: (these already set to defaults in welcome_init)
;    var070 = Drive where Openview exists, w/colon
;    var071 = Directory where Openview exists, w/o backslash
;
	set var022 1            
	set var008 win_name

	set var014 box_dep1
	set var015 box_dep2
	set var016 box_dep3
	set var017 box_dep4

 	set var018 box_stitle1
 	set var019 box_stitle2
 	set var020 box_stitle3
 	set var021 box_stitle4

	set var023 var070
        strcat var023 var071
	gosub get_info
	mid var070 var023 1 2
	mid var071 var023 3 62

	gosub find_windows
return

find_windows
; Purpose - to find and set paths to MS Windows Files & Directories
;           - WIN.INI file      - Modified
;           - SYSTEM.INI file   - Checked/Modified for IPX
;           - SYSTEM directory  - drivers installed here for IPX
;
	gosub print_welcome
        ;Print Looking for Windows message
	print cr cr cr winlook cr
	onerror gosub win_drive_error

	set status 0			;If drive exists, go to that drive.
	size var070 status
	if status = 0 goto win_retry
	changedrive var070
	cd \

	exist var071 status		    ;If dir exists, go to that dir.
	if status != 2 goto win_retry
	cd var071

        ;Begin checking for file existance
	exist win_file1 status
	if status = -1 goto win_retry       ;file doesn't exist?

	exist win_file2 status
	if status = -1 goto win_retry       ;file doesn't exist?

	; If file WIN.INI exists in given directory, use it,
	; otherwise ask user where it is
	exist win_ini status
	if status = 1 set var072 var070     ;file exists, use windows drive
	if status = 1 set var073 var071     ;file exists, use windows directory
	if status != 1 gosub get_winini     ;Doesn't exist ask where it is

        ; If installing for NETWARE, must get path to windows file SYSTEM.INI 
	; and windows directory SYSTEM (for drivers), otherwise, goto end.
	if net_type != net_netware goto find_win_end

	; If file SYSTEM.INI exists in given directory, use it,
	; otherwise ask user where it is
	exist system_ini status
	if status = 1 set var172 var070     ;file exists, use windows drive
	if status = 1 set var173 var071     ;file exists, use windows directory
	if status != 1 gosub get_sysini     ;Doesn't exist ask where it is

	goto find_win_end

win_retry                                 ;reprint message to give user
	move 0, -3                      ;another chance

	set var022 3

        set var008 win_name       ;prepare print strings
        set var100 var070
        set var101 var071

 	set var018 box_stitle1
 	set var019 box_stitle2
 	set var020 box_stitle3
 	set var021 box_stitle4

	set var014 need_file1
	set var015 need_file2
	set var016 need_file3
	set var017 need_file4

	set var023 var070
        strcat var023 var071
	gosub get_info
	mid var070 var023 1 2
	mid var071 var023 3 62

	gosub rebuild_screen
	goto find_windows

find_win_end
	changedrive var003                       ;restore drive and path
	cd app_inst
return

get_ov 
; Purpose - to collect openview location from user
;
; created 10/04/89 - Tamra Perez
;
; sets:
;    var074 = Drive where Openview exists, w/colon
;    var075 = Directory where Openview exists, w/o backslash
;
	set var022 1            
	set var008 ov_name

	set var014 box_dep1
	set var015 box_dep2
	set var016 box_dep3
	set var017 box_dep4

 	set var018 box_stitle1
 	set var019 box_stitle2
 	set var020 box_stitle3
 	set var021 box_stitle4

	set var023 defdrive
        strcat var023 colon OV_location
	gosub get_info
	mid var074 var023 1 2
	mid var075 var023 3 62

	gosub find_ov
return

find_ov
; Purpose - to determine if Openview exists
;
; Created 10/04/89 - Tamra Perez

	gosub print_welcome
        ;Print Looking for OpenView message
        print cr cr cr ovlook cr
	onerror gosub win_drive_error

	set status 0			;If drive exists, go to that drive.
	size var074 status
	if status = 0 goto ov_retry
	changedrive var074
	cd \

	exist var075 status		    ;If dir exists, go to that dir.
	if status != 2 goto ov_retry
	cd var075

        ;Begin checking for file existance
	exist ov_file1 status
	if status = -1 goto ov_retry       ;file doesn't exist?

        if ov_file2 = "" goto find_ov_end  ;exit if done
        exist ov_file2 status
        if status = -1 goto ov_retry

        if ov_file3 = "" goto find_ov_end
        exist ov_file3 status
        if status = -1 goto ov_retry
        goto find_ov_end             ;successful exit

ov_retry                                 ;reprint message to give user
	move 0, -3                      ;another chance

	set var022 3

        set var008 ov_name       ;prepare print strings
        set var100 var074
        set var101 var075

 	set var018 box_stitle1
 	set var019 box_stitle2
 	set var020 box_stitle3
 	set var021 box_stitle4

	set var014 need_file1
	set var015 need_file2
	set var016 need_file3
	set var017 need_file4

	set var023 var074
        strcat var023 var075
	gosub get_info
	mid var074 var023 1 2
	mid var075 var023 3 62

	gosub rebuild_screen

	goto find_ov

find_ov_end
        ; Check if enough disk space on this drive
        free var074 amount
        valtostr amount_str amount
        if amount > val_disk_space goto enough_space
		mid mbyte str_disk_space 1 1
		mid kbyte str_disk_space 3 1
        set var014 "Warning:  You will need "
        strcat var014 mbyte kbyte "00 KB of disk space for"
		set var015 "          !2."
        set var016 "          You only have "
        strcat var016 amount_str " KB on drive !74"
        set var017 "You may Continue if installing over an old copy."
		set var023 ""		; Edit string is blank
		set var022 2		; Only choices are Continue/Quit
		gosub get_info
     enough_space

        changedrive var003                       ;restore drive and path
        cd app_inst
return

check_ver
;
; purpose - To ensure that the correct versions of Officeshare and
;           OpenView are installed.
;
; Created 10/02/89 - Tamra Perez
        onerror set dummy ""           ;dummy to avoid faulty error call 
        set vers_prog var003			; Build Full path to
        strcat vers_prog "\install\findstr.exe"	; executable findstr.exe

        if req_ovrun = "" goto check_ovdraw
        print cr "Checking version of " ov_name " . . ." cr
        set version_string ""                   ;initialize string
        envstr version_string                   ;"what" string from OV run
        set file_name var074                    ;path to netif
        strcat file_name var075 bslash ov_file1
        print "     " file_name cr
        run vers_prog file_name
        strlen version_string version_string_len

        if version_string_len <= 0 goto check_run_err

        ; extract version number and compare with required version
        gosub get_a_dd_dd
        if extract_ver >= req_ovrun goto check_ovdraw

check_run_err
        set var008 var002                 ;HubManager version
        strcat var008 " " var001

        set var100 ov_name                ;required SW name
        set var101 req_ovrun              ;required version
        goto check_error

check_ovdraw
        if req_ovdraw = "" goto check_netif
        set version_string ""               ;initialize string
        envstr version_string               ;"what" string from OV draw
        set file_name var074                ;path to ovdraw
        strcat file_name var075 bslash ov_file2
        print "     " file_name cr
        run vers_prog file_name
        strlen version_string version_string_len

        if version_string_len <= 0  goto check_draw_err

        ; extract version number and compare with required version
        gosub get_a_dd_dd
        if extract_ver >= req_ovdraw goto check_netif

check_draw_err
        set var008 var002                 ;HubManager version
        strcat var008 " " var001

        set var100 ov_name                ;required SW 
        set var101 req_ovdraw             ;required version
        goto check_error

check_netif
        if net_type != net_tcpip goto check_ver_end
        if app_name = emulatr goto check_ver_end
        if req_arpa_f1 = "" goto check_ver_end
        print cr "Checking version of " OfficeShare " . . ." cr
        set driver_dir var076               ;path to netif
        strcat driver_dir var077 arpa_dir1
        set arpa_file driver_dir
        strcat arpa_file req_arpa_f1
        exist arpa_file status
        if status = 1 goto found_req_arpa
        set driver_dir var076               ;path to netif
        strcat driver_dir var077 arpa_dir2
        set arpa_file driver_dir
        strcat arpa_file req_arpa_f1
        exist arpa_file status
        if status != 1 goto check_net_err
     found_req_arpa
	upshift arpa_file
	print "     " arpa_file cr
        set version_string ""                    ;initialize string
        envstr version_string                    ;"what" string
        run vers_prog arpa_file
        strlen version_string version_string_len

        if version_string_len <= 0 goto check_net_err

        ; extract version number and compare with required version
        gosub get_a_dd_dd
        if extract_ver >= req_arpa_v1 goto check_ver_end

check_net_err
        set var008 var002                     ;HubManager version
        strcat var008 " " var001

        set var100 Officeshare                ;required SW name
        set var101 req_netif_rls              ;required version

check_error
;       cls                                   ;Print version error
;       pos app_err_margin,box_title
        mov app_err_margin,0
	print cr version_err1 cr
	move app_err_margin,0
	print version_err2 cr 
	move app_err_margin,0		    
	print version_err3 cr cr
	move app_err_margin,0
	print version_err4 cr cr cr
        
        set status -1
        goto quit        
            
check_ver_end
return

update_progman_ini
     ; Purpose: to add a line to PROGMAN.INI for the group file.
     set group_prefix "Group"

     ; Build path to PROGMAN.INI file for updating,
     ; Check existence and print error if not a file.
     set upfile var070
     strcat upfile var071 bslash progman_ini
     exist upfile status
     if status != 1 goto progman_error

     ; Backup old PROGMAN.INI file
     set bk_drive var072
     set bk_dir var073
     set bk_ofile progman_ini
     set bk_nfile "PROGMAN.BAK"
     gosub backup_file

     ; Check if PROGMAN.INI section for Group Files should be UpShifted
     ; Windows 3.00a used [Groups] and Windows 3.1 uses [GROUPS]
     set test_string group_hdr
     strcat test_string group_prefix "1="
     set ret_string ""
     update upfile test_string 15 ret_string
     if ret_string != "" goto lower_group
     ; No match for '[Groups]Group1=', so see if a match for '[GROUPS]GROUP1='
     upshift test_string
     set ret_string ""
     update upfile test_string 15 ret_string
     if ret_string != "" upshift group_hdr

  lower_group
     ; Delete old entry if it exists
     set del_prog var003
     strcat del_prog "\install\delline.exe"
     run del_prog upfile group_hdr group_file

     ; Search through PROGMAN.INI to find next available group number
     ; This is done using the UPDATE 15 and checking to see if that
     ; group number has an entry.  There is a maximum number of groups
     ; to search before reporting an error.
     set num_val 0
  next_grp_num
     add 1 num_val
     if num_val > 25 goto progman_error
     valtostr num_str num_val
     set group_num group_hdr
     strcat group_num group_prefix num_str "="
     set cur_value ""
     update upfile group_num 15 cur_value
     if cur_value != "" goto next_grp_num

     ; group_num now has the HEADER and group number entry that is not being
     ; used in PROGMAN.INI.  Use this for the new group file.
     print "Adding group file " group_file " to " progman_ini cr
     set mod_string group_num
     strcat mod_string var070 var071 bslash group_file
     update upfile mod_string 11
     goto end_upprogman

     ; ERROR: inform user that update was not performed.
  progman_error
     print "     Unable to update " upfile cr

  end_upprogman
return

update_win_ini
;purpose - to modify [OpenView] and [OpenviewApps] sections of
;win.ini all at once without use of mdini.exe or addwin.ini files.
;
        set bk_drive var072
        set bk_dir var073
        set bk_ofile win_ini
        set bk_nfile "WIN.BAK"
	gosub backup_file
	print "Inserting entries in WIN.INI . . ." cr

        set var008 var072      			;build path to win.ini
        strcat var008 var073 bslash win_ini

;04/11/91 RLD - Added this section to remove references to old mgr software.

	set app_key_old app_key_oldhm                  ;ptr to old HM.
	   gosub comment_old_mgr
	set app_key_old app_key_oldad                  ;ptr to old AD.
	   set add_string app_hdr1
           set ret_string null
           strcat add_string app_key4
           update var008 add_string 15 ret_string
           if ret_string = Null gosub comment_old_mgr
	set app_key_old app_key_oldbm                   ;ptr to old BM.
	   gosub comment_old_mgr

        set add_string app_hdr                         ;increase symbols.
        strcat add_string app_section_msym		; in [Openview]
        update var008 add_string 11

        set add_string app_hdr1           ;ptr to AD run,draw,admin files
        strcat add_string app_key1 "," var004 var005 app_prv bslash ov_draw_app ","
        update var008 add_string 11

	if app_name != hubmgr goto real_bridges
	; add blank entries for the bridge products
	set add_string app_hdr1                        ;BRG1010 entry
	strcat add_string app_key2 ""                  ;set to blank
	update var008 add_string 11
	set add_string app_hdr1                        ;BRGREM entry
	strcat add_string app_key3 ""                  ;set to blank
	update var008 add_string 11
	goto hub_entries

     real_bridges
        set add_string app_hdr1                 	;ptr to BRG1010 files.
        strcat add_string app_key2 var004 var005 app_prv bslash ov_run_app2
	update var008 add_string 11

        set add_string app_hdr1				;ptr to BRGREM files.
        strcat add_string app_key3 var004 var005 app_prv bslash ov_run_app3
	update var008 add_string 11

     hub_entries
        set add_string app_hdr1                 	;ptr to HUB12 files.
        strcat add_string app_key4 var004 var005 app_prv bslash ov_run_app4
	update var008 add_string 11

	set add_string app_hdr1                         ;ptr to HUB12B files.
	strcat add_string app_key5 var004 var005 app_prv bslash ov_run_app5
	update var008 add_string 11

	set add_string app_hdr1                         ;ptr to HUB48 files.
	strcat add_string app_key6 var004 var005 app_prv bslash ov_run_app6
	update var008 add_string 11

	set add_string app_hdr1                         ;ptr to HUBF files.
	strcat add_string app_key7 var004 var005 app_prv bslash ov_run_app7
	update var008 add_string 11

	set add_string app_hdr1                         ;ptr to HUBT files.
	strcat add_string app_key8 var004 var005 app_prv bslash ov_run_app8
	update var008 add_string 11

        set add_string app_hdr1				;ptr to SNMPMGR files
        strcat add_string app_key9 var004 var005 app_prv bslash ov_run_app9
        update var008 add_string 11

        ; In order to run GRAPHS on devices, GRAPHCTS must be started after
	; the executable for that device.  Therefore, GRAPHCTS Must be the
	; last entry in the section for GRAPHS to run on all devices.
	; So, we delete the GRAPHCTS line and add it last (to the bottom).
	set del_prog var003				; Build full path
	strcat del_prog "\install\delline.exe"		; to executable
	run del_prog var008 app_hdr1 app_key10
        set add_string app_hdr1 	                ;ptr to GRAPHCTS files
        strcat add_string app_key10 var004 var005 app_prv bslash ov_run_app10
        update var008 add_string 11

	set app_keyx app_key11				;ptr to Blank Line.
	gosub add_pointers

        set add_string app_hdr2                         ;HM Files entry.
        strcat add_string app_section_file var004 var005 app_prvhid bslash
        update var008 add_string 11

        set add_string app_hdr2                         ;EventFile entry.
        strcat add_string event_file var004 var005 app_prvhid bslash event_log
        update var008 add_string 11

        set add_string app_hdr2                         ;Network Log entry.
        strcat add_string app_netlog var004 var005 app_prvhid bslash net_log
        update var008 add_string 11

        set add_string app_hdr2                         ;ADErrorLogName entry.
        strcat add_string app_errlog var004 var005 app_prvhid bslash ov_adlog
	update var008 add_string 11

        set add_string app_hdr2                   ;install GraphLogName entry.
        strcat add_string graph_log var004 var005 app_prvhid bslash glog_name
	update var008 add_string 11

        set add_string app_hdr2                         ;HM Mibs entry.
        strcat add_string app_section_mibs var004 var005 app_mibsdir bslash
        update var008 add_string 11

	set add_string app_hdr2                         ;MIB Browse entry.
        strcat add_string browse_mib var004 var005 app_mibsdir bslash sys_mib
        update var008 add_string 11

        set add_string app_hdr2
        strcat add_string app_winini11
        update var008 add_string 11

        set add_string app_hdr2			;NetworkMaxDiscoverTime entry
        if net_type = net_tcpip strcat add_string app_ip_timeout
        if net_type = net_netware strcat add_string app_ipx_timeout
        update var008 add_string 11

        set add_string app_hdr			;PropagateStatus entry
        strcat add_string app_prop_stat
        update var008 add_string 11

        if app_name != emulatr goto end_upd_win		;Default map entry
        set add_string app_hdr
        strcat add_string app_section_map
        update var008 add_string 15 cur_value
        if cur_value != "" goto end_upd_win		;Only if not set
        strcat add_string var074 var075 "\devmgr"
        if net_type = net_tcpip strcat add_string "\samplip"
        if net_type = net_netware strcat add_string "\samplipx"
        update var008 add_string 11

     end_upd_win
return

comment_old_mgr
	set add_string app_hdr1                         ;comment old Mgr ptr.
	set ret_string null
	strcat add_string app_key_old
	update var008 add_string 15 ret_string
	if ret_string = Null goto end_comment
	if ret_string = "" goto end_comment
	    set new_string app_hdr1
	    if app_key_old = app_key_oldhm set app_key_old "HMOLD="
	    if app_key_old = app_key_oldad set app_key_old "ADOLD="
	    if app_key_old = app_key_oldbm set app_key_old "BM2OLD="
	    strcat new_string ";" app_key_old ret_string
	    strcat add_string ""
	    update var008 add_string 11
	    update var008 new_string 11
end_comment
return

add_pointers
	set add_string app_hdr1                        ;ptr to execute files.
	set ret_string null
	strcat add_string app_keyx
	update var008 add_string 15 ret_string
	if ret_string = Null update var008 add_string 11
return

add_flag
        set add_string app_hdr2                         ;Add flag to win.ini.
        strcat add_string flag_to_add
        update var008 add_string 11
return

get_d_dd
; Purpose: To extract the first occurance of D.DD (where D is any digit) from
; a string.  Used to extract versions from a string.
;
; Input:  version_string    - string containing the version to extract
; Output: extract_ver       - string containing only the D.DD version

     strlen version_string version_string_len
     set char_num 0

  loop_d_dd
     ; Initialize the FOUND string to NULL and move to next character
     set extract_ver ""
     add 1 char_num

     ; Calculate chars left in string, exit if not enough
     set chars_left version_string_len
     sub char_num chars_left
     if chars_left < 3 goto end_d_dd

     ; Extract enough characters for the version string
     mid extract_ver version_string char_num 4

     ; Check CHAR1 for DIGIT
     mid ch1 extract_ver 1 1
     if ch1 < "0" goto loop_d_dd
     if ch1 > "9" goto loop_d_dd

     ; Check CHAR2 for a dot "."
     mid ch2 extract_ver 2 1
     if ch2 != "." goto loop_d_dd

     ; Check CHAR3 for DIGIT
     mid ch3 extract_ver 3 1
     if ch3 < "0" goto loop_d_dd
     if ch3 > "9" goto loop_d_dd

     ; Check CHAR4 for DIGIT
     mid ch4 extract_ver 4 1
     if ch4 < "0" goto loop_d_dd
     if ch4 > "9" goto loop_d_dd

     ; Everything compared OK, FOUND a match for D.DD
  end_d_dd
return


get_a_dd_dd
; Purpose: To extract the first occurance of A.DD.DD (where A is an uppercase
; character and D is any digit) from a string.  Used to extract versions from
; a string.
;
; Input:  version_string    - string containing the version to extract
; Output: extract_ver       - string containing only the A.DD.DD version

     strlen version_string version_string_len
     set char_num 0

  loop_a_dd_dd
     ; Initialize the FOUND string to NULL and move to next character
     set extract_ver ""
     add 1 char_num

     ; Calculate chars left in string, exit if not enough
     set chars_left version_string_len
     sub char_num chars_left
     if chars_left < 6 goto end_a_dd_dd

     ; Extract enough characters for the version string
     mid extract_ver version_string char_num 7

     ; Check CHAR1 for Uppercase Alpha Char 
     mid ch1 extract_ver 1 1
     if ch1 < "A" goto loop_a_dd_dd
     if ch1 > "Z" goto loop_a_dd_dd

     ; Check CHAR2 for a dot "."
     mid ch2 extract_ver 2 1
     if ch2 != "." goto loop_a_dd_dd

     ; Check CHAR3 for a DIGIT
     mid ch3 extract_ver 3 1
     if ch3 < "0" goto loop_a_dd_dd
     if ch3 > "9" goto loop_a_dd_dd

     ; Check CHAR4 for a DIGIT
     mid ch4 extract_ver 4 1
     if ch4 < "0" goto loop_a_dd_dd
     if ch4 > "9" goto loop_a_dd_dd

     mid ch5 extract_ver 5 1
     if ch5 != "." goto loop_a_dd_dd

     ; Check CHAR6 for a DIGIT
     mid ch6 extract_ver 6 1
     if ch6 < "0" goto loop_a_dd_dd
     if ch6 > "9" goto loop_a_dd_dd

     ; Check CHAR7 for a DIGIT
     mid ch7 extract_ver 7 1
     if ch7 < "0" goto loop_a_dd_dd
     if ch7 > "9" goto loop_a_dd_dd

     ; Everything compared OK, FOUND a match for A.DD.DD
  end_a_dd_dd
return

install_app_symbol
;purpose to add application defined symbols into openview libraries.
;
;input: none
;output: none
	print cr "Installing pictures in HP OpenView table . . ." cr

	set file_name ""
	set key_string app_hdr
	strcat key_string ov_symbol_key
	update var008 key_string 15 file_name
	if file_name != "" goto symbol_inst
        set file_name var074                  ;point file_name to directory
        strcat file_name var075 ov_symbol_dir bslash ;containing ov symbol file
	print "   HP OpenView Symbols Directory is " file_name cr

symbol_inst
	changedrive file_name
	cd file_name

	set target_name ""
	set key_string app_hdr
	strcat key_string ov_symbol_fkey
	update var008 key_string 15 target_name     
	if target_name != "" goto symbol_inst2
	set target_name file_name
        strcat target_name ov_symbol_file    ;fname to point at symbol

symbol_inst2
	set prog_name file_name
	strcat prog_name "symbol.exe"
	strcat file_name "symbol.inf"

	run prog_name "-f" target_name "-c" file_name
	return

update_mskermit

	print cr "Adding a line to MSKERMIT.INI . . ." cr

	changedrive var003		; add a line to MSKERMIT.INI file
	cd \
	cd app_inst

	set msk_file var076                     ; Check ARPA Only path
        strcat msk_file var077 mskermit1
        exist msk_file status
        if status = 1 goto upd_msk_file

	set msk_file var076                     ; Check LANMAN path
        strcat msk_file var077 mskermit2
        exist msk_file status
        if status != 1 goto end_upd_msk

     upd_msk_file
	print "     " msk_file
	set addprog var003			; Build path to executable
	strcat addprog "\install\addline.exe"	; file addline.exe
	run addprog msk_file msk_line
     end_upd_msk
return
