Ejemplo n.º 1
0
asmlinkage int sunos_nfs_mount(char *dir_name, int linux_flags, void *data)
{
	int  ret = -ENODEV, error;
	int  server_fd;
	char *the_name;
	struct nfs_mount_data linux_nfs_mount;
	struct sunos_nfs_mount_args *sunos_mount = data;
	dev_t dev;

	error = verify_area(VERIFY_READ, data, sizeof (struct sunos_nfs_mount_args));
	if (error)
		return error;
	/* Ok, here comes the fun part: Linux's nfs mount needs a
	 * socket connection to the server, but SunOS mount does not
	 * require this, so we use the information on the destination
	 * address to create a socket and bind it to a reserved
	 * port on this system
	 */
	server_fd = sys_socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if (server_fd < 0)
		return -ENXIO;

	if (!sunos_nfs_get_server_fd (server_fd, sunos_mount->addr)){
		sys_close (server_fd);
		return -ENXIO;
	}

	/* Now, bind it to a locally reserved port */
	linux_nfs_mount.version  = NFS_MOUNT_VERSION;
	linux_nfs_mount.flags    = sunos_mount->flags;
	linux_nfs_mount.addr     = *sunos_mount->addr;
	linux_nfs_mount.root     = *sunos_mount->fh;
	linux_nfs_mount.fd       = server_fd;
	
	linux_nfs_mount.rsize    = get_default (sunos_mount->rsize, 8192);
	linux_nfs_mount.wsize    = get_default (sunos_mount->wsize, 8192);
	linux_nfs_mount.timeo    = get_default (sunos_mount->timeo, 10);
	linux_nfs_mount.retrans  = sunos_mount->retrans;
	
	linux_nfs_mount.acregmin = sunos_mount->acregmin;
	linux_nfs_mount.acregmax = sunos_mount->acregmax;
	linux_nfs_mount.acdirmin = sunos_mount->acdirmin;
	linux_nfs_mount.acdirmax = sunos_mount->acdirmax;

	if (getname (sunos_mount->hostname, &the_name))
		return -EFAULT;

	strncpy (linux_nfs_mount.hostname, the_name, 254);
	linux_nfs_mount.hostname [255] = 0;
	putname (the_name);

	dev = get_unnamed_dev ();
	
	ret = do_mount (dev, "", dir_name, "nfs", linux_flags, &linux_nfs_mount);
	if (ret)
	    put_unnamed_dev(dev);

	return ret;
}
Ejemplo n.º 2
0
/* XXXXXXXXXXXXXXXXXXXX */
static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data)
{
	int  server_fd;
	char *the_name;
	struct nfs_mount_data linux_nfs_mount;
	struct sunos_nfs_mount_args sunos_mount;

	/* Ok, here comes the fun part: Linux's nfs mount needs a
	 * socket connection to the server, but SunOS mount does not
	 * require this, so we use the information on the destination
	 * address to create a socket and bind it to a reserved
	 * port on this system
	 */
	if (copy_from_user(&sunos_mount, data, sizeof(sunos_mount)))
		return -EFAULT;

	server_fd = sys_socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if (server_fd < 0)
		return -ENXIO;

	if (copy_from_user(&linux_nfs_mount.addr,sunos_mount.addr,
				sizeof(*sunos_mount.addr)) ||
	    copy_from_user(&linux_nfs_mount.root,sunos_mount.fh,
				sizeof(*sunos_mount.fh))) {
		sys_close (server_fd);
		return -EFAULT;
	}

	if (!sunos_nfs_get_server_fd (server_fd, &linux_nfs_mount.addr)){
		sys_close (server_fd);
		return -ENXIO;
	}

	/* Now, bind it to a locally reserved port */
	linux_nfs_mount.version  = NFS_MOUNT_VERSION;
	linux_nfs_mount.flags    = sunos_mount.flags;
	linux_nfs_mount.fd       = server_fd;
	
	linux_nfs_mount.rsize    = get_default (sunos_mount.rsize, 8192);
	linux_nfs_mount.wsize    = get_default (sunos_mount.wsize, 8192);
	linux_nfs_mount.timeo    = get_default (sunos_mount.timeo, 10);
	linux_nfs_mount.retrans  = sunos_mount.retrans;
	
	linux_nfs_mount.acregmin = sunos_mount.acregmin;
	linux_nfs_mount.acregmax = sunos_mount.acregmax;
	linux_nfs_mount.acdirmin = sunos_mount.acdirmin;
	linux_nfs_mount.acdirmax = sunos_mount.acdirmax;

	the_name = getname(sunos_mount.hostname);
	if(IS_ERR(the_name))
		return PTR_ERR(the_name);

	strlcpy(linux_nfs_mount.hostname, the_name,
		sizeof(linux_nfs_mount.hostname));
	putname (the_name);
	
	return do_mount ("", dir_name, "nfs", linux_flags, &linux_nfs_mount);
}
Ejemplo n.º 3
0
 void fee_schedule::zero_all_fees()
 {
    *this = get_default();
    for( fee_parameters& i : parameters )
       i.visit( zero_fee_visitor() );
    this->scale = 0;
 }
