Changeset 57c8555003f53800da1bb93a765d80678ae230ae

Show
Ignore:
Timestamp:
10/27/09 20:04:31 (2 years ago)
Author:
Pierre-Alexandre Meyer <pierre@…>
Children:
4dc540d979c770c6131217d6e94b29a6f188e1c1
Parents:
47ac912cd5d8df0a96b8f5b98d7476f7cfb1cb19, 3fc3126d0c7df5701680e043c34f200166f24564
git-committer:
Pierre-Alexandre Meyer <pierre@ning.com> / 2009-10-27T13:04:31Z-0700
Message:

Merge commit 'erwan/master' into hdt-0.3.5

Files:
12 added
3 removed
49 modified

Legend:

Unmodified
Added
Removed
  • MCONFIG

    rfe9385 r18d726  
    5353GZIPPROG = gzip 
    5454PNGTOPNM = pngtopnm 
     55MCOPY    = mcopy 
     56MFORMAT  = mformat 
     57MKISOFS  = mkisofs 
    5558 
    5659com32    = $(topdir)/com32 
  • NEWS

    r788da30 r0d5291  
    1919        * Simple menu: fix crash on some platforms. 
    2020        * Gfxboot: fixes to the configuration file parsing. 
     21        * PXELINUX: add a tool to override specific DHCP options via 
     22          values hardcoded in the pxelinux.0 file.  These hardcoded 
     23          values can be either "before DHCP" (defaults if DHCP do not 
     24          provide values), or "after DHCP" (overrides DHCP).  The tool 
     25          pxelinux-options can be used to set these options.  This 
     26          feature does not apply to gpxelinux.0; when used with gPXE 
     27          this is better handled by modifying the embedded script. 
    2128 
    2229Changes in 3.82: 
  • com32/cmenu/adv_menu.tpl

    r37bfb1 r352337  
    4141#include <string.h> 
    4242#include <stdlib.h> 
     43#include <unistd.h> 
    4344 
    4445#define MAX_CMD_LINE_LENGTH 514 
     
    193194} 
    194195 
    195 void keys_handler(t_menusystem *ms, t_menuitem *mi,unsigned int scancode) 
    196 { 
    197    char nc; 
    198  
    199    if ( ((scancode >> 8) == F1) && (mi->helpid != 0xFFFF) ) { // If scancode of F1 and non-trivial helpid 
     196void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode) 
     197{ 
     198   int nc, nr; 
     199 
     200   if (getscreensize(1, &nr, &nc)) { 
     201       /* Unknown screen size? */ 
     202       nc = 80; 
     203       nr = 24; 
     204   } 
     205 
     206   if ( (scancode == KEY_F1) && (mi->helpid != 0xFFFF) ) { // If scancode of F1 and non-trivial helpid 
    200207      runhelpsystem(mi->helpid); 
    201208   } 
     
    203210   // If user hit TAB, and item is an "executable" item 
    204211   // and user has privileges to edit it, edit it in place. 
    205    if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN) && 
    206        (EDIT_ROW < getnumrows()) && (EDIT_ROW > 0) && 
     212   if ((scancode == KEY_TAB) && (mi->action == OPT_RUN) && 
     213       (EDIT_ROW < nr) && (EDIT_ROW > 0) && 
    207214       (isallowed(username,"editcmd") || isallowed(username,"root"))) { 
    208      nc = getnumcols(); 
    209215     // User typed TAB and has permissions to edit command line 
    210      gotoxy(EDIT_ROW,1,ms->menupage); 
     216     gotoxy(EDIT_ROW,1); 
    211217     csprint("Command line:",0x07); 
    212218     editstring(mi->data,ACTIONLEN); 
    213      gotoxy(EDIT_ROW,1,ms->menupage); 
    214      cprint(' ',0x07,nc-1,ms->menupage); 
    215    } 
    216 } 
    217  
    218 t_handler_return login_handler(t_menusystem *ms, t_menuitem *mi) 
     219     gotoxy(EDIT_ROW,1); 
     220     cprint(' ',0x07,nc-1); 
     221   } 
     222} 
     223 
     224t_handler_return login_handler(t_menuitem *mi) 
    219225{ 
    220226  (void)mi; // Unused 
    221227  char pwd[40]; 
    222228  char login[40]; 
    223   char nc; 
     229  int nc, nr; 
    224230  t_handler_return rv; 
    225231 
     
    228234 
    229235  if (mi->item == loginstr) { /* User wants to login */ 
    230     nc = getnumcols(); 
    231     gotoxy(PWD_ROW,1,ms->menupage); 
     236    if (getscreensize(1, &nr, &nc)) { 
     237        /* Unknown screen size? */ 
     238        nc = 80; 
     239        nr = 24; 
     240    } 
     241 
     242    gotoxy(PWD_ROW,1); 
    232243    csprint("Enter Username: ",0x07); 
    233244    getstring(login, sizeof username); 
    234     gotoxy(PWD_ROW,1,ms->menupage); 
    235     cprint(' ',0x07,nc,ms->menupage); 
     245    gotoxy(PWD_ROW,1); 
     246    cprint(' ',0x07,nc); 
    236247    csprint("Enter Password: ",0x07); 
    237248    getpwd(pwd, sizeof pwd); 
    238     gotoxy(PWD_ROW,1,ms->menupage); 
    239     cprint(' ',0x07,nc,ms->menupage); 
     249    gotoxy(PWD_ROW,1); 
     250    cprint(' ',0x07,nc); 
    240251 
    241252    if (authenticate_user(login,pwd)) 
  • com32/cmenu/complex.c

    r9e5b97 r3e8d9f  
    2222#include <stdlib.h> 
    2323#include <stdio.h> 
     24#include <unistd.h> 
     25#include <getkey.h> 
    2426 
    2527/* Global variables */ 
     
    6668#define EDITPROMPT 21 
    6769 
    68 void keys_handler(t_menusystem * ms, t_menuitem * mi, unsigned int scancode) 
    69 { 
    70     char nc; 
    71  
    72     if ((scancode >> 8) == F1) {        // If scancode of F1 
     70void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode) 
     71{ 
     72    int nc, nr; 
     73 
     74    if ((scancode) == KEY_F1 && mi->helpid != 0xFFFF) { // If scancode of F1 
    7375        runhelpsystem(mi->helpid); 
    7476    } 
    7577    // If user hit TAB, and item is an "executable" item 
    7678    // and user has privileges to edit it, edit it in place. 
    77     if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN) && 
     79    if ((scancode == KEY_TAB) && (mi->action == OPT_RUN) && 
    7880        (isallowed(username, "editcmd") || isallowed(username, "root"))) { 
    79         nc = getnumcols(); 
     81    if (getscreensize(1, &nr, &nc)) { 
     82        /* Unknown screen size? */ 
     83        nc = 80; 
     84        nr = 24; 
     85    } 
    8086        // User typed TAB and has permissions to edit command line 
    81         gotoxy(EDITPROMPT, 1, ms->menupage); 
     87        gotoxy(EDITPROMPT, 1); 
    8288        csprint("Command line:", 0x07); 
    8389        editstring(mi->data, ACTIONLEN); 
    84         gotoxy(EDITPROMPT, 1, ms->menupage); 
    85         cprint(' ', 0x07, nc - 1, ms->menupage); 
    86     } 
    87 } 
    88  
    89 t_handler_return login_handler(t_menusystem * ms, t_menuitem * mi) 
     90        gotoxy(EDITPROMPT, 1); 
     91    clear_line(); 
     92    } 
     93} 
     94 
     95t_handler_return login_handler(t_menuitem * mi) 
    9096{ 
    9197    (void)mi;                   // Unused 
    9298    char pwd[40]; 
    9399    char login[40]; 
    94     char nc; 
     100    int nc, nr; 
    95101    t_handler_return rv; 
    96102 
    97103    if (mi->item == loginstr) { /* User wants to login */ 
    98         nc = getnumcols(); 
    99         gotoxy(PWDPROMPT, 1, ms->menupage); 
     104    if (getscreensize(1, &nr, &nc)) { 
     105        /* Unknown screen size? */ 
     106        nc = 80; 
     107        nr = 24; 
     108    } 
     109        gotoxy(PWDPROMPT, 1); 
    100110        csprint("Enter Username: ", 0x07); 
    101111        getstring(login, sizeof username); 
    102         gotoxy(PWDPROMPT, 1, ms->menupage); 
    103         cprint(' ', 0x07, nc, ms->menupage); 
     112        gotoxy(PWDPROMPT, 1); 
     113    clear_line(); 
    104114        csprint("Enter Password: ", 0x07); 
    105115        getpwd(pwd, sizeof pwd); 
    106         gotoxy(PWDPROMPT, 1, ms->menupage); 
    107         cprint(' ', 0x07, nc, ms->menupage); 
     116        gotoxy(PWDPROMPT, 1); 
     117    clear_line(); 
    108118 
    109119        if (authenticate_user(login, pwd)) { 
     
    134144void msys_handler(t_menusystem * ms, t_menuitem * mi) 
    135145{ 
    136     char nc; 
     146    int nc, nr; 
    137147    void *v; 
    138     nc = getnumcols();          // Get number of columns 
    139  
    140     gotoxy(PWDLINE, PWDCOLUMN, ms->menupage); 
     148 
     149    if (getscreensize(1, &nr, &nc)) { 
     150        /* Unknown screen size? */ 
     151        nc = 80; 
     152        nr = 24; 
     153    } 
     154    gotoxy(PWDLINE, PWDCOLUMN); 
    141155    csprint("User: ", PWDATTR); 
    142     cprint(ms->fillchar, ms->fillattr, sizeof username, ms->menupage); 
    143     gotoxy(PWDLINE, PWDCOLUMN + 6, ms->menupage); 
     156    cprint(ms->fillchar, ms->fillattr, sizeof username); 
     157    gotoxy(PWDLINE, PWDCOLUMN + 6); 
    144158    csprint(username, PWDATTR); 
    145159 
    146160    if (mi->parindex != PREPMENU)       // If we are not in the PREP MENU 
    147161    { 
    148         gotoxy(INFLINE, 0, ms->menupage); 
    149         cprint(' ', 0x07, nc, ms->menupage); 
    150         gotoxy(INFLINE + 1, 0, ms->menupage); 
    151         cprint(' ', 0x07, nc, ms->menupage); 
     162        gotoxy(INFLINE, 0); 
     163    reset_colors(); 
     164    clear_line(); 
     165        gotoxy(INFLINE + 1, 0); 
     166    clear_line(); 
    152167        return; 
    153168    } 
     
    168183        strcat(infoline, "repair=lin "); 
    169184 
    170     gotoxy(INFLINE, 0, ms->menupage); 
    171     cprint(' ', 0x07, nc, ms->menupage); 
    172     gotoxy(INFLINE + 1, 0, ms->menupage); 
    173     cprint(' ', 0x07, nc, ms->menupage); 
    174     gotoxy(INFLINE, 0, ms->menupage); 
     185    gotoxy(INFLINE, 0); 
     186    reset_colors(); 
     187    clear_line(); 
     188    gotoxy(INFLINE + 1, 0); 
     189    clear_line(); 
     190    gotoxy(INFLINE, 0); 
    175191    csprint("Kernel Arguments:", 0x07); 
    176     gotoxy(INFLINE, 17, ms->menupage); 
     192    gotoxy(INFLINE, 17); 
    177193    csprint(infoline, 0x07); 
    178194} 
     
    195211{ 
    196212    (void)ms;                   /* Unused */ 
     213 
     214    t_handler_return rv; 
    197215 
    198216    if (mi->action != OPT_CHECKBOX) 
     
    221239    if (strcmp(mi->data, "mountcd") == 0) 
    222240        flags.mountcd = (mi->itemdata.checked ? 1 : 0); 
    223     return ACTION_VALID; 
    224 } 
    225  
    226 /* 
    227   Clears keyboard buffer and then 
    228   wait for stepsize*numsteps milliseconds for user to press any key 
    229   checks for keypress every stepsize milliseconds. 
    230   Returns: 1 if user pressed a key (not read from the buffer), 
    231            0 if time elapsed 
    232 */ 
    233 int checkkeypress(int stepsize, int numsteps) 
    234 { 
    235     int i; 
    236     clearkbdbuf(); 
    237     for (i = 0; i < numsteps; i++) { 
    238         if (checkkbdbuf()) 
    239             return 1; 
    240         sleep(stepsize); 
    241     } 
    242     return 0; 
     241 
     242    rv.valid = 0; 
     243    rv.refresh = 1; 
     244    return rv; 
    243245} 
    244246 
     
    272274    reg_handler(HDLR_KEYS, &keys_handler); 
    273275    // Register the ontimeout handler, with a time out of 10 seconds 
    274     reg_ontimeout(ontimeout, 1000, 0); 
     276    reg_ontimeout(ontimeout, 10, 0); 
    275277 
    276278    NETMENU = add_menu(" Init Network ", -1); 
     
    402404    set_item_options(-1, 30); 
    403405    csprint("Press any key within 5 seconds to show menu...", 0x07); 
    404     if (!checkkeypress(100, 50))        // Granularity of 100 milliseconds 
     406    if (get_key(stdin, 50) == KEY_NONE) // Granularity of 100 milliseconds 
    405407    { 
    406408        csprint("Sorry! Time's up.\r\n", 0x07); 
    407409        return 1; 
    408     } else 
    409         clearkbdbuf();          // Just in case user pressed something important 
     410    } 
    410411    curr = showmenus(MAIN); 
    411412    if (curr) { 
  • com32/cmenu/libmenu/com32io.c

    r62038f r9df342  
    1414#include <com32.h> 
    1515#include "com32io.h" 
     16#include "tui.h" 
    1617#include "syslnx.h" 
    1718 
    1819com32sys_t inreg, outreg;       // Global register sets for use 
    19  
    20 /* Print character and attribute at cursor */ 
    21 void cprint(char chr, char attr, unsigned int times, char disppage) 
    22 { 
    23     REG_AH(inreg) = 0x09; 
    24     REG_AL(inreg) = chr; 
    25     REG_BH(inreg) = disppage; 
    26     REG_BL(inreg) = attr; 
    27     REG_CX(inreg) = times; 
    28     __intcall(0x10, &inreg, &outreg); 
    29 } 
    30  
    31 void setdisppage(char num)      // Set the display page to specified number 
    32 { 
    33     REG_AH(inreg) = 0x05; 
    34     REG_AL(inreg) = num; 
    35     __intcall(0x10, &inreg, &outreg); 
    36 } 
    37  
    38 char getdisppage()              // Get current display page 
    39 { 
    40     REG_AH(inreg) = 0x0f; 
    41     __intcall(0x10, &inreg, &outreg); 
    42     return REG_BH(outreg); 
    43 } 
    4420 
    4521void getpos(char *row, char *col, char page) 
     
    5026    *row = REG_DH(outreg); 
    5127    *col = REG_DL(outreg); 
    52 } 
    53  
    54 void gotoxy(char row, char col, char page) 
    55 { 
    56     REG_AH(inreg) = 0x02; 
    57     REG_BH(inreg) = page; 
    58     REG_DX(inreg) = (row << 8) + col; 
    59     __intcall(0x10, &inreg, &outreg); 
    6028} 
    6129 
     
    6937    __intcall(0x15, &inreg, &outreg); 
    7038    return REG_AH(outreg); 
    71 } 
    72  
    73 void beep() 
    74 { 
    75     REG_AH(inreg) = 0x0E; 
    76     REG_AL(inreg) = 0x07; 
    77     REG_BH(inreg) = 0; 
    78     __intcall(0x10, &inreg, &outreg); 
    79 } 
    80  
    81 void scrollupwindow(char top, char left, char bot, char right, char attr, 
    82                     char numlines) 
    83 { 
    84     REG_AH(inreg) = 0x06; 
    85     REG_AL(inreg) = numlines; 
    86     REG_BH(inreg) = attr;       // Attribute to write blanks lines 
    87     REG_DX(inreg) = (bot << 8) + right; // BOT RIGHT corner of window 
    88     REG_CX(inreg) = (top << 8) + left;  // TOP LEFT of window 
    89     __intcall(0x10, &inreg, &outreg); 
    9039} 
    9140 
     
    10251void getcursorshape(char *start, char *end) 
    10352{ 
    104     char page = getdisppage(); 
     53    char page = 0; // XXX TODO 
    10554    REG_AH(inreg) = 0x03; 
    10655    REG_BH(inreg) = page; 
     
    11867} 
    11968 
    120 char getchar(void) 
    121 { 
    122     REG_AH(inreg) = 0x08; 
    123     __intcall(0x21, &inreg, &outreg); 
    124     return REG_AL(outreg); 
    125 } 
    126  
    12769void setvideomode(char mode) 
    12870{ 
     
    13072    REG_AL(inreg) = mode; 
    13173    __intcall(0x10, &inreg, &outreg); 
    132 } 
    133  
    134 unsigned char checkkbdbuf() 
    135 { 
    136     REG_AH(inreg) = 0x11; 
    137     __intcall(0x16, &inreg, &outreg); 
    138     return !(outreg.eflags.l & EFLAGS_ZF); 
    13974} 
    14075 
  • com32/cmenu/libmenu/com32io.h

    r0b19ab r9df342  
    1515 
    1616#include <com32.h> 
     17#include <stdio.h> 
     18#include <libansi.h> 
    1719 
    1820#ifndef NULL 
     
    2022#endif 
    2123 
     24/* Bits representing ShiftFlags, See Int16/Function 2 or Mem[0x417] to get this info */ 
     25 
     26#define INSERT_ON     (1<<7) 
     27#define CAPSLOCK_ON   (1<<6) 
     28#define NUMLOCK_ON    (1<<5) 
     29#define SCRLLOCK_ON   (1<<4) 
     30#define ALT_PRESSED   (1<<3) 
     31#define CTRL_PRESSED  (1<<2) 
     32// actually 1<<1 is Left Shift, 1<<0 is right shift 
     33#define SHIFT_PRESSED (1<<1 | 1 <<0) 
     34 
    2235/* BIOS Assisted output routines */ 
    23  
    24 void cswprint(const char *str, char attr, char left); 
    25 // Print a C str (NUL-terminated) respecting the left edge of window 
    26 // i.e. \n in str will move cursor to column left 
    27 // Print a C str (NUL-terminated) 
    28  
    29 static inline void csprint(const char *str, char attr) 
    30 { 
    31     cswprint(str, attr, 0); 
    32 } 
    33  
    34 void cprint(char chr, char attr, unsigned int times, char disppage);    // Print a char 
    35  
    36 void setdisppage(char num);     // Set the display page to specified number 
    37  
    38 char getdisppage();             // Get current display page 
    39  
    40 void gotoxy(char row, char col, char page); 
    4136 
    4237void getpos(char *row, char *col, char page); 
    4338 
    4439char inputc(char *scancode);    // Return ASCII char by val, and scancode by reference 
    45  
    46 static inline void putch(char x, char attr, char page) 
    47 { 
    48     cprint(x, attr, 1, page); 
    49 } 
    5040 
    5141void setcursorshape(char start, char end);      // Set cursor shape 
     
    5545unsigned char getcharat(char page); 
    5646 
    57 static inline void cursoroff(void) 
    58 {                               /* Turns off cursor */ 
    59     setcursorshape(32, 33); 
    60 } 
    61  
    62 static inline void cursoron(void) 
    63 {                               /* Turns on cursor */ 
    64     setcursorshape(6, 7); 
    65 } 
    66  
    6747static inline unsigned char readbiosb(unsigned int ofs) 
    6848{ 
    6949    return *((unsigned char *)MK_PTR(0, ofs)); 
    70 } 
    71  
    72 static inline char getnumrows() 
    73 { 
    74     return readbiosb(0x484)+1; // Actually numrows - 1 
    75 } 
    76  
    77 static inline char getnumcols(void) 
    78 { 
    79     return readbiosb(0x44a);    // Actually numcols 
    8050} 
    8151 
     
    8656 
    8757void scrollupwindow(char top, char left, char bot, char right, char attr, char numlines);       //Scroll up given window 
    88  
    89 static inline void scrollup(void)       //Scroll up display screen by one line 
    90 { 
    91     scrollupwindow(0, 0, getnumrows(), getnumcols(), 0x07, 1); 
    92 } 
    9358 
    9459void setvideomode(char mode);   // Set the video mode. 
     
    10166unsigned char sleep(unsigned int msec); // Sleep for specified time 
    10267 
    103 void beep();                    // A Bell 
    104  
    105 unsigned char checkkbdbuf();    // Check to see if there is kbd buffer is non-empty? 
    106  
    107 static inline void clearkbdbuf()        // Clear the kbd buffer (how many chars removed?) 
    108 { 
    109     while (checkkbdbuf()) 
    110         inputc(NULL); 
    111 } 
    112  
    11368#endif 
  • com32/cmenu/libmenu/help.c

    rd8b2ee r1913ab  
    1717#include <syslinux/loadfile.h>  // to read entire file into memory 
    1818 
     19int nc, nr; // Number of columns/rows of the screen 
    1920char helpbasedir[HELPDIRLEN];   // name of help directory limited to HELPDIRLEN 
    2021 
    2122// Find the occurence of the count'th \n in buffer (or NULL) if not found 
    22 char *findline(char *buffer, int count) 
     23static char *findline(char *buffer, int count) 
    2324{ 
    2425    int ctr; 
     
    3637 
    3738// return the number of lines in buffer 
    38 int countlines(char *buffer) 
     39static int countlines(char *buffer) 
    3940{ 
    4041    int ans; 
     
    5152 
    5253// Print numlines of text starting from buf 
    53 void printtext(char *buf, int from) 
    54 { 
    55     char *p, *f; 
    56     char right, bot, nlines; 
     54static void printtext(char *buf, int from) 
     55{ 
     56    char *f, *t; 
     57    int right, nlines, i; 
    5758 
    5859    // clear window to print 
    59     right = getnumcols() - HELP_RIGHT_MARGIN; 
    60     bot = getnumrows() - HELP_BOTTOM_MARGIN; 
    61     nlines = bot - HELP_BODY_ROW + 1; 
    62     scrollupwindow(HELP_BODY_ROW, HELP_LEFT_MARGIN, bot, right, 0x07, nlines); 
     60    right = nc - HELP_RIGHT_MARGIN; 
     61    nlines = nr - HELP_BODY_ROW - HELP_BOTTOM_MARGIN - 1; 
    6362 
    6463    f = findline(buf, from); 
     
    6766    if (*f == '\n') 
    6867        f++;                    // start of from+1st line 
    69     p = findline(f, nlines); 
    70     if (p && (*p == '\n')) 
    71         *p = '\0';              // change to NUL 
    72     gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN, HELPPAGE); 
    73     cswprint(f, 0x07, HELP_LEFT_MARGIN); 
    74     if (p) 
    75         *p = '\n';              // set it back 
     68    t = f; 
     69    while (i < nlines) { 
     70        gotoxy(HELP_BODY_ROW + i, HELP_LEFT_MARGIN); 
     71        clear_end_of_line(); 
     72        putchar(SO); 
     73        gotoxy(HELP_BODY_ROW + i, nc - 1); 
     74        putch(LEFT_BORDER, 0x07); 
     75        putchar(SI); 
     76 
     77        gotoxy(HELP_BODY_ROW + i, HELP_LEFT_MARGIN); 
     78        while (*t != '\n') { 
     79            if (*t == '\0') 
     80                return; 
     81            putchar(*t); 
     82            t++; 
     83        } 
     84        putchar('\n'); 
     85        t++; 
     86        i++; 
     87    } 
    7688} 
    7789 
    7890void showhelp(const char *filename) 
    7991{ 
    80     char nc, nr, ph; 
     92    char ph; 
    8193    char *title, *text; 
    8294    union { 
     
    8799    char line[512]; 
    88100    size_t size; 
    89     char scan; 
     101    int scan; 
    90102    int rv, numlines, curr_line; 
    91103 
    92     nc = getnumcols(); 
    93     nr = getnumrows(); 
    94     ph = nr - HELP_BOTTOM_MARGIN - HELP_BODY_ROW - 1; 
     104    if (getscreensize(1, &nr, &nc)) { 
     105        /* Unknown screen size? */ 
     106        nc = 80; 
     107        nr = 24; 
     108    } 
     109    ph = nr - HELP_BODY_ROW; 
    95110    cls(); 
    96     drawbox(0, 0, nr, nc - 1, HELPPAGE, 0x07, HELPBOX); 
    97  
    98     drawhorizline(2, 0, nc - 1, HELPPAGE, 0x07, HELPBOX, 0);    // dumb==0 
     111 
     112    /* Turn autowrap off, to avoid scrolling the menu */ 
     113    printf(CSI "?7l"); 
     114 
    99115    if (filename == NULL) {     // print file contents 
    100         gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN, HELPPAGE); 
    101         cswprint("Filename not given", 0x07, HELP_LEFT_MARGIN); 
    102         while (1) { 
    103             inputc(&scan); 
    104             if (scan == ESCAPE) 
    105                 break; 
    106         } 
    107         cls(); 
    108         return; 
     116        strcpy(line, "Filename not given"); 
     117        goto puke; 
    109118    } 
    110119 
    111120    rv = loadfile(filename, (void **)&buf.vbuf, &size); // load entire file into memory 
    112121    if (rv < 0) {               // Error reading file or no such file 
    113         sprintf(line, "Error reading file or file not found\n file=%s", 
    114                 filename); 
    115         gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN, HELPPAGE); 
    116         cswprint(line, 0x07, HELP_LEFT_MARGIN); 
    117         while (1) { 
    118             inputc(&scan); 
    119             if (scan == ESCAPE) 
    120                 break; 
    121         } 
    122         cls(); 
    123         return; 
     122        sprintf(line, "Error reading file or file not found\n file=%s", filename); 
     123        goto puke; 
    124124    } 
    125125 
     
    129129 
    130130    // Now we have a file just print it. 
    131     gotoxy(1, (nc - strlen(title)) / 2, HELPPAGE); 
    132     csprint(title, 0x07); 
    133131    numlines = countlines(text); 
    134132    curr_line = 0; 
    135     scan = ESCAPE + 1;          // anything except ESCAPE 
    136  
    137     while (scan != ESCAPE) { 
     133    scan = KEY_ESC + 1;         // anything except ESCAPE 
     134 
     135    /* top, left, bottom, right, attr */ 
     136    drawbox(0, 0, nr - 1, nc - 1, 0x07); 
     137    while (scan != KEY_ESC) { 
     138    /* Title */ 
     139    gotoxy(1, (nc - strlen(title)) / 2); 
     140    fputs(title, stdout); 
     141    drawhorizline(2, HELP_LEFT_MARGIN - 1, nc - HELP_RIGHT_MARGIN, 0x07, 0);    // dumb==0 
     142    /* Text */ 
    138143        printtext(text, curr_line); 
    139         gotoxy(HELP_BODY_ROW - 1, nc - HELP_RIGHT_MARGIN, HELPPAGE); 
     144    gotoxy(HELP_BODY_ROW - 1, nc - HELP_RIGHT_MARGIN); 
    140145        if (curr_line > 0) 
    141             putch(HELP_MORE_ABOVE, 0x07, HELPPAGE); 
     146            putchar(HELP_MORE_ABOVE); 
    142147        else 
    143             putch(' ', 0x07, HELPPAGE); 
    144         gotoxy(nr - HELP_BOTTOM_MARGIN + 1, nc - HELP_RIGHT_MARGIN, HELPPAGE); 
     148            putchar(' '); 
     149        gotoxy(nr - HELP_BOTTOM_MARGIN - 1, nc - HELP_RIGHT_MARGIN); 
    145150        if (curr_line < numlines - ph) 
    146             putch(HELP_MORE_BELOW, 0x07, HELPPAGE); 
     151            putchar(HELP_MORE_BELOW); 
    147152        else 
    148             putch(' ', 0x07, HELPPAGE); 
    149  
    150         inputc(&scan);          // wait for user keypress 
     153            putchar(' '); 
     154 
     155    scan = get_key(stdout, 0); // wait for user keypress 
    151156 
    152157        switch (scan) { 
    153         case HOMEKEY: 
     158        case KEY_HOME: 
    154159            curr_line = 0; 
    155160            break; 
    156         case ENDKEY: 
     161        case KEY_END: 
    157162            curr_line = numlines; 
    158163            break; 
    159         case UPARROW: 
     164        case KEY_UP: 
    160165            curr_line--; 
    161166            break; 
    162         case DNARROW: 
     167        case KEY_DOWN: 
    163168            curr_line++; 
    164169            break; 
    165         case PAGEUP: 
     170        case KEY_PGUP: 
    166171            curr_line -= ph; 
    167172            break; 
    168         case PAGEDN: 
     173        case KEY_PGDN: 
    169174            curr_line += ph; 
    170175            break; 
     
    177182            curr_line = 0; 
    178183    } 
     184out: 
    179185    cls(); 
    180186    return; 
     187 
     188puke: 
     189    gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN); 
     190    fputs(line, stdout); 
     191    while (1) { 
     192        scan = get_key(stdin, 0); 
     193        if (scan == KEY_ESC) 
     194            break; 
     195    } 
     196    goto out; 
    181197} 
    182198 
    183199void runhelp(const char *filename) 
    184200{ 
    185     char dp; 
    186201    char fullname[HELPDIRLEN + 16]; 
    187202 
    188     dp = getdisppage(); 
    189     if (dp != HELPPAGE) 
    190         setdisppage(HELPPAGE); 
     203        cls(); 
    191204    cursoroff(); 
    192205    if (helpbasedir[0] != 0) { 
     
    197210    } else 
    198211        showhelp(filename);     // Assume filename is absolute 
    199     if (dp != HELPPAGE) 
    200         setdisppage(dp); 
    201212} 
    202213 
     
    205216    char filename[15]; 
    206217 
    207     sprintf(filename, "hlp%5d.txt", helpid); 
     218    sprintf(filename, "hlp%05d.txt", helpid); 
    208219    runhelp(filename); 
    209220} 
  • com32/cmenu/libmenu/help.h

    r610468 r9dbacd3  
    2424#define HELP_LEFT_MARGIN 2 
    2525#define HELP_RIGHT_MARGIN 2     // Assume all lines dont cross this 
    26 #define HELP_BOTTOM_MARGIN 2    // Number of lines not use from bottom of screen 
     26#define HELP_BOTTOM_MARGIN 1    // Number of lines not use from bottom of screen 
    2727 
    2828#define HELPBOX BOX_SINSIN 
     
    3030#define HELPPAGE 2 
    3131 
    32 #define HELP_MORE_ABOVE 24      // to print when more is available above 
    33 #define HELP_MORE_BELOW 25      // same as above but for below 
     32#define HELP_MORE_ABOVE '^'     // to print when more is available above 
     33#define HELP_MORE_BELOW 'v'     // same as above but for below 
    3434 
    3535// Display one screen of help information 
  • com32/cmenu/libmenu/menu.c

    r204ff3 r397586  
    1414#include "com32io.h" 
    1515#include <stdlib.h> 
     16#include <console.h> 
    1617 
    1718// Local Variables 
    18 static pt_menusystem ms;        // Pointer to the menusystem 
     19static pt_menusystem ms;    // Pointer to the menusystem 
    1920char TITLESTR[] = 
    2021    "COMBOOT Menu System for SYSLINUX developed by Murali Krishnan Ganapathy"; 
     
    4041// and calls it when needed. For the callee, there is no difference 
    4142// as this will not return unless a key has been pressed. 
    42 char getch(char *scan) 
    43 { 
     43static int getch() 
     44{ 
     45    t_timeout_handler th; 
     46    int key; 
    4447    unsigned long i; 
    45     TIMEOUTCODE c; 
    46     t_timeout_handler th; 
    4748 
    4849    // Wait until keypress if no handler specified 
    4950    if ((ms->ontimeout == NULL) && (ms->ontotaltimeout == NULL)) 
    50         return inputc(scan); 
     51        return get_key(stdin, 0); 
    5152 
    5253    th = ms->ontimeout; 
    53     while (1)                   // Forever do 
    54     { 
    55         for (i = 0; i < ms->tm_numsteps; i++) { 
    56             if (checkkbdbuf()) 
    57                 return inputc(scan); 
    58             sleep(ms->tm_stepsize); 
    59             if ((ms->tm_total_timeout == 0) || (ms->ontotaltimeout == NULL)) 
    60                 continue;       // Dont bother with calculations if no handler 
    61             ms->tm_sofar_timeout += ms->tm_stepsize; 
    62             if (ms->tm_sofar_timeout >= ms->tm_total_timeout) { 
    63                 th = ms->ontotaltimeout; 
    64                 ms->tm_sofar_timeout = 0; 
    65                 break;          // Get out of the for loop 
    66             } 
    67         } 
    68         if (!th) 
    69             continue;           // no handler dont call 
    70         c = th(); 
    71         switch (c) { 
    72         case CODE_ENTER:        // Pretend user hit enter 
    73             *scan = ENTERA; 
    74             return '\015';      // \015 octal = 13 
    75         case CODE_ESCAPE:       // Pretend user hit escape 
    76             *scan = ESCAPE; 
    77             return '\033';      // \033 octal = 27 
    78         default: 
    79             break; 
    80         } 
    81     } 
    82     return 0; 
    83 } 
    84  
    85 /* Print a menu item */ 
    86 /* attr[0] is non-hilite attr, attr[1] is highlight attr */ 
    87 void printmenuitem(const char *str, uchar * attr) 
    88 { 
    89     uchar page = getdisppage(); 
    90     uchar row, col; 
    91     int hlite = NOHLITE;        // Initially no highlighting 
    92  
    93     getpos(&row, &col, page); 
    94     while (*str) { 
    95         switch (*str) { 
    96         case '\b': 
    97             --col; 
    98             break; 
    99         case '\n': 
    100             ++row; 
    101             break; 
    102         case '\r': 
    103             col = 0; 
    104             break; 
    105         case BELL:              // No Bell Char 
    106             break; 
    107         case ENABLEHLITE:       // Switch on highlighting 
    108             hlite = HLITE; 
    109             break; 
    110         case DISABLEHLITE:      // Turn off highlighting 
    111             hlite = NOHLITE; 
    112             break; 
    113         default: 
    114             putch(*str, attr[hlite], page); 
    115             ++col; 
    116         } 
    117         if (col > getnumcols()) { 
    118             ++row; 
    119             col = 0; 
    120         } 
    121         if (row > getnumrows()) { 
    122             scrollup(); 
    123             row = getnumrows(); 
    124         } 
    125         gotoxy(row, col, page); 
    126         str++; 
    127     } 
     54    for (;;) { 
     55        for (i = 0; i < ms->tm_numsteps; i++) { 
     56            key = get_key(stdin, ms->tm_stepsize); 
     57            if (key != KEY_NONE) 
     58                return key; 
     59 
     60            if ((ms->tm_total_timeout == 0) || (ms->ontotaltimeout == NULL)) 
     61                continue;   // Dont bother with calculations if no handler 
     62            ms->tm_sofar_timeout += ms->tm_stepsize; 
     63            if (ms->tm_sofar_timeout >= ms->tm_total_timeout) { 
     64                th = ms->ontotaltimeout; 
     65                ms->tm_sofar_timeout = 0; 
     66                break;      // Get out of the for loop 
     67            } 
     68        } 
     69        if (!th) 
     70            continue;       // no handler 
     71        key = th(); 
     72        switch (key) { 
     73        case CODE_ENTER:    // Pretend user hit enter 
     74            return KEY_ENTER; 
     75        case CODE_ESCAPE:   // Pretend user hit escape 
     76            return KEY_ESC; 
     77        default: 
     78            break; 
     79        } 
     80    } 
     81    return KEY_NONE; 
    12882} 
    12983 
     
    13690    // Garbage in garbage out 
    13791    if ((index < 0) || (index >= menu->numitems)) 
    138         return index; 
     92    return index; 
    13993    ans = index + 1; 
    14094    // Go till end of menu 
    14195    while (ans < menu->numitems) { 
    142         mi = menu->items[ans]; 
    143         if ((mi->action == OPT_INVISIBLE) || (mi->action == OPT_SEP) 
    144             || (mi->shortcut != shortcut)) 
    145             ans++; 
    146         else 
    147             return ans; 
     96    mi = menu->items[ans]; 
     97    if ((mi->action == OPT_INVISIBLE) || (mi->action == OPT_SEP) 
     98        || (mi->shortcut != shortcut)) 
     99        ans++; 
     100    else 
     101        return ans; 
    148102    } 
    149103    // Start at the beginning and try again 
    150104    ans = 0; 
    151105    while (ans < index) { 
    152         mi = menu->items[ans]; 
    153         if ((mi->action == OPT_INVISIBLE) || (mi->action == OPT_SEP) 
    154             || (mi->shortcut != shortcut)) 
    155             ans++; 
    156         else 
    157             return ans; 
    158     } 
    159     return index;               // Sorry not found 
     106    mi = menu->items[ans]; 
     107    if ((mi->action == OPT_INVISIBLE) || (mi->action == OPT_SEP) 
     108        || (mi->shortcut != shortcut)) 
     109        ans++; 
     110    else 
     111        return ans; 
     112    } 
     113    return index;       // Sorry not found 
     114} 
     115 
     116/* Redraw background and title */ 
     117static void reset_ui(void) 
     118{ 
     119    uchar tpos; 
     120 
     121    cls(); 
     122    clearwindow(ms->minrow, ms->mincol, ms->maxrow, ms->maxcol, 
     123                ms->fillchar, ms->fillattr); 
     124 
     125    tpos = (ms->numcols - strlen(ms->title) - 1) >> 1;  // center it on line 
     126    gotoxy(ms->minrow, ms->mincol); 
     127    cprint(ms->tfillchar, ms->titleattr, ms->numcols); 
     128    gotoxy(ms->minrow, ms->mincol + tpos); 
     129    csprint(ms->title, ms->titleattr); 
     130 
     131    cursoroff(); 
     132} 
     133 
     134/* 
     135 * Print a menu item 
     136 * 
     137 * attr[0] is non-hilite attr, attr[1] is highlight attr 
     138 */ 
     139void printmenuitem(const char *str, uchar * attr) 
     140{ 
     141    int hlite = NOHLITE;    // Initially no highlighting 
     142 
     143    while (*str) { 
     144        switch (*str) { 
     145            case BELL:      // No Bell Char 
     146                break; 
     147            case ENABLEHLITE:   // Switch on highlighting 
     148                hlite = HLITE; 
     149                break; 
     150            case DISABLEHLITE:  // Turn off highlighting 
     151                hlite = NOHLITE; 
     152                break; 
     153            default: 
     154                putch(*str, attr[hlite]); 
     155        } 
     156        str++; 
     157    } 
     158} 
     159 
     160 
     161/** 
     162 * print_line - Print a whole line in a menu 
     163 * @menu:   current menu to handle 
     164 * @curr:   index of the current entry highlighted 
     165 * @top:    top coordinate of the @menu 
     166 * @left:   left coordinate of the @menu 
     167 * @x:      index in the menu of curr 
     168 * @row:    row currently displayed 
     169 * @radio:  radio item? 
     170 **/ 
     171static void print_line(pt_menu menu, int curr, uchar top, uchar left, 
     172                       int x, int row, bool radio) 
     173{ 
     174    pt_menuitem ci; 
     175    char fchar[6], lchar[6];    // The first and last char in for each entry 
     176    const char *str;            // Item string (cf printmenuitem) 
     177    char sep[MENULEN];          // Separator (OPT_SEP) 
     178    uchar *attr;                // Attribute 
     179    int menuwidth = menu->menuwidth + 3; 
     180 
     181    if (row >= menu->menuheight) 
     182        return; 
     183 
     184    ci = menu->items[x]; 
     185 
     186    memset(sep, ms->box_horiz, menuwidth); 
     187    sep[menuwidth - 1] = 0; 
     188 
     189    // Setup the defaults now 
     190    if (radio) { 
     191        fchar[0] = '\b'; 
     192        fchar[1] = SO; 
     193        fchar[2] = (x == curr ? RADIOSEL : RADIOUNSEL); 
     194        fchar[3] = SI; 
     195        fchar[4] = '\0';    // Unselected ( ) 
     196        lchar[0] = '\0';    // Nothing special after 
     197        attr = ms->normalattr;  // Always same attribute 
     198    } else { 
     199        lchar[0] = fchar[0] = ' '; 
     200        lchar[1] = fchar[1] = '\0'; // fchar and lchar are just spaces 
     201        attr = (x == curr ? ms->reverseattr : ms->normalattr);  // Normal attributes 
     202    } 
     203    str = ci->item;     // Pointer to item string 
     204    switch (ci->action) // set up attr,str,fchar,lchar for everything 
     205    { 
     206    case OPT_INACTIVE: 
     207        if (radio) 
     208            attr = ms->inactattr; 
     209        else 
     210            attr = (x == curr ? ms->revinactattr : ms->inactattr); 
     211        break; 
     212    case OPT_SUBMENU: 
     213        if (radio) 
     214            break;      // Not supported for radio menu 
     215        lchar[0] = '>'; 
     216        lchar[1] = 0; 
     217        break; 
     218    case OPT_RADIOMENU: 
     219        if (radio) 
     220            break;      // Not supported for radio menu 
     221        lchar[0] = RADIOMENUCHAR; 
     222        lchar[1] = 0; 
     223        break; 
     224    case OPT_CHECKBOX: 
     225        if (radio) 
     226            break;      // Not supported for radio menu 
     227        lchar[0] = '\b'; 
     228        lchar[1] = SO; 
     229        lchar[2] = (ci->itemdata.checked ? CHECKED : UNCHECKED); 
     230        lchar[3] = SI; 
     231        lchar[4] = 0; 
     232        break; 
     233    case OPT_SEP: 
     234        fchar[0] = '\b'; 
     235        fchar[1] = SO; 
     236        fchar[2] = LEFT_MIDDLE_BORDER; 
     237        fchar[3] = MIDDLE_BORDER; 
     238        fchar[4] = MIDDLE_BORDER; 
     239        fchar[5] = 0; 
     240        memset(sep, MIDDLE_BORDER, menuwidth); 
     241        sep[menuwidth - 1] = 0; 
     242        str = sep; 
     243        lchar[0] = MIDDLE_BORDER; 
     244        lchar[1] = RIGHT_MIDDLE_BORDER; 
     245        lchar[2] = SI; 
     246        lchar[3] = 0; 
     247        break; 
     248    case OPT_EXITMENU: 
     249        if (radio) 
     250            break;      // Not supported for radio menu 
     251        fchar[0] = '<'; 
     252        fchar[1] = 0; 
     253        break; 
     254    default:        // Just to keep the compiler happy 
     255        break; 
     256    } 
     257 
     258    // Wipe area with spaces 
     259    gotoxy(top + row, left - 2); 
     260    cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2); 
     261 
     262    // Print first part 
     263    gotoxy(top + row, left - 2); 
     264    csprint(fchar, attr[NOHLITE]); 
     265 
     266    // Print main part 
     267    gotoxy(top + row, left); 
     268    printmenuitem(str, attr); 
     269 
     270    // Print last part 
     271    gotoxy(top + row, left + menuwidth - 1); 
     272    csprint(lchar, attr[NOHLITE]); 
    160273} 
    161274 
    162275// print the menu starting from FIRST 
    163276// will print a maximum of menu->menuheight items 
    164 void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first) 
    165 { 
    166     int x, row;                 // x = index, row = position from top 
     277static void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first, bool radio) 
     278{ 
     279    int x, row;         // x = index, row = position from top 
    167280    int numitems, menuwidth; 
    168     char fchar[5], lchar[5];    // The first and last char in for each entry 
    169     const char *str;            // and inbetween the item or a seperator is printed 
    170     uchar *attr;                // attribute attr 
    171     char sep[MENULEN];          // and inbetween the item or a seperator is printed 
    172281    pt_menuitem ci; 
    173282 
    174283    numitems = calc_visible(menu, first); 
    175284    if (numitems > menu->menuheight) 
    176         numitems = menu->menuheight; 
     285    numitems = menu->menuheight; 
    177286 
    178287    menuwidth = menu->menuwidth + 3; 
    179288    clearwindow(top, left - 2, top + numitems + 1, left + menuwidth + 1, 
    180                 ms->menupage, ms->fillchar, ms->shadowattr); 
     289        ms->fillchar, ms->shadowattr); 
    181290    drawbox(top - 1, left - 3, top + numitems, left + menuwidth, 
    182             ms->menupage, ms->normalattr[NOHLITE], ms->menubt); 
    183     memset(sep, ms->box_horiz, menuwidth);      // String containing the seperator string 
    184     sep[menuwidth - 1] = 0; 
     291        ms->normalattr[NOHLITE]); 
     292 
    185293    // Menu title 
    186294    x = (menuwidth - strlen(menu->title) - 1) >> 1; 
    187     gotoxy(top - 1, left + x, ms->menupage); 
     295    gotoxy(top - 1, left + x); 
    188296    printmenuitem(menu->title, ms->normalattr); 
    189     row = -1;                   // 1 less than inital value of x 
     297 
     298    // All lines in the menu 
     299    row = -1;           // 1 less than inital value of x 
    190300    for (x = first; x < menu->numitems; x++) { 
    191         ci = menu->items[x]; 
    192         if (ci->action == OPT_INVISIBLE) 
    193             continue; 
    194         row++; 
    195         if (row >= numitems) 
    196             break;              // Already have enough number of items 
    197         // Setup the defaults now 
    198         lchar[0] = fchar[0] = ' '; 
    199         lchar[1] = fchar[1] = '\0';     // fchar and lchar are just spaces 
    200         str = ci->item;         // Pointer to item string 
    201         attr = (x == curr ? ms->reverseattr : ms->normalattr);  // Normal attributes 
    202         switch (ci->action)     // set up attr,str,fchar,lchar for everything 
    203         { 
    204         case OPT_INACTIVE: 
    205             attr = (x == curr ? ms->revinactattr : ms->inactattr); 
    206             break; 
    207         case OPT_SUBMENU: 
    208             lchar[0] = SUBMENUCHAR; 
    209             lchar[1] = 0; 
    210             break; 
    211         case OPT_RADIOMENU: 
    212             lchar[0] = RADIOMENUCHAR; 
    213             lchar[1] = 0; 
    214             break; 
    215         case OPT_CHECKBOX: 
    216             lchar[0] = (ci->itemdata.checked ? CHECKED : UNCHECKED); 
    217             lchar[1] = 0; 
    218             break; 
    219         case OPT_SEP: 
    220             fchar[0] = '\b'; 
    221             fchar[1] = ms->box_ltrt; 
    222             fchar[2] = ms->box_horiz; 
    223             fchar[3] = ms->box_horiz; 
    224             fchar[4] = 0; 
    225             lchar[0] = ms->box_horiz; 
    226             lchar[1] = ms->box_rtlt; 
    227             lchar[2] = 0; 
    228             str = sep; 
    229             break; 
    230         case OPT_EXITMENU: 
    231             fchar[0] = EXITMENUCHAR; 
    232             fchar[1] = 0; 
    233             break; 
    234         default:                // Just to keep the compiler happy 
    235             break; 
    236         } 
    237         gotoxy(top + row, left - 2, ms->menupage); 
    238         cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2, ms->menupage);      // Wipe area with spaces 
    239         gotoxy(top + row, left - 2, ms->menupage); 
    240         csprint(fchar, attr[NOHLITE]);  // Print first part 
    241         gotoxy(top + row, left, ms->menupage); 
    242         printmenuitem(str, attr);       // Print main part 
    243         gotoxy(top + row, left + menuwidth - 1, ms->menupage);  // Last char if any 
    244         csprint(lchar, attr[NOHLITE]);  // Print last part 
     301        ci = menu->items[x]; 
     302        if (ci->action == OPT_INVISIBLE) 
     303            continue; 
     304        row++; 
     305        if (row >= numitems) 
     306            break;      // Already have enough number of items 
     307        print_line(menu, curr, top, left, x, row, radio); 
    245308    } 
    246309    // Check if we need to MOREABOVE and MOREBELOW to be added 
    247310    // reuse x 
    248311    row = 0; 
    249     x = next_visible_sep(menu, 0);      // First item 
    250     if (!isvisible(menu, first, x))     // There is more above 
     312    x = next_visible_sep(menu, 0);  // First item 
     313    if (!isvisible(menu, first, x)) // There is more above 
    251314    { 
    252         row = 1; 
    253         gotoxy(top, left + menuwidth, ms->menupage); 
    254         cprint(MOREABOVE, ms->normalattr[NOHLITE], 1, ms->menupage); 
    255     } 
    256     x = prev_visible_sep(menu, menu->numitems); // last item 
    257     if (!isvisible(menu, first, x))     // There is more above 
     315    row = 1; 
     316    gotoxy(top, left + menuwidth); 
     317    cprint(MOREABOVE, ms->normalattr[NOHLITE], 1); 
     318    } 
     319    x = prev_visible_sep(menu, menu->numitems); // last item 
     320    if (!isvisible(menu, first, x)) // There is more above 
    258321    { 
    259         row = 1; 
    260         gotoxy(top + numitems - 1, left + menuwidth, ms->menupage); 
    261         cprint(MOREBELOW, ms->normalattr[NOHLITE], 1, ms->menupage); 
     322    row = 1; 
     323    gotoxy(top + numitems - 1, left + menuwidth); 
     324    cprint(MOREBELOW, ms->normalattr[NOHLITE], 1); 
    262325    } 
    263326    // Add a scroll box 
    264327    x = ((numitems - 1) * curr) / (menu->numitems); 
    265328    if ((x > 0) && (row == 1)) { 
    266         gotoxy(top + x, left + menuwidth, ms->menupage); 
    267         cprint(SCROLLBOX, ms->normalattr[NOHLITE], 1, ms->menupage); 
     329    gotoxy(top + x, left + menuwidth); 
     330    csprint("\016\141\017", ms->normalattr[NOHLITE]); 
    268331    } 
    269332    if (ms->handler) 
    270         ms->handler(ms, menu->items[curr]); 
    271 } 
    272  
    273 // Difference between this and regular menu, is that only 
    274 // OPT_INVISIBLE, OPT_SEP are honoured 
    275 void printradiomenu(pt_menu menu, int curr, uchar top, uchar left, int first) 
    276 { 
    277     int x, row;                 // x = index, row = position from top 
    278     int numitems, menuwidth; 
    279     char fchar[5], lchar[5];    // The first and last char in for each entry 
    280     const char *str;            // and inbetween the item or a seperator is printed 
    281     uchar *attr;                // all in the attribute attr 
    282     char sep[MENULEN];          // and inbetween the item or a seperator is printed 
    283     pt_menuitem ci; 
    284  
    285     numitems = calc_visible(menu, first); 
     333    ms->handler(ms, menu->items[curr]); 
     334} 
     335 
     336void cleanupmenu(pt_menu menu, uchar top, uchar left, int numitems) 
     337{ 
    286338    if (numitems > menu->menuheight) 
    287         numitems = menu->menuheight; 
    288  
    289     menuwidth = menu->menuwidth + 3; 
    290     clearwindow(top, left - 2, top + numitems + 1, left + menuwidth + 1, 
    291                 ms->menupage, ms->fillchar, ms->shadowattr); 
    292     drawbox(top - 1, left - 3, top + numitems, left + menuwidth, 
    293             ms->menupage, ms->normalattr[NOHLITE], ms->menubt); 
    294     memset(sep, ms->box_horiz, menuwidth);      // String containing the seperator string 
    295     sep[menuwidth - 1] = 0; 
    296     // Menu title 
    297     x = (menuwidth - strlen(menu->title) - 1) >> 1; 
    298     gotoxy(top - 1, left + x, ms->menupage); 
    299     printmenuitem(menu->title, ms->normalattr); 
    300     row = -1;                   // 1 less than inital value of x 
    301     for (x = first; x < menu->numitems; x++) { 
    302         ci = menu->items[x]; 
    303         if (ci->action == OPT_INVISIBLE) 
    304             continue; 
    305         row++; 
    306         if (row > numitems) 
    307             break; 
    308         // Setup the defaults now 
    309         fchar[0] = RADIOUNSEL; 
    310         fchar[1] = '\0';        // Unselected ( ) 
    311         lchar[0] = '\0';        // Nothing special after 
    312         str = ci->item;         // Pointer to item string 
    313         attr = ms->normalattr;  // Always same attribute 
    314         fchar[0] = (x == curr ? RADIOSEL : RADIOUNSEL); 
    315         switch (ci->action)     // set up attr,str,fchar,lchar for everything 
    316         { 
    317         case OPT_INACTIVE: 
    318             attr = ms->inactattr; 
    319             break; 
    320         case OPT_SEP: 
    321             fchar[0] = '\b'; 
    322             fchar[1] = ms->box_ltrt; 
    323             fchar[2] = ms->box_horiz; 
    324             fchar[3] = ms->box_horiz; 
    325             fchar[4] = 0; 
    326             lchar[0] = ms->box_horiz; 
    327             lchar[1] = ms->box_rtlt; 
    328             lchar[3] = 0; 
    329             str = sep; 
    330             break; 
    331         default:                // To keep the compiler happy 
    332             break; 
    333         } 
    334         gotoxy(top + row, left - 2, ms->menupage); 
    335         cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2, ms->menupage);      // Wipe area with spaces 
    336         gotoxy(top + row, left - 2, ms->menupage); 
    337         csprint(fchar, attr[NOHLITE]);  // Print first part 
    338         gotoxy(top + row, left, ms->menupage); 
    339         printmenuitem(str, attr);       // Print main part 
    340         gotoxy(top + row, left + menuwidth - 1, ms->menupage);  // Last char if any 
    341         csprint(lchar, attr[NOHLITE]);  // Print last part 
    342     } 
    343     // Check if we need to MOREABOVE and MOREBELOW to be added 
    344     // reuse x 
    345     row = 0; 
    346     x = next_visible_sep(menu, 0);      // First item 
    347     if (!isvisible(menu, first, x))     // There is more above 
    348     { 
    349         row = 1; 
    350         gotoxy(top, left + menuwidth, ms->menupage); 
    351         cprint(MOREABOVE, ms->normalattr[NOHLITE], 1, ms->menupage); 
    352     } 
    353     x = prev_visible_sep(menu, menu->numitems); // last item 
    354     if (!isvisible(menu, first, x))     // There is more above 
    355     { 
    356         row = 1; 
    357         gotoxy(top + numitems - 1, left + menuwidth, ms->menupage); 
    358         cprint(MOREBELOW, ms->normalattr[NOHLITE], 1, ms->menupage); 
    359     } 
    360     // Add a scroll box 
    361     x = ((numitems - 1) * curr) / (menu->numitems); 
    362     if ((x > 0) && (row == 1)) { 
    363         gotoxy(top + x, left + menuwidth, ms->menupage); 
    364         cprint(SCROLLBOX, ms->normalattr[NOHLITE], 1, ms->menupage); 
    365     } 
    366     if (ms->handler) 
    367         ms->handler(ms, menu->items[curr]); 
    368 } 
    369  
    370 void cleanupmenu(pt_menu menu, uchar top, uchar left, int numitems) 
    371 { 
    372     if (numitems > menu->menuheight) 
    373         numitems = menu->menuheight; 
    374     clearwindow(top, left - 2, top + numitems + 1, left + menu->menuwidth + 4, ms->menupage, ms->fillchar, ms->fillattr);       // Clear the shadow 
    375     clearwindow(top - 1, left - 3, top + numitems, left + menu->menuwidth + 3, ms->menupage, ms->fillchar, ms->fillattr);       // main window 
    376 } 
    377  
    378 /* Handle a radio menu */ 
    379 pt_menuitem getradiooption(pt_menu menu, uchar top, uchar left, uchar startopt) 
     339    numitems = menu->menuheight; 
     340    clearwindow(top, left - 2, top + numitems + 1, left + menu->menuwidth + 4, ms->fillchar, ms->fillattr); // Clear the shadow 
     341    clearwindow(top - 1, left - 3, top + numitems, left + menu->menuwidth + 3, ms->fillchar, ms->fillattr); // main window 
     342} 
     343 
     344 
     345/* Handle one menu */ 
     346static pt_menuitem getmenuoption(pt_menu menu, uchar top, uchar left, uchar startopt, bool radio) 
    380347     // Return item chosen or NULL if ESC was hit. 
    381348{ 
    382     int curr, i, first, tmp; 
    383     uchar asc, scan; 
     349    int prev, prev_first, curr, i, first, tmp; 
     350    int asc = 0; 
     351    bool redraw = true; // Need to draw the menu the first time 
    384352    uchar numitems; 
    385     pt_menuitem ci;             // Current item 
     353    pt_menuitem ci;     // Current item 
     354    t_handler_return hr;    // Return value of handler 
    386355 
    387356    numitems = calc_visible(menu, 0); 
    388357    // Setup status line 
    389     gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
    390     cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, ms->menupage); 
     358    gotoxy(ms->minrow + ms->statline, ms->mincol); 
     359    cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols); 
    391360 
    392361    // Initialise current menu item 
    393362    curr = next_visible(menu, startopt); 
    394  
    395     gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
    396     cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, 1); 
    397     gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
     363    prev = curr; 
     364 
     365    gotoxy(ms->minrow + ms->statline, ms->mincol); 
     366    cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols); 
     367    gotoxy(ms->minrow + ms->statline, ms->mincol); 
    398368    printmenuitem(menu->items[curr]->status, ms->statusattr); 
    399369    first = calc_first_early(menu, curr); 
    400     while (1)                   // Forever 
     370    prev_first = first; 
     371    while (1)           // Forever 
    401372    { 
    402         printradiomenu(menu, curr, top, left, first); 
    403         ci = menu->items[curr]; 
    404  
    405         asc = getch(&scan); 
    406         switch (scan) { 
    407         case HOMEKEY: 
    408             curr = next_visible(menu, 0); 
    409             first = calc_first_early(menu, curr); 
    410             break; 
    411         case ENDKEY: 
    412             curr = prev_visible(menu, numitems - 1); 
    413             first = calc_first_late(menu, curr); 
    414             break; 
    415         case PAGEDN: 
    416             for (i = 0; i < 5; i++) 
    417                 curr = next_visible(menu, curr + 1); 
    418             first = calc_first_late(menu, curr); 
    419             break; 
    420         case PAGEUP: 
    421             for (i = 0; i < 5; i++) 
    422                 curr = prev_visible(menu, curr - 1); 
    423             first = calc_first_early(menu, curr); 
    424             break; 
    425         case UPARROW: 
    426             curr = prev_visible(menu, curr - 1); 
    427             if (curr < first) 
    428                 first = calc_first_early(menu, curr); 
    429             break; 
    430         case DNARROW: 
    431             curr = next_visible(menu, curr + 1); 
    432             if (!isvisible(menu, first, curr)) 
    433                 first = calc_first_late(menu, curr); 
    434             break; 
    435         case LTARROW: 
    436         case ESCAPE: 
    437             return NULL; 
    438             break; 
    439         case RTARROW: 
    440         case ENTERA: 
    441         case ENTERB: 
    442             if (ci->action == OPT_INACTIVE) 
    443                 break; 
    444             if (ci->action == OPT_SEP) 
    445                 break; 
    446             return ci; 
    447             break; 
    448         default: 
    449             // Check if this is a shortcut key 
    450             if (((asc >= 'A') && (asc <= 'Z')) || 
    451                 ((asc >= 'a') && (asc <= 'z')) || 
    452                 ((asc >= '0') && (asc <= '9'))) { 
    453                 tmp = find_shortcut(menu, asc, curr); 
    454                 if ((tmp > curr) && (!isvisible(menu, first, tmp))) 
    455                     first = calc_first_late(menu, tmp); 
    456                 if (tmp < curr) 
    457                     first = calc_first_early(menu, tmp); 
    458                 curr = tmp; 
    459             } else { 
    460                 if (ms->keys_handler)   // Call extra keys handler 
    461                     ms->keys_handler(ms, menu->items[curr], (scan << 8) | asc); 
    462             } 
    463             break; 
    464         } 
    465         // Update status line 
    466         gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
    467         cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, 
    468                ms->menupage); 
    469         printmenuitem(menu->items[curr]->status, ms->statusattr); 
    470     } 
    471     return NULL;                // Should never come here 
    472 } 
    473  
    474 /* Handle one menu */ 
    475 pt_menuitem getmenuoption(pt_menu menu, uchar top, uchar left, uchar startopt) 
    476      // Return item chosen or NULL if ESC was hit. 
    477 { 
    478     int curr, i, first, tmp; 
    479     uchar asc, scan; 
    480     uchar numitems; 
    481     pt_menuitem ci;             // Current item 
    482     t_handler_return hr;        // Return value of handler 
    483  
    484     numitems = calc_visible(menu, 0); 
    485     // Setup status line 
    486     gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
    487     cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, ms->menupage); 
    488  
    489     // Initialise current menu item 
    490     curr = next_visible(menu, startopt); 
    491  
    492     gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
    493     cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, 1); 
    494     gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
     373    /* Redraw everything if: 
     374     *  + we need to scroll (take care of scroll bars, ...) 
     375     *  + menuoption 
     376     */ 
     377    if (prev_first != first || redraw) { 
     378        printmenu(menu, curr, top, left, first, radio); 
     379    } else { 
     380        /* Redraw only the highlighted entry */ 
     381        print_line(menu, curr, top, left, prev, prev - first, radio); 
     382        print_line(menu, curr, top, left, curr, curr - first, radio); 
     383    } 
     384    redraw = false; 
     385    prev = curr; 
     386    prev_first = first; 
     387    ci = menu->items[curr]; 
     388    asc = getch(); 
     389    switch (asc) { 
     390        case KEY_CTRL('L'): 
     391        redraw = true; 
     392        break; 
     393    case KEY_HOME: 
     394        curr = next_visible(menu, 0); 
     395        first = calc_first_early(menu, curr); 
     396        break; 
     397    case KEY_END: 
     398        curr = prev_visible(menu, numitems - 1); 
     399        first = calc_first_late(menu, curr); 
     400        break; 
     401    case KEY_PGDN: 
     402        for (i = 0; i < 5; i++) 
     403        curr = next_visible(menu, curr + 1); 
     404        first = calc_first_late(menu, curr); 
     405        break; 
     406    case KEY_PGUP: 
     407        for (i = 0; i < 5; i++) 
     408        curr = prev_visible(menu, curr - 1); 
     409        first = calc_first_early(menu, curr); 
     410        break; 
     411    case KEY_UP: 
     412        curr = prev_visible(menu, curr - 1); 
     413        if (curr < first) 
     414        first = calc_first_early(menu, curr); 
     415        break; 
     416    case KEY_DOWN: 
     417        curr = next_visible(menu, curr + 1); 
     418        if (!isvisible(menu, first, curr)) 
     419        first = calc_first_late(menu, curr); 
     420        break; 
     421    case KEY_LEFT: 
     422    case KEY_ESC: 
     423        return NULL; 
     424        break; 
     425    case KEY_RIGHT: 
     426    case KEY_ENTER: 
     427        if (ci->action == OPT_INACTIVE) 
     428        break; 
     429        if (ci->action == OPT_CHECKBOX) 
     430        break; 
     431        if (ci->action == OPT_SEP) 
     432        break; 
     433        if (ci->action == OPT_EXITMENU) 
     434        return NULL;    // As if we hit Esc 
     435        // If we are going into a radio menu, dont call handler, return ci 
     436        if (ci->action == OPT_RADIOMENU) 
     437        return ci; 
     438        if (ci->handler != NULL)    // Do we have a handler 
     439        { 
     440        hr = ci->handler(ms, ci); 
     441        if (hr.refresh) // Do we need to refresh 
     442        { 
     443            // Cleanup menu using old number of items 
     444            cleanupmenu(menu, top, left, numitems); 
     445            // Recalculate the number of items 
     446            numitems = calc_visible(menu, 0); 
     447            // Reprint the menu 
     448            printmenu(menu, curr, top, left, first, radio); 
     449        } 
     450        if (hr.valid) 
     451            return ci; 
     452        } else 
     453        return ci; 
     454        break; 
     455    case SPACECHAR: 
     456        if (ci->action != OPT_CHECKBOX) 
     457        break; 
     458        ci->itemdata.checked = !ci->itemdata.checked; 
     459        if (ci->handler != NULL)    // Do we have a handler 
     460        { 
     461        hr = ci->handler(ms, ci); 
     462        if (hr.refresh) // Do we need to refresh 
     463        { 
     464            // Cleanup menu using old number of items 
     465            cleanupmenu(menu, top, left, numitems); 
     466            // Recalculate the number of items 
     467            numitems = calc_visible(menu, 0); 
     468            // Reprint the menu 
     469            printmenu(menu, curr, top, left, first, radio); 
     470        } 
     471        } 
     472        break; 
     473    default: 
     474        // Check if this is a shortcut key 
     475        if (((asc >= 'A') && (asc <= 'Z')) || 
     476        ((asc >= 'a') && (asc <= 'z')) || 
     477        ((asc >= '0') && (asc <= '9'))) { 
     478        tmp = find_shortcut(menu, asc, curr); 
     479        if ((tmp > curr) && (!isvisible(menu, first, tmp))) 
     480            first = calc_first_late(menu, tmp); 
     481        if (tmp < curr) 
     482            first = calc_first_early(menu, tmp); 
     483        curr = tmp; 
     484        } else { 
     485        if (ms->keys_handler)   // Call extra keys handler 
     486            ms->keys_handler(ms, menu->items[curr], asc); 
     487 
     488            /* The handler may have changed the UI, reset it on exit */ 
     489            reset_ui(); 
     490            // Cleanup menu using old number of items 
     491            cleanupmenu(menu, top, left, numitems); 
     492            // Recalculate the number of items 
     493            numitems = calc_visible(menu, 0); 
     494            // Reprint the menu 
     495            printmenu(menu, curr, top, left, first, radio); 
     496        } 
     497        break; 
     498    } 
     499    // Update status line 
     500    /* Erase the previous status */ 
     501    gotoxy(ms->minrow + ms->statline, ms->mincol); 
     502    cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols); 
     503    /* Print the new status */ 
     504    gotoxy(ms->minrow + ms->statline, ms->mincol); 
    495505    printmenuitem(menu->items[curr]->status, ms->statusattr); 
    496     first = calc_first_early(menu, curr); 
    497     while (1)                   // Forever 
    498     { 
    499         printmenu(menu, curr, top, left, first); 
    500         ci = menu->items[curr]; 
    501         asc = getch(&scan); 
    502         switch (scan) { 
    503         case HOMEKEY: 
    504             curr = next_visible(menu, 0); 
    505             first = calc_first_early(menu, curr); 
    506             break; 
    507         case ENDKEY: 
    508             curr = prev_visible(menu, numitems - 1); 
    509             first = calc_first_late(menu, curr); 
    510             break; 
    511         case PAGEDN: 
    512             for (i = 0; i < 5; i++) 
    513                 curr = next_visible(menu, curr + 1); 
    514             first = calc_first_late(menu, curr); 
    515             break; 
    516         case PAGEUP: 
    517             for (i = 0; i < 5; i++) 
    518                 curr = prev_visible(menu, curr - 1); 
    519             first = calc_first_early(menu, curr); 
    520             break; 
    521         case UPARROW: 
    522             curr = prev_visible(menu, curr - 1); 
    523             if (curr < first) 
    524                 first = calc_first_early(menu, curr); 
    525             break; 
    526         case DNARROW: 
    527             curr = next_visible(menu, curr + 1); 
    528             if (!isvisible(menu, first, curr)) 
    529                 first = calc_first_late(menu, curr); 
    530             break; 
    531         case LTARROW: 
    532         case ESCAPE: 
    533             return NULL; 
    534             break; 
    535         case RTARROW: 
    536         case ENTERA: 
    537         case ENTERB: 
    538             if (ci->action == OPT_INACTIVE) 
    539                 break; 
    540             if (ci->action == OPT_CHECKBOX) 
    541                 break; 
    542             if (ci->action == OPT_SEP) 
    543                 break; 
    544             if (ci->action == OPT_EXITMENU) 
    545                 return NULL;    // As if we hit Esc 
    546             // If we are going into a radio menu, dont call handler, return ci 
    547             if (ci->action == OPT_RADIOMENU) 
    548                 return ci; 
    549             if (ci->handler != NULL)    // Do we have a handler 
    550             { 
    551                 hr = ci->handler(ms, ci); 
    552                 if (hr.refresh) // Do we need to refresh 
    553                 { 
    554                     // Cleanup menu using old number of items 
    555                     cleanupmenu(menu, top, left, numitems); 
    556                     // Recalculate the number of items 
    557                     numitems = calc_visible(menu, 0); 
    558                     // Reprint the menu 
    559                     printmenu(menu, curr, top, left, first); 
    560                 } 
    561                 if (hr.valid) 
    562                     return ci; 
    563             } else 
    564                 return ci; 
    565             break; 
    566         case SPACEKEY: 
    567             if (ci->action != OPT_CHECKBOX) 
    568                 break; 
    569             ci->itemdata.checked = !ci->itemdata.checked; 
    570             if (ci->handler != NULL)    // Do we have a handler 
    571             { 
    572                 hr = ci->handler(ms, ci); 
    573                 if (hr.refresh) // Do we need to refresh 
    574                 { 
    575                     // Cleanup menu using old number of items 
    576                     cleanupmenu(menu, top, left, numitems); 
    577                     // Recalculate the number of items 
    578                     numitems = calc_visible(menu, 0); 
    579                     // Reprint the menu 
    580                     printmenu(menu, curr, top, left, first); 
    581                 } 
    582             } 
    583             break; 
    584         default: 
    585             // Check if this is a shortcut key 
    586             if (((asc >= 'A') && (asc <= 'Z')) || 
    587                 ((asc >= 'a') && (asc <= 'z')) || 
    588                 ((asc >= '0') && (asc <= '9'))) { 
    589                 tmp = find_shortcut(menu, asc, curr); 
    590                 if ((tmp > curr) && (!isvisible(menu, first, tmp))) 
    591                     first = calc_first_late(menu, tmp); 
    592                 if (tmp < curr) 
    593                     first = calc_first_early(menu, tmp); 
    594                 curr = tmp; 
    595             } else { 
    596                 if (ms->keys_handler)   // Call extra keys handler 
    597                     ms->keys_handler(ms, menu->items[curr], (scan << 8) | asc); 
    598             } 
    599             break; 
    600         } 
    601         // Update status line 
    602         gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage); 
    603         cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, 
    604                ms->menupage); 
    605         printmenuitem(menu->items[curr]->status, ms->statusattr); 
    606     } 
    607     return NULL;                // Should never come here 
     506    } 
     507    return NULL;        // Should never come here 
    608508} 
    609509 
    610510/* Handle the entire system of menu's. */ 
    611511pt_menuitem runmenusystem(uchar top, uchar left, pt_menu cmenu, uchar startopt, 
    612                           uchar menutype) 
     512              uchar menutype) 
    613513     /* 
    614514      * cmenu 
     
    630530 
    631531    if (cmenu == NULL) 
    632         return NULL; 
     532    return NULL; 
     533 
    633534startover: 
    634535    // Set the menu height 
    635536    cmenu->menuheight = ms->maxrow - top - 3; 
    636537    if (cmenu->menuheight > ms->maxmenuheight) 
    637         cmenu->menuheight = ms->maxmenuheight; 
     538    cmenu->menuheight = ms->maxmenuheight; 
    638539    if (menutype == NORMALMENU) 
    639         opt = getmenuoption(cmenu, top, left, startopt); 
    640     else                        // menutype == RADIOMENU 
    641         opt = getradiooption(cmenu, top, left, startopt); 
     540    opt = getmenuoption(cmenu, top, left, startopt, false); 
     541    else            // menutype == RADIOMENU 
     542    opt = getmenuoption(cmenu, top, left, startopt, true); 
    642543 
    643544    if (opt == NULL) { 
    644         // User hit Esc 
    645         cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
    646         return NULL; 
     545    // User hit Esc 
     546    cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
     547    return NULL; 
    647548    } 
    648549    // Are we done with the menu system? 
    649550    if ((opt->action != OPT_SUBMENU) && (opt->action != OPT_RADIOMENU)) { 
    650         cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
    651         return opt;             // parent cleanup other menus 
     551    cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
     552    return opt;     // parent cleanup other menus 
    652553    } 
    653554    // Either radiomenu or submenu 
    654555    // Do we have a valid menu number? The next hack uses the fact that 
    655556    // itemdata.submenunum = itemdata.radiomenunum (since enum data type) 
    656     if (opt->itemdata.submenunum >= ms->nummenus)       // This is Bad.... 
     557    if (opt->itemdata.submenunum >= ms->nummenus)   // This is Bad.... 
    657558    { 
    658         gotoxy(12, 12, ms->menupage);   // Middle of screen 
    659         csprint("ERROR: Invalid submenu requested.", 0x07); 
    660         cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
    661         return NULL;            // Pretend user hit esc 
     559    gotoxy(12, 12); // Middle of screen 
     560    csprint("ERROR: Invalid submenu requested.", 0x07); 
     561    cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
     562    return NULL;        // Pretend user hit esc 
    662563    } 
    663564    // Call recursively for submenu 
     
    667568    col = ms->menus[(unsigned int)opt->itemdata.submenunum]->col; 
    668569    if (row == 0xFF) 
    669         row = top + opt->index + 2; 
     570    row = top + opt->index + 2; 
    670571    if (col == 0xFF) 
    671         col = left + 3 + (cmenu->menuwidth >> 1); 
     572    col = left + 3 + (cmenu->menuwidth >> 1); 
    672573    mt = (opt->action == OPT_SUBMENU ? NORMALMENU : RADIOMENU); 
    673574    startat = 0; 
    674575    if ((opt->action == OPT_RADIOMENU) && (opt->data != NULL)) 
    675         startat = ((t_menuitem *) opt->data)->index; 
     576    startat = ((t_menuitem *) opt->data)->index; 
    676577 
    677578    choice = runmenusystem(row, col, 
    678                            ms->menus[(unsigned int)opt->itemdata.submenunum], 
    679                            startat, mt); 
     579               ms->menus[(unsigned int)opt->itemdata.submenunum], 
     580               startat, mt); 
    680581    if (opt->action == OPT_RADIOMENU) { 
    681         if (choice != NULL) 
    682             opt->data = (void *)choice; // store choice in data field 
    683         if (opt->handler != NULL) 
    684             opt->handler(ms, opt); 
    685         choice = NULL;          // Pretend user hit esc 
    686     } 
    687     if (choice == NULL)         // User hit Esc in submenu 
     582    if (choice != NULL) 
     583        opt->data = (void *)choice; // store choice in data field 
     584    if (opt->handler != NULL) 
     585        opt->handler(ms, opt); 
     586    choice = NULL;      // Pretend user hit esc 
     587    } 
     588    if (choice == NULL)     // User hit Esc in submenu 
    688589    { 
    689         // Startover 
    690         startopt = opt->index; 
    691         goto startover; 
     590    // Startover 
     591    startopt = opt->index; 
     592    goto startover; 
    692593    } else { 
    693         cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
    694         return choice; 
     594    cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0)); 
     595    return choice; 
    695596    } 
    696597} 
     
    703604 
    704605    if (name == NULL) 
    705         return (uchar) (-1); 
     606    return (uchar) (-1); 
    706607    for (i = 0; i < ms->nummenus; i++) { 
    707         m = ms->menus[i]; 
    708         if ((m->name) && (strcmp(m->name, name) == 0)) 
    709             return i; 
     608    m = ms->menus[i]; 
     609    if ((m->name) && (strcmp(m->name, name) == 0)) 
     610        return i; 
    710611    } 
    711612    return (uchar) (-1); 
     
    723624    i = 0; 
    724625    for (i = 0; i < ms->nummenus; i++) { 
    725         m = ms->menus[i]; 
    726         for (j = 0; j < m->numitems; j++) { 
    727             mi = m->items[j]; 
    728             // if item is a submenu and has non-empty non-trivial data string 
    729             if (mi->data && strlen(mi->data) > 0 && 
    730                 ((mi->action == OPT_SUBMENU) 
    731                 || (mi->action == OPT_RADIOMENU))) { 
    732                 mi->itemdata.submenunum = find_menu_num(mi->data); 
    733             } 
    734         } 
     626    m = ms->menus[i]; 
     627    for (j = 0; j < m->numitems; j++) { 
     628        mi = m->items[j]; 
     629        // if item is a submenu and has non-empty non-trivial data string 
     630        if (mi->data && strlen(mi->data) > 0 && 
     631        ((mi->action == OPT_SUBMENU) 
     632        || (mi->action == OPT_RADIOMENU))) { 
     633        mi->itemdata.submenunum = find_menu_num(mi->data); 
     634        } 
     635    } 
    735636    } 
    736637} 
     
    741642{ 
    742643    pt_menuitem rv; 
    743     uchar oldpage, tpos; 
    744  
    745     fix_submenus();             // Fix submenu numbers incase nick names were used 
     644 
     645    fix_submenus();     // Fix submenu numbers incase nick names were used 
     646 
     647    /* Turn autowrap off, to avoid scrolling the menu */ 
     648    printf(CSI "?7l"); 
    746649 
    747650    // Setup screen for menusystem 
    748     oldpage = getdisppage(); 
    749     setdisppage(ms->menupage); 
    750     cls(); 
    751     clearwindow(ms->minrow, ms->mincol, ms->maxrow, ms->maxcol, 
    752                 ms->menupage, ms->fillchar, ms->fillattr); 
    753     tpos = (ms->numcols - strlen(ms->title) - 1) >> 1;  // center it on line 
    754     gotoxy(ms->minrow, ms->mincol, ms->menupage); 
    755     cprint(ms->tfillchar, ms->titleattr, ms->numcols, ms->menupage); 
    756     gotoxy(ms->minrow, ms->mincol + tpos, ms->menupage); 
    757     csprint(ms->title, ms->titleattr); 
    758  
    759     cursoroff();                // Doesn't seem to work? 
     651    reset_ui(); 
    760652 
    761653    // Go, main menu cannot be a radio menu 
    762654    rv = runmenusystem(ms->minrow + MENUROW, ms->mincol + MENUCOL, 
    763                        ms->menus[(unsigned int)startmenu], 0, NORMALMENU); 
     655               ms->menus[(unsigned int)startmenu], 0, NORMALMENU); 
    764656 
    765657    // Hide the garbage we left on the screen 
    766658    cursoron(); 
    767     if (oldpage == ms->menupage) 
    768         cls(); 
    769     else 
    770         setdisppage(oldpage); 
     659    cls(); 
    771660 
    772661    // Return user choice 
     
    781670    ms = (pt_menusystem) malloc(sizeof(t_menusystem)); 
    782671    if (ms == NULL) 
    783         return NULL; 
     672    return NULL; 
    784673    ms->nummenus = 0; 
    785674    // Initialise all menu pointers 
    786675    for (i = 0; i < MAXMENUS; i++) 
    787         ms->menus[i] = NULL; 
     676    ms->menus[i] = NULL; 
    788677 
    789678    ms->title = (char *)malloc(TITLELEN + 1); 
    790679    if (title == NULL) 
    791         strcpy(ms->title, TITLESTR);    // Copy string 
     680    strcpy(ms->title, TITLESTR);    // Copy string 
    792681    else 
    793         strcpy(ms->title, title); 
     682    strcpy(ms->title, title); 
    794683 
    795684    // Timeout settings 
     
    821710    ms->shadowattr = SHADOWATTR; 
    822711 
    823     ms->menupage = MENUPAGE;    // Usually no need to change this at all 
     712    ms->menupage = MENUPAGE;    // Usually no need to change this at all 
    824713 
    825714    // Initialise all handlers 
    826715    ms->handler = NULL; 
    827716    ms->keys_handler = NULL; 
    828     ms->ontimeout = NULL;       // No timeout handler 
     717    ms->ontimeout = NULL;   // No timeout handler 
    829718    ms->tm_total_timeout = 0; 
    830719    ms->tm_sofar_timeout = 0; 
     
    839728    // Figure out the size of the screen we are in now. 
    840729    // By default we use the whole screen for our menu 
     730    if (getscreensize(1, &ms->numrows, &ms->numcols)) { 
     731        /* Unknown screen size? */ 
     732        ms->numcols = 80; 
     733        ms->numrows = 24; 
     734    } 
    841735    ms->minrow = ms->mincol = 0; 
    842     ms->numcols = getnumcols(); 
    843     ms->numrows = getnumrows(); 
    844736    ms->maxcol = ms->numcols - 1; 
    845737    ms->maxrow = ms->numrows - 1; 
     
    848740    ms->maxmenuheight = ms->maxrow - ms->minrow - 3; 
    849741    if (ms->maxmenuheight > MAXMENUHEIGHT) 
    850         ms->maxmenuheight = MAXMENUHEIGHT; 
    851  
    852     // Set up the look of the box 
    853     set_box_type(MENUBOXTYPE); 
     742    ms->maxmenuheight = MAXMENUHEIGHT; 
     743 
     744    console_ansi_raw(); 
     745 
    854746    return ms; 
    855747} 
    856748 
    857749void set_normal_attr(uchar normal, uchar selected, uchar inactivenormal, 
    858                      uchar inactiveselected) 
     750             uchar inactiveselected) 
    859751{ 
    860752    if (normal != 0xFF) 
    861         ms->normalattr[0] = normal; 
     753    ms->normalattr[0] = normal; 
    862754    if (selected != 0xFF) 
    863         ms->reverseattr[0] = selected; 
     755    ms->reverseattr[0] = selected; 
    864756    if (inactivenormal != 0xFF) 
    865         ms->inactattr[0] = inactivenormal; 
     757    ms->inactattr[0] = inactivenormal; 
    866758    if (inactiveselected != 0xFF) 
    867         ms->revinactattr[0] = inactiveselected; 
     759    ms->revinactattr[0] = inactiveselected; 
    868760} 
    869761 
    870762void set_normal_hlite(uchar normal, uchar selected, uchar inactivenormal, 
    871                       uchar inactiveselected) 
     763              uchar inactiveselected) 
    872764{ 
    873765    if (normal != 0xFF) 
    874         ms->normalattr[1] = normal; 
     766    ms->normalattr[1] = normal; 
    875767    if (selected != 0xFF) 
    876         ms->reverseattr[1] = selected; 
     768    ms->reverseattr[1] = selected; 
    877769    if (inactivenormal != 0xFF) 
    878         ms->inactattr[1] = inactivenormal; 
     770    ms->inactattr[1] = inactivenormal; 
    879771    if (inactiveselected != 0xFF) 
    880         ms->revinactattr[1] = inactiveselected; 
     772    ms->revinactattr[1] = inactiveselected; 
    881773} 
    882774 
     
    884776{ 
    885777    if (statusattr != 0xFF) 
    886         ms->statusattr[NOHLITE] = statusattr; 
     778    ms->statusattr[NOHLITE] = statusattr; 
    887779    if (statushlite != 0xFF) 
    888         ms->statusattr[HLITE] = statushlite; 
     780    ms->statusattr[HLITE] = statushlite; 
    889781    // statline is relative to minrow 
    890782    if (statline >= ms->numrows) 
    891         statline = ms->numrows - 1; 
    892     ms->statline = statline;    // relative to ms->minrow, 0 based 
     783    statline = ms->numrows - 1; 
     784    ms->statline = statline;    // relative to ms->minrow, 0 based 
    893785} 
    894786 
     
    896788{ 
    897789    if (tfillchar != 0xFF) 
    898         ms->tfillchar = tfillchar; 
     790    ms->tfillchar = tfillchar; 
    899791    if (titleattr != 0xFF) 
    900         ms->titleattr = titleattr; 
     792    ms->titleattr = titleattr; 
    901793} 
    902794 
    903795void set_misc_info(uchar fillchar, uchar fillattr, uchar spacechar, 
    904                    uchar shadowattr) 
     796           uchar shadowattr) 
    905797{ 
    906798    if (fillchar != 0xFF) 
    907         ms->fillchar = fillchar; 
     799    ms->fillchar = fillchar; 
    908800    if (fillattr != 0xFF) 
    909         ms->fillattr = fillattr; 
     801    ms->fillattr = fillattr; 
    910802    if (spacechar != 0xFF) 
    911         ms->spacechar = spacechar; 
     803    ms->spacechar = spacechar; 
    912804    if (shadowattr != 0xFF) 
    913         ms->shadowattr = shadowattr; 
    914 } 
    915  
    916 void set_box_type(boxtype bt) 
    917 { 
    918     uchar *bxc; 
    919     ms->menubt = bt; 
    920     bxc = getboxchars(bt); 
    921     ms->box_horiz = bxc[BOX_HORIZ];     // The char used to draw top line 
    922     ms->box_ltrt = bxc[BOX_LTRT]; 
    923     ms->box_rtlt = bxc[BOX_RTLT]; 
     805    ms->shadowattr = shadowattr; 
    924806} 
    925807 
     
    927809{ 
    928810    if (maxmenuheight != 0xFF) 
    929         ms->maxmenuheight = maxmenuheight; 
     811    ms->maxmenuheight = maxmenuheight; 
    930812} 
    931813 
     
    933815void set_window_size(uchar top, uchar left, uchar bot, uchar right) 
    934816{ 
    935  
    936     uchar nr, nc; 
     817    int nr, nc; 
     818 
    937819    if ((top > bot) || (left > right)) 
    938         return;                 // Sorry no change will happen here 
    939     nr = getnumrows(); 
    940     nc = getnumcols(); 
     820    return;         // Sorry no change will happen here 
     821 
     822    if (getscreensize(1, &nr, &nc)) { 
     823        /* Unknown screen size? */ 
     824        nr = 80; 
     825        nc = 24; 
     826    } 
    941827    if (bot >= nr) 
    942         bot = nr - 1; 
     828    bot = nr - 1; 
    943829    if (right >= nc) 
    944         right = nc - 1; 
     830    right = nc - 1; 
    945831    ms->minrow = top; 
    946832    ms->mincol = left; 
     
    950836    ms->numrows = bot - top + 1; 
    951837    if (ms->statline >= ms->numrows) 
    952         ms->statline = ms->numrows - 1; // Clip statline if need be 
     838    ms->statline = ms->numrows - 1; // Clip statline if need be 
    953839} 
    954840 
     
    958844    switch (htype) { 
    959845    case HDLR_KEYS: 
    960         ms->keys_handler = (t_keys_handler) handler; 
    961         break; 
     846    ms->keys_handler = (t_keys_handler) handler; 
     847    break; 
    962848    default: 
    963         ms->handler = (t_menusystem_handler) handler; 
    964         break; 
     849    ms->handler = (t_menusystem_handler) handler; 
     850    break; 
    965851    } 
    966852} 
     
    970856    switch (htype) { 
    971857    case HDLR_KEYS: 
    972         ms->keys_handler = NULL; 
    973         break; 
     858    ms->keys_handler = NULL; 
     859    break; 
    974860    default: 
    975         ms->handler = NULL; 
    976         break; 
     861    ms->handler = NULL; 
     862    break; 
    977863    } 
    978864} 
    979865 
    980866void reg_ontimeout(t_timeout_handler handler, unsigned int numsteps, 
    981                    unsigned int stepsize) 
     867           unsigned int stepsize) 
    982868{ 
    983869    ms->ontimeout = handler; 
    984870    if (numsteps != 0) 
    985         ms->tm_numsteps = numsteps; 
     871    ms->tm_numsteps = numsteps; 
    986872    if (stepsize != 0) 
    987         ms->tm_stepsize = stepsize; 
     873    ms->tm_stepsize = stepsize; 
    988874} 
    989875 
     
    994880 
    995881void reg_ontotaltimeout(t_timeout_handler handler, 
    996                         unsigned long numcentiseconds) 
     882            unsigned long numcentiseconds) 
    997883{ 
    998884    if (numcentiseconds != 0) { 
    999         ms->ontotaltimeout = handler; 
    1000         ms->tm_total_timeout = numcentiseconds * 10;    // to convert to milliseconds 
    1001         ms->tm_sofar_timeout = 0; 
     885    ms->ontotaltimeout = handler; 
     886    ms->tm_total_timeout = numcentiseconds * 10;    // to convert to milliseconds 
     887    ms->tm_sofar_timeout = 0; 
    1002888    } 
    1003889} 
     
    1012898    int ans; 
    1013899    if (index < 0) 
    1014         ans = 0; 
     900    ans = 0; 
    1015901    else if (index >= menu->numitems) 
    1016         ans = menu->numitems - 1; 
     902    ans = menu->numitems - 1; 
    1017903    else 
    1018         ans = index; 
     904    ans = index; 
    1019905    while ((ans < menu->numitems - 1) && 
    1020            ((menu->items[ans]->action == OPT_INVISIBLE) || 
    1021             (menu->items[ans]->action == OPT_SEP))) 
    1022         ans++; 
     906       ((menu->items[ans]->action == OPT_INVISIBLE) || 
     907        (menu->items[ans]->action == OPT_SEP))) 
     908    ans++; 
    1023909    return ans; 
    1024910} 
    1025911 
    1026 int prev_visible(pt_menu menu, int index)       // Return index of prev visible 
     912int prev_visible(pt_menu menu, int index)   // Return index of prev visible 
    1027913{ 
    1028914    int ans; 
    1029915    if (index < 0) 
    1030         ans = 0; 
     916    ans = 0; 
    1031917    else if (index >= menu->numitems) 
    1032         ans = menu->numitems - 1; 
     918    ans = menu->numitems - 1; 
    1033919    else 
    1034         ans = index; 
     920    ans = index; 
    1035921    while ((ans > 0) && 
    1036            ((menu->items[ans]->action == OPT_INVISIBLE) || 
    1037             (menu->items[ans]->action == OPT_SEP))) 
    1038         ans--; 
     922       ((menu->items[ans]->action == OPT_INVISIBLE) || 
     923        (menu->items[ans]->action == OPT_SEP))) 
     924    ans--; 
    1039925    return ans; 
    1040926} 
     
    1044930    int ans; 
    1045931    if (index < 0) 
    1046         ans = 0; 
     932    ans = 0; 
    1047933    else if (index >= menu->numitems) 
    1048         ans = menu->numitems - 1; 
     934    ans = menu->numitems - 1; 
    1049935    else 
    1050         ans = index; 
     936    ans = index; 
    1051937    while ((ans < menu->numitems - 1) && 
    1052            (menu->items[ans]->action == OPT_INVISIBLE)) 
    1053         ans++; 
     938       (menu->items[ans]->action == OPT_INVISIBLE)) 
     939    ans++; 
    1054940    return ans; 
    1055941} 
    1056942 
    1057 int prev_visible_sep(pt_menu menu, int index)   // Return index of prev visible 
     943int prev_visible_sep(pt_menu menu, int index)   // Return index of prev visible 
    1058944{ 
    1059945    int ans; 
    1060946    if (index < 0) 
    1061         ans = 0; 
     947    ans = 0; 
    1062948    else if (index >= menu->numitems) 
    1063         ans = menu->numitems - 1; 
     949    ans = menu->numitems - 1; 
    1064950    else 
    1065         ans = index; 
     951    ans = index; 
    1066952    while ((ans > 0) && (menu->items[ans]->action == OPT_INVISIBLE)) 
    1067         ans--; 
     953    ans--; 
    1068954    return ans; 
    1069955} 
     
    1074960 
    1075961    if (menu == NULL) 
    1076         return 0; 
     962    return 0; 
    1077963    ans = 0; 
    1078964    for (i = first; i < menu->numitems; i++) 
    1079         if (menu->items[i]->action != OPT_INVISIBLE) 
    1080             ans++; 
     965    if (menu->items[i]->action != OPT_INVISIBLE) 
     966        ans++; 
    1081967    return ans; 
    1082968} 
     
    1086972{ 
    1087973    if (curr < first) 
    1088         return 0; 
     974    return 0; 
    1089975    return (calc_visible(menu, first) - calc_visible(menu, curr) < 
    1090             menu->menuheight); 
     976        menu->menuheight); 
    1091977} 
    1092978 
     
    1099985    nv = calc_visible(menu, 0); 
    1100986    if (nv <= menu->menuheight) 
    1101         return 0; 
     987    return 0; 
    1102988    // Start with curr and go back menu->menuheight times 
    1103989    ans = curr + 1; 
    1104990    for (i = 0; i < menu->menuheight; i++) 
    1105         ans = prev_visible_sep(menu, ans - 1); 
     991    ans = prev_visible_sep(menu, ans - 1); 
    1106992    return ans; 
    1107993} 
     
    11151001    nv = calc_visible(menu, 0); 
    11161002    if (nv <= menu->menuheight) 
    1117         return 0; 
     1003    return 0; 
    11181004    // Start with curr and go back till >= menu->menuheight 
    11191005    // items are visible 
    1120     nv = calc_visible(menu, curr);      // Already nv of them are visible 
     1006    nv = calc_visible(menu, curr);  // Already nv of them are visible 
    11211007    ans = curr; 
    11221008    for (i = 0; i < menu->menuheight - nv; i++) 
    1123         ans = prev_visible_sep(menu, ans - 1); 
     1009    ans = prev_visible_sep(menu, ans - 1); 
    11241010    return ans; 
    11251011} 
     
    11331019    num = ms->nummenus; 
    11341020    if (num >= MAXMENUS) 
    1135         return -1; 
     1021    return -1; 
    11361022    m = NULL; 
    11371023    m = (pt_menu) malloc(sizeof(t_menu)); 
    11381024    if (m == NULL) 
    1139         return -1; 
     1025    return -1; 
    11401026    ms->menus[num] = m; 
    11411027    m->numitems = 0; 
     
    11441030    m->col = 0xFF; 
    11451031    if (maxmenusize < 1) 
    1146         m->maxmenusize = MAXMENUSIZE; 
     1032    m->maxmenusize = MAXMENUSIZE; 
    11471033    else 
    1148         m->maxmenusize = maxmenusize; 
     1034    m->maxmenusize = maxmenusize; 
    11491035    m->items = (pt_menuitem *) malloc(sizeof(pt_menuitem) * (m->maxmenusize)); 
    11501036    for (i = 0; i < m->maxmenusize; i++) 
    1151         m->items[i] = NULL; 
     1037    m->items[i] = NULL; 
    11521038 
    11531039    m->title = (char *)malloc(MENULEN + 1); 
    11541040    if (title) { 
    1155         if (strlen(title) > MENULEN - 2) 
    1156             strcpy(m->title, TITLELONG); 
    1157         else 
    1158             strcpy(m->title, title); 
     1041    if (strlen(title) > MENULEN - 2) 
     1042        strcpy(m->title, TITLELONG); 
     1043    else 
     1044        strcpy(m->title, title); 
    11591045    } else 
    1160         strcpy(m->title, EMPTYSTR); 
     1046    strcpy(m->title, EMPTYSTR); 
    11611047    m->menuwidth = strlen(m->title); 
    11621048    ms->nummenus++; 
     
    11641050} 
    11651051 
    1166 void set_menu_name(const char *name)    // Set the "name" of this menu 
     1052void set_menu_name(const char *name)    // Set the "name" of this menu 
    11671053{ 
    11681054    pt_menu m; 
    11691055 
    11701056    m = ms->menus[ms->nummenus - 1]; 
    1171     if (m->name)                // Free up previous name 
     1057    if (m->name)        // Free up previous name 
    11721058    { 
    1173         free(m->name); 
    1174         m->name = NULL; 
     1059    free(m->name); 
     1060    m->name = NULL; 
    11751061    } 
    11761062 
    11771063    if (name) { 
    1178         m->name = (char *)malloc(strlen(name) + 1); 
    1179         strcpy(m->name, name); 
     1064    m->name = (char *)malloc(strlen(name) + 1); 
     1065    strcpy(m->name, name); 
    11801066    } 
    11811067} 
     
    11891075} 
    11901076 
    1191 void set_menu_pos(uchar row, uchar col) // Set the position of this menu. 
     1077void set_menu_pos(uchar row, uchar col) // Set the position of this menu. 
    11921078{ 
    11931079    pt_menu m; 
     
    11981084} 
    11991085 
    1200 pt_menuitem add_sep()           // Add a separator to current menu 
     1086pt_menuitem add_sep()       // Add a separator to current menu 
    12011087{ 
    12021088    pt_menuitem mi; 
     
    12071093    mi = (pt_menuitem) malloc(sizeof(t_menuitem)); 
    12081094    if (mi == NULL) 
    1209         return NULL; 
     1095    return NULL; 
    12101096    m->items[(unsigned int)m->numitems] = mi; 
    1211     mi->handler = NULL;         // No handler 
     1097    mi->handler = NULL;     // No handler 
    12121098    mi->item = mi->status = mi->data = NULL; 
    12131099    mi->action = OPT_SEP; 
     
    12211107// Add item to the "current" menu 
    12221108pt_menuitem add_item(const char *item, const char *status, t_action action, 
    1223                      const char *data, uchar itemdata) 
     1109             const char *data, uchar itemdata) 
    12241110{ 
    12251111    pt_menuitem mi; 
    12261112    pt_menu m; 
    12271113    const char *str; 
    1228     uchar inhlite = 0;          // Are we inside hlite area 
     1114    uchar inhlite = 0;      // Are we inside hlite area 
    12291115 
    12301116    m = (ms->menus[ms->nummenus - 1]); 
     
    12321118    mi = (pt_menuitem) malloc(sizeof(t_menuitem)); 
    12331119    if (mi == NULL) 
    1234         return NULL; 
     1120    return NULL; 
    12351121    m->items[(unsigned int)m->numitems] = mi; 
    1236     mi->handler = NULL;         // No handler 
     1122    mi->handler = NULL;     // No handler 
    12371123 
    12381124    // Allocate space to store stuff 
     
    12421128 
    12431129    if (item) { 
    1244         if (strlen(item) > MENULEN) { 
    1245             strcpy(mi->item, ITEMLONG); 
    1246         } else { 
    1247             strcpy(mi->item, item); 
    1248         } 
    1249         if (strlen(mi->item) > m->menuwidth) 
    1250             m->menuwidth = strlen(mi->item); 
     1130    if (strlen(item) > MENULEN) { 
     1131        strcpy(mi->item, ITEMLONG); 
     1132    } else { 
     1133        strcpy(mi->item, item); 
     1134    } 
     1135    if (strlen(mi->item) > m->menuwidth) 
     1136        m->menuwidth = strlen(mi->item); 
    12511137    } else 
    1252         strcpy(mi->item, EMPTYSTR); 
     1138    strcpy(mi->item, EMPTYSTR); 
    12531139 
    12541140    if (status) { 
    1255         if (strlen(status) > STATLEN) { 
    1256             strcpy(mi->status, STATUSLONG); 
    1257         } else { 
    1258             strcpy(mi->status, status); 
    1259         } 
     1141    if (strlen(status) > STATLEN) { 
     1142        strcpy(mi->status, STATUSLONG); 
     1143    } else { 
     1144        strcpy(mi->status, status); 
     1145    } 
    12601146    } else 
    1261         strcpy(mi->status, EMPTYSTR); 
     1147    strcpy(mi->status, EMPTYSTR); 
    12621148 
    12631149    mi->action = action; 
     
    12651151    mi->shortcut = 0; 
    12661152    mi->helpid = 0xFFFF; 
    1267     inhlite = 0;                // We have not yet seen an ENABLEHLITE char 
     1153    inhlite = 0;        // We have not yet seen an ENABLEHLITE char 
    12681154    // Find the first char in [A-Za-z0-9] after ENABLEHLITE and not arg to control char 
    12691155    while (*str) { 
    1270         if (*str == ENABLEHLITE) { 
    1271             inhlite = 1; 
    1272         } 
    1273         if (*str == DISABLEHLITE) { 
    1274             inhlite = 0; 
    1275         } 
    1276         if ((inhlite == 1) && 
    1277             (((*str >= 'A') && (*str <= 'Z')) || 
    1278              ((*str >= 'a') && (*str <= 'z')) || 
    1279              ((*str >= '0') && (*str <= '9')))) { 
    1280             mi->shortcut = *str; 
    1281             break; 
    1282         } 
    1283         ++str; 
    1284     } 
    1285     if ((mi->shortcut >= 'A') && (mi->shortcut <= 'Z')) // Make lower case 
    1286         mi->shortcut = mi->shortcut - 'A' + 'a'; 
     1156    if (*str == ENABLEHLITE) { 
     1157        inhlite = 1; 
     1158    } 
     1159    if (*str == DISABLEHLITE) { 
     1160        inhlite = 0; 
     1161    } 
     1162    if ((inhlite == 1) && 
     1163        (((*str >= 'A') && (*str <= 'Z')) || 
     1164         ((*str >= 'a') && (*str <= 'z')) || 
     1165         ((*str >= '0') && (*str <= '9')))) { 
     1166        mi->shortcut = *str; 
     1167        break; 
     1168    } 
     1169    ++str; 
     1170    } 
     1171    if ((mi->shortcut >= 'A') && (mi->shortcut <= 'Z')) // Make lower case 
     1172    mi->shortcut = mi->shortcut - 'A' + 'a'; 
    12871173 
    12881174    if (data) { 
    1289         if (strlen(data) > ACTIONLEN) { 
    1290             strcpy(mi->data, ACTIONLONG); 
    1291         } else { 
    1292             strcpy(mi->data, data); 
    1293         } 
     1175    if (strlen(data) > ACTIONLEN) { 
     1176        strcpy(mi->data, ACTIONLONG); 
     1177    } else { 
     1178        strcpy(mi->data, data); 
     1179    } 
    12941180    } else 
    1295         strcpy(mi->data, EMPTYSTR); 
     1181    strcpy(mi->data, EMPTYSTR); 
    12961182 
    12971183    switch (action) { 
    12981184    case OPT_SUBMENU: 
    1299         mi->itemdata.submenunum = itemdata; 
    1300         break; 
     1185    mi->itemdata.submenunum = itemdata; 
     1186    break; 
    13011187    case OPT_CHECKBOX: 
    1302         mi->itemdata.checked = itemdata; 
    1303         break; 
     1188    mi->itemdata.checked = itemdata; 
     1189    break; 
    13041190    case OPT_RADIOMENU: 
    1305         mi->itemdata.radiomenunum = itemdata; 
    1306         if (mi->data) 
    1307             free(mi->data); 
    1308         mi->data = NULL;        // No selection made 
    1309         break; 
    1310     default:                    // to keep the compiler happy 
    1311         break; 
     1191    mi->itemdata.radiomenunum = itemdata; 
     1192    if (mi->data) 
     1193        free(mi->data); 
     1194    mi->data = NULL;    // No selection made 
     1195    break; 
     1196    default:            // to keep the compiler happy 
     1197    break; 
    13121198    } 
    13131199    mi->index = m->numitems++; 
     
    13241210    m = (ms->menus[ms->nummenus - 1]); 
    13251211    if (m->numitems <= 0) 
    1326         return; 
     1212    return; 
    13271213    mi = m->items[(unsigned int)m->numitems - 1]; 
    13281214 
    13291215    if (shortcut != 0xFF) 
    1330         mi->shortcut = shortcut; 
     1216    mi->shortcut = shortcut; 
    13311217    if (helpid != 0xFFFF) 
    1332         mi->helpid = helpid; 
     1218    mi->helpid = helpid; 
    13331219} 
    13341220 
     
    13451231    char *app; 
    13461232    int ctr; 
    1347     char dp; 
    1348  
    1349     dp = getdisppage(); 
     1233 
    13501234    menu = ms->menus[menunum]; 
    13511235    for (ctr = 0; ctr < (int)menu->numitems; ctr++) { 
    1352         mi = menu->items[ctr]; 
    1353         app = NULL;             //What to append 
    1354         switch (mi->action) { 
    1355         case OPT_CHECKBOX: 
    1356             if (mi->itemdata.checked) 
    1357                 app = mi->data; 
    1358             break; 
    1359         case OPT_RADIOMENU: 
    1360             if (mi->data) {     // Some selection has been made 
    1361                 ri = (pt_menuitem) (mi->data); 
    1362                 app = ri->data; 
    1363             } 
    1364             break; 
    1365         case OPT_SUBMENU: 
    1366             append_line_helper(mi->itemdata.submenunum, line); 
    1367             break; 
    1368         default: 
    1369             break; 
    1370         } 
    1371         if (app) { 
    1372             strcat(line, " "); 
    1373             strcat(line, app); 
    1374         } 
     1236    mi = menu->items[ctr]; 
     1237    app = NULL;     //What to append 
     1238    switch (mi->action) { 
     1239    case OPT_CHECKBOX: 
     1240        if (mi->itemdata.checked) 
     1241        app = mi->data; 
     1242        break; 
     1243    case OPT_RADIOMENU: 
     1244        if (mi->data) { // Some selection has been made 
     1245        ri = (pt_menuitem) (mi->data); 
     1246        app = ri->data; 
     1247        } 
     1248        break; 
     1249    case OPT_SUBMENU: 
     1250        append_line_helper(mi->itemdata.submenunum, line); 
     1251        break; 
     1252    default: 
     1253        break; 
     1254    } 
     1255    if (app) { 
     1256        strcat(line, " "); 
     1257        strcat(line, app); 
     1258    } 
    13751259    } 
    13761260} 
     
    13841268    menunum = find_menu_num(menu_name); 
    13851269    if (menunum < 0) 
    1386         return;                 // No such menu 
     1270    return;         // No such menu 
    13871271    append_line_helper(menunum, line); 
    13881272} 
  • com32/cmenu/libmenu/menu.h

    r1ef30e r397586  
    2323#include "tui.h" 
    2424#include "syslnx.h" 
    25 #include "scancodes.h" 
    2625#include <string.h> 
     26#include <unistd.h> 
    2727 
    2828// TIMEOUT PARAMETERS 
     
    6060#define STATUSHLITE   0x7B      // Status highlight 
    6161 
    62 #define FILLCHAR      177 
    63 #define FILLATTR      0x01 
     62#define FILLCHAR      ' ' 
     63#define FILLATTR      NORMALATTR 
    6464#define SHADOWATTR    0x00 
    6565#define SPACECHAR     ' ' 
     
    7373#define HLITE         1         // The offset for Hlite attrib 
    7474 
    75 #define MOREABOVE    24         // char to print when more menu items available above 
    76 #define MOREBELOW    25         // more items available below 
    77 #define SCROLLBOX    176        // Filled char to display 
     75#define MOREABOVE    '^'                // char to print when more menu items available above 
     76#define MOREBELOW    'v'                // more items available below 
    7877 
    7978// Attributes of the menu system 
     
    10099 
    101100// Other Chars 
    102 #define SUBMENUCHAR   175       // This is >> symbol 
    103101#define RADIOMENUCHAR '>'       // > symbol for radio menu? 
    104 #define EXITMENUCHAR  174       // This is << symbol 
    105 #define CHECKED       251       // Check mark 
    106 #define UNCHECKED     250       // Light bullet 
     102#define CHECKED       '\140'    // Check mark 
     103#define UNCHECKED     '\146'    // Light bullet 
    107104#define RADIOSEL      '.'       // Current Radio Selection 
    108105#define RADIOUNSEL    ' '       // Radio option not selected 
     
    215212    uchar statline; 
    216213    uchar menupage; 
    217     uchar maxrow, minrow, numrows;      // Number of rows in the window 
    218     uchar maxcol, mincol, numcols;      // Number of columns in the window 
     214    int maxrow, minrow, numrows;        // Number of rows in the window 
     215    int maxcol, mincol, numcols;        // Number of columns in the window 
    219216 
    220217    // Menu box look 
    221     boxtype menubt;             // What type of boxes should be drawn 
    222218    char box_horiz, box_ltrt, box_rtlt; // Some chars of the box, for redrawing portions of the box 
    223219 
     
    244240void set_misc_info(uchar fillchar, uchar fillattr, uchar spacechar, 
    245241                   uchar shadowattr); 
    246 void set_box_type(boxtype bt); 
    247242 
    248243void set_window_size(uchar top, uchar left, uchar bot, uchar right);    // Set the window which menusystem should use 
  • com32/cmenu/libmenu/tui.c

    r9ee1ad r843f0e  
    1515#include <com32.h> 
    1616#include <stdlib.h> 
     17#include "com32io.h" 
    1718 
    1819com32sys_t inreg, outreg;       // Global register sets for use 
     
    2021char bkspstr[] = " \b$"; 
    2122char eolstr[] = "\n$"; 
    22 #define GETSTRATTR 0x07 
    2323 
    2424// Reads a line of input from stdin. Replace CR with NUL byte 
     
    3030                  unsigned int showoldvalue) 
    3131{ 
    32     unsigned char c, scan; 
     32    unsigned int c; 
    3333    char *p, *q;                // p = current char of string, q = tmp 
    3434    char *last;                 // The current last char of string 
    3535    char *str;                  // pointer to string which is going to be allocated 
    36     char page; 
    3736    char row, col; 
    3837    char start, end;            // Cursor shape 
     
    4039    char insmode;               // Are we in insert or overwrite 
    4140 
    42     page = getdisppage(); 
    43     getpos(&row, &col, page);   // Get current position 
     41    getpos(&row, &col, 0);      // Get current position 
    4442    getcursorshape(&start, &end); 
    4543    insmode = 1; 
     
    6866    if (password == 0)          // Not a password, print initial value 
    6967    { 
    70         gotoxy(row, col, page); 
     68        gotoxy(row, col); 
    7169        csprint(str, GETSTRATTR); 
    7270    } 
    7371    while (1) {                 // Do forever 
    74         c = inputc(&scan); 
    75         if (c == '\r') 
     72        c = get_key(stdin, 0); 
     73        if (c == KEY_ENTER) 
    7674            break;              // User hit Enter getout of loop 
    77         if (scan == ESCAPE)     // User hit escape getout and nullify string 
     75        if (c == KEY_ESC)       // User hit escape getout and nullify string 
    7876        { 
    7977            *str = 0; 
     
    8482        // else if char code is recognized do something 
    8583        // else ignore 
    86         switch (scan) { 
    87         case HOMEKEY: 
     84        switch (c) { 
     85        case KEY_HOME: 
    8886            p = str; 
    8987            break; 
    90         case ENDKEY: 
     88        case KEY_END: 
    9189            p = last; 
    9290            break; 
    93         case LTARROW: 
     91        case KEY_LEFT: 
    9492            if (p > str) 
    9593                p--; 
    9694            break; 
    97         case CTRLLT: 
     95        case KEY_CTRL(KEY_LEFT): 
    9896            if (p == str) 
    9997                break; 
     
    111109                p--; 
    112110            break; 
    113         case RTARROW: 
     111        case KEY_RIGHT: 
    114112            if (p < last) 
    115113                p++; 
    116114            break; 
    117         case CTRLRT: 
     115        case KEY_CTRL(KEY_RIGHT): 
    118116            if (*p == 0) 
    119117                break;          // At end of string 
     
    126124                p++; 
    127125            break; 
    128         case DELETE: 
     126        case KEY_DEL: 
     127        case KEY_DELETE: 
    129128            q = p; 
    130129            while (*(q + 1)) { 
     
    136135            fudge = 1; 
    137136            break; 
    138         case INSERT: 
     137        case KEY_INSERT: 
    139138            insmode = 1 - insmode;      // Switch mode 
    140139            if (insmode == 0) 
     
    143142                setcursorshape(6, 7);   // Normal cursor 
    144143            break; 
    145  
    146         default:                // Unrecognized scan code, look at the ascii value 
    147             switch (c) { 
    148             case '\b':          // Move over by one 
     144        case KEY_BACKSPACE:             // Move over by one 
    149145                q = p; 
    150146                while (q <= last) { 
     
    158154                fudge = 1; 
    159155                break; 
    160             case '\x15':        /* Ctrl-U: kill input */ 
     156        case KEY_CTRL('U'):     /* Ctrl-U: kill input */ 
    161157                fudge = last - str; 
    162158                while (p > str) 
     
    166162                last = str; 
    167163                break; 
    168             default:            // Handle insert and overwrite mode 
     164        default:                // Handle insert and overwrite mode 
    169165                if ((c >= ' ') && (c < 128) && 
    170166                    ((unsigned int)(p - str) < size - 1)) { 
     
    190186                } else 
    191187                    beep(); 
    192             } 
    193188            break; 
    194189        } 
    195190        // Now the string has been modified, print it 
    196191        if (password == 0) { 
    197             gotoxy(row, col, page); 
     192            gotoxy(row, col); 
    198193            csprint(str, GETSTRATTR); 
    199194            if (fudge > 0) 
    200                 cprint(' ', GETSTRATTR, fudge, page); 
    201             gotoxy(row, col + (p - str), page); 
     195                cprint(' ', GETSTRATTR, fudge); 
     196            gotoxy(row, col + (p - str)); 
    202197        } 
    203     } 
     198    } /* while */ 
    204199    *p = '\0'; 
    205200    if (password == 0) 
     
    207202    setcursorshape(start, end); // Block cursor 
    208203    // If user hit ESCAPE so return without any changes 
    209     if (scan != ESCAPE) 
     204    if (c != KEY_ESC) 
    210205        strcpy(stra, str); 
    211206    free(str); 
    212207} 
    213208 
    214 /* Print a C string (NUL-terminated) */ 
    215 void cswprint(const char *str, char attr, char left) 
     209//////////////////////////////Box Stuff 
     210 
     211// Draw box and lines 
     212void drawbox(const char top, const char left, const char bot, 
     213             const char right, const char attr) 
    216214{ 
    217     char page = getdisppage(); 
    218     char newattr = 0, cha, chb; 
    219     char row, col; 
    220     char nr, nc; 
    221  
    222     nr = getnumrows(); 
    223     nc = getnumcols(); 
    224     getpos(&row, &col, page); 
    225     while (*str) { 
    226         switch (*str) { 
    227         case '\b': 
    228             --col; 
    229             break; 
    230         case '\n': 
    231             ++row; 
    232             col = left; 
    233             break; 
    234         case '\r': 
    235             //col=left; 
    236             break; 
    237         case BELL:              // Bell Char 
    238             beep(); 
    239             break; 
    240         case CHRELATTR: // change attribute (relatively) 
    241         case CHABSATTR: // change attribute (absolute) 
    242             cha = *(str + 1); 
    243             chb = *(str + 2); 
    244             if ((((cha >= '0') && (cha <= '9')) || ((cha >= 'A') && (cha <= 'F'))) && (((chb >= '0') && (chb <= '9')) || ((chb >= 'A') && (chb <= 'F'))))       // Next two chars are legal 
    245             { 
    246                 if ((cha >= 'A') && (cha <= 'F')) 
    247                     cha = cha - 'A' + 10; 
    248                 else 
    249                     cha = cha - '0'; 
    250                 if ((chb >= 'A') && (chb <= 'F')) 
    251                     chb = chb - 'A' + 10; 
    252                 else 
    253                     chb = chb - '0'; 
    254                 newattr = (cha << 4) + chb; 
    255                 attr = (*str == CHABSATTR ? newattr : attr ^ newattr); 
    256                 str += 2;       // Will be incremented again later 
    257             } 
    258             break; 
    259         default: 
    260             putch(*str, attr, page); 
    261             ++col; 
    262         } 
    263         if (col >= nc) { 
    264             ++row; 
    265             col = left; 
    266         } 
    267         if (row > nr) { 
    268             scrollup(); 
    269             row = nr; 
    270         } 
    271         gotoxy(row, col, page); 
    272         str++; 
    273     } 
    274 } 
    275  
    276 void clearwindow(char top, char left, char bot, char right, char page, 
    277                  char fillchar, char fillattr) 
    278 { 
    279     char x; 
    280     for (x = top; x < bot + 1; x++) { 
    281         gotoxy(x, left, page); 
    282         cprint(fillchar, fillattr, right - left + 1, page); 
    283     } 
    284 } 
    285  
    286 void cls(void) 
    287 { 
    288     unsigned char dp = getdisppage(); 
    289     gotoxy(0, 0, dp); 
    290     cprint(' ', GETSTRATTR, (1 + getnumrows()) * getnumcols(), dp); 
    291 } 
    292  
    293 //////////////////////////////Box Stuff 
    294  
    295 // This order of numbers must match 
    296 // the values of BOX_TOPLEFT,... in the header file 
    297  
    298 unsigned char SINSIN_CHARS[] = { 218, 192, 191, 217,    //Corners 
    299     196, 179,                   // Horiz and Vertical 
    300     195, 180, 194, 193, 197 
    301 };                              // Connectors & Middle 
    302  
    303 unsigned char DBLDBL_CHARS[] = { 201, 200, 187, 188,    // Corners 
    304     205, 186,                   // Horiz and Vertical 
    305     199, 182, 203, 202, 206 
    306 };                              // Connectors & Middle 
    307  
    308 unsigned char SINDBL_CHARS[] = { 214, 211, 183, 189,    // Corners 
    309     196, 186,                   // Horiz & Vert 
    310     199, 182, 210, 208, 215 
    311 };                              // Connectors & Middle 
    312  
    313 unsigned char DBLSIN_CHARS[] = { 213, 212, 184, 190,    // Corners 
    314     205, 179,                   // Horiz & Vert 
    315     198, 181, 209, 207, 216 
    316 };                              // Connectors & Middle 
    317  
    318 unsigned char *getboxchars(boxtype bt) 
    319 { 
    320     switch (bt) { 
    321     case BOX_SINSIN: 
    322         return SINSIN_CHARS; 
    323         break; 
    324     case BOX_DBLDBL: 
    325         return DBLDBL_CHARS; 
    326         break; 
    327     case BOX_SINDBL: 
    328         return SINDBL_CHARS; 
    329         break; 
    330     case BOX_DBLSIN: 
    331         return DBLSIN_CHARS; 
    332         break; 
    333     default: 
    334         return SINSIN_CHARS; 
    335         break; 
    336     } 
    337     return SINSIN_CHARS; 
    338 } 
    339  
    340 // Draw box and lines 
    341 void drawbox(char top, char left, char bot, char right, 
    342              char page, char attr, boxtype bt) 
    343 { 
    344     unsigned char *box_chars;   // pointer to array of box chars 
    345215    unsigned char x; 
    346  
    347     box_chars = getboxchars(bt); 
     216        putchar(SO); 
    348217    // Top border 
    349     gotoxy(top, left, page); 
    350     cprint(box_chars[BOX_TOPLEFT], attr, 1, page); 
    351     gotoxy(top, left + 1, page); 
    352     cprint(box_chars[BOX_TOP], attr, right - left, page); 
    353     gotoxy(top, right, page); 
    354     cprint(box_chars[BOX_TOPRIGHT], attr, 1, page); 
     218    gotoxy(top, left); 
     219    putch(TOP_LEFT_CORNER_BORDER, attr); 
     220    cprint(TOP_BORDER, attr, right - left - 1); 
     221    putch(TOP_RIGHT_CORNER_BORDER, attr); 
    355222    // Bottom border 
    356     gotoxy(bot, left, page); 
    357     cprint(box_chars[BOX_BOTLEFT], attr, 1, page); 
    358     gotoxy(bot, left + 1, page); 
    359     cprint(box_chars[BOX_BOT], attr, right - left, page); 
    360     gotoxy(bot, right, page); 
    361     cprint(box_chars[BOX_BOTRIGHT], attr, 1, page); 
     223    gotoxy(bot, left); 
     224    putch(BOTTOM_LEFT_CORNER_BORDER, attr); 
     225    cprint(BOTTOM_BORDER, attr, right - left - 1); 
     226    putch(BOTTOM_RIGHT_CORNER_BORDER, attr); 
    362227    // Left & right borders 
    363228    for (x = top + 1; x < bot; x++) { 
    364         gotoxy(x, left, page); 
    365         cprint(box_chars[BOX_LEFT], attr, 1, page); 
    366         gotoxy(x, right, page); 
    367         cprint(box_chars[BOX_RIGHT], attr, 1, page); 
    368     } 
     229        gotoxy(x, left); 
     230        putch(LEFT_BORDER, attr); 
     231        gotoxy(x, right); 
     232        putch(RIGHT_BORDER, attr); 
     233    } 
     234        putchar(SI); 
    369235} 
    370236 
    371 void drawhorizline(char top, char left, char right, char page, char attr, 
    372                    boxtype bt, char dumb) 
     237void drawhorizline(const char top, const char left, const char right, 
     238                   const char attr, char dumb) 
    373239{ 
    374240    unsigned char start, end; 
    375     unsigned char *box_chars = getboxchars(bt); 
    376241    if (dumb == 0) { 
    377242        start = left + 1; 
     
    381246        end = right; 
    382247    } 
    383     gotoxy(top, start, page); 
    384     cprint(box_chars[BOX_HORIZ], attr, end - start + 1, page); 
     248    gotoxy(top, start); 
     249        putchar(SO); 
     250    cprint(MIDDLE_BORDER, attr, end - start + 1); 
    385251    if (dumb == 0) { 
    386         gotoxy(top, left, page); 
    387         cprint(box_chars[BOX_LTRT], attr, 1, page); 
    388         gotoxy(top, right, page); 
    389         cprint(box_chars[BOX_RTLT], attr, 1, page); 
    390     } 
     252        gotoxy(top, left); 
     253        putch(MIDDLE_BORDER, attr); 
     254        gotoxy(top, right); 
     255        putch(MIDDLE_BORDER, attr); 
     256    } 
     257        putchar(SI); 
    391258} 
  • com32/cmenu/libmenu/tui.h

    rc70547f r843f0e  
    1515 
    1616#include <com32.h> 
     17#include <getkey.h> 
     18#include <consoles.h> 
    1719#include "syslnx.h" 
    1820#include "com32io.h" 
    19 #include "scancodes.h" 
    2021 
    2122#ifndef NULL 
     
    2324#endif 
    2425 
     26#define SO '\016' 
     27#define SI '\017' 
     28 
     29#define TOP_LEFT_CORNER_BORDER '\154' 
     30#define TOP_BORDER '\161' 
     31#define TOP_RIGHT_CORNER_BORDER '\153' 
     32#define BOTTOM_LEFT_CORNER_BORDER '\155' 
     33#define BOTTOM_BORDER '\161' 
     34#define BOTTOM_RIGHT_CORNER_BORDER '\152' 
     35#define LEFT_BORDER '\170' 
     36#define RIGHT_BORDER '\170' 
     37#define LEFT_MIDDLE_BORDER '\164' 
     38#define MIDDLE_BORDER '\161' 
     39#define RIGHT_MIDDLE_BORDER '\165' 
     40 
    2541#define BELL 0x07 
    26 // CHRELATTR = ^N, CHABSATTR = ^O 
    27 #define CHABSATTR 15 
    28 #define CHRELATTR 14 
    29  
    30 void clearwindow(char top, char left, char bot, char right, 
    31                  char page, char fillchar, char fillattr); 
    32  
    33 void cls(void);                 /* Clears the entire current screen page */ 
     42#define GETSTRATTR 0x07 
    3443 
    3544// Generic user input, 
     
    5463} 
    5564 
    56 // Box drawing Chars offsets into array 
    57 #define BOX_TOPLEFT  0x0 
    58 #define BOX_BOTLEFT  0x1 
    59 #define BOX_TOPRIGHT 0x2 
    60 #define BOX_BOTRIGHT 0x3 
    61 #define BOX_TOP      0x4        // TOP = BOT = HORIZ 
    62 #define BOX_BOT      0x4 
    63 #define BOX_HORIZ    0x4 
    64 #define BOX_LEFT     0x5 
    65 #define BOX_RIGHT    0x5 
    66 #define BOX_VERT     0x5        // LEFT=RIGHT=VERT 
    67 #define BOX_LTRT     0x6 
    68 #define BOX_RTLT     0x7 
    69 #define BOX_TOPBOT   0x8 
    70 #define BOX_BOTTOP   0x9 
    71 #define BOX_MIDDLE   0xA 
    72  
    73 typedef enum { BOX_SINSIN, BOX_DBLDBL, BOX_SINDBL, BOX_DBLSIN } boxtype; 
    74  
    75 unsigned char *getboxchars(boxtype bt); 
    76  
    77 void drawbox(char top, char left, char bot, char right, 
    78              char page, char attr, boxtype bt); 
     65void drawbox(const char, const char, const char, const char, 
     66             const char); 
    7967 
    8068// Draw a horizontal line 
     
    8270// dumb == 0 means check the first and last positions and depending on what is 
    8371//    currently on the screen make it a LTRT and/or RTLT appropriately. 
    84 void drawhorizline(char top, char left, char right, char page, char attr, 
    85                    boxtype bt, char dumb); 
     72void drawhorizline(const char, const char, const char, const char, 
     73                   const char dumb); 
    8674 
    8775#endif 
  • com32/gplinclude/cpuid.h

    rc93e27 r57c855  
    6666    bool now;                   /* 3DNow! */ 
    6767    bool smp;                   /* A smp configuration has been found */ 
     68    bool vmx;                   /* Hardware virtualization */ 
     69    bool svm;                   /* Secure virtual machine */ 
    6870} s_cpu_flags; 
    6971 
  • com32/gplinclude/disk/common.h

    rb3a797 r29fc5c  
    1818#include <stdint.h> 
    1919 
     20/* For PAGE_SIZE */ 
     21#include <cpuid.h> 
     22 
    2023#define SECTOR 512              /* bytes/sector */ 
    21  
    22 #undef PAGE_SIZE 
    23 #define PAGE_SIZE (1<<12) 
    2424 
    2525struct ebios_dapa { 
  • com32/gplinclude/disk/error.h

    rd93474 r196e20  
    1010#ifndef _ERROR_H_ 
    1111#define _ERROR_H_ 
    12 void get_error(void*); 
    13 #endif /* _UTIL_H_ */ 
     12void get_error(const char*); 
     13#endif /* _ERROR_H_ */ 
  • com32/gplinclude/disk/util.h

    rb3a797 r196e20  
    1919 
    2020int int13_retry(const com32sys_t *inreg, com32sys_t *outreg); 
    21 void get_error(const int, char**); 
    2221#endif /* _UTIL_H_ */ 
  • com32/gpllib/cpuid.c

    r5b5b1b r8ba991  
    296296    cpu->flags.now = cpu_has(c, X86_FEATURE_3DNOW); 
    297297    cpu->flags.smp = find_smp_config(); 
     298    cpu->flags.vmx = cpu_has(c, X86_FEATURE_VMX); 
     299    cpu->flags.svm = cpu_has(c, X86_FEATURE_SVM); 
    298300} 
    299301 
  • com32/gpllib/disk/ata.c

    r4d9e46 r5e5230  
    11#include <inttypes.h> 
     2#include <string.h> 
    23 
    34/** 
  • com32/gpllib/disk/error.c

    r9ffe8b r39c3e6  
    1414/** 
    1515 * get_error - decode a disk error status 
    16  * @buffer_ptr: Preallocated buffer 
     16 * @s:  Preallocated buffer 
    1717 * 
    1818 * Fill @buffer_ptr with the last errno_disk 
  • com32/hdt/Makefile

    rb8f633 r18d726  
    2828OBJS      = $(patsubst %.c,%.o,$(wildcard *.c)) 
    2929 
     30KERNEL_VERSION          ?= $(shell uname -r) 
     31MODULES_ALIAS_FILE      ?= /lib/modules/$(KERNEL_VERSION)/modules.alias 
     32MODULES_PCIMAP_FILE     ?= /lib/modules/$(KERNEL_VERSION)/modules.pcimap 
     33ISO_DIR                 ?= iso 
     34ISOLINUX_DIR            ?= isolinux 
     35FLOPPY_DIR              ?= floppy 
     36PCI_IDS_FILE            ?= $(PWD)/$(FLOPPY_DIR)/pci.ids 
     37 
    3038all: $(MODULES) $(TESTFILES) 
    3139 
    3240hdt.elf : $(OBJS) $(LIBS) $(C_LIBS) 
    3341        $(LD) $(LDFLAGS) -o $@ $^ 
     42 
     43hdt.img: hdt.c32 $(FLOPPY_DIR)/hdt.cfg $(FLOPPY_DIR)/mtools.conf $(topdir)/mtools/syslinux 
     44        rm -f hdt.img 
     45        MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MFORMAT) -v HDT -f 2880 -C a: 
     46        $(topdir)/mtools/syslinux hdt.img 
     47        -[ ! -f $(PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(PCI_IDS_FILE) 
     48        -[ ! -f $(PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(PCI_IDS_FILE) 
     49        -[ -f $(MODULES_ALIAS_FILE) ] && MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(MODULES_ALIAS_FILE) a: 
     50        -[ -f $(MODULES_PCIMAP_FILE) ] && MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(MODULES_PCIMAP_FILE) a: 
     51        MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) hdt.c32 a: 
     52        @ [ -f $(PCI_IDS_FILE) ] && MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(PCI_IDS_FILE) a: || printf "\nThe $(FLOPPY_DIR)/pci.ids file is missing and can be downloaded from http://pciids.sourceforge.net and put in\nthe ./com32/hdt/$(FLOPPY_DIR) directory of the extracted Syslinux source.\n\n" 
     53        MTOOLSRC=$(PWD)/$(FLOPPY_DIR)/mtools.conf $(MCOPY) $(FLOPPY_DIR)/hdt.cfg a:syslinux.cfg 
     54 
     55hdt.iso: hdt.c32 $(topdir)/core/isolinux.bin $(FLOPPY_DIR)/hdt.cfg 
     56        rm -rf $(ISO_DIR) 
     57        rm -f hdt.iso 
     58        mkdir -p $(ISO_DIR)/$(ISOLINUX_DIR) 
     59        cp $(topdir)/core/isolinux.bin $(ISO_DIR)/$(ISOLINUX_DIR) 
     60        cp $(FLOPPY_DIR)/hdt.cfg $(ISO_DIR)/$(ISOLINUX_DIR)/isolinux.cfg 
     61        cp hdt.c32 $(ISO_DIR)/$(ISOLINUX_DIR) 
     62        -[ ! -f $(PCI_IDS_FILE) ] && cp /usr/share/hwdata/pci.ids $(ISO_DIR)/$(ISOLINUX_DIR) 
     63        -[ ! -f $(PCI_IDS_FILE) ] && cp /usr/share/pci.ids $(ISO_DIR)/$(ISOLINUX_DIR) 
     64        -[ -f $(MODULES_ALIAS_FILE) ] && cp $(MODULES_ALIAS_FILE) $(ISO_DIR)/$(ISOLINUX_DIR) 
     65        -[ -f $(MODULES_PCIMAP_FILE) ] && cp $(MODULES_PCIMAP_FILE) $(ISO_DIR)/$(ISOLINUX_DIR) 
     66        -[ ! -f $(ISO_DIR)/$(ISOLINUX_DIR)/pci.ids ] && printf "\nThe $(FLOPPY_DIR)/pci.ids file is missing and can be downloaded from http://pciids.sourceforge.net and put in\nthe ./com32/hdt/$(FLOPPY_DIR) directory of the extracted Syslinux source.\n\n" 
     67        $(MKISOFS) -o hdt.iso -b $(ISOLINUX_DIR)/isolinux.bin -c $(ISOLINUX_DIR)/boot.cat \ 
     68                -no-emul-boot -boot-load-size 4 -boot-info-table \ 
     69                $(ISO_DIR) 
    3470 
    3571tidy dist: 
     
    4076 
    4177spotless: clean 
    42         rm -f *.lss *.c32 *.com 
     78        rm -f *.lss *.c32 *.com hdt.img hdt.iso 
     79        rm -rf $(ISO_DIR) 
    4380        rm -f *~ \#* 
    4481 
  • com32/hdt/hdt-cli-cpu.c

    rd0a0e5 r8ba991  
    175175        if (hardware->cpu.flags.now) 
    176176                strcat(buffer1, "3dnow! "); 
     177        if (hardware->cpu.flags.svm) 
     178                strcat(buffer1, "svm "); 
     179        if (hardware->cpu.flags.vmx) 
     180                strcat(buffer1, "vmx "); 
    177181        if (buffer1[0]) { 
    178182                snprintf(buffer, sizeof buffer, "Flags     : %s\n", buffer1); 
  • com32/hdt/hdt-cli-disk.c

    rb7ec0f re9069c  
    3131#include <stdlib.h> 
    3232#include <errno.h> 
    33  
    34 #include <disk/errno_disk.h> 
    35 #include <disk/geom.h> 
    36 #include <disk/read.h> 
    37 #include <disk/error.h> 
    38 #include <disk/swsusp.h> 
    39 #include <disk/msdos.h> 
    4033 
    4134#include "hdt-cli.h" 
     
    6457{ 
    6558        char size[9]; 
     59        char bootloader_name[9]; 
    6660        char *parttype; 
    6761        unsigned int start, end; 
     
    7872 
    7973        if (i == 1) 
    80                 more_printf("   #  B       Start         End    Size Id Type\n"); 
     74                more_printf(" #  B       Start         End    Size Id Type\n"); 
    8175 
    8276        get_label(ptab->ostype, &parttype); 
    83         more_printf("  %2d  %s %11d %11d %s %02X %s", 
     77        more_printf("%2d  %s %11d %11d %s %02X %s", 
    8478                    i, (ptab->active_flag == 0x80) ? "x" : " ", 
    8579                    start, 
     
    9286                more_printf("%s", " (Swsusp sig. detected)"); 
    9387 
     88        if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) 
     89                more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name); 
     90 
    9491        more_printf("\n"); 
    9592 
     
    10097                    struct s_hardware *hardware) 
    10198{ 
    102         reset_more_printf(); 
    10399        if (!argc) { 
    104100                more_printf("Which disk?\n"); 
     
    116112        struct driveinfo *d = &hardware->disk_info[i]; 
    117113        char disk_size[9]; 
     114        char mbr_name[50]; 
    118115 
    119116        detect_disks(hardware); 
    120117        if (!hardware->disk_info[i].cbios) 
    121118                return; /* Invalid geometry */ 
     119 
     120        get_mbr_string(hardware->mbr_ids[i], &mbr_name, 50); 
    122121 
    123122        if ((int) d->edd_params.sectors > 0) 
     
    128127        more_printf("DISK 0x%X:\n" 
    129128                    "  C/H/S: %d cylinders, %d heads, %d sectors/track\n" 
    130                     "  EDD:  Version: %X\n" 
     129                    "    EDD: Version: %X\n" 
    131130                    "         Size: %s, %d bytes/sector, %d sectors/track\n" 
    132                     "         Host bus: %s, Interface type: %s\n\n", 
     131                    "         Host bus: %s, Interface type: %s\n" 
     132                    "    MBR: %s (id 0x%X)\n\n", 
    133133                d->disk, 
    134134                d->legacy_max_cylinder + 1, d->legacy_max_head + 1, d->legacy_sectors_per_track, 
    135135                d->edd_version, 
    136136                disk_size, (int) d->edd_params.bytes_per_sector, (int) d->edd_params.sectors_per_track, 
    137                 remove_spaces(d->edd_params.host_bus_type), remove_spaces(d->edd_params.interface_type)); 
     137                remove_spaces((char *) d->edd_params.host_bus_type), remove_spaces((char*) d->edd_params.interface_type), 
     138                mbr_name, hardware->mbr_ids[i]); 
     139        display_line_nb += 6; 
    138140 
    139141        if (parse_partition_table(d, &show_partition_information)) { 
     
    146148                fprintf(stderr, "\n"); 
    147149        } 
     150 
     151        more_printf("\n"); 
    148152} 
    149153 
     
    154158        detect_disks(hardware); 
    155159 
     160        int first_one = 0; 
    156161        for (int drive = 0x80; drive < 0xff; drive++) { 
    157                 char buf[5] = ""; 
    158                 sprintf(buf, "0x%x", drive); 
    159                 char *argv[1] = { buf }; 
    160                 main_show_disk(1, argv, hardware); 
     162                if (hardware->disk_info[drive - 0x80].cbios) { 
     163                        if (!first_one) { 
     164                                first_one = 1; 
     165                        } else { 
     166                                pause_printf(); 
     167                        } 
     168                        char buf[5] = ""; 
     169                        sprintf(buf, "0x%x", drive); 
     170                        char *argv[1] = { buf }; 
     171                        main_show_disk(1, argv, hardware); 
     172                } 
    161173        } 
    162174} 
     
    168180 
    169181        detect_disks(hardware); 
     182        reset_more_printf(); 
    170183 
    171184        for (int drive = 0x80; drive < 0xff; drive++) { 
     
    188201                        disk_size); 
    189202                more_printf("         Host bus: %s, Interface type: %s\n\n", 
    190                         remove_spaces(d->edd_params.host_bus_type), 
    191                         remove_spaces(d->edd_params.interface_type)); 
     203                        remove_spaces((char*) d->edd_params.host_bus_type), 
     204                        remove_spaces((char*) d->edd_params.interface_type)); 
    192205        } 
    193206} 
  • com32/hdt/hdt-cli-hdt.c

    ra872cb r486ec6  
    192192{ 
    193193        char version_string[256]; 
    194         snprintf(version_string, sizeof version_string, "%s %s by %s", 
    195                  PRODUCT_NAME, VERSION, AUTHOR); 
     194        snprintf(version_string, sizeof version_string, "%s %s", 
     195                 PRODUCT_NAME, VERSION); 
    196196        start_menu_mode(hardware, version_string); 
    197197        return; 
  • com32/hdt/hdt-cli.c

    r18366f r47ac91  
    3333#include "hdt-cli.h" 
    3434#include "hdt-common.h" 
    35 #include "lib-ansi.h" 
    3635 
    3736struct cli_mode_descr *list_modes[] = { 
     
    5554 * strings first. 
    5655 */ 
    57 char *exit_aliases[] = {"q", "quit"}; 
    58 char *help_aliases[] = {"h", "?"}; 
     56const char *exit_aliases[] = {"q", "quit"}; 
     57const char *help_aliases[] = {"h", "?"}; 
    5958 
    6059/* List of aliases */ 
  • com32/hdt/hdt-common.c

    r9ffe8b r47ac91  
    3434#include "../lib/sys/vesa/vesa.h" 
    3535#include "hdt-common.h" 
    36 #include "lib-ansi.h" 
    3736#include <disk/util.h> 
     37#include <disk/mbrs.h> 
    3838 
    3939/* ISOlinux requires a 8.3 format */ 
     
    269269                if (err == -1 || !hardware->disk_info[i].cbios) 
    270270                        continue; 
     271 
     272                /* Detect MBR */ 
     273                hardware->mbr_ids[i] = get_mbr_id(&hardware->disk_info[i]); 
    271274 
    272275                hardware->disks_count++; 
     
    535538} 
    536539 
     540/* remove trailing LF */ 
     541char *remove_trailing_lf(char *p) 
     542{ 
     543  char *save=p; 
     544  p+=strlen(p)-1; 
     545  while (*p && *p == 10) { 
     546   *p='\0'; 
     547   p--; 
     548  } 
     549  p=save; 
     550 
     551  return p; 
     552} 
     553 
    537554/* delete multiple spaces, one is enough */ 
    538555char *del_multi_spaces(char *p) { 
  • com32/hdt/hdt-common.h

    rf8ac66 r47ac91  
    3333#include "sys/pci.h" 
    3434 
     35#include <disk/bootloaders.h> 
     36#include <disk/errno_disk.h> 
     37#include <disk/error.h> 
    3538#include <disk/geom.h> 
     39#include <disk/mbrs.h> 
     40#include <disk/msdos.h> 
     41#include <disk/partition.h> 
     42#include <disk/swsusp.h> 
     43#include <disk/read.h> 
    3644 
    3745#include "cpuid.h" 
     
    4048#include "../lib/sys/vesa/vesa.h" 
    4149#include <vpd/vpd.h> 
     50#include <libansi.h> 
    4251 
    4352/* Declare a variable or data structure as unused. */ 
     
    5160extern int display_line_nb; 
    5261 
     62#define pause_printf() do {\ 
     63        printf("--More--");\ 
     64        get_key(stdin, 0);\ 
     65        printf("\n");\ 
     66} while (0); 
     67 
    5368#define more_printf(...) do {\ 
    54  if (display_line_nb == 23) {\ 
    55    printf("Press any key to continue\n");\ 
     69 if (display_line_nb == 20) {\ 
     70   printf("\nPress any key to continue");\ 
    5671   display_line_nb=0;\ 
    5772   get_key(stdin, 0);\ 
     
    115130  struct pci_domain *pci_domain;  /* PCI Devices */ 
    116131  struct driveinfo disk_info[256]; /* Disk Information */ 
     132  uint32_t mbr_ids[256];          /* MBR ids */ 
    117133  int disks_count;                /* Number of detected disks */ 
    118134  struct s_pxe pxe; 
     
    147163const char *find_argument(const char **argv, const char *argument); 
    148164char *remove_spaces(char *p); 
     165char *remove_trailing_lf(char *p); 
    149166char *skip_spaces(char *p); 
    150167char *del_multi_spaces(char *p); 
  • com32/hdt/hdt-menu-disk.c

    r9ffe8b re9069c  
    2828 
    2929#include <stdlib.h> 
    30 #include <disk/errno_disk.h> 
    31 #include <disk/geom.h> 
    32 #include <disk/read.h> 
    33 #include <disk/partition.h> 
    34 #include <disk/error.h> 
    35 #include <disk/msdos.h> 
    36 #include <disk/swsusp.h> 
    3730 
    3831#include "hdt-menu.h" 
     
    8275{ 
    8376        char size[9]; 
     77        char bootloader_name[9]; 
    8478        char *parttype; 
    8579        unsigned int start, end; 
     
    121115        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    122116 
     117        if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) { 
     118                snprintf(buffer, sizeof buffer, "Bootloader  : %s", 
     119                         bootloader_name); 
     120                snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s", 
     121                         bootloader_name); 
     122                add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     123        } 
     124 
    123125        snprintf(buffer, sizeof buffer, "Bootable    : %s", 
    124126                 (ptab->active_flag == 0x80) ? "Yes" : "No"); 
     
    158160/* Compute the disk submenu */ 
    159161static int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu, 
    160                                struct driveinfo *d, int disk_number) 
     162                               const struct s_hardware *hardware, int disk_number) 
    161163{ 
    162164  char buffer[MENULEN + 1]; 
    163165  char statbuffer[STATLEN + 1]; 
     166        char mbr_name[50]; 
     167        struct driveinfo *d = (struct driveinfo*) hardware->disk_info; 
    164168 
    165169  snprintf(buffer, sizeof buffer, " Disk <0x%X> (EDD %X)", d[disk_number].disk, 
     
    182186 
    183187  snprintf(buffer, sizeof buffer, "Host Bus / Interface : %s / %s", 
    184      remove_spaces(d[disk_number].edd_params.host_bus_type), 
     188     remove_spaces((char *) d[disk_number].edd_params.host_bus_type), 
    185189     d[disk_number].edd_params.interface_type); 
    186190  snprintf(statbuffer, sizeof statbuffer, "Host Bus / Interface: %s / %s", 
    187      remove_spaces(d[disk_number].edd_params.host_bus_type), 
     191     remove_spaces((char *) d[disk_number].edd_params.host_bus_type), 
    188192     d[disk_number].edd_params.interface_type); 
    189193  add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     
    208212  menu[nb_sub_disk_menu].items_count++; 
    209213 
     214        get_mbr_string(hardware->mbr_ids[disk_number], &mbr_name, 50); 
     215 
     216        snprintf(buffer, sizeof buffer, "MBR                  : %s (0x%X)", 
     217                 remove_spaces(mbr_name), 
     218                 hardware->mbr_ids[disk_number]); 
     219        snprintf(statbuffer, sizeof statbuffer, "MBR: %s (id 0x%X)", 
     220                 remove_spaces(mbr_name), 
     221                 hardware->mbr_ids[disk_number]); 
     222        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     223        menu[nb_sub_disk_menu].items_count++; 
     224 
    210225  dn=disk_number; 
    211226 
     
    220235 
    221236/* Compute the Disks menu */ 
    222 void compute_disks(struct s_hdt_menu *menu, struct driveinfo *disk_info, struct s_hardware *hardware) 
     237void compute_disks(struct s_hdt_menu *menu, struct s_hardware *hardware) 
    223238{ 
    224239  char buffer[MENULEN + 1]; 
     
    233248      continue; /* Invalid geometry */ 
    234249    compute_disk_module 
    235         ((struct s_my_menu*) &(menu->disk_sub_menu), nb_sub_disk_menu, disk_info, 
    236         i); 
     250        ((struct s_my_menu*) &(menu->disk_sub_menu), nb_sub_disk_menu, 
     251         hardware, i); 
    237252    nb_sub_disk_menu++; 
    238253  } 
  • com32/hdt/hdt-menu-kernel.c

    rdb265a9 r8e7362  
    7676           pci_device->dev_info->class_name); 
    7777        snprintf(infobar, sizeof infobar, 
    78            "%04x:%04x %s : %s\n", 
     78           "%04x:%04x %s : %s", 
    7979           pci_device->vendor, 
    8080           pci_device->product, 
  • com32/hdt/hdt-menu-pci.c

    r157629 r8e7362  
    168168       pci_device->dev_info->product_name); 
    169169    snprintf(infobar[i], STATLEN, 
    170        "%02x:%02x.%01x # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s\n", 
     170       "%02x:%02x.%01x # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s", 
    171171       __pci_bus, __pci_slot, __pci_func, 
    172172       pci_device->dev_info->class_name, pci_device->vendor, 
  • com32/hdt/hdt-menu-processor.c

    r5f036a r8ba991  
    232232  if (hardware->cpu.flags.now) 
    233233    strcat(buffer1, "3dnow! "); 
     234  if (hardware->cpu.flags.vmx) 
     235    strcat(buffer1, "vmx "); 
     236  if (hardware->cpu.flags.svm) 
     237    strcat(buffer1, "svm "); 
    234238  snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
    235239  snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
  • com32/hdt/hdt-menu-summary.c

    ra00023 r8e7362  
    190190           pci_device->dev_info->class_name); 
    191191        snprintf(statbuffer, sizeof statbuffer, 
    192            "%04x:%04x %s : %s\n", 
     192           "%04x:%04x %s : %s", 
    193193           pci_device->vendor, 
    194194           pci_device->product, 
  • com32/hdt/hdt-menu-syslinux.c

    ra00023 r8e7362  
    7777  snprintf(buffer, sizeof buffer, "%s", 
    7878     hardware->sv->copyright_string + 1); 
     79  /* Remove the trailing LF in the copyright string to avoid scrolling */ 
    7980  snprintf(statbuffer, sizeof statbuffer, "%s", 
    80      hardware->sv->copyright_string + 1); 
     81     remove_trailing_lf(hardware->sv->copyright_string + 1)); 
    8182  add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    8283  menu->items_count++; 
  • com32/hdt/hdt-menu.c

    rea541f r47ac91  
    2828 
    2929#include "hdt-menu.h" 
     30#include <unistd.h> 
    3031 
    3132int start_menu_mode(struct s_hardware *hardware, char *version_string) 
     
    8586 
    8687/* Keyboard handler for the menu system */ 
    87 void keys_handler(t_menusystem * ms, t_menuitem * mi, unsigned int scancode) 
    88 { 
    89   char nc; 
    90  
    91   if ((scancode >> 8) == F1) {  // If scancode of F1 
     88void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode) 
     89{ 
     90  int nr, nc; 
     91 
     92  /* 0xFFFF is an invalid helpid */ 
     93  if (scancode == KEY_F1 && mi->helpid != 0xFFFF) { 
    9294    runhelpsystem(mi->helpid); 
    9395  } 
     96 
    9497  /* 
    9598   * If user hit TAB, and item is an "executable" item 
    9699   * and user has privileges to edit it, edit it in place. 
    97100   */ 
    98   if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN)) { 
     101  if ((scancode == KEY_TAB) && (mi->action == OPT_RUN)) { 
    99102//(isallowed(username,"editcmd") || isallowed(username,"root"))) { 
    100     nc = getnumcols(); 
     103    if (getscreensize(1, &nr, &nc)) { 
     104        /* Unknown screen size? */ 
     105        nc = 80; 
     106        nr = 24; 
     107    } 
    101108    /* User typed TAB and has permissions to edit command line */ 
    102     gotoxy(EDITPROMPT, 1, ms->menupage); 
     109    gotoxy(EDITPROMPT, 1); 
    103110    csprint("Command line:", 0x07); 
    104111    editstring(mi->data, ACTIONLEN); 
    105     gotoxy(EDITPROMPT, 1, ms->menupage); 
    106     cprint(' ', 0x07, nc - 1, ms->menupage); 
     112    gotoxy(EDITPROMPT, 1); 
     113    cprint(' ', 0x07, nc - 1); 
    107114  } 
    108115} 
     
    155162  compute_processor(&(hdt_menu->cpu_menu), hardware); 
    156163  compute_vpd(&(hdt_menu->vpd_menu), hardware); 
    157   compute_disks(hdt_menu, hardware->disk_info, hardware); 
     164  compute_disks(hdt_menu, hardware); 
    158165 
    159166#ifdef WITH_PCI 
  • com32/hdt/hdt-menu.h

    rf5e4ae r47ac91  
    3030#define DEFINE_HDT_MENU_H 
    3131#include <stdio.h> 
     32#include <getkey.h> 
    3233 
    3334#include "menu.h" 
     
    8384 
    8485TIMEOUTCODE ontimeout(); 
    85 void keys_handler(t_menusystem * ms, t_menuitem * mi, unsigned int scancode); 
     86void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode); 
    8687 
    8788// PCI Stuff 
     
    9293 
    9394// Disk Stuff 
    94 void compute_disks(struct s_hdt_menu *menu, struct driveinfo *disk_info, struct s_hardware *hardware); 
     95void compute_disks(struct s_hdt_menu *menu, struct s_hardware *hardware); 
    9596 
    9697// DMI Stuff 
  • com32/hdt/hdt.c

    r2d34df r486ec6  
    4949  struct s_hardware hardware; 
    5050 
    51   snprintf(version_string, sizeof version_string, "%s %s by %s", 
    52            PRODUCT_NAME,VERSION,AUTHOR); 
     51  snprintf(version_string, sizeof version_string, "%s %s", 
     52           PRODUCT_NAME,VERSION); 
    5353 
    5454  /* Opening the Syslinux console */ 
  • com32/include/cpufeature.h

    rb71004 r8ba991  
    7373#define X86_FEATURE_MWAIT       (4*32+ 3)       /* Monitor/Mwait support */ 
    7474#define X86_FEATURE_DSCPL       (4*32+ 4)       /* CPL Qualified Debug Store */ 
     75#define X86_FEATURE_VMX         (4*32+ 5)       /* Hardware virtualization */ 
    7576#define X86_FEATURE_EST         (4*32+ 7)       /* Enhanced SpeedStep */ 
    7677#define X86_FEATURE_TM2         (4*32+ 8)       /* Thermal Monitor 2 */ 
     
    8889#define X86_FEATURE_LAHF_LM     (6*32+ 0)       /* LAHF/SAHF in long mode */ 
    8990#define X86_FEATURE_CMP_LEGACY  (6*32+ 1)       /* If yes HyperThreading not valid */ 
     91#define X86_FEATURE_SVM         (6*32+ 2)       /* Secure virtual machine */ 
    9092 
    9193#endif /* __ASM_I386_CPUFEATURE_H */ 
  • com32/lib/Makefile

    r3ec185 rfa1b9d  
    5353        \ 
    5454        sys/ansi.o                                                      \ 
     55        \ 
     56        sys/libansi.o                                                   \ 
    5557        \ 
    5658        sys/ansicon_write.o sys/ansiserial_write.o                      \ 
  • com32/lib/sys/ansi.c

    redeeda r86e267  
    3737 
    3838static const struct term_state default_state = { 
     39    .state = st_init, 
     40    .pvt = false, 
     41    .nparms = 0, 
    3942    .xy = {0, 0}, 
    4043    .cindex = 0,                /* First color table entry */ 
    41     .vtgraphics = 0, 
     44    .vtgraphics = false, 
    4245    .intensity = 1, 
    43     .underline = 0, 
    44     .blink = 0, 
    45     .reverse = 0, 
     46    .underline = false, 
     47    .blink = false, 
     48    .reverse = false, 
    4649    .fg = 7, 
    4750    .bg = 0, 
    48     .autocr = 1,                /* Mimic \n -> \r\n conversion by default */ 
     51    .autocr = true,             /* Mimic \n -> \r\n conversion by default */ 
     52    .autowrap = true,           /* Wrap lines by default */ 
    4953    .saved_xy = {0, 0}, 
    50     .cursor = 1, 
    51     .state = st_init, 
    52     .pvt = 0, 
    53     .nparms = 0, 
     54    .cursor = true, 
    5455}; 
    5556 
     
    124125                    ch = decvt_to_cp437[ch - 0x60]; 
    125126 
    126                 op->write_char(xy.x, xy.y, ch, st); 
     127                op->write_char(xy.x, xy.y, BIOS_PAGE, ch, st); 
    127128                xy.x++; 
    128129            } 
     
    142143        case '[': 
    143144            st->state = st_csi; 
    144             st->nparms = st->pvt = 0; 
     145            st->nparms = 0; 
     146            st->pvt = false; 
    145147            memset(st->parms, 0, sizeof st->parms); 
    146148            break; 
     
    171173                break; 
    172174            } else if (ch == '?') { 
    173                 st->pvt = 1; 
     175                st->pvt = true; 
    174176            } else { 
    175177                switch (ch) { 
     
    279281                case 'h': 
    280282                case 'l': 
    281                     { 
    282                         int set = (ch == 'h'); 
    283                         switch (st->parms[0]) { 
    284                         case 20: 
    285                             st->autocr = set; 
    286                             break; 
    287                         case 25: 
    288                             st->cursor = set; 
    289                             op->showcursor(st); 
    290                             break; 
    291                         default: 
    292                             /* Ignore */ 
    293                             break; 
    294                         } 
    295                     } 
    296                     break; 
     283                { 
     284                    bool set = (ch == 'h'); 
     285                    switch (st->parms[0]) { 
     286                    case 7:     /* DECAWM */ 
     287                        st->autowrap = set; 
     288                        break; 
     289                    case 20:    /* LNM */ 
     290                        st->autocr = set; 
     291                        break; 
     292                    case 25:    /* DECTECM */ 
     293                        st->cursor = set; 
     294                        op->showcursor(st); 
     295                        break; 
     296                    default: 
     297                        /* Ignore */ 
     298                        break; 
     299                    } 
     300                    break; 
     301                } 
    297302                case 'm': 
    298303                    { 
     
    422427    /* If we fell off the end of the screen, adjust */ 
    423428    if (xy.x >= cols) { 
    424         xy.x = 0; 
    425         xy.y++; 
     429        if (st->autowrap) { 
     430            xy.x = 0; 
     431            xy.y++; 
     432        } else { 
     433            xy.x = cols - 1; 
     434        } 
    426435    } 
    427436    while (xy.y >= rows) { 
     
    431440 
    432441    /* Update cursor position */ 
    433     op->set_cursor(xy.x, xy.y, st->cursor); 
     442    op->set_cursor(xy.x, xy.y, BIOS_PAGE, st->cursor); 
    434443    st->xy = xy; 
    435444} 
  • com32/lib/sys/ansi.h

    r6aa75e r86e267  
    77 
    88#include <inttypes.h> 
     9#include <stdbool.h> 
    910 
    1011#define ANSI_MAX_PARMS  16 
     12 
     13#define BIOS_CURXY ((struct curxy *)0x450)      /* Array for each page */ 
     14#define BIOS_ROWS (*(uint8_t *)0x484)   /* Minus one; if zero use 24 (= 25 lines) */ 
     15#define BIOS_COLS (*(uint16_t *)0x44A)  /* Number of columns on screen */ 
     16#define BIOS_PAGE (*(uint8_t *)0x462)   /* Current page number  */ 
    1117 
    1218enum ansi_state { 
     
    2329 
    2430struct term_state { 
    25     struct curxy xy; 
    26     int cindex;                 /* SOH color index */ 
    27     int vtgraphics;             /* VT graphics on/off */ 
    28     int intensity; 
    29     int underline; 
    30     int blink; 
    31     int reverse; 
    32     int fg; 
    33     int bg; 
    34     int autocr; 
    35     struct curxy saved_xy; 
    36     int cursor; 
    3731    enum ansi_state state; 
    38     int pvt;                    /* Private code? */ 
    3932    int nparms;                 /* Number of parameters seen */ 
    4033    int parms[ANSI_MAX_PARMS]; 
     34    bool pvt;                   /* Private code? */ 
     35    struct curxy xy; 
     36    struct curxy saved_xy; 
     37    uint8_t cindex;             /* SOH color index */ 
     38    uint8_t fg; 
     39    uint8_t bg; 
     40    uint8_t intensity; 
     41    bool vtgraphics;            /* VT graphics on/off */ 
     42    bool underline; 
     43    bool blink; 
     44    bool reverse; 
     45    bool autocr; 
     46    bool autowrap; 
     47    bool cursor; 
    4148}; 
    4249 
     
    4451    void (*erase) (const struct term_state * st, int x0, int y0, int x1, 
    4552                   int y1); 
    46     void (*write_char) (int x, int y, uint8_t ch, const struct term_state * st); 
     53    void (*write_char) (int x, int y, int page, uint8_t ch, const struct term_state * st); 
    4754    void (*showcursor) (const struct term_state * st); 
    4855    void (*scroll_up) (const struct term_state * st); 
    49     void (*set_cursor) (int x, int y, int visible); 
     56    void (*set_cursor) (int x, int y, int page, int visible); 
    5057    void (*beep) (void); 
    5158}; 
  • com32/lib/sys/ansicon_write.c

    r11c6d38 re9b317  
    4545 
    4646static void ansicon_erase(const struct term_state *, int, int, int, int); 
    47 static void ansicon_write_char(int, int, uint8_t, const struct term_state *); 
     47static void ansicon_write_char(int, int, int, uint8_t, const struct term_state *); 
    4848static void ansicon_showcursor(const struct term_state *); 
    4949static void ansicon_scroll_up(const struct term_state *); 
    50 static void ansicon_set_cursor(int, int, int); 
     50static void ansicon_set_cursor(int, int, int, int); 
    5151 
    5252static struct term_state ts; 
     
    6565    .op = &__ansicon_ops 
    6666}; 
    67  
    68 #define BIOS_CURXY ((struct curxy *)0x450)      /* Array for each page */ 
    69 #define BIOS_ROWS (*(uint8_t *)0x484)   /* Minus one; if zero use 24 (= 25 lines) */ 
    70 #define BIOS_COLS (*(uint16_t *)0x44A) 
    71 #define BIOS_PAGE (*(uint8_t *)0x462) 
    7267 
    7368/* Reference counter to the screen, to keep track of if we need 
     
    177172} 
    178173 
    179 static void ansicon_set_cursor(int x, int y, int visible) 
    180 { 
    181     const int page = BIOS_PAGE; 
     174static void ansicon_set_cursor(int x, int y, int page, int visible) 
     175{ 
    182176    struct curxy xy = BIOS_CURXY[page]; 
    183177    static com32sys_t ireg; 
     
    194188} 
    195189 
    196 static void ansicon_write_char(int x, int y, uint8_t ch, 
     190static void ansicon_write_char(int x, int y, int page, uint8_t ch, 
    197191                               const struct term_state *st) 
    198192{ 
    199193    static com32sys_t ireg; 
    200194 
    201     ansicon_set_cursor(x, y, 0); 
     195    ansicon_set_cursor(x, y, 0, page); 
    202196 
    203197    ireg.eax.b[1] = 0x09; 
    204198    ireg.eax.b[0] = ch; 
    205     ireg.ebx.b[1] = BIOS_PAGE; 
     199    ireg.ebx.b[1] = page; 
    206200    ireg.ebx.b[0] = ansicon_attribute(st); 
    207201    ireg.ecx.w[0] = 1; 
  • com32/mboot/map.c

    rfd0064 r3d6f51  
    128128            mbh_len = 12; 
    129129 
    130         if (i + mbh_len < len) 
     130        if (i + mbh_len > len) 
    131131            mbh_len = 0;        /* Invalid... */ 
    132132        else 
  • com32/modules/Makefile

    r0b19ab r08d95c  
    1919include ../MCONFIG 
    2020 
    21 MODULES   = chain.c32 config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 disk.c32 \ 
    22             pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 meminfo.c32 \ 
    23             sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 kbdmap.c32 cmd.c32 \ 
    24             vpdtest.c32 
     21MODULES   = chain.c32 config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 \ 
     22            disk.c32 pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 \ 
     23            meminfo.c32 sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 \ 
     24            kbdmap.c32 cmd.c32 vpdtest.c32 gpxecmd.c32 
    2525 
    2626TESTFILES = 
  • com32/modules/chain.c

    rf4b44a r3fc312  
    447447 
    448448    if (!mmap) { 
    449         error("Cannot read system memory map"); 
     449        error("Cannot read system memory map\n"); 
    450450        return; 
    451451    } 
     
    548548 
    549549too_big: 
    550     error("Loader file too large"); 
     550    error("Loader file too large\n"); 
    551551    return; 
    552552 
    553553enomem: 
    554     error("Out of memory"); 
     554    error("Out of memory\n"); 
    555555    return; 
    556556} 
     
    615615            uint32_t segval = strtoul(argv[i] + 4, NULL, 0); 
    616616            if (segval < 0x50 || segval > 0x9f000) { 
    617                 error("Invalid segment"); 
     617                error("Invalid segment\n"); 
    618618                goto bail; 
    619619            } 
     
    651651        } else { 
    652652            error 
    653                 ("Usage: chain.c32 (hd#|fd#|mbr:#|boot)[,partition] [options]\n"); 
     653                ("Usage:   chain.c32 hd<disk#> [<partition>] [options]\n" 
     654                 "         chain.c32 fd<disk#> [options]\n" 
     655                 "         chain.c32 mbr:<id> [<partition>] [options]\n" 
     656                 "         chain.c32 boot [<partition>] [options]\n" 
     657                 "Options: file=<loader>      load file, instead of boot sector\n" 
     658                 "         ntldr=<loader>     load Windows bootloaders: NTLDR, SETUPLDR, BOOTMGR\n" 
     659                 "         freedos=<loader>   load FreeDOS kernel.sys\n" 
     660                 "         msdos=<loader>     load MS-DOS io.sys\n" 
     661                 "         pcdos=<loader>     load PC-DOS ibmbio.com\n" 
     662                 "         seg=<segment>      jump to <seg>:0000 instead of 0000:7C00\n" 
     663                 "         swap               swap drive numbers, if bootdisk is not fd0/hd0\n" 
     664                 "         hide               hide primary partitions, except selected partition\n"); 
    654665            goto bail; 
    655666        } 
  • com32/modules/cpuidtest.c

    r7dc104 r8ba991  
    122122        if (cpu.flags.now) 
    123123            printf("3dnow! "); 
     124        if (cpu.flags.vmx) 
     125            printf("vmx "); 
     126        if (cpu.flags.svm) 
     127            printf("svm "); 
    124128        printf("\n"); 
    125129        printf("SMP         = "); 
  • core/localboot.inc

    r541778 r96281d  
    3232                mov si,localboot_msg 
    3333                call writestr 
     34                call cleanup_hardware 
    3435                cmp ax,-1 
    3536                je .int18 
  • core/pxelinux.asm

    r3cdc49 r1d8b22  
    225225bootsec         equ $ 
    226226_start: 
     227                jmp 0:_start1           ; Canonicalize the address and skip 
     228                                        ; the patch header 
     229 
     230; 
     231; Patch area for adding hardwired DHCP options 
     232; 
     233                align 4 
     234 
     235hcdhcp_magic    dd 0x2983c8ac           ; Magic number 
     236hcdhcp_len      dd 7*4                  ; Size of this structure 
     237hcdhcp_flags    dd 0                    ; Reserved for the future 
     238                ; Parameters to be parsed before the ones from PXE 
     239bdhcp_offset    dd 0                    ; Offset (entered by patcher) 
     240bdhcp_len       dd 0                    ; Length (entered by patcher) 
     241                ; Parameters to be parsed *after* the ones from PXE 
     242adhcp_offset    dd 0                    ; Offset (entered by patcher) 
     243adhcp_len       dd 0                    ; Length (entered by patcher) 
     244 
     245_start1: 
    227246                pushfd                  ; Paranoia... in case of return to PXE 
    228247                pushad                  ; ... save as much state as possible 
     
    237256                mov es,ax 
    238257 
    239                 jmp 0:_start1           ; Canonicalize address 
    240 _start1: 
    241258                ; That is all pushed onto the PXE stack.  Save the pointer 
    242259                ; to it and switch to an internal stack. 
     
    253270                lss esp,[BaseStack] 
    254271                sti                     ; Stack set up and ready 
     272; 
     273; Move the hardwired DHCP options (if present) to a safe place... 
     274; 
     275bdhcp_copy: 
     276                mov cx,[bdhcp_len] 
     277                mov ax,trackbufsize/2 
     278                jcxz .none 
     279                cmp cx,ax 
     280                jbe .oksize 
     281                mov cx,ax 
     282                mov [bdhcp_len],ax 
     283.oksize: 
     284                mov eax,[bdhcp_offset] 
     285                add eax,_start 
     286                mov si,ax 
     287                and si,000Fh 
     288                shr eax,4 
     289                push ds 
     290                mov ds,ax 
     291                mov di,trackbuf 
     292                add cx,3 
     293                shr cx,2 
     294                rep movsd 
     295                pop ds 
     296.none: 
     297 
     298adhcp_copy: 
     299                mov cx,[adhcp_len] 
     300                mov ax,trackbufsize/2 
     301                jcxz .none 
     302                cmp cx,ax 
     303                jbe .oksize 
     304                mov cx,ax 
     305                mov [adhcp_len],ax 
     306.oksize: 
     307                mov eax,[adhcp_offset] 
     308                add eax,_start 
     309                mov si,ax 
     310                and si,000Fh 
     311                shr eax,4 
     312                push ds 
     313                mov ds,ax 
     314                mov di,trackbuf+trackbufsize/2 
     315                add cx,3 
     316                shr cx,2 
     317                rep movsd 
     318                pop ds 
     319.none: 
    255320 
    256321; 
     
    267332                mov si,copyright_str 
    268333                call writestr_early 
     334 
     335; 
     336; Look to see if we are on an EFI CSM system.  Some EFI 
     337; CSM systems put the BEV stack in low memory, which means 
     338; a return to the PXE stack will crash the system.  However, 
     339; INT 18h works reliably, so in that case hack the stack and 
     340; point the "return address" to an INT 18h instruction. 
     341; 
     342; Hack the stack instead of the much simpler "just invoke INT 18h 
     343; if we want to reset", so that chainloading other NBPs will work. 
     344; 
     345efi_csm_workaround: 
     346                les bp,[InitStack]      ; GS:SP -> original stack 
     347                les bx,[es:bp+44]       ; Return address 
     348                cmp word [es:bx],18CDh  ; Already pointing to INT 18h? 
     349                je .skip 
     350 
     351                ; Search memory from E0000 to FFFFF for a $EFI structure 
     352                mov bx,0E000h 
     353.scan_mem: 
     354                mov es,bx 
     355                cmp dword [es:0],'IFE$' ; $EFI is byte-reversed... 
     356                jne .not_here 
     357                ; 
     358                ; Verify the table.  We don't check the checksum because 
     359                ; it seems some CSMs leave it at zero. 
     360                ; 
     361                movzx cx,byte [es:5]    ; Table length 
     362                cmp cx,83               ; 83 bytes is the current length... 
     363                jae .found_it 
     364 
     365.not_here: 
     366                inc bx 
     367                jnz .scan_mem 
     368                jmp .skip               ; No $EFI structure found 
     369 
     370                ; 
     371                ; Found a $EFI structure.  Move down the original stack 
     372                ; and put an INT 18h instruction there instead. 
     373                ; 
     374.found_it: 
     375%if USE_PXE_PROVIDED_STACK 
     376                mov cx,efi_csm_hack_size 
     377                mov si,sp 
     378                sub sp,cx 
     379                mov di,sp 
     380                mov ax,ss 
     381                mov es,ax 
     382                sub [InitStack],cx 
     383                sub [BaseStack],cx 
     384%else 
     385                les si,[InitStack] 
     386                lea di,[si-efi_csm_hack_size] 
     387                mov [InitStack],di 
     388%endif 
     389                lea cx,[bp+52]          ; End of the stack we care about 
     390                sub cx,si 
     391                es rep movsb 
     392                mov [es:di-8],di        ; Clobber the return address 
     393                mov [es:di-6],es 
     394                mov si,efi_csm_hack 
     395                mov cx,efi_csm_hack_size 
     396                rep movsb 
     397 
     398.skip:   
     399 
     400                section .data 
     401                alignz 4 
     402efi_csm_hack: 
     403                int 18h 
     404                jmp 0F000h:0FFF0h 
     405                hlt 
     406efi_csm_hack_size equ $-efi_csm_hack 
     407 
     408                section .text 
    269409 
    270410; 
     
    451591                mov [LocalDomain],al            ; No LocalDomain received 
    452592 
     593 
     594; This is a good time to initialize DHCPMagic... 
     595; Initialize it to 1 meaning we will accept options found; 
     596; in earlier versions of PXELINUX bit 0 was used to indicate 
     597; we have found option 208 with the appropriate magic number; 
     598; we no longer require that, but MAY want to re-introduce 
     599; it in the future for vendor encapsulated options. 
     600                mov byte [DHCPMagic],1 
     601 
     602; 
     603; Process any hardwired options the user may have specified.  This is 
     604; different than the actual packets in that there is no header, just 
     605; an option field. 
     606; 
     607                mov cx,[bdhcp_len] 
     608                mov si,trackbuf 
     609                call parse_dhcp_options 
     610 
    453611; 
    454612; The DHCP client identifiers are best gotten from the DHCPREQUEST 
     
    462620                call pxe_get_cached_info 
    463621                call parse_dhcp 
    464  
    465                 ; We don't use flags from the request packet, so 
    466                 ; this is a good time to initialize DHCPMagic... 
    467                 ; Initialize it to 1 meaning we will accept options found; 
    468                 ; in earlier versions of PXELINUX bit 0 was used to indicate 
    469                 ; we have found option 208 with the appropriate magic number; 
    470                 ; we no longer require that, but MAY want to re-introduce 
    471                 ; it in the future for vendor encapsulated options. 
    472                 mov byte [DHCPMagic],1 
    473622 
    474623; 
     
    513662                call parse_dhcp                 ; Parse DHCP packet 
    514663                call crlf 
     664 
     665; 
     666; Process any hardwired options the user may have specified.  This is 
     667; different than the actual packets in that there is no header, just 
     668; an option field.  This handles the "after" options 
     669; 
     670                mov cx,[adhcp_len] 
     671                mov si,trackbuf+trackbufsize/2 
     672                call parse_dhcp_options 
    515673 
    516674; 
     
    790948                call writestr_early 
    791949                ; Restore the environment we were called with 
     950                call cleanup_hardware 
    792951                lss sp,[InitStack] 
    793952                pop gs 
     
    21772336; 
    21782337; Get a DHCP packet from the PXE stack into the trackbuf. 
     2338; Leaves the upper half of the trackbuf untouched. 
    21792339; 
    21802340; Input: 
     
    21972357                movzx ax,dl 
    21982358                stosw           ; Packet type 
    2199                 mov ax,trackbufsize 
     2359                mov ax,trackbufsize/2 
    22002360                stosw           ; Buffer size 
    22012361                mov ax,trackbuf 
  • core/serirq.inc

    ree8989 r03ae23  
    9292SerialTail      dw 0                    ; Tail of serial port rx buffer 
    9393 
     94                section .bss 
     95IRQMask         resw 1                  ; PIC IRQ mask status 
     96 
    9497                section .text 
    9598 
     
    133136                mov al,1                ; Enable receive interrupt 
    134137                slow_out dx,al 
     138 
     139                ; 
     140                ; Enable all ther interupt lines at the PIC.  Some BIOSes 
     141                ; only enable the timer interrupts and other interrupts 
     142                ; actively in use by the BIOS. 
     143                ; 
     144                in al,0xA1              ; Secondary PIC mask register 
     145                mov ah,al 
     146                in al,0x21              ; Primary PIC mask register 
     147                mov [IRQMask],ax 
     148 
     149                io_delay 
     150 
     151                xor ax,ax               ; Remove all interrupt masks 
     152                out 0x21,al 
     153                out 0xA1,al 
    135154 
    136155                popad 
     
    157176                slow_out dx,al          ; Clear IER 
    158177 
     178                ; Restore PIC masks 
     179                mov ax,[IRQMask] 
     180                out 0x21,al 
     181                mov al,ah 
     182                out 0xA1,al 
     183 
    159184                ; Restore the original interrupt vectors 
    160185                mov si,oldirq0 
     
    165190                mov cx,8 
    166191                rep movsd 
     192 
     193                xor ax,ax 
     194                mov [SerialIRQPort],ax          ; No active interrupt system 
    167195 
    168196.done: 
  • modules/Makefile

    rcc460b r37dce9  
    2020INCLUDES   = -I$(com32)/include 
    2121 
    22 BINS = pxechain.com gfxboot.com poweroff.com 
     22BINS = pxechain.com gfxboot.com poweroff.com int18.com 
    2323 
    2424all: $(BINS) 
  • utils/Makefile

    re462c2 r87d502  
    2222 
    2323TARGETS  = mkdiskimage isohybrid gethostip 
    24 ASIS     = keytab-lilo lss16toppm md5pass ppmtolss16 sha1pass syslinux2ansi 
     24ASIS     = keytab-lilo lss16toppm md5pass ppmtolss16 sha1pass syslinux2ansi \ 
     25           pxelinux-options 
    2526 
    2627ISOHDPFX = ../mbr/isohdpfx.bin ../mbr/isohdpfx_f.bin ../mbr/isohdpfx_c.bin \