예제 #1
0
파일: common.c 프로젝트: comex/fastdbg
void tjson_newline(struct tjson *tj) {
    assert(tj->indent < 1000000);
    _putc('\n', tj->fp);
    size_t nspaces = tj->indent * 2;
    for (size_t i = 0; i < nspaces; i++)
        _putc(' ', tj->fp);
}
예제 #2
0
파일: devtty.c 프로젝트: chettrick/uzics
int
tty_write(int16 minor, int16 rawflag)
{
	int towrite;

	towrite = udata.u_count;

	while (udata.u_count-- != 0) {
		/* Wait on the ^S/^Q flag. */
		for (;;) {
			di();
			ifnot (stopflag)    
				break;
			psleep(&stopflag);
			/* XXX - messy */
			if (udata.u_cursig || udata.u_ptab->p_pending) {
				udata.u_error = EINTR;
				return (-1);
			}
		}
		ei();   
		ifnot (flshflag) {
			if (*udata.u_base == '\n')
				_putc('\r');
			_putc(*udata.u_base);
		}
		++udata.u_base;
	}
	return (towrite);
}
예제 #3
0
파일: uart.c 프로젝트: kcoewoys/work
void _puts(char *str)
{
	while(*str != '\0')
	{
		_putc(*str);
		if(*str == '\n')
			_putc('\r');

		str++;
	}
}
예제 #4
0
void rt_hw_console_output(const char *str)
{
    while(*str != '\0')
    {
        if (*str == '\n') {
            _putc(&_emsk_uart1,'\r');
        }
        _putc(&_emsk_uart1,*str);
        str++;
    }
}
예제 #5
0
파일: common.c 프로젝트: comex/fastdbg
void tjson_str(struct tjson *tj, const char *str) {
    _tjson_item(tj);
    _putc('"', tj->fp);
    // this ignores control characters, in case anyone cares
    unsigned char c;
    while((c = *str++)) {
        if (c == '"' || c == '\\')
            _putc('\\', tj->fp);
        _putc(c, tj->fp);
    }
    _putc('"', tj->fp);
}
예제 #6
0
/**
 * @brief   Prints a decimal unsigned number.
 *
 * @param[in] n         the number to be printed
 */
void test_printn(uint32_t n) {
  char buf[16], *p;

  if (!n)
    _putc(chp, '0');
  else {
    p = buf;
    while (n)
      *p++ = (n % 10) + '0', n /= 10;
    while (p > buf)
      _putc(chp, *--p);
  }
}
예제 #7
0
파일: format.c 프로젝트: borlox/unitlib
static bool p_latex_fac(struct status *stat, ul_number fac, bool *first)
{
	ul_number m; int e;
	getnexp(fac, &m, &e);

	if (!*first)
		CHECK(_putc(stat, ' '));
	CHECK(_putn(stat, m));
	if (e != 0) {
		CHECK(_puts(stat, " \\cdot 10^{"));
		CHECK(_putd(stat, e));
		CHECK(_putc(stat, '}'));
	}
	*first = false;
	return true;
}
예제 #8
0
파일: format.c 프로젝트: borlox/unitlib
static bool p_plain_sym(struct status *stat, const char *sym, int exp, bool *first)
{
	if (!exp)
		return true;

	if (!*first)
		CHECK(_putc(stat, ' '));

	CHECK(_puts(stat, sym));
	if (exp != 1) {
		CHECK(_putc(stat, '^'));
		CHECK(_putd(stat, exp));
	}
	*first = false;
	return true;
}
예제 #9
0
static void print_line(void) {
  unsigned i;

  for (i = 0; i < 76; i++)
    _putc(chp, '-');
  chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2);
}
예제 #10
0
ssize_t
vfb_write(const char * s, size_t count)
{
    ssize_t i;

    for (i = 0; i < (ssize_t) count; ++i)
    {
        if (g_vfb.is_esc_seq)
        {
            g_vfb.esc_buf[g_vfb.esc_buf_ndx++] = s[i];

            if (_handle_escape_seq())
            {
                g_vfb.is_esc_seq = 0;
                g_vfb.esc_buf_ndx = 0;
            }
        }
        else if (s[i] == 27) /* ESC */
            g_vfb.is_esc_seq = 1;
        else if (s[i] == '\n')
            _add_newline();
        else if (s[i] == '\b')
            _back_cursor();
        else if (s[i] == '\r')
            _carriage_return();
        else
            _putc(s[i]);
    }

    return (i);
}
예제 #11
0
		void DumpChild( DWORD64 modBase, DWORD dwTypeIndex, unsigned nestingLevel, DWORD_PTR offset )
		{
			// Determine how many children this type has.
			DWORD dwChildrenCount = 0;
			SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_CHILDRENCOUNT, &dwChildrenCount );

			// Prepare to get an array of "TypeIds", representing each of the children.
			// SymGetTypeInfo(TI_FINDCHILDREN) expects more memory than just a
			// TI_FINDCHILDREN_PARAMS struct has.  Use derivation to accomplish this.
			struct FINDCHILDREN : TI_FINDCHILDREN_PARAMS
			{
				ULONG   MoreChildIds[64];
			} children;

			children.Count = __min( dwChildrenCount, _countof( children.MoreChildIds ) );
			children.Start = 0;

			// Get the array of TypeIds, one for each child type
			if( SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_FINDCHILDREN, &children ) )
			{
				_putc( '\n' );
				// Iterate through each of the children
				for( unsigned i = 0; i < dwChildrenCount; i++ )
				{
					DWORD dwMemberOffset = 0;
					// Get the offset of the child member, relative to its parent
					if( !SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i], TI_GET_OFFSET, &dwMemberOffset ) )
						continue;

					// If the child wasn't a UDT, format it appropriately
					DumpTypeIndex( modBase, children.ChildId[i], nestingLevel + 1, offset + dwMemberOffset );
				}
			}
		}
