Exemple #1
0
void term_init(int screenheight)
{
   struct text_info dat;

   if (saved_lines <= 0) {
      gettextinfo(&dat);
      screen_h = saved_lines = dat.screenheight;
      screen_w = dat.screenwidth;
      norm_attrib = dat.normattr;
   }

   if (screen_h != screenheight) {
      _set_screen_lines(screenheight);
      gettextinfo(&dat);
      screen_h = dat.screenheight;
      screen_w = dat.screenwidth;
   }

   set_bright_backgrounds();

   n_vid();
   textattr(attrib);
   cls();

   mouse_init();

   errno = 0;
}
Exemple #2
0
void term_reinit(int wait)             /* fixup after running other progs */
{
   struct text_info dat;

   gppconio_init();
   gettextinfo(&dat);

   if (dat.screenheight != screen_h) {
      _set_screen_lines(screen_h);
      gettextinfo(&dat);
      screen_h = dat.screenheight;
      screen_w = dat.screenwidth;
      mouse_init();
   }

   set_bright_backgrounds();

   if (wait) {
      clear_keybuf();
      gch();
   }

   __djgpp_set_ctrl_c(0);
   setcbrk(0);
}
Exemple #3
0
 int con_init()
 {
   gppconio_init();
   gettextinfo( &ti );
   original_ta = ti.attribute;
   return 0;
 }
Exemple #4
0
/* PROTO */
void
get_screen_size(void)
{
#if defined(__MINGW32__) || defined(__DJGPP__) || defined(PLAN9)
#ifdef __MINGW32__
	CONSOLE_SCREEN_BUFFER_INFO p;

	GetConsoleScreenBufferInfo(hOut, &p);

	screen_cols = (int) p.dwSize.X;
	screen_lines = (int) p.dwSize.Y;
#endif

#ifdef PLAN9
	screen_cols = getwidth();
	screen_lines = 25;
#endif

#ifdef __DJGPP__
	struct text_info ti;

	gettextinfo(&ti);

	screen_cols = ti.screenwidth;
	screen_lines = ti.screenheight;
#endif
#else
	struct winsize  scrsize;

	ioctl(fileno(stdin), TIOCGWINSZ, &scrsize);
	screen_cols = scrsize.ws_col;
	screen_lines = scrsize.ws_row;
#endif
}
Exemple #5
0
/*
 * This function gets called once, to set up
 * the terminal channel. 
 */
ttopen() {
#ifdef TCCONIO
	gettextinfo(&tinfo);
	oldmode = tinfo.currmode;
#if TCCONIOMODE
	textmode(TCCONIOMODE);
#endif
	directvideo = 0;
#else
	register char *tv_stype;
	char *getenv(), tcbuf[1024], err_str[72];

/* do this the REAL way */
	if ((tv_stype = getenv("TERM")) == NULL)
	{
		puts("Environment variable TERM not defined!");
		exit(1);
	}

	if((tgetent(tcbuf, tv_stype)) != 1)
	{
		(void) sprintf(err_str, "Unknown terminal type %s!", tv_stype);
		puts(err_str);
		exit(1);
	}
#endif	/* TCCONIO */
	if (ttraw() == FALSE)
		panic("aborting due to terminal initialize failure");

#ifdef FEPCTRL	/* 90.11.26  by K.Takano */
	fepmode_init();
#endif
}
Exemple #6
0
static int conio_init_graphics(caca_display_t *dp)
{
    dp->drv.p = malloc(sizeof(struct driver_private));

    _wscroll = 0;
    _setcursortype(_NOCURSOR);
    clrscr();

    gettextinfo(&dp->drv.p->ti);
    dp->drv.p->screen = malloc(2 * dp->drv.p->ti.screenwidth
                                 * dp->drv.p->ti.screenheight * sizeof(char));
    if(dp->drv.p->screen == NULL)
        return -1;
#   if defined(SCREENUPDATE_IN_PC_H)
    ScreenRetrieve(dp->drv.p->screen);
#   else
    /* FIXME */
#   endif
    dp->resize.allow = 1;
    caca_set_canvas_size(dp->cv, dp->drv.p->ti.screenwidth,
                                  dp->drv.p->ti.screenheight);
    dp->resize.allow = 0;

    return 0;
}
Exemple #7
0
void dtioStart(void) {

	#if PLATFORM == VSNET2K3
	/************************** VS.Net Env ******************************/
	
		std_out = GetStdHandle(STD_OUTPUT_HANDLE);
		
		/* MUST BE DECLARED inorder to use console */
		/* and structures */						
		GetConsoleScreenBufferInfo(   
			std_out, 						
			&winscreen_info
		);			
		dtioClear();

	#elif PLATFORM == BCC32
	/************************** Borland Env ******************************/
		gettextinfo(&x);
		clrscr();

	#else
	/************************* AIX + GCC Env ****************************/
	
		initscr();         /* Initialize direct terminal console        */
		noecho();          /* turn off echo of characters when typed    */
		cbreak();          /* program controls revert on each keyboard  */
		keypad(stdscr,1);  /* non ascii keys are treated as keys.       */

	#endif

}
Exemple #8
0
/*----------------------------------------------------------------------
  ToggleWindow
  ----------------------------------------------------------------------*/