Ejemplo n.º 4
0
 std::string get_value(char const * name) {
     std::string r;
     bool error = false;
     std::string error_msg;
     #pragma omp critical (gparams)
     {
         try {
             symbol m, p;
             normalize(name, m, p);
             if (m == symbol::null) {
                 if (m_params.contains(p)) {
                     r = get_value(m_params, p);
                 }
                 else {
                     r = get_default(get_param_descrs(), p, m);
                 }
             }
             else {
                 params_ref * ps = nullptr;
                 if (m_module_params.find(m, ps) && ps->contains(p)) {
                     r = get_value(*ps, p);
                 }
                 else {
                     param_descrs * d;
                     if (get_module_param_descrs().find(m, d)) {
                         r = get_default(*d, p, m);
                     }
                     else {
                         std::stringstream strm;
                         strm << "unknown module '" << m << "'";
                         throw exception(strm.str());
                     }
                 }
             }
         }
         catch (z3_exception & ex) {
             // Exception cannot cross critical section boundaries.
             error = true;
             error_msg = ex.msg();
         }
     }
     if (error)
         throw exception(std::move(error_msg));
     return r;
 }
Ejemplo n.º 5
0
Archivo: lldp.c Proyecto: mchf/wicked
void
get_string(ni_dbus_variant_t *dict, const char *name, const char *value)
{
	if (strncmp(name, "default-", 8) != 0)
		ni_fatal("get_string: bad element name %s (should start with default-", name);
	if (value == NULL || *value == '\0')
		get_default(dict, name);
	else
		ni_dbus_dict_add_string(dict, name + 8, value);
}
/**
 * \brief Get the configuration
 */
