Esempio n. 1
0
static int virtio_ccw_rng_init(VirtioCcwDevice *dev)
{
    VirtIODevice *vdev;

    if (dev->rng.rng == NULL) {
        dev->rng.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
        object_property_add_child(OBJECT(dev), "default-backend",
                                  OBJECT(dev->rng.default_backend), NULL);
        object_property_set_link(OBJECT(dev), OBJECT(dev->rng.default_backend),
                                 "rng", NULL);
    }
    vdev = virtio_rng_init((DeviceState *)dev, &dev->rng);
    if (!vdev) {
        return -1;
    }
    return virtio_ccw_device_init(dev, vdev);
}
Esempio n. 2
0
File: cpu.c Progetto: DVSB/qemu
SPARCCPU *cpu_sparc_init(const char *cpu_model)
{
    SPARCCPU *cpu;
    CPUSPARCState *env;

    cpu = SPARC_CPU(object_new(TYPE_SPARC_CPU));
    env = &cpu->env;

    if (cpu_sparc_register(env, cpu_model) < 0) {
        object_unref(OBJECT(cpu));
        return NULL;
    }

    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);

    return cpu;
}
Esempio n. 3
0
void jit_gl_hap_notify_atomarray_prep(t_jit_gl_hap *x, t_symbol *s, long ac, t_atom *av)
{
	if (ac && av) {
		t_object *arr;
		t_atom *a;
		
		if (a = (t_atom *)sysmem_newptr(sizeof(t_atom) * (ac + 1))) {
			jit_atom_setsym(a, s);
			sysmem_copyptr(av, a + 1, sizeof(t_atom) * ac);
			arr = (t_object *)object_new(gensym("nobox"), gensym("atomarray"), ac + 1, a);
			jit_object_notify(x, gensym("typedmess"), arr);
			freeobject(arr);
			sysmem_freeptr(a);
		}
	}
	else jit_object_notify(x, s, NULL);
}
Esempio n. 4
0
Directory * directory_new(AppServerOptions options, Event * event)
{
	Directory * directory;

	if((directory = object_new(sizeof(*directory))) == NULL)
		return NULL;
	_new_config(directory);
	directory->appserver = appserver_new_event(PACKAGE, options, event);
	if(directory->config == NULL
			|| directory->appserver == NULL)
	{
		directory_delete(directory);
		return NULL;
	}
	config = directory->config; /* FIXME ugly work-around */
	return directory;
}
Esempio n. 5
0
/**
 * Initialise player struct
 */
