AIX Simulation SCO UNIX Menu Drive
Wang Guanghong
AIX has a Curses library, but there is no Menu driver, which gives the user a problem: one need to write a Menu program, and the second is to transplant from Sco Unix to AIX. If you use Menu, you cannot be ported. I have successfully prepared the Menu driver code for the AIX Simulation SCO UNIX for SCO UNIX:
#include
#include "menu.h" // Put the Menu.h of Sco Unix to AIX
#include
Static int index = 0;
Item * new_item (char * name, char * DESC)
{
Item * i;
I = (item *) Malloc (sizeof (item));
I-> Name.str = NAME;
I-> Name.length = Strlen (Name);
I-> Description.str = DESC;
I-> Description.Length = Strlen (DESC);
I-> INDEX = INDEX ;
I-> IMenu = (MENU *) 0;
I-> Value = 0;
I-> Userptr = (char *) 0;
I-> OPT = 0x00;
I-> status = 0;
I-> y = 0;
I-> x = 0;
I-> LEFT = (item *) 0;
I-> Right = (item *) 0;
I-> Up = (item *) 0;
I-> DOWN = (item *) 0;
Return I;
}
Menu * new_menu (item ** item)
{
Menu * m;
INT n = 0;
INDEX = 0;
M = (menu *) Malloc (Sizeof (Menu));
MEMSET (M, 0L, SIZEOF (MENU);
m-> items = item;
M-> Curitem = item [0];
For (n = m-> nitems = 0; item [n]; m-> nitems , n ) {
IF (M-> Namelen
M-> Namelen = Item [N] -> Name.Length;
IF (M-> Desclen
M-> desclen = item [n] -> description.Length;
}
M-> Marklen = 1;
M-> width = m-> Namelen M-> Desclen 1 M-> Marklen;
M-> rows = m-> height = m-> Nitems;
M-> COLS = 1;
m-> FROWS = 16;
m-> fcols = 1;
m-> itemlen = m-> width;
M-> PAD = '';
m-> Toprow = 0;
Return M;
}
Int Strncmpi (Char * S1, Char * S2, INT LEN)
{
INT I;
CHAR T1 [512], T2 [512];
STRCPY (T1, S1);
STRCPY (T2, S2); for (i = 0; I IF (Isupper (T1 [i])) T1 [i] = TOLOWER (T1 [i]); For (i = 0; i IF (Isupper (T2 [i])) T2 [i] = TOLOWER (T2 [i]); Return Strncmp (T1, T2, LEN); } INT set_menu_pattern (Menu * M, Char * Pattern) { INT LEN, N, S; Item * Ci; Len = Strlen (Pattern); n = m-> Curitem-> index; Ci = m-> Curitem; For (s = 0; s N% = m-> Nitems; IF (Strncmpi (M-> Items [N] -> Name.STR, PATTERN, LEN) == 0) { m-> pattern = pattern; M-> Curitem = m-> items [n]; Return E_OK; } } RETURN E_NO_MATCH; } INT set_menu_mark (Menu * M, Char * Mark) { M-> Mark = Mark; M-> Marklen = Strlen (Mark); M-> width = m-> marklen; M-> itemlen = m-> marklen; M-> width = m-> itemlen; Return 0; } INT set_menu_pad (menu * m, int pad) { M-> PAD = PAD; Return 0; } INT set_menu_format (menu * m, int y, int x) { M-> FROWS = Y; m-> fcols = x; IF (x> m-> cols) { IF (x> = m-> nitems) { M-> cols = m-> Nitems; M-> rows = 1; } Else { m-> cols = x; M-> rows = (int) (m-> nitems / x) (m-> NItems% x> 0); } } M-> height = y M-> width = (x Return 0; } INT scale_menu (menu * m, int * rows, int * cols) { * rows = m-> height; * cols = m-> width; Return 0; } INT set_menu_win (menu * m, window * w) { M-> WIN = W; } INT set_menu_sub (menu * m, window * w) { M-> SUB = W; } Static char * menu_LABLE (int N, menu * m) { Static char Lable [81]; CHAR TAG [2]; Int S, T; TAG [0] = M-> PAD; TAG [1] = 0; MEMSET (Lable, 0L, SIZEOF (Lable); IF (n> = m-> Nitems) Return Lable; S = m-> itemlen - m-> items [n] -> name.length - m-> items [n] -> description.length - m-> marklen -1; Sprintf (Lable, "% s", M-> items [n] -> name.str); For (t = 0; t STRCAT (Lable, M-> Items [N] -> Description.STR); Return lable; } (to be continued)