void ToggleWindow(void)
{

  struct text_info TextInfo;
  char *Clip;
  int Grootte;

  if (hWnd>=0) {

	 gettextinfo(&TextInfo);

	 Grootte=((TextInfo.winbottom-TextInfo.wintop+2)*
				(TextInfo.winright-TextInfo.winleft+3))*2;
	 Clip=(char *) malloc(Grootte);

	 gettext(TextInfo.winleft,TextInfo.wintop,TextInfo.winright+2,
				TextInfo.winbottom+1,Clip);

	 puttext(TextInfo.winleft,TextInfo.wintop,TextInfo.winright+2,
				TextInfo.winbottom+1,WindowStruc[hWnd]->Clip);

	 memcpy(WindowStruc[hWnd]->Clip,Clip,Grootte);
	 free(Clip);

  }

}
Exemple #9
0
int	selectwindow(void)
{
	int	row,col;
	char	scrn[61-19+1][2];
	struct	text_info t;

	window(19,1,61,24);
	textbackground(CYAN);
	textcolor(BLACK);
	clrscr();

	memset(scrn,0x20,sizeof(scrn));
	for (col=0; col<43; col++)
		scrn[col][1]=CYAN*16+BLACK;

	scrn[0][0]=scrn[42][0]='º';
	scrn[0][1]=scrn[42][1]=CYAN*16+BLUE;

	gettextinfo(&t);
	for (row=t.wintop; row<=t.winbottom; row++)
		puttext(t.winleft,row,t.winright,row,scrn);

	window(20,1,60,24);

	return	1;
}
Exemple #10
0
void drawchatwin(box_t *boxch, char* topname, char* botname) {
	struct text_info ti;
	int	i;

	_wscroll=0;
	gettextinfo(&ti);
	textcolor(WHITE);
	textbackground(BLACK);
	clrscr();
	uwin.top=1;
	uwin.left=1;
	uwin.right=ti.screenwidth;
	uwin.bottom=ti.screenheight/2-1;
	uwin.colour=GREEN;
	swin.top=ti.screenheight/2+1;
	swin.left=1;
	swin.right=ti.screenwidth;
	swin.bottom=ti.screenheight;
	swin.colour=LIGHTGREEN;

	gotoxy(1,ti.screenheight/2);
	putch(196);
	putch(196);
	putch(196);
	putch(196);
	putch(180);
	cputs(topname);
	putch(195);
	for(i=wherex();i<=ti.screenwidth;i++)
		putch(196);

	_wscroll=1;
}
Exemple #11
0
/*----------------------------------------------------------------------
  MakeWindow
  ----------------------------------------------------------------------*/
void MakeWindow(int Boven,int Links,int Onder,int Rechts,
		int Stijl,unsigned int Attr)
{

  if (hWnd<MAXWINDOWS-1) {

    hWnd++;
    WindowStruc[hWnd]=(hbWindow *) malloc(sizeof(hbWindow));

	 WindowStruc[hWnd]->Clip=(char *)
	 malloc(((Onder-Boven+2)*(Rechts-Links+3))*2);

    gettextinfo(&WindowStruc[hWnd]->TextInfo);

	 gettext(Links,Boven,Rechts+2,Onder+1,WindowStruc[hWnd]->Clip);

    textattr(Attr);
    window(Links,Boven,Rechts,Onder);
    clrscr();
	 if (Stijl)
      Box(Boven,Links,Onder,Rechts,Stijl,Attr);
    Schaduw(Boven,Links,Onder,Rechts);

  }

}
Exemple #12
0
void startup(void)
{
	/* this function will set up the system for the UVEA application */

	/* setup fonts */
	rename("ccslchr0.fnt","tscr.chr");
	rename("ccslchr1.fnt","goth.chr");
	rename("ccslchr2.fnt","litt.chr");
	rename("ccslchr3.fnt","sans.chr");
	rename("ccslchr4.fnt","trip.chr");
	rename("ccslchr5.fnt","bold.chr");
	rename("ccslchr6.fnt","euro.chr");
	rename("ccslchr7.fnt","lcom.chr");
	rename("ccslchr8.fnt","scri.chr");
	rename("ccslchr9.fnt","simp.chr");

	/* setup graphics interface */
	rename("ccslgfx1.gri","att.bgi");
	rename("ccslgfx2.gri","cga.bgi");
	rename("ccslgfx3.gri","egavga.bgi");
	rename("ccslgfx4.gri","herc.bgi");
	rename("ccslgfx5.gri","ibm8514.bgi");
	rename("ccslgfx6.gri","pc3270.bgi");

	/* Set up graphics */
	gettextinfo(&original);
	initgraph(&graphdriver, &graphmode, "");
	setccslpalette();				/* set palette */
	putlogo();						/* display logo */
	putbackground();				/* display UVEA "wallpaper" */
	initrat(&rat);
	raton();
    PXInit();
}
int main()
{
   struct text_info ti;
   gettextinfo( &ti );

   Set_Coords( ti.screenwidth / 2, ti.screenheight / 2 );
   Draw_Happy_Face( 0x2 );
   Print_Message( Name );
   return 0;
}
Exemple #14
0
void tui_init(void)
{
    set_gfx_mode(GFX_TEXT, 80, 25, 0, 0);

    /* FIXME: this should be made more flexible, to handle other screen modes
       automatically. */
    _set_screen_lines(25);

    gettextinfo(&text_mode_info);
    /* _setcursortype(_NOCURSOR); */
}
Exemple #15
0
/*----------------------------------------------------------------------
  TitleWindow
  ----------------------------------------------------------------------*/