예제 #12
0
파일: cat.c 프로젝트: taras-ko/c
void filecopy(_FILE *ifp, _FILE *ofp)
{
	int c;

	while ((c = _getc(ifp)) != EOF)
		_putc(c, ofp);
}
예제 #13
0
파일: console.c 프로젝트: m-rinaldi/kboot86
static void _tab(void)
{
    unsigned int i;

    for (i = 0; i < TAB_WIDTH; i++)
        _putc(' ', true);
}
예제 #14
0
		void FormatSymbolValue( PSYMBOL_INFO pSym )
		{
			// If it's a function, don't do anything.
			if( pSym->Tag == SymTagFunction )   // SymTagFunction from CVCONST.H from the DIA SDK
			{
				_putc( '\n' );
				return;
			}

			// Indicate if the variable is a local or parameter
			if( pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER )
				_printf( "\tParameter = %s", pSym->Name );
			else if( pSym->Flags & IMAGEHLP_SYMBOL_INFO_LOCAL )
				_printf( "\tLocal = %s", pSym->Name );
			else
			{
				// Emit the variable name
				_printf( "\t%s", pSym->Name );
			}

			DWORD_PTR pVariable = 0;    // Will point to the variable's data in memory

			if( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE )
			{
				pVariable = m_pStackFrame->AddrFrame.Offset;
				pVariable += (DWORD_PTR) pSym->Address;
			}
			else if( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER )
			{
				_putc( '\n' );
				return;   // Don't try to report register variable
			}
			else
			{
				pVariable = (DWORD_PTR) pSym->Address;   // It must be a global variable
			}

			// Determine if the variable is a user defined type (UDT).  IF so, bHandled
			// will return true.

			if( !DumpTypeIndex( pSym->ModBase, pSym->TypeIndex, 1, pVariable ) )
			{
				_putc( '\n' );
			}
			return;
		}
