本文整理汇总了C++中GUINT16_FROM_LE函数的典型用法代码示例。如果您正苦于以下问题:C++ GUINT16_FROM_LE函数的具体用法?C++ GUINT16_FROM_LE怎么用?C++ GUINT16_FROM_LE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GUINT16_FROM_LE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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]);
}
示例3: ico_write_int16
static gint
ico_write_int16 (FILE *fp,
guint16 *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] = GUINT16_FROM_LE (data[i]);
#endif
ico_write_int8 (fp, (guint8 *) data, count * 2);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
/* Put it back like we found it */
for (i = 0; i < count; i++)
data[i] = GUINT16_FROM_LE (data[i]);
#endif
}
return total * 2;
}
示例4: wav_open
static gint wav_open(void)
{
memcpy(&header.main_chunk, "RIFF", 4);
header.length = GUINT32_TO_LE(0);
memcpy(&header.chunk_type, "WAVE", 4);
memcpy(&header.sub_chunk, "fmt ", 4);
header.sc_len = GUINT32_TO_LE(16);
header.format = GUINT16_TO_LE(1);
header.modus = GUINT16_TO_LE(input.channels);
header.sample_fq = GUINT32_TO_LE(input.frequency);
if (input.format == FMT_U8 || input.format == FMT_S8)
header.bit_p_spl = GUINT16_TO_LE(8);
else
header.bit_p_spl = GUINT16_TO_LE(16);
header.byte_p_sec = GUINT32_TO_LE(input.frequency * header.modus * (GUINT16_FROM_LE(header.bit_p_spl) / 8));
header.byte_p_spl = GUINT16_TO_LE((GUINT16_FROM_LE(header.bit_p_spl) / (8 / input.channels)));
memcpy(&header.data_chunk, "data", 4);
header.data_length = GUINT32_TO_LE(0);
if (vfs_fwrite (& header, 1, sizeof header, output_file) != sizeof header)
return 0;
written = 0;
return 1;
}
示例5: gfire_read_attrib
int gfire_read_attrib(GList **values, guint8 *buffer, int packet_len, const char *name,
gboolean dynamic, gboolean binary, int bytes_to_first, int bytes_between, int vallen)
{
int index = 0; int i=0; int ali = 0; int alen = 0;
gchar tmp[100];
guint16 numitems = 0; guint16 attr_len = 0;
guint8 *str;
memset(tmp, 0x00, 100);
alen = strlen(name);
memcpy(tmp, buffer + index, alen);
index += strlen(name);
if ( 0 == g_ascii_strcasecmp(name, tmp)) {
index += 2;
memcpy(&numitems, buffer + index, 2);
numitems = GUINT16_FROM_LE(numitems);
index += 2;
purple_debug(PURPLE_DEBUG_MISC, "gfire", "Looking for %d %s's in packet.\n", numitems, NN(name));
} else {
purple_debug(PURPLE_DEBUG_MISC, "gfire", "ERROR: %s signature isn't in the correct position.\n", NN(name));
return -1;
}
/* if we are copying a string make sure we have a space for the trailing \0 */
if (binary) ali = 0;
else ali = 1;
for (i = 0; i < numitems; i++) {
if (dynamic) {
memcpy(&attr_len, buffer + index, 2);
attr_len = GUINT16_FROM_LE(attr_len); index+=2;
} else attr_len = vallen;
if (dynamic && (attr_len == 0)) str = NULL;
else {
str = g_malloc0(sizeof(char) * (attr_len+ali));
memcpy(str, buffer + index, attr_len);
if (!binary) str[attr_len] = 0x00;
}
index += attr_len;
*values = g_list_append(*values,(gpointer *)str);
if ( index > packet_len ) {
purple_debug(PURPLE_DEBUG_MISC, "gfire", "ERROR: pkt 131: more friends then packet length.\n");
return -1;
}
}
return index;
}
示例6: 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);
}
示例7: deserialize_buffer
static gboolean
deserialize_buffer (SBlbDeserializer *deserializer, FlowPacketQueue *packet_queue, FlowPad *output_pad)
{
SBlbDeserializerPrivate *priv = deserializer->priv;
union
{
guint16 u16;
guchar c [2];
}
u;
guchar *buf;
if (priv->buffer_size < 0)
{
if (!pop_bytes_and_propagate_objects ((FlowElement *) deserializer, packet_queue, output_pad, u.c, 2))
return TRUE;
u.u16 = GUINT16_FROM_LE (u.u16);
priv->buffer_size = u.u16;
}
buf = alloca (priv->buffer_size);
if (!pop_bytes_and_propagate_objects ((FlowElement *) deserializer, packet_queue, output_pad, buf, priv->buffer_size))
return TRUE;
flow_pad_push (output_pad, flow_packet_new (FLOW_PACKET_FORMAT_BUFFER, buf, priv->buffer_size));
return FALSE;
}
示例8: deserialize_begin
static gboolean
deserialize_begin (SBlbDeserializer *deserializer, FlowPacketQueue *packet_queue, FlowPad *output_pad)
{
SBlbDeserializerPrivate *priv = deserializer->priv;
union
{
guint16 id;
guchar c [2];
}
u;
if (!pop_bytes_and_propagate_objects ((FlowElement *) deserializer, packet_queue, output_pad, u.c, 2))
return FALSE;
u.id = GUINT16_FROM_LE (u.id);
if (u.id == 65535)
{
priv->current_type = BUFFER_TYPE;
priv->buffer_size = -1;
}
else
{
priv->current_type = sblb_type_id_to_gtype (u.id);
if (priv->current_type == G_TYPE_INVALID)
{
g_warning ("Error deserializing: Invalid message type %d.", u.id);
return TRUE;
}
priv->current_context = flow_serializable_deserialize_begin (priv->current_type);
}
return TRUE;
}
示例9: msn_read16le
guint16
msn_read16le(const char *buf)
{
guint16 val;
memcpy(&val, buf, sizeof(val));
return GUINT16_FROM_LE(val);
}
示例10: microprof_read_data_field
static GwyDataField*
microprof_read_data_field(const MicroProfFile *mfile,
const guchar *buffer)
{
const guint16 *d16 = (const guint16*)buffer;
GwyDataField *dfield;
GwySIUnit *siunit;
gdouble *d;
guint xres, yres, i, j;
xres = mfile->xres;
yres = mfile->yres;
dfield = gwy_data_field_new(xres, yres,
mfile->xrange, mfile->yrange, FALSE);
d = gwy_data_field_get_data(dfield);
for (i = 0; i < yres; i++) {
for (j = 0; j < xres; j++) {
d[(yres-1 - i)*xres + j] = mfile->zscale*GUINT16_FROM_LE(*d16);
d16++;
}
}
siunit = gwy_data_field_get_si_unit_xy(dfield);
gwy_si_unit_set_from_string(siunit, "m");
siunit = gwy_data_field_get_si_unit_z(dfield);
gwy_si_unit_set_from_string(siunit, "m");
return dfield;
}
示例11: convert_stereo_to_mono_u16le
static int convert_stereo_to_mono_u16le(struct xmms_convert_buffers* buf, void **data, int length)
{
guint16 *output = *data, *input = *data;
int i;
for (i = 0; i < length / 4; i++)
{
guint32 tmp;
guint16 stmp;
tmp = GUINT16_FROM_LE(*input);
input++;
tmp += GUINT16_FROM_LE(*input);
input++;
stmp = tmp / 2;
*output++ = GUINT16_TO_LE(stmp);
}
return length / 2;
}
示例12: vfs_fget_le16
/**
* Reads an unsigned 16-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_le16(uint16_t *value, VFSFile *stream)
{
uint16_t tmp;
if (vfs_fread(&tmp, sizeof(tmp), 1, stream) != 1)
return FALSE;
*value = GUINT16_FROM_LE(tmp);
return TRUE;
}
示例13: __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);
}
示例14: koneplus_rmp_macro_key_info_new
KoneplusRmpMacroKeyInfo *koneplus_rmp_macro_key_info_v1_to_koneplus_rmp_macro_key_info(KoneplusRmpMacroKeyInfoV1 const *v1) {
KoneplusRmpMacroKeyInfo *result;
result = koneplus_rmp_macro_key_info_new();
result->button_number = v1->button_number;
result->type = v1->type;
koneplus_rmp_macro_key_info_set_talk_device(result, GUINT16_FROM_LE(v1->talk_device));
koneplus_rmp_macro_key_info_set_macroset_name(result, (gchar const *)v1->macroset_name);
koneplus_rmp_macro_key_info_set_macro_name(result, (gchar const *)v1->macro_name);
koneplus_rmp_macro_key_info_set_loop(result, GUINT32_FROM_LE(v1->loop));
koneplus_rmp_macro_key_info_set_count(result, GUINT16_FROM_LE(v1->count));
memcpy(&result->keystrokes[0], &v1->keystrokes[0], sizeof(result->keystrokes));
koneplus_rmp_macro_key_info_set_timer_length(result, GUINT32_FROM_LE(v1->timer_length));
koneplus_rmp_macro_key_info_set_timer_name(result, (gchar const *)v1->timer_name);
koneplus_rmp_macro_key_info_set_filename(result, (gchar const *)v1->filename);
return result;
}
示例15: GetWORD
static WORD
GetWORD (int position, BYTE *data)
{
WORD *value = (WORD*)(data + position);
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
return GUINT16_FROM_LE (*value);
#else
return *value;
#endif
}