void TitleWindow(int Positie,const char *Titel)
{

  int x,y,Lengte;
  struct text_info TextInfo;

  Lengte=strlen(Titel);
  gettextinfo(&TextInfo);

  switch(Positie) {

  case LINKSBOVEN:

      x=2;
      y=1;
      break;

  case MIDDENBOVEN:

		x=((TextInfo.winright-TextInfo.winleft+3)/2)-(Lengte/2);
		y=1;
		break;

  case RECHTSBOVEN:

		x=TextInfo.winright-TextInfo.winleft+1-Lengte;
		y=1;
		break;

  case LINKSONDER:

		x=2;
		y=TextInfo.winbottom-TextInfo.wintop+1;
		break;

  case MIDDENONDER:
		x=((TextInfo.winright-TextInfo.winleft+3)/2)-(Lengte/2);
		y=TextInfo.winbottom-TextInfo.wintop+1;
      break;

  case RECHTSONDER:

      x=TextInfo.winright-TextInfo.winleft+1-Lengte;
      y=TextInfo.winbottom-TextInfo.wintop+1;
      break;

  }

  gotoxy(x,y);
  cprintf("%s",Titel);

}
Exemple #16
0
struct spox *spox_init(const int width, const int height, const int interval, const int bright) {
	struct spox *s;
#ifdef CURSES
	WINDOW *win;
#endif
#ifdef CONIO
	struct text_info *r;
#endif

	s = (struct spox*) malloc(sizeof (struct spox));
	if (!s)
		return NULL;
#ifdef CURSES
	win = initscr();
	if (!win)
		return NULL;
	nodelay(win, 1);
	getmaxyx(win, s->scr_height, s->scr_width);
#endif
#ifdef CONIO
	r = NULL;
	textmode(BW80);
	_setcursortype(_NOCURSOR);
	gotoxy(3, 3);
	cputs("press <alt> + <enter> for full screen");
	sleep(3);
	gettextinfo(r);
	s->scr_width = (int) r->screenwidth;
	s->scr_height = (int) r->screenheight;
#endif
	s->win_width = s->scr_width;
	s->win_height = s->scr_height;
	s->offset_x = 0;
	s->offset_y = 0;
	if (width < s->scr_width && width > 8) {
		s->win_width = width;
		s->offset_x = (s->win_width - width) / 2;
	}
	if (height < s->scr_height && height > 8) {
		s->win_height = height;
		s->offset_y = (s->win_height - height) / 2;
	}
	s->img_width = s->win_width * PPW;
	s->img_height = s->win_height * PPH;
	s->bright = bright;
	s->interval = interval;
	return s;
}
Exemple #17
0
/*----------------------------------------------------------------------
  PrintcWindow
  ----------------------------------------------------------------------*/
void PrintcWindow(int Regel,const char *Tekst)
{

  int x,Lengte;
  struct text_info TextInfo;

  Lengte=strlen(Tekst);
  gettextinfo(&TextInfo);

  x=((TextInfo.winright-TextInfo.winleft+3)/2)-(Lengte/2);

  gotoxy(x,Regel);
  cprintf("%s",Tekst);


}
Exemple #18
0
void main(void)
 {
   struct text_info text;

   gettextinfo(&text);

   cprintf("Screen coordinates %d,%d to %d,%d\r\n",
     text.wintop, text.winleft, text.winbottom, text.winright);

   cprintf("Text attribute %d Normal attribute %d\r\n",
     text.attribute, text.normattr);

   cprintf("Screen height %d width %d\r\n", text.screenheight,
     text.screenwidth);

   cprintf("Cursor position was row %d column %d\r\n",
     text.cury, text.curx);
 }
