当前位置: 首页>>代码示例>>C++>>正文


C++ GUINT32_FROM_LE函数代码示例

本文整理汇总了C++中GUINT32_FROM_LE函数的典型用法代码示例。如果您正苦于以下问题:C++ GUINT32_FROM_LE函数的具体用法?C++ GUINT32_FROM_LE怎么用?C++ GUINT32_FROM_LE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GUINT32_FROM_LE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dfu_image_from_dfuse

/**
 * dfu_image_from_dfuse: (skip)
 * @data: data buffer
 * @length: length of @data we can access
 * @consumed: (out): the number of bytes we consued
 * @error: a #GError, or %NULL
 *
 * Unpacks an image from DfuSe data.
 *
 * Returns: a #DfuImage, or %NULL for error
 **/
static DfuImage *
dfu_image_from_dfuse (const guint8 *data,
		      guint32 length,
		      guint32 *consumed,
		      GError **error)
{
	DfuSeImagePrefix *im;
	guint32 elements;
	guint32 offset = sizeof(DfuSeImagePrefix);
	g_autoptr(DfuImage) image = NULL;

	g_assert_cmpint(sizeof(DfuSeImagePrefix), ==, 274);

	/* check input buffer size */
	if (length < sizeof(DfuSeImagePrefix)) {
		g_set_error (error,
			     FWUPD_ERROR,
			     FWUPD_ERROR_INTERNAL,
			     "invalid image data size %u",
			     (guint32) length);
		return NULL;
	}

	/* verify image signature */
	im = (DfuSeImagePrefix *) data;
	if (memcmp (im->sig, "Target", 6) != 0) {
		g_set_error_literal (error,
				     FWUPD_ERROR,
				     FWUPD_ERROR_INVALID_FILE,
				     "invalid DfuSe target signature");
		return NULL;
	}

	/* create new image */
	image = dfu_image_new ();
	dfu_image_set_alt_setting (image, im->alt_setting);
	if (GUINT32_FROM_LE (im->target_named) == 0x01)
		dfu_image_set_name (image, im->target_name);

	/* parse elements */
	length -= offset;
	elements = GUINT32_FROM_LE (im->elements);
	for (guint j = 0; j < elements; j++) {
		guint32 consumed_local;
		g_autoptr(DfuElement) element = NULL;
		element = dfu_element_from_dfuse (data + offset, length,
						  &consumed_local, error);
		if (element == NULL)
			return NULL;
		dfu_image_add_element (image, element);
		offset += consumed_local;
		length -= consumed_local;
	}

	/* return size */
	if (consumed != NULL)
		*consumed = offset;

	return g_object_ref (image);
}
开发者ID:superm1,项目名称:fwupd,代码行数:71,代码来源:dfu-format-dfuse.c

示例2: ico_write_int32

static gint
ico_write_int32 (FILE     *fp,
                 guint32  *data,
                 gint      count)
{
  gint total;

  total = count;
  if (count > 0)
    {
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
      gint i;

      for (i = 0; i < count; i++)
        data[i] = GUINT32_FROM_LE (data[i]);
#endif

      ico_write_int8 (fp, (guint8 *) data, count * 4);

#if (G_BYTE_ORDER == G_BIG_ENDIAN)
      /* Put it back like we found it */
      for (i = 0; i < count; i++)
        data[i] = GUINT32_FROM_LE (data[i]);
#endif
    }

  return total * 4;
}
开发者ID:Distrotech,项目名称:gimp,代码行数:28,代码来源:ico-save.c

示例3: dfu_firmware_from_dfuse

/**
 * dfu_firmware_from_dfuse: (skip)
 * @firmware: a #DfuFirmware
 * @bytes: data to parse
 * @flags: some #DfuFirmwareParseFlags
 * @error: a #GError, or %NULL
 *
 * Unpacks into a firmware object from DfuSe data.
 *
 * Returns: %TRUE for success
 **/
