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

📄 gdevpcl3.c

📁 openmeetings组件之GS openmeetings组件之GS openmeetings组件之GS
💻 C
📖 第 1 页 / 共 4 页
字号:
    for (j = 1; j < array_size(subdevice_list) - 1; j++)      assert(cmp_by_value(subdevice_list + j - 1, subdevice_list + j) <= 0);  }#endif	/* !NDEBUG */  /* Base class fields */  if (is_generic_device(dev)) dev->Duplex_set = 0;   /* "Duplex" is null. See remarks on the "Duplex" page device parameter in      pcl3_put_params(). */  /* pcl3 fields */  dev->use_card = bn_null;  dev->duplex_capability = Duplex_none;  dev->tumble = false;  dev->configured = false;  dev->configure_every_page = false;  /* Initialize 'file_data' */  pcl3_fill_defaults(dev->printer, &dev->file_data);  dev->initialized = true;  return;}/******************************************************************************  Function: pcl3_flag_mismatch_reporter  Flag mismatch reporting function for the pcl3 device.  The 'desired_flags' field can only contain MS_BIG_FLAG and PCL_CARD_FLAG.******************************************************************************/static void pcl3_flag_mismatch_reporter(FILE *err,  const struct s_eprn_Device *eprn, bool no_match){  const char *epref = eprn->CUPS_messages? CUPS_ERRPREF: "";  if (eprn->desired_flags == 0) {    eprintf2(      "%s" ERRPREF "The %s does not support the requested media properties.\n",      epref, eprn->cap->name);  }  else if (eprn->desired_flags == MS_BIG_FLAG) {    eprintf2("%s" ERRPREF "The %s does not support banner printing",      epref, eprn->cap->name);    if (!no_match) eprintf(" for this size");    eprintf(".\n");  }  else if (eprn->desired_flags == PCL_CARD_FLAG) {    eprintf2("%s" ERRPREF      "The %s does not support a `Card' variant for ",      epref, eprn->cap->name);    if (no_match) eprintf("any"); else eprintf("this");    eprintf(" size.\n");  }  else {    eprintf1(      "%s" ERRPREF "Banner printing on postcards?? You must be joking!\n",      epref);  }      return;}/******************************************************************************  Function: find_subdevice_name  This function returns a pointer to a static storage location containing  a NUL-terminated string with the name of the subdevice for 'subdev'.  It must not be called for invalid 'subdev' values.******************************************************************************/static const char *find_subdevice_name(int subdev){  eprn_StringAndInt    key = {NULL, 0};  const eprn_StringAndInt    *found;  key.value = subdev;  found = (const eprn_StringAndInt *)bsearch(&key, subdevice_list,    array_size(subdevice_list) - 1, sizeof(eprn_StringAndInt), cmp_by_value);  assert(found != NULL);  return found->name;}/******************************************************************************  Function: pcl3_get_params  This function returns to the caller information about the values of  parameters defined for the device. This includes parameters defined in base  classes.  The function returns zero on success and a negative value on error.******************************************************************************/static int pcl3_get_params(gx_device *device, gs_param_list *plist){  gs_param_string string_value;  pcl3_Device *dev = (pcl3_Device *)device;  const pcl_FileData *data = &dev->file_data;  int    temp,  /* Used as an intermediate for various reasons */    rc;  /* Constructor */  if (!dev->initialized) init(dev);  /* Base class parameters */  rc = eprn_get_params(device, plist);  if (rc < 0) return rc;  /* Compression method */  temp = data->compression;  if ((rc = param_write_int(plist, "CompressionMethod", &temp)) < 0) return rc;  /* Configure every page */  if ((rc = param_write_bool(plist, "ConfigureEveryPage",    &dev->configure_every_page)) < 0) return rc;  /* Dry time */  if (data->dry_time < 0) {    if ((rc = param_write_null(plist, "DryTime")) < 0) return rc;  }  else if ((rc = param_write_int(plist, "DryTime", &data->dry_time)) < 0)    return rc;  /* Duplex capability */  if (is_generic_device(dev)) {    eprn_get_string(dev->duplex_capability, duplex_capabilities_list,      &string_value);    if ((rc = param_write_string(plist, "DuplexCapability", &string_value)) < 0)      return rc;  }  /* Manual feed */  {    bool temp = dev->file_data.manual_feed;    if ((rc = param_write_bool(plist, "ManualFeed", &temp)) < 0) return rc;  }  /* PCL media type */  get_string_for_int(data->media_type, media_type_list, &string_value);  if ((rc = param_write_string(plist, "Medium", &string_value)) < 0)    return rc;  /* Media destination */  if ((rc = param_write_int(plist, "%MediaDestination",    &data->media_destination)) < 0) return rc;  /* Media source */  if ((rc = param_write_int(plist, "%MediaSource", &data->media_source)) < 0)    return rc;  /* Use of Configure Raster Data */  if (is_generic_device(dev) || pcl_has_CRD(data->level)) {    bool temp = (data->level == pcl_level_3plus_CRD_only);    if ((rc = param_write_bool(plist, "OnlyCRD", &temp)) < 0) return rc;  }  /* PCL initilization strings */  if (data->init1.length == 0) {    if ((rc = param_write_null(plist, "PCLInit1")) < 0) return rc;  }  else {    string_value.data = (const byte *)data->init1.str;    string_value.size = data->init1.length;    string_value.persistent = false;    if ((rc = param_write_string(plist, "PCLInit1", &string_value)) < 0)      return rc;  }  if (data->init2.length == 0) {    if ((rc = param_write_null(plist, "PCLInit2")) < 0) return rc;  }  else {    string_value.data = (const byte *)data->init2.str;    string_value.size = data->init2.length;    string_value.persistent = false;    if ((rc = param_write_string(plist, "PCLInit2", &string_value)) < 0)      return rc;  }  /* PJL job name */  if (data->PJL_job == NULL) {    if ((rc = param_write_null(plist, "PJLJob")) < 0) return rc;  }  else {    string_value.data = (const byte *)data->PJL_job;    string_value.size = strlen(data->PJL_job);    string_value.persistent = false;    if ((rc = param_write_string(plist, "PJLJob", &string_value)) < 0)      return rc;  }  /* PJL language */  if (data->PJL_language == NULL) {    if ((rc = param_write_null(plist, "PJLLanguage")) < 0) return rc;  }  else {    string_value.data = (const byte *)data->PJL_language;    string_value.size = strlen(data->PJL_language);    string_value.persistent = false;    if ((rc = param_write_string(plist, "PJLLanguage", &string_value)) < 0)      return rc;  }  /* Print quality */  get_string_for_int(data->print_quality, print_quality_list, &string_value);  if ((rc = param_write_string(plist, "PrintQuality", &string_value)) < 0)    return rc;  /* Black bit planes first (standard PCL) or last */  {    bool temp = (data->order_CMYK == TRUE);    if ((rc = param_write_bool(plist, "SendBlackLast", &temp)) < 0) return rc;  }  /* NUL header */  if ((rc = param_write_int(plist, "SendNULs", &data->NULs_to_send)) < 0)    return rc;  /* Subdevice name, but only for the generic device */  if (is_generic_device(dev)) {    const char *name = find_subdevice_name(dev->printer);    string_value.data = (const byte *)name;    string_value.size = strlen(name);    string_value.persistent = true;    if ((rc = param_write_string(plist, "Subdevice", &string_value)) < 0)      return rc;  }  /* Tumble */  if (is_generic_device(dev))    if ((rc = param_write_bool(plist, "Tumble", &dev->tumble)) < 0) return rc;  /* UseCard */  if (dev->use_card == bn_null) {    if ((rc = param_write_null(plist, "UseCard")) < 0) return rc;  }  else {    bool temp = (dev->use_card == bn_true);    if ((rc = param_write_bool(plist, "UseCard", &temp)) < 0) return rc;  }  /* The old quality commands if they have meaning for this device */  if (pcl_use_oldquality(data->level)) {    /* Depletion */    if (data->depletion == 0) {      if ((rc = param_write_null(plist, "Depletion")) < 0) return rc;    }    else if ((rc = param_write_int(plist, "Depletion", &data->depletion)) < 0)      return rc;    /* Raster Graphics Quality */    if ((rc = param_write_int(plist, "RasterGraphicsQuality",      &data->raster_graphics_quality)) < 0) return rc;    /* Shingling */    if ((rc = param_write_int(plist, "Shingling", &data->shingling)) < 0)      return rc;  }  else if (is_generic_device(dev)) {    /* It is logically wrong for these parameters to be visible if we are       dealing with a group-3 device, but I haven't yet found a way to get       around ghostscript's undefined-parameter-update problem. */    if ((rc = param_write_null(plist, "Depletion")) < 0) return rc;    if ((rc = param_write_null(plist, "RasterGraphicsQuality")) < 0) return rc;    if ((rc = param_write_null(plist, "Shingling")) < 0) return rc;  }#ifdef EPRN_TRACE  if (gs_debug_c(EPRN_TRACE_CHAR)) {    dlprintf("! pcl3_get_params() returns the following parameters:\n");    eprn_dump_parameter_list(plist);  }#endif  return 0;}/******************************************************************************  Function: fetch_octets  This function checks whether 'plist' contains a string entry for the parameter  'pname' and returns the value via '*s' if it does.  Neither 'plist' nor 'pname' may be NULL. On entry, '*s' must be a valid octet  string; if it is non-zero, 's->str' must point to a gs_malloc()-allocated  storage area of length 's->length'.  If the parameter exists in 'plist', its type must be null or string. If it is  null, '*s' will become zero. If the parameter type is string, the value will  be copied to '*s'.  The function returns a negative ghostscript error code on error and zero  otherwise. In the former case an error message will have been issued,   using 'epref' as a prefix for the message.******************************************************************************/static int fetch_octets(const char *epref,  gs_param_list *plist, const char *pname, pcl_OctetString *s){  gs_param_string string_value;  int rc;  if ((rc = param_read_null(plist, pname)) == 0) {    if (s->length != 0)      gs_free(gs_lib_ctx_get_non_gc_memory_t(), s->str, s->length, sizeof(pcl_Octet), "fetch_octets");    s->str = NULL;    s->length = 0;  }  else if (rc < 0 &&      (rc = param_read_string(plist, pname, &string_value)) == 0) {    /* Free old storage */    if (s->length != 0)      gs_free(gs_lib_ctx_get_non_gc_memory_t(), s->str, s->length, sizeof(pcl_Octet), "fetch_octets");    /* Allocate new */    s->str = (pcl_Octet *)gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), string_value.size, sizeof(pcl_Octet),      "fetch_octets");    if (s->str == NULL) {      s->length = 0;      eprintf1("%s" ERRPREF	"Memory allocation failure from gs_malloc().\n", epref);      rc = gs_error_VMerror;      param_signal_error(plist, pname, rc);    }    else {      memcpy(s->str, string_value.data, string_value.size);      s->length = string_value.size;    }  }  else if (rc > 0) rc = 0;  return rc;}/******************************************************************************  Function: fetch_cstring  This function checks whether 'plist' contains a string entry for the parameter  'pname' and returns the value via '*s' if it does.  Neither 'plist' nor 'pname' may be NULL. On entry, '*s' must be NULL or point  to a NUL-terminated string in a gs_malloc()-allocated storage area.  If the parameter exists in 'plist', its type must be null or string. If it is  null, '*s' will be gs_free()d and set to NULL. If it is a string, '*s' will  be reallocated to contain the NUL-terminated value of the string. Should the  string already contain a NUL value, only the part up to the NUL will be  copied.  The function returns a negative ghostscript error code on error and zero  otherwise. In the former case an error message will have been issued.******************************************************************************/static int fetch_cstring(const char *epref,  gs_param_list *plist, const char *pname, char **s){  gs_param_string string_value;  int rc;  if ((rc = param_read_null(plist, pname)) == 0) {    if (*s != NULL) gs_free(gs_lib_ctx_get_non_gc_memory_t(), *s, strlen(*s) + 1, sizeof(char), "fetch_cstring");    *s = NULL;  }  else if (rc < 0 &&      (rc = param_read_string(plist, pname, &string_value)) == 0) {    /* Free old storage */    if (*s != NULL) gs_free(gs_lib_ctx_get_non_gc_memory_t(), *s, strlen(*s) + 1, sizeof(char), "fetch_cstring");    /* Allocate new */    *s = (char *)gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), string_value.size + 1, sizeof(char),      "fetch_cstring");    if (*s == NULL) {      eprintf1("%s" ERRPREF	"Memory allocation failure from gs_malloc().\n", epref);      rc = gs_error_VMerror;      param_signal_error(plist, pname, rc);

⌨️ 快捷键说明

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