From: Marius Gavrilescu Date: Sat, 18 Jul 2015 08:30:29 +0000 (+0300) Subject: Don't give special treatement to nethackify either X-Git-Tag: debian/2.54~9 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=846aed59c5121e74a5d8c7b9c0421487933d1536;p=filters.git Don't give special treatement to nethackify either --- diff --git a/Makefile b/Makefile index a59b5ab..13d54a4 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,6 @@ samples: $(BUILD) $(OTHER) clean: $(RM) -f core *.o *~ $(BUILD) SAMPLES cd ky00te.dir && make clean - cd nethackify.dir && make clean .SUFFIXES: .l @@ -52,7 +51,5 @@ clean: ky00te: cd ky00te.dir && make -nethackify: - cd nethackify.dir && make - +nethackify: nethackify.c scramble: scramble.c diff --git a/nethackify.c b/nethackify.c new file mode 100644 index 0000000..1f6cb6c --- /dev/null +++ b/nethackify.c @@ -0,0 +1,87 @@ + +/* +nethackify +tries to write text ala nethack + +cat /etc/motd/ | nethackify +/exec -o nethackify "good morning :)" + +gurkan@linuks.mine.nu +*/ + +#include +#include +#include +#include + +char *normal ="ABCDEFGHIKLMNOPQRTUVWZbdeghjklmnoqwy:;01678"; +char *nethack1="^P(|||C||||||CFCP|J/V/|cccni||nrccvv.,C|o/3"; +char *nethack2="?b?)F-(-?<_??(?(F???/??|??????r???????(???o"; +char *nethack3=" [ [L \\ "; +char *nethack4=" [ \\ "; +char *nethack5=" _ \\ "; + +int myrandom(float max) +{ + return ((int)(max*rand()/(RAND_MAX+1.0))); +} + +void nethackify(char* str) +{ + int i,c; + for(i=0; i0) { + switch(myrandom(5)) { + case 4: if(nethack5[c]!=' ') str[i]=nethack5[c]; + case 3: if(nethack4[c]!=' ') str[i]=nethack4[c]; + case 2: if(nethack3[c]!=' ') str[i]=nethack3[c]; break; + case 1: if(nethack2[c]!=' ') str[i]=nethack2[c]; break; + case 0: str[i]=nethack1[c]; break; + default: break; + } + } + } + } + printf("%c",str[i]); + } + + printf(" "); +} + +int main(int argc, char **argv) +{ + int i,c; + struct timeval tv; + FILE *f; + char ch[1]; + + srand((gettimeofday(&tv,NULL),tv.tv_usec)); + if (argc==1) { + f=stdin; + while(fread(ch,1,1,f)) { + for(c=0; c -#include -#include -#include - -char *normal ="ABCDEFGHIKLMNOPQRTUVWZbdeghjklmnoqwy:;01678"; -char *nethack1="^P(|||C||||||CFCP|J/V/|cccni||nrccvv.,C|o/3"; -char *nethack2="?b?)F-(-?<_??(?(F???/??|??????r???????(???o"; -char *nethack3=" [ [L \\ "; -char *nethack4=" [ \\ "; -char *nethack5=" _ \\ "; - -int myrandom(float max) -{ - return ((int)(max*rand()/(RAND_MAX+1.0))); -} - -void nethackify(char* str) -{ - int i,c; - for(i=0; i0) { - switch(myrandom(5)) { - case 4: if(nethack5[c]!=' ') str[i]=nethack5[c]; - case 3: if(nethack4[c]!=' ') str[i]=nethack4[c]; - case 2: if(nethack3[c]!=' ') str[i]=nethack3[c]; break; - case 1: if(nethack2[c]!=' ') str[i]=nethack2[c]; break; - case 0: str[i]=nethack1[c]; break; - default: break; - } - } - } - } - printf("%c",str[i]); - } - - printf(" "); -} - -int main(int argc, char **argv) -{ - int i,c; - struct timeval tv; - FILE *f; - char ch[1]; - - srand((gettimeofday(&tv,NULL),tv.tv_usec)); - if (argc==1) { - f=stdin; - while(fread(ch,1,1,f)) { - for(c=0; c