Esempio n. 1
0
stp_list_t *
stp_list_copy(const stp_list_t *list)
{
  stp_list_t *ret;
  stp_node_copyfunc copyfunc = stp_list_get_copyfunc(list);
  stp_list_item_t *item = list->start;

  check_list(list);

  ret = stp_list_create();
  stp_list_set_copyfunc(ret, stp_list_get_copyfunc(list));
  /* If we use default (shallow) copy, we can't free the elements of it */
  if (stp_list_get_copyfunc(list))
    stp_list_set_freefunc(ret, stp_list_get_freefunc(list));
  stp_list_set_namefunc(ret, stp_list_get_namefunc(list));
  stp_list_set_long_namefunc(ret, stp_list_get_long_namefunc(list));
  stp_list_set_sortfunc(ret, stp_list_get_sortfunc(list));
  while (item)
    {
      void *data = item->data;
      if (copyfunc)
	stp_list_item_create (ret, NULL, (*copyfunc)(data));
      else
	stp_list_item_create(ret, NULL, data);
      item = stp_list_item_next(item);
    }
  return ret;
}
Esempio n. 2
0
static void
stp_xml_dither_cache_set(int x, int y, const char *filename)
{
  stp_xml_dither_cache_t *cacheval;

  assert(x && y && filename);

  stp_xml_init();

  if (dither_matrix_cache == NULL)
    dither_matrix_cache = stp_list_create();

  if (stp_xml_dither_cache_get(x, y))
      /* Already cached for this x and y aspect */
    return;

  cacheval = stp_malloc(sizeof(stp_xml_dither_cache_t));
  cacheval->x = x;
  cacheval->y = y;
  cacheval->filename = stp_strdup(filename);
  cacheval->dither_array = NULL;

  stp_list_item_create(dither_matrix_cache, NULL, (void *) cacheval);

  stp_deprintf(STP_DBG_XML, "stp_xml_dither_cache_set: added %dx%d\n", x, y);

  stp_xml_exit();

  return;
}
Esempio n. 3
0
void
stp_string_list_add_string_unsafe(stp_string_list_t *list,
				  const char *name,
				  const char *text)
{
  stp_param_string_t *new_string = stp_malloc(sizeof(stp_param_string_t));
  new_string->name = stp_strdup(name);
  new_string->text = stp_strdup(text);
  stp_list_item_create((stp_list_t *) list, NULL, new_string);
}
Esempio n. 4
0
void
stp_register_xml_preload(const char *filename)
{
  stp_list_item_t *item = stp_list_get_item_by_name(stpi_xml_preloads, filename);
  if (!item)
    {
      char *the_filename = stp_strdup(filename);
      stp_list_item_create(stpi_xml_preloads, NULL, the_filename);
    }
}
Esempio n. 5
0
void
stp_register_xml_parser(const char *name, stp_xml_parse_func parse_func)
{
  stpi_xml_parse_registry *xmlp;
  stp_list_item_t *item = stp_list_get_item_by_name(stpi_xml_registry, name);
  if (item)
    xmlp = (stpi_xml_parse_registry *) stp_list_item_get_data(item);
  else
    {
      xmlp = stp_malloc(sizeof(stpi_xml_parse_registry));
      xmlp->name = stp_strdup(name);
      stp_list_item_create(stpi_xml_registry, NULL, xmlp);
    }
  xmlp->parse_func = parse_func;
}
Esempio n. 6
0
void
stp_string_list_add_string(stp_string_list_t *list,
			   const char *name,
			   const char *text)
{
  stp_param_string_t *new_string = stp_malloc(sizeof(stp_param_string_t));
  do
    {
      const char *xname = name;
      while (*xname)
	{
	  if (!isalnum(*xname) &&
	      *xname != '_' && *xname != '-' && *xname != '+')
	    {
	      stp_erprintf("Gutenprint: bad string %s (%s)\n", name, text);
	      break;
	    }
	  xname++;
	}
    } while(0);
  new_string->name = stp_strdup(name);
  new_string->text = stp_strdup(text);
  stp_list_item_create((stp_list_t *) list, NULL, new_string);
}