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

📄 printutils.c

📁 nedit 是一款linux下的开发源码的功能强大的编辑器
💻 C
📖 第 1 页 / 共 3 页
字号:
static const char CVSID[] = "$Id: printUtils.c,v 1.22 2003/04/07 22:51:42 yooden Exp $";/********************************************************************************									       ** printUtils.c -- Nirvana library Printer Menu	& Printing Routines   	       **									       ** Copyright (C) 1999 Mark Edel						       **									       ** This is free software; you can redistribute it and/or modify it under the    ** terms of the GNU General Public License as published by the Free Software    ** Foundation; either version 2 of the License, or (at your option) any later   ** version.							               ** 									       ** This software is distributed in the hope that it will be useful, but WITHOUT ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        ** FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License        ** for more details.							       ** 									       ** You should have received a copy of the GNU General Public License along with ** software; if not, write to the Free Software Foundation, Inc., 59 Temple     ** Place, Suite 330, Boston, MA  02111-1307 USA		                       **									       ** Nirvana Text Editor	    						       **                                        				       ** April 20, 1992							       **									       ** Written by Arnulfo Zepeda-Navratil				               **            Centro de Investigacion y Estudio Avanzados ( CINVESTAV )         **            Dept. Fisica - Mexico                                             **            BITNET: ZEPEDA@CINVESMX                                           **									       ** Modified by Donna Reid and Joy Kyriakopulos 4/8/93 - VMS port		       **									       ********************************************************************************/#ifdef HAVE_CONFIG_H#include "../config.h"#endif#include "printUtils.h"#include "DialogF.h"#include "misc.h"#include "prefFile.h"#include <string.h>#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <sys/types.h>#ifdef VMS#include "vmsparam.h"#include <ssdef.h>#include <lib$routines.h>#include <descrip.h>#include <starlet.h>#include <lnmdef.h>#include <clidef.h>#else#ifdef USE_DIRENT#include <dirent.h>#else#include <sys/dir.h>#endif /* USE_DIRENT */#ifndef __MVS__#include <sys/param.h>#endif#endif /*VMS*/#include <sys/stat.h>#include <X11/StringDefs.h>#include <X11/Intrinsic.h>#include <X11/Shell.h>#include <Xm/Xm.h>#include <Xm/Form.h>#include <Xm/LabelG.h>#include <Xm/PushB.h>#include <Xm/SeparatoG.h>#include <Xm/Text.h>#ifdef HAVE_DEBUG_H#include "../debug.h"#endif/* Separator between directory references in PATH environmental variable */#ifdef __EMX__  /* For OS/2 */#define SEPARATOR ';'#else#define SEPARATOR ':'  #endif/* Number of extra pixels down to place a label even with a text widget */#define LABEL_TEXT_DIFF 6/* Maximum text string lengths */#define MAX_OPT_STR 20#define MAX_QUEUE_STR 60#define MAX_INT_STR 13#define MAX_HOST_STR 100#define MAX_PCMD_STR 100#define MAX_NAME_STR 100#define MAX_CMD_STR 256#define VMS_MAX_JOB_NAME_STR 39#define N_PRINT_PREFS 7 /* must agree with number of preferences below */struct printPrefDescrip {    PrefDescripRec printCommand;    PrefDescripRec copiesOption;    PrefDescripRec queueOption;    PrefDescripRec nameOption;    PrefDescripRec hostOption;    PrefDescripRec defaultQueue;    PrefDescripRec defaultHost;};/* Function Prototypes */static Widget createForm(Widget parent);static void allowOnlyNumInput(Widget widget, caddr_t client_data,	XmTextVerifyCallbackStruct *call_data);static void noSpaceOrPunct(Widget widget, caddr_t client_data,	XmTextVerifyCallbackStruct *call_data);static void updatePrintCmd(Widget w, caddr_t client_data, caddr_t call_data);static void printCmdModified(Widget w, caddr_t client_data, caddr_t call_data);static void printButtonCB(Widget widget, caddr_t client_data, caddr_t call_data);static void cancelButtonCB(Widget widget, caddr_t client_data, caddr_t call_data);static void setQueueLabelText(void);static int fileInDir(const char *filename, const char *dirpath, unsigned short mode_flags);static int fileInPath(const char *filename, unsigned short mode_flags);static int flprPresent(void);#ifdef USE_LPR_PRINT_CMDstatic void getLprQueueDefault(char *defqueue);#endif#ifndef USE_LPR_PRINT_CMDstatic void getLpQueueDefault(char *defqueue);#endifstatic void setHostLabelText(void);#ifdef VMSstatic void getVmsQueueDefault(char *defqueue);#elsestatic void getFlprHostDefault(char *defhost);static void getFlprQueueDefault(char *defqueue);#endif/* Module Global Variables */static Boolean  DoneWithDialog;static Boolean	PreferencesLoaded = False;static Widget	Form;static Widget	Label2;static Widget	Label3;static Widget	Text1;static Widget	Text2;static Widget	Text3;static Widget	Text4;static const char *PrintFileName;static const char *PrintJobName;static char PrintCommand[MAX_PCMD_STR];	/* print command string */static char CopiesOption[MAX_OPT_STR];	/* # of copies argument string */static char QueueOption[MAX_OPT_STR];	/* queue name argument string */static char NameOption[MAX_OPT_STR];	/* print job name argument string */static char HostOption[MAX_OPT_STR];	/* host name argument string */static char DefaultQueue[MAX_QUEUE_STR];/* default print queue */static char DefaultHost[MAX_HOST_STR];	/* default host name */static char Copies[MAX_INT_STR] = "";	/* # of copies last entered by user */static char Queue[MAX_QUEUE_STR] = "";	/* queue name last entered by user */static char Host[MAX_HOST_STR] = "";	/* host name last entered by user */static char CmdText[MAX_CMD_STR] = "";	/* print command last entered by user */static int  CmdFieldModified = False;	/* user last changed the print command					   field, so don't trust the rest */#ifdef VMSstatic int DeleteFile;			/* append /DELETE to VMS print command*/#endif /*VMS*/static struct printPrefDescrip PrintPrefDescrip = {    {"printCommand", "PrintCommand", PREF_STRING, NULL,    	PrintCommand, (void *)MAX_PCMD_STR, False},    {"printCopiesOption", "PrintCopiesOption", PREF_STRING, NULL,    	CopiesOption, (void *)MAX_OPT_STR, False},    {"printQueueOption", "PrintQueueOption", PREF_STRING, NULL,    	QueueOption, (void *)MAX_OPT_STR, False},    {"printNameOption", "PrintNameOption", PREF_STRING, NULL,    	NameOption, (void *)MAX_OPT_STR, False},    {"printHostOption", "PrintHostOption", PREF_STRING, NULL,    	HostOption, (void *)MAX_OPT_STR, False},    {"printDefaultQueue", "PrintDefaultQueue", PREF_STRING, NULL,    	DefaultQueue, (void *)MAX_QUEUE_STR, False},    {"printDefaultHost", "PrintDefaultHost", PREF_STRING, NULL,    	DefaultHost, (void *)MAX_HOST_STR, False},};/*** PrintFile(Widget parent, char *printFile, char *jobName);**** function to put up an application-modal style Print Panel dialog ** box.****	parent		Parent widget for displaying dialog**	printFile	File to print (assumed to be a temporary file**			and not revealed to the user)**	jobName		Title for the print banner page*/#ifdef VMSvoid PrintFile(Widget parent, const char *printFile, const char *jobName, int delete)#elsevoid PrintFile(Widget parent, const char *printFile, const char *jobName)#endif /*VMS*/{    /* In case the program hasn't called LoadPrintPreferences, set up the       default values for the print preferences */    if (!PreferencesLoaded)    	LoadPrintPreferences(NULL, "", "", True);        /* Make the PrintFile information available to the callback routines */    PrintFileName = printFile;    PrintJobName = jobName;#ifdef VMS    DeleteFile = delete;#endif /*VMS*/    /* Create and display the print dialog */    DoneWithDialog = False;    Form = createForm(parent);    ManageDialogCenteredOnPointer(Form);    /* Process events until the user is done with the print dialog */    while (!DoneWithDialog)        XtAppProcessEvent(XtWidgetToApplicationContext(Form), XtIMAll);        /* Destroy the dialog.  Print dialogs are not preserved across calls       to PrintFile so that it may be called with different parents and       to generally simplify the call (this, of course, makes it slower) */     XtDestroyWidget(Form);}/*** LoadPrintPreferences**** Read an X database to obtain print dialog preferences.****	prefDB		X database potentially containing print preferences**	appName		Application name which can be used to qualify **			resource names for database lookup.**	appClass	Application class which can be used to qualify **			resource names for database lookup.**	lookForFlpr	Check if the flpr print command is installed**			and use that for the default if it's found.**			(flpr is a Fermilab utility for printing on**			arbitrary systems that support the lpr protocol)*/void LoadPrintPreferences(XrmDatabase prefDB, const char *appName,        const char *appClass, int lookForFlpr){    static char defaultQueue[MAX_QUEUE_STR], defaultHost[MAX_HOST_STR];#ifdef VMS    /* VMS built-in print command */    getVmsQueueDefault(defaultQueue);    PrintPrefDescrip.printCommand.defaultString = "print";    PrintPrefDescrip.copiesOption.defaultString = "/copies=";    PrintPrefDescrip.queueOption.defaultString = "/queue=";    PrintPrefDescrip.nameOption.defaultString = "/name=";    PrintPrefDescrip.hostOption.defaultString = "";    PrintPrefDescrip.defaultQueue.defaultString = defaultQueue;    PrintPrefDescrip.defaultHost.defaultString = "";#else    /* check if flpr is installed, and otherwise choose appropriate       printer per system type */    if (lookForFlpr && flprPresent()) {    	getFlprQueueDefault(defaultQueue);    	getFlprHostDefault(defaultHost);    	PrintPrefDescrip.printCommand.defaultString = "flpr";    	PrintPrefDescrip.copiesOption.defaultString = "";    	PrintPrefDescrip.queueOption.defaultString = "-q";    	PrintPrefDescrip.nameOption.defaultString = "-j ";    	PrintPrefDescrip.hostOption.defaultString = "-h";    	PrintPrefDescrip.defaultQueue.defaultString = defaultQueue;    	PrintPrefDescrip.defaultHost.defaultString = defaultHost;    } else {#ifdef USE_LPR_PRINT_CMD	getLprQueueDefault(defaultQueue);     	PrintPrefDescrip.printCommand.defaultString = "lpr";    	PrintPrefDescrip.copiesOption.defaultString = "-# ";    	PrintPrefDescrip.queueOption.defaultString = "-P ";    	PrintPrefDescrip.nameOption.defaultString = "-J ";    	PrintPrefDescrip.hostOption.defaultString = "";    	PrintPrefDescrip.defaultQueue.defaultString = defaultQueue;    	PrintPrefDescrip.defaultHost.defaultString = "";#else     	getLpQueueDefault(defaultQueue);     	PrintPrefDescrip.printCommand.defaultString = "lp"; /* was lp -c */    	PrintPrefDescrip.copiesOption.defaultString = "-n";    	PrintPrefDescrip.queueOption.defaultString = "-d";    	PrintPrefDescrip.nameOption.defaultString = "-t";    	PrintPrefDescrip.hostOption.defaultString = "";    	PrintPrefDescrip.defaultQueue.defaultString = defaultQueue;    	PrintPrefDescrip.defaultHost.defaultString = "";#endif    }#endif        /* Read in the preferences from the X database using the mechanism from       prefFile.c (this allows LoadPrintPreferences to work before any       widgets are created, which is more convenient than XtGetApplication-       Resources for applications which have no main window) */    RestorePreferences(NULL, prefDB, appName, appClass,    	    (PrefDescripRec *)&PrintPrefDescrip, N_PRINT_PREFS);        PreferencesLoaded = True;}static Widget createForm(Widget parent){    Widget form, printOk, printCancel, label1, separator;    Widget topWidget = NULL;    XmString st0;    Arg args[65];    int argcnt;    Widget bwidgetarray [30];    int bwidgetcnt = 0;     /************************ FORM ***************************/    argcnt = 0;    XtSetArg(args[argcnt], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);    argcnt++;    XtSetArg(args[argcnt], XmNdialogTitle, (st0=XmStringCreateLtoR(		"Print", XmSTRING_DEFAULT_CHARSET))); argcnt++;    XtSetArg(args[argcnt], XmNautoUnmanage, False); argcnt++;    form = CreateFormDialog(parent, "printForm", args, argcnt);    XtVaSetValues(form, XmNshadowThickness, 0, NULL);        XmStringFree( st0 );    /*********************** LABEL 1 and TEXT BOX 1 *********************/    if (CopiesOption[0] != '\0') {

⌨️ 快捷键说明

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