mirror of
https://git.soft.fish/val/MicroCorruption.git
synced 2024-11-22 17:25:58 +00:00
40 lines
672 B
C
40 lines
672 B
C
#ifndef __uC_IO_C__
|
|
#define __uC_IO_C__
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "mem.h"
|
|
// 512 600 0011
|
|
void INT (int arg, ...);
|
|
|
|
char hascii(int i) {
|
|
if (i > '9')
|
|
i += 9;
|
|
return i & 0x0f;
|
|
}
|
|
|
|
// gets (getsn)
|
|
void getsn (char* buf, size_t size) {
|
|
char *temp = malloc(size*2);
|
|
fgets(temp, size*2, stdin);
|
|
for (int i = 0; i < size * 2; i+=2) {
|
|
buf[i/2] = ((hascii(temp[i]))<<4)|(hascii(temp[i+1]));
|
|
printf("%02x", buf[i/2] & 0xff);
|
|
}
|
|
printf("\n");
|
|
free(temp);
|
|
}
|
|
|
|
// putchar
|
|
// int putchar (int c);
|
|
|
|
// puts
|
|
// int puts(const char *);
|
|
|
|
// printf
|
|
//int printf (const char * restrict format_str, ...);
|
|
|
|
|
|
|
|
#endif // __uC_IO_C__
|