(2006-08-06) rescue-bootcd
This commit is contained in:
12
extra/syslinux-3.09/menu/CHANGES
Normal file
12
extra/syslinux-3.09/menu/CHANGES
Normal file
@@ -0,0 +1,12 @@
|
||||
Changes in v1.1
|
||||
---------------
|
||||
* Additional handler type: Keys handler
|
||||
* Menuitem handlers now have a return value of type t_handler_return.
|
||||
For all simple cases, you just return ACTION_VALID or ACTION_INVALID
|
||||
(For some types of menu items, handlers are ignored, and for
|
||||
others the return value is ignored)
|
||||
* add_menu takes an extra argument (to better control memory footprint)
|
||||
You can just set it to -1 to choose the default value
|
||||
* Now the menu system support long menu's using scroll bars.
|
||||
* Support for passwords and context sensitive help is added.
|
||||
|
||||
20
extra/syslinux-3.09/menu/HISTORY
Normal file
20
extra/syslinux-3.09/menu/HISTORY
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
GCC & 32-bit code
|
||||
-----------------
|
||||
Due to the limitations of the COM file format,
|
||||
(64KB limit on memory footprint) the code has been changed
|
||||
so that the code compiles to a 32-bit COMBOOT program.
|
||||
Since the code makes use of BIOS calls, this code cannot be
|
||||
compiled into a format which can execute under Linux. As a
|
||||
side effect, there is no nice way to debug this code. In order
|
||||
to debug this code, you will have to run the code under syslinux.
|
||||
|
||||
GCC & 16-bit code
|
||||
-----------------
|
||||
The code was ported to GCC by Peter Anvin.
|
||||
|
||||
OpenWatcom & 16-bit code
|
||||
------------------------
|
||||
Originally this code was written for the Openwatcom compiler
|
||||
and generated .COM files, which could execute under DOS as well as
|
||||
SYSLINUX.
|
||||
330
extra/syslinux-3.09/menu/MANUAL
Normal file
330
extra/syslinux-3.09/menu/MANUAL
Normal file
@@ -0,0 +1,330 @@
|
||||
Overview of writing code using the menu system
|
||||
----------------------------------------------
|
||||
|
||||
This file contains implementation and developer documentation.
|
||||
For simple cases, you should start by using simple.c as a template.
|
||||
complex.c illustrates most of the features available in the menu system.
|
||||
|
||||
Menu Features currently supported are:
|
||||
* menu items,
|
||||
* submenus,
|
||||
* disabled items,
|
||||
* checkboxes,
|
||||
* invisible items (useful for dynamic menus), and
|
||||
* Radio menus,
|
||||
* Context sensitive help
|
||||
* Authenticated users
|
||||
|
||||
The keys used are:
|
||||
|
||||
* Arrow Keys, PgUp, PgDn, Home, End Keys
|
||||
* Space to switch state of a checkbox
|
||||
* Enter to choose the item
|
||||
* Escape to exit from it
|
||||
* Shortcut keys
|
||||
|
||||
1. Overview
|
||||
-----------
|
||||
|
||||
The code usually consists of many stages.
|
||||
|
||||
* Configuring the menusytem
|
||||
* Installing global handlers [optional]
|
||||
* Populating the menusystem
|
||||
* Executing the menusystem
|
||||
* Processing the result
|
||||
|
||||
1.1 Configuring the menusystem
|
||||
------------------------------
|
||||
This includes setting the window the menu system should use,
|
||||
the choice of colors, the title of the menu etc. In most functions
|
||||
calls, a value of -1 indicates that the default value be used.
|
||||
For details about what the arguments are look at function
|
||||
declarations in menu.h
|
||||
|
||||
<code>
|
||||
// Choose the default title and setup default values for all attributes....
|
||||
init_menusystem(NULL);
|
||||
set_window_size(1,1,23,78); // Leave one row/col border all around
|
||||
|
||||
// Choose the default values for all attributes and char's
|
||||
// -1 means choose defaults (Actually the next 4 lines are not needed)
|
||||
set_normal_attr (-1,-1,-1,-1);
|
||||
set_status_info (-1,-1);
|
||||
set_title_info (-1,-1);
|
||||
set_misc_info(-1,-1,-1,-1);
|
||||
</code>
|
||||
|
||||
1.2 Populating the menusystem
|
||||
-----------------------------
|
||||
This involves adding a menu to the system, and the options which
|
||||
should appear in the menu. An example is given below.
|
||||
|
||||
<code>
|
||||
MAINMENU = add_menu(" Menu Title ",-1);
|
||||
CHECKED = 1;
|
||||
add_item("option1","Status 1",OPT_RUN,"kernel1 arg1=val1",0);
|
||||
add_item("selfloop","Status 2",OPT_SUBMENU,NULL,MAINMENU);
|
||||
add_sep();
|
||||
add_item("checkbox,"Checkbox Info",OPT_CHECKBOX,NULL,CHECKED);
|
||||
add_item("Exit ","Status String",OPT_EXITMENU,NULL,0);
|
||||
// "any string" not used by the menu system, useful for storing kernel names
|
||||
// NUM = index of submenu if OPT_SUBMENU,
|
||||
// 0/1 default checked state if OPT_CHECKBOX
|
||||
// unused otherwise.
|
||||
</code>
|
||||
|
||||
The call to add_menu has two arguments, the first being the title of
|
||||
the menu and the second an upper bound on the number of items in the menu.
|
||||
Putting a -1, will use the default (see MENUSIZE in menu.h). If you try
|
||||
to add more items than specified, the extra items will not appear in
|
||||
the menu. The accuracy of this number affects the memory required
|
||||
to run the system. Currently the code compiles to a .COM file which
|
||||
has a 64K limit on memory used.
|
||||
|
||||
The call to add_item has five arguments.
|
||||
The first argument is the text which appears in the menu itself.
|
||||
The second argument is the text displayed in the status line.
|
||||
The third argument indicates the type of this menuitem. It is one of
|
||||
the following
|
||||
|
||||
* OPT_RUN : executable content
|
||||
* OPT_EXITMENU : exits menu to parent
|
||||
* OPT_SUBMENU : if selected, displays a submenu
|
||||
* OPT_CHECKBOX : associates a boolean with this item which can be toggled
|
||||
* OPT_RADIOMENU: associates this with a radio menu.
|
||||
After execution, the data field of this item will point
|
||||
to the option selected.
|
||||
* OPT_SEP : A menu seperator (visually divide menu into parts)
|
||||
* OPT_RADIOITEM: this item is one of the options in a RADIOMENU
|
||||
* OPT_INACTIVE : A disabled item (user cannot select this)
|
||||
* OPT_INVISIBLE: This item will not be displayed.
|
||||
|
||||
The fourth argument is the value of the data field. This pointer is just
|
||||
stored. In case of a radiomenu this points to the menuitem chosen (Dont
|
||||
forget to typecase this pointer to (t_menuitem *) when reading this info).
|
||||
|
||||
The fifth argument is a number whose meaning depends on the type of the
|
||||
item. For a CHECKBOX it should be 0/1 setting the initial state of the
|
||||
checkbox. For a SUBMENU it should be the index of the menu which should
|
||||
be displayed if this option is chosen. For a RADIOMENU it should be the
|
||||
index of the menu which contains all the options (All items in that menu
|
||||
should not of type RADIOITEM are ignored). For all other types, this
|
||||
argument has no meaning at all.
|
||||
|
||||
A call to add_sep is a convenient shorthand for calling add_item
|
||||
with the type set to OPT_SEP.
|
||||
|
||||
1.3 Executing the menusystem
|
||||
----------------------------
|
||||
This is the simplest of all. Just call showmenus, with the index
|
||||
of the main menu as its argument. It returns a pointer to the menu
|
||||
item which was selected by the user.
|
||||
|
||||
<code>
|
||||
choice = showmenus(MAIN); // Initial menu is the one with index MAIN
|
||||
</code>
|
||||
|
||||
1.4 Processing the result
|
||||
-------------------------
|
||||
This pointer will either be NULL (user hit Escape) or always point
|
||||
to a menuitem which can be "executed", i.e. it will be of type OPT_RUN.
|
||||
Usually at this point, all we need to do is to ask syslinux to run
|
||||
the command associated with this menuitem. The following code executes
|
||||
the command stored in choice->data (there is no other use for the data
|
||||
field, except for radiomenu's)
|
||||
|
||||
<code>
|
||||
if (choice)
|
||||
{
|
||||
if (choice->action == OPT_RUN)
|
||||
{
|
||||
if (syslinux) runcommand(choice->data);
|
||||
else csprint(choice->data,0x07);
|
||||
return 1;
|
||||
}
|
||||
csprint("Error in programming!",0x07);
|
||||
}
|
||||
</code>
|
||||
|
||||
2. Advanced features
|
||||
--------------------
|
||||
Everycall to add_item actually returns a pointer to the menuitem
|
||||
created. This can be useful when using any of the advanced features.
|
||||
|
||||
2.1 extra_data
|
||||
--------------
|
||||
For example, every menuitem has an "extra_data" field (a pointer)
|
||||
which the user can use to point any data he/she pleases. The menusystem
|
||||
itself does not use this field in anyway.
|
||||
|
||||
2.2 helpid
|
||||
----------
|
||||
Every item also has a field called "helpid". It is meant to hold some
|
||||
kind of identifier which can be referenced and used to generate
|
||||
a context sensitive help system. This can be set after a call to
|
||||
add_item as follows
|
||||
<code>
|
||||
add_item("selfloop","Status 2",OPT_SUBMENU,NULL,MAINMENU);
|
||||
set_item_options('A',4516);
|
||||
</code>
|
||||
|
||||
The first is the shortcut key for this entry. You can put -1 to ensure
|
||||
that the shortcut key is not reset. The second is some unsigned integer.
|
||||
If this value is 0xFFFF, then the helpid is not changed.
|
||||
|
||||
2.3 Installing global handlers
|
||||
------------------------------
|
||||
It is possible to register handlers for the menu system. These are
|
||||
user functions which are called by the menusystem in certain
|
||||
situations. Usually the handlers get a pointer to the menusystem
|
||||
datastructure as well as a pointer to the current item selected.
|
||||
Some handlers may get additional information. Some handlers are
|
||||
required to return values while others are not required to do so.
|
||||
|
||||
Currently the menusystem support three types of global handlers
|
||||
* timeout handler
|
||||
* screen handler
|
||||
* keys handler
|
||||
|
||||
2.3.1 timeout handler
|
||||
---------------------
|
||||
This is installed using a call to "reg_ontimeout(fn,numsteps,stepsize)"
|
||||
function. fn is a pointer to a function which takes no arguments and
|
||||
returns one of CODE_WAIT, CODE_ENTER, CODE_ESCAPE. This function is
|
||||
called when numsteps*stepsize Centiseconds have gone by without any
|
||||
user input. If the function returns CODE_WAIT then the menusystem
|
||||
waits for user input (for another numsteps*stepsize Centiseconds). If
|
||||
CODE_ENTER or CODE_ESCAPE is returned, then the system pretends that
|
||||
the user hit ENTER or ESCAPE on the keyboard and acts accordingly.
|
||||
|
||||
2.3.2 Screen handler
|
||||
--------------------
|
||||
This is installed using a call to "reg_handler(HDLR_SCREEN,fn)". fn is
|
||||
a pointer to a function which takes a pointer to the menusystem
|
||||
datastructure and the current item selected and returns nothing.
|
||||
This is called everytime a menu is drawn (i.e. everytime user changes
|
||||
the current selection). This is meant for displaying any additional
|
||||
information which reflects the current state of the system.
|
||||
|
||||
2.3.3 Keys handler
|
||||
------------------
|
||||
This is installed using a call to "reg_handler(HDLR_KEYS,fn)". fn is
|
||||
a pointer to a function which takes a pointer to the menusystem
|
||||
datastructure, the current item and the scan code of a key and returns
|
||||
nothing. This function is called when the user presses a key which
|
||||
the menusystem does not know to dealwith. In any case, when this call
|
||||
returns the screen should not have changed in any way. Usually,
|
||||
one can change the active page and display any output needed and
|
||||
reset the active page when you return from this call.
|
||||
|
||||
complex.c implements a key_handler, which implements a simple
|
||||
context sensitive help system, by displaying the contents of a
|
||||
file whose name is based on the helpid of the active item.
|
||||
|
||||
Also, complex.c's handler allows certain users to make changes
|
||||
to edit the commands associated with a menu item.
|
||||
|
||||
2.4 Installing item level handlers
|
||||
----------------------------------
|
||||
In addition to global handlers, one can also install handlers for each
|
||||
individual item. A handler for an individual item is a function which
|
||||
takes a pointer to the menusystem datastructure and a pointer to the
|
||||
current item and return a structure of type t_handler_return. Currently
|
||||
it has two bit fields "valid" and "refresh".
|
||||
|
||||
This handler is called when the user hits "enter" on a RUN item, or
|
||||
changes the status of a CHECKBOX, or called *after* a radio menu choice
|
||||
has been set. In all other cases, installing a handler has no effect.
|
||||
|
||||
The handler can change any of the internal datastructures it pleases.
|
||||
For e.g. in a radiomenu handler, one can change the text displayed
|
||||
on the menuitem depending on which choice was selected (see complex.c
|
||||
for an example). The return values are ignored for RADIOMENU's.
|
||||
|
||||
In case of RUN items: the return values are used as follows. If the
|
||||
return value of "valid" was false, then this user choice is ignored.
|
||||
This is useful if the handler has useful side effects. For e.g.
|
||||
complex.c has a Login item, whose handler always return INVALID. It
|
||||
sets a global variable to the name of the user logged in, and enables
|
||||
some menu items, and makes some invisible items visible.
|
||||
|
||||
* If the handler does not change the visibility status of any items,
|
||||
the handler should set "refresh" to 0.
|
||||
* If the handler changes the visibility status of items in the current
|
||||
menu set "refresh" to 1.
|
||||
* If you are changing the visibility status of items in menu's currently
|
||||
not displayed, then you can set "refresh" to 0.
|
||||
* Changing the visibility status of items in another menu
|
||||
which is currently displayed, is not supported. If you do it,
|
||||
the screen contents may not reflect the change until you get to the
|
||||
menu which was changed. When you do get to that menu, you may notice
|
||||
pieces of the old menu still on the screen.
|
||||
|
||||
In case of CHECKBOXES: the return value of "valid" is ignored. Because,
|
||||
the handler can change the value of checkbox if the user selected value
|
||||
is not appropriate. only the value of "refresh" is honored. In this case
|
||||
all the caveats in the previous paragraph apply.
|
||||
|
||||
menu.h defines two instances of t_handler_return
|
||||
ACTION_VALID and ACTION_INVALID for common use. These set the valid flag
|
||||
to 1 and 0 respectively and the refresh flag to 0.
|
||||
|
||||
3. Things to look out for
|
||||
-------------------------
|
||||
When you define the menu system, always declare it in the opposite
|
||||
order, i.e. all lower level menu's should be defined before the higher
|
||||
level menus. This is because in order to define the MAINMENU, you need
|
||||
to know the index assigned to all its submenus.
|
||||
|
||||
4. Additional Modules
|
||||
---------------------
|
||||
You can make use of the following additional modules, in writing your
|
||||
handlers.
|
||||
|
||||
* Passwords
|
||||
* Help
|
||||
|
||||
4.1 Passwords
|
||||
-------------
|
||||
This module was written by Th. Gebhardt. This is basically a modification
|
||||
of the DES crypt function obtained by removing the dependence of the
|
||||
original crypt function on C libraries. The following functions are
|
||||
defined
|
||||
|
||||
init_passwords(PWDFILE)
|
||||
// Read in the password database from the file
|
||||
authenticate_user(user,pwd)
|
||||
// Checks if user,pwd is valid
|
||||
isallowed(user,perm)
|
||||
// Checks if the user has a specified permission
|
||||
close_passwords()
|
||||
// Unloads password database from memory
|
||||
|
||||
See the sample password file for more details about the file format
|
||||
and the implementation of permissions.
|
||||
|
||||
See complex.c for a example of how to use this.
|
||||
|
||||
4.2 Help
|
||||
--------
|
||||
This can be used to set up a context sensitive help system. The following
|
||||
functions are defined
|
||||
|
||||
init_help(HELPBASEDIR)
|
||||
// Initialises the help system. All help files will be loaded
|
||||
// from the directory specified.
|
||||
runhelpsystem(context)
|
||||
// Displays the contents of HELPBASEDIR/hlp<context>.txt
|
||||
|
||||
In order to have a functioning help system, you just need to create
|
||||
the hlp<NNNNN>.txt files and initialize the help system by specifying
|
||||
the base directory.
|
||||
|
||||
The first line of this file assumed to be the title of the help screen.
|
||||
You can use ^N and ^O to change attributes absolutely and relatively,
|
||||
i.e. [^O]46 (i.e. Ctrl-O followed by chars 4 and 6) will set the
|
||||
attribute to 46, while [^N]08 will XOR the current attribute with
|
||||
specified number, thus in this case the first [^N]08 will turn on
|
||||
highlighting and the second one will turn it off.
|
||||
|
||||
79
extra/syslinux-3.09/menu/Makefile
Normal file
79
extra/syslinux-3.09/menu/Makefile
Normal file
@@ -0,0 +1,79 @@
|
||||
#ident "$Id: Makefile,v 1.9 2005/04/28 23:12:09 hpa Exp $"
|
||||
## -----------------------------------------------------------------------
|
||||
##
|
||||
## Copyright 2001-2005 H. Peter Anvin - All Rights Reserved
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
## Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
## (at your option) any later version; incorporated herein by reference.
|
||||
##
|
||||
## -----------------------------------------------------------------------
|
||||
|
||||
##
|
||||
## samples for syslinux users
|
||||
##
|
||||
|
||||
gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
|
||||
then echo $(1); else echo $(2); fi)
|
||||
|
||||
M32 := $(call gcc_ok,-m32,)
|
||||
|
||||
CC = gcc
|
||||
LD = ld -m elf_i386
|
||||
AR = ar
|
||||
NASM = nasm
|
||||
RANLIB = ranlib
|
||||
COM32DIR = ../com32
|
||||
LUDIR = $(COM32DIR)/libutil
|
||||
LDIR = $(COM32DIR)/lib
|
||||
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os -fomit-frame-pointer -I$(LUDIR)/include -I$(COM32DIR)/include -Ilibmenu -D__COM32__
|
||||
SFLAGS = -D__COM32__ -march=i386
|
||||
LDFLAGS = -T $(LDIR)/com32.ld
|
||||
OBJCOPY = objcopy
|
||||
LIBGCC := $(shell $(CC) --print-libgcc)
|
||||
|
||||
LIBS = libmenu/libmenu.a $(LUDIR)/libutil_com.a $(LDIR)/libcom32.a $(LIBGCC)
|
||||
|
||||
LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
|
||||
libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o
|
||||
|
||||
MENUS = $(patsubst %.c,%.c32,$(wildcard *.c))
|
||||
|
||||
.SUFFIXES: .S .c .o .elf .c32
|
||||
|
||||
.PRECIOUS: %.o
|
||||
%.o: %.S
|
||||
$(CC) $(SFLAGS) -c -o $@ $<
|
||||
|
||||
.PRECIOUS: %.o
|
||||
%.o: %.c %.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
.PRECIOUS: %.elf
|
||||
%.elf: %.o $(LIBS)
|
||||
$(LD) $(LDFLAGS) -o $@ $^
|
||||
|
||||
%.c32: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
all: menus
|
||||
|
||||
libmenu/libmenu.a: $(LIBMENU)
|
||||
-rm -f $@
|
||||
$(AR) cq $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
tidy:
|
||||
rm -f *.o *.lo *.a *.lst *.elf libmenu/*.o libmenu/*.a
|
||||
|
||||
clean: tidy
|
||||
rm -f *.lss *.c32 *.com
|
||||
|
||||
spotless: clean
|
||||
rm -f *~ \#*
|
||||
|
||||
menus: $(MENUS)
|
||||
|
||||
install: # Don't install samples
|
||||
93
extra/syslinux-3.09/menu/README
Normal file
93
extra/syslinux-3.09/menu/README
Normal file
@@ -0,0 +1,93 @@
|
||||
Text User Interface using comboot
|
||||
---------------------------------
|
||||
|
||||
This is a menu system written by Murali Krishnan Ganapathy and ported
|
||||
from OpenWatcom to gcc by HPA. It is currently being maintained by the
|
||||
original author.
|
||||
|
||||
To configure the menus, you need to set up a menu configuration file
|
||||
to have the menu items you desire, then build the menu system using
|
||||
make. You can use either simple.c or complex.c as a starting point
|
||||
for your own menu configuration file; then add the name with a .c32
|
||||
extension to the MENUS list in the Makefile.
|
||||
|
||||
The resulting code is a 32-bit COMBOOT code, and hence can be executed
|
||||
only under syslinux. You can use tools like bochs to help debug your
|
||||
code.
|
||||
|
||||
Menu Features currently supported are:
|
||||
* menu items,
|
||||
* submenus,
|
||||
* disabled items,
|
||||
* checkboxes,
|
||||
* invisible items (useful for dynamic menus), and
|
||||
* Radio menus,
|
||||
* Context sensitive help
|
||||
* Authenticated users
|
||||
* Editing commands associated with items
|
||||
|
||||
The keys used are:
|
||||
|
||||
* Arrow Keys, PgUp, PgDn, Home, End Keys
|
||||
* Space to switch state of a checkbox
|
||||
* Enter to choose the item
|
||||
* Escape to exit from it
|
||||
* Shortcut keys
|
||||
|
||||
Features
|
||||
--------
|
||||
This is a general purpose menu system implemented using only BIOS calls,
|
||||
so it can be executed in a COMBOOT environment as well. It is highly
|
||||
customizable. Some features include:
|
||||
|
||||
* Status line
|
||||
Display any help information associated with each menu item.
|
||||
* Window
|
||||
Specify a window within which the menu system draws all its menu's.
|
||||
It is upto the user to ensure that the menu's fit within the window.
|
||||
* Positioning submenus
|
||||
By default, each submenu is positioned just below the corresponding
|
||||
entry of the parent menu. However, the user may position each menu
|
||||
at a specific location of his choice. This is useful, when the menu's
|
||||
have lots of options.
|
||||
* Registering handlers for each menu item
|
||||
This is mainly used for checkboxes and radiomenu's, where a selection may
|
||||
result in disabling other menu items/checkboxes
|
||||
* Global Screen Handler
|
||||
This is called every time the menu is redrawn. The user can display
|
||||
additional information (usually outside the window where the menu is
|
||||
being displayed). See the complex.c for an example, where the global
|
||||
handler is used to display the choices made so far.
|
||||
* Global Keys Handler
|
||||
This is called every time the user presses a key which the menu
|
||||
system does not understand. This can be used to display context
|
||||
sensitive help. See complex.c for how to use this hook to implement
|
||||
a context sensitive help system as well as "On the fly" editing
|
||||
of commands associated with menus.
|
||||
* Shortcut Keys
|
||||
With each item one can register a shortcut key from [A-Za-z0-9].
|
||||
Pressing a key within that range, will take you to the next item
|
||||
with that shortcut key (so you can have multiple items with the
|
||||
same shortcut key). The default shortcut key for each item, is
|
||||
the lower case version of the first char of the item in the range
|
||||
[A-Za-z0-9].
|
||||
* Escape Keys
|
||||
Each item entry can have a substring enclosed in < and >. This part
|
||||
is highlighted. Can be used to highlight the shortcut keys. By default
|
||||
if an item has a <, then the first char inside < and > in the range
|
||||
[A-Za-z0-9] is converted to lower case and set as the shortcut key.
|
||||
* Ontimeout handler
|
||||
The user can register an ontimeout handler, which gets called if
|
||||
no key has been pressed for a user specific amount of time (default 5 min).
|
||||
For an example see the complex.c file.
|
||||
|
||||
Credits
|
||||
-------
|
||||
* The Watcom developers and Peter Anvin for figuring out an OS
|
||||
independent startup code.
|
||||
* Thomas for porting the crypt function and removing all C library
|
||||
dependencies
|
||||
* Peter Anvin for porting the code to GCC
|
||||
|
||||
- Murali (gmurali+guicd@cs.uchicago.edu)
|
||||
|
||||
9
extra/syslinux-3.09/menu/TODO
Normal file
9
extra/syslinux-3.09/menu/TODO
Normal file
@@ -0,0 +1,9 @@
|
||||
* Read menu structure from config files
|
||||
- This will eliminate the need for recompiling the code, especially
|
||||
for the simple menus
|
||||
* Features to add
|
||||
- Parse commandline arguments
|
||||
* Help support
|
||||
- Beef up help.c so that the text file can be larger than one page, and
|
||||
user can scroll down page to view extra text.
|
||||
|
||||
424
extra/syslinux-3.09/menu/complex.c
Normal file
424
extra/syslinux-3.09/menu/complex.c
Normal file
@@ -0,0 +1,424 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
#include "menu.h"
|
||||
#include "com32io.h"
|
||||
#include "help.h"
|
||||
#include "passwords.h"
|
||||
#include "des.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Global variables */
|
||||
char infoline[160];
|
||||
char buffer[80];
|
||||
|
||||
// Different network options
|
||||
static char nonet[] = "<n>etwork [none]";
|
||||
static char dhcpnet[]="<n>etwork [dhcp]";
|
||||
static char statnet[]="<n>etwork [static]";
|
||||
|
||||
static char loginstr[] = "<L>ogin ";
|
||||
static char logoutstr[]= "<L>ogout ";
|
||||
|
||||
struct {
|
||||
unsigned int baseurl : 1; // Do we need to specify by url
|
||||
unsigned int mountcd : 1; // Should we mount the cd
|
||||
unsigned int winrep : 1; // Want to repair windows?
|
||||
unsigned int linrep : 1; // Want to repair linux?
|
||||
} flags;
|
||||
|
||||
// Some menu options
|
||||
t_menuitem *baseurl,*mountcd,*network,*runprep,*winrep,*linrep;
|
||||
t_menuitem * stat,*dhcp,*none,*prepopt,*secret;
|
||||
|
||||
// all the menus we are going to declare
|
||||
unsigned char TESTING,RESCUE,MAIN,PREPMENU,NETMENU,LONGMENU,SECRETMENU;
|
||||
|
||||
char username[12]; // Name of user currently using the system
|
||||
|
||||
/* End globals */
|
||||
|
||||
TIMEOUTCODE ontimeout()
|
||||
{
|
||||
beep();
|
||||
return CODE_WAIT;
|
||||
}
|
||||
|
||||
|
||||
#define INFLINE 22
|
||||
#define PWDLINE 3
|
||||
#define PWDPROMPT 21
|
||||
#define PWDCOLUMN 60
|
||||
#define PWDATTR 0x74
|
||||
#define EDITPROMPT 21
|
||||
|
||||
void keys_handler(t_menusystem *ms, t_menuitem *mi,unsigned int scancode)
|
||||
{
|
||||
char nc;
|
||||
|
||||
if ((scancode >> 8) == F1) { // If scancode of F1
|
||||
runhelpsystem(mi->helpid);
|
||||
}
|
||||
// If user hit TAB, and item is an "executable" item
|
||||
// and user has privileges to edit it, edit it in place.
|
||||
if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN) &&
|
||||
(isallowed(username,"editcmd") || isallowed(username,"root"))) {
|
||||
nc = getnumcols();
|
||||
// User typed TAB and has permissions to edit command line
|
||||
gotoxy(EDITPROMPT,1,ms->menupage);
|
||||
csprint("Command line:",0x07);
|
||||
editstring(mi->data,ACTIONLEN);
|
||||
gotoxy(EDITPROMPT,1,ms->menupage);
|
||||
cprint(' ',0x07,nc-1,ms->menupage);
|
||||
}
|
||||
}
|
||||
|
||||
t_handler_return login_handler(t_menusystem *ms, t_menuitem *mi)
|
||||
{
|
||||
(void)mi; // Unused
|
||||
char pwd[40];
|
||||
char login[40];
|
||||
char nc;
|
||||
t_handler_return rv;
|
||||
|
||||
if (mi->item == loginstr) { /* User wants to login */
|
||||
nc = getnumcols();
|
||||
gotoxy(PWDPROMPT,1,ms->menupage);
|
||||
csprint("Enter Username: ",0x07);
|
||||
getstring(login, sizeof username);
|
||||
gotoxy(PWDPROMPT,1,ms->menupage);
|
||||
cprint(' ',0x07,nc,ms->menupage);
|
||||
csprint("Enter Password: ",0x07);
|
||||
getpwd(pwd, sizeof pwd);
|
||||
gotoxy(PWDPROMPT,1,ms->menupage);
|
||||
cprint(' ',0x07,nc,ms->menupage);
|
||||
|
||||
if (authenticate_user(login,pwd))
|
||||
{
|
||||
strcpy(username,login);
|
||||
mi->item = logoutstr; // Change item to read "Logout"
|
||||
}
|
||||
else strcpy(username,GUEST_USER);
|
||||
}
|
||||
else // User needs to logout
|
||||
{
|
||||
strcpy(username,GUEST_USER);
|
||||
mi->item = loginstr;
|
||||
}
|
||||
|
||||
if (strcmp(username,GUEST_USER)==0)
|
||||
{
|
||||
prepopt->action = OPT_INACTIVE;
|
||||
secret->action = OPT_INVISIBLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
prepopt->action = OPT_SUBMENU;
|
||||
prepopt->itemdata.radiomenunum = PREPMENU;
|
||||
secret->action = OPT_SUBMENU;
|
||||
secret->itemdata.submenunum = SECRETMENU;
|
||||
}
|
||||
rv.valid = 0;
|
||||
rv.refresh = 1;
|
||||
return rv;
|
||||
}
|
||||
|
||||
void msys_handler(t_menusystem *ms, t_menuitem *mi)
|
||||
{
|
||||
char nc;
|
||||
void *v;
|
||||
nc = getnumcols(); // Get number of columns
|
||||
|
||||
gotoxy(PWDLINE,PWDCOLUMN,ms->menupage);
|
||||
csprint("User: ",PWDATTR);
|
||||
cprint(ms->fillchar,ms->fillattr,sizeof username,ms->menupage);
|
||||
gotoxy(PWDLINE,PWDCOLUMN +6,ms->menupage);
|
||||
csprint(username,PWDATTR);
|
||||
|
||||
if (mi->parindex != PREPMENU) // If we are not in the PREP MENU
|
||||
{
|
||||
gotoxy(INFLINE,0,ms->menupage);
|
||||
cprint(' ',0x07,nc,ms->menupage);
|
||||
gotoxy(INFLINE+1,0,ms->menupage);
|
||||
cprint(' ',0x07,nc,ms->menupage);
|
||||
return;
|
||||
}
|
||||
strcpy (infoline," ");
|
||||
if (flags.baseurl) strcat(infoline,"baseurl=http://192.168.11.12/gui ");
|
||||
if (flags.mountcd) strcat(infoline,"mountcd=yes ");
|
||||
v = (void *)network->data;
|
||||
if (v!=NULL) // Some network option specified
|
||||
{
|
||||
strcat(infoline,"network=");
|
||||
strcat(infoline,(char *)(((t_menuitem *)v)->data));
|
||||
}
|
||||
if (flags.winrep) strcat(infoline,"repair=win ");
|
||||
if (flags.linrep) strcat(infoline,"repair=lin ");
|
||||
|
||||
gotoxy(INFLINE,0,ms->menupage);
|
||||
cprint(' ',0x07,nc,ms->menupage);
|
||||
gotoxy(INFLINE+1,0,ms->menupage);
|
||||
cprint(' ',0x07,nc,ms->menupage);
|
||||
gotoxy(INFLINE,0,ms->menupage);
|
||||
csprint("Kernel Arguments:",0x07);
|
||||
gotoxy(INFLINE,17,ms->menupage);
|
||||
csprint(infoline,0x07);
|
||||
}
|
||||
|
||||
t_handler_return network_handler(t_menusystem *ms, t_menuitem *mi)
|
||||
{
|
||||
// mi=network since this is handler only for that.
|
||||
(void)ms; // Unused
|
||||
|
||||
if (mi->data == (void *)none) mi->item = nonet;
|
||||
if (mi->data == (void *)stat) mi->item = statnet;
|
||||
if (mi->data == (void *)dhcp) mi->item = dhcpnet;
|
||||
return ACTION_INVALID; // VALID or INVALID does not matter
|
||||
}
|
||||
|
||||
t_handler_return checkbox_handler(t_menusystem *ms, t_menuitem *mi)
|
||||
{
|
||||
(void)ms; /* Unused */
|
||||
|
||||
if (mi->action != OPT_CHECKBOX) return ACTION_INVALID;
|
||||
|
||||
if (strcmp(mi->data,"baseurl") == 0) flags.baseurl = (mi->itemdata.checked ? 1 : 0);
|
||||
if (strcmp(mi->data,"winrepair") == 0) {
|
||||
if (mi->itemdata.checked)
|
||||
{
|
||||
flags.winrep = 1;
|
||||
linrep->action = OPT_INACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.winrep = 0;
|
||||
linrep->action = OPT_CHECKBOX;
|
||||
}
|
||||
}
|
||||
if (strcmp(mi->data,"linrepair") == 0) {
|
||||
if (mi->itemdata.checked)
|
||||
{
|
||||
flags.linrep = 1;
|
||||
winrep->action = OPT_INACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.winrep = 0;
|
||||
winrep->action = OPT_CHECKBOX;
|
||||
}
|
||||
}
|
||||
if (strcmp(mi->data,"mountcd") == 0) flags.mountcd = (mi->itemdata.checked ? 1 : 0);
|
||||
return ACTION_VALID;
|
||||
}
|
||||
|
||||
/*
|
||||
Clears keyboard buffer and then
|
||||
wait for stepsize*numsteps milliseconds for user to press any key
|
||||
checks for keypress every stepsize milliseconds.
|
||||
Returns: 1 if user pressed a key (not read from the buffer),
|
||||
0 if time elapsed
|
||||
*/
|
||||
int checkkeypress(int stepsize, int numsteps)
|
||||
{
|
||||
int i;
|
||||
clearkbdbuf();
|
||||
for (i=0; i < numsteps; i++)
|
||||
{
|
||||
if (checkkbdbuf()) return 1;
|
||||
sleep(stepsize);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
t_menuitem * curr;
|
||||
char cmd[160];
|
||||
char ip[30];
|
||||
|
||||
// Set default username as guest
|
||||
strcpy(username,GUEST_USER);
|
||||
|
||||
// Switch video mode here
|
||||
// setvideomode(0x18); // or whatever mode you want
|
||||
|
||||
// Choose the default title and setup default values for all attributes....
|
||||
init_passwords("/isolinux/password");
|
||||
init_help("/isolinux/help");
|
||||
init_menusystem(NULL);
|
||||
set_window_size(1,1,20,78); // Leave some space around
|
||||
|
||||
// Choose the default values for all attributes and char's
|
||||
// -1 means choose defaults (Actually the next 4 lines are not needed)
|
||||
//set_normal_attr (-1,-1,-1,-1);
|
||||
//set_status_info (-1,-1); // Display status on the last line
|
||||
//set_title_info (-1,-1);
|
||||
//set_misc_info(-1,-1,-1,-1);
|
||||
|
||||
// Register the menusystem handler
|
||||
reg_handler(HDLR_SCREEN,&msys_handler);
|
||||
reg_handler(HDLR_KEYS,&keys_handler);
|
||||
// Register the ontimeout handler, with a time out of 10 seconds
|
||||
reg_ontimeout(ontimeout,1000,0);
|
||||
|
||||
NETMENU = add_menu(" Init Network ",-1);
|
||||
none = add_item("<N>one","Dont start network",OPT_RADIOITEM,"no ",0);
|
||||
dhcp = add_item("<d>hcp","Use DHCP",OPT_RADIOITEM,"dhcp ",0);
|
||||
stat = add_item("<s>tatic","Use static IP I will specify later",OPT_RADIOITEM,"static ",0);
|
||||
|
||||
TESTING = add_menu(" Testing ",-1);
|
||||
set_menu_pos(5,55);
|
||||
add_item("<M>emory Test","Perform extensive memory testing",OPT_RUN, "memtest",0);
|
||||
add_item("<I>nvisible","You dont see this",OPT_INVISIBLE,"junk",0);
|
||||
add_item("<E>xit this menu","Go one level up",OPT_EXITMENU,"exit",0);
|
||||
|
||||
RESCUE = add_menu(" Rescue Options ",-1);
|
||||
add_item("<L>inux Rescue","linresc",OPT_RUN,"linresc",0);
|
||||
add_item("<D>os Rescue","dosresc",OPT_RUN,"dosresc",0);
|
||||
add_item("<W>indows Rescue","winresc",OPT_RUN,"winresc",0);
|
||||
add_item("<E>xit this menu","Go one level up",OPT_EXITMENU,"exit",0);
|
||||
|
||||
PREPMENU = add_menu(" Prep options ",-1);
|
||||
baseurl = add_item("<b>aseurl by IP?","Specify gui baseurl by IP address",OPT_CHECKBOX,"baseurl",0);
|
||||
mountcd = add_item("<m>ountcd?","Mount the cdrom drive?",OPT_CHECKBOX,"mountcd",0);
|
||||
network = add_item(dhcpnet,"How to initialise network device?",OPT_RADIOMENU,NULL,NETMENU);
|
||||
add_sep();
|
||||
winrep = add_item("Reinstall <w>indows","Re-install the windows side of a dual boot setup",OPT_CHECKBOX,"winrepair",0);
|
||||
linrep = add_item("Reinstall <l>inux","Re-install the linux side of a dual boot setup",OPT_CHECKBOX,"linrepair",0);
|
||||
add_sep();
|
||||
runprep = add_item("<R>un prep now","Execute prep with the above options",OPT_RUN,"prep",0);
|
||||
add_item("<E>xit this menu","Go up one level",OPT_EXITMENU,"exitmenu",0);
|
||||
baseurl->handler = &checkbox_handler;
|
||||
mountcd->handler = &checkbox_handler;
|
||||
winrep->handler = &checkbox_handler;
|
||||
linrep->handler = &checkbox_handler;
|
||||
network->handler = &network_handler;
|
||||
flags.baseurl = 0;
|
||||
flags.mountcd = 0;
|
||||
flags.winrep = 0;
|
||||
flags.linrep = 0;
|
||||
|
||||
SECRETMENU = add_menu(" Secret Menu ",-1);
|
||||
add_item("secret 1","Secret",OPT_RUN,"A",0);
|
||||
add_item("secret 2","Secret",OPT_RUN,"A",0);
|
||||
|
||||
LONGMENU = add_menu(" Long Menu ",40); // Override default here
|
||||
add_item("<A>a","Aa",OPT_RUN,"A",0);
|
||||
add_item("<B>b","Ab",OPT_RUN,"A",0);
|
||||
add_item("<C>","A",OPT_RUN,"A",0);
|
||||
add_item("<D>","A",OPT_RUN,"A",0);
|
||||
add_item("<E>","A",OPT_RUN,"A",0);
|
||||
add_item("<F>","A",OPT_RUN,"A",0);
|
||||
add_item("<G>","A",OPT_RUN,"A",0);
|
||||
add_item("<H>","A",OPT_RUN,"A",0);
|
||||
add_item("<I>","A",OPT_RUN,"A",0);
|
||||
add_item("<J>","A",OPT_RUN,"A",0);
|
||||
add_item("<K>","A",OPT_RUN,"A",0);
|
||||
add_item("<L>","A",OPT_RUN,"A",0);
|
||||
add_item("<J>","A",OPT_RUN,"A",0);
|
||||
add_item("<K>","A",OPT_RUN,"A",0);
|
||||
add_item("<L>","A",OPT_RUN,"A",0);
|
||||
add_item("<M>","A",OPT_RUN,"A",0);
|
||||
add_item("<N>","A",OPT_RUN,"A",0);
|
||||
add_item("<O>","A",OPT_RUN,"A",0);
|
||||
add_item("<P>","A",OPT_RUN,"A",0);
|
||||
add_item("<Q>","A",OPT_RUN,"A",0);
|
||||
add_item("<R>","A",OPT_RUN,"A",0);
|
||||
add_item("<S>","A",OPT_RUN,"A",0);
|
||||
add_item("<T>","A",OPT_RUN,"A",0);
|
||||
add_item("<U>","A",OPT_RUN,"A",0);
|
||||
add_item("<V>","A",OPT_RUN,"A",0);
|
||||
add_item("<W>","A",OPT_RUN,"A",0);
|
||||
add_item("<X>","A",OPT_RUN,"A",0);
|
||||
add_item("<Y>","A",OPT_RUN,"A",0);
|
||||
add_item("<Z>","A",OPT_RUN,"A",0);
|
||||
add_item("<1>","A",OPT_RUN,"A",0);
|
||||
add_item("<2>","A",OPT_RUN,"A",0);
|
||||
add_item("<3>","A",OPT_RUN,"A",0);
|
||||
add_item("<4>","A",OPT_RUN,"A",0);
|
||||
add_item("<5>","A",OPT_RUN,"A",0);
|
||||
add_item("<6>","A",OPT_RUN,"A",0);
|
||||
add_item("<7>","A",OPT_RUN,"A",0);
|
||||
add_item("<8>","A",OPT_RUN,"A",0);
|
||||
add_item("<9>","A",OPT_RUN,"A",0);
|
||||
|
||||
MAIN = add_menu(" Main Menu ",8);
|
||||
curr = add_item(loginstr,"Login as a privileged user",OPT_RUN,NULL,0);
|
||||
set_item_options(-1,23);
|
||||
curr->handler = &login_handler;
|
||||
|
||||
add_item("<P>repare","prep",OPT_RUN,"prep",0);
|
||||
set_item_options(-1,24);
|
||||
prepopt = add_item("<P>rep options...","Options for prep image: Requires authenticated user",OPT_INACTIVE,NULL,PREPMENU);
|
||||
set_item_options(-1,25);
|
||||
|
||||
add_item("<R>escue options...","Troubleshoot a system",OPT_SUBMENU,NULL,RESCUE);
|
||||
set_item_options(-1,26);
|
||||
add_item("<T>esting...","Options to test hardware",OPT_SUBMENU,NULL,TESTING);
|
||||
set_item_options(-1,27);
|
||||
add_item("<L>ong Menu...","test menu system",OPT_SUBMENU,NULL,LONGMENU);
|
||||
set_item_options(-1,28);
|
||||
secret = add_item("<S>ecret Menu...","Secret menu",OPT_INVISIBLE,NULL,SECRETMENU);
|
||||
set_item_options(-1,29);
|
||||
add_item("<E>xit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
|
||||
set_item_options(-1,30);
|
||||
csprint("Press any key within 5 seconds to show menu...",0x07);
|
||||
if (!checkkeypress(100,50)) // Granularity of 100 milliseconds
|
||||
{
|
||||
csprint("Sorry! Time's up.\r\n",0x07);
|
||||
return 1;
|
||||
}
|
||||
else clearkbdbuf(); // Just in case user pressed something important
|
||||
curr = showmenus(MAIN);
|
||||
if (curr)
|
||||
{
|
||||
if (curr->action == OPT_RUN)
|
||||
{
|
||||
strcpy(cmd,curr->data);
|
||||
if (curr == runprep)
|
||||
{
|
||||
strcat(cmd,infoline);
|
||||
if (network->data == (void *)stat) // We want static
|
||||
{
|
||||
csprint("Enter IP address (last two octets only): ",0x07);
|
||||
strcpy(ip, "Junk");
|
||||
editstring(ip, sizeof ip);
|
||||
strcat(cmd,"ipaddr=192.168.");
|
||||
strcat(cmd,ip);
|
||||
}
|
||||
}
|
||||
if (issyslinux())
|
||||
runsyslinuxcmd(cmd);
|
||||
else csprint(cmd,0x07);
|
||||
return 1; // Should not happen when run from SYSLINUX
|
||||
}
|
||||
}
|
||||
// If user quits the menu system, control comes here
|
||||
// If you want to execute some specific command uncomment the next two lines
|
||||
|
||||
// if (syslinux) runcommand(YOUR_COMMAND_HERE);
|
||||
// else csprint(YOUR_COMMAND_HERE,0x07);
|
||||
|
||||
// Deallocate space used for these data structures
|
||||
close_passwords();
|
||||
close_help();
|
||||
close_menusystem();
|
||||
|
||||
// Return to prompt
|
||||
return 0;
|
||||
}
|
||||
|
||||
147
extra/syslinux-3.09/menu/libmenu/com32io.c
Normal file
147
extra/syslinux-3.09/menu/libmenu/com32io.c
Normal file
@@ -0,0 +1,147 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#include <string.h>
|
||||
#include <com32.h>
|
||||
#include "com32io.h"
|
||||
#include "syslnx.h"
|
||||
|
||||
com32sys_t inreg,outreg; // Global register sets for use
|
||||
|
||||
/* Print character and attribute at cursor */
|
||||
void cprint(char chr,char attr,unsigned int times,char disppage)
|
||||
{
|
||||
REG_AH(inreg) = 0x09;
|
||||
REG_AL(inreg) = chr;
|
||||
REG_BH(inreg) = disppage;
|
||||
REG_BL(inreg) = attr;
|
||||
REG_CX(inreg) = times;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
}
|
||||
|
||||
void setdisppage(char num) // Set the display page to specified number
|
||||
{
|
||||
REG_AH(inreg) = 0x05;
|
||||
REG_AL(inreg) = num;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
}
|
||||
|
||||
char getdisppage() // Get current display page
|
||||
{
|
||||
REG_AH(inreg) = 0x0f;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
return REG_BH(outreg);
|
||||
}
|
||||
|
||||
void getpos(char * row, char * col, char page)
|
||||
{
|
||||
REG_AH(inreg) = 0x03;
|
||||
REG_BH(inreg) = page;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
*row = REG_DH(outreg);
|
||||
*col = REG_DL(outreg);
|
||||
}
|
||||
|
||||
void gotoxy(char row,char col, char page)
|
||||
{
|
||||
REG_AH(inreg) = 0x02;
|
||||
REG_BH(inreg) = page;
|
||||
REG_DX(inreg) = (row << 8)+col;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
}
|
||||
|
||||
unsigned char sleep(unsigned int msec)
|
||||
{
|
||||
unsigned long micro = 1000*msec;
|
||||
|
||||
REG_AH(inreg) = 0x86;
|
||||
REG_CX(inreg) = (micro >> 16);
|
||||
REG_DX(inreg) = (micro % 0x10000);
|
||||
__intcall(0x15,&inreg,&outreg);
|
||||
return REG_AH(outreg);
|
||||
}
|
||||
|
||||
void beep()
|
||||
{
|
||||
REG_AH(inreg) = 0x0E;
|
||||
REG_AL(inreg) = 0x07;
|
||||
REG_BH(inreg) = 0;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
}
|
||||
|
||||
void scrollup()
|
||||
{
|
||||
unsigned int dx = (getnumrows()<< 8) + getnumcols();
|
||||
REG_AH(inreg) = 0x06;
|
||||
REG_AL(inreg) = 0x01;
|
||||
REG_BH(inreg) = 0x07; // Attribute to write blanks lines
|
||||
REG_DX(inreg) = dx; // BOT RIGHT corner to window
|
||||
REG_CX(inreg) = 0; // TOP LEFT of window
|
||||
}
|
||||
|
||||
char inputc(char * scancode)
|
||||
{
|
||||
REG_AH(inreg) = 0x10;
|
||||
__intcall(0x16,&inreg,&outreg);
|
||||
if (scancode)
|
||||
*scancode = REG_AH(outreg);
|
||||
return REG_AL(outreg);
|
||||
}
|
||||
|
||||
void getcursorshape(char *start, char *end)
|
||||
{
|
||||
char page = getdisppage();
|
||||
REG_AH(inreg) = 0x03;
|
||||
REG_BH(inreg) = page;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
*start = REG_CH(outreg);
|
||||
*end = REG_CL(outreg);
|
||||
}
|
||||
|
||||
void setcursorshape(char start, char end)
|
||||
{
|
||||
REG_AH(inreg) = 0x01;
|
||||
REG_CH(inreg) = start;
|
||||
REG_CL(inreg) = end;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
}
|
||||
|
||||
char getchar(void)
|
||||
{
|
||||
REG_AH(inreg) = 0x08;
|
||||
__intcall(0x21,&inreg,&outreg);
|
||||
return REG_AL(outreg);
|
||||
}
|
||||
|
||||
void setvideomode(char mode)
|
||||
{
|
||||
REG_AH(inreg) = 0x00;
|
||||
REG_AL(inreg) = mode;
|
||||
__intcall(0x10,&inreg,&outreg);
|
||||
}
|
||||
|
||||
unsigned char checkkbdbuf()
|
||||
{
|
||||
REG_AH(inreg) = 0x11;
|
||||
__intcall(0x16,&inreg,&outreg);
|
||||
return (outreg.eflags.l & EFLAGS_ZF);
|
||||
}
|
||||
|
||||
// Get char displayed at current position
|
||||
unsigned char getcharat(char page)
|
||||
{
|
||||
REG_AH(inreg) = 0x08;
|
||||
REG_BH(inreg) = page;
|
||||
__intcall(0x16,&inreg,&outreg);
|
||||
return REG_AL(outreg);
|
||||
}
|
||||
|
||||
97
extra/syslinux-3.09/menu/libmenu/com32io.h
Normal file
97
extra/syslinux-3.09/menu/libmenu/com32io.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef __COM32IO_H__
|
||||
#define __COM32IO_H__
|
||||
|
||||
#include <com32.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
/* BIOS Assisted output routines */
|
||||
|
||||
void cswprint(const char *str, char attr, char left);
|
||||
// Print a C str (NUL-terminated) respecting the left edge of window
|
||||
// i.e. \n in str will move cursor to column left
|
||||
// Print a C str (NUL-terminated)
|
||||
|
||||
static inline void csprint(const char *str, char attr)
|
||||
{
|
||||
cswprint(str,attr,0);
|
||||
}
|
||||
|
||||
void cprint(char chr,char attr,unsigned int times, char disppage); // Print a char
|
||||
|
||||
void setdisppage(char num); // Set the display page to specified number
|
||||
|
||||
char getdisppage(); // Get current display page
|
||||
|
||||
void gotoxy(char row,char col, char page);
|
||||
|
||||
void getpos(char * row, char * col, char page);
|
||||
|
||||
char inputc(char * scancode); // Return ASCII char by val, and scancode by reference
|
||||
|
||||
static inline void putch(char x, char attr, char page)
|
||||
{
|
||||
cprint(x,attr,1,page);
|
||||
}
|
||||
|
||||
void setcursorshape(char start,char end); // Set cursor shape
|
||||
void getcursorshape(char *start,char *end); // Get shape for current page
|
||||
|
||||
// Get char displayed at current position in specified page
|
||||
unsigned char getcharat(char page);
|
||||
|
||||
static inline void cursoroff(void) /* Turns off cursor */
|
||||
{
|
||||
setcursorshape(32,33);
|
||||
}
|
||||
|
||||
static inline void cursoron(void) /* Turns on cursor */
|
||||
{
|
||||
setcursorshape(6,7);
|
||||
}
|
||||
|
||||
static inline unsigned char readbiosb(unsigned int ofs)
|
||||
{
|
||||
return *((unsigned char *)MK_PTR(0,ofs));
|
||||
}
|
||||
|
||||
static inline char getnumrows()
|
||||
{
|
||||
return readbiosb(0x484); // Actually numrows - 1
|
||||
}
|
||||
|
||||
static inline char getnumcols(void)
|
||||
{
|
||||
return readbiosb(0x44a); // Actually numcols
|
||||
}
|
||||
|
||||
void scrollup(); //Scroll up display screen by one line
|
||||
|
||||
void setvideomode(char mode); // Set the video mode.
|
||||
|
||||
unsigned char sleep(unsigned int msec); // Sleep for specified time
|
||||
|
||||
void beep(); // A Bell
|
||||
|
||||
unsigned char checkkbdbuf(); // Check to see if there is kbd buffer is non-empty?
|
||||
|
||||
static inline void clearkbdbuf() // Clear the kbd buffer (how many chars removed?)
|
||||
{
|
||||
while (checkkbdbuf()) inputc(NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
1102
extra/syslinux-3.09/menu/libmenu/des.c
Normal file
1102
extra/syslinux-3.09/menu/libmenu/des.c
Normal file
File diff suppressed because it is too large
Load Diff
9
extra/syslinux-3.09/menu/libmenu/des.h
Normal file
9
extra/syslinux-3.09/menu/libmenu/des.h
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
#ifndef _DES_H_
|
||||
#define _DES_H_
|
||||
|
||||
// des crypt
|
||||
extern char *crypt (const char *key, const char *salt);
|
||||
|
||||
#endif
|
||||
|
||||
84
extra/syslinux-3.09/menu/libmenu/help.c
Normal file
84
extra/syslinux-3.09/menu/libmenu/help.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#include "help.h"
|
||||
#include <stdio.h>
|
||||
#include "string.h"
|
||||
|
||||
char helpbasedir[HELPDIRLEN]; // name of help directory limited to HELPDIRLEN
|
||||
|
||||
void showhelp(const char *filename)
|
||||
{
|
||||
char nc,nr;
|
||||
FILE *f;
|
||||
char line[512]; // Max length of a line
|
||||
|
||||
nc = getnumcols();
|
||||
nr = getnumrows();
|
||||
cls();
|
||||
drawbox(0,0,nr,nc-1,HELPPAGE,0x07,HELPBOX);
|
||||
|
||||
drawhorizline(2,0,nc-1,HELPPAGE,0x07,HELPBOX,0); // dumb==0
|
||||
if (filename == NULL) { // print file contents
|
||||
gotoxy(HELP_BODY_ROW,HELP_LEFT_MARGIN,HELPPAGE);
|
||||
cswprint("Help system not initialized",0x07,HELP_LEFT_MARGIN);
|
||||
return;
|
||||
}
|
||||
|
||||
f = fopen(filename,"r");
|
||||
if (!f) { // No such file
|
||||
sprintf(line, "File %s not found",filename);
|
||||
gotoxy(HELP_BODY_ROW,HELP_LEFT_MARGIN,HELPPAGE);
|
||||
cswprint(line,0x07,HELP_LEFT_MARGIN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now we have a file just print it.
|
||||
fgets(line,sizeof line,f); // Get first line (TITLE)
|
||||
gotoxy(1,(nc-strlen(line))/2,HELPPAGE);
|
||||
csprint(line,0x07);
|
||||
|
||||
gotoxy(HELP_BODY_ROW,HELP_LEFT_MARGIN,HELPPAGE);
|
||||
while ( fgets(line, sizeof line, f) ) cswprint(line,0x07,HELP_LEFT_MARGIN);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void runhelpsystem(unsigned int helpid)
|
||||
{
|
||||
char dp;
|
||||
char scan;
|
||||
char filename[HELPDIRLEN+16];
|
||||
|
||||
dp = getdisppage();
|
||||
if (dp != HELPPAGE) setdisppage(HELPPAGE);
|
||||
if (helpbasedir[0] != 0) {
|
||||
sprintf(filename,"%s/hlp%05d.txt",helpbasedir,helpid);
|
||||
showhelp(filename);
|
||||
}
|
||||
else showhelp (NULL);
|
||||
while (1) {
|
||||
inputc(&scan);
|
||||
if (scan == ESCAPE) break;
|
||||
}
|
||||
if (dp != HELPPAGE) setdisppage(dp);
|
||||
}
|
||||
|
||||
void init_help(const char *helpdir)
|
||||
{
|
||||
if (helpdir != NULL)
|
||||
strcpy(helpbasedir,helpdir);
|
||||
else helpbasedir[0] = 0;
|
||||
}
|
||||
|
||||
void close_help(void)
|
||||
{
|
||||
}
|
||||
39
extra/syslinux-3.09/menu/libmenu/help.h
Normal file
39
extra/syslinux-3.09/menu/libmenu/help.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef __HELP_H_
|
||||
#define __HELP_H_
|
||||
|
||||
#include "menu.h"
|
||||
#include "com32io.h"
|
||||
#include "tui.h"
|
||||
#include <string.h>
|
||||
|
||||
// How many rows for the title
|
||||
#define HELP_TITLE_HEIGHT 1
|
||||
#define HELP_BODY_ROW (HELP_TITLE_HEIGHT+3)
|
||||
#define HELP_LEFT_MARGIN 2
|
||||
#define HELPBOX BOX_SINSIN
|
||||
#define HELPDIRLEN 64
|
||||
|
||||
// Display one screen of help information
|
||||
void showhelp(const char *filename);
|
||||
|
||||
// Start the help system using id helpid
|
||||
void runhelpsystem(unsigned int helpid);
|
||||
|
||||
// Directory where help files are located
|
||||
void init_help(const char *helpdir);
|
||||
// Free internal datastructures
|
||||
void close_help(void);
|
||||
|
||||
#endif
|
||||
1148
extra/syslinux-3.09/menu/libmenu/menu.c
Normal file
1148
extra/syslinux-3.09/menu/libmenu/menu.c
Normal file
File diff suppressed because it is too large
Load Diff
287
extra/syslinux-3.09/menu/libmenu/menu.h
Normal file
287
extra/syslinux-3.09/menu/libmenu/menu.h
Normal file
@@ -0,0 +1,287 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
/* This program can be compiled for DOS with the OpenWatcom compiler
|
||||
* (http://www.openwatcom.org/):
|
||||
*
|
||||
* wcl -3 -osx -mt <filename>.c
|
||||
*/
|
||||
|
||||
#ifndef __MENU_H__
|
||||
#define __MENU_H__
|
||||
|
||||
#include "com32io.h"
|
||||
#include "tui.h"
|
||||
#include "syslnx.h"
|
||||
#include "scancodes.h"
|
||||
#include <string.h>
|
||||
|
||||
// TIMEOUT PARAMETERS
|
||||
/* If no key is pressed within TIMEOUTNUMSTEPS * TIMEOUTSTEPSIZE milliseconds
|
||||
and if a timeout handler is registered, then that will be called.
|
||||
The handler should either either take control from there on, or return without
|
||||
producing any change in the current video settings.
|
||||
|
||||
For e.g. the handler could
|
||||
* Could just quit the menu program
|
||||
* beep and return.
|
||||
|
||||
TIMEOUTSTEPSIZE is the interval for which the program sleeps without checking for
|
||||
any keystroke. So increasing this will make the response of the system slow.
|
||||
Decreasing this will make a lot of interrupt calls using up your CPU. Default
|
||||
value of TIMEOUTSTEPSIZE of 0.1 seconds should be right in most cases.
|
||||
|
||||
TIMEOUTNUMSTEPS of 3000 corresponds to a wait time of 300 seconds or 5 minutes
|
||||
*/
|
||||
|
||||
#define TIMEOUTSTEPSIZE 10
|
||||
#define TIMEOUTNUMSTEPS 30000L
|
||||
|
||||
// Attributes
|
||||
#define NORMALATTR 0x17
|
||||
#define NORMALHLITE 0x1F // Normal Highlight attribute
|
||||
#define REVERSEATTR 0x70
|
||||
#define REVERSEHLITE 0x78 // Reverse Hightlight attribute
|
||||
#define INACTATTR 0x18
|
||||
#define INACTHLITE 0x10 // Inactive Highlight attribute
|
||||
#define REVINACTATTR 0x78
|
||||
#define REVINACTHLITE 0x70 // Reverse Inactive Highlight attr
|
||||
|
||||
#define STATUSATTR 0x74
|
||||
#define STATUSHLITE 0x7B // Status highlight
|
||||
|
||||
#define FILLCHAR 177
|
||||
#define FILLATTR 0x01
|
||||
#define SHADOWATTR 0x00
|
||||
#define SPACECHAR ' '
|
||||
|
||||
#define TFILLCHAR ' '
|
||||
#define TITLEATTR 0x70
|
||||
|
||||
#define ENABLEHLITE '<' // Char which turns on highlight
|
||||
#define DISABLEHLITE '>' // Char which turns off highlight
|
||||
#define NOHLITE 0 // The offset into attrib array for non-hilite
|
||||
#define HLITE 1 // The offset for Hlite attrib
|
||||
|
||||
#define MOREABOVE 24 // char to print when more menu items available above
|
||||
#define MOREBELOW 25 // more items available below
|
||||
#define SCROLLBOX 176 // Filled char to display
|
||||
|
||||
// Attributes of the menu system
|
||||
#define MAXMENUS 10 // Maximum number of menu's allowed
|
||||
#define MAXMENUSIZE 30 // Default value for max num of entries in each menu
|
||||
#define MAXMENUHEIGHT 14 // Maximum number of entries displayed
|
||||
#define MENUBOXTYPE BOX_SINSIN // Default box type Look at tui.h for other values
|
||||
|
||||
// Upper bounds on lengths
|
||||
// We copy the given string, so user can reuse the space used to store incoming arguments.
|
||||
#define MENULEN 40 // Each menu entry is atmost MENULEN chars
|
||||
#define STATLEN 80 // Maximum length of status string
|
||||
#define TITLELEN 80 // Maximum length of title string
|
||||
#define ACTIONLEN 255 // Maximum length of an action string
|
||||
|
||||
// Layout of menu
|
||||
#define MENUROW 3 // Row where menu is displayed (relative to window)
|
||||
#define MENUCOL 4 // Col where menu is displayed (relative to window)
|
||||
#define MENUPAGE 1 // show in display page 1
|
||||
#define HELPPAGE 2 // Use this page for any additional information
|
||||
#define STATLINE 24 // Line number where status line starts (relative to window)
|
||||
|
||||
// Used for printing debugging messages
|
||||
#define DEBUGLINE 23 // debugging info goes here
|
||||
|
||||
// Other Chars
|
||||
#define SUBMENUCHAR 175 // This is >> symbol
|
||||
#define RADIOMENUCHAR '>' // > symbol for radio menu?
|
||||
#define EXITMENUCHAR 174 // This is << symbol
|
||||
#define CHECKED 251 // Check mark
|
||||
#define UNCHECKED 250 // Light bullet
|
||||
#define RADIOSEL '.' // Current Radio Selection
|
||||
#define RADIOUNSEL ' ' // Radio option not selected
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
||||
// Types of menu's
|
||||
#define NORMALMENU 1
|
||||
#define RADIOMENU 2
|
||||
|
||||
typedef enum {OPT_INACTIVE, OPT_SUBMENU, OPT_RUN, OPT_EXITMENU, OPT_CHECKBOX,
|
||||
OPT_RADIOMENU, OPT_SEP, OPT_INVISIBLE,
|
||||
OPT_RADIOITEM} t_action;
|
||||
|
||||
typedef union {
|
||||
uchar submenunum; // For submenu's
|
||||
uchar checked; // For check boxes
|
||||
uchar radiomenunum; // Item mapping to a radio menu
|
||||
} t_itemdata;
|
||||
|
||||
struct s_menuitem;
|
||||
struct s_menu;
|
||||
struct s_menusystem;
|
||||
|
||||
typedef struct {
|
||||
unsigned int valid :1; // Is action valid?
|
||||
unsigned int refresh:1; // Should we recompute menu stuff?
|
||||
unsigned int reserved:6; // For future expansion
|
||||
} t_handler_return;
|
||||
|
||||
t_handler_return ACTION_VALID,ACTION_INVALID; // Specific values
|
||||
|
||||
typedef t_handler_return (*t_item_handler)(struct s_menusystem *, struct s_menuitem *);
|
||||
typedef void (*t_menusystem_handler)(struct s_menusystem *, struct s_menuitem *);
|
||||
typedef void (*t_keys_handler)(struct s_menusystem *, struct s_menuitem *,
|
||||
unsigned int scancode);
|
||||
// Last parameter = HIGH BYTE = scan code , LOW BYTE = ASCII CODE
|
||||
|
||||
typedef enum {HDLR_SCREEN, HDLR_KEYS } t_handler;
|
||||
// Types of handlers for menu system
|
||||
|
||||
// TIMEOUT is the list of possible values which can be returned by the handler
|
||||
// instructing the menusystem what to do. The default is CODE_WAIT
|
||||
typedef enum {CODE_WAIT, CODE_ENTER, CODE_ESCAPE } TIMEOUTCODE;
|
||||
typedef TIMEOUTCODE (*t_timeout_handler)(void);
|
||||
|
||||
typedef struct s_menuitem {
|
||||
char *item;
|
||||
char *status;
|
||||
char *data; // string containing kernel to run.. but...
|
||||
// for radio menu's this is a pointer to the item selected or NULL (initially)
|
||||
void * extra_data; // Any other data user can point to
|
||||
t_item_handler handler; // Pointer to function of type menufn
|
||||
t_action action;
|
||||
t_itemdata itemdata; // Data depends on action value
|
||||
unsigned int helpid; // context sensitive help system ID
|
||||
uchar shortcut; // one of [A-Za-z0-9] shortcut for this menu item
|
||||
uchar index; // Index within the menu array
|
||||
uchar parindex; // Index of the menu in which this item appears.
|
||||
} t_menuitem;
|
||||
|
||||
typedef t_menuitem *pt_menuitem; // Pointer to type menuitem
|
||||
|
||||
typedef struct s_menu {
|
||||
pt_menuitem *items; // pointer to array of pointer to menuitems
|
||||
char *title;
|
||||
int maxmenusize; // the size of array allocated
|
||||
uchar numitems; // how many items do we actually have
|
||||
uchar menuwidth;
|
||||
uchar row,col; // Position where this menu should be displayed
|
||||
uchar menuheight; // Maximum number of items to be displayed
|
||||
} t_menu;
|
||||
|
||||
typedef t_menu *pt_menu; // Pointer to type menu
|
||||
|
||||
typedef struct s_menusystem {
|
||||
pt_menu menus[MAXMENUS];
|
||||
char *title;
|
||||
t_menusystem_handler handler; // Menu system handler
|
||||
t_keys_handler keys_handler; // Handler for unknown keys
|
||||
t_timeout_handler ontimeout; // Timeout handler
|
||||
unsigned long tm_numsteps;
|
||||
// Time to wait for key press=numsteps * stepsize milliseconds
|
||||
unsigned int tm_stepsize; // Timeout step size (in milliseconds)
|
||||
|
||||
int maxmenuheight;
|
||||
uchar nummenus;
|
||||
uchar normalattr[2]; // [0] is non-hlite attr, [1] is hlite attr
|
||||
uchar reverseattr[2];
|
||||
uchar inactattr[2];
|
||||
uchar revinactattr[2];
|
||||
uchar statusattr[2];
|
||||
uchar fillchar;
|
||||
uchar fillattr;
|
||||
uchar spacechar;
|
||||
uchar tfillchar;
|
||||
uchar titleattr;
|
||||
uchar shadowattr;
|
||||
uchar statline;
|
||||
uchar menupage;
|
||||
uchar maxrow,minrow,numrows; // Number of rows in the window
|
||||
uchar maxcol,mincol,numcols; // Number of columns in the window
|
||||
|
||||
// Menu box look
|
||||
boxtype menubt; // What type of boxes should be drawn
|
||||
char box_horiz,box_ltrt,box_rtlt; // Some chars of the box, for redrawing portions of the box
|
||||
|
||||
} t_menusystem;
|
||||
|
||||
typedef t_menusystem *pt_menusystem; // Pointer to type menusystem
|
||||
|
||||
/************************************************************************
|
||||
* IMPORTANT INFORMATION
|
||||
*
|
||||
* All functions which take a string as argument store the pointer
|
||||
* for later use. So if you have alloc'ed a space for the string
|
||||
* and are passing it to any of these functions, DO NOT deallocate it.
|
||||
*
|
||||
* If they are constant strings, you may receive warning from the compiler
|
||||
* about "converting from char const * to char *". Ignore these errors.
|
||||
*
|
||||
* This hack/trick of storing these pointers will help in reducing the size
|
||||
* of the internal structures by a lot.
|
||||
*
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
pt_menuitem showmenus(uchar startmenu);
|
||||
|
||||
pt_menusystem init_menusystem(const char *title);
|
||||
void close_menusystem(); // Deallocate memory used
|
||||
|
||||
void set_normal_attr(uchar normal, uchar selected, uchar inactivenormal, uchar inactiveselected);
|
||||
|
||||
void set_normal_hlite(uchar normal, uchar selected, uchar inactivenormal, uchar inactiveselected);
|
||||
|
||||
void set_status_info(uchar statusattr, uchar statushlite, uchar statline);
|
||||
|
||||
void set_title_info(uchar tfillchar, uchar titleattr);
|
||||
|
||||
void set_misc_info(uchar fillchar, uchar fillattr,uchar spacechar, uchar shadowattr);
|
||||
void set_box_type(boxtype bt);
|
||||
|
||||
void set_window_size(uchar top, uchar left, uchar bot, uchar right); // Set the window which menusystem should use
|
||||
|
||||
void set_menu_options(uchar maxmenuheight);
|
||||
// maximum height of a menu
|
||||
|
||||
void reg_handler(t_handler htype, void * handler); // Register handler
|
||||
|
||||
void unreg_handler( t_handler htype);
|
||||
|
||||
void reg_ontimeout(t_timeout_handler, unsigned int numsteps, unsigned int stepsize);
|
||||
// Set timeout handler, set 0 for default values.
|
||||
// So stepsize=0 means numsteps is measured in centiseconds.
|
||||
void unreg_ontimeout();
|
||||
|
||||
// Create a new menu and return its position
|
||||
uchar add_menu(const char *title, int maxmenusize);
|
||||
|
||||
void set_menu_pos(uchar row,uchar col); // Set the position of this menu.
|
||||
|
||||
// Add item to the "current" menu
|
||||
pt_menuitem add_item(const char *item, const char *status, t_action action, const char *data, uchar itemdata);
|
||||
|
||||
// Set shortcut key and help id
|
||||
void set_item_options(uchar shortcut,int helpid);
|
||||
|
||||
// Set the shortcut key for the current item
|
||||
static inline void set_shortcut(uchar shortcut)
|
||||
{
|
||||
set_item_options(shortcut,0xFFFF);
|
||||
}
|
||||
|
||||
// Add a separator to the "current" menu
|
||||
pt_menuitem add_sep();
|
||||
|
||||
// Main function for the user's config file
|
||||
int menumain(char *cmdline);
|
||||
|
||||
#endif
|
||||
140
extra/syslinux-3.09/menu/libmenu/passwords.c
Normal file
140
extra/syslinux-3.09/menu/libmenu/passwords.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Bostom MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#include "passwords.h"
|
||||
#include "des.h"
|
||||
#include "string.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "tui.h"
|
||||
|
||||
#define MAX_LINE 512
|
||||
// Max line length in a pwdfile
|
||||
p_pwdentry userdb[MAX_USERS]; // Array of pointers
|
||||
int numusers; // Actual number of users
|
||||
|
||||
// returns true or false, i.e. 1 or 0
|
||||
char authenticate_user(const char * username, const char* pwd)
|
||||
{
|
||||
char salt[12];
|
||||
int i, password_ok;
|
||||
|
||||
password_ok=0;
|
||||
|
||||
for (i=0; i< numusers; i++) {
|
||||
if (userdb[i] == NULL) continue;
|
||||
if (strcmp(username,userdb[i]->username)==0) {
|
||||
strcpy(salt, userdb[i]->pwdhash);
|
||||
salt[2] = '\0';
|
||||
if (strcmp(userdb[i]->pwdhash,crypt(pwd,salt))==0) return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Does user USERNAME have permission PERM
|
||||
char isallowed(const char *username, const char *perm)
|
||||
{
|
||||
int i;
|
||||
char *dperm;
|
||||
char *tmp;
|
||||
|
||||
if (strcmp(username,GUEST_USER) == 0) return 0;
|
||||
dperm = (char *) malloc(strlen(perm)+3);
|
||||
strcpy(dperm+1,perm);
|
||||
dperm[0] = ':';
|
||||
dperm[strlen(perm)+1]=':';
|
||||
dperm[strlen(perm)+2]=0;
|
||||
// Now dperm = ":perm:"
|
||||
for (i=0; i < numusers; i++) {
|
||||
if (strcmp(userdb[i]->username,username)==0) // Found the user
|
||||
{
|
||||
if (userdb[i]->perms == NULL) return 0; // No permission
|
||||
tmp = strstr(userdb[i]->perms,dperm); // Search for permission
|
||||
free (dperm); // Release memory
|
||||
if (tmp == NULL) return 0; else return 1;
|
||||
}
|
||||
}
|
||||
// User not found return 0
|
||||
free (dperm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initialise the list of of user passwords permissions from file
|
||||
void init_passwords(const char *filename)
|
||||
{
|
||||
int i;
|
||||
char line[MAX_LINE], *p,*user,*pwdhash,*perms;
|
||||
FILE *f;
|
||||
|
||||
for (i=0; i < MAX_USERS; i++) userdb[i] = NULL;
|
||||
numusers = 0;
|
||||
|
||||
if ( !filename ) return; // No filename specified
|
||||
|
||||
f = fopen(filename,"r");
|
||||
if ( !f ) return; // File does not exist
|
||||
|
||||
// Process each line
|
||||
while ( fgets(line, sizeof line, f) ) {
|
||||
// Replace EOLN with \0
|
||||
p = strchr(line, '\r');
|
||||
if ( p ) *p = '\0';
|
||||
p = strchr(line, '\n');
|
||||
if ( p ) *p = '\0';
|
||||
|
||||
// If comment line or empty ignore line
|
||||
p = line;
|
||||
while (*p==' ') p++; // skip initial spaces
|
||||
if ( (*p == '#') || (*p == '\0')) continue; // Skip comment lines
|
||||
|
||||
user = p; // This is where username starts
|
||||
p = strchr(user,':');
|
||||
if (p == NULL) continue; // Malformed line skip
|
||||
*p = '\0';
|
||||
pwdhash = p+1;
|
||||
if (*pwdhash == 0) continue; // Malformed line (no password specified)
|
||||
p = strchr(pwdhash,':');
|
||||
if (p == NULL) { // No perms specified
|
||||
perms = NULL;
|
||||
} else {
|
||||
*p = '\0';
|
||||
perms = p+1;
|
||||
if (*perms == 0) perms = NULL;
|
||||
}
|
||||
// At this point we have user,pwdhash and perms setup
|
||||
userdb[numusers] = (p_pwdentry)malloc(sizeof(pwdentry));
|
||||
strcpy(userdb[numusers]->username,user);
|
||||
strcpy(userdb[numusers]->pwdhash,pwdhash);
|
||||
if (perms == NULL)
|
||||
userdb[numusers]->perms = NULL;
|
||||
else {
|
||||
userdb[numusers]->perms = (char *)malloc(strlen(perms)+3);
|
||||
(userdb[numusers]->perms)[0] = ':';
|
||||
strcpy(userdb[numusers]->perms + 1,perms);
|
||||
(userdb[numusers]->perms)[strlen(perms)+1] = ':';
|
||||
(userdb[numusers]->perms)[strlen(perms)+2] = 0;
|
||||
// Now perms field points to ":perms:"
|
||||
}
|
||||
numusers++;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void close_passwords()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < numusers; i++)
|
||||
if (userdb[i] != NULL) free(userdb[i]);
|
||||
numusers = 0;
|
||||
}
|
||||
27
extra/syslinux-3.09/menu/libmenu/passwords.h
Normal file
27
extra/syslinux-3.09/menu/libmenu/passwords.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef _PASSWORDS_H_
|
||||
#define _PASSWORDS_H_
|
||||
|
||||
char authenticate_user(const char * username, const char* pwd);
|
||||
|
||||
char isallowed(const char *username, const char * perm);
|
||||
|
||||
// Initialise the list of of user passwords permissions from file
|
||||
void init_passwords(const char *filename);
|
||||
// Free all space used for internal data structures
|
||||
void close_passwords();
|
||||
|
||||
#define MAX_USERS 128 // Maximum number of users
|
||||
#define USERNAME_LENGTH 12 // Max length of user name
|
||||
#define PWDHASH_LENGTH 40 // Max lenght of pwd hash
|
||||
|
||||
typedef struct {
|
||||
char username[USERNAME_LENGTH+1];
|
||||
char pwdhash[PWDHASH_LENGTH+1];
|
||||
char *perms; // pointer to string containing ":" delimited permissions
|
||||
} pwdentry;
|
||||
|
||||
typedef pwdentry *p_pwdentry;
|
||||
|
||||
#define GUEST_USER "guest"
|
||||
|
||||
#endif
|
||||
75
extra/syslinux-3.09/menu/libmenu/scancodes.h
Normal file
75
extra/syslinux-3.09/menu/libmenu/scancodes.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef __SCANCODES_H__
|
||||
#define __SCANCODES_H__
|
||||
|
||||
// Scancodes of some keys
|
||||
#define ESCAPE 1
|
||||
#define ENTERA 28
|
||||
#define ENTERB 224
|
||||
|
||||
#define HOMEKEY 71
|
||||
#define UPARROW 72
|
||||
#define PAGEUP 73
|
||||
#define LTARROW 75
|
||||
#define RTARROW 77
|
||||
#define ENDKEY 79
|
||||
#define DNARROW 80
|
||||
#define PAGEDN 81
|
||||
#define INSERT 82
|
||||
#define DELETE 83
|
||||
#define SPACEKEY 57 // Scan code for SPACE
|
||||
|
||||
#define CTRLLT 0x73
|
||||
#define CTRLRT 0x74
|
||||
|
||||
#define F1 0x3B
|
||||
#define F2 0x3C
|
||||
#define F3 0x3D
|
||||
#define F4 0x3E
|
||||
#define F5 0x3F
|
||||
#define F6 0x40
|
||||
#define F7 0x41
|
||||
#define F8 0x42
|
||||
#define F9 0x43
|
||||
#define F10 0x44
|
||||
#define F11 0x85
|
||||
#define F12 0x86
|
||||
|
||||
#define CTRLF1 0x5E
|
||||
#define CTRLF2 0x5F
|
||||
#define CTRLF3 0x60
|
||||
#define CTRLF4 0x61
|
||||
#define CTRLF5 0x62
|
||||
#define CTRLF6 0x63
|
||||
#define CTRLF7 0x64
|
||||
#define CTRLF8 0x65
|
||||
#define CTRLF9 0x66
|
||||
#define CTRLF10 0x67
|
||||
#define CTRLF11 0x89
|
||||
#define CTRLF12 0x8A
|
||||
|
||||
#define ALTF1 0x68
|
||||
#define ALTF2 0x69
|
||||
#define ALTF3 0x6A
|
||||
#define ALTF4 0x6B
|
||||
#define ALTF5 0x6C
|
||||
#define ALTF6 0x6D
|
||||
#define ALTF7 0x6E
|
||||
#define ALTF8 0x6F
|
||||
#define ALTF9 0x70
|
||||
#define ALTF10 0x71
|
||||
#define ALTF11 0x8B
|
||||
#define ALTF12 0x8C
|
||||
|
||||
#endif
|
||||
44
extra/syslinux-3.09/menu/libmenu/syslnx.c
Normal file
44
extra/syslinux-3.09/menu/libmenu/syslnx.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#include <string.h>
|
||||
#include <com32.h>
|
||||
#include "syslnx.h"
|
||||
|
||||
com32sys_t inreg,outreg; // Global registers for this module
|
||||
|
||||
char issyslinux(void)
|
||||
{
|
||||
REG_EAX(inreg) = 0x00003000;
|
||||
REG_EBX(inreg) = REG_ECX(inreg) = REG_EDX(inreg) = 0xFFFFFFFF;
|
||||
__intcall(0x21,&inreg,&outreg);
|
||||
return (REG_EAX(outreg) == 0x59530000) &&
|
||||
(REG_EBX(outreg) == 0x4c530000) &&
|
||||
(REG_ECX(outreg) == 0x4e490000) &&
|
||||
(REG_EDX(outreg) == 0x58550000);
|
||||
}
|
||||
|
||||
void runsyslinuxcmd(const char *cmd)
|
||||
{
|
||||
strcpy(__com32.cs_bounce, cmd);
|
||||
REG_AX(inreg) = 0x0003; // Run command
|
||||
REG_BX(inreg) = OFFS(__com32.cs_bounce);
|
||||
inreg.es = SEG(__com32.cs_bounce);
|
||||
__intcall(0x22, &inreg, &outreg);
|
||||
}
|
||||
|
||||
void gototxtmode(void)
|
||||
{
|
||||
REG_AX(inreg) = 0x0005;
|
||||
__intcall(0x22,&inreg,&outreg);
|
||||
}
|
||||
|
||||
47
extra/syslinux-3.09/menu/libmenu/syslnx.h
Normal file
47
extra/syslinux-3.09/menu/libmenu/syslnx.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef __SYSLNX_H__
|
||||
#define __SYSLNX_H__
|
||||
|
||||
#include <com32.h>
|
||||
|
||||
//Macros which help user not have to remember the structure of register
|
||||
// Data structure
|
||||
|
||||
#define REG_AH(x) ((x).eax.b[1])
|
||||
#define REG_AL(x) ((x).eax.b[0])
|
||||
#define REG_AX(x) ((x).eax.w[0])
|
||||
#define REG_EAX(x) ((x).eax.l)
|
||||
|
||||
#define REG_BH(x) ((x).ebx.b[1])
|
||||
#define REG_BL(x) ((x).ebx.b[0])
|
||||
#define REG_BX(x) ((x).ebx.w[0])
|
||||
#define REG_EBX(x) ((x).ebx.l)
|
||||
|
||||
#define REG_CH(x) ((x).ecx.b[1])
|
||||
#define REG_CL(x) ((x).ecx.b[0])
|
||||
#define REG_CX(x) ((x).ecx.w[0])
|
||||
#define REG_ECX(x) ((x).ecx.l)
|
||||
|
||||
#define REG_DH(x) ((x).edx.b[1])
|
||||
#define REG_DL(x) ((x).edx.b[0])
|
||||
#define REG_DX(x) ((x).edx.w[0])
|
||||
#define REG_EDX(x) ((x).edx.l)
|
||||
|
||||
char issyslinux(void); /* Check if syslinux is running */
|
||||
|
||||
void runsyslinuxcmd(const char *cmd); /* Run specified command */
|
||||
|
||||
void gototxtmode(void); /* Change mode to text mode */
|
||||
|
||||
#endif
|
||||
360
extra/syslinux-3.09/menu/libmenu/tui.c
Normal file
360
extra/syslinux-3.09/menu/libmenu/tui.c
Normal file
@@ -0,0 +1,360 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#include <string.h>
|
||||
#include <com32.h>
|
||||
#include "tui.h"
|
||||
#include "syslnx.h"
|
||||
#include "com32io.h"
|
||||
#include "scancodes.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
com32sys_t inreg,outreg; // Global register sets for use
|
||||
|
||||
char bkspstr[] = " \b$";
|
||||
char eolstr[] = "\n$";
|
||||
#define GETSTRATTR 0x07
|
||||
|
||||
// Reads a line of input from stdin. Replace CR with NUL byte
|
||||
// password <> 0 implies not echoed on screen
|
||||
// showoldvalue <> 0 implies currentvalue displayed first
|
||||
// If showoldvalue <> 0 then caller responsibility to ensure that
|
||||
// str is NULL terminated.
|
||||
void getuserinput(char *stra, unsigned int size, unsigned int password,
|
||||
unsigned int showoldvalue)
|
||||
{
|
||||
unsigned char c,scan;
|
||||
char *p,*q; // p = current char of string, q = tmp
|
||||
char *last; // The current last char of string
|
||||
char *str; // pointer to string which is going to be allocated
|
||||
char page;
|
||||
char row,col;
|
||||
char start,end; // Cursor shape
|
||||
char fudge; // How many chars should be removed from output
|
||||
char insmode; // Are we in insert or overwrite
|
||||
|
||||
page = getdisppage();
|
||||
getpos(&row,&col,page); // Get current position
|
||||
getcursorshape(&start,&end);
|
||||
insmode = 1;
|
||||
|
||||
str = (char *)malloc(size+1); // Allocate memory to store user input
|
||||
memset(str,0,size+1); // Zero it out
|
||||
if (password != 0) showoldvalue = 0; // Password's never displayed
|
||||
|
||||
if (showoldvalue != 0) strcpy(str,stra); // If show old value copy current value
|
||||
|
||||
last = str;
|
||||
while (*last) {last++;} // Find the terminating null byte
|
||||
p = str+ strlen(str);
|
||||
|
||||
if (insmode == 0)
|
||||
setcursorshape(1,7); // Block cursor
|
||||
else setcursorshape(6,7); // Normal cursor
|
||||
|
||||
// Invariants: p is the current char
|
||||
// col is the corresponding column on the screen
|
||||
if (password == 0) // Not a password, print initial value
|
||||
{
|
||||
gotoxy(row,col,page);
|
||||
csprint(str,GETSTRATTR);
|
||||
}
|
||||
while (1) { // Do forever
|
||||
c = inputc(&scan);
|
||||
if (c == '\r') break; // User hit Enter getout of loop
|
||||
if (scan == ESCAPE) // User hit escape getout and nullify string
|
||||
{ *str = 0;
|
||||
break;
|
||||
}
|
||||
fudge = 0;
|
||||
// if scan code is regognized do something
|
||||
// else if char code is recognized do something
|
||||
// else ignore
|
||||
switch(scan) {
|
||||
case HOMEKEY:
|
||||
p = str;
|
||||
break;
|
||||
case ENDKEY:
|
||||
p = last;
|
||||
break;
|
||||
case LTARROW:
|
||||
if (p > str) p--;
|
||||
break;
|
||||
case CTRLLT:
|
||||
if (p==str) break;
|
||||
if (*p == ' ')
|
||||
while ((p > str) && (*p == ' ')) p--;
|
||||
else {
|
||||
if (*(p-1) == ' ') {
|
||||
p--;
|
||||
while ((p > str) && (*p == ' ')) p--;
|
||||
}
|
||||
}
|
||||
while ((p > str) && ((*p == ' ') || (*(p-1) != ' '))) p--;
|
||||
break;
|
||||
case RTARROW:
|
||||
if (p < last) p++;
|
||||
break;
|
||||
case CTRLRT:
|
||||
if (*p==0) break; // At end of string
|
||||
if (*p != ' ')
|
||||
while ((*p!=0) && (*p != ' ')) p++;
|
||||
while ((*p!=0) && ((*p == ' ') && (*(p+1) != ' '))) p++;
|
||||
if (*p==' ') p++;
|
||||
break;
|
||||
case DELETE:
|
||||
q = p;
|
||||
while (*(q+1)) {*q = *(q+1); q++; }
|
||||
if (last > str) last--;
|
||||
fudge = 1;
|
||||
break;
|
||||
case INSERT:
|
||||
insmode = 1-insmode; // Switch mode
|
||||
if (insmode == 0)
|
||||
setcursorshape(1,7); // Block cursor
|
||||
else setcursorshape(6,7); // Normal cursor
|
||||
break;
|
||||
|
||||
default: // Unrecognized scan code, look at the ascii value
|
||||
switch (c) {
|
||||
case '\b': // Move over by one
|
||||
q=p;
|
||||
while ( q <= last ) { *(q-1)=*q; q++;}
|
||||
if (last > str) last--;
|
||||
if (p > str) p--;
|
||||
fudge = 1;
|
||||
break;
|
||||
case '\x15': /* Ctrl-U: kill input */
|
||||
fudge = last-str;
|
||||
while ( p > str ) *p--=0;
|
||||
p = str; *p=0; last = str;
|
||||
break;
|
||||
default: // Handle insert and overwrite mode
|
||||
if ((c >= ' ') && (c < 128) &&
|
||||
((unsigned int)(p-str) < size-1) ) {
|
||||
if (insmode == 0) { // Overwrite mode
|
||||
if (p==last) last++;
|
||||
*last = 0;
|
||||
*p++ = c;
|
||||
} else { // Insert mode
|
||||
if (p==last) { // last char
|
||||
last++;
|
||||
*last=0;
|
||||
*p++=c;
|
||||
} else { // Non-last char
|
||||
q=last++;
|
||||
while (q >= p) { *q=*(q-1); q--;}
|
||||
*p++=c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else beep();
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Now the string has been modified, print it
|
||||
if (password == 0) {
|
||||
gotoxy(row,col,page);
|
||||
csprint(str,GETSTRATTR);
|
||||
if (fudge > 0) cprint(' ',GETSTRATTR,fudge,page);
|
||||
gotoxy(row,col+(p-str),page);
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
if (password == 0) csprint("\r\n",GETSTRATTR);
|
||||
setcursorshape(start,end); // Block cursor
|
||||
// If user hit ESCAPE so return without any changes
|
||||
if (scan != ESCAPE) strcpy(stra,str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
/* Print a C string (NUL-terminated) */
|
||||
void cswprint(const char *str,char attr,char left)
|
||||
{
|
||||
char page = getdisppage();
|
||||
char newattr=0,cha,chb;
|
||||
char row,col;
|
||||
char nr,nc;
|
||||
|
||||
nr = getnumrows();
|
||||
nc = getnumcols();
|
||||
getpos(&row,&col,page);
|
||||
while ( *str ) {
|
||||
switch (*str)
|
||||
{
|
||||
case '\b':
|
||||
--col;
|
||||
break;
|
||||
case '\n':
|
||||
++row;
|
||||
col = left;
|
||||
break;
|
||||
case '\r':
|
||||
//col=left;
|
||||
break;
|
||||
case BELL: // Bell Char
|
||||
beep();
|
||||
break;
|
||||
case CHRELATTR: // change attribute (relatively)
|
||||
case CHABSATTR: // change attribute (absolute)
|
||||
cha = *(str+1);
|
||||
chb = *(str+2);
|
||||
if ((((cha >= '0') && (cha <= '9')) ||
|
||||
((cha >= 'A') && (cha <= 'F'))) &&
|
||||
(((chb >= '0') && (chb <= '9')) ||
|
||||
((chb >= 'A') && (chb <= 'F')))) // Next two chars are legal
|
||||
{
|
||||
if ((cha >= 'A') && (cha <= 'F'))
|
||||
cha = cha - 'A'+10;
|
||||
else cha = cha - '0';
|
||||
if ((chb >= 'A') && (chb <= 'F'))
|
||||
chb = chb - 'A'+10;
|
||||
else chb = chb - '0';
|
||||
newattr = (cha << 4) + chb;
|
||||
attr = (*str == CHABSATTR ? newattr : attr ^ newattr);
|
||||
str += 2; // Will be incremented again later
|
||||
}
|
||||
break;
|
||||
default:
|
||||
putch(*str, attr, page);
|
||||
++col;
|
||||
}
|
||||
if (col >= nc)
|
||||
{
|
||||
++row;
|
||||
col=left;
|
||||
}
|
||||
if (row > nr)
|
||||
{
|
||||
scrollup();
|
||||
row= nr;
|
||||
}
|
||||
gotoxy(row,col,page);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
void clearwindow(char top, char left, char bot, char right, char page, char fillchar, char fillattr)
|
||||
{
|
||||
char x;
|
||||
for (x=top; x < bot+1; x++)
|
||||
{
|
||||
gotoxy(x,left,page);
|
||||
cprint(fillchar,fillattr,right-left+1,page);
|
||||
}
|
||||
}
|
||||
|
||||
void cls(void)
|
||||
{
|
||||
unsigned char dp = getdisppage();
|
||||
gotoxy(0,0,dp);
|
||||
cprint(' ',GETSTRATTR,(1+getnumrows())*getnumcols(),dp);
|
||||
}
|
||||
|
||||
//////////////////////////////Box Stuff
|
||||
|
||||
// This order of numbers must match
|
||||
// the values of BOX_TOPLEFT,... in the header file
|
||||
|
||||
unsigned char SINSIN_CHARS[] = {218,192,191,217, //Corners
|
||||
196,179, // Horiz and Vertical
|
||||
195,180,194,193,197}; // Connectors & Middle
|
||||
|
||||
unsigned char DBLDBL_CHARS[] = {201,200,187,188, // Corners
|
||||
205,186, // Horiz and Vertical
|
||||
199,182,203,202,206}; // Connectors & Middle
|
||||
|
||||
unsigned char SINDBL_CHARS[] = {214,211,183,189, // Corners
|
||||
196,186, // Horiz & Vert
|
||||
199,182,210,208,215}; // Connectors & Middle
|
||||
|
||||
unsigned char DBLSIN_CHARS[] = {213,212,184,190, // Corners
|
||||
205,179, // Horiz & Vert
|
||||
198,181,209,207,216}; // Connectors & Middle
|
||||
|
||||
unsigned char * getboxchars(boxtype bt)
|
||||
{
|
||||
switch (bt)
|
||||
{
|
||||
case BOX_SINSIN:
|
||||
return SINSIN_CHARS;
|
||||
break;
|
||||
case BOX_DBLDBL:
|
||||
return DBLDBL_CHARS;
|
||||
break;
|
||||
case BOX_SINDBL:
|
||||
return SINDBL_CHARS;
|
||||
break;
|
||||
case BOX_DBLSIN:
|
||||
return DBLSIN_CHARS;
|
||||
break;
|
||||
default:
|
||||
return SINSIN_CHARS;
|
||||
break;
|
||||
}
|
||||
return SINSIN_CHARS;
|
||||
}
|
||||
|
||||
// Draw box and lines
|
||||
void drawbox(char top,char left,char bot, char right,
|
||||
char page, char attr,boxtype bt)
|
||||
{
|
||||
unsigned char *box_chars; // pointer to array of box chars
|
||||
unsigned char x;
|
||||
|
||||
box_chars = getboxchars(bt);
|
||||
// Top border
|
||||
gotoxy(top,left,page);
|
||||
cprint(box_chars[BOX_TOPLEFT],attr,1,page);
|
||||
gotoxy(top,left+1,page);
|
||||
cprint(box_chars[BOX_TOP],attr,right-left,page);
|
||||
gotoxy(top,right,page);
|
||||
cprint(box_chars[BOX_TOPRIGHT],attr,1,page);
|
||||
// Bottom border
|
||||
gotoxy(bot,left,page);
|
||||
cprint(box_chars[BOX_BOTLEFT],attr,1,page);
|
||||
gotoxy(bot,left+1,page);
|
||||
cprint(box_chars[BOX_BOT],attr,right-left,page);
|
||||
gotoxy(bot,right,page);
|
||||
cprint(box_chars[BOX_BOTRIGHT],attr,1,page);
|
||||
// Left & right borders
|
||||
for (x=top+1; x < bot; x++)
|
||||
{
|
||||
gotoxy(x,left,page);
|
||||
cprint(box_chars[BOX_LEFT],attr,1,page);
|
||||
gotoxy(x,right,page);
|
||||
cprint(box_chars[BOX_RIGHT],attr,1,page);
|
||||
}
|
||||
}
|
||||
|
||||
void drawhorizline(char top, char left, char right, char page, char attr,
|
||||
boxtype bt, char dumb)
|
||||
{
|
||||
unsigned char start,end;
|
||||
unsigned char *box_chars = getboxchars(bt);
|
||||
if (dumb==0) {
|
||||
start = left+1;
|
||||
end = right-1;
|
||||
} else {
|
||||
start = left;
|
||||
end = right;
|
||||
}
|
||||
gotoxy(top,start,page);
|
||||
cprint(box_chars[BOX_HORIZ],attr,end-start+1,page);
|
||||
if (dumb == 0)
|
||||
{
|
||||
gotoxy(top,left,page);
|
||||
cprint(box_chars[BOX_LTRT],attr,1,page);
|
||||
gotoxy(top,right,page);
|
||||
cprint(box_chars[BOX_RTLT],attr,1,page);
|
||||
}
|
||||
}
|
||||
85
extra/syslinux-3.09/menu/libmenu/tui.h
Normal file
85
extra/syslinux-3.09/menu/libmenu/tui.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef __TUI_H__
|
||||
#define __TUI_H__
|
||||
|
||||
#include <com32.h>
|
||||
#include "com32io.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#define BELL 0x07
|
||||
// CHRELATTR = ^N, CHABSATTR = ^O
|
||||
#define CHABSATTR 15
|
||||
#define CHRELATTR 14
|
||||
|
||||
void clearwindow(char top, char left, char bot, char right,
|
||||
char page, char fillchar, char fillattr);
|
||||
|
||||
void cls(void); /* Clears the entire current screen page */
|
||||
|
||||
// Generic user input,
|
||||
// password = 0 iff chars echoed on screen
|
||||
// showoldvalue <> 0 iff current displayed for editing
|
||||
void getuserinput(char *str, unsigned int size,
|
||||
unsigned int password, unsigned int showoldvalue);
|
||||
|
||||
static inline void getstring(char *str, unsigned int size)
|
||||
{
|
||||
getuserinput(str,size,0,0);
|
||||
}
|
||||
|
||||
static inline void editstring(char *str, unsigned int size)
|
||||
{
|
||||
getuserinput(str,size,0,1);
|
||||
}
|
||||
|
||||
static inline void getpwd(char * str, unsigned int size)
|
||||
{
|
||||
getuserinput(str,size,1,0);
|
||||
}
|
||||
|
||||
// Box drawing Chars offsets into array
|
||||
#define BOX_TOPLEFT 0x0
|
||||
#define BOX_BOTLEFT 0x1
|
||||
#define BOX_TOPRIGHT 0x2
|
||||
#define BOX_BOTRIGHT 0x3
|
||||
#define BOX_TOP 0x4 // TOP = BOT = HORIZ
|
||||
#define BOX_BOT 0x4
|
||||
#define BOX_HORIZ 0x4
|
||||
#define BOX_LEFT 0x5
|
||||
#define BOX_RIGHT 0x5
|
||||
#define BOX_VERT 0x5 // LEFT=RIGHT=VERT
|
||||
#define BOX_LTRT 0x6
|
||||
#define BOX_RTLT 0x7
|
||||
#define BOX_TOPBOT 0x8
|
||||
#define BOX_BOTTOP 0x9
|
||||
#define BOX_MIDDLE 0xA
|
||||
|
||||
typedef enum {BOX_SINSIN,BOX_DBLDBL, BOX_SINDBL, BOX_DBLSIN} boxtype;
|
||||
|
||||
unsigned char * getboxchars(boxtype bt);
|
||||
|
||||
void drawbox(char top,char left,char bot, char right,
|
||||
char page, char attr,boxtype bt);
|
||||
|
||||
// Draw a horizontal line
|
||||
// dumb == 1, means just draw the line
|
||||
// dumb == 0 means check the first and last positions and depending on what is
|
||||
// currently on the screen make it a LTRT and/or RTLT appropriately.
|
||||
void drawhorizline(char top, char left, char right, char page, char attr,
|
||||
boxtype bt, char dumb);
|
||||
|
||||
#endif
|
||||
19
extra/syslinux-3.09/menu/password
Normal file
19
extra/syslinux-3.09/menu/password
Normal file
@@ -0,0 +1,19 @@
|
||||
# This file should be available as /isolinux/password
|
||||
# for complex.c to use.
|
||||
#
|
||||
# All lines starting with # and empty lines are ignored
|
||||
#
|
||||
# All non-comment lines here are of the form
|
||||
# USERNAME:PWDHASH:PERM1:PERM2:...:
|
||||
#
|
||||
# where USERNAME is maximum of 12 chars,
|
||||
# PWDHASH is maximum of 40 chars (DES ENCRYPTED)
|
||||
# PERM1,... are arbitrary strings
|
||||
#
|
||||
# The current lines correspond to
|
||||
# user1:secret1, user2:secret2, user3:secret3
|
||||
|
||||
user1:LcMRo3YZGtP0c:editcmd
|
||||
user2:FqewzyxP78a7A:
|
||||
user3:MKjmc.IHoXBNU:root
|
||||
|
||||
78
extra/syslinux-3.09/menu/simple.c
Normal file
78
extra/syslinux-3.09/menu/simple.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -*- c -*- ------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, Inc., 53 Temple Place Ste 330,
|
||||
* Boston MA 02111-1307, USA; either version 2 of the License, or
|
||||
* (at your option) any later version; incorporated herein by reference.
|
||||
*
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
#include "menu.h"
|
||||
#include "com32io.h"
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
t_menuitem * curr;
|
||||
|
||||
char TESTING,RESCUE,MAIN; /* The menus we're going to declare */
|
||||
|
||||
// Change the video mode here
|
||||
// setvideomode(0)
|
||||
|
||||
// Choose the default title and setup default values for all attributes....
|
||||
init_menusystem(NULL);
|
||||
set_window_size(1,1,23,78); // Leave one row/col border all around
|
||||
|
||||
// Choose the default values for all attributes and char's
|
||||
// -1 means choose defaults (Actually the next 4 lines are not needed)
|
||||
//set_normal_attr (-1,-1,-1,-1);
|
||||
//set_status_info (-1,-1);
|
||||
//set_title_info (-1,-1);
|
||||
//set_misc_info(-1,-1,-1,-1);
|
||||
|
||||
// menuindex = add_menu(" Menu Title ",-1);
|
||||
// add_item("Item string","Status String",TYPE,"any string",NUM)
|
||||
// TYPE = OPT_RUN | OPT_EXITMENU | OPT_SUBMENU | OPT_CHECKBOX | OPT_INACTIVE
|
||||
// "any string" not used by the menu system, useful for storing kernel names
|
||||
// NUM = index of submenu if OPT_SUBMENU,
|
||||
// 0/1 default checked state if OPT_CHECKBOX
|
||||
// unused otherwise.
|
||||
|
||||
TESTING = add_menu(" Testing ",-1);
|
||||
add_item("Self Loop","Go to testing",OPT_SUBMENU,NULL,TESTING);
|
||||
add_item("Memory Test","Perform extensive memory testing",OPT_RUN, "memtest",0);
|
||||
add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
|
||||
|
||||
RESCUE = add_menu(" Rescue Options ",-1);
|
||||
add_item("Linux Rescue","linresc",OPT_RUN,"linresc",0);
|
||||
add_item("Dos Rescue","dosresc",OPT_RUN,"dosresc",0);
|
||||
add_item("Windows Rescue","winresc",OPT_RUN,"winresc",0);
|
||||
add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
|
||||
|
||||
MAIN = add_menu(" Main Menu ",-1);
|
||||
add_item("Prepare","prep",OPT_RUN,"prep",0);
|
||||
add_item("Rescue options...","Troubleshoot a system",OPT_SUBMENU,NULL,RESCUE);
|
||||
add_item("Testing...","Options to test hardware",OPT_SUBMENU,NULL,TESTING);
|
||||
add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
|
||||
|
||||
curr = showmenus(MAIN); // Initial menu is the one with index MAIN
|
||||
if (curr)
|
||||
{
|
||||
if (curr->action == OPT_RUN)
|
||||
{
|
||||
if (issyslinux()) runsyslinuxcmd(curr->data);
|
||||
else csprint(curr->data,0x07);
|
||||
return 1;
|
||||
}
|
||||
csprint("Error in programming!",0x07);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user