/*++ Copyright (c) 1997 Microsoft Corporation Module Name: disksel.c Abstract: Routine to allow the user to select a disk from a list of disks. The UI is a simple character-based deal. Author: Ted Miller (tedm) 29-May-1997 Revision History: --*/ #include #include #include #include #include #include #include typedef BOOL (*PDISKSEL_VALIDATION_ROUTINE) ( IN USHORT DiskId ); INT _far SelectDisk( IN UINT DiskCount, IN FPCHAR Prompt, IN PDISKSEL_VALIDATION_ROUTINE Validate, OPTIONAL OUT char *AlternateResponse, OPTIONAL IN FPCHAR textDisk, IN FPCHAR textPaddedMbCount, IN FPCHAR textInvalidSelection, IN FPCHAR textMasterDisk ) { UINT i,l; BYTE Int13Unit; BYTE SectorsPerTrack; USHORT Heads; USHORT Cylinders; ULONG SectorCount; UINT Selection; CHAR line[256]; FPVOID Buffer,OriginalBuffer; if(!AllocTrackBuffer(1,&Buffer,&OriginalBuffer)) { Buffer = NULL; OriginalBuffer = NULL; } select: printf("\n\n"); for(i=0; i DiskCount)) { if(AlternateResponse) { strcpy(AlternateResponse,line); if(OriginalBuffer) { free(OriginalBuffer); } return(-1); } else { printf("\n\n%s\n",textInvalidSelection); goto select; } } if(Validate && !Validate(Selection-1)) { printf("\n\n%s\n",textInvalidSelection); goto select; } if(OriginalBuffer) { free(OriginalBuffer); } return(Selection-1); }