예제 #15
0
파일: format.c 프로젝트: borlox/unitlib
static bool p_plain_fac(struct status *stat, ul_number fac, bool *first)
{
	if (!*first)
		CHECK(_putc(stat, ' '));
	CHECK(_putn(stat, fac));
	*first = false;
	return true;
}
예제 #16
0
파일: console.c 프로젝트: m-rinaldi/kboot86
static void _display_ibuf(void)
{
    unsigned int i;

    for (i = 0; i < _.widx; i++)
        _putc(_.ibuf[i], true);

    vga_draw_cursor_xy(_.curs_x, _.curs_y);
}
예제 #17
0
파일: format.c 프로젝트: borlox/unitlib
static bool _puts(struct status *s, const char *str)
{
	while (*str) {
		char c = *str++;
		if (!_putc(s, c))
			return false;
	}
	return true;
}
예제 #18
0
파일: Stream.cpp 프로젝트: sg-/sdw-workshop
ssize_t Stream::write(const void* buffer, size_t length) {
    const char* ptr = (const char*)buffer;
    const char* end = ptr + length;
    while (ptr != end) {
        if (_putc(*ptr++) == EOF) {
            break;
        }
    }
    return ptr - (const char*)buffer;
}
예제 #19
0
파일: uart.c 프로젝트: nvll/lpc
void _putc(char c)
{
	if (c == '\n')
		_putc('\r');

	while (!(LPC_UART->LSR & LPC13XX_UART_THRE))
		;;


	LPC_UART->THR = c;
}
예제 #20
0
파일: format.c 프로젝트: borlox/unitlib
static bool p_latex_sym(struct status *stat, const char *sym, int exp, bool *first)
{
	if (!*first)
		CHECK(_putc(stat, ' '));

	CHECK(_puts(stat, "\\text{"));
	if (!*first)
		CHECK(_putc(stat, ' '));

	CHECK(_puts(stat, sym));
	CHECK(_puts(stat, "}"));
	if (exp != 1) {
		CHECK(_putc(stat, '^'));
		CHECK(_putc(stat, '{'));
		CHECK(_putd(stat, exp));
		CHECK(_putc(stat, '}'));
	}
	if (first)
		*first = false;
	return true;
}
예제 #21
0
파일: console.c 프로젝트: m-rinaldi/kboot86
// called from keyboard ISR
void console_put_ibuf(char c)
{
    bool printable;

    if ('\n' == c)
        _.line_completed = true;

    printable = _putc(c, !_ibuf_is_full());

    if (printable && !_ibuf_is_full()) {
        _.ibuf[_.widx++] = c;
        vga_draw_cursor_xy(_.curs_x, _.curs_y);
    }
}
예제 #22
0
파일: console.c 프로젝트: m-rinaldi/kboot86
int console_puts(const char *s)
{
    int i;

    if (!s)
        return 0;

    for (i = 0; s[i]; i++)
        _putc(s[i], true);

    // update the cursor after writing the whole string
    vga_draw_cursor_xy(_.curs_x, _.curs_y);

    return i;
}
예제 #23
0
파일: devtty.c 프로젝트: chettrick/uzics
/*
 * This tty interrupt routine checks to see if the uart receiver
 * actually caused the interrupt.  If so it adds the character to
 * the tty input queue, echoing and processing backspace and carriage
 * return.  If the queue contains a full line, it wakes up anything
 * waiting on it.  If it is totally full, it beeps at the user.
 */
