예제 #1
0
GByteArray*
aclist_to_binary(const ACList *in_aclist, gssize in_block_size)
{
    if (in_aclist == NULL)
    {
        return NULL;
    }

    GByteArray *ret_val = g_byte_array_new();

    if (!aclist_write_to_binary(in_aclist, ret_val, in_block_size))
    {
        g_byte_array_free(ret_val, TRUE);
        return NULL;
    }

    return ret_val;
}
static void
stream_mem_finalize (GObject *object)
{
	CamelStreamMemPrivate *priv;

	priv = CAMEL_STREAM_MEM_GET_PRIVATE (object);

	if (priv->buffer && priv->owner) {
		/* TODO: we need our own bytearray type since we don't know
		   the real size of the underlying buffer :-/ */
		if (priv->secure && priv->buffer->len)
			clear_mem (priv->buffer->data, priv->buffer->len);
		g_byte_array_free (priv->buffer, TRUE);
	}

	/* Chain up to parent's finalize() method. */
	G_OBJECT_CLASS (camel_stream_mem_parent_class)->finalize (object);
}
예제 #3
0
static BMSettingsConnectionInterface *
get_connection_for_bdaddr (BMSettingsInterface *settings,
                           const char *bdaddr,
                           gboolean pan)
{
	BMSettingsConnectionInterface *found = NULL;
	GSList *list, *l;
	GByteArray *array;

	array = get_array_from_bdaddr (bdaddr);
	if (array == NULL)
		return NULL;

	list = bm_settings_interface_list_connections (settings);
	for (l = list; l != NULL; l = l->next) {
		BMSettingsConnectionInterface *candidate = l->data;
		BMSetting *setting;
		const char *type;
		const GByteArray *addr;

		setting = bm_connection_get_setting_by_name (BM_CONNECTION (candidate), BM_SETTING_BLUETOOTH_SETTING_NAME);
		if (setting == NULL)
			continue;

		type = bm_setting_bluetooth_get_connection_type (BM_SETTING_BLUETOOTH (setting));
		if (pan) {
			if (g_strcmp0 (type, BM_SETTING_BLUETOOTH_TYPE_PANU) != 0)
				continue;
		} else {
			if (g_strcmp0 (type, BM_SETTING_BLUETOOTH_TYPE_DUN) != 0)
				continue;
		}

		addr = bm_setting_bluetooth_get_bdaddr (BM_SETTING_BLUETOOTH (setting));
		if (addr == NULL || memcmp (addr->data, array->data, addr->len) != 0)
			continue;
		found = candidate;
		break;
	}
	g_slist_free (list);

	g_byte_array_free (array, TRUE);
	return found;
}
예제 #4
0
static void write_dict(GByteArray * bplist, GNode * node, GHashTable * ref_table, uint8_t dict_param_size)
{
    uint64_t idx1 = 0;
    uint64_t idx2 = 0;
    uint8_t *buff = NULL;

    GNode *cur = NULL;
    uint64_t i = 0;

    uint64_t size = g_node_n_children(node) / 2;
    uint8_t marker = BPLIST_DICT | (size < 15 ? size : 0xf);
    g_byte_array_append(bplist, &marker, sizeof(uint8_t));
    if (size >= 15)
    {
        GByteArray *int_buff = g_byte_array_new();
        write_int(int_buff, size);
        g_byte_array_append(bplist, int_buff->data, int_buff->len);
        g_byte_array_free(int_buff, TRUE);
    }

    buff = (uint8_t *) malloc(size * 2 * dict_param_size);

    for (i = 0, cur = node->children; cur && i < size; cur = cur->next->next, i++)
    {
        idx1 = *(uint64_t *) (g_hash_table_lookup(ref_table, cur));
#if G_BYTE_ORDER == G_BIG_ENDIAN
	idx1 = idx1 << ((sizeof(uint64_t) - dict_param_size) * 8);
#endif
        memcpy(buff + i * dict_param_size, &idx1, dict_param_size);
        byte_convert(buff + i * dict_param_size, dict_param_size);

        idx2 = *(uint64_t *) (g_hash_table_lookup(ref_table, cur->next));
#if G_BYTE_ORDER == G_BIG_ENDIAN
	idx2 = idx2 << ((sizeof(uint64_t) - dict_param_size) * 8);
#endif
        memcpy(buff + (i + size) * dict_param_size, &idx2, dict_param_size);
        byte_convert(buff + (i + size) * dict_param_size, dict_param_size);
    }

    //now append to bplist
    g_byte_array_append(bplist, buff, size * 2 * dict_param_size);
    free(buff);

}
예제 #5
0
static void
gst_dshowaudiosrc_dispose (GObject * gobject)
{
  GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (gobject);

  if (src->device) {
    g_free (src->device);
    src->device = NULL;
  }

  if (src->device_name) {
    g_free (src->device_name);
    src->device_name = NULL;
  }

  if (src->caps) {
    gst_caps_unref (src->caps);
    src->caps = NULL;
  }

  if (src->pins_mediatypes) {
    gst_dshow_free_pins_mediatypes (src->pins_mediatypes);
    src->pins_mediatypes = NULL;
  }

  if (src->gbarray) {
    g_byte_array_free (src->gbarray, TRUE);
    src->gbarray = NULL;
  }

  if (src->gbarray_lock) {
    g_mutex_free (src->gbarray_lock);
    src->gbarray_lock = NULL;
  }

  /* clean dshow */
  if (src->audio_cap_filter) {
    IBaseFilter_Release (src->audio_cap_filter);
  }

  CoUninitialize ();

  G_OBJECT_CLASS (parent_class)->dispose (gobject);
}
예제 #6
0
static void
_client_free(struct gridd_client_s *client)
{
	EXTRA_ASSERT(client != NULL);
	EXTRA_ASSERT(client->abstract.vtable == &VTABLE_CLIENT);

	_client_reset_reply(client);
	_client_reset_request(client);
	_client_reset_cnx(client);
	_client_reset_target(client);
	_client_reset_error(client);
	if (client->reply)
		g_byte_array_free(client->reply, TRUE);
	if (client->past_url)
		g_string_free(client->past_url, TRUE);
	memset(client, 0, sizeof(*client));
	client->fd = -1;
	g_free(client);
}
예제 #7
0
static void write_raw_data(GByteArray * bplist, uint8_t mark, uint8_t * val, uint64_t size)
{
    uint8_t *buff = NULL;
    uint8_t marker = mark | (size < 15 ? size : 0xf);
    g_byte_array_append(bplist, &marker, sizeof(uint8_t));
    if (size >= 15)
    {
        GByteArray *int_buff = g_byte_array_new();
        write_int(int_buff, size);
        g_byte_array_append(bplist, int_buff->data, int_buff->len);
        g_byte_array_free(int_buff, TRUE);
    }
    //stupid unicode buffer length
    if (BPLIST_UNICODE==mark) size *= 2;
    buff = (uint8_t *) malloc(size);
    memcpy(buff, val, size);
    g_byte_array_append(bplist, buff, size);
    free(buff);
}
예제 #8
0
static size_t
transfer_payload_headers (GstCurlSmtpSink * sink,
    void *curl_ptr, size_t block_size)
{
  size_t bytes_to_send;
  GByteArray *headers = sink->payload_headers;

  bytes_to_send = MIN (block_size, headers->len);
  memcpy ((guint8 *) curl_ptr, headers->data, bytes_to_send);
  g_byte_array_remove_range (headers, 0, bytes_to_send);


  if (headers->len == 0) {
    g_byte_array_free (headers, TRUE);
    sink->payload_headers = NULL;
  }

  return bytes_to_send;
}
예제 #9
0
static void
cockpit_ssh_transport_finalize (GObject *object)
{
  CockpitSshTransport *self = COCKPIT_SSH_TRANSPORT (object);

  /* libssh channels like to hang around even after they're freed */
  memset (&self->channel_cbs, 0, sizeof (self->channel_cbs));
  ssh_event_free (self->event);

  cockpit_ssh_data_free (self->data);
  g_free (self->logname);

  g_queue_free_full (self->queue, (GDestroyNotify)g_bytes_unref);
  g_byte_array_free (self->buffer, TRUE);

  g_assert (self->io == NULL);

  G_OBJECT_CLASS (cockpit_ssh_transport_parent_class)->finalize (object);
}
예제 #10
0
/* Verifies that a private key can be read, and if a password is given, that
 * the private key can be decrypted with that password.
 */
