inline void write_Int(int n)
 {
     if(n<0)
     {
         write_char('-');
         write_flush();
         n *= (-1);
     }
     write_int(n);
 }
示例#2
0
文件: UmlCom.cpp 项目: DoUML/douml
void UmlCom::send_cmd(const void * id, OnInstanceCmd cmd, const UmlTypeSpec & arg)
{
#ifdef TRACE
  qDebug() << "UmlCom::send_cmd(id, " << cmd << ", UmlTypeSpec)\n";
#endif
  
  write_char(onInstanceCmd);
  write_id(id);
  write_char(cmd);
  if (arg.type) {
    write_id(arg.type->_identifier);
    write_string("");
  }
  else {
    write_id(0);
    write_string(arg.explicit_type);
  }
  flush();
}
示例#3
0
void write_text(MPL *mpl, char *fmt, ...)
{     va_list arg;
      char buf[OUTBUF_SIZE], *c;
      va_start(arg, fmt);
      vsprintf(buf, fmt, arg);
      xassert(strlen(buf) < sizeof(buf));
      va_end(arg);
      for (c = buf; *c != '\0'; c++) write_char(mpl, *c);
      return;
}
示例#4
0
文件: UmlCom.cpp 项目: DoUML/douml
void UmlCom::send_cmd(const void * id, OnInstanceCmd cmd, const QVector<UmlClass*> & l)
{
#ifdef TRACE
    qDebug() << "UmlCom::send_cmd(id, " << cmd << ", const QVector<UmlClass*> & l)\n";
#endif

    write_char(onInstanceCmd);
    write_id(id);
  write_char(cmd);
  
  unsigned n = l.count();
  
  write_unsigned(n);
  
  for (unsigned i = 0; i != n; i += 1)
    write_id(((UmlBaseItem *) l[i])->_identifier);
  
  flush();
}
示例#5
0
static void		write_char(int key, t_line *line)
{
  if (key >= 256)
    {
      write_char(key % 256, line);
      write_char(key / 256, line);
    }
  else if (key != '\n')
    {
      if (line->line_len >= (BUFF_LINE * line->realloc_cpt))
	line_realloc(line);
      add_char_in_tab(key, line->line, line->pos);
      CAP("nd");
      line->pos++;
      line->line_len++;
      (line->line_len % get_cols()) == 0 ? clear_scr(line) :
	clear_and_display(line);
    }
}
示例#6
0
static void write_ccc(struct bt_scpp *scan, GAttrib *attrib, uint16_t handle,
								void *user_data)
{
	uint8_t value[2];

	put_le16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);

	write_char(scan, attrib, handle, value, sizeof(value), ccc_written_cb,
								user_data);
}
示例#7
0
bool wp_write(char ch)
{
	int		i;
	bool	ok;

	if ((ch == TAB) || (ch == ' '))
	{
		if (proportional)
		{
			if  (ch == ' ')
			{
				char_pos++;
				nr_spaces++;
			}
			else
			{
				char_pos += tab_size;
				nr_spaces += tab_size;
			}
		}
		else
		{
		  	if (ch == ' ')
				ok = write_char(' ');
			else
			 	for (i = 1; i <= tab_size; i++)
					ok = write_char(' ');
		}
	}
	else
	{
		if (nr_spaces > 1)
			ok = set_head();
		else if (nr_spaces == 1)
		{
			ok = write_char(' ');
			nr_spaces = 0;
		}
		ok = write_char(ch);
	}
	return ok;
}
void temperature_timer_interrupt (void)
{

	char buf[16];
	u08 i;
	short temperature;

	if(conf->current_sector > mmcSectorCount) {
		cbi(PORTA,PA0);
		return;
	}
	else {
		sbi(PORTA,PA0);
	}

  
	do {
		temperature = read_temperature();
	} while(temperature>>TEMPERATURE_POINT < -200);

	// Format temperature.
	format_temperature(buf, temperature);
	for (i = 0; buf[i] != '.'; i++);
	if (buf[i + 2] >= '5')
		buf[i + 1]++;
	buf[i + 2] = '\0';

	//cbi(PORTA, PA0);
	if (mmc_buf_i != 0 || conf->current_sector != START_SECTOR)
		write_char('\n');

	for (i = 0; buf[i] != '\0'; i++)
		write_char(buf[i]);

	write_char('\0');
	mmc_buf_i--;

	// Write to sector.
	mmcWrite(conf->current_sector, mmc_buf);

	//sbi(PORTA, PA0);
}
示例#9
0
// TODO: Ugly, might want to revisit this ...
int ulcd_sd_list(ulcd_dev *dev, const char *filter, char *buffer, int buflen) {
    // Commands
    write_char(dev, 0x40);
    write_char(dev, 0x64);
    serial_write(dev->port, filter, strlen(filter));
    write_char(dev, 0x00);

    // Some vars
    int run = 1;
    int pos = 0;
    char last = 0;
    char in;

    // Get much data! MMMMmmmm.... daaaataaaaa....
    while(run) {
        if(pos > buflen) {
            sprintf(errorstr, "Directory listing too long.");
            break;
        }

        in = read_char(dev);
        if(in == 0x06 && last == 0) {
            return pos;
        }
        if(in == 0x06 && last == 0x0A) {
            return pos;
        }
        if(in == 0x15 && (last == 0x0A || last == 0)) {
            sprintf(errorstr, "Directory listing failed.");
            return pos;
        }
        if(in == 0x0A) {
            buffer[pos++] = ',';
            last = in;
            continue;
        }
        buffer[pos++] = in;
        last = in;
    }

    return pos;
}
示例#10
0
文件: UmlCom.cpp 项目: hl037/douuml
void UmlCom::send_cmd(const void * id, OnInstanceCmd cmd, unsigned int arg1, const UmlTypeSpec & arg2)
{
#ifdef TRACE
    cout << "UmlCom::send_cmd(id, " << cmd << ", " << arg1 << ", UmlTypeSpec)\n";
#endif

    write_char(onInstanceCmd);
    write_id(id);
    write_char(cmd);
    write_unsigned(arg1);
    if (arg2.type) {
        write_id(arg2.type->_identifier);
        write_string("");
    }
    else {
        write_id(0);
        write_string(arg2.explicit_type);
    }
    flush();
}
示例#11
0
文件: glpmpl4.c 项目: ecotox/pacfm
void close_output(MPL *mpl)
{     insist(mpl->out_fp != NULL);
      if (mpl->out_cnt > 0) write_char(mpl, '\n');
      if (mpl->out_fp != stdout) ufclose(mpl->out_fp);
      ufree(mpl->out_buf);
      mpl->out_fp = NULL;
      mpl->out_file = NULL;
      mpl->out_buf = NULL;
      mpl->out_cnt = 0;
      return;
}
示例#12
0
static void
write_string (const char * s)
{
  while (1)
    {
      char c = (*s++);
      if (c == '\0')
	break;
      write_char (c);
    }
}
示例#13
0
void generic_terminal_device::term_write(uint8_t data)
{
	if (data > 0x1f)
	{
		// printable char
		if (data != 0x7f) write_char(data);
	}
	else
	{
		const uint16_t options = m_io_term_conf->read();
		switch(data)
		{
		case 0x07: // bell
			m_beeper->set_state(1);
			m_bell_timer->reset(attotime::from_msec(250));
			break;

		case 0x08: // backspace
			if (m_x_pos) m_x_pos--;
			break;

		case 0x09: // horizontal tab
			m_x_pos = (std::min<uint8_t>)((m_x_pos & 0xf8) + 8, TERMINAL_WIDTH - 1);
			break;

		case 0x0d: // carriage return
			m_x_pos = 0;
			if (!(options & 0x080)) break;

		case 0x0a: // linefeed
			m_y_pos++;
			if (m_y_pos >= TERMINAL_HEIGHT)
			{
				scroll_line();
				m_y_pos = TERMINAL_HEIGHT - 1;
			}
			if (options & 0x040) m_x_pos = 0;
			break;

		case 0x0b: // vertical tab
			if (m_y_pos) m_y_pos--;
			break;

		case 0x0c: // form feed
			clear();
			break;

		case 0x1e: // record separator
			m_x_pos = 0;
			m_y_pos = 0;
			break;
		}
	}
}
示例#14
0
void flush_output(MPL *mpl)
{     insist(mpl->out_fp != NULL);
      if (mpl->out_cnt > 0) write_char(mpl, '\n');
      if (mpl->out_fp != stdout)
      {  fflush(mpl->out_fp);
         if (ferror(mpl->out_fp))
            error(mpl, "write error on %s - %s", mpl->out_file,
               strerror(errno));
      }
      return;
}
示例#15
0
/******************************************************************
 *		write_block
 *
 * WriteConsoleOutput helper: writes a block of non special characters
 * Block can spread on several lines, and wrapping, if needed, is
 * handled
 *
 */