gboolean
dfu_firmware_from_dfuse (DfuFirmware *firmware,
			 GBytes *bytes,
			 DfuFirmwareParseFlags flags,
			 GError **error)
{
	DfuSePrefix *prefix;
	gsize len;
	guint32 offset = sizeof(DfuSePrefix);
	guint8 *data;

	/* check the prefix (BE) */
	data = (guint8 *) g_bytes_get_data (bytes, &len);
	prefix = (DfuSePrefix *) data;
	if (memcmp (prefix->sig, "DfuSe", 5) != 0) {
		g_set_error_literal (error,
				     FWUPD_ERROR,
				     FWUPD_ERROR_INTERNAL,
				     "invalid DfuSe prefix");
		return FALSE;
	}

	/* check the version */
	if (prefix->ver != 0x01) {
		g_set_error (error,
			     FWUPD_ERROR,
			     FWUPD_ERROR_INTERNAL,
			     "invalid DfuSe version, got %02x",
			     prefix->ver);
		return FALSE;
	}

	/* check image size */
	if (GUINT32_FROM_LE (prefix->image_size) != len) {
		g_set_error (error,
			     FWUPD_ERROR,
			     FWUPD_ERROR_INTERNAL,
			     "invalid DfuSe image size, "
			     "got %" G_GUINT32_FORMAT ", "
			     "expected %" G_GSIZE_FORMAT,
			     GUINT32_FROM_LE (prefix->image_size),
			     len);
		return FALSE;
	}

	/* parse the image targets */
	len -= sizeof(DfuSePrefix);
	for (guint i = 0; i < prefix->targets; i++) {
		guint consumed;
		g_autoptr(DfuImage) image = NULL;
		image = dfu_image_from_dfuse (data + offset, (guint32) len,
					      &consumed, error);
		if (image == NULL)
			return FALSE;
		dfu_firmware_add_image (firmware, image);
		offset += consumed;
		len -= consumed;
	}
	return TRUE;
}
开发者ID:superm1,项目名称:fwupd,代码行数:71,代码来源:dfu-format-dfuse.c

示例4: hcidump_process_packet

static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
    Buffer *buf, int *err, gchar **err_info)
{
	struct dump_hdr dh;
	int packet_size;

	if (!wtap_read_bytes_or_eof(fh, &dh, DUMP_HDR_SIZE, err, err_info))
		return FALSE;

	packet_size = GUINT16_FROM_LE(dh.len);
	if (packet_size > WTAP_MAX_PACKET_SIZE) {
		/*
		 * Probably a corrupt capture file; don't blow up trying
		 * to allocate space for an immensely-large packet.
		 */
		*err = WTAP_ERR_BAD_FILE;
		*err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u",
			packet_size, WTAP_MAX_PACKET_SIZE);
		return FALSE;
	}

	phdr->rec_type = REC_TYPE_PACKET;
	phdr->presence_flags = WTAP_HAS_TS;
	phdr->ts.secs = GUINT32_FROM_LE(dh.ts_sec);
	phdr->ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000;
	phdr->caplen = packet_size;
	phdr->len = packet_size;

	phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE);

	return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
}
开发者ID:ARK1988,项目名称:wireshark,代码行数:32,代码来源:hcidump.c

示例5: riff_seek_id3

size_t
riff_seek_id3(FILE *file)
{
	int ret;
	struct stat st;
	struct riff_header header;
	struct riff_chunk_header chunk;
	size_t size;

	/* determine the file size */

	ret = fstat(fileno(file), &st);
	if (ret < 0) {
		g_warning("Failed to stat file descriptor: %s",
			  strerror(errno));
		return 0;
	}

	/* seek to the beginning and read the RIFF header */

	ret = fseek(file, 0, SEEK_SET);
	if (ret != 0) {
		g_warning("Failed to seek: %s", g_strerror(errno));
		return 0;
	}

	size = fread(&header, sizeof(header), 1, file);
	if (size != 1 ||
	    memcmp(header.id, "RIFF", 4) != 0 ||
	    GUINT32_FROM_LE(header.size) > (uint32_t)st.st_size)
		/* not a RIFF file */
		return 0;

	while (true) {
		/* read the chunk header */

		size = fread(&chunk, sizeof(chunk), 1, file);
		if (size != 1)
			return 0;

		size = GUINT32_FROM_LE(chunk.size);
		if (size > G_MAXINT32)
			/* too dangerous, bail out: possible integer
			   underflow when casting to off_t */
			return 0;

		if (size % 2 != 0)
			/* pad byte */
			++size;

		if (memcmp(chunk.id, "id3 ", 4) == 0)
			/* found it! */
			return size;

		ret = fseek(file, size, SEEK_CUR);
		if (ret != 0)
			return 0;
	}
}
开发者ID:GunioRobot,项目名称:mpd,代码行数:59,代码来源:riff.c

