<commit_before>#include <lib/memory.h>
#include <lib/string.h>
#include <kernel/arch/x86/io.h>
#include <kernel/modules.h>
#include <kernel/vfs.h>
#include <modules/stream/stream.h>
#include <modules/rtc/rtc.h>

static struct rtc_device device;

static unsigned char convert(unsigned char num)
{

    return ((num & 0xF0) >> 1) + ((num & 0xF0) >> 3) + (num & 0x0F);

}

static unsigned char get_value(unsigned int type)
{

//    do { io_outb(RTC_PORT_WRITE, 0x0A); }
//    while (io_inb(RTC_PORT_READ) != 0x80);

    io_outb(RTC_PORT_WRITE, type);

    return convert(io_inb(RTC_PORT_READ));

}

static unsigned int rtc_device_stream_read(struct vfs_node *self, unsigned int count, void *buffer)
{

    char num[32];

    string_write(buffer, "20");
    string_write_num(num, get_value(RTC_FLAG_YEAR), 10);
    string_write_concat(buffer, num);
    string_write_concat(buffer, "-");
    string_write_num(num, get_value(RTC_FLAG_MONTH), 10);
    string_write_concat(buffer, num);
    string_write_concat(buffer, "-");
    string_write_num(num, get_value(RTC_FLAG_DAY), 10);
    string_write_concat(buffer, num);
    string_write_concat(buffer, " ");
    string_write_num(num, get_value(RTC_FLAG_HOURS), 10);
    string_write_concat(buffer, num);
    string_write_concat(buffer, ":");
    string_write_num(num, get_value(RTC_FLAG_MINUTES), 10);
    string_write_concat(buffer, num);
    string_write_concat(buffer, ":");
    string_write_num(num, get_value(RTC_FLAG_SECONDS), 10);
    string_write_concat(buffer, num);

    return string_length(buffer);

}<commit_msg>cleanup for rtc<commit_after>#include <lib/memory.h>
#include <lib/string.h>
#include <kernel/arch/x86/io.h>
#include <kernel/modules.h>
#include <kernel/vfs.h>
#include <modules/stream/stream.h>
#include <modules/rtc/rtc.h>

static struct rtc_device device;

static unsigned char convert(unsigned char num)
{

    return ((num & 0xF0) >> 1) + ((num & 0xF0) >> 3) + (num & 0x0F);

}

static unsigned char get_value(unsigned int type)
{

//    do { io_outb(RTC_PORT_WRITE, 0x0A); }
//    while (io_inb(RTC_PORT_READ) != 0x80);

    io_outb(RTC_PORT_WRITE, type);

    return convert(io_inb(RTC_PORT_READ));

}

static unsigned int rtc_device_stream_read(struct vfs_node *self, unsigned int count, void *buffer)
{

    string_write_format(buffer, "20%d-%d-%d %d:%d:%d", get_value(RTC_FLAG_YEAR), get_value(RTC_FLAG_MONTH), get_value(RTC_FLAG_DAY), get_value(RTC_FLAG_HOURS), get_value(RTC_FLAG_MINUTES), get_value(RTC_FLAG_SECONDS));

    return string_length(buffer);

}
{'fraction_non_alphanumeric': 0.1416173570019724, 'fraction_numerical': 0.01893491124260355, 'mean_word_length': 5.125603864734299, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2834294', 'n_tokens_mistral': 1017, 'n_tokens_neox': 949, 'n_words': 174}