CSC 265 -- Exercise 1

DUE: midnight on Tuesday 24 September 1996



PROBLEM SUMMARY

Your task is to change a graphical user interface (GUI) to the KWIC system so that the user enters a keyword interactively and so that the results are displayed immediately. The displayed results will consist of 24 lines of sorted output from KWIC where the first line begins with the specified keyword.

PROBLEM SPECIFICATION

  1. Copy the directory tree
    	~csc265/Exercises/Ex1/kwic_ex1
    
    This directory contains all the source code to build the existing non-interactive version of KWIC.

  2. Build and run the existing KWIC system to see that it works.
    You build the program by typing (in the kwic_ex1 directory) the command:
    	make kwic
    
    You can run the program by supplying one or more files on the command line. For example,
    	kwic input/test0
    
    will run the program using a short test file supplied with the KWIC system. A much longer test file is provided as input/test1.

  3. There is a new module, XDialog (abbreviated to XD), which supports interactive input-output on a workstation running X-windows.

    You must integrate this new module into the KWIC system. The sub-steps given below will begin this integration process for you. (You should also read the interface file XDialog.h and the README file for information about the module's services. You can run the test program, testXD, to see the nature of the GUI interface that XD supplies.)

    1. Copy the XD module directory, ~csc265/Exercises/Ex1/XDialog, into your copy of the KWIC directory tree. The XDialog directory should be an equal partner with the other modules (Input, ShiftSort, etc.)
    2. Copy the XD header file (XDialog.h) from the XDialog directory to the directory named include.
    3. Replace the file named Makefile in the root of your KWIC directory tree with the new Makefile provided as ~csc265/Exercises/Ex1/Makefile-new.
    4. Replace the file include/Output.h with the new file Output-new.h.
    5. Edit the file named main.c so that it contains a call to the XD module initialization function, XDinit. The call should appear with the other calls to module initialization functions. The exact coding of this call should be:
      		XDinit("KWIC Program", OUNROWS, OUNCOLS);
      
      You must also add the line
      		#include "XDialog.h"
      
      near the beginning of the main.c file.


  4. You must now re-code the Output module (file Output.c) so that


  • The XDcreateDisplayText function takes a keyword string as its argument. The function must search through the lines of text produced by the ShiftSort module to find the first line which begins with the characters of the given keyword. That line plus the 23 succeeding lines are then copied into a character array, which is returned as the result of the XDcreateDisplayText function.

    Some coding help for this function and for the new version of the Output module is provided in the file: ~csc265/Exercises/Ex1/Output-new.c

    Note that the XDcreateDisplayText function may receive a keyword string that contains spaces. In that situation, you must consider the string to consist of one or more complete keywords followed by, perhaps, the partial text of a final keyword.

    For example, if the file input to the kwic program is
    	rcp -- remote file copy
    	cp -- copy files
    	cpio -- copy file archives in and out
    	dd -- convert a file while copying it
    
    then the user can enter the keyword string as
    	copy fi
    
    and see output like the following displayed in the window:
    	copy file archives in and out, cpio --
    	copy files, cp --
    	copying it, dd -- convert a file while
    	...
    
  • Note: apart from the minor changes to main.c specified above, all your coding changes must be confined to the Output.c file. You are not permitted to change any other files.

  • Note: a working solution to this assignment has been produced. If you wish to try running it, execute the command:
    /home/csc265/bin/kwic inputfile
    where you supply the name of a text file to use as the input instead of the name inputfile. (As with all software, we do not guarantee the correctness of this kwic program. If you lose points for submitting an incorrect program for this assignment, you cannot use the excuse that example solution has the same behaviour.)

    GRADING CRITERIA

    Your mark will be based on the following three criteria:
    1. Does the changed kwic program still work correctly?
    2. Are your changes to the program elegant and minimal?
    3. Have you followed the instructions for submitting the assignment?


    SUBMISSION

    Your solution must be sent in a single e-mail message to csc265@gulf. When you are ready to submit, carefully follow the instructions below:
    1. Make sure that the Output.c file correctly identifies your team and its members in the initial comment.
    2. Change your working directory to the Output directory -- which holds your new version of the Output.c file.
    3. Execute the command:
      	mail -s 'Exercise 1 submission' csc265 < Output.c
      
      This command will e-mail the file to user csc265.
    You are not permitted to send multiple messages. Only the first e-mail submission will accepted.