示例6: print_obj

static void print_obj(struct db_obj_ent *obj)
{
	uint32_t n_str = GUINT32_FROM_LE(obj->n_str);
	int i;
	void *p;
	uint16_t *slenp;
	char *dbstr;

	if (GUINT32_FROM_LE(obj->flags) & DB_OBJ_INLINE) {
		printf("%s\t%s\t%s\t[%u]\t%u\n",
			obj->bucket,
			obj->owner,
			obj->md5,
			(unsigned) GUINT64_FROM_LE(obj->size),
			n_str);
	} else {
		printf("%s\t%s\t%s\t%llX",
			obj->bucket,
			obj->owner,
			obj->md5,
			(long long) GUINT64_FROM_LE(obj->d.a.oid));
		for (i = 0; i < MAXWAY; i++) {
			if (i == 0) {
				printf("\t");
			} else {
				printf(",");
			}
			printf("%d", GUINT32_FROM_LE(obj->d.a.nidv[i]));
		}
		printf(" %u\n", n_str);
	}

	p = obj;
	p += sizeof(*obj);
	slenp = p;

	p += n_str * sizeof(uint16_t);

	for (i = 0; i < n_str; i++) {
		char pfx[16];

		dbstr = p;
		p += GUINT16_FROM_LE(*slenp);
		slenp++;

		if (i == 0)
			strcpy(pfx, "key: ");
		else
			sprintf(pfx, "str%d: ", i);

		printf("%s%s\n", pfx, dbstr);
	}

	printf("====\n");
}
开发者ID:jgarzik,项目名称:tabled,代码行数:55,代码来源:tdbadm.c

示例7: g_assert

static BlueSkyCleanerItem *bluesky_cleaner_deserialize(BlueSkyRCStr *raw)
{
    const char *data = raw->data;
    size_t len = raw->len;
    const char *data1, *data2, *data3;
    size_t len1, len2, len3;

    g_assert(len > 4);
    if (len < sizeof(struct cloudlog_header)
        || memcmp(data, CLOUDLOG_MAGIC, 4) != 0)
    {
        g_warning("Deserializing garbage cloud log item from cleaner!");
        return NULL;
    };

    struct cloudlog_header *header = (struct cloudlog_header *)data;
    len1 = GUINT32_FROM_LE(header->size1);
    len2 = GUINT32_FROM_LE(header->size2);
    len3 = GUINT32_FROM_LE(header->size3);
    data1 = data + sizeof(struct cloudlog_header);
    data2 = data1 + len1;
    data3 = data2 + len2;
    g_assert(data3 + len3 - data <= len);

    BlueSkyCleanerItem *item = g_new0(BlueSkyCleanerItem, 1);
    item->type = header->type - '0';
    item->inum = GUINT64_FROM_LE(header->inum);
    memcpy(&item->id, &header->id, sizeof(BlueSkyCloudID));

    int link_count = len2 / sizeof(BlueSkyCloudID);
    g_print("Outgoing links: %d\n", link_count);
    item->links = g_array_new(FALSE, TRUE, sizeof(BlueSkyCleanerLink));
    for (int i = 0; i < link_count; i++) {
        BlueSkyCleanerLink link;

        g_assert(len2 >= sizeof(link.id));
        memcpy(&link.id, data2, sizeof(link.id));
        data2 += sizeof(link.id); len2 -= sizeof(link.id);

        g_assert(len3 >= sizeof(link.location));
        memcpy(&link.location, data3, sizeof(link.location));
        data3 += sizeof(link.location); len3 -= sizeof(link.location);

        g_array_append_val(item->links, link);
    }

    return item;
}
开发者ID:richwolski,项目名称:bluesky,代码行数:48,代码来源:cleaner.c

