本文整理汇总了C++中PJ_RETURN_OS_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ PJ_RETURN_OS_ERROR函数的具体用法?C++ PJ_RETURN_OS_ERROR怎么用?C++ PJ_RETURN_OS_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PJ_RETURN_OS_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PJ_DEF
/*
* Create new socket/endpoint for communication and returns a descriptor.
*/
PJ_DEF(pj_status_t) pj_sock_socket(int af,
int type,
int proto,
pj_sock_t *sock)
{
PJ_CHECK_STACK();
/* Sanity checks. */
PJ_ASSERT_RETURN(sock!=NULL, PJ_EINVAL);
PJ_ASSERT_RETURN((unsigned)PJ_INVALID_SOCKET==INVALID_SOCKET,
(*sock=PJ_INVALID_SOCKET, PJ_EINVAL));
*sock = WSASocket(af, type, proto, NULL, 0, WSA_FLAG_OVERLAPPED);
if (*sock == PJ_INVALID_SOCKET)
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
#if PJ_SOCK_DISABLE_WSAECONNRESET && \
(!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0)
#ifndef SIO_UDP_CONNRESET
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
#endif
/* Disable WSAECONNRESET for UDP.
* See https://trac.pjsip.org/repos/ticket/1197
*/
if (type==PJ_SOCK_DGRAM) {
DWORD dwBytesReturned = 0;
BOOL bNewBehavior = FALSE;
DWORD rc;
rc = WSAIoctl(*sock, SIO_UDP_CONNRESET,
&bNewBehavior, sizeof(bNewBehavior),
NULL, 0, &dwBytesReturned,
NULL, NULL);
if (rc==SOCKET_ERROR) {
// Ignored..
}
}
#endif
return PJ_SUCCESS;
}
示例2: PJ_DEF
/*
* Instruct the I/O Queue to write to the handle.
*/
PJ_DEF(pj_status_t) pj_ioqueue_sendto( pj_ioqueue_key_t *key,
pj_ioqueue_op_key_t *op_key,
const void *data,
pj_ssize_t *length,
pj_uint32_t flags,
const pj_sockaddr_t *addr,
int addrlen)
{
TRequestStatus reqStatus;
TPtrC8 aBuffer;
TInetAddr inetAddr;
TSockXfrLength aLen;
pj_status_t status;
PJ_UNUSED_ARG(op_key);
// Forcing pending operation is not supported.
PJ_ASSERT_RETURN((flags & PJ_IOQUEUE_ALWAYS_ASYNC)==0, PJ_EINVAL);
// Return failure if access point is marked as down by app.
PJ_SYMBIAN_CHECK_CONNECTION();
// Convert address
status = PjSymbianOS::pj2Addr(*(const pj_sockaddr*)addr, addrlen,
inetAddr);
if (status != PJ_SUCCESS)
return status;
// Clear flag
flags &= ~PJ_IOQUEUE_ALWAYS_ASYNC;
aBuffer.Set((const TUint8*)data, (TInt)*length);
CPjSocket *pjSock = key->cbObj->get_pj_socket();
pjSock->Socket().SendTo(aBuffer, inetAddr, flags, reqStatus, aLen);
User::WaitForRequest(reqStatus);
if (reqStatus.Int() != KErrNone)
return PJ_RETURN_OS_ERROR(reqStatus.Int());
//At least in UIQ Emulator, aLen.Length() reports incorrect length
//for UDP (some newlc.com users seem to have reported this too).
//*length = aLen.Length();
return PJ_SUCCESS;
}
示例3: PJ_DEF
PJ_DEF(pj_status_t) pj_rwmutex_create(pj_pool_t *pool, const char *name,
pj_rwmutex_t **p_mutex)
{
pj_rwmutex_t *rwm;
pj_status_t status;
PJ_UNUSED_ARG(name);
rwm = PJ_POOL_ALLOC_T(pool, pj_rwmutex_t);
PJ_ASSERT_RETURN(rwm, PJ_ENOMEM);
status = pthread_rwlock_init(&rwm->rwlock, NULL);
if (status != 0)
return PJ_RETURN_OS_ERROR(status);
*p_mutex = rwm;
return PJ_SUCCESS;
}
示例4: PJ_DEF
/*
* Start listening to incoming connections.
*/
PJ_DEF(pj_status_t) pj_sock_listen( pj_sock_t sock,
int backlog)
{
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(sock && backlog, PJ_EINVAL);
CPjSocket *pjSock = (CPjSocket*)sock;
RSocket &rSock = pjSock->Socket();
TInt rc = rSock.Listen((TUint)backlog);
if (rc == KErrNone) {
return PJ_SUCCESS;
} else {
return PJ_RETURN_OS_ERROR(rc);
}
}
示例5: PJ_DEF
/*
* Close socket.
*/
PJ_DEF(pj_status_t) pj_sock_close(pj_sock_t sock)
{
int rc;
PJ_CHECK_STACK();
#if defined(PJ_WIN32) && PJ_WIN32!=0 || \
defined(PJ_WIN64) && PJ_WIN64 != 0 || \
defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
rc = closesocket(sock);
#else
rc = close(sock);
#endif
if (rc != 0)
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
else
return PJ_SUCCESS;
}
示例6: PJ_ASSERT_RETURN
int CPjSSLSocket::Connect(CPjSSLSocket_cb cb, void *key,
const TInetAddr &local_addr,
const TInetAddr &rem_addr,
const TDesC8 &servername,
const TDesC8 &ciphers)
{
pj_status_t status;
PJ_ASSERT_RETURN(state_ == SSL_STATE_NULL, PJ_EINVALIDOP);
status = pj_sock_socket(rem_addr.Family(), pj_SOCK_STREAM(), 0, &sock_);
if (status != PJ_SUCCESS)
return status;
// Apply QoS
status = pj_sock_apply_qos2(sock_, qos_type_, &qos_params_,
2, THIS_FILE, NULL);
RSocket &rSock = ((CPjSocket*)sock_)->Socket();
local_addr_ = local_addr;
if (!local_addr_.IsUnspecified()) {
TInt err = rSock.Bind(local_addr_);
if (err != KErrNone)
return PJ_RETURN_OS_ERROR(err);
}
cb_ = cb;
key_ = key;
rem_addr_ = rem_addr;
/* Note: the following members only keep the pointer, not the data */
servername_.Set(servername);
ciphers_.Set(ciphers);
rSock.Connect(rem_addr_, iStatus);
SetActive();
state_ = SSL_STATE_CONNECTING;
rSock.LocalName(local_addr_);
return PJ_EPENDING;
}
示例7: PJ_DEF
/*
* pj_mutex_trylock()
*/
PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex)
{
#if PJ_HAS_THREADS
int status;
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying",
pj_thread_this()->obj_name));
status = pthread_mutex_trylock( &mutex->mutex );
if (status==0)
{
#if PJ_DEBUG
mutex->owner = pj_thread_this();
pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name);
++mutex->nesting_level;
PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)",
pj_thread_this()->obj_name,
mutex->nesting_level));
#else
PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s",
pj_thread_this()->obj_name));
#endif
}
else
{
PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed",
pj_thread_this()->obj_name));
}
if (status==0)
return PJ_SUCCESS;
else
return PJ_RETURN_OS_ERROR(status);
#else /* PJ_HAS_THREADS */
pj_assert( mutex == (pj_mutex_t*)1);
return PJ_SUCCESS;
#endif
}
示例8: PJ_DEF
/*
* Create new socket/endpoint for communication and returns a descriptor.
*/
PJ_DEF(pj_status_t) pj_sock_socket(int af,
int type,
int proto,
pj_sock_t *sock)
{
PJ_CHECK_STACK();
/* Sanity checks. */
PJ_ASSERT_RETURN(sock!=NULL, PJ_EINVAL);
PJ_ASSERT_RETURN(PJ_INVALID_SOCKET==-1,
(*sock=PJ_INVALID_SOCKET, PJ_EINVAL));
*sock = socket(af, type, proto);
if (*sock == PJ_INVALID_SOCKET)
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
else
return PJ_SUCCESS;
}
示例9: PJ_DEF
PJ_DEF(pj_status_t) pj_file_open( pj_pool_t *pool,
const char *pathname,
unsigned flags,
pj_oshandle_t *fd)
{
char mode[8];
char *p = mode;
PJ_ASSERT_RETURN(pathname && fd, PJ_EINVAL);
PJ_UNUSED_ARG(pool);
if ((flags & PJ_O_APPEND) == PJ_O_APPEND) {
if ((flags & PJ_O_WRONLY) == PJ_O_WRONLY) {
*p++ = 'a';
if ((flags & PJ_O_RDONLY) == PJ_O_RDONLY)
*p++ = '+';
} else {
/* This is invalid.
* Can not specify PJ_O_RDONLY with PJ_O_APPEND!
*/
}
} else {
if ((flags & PJ_O_RDONLY) == PJ_O_RDONLY) {
*p++ = 'r';
if ((flags & PJ_O_WRONLY) == PJ_O_WRONLY)
*p++ = '+';
} else {
*p++ = 'w';
}
}
if (p==mode)
return PJ_EINVAL;
*p++ = 'b';
*p++ = '\0';
*fd = fopen(pathname, mode);
if (*fd == NULL)
return PJ_RETURN_OS_ERROR(errno);
return PJ_SUCCESS;
}
示例10: PJ_DEF
/*
* Set the thread priority.
*/
PJ_DEF(pj_status_t) pj_thread_set_prio(pj_thread_t *thread, int prio)
{
#if PJ_HAS_THREADS
PJ_ASSERT_RETURN(thread, PJ_EINVAL);
PJ_ASSERT_RETURN(prio>=THREAD_PRIORITY_IDLE &&
prio<=THREAD_PRIORITY_TIME_CRITICAL,
PJ_EINVAL);
if (SetThreadPriority(thread->hthread, prio) == FALSE)
return PJ_RETURN_OS_ERROR(GetLastError());
return PJ_SUCCESS;
#else
PJ_UNUSED_ARG(thread);
PJ_UNUSED_ARG(prio);
pj_assert("pj_thread_set_prio() called in non-threading mode!");
return PJ_EINVALIDOP;
#endif
}
示例11: PJ_DEF
/*
* Bind socket.
*/
PJ_DEF(pj_status_t) pj_sock_bind( pj_sock_t sock,
const pj_sockaddr_t *addr,
int len)
{
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(addr && len >= (int)sizeof(struct sockaddr_in), PJ_EINVAL);
CHECK_ADDR_LEN(addr, len);
pj_int32_t val = 1;
int rc = pj_sock_setsockopt(sock, pj_SOL_SOCKET(), pj_SO_REUSEADDR(), &val, sizeof(val));
if (rc != 0)
return rc;
if (bind(sock, (struct sockaddr*)addr, len) != 0)
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
else
return PJ_SUCCESS;
}
示例12: PJ_DEF
/*
* Send data.
*/
PJ_DEF(pj_status_t) pj_sock_sendto(pj_sock_t sock,
const void *buf,
pj_ssize_t *len,
unsigned flags,
const pj_sockaddr_t *to,
int tolen)
{
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(len, PJ_EINVAL);
CHECK_ADDR_LEN(to, tolen);
*len = sendto(sock, (const char*)buf, *len, flags,
(const struct sockaddr*)to, tolen);
if (*len < 0)
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
else
return PJ_SUCCESS;
}
示例13: PJ_DEF
/*
* pj_sem_post()
*/
PJ_DEF(pj_status_t) pj_sem_post(pj_sem_t *sem)
{
#if PJ_HAS_THREADS
int result;
PJ_LOG(6, (sem->obj_name, "Semaphore released by thread %s",
pj_thread_this(sem->inst_id)->obj_name));
#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
result = dispatch_semaphore_signal(sem->sem);
#else
result = sem_post( sem->sem );
#endif
if (result == 0)
return PJ_SUCCESS;
else
return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
#else
pj_assert( sem == (pj_sem_t*) 1);
return PJ_SUCCESS;
#endif
}
示例14: PJ_DEF
/*
* pj_file_getstat()
*/
PJ_DEF(pj_status_t) pj_file_getstat(const char *filename,
pj_file_stat *statbuf)
{
struct stat buf;
PJ_ASSERT_RETURN(filename && statbuf, PJ_EINVAL);
if (stat(filename, &buf) != 0) {
return PJ_RETURN_OS_ERROR(errno);
}
statbuf->size = buf.st_size;
statbuf->ctime.sec = buf.st_ctime;
statbuf->ctime.msec = 0;
statbuf->mtime.sec = buf.st_mtime;
statbuf->mtime.msec = 0;
statbuf->atime.sec = buf.st_atime;
statbuf->atime.msec = 0;
return PJ_SUCCESS;
}
示例15: PJ_DEF
/*
* Connect socket.
*/
PJ_DEF(pj_status_t) pj_sock_connect( pj_sock_t sockfd,
const pj_sockaddr_t *addr,
int namelen)
{
long err;
mm_segment_t oldfs;
PJ_CHECK_STACK();
oldfs = get_fs();
set_fs(KERNEL_DS);
err = sys_connect( sockfd, (void*)addr, namelen );
set_fs(oldfs);
if (err)
return PJ_RETURN_OS_ERROR(-err);
else
return PJ_SUCCESS;
}