home *** CD-ROM | disk | FTP | other *** search
- #include "part.h"
-
- #define BACKSPACE 8
- #define ESC 27
-
- int
- get_scr_val(start, m_str, def_val, low_lim, high_lim)
- int start; /* what line this goes on */
- char *m_str; /* what to say on that line */
- int def_val, /* default value */
- low_lim, /* least acceptable value */
- high_lim; /* highest acceptable value */
- {
- int val, len, len1, len2, len3;
- word pos, row, col, col2;
- char buf[8];
-
- len1 = strlen(itoa(def_val, buf, 10));
- len2 = strlen(itoa(low_lim, buf, 10));
- len3 = strlen(itoa(high_lim, buf, 10));
- len = max(max(len1,len2),len3);
- scr_pos(start,0);
- printf("%s [%*s]",m_str,len," ");
- fflush(stdout);
- pos = scr_rpos(); /* read scr_pos position */
- row = pos >> 8;
- col2 = (pos & 0xff) - 2;
- col = col2-len+1;
- #ifdef DEBUG
- scr_pos(24,0); printf("len %d, row %d, col2 %d",len,row,col2);
- fflush(stdout);
- #endif
- do {
- int c;
-
- val = 0;
- do {
- scr_pos(row, col);
- printf("%*d",len,val ? val : def_val);
- fflush(stdout);
- scr_pos(row, col2);
- c=getch();
- #ifdef DEBUG
- scr_pos(18,0);printf("!! val %d, c %d\n",val,c);fflush(stdout);
- #endif
- switch (c) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if((val = val*10 + c - '0') > high_lim) {
- scr_pos(row+2,0);
- printf("Maximum value is %d.",high_lim);
- sleep(1000L);
- erase_eol(row+2);
- val = 0;
- }
- break;
- case BACKSPACE:
- if(val)
- val /= 10;
- break;
-
- case EOF:
- exit(1); /* assume we need an immediate abort */
- /* NOTREACHED */
-
- /* default: ignore the character. */
-
- } /* end of switch */
- } while (c != '\r' && c != '\n' && c != ESC);
- if(!val)
- val = def_val;
- else if (val<low_lim) {
- scr_pos(row+2,0);
- printf("Minimum value is %d.",low_lim);
- sleep(1000L);
- erase_eol(row+2);
- }
- } while(val<low_lim);
- return(val);
- }
-
- int
- get_scr_char(start, m_str, low_lim, high_lim)
- int start;
- char *m_str;
- char low_lim, high_lim;
- {
- int len=strlen(m_str), pos, chr;
-
- scr_pos(start,0);
- fputs(m_str,stdout);
- fputs(" [ ]",stdout);
- fflush(stdout);
- pos = scr_rpos(); /* read scr_pos position */
- scr_pos(pos >> 8, (pos & 0xff) -2);
- do {
- chr = getch();
- } while(chr != EOF && chr != ESC &&
- (chr < low_lim || chr > high_lim));
- if(chr == EOF || chr == ESC)
- chr = '.';
- putchar(chr);
- return(chr);
- }
-
- void
- message(str)
- char *str;
- {
- puts(str);
- sleep(1000L); /* length (in milliseconds) is somewhat arbitrary */
- }
-
- void
- pr_head()
- {
- extern byte fixed_disk, num_disks;
-
- if(num_disks > 1)
- printf("Disk number %c:\n",fixed_disk == DISK0 ? '0' : '1');
- puts("# OS ID Boot start c/s/h end c/s/h # sec");
- puts("- ----- ---- ----------- --------- -----");
- }
-
- char *unkname = "unknown",
- *myname = "Additional DOS volume",
- *xdosname = "Extended Dos Partition",
- *dosname = "DOS",
- *xenixname = "XENIX";
-
- void
- pr_part(part_no,part)
- int part_no;
- PARTITION *part;
- {
- char *bootable, *sys;
-
- switch(part->sys_ind) {
- case EDOS_PART:
- sys = myname;
- break;
- case XDOS_PART:
- sys = xdosname;
- break;
- case DOS_PART:
- sys = dosname;
- break;
- case XENIX_PART:
- sys = xenixname;
- break;
- default:
- sys = "Unknown";
- }
- bootable = part->boot_ind ? "yes" : " no";
-
- printf("%-3d%-23s%-3s%5u/%2u/%-2u%7u/%2u/%-2u%8lu\n",
- part_no, sys, bootable,
- get_cyl(part->s_sec_cyl), get_sec(part->s_sec_cyl), part->s_head,
- get_cyl(part->e_sec_cyl), get_sec(part->e_sec_cyl), part->e_head,
- part->num_sects);
- }
-
- void
- erase_eos(from) /* erase from "from" to end of screen. Leave cursor at "from" */
- word from;
- {
- scr_scroll(from, 0, 24, 79, 0, 7);
- scr_pos(from,0);
- }
-
- void
- erase_eol(from) /* erase line "from" and stay there */
- word from;
- {
- scr_scroll(from, 0, from, 79, 0, 7);
- scr_pos(from,0);
- }
-
-