static void init_player(void) {
	/* Create the player array, initialised with 0 */
	player = mem_zalloc(sizeof *player);

	/* Allocate player sub-structs */
	player->upkeep = mem_zalloc(sizeof(struct player_upkeep));
	player->upkeep->inven = mem_zalloc((z_info->pack_size + 1) * sizeof(struct object *));
	player->upkeep->quiver = mem_zalloc(z_info->quiver_size * sizeof(struct object *));
	player->timed = mem_zalloc(TMD_MAX * sizeof(s16b));
	player->obj_k = object_new();
	player->obj_k->brands = mem_zalloc(z_info->brand_max * sizeof(bool));
	player->obj_k->slays = mem_zalloc(z_info->slay_max * sizeof(bool));
	player->obj_k->curses = mem_zalloc(z_info->curse_max *
									   sizeof(struct curse_data));

	options_init_defaults(&player->opts);
}
Esempio n. 6
0
/* config_new */
File * file_new(char const * filename, FileMode mode)
{
	File * file;
	char const * fmode;

	if((fmode = _file_get_fmode(mode)) == NULL)
		return NULL;
	if((file = object_new(sizeof(*file))) == NULL)
		return NULL;
	if((file->fp = fopen(filename, fmode)) == NULL)
	{
		file_delete(file);
		return NULL;
	}
	file->mode = mode;
	return file;
}
Esempio n. 7
0
static void file_archscan_small(
    int fd, char const *archive, scanback func, void *closure)
{
    struct fl_hdr fl_hdr;

    struct {
        struct ar_hdr hdr;
        char pad[ 256 ];
    } ar_hdr ;

    char buf[ MAXJPATH ];
    long offset;

    if ( read( fd, (char *)&fl_hdr, FL_HSZ ) != FL_HSZ)
        return;

    sscanf( fl_hdr.fl_fstmoff, "%ld", &offset );

    if ( DEBUG_BINDSCAN )
        printf( "scan archive %s\n", archive );

    while ( ( offset > 0 )
           && ( lseek( fd, offset, 0 ) >= 0 )
           && ( read( fd, &ar_hdr, sizeof( ar_hdr ) ) >= (int)sizeof( ar_hdr.hdr ) ) )
    {
        long lar_date;
        int  lar_namlen;
        OBJECT * member;

        sscanf( ar_hdr.hdr.ar_namlen, "%d" , &lar_namlen );
        sscanf( ar_hdr.hdr.ar_date  , "%ld", &lar_date   );
        sscanf( ar_hdr.hdr.ar_nxtmem, "%ld", &offset     );

        if ( !lar_namlen )
            continue;

        ar_hdr.hdr._ar_name.ar_name[ lar_namlen ] = '\0';

        sprintf( buf, "%s(%s)", archive, ar_hdr.hdr._ar_name.ar_name );

        member = object_new( buf );
        (*func)( closure, member, 1 /* time valid */, (time_t)lar_date );
        object_free( member );
    }
}
Esempio n. 8
0
/* binary search for the property value */
LIST * property_set_contains_features( FRAME * frame, int flags )
{
    OBJECT * varname = object_new( "self.raw" );
    LIST * props = var_get( frame->module, varname );
    LIST * features = lol_get( frame->args, 0 );
    LIST * result = L0;
    LISTITER features_iter = list_begin( features );
    LISTITER features_end = list_end( features ) ;
    object_free( varname );

    for ( ; features_iter != features_end; ++features_iter )
    {
        const char * name = object_str( list_item( features_iter ) );
        size_t name_len = strlen( name );
        LISTITER begin, end;
        /* Assumes random access */
        begin = list_begin( props ), end = list_end( props );

        while ( 1 )
        {
            ptrdiff_t diff = (end - begin);
            LISTITER mid = begin + diff / 2;
            int res;
            if ( diff == 0 )
            {
                /* The feature is missing */
                return L0;
            }
            res = strncmp( object_str( list_item( mid ) ), name, name_len );
            if ( res < 0 )
            {
                begin = mid + 1;
            }
            else if ( res > 0 )
            {
                end = mid;
            }
            else /* We've found the property */
            {
                break;
            }
        }
    }
    return list_new( object_copy( constant_true ) );
}
Esempio n. 9
0
/* keyboard_init */
static KeyboardWidget * _keyboard_init(char const * name)
{
	KeyboardWidget * keyboard;
	KeyboardPrefs prefs;

	if((keyboard = object_new(sizeof(*keyboard))) == NULL)
		return NULL;
	prefs.monitor = -1;
	prefs.font = NULL;
	prefs.mode = KEYBOARD_MODE_WIDGET;
	prefs.wait = 0;
	if((keyboard->keyboard = keyboard_new(&prefs)) == NULL)
	{
		_keyboard_destroy(keyboard);
		return NULL;
	}
	return keyboard;
}
Esempio n. 10
0
/* ussd_init */
static USSD * _ussd_init(PhonePluginHelper * helper)
{
	USSD * ussd;

	if((ussd = object_new(sizeof(*ussd))) == NULL)
		return NULL;
	ussd->config = config_new();
	ussd->_operator = NULL;
	ussd->helper = helper;
	ussd->window = NULL;
	ussd->operators = NULL;
	ussd->codes = NULL;
	/* check for errors */
	if(ussd->config == NULL || config_load(ussd->config,
				SYSCONFDIR "/" PACKAGE "/ussd.conf") != 0)
		helper->error(helper->phone, error_get(NULL), 1);
	return ussd;
}
Esempio n. 11
0
static SMSCrypt * _smscrypt_init(PhonePluginHelper * helper)
{
	SMSCrypt * smscrypt;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	if((smscrypt = object_new(sizeof(*smscrypt))) == NULL)
		return NULL;
	smscrypt->helper = helper;
	smscrypt->len = sizeof(smscrypt->buf);
	smscrypt->window = NULL;
	smscrypt->store = gtk_list_store_new(SMSCC_COUNT, G_TYPE_STRING,
			G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
	helper->config_foreach(helper->phone, "smscrypt", _init_foreach,
			smscrypt);
	return smscrypt;
}
Esempio n. 12
0
QIOChannelWebsock *
qio_channel_websock_new_server(QIOChannel *master)
{
    QIOChannelWebsock *wioc;
    QIOChannel *ioc;

    wioc = QIO_CHANNEL_WEBSOCK(object_new(TYPE_QIO_CHANNEL_WEBSOCK));
    ioc = QIO_CHANNEL(wioc);

    wioc->master = master;
    if (master->features & (1 << QIO_CHANNEL_FEATURE_SHUTDOWN)) {
        ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN);
    }
    object_ref(OBJECT(master));

    trace_qio_channel_websock_new_server(wioc, master);
    return wioc;
}
Esempio n. 13
0
static void cubieboard_init(MachineState *machine)
{
    CubieBoardState *s = g_new(CubieBoardState, 1);
    Error *err = NULL;

    s->a10 = AW_A10(object_new(TYPE_AW_A10));

    object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err);
    if (err != NULL) {
        error_report("Couldn't set phy address: %s", error_get_pretty(err));
        exit(1);
    }

    object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err);
    if (err != NULL) {
        error_report("Couldn't set clk0 frequency: %s", error_get_pretty(err));
        exit(1);
    }

    object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq",
                            &err);
    if (err != NULL) {
        error_report("Couldn't set clk1 frequency: %s", error_get_pretty(err));
        exit(1);
    }

    object_property_set_bool(OBJECT(s->a10), true, "realized", &err);
    if (err != NULL) {
        error_report("Couldn't realize Allwinner A10: %s",
                     error_get_pretty(err));
        exit(1);
    }

    memory_region_init_ram(&s->sdram, NULL, "cubieboard.ram",
                           machine->ram_size);
    vmstate_register_ram_global(&s->sdram);
    memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
                                &s->sdram);

    cubieboard_binfo.ram_size = machine->ram_size;
    cubieboard_binfo.kernel_filename = machine->kernel_filename;
    cubieboard_binfo.kernel_cmdline = machine->kernel_cmdline;
    arm_load_kernel(&s->a10->cpu, &cubieboard_binfo);
}
Esempio n. 14
0
static int lgob_parse_launch(lua_State* L)
{
	luaL_checktype(L, 1, LUA_TSTRING);
	
	GError* errors = NULL;
	GstElement* ptr = gst_parse_launch(lua_tostring(L, 1), &errors);
	
	if(!ptr)
	{
		lua_pushboolean(L, FALSE);
		lua_pushstring(L, errors->message);
		g_error_free(errors);
		return 2;
	}
	 
	object_new(L, ptr, "Pipeline");
	
	return 1;
}
Esempio n. 15
0
static void file_archivescan_impl( OBJECT * path, archive_scanback func, void * closure )
{
    file_archive_info_t * const archive = file_archive_query( path );
    if ( !archive || !archive->file->is_file )
        return;

    /* Lazy collect the archive content information. */
    if ( filelist_empty( archive->members ) )
    {
        if ( DEBUG_BINDSCAN )
            printf( "scan archive %s\n", object_str( archive->file->name ) );
        if ( file_collect_archive_content_( archive ) < 0 )
            return;
    }

    /* OS specific part of the file_archivescan operation. */
    file_archivescan_( archive, func, closure );

    /* Report the collected archive content. */
    {
        FILELISTITER iter = filelist_begin( archive->members );
        FILELISTITER const end = filelist_end( archive->members );
        char buf[ MAXJPATH ];

        for ( ; iter != end ; iter = filelist_next( iter ) )
        {
            file_info_t * member_file = filelist_item( iter );
            LIST * symbols = member_file->files;

            /* Construct member path: 'archive-path(member-name)'
             */
            sprintf( buf, "%s(%s)",
                object_str( archive->file->name ),
                object_str( member_file->name ) );

            {
                OBJECT * const member = object_new( buf );
                (*func)( closure, member, symbols, 1, &member_file->time );
                object_free( member );
            }
        }
    }
}
Esempio n. 16
0
File: search.c Progetto: Kirija/XPIR
/* Records the binding of a target with an explicit LOCATE. */
void set_explicit_binding( OBJECT * target, OBJECT * locate )
{
    OBJECT * boundname;
    OBJECT * key;
    PATHNAME f[ 1 ];
    string buf[ 1 ];
    int found;
    BINDING * ba;

    if ( !explicit_bindings )
        explicit_bindings = hashinit( sizeof( BINDING ), "explicitly specified "
            "locations" );

    string_new( buf );

    /* Parse the filename. */
    path_parse( object_str( target ), f );

    /* Ignore the grist. */
    f->f_grist.ptr = 0;
    f->f_grist.len = 0;

    /* Root the target path at the given location. */
    f->f_root.ptr = object_str( locate );
    f->f_root.len = strlen( object_str( locate ) );

    path_build( f, buf );
    boundname = object_new( buf->value );
    if ( DEBUG_SEARCH )
        printf( "explicit locate %s: %s\n", object_str( target ), buf->value );
    string_free( buf );
    key = path_as_key( boundname );
    object_free( boundname );

    ba = (BINDING *)hash_insert( explicit_bindings, key, &found );
    if ( !found )
    {
        ba->binding = key;
        ba->target = target;
    }
    else
        object_free( key );
}
Esempio n. 17
0
// Create
void *send_new(t_symbol *s, long argc, t_atom *argv)
{
	long 	attrstart = attr_args_offset(argc, argv);		// support normal arguments
	t_send 	*x = (t_send *)object_alloc(s_send_class);
	if(x){
		object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x, NULL));

		if(attrstart > 0)
			x->attr_name = atom_getsym(argv);
		else
			x->attr_name = gensym("jcom.send no arg specified");
			
		attr_args_process(x, argc, argv);					// handle attribute args
		
		if(!g_receivemaster_object)
			g_receivemaster_object = (t_object *)object_new(CLASS_NOBOX, gensym("jcom.receivemaster"));
	}
	return x;
}
Esempio n. 18
0
SAFFIRE_OPERATOR_METHOD(numerical, sl) {
    t_numerical_object *self = (t_numerical_object *)_self;
    t_numerical_object *other;

    // Parse the arguments
    if (! object_parse_arguments(SAFFIRE_METHOD_ARGS, "n", &other)) {
        saffire_warning("Error while parsing argument list\n");
        RETURN_NUMERICAL(0);
    }

    if (in_place) {
        DEBUG_PRINT("Add to self\n");
        self->value <<= other->value;
        RETURN_SELF;
    }

    t_object *obj = object_new(Object_Numerical, self->value << other->value);
    RETURN_OBJECT(obj);
}
Esempio n. 19
0
object_t *server_write_to_cache(session_t *session, msgidx_t *msgidx)
{

    vnode_t *vnode = get_vnode_by_key(SERVER(session), msgidx->key_md5);
    assert(vnode != NULL);
    object_queue_t *caching_objects = vnode->caching_objects;

    int blockid = msgidx->message->id;
    uint32_t object_size = msgidx->object_size; 
    const char *write_buf = msgidx->data;
    uint32_t write_bytes = msgidx->data_size;;

    object_t obj;
    memset(&obj, 0, sizeof(object_t));
    memcpy(&obj.key_md5, msgidx->key_md5, sizeof(md5_value_t));
    object_t *object = object_queue_find(caching_objects, &obj);
    /*object_t *object = object_queue_find(caching_objects, &msgidx->key_md5);*/

    if ( object == NULL ){
        object = object_new(msgidx->key, msgidx->keylen);
        object->object_size = object_size;

        if ( check_md5(&object->key_md5, msgidx->key_md5) != 0 ){
            error_log("Check md5 error. session(%d), block_id:%d, key:%s object->key:%s", session->id, blockid, msgidx->key, object->key);
            /*assert(1==0);*/
            object_free(object);
            return NULL;
        }

        object_queue_insert(caching_objects, object);
    }

    object_add_slice(object, write_buf, write_bytes);
    /*slice_t *slice = slice_new(); */
    /*slice->seq_num = blockid;*/
    /*byte_block_write(&slice->byteblock, write_buf, write_bytes);*/
    /*listAddNodeTail(object->slices, slice);*/

    session->total_writed += msgidx->data_size;

    return object;

}
Esempio n. 20
0
/* appmessage_new_callv_variables */
AppMessage * appmessage_new_callv_variables(char const * method, ...)
{
	AppMessage * message;
	va_list ap;
	size_t i;
	Variable * v;
	AppMessageCallArgument * p;

	if((message = object_new(sizeof(*message))) == NULL)
		return NULL;
	message->type = AMT_CALL;
	message->id = 0;
	message->t.call.method = string_new(method);
	message->t.call.args = NULL;
	message->t.call.args_cnt = 0;
	/* check for errors */
	if(message->t.call.method == NULL)
	{
		appmessage_delete(message);
		return NULL;
	}
	/* copy the arguments */
	va_start(ap, method);
	for(i = 0; (v = va_arg(ap, Variable *)) != NULL; i++)
	{
		if((p = realloc(message->t.call.args, sizeof(*p) * (i + 1)))
				== NULL)
			break;
		message->t.call.args = p;
		if((v = variable_new_copy(v)) == NULL)
		{
			appmessage_delete(message);
			message = NULL;
			break;
		}
		message->t.call.args[i].direction = AMCD_IN; /* XXX */
		message->t.call.args[i].arg = v;
		message->t.call.args_cnt = i + 1;
	}
	va_end(ap);
	return message;
}
Esempio n. 21
0
static int _elf_init(AsmFormatPlugin * format, char const * arch)
{
	Elf * elf;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, arch);
