req = *(GIsiRequest **)ret;
- if (req->func) {
- bool handled;
-
- handled = req->func(client, msg + 1, len - 1, obj, req->data);
- if (!handled)
- return;
- }
- g_isi_request_cancel(req);
+ if (!req->func || req->func(client, msg + 1, len - 1, obj, req->data))
+ g_isi_request_cancel(req);
}
/* Data callback for both responses and indications */
#endif
#include <stdint.h>
-#include <stdbool.h>
#include <gisi/modem.h>
struct _GIsiClient;
struct _GIsiRequest;
typedef struct _GIsiRequest GIsiRequest;
-typedef void (*GIsiVerifyFunc)(GIsiClient *client, bool alive,
+typedef void (*GIsiVerifyFunc)(GIsiClient *client, gboolean alive,
uint16_t object, void *opaque);
-typedef bool (*GIsiResponseFunc)(GIsiClient *client,
- const void *restrict data, size_t len,
- uint16_t object, void *opaque);
+typedef gboolean (*GIsiResponseFunc)(GIsiClient *client,
+ const void *restrict data, size_t len,
+ uint16_t object, void *opaque);
typedef void (*GIsiIndicationFunc) (GIsiClient *client,
- const void *restrict data, size_t len,
- uint16_t object, void *opaque);
+ const void *restrict data, size_t len,
+ uint16_t object, void *opaque);
GIsiClient *g_isi_client_create(GIsiModem *modem, uint8_t resource);
GIsiResponseFunc func, void *opaque);
struct iovec;
GIsiRequest *g_isi_request_vmake(GIsiClient *client, const struct iovec *iov,
- size_t iovlen, unsigned timeout,
- GIsiResponseFunc func, void *opaque);
+ size_t iovlen, unsigned timeout,
+ GIsiResponseFunc func, void *opaque);
void g_isi_request_cancel(GIsiRequest *req);
#include <config.h>
#endif
-#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <glib.h>
}
void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const void *restrict data,
- size_t len, size_t used, bool longhdr,
+ size_t len, size_t used, gboolean longhdr,
uint16_t sub_blocks)
{
if (!data)
iter->start = (uint8_t *)data + used;
iter->end = iter->start + len;
- iter->longhdr = false;
+ iter->longhdr = FALSE;
iter->sub_blocks = len > used ? iter->start[-1] : 0;
}
-bool g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter)
+gboolean g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter)
{
if (!iter)
- return false;
+ return FALSE;
if (iter->sub_blocks == 0)
- return false;
+ return FALSE;
if (iter->start + (iter->longhdr ? 4 : 2) > iter->end)
- return false;
+ return FALSE;
if (iter->start + g_isi_sb_iter_get_len(iter) > iter->end)
- return false;
+ return FALSE;
- return true;
+ return TRUE;
}
int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter)
return iter->start[1];
}
-bool g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
void **data, unsigned pos)
{
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|| iter->start + pos > iter->end)
- return false;
+ return FALSE;
*data = (void *)iter->start + pos;
- return true;
+ return TRUE;
}
-bool g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
uint8_t *byte, unsigned pos)
{
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|| iter->start + pos > iter->end)
- return false;
+ return FALSE;
*byte = iter->start[pos];
- return true;
+ return TRUE;
}
-bool g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
uint16_t *word, unsigned pos)
{
uint16_t val;
if (pos + 1 > g_isi_sb_iter_get_len(iter))
- return false;
+ return FALSE;
memcpy(&val, iter->start + pos, sizeof(uint16_t));
*word = ntohs(val);
- return true;
+ return TRUE;
}
-bool g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
- uint32_t *dword, unsigned pos)
+gboolean g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
+ uint32_t *dword, unsigned pos)
{
uint32_t val;
if (pos + 3 > g_isi_sb_iter_get_len(iter))
- return false;
+ return FALSE;
memcpy(&val, iter->start + pos, sizeof(uint32_t));
*dword = ntohl(val);
- return true;
+ return TRUE;
}
-bool g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
char *mcc, char *mnc, unsigned pos)
{
if (pos + 2 > g_isi_sb_iter_get_len(iter))
- return false;
+ return FALSE;
bcd_to_mccmnc(iter->start + pos, mcc, mnc);
- return true;
+ return TRUE;
}
-bool g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
char **utf8, size_t len, unsigned pos)
{
uint8_t *ucs2 = NULL;
if (pos > g_isi_sb_iter_get_len(iter))
- return false;
+ return FALSE;
if (!utf8 || len == 0 || pos + len > g_isi_sb_iter_get_len(iter))
- return false;
+ return FALSE;
ucs2 = iter->start + pos;
if (ucs2 + len > iter->end)
- return false;
+ return FALSE;
*utf8 = g_convert((const char *)ucs2, len, "UTF-8//TRANSLIT", "UCS-2BE",
NULL, NULL, NULL);
return *utf8 != NULL;
}
-bool g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
char **latin, size_t len, unsigned pos)
{
uint8_t *str = NULL;
if (pos > g_isi_sb_iter_get_len(iter))
- return false;
+ return FALSE;
if (!latin || len == 0 || pos + len > g_isi_sb_iter_get_len(iter))
- return false;
+ return FALSE;
str = iter->start + pos;
if (str + len > iter->end)
- return false;
+ return FALSE;
*latin = g_strndup((char *)str, len);
return *latin != NULL;
}
-bool g_isi_sb_iter_next(GIsiSubBlockIter *iter)
+gboolean g_isi_sb_iter_next(GIsiSubBlockIter *iter)
{
uint8_t len = g_isi_sb_iter_get_len(iter);
len = iter->longhdr ? 4 : 2;
if (iter->sub_blocks == 0)
- return false;
+ return FALSE;
if (iter->start + len > iter->end)
- return false;
+ return FALSE;
iter->start += len;
iter->sub_blocks--;
- return true;
+ return TRUE;
}
#endif
#include <stdint.h>
-#include <stdbool.h>
struct _GIsiSubBlockIter {
uint8_t *start;
void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter,
const void *restrict data,
size_t len, size_t used,
- bool longhdr,
+ gboolean longhdr,
uint16_t sub_blocks);
-bool g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter);
+gboolean g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter);
-bool g_isi_sb_iter_next(GIsiSubBlockIter *iter);
+gboolean g_isi_sb_iter_next(GIsiSubBlockIter *iter);
int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter);
size_t g_isi_sb_iter_get_len(const GIsiSubBlockIter *iter);
-bool g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
void **data, unsigned pos);
-bool g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
uint8_t *byte, unsigned pos);
-bool g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
uint16_t *word, unsigned pos);
-bool g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
- uint32_t *dword, unsigned pos);
-bool g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
+ uint32_t *dword, unsigned pos);
+gboolean g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
char *mcc, char *mnc, unsigned pos);
-bool g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
char **utf8, size_t len, unsigned pos);
-bool g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
+gboolean g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
char **ascii, size_t len, unsigned pos);
#ifdef __cplusplus
#include <config.h>
#endif
-#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
*
*/
-#include <stdbool.h>
#include <stdint.h>
#include <gisi/modem.h>
#endif
#include <stdint.h>
-#include <stdbool.h>
#include <errno.h>
#include <glib.h>
#include "client.h"
void *opaque;
int error;
uint8_t handle;
- bool enabled;
- bool enabling;
+ gboolean enabled;
+ gboolean enabling;
};
static int g_isi_pipe_error(uint8_t code)
pipe->error_handler(pipe);
}
-static bool g_isi_pipe_created(GIsiClient *client,
- const void *restrict data, size_t len,
- uint16_t object, void *opaque)
+static gboolean g_isi_pipe_created(GIsiClient *client,
+ const void *restrict data, size_t len,
+ uint16_t object, void *opaque)
{
GIsiPipe *pipe = opaque;
const isi_pipe_resp_t *resp = data;
if (len < 5 ||
resp->cmd != PNS_PIPE_CREATE_RESP)
- return false;
+ return FALSE;
if (resp->pipe_handle != PN_PIPE_INVALID_HANDLE) {
pipe->handle = resp->pipe_handle;
pipe->handler(pipe);
} else
g_isi_pipe_handle_error(pipe, resp->error_code);
- return true;
+ return TRUE;
}
/**
pipe->handler = created;
pipe->error_handler = NULL;
pipe->error = 0;
- pipe->enabling = false;
- pipe->enabled = false;
+ pipe->enabling = FALSE;
+ pipe->enabled = FALSE;
pipe->handle = PN_PIPE_INVALID_HANDLE;
if (pipe->client == NULL ||
return resp;
}
-static bool g_isi_pipe_enabled(GIsiClient *client,
- const void *restrict data, size_t len,
- uint16_t object, void *opaque)
+static gboolean g_isi_pipe_enabled(GIsiClient *client,
+ const void *restrict data, size_t len,
+ uint16_t object, void *opaque)
{
GIsiPipe *pipe = opaque;
const isi_pipe_resp_t *resp;
resp = g_isi_pipe_check_resp(pipe, PNS_PIPE_ENABLE_RESP, data, len);
if (!resp)
- return false;
+ return FALSE;
g_isi_pipe_handle_error(pipe, resp->error_code);
- pipe->enabling = false;
+ pipe->enabling = FALSE;
if (!pipe->error)
- pipe->enabled = true;
- return true;
+ pipe->enabled = TRUE;
+ return TRUE;
}
static GIsiRequest *g_isi_pipe_enable(GIsiPipe *pipe)
if (pipe->handle != PN_PIPE_INVALID_HANDLE)
g_isi_pipe_enable(pipe);
else
- pipe->enabling = true;
+ pipe->enabling = TRUE;
return 0;
}
/* Not very useful, it will never have time to trigger */
-static bool g_isi_pipe_removed(GIsiClient *client,
- const void *restrict data, size_t len,
- uint16_t object, void *opaque)
+static gboolean g_isi_pipe_removed(GIsiClient *client,
+ const void *restrict data, size_t len,
+ uint16_t object, void *opaque)
{
GIsiPipe *pipe = opaque;
const isi_pipe_resp_t *resp;
resp = g_isi_pipe_check_resp(pipe, PNS_PIPE_REMOVE_RESP, data, len);
if (!resp)
- return false;
+ return FALSE;
pipe->handle = PN_PIPE_INVALID_HANDLE;
pipe->error = -EPIPE;
- return true;
+ return TRUE;
}
#endif
#include <stdint.h>
-#include <stdbool.h>
#include <gisi/modem.h>
struct _GIsiServer;
struct _GIsiIncoming;
typedef struct _GIsiIncoming GIsiIncoming;
-typedef bool (*GIsiRequestFunc)(GIsiServer *server,
- const void *restrict data, size_t len,
- GIsiIncoming *, void *opaque);
+typedef gboolean (*GIsiRequestFunc)(GIsiServer *server,
+ const void *restrict data, size_t len,
+ GIsiIncoming *, void *opaque);
GIsiServer *g_isi_server_create(GIsiModem *modem, uint8_t resource,
uint8_t major, uint8_t minor);
#endif
#include <stdint.h>
-#include <stdbool.h>
#include <glib.h>
#include "client.h"
void *data;
};
-static bool verify_cb(GIsiClient *client, const void *restrict data,
- size_t len, uint16_t object, void *opaque)
+static gboolean verify_cb(GIsiClient *client, const void *restrict data,
+ size_t len, uint16_t object, void *opaque)
{
const uint8_t *msg = data;
struct verify_data *vd = opaque;
GIsiVerifyFunc func = vd->func;
- bool alive = false;
+ gboolean alive = FALSE;
if (!msg)
goto out;
if (msg[1] == COMM_ISI_VERSION_GET_RESP && len >= 4) {
g_isi_version_set(client, msg[2], msg[3]);
- alive = true;
+ alive = TRUE;
goto out;
}
if (msg[1] != COMM_ISA_ENTITY_NOT_REACHABLE_RESP)
- alive = true;
+ alive = TRUE;
out:
if (func)
func(client, alive, object, vd->data);
g_free(vd);
- return true;
+ return TRUE;
}
/**