diff options
| author | beck <> | 2000-04-15 06:18:51 +0000 |
|---|---|---|
| committer | beck <> | 2000-04-15 06:18:51 +0000 |
| commit | b608c7f2b175e121f2c22d53341a317153afdc8e (patch) | |
| tree | e94b160b3fcd8180df79e4251d68d24d665f0195 /src/lib/libcrypto/bio | |
| parent | c8d6701c396cebdcd0d45eac73b762e9498f6b01 (diff) | |
| download | openbsd-b608c7f2b175e121f2c22d53341a317153afdc8e.tar.gz openbsd-b608c7f2b175e121f2c22d53341a317153afdc8e.tar.bz2 openbsd-b608c7f2b175e121f2c22d53341a317153afdc8e.zip | |
OpenSSL 0.9.5a merge
Diffstat (limited to 'src/lib/libcrypto/bio')
| -rw-r--r-- | src/lib/libcrypto/bio/Makefile.ssl | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/b_print.c | 230 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio.h | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_err.c | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_bio.c | 39 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_log.c | 220 |
7 files changed, 378 insertions, 124 deletions
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl index 2e7480ead9..755f255fe4 100644 --- a/src/lib/libcrypto/bio/Makefile.ssl +++ b/src/lib/libcrypto/bio/Makefile.ssl | |||
| @@ -172,8 +172,10 @@ bss_acpt.o: ../../include/openssl/opensslconf.h | |||
| 172 | bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 172 | bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h |
| 173 | bss_acpt.o: ../../include/openssl/stack.h ../cryptlib.h | 173 | bss_acpt.o: ../../include/openssl/stack.h ../cryptlib.h |
| 174 | bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 174 | bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
| 175 | bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h | 175 | bss_bio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
| 176 | bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 176 | bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h |
| 177 | bss_bio.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 178 | bss_bio.o: ../../include/openssl/stack.h | ||
| 177 | bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 179 | bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 178 | bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | 180 | bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h |
| 179 | bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 181 | bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c index 2a5e8b58c9..b11b501512 100644 --- a/src/lib/libcrypto/bio/b_print.c +++ b/src/lib/libcrypto/bio/b_print.c | |||
| @@ -64,6 +64,8 @@ | |||
| 64 | #include <stdarg.h> | 64 | #include <stdarg.h> |
| 65 | #include <string.h> | 65 | #include <string.h> |
| 66 | #include <ctype.h> | 66 | #include <ctype.h> |
| 67 | #include <assert.h> | ||
| 68 | #include <limits.h> | ||
| 67 | #include "cryptlib.h" | 69 | #include "cryptlib.h" |
| 68 | #ifndef NO_SYS_TYPES_H | 70 | #ifndef NO_SYS_TYPES_H |
| 69 | #include <sys/types.h> | 71 | #include <sys/types.h> |
| @@ -72,12 +74,16 @@ | |||
| 72 | 74 | ||
| 73 | #ifdef BN_LLONG | 75 | #ifdef BN_LLONG |
| 74 | # ifndef HAVE_LONG_LONG | 76 | # ifndef HAVE_LONG_LONG |
| 75 | # define HAVE_LONG_LONG | 77 | # define HAVE_LONG_LONG 1 |
| 76 | # endif | 78 | # endif |
| 77 | #endif | 79 | #endif |
| 78 | 80 | ||
| 79 | static void dopr (char *buffer, size_t maxlen, size_t *retlen, | 81 | static void dopr (char *buffer, size_t maxlen, size_t *retlen, |
| 80 | const char *format, va_list args); | 82 | const char *format, va_list args); |
| 83 | #ifdef USE_ALLOCATING_PRINT | ||
| 84 | static void doapr (char **buffer, size_t *retlen, | ||
| 85 | const char *format, va_list args); | ||
| 86 | #endif | ||
| 81 | 87 | ||
| 82 | int BIO_printf (BIO *bio, ...) | 88 | int BIO_printf (BIO *bio, ...) |
| 83 | { | 89 | { |
| @@ -85,15 +91,32 @@ int BIO_printf (BIO *bio, ...) | |||
| 85 | char *format; | 91 | char *format; |
| 86 | int ret; | 92 | int ret; |
| 87 | size_t retlen; | 93 | size_t retlen; |
| 94 | #ifdef USE_ALLOCATING_PRINT | ||
| 95 | char *hugebuf; | ||
| 96 | #else | ||
| 88 | MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */ | 97 | MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */ |
| 98 | #endif | ||
| 89 | 99 | ||
| 90 | va_start(args, bio); | 100 | va_start(args, bio); |
| 91 | format=va_arg(args, char *); | 101 | format=va_arg(args, char *); |
| 92 | 102 | ||
| 103 | #ifndef USE_ALLOCATING_PRINT | ||
| 93 | hugebuf[0]='\0'; | 104 | hugebuf[0]='\0'; |
| 94 | dopr(hugebuf, sizeof(hugebuf), &retlen, format, args); | 105 | dopr(hugebuf, sizeof(hugebuf), &retlen, format, args); |
| 95 | ret=BIO_write(bio, hugebuf, (int)retlen); | 106 | #else |
| 107 | hugebuf = NULL; | ||
| 108 | CRYPTO_push_info("doapr()"); | ||
| 109 | doapr(&hugebuf, &retlen, format, args); | ||
| 110 | if (hugebuf) | ||
| 111 | { | ||
| 112 | #endif | ||
| 113 | ret=BIO_write(bio, hugebuf, (int)retlen); | ||
| 96 | 114 | ||
| 115 | #ifdef USE_ALLOCATING_PRINT | ||
| 116 | Free(hugebuf); | ||
| 117 | } | ||
| 118 | CRYPTO_pop_info(); | ||
| 119 | #endif | ||
| 97 | va_end(args); | 120 | va_end(args); |
| 98 | return(ret); | 121 | return(ret); |
| 99 | } | 122 | } |
| @@ -131,10 +154,26 @@ int BIO_printf (BIO *bio, ...) | |||
| 131 | #define LLONG long | 154 | #define LLONG long |
| 132 | #endif | 155 | #endif |
| 133 | 156 | ||
| 134 | static void fmtstr (char *, size_t *, size_t, char *, int, int, int); | 157 | static void fmtstr (void (*)(char **, size_t *, size_t *, int), |
| 135 | static void fmtint (char *, size_t *, size_t, LLONG, int, int, int, int); | 158 | char **, size_t *, size_t *, const char *, int, int, |
| 136 | static void fmtfp (char *, size_t *, size_t, LDOUBLE, int, int, int); | 159 | int); |
| 137 | static void dopr_outch (char *, size_t *, size_t, int); | 160 | static void fmtint (void (*)(char **, size_t *, size_t *, int), |
| 161 | char **, size_t *, size_t *, LLONG, int, int, int, int); | ||
| 162 | static void fmtfp (void (*)(char **, size_t *, size_t *, int), | ||
| 163 | char **, size_t *, size_t *, LDOUBLE, int, int, int); | ||
| 164 | #ifndef USE_ALLOCATING_PRINT | ||
| 165 | static int dopr_isbig (size_t, size_t); | ||
| 166 | static int dopr_copy (size_t); | ||
| 167 | static void dopr_outch (char **, size_t *, size_t *, int); | ||
| 168 | #else | ||
| 169 | static int doapr_isbig (size_t, size_t); | ||
| 170 | static int doapr_copy (size_t); | ||
| 171 | static void doapr_outch (char **, size_t *, size_t *, int); | ||
| 172 | #endif | ||
| 173 | static void _dopr(void (*)(char **, size_t *, size_t *, int), | ||
| 174 | int (*)(size_t, size_t), int (*)(size_t), | ||
| 175 | char **buffer, size_t *maxlen, size_t *retlen, | ||
| 176 | const char *format, va_list args); | ||
| 138 | 177 | ||
| 139 | /* format read states */ | 178 | /* format read states */ |
| 140 | #define DP_S_DEFAULT 0 | 179 | #define DP_S_DEFAULT 0 |
| @@ -165,6 +204,7 @@ static void dopr_outch (char *, size_t *, size_t, int); | |||
| 165 | #define char_to_int(p) (p - '0') | 204 | #define char_to_int(p) (p - '0') |
| 166 | #define MAX(p,q) ((p >= q) ? p : q) | 205 | #define MAX(p,q) ((p >= q) ? p : q) |
| 167 | 206 | ||
| 207 | #ifndef USE_ALLOCATING_PRINT | ||
| 168 | static void | 208 | static void |
| 169 | dopr( | 209 | dopr( |
| 170 | char *buffer, | 210 | char *buffer, |
| @@ -173,6 +213,35 @@ dopr( | |||
| 173 | const char *format, | 213 | const char *format, |
| 174 | va_list args) | 214 | va_list args) |
| 175 | { | 215 | { |
| 216 | _dopr(dopr_outch, dopr_isbig, dopr_copy, | ||
| 217 | &buffer, &maxlen, retlen, format, args); | ||
| 218 | } | ||
| 219 | |||
| 220 | #else | ||
| 221 | static void | ||
| 222 | doapr( | ||
| 223 | char **buffer, | ||
| 224 | size_t *retlen, | ||
| 225 | const char *format, | ||
| 226 | va_list args) | ||
| 227 | { | ||
| 228 | size_t dummy_maxlen = 0; | ||
| 229 | _dopr(doapr_outch, doapr_isbig, doapr_copy, | ||
| 230 | buffer, &dummy_maxlen, retlen, format, args); | ||
| 231 | } | ||
| 232 | #endif | ||
| 233 | |||
| 234 | static void | ||
| 235 | _dopr( | ||
| 236 | void (*outch_fn)(char **, size_t *, size_t *, int), | ||
| 237 | int (*isbig_fn)(size_t, size_t), | ||
| 238 | int (*copy_fn)(size_t), | ||
| 239 | char **buffer, | ||
| 240 | size_t *maxlen, | ||
| 241 | size_t *retlen, | ||
| 242 | const char *format, | ||
| 243 | va_list args) | ||
| 244 | { | ||
| 176 | char ch; | 245 | char ch; |
| 177 | LLONG value; | 246 | LLONG value; |
| 178 | LDOUBLE fvalue; | 247 | LDOUBLE fvalue; |
| @@ -190,7 +259,7 @@ dopr( | |||
| 190 | ch = *format++; | 259 | ch = *format++; |
| 191 | 260 | ||
| 192 | while (state != DP_S_DONE) { | 261 | while (state != DP_S_DONE) { |
| 193 | if ((ch == '\0') || (currlen >= maxlen)) | 262 | if ((ch == '\0') || (*isbig_fn)(currlen, *maxlen)) |
| 194 | state = DP_S_DONE; | 263 | state = DP_S_DONE; |
| 195 | 264 | ||
| 196 | switch (state) { | 265 | switch (state) { |
| @@ -198,7 +267,7 @@ dopr( | |||
| 198 | if (ch == '%') | 267 | if (ch == '%') |
| 199 | state = DP_S_FLAGS; | 268 | state = DP_S_FLAGS; |
| 200 | else | 269 | else |
| 201 | dopr_outch(buffer, &currlen, maxlen, ch); | 270 | (*outch_fn)(buffer, &currlen, maxlen, ch); |
| 202 | ch = *format++; | 271 | ch = *format++; |
| 203 | break; | 272 | break; |
| 204 | case DP_S_FLAGS: | 273 | case DP_S_FLAGS: |
| @@ -304,7 +373,8 @@ dopr( | |||
| 304 | value = va_arg(args, int); | 373 | value = va_arg(args, int); |
| 305 | break; | 374 | break; |
| 306 | } | 375 | } |
| 307 | fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags); | 376 | fmtint(outch_fn, buffer, &currlen, maxlen, |
| 377 | value, 10, min, max, flags); | ||
| 308 | break; | 378 | break; |
| 309 | case 'X': | 379 | case 'X': |
| 310 | flags |= DP_F_UP; | 380 | flags |= DP_F_UP; |
| @@ -329,7 +399,7 @@ dopr( | |||
| 329 | unsigned int); | 399 | unsigned int); |
| 330 | break; | 400 | break; |
| 331 | } | 401 | } |
| 332 | fmtint(buffer, &currlen, maxlen, value, | 402 | fmtint(outch_fn, buffer, &currlen, maxlen, value, |
| 333 | ch == 'o' ? 8 : (ch == 'u' ? 10 : 16), | 403 | ch == 'o' ? 8 : (ch == 'u' ? 10 : 16), |
| 334 | min, max, flags); | 404 | min, max, flags); |
| 335 | break; | 405 | break; |
| @@ -338,7 +408,8 @@ dopr( | |||
| 338 | fvalue = va_arg(args, LDOUBLE); | 408 | fvalue = va_arg(args, LDOUBLE); |
| 339 | else | 409 | else |
| 340 | fvalue = va_arg(args, double); | 410 | fvalue = va_arg(args, double); |
| 341 | fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags); | 411 | fmtfp(outch_fn, buffer, &currlen, maxlen, |
| 412 | fvalue, min, max, flags); | ||
| 342 | break; | 413 | break; |
| 343 | case 'E': | 414 | case 'E': |
| 344 | flags |= DP_F_UP; | 415 | flags |= DP_F_UP; |
| @@ -357,19 +428,19 @@ dopr( | |||
| 357 | fvalue = va_arg(args, double); | 428 | fvalue = va_arg(args, double); |
| 358 | break; | 429 | break; |
| 359 | case 'c': | 430 | case 'c': |
| 360 | dopr_outch(buffer, &currlen, maxlen, | 431 | (*outch_fn)(buffer, &currlen, maxlen, |
| 361 | va_arg(args, int)); | 432 | va_arg(args, int)); |
| 362 | break; | 433 | break; |
| 363 | case 's': | 434 | case 's': |
| 364 | strvalue = va_arg(args, char *); | 435 | strvalue = va_arg(args, char *); |
| 365 | if (max < 0) | 436 | if (max < 0) |
| 366 | max = maxlen; | 437 | max = (*copy_fn)(*maxlen); |
| 367 | fmtstr(buffer, &currlen, maxlen, strvalue, | 438 | fmtstr(outch_fn, buffer, &currlen, maxlen, strvalue, |
| 368 | flags, min, max); | 439 | flags, min, max); |
| 369 | break; | 440 | break; |
| 370 | case 'p': | 441 | case 'p': |
| 371 | value = (long)va_arg(args, void *); | 442 | value = (long)va_arg(args, void *); |
| 372 | fmtint(buffer, &currlen, maxlen, | 443 | fmtint(outch_fn, buffer, &currlen, maxlen, |
| 373 | value, 16, min, max, flags); | 444 | value, 16, min, max, flags); |
| 374 | break; | 445 | break; |
| 375 | case 'n': /* XXX */ | 446 | case 'n': /* XXX */ |
| @@ -392,7 +463,7 @@ dopr( | |||
| 392 | } | 463 | } |
| 393 | break; | 464 | break; |
| 394 | case '%': | 465 | case '%': |
| 395 | dopr_outch(buffer, &currlen, maxlen, ch); | 466 | (*outch_fn)(buffer, &currlen, maxlen, ch); |
| 396 | break; | 467 | break; |
| 397 | case 'w': | 468 | case 'w': |
| 398 | /* not supported yet, treat as next char */ | 469 | /* not supported yet, treat as next char */ |
| @@ -413,19 +484,20 @@ dopr( | |||
| 413 | break; | 484 | break; |
| 414 | } | 485 | } |
| 415 | } | 486 | } |
| 416 | if (currlen >= maxlen - 1) | 487 | if (currlen >= *maxlen - 1) |
| 417 | currlen = maxlen - 1; | 488 | currlen = *maxlen - 1; |
| 418 | buffer[currlen] = '\0'; | 489 | (*buffer)[currlen] = '\0'; |
| 419 | *retlen = currlen; | 490 | *retlen = currlen; |
| 420 | return; | 491 | return; |
| 421 | } | 492 | } |
| 422 | 493 | ||
| 423 | static void | 494 | static void |
| 424 | fmtstr( | 495 | fmtstr( |
| 425 | char *buffer, | 496 | void (*outch_fn)(char **, size_t *, size_t *, int), |
| 497 | char **buffer, | ||
| 426 | size_t *currlen, | 498 | size_t *currlen, |
| 427 | size_t maxlen, | 499 | size_t *maxlen, |
| 428 | char *value, | 500 | const char *value, |
| 429 | int flags, | 501 | int flags, |
| 430 | int min, | 502 | int min, |
| 431 | int max) | 503 | int max) |
| @@ -444,16 +516,16 @@ fmtstr( | |||
| 444 | padlen = -padlen; | 516 | padlen = -padlen; |
| 445 | 517 | ||
| 446 | while ((padlen > 0) && (cnt < max)) { | 518 | while ((padlen > 0) && (cnt < max)) { |
| 447 | dopr_outch(buffer, currlen, maxlen, ' '); | 519 | (*outch_fn)(buffer, currlen, maxlen, ' '); |
| 448 | --padlen; | 520 | --padlen; |
| 449 | ++cnt; | 521 | ++cnt; |
| 450 | } | 522 | } |
| 451 | while (*value && (cnt < max)) { | 523 | while (*value && (cnt < max)) { |
| 452 | dopr_outch(buffer, currlen, maxlen, *value++); | 524 | (*outch_fn)(buffer, currlen, maxlen, *value++); |
| 453 | ++cnt; | 525 | ++cnt; |
| 454 | } | 526 | } |
| 455 | while ((padlen < 0) && (cnt < max)) { | 527 | while ((padlen < 0) && (cnt < max)) { |
| 456 | dopr_outch(buffer, currlen, maxlen, ' '); | 528 | (*outch_fn)(buffer, currlen, maxlen, ' '); |
| 457 | ++padlen; | 529 | ++padlen; |
| 458 | ++cnt; | 530 | ++cnt; |
| 459 | } | 531 | } |
| @@ -461,9 +533,10 @@ fmtstr( | |||
| 461 | 533 | ||
| 462 | static void | 534 | static void |
| 463 | fmtint( | 535 | fmtint( |
| 464 | char *buffer, | 536 | void (*outch_fn)(char **, size_t *, size_t *, int), |
| 537 | char **buffer, | ||
| 465 | size_t *currlen, | 538 | size_t *currlen, |
| 466 | size_t maxlen, | 539 | size_t *maxlen, |
| 467 | LLONG value, | 540 | LLONG value, |
| 468 | int base, | 541 | int base, |
| 469 | int min, | 542 | int min, |
| @@ -517,28 +590,28 @@ fmtint( | |||
| 517 | 590 | ||
| 518 | /* spaces */ | 591 | /* spaces */ |
| 519 | while (spadlen > 0) { | 592 | while (spadlen > 0) { |
| 520 | dopr_outch(buffer, currlen, maxlen, ' '); | 593 | (*outch_fn)(buffer, currlen, maxlen, ' '); |
| 521 | --spadlen; | 594 | --spadlen; |
| 522 | } | 595 | } |
| 523 | 596 | ||
| 524 | /* sign */ | 597 | /* sign */ |
| 525 | if (signvalue) | 598 | if (signvalue) |
| 526 | dopr_outch(buffer, currlen, maxlen, signvalue); | 599 | (*outch_fn)(buffer, currlen, maxlen, signvalue); |
| 527 | 600 | ||
| 528 | /* zeros */ | 601 | /* zeros */ |
| 529 | if (zpadlen > 0) { | 602 | if (zpadlen > 0) { |
| 530 | while (zpadlen > 0) { | 603 | while (zpadlen > 0) { |
| 531 | dopr_outch(buffer, currlen, maxlen, '0'); | 604 | (*outch_fn)(buffer, currlen, maxlen, '0'); |
| 532 | --zpadlen; | 605 | --zpadlen; |
| 533 | } | 606 | } |
| 534 | } | 607 | } |
| 535 | /* digits */ | 608 | /* digits */ |
| 536 | while (place > 0) | 609 | while (place > 0) |
| 537 | dopr_outch(buffer, currlen, maxlen, convert[--place]); | 610 | (*outch_fn)(buffer, currlen, maxlen, convert[--place]); |
| 538 | 611 | ||
| 539 | /* left justified spaces */ | 612 | /* left justified spaces */ |
| 540 | while (spadlen < 0) { | 613 | while (spadlen < 0) { |
| 541 | dopr_outch(buffer, currlen, maxlen, ' '); | 614 | (*outch_fn)(buffer, currlen, maxlen, ' '); |
| 542 | ++spadlen; | 615 | ++spadlen; |
| 543 | } | 616 | } |
| 544 | return; | 617 | return; |
| @@ -577,9 +650,10 @@ round(LDOUBLE value) | |||
| 577 | 650 | ||
| 578 | static void | 651 | static void |
| 579 | fmtfp( | 652 | fmtfp( |
| 580 | char *buffer, | 653 | void (*outch_fn)(char **, size_t *, size_t *, int), |
| 654 | char **buffer, | ||
| 581 | size_t *currlen, | 655 | size_t *currlen, |
| 582 | size_t maxlen, | 656 | size_t *maxlen, |
| 583 | LDOUBLE fvalue, | 657 | LDOUBLE fvalue, |
| 584 | int min, | 658 | int min, |
| 585 | int max, | 659 | int max, |
| @@ -657,54 +731,114 @@ fmtfp( | |||
| 657 | 731 | ||
| 658 | if ((flags & DP_F_ZERO) && (padlen > 0)) { | 732 | if ((flags & DP_F_ZERO) && (padlen > 0)) { |
| 659 | if (signvalue) { | 733 | if (signvalue) { |
| 660 | dopr_outch(buffer, currlen, maxlen, signvalue); | 734 | (*outch_fn)(buffer, currlen, maxlen, signvalue); |
| 661 | --padlen; | 735 | --padlen; |
| 662 | signvalue = 0; | 736 | signvalue = 0; |
| 663 | } | 737 | } |
| 664 | while (padlen > 0) { | 738 | while (padlen > 0) { |
| 665 | dopr_outch(buffer, currlen, maxlen, '0'); | 739 | (*outch_fn)(buffer, currlen, maxlen, '0'); |
| 666 | --padlen; | 740 | --padlen; |
| 667 | } | 741 | } |
| 668 | } | 742 | } |
| 669 | while (padlen > 0) { | 743 | while (padlen > 0) { |
| 670 | dopr_outch(buffer, currlen, maxlen, ' '); | 744 | (*outch_fn)(buffer, currlen, maxlen, ' '); |
| 671 | --padlen; | 745 | --padlen; |
| 672 | } | 746 | } |
| 673 | if (signvalue) | 747 | if (signvalue) |
| 674 | dopr_outch(buffer, currlen, maxlen, signvalue); | 748 | (*outch_fn)(buffer, currlen, maxlen, signvalue); |
| 675 | 749 | ||
| 676 | while (iplace > 0) | 750 | while (iplace > 0) |
| 677 | dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]); | 751 | (*outch_fn)(buffer, currlen, maxlen, iconvert[--iplace]); |
| 678 | 752 | ||
| 679 | /* | 753 | /* |
| 680 | * Decimal point. This should probably use locale to find the correct | 754 | * Decimal point. This should probably use locale to find the correct |
| 681 | * char to print out. | 755 | * char to print out. |
| 682 | */ | 756 | */ |
| 683 | if (max > 0) { | 757 | if (max > 0) { |
| 684 | dopr_outch(buffer, currlen, maxlen, '.'); | 758 | (*outch_fn)(buffer, currlen, maxlen, '.'); |
| 685 | 759 | ||
| 686 | while (fplace > 0) | 760 | while (fplace > 0) |
| 687 | dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]); | 761 | (*outch_fn)(buffer, currlen, maxlen, fconvert[--fplace]); |
| 688 | } | 762 | } |
| 689 | while (zpadlen > 0) { | 763 | while (zpadlen > 0) { |
| 690 | dopr_outch(buffer, currlen, maxlen, '0'); | 764 | (*outch_fn)(buffer, currlen, maxlen, '0'); |
| 691 | --zpadlen; | 765 | --zpadlen; |
| 692 | } | 766 | } |
| 693 | 767 | ||
| 694 | while (padlen < 0) { | 768 | while (padlen < 0) { |
| 695 | dopr_outch(buffer, currlen, maxlen, ' '); | 769 | (*outch_fn)(buffer, currlen, maxlen, ' '); |
| 696 | ++padlen; | 770 | ++padlen; |
| 697 | } | 771 | } |
| 698 | } | 772 | } |
| 699 | 773 | ||
| 774 | static int | ||
| 775 | dopr_copy( | ||
| 776 | size_t len) | ||
| 777 | { | ||
| 778 | return len; | ||
| 779 | } | ||
| 780 | |||
| 781 | #ifdef USE_ALLOCATING_PRINT | ||
| 782 | static int | ||
| 783 | doapr_copy( | ||
| 784 | size_t len) | ||
| 785 | { | ||
| 786 | /* Return as high an integer as possible */ | ||
| 787 | return INT_MAX; | ||
| 788 | } | ||
| 789 | #endif | ||
| 790 | |||
| 791 | static int | ||
| 792 | dopr_isbig( | ||
| 793 | size_t currlen, | ||
| 794 | size_t maxlen) | ||
| 795 | { | ||
| 796 | return currlen > maxlen; | ||
| 797 | } | ||
| 798 | |||
| 799 | #ifdef USE_ALLOCATING_PRINT | ||
| 800 | static int | ||
| 801 | doapr_isbig( | ||
| 802 | size_t currlen, | ||
| 803 | size_t maxlen) | ||
| 804 | { | ||
| 805 | return 0; | ||
| 806 | } | ||
| 807 | #endif | ||
| 808 | |||
| 700 | static void | 809 | static void |
| 701 | dopr_outch( | 810 | dopr_outch( |
| 702 | char *buffer, | 811 | char **buffer, |
| 703 | size_t *currlen, | 812 | size_t *currlen, |
| 704 | size_t maxlen, | 813 | size_t *maxlen, |
| 814 | int c) | ||
| 815 | { | ||
| 816 | if (*currlen < *maxlen) | ||
| 817 | (*buffer)[(*currlen)++] = (char)c; | ||
| 818 | return; | ||
| 819 | } | ||
| 820 | |||
| 821 | #ifdef USE_ALLOCATING_PRINT | ||
| 822 | static void | ||
| 823 | doapr_outch( | ||
| 824 | char **buffer, | ||
| 825 | size_t *currlen, | ||
| 826 | size_t *maxlen, | ||
| 705 | int c) | 827 | int c) |
| 706 | { | 828 | { |
| 707 | if (*currlen < maxlen) | 829 | if (*buffer == NULL) { |
| 708 | buffer[(*currlen)++] = (char)c; | 830 | if (*maxlen == 0) |
| 831 | *maxlen = 1024; | ||
| 832 | *buffer = Malloc(*maxlen); | ||
| 833 | } | ||
| 834 | while (*currlen >= *maxlen) { | ||
| 835 | *maxlen += 1024; | ||
| 836 | *buffer = Realloc(*buffer, *maxlen); | ||
| 837 | } | ||
| 838 | /* What to do if *buffer is NULL? */ | ||
| 839 | assert(*buffer != NULL); | ||
| 840 | |||
| 841 | (*buffer)[(*currlen)++] = (char)c; | ||
| 709 | return; | 842 | return; |
| 710 | } | 843 | } |
| 844 | #endif | ||
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index bc08401eeb..ebdb18170b 100644 --- a/src/lib/libcrypto/bio/bio.h +++ b/src/lib/libcrypto/bio/bio.h | |||
| @@ -507,7 +507,7 @@ int BIO_set(BIO *a,BIO_METHOD *type); | |||
| 507 | int BIO_free(BIO *a); | 507 | int BIO_free(BIO *a); |
| 508 | int BIO_read(BIO *b, void *data, int len); | 508 | int BIO_read(BIO *b, void *data, int len); |
| 509 | int BIO_gets(BIO *bp,char *buf, int size); | 509 | int BIO_gets(BIO *bp,char *buf, int size); |
| 510 | int BIO_write(BIO *b, const char *data, int len); | 510 | int BIO_write(BIO *b, const void *data, int len); |
| 511 | int BIO_puts(BIO *bp,const char *buf); | 511 | int BIO_puts(BIO *bp,const char *buf); |
| 512 | long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); | 512 | long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); |
| 513 | long BIO_callback_ctrl(BIO *bp,int cmd,void (*fp)()); | 513 | long BIO_callback_ctrl(BIO *bp,int cmd,void (*fp)()); |
diff --git a/src/lib/libcrypto/bio/bio_err.c b/src/lib/libcrypto/bio/bio_err.c index b5f07de5a0..f38e7b9178 100644 --- a/src/lib/libcrypto/bio/bio_err.c +++ b/src/lib/libcrypto/bio/bio_err.c | |||
| @@ -54,7 +54,8 @@ | |||
| 54 | */ | 54 | */ |
| 55 | 55 | ||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes |
| 57 | * made to it will be overwritten when the script next updates this file. | 57 | * made to it will be overwritten when the script next updates this file, |
| 58 | * only reason strings will be preserved. | ||
| 58 | */ | 59 | */ |
| 59 | 60 | ||
| 60 | #include <stdio.h> | 61 | #include <stdio.h> |
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index cf8e6150fd..e88dcc80f3 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
| @@ -169,7 +169,7 @@ int BIO_read(BIO *b, void *out, int outl) | |||
| 169 | return(i); | 169 | return(i); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | int BIO_write(BIO *b, const char *in, int inl) | 172 | int BIO_write(BIO *b, const void *in, int inl) |
| 173 | { | 173 | { |
| 174 | int i; | 174 | int i; |
| 175 | long (*cb)(); | 175 | long (*cb)(); |
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c index 0d0f9356f7..1e2d7491f2 100644 --- a/src/lib/libcrypto/bio/bss_bio.c +++ b/src/lib/libcrypto/bio/bss_bio.c | |||
| @@ -19,8 +19,14 @@ | |||
| 19 | 19 | ||
| 20 | #include <openssl/bio.h> | 20 | #include <openssl/bio.h> |
| 21 | #include <openssl/err.h> | 21 | #include <openssl/err.h> |
| 22 | #include <openssl/err.h> | ||
| 22 | #include <openssl/crypto.h> | 23 | #include <openssl/crypto.h> |
| 23 | 24 | ||
| 25 | #include "openssl/e_os.h" | ||
| 26 | #ifndef SSIZE_MAX | ||
| 27 | # define SSIZE_MAX INT_MAX | ||
| 28 | #endif | ||
| 29 | |||
| 24 | static int bio_new(BIO *bio); | 30 | static int bio_new(BIO *bio); |
| 25 | static int bio_free(BIO *bio); | 31 | static int bio_free(BIO *bio); |
| 26 | static int bio_read(BIO *bio, char *buf, int size); | 32 | static int bio_read(BIO *bio, char *buf, int size); |
| @@ -205,10 +211,10 @@ static int bio_read(BIO *bio, char *buf, int size_) | |||
| 205 | */ | 211 | */ |
| 206 | /* WARNING: The non-copying interface is largely untested as of yet | 212 | /* WARNING: The non-copying interface is largely untested as of yet |
| 207 | * and may contain bugs. */ | 213 | * and may contain bugs. */ |
| 208 | static size_t bio_nread0(BIO *bio, char **buf) | 214 | static ssize_t bio_nread0(BIO *bio, char **buf) |
| 209 | { | 215 | { |
| 210 | struct bio_bio_st *b, *peer_b; | 216 | struct bio_bio_st *b, *peer_b; |
| 211 | size_t num; | 217 | ssize_t num; |
| 212 | 218 | ||
| 213 | BIO_clear_retry_flags(bio); | 219 | BIO_clear_retry_flags(bio); |
| 214 | 220 | ||
| @@ -243,15 +249,20 @@ static size_t bio_nread0(BIO *bio, char **buf) | |||
| 243 | return num; | 249 | return num; |
| 244 | } | 250 | } |
| 245 | 251 | ||
| 246 | static size_t bio_nread(BIO *bio, char **buf, size_t num) | 252 | static ssize_t bio_nread(BIO *bio, char **buf, size_t num_) |
| 247 | { | 253 | { |
| 248 | struct bio_bio_st *b, *peer_b; | 254 | struct bio_bio_st *b, *peer_b; |
| 249 | size_t available; | 255 | ssize_t num, available; |
| 256 | |||
| 257 | if (num_ > SSIZE_MAX) | ||
| 258 | num = SSIZE_MAX; | ||
| 259 | else | ||
| 260 | num = (ssize_t)num_; | ||
| 250 | 261 | ||
| 251 | available = bio_nread0(bio, buf); | 262 | available = bio_nread0(bio, buf); |
| 252 | if (num > available) | 263 | if (num > available) |
| 253 | num = available; | 264 | num = available; |
| 254 | if (num == 0) | 265 | if (num <= 0) |
| 255 | return num; | 266 | return num; |
| 256 | 267 | ||
| 257 | b = bio->ptr; | 268 | b = bio->ptr; |
| @@ -351,7 +362,7 @@ static int bio_write(BIO *bio, char *buf, int num_) | |||
| 351 | * (example usage: bio_nwrite0(), write to buffer, bio_nwrite() | 362 | * (example usage: bio_nwrite0(), write to buffer, bio_nwrite() |
| 352 | * or just bio_nwrite(), write to buffer) | 363 | * or just bio_nwrite(), write to buffer) |
| 353 | */ | 364 | */ |
| 354 | static size_t bio_nwrite0(BIO *bio, char **buf) | 365 | static ssize_t bio_nwrite0(BIO *bio, char **buf) |
| 355 | { | 366 | { |
| 356 | struct bio_bio_st *b; | 367 | struct bio_bio_st *b; |
| 357 | size_t num; | 368 | size_t num; |
| @@ -399,15 +410,20 @@ static size_t bio_nwrite0(BIO *bio, char **buf) | |||
| 399 | return num; | 410 | return num; |
| 400 | } | 411 | } |
| 401 | 412 | ||
| 402 | static size_t bio_nwrite(BIO *bio, char **buf, size_t num) | 413 | static ssize_t bio_nwrite(BIO *bio, char **buf, size_t num_) |
| 403 | { | 414 | { |
| 404 | struct bio_bio_st *b; | 415 | struct bio_bio_st *b; |
| 405 | size_t space; | 416 | ssize_t num, space; |
| 417 | |||
| 418 | if (num_ > SSIZE_MAX) | ||
| 419 | num = SSIZE_MAX; | ||
| 420 | else | ||
| 421 | num = (ssize_t)num_; | ||
| 406 | 422 | ||
| 407 | space = bio_nwrite0(bio, buf); | 423 | space = bio_nwrite0(bio, buf); |
| 408 | if (num > space) | 424 | if (num > space) |
| 409 | num = space; | 425 | num = space; |
| 410 | if (num == 0) | 426 | if (num <= 0) |
| 411 | return num; | 427 | return num; |
| 412 | b = bio->ptr; | 428 | b = bio->ptr; |
| 413 | assert(b != NULL); | 429 | assert(b != NULL); |
| @@ -509,6 +525,11 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) | |||
| 509 | ret = 1; | 525 | ret = 1; |
| 510 | break; | 526 | break; |
| 511 | 527 | ||
| 528 | case BIO_C_NREAD0: | ||
| 529 | /* prepare for non-copying read */ | ||
| 530 | ret = (long) bio_nread0(bio, ptr); | ||
| 531 | break; | ||
| 532 | |||
| 512 | case BIO_C_NREAD: | 533 | case BIO_C_NREAD: |
| 513 | /* non-copying read */ | 534 | /* non-copying read */ |
| 514 | ret = (long) bio_nread(bio, ptr, (size_t) num); | 535 | ret = (long) bio_nread(bio, ptr, (size_t) num); |
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c index 4308b19663..497eb1af72 100644 --- a/src/lib/libcrypto/bio/bss_log.c +++ b/src/lib/libcrypto/bio/bss_log.c | |||
| @@ -57,8 +57,8 @@ | |||
| 57 | Why BIO_s_log? | 57 | Why BIO_s_log? |
| 58 | 58 | ||
| 59 | BIO_s_log is useful for system daemons (or services under NT). | 59 | BIO_s_log is useful for system daemons (or services under NT). |
| 60 | It is one-way BIO, it sends all stuff to syslogd (or event log | 60 | It is one-way BIO, it sends all stuff to syslogd (on system that |
| 61 | under NT). | 61 | commonly use that), or event log (on NT), or OPCOM (on OpenVMS). |
| 62 | 62 | ||
| 63 | */ | 63 | */ |
| 64 | 64 | ||
| @@ -66,29 +66,58 @@ | |||
| 66 | #include <stdio.h> | 66 | #include <stdio.h> |
| 67 | #include <errno.h> | 67 | #include <errno.h> |
| 68 | 68 | ||
| 69 | #ifndef WIN32 | 69 | #if defined(WIN32) |
| 70 | #ifdef __ultrix | 70 | # include <process.h> |
| 71 | #include <sys/syslog.h> | 71 | #elif defined(VMS) || defined(__VMS) |
| 72 | #else | 72 | # include <opcdef.h> |
| 73 | #include <syslog.h> | 73 | # include <descrip.h> |
| 74 | #endif | 74 | # include <lib$routines.h> |
| 75 | #else | 75 | # include <starlet.h> |
| 76 | #include <process.h> | 76 | #elif defined(__ultrix) |
| 77 | # include <sys/syslog.h> | ||
| 78 | #elif !defined(MSDOS) /* Unix */ | ||
| 79 | # include <syslog.h> | ||
| 77 | #endif | 80 | #endif |
| 78 | 81 | ||
| 79 | #include "cryptlib.h" | 82 | #include "cryptlib.h" |
| 80 | #include <openssl/buffer.h> | 83 | #include <openssl/buffer.h> |
| 81 | #include <openssl/err.h> | 84 | #include <openssl/err.h> |
| 85 | |||
| 82 | #ifndef NO_SYSLOG | 86 | #ifndef NO_SYSLOG |
| 83 | 87 | ||
| 88 | #if defined(WIN32) | ||
| 89 | #define LOG_EMERG 0 | ||
| 90 | #define LOG_ALERT 1 | ||
| 91 | #define LOG_CRIT 2 | ||
| 92 | #define LOG_ERR 3 | ||
| 93 | #define LOG_WARNING 4 | ||
| 94 | #define LOG_NOTICE 5 | ||
| 95 | #define LOG_INFO 6 | ||
| 96 | #define LOG_DEBUG 7 | ||
| 97 | |||
| 98 | #define LOG_DAEMON (3<<3) | ||
| 99 | #elif defined(VMS) | ||
| 100 | /* On VMS, we don't really care about these, but we need them to compile */ | ||
| 101 | #define LOG_EMERG 0 | ||
| 102 | #define LOG_ALERT 1 | ||
| 103 | #define LOG_CRIT 2 | ||
| 104 | #define LOG_ERR 3 | ||
| 105 | #define LOG_WARNING 4 | ||
| 106 | #define LOG_NOTICE 5 | ||
| 107 | #define LOG_INFO 6 | ||
| 108 | #define LOG_DEBUG 7 | ||
| 109 | |||
| 110 | #define LOG_DAEMON OPC$M_NM_NTWORK | ||
| 111 | #endif | ||
| 84 | 112 | ||
| 85 | static int MS_CALLBACK slg_write(BIO *h,char *buf,int num); | 113 | static int MS_CALLBACK slg_write(BIO *h,char *buf,int num); |
| 86 | static int MS_CALLBACK slg_puts(BIO *h,char *str); | 114 | static int MS_CALLBACK slg_puts(BIO *h,char *str); |
| 87 | static long MS_CALLBACK slg_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 115 | static long MS_CALLBACK slg_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 88 | static int MS_CALLBACK slg_new(BIO *h); | 116 | static int MS_CALLBACK slg_new(BIO *h); |
| 89 | static int MS_CALLBACK slg_free(BIO *data); | 117 | static int MS_CALLBACK slg_free(BIO *data); |
| 90 | static int xopenlog(BIO* bp, const char* name, int level); | 118 | static void xopenlog(BIO* bp, const char* name, int level); |
| 91 | static int xcloselog(BIO* bp); | 119 | static void xsyslog(BIO* bp, int priority, const char* string); |
| 120 | static void xcloselog(BIO* bp); | ||
| 92 | 121 | ||
| 93 | static BIO_METHOD methods_slg= | 122 | static BIO_METHOD methods_slg= |
| 94 | { | 123 | { |
| @@ -113,11 +142,7 @@ static int MS_CALLBACK slg_new(BIO *bi) | |||
| 113 | bi->init=1; | 142 | bi->init=1; |
| 114 | bi->num=0; | 143 | bi->num=0; |
| 115 | bi->ptr=NULL; | 144 | bi->ptr=NULL; |
| 116 | #ifndef WIN32 | ||
| 117 | xopenlog(bi, "application", LOG_DAEMON); | 145 | xopenlog(bi, "application", LOG_DAEMON); |
| 118 | #else | ||
| 119 | xopenlog(bi, "application", 0); | ||
| 120 | #endif | ||
| 121 | return(1); | 146 | return(1); |
| 122 | } | 147 | } |
| 123 | 148 | ||
| @@ -133,43 +158,14 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl) | |||
| 133 | int ret= inl; | 158 | int ret= inl; |
| 134 | char* buf= in; | 159 | char* buf= in; |
| 135 | char* pp; | 160 | char* pp; |
| 136 | #if defined(WIN32) | ||
| 137 | LPCSTR lpszStrings[2]; | ||
| 138 | WORD evtype= EVENTLOG_ERROR_TYPE; | ||
| 139 | int pid = _getpid(); | ||
| 140 | char pidbuf[20]; | ||
| 141 | #else | ||
| 142 | int priority; | 161 | int priority; |
| 143 | #endif | ||
| 144 | 162 | ||
| 145 | if((buf= (char *)Malloc(inl+ 1)) == NULL){ | 163 | if((buf= (char *)Malloc(inl+ 1)) == NULL){ |
| 146 | return(0); | 164 | return(0); |
| 147 | } | 165 | } |
| 148 | strncpy(buf, in, inl); | 166 | strncpy(buf, in, inl); |
| 149 | buf[inl]= '\0'; | 167 | buf[inl]= '\0'; |
| 150 | #if defined(WIN32) | ||
| 151 | if(strncmp(buf, "ERR ", 4) == 0){ | ||
| 152 | evtype= EVENTLOG_ERROR_TYPE; | ||
| 153 | pp= buf+ 4; | ||
| 154 | }else if(strncmp(buf, "WAR ", 4) == 0){ | ||
| 155 | evtype= EVENTLOG_WARNING_TYPE; | ||
| 156 | pp= buf+ 4; | ||
| 157 | }else if(strncmp(buf, "INF ", 4) == 0){ | ||
| 158 | evtype= EVENTLOG_INFORMATION_TYPE; | ||
| 159 | pp= buf+ 4; | ||
| 160 | }else{ | ||
| 161 | evtype= EVENTLOG_ERROR_TYPE; | ||
| 162 | pp= buf; | ||
| 163 | } | ||
| 164 | 168 | ||
| 165 | sprintf(pidbuf, "[%d] ", pid); | ||
| 166 | lpszStrings[0] = pidbuf; | ||
| 167 | lpszStrings[1] = pp; | ||
| 168 | |||
| 169 | if(b->ptr) | ||
| 170 | ReportEvent(b->ptr, evtype, 0, 1024, NULL, 2, 0, | ||
| 171 | lpszStrings, NULL); | ||
| 172 | #else | ||
| 173 | if(strncmp(buf, "ERR ", 4) == 0){ | 169 | if(strncmp(buf, "ERR ", 4) == 0){ |
| 174 | priority= LOG_ERR; | 170 | priority= LOG_ERR; |
| 175 | pp= buf+ 4; | 171 | pp= buf+ 4; |
| @@ -184,8 +180,8 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl) | |||
| 184 | pp= buf; | 180 | pp= buf; |
| 185 | } | 181 | } |
| 186 | 182 | ||
| 187 | syslog(priority, "%s", pp); | 183 | xsyslog(b, priority, pp); |
| 188 | #endif | 184 | |
| 189 | Free(buf); | 185 | Free(buf); |
| 190 | return(ret); | 186 | return(ret); |
| 191 | } | 187 | } |
| @@ -213,28 +209,128 @@ static int MS_CALLBACK slg_puts(BIO *bp, char *str) | |||
| 213 | return(ret); | 209 | return(ret); |
| 214 | } | 210 | } |
| 215 | 211 | ||
| 216 | static int xopenlog(BIO* bp, const char* name, int level) | ||
| 217 | { | ||
| 218 | #if defined(WIN32) | 212 | #if defined(WIN32) |
| 219 | if((bp->ptr= (char *)RegisterEventSource(NULL, name)) == NULL){ | 213 | |
| 220 | return(0); | 214 | static void xopenlog(BIO* bp, const char* name, int level) |
| 221 | } | 215 | { |
| 222 | #else | 216 | bp->ptr= (char *)RegisterEventSource(NULL, name); |
| 223 | openlog(name, LOG_PID|LOG_CONS, level); | ||
| 224 | #endif | ||
| 225 | return(1); | ||
| 226 | } | 217 | } |
| 227 | 218 | ||
| 228 | static int xcloselog(BIO* bp) | 219 | static void xsyslog(BIO *bp, int priority, const char *string) |
| 220 | { | ||
| 221 | LPCSTR lpszStrings[2]; | ||
| 222 | WORD evtype= EVENTLOG_ERROR_TYPE; | ||
| 223 | int pid = _getpid(); | ||
| 224 | char pidbuf[20]; | ||
| 225 | |||
| 226 | switch (priority) | ||
| 227 | { | ||
| 228 | case LOG_ERR: | ||
| 229 | evtype = EVENTLOG_ERROR_TYPE; | ||
| 230 | break; | ||
| 231 | case LOG_WARNING: | ||
| 232 | evtype = EVENTLOG_WARNING_TYPE; | ||
| 233 | break; | ||
| 234 | case LOG_INFO: | ||
| 235 | evtype = EVENTLOG_INFORMATION_TYPE; | ||
| 236 | break; | ||
| 237 | default: | ||
| 238 | evtype = EVENTLOG_ERROR_TYPE; | ||
| 239 | break; | ||
| 240 | } | ||
| 241 | |||
| 242 | sprintf(pidbuf, "[%d] ", pid); | ||
| 243 | lpszStrings[0] = pidbuf; | ||
| 244 | lpszStrings[1] = string; | ||
| 245 | |||
| 246 | if(bp->ptr) | ||
| 247 | ReportEvent(bp->ptr, evtype, 0, 1024, NULL, 2, 0, | ||
| 248 | lpszStrings, NULL); | ||
| 249 | } | ||
| 250 | |||
| 251 | static void xcloselog(BIO* bp) | ||
| 229 | { | 252 | { |
| 230 | #if defined(WIN32) | ||
| 231 | if(bp->ptr) | 253 | if(bp->ptr) |
| 232 | DeregisterEventSource((HANDLE)(bp->ptr)); | 254 | DeregisterEventSource((HANDLE)(bp->ptr)); |
| 233 | bp->ptr= NULL; | 255 | bp->ptr= NULL; |
| 234 | #else | 256 | } |
| 257 | |||
| 258 | #elif defined(VMS) | ||
| 259 | |||
| 260 | static int VMS_OPC_target = LOG_DAEMON; | ||
| 261 | |||
| 262 | static void xopenlog(BIO* bp, const char* name, int level) | ||
| 263 | { | ||
| 264 | VMS_OPC_target = level; | ||
| 265 | } | ||
| 266 | |||
| 267 | static void xsyslog(BIO *bp, int priority, const char *string) | ||
| 268 | { | ||
| 269 | struct dsc$descriptor_s opc_dsc; | ||
| 270 | struct opcdef *opcdef_p; | ||
| 271 | char buf[10240]; | ||
| 272 | unsigned int len; | ||
| 273 | struct dsc$descriptor_s buf_dsc; | ||
| 274 | $DESCRIPTOR(fao_cmd, "!AZ: !AZ"); | ||
| 275 | char *priority_tag; | ||
| 276 | |||
| 277 | switch (priority) | ||
| 278 | { | ||
| 279 | case LOG_EMERG: priority_tag = "Emergency"; break; | ||
| 280 | case LOG_ALERT: priority_tag = "Alert"; break; | ||
| 281 | case LOG_CRIT: priority_tag = "Critical"; break; | ||
| 282 | case LOG_ERR: priority_tag = "Error"; break; | ||
| 283 | case LOG_WARNING: priority_tag = "Warning"; break; | ||
| 284 | case LOG_NOTICE: priority_tag = "Notice"; break; | ||
| 285 | case LOG_INFO: priority_tag = "Info"; break; | ||
| 286 | case LOG_DEBUG: priority_tag = "DEBUG"; break; | ||
| 287 | } | ||
| 288 | |||
| 289 | buf_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | ||
| 290 | buf_dsc.dsc$b_class = DSC$K_CLASS_S; | ||
| 291 | buf_dsc.dsc$a_pointer = buf; | ||
| 292 | buf_dsc.dsc$w_length = sizeof(buf) - 1; | ||
| 293 | |||
| 294 | lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); | ||
| 295 | |||
| 296 | /* we know there's an 8 byte header. That's documented */ | ||
| 297 | opcdef_p = (struct opcdef *) Malloc(8 + len); | ||
| 298 | opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; | ||
| 299 | memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); | ||
| 300 | opcdef_p->opc$l_ms_rqstid = 0; | ||
| 301 | memcpy(&opcdef_p->opc$l_ms_text, buf, len); | ||
| 302 | |||
| 303 | opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | ||
| 304 | opc_dsc.dsc$b_class = DSC$K_CLASS_S; | ||
| 305 | opc_dsc.dsc$a_pointer = (char *)opcdef_p; | ||
| 306 | opc_dsc.dsc$w_length = len + 8; | ||
| 307 | |||
| 308 | sys$sndopr(opc_dsc, 0); | ||
| 309 | |||
| 310 | Free(opcdef_p); | ||
| 311 | } | ||
| 312 | |||
| 313 | static void xcloselog(BIO* bp) | ||
| 314 | { | ||
| 315 | } | ||
| 316 | |||
| 317 | #else /* Unix */ | ||
| 318 | |||
| 319 | static void xopenlog(BIO* bp, const char* name, int level) | ||
| 320 | { | ||
| 321 | openlog(name, LOG_PID|LOG_CONS, level); | ||
| 322 | } | ||
| 323 | |||
| 324 | static void xsyslog(BIO *bp, int priority, const char *string) | ||
| 325 | { | ||
| 326 | syslog(priority, "%s", string); | ||
| 327 | } | ||
| 328 | |||
| 329 | static void xcloselog(BIO* bp) | ||
| 330 | { | ||
| 235 | closelog(); | 331 | closelog(); |
| 236 | #endif | ||
| 237 | return(1); | ||
| 238 | } | 332 | } |
| 239 | 333 | ||
| 240 | #endif | 334 | #endif /* Unix */ |
| 335 | |||
| 336 | #endif /* NO_SYSLOG */ | ||
