mruby/c VM Source Code master (2026/08/06)
Loading...
Searching...
No Matches
console.c File Reference

console output module. (not yet input) More...

#include "mrubyc.h"
Include dependency graph for console.c:

Go to the source code of this file.

Macros

#define MRBC_PRINTF_MAX_WIDTH   82

Functions

static int mrbc_printf_sub_output_arg (mrbc_printf_t *pf, va_list *ap)
static int mrbc_p_sub_hashkey (const mrbc_value *v)
void mrbc_putchar (char c)
void mrbc_print_symbol (mrbc_sym sym_id)
void mrbc_nprint (const char *str, int size)
void mrbc_printf (const char *fstr,...)
void mrbc_asprintf (char **buf, int bufsiz, const char *fstr,...)
void mrbc_snprintf (char *buf, int bufsiz, const char *fstr,...)
void mrbc_vprintf (const char *fstr, va_list ap)
void mrbc_vasprintf (char **buf, int bufsiz, const char *fstr, va_list ap)
void mrbc_p (const mrbc_value *v)
void mrbc_char_to_s (char *buf, const void *src)
int mrbc_p_sub (const mrbc_value *v)
int mrbc_puts_sub (const mrbc_value *v)
int mrbc_print_sub (const mrbc_value *v)
void mrbc_printf_replace_buffer (mrbc_printf_t *pf, char *buf, int size)
int mrbc_printf_main (mrbc_printf_t *pf)
int mrbc_printf_char (mrbc_printf_t *pf, int ch)
int mrbc_printf_bstr (mrbc_printf_t *pf, const char *str, int len, int pad)
int mrbc_printf_int (mrbc_printf_t *pf, mrbc_int_t value, unsigned int base)
int mrbc_printf_bit (mrbc_printf_t *pf, mrbc_int_t value, int bit)
int mrbc_printf_float (mrbc_printf_t *pf, double value)
int mrbc_printf_pointer (mrbc_printf_t *pf, void *ptr)

Detailed Description

console output module. (not yet input)

Copyright (C) 2015-      Kyushu Institute of Technology.
Copyright (C) 2015-2026  Shimane IT Open-Innovation Center.
Copyright (C) 2026-      Shimane Institute for Industrial Technology.

This file is distributed under BSD 3-Clause License.

Definition in file console.c.

Macro Definition Documentation

◆ MRBC_PRINTF_MAX_WIDTH

#define MRBC_PRINTF_MAX_WIDTH   82

Definition at line 32 of file console.c.

Function Documentation

◆ mrbc_asprintf()

void mrbc_asprintf ( char ** buf,
int bufsiz,
const char * fstr,
... )

formatted output conversion, output to heap buffer.

Parameters
bufdouble pointer to output buffer. must be allocated by mrbc_alloc.
bufsizbuffer size.
fstrformat string.

Definition at line 223 of file console.c.

Here is the call graph for this function:

◆ mrbc_char_to_s()

void mrbc_char_to_s ( char * buf,
const void * src )

convert char to string (escape sequence)

Parameters
bufoutput buffer. (5bytes at least)
srcpointer to input char.

Definition at line 359 of file console.c.

Here is the caller graph for this function:

◆ mrbc_nprint()

void mrbc_nprint ( const char * str,
int size )

output string with length parameter.

Parameters
strstr
sizebyte length.

Definition at line 176 of file console.c.

Here is the caller graph for this function:

◆ mrbc_p()

void mrbc_p ( const mrbc_value * v)

print mrbc_value

Parameters
vpointer to target value.

Definition at line 346 of file console.c.

Here is the call graph for this function:

◆ mrbc_p_sub()

int mrbc_p_sub ( const mrbc_value * v)

p - sub function

Parameters
vpointer to target value.

Definition at line 398 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_p_sub_hashkey()

int mrbc_p_sub_hashkey ( const mrbc_value * v)
static

Definition at line 105 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_print_sub()

int mrbc_print_sub ( const mrbc_value * v)

print - sub function

Parameters
vpointer to target value.
Return values
0normal return.
1already output LF.

Definition at line 522 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_print_symbol()

void mrbc_print_symbol ( mrbc_sym sym_id)

display symbol name.

Parameters
sym_idsymbol ID to print.

Definition at line 152 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_printf()

void mrbc_printf ( const char * fstr,
... )

formatted output conversion, output to console.

Parameters
fstrformat string.

Definition at line 205 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_printf_bit()

int mrbc_printf_bit ( mrbc_printf_t * pf,
mrbc_int_t value,
int bit )

