Changeset 3110 for pjproject/trunk/pjlib/src/pj/ssl_sock_dump.c
- Timestamp:
- Feb 25, 2010 11:58:19 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_dump.c
r3106 r3110 28 28 #define THIS_FILE "ssl_sock_dump.c" 29 29 30 #define CHECK_BUF_LEN() \ 31 if ((len < 0) || ((p+=len) >= end)) { \ 32 *(p-1) = '\0'; \ 33 return PJ_ETOOSMALL; \ 34 } 30 #define CHECK_BUF_LEN() \ 31 if ((len < 0) || (len >= end-p)) { \ 32 *p = '\0'; \ 33 return -1; \ 34 } \ 35 p += len; 35 36 36 PJ_DEF(pj_s tatus_t) pj_ssl_cert_info_dump(const pj_ssl_cert_info *ci,37 const char *prefix,38 39 37 PJ_DEF(pj_ssize_t) pj_ssl_cert_info_dump(const pj_ssl_cert_info *ci, 38 const char *indent, 39 char *buf, 40 pj_size_t buf_size) 40 41 { 41 42 const char *wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; … … 54 55 /* Version */ 55 56 len = pj_ansi_snprintf(p, end-p, "%sVersion : v%d\n", 56 prefix, ci->version);57 indent, ci->version); 57 58 CHECK_BUF_LEN(); 58 59 59 60 /* Serial number */ 60 len = pj_ansi_snprintf(p, end-p, "%sSerial : ", prefix);61 len = pj_ansi_snprintf(p, end-p, "%sSerial : ", indent); 61 62 CHECK_BUF_LEN(); 62 63 … … 69 70 70 71 /* Subject */ 71 len = pj_ansi_snprintf( p, end-p, "%sSubject : %.*s\n", prefix,72 len = pj_ansi_snprintf( p, end-p, "%sSubject : %.*s\n", indent, 72 73 ci->subject.cn.slen, 73 74 ci->subject.cn.ptr); 74 75 CHECK_BUF_LEN(); 75 len = pj_ansi_snprintf( p, end-p, "%s %.*s\n", prefix,76 len = pj_ansi_snprintf( p, end-p, "%s %.*s\n", indent, 76 77 ci->subject.info.slen, 77 78 ci->subject.info.ptr); … … 79 80 80 81 /* Issuer */ 81 len = pj_ansi_snprintf( p, end-p, "%sIssuer : %.*s\n", prefix,82 len = pj_ansi_snprintf( p, end-p, "%sIssuer : %.*s\n", indent, 82 83 ci->issuer.cn.slen, 83 84 ci->issuer.cn.ptr); 84 85 CHECK_BUF_LEN(); 85 len = pj_ansi_snprintf( p, end-p, "%s %.*s\n", prefix,86 len = pj_ansi_snprintf( p, end-p, "%s %.*s\n", indent, 86 87 ci->issuer.info.slen, 87 88 ci->issuer.info.ptr); … … 90 91 /* Validity period */ 91 92 len = pj_ansi_snprintf( p, end-p, "%sValid from : %s %4d-%02d-%02d " 92 "%02d:%02d:%02d.%03d %s\n", prefix,93 "%02d:%02d:%02d.%03d %s\n", indent, 93 94 wdays[pt1.wday], pt1.year, pt1.mon+1, pt1.day, 94 95 pt1.hour, pt1.min, pt1.sec, pt1.msec, … … 97 98 98 99 len = pj_ansi_snprintf( p, end-p, "%sValid to : %s %4d-%02d-%02d " 99 "%02d:%02d:%02d.%03d %s\n", prefix,100 "%02d:%02d:%02d.%03d %s\n", indent, 100 101 wdays[pt2.wday], pt2.year, pt2.mon+1, pt2.day, 101 102 pt2.hour, pt2.min, pt2.sec, pt2.msec, … … 108 109 109 110 len = pj_ansi_snprintf(p, end-p, "%ssubjectAltName extension\n", 110 prefix);111 indent); 111 112 CHECK_BUF_LEN(); 112 113 … … 131 132 } 132 133 if (type) { 133 len = pj_ansi_snprintf( p, end-p, "%s %s : %.*s\n", prefix,134 len = pj_ansi_snprintf( p, end-p, "%s %s : %.*s\n", indent, 134 135 type, 135 136 ci->subj_alt_name.entry[i].name.slen, … … 140 141 } 141 142 142 return PJ_SUCCESS;143 return (p-buf); 143 144 } 144 145
Note: See TracChangeset
for help on using the changeset viewer.