NMCryptoFileFormat
crypto_verify_private_key_data (const GByteArray *contents,
                                const char *password,
                                GError **error)
{
	GByteArray *tmp;
	NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
	NMCryptoKeyType ktype = NM_CRYPTO_KEY_TYPE_UNKNOWN;
	gboolean is_encrypted = FALSE;

	g_return_val_if_fail (contents != NULL, FALSE);

	/* Check for PKCS#12 first */
	if (crypto_is_pkcs12_data (contents)) {
		if (!password || crypto_verify_pkcs12 (contents, password, error))
			format = NM_CRYPTO_FILE_FORMAT_PKCS12;
	} else {
		/* Maybe it's PKCS#8 */
		tmp = parse_pkcs8_key_file (contents, &is_encrypted, error);
		if (tmp) {
			if (!password || crypto_verify_pkcs8 (tmp, is_encrypted, password, error))
				format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
		} else {
			g_clear_error (error);

			/* Or it's old-style OpenSSL */
			tmp = crypto_decrypt_private_key_data (contents, password, &ktype, error);
			if (tmp)
				format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
			else if (!password && (ktype != NM_CRYPTO_KEY_TYPE_UNKNOWN))
				format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
		}

		if (tmp) {
			/* Don't leave decrypted key data around */
			memset (tmp->data, 0, tmp->len);
			g_byte_array_free (tmp, TRUE);
		}
	}

	return format;
}
예제 #11
0
static GByteArray *
fb_util_zlib_conv(GConverter *conv, const GByteArray *bytes, GError **error)
{
    GByteArray *ret;
    GConverterResult res;
    gsize cize = 0;
    gsize rize;
    gsize wize;
    guint8 data[1024];

    ret = g_byte_array_new();

    while (TRUE) {
        rize = 0;
        wize = 0;

        res = g_converter_convert(conv,
                                  bytes->data + cize,
                                  bytes->len - cize,
                                  data, sizeof data,
                                  G_CONVERTER_INPUT_AT_END,
                                  &rize, &wize, error);

        switch (res) {
        case G_CONVERTER_CONVERTED:
            g_byte_array_append(ret, data, wize);
            cize += rize;
            break;

        case G_CONVERTER_ERROR:
            g_byte_array_free(ret, TRUE);
            return NULL;

        case G_CONVERTER_FINISHED:
            g_byte_array_append(ret, data, wize);
            return ret;

        default:
            break;
        }
    }
}
예제 #12
0
파일: plugin.c 프로젝트: vzupanovic/projekt
static void
bind_device_to_connection (SCPluginIfupdown *self,
                           GUdevDevice *device,
                           NMIfupdownConnection *exported)
{
	GByteArray *mac_address;
	NMSettingWired *s_wired;
	NMSettingWireless *s_wifi;
	const char *iface, *address;

	iface = g_udev_device_get_name (device);
	if (!iface) {
		PLUGIN_WARN ("SCPluginIfupdown", "failed to get ifname for device.");
		return;
	}

	address = g_udev_device_get_sysfs_attr (device, "address");
	if (!address || !strlen (address)) {
		PLUGIN_WARN ("SCPluginIfupdown", "failed to get MAC address for %s", iface);
		return;
	}

	mac_address = nm_utils_hwaddr_atoba (address, ARPHRD_ETHER);
	if (!mac_address) {
		PLUGIN_WARN ("SCPluginIfupdown", "failed to parse MAC address '%s' for %s",
		             address, iface);
		return;
	}

	s_wired = nm_connection_get_setting_wired (NM_CONNECTION (exported));
	s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (exported));
	if (s_wired) {
		PLUGIN_PRINT ("SCPluginIfupdown", "locking wired connection setting");
		g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac_address, NULL);
	} else if (s_wifi) {
		PLUGIN_PRINT ("SCPluginIfupdown", "locking wireless connection setting");
		g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, mac_address, NULL);
	}
	g_byte_array_free (mac_address, TRUE);

	nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), ignore_cb, NULL);
}    
예제 #13
0
END_TEST