int
tty_int(void)
{
	char c;
	int found;
	char oc;

	found = 0;
again:
	if ((in(0x72) & 0x81) != 0x81)
		return (found);
	c = (in(0x73) & 0x7f);

	if (c == 0x1a)			/* ^Z */
		idump();		/* For debugging. */

	if (c == '\003')		/* ^C */
		sendsig(NULL, SIGINT);
	else if (c == '\017')		/* ^O */
		flshflag = !flshflag;
	else if (c == '\023')		/* ^S */
		stopflag = 1;
	else if (c == '\021') {		/* ^Q */
		stopflag = 0;
		wakeup(&stopflag);
	} else if (c == '\b') {
		if (uninsq(&ttyinq, &oc)) {
			if (oc == '\n') {
				/* Don't erase past newline. */
				insq(&ttyinq, oc);
			} else {
				_putc('\b');
				_putc(' ');
				_putc('\b');
			}
		}
	} else {
		if ((c == '\r') || (c == '\n')) {
			c = '\n';
			_putc('\r');
		}

		if (insq(&ttyinq, c))
			_putc(c);
		else
			_putc('\007');	/* Beep if no more room. */
	}

	if ((c == '\n') || (c == '\004'))	/* ^D */
		wakeup(&ttyinq);

	found = 1;
	goto again;	/* Loop until the uart has no data ready. */
}
예제 #24
0
파일: console.c 프로젝트: m-rinaldi/kboot86
static int _del_ibuf(void)
{
    if (_.line_completed)
        return -1;

    if (_ibuf_is_empty())
        return -1;

    _.widx--;

    // TODO del tab
    _curs_backward();
    _putc(' ', true);
    _curs_backward();

    vga_draw_cursor_xy(_.curs_x, _.curs_y);
    return 0;
}
예제 #25
0
파일: uart.c 프로젝트: kcoewoys/work
int _printf(const char *fmt, ...)
{
	va_list ap;

	int n;
	char buf[64];
	char *s;
	
	va_start(ap, fmt);

	while(*fmt)
	{
		if(*fmt == '%')
		{
			fmt++;
			switch(*fmt)
			{
				case 'd':
					n = va_arg(ap, int);
					itoa(n, buf);
					_puts(buf);
					break;
				case 'x':
					n = va_arg(ap, int);
					xtoa(n, buf);
					_puts(buf);
					break;
				case 'c':
					n = va_arg(ap, int);
					_putc(n);
					break;
				case 's':
					s = va_arg(ap, char *);
					_puts(s);
					break;
				default:
					break;
			}	
		}
		else
		{
예제 #26
0
파일: hax.c 프로젝트: mkoval/hax
void loop_1(void)
{
	Getdata(&rxdata);

#ifdef DEBUG
	{
		uint8_t i;
		printf((char*)
			   "rxdata:\n"
			   "  packet_num rcmode rcstatusflag: %i %i %i\n"
			   , rxdata.packet_num
			   , rxdata.rcmode.allbits
			   , rxdata.rcstatusflag.allbits);

		_puts( "  reserved_1[0..2] : ");
		for(i = 0; i < 3; i++) {
			printf((char*)"%i, ",rxdata.reserved_1[i]);
		}

		_puts( "; reserved_2[0..8] : ");
		for(i = 0; i < 8; i++) {
			printf((char*)"%i, ",rxdata.reserved_2[i]);
		}

		printf((char*) "\n"
			   "  master_version : %i\n", rxdata.master_version);

		printf((char*)
			    "statusflag: 0x%02x\n"
				"  ",statusflag.a);
		for(i = 0; i < 8; i++) {
			printf((char*)"%i, ", (statusflag.a & (1<<i) ) >> i);
		}
		_putc('\n');
	}
#endif
}
예제 #27
0
파일: format.c 프로젝트: borlox/unitlib
static enum result p_lfrac(struct printer *p, struct status *stat)
{
	if (p->prefix)
		CHECK_R(_puts(stat, p->prefix));

	bool first = true;

	CHECK_R(_puts(stat, "\\frac{"));
	if (_fabsn(stat->unit->factor) >= 1)
		CHECK_R(p->fac(stat, stat->unit->factor, &first));

	for (int i=0; i < NUM_BASE_UNITS; ++i) {
		if (stat->unit->exps[i] > 0)
			CHECK_R(p->sym(stat, _ul_symbols[i], stat->unit->exps[i], &first));
	}
	if (first)
		CHECK_R(p->fac(stat, 1.0, &first));

	CHECK_R(_puts(stat, "}{"));
	first = true;
	if (_fabsn(stat->unit->factor) < 1)
		CHECK_R(p->fac(stat, stat->unit->factor, &first));
	for (int i=0; i < NUM_BASE_UNITS; ++i) {
		if (stat->unit->exps[i] < 0)
			CHECK_R(p->sym(stat, _ul_symbols[i], -stat->unit->exps[i], &first));
	}
	if (first)
		CHECK_R(p->fac(stat, 1.0, &first));

	CHECK_R(_putc(stat, '}'));

	if (p->postfix)
		CHECK_R(_puts(stat, p->postfix));

	return RES_OK;
}
예제 #28
0
void _puts(const char *s)
{
	char c;
	while ((c = *s++))
		_putc(c);
}
예제 #29
0
파일: printk.c 프로젝트: skaramoosh/Pritha
/**********************************************************************
 * Description:
 * 		Prints Formatted strings for STD out. Format specifiers
 * provide what type of data to be printed and the data value is taken
 * from the argument list.
 *
 * Input:
 * 		One or more Formatted string messages to be printed allong with
 * other data values to be printed.
 *
 * Output:
 * 		Number of characters actually printed. -1 if failure.
 *********************************************************************/
int printk(char *fmt, ...)
{
	va_list arg;
	int ret = 0;
	uint32_t val;
	uint64_t val64;

	//Check if valid putc() is registered.
	if (_putc == NULL)
		return -1;

	// Variable argument processing
	va_start(arg, fmt);

	// Till the end of string
	while(*fmt != '\0')
	{
		// Format the data to be printed
		if(*fmt == '%')
		{
			fmt++;
			switch(*fmt)
			{
			case 'd':	// Print the integer
				val = va_arg(arg,int);
				ret += print_int32((int)val);
				break;
			case 'x':	// Print Hex
				val = va_arg(arg, uint32_t);
				ret += print_hex32(val, 1);
				break;
			case 'c':	// Print the char
				val = va_arg(arg, int);
				_putc((char)val);
				ret++;
				break;
			case 'u':	// Print unsigned int
				val = va_arg(arg, uint32_t);
				ret += print_uint32(val);
				break;
			case 's':	// Print the string
				val = va_arg(arg, uint32_t);
				ret += print_string((char*)val);
				break;
			case 'l':	// Long data
				switch(*(++fmt))
				{
				case 'u':
					val64 = va_arg(arg, uint64_t);
					ret += print_uint64(val64);
					break;
				case 'd':
					val64 = va_arg(arg, int64_t);
					ret += print_int64(val64);
					break;
				case 'x':
					val64 = va_arg(arg, uint64_t);
					ret += print_hex64(val64);
					break;
				default:
					val64 = va_arg(arg, int64_t);
					ret += print_int64(val64);
					break;
				}
				break;
			default:
				_putc(*fmt);
				ret++;
				break;
			}
		}
		else
		{
예제 #30
0
static void debug_putc(struct platform_device *pdev, unsigned int c)
{
	if (c != 0x0d) // skip ^M
		_putc(c);
}