ConfigurationPtr	Configuration::get() {
	std::string	filename = get_default();

	// if the filename is still empty, then we have a problem
	debug(LOG_DEBUG, DEBUG_LOG, 0, "configuration file: %s",
		filename.c_str());
	if (0 == filename.size()) {
		throw std::runtime_error("no default config file name found");
	}
	return get(filename);
}
Ejemplo n.º 7
0
//-------------------------------------------------------------------
// Process short form entry on single line
//      '#VAR=VAL "TITLE" [MIN MAX]'
// or   '#VAR=VAL "TITLE" {A B C D ...}'
//-------------------------------------------------------------------
static int process_single(const char *ptr)
{
    sc_param *p;
    ptr = get_name(ptr, MAX_PARAM_NAME_LEN, &p, 1);
    if (p)
    {
        ptr = get_default(p, ptr, 1);
        ptr = skip_whitespace(ptr);
        if ((*ptr == '"') || (*ptr == '\''))
        {
            const char *s = skip_tochar(ptr+1, *ptr);
            p->desc = malloc(s-ptr);
            strncpy(p->desc, ptr+1, s-ptr-1);
            p->desc[s-ptr-1] = 0;
            if (*s == *ptr) s++;
            ptr = skip_whitespace(s);
        }
        else
        {
            // Error - log to console and abort
            return 0;
        }
        if (*ptr == '[')
        {
            ptr = get_range(p, ptr+1, ']');
        }
        else if (*ptr == '{')
        {
            ptr = get_values(p, ptr+1, '}');
            ptr = skip_whitespace(ptr);
            if (strncmp(ptr,"table",5) == 0)
            {
                p->data_type = DTYPE_TABLE;
                p->val--;   // Initial value is 1 based for Lua table, convert to 0 based for C code
                p->def_val--;   // also adjust default
            }
        }
        ptr = skip_whitespace(ptr);
        if (strncmp(ptr,"bool",4) == 0)
        {
            p->range = MENU_MINMAX(1,0);   // Force boolean data type in Lua (ToDo: this is clunky, needs fixing)
            p->range_type = MENUITEM_BOOL|MENUITEM_SCRIPT_PARAM;
            ptr = skip_token(ptr);
        }
        ptr = skip_whitespace(ptr);
        if (strncmp(ptr,"long",4) == 0)
        {
            p->range = 9999999;
            p->range_type = MENUITEM_INT|MENUITEM_SD_INT;
            ptr = skip_token(ptr);
        }
    }
    return 1;
}
Ejemplo n.º 8
0
void Theme::copy_default_theme() {

	Ref<Theme> default_theme=get_default();

	icon_map=default_theme->icon_map;
	style_map=default_theme->style_map;
	font_map=default_theme->font_map;
	color_map=default_theme->color_map;
	constant_map=default_theme->constant_map;
	_change_notify();
}
Ejemplo n.º 9
0
void *calloc(size_t nmemb, size_t size){
    if(!calloc_default){//Need initializing
	if(!inited){//True first time
	    get_default();
	}else{//simple allocator
	    return simple_calloc(nmemb, size);
	}
    }
    void *p=calloc_default(nmemb,size);
    if(!disable_memdbg) memkey_add(p,size);
    return p;
}
Ejemplo n.º 10
0
static kadm5_ret_t
create_principal(kadm5_server_context *context,
		 kadm5_principal_ent_t princ,
		 uint32_t mask,
		 hdb_entry_ex *ent,
		 uint32_t required_mask,
		 uint32_t forbidden_mask)
{
    kadm5_ret_t ret;
    kadm5_principal_ent_rec defrec, *defent;
    uint32_t def_mask;

    memset(ent, 0, sizeof(*ent));
    if((mask & required_mask) != required_mask)
	return KADM5_BAD_MASK;
    if((mask & forbidden_mask))
	return KADM5_BAD_MASK;
    if((mask & KADM5_POLICY) && strcmp(princ->policy, "default"))
	/* XXX no real policies for now */
	return KADM5_UNK_POLICY;
    ret  = krb5_copy_principal(context->context, princ->principal,
			       &ent->entry.principal);
    if(ret)
	return ret;

    defent = &defrec;
    ret = get_default(context, princ->principal, defent);
    if(ret) {
	defent   = NULL;
	def_mask = 0;
    } else {
	def_mask = KADM5_ATTRIBUTES | KADM5_MAX_LIFE | KADM5_MAX_RLIFE;
    }

    ret = _kadm5_setup_entry(context,
			     ent, mask | def_mask,
			     princ, mask,
			     defent, def_mask);
    if(defent)
	kadm5_free_principal_ent(context, defent);
    if (ret)
	return ret;

    ent->entry.created_by.time = time(NULL);

    return krb5_copy_principal(context->context, context->caller,
			       &ent->entry.created_by.principal);
}
Ejemplo n.º 11
0
void set_string (const char * section, const char * name, const char * value)
{
    g_return_if_fail (defaults && keyfile);
    g_return_if_fail (name && value);
    pthread_mutex_lock (& mutex);

    if (! section)
        section = DEFAULT_SECTION;

    const char * def = get_default (section, name);
    bool_t changed = FALSE;

    if (! strcmp (value, def))
    {
        if (g_key_file_has_key (keyfile, section, name, NULL))
        {
            g_key_file_remove_key (keyfile, section, name, NULL);
            changed = TRUE;
        }
    }
    else
    {
        char * old = g_key_file_has_key (keyfile, section, name, NULL) ?
         g_key_file_get_value (keyfile, section, name, NULL) : NULL;

        if (! old || strcmp (value, old))
        {
            g_key_file_set_value (keyfile, section, name, value);
            changed = TRUE;
        }

        g_free (old);
    }

    if (changed)
    {
        modified = TRUE;

        if (! strcmp (section, DEFAULT_SECTION))
        {
            char * event = g_strdup_printf ("set %s", name);
            event_queue (event, NULL);
            g_free (event);
        }
    }

    pthread_mutex_unlock (& mutex);
}
Ejemplo n.º 12
0
char * get_string (const char * section, const char * name)
{
    g_return_val_if_fail (defaults && keyfile, g_strdup (""));
    g_return_val_if_fail (name, g_strdup (""));
    pthread_mutex_lock (& mutex);

    if (! section)
        section = DEFAULT_SECTION;

    char * value = g_key_file_has_key (keyfile, section, name, NULL) ?
     g_key_file_get_value (keyfile, section, name, NULL) : NULL;

    if (! value)
        value = g_strdup (get_default (section, name));

    pthread_mutex_unlock (& mutex);
    return value;
}
Ejemplo n.º 13
0
chd_error mfmhd_generic_format::load(chd_file* chdfile, uint16_t* trackimage, int tracksize, int cylinder, int head)
{
	chd_error state = CHDERR_NONE;
	uint8_t sector_content[16384];

	int sectorcount = m_param.sectors_per_track;
	int size = m_param.sector_size;
	int position = 0; // will be incremented by each encode call
	int sec_number = 0;
	int identfield = 0;
	int cylfield = 0;
	int headfield = 0;
	int sizefield = (size >> 7)-1;

	// If we don't have interleave data in the CHD, take a default
	if (m_param.interleave==0)
	{
		m_param.interleave = get_default(MFMHD_IL);
		m_param.cylskew = get_default(MFMHD_CSKEW);
		m_param.headskew = get_default(MFMHD_HSKEW);
	}

	int sec_il_start = (m_param.cylskew * cylinder + m_param.headskew * head) % sectorcount;
	int delta = (sectorcount + m_param.interleave-1) / m_param.interleave;

	if (TRACE_RWTRACK) osd_printf_verbose("%s: Load track (c=%d,h=%d) from CHD, interleave=%d, cylskew=%d, headskew=%d\n", tag(), cylinder, head, m_param.interleave, m_param.cylskew, m_param.headskew);

	m_lastbit = false;

	if (m_param.sync==0)
	{
		m_param.gap1 = get_default(MFMHD_GAP1);
		m_param.gap2 = get_default(MFMHD_GAP2);
		m_param.gap3 = get_default(MFMHD_GAP3);
		m_param.sync = get_default(MFMHD_SYNC);
		m_param.headerlen = get_default(MFMHD_HLEN);
		m_param.ecctype = get_default(MFMHD_ECC);
	}

	// Gap 1
	mfm_encode(trackimage, position, 0x4e, m_param.gap1);

	if (TRACE_LAYOUT) osd_printf_verbose("%s: cyl=%d head=%d: sector sequence = ", tag(), cylinder, head);

	sec_number = sec_il_start;
	for (int sector = 0; sector < sectorcount; sector++)
	{
		if (TRACE_LAYOUT) osd_printf_verbose("%02d ", sec_number);

		// Sync gap
		mfm_encode(trackimage, position, 0x00, m_param.sync);

		// Write IDAM
		mfm_encode_a1(trackimage, position);

		// Write header
		identfield = cylinder_to_ident(cylinder);
		cylfield = cylinder & 0xff;
		headfield = head & 0x0f;
		if (m_param.headerlen==5)
			headfield |= ((cylinder & 0x700)>>4);

		mfm_encode(trackimage, position, identfield);
		mfm_encode(trackimage, position, cylfield);
		mfm_encode(trackimage, position, headfield);
		mfm_encode(trackimage, position, sec_number);
		if (m_param.headerlen==5)
			mfm_encode(trackimage, position, sizefield);

		// Write CRC for header.
		int crc = m_current_crc;
		mfm_encode(trackimage, position, (crc >> 8) & 0xff);
		mfm_encode(trackimage, position, crc & 0xff);

		// Gap 2
		mfm_encode(trackimage, position, 0x4e, m_param.gap2);

		// Sync
		mfm_encode(trackimage, position, 0x00, m_param.sync);

		// Write DAM
		mfm_encode_a1(trackimage, position);
		mfm_encode(trackimage, position, 0xfb);

		// Get sector content from CHD
		int lbaposition = chs_to_lba(cylinder, head, sec_number);
		if (lbaposition>=0)
		{
			chd_error state = chdfile->read_units(lbaposition, sector_content);
			if (state != CHDERR_NONE) break;
		}
		else
		{
			osd_printf_verbose("%s: Invalid CHS data (%d,%d,%d); not loading from CHD\n", tag(), cylinder, head, sector);
		}

		for (int i=0; i < size; i++)
			mfm_encode(trackimage, position, sector_content[i]);

		// Write CRC for content.
		crc = m_current_crc;
		mfm_encode(trackimage, position, (crc >> 8) & 0xff);
		mfm_encode(trackimage, position, crc & 0xff);

		// Gap 3
		mfm_encode(trackimage, position, 0x00, 3);
		mfm_encode(trackimage, position, 0x4e, m_param.gap3-3);

		// Calculate next sector number
		sec_number += delta;
		if (sec_number >= sectorcount)
		{
			sec_il_start = (sec_il_start+1) % delta;
			sec_number = sec_il_start;
		}
	}
	if (TRACE_LAYOUT) osd_printf_verbose("\n");

	// Gap 4
	if (state == CHDERR_NONE)
	{
		// Fill the rest with 0x4e
		mfm_encode(trackimage, position, 0x4e, tracksize-position);
		if (TRACE_IMAGE) showtrack(trackimage, tracksize);
	}
	return state;
}
Ejemplo n.º 14
0
/**
 * @brief Returns a settings default integer value.
 * @param key The key of the setting.
 * @return The default integer value of the setting.
 */
