# Main menu for sample client # # $Id: menu.mgl,v 1.3 2003/01/25 23:29:44 gkminix Exp $ const BOOTP_FLASH = 130; # BOOTP tag for flash programming password # Read in a password. Since we don't want to let the user input appear # on the screen while typing the password we have to do reading it ourselves # instead of using a runtime routine (which echos the input data) function getpasswd (bootp, x, y : integer) : boolean; const pwdlen = 20; var s : string[pwdlen]; x1, i : integer; ch : char; begin i := 0; s := ""; x1 := x; # Read in the password while i < 20 do begin get ch at [x1, y]; if (ch = '\b') and (i > 0) then begin x1 := pred(x1); i := pred(i); s[i] := '\0'; print ' ' at [x1, y] end else if (ch >= ' ') and (ch <= chr(127)) then begin print '*' at [x1, y]; x1 := succ(x1); i := succ(i); s := s + ch end else if (ch = '\r') break end; # Check that the password is correct getpasswd := true; if s <> $[bootp] then begin cls; print "\033[41mInvalid password\033[40m" at [20, 12]; print "Press any key to continue..." at [20, 15]; get ch; getpasswd := false end end; # Main screen which prints and handles the menu screen main; var i : integer; root : string; doflash : boolean; begin # Set default parameters root := $[BOOTP_ROOTPATH]; if root.len = 0 root := "/tftpboot/root-" + hostname; doflash := ($[BOOTP_FLASH] <> ""); # Print menu header cls; print "\033[44m"; print chr(201) + chr(205)*50 + chr(187) at [10,2]; i := 3; repeat print chr(186) + chr(32)*50 + chr(186) at [10,i]; i := i + 1; until i >= 8; print chr(200) + chr(205)*50 + chr(188) at [10,8]; print "Boot menu for " + hostname at [20,5]; print "\033[40m"; # Print menu itself print "1 - Linux from server" at [15,11]; print "2 - MS-DOS from server" at [15,12]; print "3 - MS-DOS from local disk" at [15,13]; print "4 - SCO Unix from local disk" at [15,14]; if doflash then print "9 - Progam Flash EPROM" at [15,15]; # Let the user enter his/her selection print "Enter selection:" at [15,17]; select at [32,17] with timeout 10 of item 1: print "Loading Linux from server" at [0,19]; gotoxy [0,21]; load root + "/bootImage-linux" from "gkminix"; item 2: print "Loading MS-DOS from server" at [0,19]; gotoxy [0,21]; load root + "/bootImage-dos" from "gkminix"; item 3: print "Loading MS-DOS from local disk" at [0,19]; gotoxy [0,21]; load "/dev/hda1"; item 4: print "Loading SCO Unix from local disk" at [0,19]; gotoxy [0,21]; load "/dev/hda4"; item 9: if doflash then begin print "Enter password:" at [15, 18]; if not getpasswd(BOOTP_FLASH, 31, 18) then restart; print "Loading FlashCard programmer" at [0,20]; gotoxy [0,22]; load root + "/bootImage-flash" from "gkminix" end; default: print "Loading MS-DOS from local disk" at [0,19]; gotoxy [0,21]; load "/dev/hda1"; end; # Should never happen restart; end.