Home » Archimedes archive » Acorn User » AU 1996-12 A.adf » Regulars » C/!Acronyms/SourceCode/c/!RunImage

C/!Acronyms/SourceCode/c/!RunImage

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1996-12 A.adf » Regulars
Filename: C/!Acronyms/SourceCode/c/!RunImage
Read OK:
File size: 45CA bytes
Load address: 0000
Exec address: 0000
File contents
/*      Name: !Acronyms
 *   Purpose: To Give The Meanings To Acronyms
 *    Author: � 1996 Gareth Duncan
 *   Version: 3.75 (28th August 1996)
 * Thanks To: Steve Mumford (Acorn User) and Clifford Downs */

/*INCLUDING ANY LIBRARIES THAT THE PROGRAM WILL NEED*/

#include <stdio.h> /*Standard input output library*/
#include <string.h> /*A library to deal with string operations*/
#include <ctype.h> /*Deals with char characters*/
#include <roslib.h> /*(Easy C RiscOs Lib) Handles risos functions*/
#include "AULib.h" /*The Acorn User library deals with wimp operations*/

/*DEFINING ANY VARIABLES THAT THE PROGRAM WILL USE*/

/*We also define a poll mask here to tell the WIMP about any events we're not
  intererested in*/

/*We are not interested in poll 1 (redraw window)*/
#define POLL_MASK 1
/*Set the number of windows the program uses, 2 in this case*/
#define MAX_WINDOWS 2
/*Set the number of words in the dictionary*/
#define MAX_NO_OF_ACRONYMS 750

/*INITIALSING GLOBAL VARIABLES*/

/*If we set QUIT_FLAG up as a global variable, it means that we can change it
 *anywhere within the program and shut things down next time we end the
 *polling loop*/

int QUIT_FLAG = 0; /*If this is set to 1 the program quits*/
char appname[] = "Acronyms"; /*The name of our application*/
/*Holds the case sensitive and insensitive acronyms along with there meanings*/
char *acronyms_case_in_sens[MAX_NO_OF_ACRONYMS+1];
char *answers_case_in_sens[MAX_NO_OF_ACRONYMS+1];
char *acronyms_case_sens[MAX_NO_OF_ACRONYMS+1];
char *answers_case_sens[MAX_NO_OF_ACRONYMS+1];
/*Initialise the structure that will hold the data for our windows*/
window_data win_array[MAX_WINDOWS];
/*Initialise the structure that will hold the data for our menus*/
menu_data globmen, help_menu, options_menu, openfiles_menu;

/*FUNCTION PROTOTYPING*/

/*The main program function*/
int main(void);
/*Deals with any messages we receive from the wimp*/
void wimpmsg(int, unsigned char[]);
/*Deals with any mouse clicks that involve our program*/
void mouseclick(unsigned char[]);
/*Deals with any key presses*/
void key_press(unsigned char []);
/*Deals with any selections of items from our menus*/
void menuselection(unsigned char[]);
/*Loads the templates that our program will use*/
int load_templates(void);
/*Deals with any requests from the wimp to open one of our windows*/
void openwindow(unsigned char[]);
/*Deals with any requests from the wimp to close one of our windows*/
void  closewindow(unsigned char[]);
/*Load any text files the program needs*/
char *load_text_file(char *file_name);
/*The function that gives the acronyms meanings*/
void check_acronym(void);
/*Finds the size of a file*/
size_t get_file_size(FILE *file_pointer);
/*Loads and sorts out the text files that the program needs*/
void initialise_text_files(void);

/*PROGRAM FUNCTIONS*/

int main(void)
{
  int task_handle; /*Holds the programs task handle*/
  /*A byte array large enough for our polling block*/
  unsigned char pollblock[257];
  int ibar_icon_handle; /*A variable to store our iconbar icon handle*/
  int pollresult; /*This holds the poll instruction that the wimp has sent us*/
  int pass; /*Used in any for loops*/
  /*Set up the acceptable message list for initialisation*/
  long int msglist[1] = {0};


  /*Clear out the acronyms and answers array before they are used*/
  for(pass=0;pass<=MAX_NO_OF_ACRONYMS;pass++)
  {
    acronyms_case_in_sens[pass]="";
    answers_case_in_sens[pass]="";
    acronyms_case_sens[pass]="";
    answers_case_sens[pass]="";
  }

  /*Initialise the task and get it's handle*/
  task_handle = au_initialise(310, appname, msglist);

  /*Load and sort out the text files that the program needs*/
  initialise_text_files();

  /*If the quit flag is not set to quit then run the program*/
  if(QUIT_FLAG!=1)
  {
    /*Now, we'll put an icon on the icon bar*/
    ibar_icon_handle = au_create_iconbar_icon(IBAR_PRIOR_APP,IBAR_ONRIGHT,ICON_ISSPRITE | ICON_HCENTRE | ICON_VCENTRE | ICON_CLICKNOTIFIESONCE,"!acronyms");

    /*Now open a template file ready for loading*/
    load_templates();

    while (QUIT_FLAG == 0) /*While the quit flag is still o*/
    {
      /*Ask the wimp what's going on*/
      pollresult = au_wimp_poll(POLL_MASK, pollblock);
      switch (pollresult)
      {
        /*If the wimp requests us to open a window we go to openwindow*/
        case  2: openwindow(pollblock);
        break;
        /*If the wimp requests us to close a window we go to closewindow*/
        case  3: closewindow(pollblock);
        break;
        /*If there is a mouse click on someting belonging to our program we go
          to mouseclick*/
        case  6: mouseclick(pollblock);
        break;
        /*Act upon any key presses there are*/
        case 8: key_press(pollblock);
        break;
        /*If s selection is made from one of our menus we go to menuselection*/
        case  9: menuselection(pollblock);
        break;
        /*The below section listens for event codes 17, 18 and 19 - the
          ones which indicate we're being sent a message and if we are we go to
          wimpmsg*/
        case 17:
        case 18:
        case 19: wimpmsg(pollresult, pollblock);
        break;
      }
    }
    /*If QUIT_FLAG changes to anything but 0, we stop going round the polling
      loop and shut down */
  }

  /*Close down our program*/
  au_closedown(task_handle);

  /*We Need to release malloc memory from window structures*/
  for(pass=0;pass<MAX_WINDOWS;pass++)
  {
    free(win_array[pass].win_name);
    free(win_array[pass].buffer);
    free(win_array[pass].workspace);
  }
}

void wimpmsg(int result, unsigned char pollblock[])
{
  /*This variable holds the number of the message that we were sent*/
  unsigned long int message_action;

  /*The next line takes bytes 16 to 19 of the polling block and forms them
    into a word holding the message action number*/
  message_action = au_bytetoword(pollblock, 16);

  switch (message_action)
  {
    case 0: QUIT_FLAG = 1; /* A request for our program to quit - time to go */
    break;
  }
}

void menuselection(unsigned char pollblock[])
{

  /*If the selected item is in the Help submenu...*/
  if(au_bytetoword(pollblock, 0) == 1)
  {
    /*...and it is the Help entry*/
    if(au_bytetoword(pollblock, 4) == 0)
    {
      /*Open the Help file*/
      os_cli("Filer_Run <AcronymsDocs$Dir>.Help");
    }

    /*...and it is the History entry*/
    if(au_bytetoword(pollblock, 4) == 1)
    {
      /*Open the History file*/
      os_cli("Filer_Run <AcronymsDocs$Dir>.History");
    }

    /*...and it is the Additional entry*/
    if(au_bytetoword(pollblock, 4) == 2)
    {
      /*Open the Additional file*/
      os_cli("Filer_Run <AcronymsDocs$Dir>.Additional");
    }
  }

  /*If the selected item is in the Options submenu...*/
  if(au_bytetoword(pollblock, 0) == 2)
  {
    /*...and it is in the OpenFiles submenu...*/
    if(au_bytetoword(pollblock, 4) == 0)
    {
      /*...and it is the CaseInSens entry*/
      if(au_bytetoword(pollblock, 8) == 0)
      {
        /*Open the CaseInSens file*/
        os_cli("Filer_Run <AcronymsTextFiles$Dir>.CaseInSens");
      }

      /*...and it is the CaseSens entry*/
      if(au_bytetoword(pollblock, 8) == 1)
      {
        /*Open the CaseSens file*/
        os_cli("Filer_Run <AcronymsTextFiles$Dir>.CaseSens");
      }
    }

    /*...and it is the ScanFiles entry*/
    if(au_bytetoword(pollblock, 4) == 1)
    {
      /*Go to the function initialise_text_files*/
      initialise_text_files();
    }
  }

  /*If the selected item is the quit option*/
  if(au_bytetoword(pollblock, 0) == 3)
  {
    /*Quit the program*/
   QUIT_FLAG = 1;
  }

  return;
}

void mouseclick(unsigned char pollblock[])
{
  char message[255];
  /*A buffer to hold an 'error' message*/
  char *text_pointer; /*A pointer to the icons text*/
  int pass; /*Used in the for loop*/

  int clk; /*Holds the mouse button that was click e.g. Select, Menu etc..*/
  _kernel_swi_regs in, out; /*Sets up the arm registers*/
  unsigned char temp_buffer[255];

  /*Determine which button was pressed*/
  clk = (int) au_bytetoword(pollblock, 8);

  /*If the 'Select' button was clicked...*/

   if(clk == 4)
   {
     /*...on the icon bar then re-open main window and return*/
     if(au_bytetoword(pollblock, 12) == -2)
     {
       au_wordtobyte(win_array[0].win_handle, temp_buffer, 0);
       in.r[1] = (int) temp_buffer;
       _kernel_swi(Wimp_GetWindowInfo, &in, &out);
       _kernel_swi(Wimp_OpenWindow, &in, &out);
       /*Get icon 1's text*/
       text_pointer=au_get_ptr_to_icontext(win_array[0].win_handle,1);
       /*Add a null character to the end of the string*/
       for(pass=0;pass<=19;pass++)
       {
         if(text_pointer[pass] < 32)
         {
           text_pointer[pass] = '\0';
           break;
         }
       }
       /*Give the window the input focus*/
       in.r[0] = (int) win_array[0].win_handle;
       in.r[1] = 1;
       in.r[4] = -1;
       in.r[5] = (int) strlen(text_pointer);
       _kernel_swi(Wimp_SetCaretPosition, &in, &out);
       return;
     }
   }

   /*If 'Menu' has been clicked on the icon bar icon - now we produce
        a menu */

   if((au_bytetoword(pollblock, 12) == -2) && (clk == 2))
   {
     au_buildmenu("Help", &help_menu);
     au_addtomenu("Help", 0, -1, 0, &help_menu);
     au_addtomenu("History", 0, -1, 0, &help_menu);
     au_addtomenu("Additional", MENU_LASTITEM, -1, 0, &help_menu);
     au_createmenu(&help_menu);
     au_buildmenu("OpenFiles", &openfiles_menu);
     au_addtomenu("CaseInSens", 0, -1, 0, &openfiles_menu);
     au_addtomenu("CaseSens", MENU_LASTITEM, -1, 0, &openfiles_menu);
     au_createmenu(&openfiles_menu);
     au_buildmenu("Options", &options_menu);
     au_addtomenu("OpenFiles", 0, (int) openfiles_menu.datablock, 0, &options_menu);
     au_addtomenu("ScanFiles", MENU_LASTITEM, -1, 0, &options_menu);
     au_createmenu(&options_menu);
     au_buildmenu("Acronyms", &globmen);
     au_addtomenu("Info", MENU_DOTTED, win_array[1].win_handle, 0, &globmen);
     au_addtomenu("Help", 0, (int) help_menu.datablock, 0, &globmen);
     au_addtomenu("Options", MENU_DOTTED, (int) options_menu.datablock, 0, &globmen);
     au_addtomenu("Quit", MENU_LASTITEM, -1, 0, &globmen);
     au_createmenu(&globmen);
     au_openmenu(&globmen, (int) au_bytetoword(pollblock, 0) - 64, (44*5)+96);
     return;
   }
}

int load_templates(void)
{
  au_opentemplate("<Acronyms$Dir>.Templates"); /*Open the Templates file*/

  /*If the template could not be found*/
  if(au_loadtemplate("Acronyms", &win_array[0], 0) == 0)
  {
    /*Report that the remplate could not be found*/
    au_report_error(1, "Template not found!", 1, appname);
    QUIT_FLAG = 1; /*And quit the program*/
  }

  /*If the template could not be found*/
  if(au_loadtemplate("Info", &win_array[1], 0) == 0)
  {
    /*Report that the remplate could not be found*/
    au_report_error(1, "Template not found!", 1, appname);
    QUIT_FLAG = 1; /*And quit the program*/
  }

  /* Now we've finished reading the templates, close the file */
  au_closetemplate();
  return 0;
}

void openwindow(unsigned char pollblock[])
{
   _kernel_swi_regs in, out;

   in.r[1] = (int) pollblock;
   _kernel_swi(Wimp_OpenWindow, &in, &out); /*Open the window*/
   return;
}

void closewindow(unsigned char pollblock[])
{
   _kernel_swi_regs in, out;

   in.r[1] = (int) pollblock;
   _kernel_swi(Wimp_CloseWindow, &in, &out); /*Close the window*/
   return;
}

void key_press(unsigned char pollblock[])
{
  _kernel_swi_regs in, out;
  int key; /*Holds the key that was pressed*/

  key=au_bytetoword(pollblock, 24); /*Find out which key was pressed*/

  switch (key)
  {
    /*If the key is F12 tell the wimp to process it*/
    case 460: in.r[0]=key; _kernel_swi(Wimp_ProcessKey, &in, &out);
    break;
    /*If the key is return go to the function check_acronym*/
    case 13: check_acronym(); /*Call the function check_acronym*/
    break;
  }

}

void check_acronym(void)
{
  _kernel_swi_regs in, out;

  int pass; /*Used in the for loop*/
  int match=0; /*If that is 1 a match has been found*/
  int string_length; /*Holds the length of the string*/
  char *text_pointer; /*A pointer to the icons text*/
  char *cp; /*A pointer to the character that will be checked to see if it
       	      is lower case and then converted to upper case if it is*/

  /*Get icon 1's text*/
  text_pointer=au_get_ptr_to_icontext(win_array[0].win_handle,1);

  /*Add a null character to the end of the string*/
  for(pass=0;pass<=19;pass++)
  {
    if(text_pointer[pass] < 32)
    {
      text_pointer[pass] = '\0';
      break;
    }
  }

  for(pass=0;pass<=MAX_NO_OF_ACRONYMS;pass++)
  {
    /*If icon 1's text match's a smiley*/
    if(strcmp(acronyms_case_sens[pass],text_pointer)==0)
    {
      /*Change icon 2's text to the answer*/
      au_icon_text_change(answers_case_sens[pass],win_array[0].win_handle,2);
      match=1; /*Set the match interger to show a match has been found*/
      break; /*Break the loop*/
    }
  }

  if(match == 0) /*If a match has not yet been found*/
  {
    for (cp=text_pointer;cp && *cp;cp++)
    {
      *cp = toupper(*cp); /*Convert the character pointed to by cp to an upper
      	    	    	    case character*/
    }

    /*Set the text in icon 1 to the new upper case string*/
    au_icon_text_change(text_pointer,win_array[0].win_handle,1);

    string_length = strlen(text_pointer);

    in.r[0] = (int) win_array[0].win_handle;
    in.r[1] = 1;
    in.r[4] = -1;
    in.r[5] = (int) string_length;
    _kernel_swi(Wimp_SetCaretPosition, &in, &out);

    for(pass=0;pass<=MAX_NO_OF_ACRONYMS;pass++)
    {
      /*If icon 1's text match's an acronym*/
      if(strcmp(acronyms_case_in_sens[pass],text_pointer)==0)
      {
        /*Change icon 2's text to the answer*/
        au_icon_text_change(answers_case_in_sens[pass],win_array[0].win_handle,2);
        match=1; /*Set the match interger to show a match has been found*/
        break; /*Break the loop*/
      }
    }
  }

  if(match==0) /*If no match is found*/
  {
    /*Set icon 2's text to 'Unknown'*/
    au_icon_text_change("Unknown",win_array[0].win_handle,2);
  }
}

size_t get_file_size(FILE *file_pointer)
{
  /*Find the size of a file pointed to by file_pointer*/
  size_t fSize;

  fseek(file_pointer, 0L, SEEK_END);
  fSize = (size_t) ftell(file_pointer);
  fseek(file_pointer, 0L, SEEK_SET);

  return fSize;
}

void initialise_text_files(void)
{
  char *filebuffer; /*The string read from the file is stored in this char*/
  int pass; /*Used in the for loop*/

  /*Open the CaseInSens file */

  filebuffer=load_text_file("<AcronymsTextFiles$Dir>.CaseInSens");

  /*If the quit flag is set return*/
  if(QUIT_FLAG==1)
  {
    free(filebuffer); /*Frees the memory allocated to filebuffer*/
    return;
  }

  /*Split the acronyms and their answers up*/

  for(pass=0;pass<=MAX_NO_OF_ACRONYMS;pass++)
  {
    /*Place the split strings into the acronyms array*/
    acronyms_case_in_sens[pass] = strtok(filebuffer, "\n");
    filebuffer=0; /*Reset to 0 and repeat with the next split string*/
    /*Place the split strings into the answers array*/
    answers_case_in_sens[pass] = strtok(filebuffer, "\n");
    filebuffer=0; /*Reset to 0 and repeat with the next split string*/
  }

  free(filebuffer); /*Frees the memory allocated to filebuffer*/

  /*Open the CaseSens file */

  filebuffer=load_text_file("<AcronymsTextFiles$Dir>.CaseSens");

  /*If the quit flag is set return*/
  if(QUIT_FLAG==1)
  {
    free(filebuffer); /*Frees the memory allocated to filebuffer*/
    return;
  }

  /*Split the acronyms and their answers up*/

  for(pass=0;pass<=MAX_NO_OF_ACRONYMS;pass++)
  {
    /*Place the split strings into the acronyms array*/
    acronyms_case_sens[pass] = strtok(filebuffer, "\n");
    filebuffer=0; /*Reset to 0 and repeat with the next split string*/
    /*Place the split strings into the answers array*/
    answers_case_sens[pass] = strtok(filebuffer, "\n");
    filebuffer=0; /*Reset to 0 and repeat with the next split string*/
  }

  free(filebuffer); /*Frees the memory allocated to filebuffer*/
}