sprintf subcontract function for 'x', 'o', 'b'

Parameters
pfpointer to mrbc_printf.
valueoutput value.
bitn bit. (4=hex, 3=oct, 1=bin)
Return values
0done.
-1buffer full.
Note
not terminate ('\0') buffer tail.

Definition at line 879 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_printf_bstr()

int mrbc_printf_bstr ( mrbc_printf_t * pf,
const char * str,
int len,
int pad )

sprintf subcontract function for byte array.

Parameters
pfpointer to mrbc_printf.
strpointer to byte array.
lenbyte length.
padpadding character.
Return values
0done.
-1buffer full.
Note
not terminate ('\0') buffer tail.

Definition at line 740 of file console.c.

Here is the caller graph for this function:

◆ mrbc_printf_char()

int mrbc_printf_char ( mrbc_printf_t * pf,
int ch )

sprintf subcontract function for char 'c'

Parameters
pfpointer to mrbc_printf
choutput character (ASCII)
Return values
0done.
-1buffer full.
Note
not terminate ('\0') buffer tail.

Definition at line 707 of file console.c.

Here is the caller graph for this function:

◆ mrbc_printf_float()

int mrbc_printf_float ( mrbc_printf_t * pf,
double value )

sprintf subcontract function for float(double) 'f'

Parameters
pfpointer to mrbc_printf.
valueoutput value.
Return values
0done.
-1buffer full.

Definition at line 939 of file console.c.

Here is the caller graph for this function:

◆ mrbc_printf_int()

int mrbc_printf_int ( mrbc_printf_t * pf,
mrbc_int_t value,
unsigned int base )

sprintf subcontract function for integer 'd', 'u'

Parameters
pfpointer to mrbc_printf.
valueoutput value.
basen base.
Return values
0done.
-1buffer full.
Note
not terminate ('\0') buffer tail.

Definition at line 792 of file console.c.

Here is the caller graph for this function:

◆ mrbc_printf_main()

int mrbc_printf_main ( mrbc_printf_t * pf)

sprintf subcontract function

Parameters
pfpointer to mrbc_printf
Return values
0(format string) done.
1found a format identifier.
-1buffer full.
Note
not terminate ('\0') buffer tail.

Definition at line 647 of file console.c.

Here is the caller graph for this function:

◆ mrbc_printf_pointer()

int mrbc_printf_pointer ( mrbc_printf_t * pf,
void * ptr )

sprintf subcontract function for pointer 'p'

Parameters
pfpointer to mrbc_printf.
ptroutput value.
Return values
0done.
-1buffer full.
Note
display '$00000000' style only. up to 8 digits, even if 64bit machines. not support sign, width, precision and other parameters.

Definition at line 973 of file console.c.

Here is the caller graph for this function:

◆ mrbc_printf_replace_buffer()

void mrbc_printf_replace_buffer ( mrbc_printf_t * pf,
char * buf,
int size )

replace output buffer

Parameters
pfpointer to mrbc_printf
bufpointer to output buffer.
sizebuffer size.

Definition at line 629 of file console.c.

Here is the caller graph for this function:

◆ mrbc_printf_sub_output_arg()

int mrbc_printf_sub_output_arg ( mrbc_printf_t * pf,
va_list * ap )
static

Definition at line 45 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_putchar()

void mrbc_putchar ( char c)

output a character

Parameters
ccharacter

Definition at line 131 of file console.c.

Here is the caller graph for this function:

◆ mrbc_puts_sub()

int mrbc_puts_sub ( const mrbc_value * v)

puts - sub function

Parameters
vpointer to target value.
Return values
0normal return.
1already output LF.

Definition at line 499 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_snprintf()

void mrbc_snprintf ( char * buf,
int bufsiz,
const char * fstr,
... )

formatted output conversion, output to fixed buffer.

Parameters
bufoutput buffer.
bufsizbuffer size.
fstrformat string.

Definition at line 241 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_vasprintf()

void mrbc_vasprintf ( char ** buf,
int bufsiz,
const char * fstr,
va_list ap )

formatted output conversion with va_list, output to heap buffer.

Parameters
bufdouble pointer to output buffer. must be allocated by mrbc_alloc.
bufsizbuffer size.
fstrformat string.
apvariable argument pointer.

Definition at line 301 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_vprintf()

void mrbc_vprintf ( const char * fstr,
va_list ap )

formatted output conversion with va_list, output to console.

Parameters
fstrformat string.
apvariable argument pointer.

Definition at line 266 of file console.c.

Here is the call graph for this function:
Here is the caller graph for this function: