本文整理汇总了C++中GUINT32_FROM_LE函数的典型用法代码示例。如果您正苦于以下问题:C++ GUINT32_FROM_LE函数的具体用法?C++ GUINT32_FROM_LE怎么用?C++ GUINT32_FROM_LE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GUINT32_FROM_LE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: dfu_element_from_dfuse
/**
* dfu_element_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 element from DfuSe data.
*
* Returns: a #DfuElement, or %NULL for error
**/
static DfuElement *
dfu_element_from_dfuse (const guint8 *data,
guint32 length,
guint32 *consumed,
GError **error)
{
DfuElement *element = NULL;
DfuSeElementPrefix *el = (DfuSeElementPrefix *) data;
guint32 size;
g_autoptr(GBytes) contents = NULL;
g_assert_cmpint(sizeof(DfuSeElementPrefix), ==, 8);
/* check input buffer size */
if (length < sizeof(DfuSeElementPrefix)) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
"invalid element data size %u",
(guint32) length);
return NULL;
}
/* check size */
size = GUINT32_FROM_LE (el->size);
if (size + sizeof(DfuSeElementPrefix) > length) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
"invalid element size %u, only %u bytes left",
size,
(guint32) (length - sizeof(DfuSeElementPrefix)));
return NULL;
}
/* create new element */
element = dfu_element_new ();
dfu_element_set_address (element, GUINT32_FROM_LE (el->address));
contents = g_bytes_new (data + sizeof(DfuSeElementPrefix), size);
dfu_element_set_contents (element, contents);
/* return size */
if (consumed != NULL)
*consumed = (guint32) sizeof(DfuSeElementPrefix) + size;
return element;
}
开发者ID:superm1,项目名称:fwupd,代码行数:58,代码来源:dfu-format-dfuse.c
示例17: incoming_node_data
// Processes messages having this format:
// https://en.bitcoin.it/wiki/Protocol_specification#Message_structure
void incoming_node_data(const int fd, struct bitcoin_storage *const st)
{
static struct msg_wire *buf = NULL; // For storing the message payload
static int buf_allocated = 0;
static int buf_pos = 0;
static int buf_left = sizeof(struct msg_wire);
static enum msg_type buf_type = UNDEFINED;
// Reallocate buffer only if it is too small.
if (buf_allocated < buf_pos+buf_left) {
buf_allocated = buf_pos+buf_left;
buf = g_realloc(buf,buf_allocated);
}
const int got = read(fd,(void*)buf+buf_pos,buf_left);
if (got == 0) {
errx(3,"Unexpected end of bitcoind stream");
} else if (got == -1) {
err(3,"Error reading bitcoind stream");
}
buf_pos += got;
buf_left -= got;
// Header received. To continue reading in next pass, update
// the message length and possibly compact the header.
if (buf_type == UNDEFINED && buf_pos == sizeof(struct msg_wire)) {
// Check message header
if (GUINT32_FROM_LE(buf->magic) != 0xD9B4BEF9) {
errx(3,"Magic error. Probably we got out of sync.");
}
// Gather message type and length
buf_type = bitcoin_find_type(buf);
const guint32 payload_len = GUINT32_FROM_LE(buf->length_le);
// Do header compaction if type is not INV. Doing
// dangerous in-place rewrite.
if (buf_type != INV) {
COMPACT->type = buf_type;
COMPACT->length = payload_len;
COMPACT->sent = false;
// Rewind to compacted payload starting pos
buf_pos = offsetof(struct msg,payload);
}
buf_left = payload_len;
}
开发者ID:9cat,项目名称:kryptoradio,代码行数:49,代码来源:incoming_node.c
示例18: vfs_fget_le32
/**
* Reads an unsigned 32-bit Little Endian value from the stream into native endian format.
*
* @param value Pointer to the variable to read the value into.
* @param stream A #VFSFile object representing the stream.
* @return TRUE if read was succesful, FALSE if there was an error.
*/
EXPORT bool_t vfs_fget_le32(uint32_t *value, VFSFile *stream)
{
uint32_t tmp;
if (vfs_fread(&tmp, sizeof(tmp), 1, stream) != 1)
return FALSE;
*value = GUINT32_FROM_LE(tmp);
return TRUE;
}
开发者ID:umurkontaci,项目名称:audacious,代码行数:15,代码来源:vfs_common.c
示例19: __attribute__
/**
* unzip_file:
* @zip_file: pointer to start of compressed data
* @unzip_size: the size of the compressed data block
*
* Returns a pointer to uncompressed data (maybe NULL)
*/
void *unzip_file(gchar *zip_file, gulong *unzip_size)
{
void *unzip_data = NULL;
#ifndef HAVE_LIBZ
goto end;
#else
gchar *zip_data;
struct _lfh {
guint32 sig;
guint16 extract_version;
guint16 flags;
guint16 comp_method;
guint16 time;
guint16 date;
guint32 crc_32;
guint32 compressed_size;
guint32 uncompressed_size;
guint16 filename_len;
guint16 extra_field_len;
} __attribute__ ((__packed__)) *local_file_header = NULL;
local_file_header = (struct _lfh *) zip_file;
if (GUINT32_FROM_LE(local_file_header->sig) != 0x04034b50) {
g_warning("%s(): wrong format", __PRETTY_FUNCTION__);
g_free(unzip_data);
goto end;
}
zip_data = zip_file + sizeof(struct _lfh)
+ GUINT16_FROM_LE(local_file_header->filename_len)
+ GUINT16_FROM_LE(local_file_header->extra_field_len);
gulong uncompressed_size = GUINT32_FROM_LE(local_file_header->uncompressed_size);
unzip_data = g_malloc(uncompressed_size);
if (!(*unzip_size = uncompress_data(unzip_data, uncompressed_size, zip_data, GUINT32_FROM_LE(local_file_header->compressed_size)))) {
g_free(unzip_data);
unzip_data = NULL;
goto end;
}
#endif
end:
return(unzip_data);
}
开发者ID:gdt,项目名称:viking,代码行数:52,代码来源:compression.c
示例20: sizeof
static struct fp_print_data *fpi_print_data_from_fp2_data(unsigned char *buf,
size_t buflen)
{
size_t total_data_len, item_len;
struct fp_print_data *data;
struct fp_print_data_item *item;
struct fpi_print_data_fp2 *raw = (struct fpi_print_data_fp2 *) buf;
unsigned char *raw_buf;
struct fpi_print_data_item_fp2 *raw_item;
total_data_len = buflen - sizeof(*raw);
data = print_data_new(GUINT16_FROM_LE(raw->driver_id),
GUINT32_FROM_LE(raw->devtype), raw->data_type);
raw_buf = raw->data;
while (total_data_len) {
if (total_data_len < sizeof(*raw_item))
break;
total_data_len -= sizeof(*raw_item);
raw_item = (struct fpi_print_data_item_fp2 *)raw_buf;
item_len = GUINT32_FROM_LE(raw_item->length);
fp_dbg("item len %d, total_data_len %d", item_len, total_data_len);
if (total_data_len < item_len) {
fp_err("corrupted fingerprint data");
break;
}
total_data_len -= item_len;
item = fpi_print_data_item_new(item_len);
/* FIXME: fp_print_data->data content is not endianess agnostic */
memcpy(item->data, raw_item->data, item_len);
data->prints = g_slist_prepend(data->prints, item);
raw_buf += sizeof(*raw_item);
raw_buf += item_len;
}
if (g_slist_length(data->prints) == 0) {
fp_print_data_free(data);
data = NULL;
}
return data;
}
开发者ID:anarsoul,项目名称:libfprint,代码行数:45,代码来源:data.c
注:本文中的GUINT32_FROM_LE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论