?? hplistc.c
字號:
/*$TITLE=Program to list C source files on an HP Laserjet printer*/
/*
*********************************************************************************************************
* HPLISTC
*
* Program to list C source files on an HP Laserjet Printer
*
*
*
* Filename : HPLISTC.C
* Programmer(s): Jean J. Labrosse
*********************************************************************************************************
*
*
* Program use :
*
* HPLISTC filename.ext [L | P] [>destination]
*
* where :
*
* filename.ext Is the name of the file to list (with extension)
* [L] Indicates that the printer will print in LANDSCAPE mode
* [P] Indicates that the printer will print in PORTRAIT mode (default)
* [>destination] Is the destination of the listed file, it can be:
* >PRN for the printer
* >file.ext for redirecting it to a file
*
* Note: This program is compiled using the Borland International C++ compiler Version 3.0
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDES
*********************************************************************************************************
*/
#include <STDIO.H>
#include <STRING.H>
#include <DOS.H>
/*$PAGE*/
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
#define PRINTER_FORM_FEED 0x0C
/* compressed mode, 10 pts BOLD */
#define PRINTER_COMPRESSED_MODE "\x01B(10U\x01B(s0P\x01B(s16.6H\x01B&k2S\x01B(s3B"
#define PRINTER_LANDSCAPE "\x01B&l1O" /* LANDSCAPE mode. */
#define PRINTER_NORMAL_MODE "\x01B&l0O\033E" /* normal mode. */
#define PRINTER_PAGE_LENGTH "\x01B&l2E\x01B&l7.6C\x01B&l66F" /* 66 lines/page. */
#define NUL 0x00
#define NULLPTR (char *)0
#define PORTRAIT 0
#define LANDSCAPE 1
#define TRUE 1
#define FALSE 0
/*
*********************************************************************************************************
* TYPE DECLARATIONS
*********************************************************************************************************
*/
typedef unsigned char BOOLEAN;
typedef struct cmd { /* Special comment COMMANDS structure */
char *CmdName; /* Name of COMMAND */
void (*CmdFnct)(char *s); /* Function to execute when COMMAND is found */
} CMD;
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
void main(int argc, char *argv[]);
static void ListcInit(void);
static BOOLEAN ListcChkCmd(char *s);
static void ListcNewPage(char *s);
static void ListcChangeTitle(char *s);
static void ListcHdr(void);
static void ListcGetDate(char *s);
static void ListcGetTime(char *s);
/*$PAGE*/
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
static char ListcInStr[256]; /* Input String */
static char ListcDate[30]; /* Current Date */
static char ListcTime[30]; /* Current Time */
static char ListcFileName[100]; /* File Name */
static int ListcLineN; /* Line counter */
static int ListcPageN; /* Page counter */
static char ListcTitle[150]; /* Page TITLE */
static FILE *ListcSrcFile; /* File pointer (Input file) */
static int ListcMode;
/*
*********************************************************************************************************
* TABLES
*********************************************************************************************************
*/
static char *ListcMonths[] = { /* Table of MONTHs */
"",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
static CMD ListcCmdTable[] = { /* Table of comment COMMANDS */
{"page", ListcNewPage}, /* PAGE break command */
{"PAGE", ListcNewPage},
{"title", ListcChangeTitle}, /* TITLE command */
{"TITLE", ListcChangeTitle},
{"", (void (*)())0}
};
/*$PAGE*/
/*
*********************************************************************************************************
* LISTC ENTRY POINT
*********************************************************************************************************
*/
void main(int argc, char *argv[])
{
if (argc < 2 || argc > 3) { /* Valid number of arguments ? */
fprintf(stdout, "\n\n");
fprintf(stdout, "Name of file to print missing, use:\n\n");
fprintf(stdout, " HPLISTC filename.ext [L | l | P | p] [>destination]\n\n\n");
fprintf(stdout, " where:\n");
fprintf(stdout, " filename.ext is the name of the file to print\n");
fprintf(stdout, " L | l indicates to put the printer in LANDSCAPE mode\n");
fprintf(stdout, " P | p indicates to put the printer in PORTRAIT mode (Dflt)\n");
fprintf(stdout, " destination is the redirected destination of the file\n");
fprintf(stdout, " >PRN to redirect the file to the printer\n");
fprintf(stdout, " >file.ext to redirect to a file\n");
return;
}
ListcMode = PORTRAIT; /* Default to PORTRAIT mode */
if (argc > 2) { /* See if mode is specified */
if ((strcmp(argv[2], "L") == 0) || (strcmp(argv[2], "l") == 0))
ListcMode = LANDSCAPE; /* Force to LANDSCAPE mode */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -