Twin Peaks Usenet Archive

Subject: Owls
From: phillip@soda.Berkeley.EDU (Phillip "Edward" Nunez)
Date: 1991-01-18, 22:14
Newsgroups: rec.birds,,alt.hackers,
Reply-to: phillip@soda.Berkeley.EDU

The following program may be of vast interest to many of you out there.
It was written by me.  It is the second version, the eagerly-awaited
re-release, of the Owlspeak program everyone was so extatic about!

It is a filter program, much like the rather infamous 'jive'.

  How to make the program:

Save this article to disk, and then delete all of the lines up to (and
including) the "CUT HERE" line.  Then you need to compile it.  For the
examples below, the filename is "owlspeak.c".

If you are using the Nunez C Compiler, simply enter the command line:

Phillip [17]:  philcc -cool owlspeak.c -o owlspeak

If you are using something like gcc, you should type something like:

  gcc owlspeak.c -o owlspeak -O -Dphillip

But if you don't compile it with philcc, it won't be as good.  And in any
case, you need a compiler able to grok ANSI C.

Run the program by piping operations through it.  For example, to read
the message of the day, use "cat /etc/motd | owlspeak".

Have some fun.  Pipe your friend's .forward through owlspeak.  Rlogin to
your favorite machine through owlspeak.  The possibilities are endless.

Send all bug reports, comments, and suggestions to

---------- CUT HERE ---------
/* Owlspeak, by Phillip "Edward" Nunez ( */


                          /* Phillip in the above refers to phillip@soda,
                             Phillip "Edward" Nunez.                      */


#ifdef X11
#endif                          /* So I can post this to comp.sources.x */

#define PUNCT "@#$%^&*()_+|~-=\\`{}[]:\";'<>?,./"
#define MESSINESS 6
#define MAXNUM 01000                    /* In octal, of course */

#define PROBABILITY 9                   /* Chances are 1 in PROBABILITY
                                           (decimal) that a strange message
                                           will appear per random slashed
                                           octal number generated and per
                                           line of text.          */

/*  You might want to nazi the source code since you don't want stupid
        users to know everything that the program might do to their
        messages unless they run it a lot.                              */

char *quotes[] = {

#define QUOTECOUNT (sizeof(quotes) / sizeof(int))

const char *nums[] = {                          /* viva INTERCAL */

        "/OH", "/ONE", "/TWO", "/THREE", "/FOUR", "/FIVE", "/SIX", "/SEVEN",
        "/EIGHT", "/NINER"

int pindex(char c) {            /* Written because I was having problems
        char *s = PUNCT;                with strchr() and subtraction and
        while (*s)                      getting negative numbers on some
                if (c == *s++)          systems.                          */
                        return c;
        return -1;

void Printnum(char c, int n) {
        fprintf(stdout, "/%c%03o", c, n);

char *cutspace(char *c) {
        while ((*c == ' ') || (*c == '\t')) c++;
        return c;

void qstatic(void) {
        int i;

        i = random() % QUOTECOUNT;
        fprintf(stdout, quotes[i]);

void sstatic(void) {
        int i;

        i = random() % MESSINESS;
        while (i-- > 0)
                Printnum(random() % 26 + 'A', random() % MAXNUM);
        if (random() % PROBABILITY) return;

void number(int n) {                    /* viva INTERCAL again */

        if (n == 0) {
                fprintf(stdout, (random() % 2) ? "/ZERO" : "/OH");
        } else if (n == 9) {
                fprintf(stdout, (random() % 2) ? "/NINE" : "/NINER");
        fprintf(stdout, nums[n]);

char *process(char *c) {
        int d;
        static int nline = 0;

        if (*c == '\n') {
                if (nline) sstatic();
                fprintf(stdout, "/C000");
                if (!(random() % PROBABILITY)) {
                        fprintf(stdout, "/C000");
                nline = 1;
                return ++c;

        nline = 0;
        if (isdigit(*c)) {
                number(*c - '0');
                return ++c;
        if (isalpha(*c)) {
                fputc('/', stdout);
                while (isalpha(*c))
                        fputc(isupper(*c) ? *c++ : toupper(*c++), stdout);
                return c;

        if (random() % 2) return ++c;       /* Don't copy 100% of punctuation,
                                                because it starts to get
                                                messy if you do.            */

        d = pindex(*c);
        if (d == -1) fprintf(stdout, "/C000");
                else Printnum('C', d);
        return ++c;

void main(int argc, char *argv[]) {
        char *s, *t = (char *)malloc(BUFSIZ);

        if (argc > 1) {
                fprintf(stdout, *(argv[1] + 1) == 'v' ? VERSION : USAGE);
        while (fgets((s = t), BUFSIZ - 1, stdin) != NULL)
                while (*s) s = process(cutspace(s));
        fprintf(stdout, "\n");