⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hplistc.c

📁 第3章-μCOS-II基础实验 3.2-GPIO实验 3.3-时器实验 3.4-PWM实验 3.5-RTC实验 3.6-信号量使用
💻 C
📖 第 1 页 / 共 2 页
字号:
/*$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 + -