Changeset 80
- Timestamp:
- Nov 23, 2005 11:25:17 AM (19 years ago)
- Location:
- pjproject/trunk/pjsip/src/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r77 r80 998 998 ... ) 999 999 { 1000 #if PJ_LOG_MAX_LEVEL > 0 1000 1001 char newformat[256]; 1001 1002 int len; … … 1027 1028 1028 1029 va_end(marker); 1030 #else 1031 PJ_UNUSED_ARG(format); 1032 PJ_UNUSED_ARG(error_code); 1033 PJ_UNUSED_ARG(sender); 1034 PJ_UNUSED_ARG(endpt); 1035 #endif 1029 1036 } 1030 1037 … … 1111 1118 pj_mutex_unlock(endpt->mutex); 1112 1119 #else 1120 PJ_UNUSED_ARG(endpt); 1121 PJ_UNUSED_ARG(detail); 1113 1122 PJ_LOG(3,(THIS_FILE, "pjsip_end_dump: can't dump because it's disabled.")); 1114 1123 #endif -
pjproject/trunk/pjsip/src/pjsip/sip_parser.c
r77 r80 53 53 54 54 #define UNREACHED(expr) 55 56 //#define IS_NEWLINE(c) ((c)=='\r' || (c)=='\n') 57 #define IS_NEWLINE(c) ((c)=='\r') 58 #define IS_SPACE(c) ((c)==' ' || (c)=='\t') 55 59 56 60 typedef struct handler_rec … … 543 547 pj_scanner scanner; 544 548 pjsip_parse_ctx context; 545 PJ_USE_EXCEPTION;546 549 547 550 init_sip_parser(); … … 554 557 context.rdata = NULL; 555 558 556 PJ_TRY { 557 msg = int_parse_msg(&context, err_list); 558 } 559 PJ_CATCH_ANY { 560 msg = NULL; 561 } 562 PJ_END 559 msg = int_parse_msg(&context, err_list); 563 560 564 561 pj_scan_fini(&scanner); … … 572 569 pj_scanner scanner; 573 570 pjsip_parse_ctx context; 574 PJ_USE_EXCEPTION;575 571 576 572 init_sip_parser(); … … 583 579 context.rdata = rdata; 584 580 585 PJ_TRY { 586 rdata->msg_info.msg = int_parse_msg(&context, &rdata->msg_info.parse_err); 587 } 588 PJ_CATCH_ANY { 589 rdata->msg_info.msg = NULL; 590 } 591 PJ_END 581 rdata->msg_info.msg = int_parse_msg(&context, &rdata->msg_info.parse_err); 592 582 593 583 pj_scan_fini(&scanner); … … 719 709 720 710 /* Must have exhausted all inputs. */ 721 if (pj_scan_is_eof(&scanner) || *scanner.curptr=='\r' || 722 *scanner.curptr=='\n') 723 { 711 if (pj_scan_is_eof(&scanner) || IS_NEWLINE(*scanner.curptr)) { 724 712 /* Success. */ 725 713 pj_scan_fini(&scanner); … … 751 739 pjsip_parser_err_report *err_list) 752 740 { 753 pjsip_msg *msg; 741 pj_bool_t parsing_headers; 742 pjsip_msg *msg = NULL; 754 743 pj_str_t hname; 755 744 pjsip_ctype_hdr *ctype_hdr = NULL; … … 758 747 PJ_USE_EXCEPTION; 759 748 760 /* Skip leading newlines. */ 761 while (*scanner->curptr=='\r' || *scanner->curptr=='\n') { 762 pj_scan_get_newline(scanner); 763 } 764 765 /* Parse request or status line */ 766 if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) { 767 msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG); 768 int_parse_status_line( scanner, &msg->line.status ); 769 } else { 770 msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG); 771 int_parse_req_line(scanner, pool, &msg->line.req ); 772 } 773 774 /* Parse headers. */ 775 parse_headers: 749 parsing_headers = PJ_FALSE; 776 750 777 751 PJ_TRY 778 752 { 753 if (parsing_headers) 754 goto parse_headers; 755 756 /* Skip leading newlines. */ 757 while (IS_NEWLINE(*scanner->curptr)) { 758 pj_scan_get_newline(scanner); 759 } 760 761 /* Parse request or status line */ 762 if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) { 763 msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG); 764 int_parse_status_line( scanner, &msg->line.status ); 765 } else { 766 msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG); 767 int_parse_req_line(scanner, pool, &msg->line.req ); 768 } 769 770 parsing_headers = PJ_TRUE; 771 772 parse_headers: 773 /* Parse headers. */ 779 774 do { 780 775 pjsip_parse_hdr_func * handler; … … 796 791 if (handler) { 797 792 hdr = (*handler)(ctx); 793 794 /* Check if we've just parsed a Content-Type header. 795 * We will check for a message body if we've got Content-Type 796 * header. 797 */ 798 if (hdr->type == PJSIP_H_CONTENT_TYPE) { 799 ctype_hdr = (pjsip_ctype_hdr*)hdr; 800 } 801 798 802 } else { 799 803 hdr = parse_hdr_generic_string(ctx); 800 hdr->type = PJSIP_H_OTHER;801 804 hdr->name = hdr->sname = hname; 802 805 } 803 806 804 /* Check if we've just parsed a Content-Type header. 805 * We will check for a message body if we've got Content-Type 806 * header. 807 */ 808 if (hdr->type == PJSIP_H_CONTENT_TYPE) { 809 ctype_hdr = (pjsip_ctype_hdr*)hdr; 810 } 811 807 812 808 /* Single parse of header line can produce multiple headers. 813 809 * For example, if one Contact: header contains Contact list … … 819 815 820 816 /* Parse until EOF or an empty line is found. */ 821 } while (!pj_scan_is_eof(scanner) && 822 *scanner->curptr != '\r' && *scanner->curptr != '\n'); 817 } while (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr)); 823 818 819 parsing_headers = PJ_FALSE; 820 821 /* If empty line is found, eat it. */ 822 if (!pj_scan_is_eof(scanner)) { 823 if (IS_NEWLINE(*scanner->curptr)) { 824 pj_scan_get_newline(scanner); 825 } 826 } 827 828 /* If we have Content-Type header, treat the rest of the message 829 * as body. 830 */ 831 if (ctype_hdr && scanner->curptr!=scanner->end) { 832 pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body)); 833 body->content_type.type = ctype_hdr->media.type; 834 body->content_type.subtype = ctype_hdr->media.subtype; 835 body->content_type.param = ctype_hdr->media.param; 836 837 body->data = scanner->curptr; 838 body->len = scanner->end - scanner->curptr; 839 body->print_body = &generic_print_body; 840 841 msg->body = body; 842 } 824 843 } 825 844 PJ_CATCH_ANY … … 828 847 * Skip until newline, and parse next header. 829 848 */ 830 pj_str_t token;831 832 849 if (err_list) { 833 850 pjsip_parser_err_report *err_info; … … 837 854 err_info->line = scanner->line; 838 855 err_info->col = pj_scan_get_col(scanner); 839 err_info->hname = hname; 856 if (parsing_headers) 857 err_info->hname = hname; 858 else 859 err_info->hname.slen = 0; 840 860 841 861 pj_list_insert_before(err_list, err_info); 842 862 } 843 863 844 if (!pj_scan_is_eof(scanner)) { 845 pj_scan_get(scanner, &pjsip_NOT_NEWLINE, &token); 846 parse_hdr_end(scanner); 847 } 848 849 if (!pj_scan_is_eof(scanner) && 850 *scanner->curptr != '\r' && *scanner->curptr != '\n'); 851 { 852 goto parse_headers; 853 } 864 if (parsing_headers) { 865 if (!pj_scan_is_eof(scanner)) { 866 /* Skip until next line. 867 * Watch for header continuation. 868 */ 869 do { 870 pj_scan_skip_line(scanner); 871 } while (IS_SPACE(*scanner->curptr)); 872 } 873 874 if (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr)) { 875 goto parse_headers; 876 } 877 } 878 879 msg = NULL; 854 880 } 855 881 PJ_END; 856 857 858 /* If empty line is found, eat it. */859 if (!pj_scan_is_eof(scanner)) {860 if (*scanner->curptr=='\r' || *scanner->curptr=='\n') {861 pj_scan_get_newline(scanner);862 }863 }864 865 /* If we have Content-Type header, treat the rest of the message as body.*/866 if (ctype_hdr && scanner->curptr!=scanner->end) {867 pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body));868 body->content_type.type = ctype_hdr->media.type;869 body->content_type.subtype = ctype_hdr->media.subtype;870 body->content_type.param = ctype_hdr->media.param;871 872 body->data = scanner->curptr;873 body->len = scanner->end - scanner->curptr;874 body->print_body = &generic_print_body;875 876 msg->body = body;877 }878 882 879 883 return msg; -
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r65 r80 839 839 840 840 pj_lock_release(mgr->lock); 841 #else 842 PJ_UNUSED_ARG(mgr); 841 843 #endif 842 844 }
Note: See TracChangeset
for help on using the changeset viewer.