- Timestamp:
- Oct 24, 2006 5:13:30 PM (18 years ago)
- Location:
- pjproject/branches/symbian
- Files:
-
- 8 added
- 35 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/symbian/pjlib/include/pj/compat/setjmp.h
r65 r788 79 79 # endif /* _ASM */ 80 80 81 #elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 82 /* Symbian framework don't use setjmp/longjmp */ 81 83 #else 82 84 # warning "setjmp()/longjmp() is not implemented" -
pjproject/branches/symbian/pjlib/include/pj/errno.h
r289 r788 190 190 191 191 /** 192 * Use this macro to generate error message text for your error code, 193 * so that they look uniformly as the rest of the libraries. 194 * 195 * @param code The error code 196 * @param msg The error test. 197 */ 198 #ifndef PJ_BUILD_ERR 199 # define PJ_BUILD_ERR(code,msg) { code, msg " (" #code ")" } 200 #endif 201 202 203 /** 192 204 * @hideinitializer 193 205 * Unknown error has been reported. … … 285 297 */ 286 298 #define PJ_ERRNO_SPACE_SIZE 50000 299 300 /** 301 * See errno.c. 302 */ 303 #define PJ_ERRNO_SPACE_GAP 10000 287 304 288 305 /** -
pjproject/branches/symbian/pjlib/include/pj/except.h
r68 r788 238 238 #define PJ_GET_EXCEPTION() GetExceptionCode() 239 239 240 241 #elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 242 243 /***************************************************************************** 244 ** 245 ** IMPLEMENTATION OF EXCEPTION USING SYMBIAN LEAVE/TRAP FRAMEWORK 246 ** 247 ****************************************************************************/ 248 249 class TPjException 250 { 251 public: 252 int code_; 253 }; 254 255 #define PJ_USE_EXCEPTION 256 #define PJ_TRY try 257 //#define PJ_CATCH(id) 258 #define PJ_CATCH_ANY catch (const TPjException & pj_excp_) 259 #define PJ_END 260 #define PJ_THROW(x_id) do { TPjException e; e.code_=x_id; throw e;} while (0) 261 #define PJ_GET_EXCEPTION() pj_excp_.code_ 262 240 263 #else 264 241 265 /***************************************************************************** 242 266 ** -
pjproject/branches/symbian/pjlib/src/pj/compat/string_compat.c
r692 r788 52 52 { 53 53 int ret; 54 55 54 va_list arg; 55 56 PJ_UNUSED_ARG(len); 57 56 58 va_start(arg, s2); 57 59 ret = vsprintf(s1, s2, arg); … … 63 65 PJ_DEF(int) vsnprintf(char *s1, pj_size_t len, const char *s2, va_list arg) 64 66 { 67 PJ_UNUSED_ARG(len); 65 68 return vsprintf(s1,s2,arg); 66 69 } -
pjproject/branches/symbian/pjlib/src/pj/errno.c
r330 r788 141 141 pj_assert(buf && bufsize); 142 142 143 if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE ) {143 if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE - PJ_ERRNO_SPACE_GAP) { 144 144 len = pj_ansi_snprintf( buf, bufsize, "Unknown error %d", statcode); 145 145 146 } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE ) {146 } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE - PJ_ERRNO_SPACE_GAP) { 147 147 len = pjlib_error(statcode, buf, bufsize); 148 148 149 } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE ) {149 } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE - PJ_ERRNO_SPACE_GAP) { 150 150 len = platform_strerror(PJ_STATUS_TO_OS(statcode), buf, bufsize); 151 151 -
pjproject/branches/symbian/pjlib/src/pj/ioqueue_symbian.cpp
r686 r788 18 18 */ 19 19 #include <pj/ioqueue.h> 20 #include <pj/assert.h> 21 #include <pj/errno.h> 22 #include <pj/list.h> 23 #include <pj/lock.h> 24 #include <pj/pool.h> 25 #include <pj/string.h> 26 27 #include "os_symbian.h" 28 29 class CIoqueueCallback; 30 31 /* 32 * IO Queue structure. 33 */ 34 struct pj_ioqueue_t 35 { 36 int eventCount; 37 CPjTimeoutTimer *timeoutTimer; 38 }; 39 40 41 ///////////////////////////////////////////////////////////////////////////// 42 // Class to encapsulate asynchronous socket operation. 43 // 44 class CIoqueueCallback : public CActive 45 { 46 public: 47 CIoqueueCallback(pj_ioqueue_t *ioqueue, 48 pj_ioqueue_key_t *key, pj_sock_t sock, 49 const pj_ioqueue_callback *cb, void *user_data) 50 : CActive(CActive::EPriorityStandard), 51 ioqueue_(ioqueue), key_(key), sock_((CPjSocket*)sock), cb_(cb), 52 user_data_(user_data), aBufferPtr_(NULL, 0), type_(TYPE_NONE) 53 { 54 CActiveScheduler::Add(this); 55 } 56 57 // 58 // Start asynchronous recv() operation 59 // 60 pj_status_t StartRead(pj_ioqueue_op_key_t *op_key, 61 void *buf, pj_ssize_t *size, unsigned flags, 62 pj_sockaddr_t *addr, int *addrlen) 63 { 64 PJ_ASSERT_RETURN(IsActive()==false, PJ_EBUSY); 65 PJ_ASSERT_RETURN(pending_data_.common_.op_key_==NULL, PJ_EBUSY); 66 67 pending_data_.read_.op_key_ = op_key; 68 pending_data_.read_.addr_ = addr; 69 pending_data_.read_.addrlen_ = addrlen; 70 71 aBufferPtr_.Set((TUint8*)buf, 0, (TInt)*size); 72 73 type_ = TYPE_READ; 74 SetActive(); 75 sock_->Socket().RecvFrom(aBufferPtr_, aAddress_, flags, iStatus); 76 77 return PJ_EPENDING; 78 } 79 80 81 // 82 // Start asynchronous accept() operation. 83 // 84 pj_status_t StartAccept(pj_ioqueue_op_key_t *op_key, 85 pj_sock_t *new_sock, 86 pj_sockaddr_t *local, 87 pj_sockaddr_t *remote, 88 int *addrlen ) 89 { 90 PJ_ASSERT_RETURN(IsActive()==false, PJ_EBUSY); 91 PJ_ASSERT_RETURN(pending_data_.common_.op_key_==NULL, PJ_EBUSY); 92 93 pending_data_.accept_.op_key_ = op_key; 94 pending_data_.accept_.new_sock_ = new_sock; 95 pending_data_.accept_.local_ = local; 96 pending_data_.accept_.remote_ = remote; 97 pending_data_.accept_.addrlen_ = addrlen; 98 99 // Create blank socket 100 blank_sock_.Open(PjSymbianOS::Instance()->SocketServ()); 101 102 type_ = TYPE_ACCEPT; 103 SetActive(); 104 sock_->Socket().Accept(blank_sock_, iStatus); 105 106 return PJ_EPENDING; 107 } 108 109 110 // 111 // Completion callback. 112 // 113 void RunL() 114 { 115 Type cur_type = type_; 116 117 type_ = TYPE_NONE; 118 119 if (cur_type == TYPE_READ) { 120 // 121 // Completion of asynchronous RecvFrom() 122 // 123 124 /* Clear op_key (save it to temp variable first!) */ 125 pj_ioqueue_op_key_t *op_key = pending_data_.read_.op_key_; 126 pending_data_.read_.op_key_ = NULL; 127 128 // Handle failure condition 129 if (iStatus != KErrNone) { 130 cb_->on_read_complete(key_, op_key, -PJ_RETURN_OS_ERROR(iStatus.Int())); 131 return; 132 } 133 134 if (pending_data_.read_.addr_) { 135 PjSymbianOS::Addr2pj(aAddress_, 136 *(pj_sockaddr_in*)pending_data_.read_.addr_); 137 pending_data_.read_.addr_ = NULL; 138 } 139 if (pending_data_.read_.addrlen_) { 140 *pending_data_.read_.addrlen_ = sizeof(pj_sockaddr_in); 141 pending_data_.read_.addrlen_ = NULL; 142 } 143 144 /* Call callback */ 145 cb_->on_read_complete(key_, op_key, aBufferPtr_.Length()); 146 147 } else if (cur_type == TYPE_ACCEPT) { 148 // 149 // Completion of asynchronous Accept() 150 // 151 152 /* Clear op_key (save it to temp variable first!) */ 153 pj_ioqueue_op_key_t *op_key = pending_data_.read_.op_key_; 154 pending_data_.read_.op_key_ = NULL; 155 156 // Handle failure condition 157 if (iStatus != KErrNone) { 158 if (pending_data_.accept_.new_sock_) 159 *pending_data_.accept_.new_sock_ = PJ_INVALID_SOCKET; 160 161 cb_->on_accept_complete(key_, op_key, PJ_INVALID_SOCKET, 162 -PJ_RETURN_OS_ERROR(iStatus.Int())); 163 return; 164 } 165 166 CPjSocket *pjNewSock = new CPjSocket(blank_sock_); 167 168 if (pending_data_.accept_.new_sock_) { 169 *pending_data_.accept_.new_sock_ = (pj_sock_t)pjNewSock; 170 pending_data_.accept_.new_sock_ = NULL; 171 } 172 173 if (pending_data_.accept_.local_) { 174 TInetAddr aAddr; 175 blank_sock_.LocalName(aAddr); 176 PjSymbianOS::Addr2pj(aAddr, *(pj_sockaddr_in*)pending_data_.accept_.local_); 177 pending_data_.accept_.local_ = NULL; 178 } 179 180 if (pending_data_.accept_.remote_) { 181 TInetAddr aAddr; 182 blank_sock_.RemoteName(aAddr); 183 PjSymbianOS::Addr2pj(aAddr, *(pj_sockaddr_in*)pending_data_.accept_.remote_); 184 pending_data_.accept_.remote_ = NULL; 185 } 186 187 if (pending_data_.accept_.addrlen_) { 188 *pending_data_.accept_.addrlen_ = sizeof(pj_sockaddr_in); 189 pending_data_.accept_.addrlen_ = NULL; 190 } 191 192 // Call callback. 193 cb_->on_accept_complete(key_, op_key, (pj_sock_t)pjNewSock, PJ_SUCCESS); 194 } 195 196 ioqueue_->eventCount++; 197 } 198 199 // 200 // CActive's DoCancel() 201 // 202 void DoCancel() 203 { 204 if (type_ == TYPE_READ) 205 sock_->Socket().CancelRecv(); 206 else if (type_ == TYPE_ACCEPT) 207 sock_->Socket().CancelAccept(); 208 209 type_ = TYPE_NONE; 210 } 211 212 // 213 // Cancel operation and call callback. 214 // 215 void CancelOperation(pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_status) 216 { 217 Type cur_type = type_; 218 219 Cancel(); 220 221 if (cur_type == TYPE_READ) 222 cb_->on_read_complete(key_, op_key, bytes_status); 223 else if (cur_type == TYPE_ACCEPT) 224 ; 225 } 226 227 // 228 // Accessors 229 // 230 void* get_user_data() const 231 { 232 return user_data_; 233 } 234 void set_user_data(void *user_data) 235 { 236 user_data_ = user_data; 237 } 238 pj_ioqueue_op_key_t *get_op_key() const 239 { 240 return pending_data_.common_.op_key_; 241 } 242 CPjSocket* get_pj_socket() 243 { 244 return sock_; 245 } 246 247 private: 248 // Type of pending operation. 249 enum Type { 250 TYPE_NONE, 251 TYPE_READ, 252 TYPE_ACCEPT, 253 }; 254 255 // Static data. 256 pj_ioqueue_t *ioqueue_; 257 pj_ioqueue_key_t *key_; 258 CPjSocket *sock_; 259 const pj_ioqueue_callback *cb_; 260 void *user_data_; 261 262 // Symbian data. 263 TPtr8 aBufferPtr_; 264 TInetAddr aAddress_; 265 266 // Application data. 267 Type type_; 268 269 union Pending_Data 270 { 271 struct Common 272 { 273 pj_ioqueue_op_key_t *op_key_; 274 } common_; 275 276 struct Pending_Read 277 { 278 pj_ioqueue_op_key_t *op_key_; 279 pj_sockaddr_t *addr_; 280 int *addrlen_; 281 } read_; 282 283 struct Pending_Accept 284 { 285 pj_ioqueue_op_key_t *op_key_; 286 pj_sock_t *new_sock_; 287 pj_sockaddr_t *local_; 288 pj_sockaddr_t *remote_; 289 int *addrlen_; 290 } accept_; 291 }; 292 293 union Pending_Data pending_data_; 294 RSocket blank_sock_; 295 }; 296 297 298 299 300 /* 301 * IO Queue key structure. 302 */ 303 struct pj_ioqueue_key_t 304 { 305 CIoqueueCallback *cbObj; 306 }; 20 307 21 308 … … 25 312 PJ_DEF(const char*) pj_ioqueue_name(void) 26 313 { 27 return "symbian"; 28 } 29 314 return "ioqueue-symbian"; 315 } 316 317 318 /* 319 * Create a new I/O Queue framework. 320 */ 321 PJ_DEF(pj_status_t) pj_ioqueue_create( pj_pool_t *pool, 322 pj_size_t max_fd, 323 pj_ioqueue_t **p_ioqueue) 324 { 325 pj_ioqueue_t *ioq; 326 327 PJ_UNUSED_ARG(max_fd); 328 329 ioq = (pj_ioqueue_t*) pj_pool_zalloc(pool, sizeof(pj_ioqueue_t)); 330 ioq->timeoutTimer = CPjTimeoutTimer::NewL(); 331 *p_ioqueue = ioq; 332 return PJ_SUCCESS; 333 } 334 335 336 /* 337 * Destroy the I/O queue. 338 */ 339 PJ_DEF(pj_status_t) pj_ioqueue_destroy( pj_ioqueue_t *ioq ) 340 { 341 delete ioq->timeoutTimer; 342 ioq->timeoutTimer = NULL; 343 344 return PJ_SUCCESS; 345 } 346 347 348 /* 349 * Set the lock object to be used by the I/O Queue. 350 */ 351 PJ_DEF(pj_status_t) pj_ioqueue_set_lock( pj_ioqueue_t *ioq, 352 pj_lock_t *lock, 353 pj_bool_t auto_delete ) 354 { 355 /* Don't really need lock for now */ 356 PJ_UNUSED_ARG(ioq); 357 358 if (auto_delete) { 359 pj_lock_destroy(lock); 360 } 361 362 return PJ_SUCCESS; 363 } 364 365 366 /* 367 * Register a socket to the I/O queue framework. 368 */ 369 PJ_DEF(pj_status_t) pj_ioqueue_register_sock( pj_pool_t *pool, 370 pj_ioqueue_t *ioq, 371 pj_sock_t sock, 372 void *user_data, 373 const pj_ioqueue_callback *cb, 374 pj_ioqueue_key_t **p_key ) 375 { 376 pj_ioqueue_key_t *key; 377 378 key = (pj_ioqueue_key_t*) pj_pool_alloc(pool, sizeof(pj_ioqueue_key_t)); 379 key->cbObj = new CIoqueueCallback(ioq, key, sock, cb, user_data); 380 381 *p_key = key; 382 return PJ_SUCCESS; 383 } 384 385 /* 386 * Unregister from the I/O Queue framework. 387 */ 388 PJ_DEF(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_key_t *key ) 389 { 390 if (key == NULL || key->cbObj == NULL) 391 return PJ_SUCCESS; 392 393 // Close socket. 394 key->cbObj->get_pj_socket()->Socket().Close(); 395 delete key->cbObj->get_pj_socket(); 396 397 // Delete async object 398 delete key->cbObj; 399 key->cbObj = NULL; 400 401 return PJ_SUCCESS; 402 } 403 404 405 /* 406 * Get user data associated with an ioqueue key. 407 */ 408 PJ_DEF(void*) pj_ioqueue_get_user_data( pj_ioqueue_key_t *key ) 409 { 410 return key->cbObj->get_user_data(); 411 } 412 413 414 /* 415 * Set or change the user data to be associated with the file descriptor or 416 * handle or socket descriptor. 417 */ 418 PJ_DEF(pj_status_t) pj_ioqueue_set_user_data( pj_ioqueue_key_t *key, 419 void *user_data, 420 void **old_data) 421 { 422 if (old_data) 423 *old_data = key->cbObj->get_user_data(); 424 key->cbObj->set_user_data(user_data); 425 426 return PJ_SUCCESS; 427 } 428 429 430 /* 431 * Initialize operation key. 432 */ 433 PJ_DEF(void) pj_ioqueue_op_key_init( pj_ioqueue_op_key_t *op_key, 434 pj_size_t size ) 435 { 436 pj_memset(op_key, 0, size); 437 } 438 439 440 /* 441 * Check if operation is pending on the specified operation key. 442 */ 443 PJ_DEF(pj_bool_t) pj_ioqueue_is_pending( pj_ioqueue_key_t *key, 444 pj_ioqueue_op_key_t *op_key ) 445 { 446 return key->cbObj->get_op_key()==op_key && 447 key->cbObj->IsActive(); 448 } 449 450 451 /* 452 * Post completion status to the specified operation key and call the 453 * appropriate callback. 454 */ 455 PJ_DEF(pj_status_t) pj_ioqueue_post_completion( pj_ioqueue_key_t *key, 456 pj_ioqueue_op_key_t *op_key, 457 pj_ssize_t bytes_status ) 458 { 459 if (pj_ioqueue_is_pending(key, op_key)) { 460 key->cbObj->CancelOperation(op_key, bytes_status); 461 } 462 return PJ_SUCCESS; 463 } 464 465 466 #if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0 467 /** 468 * Instruct I/O Queue to accept incoming connection on the specified 469 * listening socket. 470 */ 471 PJ_DEF(pj_status_t) pj_ioqueue_accept( pj_ioqueue_key_t *key, 472 pj_ioqueue_op_key_t *op_key, 473 pj_sock_t *new_sock, 474 pj_sockaddr_t *local, 475 pj_sockaddr_t *remote, 476 int *addrlen ) 477 { 478 479 return key->cbObj->StartAccept(op_key, new_sock, local, remote, addrlen); 480 } 481 482 483 /* 484 * Initiate non-blocking socket connect. 485 */ 486 PJ_DEF(pj_status_t) pj_ioqueue_connect( pj_ioqueue_key_t *key, 487 const pj_sockaddr_t *addr, 488 int addrlen ) 489 { 490 PJ_ASSERT_RETURN(addrlen == sizeof(pj_sockaddr_in), PJ_EINVAL); 491 492 RSocket &rSock = key->cbObj->get_pj_socket()->Socket(); 493 TInetAddr inetAddr; 494 PjSymbianOS::pj2Addr(*(const pj_sockaddr_in*)addr, inetAddr); 495 TRequestStatus reqStatus; 496 497 // We don't support async connect for now. 498 PJ_TODO(IOQUEUE_SUPPORT_ASYNC_CONNECT); 499 500 rSock.Connect(inetAddr, reqStatus); 501 User::WaitForRequest(reqStatus); 502 503 if (reqStatus == KErrNone) 504 return PJ_SUCCESS; 505 506 return PJ_RETURN_OS_ERROR(reqStatus.Int()); 507 } 508 509 510 #endif /* PJ_HAS_TCP */ 511 512 /* 513 * Poll the I/O Queue for completed events. 514 */ 515 PJ_DEF(int) pj_ioqueue_poll( pj_ioqueue_t *ioq, 516 const pj_time_val *timeout) 517 { 518 CPjTimeoutTimer *timer; 519 520 if (timeout) { 521 if (!ioq->timeoutTimer->IsActive()) 522 timer = ioq->timeoutTimer; 523 else 524 timer = CPjTimeoutTimer::NewL(); 525 526 timer->StartTimer(timeout->sec*1000 + timeout->msec); 527 528 } else { 529 timer = NULL; 530 } 531 532 ioq->eventCount = 0; 533 534 do { 535 PjSymbianOS::Instance()->WaitForActiveObjects(); 536 } while (ioq->eventCount == 0 && !timer->HasTimedOut()); 537 538 if (!timer->HasTimedOut()) 539 timer->Cancel(); 540 541 if (timer != ioq->timeoutTimer) 542 delete timer; 543 544 return ioq->eventCount; 545 } 546 547 548 /* 549 * Instruct the I/O Queue to read from the specified handle. 550 */ 551 PJ_DEF(pj_status_t) pj_ioqueue_recv( pj_ioqueue_key_t *key, 552 pj_ioqueue_op_key_t *op_key, 553 void *buffer, 554 pj_ssize_t *length, 555 pj_uint32_t flags ) 556 { 557 return pj_ioqueue_recvfrom(key, op_key, buffer, length, flags, NULL, NULL); 558 } 559 560 561 /* 562 * This function behaves similarly as #pj_ioqueue_recv(), except that it is 563 * normally called for socket, and the remote address will also be returned 564 * along with the data. 565 */ 566 PJ_DEF(pj_status_t) pj_ioqueue_recvfrom( pj_ioqueue_key_t *key, 567 pj_ioqueue_op_key_t *op_key, 568 void *buffer, 569 pj_ssize_t *length, 570 pj_uint32_t flags, 571 pj_sockaddr_t *addr, 572 int *addrlen) 573 { 574 if (key->cbObj->IsActive()) 575 return PJ_EBUSY; 576 577 return key->cbObj->StartRead(op_key, buffer, length, flags, addr, addrlen); 578 } 579 580 581 /* 582 * Instruct the I/O Queue to write to the handle. 583 */ 584 PJ_DEF(pj_status_t) pj_ioqueue_send( pj_ioqueue_key_t *key, 585 pj_ioqueue_op_key_t *op_key, 586 const void *data, 587 pj_ssize_t *length, 588 pj_uint32_t flags ) 589 { 590 TRequestStatus reqStatus; 591 TPtrC8 aBuffer((const TUint8*)data, (TInt)*length); 592 TSockXfrLength aLen; 593 594 PJ_UNUSED_ARG(op_key); 595 596 // Forcing pending operation is not supported. 597 PJ_ASSERT_RETURN((flags & PJ_IOQUEUE_ALWAYS_ASYNC)==0, PJ_EINVAL); 598 599 key->cbObj->get_pj_socket()->Socket().Send(aBuffer, flags, reqStatus, aLen); 600 User::WaitForRequest(reqStatus); 601 602 if (reqStatus.Int() != KErrNone) 603 return PJ_RETURN_OS_ERROR(reqStatus.Int()); 604 605 *length = aLen.Length(); 606 return PJ_SUCCESS; 607 } 608 609 610 /* 611 * Instruct the I/O Queue to write to the handle. 612 */ 613 PJ_DEF(pj_status_t) pj_ioqueue_sendto( pj_ioqueue_key_t *key, 614 pj_ioqueue_op_key_t *op_key, 615 const void *data, 616 pj_ssize_t *length, 617 pj_uint32_t flags, 618 const pj_sockaddr_t *addr, 619 int addrlen) 620 { 621 TRequestStatus reqStatus; 622 TPtrC8 aBuffer; 623 TInetAddr inetAddr; 624 TSockXfrLength aLen; 625 626 PJ_UNUSED_ARG(op_key); 627 628 // Forcing pending operation is not supported. 629 PJ_ASSERT_RETURN((flags & PJ_IOQUEUE_ALWAYS_ASYNC)==0, PJ_EINVAL); 630 631 // Must be pj_sockaddr_in for now. 632 PJ_ASSERT_RETURN(addrlen == sizeof(pj_sockaddr_in), PJ_EINVAL); 633 634 aBuffer.Set((const TUint8*)data, (TInt)*length); 635 PjSymbianOS::pj2Addr(*(const pj_sockaddr_in*)addr, inetAddr); 636 CPjSocket *pjSock = key->cbObj->get_pj_socket(); 637 638 pjSock->Socket().Send(aBuffer, flags, reqStatus, aLen); 639 User::WaitForRequest(reqStatus); 640 641 if (reqStatus.Int() != KErrNone) 642 return PJ_RETURN_OS_ERROR(reqStatus.Int()); 643 644 *length = aLen.Length(); 645 return PJ_SUCCESS; 646 } 647 -
pjproject/branches/symbian/pjlib/src/pj/log.c
r315 r788 151 151 log_buffer[len++] = '\n'; 152 152 } 153 log_buffer[len ++] = '\0';153 log_buffer[len] = '\0'; 154 154 } else { 155 155 len = sizeof(log_buffer)-1; -
pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp
r692 r788 18 18 */ 19 19 20 #include <e32cmn.h>21 #include <e32std.h>22 23 20 #include <pj/os.h> 24 21 #include <pj/assert.h> … … 31 28 #include <pj/errno.h> 32 29 30 #include "os_symbian.h" 31 33 32 34 33 #define PJ_MAX_TLS 32 35 34 #define DUMMY_MUTEX ((pj_mutex_t*)101) 36 35 #define DUMMY_SEMAPHORE ((pj_sem_t*)102) 37 38 36 #define THIS_FILE "os_core_symbian.c" 37 39 38 /* 40 39 * Note: … … 61 60 62 61 62 63 ///////////////////////////////////////////////////////////////////////////// 64 // 65 // CPjTimeoutTimer implementation 66 // 67 68 CPjTimeoutTimer::CPjTimeoutTimer() 69 : CActive(EPriorityNormal), hasTimedOut_(false) 70 { 71 } 72 73 CPjTimeoutTimer::~CPjTimeoutTimer() 74 { 75 if (IsActive()) 76 Cancel(); 77 timer_.Close(); 78 } 79 80 void CPjTimeoutTimer::ConstructL() 81 { 82 timer_.CreateLocal(); 83 CActiveScheduler::Add(this); 84 } 85 86 CPjTimeoutTimer *CPjTimeoutTimer::NewL() 87 { 88 CPjTimeoutTimer *self = new (ELeave) CPjTimeoutTimer; 89 CleanupStack::PushL(self); 90 91 self->ConstructL(); 92 93 CleanupStack::Pop(self); 94 return self; 95 96 } 97 98 void CPjTimeoutTimer::StartTimer(TUint miliSeconds) 99 { 100 if (IsActive()) 101 Cancel(); 102 103 hasTimedOut_ = false; 104 timer_.After(iStatus, miliSeconds * 1000); 105 SetActive(); 106 } 107 108 bool CPjTimeoutTimer::HasTimedOut() const 109 { 110 return hasTimedOut_; 111 } 112 113 void CPjTimeoutTimer::RunL() 114 { 115 hasTimedOut_ = true; 116 } 117 118 void CPjTimeoutTimer::DoCancel() 119 { 120 timer_.Cancel(); 121 } 122 123 TInt CPjTimeoutTimer::RunError(TInt aError) 124 { 125 PJ_UNUSED_ARG(aError); 126 return KErrNone; 127 } 128 129 130 131 ///////////////////////////////////////////////////////////////////////////// 132 // 133 // PjSymbianOS implementation 134 // 135 136 PjSymbianOS::PjSymbianOS() 137 : isSocketServInitialized_(false), isResolverInitialized_(false), 138 console_(NULL), selectTimeoutTimer_(NULL) 139 { 140 } 141 142 // Get PjSymbianOS instance 143 PjSymbianOS *PjSymbianOS::Instance() 144 { 145 static PjSymbianOS instance_; 146 return &instance_; 147 } 148 149 150 // Initialize 151 TInt PjSymbianOS::Initialize() 152 { 153 TInt err; 154 155 selectTimeoutTimer_ = CPjTimeoutTimer::NewL(); 156 157 #if 0 158 pj_assert(console_ == NULL); 159 TRAPD(err, console_ = Console::NewL(_L("PJLIB"), 160 TSize(KConsFullScreen,KConsFullScreen))); 161 return err; 162 #endif 163 164 if (!isSocketServInitialized_) { 165 err = socketServ_.Connect(); 166 if (err != KErrNone) 167 goto on_error; 168 169 isSocketServInitialized_ = true; 170 } 171 172 if (!isResolverInitialized_) { 173 err = hostResolver_.Open(SocketServ(), KAfInet, KSockStream); 174 if (err != KErrNone) 175 goto on_error; 176 177 isResolverInitialized_ = true; 178 } 179 180 return KErrNone; 181 182 on_error: 183 Shutdown(); 184 return err; 185 } 186 187 // Shutdown 188 void PjSymbianOS::Shutdown() 189 { 190 if (isResolverInitialized_) { 191 hostResolver_.Close(); 192 isResolverInitialized_ = false; 193 } 194 195 if (isSocketServInitialized_) { 196 socketServ_.Close(); 197 isSocketServInitialized_ = false; 198 } 199 200 if (console_) { 201 delete console_; 202 console_ = NULL; 203 } 204 205 if (selectTimeoutTimer_) { 206 delete selectTimeoutTimer_; 207 selectTimeoutTimer_ = NULL; 208 } 209 } 210 211 // Convert to Unicode 212 TInt PjSymbianOS::ConvertToUnicode(TDes16 &aUnicode, const TDesC8 &aForeign) 213 { 214 #if 0 215 pj_assert(conv_ != NULL); 216 return conv_->ConvertToUnicode(aUnicode, aForeign, convToUnicodeState_); 217 #else 218 return CnvUtfConverter::ConvertToUnicodeFromUtf8(aUnicode, aForeign); 219 #endif 220 } 221 222 // Convert from Unicode 223 TInt PjSymbianOS::ConvertFromUnicode(TDes8 &aForeign, const TDesC16 &aUnicode) 224 { 225 #if 0 226 pj_assert(conv_ != NULL); 227 return conv_->ConvertFromUnicode(aForeign, aUnicode, convToAnsiState_); 228 #else 229 return CnvUtfConverter::ConvertFromUnicodeToUtf8(aForeign, aUnicode); 230 #endif 231 } 232 233 234 ///////////////////////////////////////////////////////////////////////////// 235 // 236 // PJLIB os.h implementation 237 // 238 63 239 PJ_DEF(pj_uint32_t) pj_getpid(void) 64 240 { … … 66 242 } 67 243 244 245 PJ_DECL(void) pj_shutdown(void); 68 246 69 247 /* … … 74 252 { 75 253 pj_ansi_strcpy(main_thread.obj_name, "pjthread"); 76 return PJ_SUCCESS; 254 255 // Initialize PjSymbianOS instance 256 PjSymbianOS *os = PjSymbianOS::Instance(); 257 258 PJ_LOG(4,(THIS_FILE, "Initializing PJLIB for Symbian OS..")); 259 260 TInt err; 261 err = os->Initialize(); 262 if (err != KErrNone) 263 goto on_error; 264 265 PJ_LOG(5,(THIS_FILE, "PJLIB initialized.")); 266 return PJ_SUCCESS; 267 268 on_error: 269 pj_shutdown(); 270 return PJ_RETURN_OS_ERROR(err); 271 } 272 273 274 PJ_DEF(void) pj_shutdown(void) 275 { 276 PjSymbianOS *os = PjSymbianOS::Instance(); 277 os->Shutdown(); 278 } 279 280 281 /* 282 * pj_thread_register(..) 283 */ 284 PJ_DEF(pj_status_t) pj_thread_register ( const char *cstr_thread_name, 285 pj_thread_desc desc, 286 pj_thread_t **thread_ptr) 287 { 288 PJ_UNUSED_ARG(cstr_thread_name); 289 PJ_UNUSED_ARG(desc); 290 PJ_UNUSED_ARG(thread_ptr); 291 return PJ_EINVALIDOP; 77 292 } 78 293 … … 150 365 PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec) 151 366 { 152 PJ_UNUSED_ARG(msec); 153 154 /* Not supported either */ 155 return PJ_EINVALIDOP; 367 User::After(msec*1000); 368 return PJ_SUCCESS; 156 369 } 157 370 -
pjproject/branches/symbian/pjlib/src/pj/pool.c
r433 r788 19 19 #include <pj/pool.h> 20 20 #include <pj/log.h> 21 #include <pj/except.h>22 21 #include <pj/assert.h> 23 22 #include <pj/os.h> -
pjproject/branches/symbian/pjlib/src/pj/sock_bsd.c
r496 r788 633 633 PJ_ASSERT_RETURN(newsock != NULL, PJ_EINVAL); 634 634 635 hello 636 635 637 #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 636 638 if (addr) { -
pjproject/branches/symbian/pjlib/src/pj/sock_select_symbian.cpp
r686 r788 18 18 */ 19 19 #include <pj/sock_select.h> 20 #include <pj/array.h> 21 #include <pj/assert.h> 22 #include <pj/os.h> 23 #include "os_symbian.h" 24 25 26 struct symbian_fd_set 27 { 28 unsigned count; 29 CPjSocket *sock[FD_SETSIZE]; 30 }; 20 31 21 32 22 33 PJ_DEF(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp) 23 34 { 24 PJ_TODO(PJ_FD_ZERO); 35 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 36 fds->count = 0; 25 37 } 26 38 … … 28 40 PJ_DEF(void) PJ_FD_SET(pj_sock_t fd, pj_fd_set_t *fdsetp) 29 41 { 30 PJ_TODO(PJ_FD_SET); 42 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 43 44 PJ_ASSERT_ON_FAIL(fds->count < FD_SETSIZE, return); 45 fds->sock[fds->count++] = (CPjSocket*)fd; 31 46 } 32 47 … … 34 49 PJ_DEF(void) PJ_FD_CLR(pj_sock_t fd, pj_fd_set_t *fdsetp) 35 50 { 36 PJ_TODO(PJ_FD_CLR); 51 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 52 unsigned i; 53 54 for (i=0; i<fds->count; ++i) { 55 if (fds->sock[i] == (CPjSocket*)fd) { 56 pj_array_erase(fds->sock, sizeof(fds->sock[0]), fds->count, i); 57 --fds->count; 58 return; 59 } 60 } 37 61 } 38 62 … … 40 64 PJ_DEF(pj_bool_t) PJ_FD_ISSET(pj_sock_t fd, const pj_fd_set_t *fdsetp) 41 65 { 42 PJ_TODO(PJ_FD_ISSET); 43 return 0; 66 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 67 unsigned i; 68 69 for (i=0; i<fds->count; ++i) { 70 if (fds->sock[i] == (CPjSocket*)fd) { 71 return PJ_TRUE; 72 } 73 } 74 75 return PJ_FALSE; 44 76 } 45 77 46 78 PJ_DEF(pj_size_t) PJ_FD_COUNT(const pj_fd_set_t *fdsetp) 47 79 { 48 PJ_TODO(PJ_FD_COUNT);49 return 0;80 symbian_fd_set *fds = (symbian_fd_set *)fdsetp; 81 return fds->count; 50 82 } 83 51 84 52 85 PJ_DEF(int) pj_sock_select( int n, … … 56 89 const pj_time_val *timeout) 57 90 { 58 PJ_TODO(pj_sock_select); 91 CPjTimeoutTimer *pjTimer; 92 unsigned i; 93 94 PJ_UNUSED_ARG(n); 95 PJ_UNUSED_ARG(writefds); 96 PJ_UNUSED_ARG(exceptfds); 97 98 if (timeout) { 99 pjTimer = PjSymbianOS::Instance()->SelectTimeoutTimer(); 100 pjTimer->StartTimer(timeout->sec*1000 + timeout->msec); 101 102 } else { 103 pjTimer = NULL; 104 } 105 106 /* Scan for readable sockets */ 107 108 if (readfds) { 109 symbian_fd_set *fds = (symbian_fd_set *)readfds; 110 111 do { 112 /* Scan sockets for readily available data */ 113 for (i=0; i<fds->count; ++i) { 114 CPjSocket *pjsock = fds->sock[i]; 115 116 if (pjsock->Reader()) { 117 if (pjsock->Reader()->HasData() && !pjsock->Reader()->IsActive()) { 118 119 /* Found socket with data ready */ 120 PJ_FD_ZERO(readfds); 121 PJ_FD_SET((pj_sock_t)pjsock, readfds); 122 123 /* Cancel timer, if any */ 124 if (pjTimer) { 125 pjTimer->Cancel(); 126 } 127 128 /* Clear writable and exception fd_set */ 129 if (writefds) 130 PJ_FD_ZERO(writefds); 131 if (exceptfds) 132 PJ_FD_ZERO(exceptfds); 133 134 return 1; 135 136 } else if (!pjsock->Reader()->IsActive()) 137 pjsock->Reader()->StartRecvFrom(); 138 139 } else { 140 pjsock->CreateReader(); 141 pjsock->Reader()->StartRecvFrom(); 142 } 143 } 144 145 PjSymbianOS::Instance()->WaitForActiveObjects(); 146 147 } while (pjTimer==NULL || !pjTimer->HasTimedOut()); 148 } 149 150 151 /* Timeout */ 152 153 if (readfds) 154 PJ_FD_ZERO(readfds); 155 if (writefds) 156 PJ_FD_ZERO(writefds); 157 if (exceptfds) 158 PJ_FD_ZERO(exceptfds); 159 59 160 return 0; 60 161 } -
pjproject/branches/symbian/pjlib/src/pjlib-test/atomic.c
r65 r788 18 18 */ 19 19 #include "test.h" 20 #include <pj lib.h>20 #include <pj/os.h> 21 21 22 22 /** -
pjproject/branches/symbian/pjlib/src/pjlib-test/echo_clt.c
r65 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/os.h> 21 #include <pj/sock.h> 21 22 22 23 #if INCLUDE_ECHO_CLIENT -
pjproject/branches/symbian/pjlib/src/pjlib-test/file.c
r65 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/file_io.h> 21 #include <pj/file_access.h> 22 21 23 22 24 #if INCLUDE_FILE_TEST -
pjproject/branches/symbian/pjlib/src/pjlib-test/ioq_perf.c
r365 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/errno.h> 21 #include <pj/ioqueue.h> 22 #include <pj/log.h> 23 #include <pj/os.h> 24 #include <pj/pool.h> 25 #include <pj/sock.h> 21 26 #include <pj/compat/high_precision.h> 22 27 … … 73 78 pj_ssize_t bytes_read) 74 79 { 75 test_item *item = pj_ioqueue_get_user_data(key);80 test_item *item = (test_item*)pj_ioqueue_get_user_data(key); 76 81 pj_status_t rc; 77 82 int data_is_available = 1; … … 151 156 pj_ssize_t bytes_sent) 152 157 { 153 test_item *item = pj_ioqueue_get_user_data(key);158 test_item *item = (test_item*)pj_ioqueue_get_user_data(key); 154 159 155 160 //TRACE_((THIS_FILE, " write complete: sent = %d", bytes_sent)); … … 189 194 static int worker_thread(void *p) 190 195 { 191 struct thread_arg *arg = p;196 struct thread_arg *arg = (struct thread_arg *)p; 192 197 const pj_time_val timeout = {0, 100}; 193 198 int rc; … … 250 255 return -10; 251 256 252 items = pj_pool_alloc(pool, sockpair_cnt*sizeof(test_item));253 thread = pj_pool_alloc(pool, thread_cnt*sizeof(pj_thread_t*));257 items = (test_item *)pj_pool_alloc(pool, sockpair_cnt*sizeof(test_item)); 258 thread = (pj_thread_t **)pj_pool_alloc(pool, thread_cnt*sizeof(pj_thread_t*)); 254 259 255 260 TRACE_((THIS_FILE, " creating ioqueue..")); … … 266 271 items[i].ioqueue = ioqueue; 267 272 items[i].buffer_size = buffer_size; 268 items[i].outgoing_buffer = pj_pool_alloc(pool, buffer_size);269 items[i].incoming_buffer = pj_pool_alloc(pool, buffer_size);273 items[i].outgoing_buffer = (char*)pj_pool_alloc(pool, buffer_size); 274 items[i].incoming_buffer = (char*)pj_pool_alloc(pool, buffer_size); 270 275 items[i].bytes_recv = items[i].bytes_sent = 0; 271 276 … … 332 337 struct thread_arg *arg; 333 338 334 arg = pj_pool_zalloc(pool, sizeof(*arg));339 arg = (struct thread_arg *)pj_pool_zalloc(pool, sizeof(*arg)); 335 340 arg->id = i; 336 341 arg->ioqueue = ioqueue; … … 444 449 enum { BUF_SIZE = 512 }; 445 450 int i, rc; 451 enum 452 { 453 SOCK_DGRAM = 1, 454 SOCK_STREAM = 2, 455 }; 446 456 struct { 447 457 int type; … … 451 461 } test_param[] = 452 462 { 453 { PJ_SOCK_DGRAM, "udp", 1, 1},454 { PJ_SOCK_DGRAM, "udp", 1, 2},455 { PJ_SOCK_DGRAM, "udp", 1, 4},456 { PJ_SOCK_DGRAM, "udp", 1, 8},457 { PJ_SOCK_DGRAM, "udp", 2, 1},458 { PJ_SOCK_DGRAM, "udp", 2, 2},459 { PJ_SOCK_DGRAM, "udp", 2, 4},460 { PJ_SOCK_DGRAM, "udp", 2, 8},461 { PJ_SOCK_DGRAM, "udp", 4, 1},462 { PJ_SOCK_DGRAM, "udp", 4, 2},463 { PJ_SOCK_DGRAM, "udp", 4, 4},464 { PJ_SOCK_DGRAM, "udp", 4, 8},465 { PJ_SOCK_DGRAM, "udp", 4, 16},466 { PJ_SOCK_STREAM, "tcp", 1, 1},467 { PJ_SOCK_STREAM, "tcp", 1, 2},468 { PJ_SOCK_STREAM, "tcp", 1, 4},469 { PJ_SOCK_STREAM, "tcp", 1, 8},470 { PJ_SOCK_STREAM, "tcp", 2, 1},471 { PJ_SOCK_STREAM, "tcp", 2, 2},472 { PJ_SOCK_STREAM, "tcp", 2, 4},473 { PJ_SOCK_STREAM, "tcp", 2, 8},474 { PJ_SOCK_STREAM, "tcp", 4, 1},475 { PJ_SOCK_STREAM, "tcp", 4, 2},476 { PJ_SOCK_STREAM, "tcp", 4, 4},477 { PJ_SOCK_STREAM, "tcp", 4, 8},478 { PJ_SOCK_STREAM, "tcp", 4, 16},463 { SOCK_DGRAM, "udp", 1, 1}, 464 { SOCK_DGRAM, "udp", 1, 2}, 465 { SOCK_DGRAM, "udp", 1, 4}, 466 { SOCK_DGRAM, "udp", 1, 8}, 467 { SOCK_DGRAM, "udp", 2, 1}, 468 { SOCK_DGRAM, "udp", 2, 2}, 469 { SOCK_DGRAM, "udp", 2, 4}, 470 { SOCK_DGRAM, "udp", 2, 8}, 471 { SOCK_DGRAM, "udp", 4, 1}, 472 { SOCK_DGRAM, "udp", 4, 2}, 473 { SOCK_DGRAM, "udp", 4, 4}, 474 { SOCK_DGRAM, "udp", 4, 8}, 475 { SOCK_DGRAM, "udp", 4, 16}, 476 { SOCK_STREAM, "tcp", 1, 1}, 477 { SOCK_STREAM, "tcp", 1, 2}, 478 { SOCK_STREAM, "tcp", 1, 4}, 479 { SOCK_STREAM, "tcp", 1, 8}, 480 { SOCK_STREAM, "tcp", 2, 1}, 481 { SOCK_STREAM, "tcp", 2, 2}, 482 { SOCK_STREAM, "tcp", 2, 4}, 483 { SOCK_STREAM, "tcp", 2, 8}, 484 { SOCK_STREAM, "tcp", 4, 1}, 485 { SOCK_STREAM, "tcp", 4, 2}, 486 { SOCK_STREAM, "tcp", 4, 4}, 487 { SOCK_STREAM, "tcp", 4, 8}, 488 { SOCK_STREAM, "tcp", 4, 16}, 479 489 /* 480 { PJ_SOCK_DGRAM, "udp", 32, 1},481 { PJ_SOCK_DGRAM, "udp", 32, 1},482 { PJ_SOCK_DGRAM, "udp", 32, 1},483 { PJ_SOCK_DGRAM, "udp", 32, 1},484 { PJ_SOCK_DGRAM, "udp", 1, 32},485 { PJ_SOCK_DGRAM, "udp", 1, 32},486 { PJ_SOCK_DGRAM, "udp", 1, 32},487 { PJ_SOCK_DGRAM, "udp", 1, 32},488 { PJ_SOCK_STREAM, "tcp", 32, 1},489 { PJ_SOCK_STREAM, "tcp", 32, 1},490 { PJ_SOCK_STREAM, "tcp", 32, 1},491 { PJ_SOCK_STREAM, "tcp", 32, 1},492 { PJ_SOCK_STREAM, "tcp", 1, 32},493 { PJ_SOCK_STREAM, "tcp", 1, 32},494 { PJ_SOCK_STREAM, "tcp", 1, 32},495 { PJ_SOCK_STREAM, "tcp", 1, 32},490 { SOCK_DGRAM, "udp", 32, 1}, 491 { SOCK_DGRAM, "udp", 32, 1}, 492 { SOCK_DGRAM, "udp", 32, 1}, 493 { SOCK_DGRAM, "udp", 32, 1}, 494 { SOCK_DGRAM, "udp", 1, 32}, 495 { SOCK_DGRAM, "udp", 1, 32}, 496 { SOCK_DGRAM, "udp", 1, 32}, 497 { SOCK_DGRAM, "udp", 1, 32}, 498 { SOCK_STREAM, "tcp", 32, 1}, 499 { SOCK_STREAM, "tcp", 32, 1}, 500 { SOCK_STREAM, "tcp", 32, 1}, 501 { SOCK_STREAM, "tcp", 32, 1}, 502 { SOCK_STREAM, "tcp", 1, 32}, 503 { SOCK_STREAM, "tcp", 1, 32}, 504 { SOCK_STREAM, "tcp", 1, 32}, 505 { SOCK_STREAM, "tcp", 1, 32}, 496 506 */ 497 507 }; … … 503 513 PJ_LOG(3,(THIS_FILE, " Type Threads Skt.Pairs Bandwidth")); 504 514 PJ_LOG(3,(THIS_FILE, " =======================================")); 515 516 for (i=0; i<PJ_ARRAY_SIZE(test_param); ++i) { 517 if (test_param[i].type == SOCK_DGRAM) 518 test_param[i].type = PJ_SOCK_DGRAM; 519 else if (test_param[i].type == SOCK_STREAM) 520 test_param[i].type = PJ_SOCK_STREAM; 521 } 505 522 506 523 best_bandwidth = 0; -
pjproject/branches/symbian/pjlib/src/pjlib-test/ioq_tcp.c
r433 r788 34 34 #if INCLUDE_TCP_IOQUEUE_TEST 35 35 36 #include <pjlib.h> 36 #include <pj/assert.h> 37 #include <pj/errno.h> 38 #include <pj/ioqueue.h> 39 #include <pj/log.h> 40 #include <pj/pool.h> 41 #include <pj/sock.h> 42 #include <pj/string.h> 43 37 44 38 45 #if PJ_HAS_TCP -
pjproject/branches/symbian/pjlib/src/pjlib-test/ioq_udp.c
r433 r788 35 35 #if INCLUDE_UDP_IOQUEUE_TEST 36 36 37 #include <pjlib.h> 37 #include <pj/assert.h> 38 #include <pj/errno.h> 39 #include <pj/ioqueue.h> 40 #include <pj/log.h> 41 #include <pj/os.h> 42 #include <pj/pool.h> 43 #include <pj/sock.h> 44 #include <pj/string.h> 45 38 46 39 47 #include <pj/compat/socket.h> … … 329 337 pj_ssize_t bytes_read) 330 338 { 331 unsigned *p_packet_cnt = pj_ioqueue_get_user_data(key);339 unsigned *p_packet_cnt = (unsigned *)pj_ioqueue_get_user_data(key); 332 340 333 341 PJ_UNUSED_ARG(op_key); … … 511 519 return PJ_ENOMEM; 512 520 513 key = pj_pool_alloc(pool, MAX*sizeof(pj_ioqueue_key_t*));514 sock = pj_pool_alloc(pool, MAX*sizeof(pj_sock_t));521 key = (pj_ioqueue_key_t **)pj_pool_alloc(pool, MAX*sizeof(pj_ioqueue_key_t*)); 522 sock = (pj_sock_t *)pj_pool_alloc(pool, MAX*sizeof(pj_sock_t)); 515 523 516 524 /* Create IOQueue */ -
pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp
r692 r788 7 7 8 8 #include "test.h" 9 #include <stdlib.h> 10 #include <pj/errno.h> 11 #include <pj/os.h> 12 #include <pj/log.h> 13 #include <pj/unicode.h> 14 #include <stdio.h> 15 16 #include <e32std.h> 17 18 #if 0 19 int main() 20 { 21 int err = 0; 22 int exp = 0; 23 24 err = test_main(); 25 //err = test_main(); 26 27 if (err) 28 return err; 29 return exp; 30 //return 0; 31 } 32 33 #else 9 34 #include <pj/os.h> 10 35 … … 13 38 #include <e32cons.h> // Console 14 39 15 16 // Constants17 18 _LIT(KTextConsoleTitle, "Console");19 _LIT(KTextFailed, " failed, leave code = %d");20 _LIT(KTextPressAnyKey, " [press any key]\n");21 40 22 41 … … 29 48 30 49 LOCAL_C void MainL() 31 50 { 32 51 // 33 52 // add your program code here, example code below 34 53 // 35 54 test_main(); 36 } 55 CActiveScheduler::Stop(); 56 } 57 58 class MyScheduler : public CActiveScheduler 59 { 60 public: 61 MyScheduler() 62 {} 63 64 void Error(TInt aError) const; 65 }; 66 67 void MyScheduler::Error(TInt aError) const 68 { 69 int i = 0; 70 } 71 72 class ProgramStarter : public CActive 73 { 74 public: 75 static ProgramStarter *NewL(); 76 void Start(); 77 78 protected: 79 ProgramStarter(); 80 void ConstructL(); 81 virtual void RunL(); 82 virtual void DoCancel(); 83 TInt RunError(TInt aError); 84 85 private: 86 RTimer timer_; 87 }; 88 89 ProgramStarter::ProgramStarter() 90 : CActive(EPriorityNormal) 91 { 92 } 93 94 void ProgramStarter::ConstructL() 95 { 96 timer_.CreateLocal(); 97 CActiveScheduler::Add(this); 98 } 99 100 ProgramStarter *ProgramStarter::NewL() 101 { 102 ProgramStarter *self = new (ELeave) ProgramStarter; 103 CleanupStack::PushL(self); 104 105 self->ConstructL(); 106 107 CleanupStack::Pop(self); 108 return self; 109 } 110 111 void ProgramStarter::Start() 112 { 113 timer_.After(iStatus, 0); 114 SetActive(); 115 } 116 117 void ProgramStarter::RunL() 118 { 119 MainL(); 120 } 121 122 void ProgramStarter::DoCancel() 123 { 124 } 125 126 TInt ProgramStarter::RunError(TInt aError) 127 { 128 PJ_UNUSED_ARG(aError); 129 return KErrNone; 130 } 37 131 38 132 … … 40 134 { 41 135 // Create active scheduler (to run active objects) 42 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();136 CActiveScheduler* scheduler = new (ELeave) MyScheduler; 43 137 CleanupStack::PushL(scheduler); 44 138 CActiveScheduler::Install(scheduler); 45 139 46 MainL(); 140 ProgramStarter *starter = ProgramStarter::NewL(); 141 starter->Start(); 142 143 CActiveScheduler::Start(); 47 144 48 145 // Delete active scheduler 49 CleanupStack::PopAndDestroy(scheduler); 146 //CActiveScheduler::Install(NULL); 147 scheduler->Stop(); 148 //delete scheduler; 50 149 } 51 150 52 151 53 152 // Global Functions 153 154 static void log_writer(int level, const char *buf, int len) 155 { 156 wchar_t buf16[PJ_LOG_MAX_SIZE]; 157 158 pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16)); 159 160 TPtrC16 aBuf((const TUint16*)buf16, (TInt)len); 161 console->Write(aBuf); 162 } 163 54 164 55 165 GLDEF_C TInt E32Main() … … 60 170 61 171 // Create output console 62 TRAPD(createError, console = Console::NewL( KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));172 TRAPD(createError, console = Console::NewL(_L("Console"), TSize(KConsFullScreen,KConsFullScreen))); 63 173 if (createError) 64 174 return createError; 175 176 pj_log_set_log_func(&log_writer); 65 177 66 178 // Run application code inside TRAP harness, wait keypress when terminated 67 179 TRAPD(mainError, DoStartL()); 68 180 if (mainError) 69 console->Printf( KTextFailed, mainError);70 console->Printf( KTextPressAnyKey);181 console->Printf(_L(" failed, leave code = %d"), mainError); 182 console->Printf(_L(" [press any key]\n")); 71 183 console->Getch(); 72 184 … … 76 188 return KErrNone; 77 189 } 190 191 #endif /* if 0 */ 192 -
pjproject/branches/symbian/pjlib/src/pjlib-test/mutex.c
r65 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/errno.h> 21 #include <pj/os.h> 21 22 22 23 #if INCLUDE_MUTEX_TEST -
pjproject/branches/symbian/pjlib/src/pjlib-test/rand.c
r65 r788 23 23 #if INCLUDE_RAND_TEST 24 24 25 #define COUNT 1024 25 #if defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 26 # define COUNT 128 27 #else 28 # define COUNT 1024 29 #endif 30 26 31 static int values[COUNT]; 27 32 -
pjproject/branches/symbian/pjlib/src/pjlib-test/select.c
r65 r788 72 72 } 73 73 74 timeout.sec = 1;74 timeout.sec = 5; 75 75 timeout.msec = 0; 76 76 -
pjproject/branches/symbian/pjlib/src/pjlib-test/sock.c
r433 r788 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 #include <pjlib.h> 19 #include <pj/errno.h> 20 #include <pj/ioqueue.h> 21 #include <pj/log.h> 22 #include <pj/sock.h> 23 #include <pj/string.h> 20 24 #include "test.h" 21 25 … … 65 69 #define BIG_DATA_LEN 9000 66 70 #define ADDRESS "127.0.0.1" 67 #define A0 12768 #define A1 069 #define A2 070 #define A3 171 71 72 72 … … 80 80 pj_in_addr addr; 81 81 const pj_str_t *hostname; 82 #if defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 83 /* Symbian IP address is saved in host order */ 84 unsigned char A[] = {1, 0, 0, 127}; 85 #else 86 unsigned char A[] = {127, 0, 0, 1}; 87 #endif 82 88 83 89 PJ_LOG(3,("test", "...format_test()")); … … 89 95 /* Check the result. */ 90 96 p = (unsigned char*)&addr; 91 if (p[0]!=A 0 || p[1]!=A1 || p[2]!=A2 || p[3]!=A3) {97 if (p[0]!=A[0] || p[1]!=A[1] || p[2]!=A[2] || p[3]!=A[3]) { 92 98 PJ_LOG(3,("test", " error: mismatched address. p0=%d, p1=%d, " 93 99 "p2=%d, p3=%d", p[0] & 0xFF, p[1] & 0xFF, … … 97 103 98 104 /* pj_inet_ntoa() */ 99 p = pj_inet_ntoa(addr);105 p = (unsigned char*)pj_inet_ntoa(addr); 100 106 if (!p) 101 107 return -20; 102 108 103 if (pj_strcmp2(&s, p) != 0)109 if (pj_strcmp2(&s, (char*)p) != 0) 104 110 return -30; 105 111 -
pjproject/branches/symbian/pjlib/src/pjlib-test/sock_perf.c
r65 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/errno.h> 21 #include <pj/ioqueue.h> 22 #include <pj/log.h> 23 #include <pj/os.h> 24 #include <pj/pool.h> 25 #include <pj/sock.h> 21 26 #include <pj/compat/high_precision.h> 22 27 … … 70 75 71 76 /* Create buffers. */ 72 outgoing_buffer = pj_pool_alloc(pool, buf_size);73 incoming_buffer = pj_pool_alloc(pool, buf_size);77 outgoing_buffer = (char*)pj_pool_alloc(pool, buf_size); 78 incoming_buffer = (char*)pj_pool_alloc(pool, buf_size); 74 79 75 80 /* Start loop. */ -
pjproject/branches/symbian/pjlib/src/pjlib-test/string_test.c
r692 r788 284 284 int string_test(void) 285 285 { 286 const pj_str_t hello_world = { HELLO_WORLD, strlen(HELLO_WORLD) };287 const pj_str_t just_hello = { JUST_HELLO, strlen(JUST_HELLO) };286 pj_str_t hello_world; 287 pj_str_t just_hello; 288 288 pj_str_t s1, s2, s3, s4, s5; 289 289 enum { RCOUNT = 10, RLEN = 16 }; … … 291 291 pj_pool_t *pool; 292 292 int i; 293 294 hello_world = pj_str(HELLO_WORLD); 295 just_hello = pj_str(JUST_HELLO); 293 296 294 297 pool = pj_pool_create(mem, NULL, 4096, 0, NULL); … … 328 331 * pj_strcpy(), pj_strcat() 329 332 */ 330 s3.ptr = pj_pool_alloc(pool, 256);333 s3.ptr = (char*)pj_pool_alloc(pool, 256); 331 334 if (!s3.ptr) 332 335 return -200; … … 348 351 * pj_utoa() 349 352 */ 350 s5.ptr = pj_pool_alloc(pool, 16);353 s5.ptr = (char*)pj_pool_alloc(pool, 16); 351 354 if (!s5.ptr) 352 355 return -270; … … 366 369 int j; 367 370 368 random[i].ptr = pj_pool_alloc(pool, RLEN);371 random[i].ptr = (char*)pj_pool_alloc(pool, RLEN); 369 372 if (!random[i].ptr) 370 373 return -320; -
pjproject/branches/symbian/pjlib/src/pjlib-test/test.c
r687 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/errno.h> 21 #include <pj/ioqueue.h> 22 #include <pj/log.h> 23 #include <pj/os.h> 24 #include <pj/pool.h> 25 #include <pj/sock.h> 26 21 27 #ifdef _MSC_VER 22 28 # pragma warning(disable:4127) … … 195 201 int test_main(void) 196 202 { 197 PJ_USE_EXCEPTION; 198 199 PJ_TRY { 200 return test_inner(); 201 } 202 PJ_CATCH_ANY { 203 int id = PJ_GET_EXCEPTION(); 204 PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)", 205 id, pj_exception_id_name(id))); 206 } 207 PJ_END; 208 209 return -1; 203 return test_inner(); 210 204 } -
pjproject/branches/symbian/pjlib/src/pjlib-test/test.h
r496 r788 25 25 #define GROUP_OS 0 26 26 #define GROUP_DATA_STRUCTURE 0 27 #define GROUP_NETWORK 027 #define GROUP_NETWORK 1 28 28 #define GROUP_FILE 0 29 29 30 #define INCLUDE_ERRNO_TEST GROUP_LIBC30 #define INCLUDE_ERRNO_TEST 0 // GROUP_LIBC 31 31 #define INCLUDE_TIMESTAMP_TEST GROUP_OS 32 32 #define INCLUDE_EXCEPTION_TEST GROUP_LIBC … … 34 34 #define INCLUDE_LIST_TEST GROUP_DATA_STRUCTURE 35 35 #define INCLUDE_POOL_TEST GROUP_LIBC 36 #define INCLUDE_POOL_PERF_TEST (PJ_HAS_MALLOC && GROUP_LIBC)37 #define INCLUDE_STRING_TEST GROUP_DATA_STRUCTURE36 #define INCLUDE_POOL_PERF_TEST 0 // (PJ_HAS_MALLOC && GROUP_LIBC) 37 #define INCLUDE_STRING_TEST 0 // GROUP_DATA_STRUCTURE 38 38 #define INCLUDE_FIFOBUF_TEST 0 // GROUP_DATA_STRUCTURE 39 39 #define INCLUDE_RBTREE_TEST GROUP_DATA_STRUCTURE 40 40 #define INCLUDE_TIMER_TEST GROUP_DATA_STRUCTURE 41 41 #define INCLUDE_ATOMIC_TEST GROUP_OS 42 #define INCLUDE_MUTEX_TEST GROUP_OS42 #define INCLUDE_MUTEX_TEST (PJ_HAS_THREADS && GROUP_OS) 43 43 #define INCLUDE_SLEEP_TEST GROUP_OS 44 #define INCLUDE_THREAD_TEST GROUP_OS45 #define INCLUDE_SOCK_TEST GROUP_NETWORK46 #define INCLUDE_SOCK_PERF_TEST GROUP_NETWORK47 #define INCLUDE_SELECT_TEST GROUP_NETWORK44 #define INCLUDE_THREAD_TEST (PJ_HAS_THREADS && GROUP_OS) 45 #define INCLUDE_SOCK_TEST 0 // GROUP_NETWORK 46 #define INCLUDE_SOCK_PERF_TEST 0 // GROUP_NETWORK 47 #define INCLUDE_SELECT_TEST 0 // GROUP_NETWORK 48 48 #define INCLUDE_UDP_IOQUEUE_TEST GROUP_NETWORK 49 49 #define INCLUDE_TCP_IOQUEUE_TEST GROUP_NETWORK -
pjproject/branches/symbian/pjlib/src/pjlib-test/timestamp.c
r433 r788 196 196 } 197 197 198 sleep(0);198 pj_thread_sleep(0); 199 199 200 200 /* Mark end time. */ -
pjproject/branches/symbian/pjlib/src/pjlib-test/udp_echo_srv_ioqueue.c
r65 r788 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 #include <pjlib.h> 19 #include <pj/errno.h> 20 #include <pj/ioqueue.h> 21 #include <pj/pool.h> 22 #include <pj/sock.h> 20 23 #include "test.h" 21 24 … … 118 121 static int worker_thread(void *arg) 119 122 { 120 pj_ioqueue_t *ioqueue = arg;123 pj_ioqueue_t *ioqueue = (pj_ioqueue_t *)arg; 121 124 struct op_key read_op, write_op; 122 125 char recv_buf[512], send_buf[512]; -
pjproject/branches/symbian/pjlib/src/pjlib-test/udp_echo_srv_sync.c
r65 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/errno.h> 21 #include <pj/ioqueue.h> 22 #include <pj/os.h> 23 #include <pj/pool.h> 24 #include <pj/sock.h> 25 #include <pj/compat/high_precision.h> 26 21 27 22 28 static pj_atomic_t *total_bytes; -
pjproject/branches/symbian/pjlib/src/pjlib-test/util.c
r433 r788 18 18 */ 19 19 #include "test.h" 20 #include <pjlib.h> 20 #include <pj/errno.h> 21 #include <pj/log.h> 22 #include <pj/os.h> 23 #include <pj/sock.h> 24 #include <pj/string.h> 25 21 26 22 27 #define THIS_FILE "util.c" -
pjproject/branches/symbian/symbian/ABLD.BAT
r692 r788 4 4 REM ** DO NOT EDIT ** 5 5 6 perl -S ABLD.PL "\Project\ symbian\symbian\\" %1 %2 %3 %4 %5 %6 %7 %8 %96 perl -S ABLD.PL "\Project\pjsymbian\symbian\\" %1 %2 %3 %4 %5 %6 %7 %8 %9 7 7 if errorlevel==1 goto CheckPerl 8 8 goto End -
pjproject/branches/symbian/symbian/b.bat
r692 r788 1 1 rem set MWSym2Libraries=1 2 2 rem set MWSym2Libraries=\Symbian\9.1\S60_3rd\Epoc32\release\winscw\udeb 3 set EPOCROOT=\Symbian\9.1\S60_3rd\ 4 abld build -v winscw udeb 3 rem set EPOCROOT=\Symbian\9.1\S60_3rd\ 4 rem call abld build -v winscw udeb 5 6 set EPOCROOT=\Symbian\UIQ3SDK\ 7 call abld build -v vs6 udeb -
pjproject/branches/symbian/symbian/bld.inf
r692 r788 1 1 prj_mmpfiles 2 2 pjlib.mmp 3 pjlib -test.mmp3 pjlib_test.mmp -
pjproject/branches/symbian/symbian/pjlib.mmp
r692 r788 1 TARGET pjlib -symbian.lib1 TARGET pjlib.lib 2 2 TARGETTYPE lib 3 3 UID 0x100039CE 0x10004299 … … 17 17 SOURCE ctype.c 18 18 SOURCE errno.c 19 SOURCE except.c20 19 SOURCE fifobuf.c 21 20 SOURCE guid.c … … 37 36 // Platform dependent source 38 37 // 39 SOURCE addr_resolv_sock.c 38 SOURCE addr_resolv_symbian.cpp 39 SOURCE exception_symbian.cpp 40 40 SOURCE file_access_unistd.c 41 41 SOURCE file_io_ansi.c 42 42 SOURCE guid_simple.c 43 SOURCE log_writer_s tdout.c43 SOURCE log_writer_symbian_console.cpp 44 44 SOURCE os_core_symbian.cpp 45 SOURCE os_error_unix.c 45 SOURCE os_error_symbian.cpp 46 SOURCE os_timestamp_common.c 46 47 SOURCE os_time_unix.c 47 SOURCE os_timestamp_common.c48 48 SOURCE os_timestamp_posix.c 49 SOURCE pool_policy_ malloc.c49 SOURCE pool_policy_new.cpp 50 50 SOURCE compat\string_compat.c 51 SOURCE sock_ bsd.c51 SOURCE sock_symbian.cpp 52 52 SOURCE sock_select_symbian.cpp 53 53 SOURCE ioqueue_symbian.cpp 54 SOURCE unicode_symbian.cpp 54 55 55 56 56 57 SYSTEMINCLUDE ..\pjlib\include 57 //SYSTEMINCLUDE \symbian\9.1\S60_3rd_MR\epoc32\include 58 //SYSTEMINCLUDE \symbian\9.1\S60_3rd_MR\epoc32\include\libc 59 SYSTEMINCLUDE \symbian\9.1\S60_3rd\epoc32\include 60 SYSTEMINCLUDE \symbian\9.1\S60_3rd\epoc32\include\libc 58 SYSTEMINCLUDE \epoc32\include 59 SYSTEMINCLUDE \epoc32\include\libc -
pjproject/branches/symbian/symbian/pjlib_test.mmp
r692 r788 1 TARGET pjlib -test-symbian.exe1 TARGET pjlib_test.exe 2 2 TARGETTYPE exe 3 3 UID 0x100039CE 0x10004299 … … 44 44 45 45 SOURCE main_symbian.cpp 46 //SOURCE main.c 46 47 47 48 48 49 SYSTEMINCLUDE ..\pjlib\include 49 SYSTEMINCLUDE \ symbian\9.1\S60_3rd\epoc32\include50 SYSTEMINCLUDE \ symbian\9.1\S60_3rd\epoc32\include\libc50 SYSTEMINCLUDE \epoc32\include 51 SYSTEMINCLUDE \epoc32\include\libc 51 52 //SYSTEMINCLUDE \symbian\9.1\S60_3rd_MR\epoc32\include 52 53 //SYSTEMINCLUDE \symbian\9.1\S60_3rd_MR\epoc32\include\libc 53 54 54 LIBRARY pjlib -symbian.lib euser.lib estlib.lib eexe.lib55 //eexe.lib 55 LIBRARY pjlib.lib esock.lib insock.lib charconv.lib euser.lib estlib.lib eexe.lib 56 STATICLIBRARY ecrt0.lib 56 57 CAPABILITY None 57 58 -
pjproject/branches/symbian/symbian/s.bat
r692 r788 1 1 rem set MWSym2Libraries=1 2 set EPOCROOT=\Symbian\9.1\S60_3rd\ 2 rem set EPOCROOT=\Symbian\9.1\S60_3rd\ 3 set EPOCROOT=\Symbian\UIQ3SDK\ 3 4 bldmake bldfiles 4 5 call b.bat
Note: See TracChangeset
for help on using the changeset viewer.