xsettings: Use glib byte order functions

This commit is contained in:
Benjamin Otte 2013-02-02 19:10:02 +01:00
parent c1a4a1da10
commit d7ea5b5266
3 changed files with 6 additions and 20 deletions

View File

@ -95,8 +95,6 @@ ignore_errors (Display *display, XErrorEvent *event)
return True;
}
static char local_byte_order = '\0';
#define BYTES_LEFT(buffer) ((buffer)->data + (buffer)->len - (buffer)->pos)
static XSettingsResult
@ -111,10 +109,10 @@ fetch_card16 (XSettingsBuffer *buffer,
x = *(CARD16 *)buffer->pos;
buffer->pos += 2;
if (buffer->byte_order == local_byte_order)
*result = x;
if (buffer->byte_order == MSBFirst)
*result = GUINT16_FROM_BE (x);
else
*result = (x << 8) | (x >> 8);
*result = GUINT16_FROM_LE (x);
return XSETTINGS_SUCCESS;
}
@ -145,10 +143,10 @@ fetch_card32 (XSettingsBuffer *buffer,
x = *(CARD32 *)buffer->pos;
buffer->pos += 4;
if (buffer->byte_order == local_byte_order)
*result = x;
if (buffer->byte_order == MSBFirst)
*result = GUINT32_FROM_BE (x);
else
*result = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
*result = GUINT32_FROM_LE (x);
return XSETTINGS_SUCCESS;
}
@ -180,8 +178,6 @@ parse_settings (unsigned char *data,
CARD32 i;
XSettingsSetting *setting = NULL;
local_byte_order = xsettings_byte_order ();
buffer.pos = buffer.data = data;
buffer.len = len;

View File

@ -149,10 +149,3 @@ xsettings_list_lookup (XSettingsList *list,
return g_hash_table_lookup (list, name);
}
char
xsettings_byte_order (void)
{
CARD32 myint = 0x01020304;
return (*(char *)&myint == 1) ? MSBFirst : LSBFirst;
}

View File

@ -32,7 +32,6 @@ extern "C" {
/* Renames for GDK inclusion */
#define xsettings_byte_order _gdk_x11_xsettings_byte_order
#define xsettings_client_destroy _gdk_x11_xsettings_client_destroy
#define xsettings_client_get_setting _gdk_x11_xsettings_client_get_setting
#define xsettings_client_new _gdk_x11_xsettings_client_new
@ -110,8 +109,6 @@ XSettingsResult xsettings_list_insert (XSettingsList **list,
XSettingsSetting *xsettings_list_lookup (XSettingsList *list,
const char *name);
char xsettings_byte_order (void);
#define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1)))
#ifdef __cplusplus