static int     	write_block(HANDLE hCon, CONSOLE_SCREEN_BUFFER_INFO* csbi,
			    DWORD mode, LPWSTR ptr, int len)
{
    int	blk;	/* number of chars to write on current line */

    if (len <= 0) return 1;

    if (mode & ENABLE_WRAP_AT_EOL_OUTPUT) /* writes remaining on next line */
    {
        int     done;

        for (done = 0; done < len; done += blk)
        {
            blk = min(len - done, csbi->dwSize.X - csbi->dwCursorPosition.X);

            if (write_char(hCon, ptr + done, blk, &csbi->dwCursorPosition) != blk)
                return 0;
            if (csbi->dwCursorPosition.X == csbi->dwSize.X && !next_line(hCon, csbi))
                return 0;
        }
    }
    else
    {
        blk = min(len, csbi->dwSize.X - csbi->dwCursorPosition.X);

        if (write_char(hCon, ptr, blk, &csbi->dwCursorPosition) != blk)
            return 0;
        if (blk < len)
        {
            csbi->dwCursorPosition.X = csbi->dwSize.X - 1;
            /* all remaining chars should be written on last column,
             * so only overwrite the last column with last char in block
             */
            if (write_char(hCon, ptr + len - 1, 1, &csbi->dwCursorPosition) != 1)
                return 0;
            csbi->dwCursorPosition.X = csbi->dwSize.X - 1;
        }
    }

    return 1;
}
示例#16
0
static void debug_print_hash_elements(lref_t obj, lref_t port, bool machine_readable)
{
     assert(HASHP(obj));

     fixnum_t count = 0;

     lref_t key, val;

     hash_iter_t ii;
     hash_iter_begin(obj, &ii);
     while (hash_iter_next(obj, &ii, &key, &val))
     {
          count++;

          write_char(port, _T(' '));

          debug_print_object(key, port, machine_readable);
          write_char(port, _T(' '));
          debug_print_object(val, port, machine_readable);
     }
}
示例#17
0
// CEA-608, Anex F 1.1.1. - Character Set Table / Special Characters
void handle_double(const unsigned char c1, const unsigned char c2, ccx_decoder_608_context *context)
{
	unsigned char c;
	if (context->channel != context->my_channel)
		return;
	if (c2>=0x30 && c2<=0x3f)
	{
		c=c2 + 0x50; // So if c>=0x80 && c<=0x8f, it comes from here
		ccx_common_logging.debug_ftn(CCX_DMT_DECODER_608, "\rDouble: %02X %02X  -->  %c\n", c1, c2, c);
		write_char(c, context);
	}
}
示例#18
0
static void debug_print_hash(lref_t obj, lref_t port, bool machine_readable)
{
     assert(HASHP(obj));

     WRITE_TEXT_CONSTANT(port, _T("{"));

     /* REVISIT: Print shallow flag? */

     debug_print_hash_elements(obj, port, machine_readable);

     write_char(port, '}');
}
void write_int(int num) 
{
	idata char buf[32]; 
	char *pbuf = buf; 
	int bytes, cnt; 
	init_lcd(); 
	clear_lcd(); 
	bytes = 0;
	bytes += sprintf(buf + bytes, "U = %3.2f",5*(num/255.0));  
	for (cnt = 0; cnt < bytes; cnt++) 
	     write_char(pbuf++);
}
示例#20
0
void do_syscall(TrapFrame *tf)
{
    switch(tf->eax) {
        /* The ``add_irq_handle'' system call is artificial. We use it to
         * let user program register its interrupt handlers. But this is
         * very dangerous in a real operating system. Therefore such a
         * system call never exists in GNU/Linux.
         */
        case 0: add_irq_handle(tf->ebx, (void*)tf->ecx); break;

        case SYS_brk: sys_brk(tf); break;

        /* TODO: Add more system calls. */

        case SYS_write:
                      tf->eax = fs_write(
                              tf->ebx,
                              (void *)(tf->ecx),
                              tf->edx);
                      break;
        case SYS_open:
                      tf->eax = fs_open((char *)tf->ebx, tf->ebx);
                      break;
        case SYS_read:
                      tf->eax = fs_read(
                              tf->ebx,
                              (void *)(tf->ecx),
                              tf->edx);
                      break;
        case SYS_lseek:
                      tf->eax = fs_lseek(tf->ebx, tf->ecx, tf->edx);
                      break;
        case SYS_close:
                      tf->eax = fs_close(tf->ebx);
                      break;

        case WRITE_INT:
                        write_int((int)(tf->ebx));
                        break;
        case READ_INT:
                        tf->eax = read_int((char *)(tf->ebx));
                        break;
        case WRITE_C:
                        write_char(tf->ebx);
                        break;
        case READ_C:
                        tf->eax = read_char();
                        break;
        default:
                      panic("Unhandled system call: id = %d", tf->eax);
    }
}
示例#21
0
static void
vidc_rawputchar(int c)
{
    int		i;

    if (c == '\t')
	/* lame tab expansion */
	for (i = 0; i < 8; i++)
	    vidc_rawputchar(' ');
    else {
	/* Emulate AH=0eh (teletype output) */
	switch(c) {
	case '\a':
	    beep();
	    return;
	case '\r':
	    curx = 0;
	    curs_move(curx, cury);
	    return;
	case '\n':
	    cury++;
	    if (cury > 24) {
		scroll_up(1, fg_c, bg_c);
		cury--;
	    } else {
		curs_move(curx, cury);
	    }
	    return;
	case '\b':
	    if (curx > 0) {
		curx--;
		curs_move(curx, cury);
		/* write_char(' ', fg_c, bg_c); XXX destructive(!) */
		return;
	    }
	    return;
	default:
	    write_char(c, fg_c, bg_c);
	    curx++;
	    if (curx > 79) {
		curx = 0;
		cury++;
	    }
	    if (cury > 24) {
		curx = 0;
		scroll_up(1, fg_c, bg_c);
		cury--;
	    }
	}
	curs_move(curx, cury);
    }
}
示例#22
0
void bfm_bd1_t::shift_data(int data)
{
	m_shift_data <<= 1;

	if ( !data ) m_shift_data |= 1;

	if ( ++m_shift_count >= 8 )
	{
		write_char(m_shift_data);
		m_shift_count = 0;
		m_shift_data  = 0;
	}
}
示例#23
0
文件: console.c 项目: blm768/arm-os
void write(char* str) {
	size_t i = 0;
	char c = str[0];
	while(c != '\0') {
		if(c == '\n') {
			write_newline();
		} else {
			write_char(c);
		}
		++i;
		c = str[i];
	}
}
示例#24
0
static void
mangle_line (const char * line, const char * prefix)
{
  const char * scan = (skip_name (line));
  scan = (skip_lws (scan));
  scan = (skip_fixed (scan, '('));
  scan = (skip_lws (scan));
  scan = (skip_fixed (scan, '"'));
  write_string (prefix);
  write_string (scan);
  write_char ('\n');
  fflush (stdout);
}
示例#25
0
文件: console.c 项目: sharkcz/skiboot
ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
{
	/* We use recursive locking here as we can get called
	 * from fairly deep debug path
	 */
	bool need_unlock = lock_recursive(&con_lock);
	const char *cbuf = buf;

	while(count--) {
		char c = *(cbuf++);
		if (c == 10)
			write_char(13);
		write_char(c);
	}

	__flush_console(flush_to_drivers);

	if (need_unlock)
		unlock(&con_lock);

	return count;
}
示例#26
0
		int bencode_recursive(OutIt& out, const entry& e)
		{
			int ret = 0;
			switch(e.type())
			{
			case entry::int_t:
				write_char(out, 'i');
				ret += write_integer(out, e.integer());
				write_char(out, 'e');
				ret += 2;
				break;
			case entry::string_t:
				ret += write_integer(out, e.string().length());
				write_char(out, ':');
				ret += write_string(e.string(), out);
				ret += 1;
				break;
			case entry::list_t:
				write_char(out, 'l');
				for (entry::list_type::const_iterator i = e.list().begin(); i != e.list().end(); ++i)
					ret += bencode_recursive(out, *i);
				write_char(out, 'e');
				ret += 2;
				break;
			case entry::dictionary_t:
				write_char(out, 'd');
				for (entry::dictionary_type::const_iterator i = e.dict().begin();
					i != e.dict().end(); ++i)
				{
					// write key
					ret += write_integer(out, i->first.length());
					write_char(out, ':');
					ret += write_string(i->first, out);
					// write value
					ret += bencode_recursive(out, i->second);
					ret += 1;
				}
				write_char(out, 'e');
				ret += 2;
				break;
			case entry::undefined_t:
				// trying to encode a structure with uninitialized values!
//				TORRENT_ASSERT_VAL(false, e.type());
				// do nothing
				break;
			}
			return ret;
		}
