void interrupt clockproc(void)
{
    static long seconds;

    if (calls < 17)
        calls++;
    else
    {
        seconds = (long) ((double) *ticks / tps);
        if (screenbase[301] != ' ') // if the attribute has changed,
            displayclock();         // the screen scrolled, so update.
        if (seconds % 60 != lastsec)
        {
            lastsec = seconds % 60;
            calls = 0;
            screenbase[314] = (char) (lastsec/10) + 48;
            screenbase[316] = (char) (lastsec%10) + 48;
            if ((! lastsec) || (lastmin < 0))
            {
                lastmin = (seconds % 3600) / 60;
                screenbase[308] = (char) (lastmin/10) + 48;
                screenbase[310] = (char) (lastmin%10) + 48;
                if ((! lastmin) || (lasthr < 0))
                {
                    lasthr = ((seconds % 86400L) / 3600L);
                    screenbase[302] = (char) (lasthr/10) + 48;
                    screenbase[304] = (char) (lasthr%10) + 48;
                }
            }
        }
    }
    oldhandler ();
}
Example #2
0
void interrupt handler(void)
{
   ch=inportb(0x60);
   outport(0x3c0,ct);
   screen = MK_FP(0xB800,0);
   screen[0][76] = m + '0' + ATTR;
   screen[0][77] = c + '0' + ATTR;
   screen[0][78] = d + '0' + ATTR;
   screen[0][79] = u + '0' + ATTR;
   //if(ch!=chant){
   //ct++;
   //u++;  }
   if(u>9){
      u=0;
      d++;}
   if(d>9){
      d=0;
      c++;}
   if(c>9){
      c=0;
      m++;}
   if(m>9){
      m=0;
      ct=0;}
   oldhandler();
   chant=ch;
}
Example #3
0
/* 新的时钟中断处理函数 */
void interrupt newhandler()
{
    /* increase the global counter */
    TimerCounter++;
    /* call the old routine */
    oldhandler();
}
Example #4
0
//---------------------------------------------------------------------------
void interrupt handler(__CPPARGS) {
	 disable();
	 oldhandler();
	 kernel->count++;
	 kernel->resume();
	 kernel->KillList->freeAll();
//	 kernel.count++;
	 kernel->transfer();
//	 kernel.transfer();
	 enable();
}//handler
Example #5
0
void interrupt handler(void)
{
   ch=inportb(0x60);
   outport(0x3c0,ct);
   screen = MK_FP(0xB800,0);
   screen[0][75] = m[0]  + ATTR;
   screen[0][76] = m[1]  + ATTR;
   screen[0][77] = m[2]  + ATTR;
   screen[0][78] = m[3]  + ATTR;
   screen[0][79] = m[4]  + ATTR;
   itoa(ct,m,10);
   //if(ch!=chant && ch<100)
   //   ct++;
   oldhandler();
   chant=ch;
}
Example #6
0
void interrupt handler(__CPPARGS)
{
  switch( ++count )
  {
   case 4:
    s=FP_SEG(col1);o=FP_OFF(col1);
    break;
   case 8:
    s=FP_SEG(col2);o=FP_OFF(col2);
    break;
   case 12:
    s=FP_SEG(col3);o=FP_OFF(col3);
    break;
   case 16:
    s=FP_SEG(col4);o=FP_OFF(col4);
    break;
   case 20:
    s=FP_SEG(col5);o=FP_OFF(col5);
    break;
   case 24:
    s=FP_SEG(col6);o=FP_OFF(col6);
    break;
   case 28:
    s=FP_SEG(col7);o=FP_OFF(col7);
    break;
   case 32:
    s=FP_SEG(col8);o=FP_OFF(col8);
    break;
   case 36:
    s=FP_SEG(col9);o=FP_OFF(col9);
    break;
   case 40:
    s=FP_SEG(col10);o=FP_OFF(col10);
    break;
   case 44:
    s=FP_SEG(col11);o=FP_OFF(col11);
    break;
   case 48:
    s=FP_SEG(col12);o=FP_OFF(col12);
    break;
   case 52:
    s=FP_SEG(col13);o=FP_OFF(col13);
    break;
   case 56:
    s=FP_SEG(col14);o=FP_OFF(col14);
    break;
   case 60:
    s=FP_SEG(col15);o=FP_OFF(col15);
    count=0;
    break;
  }

 // wait retrace
  asm	mov dx,0x3DA

 l1:

  asm	in al,dx
  asm	and al,0x08
  asm	jnz l1

 l2:

  asm	in al,dx
  asm	and al,0x08
  asm	jz  l2


  // set color registers
  asm {
	mov ah,10h
	mov al,12h
	mov bx, s
	mov es, bx
	mov dx, o
	mov bx,240
	mov cx,16
	int 10h
  }

  oldhandler();
}
bool GSCreator::create(const QString &path, int width, int height, QImage &img)
{
// The code in the loop (when testing whether got_sig_term got set)
// should read some variation of:
// 		parentJob()->wasKilled()
//
// Unfortunatelly, that's currently impossible without breaking BIC.
// So we need to catch the signal ourselves.
// Otherwise, on certain funny PS files (for example
// http://www.tjhsst.edu/~Eedanaher/pslife/life.ps )
// gs would run forever after we were dead.
// #### Reconsider for KDE 4 ###
// (24/12/03 - luis_pedro)
//
  typedef void ( *sighandler_t )( int );
  // according to linux's "man signal" the above typedef is a gnu extension
  sighandler_t oldhandler = signal( SIGTERM, handle_sigterm );

  int input[2];
  int output[2];
  int dvipipe[2];

  QByteArray data(1024, '\0');

  bool ok = false;

  // Test if file is DVI
  bool no_dvi =!correctDVI(path);

  if (pipe(input) == -1) {
    return false;
  }
  if (pipe(output) == -1) {
    close(input[0]);
    close(input[1]);
    return false;
  }

  KDSC dsc;
  endComments = false;
  dsc.setCommentHandler(this);

  if (no_dvi)
  {
    FILE* fp = fopen(QFile::encodeName(path), "r");
    if (fp == 0) return false;

    char buf[4096];
    int count;
    while ((count = fread(buf, sizeof(char), 4096, fp)) != 0
           && !endComments) {
      dsc.scanData(buf, count);
    }
    fclose(fp);

    if (dsc.pjl() || dsc.ctrld()) {
      // this file is a mess.
      return false;
    }
  }

  const bool is_encapsulated = no_dvi &&
    (path.indexOf(QRegExp("\\.epsi?$", Qt::CaseInsensitive)) > 0) &&
    (dsc.bbox()->width() > 0) && (dsc.bbox()->height() > 0) &&
    (dsc.page_count() <= 1);

  char translation[64] = "";
  char pagesize[32] = "";
  char resopt[32] = "";
  std::auto_ptr<KDSCBBOX> bbox = dsc.bbox();
  if (is_encapsulated) {
    // GhostScript's rendering at the extremely low resolutions
    // required for thumbnails leaves something to be desired. To
    // get nicer images, we render to four times the required
    // resolution and let QImage scale the result.
    const int hres = (width * 72) / bbox->width();
    const int vres = (height * 72) / bbox->height();
    const int resolution = (hres > vres ? vres : hres) * 4;
    const int gswidth = ((bbox->urx() - bbox->llx()) * resolution) / 72;
    const int gsheight = ((bbox->ury() - bbox->lly()) * resolution) / 72;

    snprintf(pagesize, 31, "-g%ix%i", gswidth, gsheight);
    snprintf(resopt, 31, "-r%i", resolution);
    snprintf(translation, 63,
       " 0 %i sub 0 %i sub translate\n", bbox->llx(),
       bbox->lly());
  }

  const CDSC_PREVIEW_TYPE previewType =
    static_cast<CDSC_PREVIEW_TYPE>(dsc.preview());

  switch (previewType) {
  case CDSC_TIFF:
  case CDSC_WMF:
  case CDSC_PICT:
    // FIXME: these should take precedence, since they can hold
    // color previews, which EPSI can't (or can it?).
     break;
  case CDSC_EPSI:
    {
      const int xscale = bbox->width() / width;
      const int yscale = bbox->height() / height;
      const int scale = xscale < yscale ? xscale : yscale;
      if (getEPSIPreview(path,
                         dsc.beginpreview(),
                         dsc.endpreview(),
                         img,
                         bbox->width() / scale,
                         bbox->height() / scale))
        return true;
      // If the preview extraction routine fails, gs is used to
      // create a thumbnail.
    }
    break;
  case CDSC_NOPREVIEW:
  default:
    // need to run ghostscript in these cases
    break;
  }

  pid_t pid = fork();
  if (pid == 0) {
    // Child process (1)

    //    close(STDERR_FILENO);

    // find first zero entry in gsargs and put the filename
    // or - (stdin) there, if DVI
    const char **gsargs = gsargs_ps;
    const char **arg = gsargs;

    if (no_dvi && is_encapsulated) {
      gsargs = gsargs_eps;
      arg = gsargs;

      // find first zero entry and put page size there
      while (*arg) ++arg;
      *arg = pagesize;

      // find second zero entry and put resolution there
      while (*arg) ++arg;
      *arg = resopt;
    }

    // find next zero entry and put the filename there
    QByteArray fname = QFile::encodeName( path );
    while (*arg)
      ++arg;
    if( no_dvi )
      *arg = fname.data();
    else
      *arg = "-";

    // find first zero entry in dvipsargs and put the filename there
    arg = dvipsargs;
    while (*arg)
      ++arg;
    *arg = fname.data();

    if( !no_dvi ){
      pipe(dvipipe);
      pid_t pid_two = fork();
      if( pid_two == 0 ){
	// Child process (2), reopen stdout on the pipe "dvipipe" and exec dvips

	close(input[0]);
	close(input[1]);
	close(output[0]);
	close(output[1]);
	close(dvipipe[0]);

	dup2( dvipipe[1], STDOUT_FILENO);

	execvp(dvipsargs[0], const_cast<char *const *>(dvipsargs));
	exit(1);
      }
      else if(pid_two != -1){
	close(input[1]);
	close(output[0]);
	close(dvipipe[1]);

	dup2( dvipipe[0], STDIN_FILENO);
	dup2( output[1], STDOUT_FILENO);

	execvp(gsargs[0], const_cast<char *const *>(gsargs));
	exit(1);
      }
      else{
	// fork() (2) failed, close these
	close(dvipipe[0]);
	close(dvipipe[1]);
      }

    }
    else if( no_dvi ){
      // Reopen stdin/stdout on the pipes and exec gs
      close(input[1]);
      close(output[0]);

      dup2(input[0], STDIN_FILENO);
      dup2(output[1], STDOUT_FILENO);

      execvp(gsargs[0], const_cast<char *const *>(gsargs));
      exit(1);
    }
  }
  else if (pid != -1) {
    // Parent process, write first-page-only-hack (the hack is not
    // used if DVI) and read the png output
    close(input[0]);
    close(output[1]);
    const char *prolog;
    if (is_encapsulated)
      prolog = epsprolog;
    else
      prolog = psprolog;
    int count = write(input[1], prolog, strlen(prolog));
    if (is_encapsulated)
      write(input[1], translation, strlen(translation));

    close(input[1]);
    if (count == static_cast<int>(strlen(prolog))) {
      int offset = 0;
	while (!ok) {
	  fd_set fds;
	  FD_ZERO(&fds);
	  FD_SET(output[0], &fds);
	  struct timeval tv;
	  tv.tv_sec = 20;
	  tv.tv_usec = 0;

	  got_sig_term = false;
	  if (select(output[0] + 1, &fds, 0, 0, &tv) <= 0) {
            if ( ( errno == EINTR || errno == EAGAIN ) && !got_sig_term ) continue;
	    break; // error, timeout or master wants us to quit (SIGTERM)
          }
	  if (FD_ISSET(output[0], &fds)) {
	    count = read(output[0], data.data() + offset, 1024);
	    if (count == -1)
	      break;
	    else
	      if (count) // prepare for next block
		{
		  offset += count;
		  data.resize(offset + 1024);
		}
	      else // got all data
		{
		  data.resize(offset);
		  ok = true;
		}
	  }
	}
    }
    if (!ok) // error or timeout, gs probably didn't exit yet
    {
      kill(pid, SIGTERM);
    }

    int status = 0;
    int ret;
    do {
      ret = waitpid(pid, &status, 0);
    } while (ret == -1 && errno == EINTR);
    if (ret != pid || (status != 0  && status != 256) )
      ok = false;
  }
  else {
    // fork() (1) failed, close these
    close(input[0]);
    close(input[1]);
    close(output[1]);
  }
  close(output[0]);

  int l = img.loadFromData( data );

  if ( got_sig_term &&
	oldhandler != SIG_ERR &&
	oldhandler != SIG_DFL &&
	oldhandler != SIG_IGN ) {
	  oldhandler( SIGTERM ); // propagate the signal. Other things might rely on it
  }
  if ( oldhandler != SIG_ERR ) signal( SIGTERM, oldhandler );

  return ok && l;
}