示例8: fu_smbios_parse_ep64

static gboolean
fu_smbios_parse_ep64 (FuSmbios *self, const gchar *buf, gsize sz, GError **error)
{
	FuSmbiosStructureEntryPoint64 *ep;
	guint8 csum = 0;

	/* verify size */
	if (sz != sizeof(FuSmbiosStructureEntryPoint64)) {
		g_set_error (error,
			     FWUPD_ERROR,
			     FWUPD_ERROR_INVALID_FILE,
			     "invalid smbios3 entry point got %" G_GSIZE_FORMAT
			     " bytes, expected %" G_GSIZE_FORMAT,
			     sz, sizeof(FuSmbiosStructureEntryPoint32));
		return FALSE;
	}

	/* verify checksum */
	for (guint i = 0; i < sz; i++)
		csum += buf[i];
	if (csum != 0x00) {
		g_set_error_literal (error,
				     FWUPD_ERROR,
				     FWUPD_ERROR_INVALID_FILE,
				     "entry point checksum invalid");
		return FALSE;
	}
	ep = (FuSmbiosStructureEntryPoint64 *) buf;
	self->structure_table_len = GUINT32_FROM_LE (ep->structure_table_len);
	self->smbios_ver = g_strdup_printf ("%u.%u",
					    ep->smbios_major_ver,
					    ep->smbios_minor_ver);
	return TRUE;
}
开发者ID:vathpela,项目名称:fwupd,代码行数:34,代码来源:fu-smbios.c

示例9: mdb_get_single

float mdb_get_single(unsigned char *buf, int offset)
{
	union {guint32 g; float f;} f;
	memcpy(&f, &buf[offset], 4);
	f.g = GUINT32_FROM_LE(f.g);
	return f.f;
}
开发者ID:Jalakas,项目名称:libgarmin,代码行数:7,代码来源:file.c

示例10: mongo_bson_new_from_data

/**
 * mongo_bson_new_from_data:
 * @buffer: (in): The buffer to create a #MongoBson.
 * @length: (in): The length of @buffer.
 *
 * Creates a new #MongoBson instance using the buffer and the length.
 *
 * Returns: A new #MongoBson that should be freed with mongo_bson_unref().
 */
MongoBson *
mongo_bson_new_from_data (const guint8 *buffer,
                          gsize         length)
{
   MongoBson *bson;
   guint32 bson_len;

   g_return_val_if_fail(buffer != NULL, NULL);

   /*
    * The first 4 bytes of a BSON are the length, including the 4 bytes
    * containing said length.
    */
   memcpy(&bson_len, buffer, sizeof bson_len);
   bson_len = GUINT32_FROM_LE(bson_len);
   if (bson_len != length) {
      return NULL;
   }

   bson = g_slice_new0(MongoBson);
   bson->ref_count = 1;
   bson->buf = g_byte_array_sized_new(length);
   g_byte_array_append(bson->buf, buffer, length);

   return bson;
}
开发者ID:codebutler,项目名称:mongo-glib,代码行数:35,代码来源:mongo-bson.c

示例11: commview_read_header

static gboolean
commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err,
    gchar **err_info)
{
	wtap_file_read_expected_bytes(&cv_hdr->data_len, 2, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->source_data_len, 2, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->version, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->year, 2, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->month, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->day, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->hours, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->minutes, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->seconds, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->usecs, 4, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->flags, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->signal_level_percent, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->rate, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->band, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->channel, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->direction, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->signal_level_dbm, 1, fh, err, err_info);
	wtap_file_read_expected_bytes(&cv_hdr->noise_level, 1, fh, err, err_info);

	/* Convert multi-byte values from little endian to host endian format */
	cv_hdr->data_len = GUINT16_FROM_LE(cv_hdr->data_len);
	cv_hdr->source_data_len = GUINT16_FROM_LE(cv_hdr->source_data_len);
	cv_hdr->year = GUINT16_FROM_LE(cv_hdr->year);
	cv_hdr->usecs = GUINT32_FROM_LE(cv_hdr->usecs);

	return TRUE;
}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:31,代码来源:commview.c

示例12: mdb_get_single