示例#27
0
static void		print_ox(t_dt *data, t_av *av)
{
	size_t		len;
	int			print;
	size_t		precision;

	len = (data->flag.precision > av->len) ? data->flag.precision : av->len;
	if (data->flag.hash && av->ui)
		len += 2;
	print = data->flag.zero && !data->flag.precision;
	if (data->flag.hash && av->ui && data->flag.zero && print)
		write_str(data, (*data->tail == 'x') ? "0x" : "0X", 2);
	if (!data->flag.minus)
	{
		while (data->flag.min_width > len && data->flag.min_width--)
			write_char(data, (print) ? '0' : ' ');
	}
	if (data->flag.hash && av->ui && !print)
		write_str(data, (*data->tail == 'x') ? "0x" : "0X", 2);
	precision = data->flag.precision;
	while (precision > av->len && precision--)
		write_char(data, '0');
}
示例#28
0
int con_write(struct tty_struct *tty)
{
	char ch;
	int res = 0;
	cur_console = tty-tty_table-1;
	irq_lock();
	while (!isempty(tty->out)) {
		GETCH(tty->out, ch);
		if (ch == '\033') {
			char tmp_x = 0, tmp_y = 0;
			while (1) {
				GETCH(tty->out, ch);
				if (ch >= '0' && ch <= '9')
					tmp_x = tmp_x * 10 + ch - '0';
				else
					break;
			}
			if (ch == ';') {
				while (1) {
					GETCH(tty->out, ch);
					if (ch >= '0' && ch <= '9')
						tmp_y = tmp_y * 10 + ch - '0';
					else
						break;
				}
			}
			if (ch == 'P') {
				if (tmp_x >= 80)
					x = 79;
				else
					x = tmp_x;
				if (tmp_y >= 25)
					x = 24;
				else
					y = tmp_y;
			} else if (ch == 'C')
				color = ((tmp_x << 4) & 0xf0) | (tmp_y & 0xf);
			else if (ch=='E')
				__echo__=0;
			else if (ch=='e')
				__echo__=1;
		} else
			write_char(ch);
		res++;
	}
	if (fg_console == cur_console)
		set_cur();
	irq_unlock();
	return res;
}
示例#29
0
void rocvfd_t::shift_data(int data)
{
	m_shift_data <<= 1;

	if ( !data ) m_shift_data |= 1;

	if ( ++m_shift_count >= 8 )
	{
		write_char(m_shift_data);
		m_shift_count = 0;
		m_shift_data  = 0;
	}
	update_display();
}
示例#30
0
文件: write.c 项目: icicle99/Gauche
/* If OBJ is a primitive object (roughly, immediate or number), write it to
   PORT.  Assumes the caller locks the PORT.
   Returns the # of characters written, or #f if OBJ is not a primitive object.
 */
