2 #include "dos.h" /* AN000 */
3 #include "fdisk.h" /* AN000 */
4 #include "subtype.h" /* AN000 */
5 #include "extern.h" /* AN000 */
6 #include "ctype.h" /* AN000 */
7 #include "string.h" /* AN000 */
9 #include "fdiskmsg.h" /* AN000 */
10 #include "doscall.h" /* AN000 */
13 char get_num_input(input_default,max_num,row,col)
26 /* print default entry if there is one */
27 if (input_default != c(NUL)) /* AC000 */
31 /* position the cursor */
32 VIOSETCURPOS(row,col,u(0)); /* AC000 */
34 /* Display the default character */
35 putch(((int)(input_default+'0')));
38 /* Assume bad input */
41 /* Loop until we get good stuff */
42 while (valid_input == FALSE)
45 /* position the cursor */
46 VIOSETCURPOS(row,col,u(0)); /* AC000 */
48 /* Flush the keyboard buffer and get the next pressed key */
49 input = get_char_input();
51 /* Do world trade get country information */
52 input = dos_upper(input); /* AN000 */
54 /* Go handle different inputs */
65 /* Set the input to the default if there is one there */
68 if (input_default != c(NUL))
70 input_value = input_default+'0';
74 /* Make the enter look like a blank for error message */
75 input_value = c(' '); /* AC000 */
78 /* See if it is digit and less or equal to max */
79 if ( (isdigit(input_value)) &&
80 (input_value <= (max_num+'0')) &&
81 (input_value != c('0')) )
88 if (isdigit(input_value))
90 /* Setup error message */
91 insert[0] = input_value;
92 insert[1] = c('1'); /* AC000 */
93 insert[2] = c('-'); /* AC000 */
94 insert[3] = max_num+'0';
99 insert[0] = c('1'); /* AC000 */
100 insert[1] = c('-'); /* AC000 */
101 insert[2] = max_num+'0';
110 putch(((int)(input)));
111 default_used = FALSE;
124 char get_yn_input(input_default,row,col)
136 /* print default entry if there is one */
137 if (input_default != c(NUL)) /* AC000 */
141 /* position the cursor */
142 VIOSETCURPOS(row,col,u(0)); /* AC000 */
144 /* Display the default character */
145 putch(((int)(input_default)));
148 /* Assume bad input */
151 /* Loop until we get good stuff */
152 while (valid_input == FALSE)
155 /* position the cursor */
156 VIOSETCURPOS(row,col,u(0)); /* AC000 */
158 /* Flush the keyboard buffer and get the next pressed key */
159 input = get_char_input();
160 input = dos_upper(input);
162 /* Go handle different inputs */
173 /* Set the input to the default if there is one there */
176 if (input_default != c(NUL)) /* AC000 */
178 input_value = input_default;
182 internal_program_error();
185 /* See if YES or NO */
187 /* Do world trade get country information */
188 input = check_yn_input(input_value); /* AN000 */
190 if ((input == c(1)) || (input == c(0))) /* AC000 */
196 /* Setup error message */
197 insert[0] = c(Yes); /* AC000 AC011 */
198 insert[1] = c('-'); /* AC000 */
199 insert[2] = c(No); /* AC000 AC011 */
207 putch(((int)(input)));
208 default_used = FALSE;
224 while (input != c(ESC)) /* AC000 */
226 /* position the cursor at the end of the ESC prompt */
227 VIOSETCURPOS(u(24),u(39),u(0)); /* AC000 */
230 input = get_char_input();
233 return(c(ESC)); /* AC000 */
239 XFLOAT get_large_num_input(input_default,max_num,max_percent,input_message,prompt_location,error_message)
241 unsigned input_default; /* AC000 */
243 unsigned max_percent;
244 char far *input_message;
245 char far *error_message;
246 unsigned prompt_location;
251 XFLOAT large_input; /* AC000 */
253 unsigned long very_big_input;
255 /* Assume bad input */
258 /* Assume no input, and use default */
261 /* Initialize the input value */
262 large_input = u(0); /* AC000 */
264 /* Loop until we get good stuff */
265 while (valid_input == FALSE)
268 /* position the cursor */
269 VIOSETCURPOS(input_row,input_col,u(0)); /* AC000 */
271 /* Flush the keyboard buffer and get the next pressed key */
273 input = get_char_input();
275 /* Go handle different inputs */
280 large_input = ((unsigned)(ESC_FLAG));
287 /* Set the input to the default if there is one there and nothing else entered */
288 if ((input_default != u(NUL)) && (default_used)) /* AC000 */
289 large_input = input_default;
290 /* See if input is less or equal to max_value */
291 if (large_input <= max_percent)
293 if (large_input != u(0))
299 display(error_message);
303 /* Set the input to the default if there is one there and nothing else entered */
304 if ((input_default != u(NUL)) && (default_used)) /* AC000 */
305 large_input = input_default;
306 /* See if input is less or equal to max_value */
307 if (large_input <= max_num)
309 if (large_input != u(0))
315 display(error_message);
322 PercentFlag = (FLAG)FALSE; /* AN000 */
324 large_input = large_input / 10;
326 /* Indicate that we are not using the default */
327 default_used = FALSE;
328 sprintf(&insert[prompt_location],"%4.0d",large_input); /* AN000 */
329 display(input_message);
332 case PERCENT: /* AN000 */
334 if (PercentFlag == (FLAG)FALSE)
336 PercentFlag = (FLAG)TRUE; /* AN000 */
337 /* Round down if > 999.9 */
338 if (large_input > u(999)) /* AN000 */
339 large_input = (large_input%1000); /* AN000 */
340 sprintf(&insert[prompt_location],"%3.0d%%",large_input); /* AN000 */
341 /* Indicate that we are not using the default */
342 default_used = FALSE; /* AN000 */
343 display(input_message); /* AN000 */
346 display(error_33); /* AN000 */
354 /* Make sure it is numerical input */
356 if ( (isdigit(input)) && ((!PercentFlag) || (default_used)) ) /* AN000 */
358 /* Add this digit in */
359 very_big_input= (((unsigned long)(large_input)) * 10) + ((unsigned long)input - '0'); /* AC000 */
361 /* Round down if > 9999.9 */
362 large_input = ((unsigned)(very_big_input%10000));
364 /* Put it in the message */
365 number_in_msg((XFLOAT)large_input,prompt_location); /* AN000 */
366 display(input_message);
368 /* Indicate that we are not using the default */
369 default_used = FALSE;
370 PercentFlag = (FLAG)FALSE; /* AN000 */
374 if (!PercentFlag) /* AN000 */
376 /* Setup error message */
377 insert[0] = c('0'); /* AC000 */
378 insert[1] = c('-'); /* AC000 */
379 insert[2] = c('9'); /* AC000 */
384 display(error_33); /* AN000 */
396 char get_alpha_input(low_letter,high_letter,row,col,error_low_letter,error_high_letter)
402 char error_low_letter;
403 char error_high_letter;
412 /* Assume bad input */
415 /* Init input_value to something non-alpha */
416 input_value = c(0); /* AC000 */
418 /* Loop until we get good stuff */
419 while (valid_input == FALSE)
422 /* position the cursor */
423 VIOSETCURPOS(row,col,u(0)); /* AC000 */
425 /* Flush the keyboard buffer and get the next pressed key */
426 input = get_char_input();
427 input = dos_upper(input);
429 /* Go handle different inputs */
440 /* See if it is digit and between given letters*/
441 /* Do world trade get country information */
442 input = dos_upper(input_value); /* AN000 */
443 if ((isalpha(input)) &&
444 (input >= low_letter) &&
445 (input <= high_letter) &&
446 (isalpha(input_value)))
452 if (isalpha(input_value))
454 /* Setup error message */
456 insert[1] = error_low_letter;
457 insert[2] = c('-'); /* AC000 */
458 insert[3] = error_high_letter;
463 insert[0] = error_low_letter;
464 insert[1] = c('-'); /* AC000 */
465 insert[2] = error_high_letter;
474 putch(((int)(input)));
475 default_used = FALSE;
486 char get_char_input()
489 regs.h.ah = uc(0x0C); /* AC000 */
490 regs.h.al = uc(0x08); /* AC000 */
492 if (regs.h.al == uc(0)) /* AC000 */
494 DOSBEEP(u(900),u(400)); /* AC000 */
496 return(((char)(regs.h.al)));
504 void get_string_input(StartRow,StartCol,string_ptr) /* AN000 */
506 unsigned StartRow; /* AN000 */
507 unsigned StartCol; /* AN000 */
508 char far *string_ptr; /* AN000 */
512 #define MAX_STRING_INPUT_LENGTH 11
514 unsigned char input; /* AN000 */
515 char input_value; /* AN000 */
516 char far *WorkingPtr; /* AN000 */
517 char far *DeletePtr; /* AN000 */
518 char Done; /* AN000 */
519 unsigned Row; /* AN000 */
520 unsigned Col; /* AN000 */
524 WorkingPtr = string_ptr; /* AN000 */
526 Row = StartRow; /* AN000 */
527 Col = StartCol; /* AN000 */
528 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
530 while(*WorkingPtr != c(NUL)) /* AN000 */
532 putch((int)(*WorkingPtr++)); /* AN000 */
534 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
537 regs.h.ah = uc(12); /* AN000 */
538 regs.h.al = uc(8); /* AN000 */
539 intdos(®s,®s); /* AN000 */
540 input = regs.h.al; /* AN000 */
542 /* Loop until we get good stuff */ /* AN000 */
543 Done = FALSE; /* AN000 */
544 while (!Done) /* AN000 */
547 /* Go handle different inputs */
549 if (input < 32) /* AN000 */
551 switch(input) /* AN000 */
553 case ESC: /* AN000 */
554 Done=TRUE; /* AN000 */
555 *string_ptr++ = c(ESC); /* AN000 */
556 *string_ptr++ = c('\0'); /* AN000 */
560 Done=TRUE; /* AN000 */
563 case 8: /* backspace */ /* AN000 */
564 if (Col > StartCol) /* AN000 */
566 WorkingPtr--; /* AN000 */
568 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
569 putch(' '); /* AN000 */
570 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
571 DeletePtr = WorkingPtr; /* AN000 */
572 while ( *(DeletePtr+1) != c('\0') ) /* AN000 */
574 *DeletePtr = *(DeletePtr+1); /* AN000 */
575 putch(*DeletePtr); /* AN000 */
576 DeletePtr++; /* AN000 */
578 *DeletePtr = c('\0'); /* AN000 */
579 putch(' '); /* AN000 */
580 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
582 else DOSBEEP(u(900),u(400)); /* AN000 */
586 regs.h.ah = uc(0x08); /* AN000 */
587 intdos(®s,®s); /* AN000 */
588 input = regs.h.al; /* AN000 */
589 switch(input) /* AN000 */
591 case 71: /* HOME */ /* AN000 */
592 WorkingPtr = string_ptr; /* AN000 */
593 Row = StartRow; /* AN000 */
594 Col = StartCol; /* AN000 */
595 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
598 case 79: /* END */ /* AN000 */
599 while (*WorkingPtr != c('\0') ) /* AN000 */
601 WorkingPtr++; /* AN000 */
603 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
608 case 75: /* Cursor Left */ /* AN000 */
609 if (Col > StartCol) /* AN000 */
611 WorkingPtr--; /* AN000 */
613 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
615 else DOSBEEP(u(900),u(400)); /* AN000 */
619 case 77: /* Cursor Right */ /* AN000 */
620 if ( *WorkingPtr != c('\0') ) /* AN000 */
622 WorkingPtr++; /* AN000 */
624 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
626 else DOSBEEP(u(900),u(400)); /* AN000 */
631 DOSBEEP(u(900),u(400)); /* AN000 */
638 DOSBEEP(u(900),u(400)); /* AN000 */
643 else /* input is >= 32 */ /* AN000 */
645 input = dos_upper(input); /* AN000 */
646 if ( (strchr(".\"/\\[]:|<>+=;,",input) == NULL) &&
647 (Col < StartCol + MAX_STRING_INPUT_LENGTH) ) /* AN000 */
649 putch(((int)(input))); /* AN000 */
650 *WorkingPtr = input; /* AN000 */
651 *(WorkingPtr+1) = c('\0'); /* AN000 */
652 if (Col < (StartCol + MAX_STRING_INPUT_LENGTH - 1) ) /* AN000 */
655 WorkingPtr++; /* AN000 */
657 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
659 else DOSBEEP(u(900),u(400)); /* AN000 */
662 if (!Done) /* AN000 */
664 /* Get a character */ /* AN000 */
665 regs.h.ah = uc(0x08); /* AN000 */
666 intdos(®s,®s); /* AN000 */
667 input = regs.h.al; /* AN000 */