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

📄 pstotxtd.c

📁 GSview 4.6 PostScript previewer。Ghostscript在MS-Windows, OS/2 and Unix下的图形化接口
💻 C
📖 第 1 页 / 共 2 页
字号:
/* pstotxtd.c *//* OS/2 and Win32 Command line interface to pstotxt[23].dll *//* 8086 MS-DOS command line EXE. *//* Russell Lang *//* derived from main.c *//* Copyright (C) 1995, Digital Equipment Corporation.         *//* All rights reserved.                                       *//* See the file pstotext.txt for a full description.          *//* Last modified on Fri Jan  9 21:11:00 AEST 2004 by rjl      *//*      modified on Sat Mar 11 09:16:00 AEST 2000 by rjl      *//*      modified on Fri Oct 16 16:30:54 PDT 1998 by mcjones   *//*      modified on Thu Nov 16 13:33:13 PST 1995 by deutsch   *//* Modifications by rjl *  Fixed compiler warnings. */#ifndef MSDOS#ifdef _Windows#include <windows.h>#include <io.h>#ifndef __BORLANDC__#define mktemp(t) _mktemp(t)#endif#else#define INCL_DOS#include <os2.h>#endif#endif#include <signal.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#ifdef MSDOS#include <io.h>#include <ctype.h>#include "bundle.h"#include "ocr.h"#include "rot270.h"#include "rot90.h"typedef int HMODULE;#endif#include "ptotdll.h"#define BOOLEAN int#define FALSE 0#define TRUE 1#define LINELEN 2000 /* longest allowable line from gs ocr.ps output *//* resource IDs for pstotxt3.dll */#define OCR_PROLOG 1#define ROT270_PROLOG 2#define ROT90_PROLOG 3static int cleanup(void);static void do_it(char *path);#define strcasecmp stricmp#define MAXPATHLEN 256static int debug = FALSE;static int cork = FALSE;#ifdef MSDOSstatic char *gscommand = "gs386.exe";#else#ifdef _Windowsstatic char *gscommand = "gswin32c.exe";#elsestatic char *gscommand = "gsos2.exe";#endif#endifstatic char *outfile = "";static char *cmd; /* = argv[0] */static enum {  portrait,  landscape,  landscapeOther} orientation = portrait;static int bboxes = FALSE;static int explicitFiles = 0; /* count of explicit file arguments */void usage(void) {  fprintf(stderr, "pstotext 1.8i of 2003-01-08\n");  fprintf(stderr, "Copyright (C) 1995-1998, Digital Equipment Corporation.\n");  fprintf(stderr, "Modified by Ghostgum Software Pty Ltd for Ghostscript 6.0.\n");  fprintf(stderr, "Comments to {mcjones,birrell}@pa.dec.com.\n\n");  fprintf(stderr, "Usage: %s [option|file]...\n", cmd);  fprintf(stderr, "Options:\n");  fprintf(stderr, "  -cork            Assume Cork encoding for dvips output\n");  fprintf(stderr, "  -landscape       rotate 270 degrees\n");  fprintf(stderr, "  -landscapeOther  rotate 90 degrees\n");  fprintf(stderr, "  -portrait        don't rotate (default)\n");  fprintf(stderr, "  -bboxes          output one word per line with bounding box\n");  fprintf(stderr, "  -debug           show Ghostscript output and error messages\n");  fprintf(stderr, "  -gs \042command\042    Ghostscript command\n");  fprintf(stderr, "  -output file     output results to \042file\042 (default is stdout)\n");  fprintf(stderr, "  -                read from stdin (default if no files specified)\n");}#ifndef _Windows#define WINAPI 		/* nothing for OS/2 or MSDOS */#endiftypedef int (WINAPI *PFN_pstotextInit)(void **instance);typedef int (WINAPI *PFN_pstotextFilter)(void *instance, char *instr,     char **pre, char **word, char **post,    int *llx, int *lly, int *urx, int *ury);typedef int (WINAPI *PFN_pstotextExit)(void *instance);typedef int (WINAPI *PFN_pstotextSetCork)(void *instance, int value);HMODULE pstotextModule;void *pstotextInstance;PFN_pstotextInit dllfn_pstotextInit;PFN_pstotextFilter dllfn_pstotextFilter;PFN_pstotextExit dllfn_pstotextExit;PFN_pstotextSetCork dllfn_pstotextSetCork;#ifdef _Windowsintload_pstotext(void){char dllname[256];char *p;    /* get path to EXE */    GetModuleFileName(0, dllname, sizeof(dllname));    if ((p = strrchr(dllname,'\\')) != (char *)NULL)	p++;    else	p = dllname;    *p = '\0';#ifdef __WIN32__#ifdef DECALPHA    strcat(dllname, "pstotxta.dll");#else    strcat(dllname, "pstotxt3.dll");#endif#else    strcat(dllname, "pstotxt1.dll");#endif    if (debug) {	fputs(dllname, stdout);	fputc('\n', stdout);    }    /* load pstotext DLL */    pstotextModule = LoadLibrary(dllname);    if (pstotextModule < (HINSTANCE)HINSTANCE_ERROR) {	fprintf(stderr, "Can't load %s\n", dllname);	return 1;    }    dllfn_pstotextInit = (PFN_pstotextInit) GetProcAddress(pstotextModule, "pstotextInit");    if (dllfn_pstotextInit == (PFN_pstotextInit)NULL) {	fprintf(stderr, "Can't find pstotextInit() in %s\n", dllname);	FreeLibrary(pstotextModule);	return 1;    }    dllfn_pstotextFilter = (PFN_pstotextFilter) GetProcAddress(pstotextModule, "pstotextFilter");    if (dllfn_pstotextFilter == (PFN_pstotextFilter)NULL) {	fprintf(stderr, "Can't find pstotextFilter() in %s\n", dllname);	FreeLibrary(pstotextModule);	return 1;    }    dllfn_pstotextExit = (PFN_pstotextExit) GetProcAddress(pstotextModule, "pstotextExit");    if (dllfn_pstotextExit == (PFN_pstotextExit)NULL) {	fprintf(stderr, "Can't find pstotextExit() in %s\n", dllname);	FreeLibrary(pstotextModule);	return 1;    }    dllfn_pstotextSetCork = (PFN_pstotextSetCork) GetProcAddress(pstotextModule, "pstotextSetCork");    if (dllfn_pstotextSetCork == (PFN_pstotextSetCork)NULL) {	fprintf(stderr, "Can't find pstotextSetCork() in %s\n", dllname);	FreeLibrary(pstotextModule);	return 1;    }    dllfn_pstotextInit(&pstotextInstance);    return 0;}intunload_pstotext(void){    if (pstotextInstance)        dllfn_pstotextExit(pstotextInstance);    pstotextInstance = NULL;    FreeLibrary(pstotextModule);    pstotextModule = NULL;    return 0;}voidsend_prolog(FILE *f, int resource){    HGLOBAL hglobal;    LPSTR prolog;    hglobal = LoadResource(pstotextModule, 	FindResource(pstotextModule, (LPSTR)resource, RT_RCDATA));    if ( (prolog = (LPSTR)LockResource(hglobal)) != (LPSTR)NULL) {	fputs(prolog, f);	FreeResource(hglobal);    }}#else /* !_Windows */#ifdef MSDOSintload_pstotext(void){    dllfn_pstotextInit = pstotextInit;    dllfn_pstotextFilter = pstotextFilter;    dllfn_pstotextExit = pstotextExit;    dllfn_pstotextSetCork = pstotextSetCork;    dllfn_pstotextInit(&pstotextInstance);    return 0;}intunload_pstotext(void){    return 0;}voidsend_prolog(FILE *f, int resource){    switch (resource) {	case OCR_PROLOG:	    putbundle(ocr, f);	    break;	case ROT270_PROLOG:	    putbundle(rot270, f);	    break;	case ROT90_PROLOG:	    putbundle(rot90, f);	    break;    }}#else /* !_Windows && !MSDOS *//* OS/2 */intload_pstotext(void){char dllname[256];char buf[256];char *p;APIRET rc;PTIB pptib;PPIB pppib;    if ( (rc = DosGetInfoBlocks(&pptib, &pppib)) != 0 ) {	fprintf(stderr,"Couldn't get pid, rc = \n", rc);	return rc;    }    /* get path to EXE */    if ( (rc = DosQueryModuleName(pppib->pib_hmte, sizeof(dllname), dllname)) != 0 ) {	fprintf(stderr,"Couldn't get module name, rc = %d\n", rc);	return rc;    }    if ((p = strrchr(dllname,'\\')) != (PCHAR)NULL) {	p++;	*p = '\0';    }    strcat(dllname, "pstotxt2.dll");    if (debug) {	fputs(dllname, stdout);	fputc('\n', stdout);    }    /* load pstotext DLL */    if (DosLoadModule(buf, sizeof(buf), dllname, &pstotextModule)) {	fprintf(stderr, "Can't load %s\n", dllname);	return 1;    }    if ((rc = DosQueryProcAddr(pstotextModule, 0, "pstotextInit", (PFN *)(&dllfn_pstotextInit))) !=0) {	fprintf(stderr, "Can't find pstotextInit() in %s\n", dllname);	DosFreeModule(pstotextModule);	pstotextModule = (HMODULE)NULL;	return 1;    }    if ((rc = DosQueryProcAddr(pstotextModule, 0, "pstotextFilter", (PFN *)(&dllfn_pstotextFilter))) !=0) {	fprintf(stderr, "Can't find pstotextFilter() in %s\n", dllname);	DosFreeModule(pstotextModule);	pstotextModule = (HMODULE)NULL;	return 1;    }    if ((rc = DosQueryProcAddr(pstotextModule, 0, "pstotextExit", (PFN *)(&dllfn_pstotextExit))) !=0) {	fprintf(stderr, "Can't find pstotextExit() in %s\n", dllname);	DosFreeModule(pstotextModule);	pstotextModule = (HMODULE)NULL;	return 1;    }    if ((rc = DosQueryProcAddr(pstotextModule, 0, "pstotextSetCork", (PFN *)(&dllfn_pstotextSetCork))) !=0) {	fprintf(stderr, "Can't find pstotextSetCork() in %s\n", dllname);	DosFreeModule(pstotextModule);	pstotextModule = (HMODULE)NULL;	return 1;    }    dllfn_pstotextInit(&pstotextInstance);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -