summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/FDISK/INPUT.C
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/FDISK/INPUT.C')
-rw-r--r--v4.0/src/CMD/FDISK/INPUT.C673
1 files changed, 673 insertions, 0 deletions
diff --git a/v4.0/src/CMD/FDISK/INPUT.C b/v4.0/src/CMD/FDISK/INPUT.C
new file mode 100644
index 0000000..a818ef8
--- /dev/null
+++ b/v4.0/src/CMD/FDISK/INPUT.C
@@ -0,0 +1,673 @@
1
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 */
8#include "stdio.h"
9#include "fdiskmsg.h" /* AN000 */
10#include "doscall.h" /* AN000 */
11
12/* */
13char get_num_input(input_default,max_num,row,col)
14
15char max_num;
16unsigned row;
17unsigned col;
18char input_default;
19
20BEGIN
21
22 char input;
23 char default_used;
24 char input_value;
25
26 /* print default entry if there is one */
27 if (input_default != c(NUL)) /* AC000 */
28
29 BEGIN
30 default_used = TRUE;
31 /* position the cursor */
32 VIOSETCURPOS(row,col,u(0)); /* AC000 */
33
34 /* Display the default character */
35 putch(((int)(input_default+'0')));
36 END
37
38 /* Assume bad input */
39 valid_input = FALSE;
40
41 /* Loop until we get good stuff */
42 while (valid_input == FALSE)
43 BEGIN
44
45 /* position the cursor */
46 VIOSETCURPOS(row,col,u(0)); /* AC000 */
47
48 /* Flush the keyboard buffer and get the next pressed key */
49 input = get_char_input();
50
51 /* Do world trade get country information */
52 input = dos_upper(input); /* AN000 */
53
54 /* Go handle different inputs */
55 switch(input)
56 BEGIN
57 case ESC:
58 BEGIN
59 valid_input = TRUE;
60 break;
61 END
62
63 case CR:
64 BEGIN
65 /* Set the input to the default if there is one there */
66 if (default_used)
67 BEGIN
68 if (input_default != c(NUL))
69 BEGIN
70 input_value = input_default+'0';
71 END
72 else
73 BEGIN
74 /* Make the enter look like a blank for error message */
75 input_value = c(' '); /* AC000 */
76 END
77 END
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')) )
82 BEGIN
83 valid_input = TRUE;
84 input = input_value;
85 END
86 else
87 BEGIN
88 if (isdigit(input_value))
89 BEGIN
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';
95 display(error_23);
96 END
97 else
98 BEGIN
99 insert[0] = c('1'); /* AC000 */
100 insert[1] = c('-'); /* AC000 */
101 insert[2] = max_num+'0';
102 display(error_31);
103 END
104 END
105 break;
106 END
107
108 default:
109 BEGIN
110 putch(((int)(input)));
111 default_used = FALSE;
112 input_value = input;
113 break;
114 END
115 END
116 END
117 return(input);
118END
119
120
121
122/* */
123
124char get_yn_input(input_default,row,col)
125
126unsigned row;
127unsigned col;
128char input_default;
129
130BEGIN
131
132 char input;
133 char default_used;
134 char input_value;
135
136 /* print default entry if there is one */
137 if (input_default != c(NUL)) /* AC000 */
138
139 BEGIN
140 default_used = TRUE;
141 /* position the cursor */
142 VIOSETCURPOS(row,col,u(0)); /* AC000 */
143
144 /* Display the default character */
145 putch(((int)(input_default)));
146 END
147
148 /* Assume bad input */
149 valid_input = FALSE;
150
151 /* Loop until we get good stuff */
152 while (valid_input == FALSE)
153 BEGIN
154
155 /* position the cursor */
156 VIOSETCURPOS(row,col,u(0)); /* AC000 */
157
158 /* Flush the keyboard buffer and get the next pressed key */
159 input = get_char_input();
160 input = dos_upper(input);
161
162 /* Go handle different inputs */
163 switch(input)
164 BEGIN
165 case ESC:
166 BEGIN
167 valid_input = TRUE;
168 break;
169 END
170
171 case CR:
172 BEGIN
173 /* Set the input to the default if there is one there */
174 if (default_used)
175 BEGIN
176 if (input_default != c(NUL)) /* AC000 */
177 BEGIN
178 input_value = input_default;
179 END
180 else
181 BEGIN
182 internal_program_error();
183 END
184 END
185 /* See if YES or NO */
186
187 /* Do world trade get country information */
188 input = check_yn_input(input_value); /* AN000 */
189
190 if ((input == c(1)) || (input == c(0))) /* AC000 */
191 BEGIN
192 valid_input = TRUE;
193 END
194 else
195 BEGIN
196 /* Setup error message */
197 insert[0] = c(Yes); /* AC000 AC011 */
198 insert[1] = c('-'); /* AC000 */
199 insert[2] = c(No); /* AC000 AC011 */
200 display(error_31);
201 END
202 break;
203 END
204
205 default:
206 BEGIN
207 putch(((int)(input)));
208 default_used = FALSE;
209 input_value = input;
210 break;
211 END
212 END
213 END
214 return(input);
215END
216
217
218/* */
219char wait_for_ESC()
220
221BEGIN
222 char input;
223
224 while (input != c(ESC)) /* AC000 */
225 BEGIN
226 /* position the cursor at the end of the ESC prompt */
227 VIOSETCURPOS(u(24),u(39),u(0)); /* AC000 */
228
229 /* Get input */
230 input = get_char_input();
231
232 END
233 return(c(ESC)); /* AC000 */
234END
235
236
237
238
239XFLOAT get_large_num_input(input_default,max_num,max_percent,input_message,prompt_location,error_message)
240
241unsigned input_default; /* AC000 */
242unsigned max_num;
243unsigned max_percent;
244char far *input_message;
245char far *error_message;
246unsigned prompt_location;
247
248BEGIN
249
250char input;
251XFLOAT large_input; /* AC000 */
252char default_used;
253unsigned long very_big_input;
254
255 /* Assume bad input */
256 valid_input = FALSE;
257
258 /* Assume no input, and use default */
259 default_used = TRUE;
260
261 /* Initialize the input value */
262 large_input = u(0); /* AC000 */
263
264 /* Loop until we get good stuff */
265 while (valid_input == FALSE)
266
267 BEGIN
268 /* position the cursor */
269 VIOSETCURPOS(input_row,input_col,u(0)); /* AC000 */
270
271 /* Flush the keyboard buffer and get the next pressed key */
272
273 input = get_char_input();
274
275 /* Go handle different inputs */
276 switch(input)
277 BEGIN
278 case ESC:
279 valid_input = TRUE;
280 large_input = ((unsigned)(ESC_FLAG));
281 break;
282
283 case CR:
284 BEGIN
285 if (PercentFlag)
286 BEGIN
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)
292 BEGIN
293 if (large_input != u(0))
294 valid_input = TRUE;
295 else
296 display(error_28);
297 END
298 else
299 display(error_message);
300 END
301 else
302 BEGIN
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)
308 BEGIN
309 if (large_input != u(0))
310 valid_input = TRUE;
311 else
312 display(error_28);
313 END
314 else
315 display(error_message);
316 END
317 break;
318 END
319
320 case BACKSPACE:
321 if (PercentFlag)
322 PercentFlag = (FLAG)FALSE; /* AN000 */
323 else
324 large_input = large_input / 10;
325
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);
330 break;
331
332 case PERCENT: /* AN000 */
333
334 if (PercentFlag == (FLAG)FALSE)
335 BEGIN /* AN000 */
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 */
344 END /* AN000 */
345 else
346 display(error_33); /* AN000 */
347
348 break; /* AN000 */
349
350
351 default:
352 BEGIN
353
354 /* Make sure it is numerical input */
355
356 if ( (isdigit(input)) && ((!PercentFlag) || (default_used)) ) /* AN000 */
357 BEGIN
358 /* Add this digit in */
359 very_big_input= (((unsigned long)(large_input)) * 10) + ((unsigned long)input - '0'); /* AC000 */
360
361 /* Round down if > 9999.9 */
362 large_input = ((unsigned)(very_big_input%10000));
363
364 /* Put it in the message */
365 number_in_msg((XFLOAT)large_input,prompt_location); /* AN000 */
366 display(input_message);
367
368 /* Indicate that we are not using the default */
369 default_used = FALSE;
370 PercentFlag = (FLAG)FALSE; /* AN000 */
371 END
372 else
373 BEGIN
374 if (!PercentFlag) /* AN000 */
375 BEGIN /* AN000 */
376 /* Setup error message */
377 insert[0] = c('0'); /* AC000 */
378 insert[1] = c('-'); /* AC000 */
379 insert[2] = c('9'); /* AC000 */
380 display(error_31);
381 END /* AN000 */
382 else /* AN000 */
383 BEGIN /* AN000 */
384 display(error_33); /* AN000 */
385 END /* AN000 */
386 END
387 END
388 END
389 END
390
391 return(large_input);
392END
393
394
395/* */
396char get_alpha_input(low_letter,high_letter,row,col,error_low_letter,error_high_letter)
397
398unsigned row;
399unsigned col;
400char low_letter;
401char high_letter;
402char error_low_letter;
403char error_high_letter;
404
405BEGIN
406
407 char input;
408 char default_used;
409 char input_value;
410
411
412 /* Assume bad input */
413 valid_input = FALSE;
414
415 /* Init input_value to something non-alpha */
416 input_value = c(0); /* AC000 */
417
418 /* Loop until we get good stuff */
419 while (valid_input == FALSE)
420 BEGIN
421
422 /* position the cursor */
423 VIOSETCURPOS(row,col,u(0)); /* AC000 */
424
425 /* Flush the keyboard buffer and get the next pressed key */
426 input = get_char_input();
427 input = dos_upper(input);
428
429 /* Go handle different inputs */
430 switch(input)
431 BEGIN
432 case ESC:
433 BEGIN
434 valid_input = TRUE;
435 break;
436 END
437
438 case CR:
439 BEGIN
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)))
447 BEGIN
448 valid_input = TRUE;
449 END
450 else
451 BEGIN
452 if (isalpha(input_value))
453 BEGIN
454 /* Setup error message */
455 insert[0] = input;
456 insert[1] = error_low_letter;
457 insert[2] = c('-'); /* AC000 */
458 insert[3] = error_high_letter;
459 display(error_23);
460 END
461 else
462 BEGIN
463 insert[0] = error_low_letter;
464 insert[1] = c('-'); /* AC000 */
465 insert[2] = error_high_letter;
466 display(error_31);
467 END
468 END
469 break;
470 END
471
472 default:
473 BEGIN
474 putch(((int)(input)));
475 default_used = FALSE;
476 input_value = input;
477 break;
478 END
479 END
480 END
481 return(input);
482END
483
484
485/* */
486char get_char_input()
487
488BEGIN
489 regs.h.ah = uc(0x0C); /* AC000 */
490 regs.h.al = uc(0x08); /* AC000 */
491 intdos(&regs,&regs);
492 if (regs.h.al == uc(0)) /* AC000 */
493 BEGIN
494 DOSBEEP(u(900),u(400)); /* AC000 */
495 END
496 return(((char)(regs.h.al)));
497
498END
499
500
501
502/* */ /* AN000 */
503 /* AN000 */
504void get_string_input(StartRow,StartCol,string_ptr) /* AN000 */
505 /* AN000 */
506unsigned StartRow; /* AN000 */
507unsigned StartCol; /* AN000 */
508char far *string_ptr; /* AN000 */
509 /* AN000 */
510BEGIN /* AN000 */
511
512#define MAX_STRING_INPUT_LENGTH 11
513 /* AN000 */
514unsigned char input; /* AN000 */
515char input_value; /* AN000 */
516char far *WorkingPtr; /* AN000 */
517char far *DeletePtr; /* AN000 */
518char Done; /* AN000 */
519unsigned Row; /* AN000 */
520unsigned Col; /* AN000 */
521int i; /* AN000 */
522 /* AN000 */
523 /* AN000 */
524 WorkingPtr = string_ptr; /* AN000 */
525
526 Row = StartRow; /* AN000 */
527 Col = StartCol; /* AN000 */
528 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
529
530 while(*WorkingPtr != c(NUL)) /* AN000 */
531 BEGIN /* AN000 */
532 putch((int)(*WorkingPtr++)); /* AN000 */
533 Col++; /* AN000 */
534 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
535 END /* AN000 */
536
537 regs.h.ah = uc(12); /* AN000 */
538 regs.h.al = uc(8); /* AN000 */
539 intdos(&regs,&regs); /* AN000 */
540 input = regs.h.al; /* AN000 */
541
542 /* Loop until we get good stuff */ /* AN000 */
543 Done = FALSE; /* AN000 */
544 while (!Done) /* AN000 */
545 BEGIN /* AN000 */
546
547 /* Go handle different inputs */
548
549 if (input < 32) /* AN000 */
550 BEGIN /* AN000 */
551 switch(input) /* AN000 */
552 BEGIN /* AN000 */
553 case ESC: /* AN000 */
554 Done=TRUE; /* AN000 */
555 *string_ptr++ = c(ESC); /* AN000 */
556 *string_ptr++ = c('\0'); /* AN000 */
557 break; /* AN000 */
558
559 case CR: /* AN000 */
560 Done=TRUE; /* AN000 */
561 break; /* AN000 */
562
563 case 8: /* backspace */ /* AN000 */
564 if (Col > StartCol) /* AN000 */
565 BEGIN /* AN000 */
566 WorkingPtr--; /* AN000 */
567 Col--; /* 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 */
573 BEGIN /* AN000 */
574 *DeletePtr = *(DeletePtr+1); /* AN000 */
575 putch(*DeletePtr); /* AN000 */
576 DeletePtr++; /* AN000 */
577 END /* AN000 */
578 *DeletePtr = c('\0'); /* AN000 */
579 putch(' '); /* AN000 */
580 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
581 END /* AN000 */
582 else DOSBEEP(u(900),u(400)); /* AN000 */
583 break; /* AN000 */
584
585 case 0: /* AN000 */
586 regs.h.ah = uc(0x08); /* AN000 */
587 intdos(&regs,&regs); /* AN000 */
588 input = regs.h.al; /* AN000 */
589 switch(input) /* AN000 */
590 BEGIN /* 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 */
596 break; /* AN000 */
597
598 case 79: /* END */ /* AN000 */
599 while (*WorkingPtr != c('\0') ) /* AN000 */
600 BEGIN /* AN000 */
601 WorkingPtr++; /* AN000 */
602 Col++; /* AN000 */
603 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
604 END /* AN000 */
605 break; /* AN000 */
606
607
608 case 75: /* Cursor Left */ /* AN000 */
609 if (Col > StartCol) /* AN000 */
610 BEGIN /* AN000 */
611 WorkingPtr--; /* AN000 */
612 Col--; /* AN000 */
613 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
614 END /* AN000 */
615 else DOSBEEP(u(900),u(400)); /* AN000 */
616 break; /* AN000 */
617
618
619 case 77: /* Cursor Right */ /* AN000 */
620 if ( *WorkingPtr != c('\0') ) /* AN000 */
621 BEGIN /* AN000 */
622 WorkingPtr++; /* AN000 */
623 Col++; /* AN000 */
624 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
625 END /* AN000 */
626 else DOSBEEP(u(900),u(400)); /* AN000 */
627 break; /* AN000 */
628
629
630 default: /* AN000 */
631 DOSBEEP(u(900),u(400)); /* AN000 */
632 break; /* AN000 */
633
634 END /* AN000 */
635 break; /* AN000 */
636
637 default: /* AN000 */
638 DOSBEEP(u(900),u(400)); /* AN000 */
639 break; /* AN000 */
640 END /* AN000 */
641
642 END /* AN000 */
643 else /* input is >= 32 */ /* AN000 */
644 BEGIN /* AN000 */
645 input = dos_upper(input); /* AN000 */
646 if ( (strchr(".\"/\\[]:|<>+=;,",input) == NULL) &&
647 (Col < StartCol + MAX_STRING_INPUT_LENGTH) ) /* AN000 */
648 BEGIN /* 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 */
653 BEGIN /* AN000 */
654 Col++; /* AN000 */
655 WorkingPtr++; /* AN000 */
656 END /* AN000 */
657 VIOSETCURPOS(Row,Col,u(0)); /* AN000 */
658 END /* AN000 */
659 else DOSBEEP(u(900),u(400)); /* AN000 */
660 END /* AN000 */
661
662 if (!Done) /* AN000 */
663 BEGIN /* AN000 */
664 /* Get a character */ /* AN000 */
665 regs.h.ah = uc(0x08); /* AN000 */
666 intdos(&regs,&regs); /* AN000 */
667 input = regs.h.al; /* AN000 */
668 END /* AN000 */
669 END /* AN000 */
670
671 return; /* AN000 */
672END /* AN000 */
673