#endif
	if((elf = object_new(sizeof(*elf))) == NULL)
		return -1;
	format->priv = elf;
	elf->es32 = NULL;
	elf->es32_cnt = 0;
	elf->es64 = NULL;
	elf->es64_cnt = 0;
	if(arch == NULL)
	{
		elf->arch = NULL;
		return 0;
	}
	if((elf->arch = _init_arch(arch)) == NULL)
	{
		object_delete(elf);
		return -1;
	}
	if(elf->arch->capacity == ELFCLASS32)
	{
		if(_init_32(format) != 0)
			return -1;
		format->exit = _exit_32;
		format->section = _section_32;
	}
	else if(elf->arch->capacity == ELFCLASS64)
	{
		if(_init_64(format) != 0)
			return -1;
		format->exit = _exit_64;
		format->section = _section_64;
	}
	else
		return -1;
	return 0;
}
Esempio n. 22
0
void jsusfx_dblclick(t_jsusfx *x) {
    if (!x->m_editor) {
        t_filehandle fh_read;
        if ( path_opensysfile(x->scriptname, x->path, &fh_read, READ_PERM) ) {
            error("jsusfx~: unable to script file");
            return;
        }
        t_handle texthandle;
        texthandle = sysmem_newhandle(0);
        sysfile_readtextfile(fh_read, texthandle, 0, TEXT_NULL_TERMINATE);
		x->m_editor = reinterpret_cast<t_object *>(object_new(CLASS_NOBOX, gensym("jed"), (t_object *)x, 0));
        object_attr_setchar(x->m_editor, gensym("scratch"), 1);
        object_method(x->m_editor, gensym("settext"), *texthandle, gensym("utf-8"));
        object_method(x->m_editor, gensym("filename"), x->scriptname, x->path);
        sysmem_freehandle(texthandle);
		sysfile_close(fh_read);
    } else {
        object_attr_setchar(x->m_editor, gensym("visible"), 1);
    }
}
Esempio n. 23
0
Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
{
    Error *local_err = NULL;
    Object *obj;

    obj = object_new(type);
    object_property_add_child(cpu, type, obj, &error_abort);
    object_unref(obj);
    object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi),
                                   &error_abort);
    object_property_add_const_link(obj, ICP_PROP_CPU, cpu, &error_abort);
    object_property_set_bool(obj, true, "realized", &local_err);
    if (local_err) {
        object_unparent(obj);
        error_propagate(errp, local_err);
        obj = NULL;
    }

    return obj;
}
static GDataFreebaseTopicObject *
reader_create_object (JsonReader *reader, TopicValueType type)
{
	GDataFreebaseTopicObject *object;

	if (type != TYPE_OBJECT && type != TYPE_COMPOUND)
		return NULL;

	json_reader_read_member (reader, "id");

	if (json_reader_get_error (reader) != NULL) {
		json_reader_end_member (reader);
		return NULL;
	}

	object = object_new (json_reader_get_string_value (reader));
	json_reader_end_member (reader);

	return object;
}
Esempio n. 25
0
QIOChannelSocket *
qio_channel_socket_new(void)
{
    QIOChannelSocket *sioc;
    QIOChannel *ioc;

    sioc = QIO_CHANNEL_SOCKET(object_new(TYPE_QIO_CHANNEL_SOCKET));
    sioc->fd = -1;

    ioc = QIO_CHANNEL(sioc);
    qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);

