[H-GEN] Robify v1.0 [SOURCE][LONG]
jason parker
s330812 at cello.it.uq.edu.au
Sat Oct 18 12:58:41 EDT 1997
Hi,
I was going to send this to announce, but 1) it's rather silly, and
2) I wasn't sure that it would get past those who run the list! :)
Anyway. Following is the source to robify version 1.0, in what I am
sure is pretty cruddy C---but it *was* hacked up late at night[1], and
it is even free, so be a little forgiving... :)
Y'all are free to do what you like with it, but let me know of any
improvements you make? (Yes I *know* it could be done in 5 characters
of perl, but C is so much more ... unix. :)
Cheers,
Jason
ph330812 at student.uq.edu.au
---CUT HERE---8<---CUT HERE---
/*
* robify.c : a filter that can be used to emulte Robert Brockway,
* president of HUMBUG.
*
* author : Jason Parker, s330812 at cello.it.uq.edu.au,
* Sun Oct 19 02:49:11 EST 1997
*
* v1.0 : performs basic character switching, longer lines are more
* likely to be muddled up.
*
* todo : add some real command line options, and other neat effects,
* like transposing words, and changing characters to others
* close to them on a qwerty keyboard.
*/
#include <stdio.h>
#define MAXLINE 80
#define PROB 1.333
void mangle(char* line)
{
int count=0;
int len=strlen(line);
int which;
char swap;
while((which=(int)(random()%(int)(MAXLINE*PROB)))<len)
swap=line[which], line[which]=line[which+1], line[which+1]=swap;
/* No good reason for the use of "," it just puts it all on one line. */
}
int main(int argc, char** argv)
{
char buf[MAXLINE];
if(argc>1) /* Poor mans argument parsing. :) */
{
printf("robify v1.0: mangle stdin to look like Robert wrote it.\n");
printf("usage : robify [-h]\n");
exit(1);
}
while(fgets(buf, MAXLINE, stdin)!=NULL)
{
mangle(buf);
if(fputs(buf,stdout)==EOF)
{
fprintf(stderr, "robify: output error\n");
exit(1);
}
}
if(ferror(stdin))
{
fprintf(stderr, "robify: input error\n");
exit(1);
}
exit(0);
}
---CUT HERE---8<---CUT HERE---
-----
`What is the sound of Perl? Is it not the sound of a wall that
people have stopped banging their heads against?' -- Larry Wall
ph330812 at student.uq.edu.au (play) | Nethack player. Ascended:
s330812 at cello.it.uq.edu.au (work) | P(2), and V(1). Next: R.
/Real/ games run under *Unix*. cf: NetHack, Doom, Quake, etc.
----------------------- HUMBUG General List --------------------------------
echo "unsubscribe general" | mail majordomo at humbug.org.au # To Unsubscribe
More information about the General
mailing list