void initcursor(void)
/* Initializes the different cursor types */
{
 struct text_info ti;

 gettextinfo(&ti);
 oldcursor = getcursor();
 if (ti.currmode == MONO)
 {
  shortcursor = 0x0A0C;
  tallcursor = 0x090C;
 }
 else
 {
  shortcursor = 0x0607;
  tallcursor = 0x0507;
 }
} /* initcursor */
Exemple #20
0
/*----------------------------------------------------------------------
  ClearWindow
  ----------------------------------------------------------------------*/
void ClearWindow(void)
{

  int i,j;
  unsigned char Teken;
  struct text_info TextInfo;

  if (hWnd>=0) {

    gettextinfo(&TextInfo);
    Teken=' ';

    for(i=TextInfo.wintop;i<TextInfo.winbottom-1;i++)
      for(j=TextInfo.winleft;j<TextInfo.winright-1;j++)
	*(VideoAdres+(i*80)+j)=Teken | (TextInfo.attribute << 8);

  }

}
Exemple #21
0
/*----------------------------------------------------------------------
  hbPrint
  ----------------------------------------------------------------------*/
void hbPrint(int y,int x,const char *Tekst,unsigned int Attr)
{

  int VorigeCursor;
  struct text_info TextInfo;

  gettextinfo(&TextInfo);
  VorigeCursor=SetCursor(UIT);

  textattr(Attr);
  window(x,y,80,25);
  cputs(Tekst);
  SetCursor(VorigeCursor);

  window(TextInfo.winleft,TextInfo.wintop,
			TextInfo.winright,TextInfo.winbottom);
  textattr(TextInfo.attribute);
  gotoxy(TextInfo.curx,TextInfo.cury);

}
Exemple #22
0
void errormessage(char far *message)
{
char scbuffer[800];
struct text_info inforec;
int x1 = 10;
int x2 = 10;
int y1 = 20;
int y2 = 23;
if (strchr(message,13) != NULL)
x2 += 2*strlen(message)/3 + 4;
else
x2 += strlen(message)+4;
burp();
gettextinfo(&inforec);
if (x2-x1 < 17) x2 = x1 + 17;
gettext(1,y1,80,y2+1,scbuffer);
textbackground(LIGHTGRAY);
window(x1+1,y1+1,x2+1,y2+1);
clrscr();
textbackground(BLACK);
textcolor(LIGHTGRAY);
window(x1,y1,x2,y2);
clrscr();
window(x1,y1,x2+1,y2+1);
textlineh(1,1,x2-x1+1);
textlineh(y2-y1+1,1,x2-x1+1);
textlinev(1,1,y2-y1+1,218,192);
textlinev(x2-x1+1,1,y2-y1+1,191,217);
window(1,1,80,25);
gotoxy(x1 + (x2-x1)/2 - 5/2,y1);
cprintf(" ERROR ");
window(x1+2,y1+1,x2-2,y2-1);
gotoxy(1,1);
cprintf("%s",message);
window(1,1,80,25);
delay(1500);
puttext(1,y1,80,y2+1,scbuffer);
textattr(inforec.attribute);
gotoxy(inforec.curx,inforec.cury);
window(inforec.winleft,inforec.wintop,inforec.winright,inforec.winbottom);
}
Exemple #23
0
						/* START SCREEN HANDLING */
void initscr( void )
{	nruns++;
	if ( 0 == debug_pcurses )
		{
#ifdef __BORLANDC__
		normal_text_colour = NORMAL_TEXT_DEFAULT;
		normal_back_colour = NORMAL_BACK_DEFAULT;
		bold_text_colour = BOLD_TEXT_DEFAULT;
		reverse_text_colour = REVERSE_TEXT_DEFAULT;
		underline_text_colour = UNDERLINE_TEXT_DEFAULT;
		gettextinfo( &screen_defaults );
		textmode( C80 );
		textcolor( normal_text_colour );
		textbackground( normal_back_colour );
		clrscr();
#endif
		}
	else
		{inform( "initscr" );
		}
}
void initcolortable(void)
/* Sets up the color table */
{
  int color, fg, bg, fcolor, bcolor;
  struct text_info ti;

  gettextinfo(&ti);
  if (ti.currmode == C80)
  {
    for (color = 0; color <= 255; color++)
      colortable[color] = color;
  }
  else
  {
    for (fg = BLACK; fg <= WHITE; fg++)
    {
      if (fg == BLACK)
        fcolor = BLACK;
      else if (fg <= LIGHTGRAY)
        fcolor = LIGHTGRAY;
      else
        fcolor = WHITE;
      for (bg = BLACK; bg <= LIGHTGRAY; bg++)
      {
        if (bg == BLACK)
          bcolor = BLACK;
        else
  {
          if (fcolor == WHITE)
            fcolor = BLACK;
          bcolor = LIGHTGRAY;
        }
        colortable[fg + (bg << 4)] = fcolor + (bcolor << 4);
      }
    }
    for (fg = 128; fg <= 255; fg++)
      colortable[fg] = colortable[fg - 128] | 0x80;
  }
} /* initcolortable */
Exemple #25
0
void startup(void)
{
	/* setup fonts */
	rename("ccslchr1.fnt","goth.chr");
	rename("ccslchr2.fnt","litt.chr");
	rename("ccslchr3.fnt","sans.chr");
	rename("ccslchr4.fnt","trip.chr");

	/* setup graphics interface */
	rename("ccslgfx1.gri","att.bgi");
	rename("ccslgfx2.gri","cga.bgi");
	rename("ccslgfx3.gri","egavga.bgi");
	rename("ccslgfx4.gri","herc.bgi");
	rename("ccslgfx5.gri","ibm8514.bgi");
	rename("ccslgfx6.gri","pc3270.bgi");

	/* Set up graphics */
	gettextinfo(&original);
	initgraph(&graphdriver, &graphmode, "");
	setccslpalette();				/* set palette */
	putlogo();						/* display logo */
	putbackground();				/* display CCSL "wallpaper" */
}
Exemple #26
0
/*----------------------------------------------------------------------
  RemoveWindow
  ----------------------------------------------------------------------*/
