コード例 #1
0
ファイル: xskin_loadBMP.c プロジェクト: 1c0n/xbmc
int DrawCompressed4bit( Display *d, Pixmap p, GC gc,
			BMPHeader *bmp, struct timidity_file *fp ) {
  int i,j;
  int a,b;
  int x,y;
  int z=1;

  x=0;
  y=bmp->h;

  while (z) {

    a=ugetc(fp);
    b=ugetc(fp);
    if ( b==EOF ) break;

    if ( a!=0 ) {
      if ( b>=bmp->ncolors ) b=0;
      for ( i=0 ; i<a ; i+=2 ) {
	if ( x<bmp->w ) {
	  XSetForeground( d, gc, color_palletes[(b>>4)&0x0f] );
	  XDrawPoint( d, p, gc, x, y-1 );
	  x++;
	  if ( i!=a-1 ) {
	    XSetForeground( d, gc, color_palletes[b&0x0f] );
	    XDrawPoint( d, p, gc, x, y-1 );
	    x++;
	  }
	}
      }

    } else {

      switch( b ) {
コード例 #2
0
ファイル: xskin_loadBMP.c プロジェクト: 1c0n/xbmc
int Get2bytes( struct timidity_file *fp ) {
  int ret;
  int i;

  if ( (i=ugetc(fp))==EOF ) return -1;
  ret  = i;
  if ( (i=ugetc(fp))==EOF ) return -1;
  ret += i*256;

  return ret;
}
コード例 #3
0
ファイル: agtk.c プロジェクト: ufaith/d2imdev
static void gtk_draw_menu_item(MENU *m, int x, int y, int w, int h, int bar, int sel)
{
    BITMAP *bmp = gui_get_screen();
    int fg, bg;
    int i, j;
    char buf[256], *tok;

    if (m->flags & D_DISABLED) {
        fg = nshadow;
        bg = normal;
    }
    else {
        fg = black;
        bg = (sel) ? highlight : normal;
    }

    rectfill(bmp, x+1, y+1, x+w-3, y+h-4, bg);

    if (ugetc(m->text)) {
        i = 0;
        j = ugetc(m->text);

        while ((j) && (j != '\t')) {
            i += usetc(buf+i, j);
            j = ugetc(m->text+i);
        }

        usetc(buf+i, 0);

        gui_textout_ex(bmp, buf, x+8, y+1, fg, bg, FALSE);

        if (j == '\t') {
            tok = m->text+i + uwidth(m->text+i);
            gui_textout_ex(bmp, tok, x+w-gui_strlen(tok)-10, y+1, fg, bg, FALSE);
        }

        if ((m->child) && (!bar))
            draw_sprite(bmp, menu_arrow_bmp, x+w-12, y+(h-menu_arrow_bmp->h)/2);
    }
    else {
        hline(bmp, x+4, y+text_height(font)/2+2, x+w-4, nshadow);
        hline(bmp, x+4, y+text_height(font)/2+3, x+w-4, highlight);
    }

    if (m->flags & D_SELECTED) {
        line(bmp, x+1, y+text_height(font)/2+1, x+3, y+text_height(font)+1, fg);
        line(bmp, x+3, y+text_height(font)+1, x+6, y+2, fg);
    }
}
コード例 #4
0
ファイル: xskin_loadBMP.c プロジェクト: 1c0n/xbmc
BMPHeader *loadBMPHeader( struct timidity_file *fp ) {

  static BMPHeader h;
  int i;

  /* file header */

  if ( (ugetc(fp) != 'B') || (ugetc(fp) != 'M') ) return NULL;
  h.size = Get4bytes( fp );    /* size */
  if ( h.size < 0 ) return NULL;
  i = Get2bytes( fp );         /* reserved 1 */
  i = Get2bytes( fp );         /* reserved 2 */
  h.offbits = Get4bytes( fp ); /* offbits */
  if ( h.offbits < 0 ) return NULL;


  /* information header */

  h.hsize = Get4bytes( fp );   /* header size */
  if ( h.hsize < 0 ) return NULL;

  if ( h.hsize == 40 ) {
    h.w = Get4bytes( fp );     /* width */
    h.h = Get4bytes( fp );     /* height */
  } else {
    h.w = Get2bytes( fp );     /* width */
    h.h = Get2bytes( fp );     /* height */
  }
  if ( h.h < 0 ) return NULL;

  i = Get2bytes( fp );         /* planes */
  if ( i != 1 ) return NULL;

  h.bitcounts = Get2bytes(fp); /* bit-counts */
  if ( h.bitcounts != 4 && h.bitcounts != 8 && h.bitcounts != 24 ) 
    return NULL;

  if ( h.hsize==40 || h.hsize==64 ) {
    i = Get4bytes( fp );       /* compress */
    h.compress = i;
    h.ncolors = ( h.offbits - h.hsize - 14 ) / 4;
                               /* colors */
  } else {
    h.ncolors = 0;
    h.compress=0;
  }

  return &h;
}
コード例 #5
0
ファイル: devlpr.c プロジェクト: 8l/FUZIX
int lpr_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
{
	int c = udata.u_count;
	char *p = udata.u_base;

	minor;
	rawflag;
	flag;			// shut up compiler

	while (c-- > 0) {
		while (lpstat & 2) {
			if (need_resched()) {
				if (psleep_flags(NULL, flag)) {
					if (udata.u_count)
						udata.u_error = 0;
					return udata.u_count;
				}
			}
		}
		/* Data */
		lpdata = ugetc(p++);
		/* Strobe */
		lpstat |= 1;
		/* FIXME: delay needed */
		lpstat &= ~1;
	}
	return udata.u_count;
}
コード例 #6
0
ファイル: net_z80pack.c プロジェクト: 8l/FUZIX
/*
 *	Write or sendto a socket. We don't yet handle message addresses
 *	sensible and that needs fixing
 */
arg_t net_write(struct socket * s, uint8_t flag)
{
	usize_t n = 0;
	uint8_t p = 0;
	struct sockdata *sd = s->s_priv;
	irqflags_t irq;
	uint8_t st;


	irq = di();
	while (1) {

		netstat = s->s_num;
		st = status(s);

		if (s->s_state == SS_CLOSED || (s->s_iflag & SI_SHUTW)) {
		        udata.u_error = EPIPE;
			break;
                }

		/* Error or EOF */
		if (st & 0xC0)
			break;

		/* Good status after a write means byte ok */
		n += p;
		if (n == udata.u_count) {
		        irqrestore(irq);
			return n;
                }
		/* Can we send more bytes ? */
		p = 0;

		if (st & 2) {
			/* Count bytes sent. The byte we just loaded isn't
			   sent until we check the status of it and it is
			   clean */
			p = 1;
			netdata = ugetc(udata.u_base++);
			continue;
		}
		s->s_iflag |= SI_THROTTLE;
		if (psleep_flags_io(&s->s_iflag, flag, &n)) {
                        irqrestore(irq);
			return n;
                }
                di();
	}
	/* It broke mummy ! */
        irqrestore(irq);
	if (n) {
	        s->s_error = udata.u_error;
	        udata.u_error = 0;
		return n;
        }
	err_xlate(s);
	if (udata.u_error == EPIPE)
		ssig(udata.u_ptab, SIGPIPE);
	return -1;
}
コード例 #7
0
ファイル: xskin_loadBMP.c プロジェクト: 1c0n/xbmc
int Draw4bit( Display *d, Pixmap p, GC gc, BMPHeader *bmp, struct timidity_file *fp ) {

  int x,y;
  int col,col1,col2;
  int pad;

  for ( y=bmp->h ; y>0 ; --y ) {
    pad = ((bmp->w+7)/8)*8;
    for ( x=0 ; x<pad ; x+=2 ) {
      col=ugetc(fp);
      col1=(col>>4)&0x0f;
      col2=col&0x0f;
      if ( col1 >= bmp->ncolors ) col1=0;
      if ( col2 >= bmp->ncolors ) col2=0;
      if ( x<bmp->w-1 ) {
	XSetForeground( d, gc, color_palletes[col1] );
	XDrawPoint( d, p, gc, x, y-1 );
	XSetForeground( d, gc, color_palletes[col2] );
	XDrawPoint( d, p, gc, x+1, y-1 );
      }
    }
  }

  return 0;
}
コード例 #8
0
ファイル: buffer.c プロジェクト: Azarien/open-watcom-v2
/*
 * Perform a write to flush the buffer.
 */
void fl_write( void )
{
        int             err;
        int             nbytes = blocksize;

#ifndef MSDOS
rewrite:
#endif
#if defined(MSDOS) && !defined(__NO_PHYS__)
        if (f_phys)
                err = physwrite(ar_block->charptr, nbytes);
        else
#endif
                err = write(archive, ar_block->charptr, nbytes);
        if (err == nbytes)
                return;
        /* multi-volume support on write -- JER */
        if (err < 0)
                perror(ar_file);
        else
#ifdef MSDOS /* DOS version handles volume change in low-level I/O code */
                fprintf(stderr, "tar: %s: write failed, short %d bytes\n",
                        ar_file, blocksize - err);
#else
        {
                sync(); /* have to flush Minix buffer */
                uprintf(ftty,"\ntar: Volume full.  Change volumes and press [Enter]: ");
                while (ugetc(ftty)!='\n') ;
                nbytes -= err;
                lseek(archive, 0L, 0);
                goto rewrite;
        }
#endif
        exit(EX_BADARCH);
}
コード例 #9
0
ファイル: syscall_exec16.c プロジェクト: erkinalp/FUZIX
bool rargs(char **userspace_argv, struct s_argblk * argbuf)
{
	char *ptr;		/* Address of base of arg strings in user space */
	char *up = (char *)userspace_argv;
	uint8_t c;
	uint8_t *bufp;

	argbuf->a_argc = 0;	/* Store argc in argbuf */
	bufp = argbuf->a_buf;

	while ((ptr = (char *) ugetp(up)) != NULL) {
		up += sizeof(uptr_t);
		++(argbuf->a_argc);	/* Store argc in argbuf. */
		do {
			*bufp++ = c = ugetc(ptr++);
			if (bufp > argbuf->a_buf + 500) {
				udata.u_error = E2BIG;
				return true;	// failed
			}
		}
		while (c);
	}
	argbuf->a_arglen = bufp - (uint8_t *)argbuf->a_buf;	/*Store total string size. */
	return false;		// success
}
コード例 #10
0
ファイル: wsystem.c プロジェクト: dodamn/pkg-allegro4.2
/* sys_directx_message:
 *  Displays a message.
 */
static void sys_directx_message(AL_CONST char *msg)
{
    char *tmp1 = _AL_MALLOC_ATOMIC(ALLEGRO_MESSAGE_SIZE);
    char tmp2[WND_TITLE_SIZE*2];
    HWND allegro_wnd = win_get_window();

    while ((ugetc(msg) == '\r') || (ugetc(msg) == '\n'))
        msg += uwidth(msg);

    MessageBoxW(allegro_wnd,
                (unsigned short *)uconvert(msg, U_CURRENT, tmp1, U_UNICODE, ALLEGRO_MESSAGE_SIZE),
                (unsigned short *)uconvert(wnd_title, U_ASCII, tmp2, U_UNICODE, sizeof(tmp2)),
                MB_OK);

    _AL_FREE(tmp1);
}
コード例 #11
0
ファイル: syscall_exec32.c プロジェクト: EtchedPixels/FUZIX
bool rargs(char **userspace_argv, struct s_argblk * argbuf)
{
	char *ptr;		/* Address of base of arg strings in user space */
	uint8_t c;
	uint8_t *bufp;
	int err;
	void *up = (void *)userspace_argv;

	argbuf->a_argc = 0;	/* Store argc in argbuf */
	bufp = argbuf->a_buf;

	while ((ptr = (char *) ugetp(up, &err)) != NULL) {
		up += sizeof(uptr_t);
		if (err)
			return true;
		++(argbuf->a_argc);	/* Store argc in argbuf. */
		do {
			*bufp++ = c = ugetc(ptr++);
			if (bufp > argbuf->a_buf + ARGBUF_SIZE - 12) {
				udata.u_error = E2BIG;
				return true;	// failed
			}
		}
		while (c);
	}
	/*Store total string size. */
	argbuf->a_arglen = bufp - (uint8_t *)argbuf->a_buf;
	/* Align */
	if (argbuf->a_arglen & 1)
		argbuf->a_arglen++ ;
	/* Success */
	return false;
}
コード例 #12
0
ファイル: pckeys.c プロジェクト: AntonLanghoff/whitecatlib
/* read_keyboard_config:
 *  Reads in the keyboard config tables.
 */
static void read_keyboard_config(void)
{
   char filename[1024], tmp1[128], tmp2[128], *ext, *datafile;
   AL_CONST char* name;

   name = get_config_string(uconvert_ascii("system", tmp1), uconvert_ascii("keyboard", tmp2), _keyboard_layout);

   if ((!name) || (!ugetc(name)))
      return;

   ext = uconvert_ascii(".cfg", tmp1);
   datafile = uconvert_ascii("keyboard.dat", tmp2);

   if (find_allegro_resource(filename, name, ext, datafile, NULL, NULL, NULL, sizeof(filename)) != 0)
      return;

   push_config_state();
   set_config_file(filename);

   read_key_table(custom_key_ascii_table,          standard_key_ascii_table,     "key_ascii");
   read_key_table(custom_key_capslock_table,       standard_key_capslock_table,  "key_capslock");
   read_key_table(custom_key_shift_table,          standard_key_shift_table,     "key_shift");
   read_key_table(custom_key_control_table,        standard_key_control_table,   "key_control");

   /* preserve backward compatibility with former unique key_altgr table */
   read_key_table(custom_key_altgr_lower_table,    standard_key_empty_table,     "key_altgr");
   read_key_table(custom_key_altgr_upper_table,    standard_key_empty_table,     "key_altgr");

   read_key_table(custom_key_altgr_lower_table,    custom_key_altgr_lower_table, "key_altgr_lower");
   read_key_table(custom_key_altgr_upper_table,    custom_key_altgr_upper_table, "key_altgr_upper");

   read_key_table(custom_key_accent1_lower_table,  standard_key_empty_table,     "key_accent1_lower");
   read_key_table(custom_key_accent1_upper_table,  standard_key_empty_table,     "key_accent1_upper");
   read_key_table(custom_key_accent2_lower_table,  standard_key_empty_table,     "key_accent2_lower");
   read_key_table(custom_key_accent2_upper_table,  standard_key_empty_table,     "key_accent2_upper");
   read_key_table(custom_key_accent3_lower_table,  standard_key_empty_table,     "key_accent3_lower");
   read_key_table(custom_key_accent3_upper_table,  standard_key_empty_table,     "key_accent3_upper");
   read_key_table(custom_key_accent4_lower_table,  standard_key_empty_table,     "key_accent4_lower");
   read_key_table(custom_key_accent4_upper_table,  standard_key_empty_table,     "key_accent4_upper");

   _key_accent1 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent1", tmp2), 0);
   _key_accent2 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent2", tmp2), 0);
   _key_accent3 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent3", tmp2), 0);
   _key_accent4 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent4", tmp2), 0);

   _key_accent1_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent1_flag", tmp2), 0);
   _key_accent2_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent2_flag", tmp2), 0);
   _key_accent3_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent3_flag", tmp2), 0);
   _key_accent4_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent4_flag", tmp2), 0);

   pop_config_state();

   set_custom_keyboard();

   update_key_descriptions();
}
コード例 #13
0
ファイル: scanf_flt-nul.c プロジェクト: ChunHungLiu/avr-libc
ssize_t uread (void *cookie, char *buf, size_t size)
{
    size_t n;

    for (n = 0; n < size; n++) {
	int i = ugetc (cookie);
	if (i < 0) break;
	*buf++ = i;
    }
    return n;
}
コード例 #14
0
ファイル: userproc.c プロジェクト: siddhugit/Operating-System
void demoProc1(int argc,char *argv[])
{
	int wfd = svc_open("/lcd",'w');
	if(wfd > 0)
	{
		char buff;
		while((buff = ugetc()) != CHAR_EOF)
		{
			svc_write(wfd,buff);
		}
		svc_close(wfd);
	}
}
コード例 #15
0
ファイル: xskin_loadBMP.c プロジェクト: 1c0n/xbmc
int Draw24bit( Display *d, Pixmap p, GC gc, BMPHeader *bmp, struct timidity_file *fp ) {

  int x,y;
  int r,g,b;
  int pad;
  pad = (4-((bmp->w*3)%4))&0x03;

  for ( y=bmp->h ; y>0 ; --y ) {
    for ( x=0 ; x<bmp->w ; x++ ) {
      b = ugetc(fp)*256;
      g = ugetc(fp)*256;
      r = ugetc(fp)*256;
      if ( r == EOF ) { y=0; break; }
      
      XSetForeground( d, gc, GetColor( d, r, g, b ) );
      XDrawPoint( d, p, gc, x, y-1 ); 
    }
    for ( x=0 ; x<pad ; x++ ) {
      ugetc(fp);
    }
  }
  return 0;
}
コード例 #16
0
ファイル: tty.c プロジェクト: jfernand/FUZIX
int tty_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
{
	struct termios *t;
	int towrite;
	uint8_t c;

	rawflag;
	flag;			// shut up compiler

	/* Minor == 0 means that it is the controlling tty of the process */
	if (!minor)
		minor = udata.u_ptab->p_tty;
	if (!udata.u_ptab->p_tty)
		udata.u_ptab->p_tty = minor;

	t = &ttydata[minor];

	towrite = udata.u_count;

	while (udata.u_count-- != 0) {
		for (;;) {	/* Wait on the ^S/^Q flag */
		        if (deadflag[minor]) {
		                udata.u_error = ENXIO;
		                return -1;
                        }
			if (!stopflag[minor])
				break;
			if (psleep_flags(&stopflag[minor], flag))
				return -1;
		}

		if (!flshflag[minor]) {
			if (udata.u_sysio)
				c = *udata.u_base;
			else
				c = ugetc(udata.u_base);

			if (t->c_oflag & OPOST) {
				if (c == '\n' && (t->c_oflag & ONLCR))
					tty_putc_wait(minor, '\r');
				if (c == '\r' && (t->c_oflag & OCRNL))
					c = '\n';
			}
			tty_putc_wait(minor, c);
		}
		++udata.u_base;
	}
	return towrite;
}
コード例 #17
0
ファイル: jwinfsel.cpp プロジェクト: ZoriaRPG/ZeldaClassic
/* fs_dlist_proc:
  *  Dialog procedure for the file selector disk list.
  */
int fs_dlist_proc(int msg, DIALOG *d, int c)
{
	DIALOG *parent = (DIALOG *)d->dp3;
    char *s = (char *)parent[FS_EDIT].dp;
    int ret, i, temp;
    
    if(msg == MSG_START)
    {
        d->d1 = d->d2 = 0;
        temp = utoupper(ugetc(s));
        
        if(((temp >= 'A') && (temp <= 'Z')) && (ugetat(s, 1) == DEVICE_SEPARATOR))
        {
            temp -= 'A';
            
            for(i=0; i<temp; i++)
                if(_al_drive_exists(i))
                    d->d1++;
        }
    }
    
    ret = jwin_droplist_proc(msg, d, c);
    
    if(ret & D_CLOSE)
    {
        temp = 'A' + get_x_drive(d->d1+1);
        
        if((temp < 'A') || (temp > 'Z'))
            temp = 'C';
            
        s += usetc(s, temp);
        s += usetc(s, DEVICE_SEPARATOR);
        s += usetc(s, OTHER_PATH_SEPARATOR);
        usetc(s, 0);
        
        object_message(parent +FS_FILES, MSG_START, 0);
        object_message(parent +FS_FILES, MSG_DRAW, 0);
        object_message(parent +FS_EDIT, MSG_START, 0);
        object_message(parent +FS_EDIT, MSG_DRAW, 0);
        
        return ret - D_CLOSE + D_O_K;
    }
    
    return ret;
}
コード例 #18
0
ファイル: devlpr.c プロジェクト: EtchedPixels/FUZIX
int lpr_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
{
    char *p = udata.u_base;
    minor; rawflag; flag; // shut up compiler

    while(udata.u_done < udata.u_count) {
        /* Note; on real hardware it might well be necessary to
           busy wait a bit just to get acceptable performance */
        while (lpstat != 0xFF) {
            if (iopoll())
                return udata.u_done;
        }
        /* FIXME: tidy up ugetc and sysio checks globally */
        lpdata = ugetc(p++);
        udata.u_done++;
    }
    return udata.u_done;
}
コード例 #19
0
ファイル: devlpr.c プロジェクト: EtchedPixels/FUZIX
int lpr_write(uint_fast8_t minor, uint_fast8_t rawflag, uint_fast8_t flag)
{
	uint8_t *p = udata.u_base;
	uint8_t *pe = p + udata.u_count;
	int n;
	irqflags_t irq;
	uint8_t buf[2];

	buf[0]=0x50;
	if (minor == 0) {
		while (p < pe) {
			if ((n = iopoll(pe - p)) != 0)
				return n;
			buf[1] = ugetc(p++);
			dw_transaction(buf, 2, NULL, 0, 0);
		}
	} 
	return udata.u_count;
}
コード例 #20
0
ファイル: net_at.c プロジェクト: aralbrec/FUZIX
arg_t net_write(struct socket *s, uint8_t flag)
{
  uint16_t n = 0;

  used(s);
  used(flag);

  while(n < udata.u_count) {
    if (sockets[0].s_state == SS_CLOSED) {
      udata.u_error = EPIPE;
      ssig(udata.u_ptab, SIGPIPE);
      return -1;
    }
    /* FIXME - screen +++ handling ! */
    netat_outbyte(ugetc(udata.u_base++));
    n++;
  }
  return udata.u_count;
}
コード例 #21
0
ファイル: tty.c プロジェクト: aralbrec/FUZIX
int tty_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
{
	struct tty *t;
	usize_t written = 0;
	uint8_t c;

	used(rawflag);
	used(flag);

	t = &ttydata[minor];

	while (udata.u_count-- != 0) {
		for (;;) {	/* Wait on the ^S/^Q flag */
		        if (t->flag & TTYF_DEAD) {
		                udata.u_error = ENXIO;
		                return -1;
                        }
			if (!(t->flag & TTYF_STOP))
				break;
			if (psleep_flags_io(&t->flag, flag, &written))
				return written;
                        jobcontrol_out(minor, t);
		}
		if (!(t->flag & TTYF_DISCARD)) {
			if (udata.u_sysio)
				c = *udata.u_base;
			else
				c = ugetc(udata.u_base);

			if (t->termios.c_oflag & OPOST) {
				if (c == '\n' && (t->termios.c_oflag & ONLCR))
					tty_putc_wait(minor, '\r');
				else if (c == '\r' && (t->termios.c_oflag & OCRNL))
					c = '\n';
			}
			tty_putc_wait(minor, c);
		}
		++udata.u_base;
		++written;
	}
	return written;
}
コード例 #22
0
ファイル: commands.c プロジェクト: siddhugit/Operating-System
static int cmd_ser2lcd(int argc, char *argv[])
{
	if(argc > 1)
	{
		my_errno = TOO_MANY_ARGUMENTS;
		return 1;
	}
	int wfd = svc_open("/lcd",'w');
	if(wfd > 0)
	{
		char buff;
		while((buff = ugetc()) != CHAR_EOF)
		{
			svc_write(wfd,buff);
		}
		svc_close(wfd);
		return 0;
	}
	return 1;
}
コード例 #23
0
ファイル: rfsel.c プロジェクト: albinoz/raine
/* fs_dlist_proc:
 *  Dialog procedure for the file selector disk list.
 */
static int fs_dlist_proc(int msg, DIALOG *d, int c)
{
   char *s = file_selector[FS_EDIT].dp;
   int ret, i, temp;

   if (msg == MSG_START) {
      d->d1 = d->d2 = 0;
      temp = utoupper(ugetc(s));
      if (((temp >= 'A') && (temp <= 'Z')) && (ugetat(s, 1) == DEVICE_SEPARATOR)) {
	 temp -= 'A';
	 for (i=0; i<temp; i++)
	    if (drive_exists(i))
	       d->d1++;
      }
   }

   ret = d_text_list_proc(msg, d, c);

   if (ret == D_CLOSE) {
      temp = 'A' + get_x_drive(d->d1+1);
      if ((temp < 'A') || (temp > 'Z'))
	 temp = 'C';

      s += usetc(s, temp);
      s += usetc(s, DEVICE_SEPARATOR);
      s += usetc(s, OTHER_PATH_SEPARATOR);
      usetc(s, 0);

      scare_mouse();
      SEND_MESSAGE(file_selector+FS_FILES, MSG_START, 0);
      SEND_MESSAGE(file_selector+FS_FILES, MSG_DRAW, 0);
      SEND_MESSAGE(file_selector+FS_EDIT, MSG_START, 0);
      SEND_MESSAGE(file_selector+FS_EDIT, MSG_DRAW, 0);
      unscare_mouse();

      return D_O_K;
   }

   return ret;
}
コード例 #24
0
ファイル: tty.c プロジェクト: jfernand/FUZIX
int pty_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
{
	uint16_t nwritten;
	minor += PTY_OFFSET;

	while (nwritten < udata.u_count) {
		if (udata.u_sysio)
			c = udata.u_base;
		else
			c = ugetc(udata.u_base);
		if (tty_inproc(minor, c)) {
			nwritten++;
			udata.u_count++;
			continue;
		}
		if (nwritten == 0
		    && psleep_flags(&ttyinq[minor].q_count, flag))
			return -1;
	}

	return nwritten;
}
コード例 #25
0
ファイル: xskin_loadBMP.c プロジェクト: 1c0n/xbmc
int Draw8bit( Display *d, Pixmap p, GC gc, BMPHeader *bmp, struct timidity_file *fp ) {

  int x,y;
  int col;
  int pad;

  for ( y=bmp->h ; y>0 ; --y ) {
    pad = ((bmp->w+3)/4)*4;
    for ( x=0 ; x<pad ; x++ ) {
      col = ugetc(fp);
      if ( col == EOF ) { y=0; break; }
      if ( col >= bmp->ncolors ) col=0;
      
      if ( x<bmp->w ) {
	XSetForeground( d, gc, color_palletes[col] );
	XDrawPoint( d, p, gc, x, y-1 ); 
      }
    }
  }

  return 0;
}
コード例 #26
0
ファイル: xskin_loadBMP.c プロジェクト: 1c0n/xbmc
Bool loadBMPColors( Display *d, BMPHeader *h, struct timidity_file *fp ) {

  int i;
  int r,g,b;

  if ( iscolorinited==0 ) {
    iscolorinited=1;
    for ( r=0 ; r<8 ; r++ ) {
      for ( g=0 ; g<8 ; g++ ) {
	for ( b=0 ; b<8 ; b++ ) {
	  cols[r][g][b]=-1;
	}
      }
    }
  }
  
  tf_seek( fp, h->hsize+14, SEEK_SET );
  if ( h->ncolors == 0 ) return True;

  if ( h->hsize==40 || h->hsize==64 ) {
    for ( i=0 ; i<h->ncolors ; i++ ) {
      b = ugetc(fp)*256;
      g = ugetc(fp)*256;
      r = ugetc(fp)*256;
      if ( ugetc(fp)==EOF ) return False;
	  
      color_palletes[i] = GetColor( d, r, g, b );
    }
  } else {
    for ( i=0 ; i<h->ncolors ; i++ ) {
      b = ugetc(fp)*256;
      g = ugetc(fp)*256;
      r = ugetc(fp)*256;
      if ( r==EOF ) return False;

      color_palletes[i] = GetColor( d, r, g, b );
    }
  }

  return True;
}
コード例 #27
0
ファイル: devlpr.c プロジェクト: EtchedPixels/FUZIX
int lpr_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
{
    used(minor);
    used(rawflag);

    /* Unusually for an 8bit micro  the MicroBee has interrupt driven
       parallel managed via the Z80PIOA. It's not always used for a printer
       so we do need to fix interactions if we add other devices for that
       port and interlock them */
    while(udata.u_done < udata.u_count) {
        /* Avoid IRQ race */
        irqflags_t irq = di();
        if (!lpready && psleep_flags_io(&lpready, flag)) {
            irqrestore(irq);
            break;
        }
        irqrestore(irq);
        lpready = 0;
        lpdata = ugetc(udata.u_base++);
        udata.u_done++;
    }
    return udata.u_done;
}
コード例 #28
0
ファイル: syscall_fs2.c プロジェクト: NoSuchProcess/FUZIX
arg_t _access(void)
{
	inoptr ino;
	uint16_t euid;
	uint16_t egid;
	int16_t retval;

	if ((mode & 07) && !ugetc(path)) {
		udata.u_error = ENOENT;
		return (-1);
	}

	/* Temporarily make eff. id real id. */
	euid = udata.u_euid;
	egid = udata.u_egid;
	udata.u_euid = udata.u_ptab->p_uid;
	udata.u_egid = udata.u_gid;

	if (!(ino = n_open(path, NULLINOPTR))) {
		retval = -1;
		goto nogood;
	}

	retval = 0;
	if (~getperm(ino) & (mode & 07)) {
		udata.u_error = EACCES;
		retval = -1;
	}

	i_deref(ino);
      nogood:
	udata.u_euid = euid;
	udata.u_egid = egid;

	return (retval);
}
コード例 #29
0
/* jwin_file_select_ex:
  *  Displays the JWin file selector, with the message as caption.
  *  Allows the user to select a file, and stores the selection in the
  *  path buffer, whose length in bytes is given by size and should have
  *  room for at least 80 characters. The files are filtered according to
  *  the file extensions in ext. Passing NULL includes all files, "PCX;BMP"
  *  includes only files with .PCX or .BMP extensions. Returns zero if it
  *  was closed with the Cancel button or non-zero if it was OK'd.
  */
int jwin_file_select_ex(AL_CONST char *message, char *path, AL_CONST char *ext, int size, int width, int height, FONT *title_font)
{
    static attrb_state_t default_attrb_state[ATTRB_MAX] = DEFAULT_ATTRB_STATE;
    int ret;
    char *p;
    char tmp[32];
    ASSERT(message);
    ASSERT(path);
    
    if(title_font)
    {
        file_selector[0].dp2=title_font;
    }
    
    if(width == OLD_FILESEL_WIDTH)
        width = 304;
        
#ifdef HAVE_DIR_LIST
        
    if(height == OLD_FILESEL_HEIGHT)
        height = 160;
        
#else
        
    if(height == OLD_FILESEL_HEIGHT)
        height = 188;
        
#endif
        
    /* for fs_dlist_proc() */
    ASSERT(size >= 4 * uwidth_max(U_CURRENT));
    
    usetc(updir, 0);
    file_selector[FS_WIN].dp = (char *)message;
    file_selector[FS_EDIT].d1 = size/uwidth_max(U_CURRENT) - 1;
    file_selector[FS_EDIT].dp = path;
    file_selector[FS_OK].dp = (void*)get_config_text("OK");
    file_selector[FS_CANCEL].dp = (void*)get_config_text("Cancel");
    
    /* Set default attributes. */
    memcpy(attrb_state, default_attrb_state, sizeof(default_attrb_state));
    
    /* Parse extension string. */
//  if (ext)// && ugetc(ext))
    {
        parse_extension_string(ext);
    }
    
    if(!ugetc(path))
    {
    
#ifdef HAVE_DIR_LIST
    
        int drive = _al_getdrive();
        
#else
        
        int drive = 0;
#endif
        
        _al_getdcwd(drive, path, size - ucwidth(OTHER_PATH_SEPARATOR));
        fix_filename_case(path);
        fix_filename_slashes(path);
        put_backslash(path);
    }
    
    clear_keybuf();
    
    do
    {
    }
    while(gui_mouse_b());
    
    file_selector[FS_TYPES].proc = fs_dummy_proc;
    enlarge_file_selector(width, height);
    ret = popup_zqdialog(file_selector, FS_EDIT);
    
    if(fext)
    {
        zc_free(fext);
        fext = NULL;
    }
    
    if(fext_p)
    {
        _al_free(fext_p);
        fext_p = NULL;
    }
    
    if((ret == FS_CANCEL) || (ret == FS_WIN) || (!ugetc(get_filename(path))))
        return FALSE;
        
    p = get_extension(path);
    
    if((!ugetc(p)) && (ext) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp))))
    {
        size -= ((long)(size_t)p - (long)(size_t)path + ucwidth('.'));
        
        if(size >= uwidth_max(U_CURRENT) + ucwidth(0))          /* do not end with '.' */
        {
            p += usetc(p, '.');
            ustrzcpy(p, size, ext);
        }
    }
    
    return TRUE;
}
コード例 #30
0
/* parse_extension_string:
  *  Parses the extension string, possibly containing attribute characters.
  */
static void parse_extension_string(AL_CONST char *ext)
{
    attrb_state_t state;
    char ext_tokens[32], attrb_char[32];
    char *last, *p, *attrb_p;
    int c, c2, i;
    
    i = 0;
    fext_size = 0;
    fext_p = NULL;
    attrb_p = NULL;
    
    if(!ext)
        return;
        
    fext = ustrdup(ext);
    
    /* Tokenize the extension string and record the pointers to the
      * beginning of each token in a dynamically growing array.
      * ???? We rely on the implementation of ustrtok_r() which writes
      * null characters in the string to delimit the tokens. Yuck.
      */
    c = usetc(ext_tokens, ' ');
    c += usetc(ext_tokens+c, ',');
    c += usetc(ext_tokens+c, ';');
    usetc(ext_tokens+c, 0);
    
    p = ustrtok_r(fext, ext_tokens, &last);
    
    if(p == NULL || !ugetc(p))
        return;
        
    do
    {
        /* Set of attribute characters. */
        if(ugetc(p) == '/')
        {
            attrb_p = p + ucwidth('/');
            continue;
        }
        
        /* Dynamically grow the array if needed. */
        if(i >= fext_size)
        {
            fext_size = (fext_size ? fext_size*2 : 2);
            fext_p = (char **)_al_sane_realloc(fext_p, fext_size * sizeof(char *));
        }
        
        /* Record a pointer to the beginning of the token. */
        fext_p[i++] = p;
        
    }
    while((p = ustrtok_r(NULL, ext_tokens, &last))!=NULL);
    
    /* This is the meaningful size now. */
    fext_size = i;
    
    if(attrb_p)
    {
        state = ATTRB_SET;
        c = usetc(attrb_char, 'r');
        c += usetc(attrb_char+c, 'h');
        c += usetc(attrb_char+c, 's');
        c += usetc(attrb_char+c, 'd');
        c += usetc(attrb_char+c, 'a');
        c += usetc(attrb_char+c, '+');
        c += usetc(attrb_char+c, '-');
        usetc(attrb_char+c, 0);
        
        /* Scan the string. */
        while((c = utolower(ugetx(&attrb_p)))!=0)
        {
            p = attrb_char;
            
            for(i = 0; (c2 = ugetx(&p))!=0; i++)
            {
                if(c == c2)
                {
                    if(i < ATTRB_MAX)
                        attrb_state[i] = state;
                    else
                        state = (i == ATTRB_MAX) ? ATTRB_SET : ATTRB_UNSET;
                        
                    break;
                }
            }
        }
    }
}