int Settings::get_default_int(const QString& key) {

  return get_default(key).toInt();
}
Ejemplo n.º 15
0
/**
 * @brief Returns a settings default string value.
 * @param key The key of the setting.
 * @return The default string value of the setting.
 */
QString Settings::get_default_string(const QString& key) {

  return get_default(key).toString();
}
Ejemplo n.º 16
0
/**
 * @brief Returns a settings default size value.
 * @param key The key of the setting.
 * @return The default size value of the setting.
 */
QSize Settings::get_default_size(const QString& key) {

  return get_default(key).toSize();
}
Updateable::Duration_t UpdateStore::TotalDefaultTimeout() const
{
	return get_default() * zero_updaters_.size();
}
Ejemplo n.º 18
0
/**
 * @brief Returns a settings default color value.
 * @param key The key of the setting.
 * @return The default color value of the setting.
 */
QColor Settings::get_default_color(const QString& key) {

  return QColor(get_default(key).toString());
}
Ejemplo n.º 19
0
static krb5_error_code
add_one_principal (const char *name,
		   int rand_key,
		   int rand_password,
		   int use_defaults,
		   char *password,
		   krb5_key_data *key_data,
		   const char *max_ticket_life,
		   const char *max_renewable_life,
		   const char *attributes,
		   const char *expiration,
		   const char *pw_expiration)
{
    krb5_error_code ret;
    kadm5_principal_ent_rec princ, defrec;
    kadm5_principal_ent_rec *default_ent = NULL;
    krb5_principal princ_ent = NULL;
    int mask = 0;
    int default_mask = 0;
    char pwbuf[1024];

    memset(&princ, 0, sizeof(princ));
    ret = krb5_parse_name(context, name, &princ_ent);
    if (ret) {
	krb5_warn(context, ret, "krb5_parse_name");
	return ret;
    }
    princ.principal = princ_ent;
    mask |= KADM5_PRINCIPAL;

    ret = set_entry(context, &princ, &mask,
		    max_ticket_life, max_renewable_life,
		    expiration, pw_expiration, attributes);
    if (ret)
	goto out;

    default_ent = &defrec;
    ret = get_default (kadm_handle, princ_ent, default_ent);
    if (ret) {
	default_ent  = NULL;
	default_mask = 0;
    } else {
	default_mask = KADM5_ATTRIBUTES | KADM5_MAX_LIFE | KADM5_MAX_RLIFE |
	    KADM5_PRINC_EXPIRE_TIME | KADM5_PW_EXPIRATION;
    }

    if(use_defaults)
	set_defaults(&princ, &mask, default_ent, default_mask);
    else
	if(edit_entry(&princ, &mask, default_ent, default_mask))
	    goto out;
    if(rand_key || key_data) {
	princ.attributes |= KRB5_KDB_DISALLOW_ALL_TIX;
	mask |= KADM5_ATTRIBUTES;
	random_password (pwbuf, sizeof(pwbuf));
	password = pwbuf;
    } else if (rand_password) {
	random_password (pwbuf, sizeof(pwbuf));
	password = pwbuf;
    } else if(password == NULL) {
	char *princ_name;
	char *prompt;

	krb5_unparse_name(context, princ_ent, &princ_name);
	asprintf (&prompt, "%s's Password: "******"failed to verify password");
	    goto out;
	}
	password = pwbuf;
    }

    ret = kadm5_create_principal(kadm_handle, &princ, mask, password);
    if(ret) {
	krb5_warn(context, ret, "kadm5_create_principal");
	goto out;
    }
    if(rand_key) {
	krb5_keyblock *new_keys;
	int n_keys, i;
	ret = kadm5_randkey_principal(kadm_handle, princ_ent,
				      &new_keys, &n_keys);
	if(ret){
	    krb5_warn(context, ret, "kadm5_randkey_principal");
	    n_keys = 0;
	}
	for(i = 0; i < n_keys; i++)
	    krb5_free_keyblock_contents(context, &new_keys[i]);
	if (n_keys > 0)
	    free(new_keys);
	kadm5_get_principal(kadm_handle, princ_ent, &princ,
			    KADM5_PRINCIPAL | KADM5_KVNO | KADM5_ATTRIBUTES);
	princ.attributes &= (~KRB5_KDB_DISALLOW_ALL_TIX);
	princ.kvno = 1;
	kadm5_modify_principal(kadm_handle, &princ,
			       KADM5_ATTRIBUTES | KADM5_KVNO);
	kadm5_free_principal_ent(kadm_handle, &princ);
    } else if (key_data) {
	ret = kadm5_chpass_principal_with_key (kadm_handle, princ_ent,
					       3, key_data);
	if (ret) {
	    krb5_warn(context, ret, "kadm5_chpass_principal_with_key");
	}
	kadm5_get_principal(kadm_handle, princ_ent, &princ,
			    KADM5_PRINCIPAL | KADM5_ATTRIBUTES);
	princ.attributes &= (~KRB5_KDB_DISALLOW_ALL_TIX);
	kadm5_modify_principal(kadm_handle, &princ, KADM5_ATTRIBUTES);
	kadm5_free_principal_ent(kadm_handle, &princ);
    } else if (rand_password) {
	char *princ_name;

	krb5_unparse_name(context, princ_ent, &princ_name);
	printf ("added %s with password \"%s\"\n", princ_name, password);
	free (princ_name);
    }
