diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-04-13 13:33:10 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-04-13 13:33:10 -0400 |
| commit | 8703eaf81470fda6cda729b45b755f403055f179 (patch) | |
| tree | 59dca9a40766ca5d68d00ac8e6ec35bc2aec27bd /src | |
| download | cmommy-8703eaf81470fda6cda729b45b755f403055f179.tar.gz | |
init
Diffstat (limited to 'src')
| -rw-r--r-- | src/Main.c | 54 | ||||
| -rw-r--r-- | src/Messages.h | 28 |
2 files changed, 82 insertions, 0 deletions
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 <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/wait.h> +#include <time.h> +#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 <command>\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 +}; |