char *load_text_file(char *file_name)
{
  FILE *fpoint; /*A pointer to an open file*/
  size_t fSize; /*The size of the open file*/
  char *error_message=""; /*Holds any error message text*/
  char *filebuffer; /*The string read from the file is stored in this char*/
  int count=0;

  /*Open the text file */

  if ((fpoint = fopen(file_name, "r")) == NULL)
  {
    error_message="Failed to open file ";
    strcat(error_message,file_name);
    au_report_error(1, error_message, 1, appname);
    QUIT_FLAG = 1; /*And quit the program*/
    return filebuffer;
  }

  /*Find out how big the file is and store that number in fsize */

  fSize = get_file_size(fpoint);

  /*Get memory for the string plus one byte for the terminator */

  if ((filebuffer = (char *) malloc(fSize+1)) == NULL)
  {
    error_message="Failed to claim enough to load file ";
    strcat(error_message,file_name);
    au_report_error(1, error_message, 1, appname);
    QUIT_FLAG = 1; /*And quit the program*/
    return filebuffer;
  }

  /*Read the text from the file into filebuffer*/

  if (fread(filebuffer, fSize, 1, fpoint) !=1)
  {
    error_message="Failed to read file ";
    strcat(error_message,file_name);
    au_report_error(1, error_message, 1, appname);
    QUIT_FLAG = 1; /*And quit the program*/
    return filebuffer;
  }

  /*Close the open file*/

  if (fclose(fpoint) !=0)
  {
    error_message="Failed to close file ";
    strcat(error_message,file_name);
    au_report_error(1, error_message, 1, appname);
    QUIT_FLAG = 1; /*And quit the program*/
    return filebuffer;
  }

  /*Add a terminator to the end of the string*/

  filebuffer[fSize] = '\0';

  return filebuffer;
}
00000000  2f 2a 20 20 20 20 20 20  4e 61 6d 65 3a 20 21 41  |/*      Name: !A|
00000010  63 72 6f 6e 79 6d 73 0a  20 2a 20 20 20 50 75 72  |cronyms. *   Pur|
00000020  70 6f 73 65 3a 20 54 6f  20 47 69 76 65 20 54 68  |pose: To Give Th|
00000030  65 20 4d 65 61 6e 69 6e  67 73 20 54 6f 20 41 63  |e Meanings To Ac|
00000040  72 6f 6e 79 6d 73 0a 20  2a 20 20 20 20 41 75 74  |ronyms. *    Aut|
00000050  68 6f 72 3a 20 a9 20 31  39 39 36 20 47 61 72 65  |hor: . 1996 Gare|
00000060  74 68 20 44 75 6e 63 61  6e 0a 20 2a 20 20 20 56  |th Duncan. *   V|
00000070  65 72 73 69 6f 6e 3a 20  33 2e 37 35 20 28 32 38  |ersion: 3.75 (28|
00000080  74 68 20 41 75 67 75 73  74 20 31 39 39 36 29 0a  |th August 1996).|
00000090  20 2a 20 54 68 61 6e 6b  73 20 54 6f 3a 20 53 74  | * Thanks To: St|
000000a0  65 76 65 20 4d 75 6d 66  6f 72 64 20 28 41 63 6f  |eve Mumford (Aco|
000000b0  72 6e 20 55 73 65 72 29  20 61 6e 64 20 43 6c 69  |rn User) and Cli|
000000c0  66 66 6f 72 64 20 44 6f  77 6e 73 20 2a 2f 0a 0a  |fford Downs */..|
000000d0  2f 2a 49 4e 43 4c 55 44  49 4e 47 20 41 4e 59 20  |/*INCLUDING ANY |
000000e0  4c 49 42 52 41 52 49 45  53 20 54 48 41 54 20 54  |LIBRARIES THAT T|
000000f0  48 45 20 50 52 4f 47 52  41 4d 20 57 49 4c 4c 20  |HE PROGRAM WILL |
00000100  4e 45 45 44 2a 2f 0a 0a  23 69 6e 63 6c 75 64 65  |NEED*/..#include|
00000110  20 3c 73 74 64 69 6f 2e  68 3e 20 2f 2a 53 74 61  | <stdio.h> /*Sta|
00000120  6e 64 61 72 64 20 69 6e  70 75 74 20 6f 75 74 70  |ndard input outp|
00000130  75 74 20 6c 69 62 72 61  72 79 2a 2f 0a 23 69 6e  |ut library*/.#in|
00000140  63 6c 75 64 65 20 3c 73  74 72 69 6e 67 2e 68 3e  |clude <string.h>|
00000150  20 2f 2a 41 20 6c 69 62  72 61 72 79 20 74 6f 20  | /*A library to |
00000160  64 65 61 6c 20 77 69 74  68 20 73 74 72 69 6e 67  |deal with string|
00000170  20 6f 70 65 72 61 74 69  6f 6e 73 2a 2f 0a 23 69  | operations*/.#i|
00000180  6e 63 6c 75 64 65 20 3c  63 74 79 70 65 2e 68 3e  |nclude <ctype.h>|
00000190  20 2f 2a 44 65 61 6c 73  20 77 69 74 68 20 63 68  | /*Deals with ch|
000001a0  61 72 20 63 68 61 72 61  63 74 65 72 73 2a 2f 0a  |ar characters*/.|
000001b0  23 69 6e 63 6c 75 64 65  20 3c 72 6f 73 6c 69 62  |#include <roslib|
000001c0  2e 68 3e 20 2f 2a 28 45  61 73 79 20 43 20 52 69  |.h> /*(Easy C Ri|
000001d0  73 63 4f 73 20 4c 69 62  29 20 48 61 6e 64 6c 65  |scOs Lib) Handle|
000001e0  73 20 72 69 73 6f 73 20  66 75 6e 63 74 69 6f 6e  |s risos function|
000001f0  73 2a 2f 0a 23 69 6e 63  6c 75 64 65 20 22 41 55  |s*/.#include "AU|
00000200  4c 69 62 2e 68 22 20 2f  2a 54 68 65 20 41 63 6f  |Lib.h" /*The Aco|
00000210  72 6e 20 55 73 65 72 20  6c 69 62 72 61 72 79 20  |rn User library |
00000220  64 65 61 6c 73 20 77 69  74 68 20 77 69 6d 70 20  |deals with wimp |
00000230  6f 70 65 72 61 74 69 6f  6e 73 2a 2f 0a 0a 2f 2a  |operations*/../*|
00000240  44 45 46 49 4e 49 4e 47  20 41 4e 59 20 56 41 52  |DEFINING ANY VAR|
00000250  49 41 42 4c 45 53 20 54  48 41 54 20 54 48 45 20  |IABLES THAT THE |
00000260  50 52 4f 47 52 41 4d 20  57 49 4c 4c 20 55 53 45  |PROGRAM WILL USE|
00000270  2a 2f 0a 0a 2f 2a 57 65  20 61 6c 73 6f 20 64 65  |*/../*We also de|
00000280  66 69 6e 65 20 61 20 70  6f 6c 6c 20 6d 61 73 6b  |fine a poll mask|
00000290  20 68 65 72 65 20 74 6f  20 74 65 6c 6c 20 74 68  | here to tell th|
000002a0  65 20 57 49 4d 50 20 61  62 6f 75 74 20 61 6e 79  |e WIMP about any|
000002b0  20 65 76 65 6e 74 73 20  77 65 27 72 65 20 6e 6f  | events we're no|
000002c0  74 0a 20 20 69 6e 74 65  72 65 72 65 73 74 65 64  |t.  intererested|
000002d0  20 69 6e 2a 2f 0a 0a 2f  2a 57 65 20 61 72 65 20  | in*/../*We are |
000002e0  6e 6f 74 20 69 6e 74 65  72 65 73 74 65 64 20 69  |not interested i|
000002f0  6e 20 70 6f 6c 6c 20 31  20 28 72 65 64 72 61 77  |n poll 1 (redraw|
00000300  20 77 69 6e 64 6f 77 29  2a 2f 0a 23 64 65 66 69  | window)*/.#defi|
00000310  6e 65 20 50 4f 4c 4c 5f  4d 41 53 4b 20 31 0a 2f  |ne POLL_MASK 1./|
00000320  2a 53 65 74 20 74 68 65  20 6e 75 6d 62 65 72 20  |*Set the number |
00000330  6f 66 20 77 69 6e 64 6f  77 73 20 74 68 65 20 70  |of windows the p|
00000340  72 6f 67 72 61 6d 20 75  73 65 73 2c 20 32 20 69  |rogram uses, 2 i|
00000350  6e 20 74 68 69 73 20 63  61 73 65 2a 2f 0a 23 64  |n this case*/.#d|
00000360  65 66 69 6e 65 20 4d 41  58 5f 57 49 4e 44 4f 57  |efine MAX_WINDOW|
00000370  53 20 32 0a 2f 2a 53 65  74 20 74 68 65 20 6e 75  |S 2./*Set the nu|
00000380  6d 62 65 72 20 6f 66 20  77 6f 72 64 73 20 69 6e  |mber of words in|
00000390  20 74 68 65 20 64 69 63  74 69 6f 6e 61 72 79 2a  | the dictionary*|
000003a0  2f 0a 23 64 65 66 69 6e  65 20 4d 41 58 5f 4e 4f  |/.#define MAX_NO|
000003b0  5f 4f 46 5f 41 43 52 4f  4e 59 4d 53 20 37 35 30  |_OF_ACRONYMS 750|
000003c0  0a 0a 2f 2a 49 4e 49 54  49 41 4c 53 49 4e 47 20  |../*INITIALSING |
000003d0  47 4c 4f 42 41 4c 20 56  41 52 49 41 42 4c 45 53  |GLOBAL VARIABLES|
000003e0  2a 2f 0a 0a 2f 2a 49 66  20 77 65 20 73 65 74 20  |*/../*If we set |
000003f0  51 55 49 54 5f 46 4c 41  47 20 75 70 20 61 73 20  |QUIT_FLAG up as |
00000400  61 20 67 6c 6f 62 61 6c  20 76 61 72 69 61 62 6c  |a global variabl|
00000410  65 2c 20 69 74 20 6d 65  61 6e 73 20 74 68 61 74  |e, it means that|
00000420  20 77 65 20 63 61 6e 20  63 68 61 6e 67 65 20 69  | we can change i|
00000430  74 0a 20 2a 61 6e 79 77  68 65 72 65 20 77 69 74  |t. *anywhere wit|
00000440  68 69 6e 20 74 68 65 20  70 72 6f 67 72 61 6d 20  |hin the program |
00000450  61 6e 64 20 73 68 75 74  20 74 68 69 6e 67 73 20  |and shut things |
00000460  64 6f 77 6e 20 6e 65 78  74 20 74 69 6d 65 20 77  |down next time w|
00000470  65 20 65 6e 64 20 74 68  65 0a 20 2a 70 6f 6c 6c  |e end the. *poll|
00000480  69 6e 67 20 6c 6f 6f 70  2a 2f 0a 0a 69 6e 74 20  |ing loop*/..int |
00000490  51 55 49 54 5f 46 4c 41  47 20 3d 20 30 3b 20 2f  |QUIT_FLAG = 0; /|
000004a0  2a 49 66 20 74 68 69 73  20 69 73 20 73 65 74 20  |*If this is set |
000004b0  74 6f 20 31 20 74 68 65  20 70 72 6f 67 72 61 6d  |to 1 the program|
000004c0  20 71 75 69 74 73 2a 2f  0a 63 68 61 72 20 61 70  | quits*/.char ap|
000004d0  70 6e 61 6d 65 5b 5d 20  3d 20 22 41 63 72 6f 6e  |pname[] = "Acron|
000004e0  79 6d 73 22 3b 20 2f 2a  54 68 65 20 6e 61 6d 65  |yms"; /*The name|
000004f0  20 6f 66 20 6f 75 72 20  61 70 70 6c 69 63 61 74  | of our applicat|
00000500  69 6f 6e 2a 2f 0a 2f 2a  48 6f 6c 64 73 20 74 68  |ion*/./*Holds th|
00000510  65 20 63 61 73 65 20 73  65 6e 73 69 74 69 76 65  |e case sensitive|
00000520  20 61 6e 64 20 69 6e 73  65 6e 73 69 74 69 76 65  | and insensitive|
00000530  20 61 63 72 6f 6e 79 6d  73 20 61 6c 6f 6e 67 20  | acronyms along |
00000540  77 69 74 68 20 74 68 65  72 65 20 6d 65 61 6e 69  |with there meani|
00000550  6e 67 73 2a 2f 0a 63 68  61 72 20 2a 61 63 72 6f  |ngs*/.char *acro|
00000560  6e 79 6d 73 5f 63 61 73  65 5f 69 6e 5f 73 65 6e  |nyms_case_in_sen|
00000570  73 5b 4d 41 58 5f 4e 4f  5f 4f 46 5f 41 43 52 4f  |s[MAX_NO_OF_ACRO|
00000580  4e 59 4d 53 2b 31 5d 3b  0a 63 68 61 72 20 2a 61  |NYMS+1];.char *a|
00000590  6e 73 77 65 72 73 5f 63  61 73 65 5f 69 6e 5f 73  |nswers_case_in_s|
000005a0  65 6e 73 5b 4d 41 58 5f  4e 4f 5f 4f 46 5f 41 43  |ens[MAX_NO_OF_AC|
000005b0  52 4f 4e 59 4d 53 2b 31  5d 3b 0a 63 68 61 72 20  |RONYMS+1];.char |
000005c0  2a 61 63 72 6f 6e 79 6d  73 5f 63 61 73 65 5f 73  |*acronyms_case_s|
000005d0  65 6e 73 5b 4d 41 58 5f  4e 4f 5f 4f 46 5f 41 43  |ens[MAX_NO_OF_AC|
000005e0  52 4f 4e 59 4d 53 2b 31  5d 3b 0a 63 68 61 72 20  |RONYMS+1];.char |
000005f0  2a 61 6e 73 77 65 72 73  5f 63 61 73 65 5f 73 65  |*answers_case_se|
00000600  6e 73 5b 4d 41 58 5f 4e  4f 5f 4f 46 5f 41 43 52  |ns[MAX_NO_OF_ACR|
00000610  4f 4e 59 4d 53 2b 31 5d  3b 0a 2f 2a 49 6e 69 74  |ONYMS+1];./*Init|
00000620  69 61 6c 69 73 65 20 74  68 65 20 73 74 72 75 63  |ialise the struc|
00000630  74 75 72 65 20 74 68 61  74 20 77 69 6c 6c 20 68  |ture that will h|
00000640  6f 6c 64 20 74 68 65 20  64 61 74 61 20 66 6f 72  |old the data for|
00000650  20 6f 75 72 20 77 69 6e  64 6f 77 73 2a 2f 0a 77  | our windows*/.w|
00000660  69 6e 64 6f 77 5f 64 61  74 61 20 77 69 6e 5f 61  |indow_data win_a|
00000670  72 72 61 79 5b 4d 41 58  5f 57 49 4e 44 4f 57 53  |rray[MAX_WINDOWS|
00000680  5d 3b 0a 2f 2a 49 6e 69  74 69 61 6c 69 73 65 20  |];./*Initialise |
00000690  74 68 65 20 73 74 72 75  63 74 75 72 65 20 74 68  |the structure th|
000006a0  61 74 20 77 69 6c 6c 20  68 6f 6c 64 20 74 68 65  |at will hold the|
000006b0  20 64 61 74 61 20 66 6f  72 20 6f 75 72 20 6d 65  | data for our me|
000006c0  6e 75 73 2a 2f 0a 6d 65  6e 75 5f 64 61 74 61 20  |nus*/.menu_data |
000006d0  67 6c 6f 62 6d 65 6e 2c  20 68 65 6c 70 5f 6d 65  |globmen, help_me|
000006e0  6e 75 2c 20 6f 70 74 69  6f 6e 73 5f 6d 65 6e 75  |nu, options_menu|
000006f0  2c 20 6f 70 65 6e 66 69  6c 65 73 5f 6d 65 6e 75  |, openfiles_menu|
00000700  3b 0a 0a 2f 2a 46 55 4e  43 54 49 4f 4e 20 50 52  |;../*FUNCTION PR|
00000710  4f 54 4f 54 59 50 49 4e  47 2a 2f 0a 0a 2f 2a 54  |OTOTYPING*/../*T|
00000720  68 65 20 6d 61 69 6e 20  70 72 6f 67 72 61 6d 20  |he main program |
00000730  66 75 6e 63 74 69 6f 6e  2a 2f 0a 69 6e 74 20 6d  |function*/.int m|
00000740  61 69 6e 28 76 6f 69 64  29 3b 0a 2f 2a 44 65 61  |ain(void);./*Dea|
00000750  6c 73 20 77 69 74 68 20  61 6e 79 20 6d 65 73 73  |ls with any mess|
00000760  61 67 65 73 20 77 65 20  72 65 63 65 69 76 65 20  |ages we receive |
00000770  66 72 6f 6d 20 74 68 65  20 77 69 6d 70 2a 2f 0a  |from the wimp*/.|
00000780  76 6f 69 64 20 77 69 6d  70 6d 73 67 28 69 6e 74  |void wimpmsg(int|
00000790  2c 20 75 6e 73 69 67 6e  65 64 20 63 68 61 72 5b  |, unsigned char[|
000007a0  5d 29 3b 0a 2f 2a 44 65  61 6c 73 20 77 69 74 68  |]);./*Deals with|
000007b0  20 61 6e 79 20 6d 6f 75  73 65 20 63 6c 69 63 6b  | any mouse click|
000007c0  73 20 74 68 61 74 20 69  6e 76 6f 6c 76 65 20 6f  |s that involve o|
000007d0  75 72 20 70 72 6f 67 72  61 6d 2a 2f 0a 76 6f 69  |ur program*/.voi|
000007e0  64 20 6d 6f 75 73 65 63  6c 69 63 6b 28 75 6e 73  |d mouseclick(uns|
000007f0  69 67 6e 65 64 20 63 68  61 72 5b 5d 29 3b 0a 2f  |igned char[]);./|
00000800  2a 44 65 61 6c 73 20 77  69 74 68 20 61 6e 79 20  |*Deals with any |
00000810  6b 65 79 20 70 72 65 73  73 65 73 2a 2f 0a 76 6f  |key presses*/.vo|
00000820  69 64 20 6b 65 79 5f 70  72 65 73 73 28 75 6e 73  |id key_press(uns|
00000830  69 67 6e 65 64 20 63 68  61 72 20 5b 5d 29 3b 0a  |igned char []);.|
00000840  2f 2a 44 65 61 6c 73 20  77 69 74 68 20 61 6e 79  |/*Deals with any|
00000850  20 73 65 6c 65 63 74 69  6f 6e 73 20 6f 66 20 69  | selections of i|
00000860  74 65 6d 73 20 66 72 6f  6d 20 6f 75 72 20 6d 65  |tems from our me|
00000870  6e 75 73 2a 2f 0a 76 6f  69 64 20 6d 65 6e 75 73  |nus*/.void menus|
00000880  65 6c 65 63 74 69 6f 6e  28 75 6e 73 69 67 6e 65  |election(unsigne|
00000890  64 20 63 68 61 72 5b 5d  29 3b 0a 2f 2a 4c 6f 61  |d char[]);./*Loa|
000008a0  64 73 20 74 68 65 20 74  65 6d 70 6c 61 74 65 73  |ds the templates|
000008b0  20 74 68 61 74 20 6f 75  72 20 70 72 6f 67 72 61  | that our progra|
000008c0  6d 20 77 69 6c 6c 20 75  73 65 2a 2f 0a 69 6e 74  |m will use*/.int|
000008d0  20 6c 6f 61 64 5f 74 65  6d 70 6c 61 74 65 73 28  | load_templates(|
000008e0  76 6f 69 64 29 3b 0a 2f  2a 44 65 61 6c 73 20 77  |void);./*Deals w|
000008f0  69 74 68 20 61 6e 79 20  72 65 71 75 65 73 74 73  |ith any requests|
00000900  20 66 72 6f 6d 20 74 68  65 20 77 69 6d 70 20 74  | from the wimp t|
00000910  6f 20 6f 70 65 6e 20 6f  6e 65 20 6f 66 20 6f 75  |o open one of ou|
00000920  72 20 77 69 6e 64 6f 77  73 2a 2f 0a 76 6f 69 64  |r windows*/.void|
00000930  20 6f 70 65 6e 77 69 6e  64 6f 77 28 75 6e 73 69  | openwindow(unsi|
00000940  67 6e 65 64 20 63 68 61  72 5b 5d 29 3b 0a 2f 2a  |gned char[]);./*|
00000950  44 65 61 6c 73 20 77 69  74 68 20 61 6e 79 20 72  |Deals with any r|
00000960  65 71 75 65 73 74 73 20  66 72 6f 6d 20 74 68 65  |equests from the|
00000970  20 77 69 6d 70 20 74 6f  20 63 6c 6f 73 65 20 6f  | wimp to close o|
00000980  6e 65 20 6f 66 20 6f 75  72 20 77 69 6e 64 6f 77  |ne of our window|
00000990  73 2a 2f 0a 76 6f 69 64  20 20 63 6c 6f 73 65 77  |s*/.void  closew|
000009a0  69 6e 64 6f 77 28 75 6e  73 69 67 6e 65 64 20 63  |indow(unsigned c|
000009b0  68 61 72 5b 5d 29 3b 0a  2f 2a 4c 6f 61 64 20 61  |har[]);./*Load a|
000009c0  6e 79 20 74 65 78 74 20  66 69 6c 65 73 20 74 68  |ny text files th|
000009d0  65 20 70 72 6f 67 72 61  6d 20 6e 65 65 64 73 2a  |e program needs*|
000009e0  2f 0a 63 68 61 72 20 2a  6c 6f 61 64 5f 74 65 78  |/.char *load_tex|
000009f0  74 5f 66 69 6c 65 28 63  68 61 72 20 2a 66 69 6c  |t_file(char *fil|
00000a00  65 5f 6e 61 6d 65 29 3b  0a 2f 2a 54 68 65 20 66  |e_name);./*The f|
00000a10  75 6e 63 74 69 6f 6e 20  74 68 61 74 20 67 69 76  |unction that giv|
00000a20  65 73 20 74 68 65 20 61  63 72 6f 6e 79 6d 73 20  |es the acronyms |
00000a30  6d 65 61 6e 69 6e 67 73  2a 2f 0a 76 6f 69 64 20  |meanings*/.void |
00000a40  63 68 65 63 6b 5f 61 63  72 6f 6e 79 6d 28 76 6f  |check_acronym(vo|
00000a50  69 64 29 3b 0a 2f 2a 46  69 6e 64 73 20 74 68 65  |id);./*Finds the|
00000a60  20 73 69 7a 65 20 6f 66  20 61 20 66 69 6c 65 2a  | size of a file*|
00000a70  2f 0a 73 69 7a 65 5f 74  20 67 65 74 5f 66 69 6c  |/.size_t get_fil|
00000a80  65 5f 73 69 7a 65 28 46  49 4c 45 20 2a 66 69 6c  |e_size(FILE *fil|
00000a90  65 5f 70 6f 69 6e 74 65  72 29 3b 0a 2f 2a 4c 6f  |e_pointer);./*Lo|
00000aa0  61 64 73 20 61 6e 64 20  73 6f 72 74 73 20 6f 75  |ads and sorts ou|
00000ab0  74 20 74 68 65 20 74 65  78 74 20 66 69 6c 65 73  |t the text files|
00000ac0  20 74 68 61 74 20 74 68  65 20 70 72 6f 67 72 61  | that the progra|
00000ad0  6d 20 6e 65 65 64 73 2a  2f 0a 76 6f 69 64 20 69  |m needs*/.void i|
00000ae0  6e 69 74 69 61 6c 69 73  65 5f 74 65 78 74 5f 66  |nitialise_text_f|
00000af0  69 6c 65 73 28 76 6f 69  64 29 3b 0a 0a 2f 2a 50  |iles(void);../*P|
00000b00  52 4f 47 52 41 4d 20 46  55 4e 43 54 49 4f 4e 53  |ROGRAM FUNCTIONS|
00000b10  2a 2f 0a 0a 69 6e 74 20  6d 61 69 6e 28 76 6f 69  |*/..int main(voi|
00000b20  64 29 0a 7b 0a 20 20 69  6e 74 20 74 61 73 6b 5f  |d).{.  int task_|
00000b30  68 61 6e 64 6c 65 3b 20  2f 2a 48 6f 6c 64 73 20  |handle; /*Holds |
00000b40  74 68 65 20 70 72 6f 67  72 61 6d 73 20 74 61 73  |the programs tas|
00000b50  6b 20 68 61 6e 64 6c 65  2a 2f 0a 20 20 2f 2a 41  |k handle*/.  /*A|
00000b60  20 62 79 74 65 20 61 72  72 61 79 20 6c 61 72 67  | byte array larg|
00000b70  65 20 65 6e 6f 75 67 68  20 66 6f 72 20 6f 75 72  |e enough for our|
00000b80  20 70 6f 6c 6c 69 6e 67  20 62 6c 6f 63 6b 2a 2f  | polling block*/|
00000b90  0a 20 20 75 6e 73 69 67  6e 65 64 20 63 68 61 72  |.  unsigned char|
00000ba0  20 70 6f 6c 6c 62 6c 6f  63 6b 5b 32 35 37 5d 3b  | pollblock[257];|
00000bb0  0a 20 20 69 6e 74 20 69  62 61 72 5f 69 63 6f 6e  |.  int ibar_icon|
00000bc0  5f 68 61 6e 64 6c 65 3b  20 2f 2a 41 20 76 61 72  |_handle; /*A var|
00000bd0  69 61 62 6c 65 20 74 6f  20 73 74 6f 72 65 20 6f  |iable to store o|
00000be0  75 72 20 69 63 6f 6e 62  61 72 20 69 63 6f 6e 20  |ur iconbar icon |
00000bf0  68 61 6e 64 6c 65 2a 2f  0a 20 20 69 6e 74 20 70  |handle*/.  int p|
00000c00  6f 6c 6c 72 65 73 75 6c  74 3b 20 2f 2a 54 68 69  |ollresult; /*Thi|
00000c10  73 20 68 6f 6c 64 73 20  74 68 65 20 70 6f 6c 6c  |s holds the poll|
00000c20  20 69 6e 73 74 72 75 63  74 69 6f 6e 20 74 68 61  | instruction tha|
00000c30  74 20 74 68 65 20 77 69  6d 70 20 68 61 73 20 73  |t the wimp has s|
00000c40  65 6e 74 20 75 73 2a 2f  0a 20 20 69 6e 74 20 70  |ent us*/.  int p|
00000c50  61 73 73 3b 20 2f 2a 55  73 65 64 20 69 6e 20 61  |ass; /*Used in a|
00000c60  6e 79 20 66 6f 72 20 6c  6f 6f 70 73 2a 2f 0a 20  |ny for loops*/. |
00000c70  20 2f 2a 53 65 74 20 75  70 20 74 68 65 20 61 63  | /*Set up the ac|
00000c80  63 65 70 74 61 62 6c 65  20 6d 65 73 73 61 67 65  |ceptable message|
00000c90  20 6c 69 73 74 20 66 6f  72 20 69 6e 69 74 69 61  | list for initia|
00000ca0  6c 69 73 61 74 69 6f 6e  2a 2f 0a 20 20 6c 6f 6e  |lisation*/.  lon|
00000cb0  67 20 69 6e 74 20 6d 73  67 6c 69 73 74 5b 31 5d  |g int msglist[1]|
00000cc0  20 3d 20 7b 30 7d 3b 0a  0a 0a 20 20 2f 2a 43 6c  | = {0};...  /*Cl|
00000cd0  65 61 72 20 6f 75 74 20  74 68 65 20 61 63 72 6f  |ear out the acro|
00000ce0  6e 79 6d 73 20 61 6e 64  20 61 6e 73 77 65 72 73  |nyms and answers|
00000cf0  20 61 72 72 61 79 20 62  65 66 6f 72 65 20 74 68  | array before th|
00000d00  65 79 20 61 72 65 20 75  73 65 64 2a 2f 0a 20 20  |ey are used*/.  |
00000d10  66 6f 72 28 70 61 73 73  3d 30 3b 70 61 73 73 3c  |for(pass=0;pass<|
00000d20  3d 4d 41 58 5f 4e 4f 5f  4f 46 5f 41 43 52 4f 4e  |=MAX_NO_OF_ACRON|
00000d30  59 4d 53 3b 70 61 73 73  2b 2b 29 0a 20 20 7b 0a  |YMS;pass++).  {.|
00000d40  20 20 20 20 61 63 72 6f  6e 79 6d 73 5f 63 61 73  |    acronyms_cas|
00000d50  65 5f 69 6e 5f 73 65 6e  73 5b 70 61 73 73 5d 3d  |e_in_sens[pass]=|
00000d60  22 22 3b 0a 20 20 20 20  61 6e 73 77 65 72 73 5f  |"";.    answers_|
00000d70  63 61 73 65 5f 69 6e 5f  73 65 6e 73 5b 70 61 73  |case_in_sens[pas|
00000d80  73 5d 3d 22 22 3b 0a 20  20 20 20 61 63 72 6f 6e  |s]="";.    acron|
00000d90  79 6d 73 5f 63 61 73 65  5f 73 65 6e 73 5b 70 61  |yms_case_sens[pa|
00000da0  73 73 5d 3d 22 22 3b 0a  20 20 20 20 61 6e 73 77  |ss]="";.    answ|
00000db0  65 72 73 5f 63 61 73 65  5f 73 65 6e 73 5b 70 61  |ers_case_sens[pa|
00000dc0  73 73 5d 3d 22 22 3b 0a  20 20 7d 0a 0a 20 20 2f  |ss]="";.  }..  /|
00000dd0  2a 49 6e 69 74 69 61 6c  69 73 65 20 74 68 65 20  |*Initialise the |
00000de0  74 61 73 6b 20 61 6e 64  20 67 65 74 20 69 74 27  |task and get it'|
00000df0  73 20 68 61 6e 64 6c 65  2a 2f 0a 20 20 74 61 73  |s handle*/.  tas|
00000e00  6b 5f 68 61 6e 64 6c 65  20 3d 20 61 75 5f 69 6e  |k_handle = au_in|
00000e10  69 74 69 61 6c 69 73 65  28 33 31 30 2c 20 61 70  |itialise(310, ap|
00000e20  70 6e 61 6d 65 2c 20 6d  73 67 6c 69 73 74 29 3b  |pname, msglist);|
00000e30  0a 0a 20 20 2f 2a 4c 6f  61 64 20 61 6e 64 20 73  |..  /*Load and s|
00000e40  6f 72 74 20 6f 75 74 20  74 68 65 20 74 65 78 74  |ort out the text|
00000e50  20 66 69 6c 65 73 20 74  68 61 74 20 74 68 65 20  | files that the |
00000e60  70 72 6f 67 72 61 6d 20  6e 65 65 64 73 2a 2f 0a  |program needs*/.|
00000e70  20 20 69 6e 69 74 69 61  6c 69 73 65 5f 74 65 78  |  initialise_tex|
00000e80  74 5f 66 69 6c 65 73 28  29 3b 0a 0a 20 20 2f 2a  |t_files();..  /*|
00000e90  49 66 20 74 68 65 20 71  75 69 74 20 66 6c 61 67  |If the quit flag|
00000ea0  20 69 73 20 6e 6f 74 20  73 65 74 20 74 6f 20 71  | is not set to q|
00000eb0  75 69 74 20 74 68 65 6e  20 72 75 6e 20 74 68 65  |uit then run the|
00000ec0  20 70 72 6f 67 72 61 6d  2a 2f 0a 20 20 69 66 28  | program*/.  if(|
00000ed0  51 55 49 54 5f 46 4c 41  47 21 3d 31 29 0a 20 20  |QUIT_FLAG!=1).  |
00000ee0  7b 0a 20 20 20 20 2f 2a  4e 6f 77 2c 20 77 65 27  |{.    /*Now, we'|
00000ef0  6c 6c 20 70 75 74 20 61  6e 20 69 63 6f 6e 20 6f  |ll put an icon o|
00000f00  6e 20 74 68 65 20 69 63  6f 6e 20 62 61 72 2a 2f  |n the icon bar*/|
00000f10  0a 20 20 20 20 69 62 61  72 5f 69 63 6f 6e 5f 68  |.    ibar_icon_h|
00000f20  61 6e 64 6c 65 20 3d 20  61 75 5f 63 72 65 61 74  |andle = au_creat|
00000f30  65 5f 69 63 6f 6e 62 61  72 5f 69 63 6f 6e 28 49  |e_iconbar_icon(I|
00000f40  42 41 52 5f 50 52 49 4f  52 5f 41 50 50 2c 49 42  |BAR_PRIOR_APP,IB|
00000f50  41 52 5f 4f 4e 52 49 47  48 54 2c 49 43 4f 4e 5f  |AR_ONRIGHT,ICON_|
00000f60  49 53 53 50 52 49 54 45  20 7c 20 49 43 4f 4e 5f  |ISSPRITE | ICON_|
00000f70  48 43 45 4e 54 52 45 20  7c 20 49 43 4f 4e 5f 56  |HCENTRE | ICON_V|
00000f80  43 45 4e 54 52 45 20 7c  20 49 43 4f 4e 5f 43 4c  |CENTRE | ICON_CL|
00000f90  49 43 4b 4e 4f 54 49 46  49 45 53 4f 4e 43 45 2c  |ICKNOTIFIESONCE,|
00000fa0  22 21 61 63 72 6f 6e 79  6d 73 22 29 3b 0a 0a 20  |"!acronyms");.. |
00000fb0  20 20 20 2f 2a 4e 6f 77  20 6f 70 65 6e 20 61 20  |   /*Now open a |
00000fc0  74 65 6d 70 6c 61 74 65  20 66 69 6c 65 20 72 65  |template file re|
00000fd0  61 64 79 20 66 6f 72 20  6c 6f 61 64 69 6e 67 2a  |ady for loading*|
00000fe0  2f 0a 20 20 20 20 6c 6f  61 64 5f 74 65 6d 70 6c  |/.    load_templ|
00000ff0  61 74 65 73 28 29 3b 0a  0a 20 20 20 20 77 68 69  |ates();..    whi|
00001000  6c 65 20 28 51 55 49 54  5f 46 4c 41 47 20 3d 3d  |le (QUIT_FLAG ==|
00001010  20 30 29 20 2f 2a 57 68  69 6c 65 20 74 68 65 20  | 0) /*While the |
00001020  71 75 69 74 20 66 6c 61  67 20 69 73 20 73 74 69  |quit flag is sti|
00001030  6c 6c 20 6f 2a 2f 0a 20  20 20 20 7b 0a 20 20 20  |ll o*/.    {.   |
00001040  20 20 20 2f 2a 41 73 6b  20 74 68 65 20 77 69 6d  |   /*Ask the wim|
00001050  70 20 77 68 61 74 27 73  20 67 6f 69 6e 67 20 6f  |p what's going o|
00001060  6e 2a 2f 0a 20 20 20 20  20 20 70 6f 6c 6c 72 65  |n*/.      pollre|
00001070  73 75 6c 74 20 3d 20 61  75 5f 77 69 6d 70 5f 70  |sult = au_wimp_p|
00001080  6f 6c 6c 28 50 4f 4c 4c  5f 4d 41 53 4b 2c 20 70  |oll(POLL_MASK, p|
00001090  6f 6c 6c 62 6c 6f 63 6b  29 3b 0a 20 20 20 20 20  |ollblock);.     |
000010a0  20 73 77 69 74 63 68 20  28 70 6f 6c 6c 72 65 73  | switch (pollres|
000010b0  75 6c 74 29 0a 20 20 20  20 20 20 7b 0a 20 20 20  |ult).      {.   |
000010c0  20 20 20 20 20 2f 2a 49  66 20 74 68 65 20 77 69  |     /*If the wi|
000010d0  6d 70 20 72 65 71 75 65  73 74 73 20 75 73 20 74  |mp requests us t|
000010e0  6f 20 6f 70 65 6e 20 61  20 77 69 6e 64 6f 77 20  |o open a window |
000010f0  77 65 20 67 6f 20 74 6f  20 6f 70 65 6e 77 69 6e  |we go to openwin|
00001100  64 6f 77 2a 2f 0a 20 20  20 20 20 20 20 20 63 61  |dow*/.        ca|
00001110  73 65 20 20 32 3a 20 6f  70 65 6e 77 69 6e 64 6f  |se  2: openwindo|
00001120  77 28 70 6f 6c 6c 62 6c  6f 63 6b 29 3b 0a 20 20  |w(pollblock);.  |
00001130  20 20 20 20 20 20 62 72  65 61 6b 3b 0a 20 20 20  |      break;.   |
00001140  20 20 20 20 20 2f 2a 49  66 20 74 68 65 20 77 69  |     /*If the wi|
00001150  6d 70 20 72 65 71 75 65  73 74 73 20 75 73 20 74  |mp requests us t|
00001160  6f 20 63 6c 6f 73 65 20  61 20 77 69 6e 64 6f 77  |o close a window|
00001170  20 77 65 20 67 6f 20 74  6f 20 63 6c 6f 73 65 77  | we go to closew|
00001180  69 6e 64 6f 77 2a 2f 0a  20 20 20 20 20 20 20 20  |indow*/.        |
00001190  63 61 73 65 20 20 33 3a  20 63 6c 6f 73 65 77 69  |case  3: closewi|
000011a0  6e 64 6f 77 28 70 6f 6c  6c 62 6c 6f 63 6b 29 3b  |ndow(pollblock);|
000011b0  0a 20 20 20 20 20 20 20  20 62 72 65 61 6b 3b 0a  |.        break;.|
000011c0  20 20 20 20 20 20 20 20  2f 2a 49 66 20 74 68 65  |        /*If the|
000011d0  72 65 20 69 73 20 61 20  6d 6f 75 73 65 20 63 6c  |re is a mouse cl|
000011e0  69 63 6b 20 6f 6e 20 73  6f 6d 65 74 69 6e 67 20  |ick on someting |
000011f0  62 65 6c 6f 6e 67 69 6e  67 20 74 6f 20 6f 75 72  |belonging to our|
00001200  20 70 72 6f 67 72 61 6d  20 77 65 20 67 6f 0a 20  | program we go. |
00001210  20 20 20 20 20 20 20 20  20 74 6f 20 6d 6f 75 73  |         to mous|
00001220  65 63 6c 69 63 6b 2a 2f  0a 20 20 20 20 20 20 20  |eclick*/.       |
00001230  20 63 61 73 65 20 20 36  3a 20 6d 6f 75 73 65 63  | case  6: mousec|
00001240  6c 69 63 6b 28 70 6f 6c  6c 62 6c 6f 63 6b 29 3b  |lick(pollblock);|
00001250  0a 20 20 20 20 20 20 20  20 62 72 65 61 6b 3b 0a  |.        break;.|
00001260  20 20 20 20 20 20 20 20  2f 2a 41 63 74 20 75 70  |        /*Act up|
00001270  6f 6e 20 61 6e 79 20 6b  65 79 20 70 72 65 73 73  |on any key press|
00001280  65 73 20 74 68 65 72 65  20 61 72 65 2a 2f 0a 20  |es there are*/. |
00001290  20 20 20 20 20 20 20 63  61 73 65 20 38 3a 20 6b  |       case 8: k|
000012a0  65 79 5f 70 72 65 73 73  28 70 6f 6c 6c 62 6c 6f  |ey_press(pollblo|
000012b0  63 6b 29 3b 0a 20 20 20  20 20 20 20 20 62 72 65  |ck);.        bre|
000012c0  61 6b 3b 0a 20 20 20 20  20 20 20 20 2f 2a 49 66  |ak;.        /*If|
000012d0  20 73 20 73 65 6c 65 63  74 69 6f 6e 20 69 73 20  | s selection is |
000012e0  6d 61 64 65 20 66 72 6f  6d 20 6f 6e 65 20 6f 66  |made from one of|
000012f0  20 6f 75 72 20 6d 65 6e  75 73 20 77 65 20 67 6f  | our menus we go|
00001300  20 74 6f 20 6d 65 6e 75  73 65 6c 65 63 74 69 6f  | to menuselectio|
00001310  6e 2a 2f 0a 20 20 20 20  20 20 20 20 63 61 73 65  |n*/.        case|
00001320  20 20 39 3a 20 6d 65 6e  75 73 65 6c 65 63 74 69  |  9: menuselecti|
00001330  6f 6e 28 70 6f 6c 6c 62  6c 6f 63 6b 29 3b 0a 20  |on(pollblock);. |
00001340  20 20 20 20 20 20 20 62  72 65 61 6b 3b 0a 20 20  |       break;.  |
00001350  20 20 20 20 20 20 2f 2a  54 68 65 20 62 65 6c 6f  |      /*The belo|
00001360  77 20 73 65 63 74 69 6f  6e 20 6c 69 73 74 65 6e  |w section listen|
00001370  73 20 66 6f 72 20 65 76  65 6e 74 20 63 6f 64 65  |s for event code|
00001380  73 20 31 37 2c 20 31 38  20 61 6e 64 20 31 39 20  |s 17, 18 and 19 |
00001390  2d 20 74 68 65 0a 20 20  20 20 20 20 20 20 20 20  |- the.          |
000013a0  6f 6e 65 73 20 77 68 69  63 68 20 69 6e 64 69 63  |ones which indic|
000013b0  61 74 65 20 77 65 27 72  65 20 62 65 69 6e 67 20  |ate we're being |
000013c0  73 65 6e 74 20 61 20 6d  65 73 73 61 67 65 20 61  |sent a message a|
000013d0  6e 64 20 69 66 20 77 65  20 61 72 65 20 77 65 20  |nd if we are we |
000013e0  67 6f 20 74 6f 0a 20 20  20 20 20 20 20 20 20 20  |go to.          |
000013f0  77 69 6d 70 6d 73 67 2a  2f 0a 20 20 20 20 20 20  |wimpmsg*/.      |
00001400  20 20 63 61 73 65 20 31  37 3a 0a 20 20 20 20 20  |  case 17:.     |
00001410  20 20 20 63 61 73 65 20  31 38 3a 0a 20 20 20 20  |   case 18:.    |
00001420  20 20 20 20 63 61 73 65  20 31 39 3a 20 77 69 6d  |    case 19: wim|
00001430  70 6d 73 67 28 70 6f 6c  6c 72 65 73 75 6c 74 2c  |pmsg(pollresult,|
00001440  20 70 6f 6c 6c 62 6c 6f  63 6b 29 3b 0a 20 20 20  | pollblock);.   |
00001450  20 20 20 20 20 62 72 65  61 6b 3b 0a 20 20 20 20  |     break;.    |
00001460  20 20 7d 0a 20 20 20 20  7d 0a 20 20 20 20 2f 2a  |  }.    }.    /*|
00001470  49 66 20 51 55 49 54 5f  46 4c 41 47 20 63 68 61  |If QUIT_FLAG cha|
00001480  6e 67 65 73 20 74 6f 20  61 6e 79 74 68 69 6e 67  |nges to anything|
00001490  20 62 75 74 20 30 2c 20  77 65 20 73 74 6f 70 20  | but 0, we stop |
000014a0  67 6f 69 6e 67 20 72 6f  75 6e 64 20 74 68 65 20  |going round the |
000014b0  70 6f 6c 6c 69 6e 67 0a  20 20 20 20 20 20 6c 6f  |polling.      lo|
000014c0  6f 70 20 61 6e 64 20 73  68 75 74 20 64 6f 77 6e  |op and shut down|
000014d0  20 2a 2f 0a 20 20 7d 0a  0a 20 20 2f 2a 43 6c 6f  | */.  }..  /*Clo|
000014e0  73 65 20 64 6f 77 6e 20  6f 75 72 20 70 72 6f 67  |se down our prog|
000014f0  72 61 6d 2a 2f 0a 20 20  61 75 5f 63 6c 6f 73 65  |ram*/.  au_close|
00001500  64 6f 77 6e 28 74 61 73  6b 5f 68 61 6e 64 6c 65  |down(task_handle|
00001510  29 3b 0a 0a 20 20 2f 2a  57 65 20 4e 65 65 64 20  |);..  /*We Need |
00001520  74 6f 20 72 65 6c 65 61  73 65 20 6d 61 6c 6c 6f  |to release mallo|
00001530  63 20 6d 65 6d 6f 72 79  20 66 72 6f 6d 20 77 69  |c memory from wi|
00001540  6e 64 6f 77 20 73 74 72  75 63 74 75 72 65 73 2a  |ndow structures*|
00001550  2f 0a 20 20 66 6f 72 28  70 61 73 73 3d 30 3b 70  |/.  for(pass=0;p|
00001560  61 73 73 3c 4d 41 58 5f  57 49 4e 44 4f 57 53 3b  |ass<MAX_WINDOWS;|
00001570  70 61 73 73 2b 2b 29 0a  20 20 7b 0a 20 20 20 20  |pass++).  {.    |
00001580  66 72 65 65 28 77 69 6e  5f 61 72 72 61 79 5b 70  |free(win_array[p|
00001590  61 73 73 5d 2e 77 69 6e  5f 6e 61 6d 65 29 3b 0a  |ass].win_name);.|
000015a0  20 20 20 20 66 72 65 65  28 77 69 6e 5f 61 72 72  |    free(win_arr|
000015b0  61 79 5b 70 61 73 73 5d  2e 62 75 66 66 65 72 29  |ay[pass].buffer)|
000015c0  3b 0a 20 20 20 20 66 72  65 65 28 77 69 6e 5f 61  |;.    free(win_a|
000015d0  72 72 61 79 5b 70 61 73  73 5d 2e 77 6f 72 6b 73  |rray[pass].works|
000015e0  70 61 63 65 29 3b 0a 20  20 7d 0a 7d 0a 0a 76 6f  |pace);.  }.}..vo|
000015f0  69 64 20 77 69 6d 70 6d  73 67 28 69 6e 74 20 72  |id wimpmsg(int r|
00001600  65 73 75 6c 74 2c 20 75  6e 73 69 67 6e 65 64 20  |esult, unsigned |
00001610  63 68 61 72 20 70 6f 6c  6c 62 6c 6f 63 6b 5b 5d  |char pollblock[]|
00001620  29 0a 7b 0a 20 20 2f 2a  54 68 69 73 20 76 61 72  |).{.  /*This var|
00001630  69 61 62 6c 65 20 68 6f  6c 64 73 20 74 68 65 20  |iable holds the |
00001640  6e 75 6d 62 65 72 20 6f  66 20 74 68 65 20 6d 65  |number of the me|
00001650  73 73 61 67 65 20 74 68  61 74 20 77 65 20 77 65  |ssage that we we|
00001660  72 65 20 73 65 6e 74 2a  2f 0a 20 20 75 6e 73 69  |re sent*/.  unsi|
00001670  67 6e 65 64 20 6c 6f 6e  67 20 69 6e 74 20 6d 65  |gned long int me|
00001680  73 73 61 67 65 5f 61 63  74 69 6f 6e 3b 0a 0a 20  |ssage_action;.. |
00001690  20 2f 2a 54 68 65 20 6e  65 78 74 20 6c 69 6e 65  | /*The next line|
000016a0  20 74 61 6b 65 73 20 62  79 74 65 73 20 31 36 20  | takes bytes 16 |
000016b0  74 6f 20 31 39 20 6f 66  20 74 68 65 20 70 6f 6c  |to 19 of the pol|
000016c0  6c 69 6e 67 20 62 6c 6f  63 6b 20 61 6e 64 20 66  |ling block and f|
000016d0  6f 72 6d 73 20 74 68 65  6d 0a 20 20 20 20 69 6e  |orms them.    in|
000016e0  74 6f 20 61 20 77 6f 72  64 20 68 6f 6c 64 69 6e  |to a word holdin|
000016f0  67 20 74 68 65 20 6d 65  73 73 61 67 65 20 61 63  |g the message ac|
00001700  74 69 6f 6e 20 6e 75 6d  62 65 72 2a 2f 0a 20 20  |tion number*/.  |
00001710  6d 65 73 73 61 67 65 5f  61 63 74 69 6f 6e 20 3d  |message_action =|
00001720  20 61 75 5f 62 79 74 65  74 6f 77 6f 72 64 28 70  | au_bytetoword(p|
00001730  6f 6c 6c 62 6c 6f 63 6b  2c 20 31 36 29 3b 0a 0a  |ollblock, 16);..|
00001740  20 20 73 77 69 74 63 68  20 28 6d 65 73 73 61 67  |  switch (messag|
00001750  65 5f 61 63 74 69 6f 6e  29 0a 20 20 7b 0a 20 20  |e_action).  {.  |
00001760  20 20 63 61 73 65 20 30  3a 20 51 55 49 54 5f 46  |  case 0: QUIT_F|
00001770  4c 41 47 20 3d 20 31 3b  20 2f 2a 20 41 20 72 65  |LAG = 1; /* A re|
00001780  71 75 65 73 74 20 66 6f  72 20 6f 75 72 20 70 72  |quest for our pr|
00001790  6f 67 72 61 6d 20 74 6f  20 71 75 69 74 20 2d 20  |ogram to quit - |
000017a0  74 69 6d 65 20 74 6f 20  67 6f 20 2a 2f 0a 20 20  |time to go */.  |
000017b0  20 20 62 72 65 61 6b 3b  0a 20 20 7d 0a 7d 0a 0a  |  break;.  }.}..|
000017c0  76 6f 69 64 20 6d 65 6e  75 73 65 6c 65 63 74 69  |void menuselecti|
000017d0  6f 6e 28 75 6e 73 69 67  6e 65 64 20 63 68 61 72  |on(unsigned char|
000017e0  20 70 6f 6c 6c 62 6c 6f  63 6b 5b 5d 29 0a 7b 0a  | pollblock[]).{.|
000017f0  0a 20 20 2f 2a 49 66 20  74 68 65 20 73 65 6c 65  |.  /*If the sele|
00001800  63 74 65 64 20 69 74 65  6d 20 69 73 20 69 6e 20  |cted item is in |
00001810  74 68 65 20 48 65 6c 70  20 73 75 62 6d 65 6e 75  |the Help submenu|
00001820  2e 2e 2e 2a 2f 0a 20 20  69 66 28 61 75 5f 62 79  |...*/.  if(au_by|
00001830  74 65 74 6f 77 6f 72 64  28 70 6f 6c 6c 62 6c 6f  |tetoword(pollblo|
00001840  63 6b 2c 20 30 29 20 3d  3d 20 31 29 0a 20 20 7b  |ck, 0) == 1).  {|
00001850  0a 20 20 20 20 2f 2a 2e  2e 2e 61 6e 64 20 69 74  |.    /*...and it|
00001860  20 69 73 20 74 68 65 20  48 65 6c 70 20 65 6e 74  | is the Help ent|
00001870  72 79 2a 2f 0a 20 20 20  20 69 66 28 61 75 5f 62  |ry*/.    if(au_b|
00001880  79 74 65 74 6f 77 6f 72  64 28 70 6f 6c 6c 62 6c  |ytetoword(pollbl|
00001890  6f 63 6b 2c 20 34 29 20  3d 3d 20 30 29 0a 20 20  |ock, 4) == 0).  |
000018a0  20 20 7b 0a 20 20 20 20  20 20 2f 2a 4f 70 65 6e  |  {.      /*Open|
000018b0  20 74 68 65 20 48 65 6c  70 20 66 69 6c 65 2a 2f  | the Help file*/|
000018c0  0a 20 20 20 20 20 20 6f  73 5f 63 6c 69 28 22 46  |.      os_cli("F|
000018d0  69 6c 65 72 5f 52 75 6e  20 3c 41 63 72 6f 6e 79  |iler_Run <Acrony|
000018e0  6d 73 44 6f 63 73 24 44  69 72 3e 2e 48 65 6c 70  |msDocs$Dir>.Help|
000018f0  22 29 3b 0a 20 20 20 20  7d 0a 0a 20 20 20 20 2f  |");.    }..    /|
00001900  2a 2e 2e 2e 61 6e 64 20  69 74 20 69 73 20 74 68  |*...and it is th|
00001910  65 20 48 69 73 74 6f 72  79 20 65 6e 74 72 79 2a  |e History entry*|
00001920  2f 0a 20 20 20 20 69 66  28 61 75 5f 62 79 74 65  |/.    if(au_byte|
00001930  74 6f 77 6f 72 64 28 70  6f 6c 6c 62 6c 6f 63 6b  |toword(pollblock|
00001940  2c 20 34 29 20 3d 3d 20  31 29 0a 20 20 20 20 7b  |, 4) == 1).    {|
00001950  0a 20 20 20 20 20 20 2f  2a 4f 70 65 6e 20 74 68  |.      /*Open th|
00001960  65 20 48 69 73 74 6f 72  79 20 66 69 6c 65 2a 2f  |e History file*/|
00001970  0a 20 20 20 20 20 20 6f  73 5f 63 6c 69 28 22 46  |.      os_cli("F|
00001980  69 6c 65 72 5f 52 75 6e  20 3c 41 63 72 6f 6e 79  |iler_Run <Acrony|
00001990  6d 73 44 6f 63 73 24 44  69 72 3e 2e 48 69 73 74  |msDocs$Dir>.Hist|
000019a0  6f 72 79 22 29 3b 0a 20  20 20 20 7d 0a 0a 20 20  |ory");.    }..  |
000019b0  20 20 2f 2a 2e 2e 2e 61  6e 64 20 69 74 20 69 73  |  /*...and it is|
000019c0  20 74 68 65 20 41 64 64  69 74 69 6f 6e 61 6c 20  | the Additional |
000019d0  65 6e 74 72 79 2a 2f 0a  20 20 20 20 69 66 28 61  |entry*/.    if(a|
000019e0  75 5f 62 79 74 65 74 6f  77 6f 72 64 28 70 6f 6c  |u_bytetoword(pol|
000019f0  6c 62 6c 6f 63 6b 2c 20  34 29 20 3d 3d 20 32 29  |lblock, 4) == 2)|
00001a00  0a 20 20 20 20 7b 0a 20  20 20 20 20 20 2f 2a 4f  |.    {.      /*O|
00001a10  70 65 6e 20 74 68 65 20  41 64 64 69 74 69 6f 6e  |pen the Addition|
00001a20  61 6c 20 66 69 6c 65 2a  2f 0a 20 20 20 20 20 20  |al file*/.      |
00001a30  6f 73 5f 63 6c 69 28 22  46 69 6c 65 72 5f 52 75  |os_cli("Filer_Ru|
00001a40  6e 20 3c 41 63 72 6f 6e  79 6d 73 44 6f 63 73 24  |n <AcronymsDocs$|
00001a50  44 69 72 3e 2e 41 64 64  69 74 69 6f 6e 61 6c 22  |Dir>.Additional"|
00001a60  29 3b 0a 20 20 20 20 7d  0a 20 20 7d 0a 0a 20 20  |);.    }.  }..  |
00001a70  2f 2a 49 66 20 74 68 65  20 73 65 6c 65 63 74 65  |/*If the selecte|
00001a80  64 20 69 74 65 6d 20 69  73 20 69 6e 20 74 68 65  |d item is in the|
00001a90  20 4f 70 74 69 6f 6e 73  20 73 75 62 6d 65 6e 75  | Options submenu|
00001aa0  2e 2e 2e 2a 2f 0a 20 20  69 66 28 61 75 5f 62 79  |...*/.  if(au_by|
00001ab0  74 65 74 6f 77 6f 72 64  28 70 6f 6c 6c 62 6c 6f  |tetoword(pollblo|
00001ac0  63 6b 2c 20 30 29 20 3d  3d 20 32 29 0a 20 20 7b  |ck, 0) == 2).  {|
00001ad0  0a 20 20 20 20 2f 2a 2e  2e 2e 61 6e 64 20 69 74  |.    /*...and it|
00001ae0  20 69 73 20 69 6e 20 74  68 65 20 4f 70 65 6e 46  | is in the OpenF|
00001af0  69 6c 65 73 20 73 75 62  6d 65 6e 75 2e 2e 2e 2a  |iles submenu...*|
00001b00  2f 0a 20 20 20 20 69 66  28 61 75 5f 62 79 74 65  |/.    if(au_byte|
00001b10  74 6f 77 6f 72 64 28 70  6f 6c 6c 62 6c 6f 63 6b  |toword(pollblock|
00001b20  2c 20 34 29 20 3d 3d 20  30 29 0a 20 20 20 20 7b  |, 4) == 0).    {|
00001b30  0a 20 20 20 20 20 20 2f  2a 2e 2e 2e 61 6e 64 20  |.      /*...and |
00001b40  69 74 20 69 73 20 74 68  65 20 43 61 73 65 49 6e  |it is the CaseIn|
00001b50  53 65 6e 73 20 65 6e 74  72 79 2a 2f 0a 20 20 20  |Sens entry*/.   |
00001b60  20 20 20 69 66 28 61 75  5f 62 79 74 65 74 6f 77  |   if(au_bytetow|
00001b70  6f 72 64 28 70 6f 6c 6c  62 6c 6f 63 6b 2c 20 38  |ord(pollblock, 8|
00001b80  29 20 3d 3d 20 30 29 0a  20 20 20 20 20 20 7b 0a  |) == 0).      {.|
00001b90  20 20 20 20 20 20 20 20  2f 2a 4f 70 65 6e 20 74  |        /*Open t|
00001ba0  68 65 20 43 61 73 65 49  6e 53 65 6e 73 20 66 69  |he CaseInSens fi|
00001bb0  6c 65 2a 2f 0a 20 20 20  20 20 20 20 20 6f 73 5f  |le*/.        os_|
00001bc0  63 6c 69 28 22 46 69 6c  65 72 5f 52 75 6e 20 3c  |cli("Filer_Run <|
00001bd0  41 63 72 6f 6e 79 6d 73  54 65 78 74 46 69 6c 65  |AcronymsTextFile|
00001be0  73 24 44 69 72 3e 2e 43  61 73 65 49 6e 53 65 6e  |s$Dir>.CaseInSen|
00001bf0  73 22 29 3b 0a 20 20 20  20 20 20 7d 0a 0a 20 20  |s");.      }..  |
00001c00  20 20 20 20 2f 2a 2e 2e  2e 61 6e 64 20 69 74 20  |    /*...and it |
00001c10  69 73 20 74 68 65 20 43  61 73 65 53 65 6e 73 20  |is the CaseSens |
00001c20  65 6e 74 72 79 2a 2f 0a  20 20 20 20 20 20 69 66  |entry*/.      if|
00001c30  28 61 75 5f 62 79 74 65  74 6f 77 6f 72 64 28 70  |(au_bytetoword(p|
00001c40  6f 6c 6c 62 6c 6f 63 6b  2c 20 38 29 20 3d 3d 20  |ollblock, 8) == |
00001c50  31 29 0a 20 20 20 20 20  20 7b 0a 20 20 20 20 20  |1).      {.     |
00001c60  20 20 20 2f 2a 4f 70 65  6e 20 74 68 65 20 43 61  |   /*Open the Ca|
00001c70  73 65 53 65 6e 73 20 66  69 6c 65 2a 2f 0a 20 20  |seSens file*/.  |
00001c80  20 20 20 20 20 20 6f 73  5f 63 6c 69 28 22 46 69  |      os_cli("Fi|
00001c90  6c 65 72 5f 52 75 6e 20  3c 41 63 72 6f 6e 79 6d  |ler_Run <Acronym|
00001ca0  73 54 65 78 74 46 69 6c  65 73 24 44 69 72 3e 2e  |sTextFiles$Dir>.|
00001cb0  43 61 73 65 53 65 6e 73  22 29 3b 0a 20 20 20 20  |CaseSens");.    |
00001cc0  20 20 7d 0a 20 20 20 20  7d 0a 0a 20 20 20 20 2f  |  }.    }..    /|
00001cd0  2a 2e 2e 2e 61 6e 64 20  69 74 20 69 73 20 74 68  |*...and it is th|
00001ce0  65 20 53 63 61 6e 46 69  6c 65 73 20 65 6e 74 72  |e ScanFiles entr|
00001cf0  79 2a 2f 0a 20 20 20 20  69 66 28 61 75 5f 62 79  |y*/.    if(au_by|
00001d00  74 65 74 6f 77 6f 72 64  28 70 6f 6c 6c 62 6c 6f  |tetoword(pollblo|
00001d10  63 6b 2c 20 34 29 20 3d  3d 20 31 29 0a 20 20 20  |ck, 4) == 1).   |
00001d20  20 7b 0a 20 20 20 20 20  20 2f 2a 47 6f 20 74 6f  | {.      /*Go to|
00001d30  20 74 68 65 20 66 75 6e  63 74 69 6f 6e 20 69 6e  | the function in|
00001d40  69 74 69 61 6c 69 73 65  5f 74 65 78 74 5f 66 69  |itialise_text_fi|
00001d50  6c 65 73 2a 2f 0a 20 20  20 20 20 20 69 6e 69 74  |les*/.      init|
00001d60  69 61 6c 69 73 65 5f 74  65 78 74 5f 66 69 6c 65  |ialise_text_file|
00001d70  73 28 29 3b 0a 20 20 20  20 7d 0a 20 20 7d 0a 0a  |s();.    }.  }..|
00001d80  20 20 2f 2a 49 66 20 74  68 65 20 73 65 6c 65 63  |  /*If the selec|
00001d90  74 65 64 20 69 74 65 6d  20 69 73 20 74 68 65 20  |ted item is the |
00001da0  71 75 69 74 20 6f 70 74  69 6f 6e 2a 2f 0a 20 20  |quit option*/.  |
00001db0  69 66 28 61 75 5f 62 79  74 65 74 6f 77 6f 72 64  |if(au_bytetoword|
00001dc0  28 70 6f 6c 6c 62 6c 6f  63 6b 2c 20 30 29 20 3d  |(pollblock, 0) =|
00001dd0  3d 20 33 29 0a 20 20 7b  0a 20 20 20 20 2f 2a 51  |= 3).  {.    /*Q|
00001de0  75 69 74 20 74 68 65 20  70 72 6f 67 72 61 6d 2a  |uit the program*|
00001df0  2f 0a 20 20 20 51 55 49  54 5f 46 4c 41 47 20 3d  |/.   QUIT_FLAG =|
00001e00  20 31 3b 0a 20 20 7d 0a  0a 20 20 72 65 74 75 72  | 1;.  }..  retur|
00001e10  6e 3b 0a 7d 0a 0a 76 6f  69 64 20 6d 6f 75 73 65  |n;.}..void mouse|
00001e20  63 6c 69 63 6b 28 75 6e  73 69 67 6e 65 64 20 63  |click(unsigned c|
00001e30  68 61 72 20 70 6f 6c 6c  62 6c 6f 63 6b 5b 5d 29  |har pollblock[])|
00001e40  0a 7b 0a 20 20 63 68 61  72 20 6d 65 73 73 61 67  |.{.  char messag|
00001e50  65 5b 32 35 35 5d 3b 0a  20 20 2f 2a 41 20 62 75  |e[255];.  /*A bu|
00001e60  66 66 65 72 20 74 6f 20  68 6f 6c 64 20 61 6e 20  |ffer to hold an |
00001e70  27 65 72 72 6f 72 27 20  6d 65 73 73 61 67 65 2a  |'error' message*|
00001e80  2f 0a 20 20 63 68 61 72  20 2a 74 65 78 74 5f 70  |/.  char *text_p|
00001e90  6f 69 6e 74 65 72 3b 20  2f 2a 41 20 70 6f 69 6e  |ointer; /*A poin|
00001ea0  74 65 72 20 74 6f 20 74  68 65 20 69 63 6f 6e 73  |ter to the icons|
00001eb0  20 74 65 78 74 2a 2f 0a  20 20 69 6e 74 20 70 61  | text*/.  int pa|
00001ec0  73 73 3b 20 2f 2a 55 73  65 64 20 69 6e 20 74 68  |ss; /*Used in th|
00001ed0  65 20 66 6f 72 20 6c 6f  6f 70 2a 2f 0a 0a 20 20  |e for loop*/..  |
00001ee0  69 6e 74 20 63 6c 6b 3b  20 2f 2a 48 6f 6c 64 73  |int clk; /*Holds|
00001ef0  20 74 68 65 20 6d 6f 75  73 65 20 62 75 74 74 6f  | the mouse butto|
00001f00  6e 20 74 68 61 74 20 77  61 73 20 63 6c 69 63 6b  |n that was click|
00001f10  20 65 2e 67 2e 20 53 65  6c 65 63 74 2c 20 4d 65  | e.g. Select, Me|
00001f20  6e 75 20 65 74 63 2e 2e  2a 2f 0a 20 20 5f 6b 65  |nu etc..*/.  _ke|
00001f30  72 6e 65 6c 5f 73 77 69  5f 72 65 67 73 20 69 6e  |rnel_swi_regs in|
00001f40  2c 20 6f 75 74 3b 20 2f  2a 53 65 74 73 20 75 70  |, out; /*Sets up|
00001f50  20 74 68 65 20 61 72 6d  20 72 65 67 69 73 74 65  | the arm registe|
00001f60  72 73 2a 2f 0a 20 20 75  6e 73 69 67 6e 65 64 20  |rs*/.  unsigned |
00001f70  63 68 61 72 20 74 65 6d  70 5f 62 75 66 66 65 72  |char temp_buffer|
00001f80  5b 32 35 35 5d 3b 0a 0a  20 20 2f 2a 44 65 74 65  |[255];..  /*Dete|
00001f90  72 6d 69 6e 65 20 77 68  69 63 68 20 62 75 74 74  |rmine which butt|
00001fa0  6f 6e 20 77 61 73 20 70  72 65 73 73 65 64 2a 2f  |on was pressed*/|
00001fb0  0a 20 20 63 6c 6b 20 3d  20 28 69 6e 74 29 20 61  |.  clk = (int) a|
00001fc0  75 5f 62 79 74 65 74 6f  77 6f 72 64 28 70 6f 6c  |u_bytetoword(pol|
00001fd0  6c 62 6c 6f 63 6b 2c 20  38 29 3b 0a 0a 20 20 2f  |lblock, 8);..  /|
00001fe0  2a 49 66 20 74 68 65 20  27 53 65 6c 65 63 74 27  |*If the 'Select'|
00001ff0  20 62 75 74 74 6f 6e 20  77 61 73 20 63 6c 69 63  | button was clic|
00002000  6b 65 64 2e 2e 2e 2a 2f  0a 0a 20 20 20 69 66 28  |ked...*/..   if(|
00002010  63 6c 6b 20 3d 3d 20 34  29 0a 20 20 20 7b 0a 20  |clk == 4).   {. |
00002020  20 20 20 20 2f 2a 2e 2e  2e 6f 6e 20 74 68 65 20  |    /*...on the |
00002030  69 63 6f 6e 20 62 61 72  20 74 68 65 6e 20 72 65  |icon bar then re|
00002040  2d 6f 70 65 6e 20 6d 61  69 6e 20 77 69 6e 64 6f  |-open main windo|
00002050  77 20 61 6e 64 20 72 65  74 75 72 6e 2a 2f 0a 20  |w and return*/. |
00002060  20 20 20 20 69 66 28 61  75 5f 62 79 74 65 74 6f  |    if(au_byteto|
00002070  77 6f 72 64 28 70 6f 6c  6c 62 6c 6f 63 6b 2c 20  |word(pollblock, |
00002080  31 32 29 20 3d 3d 20 2d  32 29 0a 20 20 20 20 20  |12) == -2).     |
00002090  7b 0a 20 20 20 20 20 20  20 61 75 5f 77 6f 72 64  |{.       au_word|
000020a0  74 6f 62 79 74 65 28 77  69 6e 5f 61 72 72 61 79  |tobyte(win_array|
000020b0  5b 30 5d 2e 77 69 6e 5f  68 61 6e 64 6c 65 2c 20  |[0].win_handle, |
000020c0  74 65 6d 70 5f 62 75 66  66 65 72 2c 20 30 29 3b  |temp_buffer, 0);|
000020d0  0a 20 20 20 20 20 20 20  69 6e 2e 72 5b 31 5d 20  |.       in.r[1] |
000020e0  3d 20 28 69 6e 74 29 20  74 65 6d 70 5f 62 75 66  |= (int) temp_buf|
000020f0  66 65 72 3b 0a 20 20 20  20 20 20 20 5f 6b 65 72  |fer;.       _ker|
00002100  6e 65 6c 5f 73 77 69 28  57 69 6d 70 5f 47 65 74  |nel_swi(Wimp_Get|
00002110  57 69 6e 64 6f 77 49 6e  66 6f 2c 20 26 69 6e 2c  |WindowInfo, &in,|
00002120  20 26 6f 75 74 29 3b 0a  20 20 20 20 20 20 20 5f  | &out);.       _|
00002130  6b 65 72 6e 65 6c 5f 73  77 69 28 57 69 6d 70 5f  |kernel_swi(Wimp_|
00002140  4f 70 65 6e 57 69 6e 64  6f 77 2c 20 26 69 6e 2c  |OpenWindow, &in,|
00002150  20 26 6f 75 74 29 3b 0a  20 20 20 20 20 20 20 2f  | &out);.       /|
00002160  2a 47 65 74 20 69 63 6f  6e 20 31 27 73 20 74 65  |*Get icon 1's te|
00002170  78 74 2a 2f 0a 20 20 20  20 20 20 20 74 65 78 74  |xt*/.       text|
00002180  5f 70 6f 69 6e 74 65 72  3d 61 75 5f 67 65 74 5f  |_pointer=au_get_|
00002190  70 74 72 5f 74 6f 5f 69  63 6f 6e 74 65 78 74 28  |ptr_to_icontext(|
000021a0  77 69 6e 5f 61 72 72 61  79 5b 30 5d 2e 77 69 6e  |win_array[0].win|
000021b0  5f 68 61 6e 64 6c 65 2c  31 29 3b 0a 20 20 20 20  |_handle,1);.    |
000021c0  20 20 20 2f 2a 41 64 64  20 61 20 6e 75 6c 6c 20  |   /*Add a null |
000021d0  63 68 61 72 61 63 74 65  72 20 74 6f 20 74 68 65  |character to the|
000021e0  20 65 6e 64 20 6f 66 20  74 68 65 20 73 74 72 69  | end of the stri|
000021f0  6e 67 2a 2f 0a 20 20 20  20 20 20 20 66 6f 72 28  |ng*/.       for(|
00002200  70 61 73 73 3d 30 3b 70  61 73 73 3c 3d 31 39 3b  |pass=0;pass<=19;|
00002210  70 61 73 73 2b 2b 29 0a  20 20 20 20 20 20 20 7b  |pass++).       {|
00002220  0a 20 20 20 20 20 20 20  20 20 69 66 28 74 65 78  |.         if(tex|
00002230  74 5f 70 6f 69 6e 74 65  72 5b 70 61 73 73 5d 20  |t_pointer[pass] |
00002240  3c 20 33 32 29 0a 20 20  20 20 20 20 20 20 20 7b  |< 32).         {|
00002250  0a 20 20 20 20 20 20 20  20 20 20 20 74 65 78 74  |.           text|
00002260  5f 70 6f 69 6e 74 65 72  5b 70 61 73 73 5d 20 3d  |_pointer[pass] =|
00002270  20 27 5c 30 27 3b 0a 20  20 20 20 20 20 20 20 20  | '\0';.         |
00002280  20 20 62 72 65 61 6b 3b  0a 20 20 20 20 20 20 20  |  break;.       |
00002290  20 20 7d 0a 20 20 20 20  20 20 20 7d 0a 20 20 20  |  }.       }.   |
000022a0  20 20 20 20 2f 2a 47 69  76 65 20 74 68 65 20 77  |    /*Give the w|
000022b0  69 6e 64 6f 77 20 74 68  65 20 69 6e 70 75 74 20  |indow the input |
000022c0  66 6f 63 75 73 2a 2f 0a  20 20 20 20 20 20 20 69  |focus*/.       i|
000022d0  6e 2e 72 5b 30 5d 20 3d  20 28 69 6e 74 29 20 77  |n.r[0] = (int) w|
000022e0  69 6e 5f 61 72 72 61 79  5b 30 5d 2e 77 69 6e 5f  |in_array[0].win_|
000022f0  68 61 6e 64 6c 65 3b 0a  20 20 20 20 20 20 20 69  |handle;.       i|
00002300  6e 2e 72 5b 31 5d 20 3d  20 31 3b 0a 20 20 20 20  |n.r[1] = 1;.    |
00002310  20 20 20 69 6e 2e 72 5b  34 5d 20 3d 20 2d 31 3b  |   in.r[4] = -1;|
00002320  0a 20 20 20 20 20 20 20  69 6e 2e 72 5b 35 5d 20  |.       in.r[5] |
00002330  3d 20 28 69 6e 74 29 20  73 74 72 6c 65 6e 28 74  |= (int) strlen(t|
00002340  65 78 74 5f 70 6f 69 6e  74 65 72 29 3b 0a 20 20  |ext_pointer);.  |
00002350  20 20 20 20 20 5f 6b 65  72 6e 65 6c 5f 73 77 69  |     _kernel_swi|
00002360  28 57 69 6d 70 5f 53 65  74 43 61 72 65 74 50 6f  |(Wimp_SetCaretPo|
00002370  73 69 74 69 6f 6e 2c 20  26 69 6e 2c 20 26 6f 75  |sition, &in, &ou|
00002380  74 29 3b 0a 20 20 20 20  20 20 20 72 65 74 75 72  |t);.       retur|
00002390  6e 3b 0a 20 20 20 20 20  7d 0a 20 20 20 7d 0a 0a  |n;.     }.   }..|
000023a0  20 20 20 2f 2a 49 66 20  27 4d 65 6e 75 27 20 68  |   /*If 'Menu' h|
000023b0  61 73 20 62 65 65 6e 20  63 6c 69 63 6b 65 64 20  |as been clicked |
000023c0  6f 6e 20 74 68 65 20 69  63 6f 6e 20 62 61 72 20  |on the icon bar |
000023d0  69 63 6f 6e 20 2d 20 6e  6f 77 20 77 65 20 70 72  |icon - now we pr|
000023e0  6f 64 75 63 65 0a 20 20  20 20 20 20 20 20 61 20  |oduce.        a |
000023f0  6d 65 6e 75 20 2a 2f 0a  0a 20 20 20 69 66 28 28  |menu */..   if((|
00002400  61 75 5f 62 79 74 65 74  6f 77 6f 72 64 28 70 6f  |au_bytetoword(po|
00002410  6c 6c 62 6c 6f 63 6b 2c  20 31 32 29 20 3d 3d 20  |llblock, 12) == |
00002420  2d 32 29 20 26 26 20 28  63 6c 6b 20 3d 3d 20 32  |-2) && (clk == 2|
00002430  29 29 0a 20 20 20 7b 0a  20 20 20 20 20 61 75 5f  |)).   {.     au_|
00002440  62 75 69 6c 64 6d 65 6e  75 28 22 48 65 6c 70 22  |buildmenu("Help"|
00002450  2c 20 26 68 65 6c 70 5f  6d 65 6e 75 29 3b 0a 20  |, &help_menu);. |
00002460  20 20 20 20 61 75 5f 61  64 64 74 6f 6d 65 6e 75  |    au_addtomenu|
00002470  28 22 48 65 6c 70 22 2c  20 30 2c 20 2d 31 2c 20  |("Help", 0, -1, |
00002480  30 2c 20 26 68 65 6c 70  5f 6d 65 6e 75 29 3b 0a  |0, &help_menu);.|
00002490  20 20 20 20 20 61 75 5f  61 64 64 74 6f 6d 65 6e  |     au_addtomen|
000024a0  75 28 22 48 69 73 74 6f  72 79 22 2c 20 30 2c 20  |u("History", 0, |
000024b0  2d 31 2c 20 30 2c 20 26  68 65 6c 70 5f 6d 65 6e  |-1, 0, &help_men|
000024c0  75 29 3b 0a 20 20 20 20  20 61 75 5f 61 64 64 74  |u);.     au_addt|
000024d0  6f 6d 65 6e 75 28 22 41  64 64 69 74 69 6f 6e 61  |omenu("Additiona|
000024e0  6c 22 2c 20 4d 45 4e 55  5f 4c 41 53 54 49 54 45  |l", MENU_LASTITE|
000024f0  4d 2c 20 2d 31 2c 20 30  2c 20 26 68 65 6c 70 5f  |M, -1, 0, &help_|
00002500  6d 65 6e 75 29 3b 0a 20  20 20 20 20 61 75 5f 63  |menu);.     au_c|
00002510  72 65 61 74 65 6d 65 6e  75 28 26 68 65 6c 70 5f  |reatemenu(&help_|
00002520  6d 65 6e 75 29 3b 0a 20  20 20 20 20 61 75 5f 62  |menu);.     au_b|
00002530  75 69 6c 64 6d 65 6e 75  28 22 4f 70 65 6e 46 69  |uildmenu("OpenFi|
00002540  6c 65 73 22 2c 20 26 6f  70 65 6e 66 69 6c 65 73  |les", &openfiles|
00002550  5f 6d 65 6e 75 29 3b 0a  20 20 20 20 20 61 75 5f  |_menu);.     au_|
00002560  61 64 64 74 6f 6d 65 6e  75 28 22 43 61 73 65 49  |addtomenu("CaseI|
00002570  6e 53 65 6e 73 22 2c 20  30 2c 20 2d 31 2c 20 30  |nSens", 0, -1, 0|
00002580  2c 20 26 6f 70 65 6e 66  69 6c 65 73 5f 6d 65 6e  |, &openfiles_men|
00002590  75 29 3b 0a 20 20 20 20  20 61 75 5f 61 64 64 74  |u);.     au_addt|
000025a0  6f 6d 65 6e 75 28 22 43  61 73 65 53 65 6e 73 22  |omenu("CaseSens"|
000025b0  2c 20 4d 45 4e 55 5f 4c  41 53 54 49 54 45 4d 2c  |, MENU_LASTITEM,|
000025c0  20 2d 31 2c 20 30 2c 20  26 6f 70 65 6e 66 69 6c  | -1, 0, &openfil|
000025d0  65 73 5f 6d 65 6e 75 29  3b 0a 20 20 20 20 20 61  |es_menu);.     a|
000025e0  75 5f 63 72 65 61 74 65  6d 65 6e 75 28 26 6f 70  |u_createmenu(&op|
000025f0  65 6e 66 69 6c 65 73 5f  6d 65 6e 75 29 3b 0a 20  |enfiles_menu);. |
00002600  20 20 20 20 61 75 5f 62  75 69 6c 64 6d 65 6e 75  |    au_buildmenu|
00002610  28 22 4f 70 74 69 6f 6e  73 22 2c 20 26 6f 70 74  |("Options", &opt|
00002620  69 6f 6e 73 5f 6d 65 6e  75 29 3b 0a 20 20 20 20  |ions_menu);.    |
00002630  20 61 75 5f 61 64 64 74  6f 6d 65 6e 75 28 22 4f  | au_addtomenu("O|
00002640  70 65 6e 46 69 6c 65 73  22 2c 20 30 2c 20 28 69  |penFiles", 0, (i|
00002650  6e 74 29 20 6f 70 65 6e  66 69 6c 65 73 5f 6d 65  |nt) openfiles_me|
00002660  6e 75 2e 64 61 74 61 62  6c 6f 63 6b 2c 20 30 2c  |nu.datablock, 0,|
00002670  20 26 6f 70 74 69 6f 6e  73 5f 6d 65 6e 75 29 3b  | &options_menu);|
00002680  0a 20 20 20 20 20 61 75  5f 61 64 64 74 6f 6d 65  |.     au_addtome|
00002690  6e 75 28 22 53 63 61 6e  46 69 6c 65 73 22 2c 20  |nu("ScanFiles", |
000026a0  4d 45 4e 55 5f 4c 41 53  54 49 54 45 4d 2c 20 2d  |MENU_LASTITEM, -|
000026b0  31 2c 20 30 2c 20 26 6f  70 74 69 6f 6e 73 5f 6d  |1, 0, &options_m|
000026c0  65 6e 75 29 3b 0a 20 20  20 20 20 61 75 5f 63 72  |enu);.     au_cr|
000026d0  65 61 74 65 6d 65 6e 75  28 26 6f 70 74 69 6f 6e  |eatemenu(&option|
000026e0  73 5f 6d 65 6e 75 29 3b  0a 20 20 20 20 20 61 75  |s_menu);.     au|
000026f0  5f 62 75 69 6c 64 6d 65  6e 75 28 22 41 63 72 6f  |_buildmenu("Acro|
00002700  6e 79 6d 73 22 2c 20 26  67 6c 6f 62 6d 65 6e 29  |nyms", &globmen)|
00002710  3b 0a 20 20 20 20 20 61  75 5f 61 64 64 74 6f 6d  |;.     au_addtom|
00002720  65 6e 75 28 22 49 6e 66  6f 22 2c 20 4d 45 4e 55  |enu("Info", MENU|
00002730  5f 44 4f 54 54 45 44 2c  20 77 69 6e 5f 61 72 72  |_DOTTED, win_arr|
00002740  61 79 5b 31 5d 2e 77 69  6e 5f 68 61 6e 64 6c 65  |ay[1].win_handle|
00002750  2c 20 30 2c 20 26 67 6c  6f 62 6d 65 6e 29 3b 0a  |, 0, &globmen);.|
00002760  20 20 20 20 20 61 75 5f  61 64 64 74 6f 6d 65 6e  |     au_addtomen|
00002770  75 28 22 48 65 6c 70 22  2c 20 30 2c 20 28 69 6e  |u("Help", 0, (in|
00002780  74 29 20 68 65 6c 70 5f  6d 65 6e 75 2e 64 61 74  |t) help_menu.dat|
00002790  61 62 6c 6f 63 6b 2c 20  30 2c 20 26 67 6c 6f 62  |ablock, 0, &glob|
000027a0  6d 65 6e 29 3b 0a 20 20  20 20 20 61 75 5f 61 64  |men);.     au_ad|
000027b0  64 74 6f 6d 65 6e 75 28  22 4f 70 74 69 6f 6e 73  |dtomenu("Options|
000027c0  22 2c 20 4d 45 4e 55 5f  44 4f 54 54 45 44 2c 20  |", MENU_DOTTED, |
000027d0  28 69 6e 74 29 20 6f 70  74 69 6f 6e 73 5f 6d 65  |(int) options_me|
000027e0  6e 75 2e 64 61 74 61 62  6c 6f 63 6b 2c 20 30 2c  |nu.datablock, 0,|
000027f0  20 26 67 6c 6f 62 6d 65  6e 29 3b 0a 20 20 20 20  | &globmen);.    |
00002800  20 61 75 5f 61 64 64 74  6f 6d 65 6e 75 28 22 51  | au_addtomenu("Q|
00002810  75 69 74 22 2c 20 4d 45  4e 55 5f 4c 41 53 54 49  |uit", MENU_LASTI|
00002820  54 45 4d 2c 20 2d 31 2c  20 30 2c 20 26 67 6c 6f  |TEM, -1, 0, &glo|
00002830  62 6d 65 6e 29 3b 0a 20  20 20 20 20 61 75 5f 63  |bmen);.     au_c|
00002840  72 65 61 74 65 6d 65 6e  75 28 26 67 6c 6f 62 6d  |reatemenu(&globm|
00002850  65 6e 29 3b 0a 20 20 20  20 20 61 75 5f 6f 70 65  |en);.     au_ope|
00002860  6e 6d 65 6e 75 28 26 67  6c 6f 62 6d 65 6e 2c 20  |nmenu(&globmen, |
00002870  28 69 6e 74 29 20 61 75  5f 62 79 74 65 74 6f 77  |(int) au_bytetow|
00002880  6f 72 64 28 70 6f 6c 6c  62 6c 6f 63 6b 2c 20 30  |ord(pollblock, 0|
00002890  29 20 2d 20 36 34 2c 20  28 34 34 2a 35 29 2b 39  |) - 64, (44*5)+9|
000028a0  36 29 3b 0a 20 20 20 20  20 72 65 74 75 72 6e 3b  |6);.     return;|
000028b0  0a 20 20 20 7d 0a 7d 0a  0a 69 6e 74 20 6c 6f 61  |.   }.}..int loa|
000028c0  64 5f 74 65 6d 70 6c 61  74 65 73 28 76 6f 69 64  |d_templates(void|
000028d0  29 0a 7b 0a 20 20 61 75  5f 6f 70 65 6e 74 65 6d  |).{.  au_opentem|
000028e0  70 6c 61 74 65 28 22 3c  41 63 72 6f 6e 79 6d 73  |plate("<Acronyms|
000028f0  24 44 69 72 3e 2e 54 65  6d 70 6c 61 74 65 73 22  |$Dir>.Templates"|
00002900  29 3b 20 2f 2a 4f 70 65  6e 20 74 68 65 20 54 65  |); /*Open the Te|
00002910  6d 70 6c 61 74 65 73 20  66 69 6c 65 2a 2f 0a 0a  |mplates file*/..|
00002920  20 20 2f 2a 49 66 20 74  68 65 20 74 65 6d 70 6c  |  /*If the templ|
00002930  61 74 65 20 63 6f 75 6c  64 20 6e 6f 74 20 62 65  |ate could not be|
00002940  20 66 6f 75 6e 64 2a 2f  0a 20 20 69 66 28 61 75  | found*/.  if(au|
00002950  5f 6c 6f 61 64 74 65 6d  70 6c 61 74 65 28 22 41  |_loadtemplate("A|
00002960  63 72 6f 6e 79 6d 73 22  2c 20 26 77 69 6e 5f 61  |cronyms", &win_a|
00002970  72 72 61 79 5b 30 5d 2c  20 30 29 20 3d 3d 20 30  |rray[0], 0) == 0|
00002980  29 0a 20 20 7b 0a 20 20  20 20 2f 2a 52 65 70 6f  |).  {.    /*Repo|
00002990  72 74 20 74 68 61 74 20  74 68 65 20 72 65 6d 70  |rt that the remp|
000029a0  6c 61 74 65 20 63 6f 75  6c 64 20 6e 6f 74 20 62  |late could not b|
000029b0  65 20 66 6f 75 6e 64 2a  2f 0a 20 20 20 20 61 75  |e found*/.    au|
000029c0  5f 72 65 70 6f 72 74 5f  65 72 72 6f 72 28 31 2c  |_report_error(1,|
000029d0  20 22 54 65 6d 70 6c 61  74 65 20 6e 6f 74 20 66  | "Template not f|
000029e0  6f 75 6e 64 21 22 2c 20  31 2c 20 61 70 70 6e 61  |ound!", 1, appna|
000029f0  6d 65 29 3b 0a 20 20 20  20 51 55 49 54 5f 46 4c  |me);.    QUIT_FL|
00002a00  41 47 20 3d 20 31 3b 20  2f 2a 41 6e 64 20 71 75  |AG = 1; /*And qu|
00002a10  69 74 20 74 68 65 20 70  72 6f 67 72 61 6d 2a 2f  |it the program*/|
00002a20  0a 20 20 7d 0a 0a 20 20  2f 2a 49 66 20 74 68 65  |.  }..  /*If the|
00002a30  20 74 65 6d 70 6c 61 74  65 20 63 6f 75 6c 64 20  | template could |
00002a40  6e 6f 74 20 62 65 20 66  6f 75 6e 64 2a 2f 0a 20  |not be found*/. |
00002a50  20 69 66 28 61 75 5f 6c  6f 61 64 74 65 6d 70 6c  | if(au_loadtempl|
00002a60  61 74 65 28 22 49 6e 66  6f 22 2c 20 26 77 69 6e  |ate("Info", &win|
00002a70  5f 61 72 72 61 79 5b 31  5d 2c 20 30 29 20 3d 3d  |_array[1], 0) ==|
00002a80  20 30 29 0a 20 20 7b 0a  20 20 20 20 2f 2a 52 65  | 0).  {.    /*Re|
00002a90  70 6f 72 74 20 74 68 61  74 20 74 68 65 20 72 65  |port that the re|
00002aa0  6d 70 6c 61 74 65 20 63  6f 75 6c 64 20 6e 6f 74  |mplate could not|
00002ab0  20 62 65 20 66 6f 75 6e  64 2a 2f 0a 20 20 20 20  | be found*/.    |
00002ac0  61 75 5f 72 65 70 6f 72  74 5f 65 72 72 6f 72 28  |au_report_error(|
00002ad0  31 2c 20 22 54 65 6d 70  6c 61 74 65 20 6e 6f 74  |1, "Template not|
00002ae0  20 66 6f 75 6e 64 21 22  2c 20 31 2c 20 61 70 70  | found!", 1, app|
00002af0  6e 61 6d 65 29 3b 0a 20  20 20 20 51 55 49 54 5f  |name);.    QUIT_|
00002b00  46 4c 41 47 20 3d 20 31  3b 20 2f 2a 41 6e 64 20  |FLAG = 1; /*And |
00002b10  71 75 69 74 20 74 68 65  20 70 72 6f 67 72 61 6d  |quit the program|
00002b20  2a 2f 0a 20 20 7d 0a 0a  20 20 2f 2a 20 4e 6f 77  |*/.  }..  /* Now|
00002b30  20 77 65 27 76 65 20 66  69 6e 69 73 68 65 64 20  | we've finished |
00002b40  72 65 61 64 69 6e 67 20  74 68 65 20 74 65 6d 70  |reading the temp|
00002b50  6c 61 74 65 73 2c 20 63  6c 6f 73 65 20 74 68 65  |lates, close the|
00002b60  20 66 69 6c 65 20 2a 2f  0a 20 20 61 75 5f 63 6c  | file */.  au_cl|
00002b70  6f 73 65 74 65 6d 70 6c  61 74 65 28 29 3b 0a 20  |osetemplate();. |
00002b80  20 72 65 74 75 72 6e 20  30 3b 0a 7d 0a 0a 76 6f  | return 0;.}..vo|
00002b90  69 64 20 6f 70 65 6e 77  69 6e 64 6f 77 28 75 6e  |id openwindow(un|
00002ba0  73 69 67 6e 65 64 20 63  68 61 72 20 70 6f 6c 6c  |signed char poll|
00002bb0  62 6c 6f 63 6b 5b 5d 29  0a 7b 0a 20 20 20 5f 6b  |block[]).{.   _k|
00002bc0  65 72 6e 65 6c 5f 73 77  69 5f 72 65 67 73 20 69  |ernel_swi_regs i|
00002bd0  6e 2c 20 6f 75 74 3b 0a  0a 20 20 20 69 6e 2e 72  |n, out;..   in.r|
00002be0  5b 31 5d 20 3d 20 28 69  6e 74 29 20 70 6f 6c 6c  |[1] = (int) poll|
00002bf0  62 6c 6f 63 6b 3b 0a 20  20 20 5f 6b 65 72 6e 65  |block;.   _kerne|
00002c00  6c 5f 73 77 69 28 57 69  6d 70 5f 4f 70 65 6e 57  |l_swi(Wimp_OpenW|
00002c10  69 6e 64 6f 77 2c 20 26  69 6e 2c 20 26 6f 75 74  |indow, &in, &out|
00002c20  29 3b 20 2f 2a 4f 70 65  6e 20 74 68 65 20 77 69  |); /*Open the wi|
00002c30  6e 64 6f 77 2a 2f 0a 20  20 20 72 65 74 75 72 6e  |ndow*/.   return|
00002c40  3b 0a 7d 0a 0a 76 6f 69  64 20 63 6c 6f 73 65 77  |;.}..void closew|
00002c50  69 6e 64 6f 77 28 75 6e  73 69 67 6e 65 64 20 63  |indow(unsigned c|
00002c60  68 61 72 20 70 6f 6c 6c  62 6c 6f 63 6b 5b 5d 29  |har pollblock[])|
00002c70  0a 7b 0a 20 20 20 5f 6b  65 72 6e 65 6c 5f 73 77  |.{.   _kernel_sw|
00002c80  69 5f 72 65 67 73 20 69  6e 2c 20 6f 75 74 3b 0a  |i_regs in, out;.|
00002c90  0a 20 20 20 69 6e 2e 72  5b 31 5d 20 3d 20 28 69  |.   in.r[1] = (i|
00002ca0  6e 74 29 20 70 6f 6c 6c  62 6c 6f 63 6b 3b 0a 20  |nt) pollblock;. |
00002cb0  20 20 5f 6b 65 72 6e 65  6c 5f 73 77 69 28 57 69  |  _kernel_swi(Wi|
00002cc0  6d 70 5f 43 6c 6f 73 65  57 69 6e 64 6f 77 2c 20  |mp_CloseWindow, |
00002cd0  26 69 6e 2c 20 26 6f 75  74 29 3b 20 2f 2a 43 6c  |&in, &out); /*Cl|
00002ce0  6f 73 65 20 74 68 65 20  77 69 6e 64 6f 77 2a 2f  |ose the window*/|
00002cf0  0a 20 20 20 72 65 74 75  72 6e 3b 0a 7d 0a 0a 76  |.   return;.}..v|
00002d00  6f 69 64 20 6b 65 79 5f  70 72 65 73 73 28 75 6e  |oid key_press(un|
00002d10  73 69 67 6e 65 64 20 63  68 61 72 20 70 6f 6c 6c  |signed char poll|
00002d20  62 6c 6f 63 6b 5b 5d 29  0a 7b 0a 20 20 5f 6b 65  |block[]).{.  _ke|
00002d30  72 6e 65 6c 5f 73 77 69  5f 72 65 67 73 20 69 6e  |rnel_swi_regs in|
00002d40  2c 20 6f 75 74 3b 0a 20  20 69 6e 74 20 6b 65 79  |, out;.  int key|
00002d50  3b 20 2f 2a 48 6f 6c 64  73 20 74 68 65 20 6b 65  |; /*Holds the ke|
00002d60  79 20 74 68 61 74 20 77  61 73 20 70 72 65 73 73  |y that was press|
00002d70  65 64 2a 2f 0a 0a 20 20  6b 65 79 3d 61 75 5f 62  |ed*/..  key=au_b|
00002d80  79 74 65 74 6f 77 6f 72  64 28 70 6f 6c 6c 62 6c  |ytetoword(pollbl|
00002d90  6f 63 6b 2c 20 32 34 29  3b 20 2f 2a 46 69 6e 64  |ock, 24); /*Find|
00002da0  20 6f 75 74 20 77 68 69  63 68 20 6b 65 79 20 77  | out which key w|
00002db0  61 73 20 70 72 65 73 73  65 64 2a 2f 0a 0a 20 20  |as pressed*/..  |
00002dc0  73 77 69 74 63 68 20 28  6b 65 79 29 0a 20 20 7b  |switch (key).  {|
00002dd0  0a 20 20 20 20 2f 2a 49  66 20 74 68 65 20 6b 65  |.    /*If the ke|
00002de0  79 20 69 73 20 46 31 32  20 74 65 6c 6c 20 74 68  |y is F12 tell th|
00002df0  65 20 77 69 6d 70 20 74  6f 20 70 72 6f 63 65 73  |e wimp to proces|
00002e00  73 20 69 74 2a 2f 0a 20  20 20 20 63 61 73 65 20  |s it*/.    case |
00002e10  34 36 30 3a 20 69 6e 2e  72 5b 30 5d 3d 6b 65 79  |460: in.r[0]=key|
00002e20  3b 20 5f 6b 65 72 6e 65  6c 5f 73 77 69 28 57 69  |; _kernel_swi(Wi|
00002e30  6d 70 5f 50 72 6f 63 65  73 73 4b 65 79 2c 20 26  |mp_ProcessKey, &|
00002e40  69 6e 2c 20 26 6f 75 74  29 3b 0a 20 20 20 20 62  |in, &out);.    b|
00002e50  72 65 61 6b 3b 0a 20 20  20 20 2f 2a 49 66 20 74  |reak;.    /*If t|
00002e60  68 65 20 6b 65 79 20 69  73 20 72 65 74 75 72 6e  |he key is return|
00002e70  20 67 6f 20 74 6f 20 74  68 65 20 66 75 6e 63 74  | go to the funct|
00002e80  69 6f 6e 20 63 68 65 63  6b 5f 61 63 72 6f 6e 79  |ion check_acrony|
00002e90  6d 2a 2f 0a 20 20 20 20  63 61 73 65 20 31 33 3a  |m*/.    case 13:|
00002ea0  20 63 68 65 63 6b 5f 61  63 72 6f 6e 79 6d 28 29  | check_acronym()|
00002eb0  3b 20 2f 2a 43 61 6c 6c  20 74 68 65 20 66 75 6e  |; /*Call the fun|
00002ec0  63 74 69 6f 6e 20 63 68  65 63 6b 5f 61 63 72 6f  |ction check_acro|
00002ed0  6e 79 6d 2a 2f 0a 20 20  20 20 62 72 65 61 6b 3b  |nym*/.    break;|
00002ee0  0a 20 20 7d 0a 0a 7d 0a  0a 76 6f 69 64 20 63 68  |.  }..}..void ch|
00002ef0  65 63 6b 5f 61 63 72 6f  6e 79 6d 28 76 6f 69 64  |eck_acronym(void|
00002f00  29 0a 7b 0a 20 20 5f 6b  65 72 6e 65 6c 5f 73 77  |).{.  _kernel_sw|
00002f10  69 5f 72 65 67 73 20 69  6e 2c 20 6f 75 74 3b 0a  |i_regs in, out;.|
00002f20  0a 20 20 69 6e 74 20 70  61 73 73 3b 20 2f 2a 55  |.  int pass; /*U|
00002f30  73 65 64 20 69 6e 20 74  68 65 20 66 6f 72 20 6c  |sed in the for l|
00002f40  6f 6f 70 2a 2f 0a 20 20  69 6e 74 20 6d 61 74 63  |oop*/.  int matc|
00002f50  68 3d 30 3b 20 2f 2a 49  66 20 74 68 61 74 20 69  |h=0; /*If that i|
00002f60  73 20 31 20 61 20 6d 61  74 63 68 20 68 61 73 20  |s 1 a match has |
00002f70  62 65 65 6e 20 66 6f 75  6e 64 2a 2f 0a 20 20 69  |been found*/.  i|
00002f80  6e 74 20 73 74 72 69 6e  67 5f 6c 65 6e 67 74 68  |nt string_length|
00002f90  3b 20 2f 2a 48 6f 6c 64  73 20 74 68 65 20 6c 65  |; /*Holds the le|
00002fa0  6e 67 74 68 20 6f 66 20  74 68 65 20 73 74 72 69  |ngth of the stri|
00002fb0  6e 67 2a 2f 0a 20 20 63  68 61 72 20 2a 74 65 78  |ng*/.  char *tex|
00002fc0  74 5f 70 6f 69 6e 74 65  72 3b 20 2f 2a 41 20 70  |t_pointer; /*A p|
00002fd0  6f 69 6e 74 65 72 20 74  6f 20 74 68 65 20 69 63  |ointer to the ic|
00002fe0  6f 6e 73 20 74 65 78 74  2a 2f 0a 20 20 63 68 61  |ons text*/.  cha|
00002ff0  72 20 2a 63 70 3b 20 2f  2a 41 20 70 6f 69 6e 74  |r *cp; /*A point|
00003000  65 72 20 74 6f 20 74 68  65 20 63 68 61 72 61 63  |er to the charac|
00003010  74 65 72 20 74 68 61 74  20 77 69 6c 6c 20 62 65  |ter that will be|
00003020  20 63 68 65 63 6b 65 64  20 74 6f 20 73 65 65 20  | checked to see |
00003030  69 66 20 69 74 0a 20 20  20 20 20 20 20 09 20 20  |if it.       .  |
00003040  20 20 20 20 69 73 20 6c  6f 77 65 72 20 63 61 73  |    is lower cas|
00003050  65 20 61 6e 64 20 74 68  65 6e 20 63 6f 6e 76 65  |e and then conve|
00003060  72 74 65 64 20 74 6f 20  75 70 70 65 72 20 63 61  |rted to upper ca|
00003070  73 65 20 69 66 20 69 74  20 69 73 2a 2f 0a 0a 20  |se if it is*/.. |
00003080  20 2f 2a 47 65 74 20 69  63 6f 6e 20 31 27 73 20  | /*Get icon 1's |
00003090  74 65 78 74 2a 2f 0a 20  20 74 65 78 74 5f 70 6f  |text*/.  text_po|
000030a0  69 6e 74 65 72 3d 61 75  5f 67 65 74 5f 70 74 72  |inter=au_get_ptr|
000030b0  5f 74 6f 5f 69 63 6f 6e  74 65 78 74 28 77 69 6e  |_to_icontext(win|
000030c0  5f 61 72 72 61 79 5b 30  5d 2e 77 69 6e 5f 68 61  |_array[0].win_ha|
000030d0  6e 64 6c 65 2c 31 29 3b  0a 0a 20 20 2f 2a 41 64  |ndle,1);..  /*Ad|
000030e0  64 20 61 20 6e 75 6c 6c  20 63 68 61 72 61 63 74  |d a null charact|
000030f0  65 72 20 74 6f 20 74 68  65 20 65 6e 64 20 6f 66  |er to the end of|
00003100  20 74 68 65 20 73 74 72  69 6e 67 2a 2f 0a 20 20  | the string*/.  |
00003110  66 6f 72 28 70 61 73 73  3d 30 3b 70 61 73 73 3c  |for(pass=0;pass<|
00003120  3d 31 39 3b 70 61 73 73  2b 2b 29 0a 20 20 7b 0a  |=19;pass++).  {.|
00003130  20 20 20 20 69 66 28 74  65 78 74 5f 70 6f 69 6e  |    if(text_poin|
00003140  74 65 72 5b 70 61 73 73  5d 20 3c 20 33 32 29 0a  |ter[pass] < 32).|
00003150  20 20 20 20 7b 0a 20 20  20 20 20 20 74 65 78 74  |    {.      text|
00003160  5f 70 6f 69 6e 74 65 72  5b 70 61 73 73 5d 20 3d  |_pointer[pass] =|
00003170  20 27 5c 30 27 3b 0a 20  20 20 20 20 20 62 72 65  | '\0';.      bre|
00003180  61 6b 3b 0a 20 20 20 20  7d 0a 20 20 7d 0a 0a 20  |ak;.    }.  }.. |
00003190  20 66 6f 72 28 70 61 73  73 3d 30 3b 70 61 73 73  | for(pass=0;pass|
000031a0  3c 3d 4d 41 58 5f 4e 4f  5f 4f 46 5f 41 43 52 4f  |<=MAX_NO_OF_ACRO|
000031b0  4e 59 4d 53 3b 70 61 73  73 2b 2b 29 0a 20 20 7b  |NYMS;pass++).  {|
000031c0  0a 20 20 20 20 2f 2a 49  66 20 69 63 6f 6e 20 31  |.    /*If icon 1|
000031d0  27 73 20 74 65 78 74 20  6d 61 74 63 68 27 73 20  |'s text match's |
000031e0  61 20 73 6d 69 6c 65 79  2a 2f 0a 20 20 20 20 69  |a smiley*/.    i|
000031f0  66 28 73 74 72 63 6d 70  28 61 63 72 6f 6e 79 6d  |f(strcmp(acronym|
00003200  73 5f 63 61 73 65 5f 73  65 6e 73 5b 70 61 73 73  |s_case_sens[pass|
00003210  5d 2c 74 65 78 74 5f 70  6f 69 6e 74 65 72 29 3d  |],text_pointer)=|
00003220  3d 30 29 0a 20 20 20 20  7b 0a 20 20 20 20 20 20  |=0).    {.      |
00003230  2f 2a 43 68 61 6e 67 65  20 69 63 6f 6e 20 32 27  |/*Change icon 2'|
00003240  73 20 74 65 78 74 20 74  6f 20 74 68 65 20 61 6e  |s text to the an|
00003250  73 77 65 72 2a 2f 0a 20  20 20 20 20 20 61 75 5f  |swer*/.      au_|
00003260  69 63 6f 6e 5f 74 65 78  74 5f 63 68 61 6e 67 65  |icon_text_change|
00003270  28 61 6e 73 77 65 72 73  5f 63 61 73 65 5f 73 65  |(answers_case_se|
00003280  6e 73 5b 70 61 73 73 5d  2c 77 69 6e 5f 61 72 72  |ns[pass],win_arr|
00003290  61 79 5b 30 5d 2e 77 69  6e 5f 68 61 6e 64 6c 65  |ay[0].win_handle|
000032a0  2c 32 29 3b 0a 20 20 20  20 20 20 6d 61 74 63 68  |,2);.      match|
000032b0  3d 31 3b 20 2f 2a 53 65  74 20 74 68 65 20 6d 61  |=1; /*Set the ma|
000032c0  74 63 68 20 69 6e 74 65  72 67 65 72 20 74 6f 20  |tch interger to |
000032d0  73 68 6f 77 20 61 20 6d  61 74 63 68 20 68 61 73  |show a match has|
000032e0  20 62 65 65 6e 20 66 6f  75 6e 64 2a 2f 0a 20 20  | been found*/.  |
000032f0  20 20 20 20 62 72 65 61  6b 3b 20 2f 2a 42 72 65  |    break; /*Bre|
00003300  61 6b 20 74 68 65 20 6c  6f 6f 70 2a 2f 0a 20 20  |ak the loop*/.  |
00003310  20 20 7d 0a 20 20 7d 0a  0a 20 20 69 66 28 6d 61  |  }.  }..  if(ma|
00003320  74 63 68 20 3d 3d 20 30  29 20 2f 2a 49 66 20 61  |tch == 0) /*If a|
00003330  20 6d 61 74 63 68 20 68  61 73 20 6e 6f 74 20 79  | match has not y|
00003340  65 74 20 62 65 65 6e 20  66 6f 75 6e 64 2a 2f 0a  |et been found*/.|
00003350  20 20 7b 0a 20 20 20 20  66 6f 72 20 28 63 70 3d  |  {.    for (cp=|
00003360  74 65 78 74 5f 70 6f 69  6e 74 65 72 3b 63 70 20  |text_pointer;cp |
00003370  26 26 20 2a 63 70 3b 63  70 2b 2b 29 0a 20 20 20  |&& *cp;cp++).   |
00003380  20 7b 0a 20 20 20 20 20  20 2a 63 70 20 3d 20 74  | {.      *cp = t|
00003390  6f 75 70 70 65 72 28 2a  63 70 29 3b 20 2f 2a 43  |oupper(*cp); /*C|
000033a0  6f 6e 76 65 72 74 20 74  68 65 20 63 68 61 72 61  |onvert the chara|
000033b0  63 74 65 72 20 70 6f 69  6e 74 65 64 20 74 6f 20  |cter pointed to |
000033c0  62 79 20 63 70 20 74 6f  20 61 6e 20 75 70 70 65  |by cp to an uppe|
000033d0  72 0a 20 20 20 20 20 20  09 20 20 20 20 09 20 20  |r.      .    .  |
000033e0  20 20 09 20 20 20 20 63  61 73 65 20 63 68 61 72  |  .    case char|
000033f0  61 63 74 65 72 2a 2f 0a  20 20 20 20 7d 0a 0a 20  |acter*/.    }.. |
00003400  20 20 20 2f 2a 53 65 74  20 74 68 65 20 74 65 78  |   /*Set the tex|
00003410  74 20 69 6e 20 69 63 6f  6e 20 31 20 74 6f 20 74  |t in icon 1 to t|
00003420  68 65 20 6e 65 77 20 75  70 70 65 72 20 63 61 73  |he new upper cas|
00003430  65 20 73 74 72 69 6e 67  2a 2f 0a 20 20 20 20 61  |e string*/.    a|
00003440  75 5f 69 63 6f 6e 5f 74  65 78 74 5f 63 68 61 6e  |u_icon_text_chan|
00003450  67 65 28 74 65 78 74 5f  70 6f 69 6e 74 65 72 2c  |ge(text_pointer,|
00003460  77 69 6e 5f 61 72 72 61  79 5b 30 5d 2e 77 69 6e  |win_array[0].win|
00003470  5f 68 61 6e 64 6c 65 2c  31 29 3b 0a 0a 20 20 20  |_handle,1);..   |
00003480  20 73 74 72 69 6e 67 5f  6c 65 6e 67 74 68 20 3d  | string_length =|
00003490  20 73 74 72 6c 65 6e 28  74 65 78 74 5f 70 6f 69  | strlen(text_poi|
000034a0  6e 74 65 72 29 3b 0a 0a  20 20 20 20 69 6e 2e 72  |nter);..    in.r|
000034b0  5b 30 5d 20 3d 20 28 69  6e 74 29 20 77 69 6e 5f  |[0] = (int) win_|
000034c0  61 72 72 61 79 5b 30 5d  2e 77 69 6e 5f 68 61 6e  |array[0].win_han|
000034d0  64 6c 65 3b 0a 20 20 20  20 69 6e 2e 72 5b 31 5d  |dle;.    in.r[1]|
000034e0  20 3d 20 31 3b 0a 20 20  20 20 69 6e 2e 72 5b 34  | = 1;.    in.r[4|
000034f0  5d 20 3d 20 2d 31 3b 0a  20 20 20 20 69 6e 2e 72  |] = -1;.    in.r|
00003500  5b 35 5d 20 3d 20 28 69  6e 74 29 20 73 74 72 69  |[5] = (int) stri|
00003510  6e 67 5f 6c 65 6e 67 74  68 3b 0a 20 20 20 20 5f  |ng_length;.    _|
00003520  6b 65 72 6e 65 6c 5f 73  77 69 28 57 69 6d 70 5f  |kernel_swi(Wimp_|
00003530  53 65 74 43 61 72 65 74  50 6f 73 69 74 69 6f 6e  |SetCaretPosition|
00003540  2c 20 26 69 6e 2c 20 26  6f 75 74 29 3b 0a 0a 20  |, &in, &out);.. |
00003550  20 20 20 66 6f 72 28 70  61 73 73 3d 30 3b 70 61  |   for(pass=0;pa|
00003560  73 73 3c 3d 4d 41 58 5f  4e 4f 5f 4f 46 5f 41 43  |ss<=MAX_NO_OF_AC|
00003570  52 4f 4e 59 4d 53 3b 70  61 73 73 2b 2b 29 0a 20  |RONYMS;pass++). |
00003580  20 20 20 7b 0a 20 20 20  20 20 20 2f 2a 49 66 20  |   {.      /*If |
00003590  69 63 6f 6e 20 31 27 73  20 74 65 78 74 20 6d 61  |icon 1's text ma|
000035a0  74 63 68 27 73 20 61 6e  20 61 63 72 6f 6e 79 6d  |tch's an acronym|
000035b0  2a 2f 0a 20 20 20 20 20  20 69 66 28 73 74 72 63  |*/.      if(strc|
000035c0  6d 70 28 61 63 72 6f 6e  79 6d 73 5f 63 61 73 65  |mp(acronyms_case|
000035d0  5f 69 6e 5f 73 65 6e 73  5b 70 61 73 73 5d 2c 74  |_in_sens[pass],t|
000035e0  65 78 74 5f 70 6f 69 6e  74 65 72 29 3d 3d 30 29  |ext_pointer)==0)|
000035f0  0a 20 20 20 20 20 20 7b  0a 20 20 20 20 20 20 20  |.      {.       |
00003600  20 2f 2a 43 68 61 6e 67  65 20 69 63 6f 6e 20 32  | /*Change icon 2|
00003610  27 73 20 74 65 78 74 20  74 6f 20 74 68 65 20 61  |'s text to the a|
00003620  6e 73 77 65 72 2a 2f 0a  20 20 20 20 20 20 20 20  |nswer*/.        |
00003630  61 75 5f 69 63 6f 6e 5f  74 65 78 74 5f 63 68 61  |au_icon_text_cha|
00003640  6e 67 65 28 61 6e 73 77  65 72 73 5f 63 61 73 65  |nge(answers_case|
00003650  5f 69 6e 5f 73 65 6e 73  5b 70 61 73 73 5d 2c 77  |_in_sens[pass],w|
00003660  69 6e 5f 61 72 72 61 79  5b 30 5d 2e 77 69 6e 5f  |in_array[0].win_|
00003670  68 61 6e 64 6c 65 2c 32  29 3b 0a 20 20 20 20 20  |handle,2);.     |
00003680  20 20 20 6d 61 74 63 68  3d 31 3b 20 2f 2a 53 65  |   match=1; /*Se|
00003690  74 20 74 68 65 20 6d 61  74 63 68 20 69 6e 74 65  |t the match inte|
000036a0  72 67 65 72 20 74 6f 20  73 68 6f 77 20 61 20 6d  |rger to show a m|
000036b0  61 74 63 68 20 68 61 73  20 62 65 65 6e 20 66 6f  |atch has been fo|
000036c0  75 6e 64 2a 2f 0a 20 20  20 20 20 20 20 20 62 72  |und*/.        br|
000036d0  65 61 6b 3b 20 2f 2a 42  72 65 61 6b 20 74 68 65  |eak; /*Break the|
000036e0  20 6c 6f 6f 70 2a 2f 0a  20 20 20 20 20 20 7d 0a  | loop*/.      }.|
000036f0  20 20 20 20 7d 0a 20 20  7d 0a 0a 20 20 69 66 28  |    }.  }..  if(|
00003700  6d 61 74 63 68 3d 3d 30  29 20 2f 2a 49 66 20 6e  |match==0) /*If n|
00003710  6f 20 6d 61 74 63 68 20  69 73 20 66 6f 75 6e 64  |o match is found|
00003720  2a 2f 0a 20 20 7b 0a 20  20 20 20 2f 2a 53 65 74  |*/.  {.    /*Set|
00003730  20 69 63 6f 6e 20 32 27  73 20 74 65 78 74 20 74  | icon 2's text t|
00003740  6f 20 27 55 6e 6b 6e 6f  77 6e 27 2a 2f 0a 20 20  |o 'Unknown'*/.  |
00003750  20 20 61 75 5f 69 63 6f  6e 5f 74 65 78 74 5f 63  |  au_icon_text_c|
00003760  68 61 6e 67 65 28 22 55  6e 6b 6e 6f 77 6e 22 2c  |hange("Unknown",|
00003770  77 69 6e 5f 61 72 72 61  79 5b 30 5d 2e 77 69 6e  |win_array[0].win|
00003780  5f 68 61 6e 64 6c 65 2c  32 29 3b 0a 20 20 7d 0a  |_handle,2);.  }.|
00003790  7d 0a 0a 73 69 7a 65 5f  74 20 67 65 74 5f 66 69  |}..size_t get_fi|
000037a0  6c 65 5f 73 69 7a 65 28  46 49 4c 45 20 2a 66 69  |le_size(FILE *fi|
000037b0  6c 65 5f 70 6f 69 6e 74  65 72 29 0a 7b 0a 20 20  |le_pointer).{.  |
000037c0  2f 2a 46 69 6e 64 20 74  68 65 20 73 69 7a 65 20  |/*Find the size |
000037d0  6f 66 20 61 20 66 69 6c  65 20 70 6f 69 6e 74 65  |of a file pointe|
000037e0  64 20 74 6f 20 62 79 20  66 69 6c 65 5f 70 6f 69  |d to by file_poi|
000037f0  6e 74 65 72 2a 2f 0a 20  20 73 69 7a 65 5f 74 20  |nter*/.  size_t |
00003800  66 53 69 7a 65 3b 0a 0a  20 20 66 73 65 65 6b 28  |fSize;..  fseek(|
00003810  66 69 6c 65 5f 70 6f 69  6e 74 65 72 2c 20 30 4c  |file_pointer, 0L|
00003820  2c 20 53 45 45 4b 5f 45  4e 44 29 3b 0a 20 20 66  |, SEEK_END);.  f|
00003830  53 69 7a 65 20 3d 20 28  73 69 7a 65 5f 74 29 20  |Size = (size_t) |
00003840  66 74 65 6c 6c 28 66 69  6c 65 5f 70 6f 69 6e 74  |ftell(file_point|
00003850  65 72 29 3b 0a 20 20 66  73 65 65 6b 28 66 69 6c  |er);.  fseek(fil|
00003860  65 5f 70 6f 69 6e 74 65  72 2c 20 30 4c 2c 20 53  |e_pointer, 0L, S|
00003870  45 45 4b 5f 53 45 54 29  3b 0a 0a 20 20 72 65 74  |EEK_SET);..  ret|
00003880  75 72 6e 20 66 53 69 7a  65 3b 0a 7d 0a 0a 76 6f  |urn fSize;.}..vo|
00003890  69 64 20 69 6e 69 74 69  61 6c 69 73 65 5f 74 65  |id initialise_te|
000038a0  78 74 5f 66 69 6c 65 73  28 76 6f 69 64 29 0a 7b  |xt_files(void).{|
000038b0  0a 20 20 63 68 61 72 20  2a 66 69 6c 65 62 75 66  |.  char *filebuf|
000038c0  66 65 72 3b 20 2f 2a 54  68 65 20 73 74 72 69 6e  |fer; /*The strin|
000038d0  67 20 72 65 61 64 20 66  72 6f 6d 20 74 68 65 20  |g read from the |
000038e0  66 69 6c 65 20 69 73 20  73 74 6f 72 65 64 20 69  |file is stored i|
000038f0  6e 20 74 68 69 73 20 63  68 61 72 2a 2f 0a 20 20  |n this char*/.  |
00003900  69 6e 74 20 70 61 73 73  3b 20 2f 2a 55 73 65 64  |int pass; /*Used|
00003910  20 69 6e 20 74 68 65 20  66 6f 72 20 6c 6f 6f 70  | in the for loop|
00003920  2a 2f 0a 0a 20 20 2f 2a  4f 70 65 6e 20 74 68 65  |*/..  /*Open the|
00003930  20 43 61 73 65 49 6e 53  65 6e 73 20 66 69 6c 65  | CaseInSens file|
00003940  20 2a 2f 0a 0a 20 20 66  69 6c 65 62 75 66 66 65  | */..  filebuffe|
00003950  72 3d 6c 6f 61 64 5f 74  65 78 74 5f 66 69 6c 65  |r=load_text_file|
00003960  28 22 3c 41 63 72 6f 6e  79 6d 73 54 65 78 74 46  |("<AcronymsTextF|
00003970  69 6c 65 73 24 44 69 72  3e 2e 43 61 73 65 49 6e  |iles$Dir>.CaseIn|
00003980  53 65 6e 73 22 29 3b 0a  0a 20 20 2f 2a 49 66 20  |Sens");..  /*If |
00003990  74 68 65 20 71 75 69 74  20 66 6c 61 67 20 69 73  |the quit flag is|
000039a0  20 73 65 74 20 72 65 74  75 72 6e 2a 2f 0a 20 20  | set return*/.  |
000039b0  69 66 28 51 55 49 54 5f  46 4c 41 47 3d 3d 31 29  |if(QUIT_FLAG==1)|
000039c0  0a 20 20 7b 0a 20 20 20  20 66 72 65 65 28 66 69  |.  {.    free(fi|
000039d0  6c 65 62 75 66 66 65 72  29 3b 20 2f 2a 46 72 65  |lebuffer); /*Fre|
000039e0  65 73 20 74 68 65 20 6d  65 6d 6f 72 79 20 61 6c  |es the memory al|
000039f0  6c 6f 63 61 74 65 64 20  74 6f 20 66 69 6c 65 62  |located to fileb|
00003a00  75 66 66 65 72 2a 2f 0a  20 20 20 20 72 65 74 75  |uffer*/.    retu|
00003a10  72 6e 3b 0a 20 20 7d 0a  0a 20 20 2f 2a 53 70 6c  |rn;.  }..  /*Spl|
00003a20  69 74 20 74 68 65 20 61  63 72 6f 6e 79 6d 73 20  |it the acronyms |
00003a30  61 6e 64 20 74 68 65 69  72 20 61 6e 73 77 65 72  |and their answer|
00003a40  73 20 75 70 2a 2f 0a 0a  20 20 66 6f 72 28 70 61  |s up*/..  for(pa|
00003a50  73 73 3d 30 3b 70 61 73  73 3c 3d 4d 41 58 5f 4e  |ss=0;pass<=MAX_N|
00003a60  4f 5f 4f 46 5f 41 43 52  4f 4e 59 4d 53 3b 70 61  |O_OF_ACRONYMS;pa|
00003a70  73 73 2b 2b 29 0a 20 20  7b 0a 20 20 20 20 2f 2a  |ss++).  {.    /*|
00003a80  50 6c 61 63 65 20 74 68  65 20 73 70 6c 69 74 20  |Place the split |
00003a90  73 74 72 69 6e 67 73 20  69 6e 74 6f 20 74 68 65  |strings into the|
00003aa0  20 61 63 72 6f 6e 79 6d  73 20 61 72 72 61 79 2a  | acronyms array*|
00003ab0  2f 0a 20 20 20 20 61 63  72 6f 6e 79 6d 73 5f 63  |/.    acronyms_c|
00003ac0  61 73 65 5f 69 6e 5f 73  65 6e 73 5b 70 61 73 73  |ase_in_sens[pass|
00003ad0  5d 20 3d 20 73 74 72 74  6f 6b 28 66 69 6c 65 62  |] = strtok(fileb|
00003ae0  75 66 66 65 72 2c 20 22  5c 6e 22 29 3b 0a 20 20  |uffer, "\n");.  |
00003af0  20 20 66 69 6c 65 62 75  66 66 65 72 3d 30 3b 20  |  filebuffer=0; |
00003b00  2f 2a 52 65 73 65 74 20  74 6f 20 30 20 61 6e 64  |/*Reset to 0 and|
00003b10  20 72 65 70 65 61 74 20  77 69 74 68 20 74 68 65  | repeat with the|
00003b20  20 6e 65 78 74 20 73 70  6c 69 74 20 73 74 72 69  | next split stri|
00003b30  6e 67 2a 2f 0a 20 20 20  20 2f 2a 50 6c 61 63 65  |ng*/.    /*Place|
00003b40  20 74 68 65 20 73 70 6c  69 74 20 73 74 72 69 6e  | the split strin|
00003b50  67 73 20 69 6e 74 6f 20  74 68 65 20 61 6e 73 77  |gs into the answ|
00003b60  65 72 73 20 61 72 72 61  79 2a 2f 0a 20 20 20 20  |ers array*/.    |
00003b70  61 6e 73 77 65 72 73 5f  63 61 73 65 5f 69 6e 5f  |answers_case_in_|
00003b80  73 65 6e 73 5b 70 61 73  73 5d 20 3d 20 73 74 72  |sens[pass] = str|
00003b90  74 6f 6b 28 66 69 6c 65  62 75 66 66 65 72 2c 20  |tok(filebuffer, |
00003ba0  22 5c 6e 22 29 3b 0a 20  20 20 20 66 69 6c 65 62  |"\n");.    fileb|
00003bb0  75 66 66 65 72 3d 30 3b  20 2f 2a 52 65 73 65 74  |uffer=0; /*Reset|
00003bc0  20 74 6f 20 30 20 61 6e  64 20 72 65 70 65 61 74  | to 0 and repeat|
00003bd0  20 77 69 74 68 20 74 68  65 20 6e 65 78 74 20 73  | with the next s|
00003be0  70 6c 69 74 20 73 74 72  69 6e 67 2a 2f 0a 20 20  |plit string*/.  |
00003bf0  7d 0a 0a 20 20 66 72 65  65 28 66 69 6c 65 62 75  |}..  free(filebu|
00003c00  66 66 65 72 29 3b 20 2f  2a 46 72 65 65 73 20 74  |ffer); /*Frees t|
00003c10  68 65 20 6d 65 6d 6f 72  79 20 61 6c 6c 6f 63 61  |he memory alloca|
00003c20  74 65 64 20 74 6f 20 66  69 6c 65 62 75 66 66 65  |ted to filebuffe|
00003c30  72 2a 2f 0a 0a 20 20 2f  2a 4f 70 65 6e 20 74 68  |r*/..  /*Open th|
00003c40  65 20 43 61 73 65 53 65  6e 73 20 66 69 6c 65 20  |e CaseSens file |
00003c50  2a 2f 0a 0a 20 20 66 69  6c 65 62 75 66 66 65 72  |*/..  filebuffer|
00003c60  3d 6c 6f 61 64 5f 74 65  78 74 5f 66 69 6c 65 28  |=load_text_file(|
00003c70  22 3c 41 63 72 6f 6e 79  6d 73 54 65 78 74 46 69  |"<AcronymsTextFi|
00003c80  6c 65 73 24 44 69 72 3e  2e 43 61 73 65 53 65 6e  |les$Dir>.CaseSen|
00003c90  73 22 29 3b 0a 0a 20 20  2f 2a 49 66 20 74 68 65  |s");..  /*If the|
00003ca0  20 71 75 69 74 20 66 6c  61 67 20 69 73 20 73 65  | quit flag is se|
00003cb0  74 20 72 65 74 75 72 6e  2a 2f 0a 20 20 69 66 28  |t return*/.  if(|
00003cc0  51 55 49 54 5f 46 4c 41  47 3d 3d 31 29 0a 20 20  |QUIT_FLAG==1).  |
00003cd0  7b 0a 20 20 20 20 66 72  65 65 28 66 69 6c 65 62  |{.    free(fileb|
00003ce0  75 66 66 65 72 29 3b 20  2f 2a 46 72 65 65 73 20  |uffer); /*Frees |
00003cf0  74 68 65 20 6d 65 6d 6f  72 79 20 61 6c 6c 6f 63  |the memory alloc|
00003d00  61 74 65 64 20 74 6f 20  66 69 6c 65 62 75 66 66  |ated to filebuff|
00003d10  65 72 2a 2f 0a 20 20 20  20 72 65 74 75 72 6e 3b  |er*/.    return;|
00003d20  0a 20 20 7d 0a 0a 20 20  2f 2a 53 70 6c 69 74 20  |.  }..  /*Split |
00003d30  74 68 65 20 61 63 72 6f  6e 79 6d 73 20 61 6e 64  |the acronyms and|
00003d40  20 74 68 65 69 72 20 61  6e 73 77 65 72 73 20 75  | their answers u|
00003d50  70 2a 2f 0a 0a 20 20 66  6f 72 28 70 61 73 73 3d  |p*/..  for(pass=|
00003d60  30 3b 70 61 73 73 3c 3d  4d 41 58 5f 4e 4f 5f 4f  |0;pass<=MAX_NO_O|
00003d70  46 5f 41 43 52 4f 4e 59  4d 53 3b 70 61 73 73 2b  |F_ACRONYMS;pass+|
00003d80  2b 29 0a 20 20 7b 0a 20  20 20 20 2f 2a 50 6c 61  |+).  {.    /*Pla|
00003d90  63 65 20 74 68 65 20 73  70 6c 69 74 20 73 74 72  |ce the split str|
00003da0  69 6e 67 73 20 69 6e 74  6f 20 74 68 65 20 61 63  |ings into the ac|
00003db0  72 6f 6e 79 6d 73 20 61  72 72 61 79 2a 2f 0a 20  |ronyms array*/. |
00003dc0  20 20 20 61 63 72 6f 6e  79 6d 73 5f 63 61 73 65  |   acronyms_case|
00003dd0  5f 73 65 6e 73 5b 70 61  73 73 5d 20 3d 20 73 74  |_sens[pass] = st|
00003de0  72 74 6f 6b 28 66 69 6c  65 62 75 66 66 65 72 2c  |rtok(filebuffer,|
00003df0  20 22 5c 6e 22 29 3b 0a  20 20 20 20 66 69 6c 65  | "\n");.    file|
00003e00  62 75 66 66 65 72 3d 30  3b 20 2f 2a 52 65 73 65  |buffer=0; /*Rese|
00003e10  74 20 74 6f 20 30 20 61  6e 64 20 72 65 70 65 61  |t to 0 and repea|
00003e20  74 20 77 69 74 68 20 74  68 65 20 6e 65 78 74 20  |t with the next |
00003e30  73 70 6c 69 74 20 73 74  72 69 6e 67 2a 2f 0a 20  |split string*/. |
00003e40  20 20 20 2f 2a 50 6c 61  63 65 20 74 68 65 20 73  |   /*Place the s|
00003e50  70 6c 69 74 20 73 74 72  69 6e 67 73 20 69 6e 74  |plit strings int|
00003e60  6f 20 74 68 65 20 61 6e  73 77 65 72 73 20 61 72  |o the answers ar|
00003e70  72 61 79 2a 2f 0a 20 20  20 20 61 6e 73 77 65 72  |ray*/.    answer|
00003e80  73 5f 63 61 73 65 5f 73  65 6e 73 5b 70 61 73 73  |s_case_sens[pass|
00003e90  5d 20 3d 20 73 74 72 74  6f 6b 28 66 69 6c 65 62  |] = strtok(fileb|
00003ea0  75 66 66 65 72 2c 20 22  5c 6e 22 29 3b 0a 20 20  |uffer, "\n");.  |
00003eb0  20 20 66 69 6c 65 62 75  66 66 65 72 3d 30 3b 20  |  filebuffer=0; |
00003ec0  2f 2a 52 65 73 65 74 20  74 6f 20 30 20 61 6e 64  |/*Reset to 0 and|
00003ed0  20 72 65 70 65 61 74 20  77 69 74 68 20 74 68 65  | repeat with the|
00003ee0  20 6e 65 78 74 20 73 70  6c 69 74 20 73 74 72 69  | next split stri|
00003ef0  6e 67 2a 2f 0a 20 20 7d  0a 0a 20 20 66 72 65 65  |ng*/.  }..  free|
00003f00  28 66 69 6c 65 62 75 66  66 65 72 29 3b 20 2f 2a  |(filebuffer); /*|
00003f10  46 72 65 65 73 20 74 68  65 20 6d 65 6d 6f 72 79  |Frees the memory|
00003f20  20 61 6c 6c 6f 63 61 74  65 64 20 74 6f 20 66 69  | allocated to fi|
00003f30  6c 65 62 75 66 66 65 72  2a 2f 0a 7d 0a 0a 63 68  |lebuffer*/.}..ch|
00003f40  61 72 20 2a 6c 6f 61 64  5f 74 65 78 74 5f 66 69  |ar *load_text_fi|
00003f50  6c 65 28 63 68 61 72 20  2a 66 69 6c 65 5f 6e 61  |le(char *file_na|
00003f60  6d 65 29 0a 7b 0a 20 20  46 49 4c 45 20 2a 66 70  |me).{.  FILE *fp|
00003f70  6f 69 6e 74 3b 20 2f 2a  41 20 70 6f 69 6e 74 65  |oint; /*A pointe|
00003f80  72 20 74 6f 20 61 6e 20  6f 70 65 6e 20 66 69 6c  |r to an open fil|
00003f90  65 2a 2f 0a 20 20 73 69  7a 65 5f 74 20 66 53 69  |e*/.  size_t fSi|
00003fa0  7a 65 3b 20 2f 2a 54 68  65 20 73 69 7a 65 20 6f  |ze; /*The size o|
00003fb0  66 20 74 68 65 20 6f 70  65 6e 20 66 69 6c 65 2a  |f the open file*|
00003fc0  2f 0a 20 20 63 68 61 72  20 2a 65 72 72 6f 72 5f  |/.  char *error_|
00003fd0  6d 65 73 73 61 67 65 3d  22 22 3b 20 2f 2a 48 6f  |message=""; /*Ho|
00003fe0  6c 64 73 20 61 6e 79 20  65 72 72 6f 72 20 6d 65  |lds any error me|
00003ff0  73 73 61 67 65 20 74 65  78 74 2a 2f 0a 20 20 63  |ssage text*/.  c|
00004000  68 61 72 20 2a 66 69 6c  65 62 75 66 66 65 72 3b  |har *filebuffer;|
00004010  20 2f 2a 54 68 65 20 73  74 72 69 6e 67 20 72 65  | /*The string re|
00004020  61 64 20 66 72 6f 6d 20  74 68 65 20 66 69 6c 65  |ad from the file|
00004030  20 69 73 20 73 74 6f 72  65 64 20 69 6e 20 74 68  | is stored in th|
00004040  69 73 20 63 68 61 72 2a  2f 0a 20 20 69 6e 74 20  |is char*/.  int |
00004050  63 6f 75 6e 74 3d 30 3b  0a 0a 20 20 2f 2a 4f 70  |count=0;..  /*Op|
00004060  65 6e 20 74 68 65 20 74  65 78 74 20 66 69 6c 65  |en the text file|
00004070  20 2a 2f 0a 0a 20 20 69  66 20 28 28 66 70 6f 69  | */..  if ((fpoi|
00004080  6e 74 20 3d 20 66 6f 70  65 6e 28 66 69 6c 65 5f  |nt = fopen(file_|
00004090  6e 61 6d 65 2c 20 22 72  22 29 29 20 3d 3d 20 4e  |name, "r")) == N|
000040a0  55 4c 4c 29 0a 20 20 7b  0a 20 20 20 20 65 72 72  |ULL).  {.    err|
000040b0  6f 72 5f 6d 65 73 73 61  67 65 3d 22 46 61 69 6c  |or_message="Fail|
000040c0  65 64 20 74 6f 20 6f 70  65 6e 20 66 69 6c 65 20  |ed to open file |
000040d0  22 3b 0a 20 20 20 20 73  74 72 63 61 74 28 65 72  |";.    strcat(er|
000040e0  72 6f 72 5f 6d 65 73 73  61 67 65 2c 66 69 6c 65  |ror_message,file|
000040f0  5f 6e 61 6d 65 29 3b 0a  20 20 20 20 61 75 5f 72  |_name);.    au_r|
00004100  65 70 6f 72 74 5f 65 72  72 6f 72 28 31 2c 20 65  |eport_error(1, e|
00004110  72 72 6f 72 5f 6d 65 73  73 61 67 65 2c 20 31 2c  |rror_message, 1,|
00004120  20 61 70 70 6e 61 6d 65  29 3b 0a 20 20 20 20 51  | appname);.    Q|
00004130  55 49 54 5f 46 4c 41 47  20 3d 20 31 3b 20 2f 2a  |UIT_FLAG = 1; /*|
00004140  41 6e 64 20 71 75 69 74  20 74 68 65 20 70 72 6f  |And quit the pro|
00004150  67 72 61 6d 2a 2f 0a 20  20 20 20 72 65 74 75 72  |gram*/.    retur|
00004160  6e 20 66 69 6c 65 62 75  66 66 65 72 3b 0a 20 20  |n filebuffer;.  |
00004170  7d 0a 0a 20 20 2f 2a 46  69 6e 64 20 6f 75 74 20  |}..  /*Find out |
00004180  68 6f 77 20 62 69 67 20  74 68 65 20 66 69 6c 65  |how big the file|
00004190  20 69 73 20 61 6e 64 20  73 74 6f 72 65 20 74 68  | is and store th|
000041a0  61 74 20 6e 75 6d 62 65  72 20 69 6e 20 66 73 69  |at number in fsi|
000041b0  7a 65 20 2a 2f 0a 0a 20  20 66 53 69 7a 65 20 3d  |ze */..  fSize =|
000041c0  20 67 65 74 5f 66 69 6c  65 5f 73 69 7a 65 28 66  | get_file_size(f|
000041d0  70 6f 69 6e 74 29 3b 0a  0a 20 20 2f 2a 47 65 74  |point);..  /*Get|
000041e0  20 6d 65 6d 6f 72 79 20  66 6f 72 20 74 68 65 20  | memory for the |
000041f0  73 74 72 69 6e 67 20 70  6c 75 73 20 6f 6e 65 20  |string plus one |
00004200  62 79 74 65 20 66 6f 72  20 74 68 65 20 74 65 72  |byte for the ter|
00004210  6d 69 6e 61 74 6f 72 20  2a 2f 0a 0a 20 20 69 66  |minator */..  if|
00004220  20 28 28 66 69 6c 65 62  75 66 66 65 72 20 3d 20  | ((filebuffer = |
00004230  28 63 68 61 72 20 2a 29  20 6d 61 6c 6c 6f 63 28  |(char *) malloc(|
00004240  66 53 69 7a 65 2b 31 29  29 20 3d 3d 20 4e 55 4c  |fSize+1)) == NUL|
00004250  4c 29 0a 20 20 7b 0a 20  20 20 20 65 72 72 6f 72  |L).  {.    error|
00004260  5f 6d 65 73 73 61 67 65  3d 22 46 61 69 6c 65 64  |_message="Failed|
00004270  20 74 6f 20 63 6c 61 69  6d 20 65 6e 6f 75 67 68  | to claim enough|
00004280  20 74 6f 20 6c 6f 61 64  20 66 69 6c 65 20 22 3b  | to load file ";|
00004290  0a 20 20 20 20 73 74 72  63 61 74 28 65 72 72 6f  |.    strcat(erro|
000042a0  72 5f 6d 65 73 73 61 67  65 2c 66 69 6c 65 5f 6e  |r_message,file_n|
000042b0  61 6d 65 29 3b 0a 20 20  20 20 61 75 5f 72 65 70  |ame);.    au_rep|
000042c0  6f 72 74 5f 65 72 72 6f  72 28 31 2c 20 65 72 72  |ort_error(1, err|
000042d0  6f 72 5f 6d 65 73 73 61  67 65 2c 20 31 2c 20 61  |or_message, 1, a|
000042e0  70 70 6e 61 6d 65 29 3b  0a 20 20 20 20 51 55 49  |ppname);.    QUI|
000042f0  54 5f 46 4c 41 47 20 3d  20 31 3b 20 2f 2a 41 6e  |T_FLAG = 1; /*An|
00004300  64 20 71 75 69 74 20 74  68 65 20 70 72 6f 67 72  |d quit the progr|
00004310  61 6d 2a 2f 0a 20 20 20  20 72 65 74 75 72 6e 20  |am*/.    return |
00004320  66 69 6c 65 62 75 66 66  65 72 3b 0a 20 20 7d 0a  |filebuffer;.  }.|
00004330  0a 20 20 2f 2a 52 65 61  64 20 74 68 65 20 74 65  |.  /*Read the te|
00004340  78 74 20 66 72 6f 6d 20  74 68 65 20 66 69 6c 65  |xt from the file|
00004350  20 69 6e 74 6f 20 66 69  6c 65 62 75 66 66 65 72  | into filebuffer|
00004360  2a 2f 0a 0a 20 20 69 66  20 28 66 72 65 61 64 28  |*/..  if (fread(|
00004370  66 69 6c 65 62 75 66 66  65 72 2c 20 66 53 69 7a  |filebuffer, fSiz|
00004380  65 2c 20 31 2c 20 66 70  6f 69 6e 74 29 20 21 3d  |e, 1, fpoint) !=|
00004390  31 29 0a 20 20 7b 0a 20  20 20 20 65 72 72 6f 72  |1).  {.    error|
000043a0  5f 6d 65 73 73 61 67 65  3d 22 46 61 69 6c 65 64  |_message="Failed|
000043b0  20 74 6f 20 72 65 61 64  20 66 69 6c 65 20 22 3b  | to read file ";|
000043c0  0a 20 20 20 20 73 74 72  63 61 74 28 65 72 72 6f  |.    strcat(erro|
000043d0  72 5f 6d 65 73 73 61 67  65 2c 66 69 6c 65 5f 6e  |r_message,file_n|
000043e0  61 6d 65 29 3b 0a 20 20  20 20 61 75 5f 72 65 70  |ame);.    au_rep|
000043f0  6f 72 74 5f 65 72 72 6f  72 28 31 2c 20 65 72 72  |ort_error(1, err|
00004400  6f 72 5f 6d 65 73 73 61  67 65 2c 20 31 2c 20 61  |or_message, 1, a|
00004410  70 70 6e 61 6d 65 29 3b  0a 20 20 20 20 51 55 49  |ppname);.    QUI|
00004420  54 5f 46 4c 41 47 20 3d  20 31 3b 20 2f 2a 41 6e  |T_FLAG = 1; /*An|
00004430  64 20 71 75 69 74 20 74  68 65 20 70 72 6f 67 72  |d quit the progr|
00004440  61 6d 2a 2f 0a 20 20 20  20 72 65 74 75 72 6e 20  |am*/.    return |
00004450  66 69 6c 65 62 75 66 66  65 72 3b 0a 20 20 7d 0a  |filebuffer;.  }.|
00004460  0a 20 20 2f 2a 43 6c 6f  73 65 20 74 68 65 20 6f  |.  /*Close the o|
00004470  70 65 6e 20 66 69 6c 65  2a 2f 0a 0a 20 20 69 66  |pen file*/..  if|
00004480  20 28 66 63 6c 6f 73 65  28 66 70 6f 69 6e 74 29  | (fclose(fpoint)|
00004490  20 21 3d 30 29 0a 20 20  7b 0a 20 20 20 20 65 72  | !=0).  {.    er|
000044a0  72 6f 72 5f 6d 65 73 73  61 67 65 3d 22 46 61 69  |ror_message="Fai|
000044b0  6c 65 64 20 74 6f 20 63  6c 6f 73 65 20 66 69 6c  |led to close fil|
000044c0  65 20 22 3b 0a 20 20 20  20 73 74 72 63 61 74 28  |e ";.    strcat(|
000044d0  65 72 72 6f 72 5f 6d 65  73 73 61 67 65 2c 66 69  |error_message,fi|
000044e0  6c 65 5f 6e 61 6d 65 29  3b 0a 20 20 20 20 61 75  |le_name);.    au|
000044f0  5f 72 65 70 6f 72 74 5f  65 72 72 6f 72 28 31 2c  |_report_error(1,|
00004500  20 65 72 72 6f 72 5f 6d  65 73 73 61 67 65 2c 20  | error_message, |
00004510  31 2c 20 61 70 70 6e 61  6d 65 29 3b 0a 20 20 20  |1, appname);.   |
00004520  20 51 55 49 54 5f 46 4c  41 47 20 3d 20 31 3b 20  | QUIT_FLAG = 1; |
00004530  2f 2a 41 6e 64 20 71 75  69 74 20 74 68 65 20 70  |/*And quit the p|
00004540  72 6f 67 72 61 6d 2a 2f  0a 20 20 20 20 72 65 74  |rogram*/.    ret|
00004550  75 72 6e 20 66 69 6c 65  62 75 66 66 65 72 3b 0a  |urn filebuffer;.|
00004560  20 20 7d 0a 0a 20 20 2f  2a 41 64 64 20 61 20 74  |  }..  /*Add a t|
00004570  65 72 6d 69 6e 61 74 6f  72 20 74 6f 20 74 68 65  |erminator to the|
00004580  20 65 6e 64 20 6f 66 20  74 68 65 20 73 74 72 69  | end of the stri|
00004590  6e 67 2a 2f 0a 0a 20 20  66 69 6c 65 62 75 66 66  |ng*/..  filebuff|
000045a0  65 72 5b 66 53 69 7a 65  5d 20 3d 20 27 5c 30 27  |er[fSize] = '\0'|
000045b0  3b 0a 0a 20 20 72 65 74  75 72 6e 20 66 69 6c 65  |;..  return file|
000045c0  62 75 66 66 65 72 3b 0a  7d 0a                    |buffer;.}.|
000045ca