-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonas Brandstötter
committed
Feb 28, 2020
0 parents
commit d0bacff
Showing
4 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CC = gcc | ||
|
||
all: thanos thanoscat | ||
|
||
install: thanos_install thanoscat_install | ||
|
||
clean: | ||
rm -f thanos | ||
rm -f thanoscat | ||
rm -f quotes.dat | ||
|
||
thanos: thanos.c | ||
$(CC) -o thanos thanos.c | ||
|
||
thanoscat: thanoscat.c | ||
$(CC) -o thanoscat thanoscat.c | ||
|
||
thanos_install: thanos quotes quotes.dat | ||
cp thanos /usr/local/bin/thanos | ||
mkdir -p /usr/share/thanos | ||
cp quotes quotes.dat /usr/share/thanos | ||
|
||
thanoscat_install: thanoscat | ||
cp thanoscat /usr/local/bin/thanoscat | ||
|
||
quotes.dat: quotes | ||
strfile quotes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
You're strong, but I could snap my fingers and you'd all | ||
cease to exist. | ||
% | ||
The hardest choices require the strongest wills. | ||
% | ||
I'm a survivor. | ||
% | ||
You should have gone for the head. | ||
% | ||
You could not live with your own failure, and where did that | ||
bring you? Back to me. | ||
% | ||
I know what it's like to lose. To feel so desperately that | ||
you're right, yet to fail nonetheless. It's frightening. | ||
Turns the legs to jelly. I ask you, to what end? Dread it. | ||
Run from it. Destiny arrives all the same. And now, it's | ||
here. Or should I say, I am. | ||
% | ||
Perfectly balanced, as all things should be. | ||
% | ||
Fun isn't something one considers when balancing the universe. | ||
But this ... does put a smile on my face. | ||
% | ||
Thanos: Daughter. | ||
Gamora: Did you do it? | ||
Thanos: Yes | ||
Gamora: What did it cost? | ||
Thanos: Everything. | ||
% | ||
You have my respect, Stark. When I'm done, half of humanity | ||
will still be alive. I hope they remember you. | ||
% | ||
Thanos: Stark. | ||
Tony Stark: You know me? | ||
Thanos: I do. You're not the only one cursed with knowledge. | ||
Tony Stark: My only curse is you. | ||
% | ||
I used the stones to destroy the stones. And it nearly killed | ||
me. But the work is done, it always will be. | ||
I am ... inevitable. | ||
% | ||
This universe is finite, its resources, finite. | ||
% | ||
I ignored my destiny once, I can not do that again. Even for | ||
you. I'm sorry, little one. | ||
% | ||
The universe required correction. After that, the stones | ||
served no purpose beyond temptation. | ||
% | ||
Fine. I'll do it myself. | ||
% | ||
With all six stones, I can simply snap my fingers, they | ||
would all cease to exist. I call that mercy. | ||
% | ||
You're strong. Me ... You're generous. Me ... But I never | ||
taught you to lie. That's why you're so bad at it. Where is | ||
the Soul Stone? | ||
% | ||
You should choose your words more carefully. | ||
% | ||
Going to bed hungry. Scrounging for scraps. Your planet was | ||
on the brink of collapse. I was the one who stopped that. You | ||
know what’s happened since then? The children born have known | ||
nothing but full bellies and clear skies. It’s a paradise. | ||
% | ||
The end is near. | ||
% | ||
Your optimism is misplaced, Asgardian. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <stdio.h> | ||
#include <arpa/inet.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
||
struct strfile_header | ||
{ | ||
uint32_t str_version; | ||
uint32_t str_numstr; | ||
uint32_t str_longlen; | ||
uint32_t str_shortlen; | ||
uint32_t str_flags; | ||
uint32_t str_delim; | ||
uint32_t *table; | ||
}__attribute__((packed)); | ||
|
||
int main() | ||
{ | ||
FILE *dat_file = fopen ("/usr/share/thanos/quotes.dat", "rb"); | ||
struct strfile_header header; | ||
|
||
srand (time (NULL)); | ||
|
||
fread (&header, sizeof (header) - sizeof (header.table), 1, dat_file); | ||
|
||
header.str_version = ntohl (header.str_version); | ||
header.str_numstr = ntohl (header.str_numstr); | ||
header.str_longlen = ntohl (header.str_longlen); | ||
header.str_shortlen = ntohl (header.str_shortlen); | ||
header.str_flags = ntohl (header.str_flags); | ||
header.str_delim = ntohl (header.str_delim); | ||
|
||
header.table = malloc (header.str_numstr * 4); | ||
|
||
size_t i; | ||
for (i = 0; i < header.str_numstr; ++i) | ||
{ | ||
unsigned int val; | ||
fread (&val, 4, 1, dat_file); | ||
header.table[i] = ntohl(val); | ||
} | ||
|
||
fclose (dat_file); | ||
|
||
unsigned int quote_index; | ||
quote_index = rand () % header.str_numstr; | ||
unsigned int len = header.table[quote_index+1] - header.table[quote_index] - 2; | ||
|
||
char *buf; | ||
buf = malloc (len+1); | ||
|
||
FILE *quotes = fopen ("/usr/share/thanos/quotes", "rb"); | ||
fseek (quotes, header.table[quote_index], SEEK_SET); | ||
fread (buf, 1, len, quotes); | ||
buf[len] = '\0'; | ||
|
||
fputs (buf, stdout); | ||
|
||
fclose (quotes); | ||
free (header.table); | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <ctype.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
srand (time (NULL)); | ||
FILE *file = NULL; | ||
if (argc >= 2) | ||
{ | ||
file = fopen (argv[1], "r"); | ||
if (file == NULL) | ||
{ | ||
fprintf (stderr, "Could not open %s: %s", argv[1], strerror (errno)); | ||
exit (1); | ||
} | ||
} else | ||
{ | ||
file = stdin; | ||
} | ||
|
||
char c; | ||
while ((c = fgetc (file)) != EOF) | ||
{ | ||
if (!isspace (c) && !iscntrl (c)) | ||
{ | ||
if (rand () % 2 == 0) | ||
{ | ||
fputc (c, stdout); | ||
} else { | ||
fputc (' ', stdout); | ||
} | ||
} else | ||
{ | ||
fputc (c, stdout); | ||
} | ||
} | ||
|
||
fclose (file); | ||
} | ||
|