OLD | NEW |
1 /* crypto/bio/bio_lib.c */ | 1 /* crypto/bio/bio_lib.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 { | 103 { |
104 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, | 104 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, |
105 &bio->ex_data); | 105 &bio->ex_data); |
106 return(0); | 106 return(0); |
107 } | 107 } |
108 return(1); | 108 return(1); |
109 } | 109 } |
110 | 110 |
111 int BIO_free(BIO *a) | 111 int BIO_free(BIO *a) |
112 { | 112 { |
113 » int ret=0,i; | 113 » int i; |
114 | 114 |
115 if (a == NULL) return(0); | 115 if (a == NULL) return(0); |
116 | 116 |
117 i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_BIO); | 117 i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_BIO); |
118 #ifdef REF_PRINT | 118 #ifdef REF_PRINT |
119 REF_PRINT("BIO",a); | 119 REF_PRINT("BIO",a); |
120 #endif | 120 #endif |
121 if (i > 0) return(1); | 121 if (i > 0) return(1); |
122 #ifdef REF_CHECK | 122 #ifdef REF_CHECK |
123 if (i < 0) | 123 if (i < 0) |
124 { | 124 { |
125 fprintf(stderr,"BIO_free, bad reference count\n"); | 125 fprintf(stderr,"BIO_free, bad reference count\n"); |
126 abort(); | 126 abort(); |
127 } | 127 } |
128 #endif | 128 #endif |
129 if ((a->callback != NULL) && | 129 if ((a->callback != NULL) && |
130 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) | 130 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) |
131 return(i); | 131 return(i); |
132 | 132 |
133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); | 133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); |
134 | 134 |
135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); | 135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); |
136 » ret=a->method->destroy(a); | 136 » a->method->destroy(a); |
137 OPENSSL_free(a); | 137 OPENSSL_free(a); |
138 return(1); | 138 return(1); |
139 } | 139 } |
140 | 140 |
141 void BIO_vfree(BIO *a) | 141 void BIO_vfree(BIO *a) |
142 { BIO_free(a); } | 142 { BIO_free(a); } |
143 | 143 |
144 void BIO_clear_flags(BIO *b, int flags) | 144 void BIO_clear_flags(BIO *b, int flags) |
145 { | 145 { |
146 b->flags &= ~flags; | 146 b->flags &= ~flags; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 BIO *lb; | 422 BIO *lb; |
423 | 423 |
424 if (b == NULL) return(bio); | 424 if (b == NULL) return(bio); |
425 lb=b; | 425 lb=b; |
426 while (lb->next_bio != NULL) | 426 while (lb->next_bio != NULL) |
427 lb=lb->next_bio; | 427 lb=lb->next_bio; |
428 lb->next_bio=bio; | 428 lb->next_bio=bio; |
429 if (bio != NULL) | 429 if (bio != NULL) |
430 bio->prev_bio=lb; | 430 bio->prev_bio=lb; |
431 /* called to do internal processing */ | 431 /* called to do internal processing */ |
432 » BIO_ctrl(b,BIO_CTRL_PUSH,0,NULL); | 432 » BIO_ctrl(b,BIO_CTRL_PUSH,0,lb); |
433 return(b); | 433 return(b); |
434 } | 434 } |
435 | 435 |
436 /* Remove the first and return the rest */ | 436 /* Remove the first and return the rest */ |
437 BIO *BIO_pop(BIO *b) | 437 BIO *BIO_pop(BIO *b) |
438 { | 438 { |
439 BIO *ret; | 439 BIO *ret; |
440 | 440 |
441 if (b == NULL) return(NULL); | 441 if (b == NULL) return(NULL); |
442 ret=b->next_bio; | 442 ret=b->next_bio; |
443 | 443 |
444 » BIO_ctrl(b,BIO_CTRL_POP,0,NULL); | 444 » BIO_ctrl(b,BIO_CTRL_POP,0,b); |
445 | 445 |
446 if (b->prev_bio != NULL) | 446 if (b->prev_bio != NULL) |
447 b->prev_bio->next_bio=b->next_bio; | 447 b->prev_bio->next_bio=b->next_bio; |
448 if (b->next_bio != NULL) | 448 if (b->next_bio != NULL) |
449 b->next_bio->prev_bio=b->prev_bio; | 449 b->next_bio->prev_bio=b->prev_bio; |
450 | 450 |
451 b->next_bio=NULL; | 451 b->next_bio=NULL; |
452 b->prev_bio=NULL; | 452 b->prev_bio=NULL; |
453 return(ret); | 453 return(ret); |
454 } | 454 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 return 0; | 593 return 0; |
594 } | 594 } |
595 | 595 |
596 unsigned long BIO_number_written(BIO *bio) | 596 unsigned long BIO_number_written(BIO *bio) |
597 { | 597 { |
598 if(bio) return bio->num_write; | 598 if(bio) return bio->num_write; |
599 return 0; | 599 return 0; |
600 } | 600 } |
601 | 601 |
602 IMPLEMENT_STACK_OF(BIO) | 602 IMPLEMENT_STACK_OF(BIO) |
OLD | NEW |