float mdb_get_single(void *buf, int offset)
{
	union {guint32 g; float f;} f;
	memcpy(&f, buf + offset, 4);
	f.g = GUINT32_FROM_LE(f.g);
	return f.f;
}
开发者ID:ASAPPinc,项目名称:mdbtools,代码行数:7,代码来源:file.c

示例13: fwupd_guid_to_string

/**
 * fwupd_guid_to_string:
 * @guid: a #fwupd_guid_t to read
 * @flags: some %FwupdGuidFlags, e.g. %FWUPD_GUID_FLAG_MIXED_ENDIAN
 *
 * Returns a text GUID of mixed or BE endian for a packed buffer.
 *
 * Returns: A new GUID
 *
 * Since: 1.2.5
 **/
gchar *
fwupd_guid_to_string (const fwupd_guid_t *guid, FwupdGuidFlags flags)
{
	fwupd_guid_native_t gnat;

	g_return_val_if_fail (guid != NULL, NULL);

	/* copy to avoid issues with aligning */
	memcpy (&gnat, guid, sizeof(gnat));

	/* mixed is bizaar, but specified as the DCE encoding */
	if (flags & FWUPD_GUID_FLAG_MIXED_ENDIAN) {
		return g_strdup_printf ("%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
					GUINT32_FROM_LE(gnat.a),
					GUINT16_FROM_LE(gnat.b),
					GUINT16_FROM_LE(gnat.c),
					GUINT16_FROM_BE(gnat.d),
					gnat.e[0], gnat.e[1],
					gnat.e[2], gnat.e[3],
					gnat.e[4], gnat.e[5]);
	}
	return g_strdup_printf ("%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
				GUINT32_FROM_BE(gnat.a),
				GUINT16_FROM_BE(gnat.b),
				GUINT16_FROM_BE(gnat.c),
				GUINT16_FROM_BE(gnat.d),
				gnat.e[0], gnat.e[1],
				gnat.e[2], gnat.e[3],
				gnat.e[4], gnat.e[5]);
}
开发者ID:vathpela,项目名称:fwupd,代码行数:41,代码来源:fwupd-common.c

示例14: msn_read32le

guint32
msn_read32le(const char *buf)
{
    guint32 val;
    memcpy(&val, buf, sizeof(val));
    return GUINT32_FROM_LE(val);
}
开发者ID:N8Fear,项目名称:purple-facebook,代码行数:7,代码来源:msnutils.c

示例15: mongo_bson_new_from_static_data

/**
 * mongo_bson_new_from_static_data:
 * @buffer: (in) (transfer full): The static buffer to use.
 * @length: (in): The number of bytes in @buffer.
 * @notify: (in): A #GDestroyNotify to free @buffer.
 *
 * Creates a new #MongoBson structure using @buffer. This does not copy
 * the content of the buffer and uses it directly. Therefore, you MUST make
 * sure that the structure outlives the buffer beneath it.
 *
 * If the structure is referenced with mongo_bson_ref(), the contents of
 * the buffer will be copied.
 *
 * When the structure is released, @notify will be called to release
 * @buffer.
 *
 * You MAY NOT modify the contents of @buffer using any of the
 * mongo_bson_append methods.
 *
 * Returns: A newly created #MongoBson structure.
 */
MongoBson *
mongo_bson_new_from_static_data (guint8         *buffer,
                                 gsize           length,
                                 GDestroyNotify  notify)
{
   MongoBson *bson;
   guint32 bson_len;

   g_return_val_if_fail(buffer != NULL, NULL);

   /*
    * The first 4 bytes of a BSON are the length, including the 4 bytes
    * containing said length.
    */
   memcpy(&bson_len, buffer, sizeof bson_len);
   bson_len = GUINT32_FROM_LE(bson_len);
   if (bson_len != length) {
      return NULL;
   }

   bson = g_slice_new0(MongoBson);
   bson->ref_count = 1;
   bson->static_data = buffer;
   bson->static_len = length;
   bson->static_notify = notify;

   return bson;
}
开发者ID:codebutler,项目名称:mongo-glib,代码行数:49,代码来源:mongo-bson.c


注:本文中的GUINT32_FROM_LE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。