home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cenvi23.zip
/
PRINT.CMM
< prev
next >
Wrap
Text File
|
1995-03-31
|
2KB
|
71 lines
//*************************************
//*** Print.cmm - Print a text file ***
//*** ver.1 ***
//*************************************
#define DEFAULT_PRINTER_SPEC "PRN"
main(argc,argv)
{
if ( argc == 2 ) {
PrinterSpec = DEFAULT_PRINTER_SPEC;
FileSpec = argv[1];
} else if ( argc == 3 ) {
PrinterSpec = argv[1];
FileSpec = argv[2];
} else {
Instructions();
}
// Open file to print
if ( !(fpIn = fopen(FileSpec,"rt")) ) {
printf("\aUnable to open \"%s\" for reading.\n\n",
FileSpec);
Instructions();
}
// Open printer to write to
if ( !(fpOut = fopen(PrinterSpec,"wt")) ) {
fclose(fpIn);
printf("\aUnable to open printer spec \"%s\" for output.\n\n",
PrinterSpec);
Instructions();
}
// read each input line and write to output
while ( line = fgets(fpIn) ) {
if ( EOF == fputs(line,fpOut) ) {
fclose(fpOut); fclose(fpIn);
printf("\aError writing to output printer \"%s\"\n\n",
PrinterSpec);
Instructions();
}
}
// close files; all done
fclose(fpOut);
fclose(fpIn);
return EXIT_SUCCESS;
}
Instructions()
{
puts("\a");
puts(`Print.cmm - Print a text file to specified printer`)
puts(``)
puts(`USAGE: CEnvi Print.cmm [Printer] <FileSpec>`)
puts(``)
puts(`WHERE: Printer: Optional name of printer device; default is `
DEFAULT_PRINTER_SPEC)
puts(` FileSpec: Specification of file to print`)
puts(``)
puts(`EXAMPLES: CEnvi Print C:\AutoExec.bat`)
puts(` CEnvi Print LPT2 G:\MYTEXT.DOC`)
puts(``)
if ( defined(_WINDOWS_) && !defined(_SHELL_) ) {
puts(`Press any key to exit...`)
getch()
}
exit(EXIT_FAILURE);
}