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

📄 gdevpcl3.c

📁 openmeetings组件之GS openmeetings组件之GS openmeetings组件之GS
💻 C
📖 第 1 页 / 共 4 页
字号:
/******************************************************************************  File:     $Id: gdevpcl3.c,v 1.32 2001/08/14 15:22:35 Martin Rel $  Contents: Ghostscript device 'pcl3' for PCL-3+ printers  Author:   Martin Lottermoser, Greifswaldstrasse 28, 38124 Braunschweig,            Germany. E-mail: Martin.Lottermoser@t-online.de.********************************************************************************									      **	Copyright (C) 2000, 2001 by Martin Lottermoser			      **	All rights reserved						      **									      ********************************************************************************  Preprocessor symbols:    GS_REVISION (integer)	If defined, this must be the ghostscript version number, e.g., 601 for	ghostscript 6.01.    PCL3_MEDIA_FILE (const char *)	Define this to set a media configuration file for the "unspec" device	unless the user overrides it.******************************************************************************//* Configuration management identification */#ifndef lintstatic const char  cm_id[] = "@(#)$Id: gdevpcl3.c,v 1.32 2001/08/14 15:22:35 Martin Rel $";#endif/*****************************************************************************/#ifndef _XOPEN_SOURCE#define _XOPEN_SOURCE	500#endif/* Special Aladdin header, must be included before <sys/types.h> on some   platforms (e.g., FreeBSD). */#include "std.h"/* Standard headers */#include <assert.h>#include <ctype.h>#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <string.h>/* Ghostscript headers */#ifdef EPRN_TRACE#include "gdebug.h"#endif	/* EPRN_TRACE *//* Driver-specific headers */#include "gdeveprn.h"#include "pclcap.h"#include "pclgen.h"#include "pclsize.h"/*****************************************************************************//* Does the argument point to an instance of the generic (pcl3) device? */#define is_generic_device(dev)	(strcmp(dev->dname, "pcl3") == 0)/*****************************************************************************//* Combined type with a range of bool plus null */typedef enum {bn_null, bn_true, bn_false} bool_or_null;/* Type for duplex capabilities */typedef enum {Duplex_none, Duplex_sameLeadingEdge, Duplex_oppositeLeadingEdge,  Duplex_both} DuplexCapabilities;/* Device structure */typedef struct {  gx_eprn_device_common;	/* eprn part including base types */  /* Printer selection and other data not directly mappable to PCL */  pcl_Printer printer;  bool_or_null use_card;  DuplexCapabilities duplex_capability;  bool tumble;	/* only relevant if 'Duplex' is 'true' */  /* PCL generation */  bool    initialized,	/* Has init() been run on this device instance? */    configured,		/* Has the output file been configured? */    configure_every_page;  /* Repeat the configuration for every page? */  pcl_FileData file_data;} pcl3_Device;/*****************************************************************************//* Device procedures */static dev_proc_open_device(pcl3_open_device);static dev_proc_close_device(pcl3_close_device);static dev_proc_get_params(pcl3_get_params);static dev_proc_put_params(pcl3_put_params);/* Device procedure table */static gx_device_procs pcl3_procs = {  eprn_procs_initdata(pcl3_open_device, pcl3_close_device, pcl3_get_params,    pcl3_put_params)};/* prn procedure implementations */#if !defined(GS_REVISION) || GS_REVISION >= 550static prn_dev_proc_print_page(pcl3_print_page);#elsestatic dev_proc_print_page(pcl3_print_page);#endif/*****************************************************************************//* Media flags known to this device in addition to the standard ones */static const ms_Flag  flag_description[] = {    {PCL_CARD_FLAG, PCL_CARD_STRING},    {ms_none, NULL}  };/* List of possible optional media flags */static const ms_MediaCode  card_is_optional[] = {PCL_CARD_FLAG, ms_none};/*****************************************************************************//* Forward declaration */static void pcl3_flag_mismatch_reporter(FILE *err,  const struct s_eprn_Device *eprn, bool no_match);/* Macro for creating device structure instances */#define pcl3_device_instance(dname, printer)			\  pcl3_Device gs_##dname##_device = {				\    eprn_device_initdata(					\      pcl3_Device,	/* device type */			\      pcl3_procs,	/* static device procedure table */	\      #dname,		/* device name */			\      300.0, 300.0,	/* horizontal and vertical resolution */\      pcl3_print_page,	/* print page routine */		\      &pcl3_printers[printer].desc, /* printer capability description */ \      flag_description,	/* flag descriptions */			\      ms_none,		/* desired media flags */		\      card_is_optional,	/* list of optional flags */		\      &pcl3_flag_mismatch_reporter),	/* reporting function */\    printer,		/* printer */				\    bn_null,		/* use_card */				\    Duplex_none,	/* duplex_capability */			\    false,		/* tumble */				\    false		/* initialized */			\    /* The remaining fields will be set in init(). */		\  }/* Generic and flexible device structure instance */pcl3_device_instance(pcl3, pcl3_generic_new);/* Printer-specific and fixed device structure instances *//* At present there is no entry for the HP DeskJet because its natural name   collides with the hpdj driver. */pcl3_device_instance(hpdjplus,	HPDeskJetPlus);pcl3_device_instance(hpdjportable, HPDJPortable);pcl3_device_instance(hpdj310,	HPDJ310);pcl3_device_instance(hpdj320,	HPDJ320);pcl3_device_instance(hpdj340,	HPDJ340);pcl3_device_instance(hpdj400,	HPDJ400);pcl3_device_instance(hpdj500,	HPDJ500);pcl3_device_instance(hpdj500c,	HPDJ500C);pcl3_device_instance(hpdj510,	HPDJ510);pcl3_device_instance(hpdj520,	HPDJ520);pcl3_device_instance(hpdj540,	HPDJ540);pcl3_device_instance(hpdj550c,	HPDJ550C);pcl3_device_instance(hpdj560c,	HPDJ560C);pcl3_device_instance(hpdj600,	HPDJ600);pcl3_device_instance(hpdj660c,	HPDJ660C);pcl3_device_instance(hpdj670c,	HPDJ670C);pcl3_device_instance(hpdj680c,	HPDJ680C);pcl3_device_instance(hpdj690c,	HPDJ690C);pcl3_device_instance(hpdj850c,	HPDJ850C);pcl3_device_instance(hpdj855c,	HPDJ855C);pcl3_device_instance(hpdj870c,	HPDJ870C);pcl3_device_instance(hpdj890c,	HPDJ890C);pcl3_device_instance(hpdj1120c,	HPDJ1120C);/*****************************************************************************/#define ERRPREF		"? pcl3: "#define WARNPREF	"?-W pcl3: "#define array_size(a)	(sizeof(a)/sizeof(a[0]))/*****************************************************************************/static const eprn_StringAndInt  /* Names for duplex capabilities */  duplex_capabilities_list[] = {    { "none",		Duplex_none },    { "sameLeadingEdge", Duplex_sameLeadingEdge },    { "oppositeLeadingEdge", Duplex_oppositeLeadingEdge },    { "both",		Duplex_both },    { NULL,		0 }  },  /* Names for PCL Media Type values */  media_type_list[] = {    /* Canonical names */    { "plain paper",	0 },    { "bond paper",	1 },    { "HP Premium paper", 2 },    { "glossy paper",	3 },    { "transparency film", 4 },    { "quick dry glossy", 5 },    { "quick dry transparency", 6 },    /* Shortened names */    { "plain",		0 },    { "bond",		1 },    { "Premium",	2 },    { "glossy",		3 },    { "transparency",	4 },    { NULL,		0 }  },  /* Print Quality */  print_quality_list[] = {    { "draft",	       -1 },    { "normal",		0 },    { "presentation",	1 },    /* Start of synonyms */    { "econo",		-1 },    { "best",		1 },    { NULL,		0 }  },  /* Subdevice names. They must be ordered by 'value' except for the last     (NULL) entry. At present, there are 26 non-NULL entries here. */  subdevice_list[] = {    { "hpdj",		HPDeskJet },    { "hpdjplus",	HPDeskJetPlus },    { "hpdjportable",	HPDJPortable },    { "hpdj310",	HPDJ310 },    { "hpdj320",	HPDJ320 },    { "hpdj340",	HPDJ340 },    { "hpdj400",	HPDJ400 },    { "hpdj500",	HPDJ500 },    { "hpdj500c",	HPDJ500C },    { "hpdj510",	HPDJ510 },    { "hpdj520",	HPDJ520 },    { "hpdj540",	HPDJ540 },    { "hpdj550c",	HPDJ550C },    { "hpdj560c",	HPDJ560C },    { "unspecold",	pcl3_generic_old },    { "hpdj600",	HPDJ600 },    { "hpdj660c",	HPDJ660C },    { "hpdj670c",	HPDJ670C },    { "hpdj680c",	HPDJ680C },    { "hpdj690c",	HPDJ690C },    { "hpdj850c",	HPDJ850C },    { "hpdj855c",	HPDJ855C },    { "hpdj870c",	HPDJ870C },    { "hpdj890c",	HPDJ890C },    { "hpdj1120c",	HPDJ1120C },    { "unspec",		pcl3_generic_new },    { NULL,		0 }  };/******************************************************************************  Function: cmp_by_value  This function compares two 'eprn_StringAndInt' instances by their 'value'  fields.******************************************************************************/static int cmp_by_value(const void *a, const void *b){  return ((const eprn_StringAndInt *)a)->value -    ((const eprn_StringAndInt *)b)->value;}/******************************************************************************  Function: get_string_for_int  This function returns a string representation of 'in_value' in '*out_value',  based on 'table'. 'table' must be an array terminated with an entry having  NULL as the 'name' value and must be permanently allocated and constant.  If 'in_value' cannot be found in 'table', the function returns a decimal  representation of 'in_value'.  The string buffer in '*out_value' will be a permanently allocated area which  must not be modified.******************************************************************************/static void get_string_for_int(int in_value, const eprn_StringAndInt *table,  gs_param_string *out_value){  while (table->name != NULL && table->value != in_value) table++;  if (table->name != NULL) {    out_value->data = (const byte *)table->name;    out_value->size = strlen(table->name);    out_value->persistent = true;  }  else {    static char buffer[22];	/* Must be sufficient for an 'int' */    sprintf(buffer, "%d", in_value);    assert(strlen(buffer) < sizeof(buffer));    out_value->data = (const byte *)buffer;    out_value->size = strlen(buffer);    out_value->persistent = false;  }  return;}/******************************************************************************  Function: get_int_for_string  This function parses 'in_value' based on 'table' and returns the result in  '*out_value'. 'table' must be an array, terminated with an entry having NULL  as the value for 'name'.  'in_value' must either be a decimal representation of an integer or must be  a string present in 'table'. In these cases, the function returns 0,  otherwise a non-zero ghostscript error value.  On returning 'gs_error_VMerror', the function will have issued an error  message.******************************************************************************/static int get_int_for_string(const gs_param_string *in_value,  const eprn_StringAndInt *table, int *out_value){  char *s;  int read;	/* counter */  /* First we construct a properly NUL-terminated string */  s = (char *) malloc(in_value->size + 1);  if (s == NULL) {    eprintf1(ERRPREF      "Memory allocation failure in get_int_for_string(): %s.\n",      strerror(errno));    return_error(gs_error_VMerror);  }  strncpy(s, (const char *)in_value->data, in_value->size);  s[in_value->size] = '\0';  /* To foil bugs in sscanf() on Windows (see gdeveprn.c in eprn) I'm removing     trailing white space here instead of skipping it with a format. */  {    char *t = strchr(s, '\0');    while (s < t && isspace(*(t-1))) t--;    *t = '\0';  }  /* Check for a numerical value */  if (sscanf(s, "%d%n", out_value, &read) != 1 || s[read] != '\0') {    /* What the user specified is not a valid numerical value */    while (table->name != NULL && strcmp(table->name, s) != 0) table++;    if (table->name == NULL) {      free(s); s = NULL;      return_error(gs_error_rangecheck);    }    *out_value = table->value;  }  free(s); s = NULL;  return 0;}/******************************************************************************  Function: init  This function does that part of initialization which cannot be performed at  compile time or which must be repeated whenever the subdevice is changed.  It must be called if 'initialized' is false and after the subdevice is  changed.  When this function is called, 'dev->printer' must have been set correctly.  This function must not and does not depend on the state of initialization of  its base devices.******************************************************************************/static void init(pcl3_Device *dev){#ifndef NDEBUG  /* Check that 'subdevice_list' is sorted by 'value' */  {    int j;

⌨️ 快捷键说明

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