本文整理汇总了C++中PUBNUB_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ PUBNUB_ASSERT函数的具体用法?C++ PUBNUB_ASSERT怎么用?C++ PUBNUB_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PUBNUB_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: prepare_port_and_hostname
static void prepare_port_and_hostname(pubnub_t *pb, uint16_t* p_port, char const** p_origin)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
PUBNUB_ASSERT_OPT((pb->state == PBS_READY) || (pb->state == PBS_WAIT_DNS_SEND));
*p_origin = PUBNUB_ORIGIN_SETTABLE ? pb->origin : PUBNUB_ORIGIN;
#if PUBNUB_USE_SSL
if (pb->flags.trySSL) {
PUBNUB_ASSERT(pb->options.useSSL);
*p_port = TLS_PORT;
}
#endif
#if PUBNUB_PROXY_API
switch (pb->proxy_type) {
case pbproxyHTTP_CONNECT:
if (!pb->proxy_tunnel_established) {
*p_origin = pb->proxy_hostname;
}
*p_port = pb->proxy_port;
break;
case pbproxyHTTP_GET:
*p_origin = pb->proxy_hostname;
*p_port = pb->proxy_port;
PUBNUB_LOG_TRACE("Using proxy: %s : %hu\n", *p_origin, *p_port);
break;
default:
break;
}
#endif
return;
}
开发者ID:sveljko,项目名称:c-core,代码行数:30,代码来源:pbpal_resolv_and_connect_sockets.c
示例2: pbpal_check_resolv_and_connect
enum pbpal_resolv_n_connect_result pbpal_check_resolv_and_connect(pubnub_t *pb)
{
#ifdef PUBNUB_CALLBACK_API
struct sockaddr_in dns_server;
struct sockaddr_in dest;
uint16_t port = HTTP_PORT;
pbpal_native_socket_t skt;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
PUBNUB_ASSERT_OPT(pb->state == PBS_WAIT_DNS_RCV);
#if PUBNUB_USE_SSL
if (pb->flags.trySSL) {
PUBNUB_ASSERT(pb->options.useSSL);
port = TLS_PORT;
}
#endif
#if PUBNUB_PROXY_API
if (pbproxyNONE != pb->proxy_type) {
port = pb->proxy_port;
}
#endif
skt = pb->pal.socket;
PUBNUB_ASSERT(SOCKET_INVALID != skt);
dns_server.sin_family = AF_INET;
dns_server.sin_port = htons(DNS_PORT);
get_dns_ip(&dns_server);
memset(&dest, '\0', sizeof dest);
switch (read_dns_response(skt, (struct sockaddr*)&dns_server, &dest)) {
case -1:
return pbpal_resolv_failed_rcv;
case +1:
return pbpal_resolv_rcv_wouldblock;
case 0:
break;
}
socket_close(skt);
return connect_TCP_socket(pb, dest, port);
#else
PUBNUB_UNUSED(pb);
/* Under regular BSD-ish sockets, this function should not be
called unless using async DNS, so this is an error */
return pbpal_connect_failed;
#endif /* PUBNUB_CALLBACK_API */
}
开发者ID:sveljko,项目名称:c-core,代码行数:50,代码来源:pbpal_resolv_and_connect_sockets.c
示例3: pubnub_init
pubnub_t* pubnub_init(pubnub_t *p, const char *publish_key, const char *subscribe_key)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(p));
pubnub_mutex_init(p->monitor);
pubnub_mutex_lock(p->monitor);
pbcc_init(&p->core, publish_key, subscribe_key);
if (PUBNUB_TIMERS_API) {
p->transaction_timeout_ms = PUBNUB_DEFAULT_TRANSACTION_TIMER;
#if defined(PUBNUB_DEFAULT_CONNECTION_TIMER)
p->connection_timeout_s = PUBNUB_DEFAULT_CONNECTION_TIMER;
#endif
#if defined(PUBNUB_CALLBACK_API)
p->previous = p->next = NULL;
#endif
}
#if defined(PUBNUB_CALLBACK_API)
p->cb = NULL;
p->user_data = NULL;
#endif
if (PUBNUB_ORIGIN_SETTABLE) {
p->origin = PUBNUB_ORIGIN;
}
p->state = PBS_IDLE;
p->trans = PBTT_NONE;
pbpal_init(p);
pubnub_mutex_unlock(p->monitor);
return p;
}
开发者ID:sjaeckel,项目名称:c-core,代码行数:31,代码来源:pubnub_coreapi.c
示例4: pbpal_resolv_and_connect
enum pubnub_res pbpal_resolv_and_connect(pubnub_t *pb)
{
struct freertos_sockaddr addr;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
PUBNUB_ASSERT_OPT((pb->state == PBS_IDLE) || (pb->state == PBS_WAIT_DNS));
addr.sin_port = FreeRTOS_htons(HTTP_PORT);
addr.sin_addr = FreeRTOS_gethostbyname(PUBNUB_ORIGIN_SETTABLE ? pb->origin : PUBNUB_ORIGIN);
if (addr.sin_addr == 0) {
return PNR_CONNECT_FAILED;
}
pb->pal.socket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP);
if (pb->pal.socket == SOCKET_INVALID) {
return PNR_CONNECT_FAILED;
}
if (FreeRTOS_connect(pb->pal.socket, &addr, sizeof addr) != 0) {
FreeRTOS_closesocket(pb->pal.socket);
pb->pal.socket = SOCKET_INVALID;
return PNR_CONNECT_FAILED;
}
{
TickType_t tmval = pdMS_TO_TICKS(pb->transaction_timeout_ms);
FreeRTOS_setsockopt(pb->pal.socket, 0, FREERTOS_SO_RCVTIMEO, &tmval, sizeof tmval);
}
return PNR_OK;
}
开发者ID:ramshenai,项目名称:c-core,代码行数:30,代码来源:pbpal_resolv_and_connect_freertos_tcp.c
示例5: pubnub_set_auth
void pubnub_set_auth(pubnub_t *pb, const char *auth)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pubnub_mutex_lock(pb->monitor);
pbcc_set_auth(&pb->core, auth);
pubnub_mutex_unlock(pb->monitor);
}
开发者ID:sjaeckel,项目名称:c-core,代码行数:7,代码来源:pubnub_coreapi.c
示例6: pubnub_free
int pubnub_free(pubnub_t* pb)
{
int result = -1;
PUBNUB_ASSERT(check_ctx_ptr(pb));
PUBNUB_LOG_TRACE("pubnub_free(%p)\n", pb);
pubnub_mutex_lock(pb->monitor);
pbnc_stop(pb, PNR_CANCELLED);
if (PBS_IDLE == pb->state) {
PUBNUB_LOG_TRACE("pubnub_free(%p) PBS_IDLE\n", pb);
pb->state = PBS_NULL;
#if defined(PUBNUB_CALLBACK_API)
pbntf_requeue_for_processing(pb);
pubnub_mutex_unlock(pb->monitor);
#else
pubnub_mutex_unlock(pb->monitor);
pballoc_free_at_last(pb);
#endif
result = 0;
}
else {
PUBNUB_LOG_TRACE("pubnub_free(%p) pb->state=%d\n", pb, pb->state);
pubnub_mutex_unlock(pb->monitor);
}
return result;
}
开发者ID:sveljko,项目名称:c-core,代码行数:30,代码来源:pubnub_alloc_std.c
示例7: save_socket
static void save_socket(struct SocketWatcherData *watcher, pubnub_t *pb)
{
size_t i;
pbpal_native_socket_t sockt = pubnub_get_native_socket(pb);
PUBNUB_ASSERT(watcher->apoll_size <= watcher->apoll_cap);
if (INVALID_SOCKET == sockt) {
return;
}
for (i = 0; i < watcher->apoll_size; ++i) {
PUBNUB_ASSERT_OPT(watcher->apoll[i].fd != sockt);
}
if (watcher->apoll_size == watcher->apoll_cap) {
size_t newcap = watcher->apoll_cap + 2;
WSAPOLLFD *npapoll = (WSAPOLLFD*)realloc(watcher->apoll, sizeof watcher->apoll[0] * newcap);
if (NULL == npapoll) {
return;
}
else {
pubnub_t **npapb = (pubnub_t**)realloc(watcher->apb, sizeof watcher->apb[0] * newcap);
watcher->apoll = npapoll;
if (NULL == npapb) {
return;
}
watcher->apb = npapb;
}
watcher->apoll_cap = newcap;
}
watcher->apoll[watcher->apoll_size].fd = sockt;
watcher->apoll[watcher->apoll_size].events = POLLOUT;
watcher->apb[watcher->apoll_size] = pb;
++watcher->apoll_size;
}
开发者ID:soumahorojean,项目名称:c-core,代码行数:35,代码来源:pubnub_ntf_callback_windows.c
示例8: pubnub_await
enum pubnub_res pubnub_await(pubnub_t* pb)
{
pbmsref_t t0;
enum pubnub_res result;
bool stopped = false;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pubnub_mutex_lock(pb->monitor);
t0 = pbms_start();
while (!pbnc_can_start_transaction(pb)) {
pbms_t delta;
pbnc_fsm(pb);
delta = pbms_elapsed(t0);
if (delta > pb->transaction_timeout_ms) {
if (!stopped) {
pbnc_stop(pb, PNR_TIMEOUT);
t0 = pbms_start();
stopped = true;
}
else {
break;
}
}
}
result = pb->core.last_result;
pubnub_mutex_unlock(pb->monitor);
return result;
}
开发者ID:sveljko,项目名称:c-core,代码行数:32,代码来源:pubnub_ntf_sync.c
示例9: pubnub_get_decrypted
enum pubnub_res pubnub_get_decrypted(pubnub_t *pb, char const* cipher_key, char *s, size_t *n)
{
char *msg;
size_t msg_len;
uint8_t decoded_msg[PUBNUB_BUF_MAXLEN];
pubnub_bymebl_t data = { (uint8_t*)s, *n };
pubnub_bymebl_t buffer = { decoded_msg, PUBNUB_BUF_MAXLEN };
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
PUBNUB_ASSERT_OPT(cipher_key != NULL);
PUBNUB_ASSERT_OPT(s != NULL);
PUBNUB_ASSERT_OPT(n != NULL);
msg = (char*)pubnub_get(pb);
if (NULL == msg) {
return PNR_INTERNAL_ERROR;
}
msg_len = strlen(msg);
if ((msg[0] != '"') || (msg[msg_len-1] != '"')) {
return PNR_FORMAT_ERROR;
}
msg[msg_len - 1] = '\0';
++msg;
pubnub_json_string_unescape_slash(msg);
if (0 != pubnub_decrypt_buffered(cipher_key, msg, &data, &buffer)) {
return PNR_INTERNAL_ERROR;
}
*n = data.size;
data.ptr[data.size] = '\0';
return PNR_OK;
}
开发者ID:sveljko,项目名称:c-core,代码行数:34,代码来源:pubnub_crypto.c
示例10: PUBNUB_ASSERT_OPT
pubnub_t *pubnub_timer_list_as_time_goes_by(pubnub_t **pplist, int time_passed_ms)
{
pubnub_t *list;
pubnub_t *expired_list = NULL;
PUBNUB_ASSERT_OPT(pplist != NULL);
PUBNUB_ASSERT_OPT(time_passed_ms > 0);
list = *pplist;
if (NULL == list) {
return NULL;
}
if (list->timeout_left_ms > time_passed_ms) {
list->timeout_left_ms -= time_passed_ms;
return NULL;
}
expired_list = list;
while (list->timeout_left_ms <= time_passed_ms) {
time_passed_ms -= list->timeout_left_ms;
if (NULL == list->next) {
*pplist = NULL;
return expired_list;
}
list = list->next;
}
list->timeout_left_ms -= time_passed_ms;
PUBNUB_ASSERT(list->previous != NULL);
list->previous->next = NULL;
list->previous = NULL;
*pplist = list;
return expired_list;
}
开发者ID:evanbeard,项目名称:c-core,代码行数:35,代码来源:pubnub_timer_list.c
示例11: pubnub_get_decrypted_alloc
pubnub_bymebl_t pubnub_get_decrypted_alloc(pubnub_t *pb, char const* cipher_key)
{
char *msg;
size_t msg_len;
pubnub_bymebl_t result = { NULL, 0 };
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
PUBNUB_ASSERT_OPT(cipher_key != NULL);
msg = (char*)pubnub_get(pb);
if (NULL == msg) {
return result;
}
msg_len = strlen(msg);
if ((msg[0] != '"') || (msg[msg_len-1] != '"')) {
return result;
}
msg[msg_len - 1] = '\0';
++msg;
pubnub_json_string_unescape_slash(msg);
result = pubnub_decrypt_alloc(cipher_key, msg);
if (NULL != result.ptr) {
result.ptr[result.size] = '\0';
}
return result;
}
开发者ID:sveljko,项目名称:c-core,代码行数:29,代码来源:pubnub_crypto.c
示例12: pubnub_register_callback
enum pubnub_res pubnub_register_callback(pubnub_t *pb, pubnub_callback_t cb, void *user_data)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pb->cb = cb;
pb->user_data = user_data;
return PNR_OK;
}
开发者ID:soumahorojean,项目名称:c-core,代码行数:7,代码来源:pubnub_ntf_callback_windows.c
示例13: pubnub_set_uuid
void pubnub_set_uuid(pubnub_t *pb, const char *uuid)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pubnub_mutex_lock(pb->monitor);
pbcc_set_uuid(&pb->core, uuid);
pubnub_mutex_unlock(pb->monitor);
}
开发者ID:sjaeckel,项目名称:c-core,代码行数:7,代码来源:pubnub_coreapi.c
示例14: pubnub_await
enum pubnub_res pubnub_await(pubnub_t *pb)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
while (pb->state != PBS_IDLE) {
pbnc_fsm(pb);
}
return pb->core.last_result;
}
开发者ID:suryasundarraj,项目名称:c-core,代码行数:8,代码来源:pubnub_ntf_sync.c
示例15: PUBNUB_ASSERT
char const *pubnub_get_origin(pubnub_t const *pb)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
if (PUBNUB_ORIGIN_SETTABLE) {
return pb->origin;
}
return PUBNUB_ORIGIN;
}
开发者ID:ramshenai,项目名称:c-core,代码行数:8,代码来源:pubnub_coreapi.c
示例16: pbpal_ntf_callback_remove_socket
void pbpal_ntf_callback_remove_socket(struct pbpal_poll_data* data, pubnub_t* pb)
{
size_t i;
int new_nfds = 0;
pbpal_native_socket_t sockt = pubnub_get_native_socket(pb);
PUBNUB_ASSERT_OPT(data != NULL);
if (INVALID_SOCKET == sockt) {
return;
}
PUBNUB_ASSERT(FD_ISSET(sockt, &data->exceptfds));
PUBNUB_ASSERT_EX(we_ve_got_ya(data, pb));
for (i = 0; i < data->size; ++i) {
pbpal_native_socket_t i_sckt = data->asocket[i];
PUBNUB_ASSERT(pubnub_get_native_socket(data->apb[i]) == data->asocket[i]);
if ((int)i_sckt > new_nfds) {
new_nfds = i_sckt;
}
if (data->apb[i] == pb) {
size_t to_move = data->size - i - 1;
if (to_move > 0) {
memmove(data->apb + i, data->apb + i + 1, sizeof data->apb[0] * to_move);
memmove(data->asocket + i,
data->asocket + i + 1,
sizeof data->asocket[0] * to_move);
}
--data->size;
break;
}
}
FD_CLR(sockt, &data->exceptfds);
FD_CLR(sockt, &data->writefds);
FD_CLR(sockt, &data->readfds);
for (; i < data->size; ++i) {
pbpal_native_socket_t i_sckt = data->asocket[i];
PUBNUB_ASSERT(pubnub_get_native_socket(data->apb[i]) == data->asocket[i]);
if ((int)i_sckt > new_nfds) {
new_nfds = i_sckt;
}
}
data->nfds = new_nfds;
}
开发者ID:sveljko,项目名称:c-core,代码行数:46,代码来源:pbpal_ntf_callback_poller_select.c
示例17: pubnub_cancel
void pubnub_cancel(pubnub_t *pb)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pubnub_mutex_lock(pb->monitor);
pbnc_stop(pb, PNR_CANCELLED);
pubnub_mutex_unlock(pb->monitor);
}
开发者ID:sjaeckel,项目名称:c-core,代码行数:8,代码来源:pubnub_coreapi.c
示例18: pubnub_last_result
enum pubnub_res pubnub_last_result(pubnub_t const *pb)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
if (pb->state != PBS_IDLE) {
pbnc_fsm((pubnub_t*)pb);
}
return pb->core.last_result;
}
开发者ID:suryasundarraj,项目名称:c-core,代码行数:8,代码来源:pubnub_ntf_sync.c
示例19: pubnub_free
int pubnub_free(pubnub_t *pb)
{
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
if (PBS_IDLE == pb->state) {
pb->state = PBS_NULL;
return 0;
}
return -1;
}
开发者ID:anovikov1984,项目名称:c-core,代码行数:9,代码来源:pubnub_alloc_static.c
示例20: pubnub_last_http_code
int pubnub_last_http_code(pubnub_t *pb)
{
int result;
PUBNUB_ASSERT(pb_valid_ctx_ptr(pb));
pubnub_mutex_lock(pb->monitor);
result = pb->http_code;
pubnub_mutex_unlock(pb->monitor);
return result;
}
开发者ID:sjaeckel,项目名称:c-core,代码行数:9,代码来源:pubnub_coreapi.c
注:本文中的PUBNUB_ASSERT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论