wmc: remove usage of glib

People have asked for leaner builds and	glib isn't strictly
required for the core library.
This commit is contained in:
Dan Williams
2012-01-03 00:12:36 -06:00
parent 267b83ae27
commit 1e1c8a5ae4
8 changed files with 196 additions and 185 deletions
+17 -17
View File
@@ -27,7 +27,7 @@
/**********************************************************************/
static int
check_command (const char *buf, gsize len, u_int8_t cmd, size_t min_len)
check_command (const char *buf, size_t len, u_int8_t cmd, size_t min_len)
{
if (len < 1) {
wmc_err (0, "Zero-length response");
@@ -95,9 +95,9 @@ wmc_cmd_init_new (char *buf, size_t buflen, int wmc2)
}
WmcResult *
wmc_cmd_init_result (const char *buf, gsize buflen, int wmc2)
wmc_cmd_init_result (const char *buf, size_t buflen, int wmc2)
{
g_return_val_if_fail (buf != NULL, NULL);
wmc_return_val_if_fail (buf != NULL, NULL);
if (wmc2) {
if (check_command (buf, buflen, WMC_CMD_INIT, sizeof (WmcCmdInit2Rsp)) < 0)
@@ -127,14 +127,14 @@ wmc_cmd_device_info_new (char *buf, size_t buflen)
}
WmcResult *
wmc_cmd_device_info_result (const char *buf, gsize buflen)
wmc_cmd_device_info_result (const char *buf, size_t buflen)
{
WmcResult *r = NULL;
WmcCmdDeviceInfoRsp *rsp = (WmcCmdDeviceInfoRsp *) buf;
WmcCmdDeviceInfo2Rsp *rsp2 = (WmcCmdDeviceInfo2Rsp *) buf;
char tmp[65];
g_return_val_if_fail (buf != NULL, NULL);
wmc_return_val_if_fail (buf != NULL, NULL);
if (check_command (buf, buflen, WMC_CMD_DEVICE_INFO, sizeof (WmcCmdDeviceInfo2Rsp)) < 0) {
rsp2 = NULL;
@@ -146,50 +146,50 @@ wmc_cmd_device_info_result (const char *buf, gsize buflen)
/* Manf */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp->manf) <= sizeof (tmp));
wmc_assert (sizeof (rsp->manf) <= sizeof (tmp));
memcpy (tmp, rsp->manf, sizeof (rsp->manf));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MANUFACTURER, tmp);
/* Model */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp->model) <= sizeof (tmp));
wmc_assert (sizeof (rsp->model) <= sizeof (tmp));
memcpy (tmp, rsp->model, sizeof (rsp->model));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MODEL, tmp);
/* Firmware revision */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp->fwrev) <= sizeof (tmp));
wmc_assert (sizeof (rsp->fwrev) <= sizeof (tmp));
memcpy (tmp, rsp->fwrev, sizeof (rsp->fwrev));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_FW_REVISION, tmp);
/* Hardware revision */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp->hwrev) <= sizeof (tmp));
wmc_assert (sizeof (rsp->hwrev) <= sizeof (tmp));
memcpy (tmp, rsp->hwrev, sizeof (rsp->hwrev));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_HW_REVISION, tmp);
if (rsp2) {
/* IMEI */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp2->imei) <= sizeof (tmp));
wmc_assert (sizeof (rsp2->imei) <= sizeof (tmp));
memcpy (tmp, rsp2->imei, sizeof (rsp2->imei));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_IMEI, tmp);
/* IMSI */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp2->iccid) <= sizeof (tmp));
wmc_assert (sizeof (rsp2->iccid) <= sizeof (tmp));
memcpy (tmp, rsp2->iccid, sizeof (rsp2->iccid));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_ICCID, tmp);
/* MCC */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp2->mcc) <= sizeof (tmp));
wmc_assert (sizeof (rsp2->mcc) <= sizeof (tmp));
memcpy (tmp, rsp2->mcc, sizeof (rsp2->mcc));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MCC, tmp);
/* MNC */
memset (tmp, 0, sizeof (tmp));
g_assert (sizeof (rsp2->mnc) <= sizeof (tmp));
wmc_assert (sizeof (rsp2->mnc) <= sizeof (tmp));
memcpy (tmp, rsp2->mnc, sizeof (rsp2->mnc));
wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MNC, tmp);
}
@@ -221,14 +221,14 @@ sanitize_dbm (u_int8_t in_dbm)
}
WmcResult *
wmc_cmd_status_result (const char *buf, gsize buflen)
wmc_cmd_status_result (const char *buf, size_t buflen)
{
WmcResult *r = NULL;
WmcCmdStatusRsp *rsp = (WmcCmdStatusRsp *) buf;
WmcCmdStatus2Rsp *rsp2 = (WmcCmdStatus2Rsp *) buf;
char tmp[65];
g_return_val_if_fail (buf != NULL, NULL);
wmc_return_val_if_fail (buf != NULL, NULL);
if (check_command (buf, buflen, WMC_CMD_STATUS, sizeof (WmcCmdStatus2Rsp)) < 0) {
rsp2 = NULL;
@@ -247,12 +247,12 @@ wmc_cmd_status_result (const char *buf, gsize buflen)
memset (tmp, 0, sizeof (tmp));
if (sanitize_dbm (rsp2->lte_dbm)) {
/* LTE operator name */
g_assert (sizeof (rsp2->lte_opname) <= sizeof (tmp));
wmc_assert (sizeof (rsp2->lte_opname) <= sizeof (tmp));
memcpy (tmp, rsp2->lte_opname, sizeof (rsp2->lte_opname));
wmc_result_add_string (r, WMC_CMD_STATUS_ITEM_OPNAME, tmp);
} else if (sanitize_dbm (rsp2->hdr_dbm) || sanitize_dbm (rsp2->cdma1x_dbm)) {
/* CDMA2000 operator name */
g_assert (sizeof (rsp2->cdma_opname) <= sizeof (tmp));
wmc_assert (sizeof (rsp2->cdma_opname) <= sizeof (tmp));
memcpy (tmp, rsp2->cdma_opname, sizeof (rsp2->cdma_opname));
wmc_result_add_string (r, WMC_CMD_STATUS_ITEM_OPNAME, tmp);
}
+1 -1
View File
@@ -106,7 +106,7 @@ val_new_u32 (const char *key, u_int32_t u)
return NULL;
v->key = strdup (key);
v->type = VAL_TYPE_U8;
v->type = VAL_TYPE_U32;
v->u.u32 = u;
return v;
}
+79 -78
View File
@@ -23,6 +23,7 @@
#include <string.h>
#include "utils.h"
#include "errors.h"
/* QCDM protocol frames are pseudo Async HDLC frames which end with a 3-byte
* trailer. This trailer consists of the 16-bit CRC of the frame plus an ending
@@ -32,7 +33,7 @@
*/
/* Table of CRCs for each possible byte, with a generator polynomial of 0x8408 */
const guint16 crc_table[256] = {
const u_int16_t crc_table[256] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
@@ -68,10 +69,10 @@ const guint16 crc_table[256] = {
};
/* Calculate the CRC for a buffer using a seed of 0xffff */
guint16
crc16 (const char *buffer, gsize len, guint16 seed)
u_int16_t
crc16 (const char *buffer, size_t len, u_int16_t seed)
{
guint16 crc = seed ? seed : 0xFFFF;
u_int16_t crc = seed ? seed : 0xFFFF;
while (len--)
crc = crc_table[(crc ^ *buffer++) & 0xff] ^ (crc >> 8);
@@ -84,21 +85,21 @@ crc16 (const char *buffer, gsize len, guint16 seed)
/* Performs DM escaping on inbuf putting the result into outbuf, and returns
* the final length of the buffer.
*/
gsize
size_t
hdlc_escape (const char *inbuf,
gsize inbuf_len,
gboolean escape_all_ctrl,
size_t inbuf_len,
wmcbool escape_all_ctrl,
char *outbuf,
gsize outbuf_len)
size_t outbuf_len)
{
const char *src = inbuf;
char *dst = outbuf;
size_t i = inbuf_len;
g_return_val_if_fail (inbuf != NULL, 0);
g_return_val_if_fail (inbuf_len > 0, 0);
g_return_val_if_fail (outbuf != NULL, 0);
g_return_val_if_fail (outbuf_len > inbuf_len, 0);
wmc_return_val_if_fail (inbuf != NULL, 0);
wmc_return_val_if_fail (inbuf_len > 0, 0);
wmc_return_val_if_fail (outbuf != NULL, 0);
wmc_return_val_if_fail (outbuf_len > inbuf_len, 0);
/* Since escaping potentially doubles the # of bytes, short-circuit the
* length check if destination buffer is clearly large enough. Note the
@@ -128,7 +129,7 @@ hdlc_escape (const char *inbuf,
src = inbuf;
i = inbuf_len;
while (i--) {
guint8 byte = (guint8) *src++;
u_int8_t byte = (u_int8_t) *src++;
if ( byte == DIAG_CONTROL_CHAR
|| byte == DIAG_ESC_CHAR
@@ -142,18 +143,18 @@ hdlc_escape (const char *inbuf,
return (dst - outbuf);
}
gsize
size_t
hdlc_unescape (const char *inbuf,
gsize inbuf_len,
size_t inbuf_len,
char *outbuf,
gsize outbuf_len,
gboolean *escaping)
size_t outbuf_len,
wmcbool *escaping)
{
size_t i, outsize;
g_return_val_if_fail (inbuf_len > 0, 0);
g_return_val_if_fail (outbuf_len >= inbuf_len, 0);
g_return_val_if_fail (escaping != NULL, 0);
wmc_return_val_if_fail (inbuf_len > 0, 0);
wmc_return_val_if_fail (outbuf_len >= inbuf_len, 0);
wmc_return_val_if_fail (escaping != NULL, 0);
for (i = 0, outsize = 0; i < inbuf_len; i++) {
if (*escaping) {
@@ -189,23 +190,23 @@ hdlc_unescape (const char *inbuf,
*
* Returns: size of the encapsulated data writted to @outbuf.
**/
gsize
size_t
hdlc_encapsulate_buffer (char *inbuf,
gsize cmd_len,
gsize inbuf_len,
guint16 crc_seed,
gboolean add_trailer,
gboolean escape_all_ctrl,
size_t cmd_len,
size_t inbuf_len,
u_int16_t crc_seed,
wmcbool add_trailer,
wmcbool escape_all_ctrl,
char *outbuf,
gsize outbuf_len)
size_t outbuf_len)
{
guint16 crc;
gsize escaped_len;
u_int16_t crc;
size_t escaped_len;
g_return_val_if_fail (inbuf != NULL, 0);
g_return_val_if_fail (cmd_len >= 1, 0);
g_return_val_if_fail (inbuf_len >= cmd_len + 2, 0); /* space for CRC */
g_return_val_if_fail (outbuf != NULL, 0);
wmc_return_val_if_fail (inbuf != NULL, 0);
wmc_return_val_if_fail (cmd_len >= 1, 0);
wmc_return_val_if_fail (inbuf_len >= cmd_len + 2, 0); /* space for CRC */
wmc_return_val_if_fail (outbuf != NULL, 0);
/* Add the CRC */
crc = crc16 (inbuf, cmd_len, crc_seed ? crc_seed : 0xFFFF);
@@ -213,7 +214,7 @@ hdlc_encapsulate_buffer (char *inbuf,
inbuf[cmd_len++] = (crc >> 8) & 0xFF;
escaped_len = hdlc_escape (inbuf, cmd_len, escape_all_ctrl, outbuf, outbuf_len);
g_return_val_if_fail (outbuf_len > escaped_len, 0);
wmc_return_val_if_fail (outbuf_len > escaped_len, 0);
if (add_trailer)
outbuf[escaped_len++] = DIAG_CONTROL_CHAR;
@@ -236,25 +237,25 @@ hdlc_encapsulate_buffer (char *inbuf,
*
* Returns: size of the encapsulated data writted to @outbuf.
*/
static gsize
static size_t
uml290_wmc_encapsulate (char *inbuf,
gsize cmd_len,
gsize inbuf_len,
size_t cmd_len,
size_t inbuf_len,
char *outbuf,
gsize outbuf_len)
size_t outbuf_len)
{
gsize encap_len;
gsize estimated_out_len;
size_t encap_len;
size_t estimated_out_len;
g_return_val_if_fail (inbuf != NULL, 0);
g_return_val_if_fail (cmd_len >= 1, 0);
g_return_val_if_fail (inbuf_len >= cmd_len + 2, 0); /* space for CRC */
g_return_val_if_fail (outbuf != NULL, 0);
wmc_return_val_if_fail (inbuf != NULL, 0);
wmc_return_val_if_fail (cmd_len >= 1, 0);
wmc_return_val_if_fail (inbuf_len >= cmd_len + 2, 0); /* space for CRC */
wmc_return_val_if_fail (outbuf != NULL, 0);
estimated_out_len = cmd_len + strlen (AT_WMC_PREFIX);
estimated_out_len += 3; /* CRC + trailer */
estimated_out_len += cmd_len * 1.3; /* escaping */
g_return_val_if_fail (outbuf_len > estimated_out_len, 0);
wmc_return_val_if_fail (outbuf_len > estimated_out_len, 0);
memcpy (outbuf, AT_WMC_PREFIX, strlen (AT_WMC_PREFIX));
@@ -283,18 +284,18 @@ uml290_wmc_encapsulate (char *inbuf,
*
* Returns: size of the encapsulated data writted to @outbuf.
*/
gsize
size_t
wmc_encapsulate (char *inbuf,
gsize cmd_len,
gsize inbuf_len,
size_t cmd_len,
size_t inbuf_len,
char *outbuf,
gsize outbuf_len,
gboolean uml290)
size_t outbuf_len,
wmcbool uml290)
{
g_return_val_if_fail (inbuf != NULL, 0);
g_return_val_if_fail (cmd_len >= 1, 0);
g_return_val_if_fail (inbuf_len >= cmd_len + 3, 0); /* space for CRC + trailer */
g_return_val_if_fail (outbuf != NULL, 0);
wmc_return_val_if_fail (inbuf != NULL, 0);
wmc_return_val_if_fail (cmd_len >= 1, 0);
wmc_return_val_if_fail (inbuf_len >= cmd_len + 3, 0); /* space for CRC + trailer */
wmc_return_val_if_fail (outbuf != NULL, 0);
if (uml290)
return uml290_wmc_encapsulate (inbuf, cmd_len, inbuf_len, outbuf, outbuf_len);
@@ -333,27 +334,27 @@ wmc_encapsulate (char *inbuf,
* all cases the caller should advance the buffer by the number of bytes
* returned in @out_used before calling this function again.
**/
gboolean
wmcbool
hdlc_decapsulate_buffer (const char *inbuf,
gsize inbuf_len,
gboolean check_known_crc,
guint16 known_crc,
size_t inbuf_len,
wmcbool check_known_crc,
u_int16_t known_crc,
char *outbuf,
gsize outbuf_len,
gsize *out_decap_len,
gsize *out_used,
gboolean *out_need_more)
size_t outbuf_len,
size_t *out_decap_len,
size_t *out_used,
wmcbool *out_need_more)
{
gboolean escaping = FALSE;
gsize i, pkt_len = 0, unesc_len;
guint16 crc, pkt_crc;
wmcbool escaping = FALSE;
size_t i, pkt_len = 0, unesc_len;
u_int16_t crc, pkt_crc;
g_return_val_if_fail (inbuf != NULL, FALSE);
g_return_val_if_fail (outbuf != NULL, FALSE);
g_return_val_if_fail (outbuf_len > 0, FALSE);
g_return_val_if_fail (out_decap_len != NULL, FALSE);
g_return_val_if_fail (out_used != NULL, FALSE);
g_return_val_if_fail (out_need_more != NULL, FALSE);
wmc_return_val_if_fail (inbuf != NULL, FALSE);
wmc_return_val_if_fail (outbuf != NULL, FALSE);
wmc_return_val_if_fail (outbuf_len > 0, FALSE);
wmc_return_val_if_fail (out_decap_len != NULL, FALSE);
wmc_return_val_if_fail (out_used != NULL, FALSE);
wmc_return_val_if_fail (out_need_more != NULL, FALSE);
*out_decap_len = 0;
*out_used = 0;
@@ -441,15 +442,15 @@ hdlc_decapsulate_buffer (const char *inbuf,
* all cases the caller should advance the buffer by the number of bytes
* returned in @out_used before calling this function again.
**/
gboolean
wmcbool
wmc_decapsulate (const char *inbuf,
gsize inbuf_len,
size_t inbuf_len,
char *outbuf,
gsize outbuf_len,
gsize *out_decap_len,
gsize *out_used,
gboolean *out_need_more,
gboolean uml290)
size_t outbuf_len,
size_t *out_decap_len,
size_t *out_used,
wmcbool *out_need_more,
wmcbool uml290)
{
return hdlc_decapsulate_buffer (inbuf, inbuf_len,
uml290, uml290 ? 0x3030 : 0,
+51 -43
View File
@@ -18,63 +18,71 @@
#ifndef UTILS_H
#define UTILS_H
#include <glib.h>
#include <sys/types.h>
typedef u_int8_t wmcbool;
#ifndef TRUE
#define TRUE ((u_int8_t) 1)
#endif
#ifndef FALSE
#define FALSE ((u_int8_t) 0)
#endif
#define DIAG_CONTROL_CHAR 0x7E
#define DIAG_TRAILER_LEN 3
/* Utility and testcase functions */
guint16 crc16 (const char *buffer, gsize len, guint16 seed);
u_int16_t crc16 (const char *buffer, size_t len, u_int16_t seed);
gsize hdlc_escape (const char *inbuf,
gsize inbuf_len,
gboolean escape_all_ctrl,
char *outbuf,
gsize outbuf_len);
size_t hdlc_escape (const char *inbuf,
size_t inbuf_len,
wmcbool escape_all_ctrl,
char *outbuf,
size_t outbuf_len);
gsize hdlc_unescape (const char *inbuf,
gsize inbuf_len,
char *outbuf,
gsize outbuf_len,
gboolean *escaping);
size_t hdlc_unescape (const char *inbuf,
size_t inbuf_len,
char *outbuf,
size_t outbuf_len,
wmcbool *escaping);
gsize hdlc_encapsulate_buffer (char *inbuf,
gsize cmd_len,
gsize inbuf_len,
guint16 crc_seed,
gboolean add_trailer,
gboolean escape_all_ctrl,
char *outbuf,
gsize outbuf_len);
size_t hdlc_encapsulate_buffer (char *inbuf,
size_t cmd_len,
size_t inbuf_len,
u_int16_t crc_seed,
wmcbool add_trailer,
wmcbool escape_all_ctrl,
char *outbuf,
size_t outbuf_len);
gboolean hdlc_decapsulate_buffer (const char *inbuf,
gsize inbuf_len,
gboolean check_known_crc,
guint16 known_crc,
char *outbuf,
gsize outbuf_len,
gsize *out_decap_len,
gsize *out_used,
gboolean *out_need_more);
wmcbool hdlc_decapsulate_buffer (const char *inbuf,
size_t inbuf_len,
wmcbool check_known_crc,
u_int16_t known_crc,
char *outbuf,
size_t outbuf_len,
size_t *out_decap_len,
size_t *out_used,
wmcbool *out_need_more);
/* Functions for actual communication */
gsize wmc_encapsulate (char *inbuf,
gsize cmd_len,
gsize inbuf_len,
char *outbuf,
gsize outbuf_len,
gboolean uml290);
size_t wmc_encapsulate (char *inbuf,
size_t cmd_len,
size_t inbuf_len,
char *outbuf,
size_t outbuf_len,
wmcbool uml290);
gboolean wmc_decapsulate (const char *inbuf,
gsize inbuf_len,
char *outbuf,
gsize outbuf_len,
gsize *out_decap_len,
gsize *out_used,
gboolean *out_need_more,
gboolean uml290);
wmcbool wmc_decapsulate (const char *inbuf,
size_t inbuf_len,
char *outbuf,
size_t outbuf_len,
size_t *out_decap_len,
size_t *out_used,
wmcbool *out_need_more,
wmcbool uml290);
#endif /* UTILS_H */
+20 -20
View File
@@ -36,12 +36,12 @@ typedef struct {
char *port;
int fd;
struct termios old_t;
gboolean debug;
gboolean uml290;
wmcbool debug;
wmcbool uml290;
} TestComData;
gpointer
test_com_setup (const char *port, gboolean uml290, gboolean debug)
test_com_setup (const char *port, wmcbool uml290, wmcbool debug)
{
TestComData *d;
int ret;
@@ -93,10 +93,10 @@ test_com_teardown (gpointer user_data)
}
static void
print_buf (const char *detail, const char *buf, gsize len)
print_buf (const char *detail, const char *buf, size_t len)
{
int i = 0;
gboolean newline = FALSE;
wmcbool newline = FALSE;
g_print ("%s (%zu) ", detail, len);
for (i = 0; i < len; i++) {
@@ -112,15 +112,15 @@ print_buf (const char *detail, const char *buf, gsize len)
g_print ("\n");
}
static gboolean
static wmcbool
send_command (TestComData *d,
char *inbuf,
gsize inbuf_len,
gsize cmd_len)
size_t inbuf_len,
size_t cmd_len)
{
int status;
int eagain_count = 1000;
gsize i = 0, sendlen;
size_t i = 0, sendlen;
char sendbuf[600];
/* Encapsulate the data for the device */
@@ -152,8 +152,8 @@ send_command (TestComData *d,
return TRUE;
}
static gsize
wait_reply (TestComData *d, char *buf, gsize len)
static size_t
wait_reply (TestComData *d, char *buf, size_t len)
{
fd_set in;
int result;
@@ -161,7 +161,7 @@ wait_reply (TestComData *d, char *buf, gsize len)
char readbuf[1024];
ssize_t bytes_read;
int total = 0, retries = 0;
gsize decap_len = 0;
size_t decap_len = 0;
FD_ZERO (&in);
FD_SET (d->fd, &in);
@@ -182,8 +182,8 @@ wait_reply (TestComData *d, char *buf, gsize len)
retries++;
continue;
} else if (bytes_read == 1) {
gboolean more = FALSE, success;
gsize used = 0;
wmcbool more = FALSE, success;
size_t used = 0;
total++;
decap_len = 0;
@@ -229,11 +229,11 @@ void
test_com_init (void *f, void *data)
{
TestComData *d = data;
gboolean success;
wmcbool success;
char buf[512];
gint len;
WmcResult *result;
gsize reply_len;
size_t reply_len;
len = wmc_cmd_init_new (buf, sizeof (buf), d->uml290);
g_assert (len == 16);
@@ -256,12 +256,12 @@ void
test_com_device_info (void *f, void *data)
{
TestComData *d = data;
gboolean success;
wmcbool success;
char buf[1024];
const char *str, *str2;
gint len;
WmcResult *result;
gsize reply_len;
size_t reply_len;
len = wmc_cmd_device_info_new (buf, sizeof (buf));
g_assert (len == 2);
@@ -318,13 +318,13 @@ void
test_com_status (void *f, void *data)
{
TestComData *d = data;
gboolean success;
wmcbool success;
char buf[1024];
const char *str;
u_int8_t dbm;
gint len;
WmcResult *result;
gsize reply_len;
size_t reply_len;
len = wmc_cmd_status_new (buf, sizeof (buf));
g_assert (len == 2);
+3 -1
View File
@@ -18,7 +18,9 @@
#ifndef TEST_WMC_COM_H
#define TEST_WMC_COM_H
gpointer test_com_setup (const char *port, gboolean uml290, gboolean debug);
#include "utils.h"
gpointer test_com_setup (const char *port, wmcbool uml290, wmcbool debug);
void test_com_teardown (gpointer d);
void test_com_port_init (void *f, void *data);
+7 -7
View File
@@ -76,7 +76,7 @@ void
test_escape1 (void *f, void *data)
{
char escaped[1024];
gsize len;
size_t len;
/* Ensure that escaping in general works */
len = hdlc_escape (data1, sizeof (data1), FALSE, escaped, sizeof (escaped));
@@ -96,7 +96,7 @@ void
test_escape2 (void *f, void *data)
{
char escaped[1024];
gsize len;
size_t len;
/* Ensure that escaping data that doesn't need escaping works */
len = hdlc_escape (data2, sizeof (data2), FALSE, escaped, sizeof (escaped));
@@ -119,7 +119,7 @@ void
test_escape_ctrl (void *f, void *data)
{
char escaped[1024];
gsize len;
size_t len;
len = hdlc_escape (data_ctrl_src, sizeof (data_ctrl_src), TRUE, escaped, sizeof (escaped));
g_assert (len == sizeof (data_ctrl_expected));
@@ -131,8 +131,8 @@ test_escape_unescape (void *f, void *data)
{
char escaped[512];
char unescaped[512];
gsize len, unlen;
gboolean escaping = FALSE;
size_t len, unlen;
wmcbool escaping = FALSE;
/* Ensure that escaping data that needs escaping, and then unescaping it,
* produces the exact same data as was originally escaped.
@@ -149,8 +149,8 @@ test_escape_unescape_ctrl (void *f, void *data)
{
char escaped[512];
char unescaped[512];
gsize len, unlen;
gboolean escaping = FALSE;
size_t len, unlen;
wmcbool escaping = FALSE;
/* Ensure that escaping data that needs escaping, and then unescaping it,
* produces the exact same data as was originally escaped.
+18 -18
View File
@@ -46,11 +46,11 @@ static const char decap_inbuf[] = {
void
test_utils_decapsulate_basic_buffer (void *f, void *data)
{
gboolean success;
wmcbool success;
char outbuf[512];
gsize decap_len = 0;
gsize used = 0;
gboolean more = FALSE;
size_t decap_len = 0;
size_t used = 0;
wmcbool more = FALSE;
success = hdlc_decapsulate_buffer (decap_inbuf, sizeof (decap_inbuf),
FALSE, 0, outbuf, sizeof (outbuf),
@@ -71,7 +71,7 @@ test_utils_encapsulate_basic_buffer (void *f, void *data)
{
char cmdbuf[10];
char outbuf[512];
gsize encap_len = 0;
size_t encap_len = 0;
cmdbuf[0] = 0x4B; /* DIAG_CMD_SUBSYS */
cmdbuf[1] = 0x05; /* DIAG_SUBSYS_HDR */
@@ -93,11 +93,11 @@ static const char cns_inbuf[] = {
void
test_utils_decapsulate_sierra_cns (void *f, void *data)
{
gboolean success;
wmcbool success;
char outbuf[512];
gsize decap_len = 0;
gsize used = 0;
gboolean more = FALSE;
size_t decap_len = 0;
size_t used = 0;
wmcbool more = FALSE;
success = hdlc_decapsulate_buffer (cns_inbuf, sizeof (cns_inbuf),
FALSE, 0, outbuf, sizeof (outbuf),
@@ -123,7 +123,7 @@ test_utils_encapsulate_uml290_wmc1 (void *f, void *data)
{
char inbuf[512];
char outbuf[512];
gsize encap_len = 0;
size_t encap_len = 0;
memcpy (inbuf, uml290_encap_src, sizeof (uml290_encap_src));
encap_len = wmc_encapsulate (inbuf, sizeof (uml290_encap_src),
@@ -167,11 +167,11 @@ static const char uml290_expected[] = {
void
test_utils_decapsulate_uml290_wmc1 (void *f, void *data)
{
gboolean success;
wmcbool success;
char outbuf[512];
gsize decap_len = 0;
gsize used = 0;
gboolean more = FALSE;
size_t decap_len = 0;
size_t used = 0;
wmcbool more = FALSE;
success = hdlc_decapsulate_buffer (uml290_src, sizeof (uml290_src),
TRUE, 0x3030, outbuf, sizeof (outbuf),
@@ -205,11 +205,11 @@ static const char pc5740_expected[] = {
void
test_utils_decapsulate_pc5740_wmc1 (void *f, void *data)
{
gboolean success;
wmcbool success;
char outbuf[512];
gsize decap_len = 0;
gsize used = 0;
gboolean more = FALSE;
size_t decap_len = 0;
size_t used = 0;
wmcbool more = FALSE;
success = hdlc_decapsulate_buffer (pc5740_src, sizeof (pc5740_src),
FALSE, 0, outbuf, sizeof (outbuf),