Esempio n. 1
1
/*! \brief  Creates and initialises a model info object.
 *
 *  \return  A valid model info object or \c NULL if unable to acquire
 *           the necessary memory resources.
 */
static _model_info_t *
_model_info_ctor (const char *fw_name, SANE_Status *status)
{
  SANE_Status s = SANE_STATUS_GOOD;
  _model_info_t *self = NULL;

  log_call ("(%s)", fw_name);
  require (fw_name);

  self = t_calloc (1, _model_info_t);
  if (!self)
    {
      if (status) *status = SANE_STATUS_NO_MEM;
      return NULL;
    }

  self->fw_name = strdup (fw_name);
  if (!self->fw_name)
    {
      _model_info_dtor (self);
      if (status) *status = SANE_STATUS_NO_MEM;
      return NULL;
    }

  /*  Set defaults using data defined in the source code.  The various
   *  getters decide a decent default in case self->fw_name is not one
   *  of the names for which we have data in our sources.
   */
  self->overseas = get_scanner_data (self->fw_name, MODEL_OVERSEAS);
  self->japan    = get_scanner_data (self->fw_name, MODEL_JAPAN);
  self->profile  = get_epson_scan_hard (self->fw_name);
  self->command  = get_scan_command (self->fw_name);

  self->from_file = false;

  s = _model_info_merge_file (self);

  self->name = _model_info_guess_name (self);

  if (self)                     /* make sure things are compliant */
    {
      promise (self->fw_name && self->name);
      promise (   self->name == self->fw_name
               || self->name == self->overseas
               || self->name == self->japan);
      promise (self->profile);
      promise (self->command);
    }
  if (status) *status = s;
  return self;
}
Esempio n. 2
0
/*
 * XXX --- `CORBA_BOA_bind' isn't defined by Section 8.2 of the CORBA 2.0
 * specification.
 *
 * This function is a stand-in for `CORBA_BOA_create', which is the specified
 * function for creating new `FLICK_TARGET's but which requires arguments that
 * we can't yet provide (because we don't have the Interface and Implementation
 * Repositories).
 */
FLICK_TARGET CORBA_BOA_bind(CORBA_BOA ths,
			    const char *type_id, CORBA_ReferenceData *key,
			    CORBA_Environment *ev)
{
#if 0
	FLICK_TARGET obj = t_calloc(FLICK_TARGET_STRUCT, 1);
	
	if (!obj)
		goto err1;
	obj->u.info.boa = ths;
	
	obj->u.info.key = *key;
	obj->u.info.key._buffer = t_malloc(char, key->_length);
	if (!obj->u.info.key._buffer)
		goto err2;
	obj->u.info.key._length = key->_length;
	obj->u.info.key._maximum = key->_maximum;
	memcpy(obj->u.info.key._buffer, key->_buffer, key->_length);
	
	obj->u.info.type_id_len = strlen(type_id);
	obj->u.info.type_id = t_malloc(char, (obj->u.info.type_id_len + 1));
	if (!obj->u.info.type_id)
		goto err3;
	strncpy((char *) obj->u.info.type_id, type_id, (obj->u.info.type_id_len + 1));
	
	if (connect(ths->socket_fd,
		    (struct sockaddr *) ths->orb->ipaddr,
		    sizeof(*ths->orb->ipaddr)))
		goto err4;
	
	CORBA_BOA_set_exception(ths, ev, CORBA_NO_EXCEPTION, 0, 0);
	return obj;
	
  err4:
	free((char *) obj->u.info.type_id);
  err3:
	free(obj->u.info.key._buffer);
  err2:
	free(obj);
  err1:
	flick_set_exception(ths, ev, ex_CORBA_NO_MEMORY,
			    0, CORBA_COMPLETED_NO);
	return 0;
#endif
	return 0;
}
Esempio n. 3
0
void *
dip_init (const char *pkglibdir, SANE_Status *status)
{
  SANE_Status s = SANE_STATUS_GOOD;

  log_call ("(%s, %p)", pkglibdir, status);

  if (dip)
    {
      err_minor ("been here, done that");
      if (status) *status = s;
      return dip;
    }

  dip = t_calloc (1, dip_type);
  if (!dip)
    {
      if (status) *status = SANE_STATUS_NO_MEM;
      return dip;
    }

  dip->plugin = ipc_exec ("esdip", pkglibdir, status);

  if (dip->plugin)
    {
      dip->autocrop = esdip_crop;
      dip->deskew   = esdip_turn;
    }
  else if (ENABLE_SANEI_MAGIC)  /* use free alternative API */
    {
      sanei_magic_init ();
      dip->autocrop = magic_crop;
      dip->deskew   = magic_turn;
    }

  if (status) *status = s;
  return dip;
}