void RemoveWindow(void)
{

  struct text_info TextInfo;

  if (hWnd>=0) {

    gettextinfo(&TextInfo);

	 puttext(TextInfo.winleft,TextInfo.wintop,TextInfo.winright+2,
				TextInfo.winbottom+1,WindowStruc[hWnd]->Clip);

	 window(WindowStruc[hWnd]->TextInfo.winleft,
		WindowStruc[hWnd]->TextInfo.wintop,
		WindowStruc[hWnd]->TextInfo.winright,
		WindowStruc[hWnd]->TextInfo.winbottom);

	 textattr(WindowStruc[hWnd]->TextInfo.attribute);

	 free(WindowStruc[hWnd]->Clip);
	 hWnd--;
  }

}
Exemple #27
0
void viewscroll(void)
{
	int	top;
	int key;
	int i;
	char	*scrollback;
	struct	text_info txtinfo;

    gettextinfo(&txtinfo);
	/* ToDo: Watch this... may be too large for alloca() */
	scrollback=(char *)malloc((txtinfo.screenwidth*2*SCROLL_LINES)+(txtinfo.screenheight*txtinfo.screenwidth*2));
	memcpy(scrollback,cterm.scrollback,txtinfo.screenwidth*2*SCROLL_LINES);
	gettext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(cterm.backpos)*cterm.width*2);
	top=cterm.backpos;
	for(i=0;!i;) {
		if(top<1)
			top=1;
		if(top>cterm.backpos)
			top=cterm.backpos;
		puttext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(txtinfo.screenwidth*2*top));
		key=getch();
		switch(key) {
			case 0xff:
			case 0:
				switch(key|getch()<<8) {
					case CIO_KEY_UP:
						top--;
						break;
					case CIO_KEY_DOWN:
						top++;
						break;
					case CIO_KEY_PPAGE:
						top-=txtinfo.screenheight;
						break;
					case CIO_KEY_NPAGE:
						top+=txtinfo.screenheight;
						break;
				}
				break;
			case 'j':
			case 'J':
				top--;
				break;
			case 'k':
			case 'K':
				top++;
				break;
			case 'h':
			case 'H':
				top-=txtinfo.screenheight;
				break;
			case 'l':
			case 'L':
				top+=txtinfo.screenheight;
				break;
			case '\033':
				i=1;
				break;
		}
	}
	free(scrollback);
	return;
}
Exemple #28
0
int main(int argc, char **argv)
{
	struct text_info	ti;
	FILE	*f;
	char	buf[BUF_SIZE*2];	/* Room for lfexpand */
	int		len;
	int		speed;
	char	*scrollbuf;
	char	*infile=NULL;
	char	title[MAX_PATH+1];
	int		expand=0;
	int		i;

	textmode(C80);
	gettextinfo(&ti);
	if((scrollbuf=malloc(SCROLL_LINES*ti.screenwidth*2))==NULL) {
		cprintf("Cannot allocate memory\n\n\rPress any key to exit.");
		getch();
		return(-1);
	}
	
	/* Parse command line */
	for(i=1; i<argc; i++) {
		if(argv[i][0]=='-') {
			if(argv[i][1]=='l' && argv[i][2]==0)
				expand=1;
			else
				goto usage;
		}
		else {
			if(infile==NULL)
				infile=argv[i];
			else
				goto usage;
		}
	}

	cterm_init(ti.screenheight, ti.screenwidth, 0, 0, SCROLL_LINES, scrollbuf);
	if(infile) {
		if((f=fopen(infile,"r"))==NULL) {
			cprintf("Cannot read %s\n\n\rPress any key to exit.",argv[1]);
			getch();
			return(-1);
		}
		sprintf(title,"SyncView: %s",getfname(argv[1]));
	}
	else {
		f=stdin;
		strcpy(title,"SyncView: [stdin]");
	}
	settitle(title);
	while((len=fread(buf, 1, BUF_SIZE, f))!=0) {
		if(expand)
			lfexpand(buf, &len);
		cterm_write(buf, len, NULL, 0, &speed);
	}
	viewscroll();
	return(0);

usage:
	cprintf("Usage: %s [-l] [filename]\r\n\r\n"
			"Displays the ANSI file filename expanding \\n to \\r\\n if -l is specified.\r\n"
			"If no filename is specified, reads input from stdin\r\n"
			"\r\n"
			"Press any key to exit.");
	getch();
	return(-1);
}
Exemple #29
0
int
main (int argc, char **argv)
{
  int dat_count;                    /* size of the dat array */
  int i;
  int mono = 0;                     /* running on monochrome monitor */

  dat_t *dat_ary;                   /* the dat file array */
  inst_t ret;                       /* no. of errors, warnings */

  struct text_info ti;              /* (borland) for gettextinfo */
 

  /* Open the language catalog */
  cat = catopen ("install", 0);

  /* Check command line */

  for (i = 1; i < argc; i++)
  {
    if (strcmpi(argv[i], "/mono") == 0)
      mono = 1;
    else if (strcmpi(argv[i], "/nopause") == 0)
      nopauseflag = 1;
    else if (strcmpi(argv[i], "/nolog") == 0)
      wantlog = 0;
    else if ( (strcmpi(argv[i], "/src") == 0) && (i+1 < argc))
    {
      fromdirflag = 1;
      i++;
      strcpy(fromdir+2, argv[i]);
    }
    else if ( (strcmpi(argv[i], "/dst") == 0) && (i+1 < argc))
    {
      destdirflag = 1;
      i++;
      strcpy(destdir+2, argv[i]);
    }
    else
    {
      fprintf (stderr, catgets (cat, SET_USAGE, MSG_USAGE, MSG_USAGE_STR));
      exit (1);
    }
  }

  /* unzip overwrites screen with warning if TZ not set, so check    */
  /* and if not set, then set for us to GMT0, which means no offsets */
  if (getenv("TZ") == NULL) putenv("TZ=GMT0");


  /* Read dat file */

  dat_ary = dat_read ("INSTALL.DAT", &dat_count);
  if (dat_ary == NULL)
  {
    if (dat_count > 0)
    {
      fprintf (stderr, catgets (cat, SET_ERRORS, MSG_ERRALLOCMEMDF, MSG_ERRALLOCMEMDF_STR));
      exit (2);
    }
    else /* Either error reading file, eg no file, or file has no entries */
    {
      fprintf (stderr, catgets (cat, SET_ERRORS, MSG_ERREMPTYDATAFILE, MSG_ERREMPTYDATAFILE_STR));
      exit (3);
    }
  }

  /* Get localized "Yes" and "No" strings */
  getLocalizedYesNo();

  /* register our SIGINT handler (Ctrl-C) */
  registerSIGINTHandler();

  /* Start the install */

  /* save current setting so we can restore them */
  gettextinfo (&ti);

  /* setup screen colors then draw the screen */
  if (mono)
  {
    textbackground (BLACK);
    textcolor (LIGHTGRAY);
  }
  else
  {
    textbackground (BLUE);
    textcolor (WHITE);
  }

  repaint_empty();
  gotoxy (2, 3);
  cat_file ("COPYR", 18);
  pause();

  repaint_empty();
  gotoxy (2, 3);
  cat_file ("OEM", 18);
  pause();

  ret.errors = 0;
  ret.warnings = 0;

  ret = install_top (dat_ary, dat_count);

  /* Finished with install */

  textattr (ti.attribute); /* restore user's screen */
  clrscr();

  if ((ret.errors == 0) && (ret.warnings == 0))
      printf (catgets (cat, SET_GENERAL, MSG_INSTALLOK, MSG_INSTALLOK_STR));
  else
      printf (catgets (cat, SET_GENERAL, MSG_INSTALLERRORS, MSG_INSTALLERRORS_STR), ret.errors, ret.warnings);

  /* Done */

  free (dat_ary);
  free (yes);
  free (no);
  catclose (cat);

  /* restore original SIGINT handler */
  unregisterSIGINTHandler();

  return (0);
}
Exemple #30
0
/******************************************************************************
* Interpret the command line and scan the given GIF file.		      *
******************************************************************************/
void main(int argc, char **argv)
{
    int	i, j, k, Error, NumFiles, Size, Row, Col, Width, Height, ExtCode,
	Count, ColorMapSize, GraphDriver, GraphMode, Sum,
	HelpFlag = FALSE,
	BGIPathFlag = FALSE,
	BGIUserDriverFlag = FALSE,
	ZoomFlag = FALSE;
    GifRecordType RecordType;
    GifByteType *Extension;
    char Str[80], *BGIUserDriverNameMode,
	**FileName = NULL;
    GifRowType *ScreenBuffer;
    GifFileType *GifFile;
    struct text_info TextInfo;      /* So we can restore starting text mode. */

    if ((Error = GAGetArgs(argc, argv, CtrlStr,
		&GifQuitePrint, &BGIPathFlag, &BGIPath,
		&BGIUserDriverFlag, &BGIUserDriverNameMode,
		&ZoomFlag, &ZoomFactor,
		&BeepsDisabled, &HelpFlag,
		&NumFiles, &FileName)) != FALSE ||
		(NumFiles > 1 && !HelpFlag)) {
	if (Error)
	    GAPrintErrMsg(Error);
	else if (NumFiles > 1)
	    GIF_MESSAGE("Error in command line parsing - one GIF file please.");
	GAPrintHowTo(CtrlStr);
	exit(1);
    }

    if (HelpFlag) {
	fprintf(stderr, VersionStr);
	GAPrintHowTo(CtrlStr);
	exit(0);
    }

    if (BGIUserDriverFlag) {
	/* Use the driver supplied by the user! */
        BGIInstallUserDriver(BGIUserDriverNameMode);
        installuserdriver(BGIUserDriverName, detectVGA);
	GraphDriver = BGI_USER_INSTALL;
    }
    else {
        /* Sense type of display we have and attempt to load right driver. */
        detectgraph(&GraphDriver, &GraphMode);
        if (GraphDriver < 0)
	    GIF_EXIT("BGI Auto detect: No graphics device detected.");
    }

    /* Put in the following any graphic driver specific setup: */
    switch (GraphDriver) {
	case CGA:
	    GraphMode = CGAHI;
	    break;
	case EGA:
	    GraphMode = EGAHI;
	    break;
	case EGA64:
	    GraphMode = EGA64HI;
	    break;
	case EGAMONO:
	    GraphMode = EGAMONOHI;
	    break;
	case HERCMONO:
	    GraphMode = HERCMONOHI;
	    break;
	case VGA:
	    GraphMode = VGAHI;
	    break;
	case BGI_USER_INSTALL:
	    GraphDriver = DETECT;
	    GraphMode = BGIUserDriverMode;
	    break;
	default:
	    GIF_EXIT("Requested graphic device is not supported.");
	    break;
    }

    if (NumFiles == 1) {
	GifFileName = *FileName;
	if ((GifFile = DGifOpenFileName(*FileName)) == NULL) {
	    PrintGifError();
	    exit(-1);
	}
    }
    else {
	/* Use the stdin instead: */
	GifFileName = "Stdin";
	setmode(0, O_BINARY);
	if ((GifFile = DGifOpenFileHandle(0)) == NULL) {
	    PrintGifError();
	    exit(-1);
	}
    }

    /* Allocate the screen as vector of column of rows. We cannt allocate    */
    /* the all screen at once, as this broken minded CPU can allocate up to  */
    /* 64k at a time and our image can be bigger than that:		     */
    /* Note this screen is device independent - its the screen as defined by */
    /* the GIF file parameters itself.					     */
    if ((ScreenBuffer = (GifRowType *)
	malloc(GifFile -> SHeight * sizeof(GifRowType *))) == NULL)
	    GIF_EXIT("Failed to allocate memory required, aborted.");

    Size = GifFile -> SWidth * sizeof(GifPixelType);/* Size in bytes of one row.*/
    if ((ScreenBuffer[0] = (GifRowType) malloc(Size)) == NULL)    /* First row. */
	GIF_EXIT("Failed to allocate memory required, aborted.");

    for (i = 0; i < GifFile -> SWidth; i++)  /* Set its color to BackGround. */
	ScreenBuffer[0][i] = GifFile -> SBackGroundColor;
    MaximumScreenHeight = GifFile -> SHeight - 1;
    for (i = 1; i < GifFile -> SHeight; i++) {
	/* Allocate the other rows, and set their color to background too: */
	if ((ScreenBuffer[i] = (GifRowType) malloc(Size)) == NULL) {
	    if (i > 30) {
		/* Free some memory for the BGI driver and auxilary. */
		for (j = 1; j < 28; j++)
	    	    free((char *) ScreenBuffer[i - j]);
	    	MaximumScreenHeight = i - 28;
	    	fprintf(stderr, "\n%s: Failed to allocate all memory required, last line %d.\n",
			PROGRAM_NAME, MaximumScreenHeight);
	    	break;
	    }
	    else
		GIF_EXIT("Failed to allocate memory required, aborted.");
	}

	memcpy(ScreenBuffer[i], ScreenBuffer[0], Size);
    }

    /* Scan the content of the GIF file and load the image(s) in: */
    do {
	if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
	    PrintGifError();
	    break;
	}
	switch (RecordType) {
	    case IMAGE_DESC_RECORD_TYPE:
		if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
		    PrintGifError();
		    exit(-1);
		}

		Row = GifFile -> ITop; /* Image Position relative to Screen. */
		Col = GifFile -> ILeft;
		Width = GifFile -> IWidth;
		Height = GifFile -> IHeight;
		GifQprintf("\n%s: Image %d at (%d, %d) [%dx%d]:     ",
		    PROGRAM_NAME, ++ImageNum, Col, Row, Width, Height);
		if (GifFile -> ILeft + GifFile -> IWidth > GifFile -> SWidth ||
		   GifFile -> ITop + GifFile -> IHeight > GifFile -> SHeight) {
		    fprintf(stderr, "Image %d is not confined to screen dimension, aborted.\n");
		    exit(-2);
		}
		if (GifFile -> IInterlace) {
		    /* Need to perform 4 passes on the images: */
		    for (Count = i = 0; i < 4; i++)
			for (j = Row + InterlacedOffset[i]; j < Row + Height;
						 j += InterlacedJumps[i]) {
			    GifQprintf("\b\b\b\b%-4d", Count++);
			    if (DGifGetLine(GifFile,
				&ScreenBuffer[MIN(j, MaximumScreenHeight)][Col],
				Width) == GIF_ERROR) {
				PrintGifError();
				exit(-1);
			    }
			}
		}
		else {
		    for (i = 0; i < Height; i++, Row++) {
			GifQprintf("\b\b\b\b%-4d", i);
			if (DGifGetLine(GifFile, &ScreenBuffer[MIN(Row, MaximumScreenHeight)][Col],
				Width) == GIF_ERROR) {
			    PrintGifError();
			    MaximumScreenHeight = MIN(i - 1, MaximumScreenHeight);
			}
		    }
		}
		break;
	    case EXTENSION_RECORD_TYPE:
		/* Skip any extension blocks in file: */
		if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR) {
		    PrintGifError();
		    exit(-1);
		}
		while (Extension != NULL) {
		    if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR) {
			PrintGifError();
			exit(-1);
		    }
		}
		break;
	    case TERMINATE_RECORD_TYPE:
		break;
	    default:		    /* Should be traps by DGifGetRecordType. */
		break;
	}
    }
    while (RecordType != TERMINATE_RECORD_TYPE);

    /* Lets display it - set the global variables required and do it: */
    BackGround = GifFile -> SBackGroundColor;
    ColorMap = (GifFile -> IColorMap ? GifFile -> IColorMap :
				       GifFile -> SColorMap);
    ColorMapSize = 1 << (GifFile -> IColorMap ? GifFile -> IBitsPerPixel :
						GifFile -> SBitsPerPixel);

    gettextinfo(&TextInfo);	     /* Save current mode so we can recover. */

    initgraph(&GraphDriver, &GraphMode, BGIPath);
    if (graphresult() != grOk)	 	       /* Error occured during init. */
	GIF_EXIT("Graphics System Error, failed to initialize driver.");

    if (getmaxcolor() + 1 < ColorMapSize) {
	sprintf(Str, "GIF Image color map (%d) is too big for device (%d).\n",
					      ColorMapSize, getmaxcolor() + 1);
	closegraph();
	GIF_EXIT(Str);
    }

    /* Initialize hardware pallete and also select fore/background color.    */
    BackGround = ForeGround = 1;
    Sum = ((int) ColorMap[1].Red) +
	  ((int) ColorMap[1].Green) +
	  ((int) ColorMap[1].Blue);
    j = k = Sum;
    for (i = 0; i < ColorMapSize; i++) {
	setrgbpalette(i, ColorMap[i].Red >> 2,
			 ColorMap[i].Green >> 2,
			 ColorMap[i].Blue >> 2);

	Sum = ((int) ColorMap[i].Red) +
	      ((int) ColorMap[i].Green) +
	      ((int) ColorMap[i].Blue);
	if (i != 0 && Sum > j) {			/* Dont use color 0. */
	    ForeGround = i;
	    j = Sum;
	}
	if (i != 0 && Sum <= k) {			/* Dont use color 0. */
	    BackGround = i;
	    k = Sum;
	}
    }

    DeviceMaxX = getmaxx();		    /* Read size of physical screen. */
    DeviceMaxY = getmaxy();
    ScreenWidth = GifFile -> SWidth;
    ScreenHeight = MIN(GifFile -> SHeight, MaximumScreenHeight);

    Tone(500, 10);
    DisplayScreen(ScreenBuffer, GifFile);

    if (DGifCloseFile(GifFile) == GIF_ERROR) {
	PrintGifError();
	closegraph();
	exit(-1);
    }

    closegraph();

    textmode(TextInfo.currmode);
}