<commit_before>#define  _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <pwd.h>
#include <utmpx.h>
#include <sys/types.h>
#include "init.h"
#include "wall.h"

#define  max(a, b) ((a) > (b) ? (a) : (b))


void warn(int runlevel, int seconds)
{
    const char *purpose;
    switch (runlevel) {
    case RUNLEVEL_SINGLE:
        purpose = "for maintenance";
        break;
    case RUNLEVEL_SHUTDOWN:
        purpose = "for shutdown";
        break;
    case RUNLEVEL_REBOOT:
        purpose = "for reboot";
        break;
    }
    int mins = seconds / 60;

    if (seconds)
        wall("The system is going down %s in %s%d minute%s!\n", purpose, mins ? "" : "<", max(mins, 1), mins == 1 ? "" : "s");
    else
        wall("The system is going down %s NOW!\n", purpose);
}

void wall(const char *message, ...)
{
    /* get username */
    uid_t uid = getuid();
    const char *username;
    struct passwd *pwd = getpwuid(uid);
    if (!pwd)
        username = pwd->pw_name;
    else
        username = "unknown";

    /* get TTY */<commit_msg>Fix incorrect username retrieval.<commit_after>#define  _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <pwd.h>
#include <utmpx.h>
#include <sys/types.h>
#include "init.h"
#include "wall.h"

#define  max(a, b) ((a) > (b) ? (a) : (b))


void warn(int runlevel, int seconds)
{
    const char *purpose;
    switch (runlevel) {
    case RUNLEVEL_SINGLE:
        purpose = "for maintenance";
        break;
    case RUNLEVEL_SHUTDOWN:
        purpose = "for shutdown";
        break;
    case RUNLEVEL_REBOOT:
        purpose = "for reboot";
        break;
    }
    int mins = seconds / 60;

    if (seconds)
        wall("The system is going down %s in %s%d minute%s!\n", purpose, mins ? "" : "<", max(mins, 1), mins == 1 ? "" : "s");
    else
        wall("The system is going down %s NOW!\n", purpose);
}

void wall(const char *message, ...)
{
    /* get username */
    uid_t uid = getuid();
    const char *username;
    struct passwd *pwd = getpwuid(uid);
    if (pwd)
        username = pwd->pw_name;
    else
        username = "unknown";

    /* get TTY */
{'fraction_non_alphanumeric': 0.1569995638901003, 'fraction_numerical': 0.006105538595726123, 'mean_word_length': 2.5565891472868216, 'pattern_counts': {'":': 0, '<': 23, '<?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': '725704', 'n_tokens_mistral': 861, 'n_tokens_neox': 817, 'n_words': 235}