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

📄 gdevpcl3.c

📁 openmeetings组件之GS openmeetings组件之GS openmeetings组件之GS
💻 C
📖 第 1 页 / 共 4 页
字号:
    }    else {      strncpy(*s, (const char*)string_value.data, string_value.size);      (*s)[string_value.size] = '\0';    }  }  else if (rc > 0) rc = 0;  return rc;}/******************************************************************************  Function: set_palette  This function sets 'dev->file_data.palette' and some other fields in  agreement with 'dev->eprn.colour_model'.******************************************************************************/static void set_palette(pcl3_Device *dev){  pcl_FileData *data = &dev->file_data;  switch(dev->eprn.colour_model) {  case eprn_DeviceGray:    {      const eprn_ColourInfo *ci = dev->eprn.cap->colour_info;      /* Can this printer switch palettes? */      while (ci->info[0] != NULL && ci->colour_model == eprn_DeviceGray) ci++;      if (ci->info[0] != NULL) data->palette = pcl_black;      else data->palette = pcl_no_palette;    }    data->number_of_colorants = 1;    data->depletion = 0;	/* Depletion is only meaningful for colour. */    break;  case eprn_DeviceCMY:    data->palette = pcl_CMY;    data->number_of_colorants = 3;    break;  case eprn_DeviceRGB:    data->palette = pcl_RGB;    data->number_of_colorants = 3;    break;  case eprn_DeviceCMY_plus_K:    /*FALLTHROUGH*/  case eprn_DeviceCMYK:    data->palette = pcl_CMYK;    data->number_of_colorants = 4;    break;  default:    assert(0);  }  return;}/******************************************************************************  Function: pcl3_put_params  This function reads a parameter list, extracts the parameters known to the  device, and configures the device appropriately. This includes parameters  defined by base classes.  If an error occurs in the processing of parameters, the function will  return a negative value, otherwise zero.  This function does *not* exhibit transactional behaviour as requested in  gsparam.h, i.e. on error the parameter values in the device structure  might have changed. However, all values will be individually valid.  Some of the parameters determine derived data in base classes or are relevant  for device initialization. Setting any of these parameters closes the  device if it is open.******************************************************************************/static int pcl3_put_params(gx_device *device, gs_param_list *plist){  bool new_quality = false;	/* has someone requested the new variables? */  gs_param_name pname;  gs_param_string string_value;  pcl3_Device *dev = (pcl3_Device *)device;  const char    *epref = dev->eprn.CUPS_messages? CUPS_ERRPREF: "",    *wpref = dev->eprn.CUPS_messages? CUPS_WARNPREF: "";  eprn_ColourModel previous_colour_model = dev->eprn.colour_model;  pcl_FileData *data = &dev->file_data;  int    last_error = 0,    temp,    rc;  struct {    int depletion, quality, shingling;  } requested = {-1, -1, -1};    /* old quality parameters. -1 means "not specified". */  /* Check for subdevice selection */  if (is_generic_device(dev)) {    if ((rc = param_read_string(plist, (pname = "Subdevice"), &string_value))        == 0) {      /* This property must be a known string. */      int j = 0;      while (subdevice_list[j].name != NULL &&	  (string_value.size != strlen(subdevice_list[j].name) ||	    strncmp((const char *)string_value.data, subdevice_list[j].name,	      string_value.size) != 0))	j++;	/* param_read_string() does not return NUL-terminated strings. */      if (subdevice_list[j].name != NULL) {	if (dev->is_open) gs_closedevice(device);	dev->printer = subdevice_list[j].value;	dev->initialized = false;	eprn_init_device((eprn_Device *)dev, &pcl3_printers[dev->printer].desc);      }      else {	eprintf1("%s" ERRPREF "Unknown subdevice name: `", epref);	errwrite(string_value.data, sizeof(char)*string_value.size);	eprintf("'.\n");	last_error = gs_error_rangecheck;	param_signal_error(plist, pname, last_error);      }    }    else if (rc < 0) last_error = rc;  }  /* Constructor */  if (!dev->initialized) init(dev);  /* Compression method */  if ((rc = param_read_int(plist, (pname = "CompressionMethod"), &temp))      == 0) {    if (temp != pcl_cm_none && temp != pcl_cm_rl && temp != pcl_cm_tiff &&	temp != pcl_cm_delta && temp != pcl_cm_crdr) {      eprintf2("%s" ERRPREF "Unsupported compression method: %d.\n",	epref, temp);      last_error = gs_error_rangecheck;      param_signal_error(plist, pname, last_error);    }    else {      if (temp == pcl_cm_crdr && (dev->printer == HPDeskJet ||	  dev->printer == HPDeskJetPlus || dev->printer == HPDJ500)) {	/* This I know to be the case for the DJ 500. The others are guessed. */	eprintf2(	  "%s" ERRPREF "The %s does not support compression method 9.\n",	  epref, dev->eprn.cap->name);	last_error = gs_error_rangecheck;	param_signal_error(plist, pname, last_error);      }      else data->compression= temp;    }  }  else if (rc < 0) last_error = rc;  /* Configure every page */  if ((rc = param_read_bool(plist, "ConfigureEveryPage",    &dev->configure_every_page)) < 0) last_error = rc;  /* Depletion */  if ((rc = param_read_null(plist, (pname = "Depletion"))) == 0)    requested.depletion = 0;  else if (rc < 0 && (rc = param_read_int(plist, pname, &temp)) == 0) {    if (1 <= temp && temp <= 5 && (dev->printer != HPDJ500C || temp <= 3))      requested.depletion = temp;    else {      eprintf2("%s" ERRPREF "Invalid value for depletion: %d.\n",	epref, temp);      last_error = gs_error_rangecheck;      param_signal_error(plist, pname, last_error);    }  }  else if (rc < 0) last_error = rc;  /* Dry time */  if ((rc = param_read_null(plist, (pname = "DryTime"))) == 0)    data->dry_time = -1;  else if (rc < 0 &&      (rc = param_read_int(plist, pname, &temp)) == 0) {    if (0 <= temp && temp <= 1200) {      if (dev->printer == HPDJ500 || dev->printer == HPDJ500C) {	 /* According to HP (DJ6/8 p. 18), only some of the series 600 and 800	    DeskJets respond to this command. I also suspect that the same is	    true for pre-DeskJet-500 printers. This should not matter, though,	    because the PCL interpreter should merely ignore the command.	    Hence I'm giving an error message only in those cases where HP	    explicitly states that the printer does not support the command.	  */	eprintf2(	  "%s" ERRPREF "The %s does not support setting a dry time.\n",	  epref, dev->eprn.cap->name);	last_error = gs_error_rangecheck;	param_signal_error(plist, pname, last_error);      }      else data->dry_time = temp;    }    else {      eprintf2("%s" ERRPREF "Invalid value for the dry time: %d.\n",	epref, temp);      last_error = gs_error_rangecheck;      param_signal_error(plist, pname, last_error);    }  }  else if (rc < 0) last_error = rc;  /* Duplex capability */  if (is_generic_device(dev)) {    if ((rc = param_read_string(plist, (pname = "DuplexCapability"),	&string_value)) == 0) {      rc = eprn_get_int(&string_value, duplex_capabilities_list, &temp);      if (rc == 0) {	if (dev->printer == pcl3_generic_new ||	    dev->printer == pcl3_generic_old || temp == Duplex_none) {	  dev->duplex_capability = temp;	  if (dev->duplex_capability == Duplex_none) 	    dev->Duplex_set = 0;	/* force to "null" */	}	else {	  eprintf2("%s" ERRPREF	    "You can use a non-trivial value for DuplexCapability\n"	    "%s  only for unspec and unspecold.\n", epref, epref);	  last_error = gs_error_rangecheck;	  param_signal_error(plist, pname, last_error);	}      }      else {	eprintf1("%s" ERRPREF "Invalid duplex capability: `", epref);	errwrite(string_value.data, sizeof(char)*string_value.size);	eprintf("'.\n");	last_error = gs_error_rangecheck;	param_signal_error(plist, pname, last_error);      }    }    else if (rc < 0) last_error = rc;  }  /* Check on "Duplex". This parameter is really read in gdev_prn_put_params(),     but we check here to prevent it being set unless the printer really     supports duplex printing. I would prefer to use the 'Duplex_set' variable     for controlling the appearance of this page device parameter, but if I do,     I can set the parameter only from PostScript and not from the command line.  */  {    bool temp;    if ((rc = param_read_bool(plist, (pname = "Duplex"), &temp)) == 0 &&	temp && dev->duplex_capability == Duplex_none) {      if (dev->printer == pcl3_generic_new || dev->printer == pcl3_generic_old)	eprintf3("%s" ERRPREF          "The '%s' device does not support duplex printing unless\n"	  "%s  'DuplexCapability' is not 'none'.\n",	  epref, find_subdevice_name(dev->printer), epref);      else	eprintf2("%s" ERRPREF	  "The %s does not support duplex printing.\n",	  epref, dev->eprn.cap->name);      last_error = gs_error_rangecheck;      param_signal_error(plist, pname, last_error);    }    /* NO check of rc because "null" is legal. */  }  /* Manual feed */  {    bool temp;    if ((rc = param_read_bool(plist, (pname = "ManualFeed"), &temp)) == 0)      dev->file_data.manual_feed = temp;    else if (rc < 0) last_error = rc;  }  /* PCL media type */  if ((rc = param_read_string(plist, (pname = "Medium"), &string_value)) == 0) {    /*  We accept numerical and string values. Numerical values at present	officially defined are 0-6, but not all printers know all these values.	We give the user the benefit of the doubt, though, because the	value is simply passed through to the printer, except for the older	DeskJets where we map illegal values to "plain paper".	If the user specifies a string, however, it must be a known one.    */    rc = get_int_for_string(&string_value, media_type_list, &temp);    if (rc != 0) {      if (rc != gs_error_VMerror) {	eprintf1("%s" ERRPREF "Unknown medium: `", epref);	errwrite(string_value.data, sizeof(char)*string_value.size);	eprintf("'.\n");      }      last_error = rc;      param_signal_error(plist, pname, last_error);    }    else {      new_quality = true;      if (temp < 0 || 6 < temp)	eprintf2("%s" WARNPREF "Unknown media type code: %d.\n",	  wpref, temp);      pcl3_set_mediatype(data, temp);    }  }  else if (rc < 0) last_error = rc;  /* Media destination */  if ((rc = param_read_int(plist, (pname = "%MediaDestination"),    &data->media_destination)) < 0) last_error = rc;  /* Media source */  if ((rc = param_read_int(plist, (pname = "%MediaSource"),    &data->media_source)) < 0) last_error = rc;  else if (rc == 0 && dev->is_open) gs_closedevice(device);    /* In pcl3, %MediaSource is relevant for banner printing and hence page       layout which is determined in the open routine. */  /* Use of Configure Raster Data */  if (is_generic_device(dev) || pcl_has_CRD(data->level)) {    bool temp;    if ((rc = param_read_bool(plist, (pname = "OnlyCRD"), &temp)) == 0) {      if (pcl_has_CRD(data->level))	data->level = (temp? pcl_level_3plus_CRD_only: pcl_level_3plus_S68);      else if (temp == true) {	eprintf1("%s" ERRPREF	  "OnlyCRD may be set only for group-3 devices.\n", epref);	last_error = gs_error_rangecheck;	param_signal_error(plist, pname, last_error);      }    }    else if (rc < 0) last_error = rc;  }  /* PCL initialization string 1 */  rc = fetch_octets(epref, plist, "PCLInit1", &data->init1);  if (rc < 0) last_error = rc;  /* PCL initialization string 2 */  rc = fetch_octets(epref, plist, "PCLInit2", &data->init2);  if (rc < 0) last_error = rc;  /* PJL job name */  rc = fetch_cstring(epref, plist, "PJLJob", &data->PJL_job);  if (rc < 0) last_error = rc;  /* PJL language */  rc = fetch_cstring(epref, plist, "PJLLanguage", &data->PJL_language);  if (rc < 0) last_error = rc;  /* Print Quality */  if ((rc = param_read_string(plist, (pname = "PrintQuality"), &string_value))      == 0) {    /*  The only known values are -1, 0 and 1. Again, however, we assume the	user knows what s/he is doing if another value is given. */    rc = get_int_for_string(&string_value, print_quality_list, &temp);    if (rc != 0) {      if (rc != gs_error_VMerror) {	eprintf1("%s" ERRPREF "Unknown print quality: `", epref);	errwrite(string_value.data, sizeof(char)*string_value.size);	eprintf("'.\n");      }      last_error = rc;      param_signal_error(plist, pname, last_error);    }    else {      new_quality = true;      if (temp < -1 || 1 < temp)	eprintf2("%s" WARNPREF "Unknown print quality: %d.\n",	  wpref, temp);      pcl3_set_printquality(data, temp);    }  }  else if (rc < 0) last_error = rc;  /* Raster Graphics Quality */  if ((rc = param_read_null(plist, (pname = "RasterGraphicsQuality"))) == 0)    ;	/* ignore */  else if (rc  < 0 &&      (rc = param_read_int(plist, (pname = "RasterGraphicsQuality"), &temp))	== 0) {    if (0 <= temp && temp <= 2) requested.quality = temp;    else {      eprintf2(	"%s" ERRPREF "Invalid value for raster graphics quality: %d.\n",	epref, temp);      last_error = gs_error_rangecheck;      param_signal_error(plist, pname, last_error);    }  }  else if (rc < 0) last_error = rc;  /* Colorant order */  {    bool temp;    if ((rc = param_read_bool(plist, (pname = "SendBlackLast"), &temp)) == 0)      data->order_CMYK = temp;    else if (rc < 0 ) last_error = rc;  }  /* Sending of NULs */  if ((rc = param_read_int(plist, (pname = "SendNULs"), &temp)) == 0) {

⌨️ 快捷键说明

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