START_TEST(test_bdd_assignment_expand_3)
{
    ipset_assignment_t  *a;

    a = ipset_assignment_new();
    ipset_assignment_set(a, 0, TRUE);
    ipset_assignment_set(a, 2, FALSE);

    ipset_expanded_assignment_t  *it;
    it = ipset_assignment_expand(a, 3);

    GByteArray  *ea = g_byte_array_sized_new(1);
    memset(ea->data, 0, 1);

    fail_if(it->finished,
            "Expanded assignment shouldn't be empty");
    IPSET_BIT_SET(ea->data, 0, TRUE);
    IPSET_BIT_SET(ea->data, 1, FALSE);
    IPSET_BIT_SET(ea->data, 2, FALSE);
    fail_unless(memcmp(ea->data, it->values->data, 1) == 0,
                "Expanded assignment 1 doesn't match");

    ipset_expanded_assignment_advance(it);
    fail_if(it->finished,
                "Expanded assignment should have at least 1 element");
    IPSET_BIT_SET(ea->data, 0, TRUE);
    IPSET_BIT_SET(ea->data, 1, TRUE);
    IPSET_BIT_SET(ea->data, 2, FALSE);
    fail_unless(memcmp(ea->data, it->values->data, 1) == 0,
                "Expanded assignment 2 doesn't match");

    ipset_expanded_assignment_advance(it);
    fail_unless(it->finished,
                "Expanded assignment should have 2 elements");

    g_byte_array_free(ea, TRUE);
    ipset_expanded_assignment_free(it);
    ipset_assignment_free(a);
}
예제 #14
0
static void fastcgi_connection_free(fastcgi_connection *fcon) {
	liVRequest *vr;
	if (!fcon) return;

	vr = fcon->vr;
	ev_io_stop(vr->wrk->loop, &fcon->fd_watcher);
	fastcgi_context_release(fcon->ctx);
	if (fcon->fd != -1) close(fcon->fd);
	li_vrequest_backend_finished(vr);

	li_chunkqueue_free(fcon->fcgi_in);
	li_chunkqueue_free(fcon->fcgi_out);
	li_chunkqueue_free(fcon->stdout);
	li_buffer_release(fcon->fcgi_in_buffer);
	g_byte_array_free(fcon->buf_in_record, TRUE);

	li_http_response_parser_clear(&fcon->parse_response_ctx);

	g_slice_free(fastcgi_connection, fcon);
}
예제 #15
0
static void
byte_array_finalize(JSFreeOp *fop,
                    JSObject *obj)
{
    ByteArrayInstance *priv;

    priv = (ByteArrayInstance*) JS_GetPrivate(obj);

    if (priv == NULL)
        return; /* prototype, not instance */

    if (priv->array) {
        g_byte_array_free(priv->array, TRUE);
        priv->array = NULL;
    } else if (priv->bytes) {
        g_clear_pointer(&priv->bytes, g_bytes_unref);
    }

    g_slice_free(ByteArrayInstance, priv);
}
예제 #16
0
void
picker_procset_free(picker_procset *set)
{
	unsigned int i;
	assert(set);

	/* close file descriptors */
	for (i=0; i < picker_procset_size(set); i++)
	{
		picker_process* proc;

		proc = picker_procset_at(set, i);
		assert(proc);
		close(proc->stat_fd);
/*      close(proc->statm_fd);*/
	}

	g_array_free(set->procs, TRUE);
	g_byte_array_free(set->pids, TRUE);
}
예제 #17
0
GByteArray*
edsio_base64_encode_region (const guint8* data, guint len)
{
  GByteArray* out = g_byte_array_new ();
  guint real_len;

  g_byte_array_set_size (out, (len+2)*4/3);

  real_len = out->len;

  if (! edsio_base64_encode_region_into (data, len, out->data, &real_len))
    {
      g_byte_array_free (out, TRUE);
      return NULL;
    }

  g_byte_array_set_size (out, real_len);

  return out;
}
예제 #18
0
/**
 * e2k_permanenturl_to_entryid:
 * @permanenturl: an Exchange permanenturl
 *
 * Creates an ENTRYID (specifically, a PR_SOURCE_KEY) based on
 * @permanenturl
 *
 * Return value: the entryid
 **/