out:
    if (princ_ent)
	krb5_free_principal (context, princ_ent);
    if(default_ent)
	kadm5_free_principal_ent (kadm_handle, default_ent);
    if (password != NULL)
	memset (password, 0, strlen(password));
    return ret;
}
Ejemplo n.º 20
0
PRIVATE void unpickle_instance(Generator *g, ObjectStoreItem *item, ObjectStore *db) {
  Data *data = safe_malloc(sizeof(Data));
  int inecount, outecount, inscount, outscount, i;
  ObjectStoreDatum *inarray, *outarray;
  g->data = data;

  data->ladspa_descriptor = g_hash_table_lookup( DescriptorIndex, g->klass->tag );
  data->lpdat = g_hash_table_lookup( LPluginIndex, g->klass->tag );
  data->instance_handle = data->ladspa_descriptor->instantiate( data->ladspa_descriptor, SAMPLE_RATE ); 

  

  inarray = objectstore_item_get(item, "ladspa_inarray");
  outarray  = objectstore_item_get(item, "ladspa_oldoutarray");

  inecount = g_list_length( data->lpdat->inevent );
  outecount = g_list_length( data->lpdat->outevent );
  inscount = g_list_length( data->lpdat->insig );
  outscount = g_list_length( data->lpdat->outsig );

  data->inevents = safe_malloc( sizeof( LADSPA_Data ) * inecount  );
  data->outevents = safe_malloc( sizeof( LADSPA_Data ) * outecount  );
  data->oldoutevents = safe_malloc( sizeof( LADSPA_Data ) * outecount  );
  data->insignals = safe_malloc( sizeof( LADSPA_Data * ) * inscount  );
  data->outsignals = safe_malloc( sizeof( LADSPA_Data * ) * outscount  );

  for( i=0; i<inecount; i++ ) {
      
      ObjectStoreDatum *field = objectstore_datum_array_get(inarray, i);
      if( field )
	  data->inevents[i] = objectstore_datum_double_value( field );
      else
      {
	  unsigned long portindex = (unsigned long) g_list_nth_data( data->lpdat->inevent, i );
	  LADSPA_PortRangeHintDescriptor hint = data->ladspa_descriptor->PortRangeHints[portindex].HintDescriptor;
	  ControlDescriptor *control = &(g->klass->controls[i]);

	  data->inevents[i] = get_default( control, hint );
      }

      data->ladspa_descriptor->connect_port( 
	      data->instance_handle, 
	      (int) g_list_nth_data( data->lpdat->inevent, i ),
	      &(data->inevents[i]) );
  }
  for( i=0; i<outecount; i++ ) {
      ObjectStoreDatum *field = objectstore_datum_array_get(outarray, i);
      if( field )
	  data->oldoutevents[i] = objectstore_datum_double_value( field );
      else
	  data->oldoutevents[i] = 0;

      data->ladspa_descriptor->connect_port(
	      data->instance_handle,
	      (int) g_list_nth_data( data->lpdat->outevent, i ),
	      &(data->outevents[i]) );
  }
  for( i=0; i<outscount; i++ ) {
      data->outsignals[i] = safe_malloc( sizeof( LADSPA_Data ) * MAXIMUM_REALTIME_STEP );

      data->ladspa_descriptor->connect_port(
	      data->instance_handle,
	      (int) g_list_nth_data( data->lpdat->outsig, i ),
	      data->outsignals[i] );
  }  
  for( i=0; i<inscount; i++ ) {
      data->insignals[i] = safe_malloc( sizeof( LADSPA_Data ) * MAXIMUM_REALTIME_STEP );

      data->ladspa_descriptor->connect_port(
	      data->instance_handle,
	      (int) g_list_nth_data( data->lpdat->insig, i ),
	      data->insignals[i] );
  }  

  if( data->ladspa_descriptor->activate )
      data->ladspa_descriptor->activate( data->instance_handle ); 

  data->lastrun = 0;

  if( outscount == 0 )
      gen_register_realtime_fn(g, realtime_handler);
}
Ejemplo n.º 21
0
static void process_default(const char *ptr, int isScript)
{
    sc_param *p;
    ptr = get_name(ptr, MAX_PARAM_NAME_LEN, &p, isScript);
    get_default(p, ptr, isScript);
}
Ejemplo n.º 22
0
int LADSPA_info ()
  {
#ifdef DEBUG
	    printf("DEBUG: method 'Ladspa_info'\n");
#endif
	if (pluginActivated)
	  {
		bool bFound;
		int knum;
		unsigned long lIndex;
		LADSPA_PortRangeHintDescriptor iHintDescriptor;
		LADSPA_Data fBound;
		printf("--------------------------------------------------\n");	
		printf(
			   "Plugin \"%s\" has the following control inputs:\n",
			   psDescriptor->Name);
		
		knum = 0;
		bFound = false;
		for (lIndex = 0; lIndex < psDescriptor->PortCount; lIndex++)
		  {
			if (LADSPA_IS_PORT_CONTROL(psDescriptor->PortDescriptors[lIndex]))
			  {
				if (LADSPA_IS_PORT_INPUT(psDescriptor->PortDescriptors[lIndex]))
				  {
					printf("\tControl %d: %s", knum++, psDescriptor->PortNames[lIndex]);
					bFound = true;
					iHintDescriptor = psDescriptor->PortRangeHints[lIndex].HintDescriptor;
					if (LADSPA_IS_HINT_BOUNDED_BELOW(iHintDescriptor)
						|| LADSPA_IS_HINT_BOUNDED_ABOVE(iHintDescriptor))
					  {
						printf( " (");
						if (LADSPA_IS_HINT_BOUNDED_BELOW(iHintDescriptor))
						  {
							fBound = psDescriptor->PortRangeHints[lIndex].LowerBound;
							if (LADSPA_IS_HINT_SAMPLE_RATE(iHintDescriptor))
							  {
								if (fBound == 0) printf( "0");
								else printf( "%g * sample rate", fBound);
							  }
							else printf( "%g", fBound);
						  }
						else
						  printf( "...");
						printf( " to ");
						if (LADSPA_IS_HINT_BOUNDED_ABOVE(iHintDescriptor))
						  {
							fBound = psDescriptor->PortRangeHints[lIndex].UpperBound;
							if (LADSPA_IS_HINT_SAMPLE_RATE(iHintDescriptor))
							  {
								if (fBound == 0)
								  printf( "0");
								else
								  printf( "%g * sample rate", fBound);
							  }
							else
							  printf( "%g", fBound);
						  }
						else
						  printf( "...");
						printf( "), default: %g\n", get_default(lIndex));
					  }
					else printf("\n");
				  }
				else
				  {
					printf("\tOutput %d: %s\n",knum++, psDescriptor->PortNames[lIndex]);
					bFound = true;
				  }
			  }
		  }
		
		if (!bFound)
		  printf( "\tnone\n");
		printf("--------------------------------------------------\n");
	  }
	else
	  if (!pluginLoaded)
		printf ("LADSPA error: no plugin loaded yet!\n");
	  else
		printf ("LADSPA error: plugin not yet activated\n");
	return 0;
  }
