
/*************************************************/
/*          Fortune Cookie Program V2            */
/*    by John Kennedy for Amiga Computing        */
/*       Written under Lattice C v 5.2           */
/*         Compile with lc -L option             */
/* NB this program needs to write a teensy-weeny */
/* file on your boot-up disc, so please let it.  */
/* (Unless it has been compiled under North C!)  */
/*************************************************/

/* Edited to work under NorthC by Steve Hawtin */
/* Indentation changed as well */

#include <exec/types.h>
#include <stdlib.h>
#include <stdio.h>

#ifdef NORTHC
#include <libraries/dos.h>

struct DateStamp date_now;

#endif

void main(argc)
    int argc;
   {
    FILE *fp;
    int number;

    if (argc!=1) 
       {/* Print a welcome message if a parameter present */
        printf("\nCookie V2.1\n");
        printf("Written by Aj and Steven Hawtin, 1990.\n");
        printf("Run this program early on from your\n");
        printf("startup-sequence for a deep and meaningful\n");
        printf("piece of advice to start your day with.\n");
        printf("Try redirecting it to your Speech device.\n");
        exit(0);
        }


#ifdef NORTHC
    /* Read the datestamp, assumes you have a real time clock and that 

       SetClock load

    has been done by now */

    DateStamp(&date_now);
    number = date_now.ds_Tick % 50;
#else
    if ((fp=fopen("cookie.file","r+"))==NULL)
        {/* File does not exist, so create it */
         fp=fopen("cookie.file","w+");
         number=0;
         fprintf(fp,"%d",number);
         fclose(fp);
         }
       else
        {/* File does exist, so get number from it */
         fscanf(fp,"%d",&number);
         number++;
         if (number==32) number=0;
             rewind(fp);
         fprintf(fp,"%d",number);
         fclose(fp);
         }
#endif


    printf("\nThought for the day:\n");

    switch (number) 
       {case 0:printf("\n\nFortune Cookie\nWritten by Aj in 1990\n\n'There ain't no dark side of the moon.'\n");break;
        case 1:printf("Meanwhile in Czechoslovakia...");break;
        case 2:printf("Whoops. Sorry about that, just re-formatted your drive.");break;
        case 3:printf("Live long and prosper, Earthling.");break;
        case 4:printf("Remember - it's all just plop.");break;
        case 5:printf("Don't worry, just blame it on Jeff.");break;
        case 6:printf("Beware of the flowers.");break;
        case 7:printf("You're never alone with a stone.");break;
        case 8:printf("Aren't you glad you don't have an ST.");break;
        case 9:printf("It could be worse - you could be bald. Oops, sorry Green.");break;
        case 10:printf("Oh no - I've just put some sugar in my Bovril.");break;
        case 11:printf("I was born under a wandering star.");break;
        case 12:printf("It must be a Thursday - I never could get the hang of Thursdays...");break;
        case 13:printf("Where is the nearest bar that sells Guinness?");break;
        case 14:printf("That was some party. Now what can I do for you?");break;
        case 15:printf("Now is this Wednesday or Thursday?");break;
        case 16:printf("Do not despise the snake because he has no horns, for who may say he will not turn into a dragon?");break;
        case 17:printf("Old programmers never die, they just branch to a new address.");break;
        case 18:printf("Hiya handsome? Watcha doin' after work?");break;
        case 19:printf("Of all the keyboards in all the world, you had to use mine.");break;
        case 20:printf("Do the Shake-and-Vac and put the freshness back.");break;
        case 21:printf("Moon Cresta? Moon-cresta? MOONCRESTA?");break;
        case 22:printf("Smoking is bad for you.");break;
        case 23:printf("Amiga Computing, the only Amiga magazine worth reading.");break;
        case 24:printf("Why is Green so stupid?");break;
        case 25:printf("Is that the phone ringing?");break;
        case 26:printf("Sorry - can't boot CP/M+ on this system.");break;
        case 27:printf("Stop biting your nails.");break;
        case 28:printf("I'm bored - do something interesting.");break;
        case 29:printf("Ok, Ploppypants - what's the news?");break;
        case 30:printf("Well I never! I thought I recognised you! What a coincidence!");break;
        case 31:printf("Uh-oh. Think I have heartburn.");break;
#ifdef NORTHC
        /* Mostly from "Principia Discordia" the only true book */
        case 32:printf("I will see it when I believe it.");break;
        case 33:printf("Hail Eris!  All Hail Discordia!");break;
        case 34:printf("Never take other peoples advice.");break;
        case 35:printf("No girdle ever cured a pregnancy.");break;
        case 36:printf("The opposite of a great truth is also true.");break;
        case 37:printf("'tis an ill wind that blows no minds");break;
        case 38:printf("\"The tide is turning...the enemy is suffering\n");
                printf(" terrible losses...\" - Gen.Geo.A.Custer");break;
        case 39:printf("It is my firm belief that it is a mistake to\n");
                printf("hold firm beliefs");break;
        case 40:printf("\"The State is the kind of organization which,\n");
                printf("though it does big things badly, does small\n");
                printf("things badly too.\" - J.K.Galbraith");break;
        case 41:printf("Remember: King Kong died for your sins"); break;
        case 42:printf("Heute die welt: Morgens das sonnensystem!");break;
        case 43:printf("Question 23: Have you now stopped molesting\n");
                printf("             children.    Yes [ ]  No [ ]");break;
        case 44:printf("When in doubt, **** it.\n");
                printf("When not in doubt...get in doubt!");break;
        case 45:printf("Hemlock? I never touch the stuff");break;
        case 46:printf("Convictions cause convicts");break;
        case 47:printf("Never write in pencil unless you are on a train\n");
                printf("or sick in bed");break;
        case 48:printf("This is a chain letter...\n");
                printf(" next month you will receive 1300 pounds of chains");
                break;
        case 49:printf("Beware! The paranoids are watching you");break;
#endif
        default:;
        }
    printf("\n\n");
    }
