/*
** Program to read in a text file, convert
** it to upper case, and then print it out.
**
** by Jon Ellis, 14 September 1994  ST Review 33
*/

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

int main(int,char *[]);
void terminate(char *);


/*
** The program starts here...
*/

int main(argc,argv)

int argc;
char *argv[];

{
    FILE *infp, *prfp;
    int c;

    if (argc != 2)
        terminate("Usage: ucprint <filename>\n\n");
    if ((prfp = fopen("PRN:","wa")) == NULL)
        terminate("Cannot open printer device !\n");
    if ((infp = fopen(argv[1],"ra")) == NULL)
        terminate("Cannot open input file !\n");
    printf("Printing file %s\n",argv[1]);
    while ((c = fgetc(infp)) != EOF)
        fputc(toupper(c),prfp);
    fclose(infp);
    fclose(prfp);
    printf("Printing finished successfully\n");
    printf("Press RETURN to exit: ");
    getchar();
    return(0);
}


/*
** Function to handle program termination.
** The argument is a pointer to a string to
** be printed on stdout. The function never
** returns, using exit() to end the program.
**
** Usage:   terminate(message);
**
**          void terminate(char *);
*/

void terminate(msg)

char *msg;

{
    puts(msg);
    printf("Press RETURN to exit: ");
    getchar();
    exit(0);
}
   
