From 8703eaf81470fda6cda729b45b755f403055f179 Mon Sep 17 00:00:00 2001 From: frosty Date: Mon, 13 Apr 2026 13:33:10 -0400 Subject: init --- src/Main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Messages.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/Main.c create mode 100644 src/Messages.h (limited to 'src') diff --git a/src/Main.c b/src/Main.c new file mode 100644 index 0000000..f3f084d --- /dev/null +++ b/src/Main.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include +#include "Messages.h" + +#define SUCCESS_COUNT (sizeof(success_messages) / sizeof(char*) - 1) +#define FAILURE_COUNT (sizeof(failure_messages) / sizeof(char*) - 1) + +static const char ANSI_RED[] = "\x1b[31m"; +static const char ANSI_RESET[] = "\x1b[0m"; + +static const char* get_random_message(const char* messages[], size_t count) { + return messages[rand() % count]; +} + +int main(int argc, char* argv[]) { + if (argc < 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + srand((unsigned int)ts.tv_nsec); + + pid_t pid = fork(); + + if (pid < 0) { + perror("fork"); + return 1; + } + + if (pid == 0) { + execvp(argv[1], &argv[1]); + perror(argv[1]); + _exit(127); + } + + int status; + waitpid(pid, &status, 0); + + const char* message; + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { + message = get_random_message(success_messages, SUCCESS_COUNT); + } else { + message = get_random_message(failure_messages, FAILURE_COUNT); + } + + printf("%s%s<3%s\n", ANSI_RED, message, ANSI_RESET); + + return 0; +} diff --git a/src/Messages.h b/src/Messages.h new file mode 100644 index 0000000..0302e2f --- /dev/null +++ b/src/Messages.h @@ -0,0 +1,28 @@ +static const char* success_messages[] = { + "yes! that's the spirit, sweetie!", + "great job, honey! i'm proud of you~", + "that's my little star! you did amazing~", + "*pets your head*", + "*gives you scratches*", + "that's a good boy~", + "aww what a good boy~ mommy knew you could do it~", + "*gives you a sticker*", + "you're doing so well~!", + "you're making mommy so happy~", + "good boy~ mommy's so proud of you~", + NULL +}; + +static const char* failure_messages[] = { + "mommy's here for you, no matter what~", + "it's alright, sweetie. take a breath and try again~", + "i believe in you, honey. let's try once more~", + "mommy believes in you~", + "it's okay, mommy's here for you~", + "try again for mommy~", + "oops~! mommy loves you anyways~", + "everything's gonna be okay~", + "do you need mommy's help~?", + "aww, you'll get it next time~", + NULL +}; -- cgit v1.2.3