Пример #1
0
TEXTMENU* ResetMenuInit(void) {
	TEXTMENUITEM *itemPtr;
	TEXTMENU *menuPtr;
	
	menuPtr = malloc(sizeof(TEXTMENU));
	memset(menuPtr,0x00,sizeof(TEXTMENU));
	strcpy(menuPtr->szCaption, "Reset Menu");

	itemPtr = malloc(sizeof(TEXTMENUITEM));
	memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
	strcpy(itemPtr->szCaption, "Reboot (slow)");
	itemPtr->functionPtr=SlowReboot;
	itemPtr->functionDataPtr = NULL;
	TextMenuAddItem(menuPtr, itemPtr);

	itemPtr = malloc(sizeof(TEXTMENUITEM));
	memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
	strcpy(itemPtr->szCaption, "Reboot (fast)");
	itemPtr->functionPtr=QuickReboot;
	itemPtr->functionDataPtr = NULL;
	TextMenuAddItem(menuPtr, itemPtr);
	
	itemPtr = malloc(sizeof(TEXTMENUITEM));
	memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
	strcpy(itemPtr->szCaption, "Power off");
	itemPtr->functionPtr=PowerOff;
	itemPtr->functionDataPtr = NULL;
	TextMenuAddItem(menuPtr, itemPtr);

	return menuPtr;
}
Пример #2
0
int Confirm(char *message, char *yesText, char *noText, int defaultItem) {
    TEXTMENU ConfirmMenu;
    TEXTMENUITEM YesItem, NoItem;

    memset(&ConfirmMenu, 0x00, sizeof(TEXTMENU));
    memset(&YesItem, 0x00, sizeof(TEXTMENUITEM));
    memset(&NoItem, 0x00, sizeof(TEXTMENUITEM));
    
    //Title the menu
    strncpy(ConfirmMenu.szCaption, message, MENUCAPTIONSIZE);
    
    //Set up the yes/no items
    strncpy(YesItem.szCaption, yesText, MENUCAPTIONSIZE);
    strncpy(NoItem.szCaption, noText, MENUCAPTIONSIZE);
    YesItem.functionPtr=Confirm_Yes;
    NoItem.functionPtr=Confirm_No;
    //Add them to the menu    
    TextMenuAddItem(&ConfirmMenu, &YesItem);    
    TextMenuAddItem(&ConfirmMenu, &NoItem);    
    
    //Draw the menu
    TextMenu(&ConfirmMenu, defaultItem?&YesItem:&NoItem);
    
    return Confirm_Result;
}
Пример #3
0
void DrawBootMenu(void *rootEntry) {
	//entry is the pointer to the root config entry
	TEXTMENU *menu;
	TEXTMENUITEM *menuPtr, *defaultMenuItem;
	CONFIGENTRY *configEntry, *currentConfigEntry;
	extern int timedOut;

	defaultMenuItem=NULL;
	configEntry = rootEntry;

	if (configEntry->nextConfigEntry==NULL) {
		//If there is only one option, just boot it.
		BootMenuEntry(configEntry);
		return;
	}

	if (timedOut) {
		//We should be non-interactive, then.
		//If there is a default entry, boot that.
		for (currentConfigEntry = configEntry; currentConfigEntry != NULL; 
			currentConfigEntry = currentConfigEntry->nextConfigEntry) {
			if (currentConfigEntry->isDefault) {
				BootMenuEntry(currentConfigEntry);
				return;
			}
		}
		//There wasn't a default entry, so just boot the first in the list
		BootMenuEntry(configEntry);
		return;
	}
	
	menu = malloc(sizeof(TEXTMENU));
	memset(menu,0x00,sizeof(TEXTMENU));
	strcpy(menu->szCaption, "Boot menu");
  
	for (currentConfigEntry = configEntry; currentConfigEntry != NULL; 
		currentConfigEntry = currentConfigEntry->nextConfigEntry) {
	
		menuPtr = malloc(sizeof(TEXTMENUITEM*));
		memset(menuPtr, 0x00, sizeof(menuPtr));
		if (currentConfigEntry->title == NULL) {
			strcpy(menuPtr->szCaption,"Untitled");
		}
		else strncpy(menuPtr->szCaption,currentConfigEntry->title,50);
		menuPtr->functionPtr = BootMenuEntry;
		menuPtr->functionDataPtr = (void *)currentConfigEntry;
		//If this config entry is default, mark the menu item as default.
		if (currentConfigEntry->isDefault) defaultMenuItem = menuPtr;
		TextMenuAddItem(menu,menuPtr);
	}
	TextMenu(menu, defaultMenuItem);
}
Пример #4
0
TEXTMENU *HDDMenuInit(void) {
    TEXTMENUITEM *itemPtr;
    TEXTMENU *menuPtr;
    int i=0;

    menuPtr = (TEXTMENU*)malloc(sizeof(TEXTMENU));
    memset(menuPtr,0x00,sizeof(TEXTMENU));
    strcpy(menuPtr->szCaption, "HDD Menu");

    for (i=0; i<2; ++i) {
        if (tsaHarddiskInfo[i].m_fDriveExists && !tsaHarddiskInfo[i].m_fAtapi) {
            //If it's not ATAPI, it must be IDE
            if((tsaHarddiskInfo[i].m_securitySettings &0x0001)==0x0001) {	//Drive Security feature supported.
                //This drive is locked - produce an unlock menu
                itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
                memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
                if((tsaHarddiskInfo[i].m_securitySettings &0x0002)==0x0002) {
                    sprintf(itemPtr->szCaption,"Unlock HDD : ");
                }
                else {
                    sprintf(itemPtr->szCaption,"Lock HDD : ");
                }
                itemPtr->szParameter[50] = i;
                sprintf(itemPtr->szParameter, "%s",i ? "slave":"master");
                itemPtr->functionPtr= AssertLockUnlock;
                itemPtr->functionDataPtr = itemPtr;
                TextMenuAddItem(menuPtr, itemPtr);
            }
    
            //Add a 'display password' menu
            itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
            memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
            sprintf(itemPtr->szCaption,"Display HDD password : "******"%s",i ? "slave":"master");
            itemPtr->functionPtr= DisplayHDDPassword;
            itemPtr->functionDataPtr = malloc(sizeof(int));
                *(int*)itemPtr->functionDataPtr = i;
            TextMenuAddItem(menuPtr, itemPtr);

            //Add a 'display HDD info' menu
            itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
            memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
            sprintf(itemPtr->szCaption,"Display HDD info : ");
            sprintf(itemPtr->szParameter, "%s",i ? "slave":"master");
            itemPtr->functionPtr= DisplayHDDInfo;
            itemPtr->functionDataPtr = malloc(sizeof(int));
                *(int*)itemPtr->functionDataPtr = i;
            TextMenuAddItem(menuPtr, itemPtr);
            if(tsaHarddiskInfo[i].m_fHasMbr != -1){     //MBR contains standard basic partition entries.
                //FORMAT C: drive
                itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
                memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
                sprintf(itemPtr->szCaption,"Format C drive : ");
                sprintf(itemPtr->szParameter, "%s",i ? "slave":"master");
                itemPtr->functionPtr= FormatDriveC;
                itemPtr->functionDataPtr = malloc(sizeof(int));
                    *(int*)itemPtr->functionDataPtr = i;
                TextMenuAddItem(menuPtr, itemPtr);

                //FORMAT E: drive
                itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
                memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
                sprintf(itemPtr->szCaption,"Format E drive : ");
                sprintf(itemPtr->szParameter, "%s",i ? "slave":"master");
                itemPtr->functionPtr= FormatDriveE;
                itemPtr->functionDataPtr = malloc(sizeof(int));
                    *(int*)itemPtr->functionDataPtr = i;
                TextMenuAddItem(menuPtr, itemPtr);

                //FORMAT X:, Y: and Z: drives.
                itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
                memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
                sprintf(itemPtr->szCaption,"Format cache drives : ");
                sprintf(itemPtr->szParameter, "%s",i ? "slave":"master");
                itemPtr->functionPtr= FormatCacheDrives;
                itemPtr->functionDataPtr = malloc(sizeof(int));
                    *(int*)itemPtr->functionDataPtr = i;
                TextMenuAddItem(menuPtr, itemPtr);

                //If there's enough sectors to make F and/or G drive(s).
                if(tsaHarddiskInfo[i].m_dwCountSectorsTotal >= (SECTOR_EXTEND + SECTORS_SYSTEM)){
                    //Format Larger drives option menu.
                    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
                    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
                    sprintf(itemPtr->szCaption,"Large HDD format : ");
                    sprintf(itemPtr->szParameter, "%s",i ? "slave":"master");
                    itemPtr->functionPtr= (void *)LargeHDDMenuInit;
                    itemPtr->functionDataPtr = malloc(sizeof(u8));
                        *(u8 *)itemPtr->functionDataPtr = i;
                    TextMenuAddItem(menuPtr, itemPtr);
                }
            }
            else{
                //Print message.
                itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
                memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
                sprintf(itemPtr->szCaption,"Unsupported partition scheme...");
                itemPtr->functionPtr= NULL;
                itemPtr->functionDataPtr = NULL;
                itemPtr->noSelect = NOSELECTERROR;
                TextMenuAddItem(menuPtr, itemPtr);

                //Print message.
                itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
                memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
                sprintf(itemPtr->szCaption,"XBlast OS will not format this HDD!");
                itemPtr->functionPtr= NULL;
                itemPtr->functionDataPtr = NULL;
                itemPtr->noSelect = NOSELECTERROR;
                TextMenuAddItem(menuPtr, itemPtr);
            }
        }
    }

    return menuPtr;
}
Пример #5
0
TEXTMENU *LargeHDDMenuInit(void * drive) {
    TEXTMENUITEM *itemPtr;
    TEXTMENU *menuPtr;
    int i=0, nDriveIndex = 1;
    
    nDriveIndex = *(u8 *) drive;

    //Amount of free sectors after standard partitions
    unsigned long nExtendSectors = tsaHarddiskInfo[nDriveIndex].m_dwCountSectorsTotal - SECTOR_EXTEND;

    menuPtr = (TEXTMENU*)malloc(sizeof(TEXTMENU));
    memset(menuPtr,0x00,sizeof(TEXTMENU));
    sprintf(menuPtr->szCaption, "Large HDD format options : %s", nDriveIndex ? "slave":"master");

    //No entry in this menu will have a configurable parameter.
    //Set first character to NULL to indicate no string is to be shown.
    itemPtr->szParameter[0]=0;

    //If lbacount >= minimum amount per partition.
    if(nExtendSectors > (SECTORS_SYSTEM + SECTORS_SYSTEM)){
        itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
        memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
        sprintf(itemPtr->szCaption,"F:, G: Split evenly");
        itemPtr->functionPtr= FormatDriveFG;
        itemPtr->functionDataPtr = malloc(sizeof(u8));
            *(u8 *)itemPtr->functionDataPtr = nDriveIndex | F_GEQUAL;
        TextMenuAddItem(menuPtr, itemPtr);
    }

    //If lbacount is high enough to max out a F: partition and still have enough left to create a G partition
    if(nExtendSectors > (LBASIZE_1024GB + SECTORS_SYSTEM)){
        itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
        memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
        sprintf(itemPtr->szCaption,"Max F:, G: takes the rest");
        itemPtr->functionPtr= FormatDriveFG;
        itemPtr->functionDataPtr = malloc(sizeof(u8));
            *(u8 *)itemPtr->functionDataPtr = nDriveIndex | FMAX_G;
        TextMenuAddItem(menuPtr, itemPtr);
    }

    //if lbacount is high enough to create G: partition but not too high to waste space because G: would be maxed out.
    if((nExtendSectors > (LBASIZE_137GB + SECTORS_SYSTEM)) && ((nExtendSectors - LBASIZE_137GB) < LBASIZE_1024GB)){
        itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
        memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
        sprintf(itemPtr->szCaption,"F: = 120GB, G: takes the rest");
        itemPtr->functionPtr= FormatDriveFG;
        itemPtr->functionDataPtr = malloc(sizeof(u8));
            *(u8 *)itemPtr->functionDataPtr = nDriveIndex | F137_G;
        TextMenuAddItem(menuPtr, itemPtr);
    }

    //If lbacount is not too high to waste space because F: can't get bigger.
    if(nExtendSectors < LBASIZE_1024GB){
        itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
        memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
        sprintf(itemPtr->szCaption,"F: take all, no G:");
        itemPtr->functionPtr= FormatDriveFG;
        itemPtr->functionDataPtr = malloc(sizeof(u8));
            *(u8 *)itemPtr->functionDataPtr = nDriveIndex | F_NOG;
        TextMenuAddItem(menuPtr, itemPtr);
    }

    ResetDrawChildTextMenu(menuPtr);

    return menuPtr;
}
Пример #6
0
TEXTMENU *AppendPathMenuInit(void) {
    
    TEXTMENUITEM *itemPtr;
    TEXTMENU *menuPtr;

    extern char appendPath[200];
    memset(appendPath, 0, 200);

    //Create the root menu - MANDATORY
    menuPtr = (TEXTMENU*)malloc(sizeof(TEXTMENU));
   memset(menuPtr,0x00,sizeof(TEXTMENU));
    menuPtr->timeout = 1;
    menuPtr->longTitle = 1;
    menuPtr->visibleCount = 3;
    strcpy(menuPtr->szCaption, "/append.txt");
    menuPtr->firstMenuItem=NULL;

    strcpy(appendPath, menuPtr->szCaption);


    // Connect
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    strcpy(itemPtr->szCaption, "Connect");
    itemPtr->functionPtr=enableHttpcAppendPath;
    itemPtr->functionDataPtr = NULL ;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);
    
    // New letter
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "->");
    itemPtr->functionPtr=nextLetterAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Delete
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "<-");
    itemPtr->functionPtr=deleteLetterAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Uppercase
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "Uppercase");
    itemPtr->functionPtr=setUCAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Lowercase
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "Lowercase");
    itemPtr->functionPtr=setLCAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Number
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "Numbers");
    itemPtr->functionPtr=setNumAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Fullstop (.)
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "Fullstop (.)");
    itemPtr->functionPtr=setFullStopAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Forward slash (/)
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "Forward slash (/)");
    itemPtr->functionPtr=setFSlashAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Dash (-)
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "Dash (-)");
    itemPtr->functionPtr=setDashAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    // Underscore (_)
    itemPtr = (TEXTMENUITEM*)malloc(sizeof(TEXTMENUITEM));
    memset(itemPtr,0x00,sizeof(TEXTMENUITEM));
    sprintf(itemPtr->szCaption, "Underscore (_)");
    itemPtr->functionPtr=setUScoreAppendPath;
    itemPtr->functionDataPtr = menuPtr->szCaption;
    itemPtr->functionLeftPtr=decrementAlphabetAppendPath;
    itemPtr->functionLeftDataPtr = menuPtr->szCaption;
    itemPtr->functionRightPtr=incrementAlphabetAppendPath;
    itemPtr->functionRightDataPtr = menuPtr->szCaption;
    TextMenuAddItem(menuPtr, itemPtr);

    return menuPtr;
}