Example #1
0
static stp_array_t *
stpi_dither_array_create_from_xmltree(stp_mxml_node_t *dm) /* Dither matrix node */
{
  const char *stmp;
  stp_mxml_node_t *child;
  int x_aspect, y_aspect; /* Dither matrix size */

  /* Get x-size */
  stmp = stp_mxmlElementGetAttr(dm, "x-aspect");
  if (stmp)
    {
      x_aspect = (int) stp_xmlstrtoul(stmp);
    }
  else
    {
      stp_erprintf("stpi_dither_array_create_from_xmltree: \"x-aspect\" missing\n");
      goto error;
    }
  /* Get y-size */
  stmp = stp_mxmlElementGetAttr(dm, "y-aspect");
  if (stmp)
    {
      y_aspect = (int) stp_xmlstrtoul(stmp);
    }
  else
    {
      stp_erprintf("stpi_dither_array_create_from_xmltree: \"y-aspect\" missing\n");
      goto error;
    }

  /* Now read in the array */
  child = stp_mxmlFindElement(dm, dm, "array", NULL, NULL, STP_MXML_DESCEND);
  if (child)
    return stp_array_create_from_xmltree(child);
  else
    stp_erprintf("stpi_dither_array_create_from_xmltree: cannot find root\n");
 error:
  return NULL;
}
Example #2
0
static void
load_shades(stp_mxml_node_t *node, stp_mxml_node_t *root, inklist_t *ikl)
{
  stp_mxml_node_t *child = node->child;
  int count = 0;

  while (child)
    {
      if (child->type == STP_MXML_ELEMENT &&
	  !strcmp(child->value.element.name, "shade"))
	count++;
      child = child->next;
    }
  ikl->n_shades = count;
  ikl->shades = stp_zalloc(sizeof(shade_t) * count);
  count = 0;
  child = node->child;
  while (child)
    {
      if (child->type == STP_MXML_ELEMENT &&
	  !strcmp(child->value.element.name, "shade"))
	{
	  if (stp_mxmlElementGetAttr(child, "count"))
	    {
	      unsigned nshades =
		stp_xmlstrtoul(stp_mxmlElementGetAttr(child, "count"));
	      ikl->shades[count].n_shades = nshades;
	      if (nshades > 0)
		{
		  char *endptr;
		  stp_mxml_node_t *cchild = child->child;
		  ikl->shades[count].shades = stp_zalloc(sizeof(double) * nshades);
		  nshades = 0;
		  while (cchild && nshades < ikl->shades[count].n_shades)
		    {
		      if (cchild->type == STP_MXML_TEXT)
			{
			  double val =
			    strtod(cchild->value.text.string, &endptr);
			  if (endptr)
			    ikl->shades[count].shades[nshades++] = val;
			}
		      cchild = cchild->next;
		    }
		}
	    }
	  count++;
	}
      child = child->next;
    }
}
Example #3
0
static void
load_subchannel(stp_mxml_node_t *node, stp_mxml_node_t *root, physical_subchannel_t *icl)
{
  const char *name;
  stp_mxml_node_t *child = node->child;
  name = stp_mxmlElementGetAttr(node, "color");
  if (name)
    icl->color = stp_xmlstrtol(name);
  name = stp_mxmlElementGetAttr(node, "subchannel");
  if (name)
    icl->subchannel = stp_xmlstrtol(name);
  else
    icl->subchannel = -1;
  name = stp_mxmlElementGetAttr(node, "headOffset");
  if (name)
    icl->head_offset = stp_xmlstrtol(name);
  name = stp_mxmlElementGetAttr(node, "name");
  if (name)
    icl->name = stp_strdup(name);
  name = stp_mxmlElementGetAttr(node, "text");
  if (name)
    icl->text = stp_strdup(name);
  while (child)
    {
      if (child->type == STP_MXML_ELEMENT)
	{
	  const char *param = child->value.element.name;
	  name = stp_mxmlElementGetAttr(child, "name");
	  if (name && !strcmp(param, "ChannelDensityParam"))
	    icl->channel_density = stp_strdup(name);
	  else if (name && !strcmp(param, "SubchannelTransitionParam"))
	    icl->subchannel_transition = stp_strdup(name);
	  else if (name && !strcmp(param, "SubchannelValueParam"))
	    icl->subchannel_value = stp_strdup(name);
	  else if (name && !strcmp(param, "SubchannelScaleParam"))
	    icl->subchannel_scale = stp_strdup(name);
	  else if (!strcmp(param, "SplitChannels"))
	    {
	      if (stp_mxmlElementGetAttr(child, "count"))
		icl->split_channel_count =
		  stp_xmlstrtoul(stp_mxmlElementGetAttr(child, "count"));
	      if (icl->split_channel_count > 0)
		{
		  char *endptr;
		  int count = 0;
		  stp_mxml_node_t *cchild = child->child;
		  icl->split_channels =
		    stp_zalloc(sizeof(short) * icl->split_channel_count);
		  while (cchild && count < icl->split_channel_count)
		    {
		      if (cchild->type == STP_MXML_TEXT)
			{
			  unsigned val =
			    strtoul(cchild->value.text.string, &endptr, 0);
			  if (endptr)
			    icl->split_channels[count++] = val;
			}
		      cchild = cchild->next;
		    }
		}
	    }
	}
      child = child->next;
    }
}
Example #4
0
static void
load_inkname(stp_mxml_node_t *node, stp_mxml_node_t *root, inkname_t *inl,
	     inklist_t *ikl)
{
  const char *name;
  stp_mxml_node_t *child = node->child;
  int channel_count = 0;
  int aux_channel_count = 0;

  while (child)
    {
      if (child->type == STP_MXML_ELEMENT)
	{
	  if (!strcmp(child->value.element.name, "Channels"))
	    {
	      stp_mxml_node_t *cchild = child->child;
	      while (cchild)
		{
		  if (cchild->type == STP_MXML_ELEMENT &&
		      !strcmp(cchild->value.element.name, "channel"))
		    {
		      name = stp_mxmlElementGetAttr(cchild, "index");
		      if (name)
			{
			  unsigned idx = stp_xmlstrtoul(name);
			  if (idx + 1 > channel_count)
			    channel_count = idx + 1;
			}
		    }
		  cchild = cchild->next;
		}
	    }
	  else if (!strcmp(child->value.element.name, "AuxChannels"))
	    {
	      stp_mxml_node_t *cchild = child->child;
	      while (cchild)
		{
		  if (cchild->type == STP_MXML_ELEMENT &&
		      !strcmp(cchild->value.element.name, "channel"))
		    {
		      name = stp_mxmlElementGetAttr(cchild, "index");
		      if (name)
			{
			  unsigned idx = stp_xmlstrtoul(name);
			  if (idx + 1 > aux_channel_count)
			    aux_channel_count = idx + 1;
			}
		    }
		  cchild = cchild->next;
		}
	    }
	}
      child = child->next;
    }
  inl->channel_count = channel_count;
  if (channel_count > 0)
    inl->channels = stp_zalloc(sizeof(ink_channel_t) * channel_count);
  inl->aux_channel_count = aux_channel_count;
  if (aux_channel_count > 0)
    inl->aux_channels = stp_zalloc(sizeof(ink_channel_t) * aux_channel_count);
  name = stp_mxmlElementGetAttr(node, "name");
  if (name)
    inl->name = stp_strdup(name);
  name = stp_mxmlElementGetAttr(node, "text");
  if (name)
    inl->text = stp_strdup(name);
  name = stp_mxmlElementGetAttr(node, "InkID");
  if (name)
    {
      if (!strcmp(name, "CMYK"))
	inl->inkset = INKSET_CMYK;
      else if (!strcmp(name, "CcMmYK"))
	inl->inkset = INKSET_CcMmYK;
      else if (!strcmp(name, "CcMmYyK"))
	inl->inkset = INKSET_CcMmYyK;
      else if (!strcmp(name, "CcMmYKk"))
	inl->inkset = INKSET_CcMmYKk;
      else if (!strcmp(name, "Quadtone"))
	inl->inkset = INKSET_QUADTONE;
      else if (!strcmp(name, "Hextone"))
	inl->inkset = INKSET_HEXTONE;
      else if (!strcmp(name, "OTHER"))
	inl->inkset = INKSET_OTHER;
      else if (!strcmp(name, "Extended"))
	inl->inkset = INKSET_EXTENDED;
    }

  channel_count = 0;
  aux_channel_count = 0;
  child = node->child;
  while (child)
    {
      if (child->type == STP_MXML_ELEMENT)
	{
	  if (!strcmp(child->value.element.name, "Channels"))
	    {
	      stp_mxml_node_t *cchild = child->child;
	      while (cchild)
		{
		  if (cchild->type == STP_MXML_ELEMENT &&
		      !strcmp(cchild->value.element.name, "channel"))
		    {
		      name = stp_mxmlElementGetAttr(cchild, "index");
		      if (name)
			{
			  unsigned idx = stp_xmlstrtoul(name);
			  load_channel(cchild, root, &(inl->channels[idx]));
			}
		    }
		  cchild = cchild->next;
		}
	    }
	  else if (!strcmp(child->value.element.name, "AuxChannels"))
	    {
	      stp_mxml_node_t *cchild = child->child;
	      while (cchild)
		{
		  if (cchild->type == STP_MXML_ELEMENT &&
		      !strcmp(cchild->value.element.name, "channel"))
		    {
		      name = stp_mxmlElementGetAttr(cchild, "index");
		      if (name)
			{
			  unsigned idx = stp_xmlstrtoul(name);
			  load_channel(cchild, root, &(inl->aux_channels[idx]));
			}
		    }
		  cchild = cchild->next;
		}
	    }
	  else if (!strcmp(child->value.element.name, "initSequence") &&
		   child->child && child->child->type == STP_MXML_TEXT)
	    ikl->init_sequence = stp_xmlstrtoraw(child->child->value.text.string);
	  else if (!strcmp(child->value.element.name, "deinitSequence") &&
		   child->child && child->child->type == STP_MXML_TEXT)
	    ikl->deinit_sequence = stp_xmlstrtoraw(child->child->value.text.string);
	}
      child = child->next;
    }
}
static void
load_model_from_file(const stp_vars_t *v, stp_mxml_node_t *xmod, int model)
{
  stp_mxml_node_t *tmp = xmod->child;
  stpi_escp2_printer_t *p = stp_escp2_get_printer(v);
  int found_black_head_config = 0;
  int found_fast_head_config = 0;
  p->max_black_resolution = -1;
  p->cd_x_offset = -1;
  p->cd_y_offset = -1;
  p->duplex_left_margin = SHRT_MIN;
  p->duplex_right_margin = SHRT_MIN;
  p->duplex_top_margin = SHRT_MIN;
  p->duplex_bottom_margin = SHRT_MIN;
  while (tmp)
    {
      if (tmp->type == STP_MXML_ELEMENT)
	{
	  const char *name = tmp->value.element.name;
	  const char *target = stp_mxmlElementGetAttr(tmp, "src");
	  if (target)
	    {
	      if (!strcmp(name, "media"))
		stp_escp2_load_media(v, target);
	      else if (!strcmp(name, "inputSlots"))
		stp_escp2_load_input_slots(v, target);
	      else if (!strcmp(name, "mediaSizes"))
		stp_escp2_load_media_sizes(v, target);
	      else if (!strcmp(name, "printerWeaves"))
		stp_escp2_load_printer_weaves(v, target);
	      else if (!strcmp(name, "qualityPresets"))
		stp_escp2_load_quality_presets(v, target);
	      else if (!strcmp(name, "resolutions"))
		stp_escp2_load_resolutions(v, target);
	      else if (!strcmp(name, "inkGroup"))
		stp_escp2_load_inkgroup(v, target);
	    }
	  else if (tmp->child && tmp->child->type == STP_MXML_TEXT)
	    {
	      stp_mxml_node_t *child = tmp->child;
	      const char *val = child->value.text.string;
	      if (!strcmp(name, "verticalBorderlessSequence"))
		{
		  STPI_ASSERT(!p->vertical_borderless_sequence, NULL);
		  p->vertical_borderless_sequence = stp_xmlstrtoraw(val);
		}
	      else if (!strcmp(name, "preinitSequence"))
		{
		  STPI_ASSERT(!p->preinit_sequence, NULL);
		  p->preinit_sequence = stp_xmlstrtoraw(val);
		}
	      else if (!strcmp(name, "preinitRemoteSequence"))
		{
		  STPI_ASSERT(!p->preinit_remote_sequence, NULL);
		  p->preinit_remote_sequence = stp_xmlstrtoraw(val);
		}
	      else if (!strcmp(name, "postinitRemoteSequence"))
		{
		  STPI_ASSERT(!p->postinit_remote_sequence, NULL);
		  p->postinit_remote_sequence = stp_xmlstrtoraw(val);
		}
	      else if (!strcmp(name, "commandSet"))
		{
		  if (!strcmp(val, "1998"))
		    p->flags |= MODEL_COMMAND_1998;
		  else if (!strcmp(val, "1999"))
		    p->flags |= MODEL_COMMAND_1999;
		  else if (!strcmp(val, "2000"))
		    p->flags |= MODEL_COMMAND_2000;
		  else if (!strcmp(val, "Pro"))
		    p->flags |= MODEL_COMMAND_PRO;
		}
	      else if (!strcmp(name, "borderless"))
		{
		  if (!strcmp(val, "No"))
		    p->flags |= MODEL_ZEROMARGIN_NO;
		  else if (!strcmp(val, "Yes"))
		    p->flags |= MODEL_ZEROMARGIN_YES;
		  else if (!strcmp(val, "Full"))
		    p->flags |= MODEL_ZEROMARGIN_FULL;
		  else if (!strcmp(val, "VerticalRestricted"))
		    p->flags |= MODEL_ZEROMARGIN_RESTR;
		  else if (!strcmp(val, "HorizontalOnly"))
		    p->flags |= MODEL_ZEROMARGIN_H_ONLY;
		}
	      else if (!strcmp(name, "preferredEnvelopeOrientation") &&
		       !strcmp(val, "Landscape"))
		p->flags |= MODEL_ENVELOPE_LANDSCAPE_YES;
	      else if (!strcmp(name, "headConfiguration"))
		{
		  const char *htype = stp_mxmlElementGetAttr(tmp, "type");
		  unsigned long data[4] = { 0, 0, 0, 0 };
		  while (child)
		    {
		      if (child->type == STP_MXML_ELEMENT && child->child &&
			  child->child->type == STP_MXML_TEXT)
			{
			  const char *cname = child->value.element.name;
			  const char *cval = child->child->value.text.string;
			  if (!strcmp(cname, "Nozzles"))
			    data[0] = stp_xmlstrtoul(cval);
			  else if (!strcmp(cname, "MinNozzles"))
			    data[1] = stp_xmlstrtoul(cval);
			  else if (!strcmp(cname, "FirstNozzle"))
			    data[2] = stp_xmlstrtoul(cval);
			  else if (!strcmp(cname, "NozzleSeparation"))
			    data[3] = stp_xmlstrtoul(cval);
			}
		      child = child->next;
		    }		      
		  if (!strcmp(htype, "default"))
		    {
		      p->nozzles = data[0];
		      p->min_nozzles = data[1];
		      p->nozzle_start = data[2];
		      p->nozzle_separation = data[3];
		      if (!found_black_head_config)
			{
			  p->black_nozzles = data[0];
			  p->min_black_nozzles = data[1];
			  p->black_nozzle_start = data[2];
			  p->black_nozzle_separation = data[3];
			}
		      if (!found_fast_head_config)
			{
			  p->fast_nozzles = data[0];
			  p->min_fast_nozzles = data[1];
			  p->fast_nozzle_start = data[2];
			  p->fast_nozzle_separation = data[3];
			}
		    }
		  else if (!strcmp(htype, "black"))
		    {
		      p->black_nozzles = data[0];
		      p->min_black_nozzles = data[1];
		      p->black_nozzle_start = data[2];
		      p->black_nozzle_separation = data[3];
		      found_black_head_config = 1;
		    }
		  else if (!strcmp(htype, "fast"))
		    {
		      p->fast_nozzles = data[0];
		      p->min_fast_nozzles = data[1];
		      p->fast_nozzle_start = data[2];
		      p->fast_nozzle_separation = data[3];
		      found_fast_head_config = 1;
		    }
		}
	      else if (!strcmp(name, "margins"))
		{
		  const char *itype = stp_mxmlElementGetAttr(tmp, "interleave");
		  const char *mtype = stp_mxmlElementGetAttr(tmp, "media");
		  const char *dtype = stp_mxmlElementGetAttr(tmp, "duplex");
		  unsigned long data[4];
		  int i = 0;
		  while (child && i < 4)
		    {
		      if (child->type == STP_MXML_TEXT)
			data[i++] = stp_xmlstrtoul(child->value.text.string);
		      child = child->next;
		    }		      
		  if (dtype && !strcmp(dtype, "duplex"))
		    {
		      p->duplex_left_margin = data[0];
		      p->duplex_right_margin = data[1];
		      p->duplex_top_margin = data[2];
		      p->duplex_bottom_margin = data[3];
		    }
		  else if (itype && !strcmp(itype, "soft") &&
			   mtype && !strcmp(mtype, "sheet"))
		    {
		      p->left_margin = data[0];
		      p->right_margin = data[1];
		      p->top_margin = data[2];
		      p->bottom_margin = data[3];
		    }
		  else if (itype && !strcmp(itype, "printer") &&
			   mtype && !strcmp(mtype, "sheet"))
		    {
		      p->m_left_margin = data[0];
		      p->m_right_margin = data[1];
		      p->m_top_margin = data[2];
		      p->m_bottom_margin = data[3];
		    }
		  else if (itype && !strcmp(itype, "soft") &&
			   mtype && !strcmp(mtype, "roll"))
		    {
		      p->roll_left_margin = data[0];
		      p->roll_right_margin = data[1];
		      p->roll_top_margin = data[2];
		      p->roll_bottom_margin = data[3];
		    }
		  else if (itype && !strcmp(itype, "printer") &&
			   mtype && !strcmp(mtype, "roll"))
		    {
		      p->m_roll_left_margin = data[0];
		      p->m_roll_right_margin = data[1];
		      p->m_roll_top_margin = data[2];
		      p->m_roll_bottom_margin = data[3];
		    }
		}
	      else if (!strcmp(name, "physicalChannels"))
		p->physical_channels = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "baseSeparation"))
		p->base_separation = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "resolutionScale"))
		p->resolution_scale = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "maxBlackResolution"))
		p->max_black_resolution = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "minimumResolution"))
		{
		  p->min_hres = stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->min_vres = stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "maximumResolution"))
		{
		  p->max_hres = stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->max_vres = stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "extraVerticalFeed"))
		p->extra_feed = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "separationRows"))
		p->separation_rows = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "pseudoSeparationRows"))
		p->pseudo_separation_rows = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "zeroMarginOffset"))
		p->zero_margin_offset = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "microLeftMargin"))
		p->micro_left_margin = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "initialVerticalOffset"))
		p->initial_vertical_offset = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "blackInitialVerticalOffset"))
		p->black_initial_vertical_offset = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "extra720DPISeparation"))
		p->extra_720dpi_separation = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "minHorizontalAlignment"))
		p->min_horizontal_position_alignment = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "baseHorizontalAlignment"))
		p->base_horizontal_position_alignment = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "bidirectionalAutoUpperLimit"))
		p->bidirectional_upper_limit = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "minimumMediaSize"))
		{
		  p->min_paper_width = stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->min_paper_height = stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "maximumMediaSize"))
		{
		  p->max_paper_width = stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->max_paper_height = stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "maximumImageableArea"))
		{
		  p->max_imageable_width = stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->max_imageable_height = stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "CDOffset"))
		{
		  p->cd_x_offset = stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->cd_y_offset = stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "CDMediaSize"))
		{
		  p->cd_page_width = stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->cd_page_height = stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "extraBottom"))
		p->paper_extra_bottom = stp_xmlstrtoul(val);
	      else if (!strcmp(name, "AlignmentChoices"))
		{
		  p->alignment_passes =
		    stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->alignment_choices =
		    stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->alternate_alignment_passes =
		    stp_xmlstrtoul(child->value.text.string);
		  child = child->next;
		  p->alternate_alignment_choices =
		    stp_xmlstrtoul(child->value.text.string);
		}
	      else if (!strcmp(name, "ChannelNames"))
		{
		  p->channel_names = stp_string_list_create();
		  while (child)
		    {
		      if (child->type == STP_MXML_ELEMENT &&
			  !strcmp(child->value.element.name, "ChannelName"))
			{
			  const char *cname = stp_mxmlElementGetAttr(child, "name");
			  stp_string_list_add_string(p->channel_names, cname, cname);
			}
		      child = child->next;
		    }
		}
	      else if (!strcmp(name, "resolutions"))
		stp_escp2_load_resolutions_from_xml(v, tmp);
	    }
	  else
	    {
	      if (!strcmp(name, "supportsVariableDropsizes"))
		p->flags |= MODEL_VARIABLE_YES;
	      else if (!strcmp(name, "hasFastGraymode"))
		p->flags |= MODEL_GRAYMODE_YES;
	      else if (!strcmp(name, "hasFast360DPI"))
		p->flags |= MODEL_FAST_360_YES;
	      else if (!strcmp(name, "sendZeroAdvance"))
		p->flags |= MODEL_SEND_ZERO_ADVANCE_YES;
	      else if (!strcmp(name, "supportsInkChange"))
		p->flags |= MODEL_SUPPORTS_INK_CHANGE_YES;
	      else if (!strcmp(name, "supportsD4Mode"))
		p->flags |= MODEL_PACKET_MODE_YES;
	      else if (!strcmp(name, "hasInterchangeableInkCartridges"))
		p->flags |= MODEL_INTERCHANGEABLE_INK_YES;
	      else if (!strcmp(name, "resolutions"))
		stp_escp2_load_resolutions_from_xml(v, tmp);
	    }
	}
      tmp = tmp->next;
    }
}