void vwarnx(const char *fmt, va_list args) { char *m; if ((m = make_message(fmt, args)) == NULL) { _native_write(STDERR_FILENO, "malloc\n", 7); real_exit(EXIT_FAILURE); } _native_write(STDERR_FILENO, _progname, strlen(_progname)); _native_write(STDERR_FILENO, ": ", 2); _native_write(STDERR_FILENO, m, strlen(m)); _native_write(STDERR_FILENO, "\n", 1); free(m); }
int puts(const char *s) { int r; r = _native_write(STDOUT_FILENO, (char*)s, strlen(s)); putchar('\n'); return r; }
int uart0_puts(char *astring, int length) { int nwritten, offset; nwritten = 0; offset = 0; while ( (length - offset > 0) && ( (nwritten = _native_write( STDOUT_FILENO, astring+offset, length-offset) ) > 0) ) { offset += nwritten; } if (nwritten == -1) { err(EXIT_FAILURE, "uart0_puts: write"); } else if ((length > 0) && (nwritten == 0)) { /* XXX: handle properly */ errx(EXIT_FAILURE, "uart0_puts: Could not write to stdout. I don't know what to do now."); } return length; }
int vprintf(const char *format, va_list argp) { int r; char *m; if ((m = make_message(format, argp)) == NULL) { err(EXIT_FAILURE, "malloc"); } r = _native_write(STDOUT_FILENO, m, strlen(m)); free(m); return r; }
void uart_write(uart_t uart, const uint8_t *data, size_t len) { DEBUG("writing to serial port "); #if ENABLE_DEBUG for (size_t i = 0; i < len; i++) { DEBUG("%02x ", (unsigned char) data[i]); } for (size_t i = 0; i < len; i++) { DEBUG("%c", (char) data[i]); } #endif DEBUG("\n"); _native_write(tty_fds[uart], data, len); }
int8_t send_buf(radio_packet_t *packet) { uint8_t buf[TAP_BUFFER_LENGTH]; int nsent, to_send; memset(buf, 0, sizeof(buf)); DEBUG("send_buf: Sending packet of length %" PRIu16 " from %" PRIu16 " to %" PRIu16 "\n", packet->length, packet->src, packet->dst); to_send = _native_marshall_ethernet(buf, packet); DEBUG("send_buf: trying to send %d bytes\n", to_send); if ((nsent = _native_write(_native_tap_fd, buf, to_send)) == -1) {; warn("write"); return -1; } return (nsent > INT8_MAX ? INT8_MAX : nsent); }
static int _send(dev_eth_t *ethdev, char* buf, int n) { dev_eth_tap_t *dev = (dev_eth_tap_t*)ethdev; return _native_write(dev->tap_fd, buf, n); }
int putchar(int c) { _native_write(STDOUT_FILENO, &c, 1); return 0; }