Ejemplo n.º 23
0
/**
 * @brief Returns a settings default boolean value.
 * @param key The key of the setting.
 * @return The default boolean value of the setting.
 */
bool Settings::get_default_bool(const QString& key) {

  return get_default(key).toBool();
}
Ejemplo n.º 24
0
char const * param_descrs::get_default(char const * name) const {
    return get_default(symbol(name));
}
Ejemplo n.º 25
0
  void connectPorts()
  {
	//const LADSPA_Descriptor * thisDescriptor = psDescriptor;
    //printf("Connecting LADSPA audio ports...\n\n");

    // Count ports
    inports = 0; // audio in
    outports = 0; // audio out
    kports = 0; // control data (in and out)

    for (int i=0; i<psDescriptor->PortCount; i++)
      {
	iPortDescriptor = psDescriptor->PortDescriptors[i];
	if (LADSPA_IS_PORT_AUDIO(iPortDescriptor))
	  {
	    if (LADSPA_IS_PORT_INPUT(iPortDescriptor)) inports++;
	    else if (LADSPA_IS_PORT_OUTPUT(iPortDescriptor)) outports++;
	  }
	else if (LADSPA_IS_PORT_CONTROL(iPortDescriptor))
	  {
	    kports++;
	  }
      }
    
    inbuf = new LADSPA_Data*[inports];
    outbuf = new LADSPA_Data*[outports];
	kbuf = new ControlData[kports];
    for (int i=0; i<inports; i++)
      {
		inbuf[i] = new LADSPA_Data[bufsize];
      }
    for (int i=0; i<outports; i++)
      {
		outbuf[i] = new LADSPA_Data[bufsize];
      }
    for (int i=0; i<kports; i++)
      {
	kbuf[i].value = 0.0;
	kbuf[i].ladspaIndex = 0;
	kbuf[i].porttype = INPUT;
      }
	
    //printf("Audio inports: %d, outports: %d, Control ports: %d\n",inports, outports, kports);
    
    int inbufIndex = 0;
    int outbufIndex = 0;
    int kbufIndex = 0;

    // connect ports
    for (int i=0; i<psDescriptor->PortCount; i++)
      {
	iPortDescriptor = psDescriptor->PortDescriptors[i];
	if (LADSPA_IS_PORT_AUDIO(iPortDescriptor))
	  {
	    if (LADSPA_IS_PORT_INPUT(iPortDescriptor))
	      psDescriptor->connect_port(pPlugin, i, inbuf[inbufIndex++]);
	    else if (LADSPA_IS_PORT_OUTPUT(iPortDescriptor))
	      psDescriptor->connect_port(pPlugin, i, outbuf[outbufIndex++]);
	  }
	else if (LADSPA_IS_PORT_CONTROL(iPortDescriptor))
	  {
	    psDescriptor->connect_port(pPlugin, i, &kbuf[kbufIndex].value);
	    kbuf[kbufIndex].ladspaIndex = i;
	    if (LADSPA_IS_PORT_INPUT (iPortDescriptor))
	      {
		kbuf[kbufIndex].porttype = INPUT;
		LADSPA_Data portDefault = get_default(i);
		kbuf[kbufIndex].value = portDefault;
	      }
	    else kbuf[kbufIndex].porttype = OUTPUT;
	    kbufIndex++;
	  }
      }
	
	if (psDescriptor->activate != NULL)
	  {
		psDescriptor->activate(pPlugin);
		pluginActivated = true;
	  }
  }