ScmObj Scm__WritePrimitive(ScmObj obj, ScmPort *port, ScmWriteContext *ctx)
{
    const ScmWriteControls *wp = Scm_GetWriteControls(ctx, port->writeState);
    
#define CASE_ITAG_RET(obj, str)                 \
    case SCM_ITAG(obj):                         \
        Scm_PutzUnsafe(str, -1, port);          \
        return SCM_MAKE_INT(sizeof(str)-1);

    if (SCM_IMMEDIATEP(obj)) {
        switch (SCM_ITAG(obj)) {
            CASE_ITAG_RET(SCM_FALSE,     "#f");
            CASE_ITAG_RET(SCM_TRUE,      "#t");
            CASE_ITAG_RET(SCM_NIL,       "()");
            CASE_ITAG_RET(SCM_EOF,       "#<eof>");
            CASE_ITAG_RET(SCM_UNDEFINED, "#<undef>");
            CASE_ITAG_RET(SCM_UNBOUND,   "#<unbound>");
        default:
            Scm_Panic("write: unknown itag object: %08x", SCM_WORD(obj));
        }
    }
    else if (SCM_INTP(obj) && wp->printBase == 10 && !wp->printRadix) {
        /* Shortcut to avoid allocation */
        char buf[SPBUFSIZ];
        int k = snprintf(buf, SPBUFSIZ, "%ld", SCM_INT_VALUE(obj));
        Scm_PutzUnsafe(buf, -1, port);
        return SCM_MAKE_INT(k);
    }
    else if (SCM_CHARP(obj)) {
        size_t k = write_char(SCM_CHAR_VALUE(obj), port, ctx);
        return SCM_MAKE_INT(k);
    }
    else if (SCM_NUMBERP(obj)) {
        ScmNumberFormat fmt;
        Scm_NumberFormatInit(&fmt);
        fmt.radix = wp->printBase;
        if (wp->printRadix) fmt.flags |= SCM_NUMBER_FORMAT_ALT_RADIX;
        return SCM_MAKE_INT(Scm_PrintNumber(port, obj, &fmt));
    }
    /* PVREF only appears in pattern temlate in the current macro expander.
       It will be go away once we rewrite the expander. */
    else if (SCM_PVREF_P(obj)) {
        char buf[SPBUFSIZ];
        int k = snprintf(buf, SPBUFSIZ, "#<pvar %ld.%ld>",
                         SCM_PVREF_LEVEL(obj), SCM_PVREF_COUNT(obj));
        Scm_PutzUnsafe(buf, -1, port);
        return SCM_MAKE_INT(k);
    }
    return SCM_FALSE;
}