#ifdef WIN32
    ioc->event = CreateEvent(NULL, FALSE, FALSE, NULL);
#endif

    trace_qio_channel_socket_new(sioc);

    return sioc;
}
/* Create tag and object entry for an untagged object (should be rare) */
static jlong
make_new_tag(jlong class_tag, jlong size, TraceIndex trace_index,
                  SerialNumber thread_serial_num,
                  ObjectIndex *pindex, SiteIndex *psite)
{
    ObjectIndex object_index;
    SiteIndex   object_site_index;

    HPROF_ASSERT(class_tag!=(jlong)0);
    object_site_index = site_find_or_create(find_cnum(class_tag), trace_index);
    object_index      = object_new(object_site_index, (jint)size, 
                                   OBJECT_SYSTEM, thread_serial_num);
    if ( pindex != NULL ) {
        *pindex = object_index;
    }
    if ( psite != NULL ) {
        *psite = object_site_index;
    }
    return tag_create(object_index);
}
Esempio n. 27
0
CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
{
    UniCore32CPU *cpu;
    CPUUniCore32State *env;
    static int inited = 1;

    if (object_class_by_name(cpu_model) == NULL) {
        return NULL;
    }
    cpu = UNICORE32_CPU(object_new(cpu_model));
    env = &cpu->env;

    if (inited) {
        inited = 0;
        uc32_translate_init();
    }

    qemu_init_vcpu(env);
    return env;
}
Esempio n. 28
0
AppMessage * appmessage_new_deserialize(Buffer * buffer)
{
	AppMessage * message;
	char const * data = buffer_get_data(buffer);
	size_t size = buffer_get_size(buffer);
	size_t pos = 0;
	size_t s;
	Variable * v;
	uint8_t u8;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	if((message = object_new(sizeof(*message))) == NULL)
		return NULL;
	s = size;
	if((v = variable_new_deserialize_type(VT_UINT8, &s, &data[pos]))
			== NULL)
	{
		object_delete(message);
		return NULL;
	}
	pos += s;
	size -= s;
	/* XXX may fail */
	variable_get_as(v, VT_UINT8, &u8);
	variable_delete(v);
	switch((message->type = u8))
	{
		case AMT_ACKNOWLEDGEMENT:
			return _new_deserialize_acknowledgement(message, data,
					size, pos);
		case AMT_CALL:
			return _new_deserialize_call(message, data, size, pos);
		default:
			error_set_code(1, "%s%u", "Unknown message type ", u8);
			/* XXX should not happen */
			object_delete(message);
			return NULL;
	}
}
Esempio n. 29
0
QIOChannelTLS *
qio_channel_tls_new_client(QIOChannel *master,
                           QCryptoTLSCreds *creds,
                           const char *hostname,
                           Error **errp)
{
    QIOChannelTLS *tioc;
    QIOChannel *ioc;

    tioc = QIO_CHANNEL_TLS(object_new(TYPE_QIO_CHANNEL_TLS));
    ioc = QIO_CHANNEL(tioc);

    tioc->master = master;
    if (master->features & (1 << QIO_CHANNEL_FEATURE_SHUTDOWN)) {
        ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN);
    }
    object_ref(OBJECT(master));

    tioc->session = qcrypto_tls_session_new(
        creds,
        hostname,
        NULL,
        QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT,
        errp);
    if (!tioc->session) {
        goto error;
    }

    qcrypto_tls_session_set_callbacks(
        tioc->session,
        qio_channel_tls_write_handler,
        qio_channel_tls_read_handler,
        tioc);

    trace_qio_channel_tls_new_client(tioc, master, creds, hostname);
    return tioc;

 error:
    object_unref(OBJECT(tioc));
    return NULL;
}
Esempio n. 30
0
/* places_init */
static Places * _places_init(BrowserPluginHelper * helper)
{
#if GTK_CHECK_VERSION(3, 10, 0)
	Places * places;

	if((places = object_new(sizeof(*places))) == NULL)
		return NULL;
	places->helper = helper;
	places->widget = gtk_places_sidebar_new();
# if GTK_CHECK_VERSION(3, 12, 0)
	gtk_places_sidebar_set_local_only(GTK_PLACES_SIDEBAR(
				places->widget), TRUE);
# endif
	g_signal_connect(places->widget, "open-location", G_CALLBACK(
				_places_on_open_location), places);
	return places;
#else
	error_set("%s: %s", plugin.name, strerror(ENOSYS));
	return NULL;
#endif
}