GByteArray *
e2k_permanenturl_to_entryid (const char *permanenturl)
{
	GByteArray *entryid;

	permanenturl = strstr (permanenturl, E2K_PERMANENTURL_INFIX);
	if (!permanenturl)
		return NULL;
	permanenturl += E2K_PERMANENTURL_INFIX_LEN;

	entryid = g_byte_array_new ();
	while (*permanenturl++ == '/') {
		if (!append_entryid_section (entryid, &permanenturl)) {
			g_byte_array_free (entryid, TRUE);
			return NULL;
		}
	}

	return entryid;
}
예제 #19
0
파일: inkjar.cpp 프로젝트: Spin0za/inkscape
guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, 
				       guint16 eflen, guint16 flags)
{
    GByteArray *gba = g_byte_array_new();
    unsigned int out_a = 0;
    unsigned int in_a = compressed_size;
    guint8 *bytes;
    guint32 crc2 = 0;
    
    crc2 = crc32(crc2, NULL, 0);
    
    bytes = (guint8 *)g_malloc(sizeof(guint8) * RDSZ);
    while(out_a < compressed_size){
	unsigned int nbytes = (in_a > RDSZ ? RDSZ : in_a);
	
	if (!(nbytes = read(bytes, nbytes))) {
	    g_free(bytes);
	    return NULL;
	}
	
	crc2 = crc32(crc2, (Bytef*)bytes, nbytes);
	    
	g_byte_array_append (gba, bytes, nbytes);
	out_a += nbytes;
	in_a -= nbytes;
	    
#ifdef DEBUG    
	std::printf("%d bytes written\n", out_a);
#endif
    }
    lseek(fd, eflen, SEEK_CUR);
    g_free(bytes);

    if (!check_crc(crc, crc2, flags)) {
        bytes = gba->data;
        g_byte_array_free(gba, FALSE);//FALSE argument does not free actual data
	return NULL;
    }
    
    return bytes;
}
IdolPlParserResult
idol_pl_parser_add_itms (IdolPlParser *parser,
			  GFile *file,
			  GFile *base_file,
			  IdolPlParseData *parse_data,
			  gpointer data)
{
#ifndef HAVE_GMIME
	WARN_NO_GMIME;
#else
	GByteArray *content;
	char *itms_uri;
	GFile *feed_file;
	IdolPlParserResult ret;

	if (g_file_has_uri_scheme (file, "itms") != FALSE) {
		itms_uri= g_file_get_uri (file);
		memcpy (itms_uri, "http", 4);
	} else if (g_file_has_uri_scheme (file, "http") != FALSE) {
		itms_uri = g_file_get_uri (file);
	} else {
		return IDOL_PL_PARSER_RESULT_ERROR;
	}

	/* Load the file using iTunes user-agent */
	content = idol_pl_parser_load_http_itunes (itms_uri);

	/* And look in the file for the feedURL */
	feed_file = idol_pl_parser_get_feed_uri ((char *) content->data, content->len);
	g_byte_array_free (content, TRUE);
	if (feed_file == NULL)
		return IDOL_PL_PARSER_RESULT_ERROR;

	DEBUG(feed_file, g_print ("Found feed URI: %s\n", uri));

	ret = idol_pl_parser_add_rss (parser, feed_file, NULL, parse_data, NULL);
	g_object_unref (feed_file);

	return ret;
#endif /* !HAVE_GMIME */
}
예제 #21
0
static void
do_coding_empty_test (void)
{
	SoupSession *session;
	SoupMessage *msg;
	SoupURI *uri;
	SoupRequester *requester;
	SoupRequest *req;
	GByteArray *body;

	debug_printf (1, "\nEmpty allegedly-encoded body test\n");

	session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
					 SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
					 SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
					 SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
					 NULL);
	requester = (SoupRequester *)soup_session_get_feature (session, SOUP_TYPE_REQUESTER);
	uri = soup_uri_new_with_base (base_uri, "/mbox");

	debug_printf (1, "  SoupMessage\n");
	msg = soup_message_new_from_uri ("GET", uri);
	soup_message_headers_append (msg->request_headers,
				     "X-Test-Options", "empty");
	soup_session_send_message (session, msg);
	check_response (msg, "gzip", "text/plain", EXPECT_NOT_DECODED);
	g_object_unref (msg);

	debug_printf (1, "  SoupRequest\n");
	req = soup_requester_request_uri (requester, uri, NULL);
	msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
	soup_message_headers_append (msg->request_headers,
				     "X-Test-Options", "empty");
	g_object_unref (msg);
	body = do_single_coding_req_test (req, "gzip", "text/plain", EXPECT_NOT_DECODED);
	g_byte_array_free (body, TRUE);
	g_object_unref (req);

	soup_uri_free (uri);
	soup_test_session_abort_unref (session);
}
예제 #22
0
int
main( int argc, char** argv )
{
	bswabe_pub_t* pub;
	bswabe_prv_t* prv;
	int file_len;
	GByteArray* aes_buf;
	GByteArray* plt;
	GByteArray* cph_buf;
	bswabe_cph_t* cph;
	element_t m;

	parse_args(argc, argv);

	pub = bswabe_pub_unserialize(suck_file(pub_file), 1);
	prv = bswabe_prv_unserialize(pub, suck_file(prv_file), 1);

	read_cpabe_file(in_file, &cph_buf, &file_len, &aes_buf);

	cph = bswabe_cph_unserialize(pub, cph_buf, 1);
	if( !bswabe_dec(pub, prv, cph, m) )
		die("%s", bswabe_error());
	bswabe_cph_free(cph);

	plt = aes_128_cbc_decrypt(aes_buf, m);
	g_byte_array_set_size(plt, file_len);
	g_byte_array_free(aes_buf, 1);

	spit_file(out_file, plt, 1);

	if( !keep )
		unlink(in_file);

	/* report ops if necessary */
/* 	if( report_ops ) */
/* 		printf("pairings:        %5d\n" */
/* 					 "exponentiations: %5d\n" */
/* 					 "multiplications: %5d\n", num_pairings, num_exps, num_muls); */

	return 0;
}
예제 #23
0
static void
load_cached_records (DMAPDb *db, const gchar *db_dir, DMAPRecordFactory *factory)
{
	GDir *d;
	GError *error = NULL;

	d = g_dir_open (db_dir, 0, &error);

	if (error != NULL) {
		g_warning ("%s", error->message);
	} else {
		if (db_dir) {
			const gchar *entry;

			while ((entry = g_dir_read_name (d))) {
				gchar *path = g_strdup_printf ("%s/%s", db_dir, entry);
				if (g_file_test (path, G_FILE_TEST_IS_REGULAR)
				    && g_str_has_suffix (path, ".record")) {
					GByteArray *blob = cache_read (path);
					if (blob) {
						g_debug ("Adding cache: %s", path);
						DMAPRecord *record = dmap_record_factory_create (factory, NULL);
						if (NULL != record) {
							if (dmap_record_set_from_blob (record, blob)) {
								dmap_db_add (DMAP_DB (db), record);
							} else {
								g_warning ("Removing stale cache entry %s\n", path);
								g_unlink (path);
							}
							g_object_unref (record);
						}
						g_byte_array_free (blob, TRUE);
					}
				}
				g_free (path);
			}
		}

		g_dir_close (d);
	}
}
예제 #24
0
static void
dispose (GObject *object)
{
	E2kSecurityDescriptor *sd = (E2kSecurityDescriptor *) object;

	if (sd->priv) {
		g_hash_table_foreach (sd->priv->sids, free_sid, NULL);
		g_hash_table_destroy (sd->priv->sids);
		g_hash_table_destroy (sd->priv->sid_order);

		g_array_free (sd->priv->aces, TRUE);

		if (sd->priv->header)
			g_byte_array_free (sd->priv->header, TRUE);

		g_free (sd->priv);
		sd->priv = NULL;
	}

	G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
set_property (GObject *object, guint prop_id,
		    const GValue *value, GParamSpec *pspec)
{
	NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);

	switch (prop_id) {
	case PROP_BDADDR:
		if (priv->bdaddr)
			g_byte_array_free (priv->bdaddr, TRUE);
		priv->bdaddr = g_value_dup_boxed (value);
		break;
	case PROP_TYPE:
		g_free (priv->type);
		priv->type = g_value_dup_string (value);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
예제 #26
0
static void
set_property (GObject *object, guint prop_id,
              const GValue *value, GParamSpec *pspec)
{
	NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);

	switch (prop_id) {
	case PROP_NETWORK_NAME:
		g_free (priv->network_name);
		priv->network_name = g_value_dup_string (value);
		break;
	case PROP_MAC_ADDRESS:
		if (priv->mac_address)
			g_byte_array_free (priv->mac_address, TRUE);
		priv->mac_address = g_value_dup_boxed (value);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
예제 #27
0
static void
test_cert (gconstpointer test_data)
{
	gs_free char *path = NULL;
	GByteArray *array;
	NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
	GError *error = NULL;

	path = g_build_filename (TEST_CERT_DIR, (const char *) test_data, NULL);

	array = crypto_load_and_verify_certificate (path, &format, &error);
	ASSERT (array != NULL, "cert",
	        "couldn't read certificate file '%s': %d %s",
	        path, error->code, error->message);

	ASSERT (format == NM_CRYPTO_FILE_FORMAT_X509, "cert",
	        "%s: unexpected certificate format (expected %d, got %d)",
	        path, NM_CRYPTO_FILE_FORMAT_X509, format);

	g_byte_array_free (array, TRUE);
}
예제 #28
0
int
build_message_from_request(message_t * message, request_t * request, GError ** error)
{
	GByteArray *req_gba;

	(void) error;

	req_gba = g_byte_array_new();
	g_byte_array_append(req_gba, (const guint8*)request->cmd, strlen(request->cmd));
	g_byte_array_append(req_gba, (const guint8*)" ", 1);

	if (request->arg) {
		g_byte_array_append(req_gba, (const guint8*)request->arg,
		    (request->arg_size > 0) ? request->arg_size : strlen(request->arg));
	}

	message->data = req_gba->data;
	message->length = req_gba->len;
	g_byte_array_free(req_gba, FALSE);
	return (1);
}
예제 #29
0
void vik_waypoint_marshall ( VikWaypoint *wp, guint8 **data, guint *datalen)
{
  GByteArray *b = g_byte_array_new();
  guint len;

  g_byte_array_append(b, (guint8 *)wp, sizeof(*wp));

#define vwm_append(s) \
  len = (s) ? strlen(s)+1 : 0; \
  g_byte_array_append(b, (guint8 *)&len, sizeof(len)); \
  if (s) g_byte_array_append(b, (guint8 *)s, len);

  vwm_append(wp->comment);
  vwm_append(wp->image);
  vwm_append(wp->symbol);

  *data = b->data;
  *datalen = b->len;
  g_byte_array_free(b, FALSE);
#undef vwm_append
}
예제 #30
0
static void
on_gnupg_source_finalize (GSource *source)
{
	GnupgSource *gnupg_source = (GnupgSource*)source;
	gint i;

	g_assert (gnupg_source->cancellable == NULL);
	g_assert (gnupg_source->cancel_sig == 0);

	for (i = 0; i < NUM_FDS; ++i)
		close_fd (&gnupg_source->polls[i].fd);

	g_object_unref (gnupg_source->process);
	if (gnupg_source->input_buf)
		g_byte_array_free (gnupg_source->input_buf, TRUE);
	g_string_free (gnupg_source->error_buf, TRUE);
	g_string_free (gnupg_source->status_buf, TRUE);

	g_assert (!gnupg_source->child_pid);
	g_assert (!gnupg_source->child_sig);
}