summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r--src/lib/libcrypto/bio/Makefile.ssl174
-rw-r--r--src/lib/libcrypto/bio/b_print.c6
-rw-r--r--src/lib/libcrypto/bio/b_sock.c66
-rw-r--r--src/lib/libcrypto/bio/bf_buff.c1
-rw-r--r--src/lib/libcrypto/bio/bf_lbuf.c12
-rw-r--r--src/lib/libcrypto/bio/bf_nbio.c1
-rw-r--r--src/lib/libcrypto/bio/bf_null.c1
-rw-r--r--src/lib/libcrypto/bio/bio.h33
-rw-r--r--src/lib/libcrypto/bio/bio_cb.c2
-rw-r--r--src/lib/libcrypto/bio/bio_err.c5
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c19
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c18
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c10
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c15
-rw-r--r--src/lib/libcrypto/bio/bss_fd.c226
-rw-r--r--src/lib/libcrypto/bio/bss_file.c18
-rw-r--r--src/lib/libcrypto/bio/bss_log.c19
-rw-r--r--src/lib/libcrypto/bio/bss_sock.c131
18 files changed, 434 insertions, 323 deletions
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl
index 567d3fb870..de5631a105 100644
--- a/src/lib/libcrypto/bio/Makefile.ssl
+++ b/src/lib/libcrypto/bio/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= bio 5DIR= bio
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -49,8 +50,7 @@ all: lib
49 50
50lib: $(LIBOBJ) 51lib: $(LIBOBJ)
51 $(AR) $(LIB) $(LIBOBJ) 52 $(AR) $(LIB) $(LIBOBJ)
52 @echo You may get an error following this line. Please ignore. 53 $(RANLIB) $(LIB) || echo Never mind.
53 - $(RANLIB) $(LIB)
54 @touch lib 54 @touch lib
55 55
56files: 56files:
@@ -89,156 +89,128 @@ clean:
89 89
90# DO NOT DELETE THIS LINE -- make depend depends on it. 90# DO NOT DELETE THIS LINE -- make depend depends on it.
91 91
92b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 92b_dump.o: ../../e_os.h ../../include/openssl/bio.h
93b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 93b_dump.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
94b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 94b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
95b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 95b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
96b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 96b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
97b_dump.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 97b_dump.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
98b_dump.o: ../cryptlib.h 98b_dump.o: ../cryptlib.h b_dump.c
99b_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 99b_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
100b_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 100b_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
101b_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 101b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
102b_print.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 102b_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
103b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 103b_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
104b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 104b_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
105b_print.o: ../../include/openssl/symhacks.h ../cryptlib.h 105b_print.o: ../cryptlib.h b_print.c
106b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 106b_sock.o: ../../e_os.h ../../include/openssl/bio.h
107b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 107b_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
108b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 108b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
109b_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 109b_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
110b_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 110b_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
111b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 111b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
112b_sock.o: ../cryptlib.h 112b_sock.o: ../cryptlib.h b_sock.c
113bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 113bf_buff.o: ../../e_os.h ../../include/openssl/bio.h
114bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 114bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
115bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 115bf_buff.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
116bf_buff.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 116bf_buff.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
117bf_buff.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 117bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
118bf_buff.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 118bf_buff.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119bf_buff.o: ../../include/openssl/err.h ../../include/openssl/evp.h 119bf_buff.o: ../cryptlib.h bf_buff.c
120bf_buff.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 120bf_nbio.o: ../../e_os.h ../../include/openssl/bio.h
121bf_buff.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 121bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122bf_buff.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 122bf_nbio.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
123bf_buff.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 123bf_nbio.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
124bf_buff.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 124bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125bf_buff.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 125bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
126bf_buff.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
127bf_buff.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
128bf_buff.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
129bf_buff.o: ../../include/openssl/symhacks.h ../cryptlib.h
130bf_nbio.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
131bf_nbio.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
132bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
133bf_nbio.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
134bf_nbio.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
135bf_nbio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
136bf_nbio.o: ../../include/openssl/err.h ../../include/openssl/evp.h
137bf_nbio.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
138bf_nbio.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
139bf_nbio.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
140bf_nbio.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
141bf_nbio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
142bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
143bf_nbio.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
144bf_nbio.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
145bf_nbio.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
146bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 126bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
147bf_nbio.o: ../cryptlib.h 127bf_nbio.o: ../cryptlib.h bf_nbio.c
148bf_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 128bf_null.o: ../../e_os.h ../../include/openssl/bio.h
149bf_null.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 129bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
150bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 130bf_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
151bf_null.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 131bf_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
152bf_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 132bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
153bf_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 133bf_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
154bf_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h 134bf_null.o: ../cryptlib.h bf_null.c
155bf_null.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 135bio_cb.o: ../../e_os.h ../../include/openssl/bio.h
156bf_null.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 136bio_cb.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
157bf_null.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
158bf_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
159bf_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
160bf_null.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
161bf_null.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
162bf_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
163bf_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
164bf_null.o: ../../include/openssl/symhacks.h ../cryptlib.h
165bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
166bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
167bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 137bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
168bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 138bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
169bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 139bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
170bio_cb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 140bio_cb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
171bio_cb.o: ../cryptlib.h 141bio_cb.o: ../cryptlib.h bio_cb.c
172bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 142bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
173bio_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 143bio_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
144bio_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
174bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 145bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
175bio_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 146bio_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 147bio_err.o: bio_err.c
177bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 148bio_lib.o: ../../e_os.h ../../include/openssl/bio.h
149bio_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
178bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 150bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
179bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 151bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
180bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 152bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
181bio_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 153bio_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
182bio_lib.o: ../cryptlib.h 154bio_lib.o: ../cryptlib.h bio_lib.c
183bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 155bss_acpt.o: ../../e_os.h ../../include/openssl/bio.h
184bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 156bss_acpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
185bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 157bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
186bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 158bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
187bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 159bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
188bss_acpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 160bss_acpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
189bss_acpt.o: ../cryptlib.h 161bss_acpt.o: ../cryptlib.h bss_acpt.c
190bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 162bss_bio.o: ../../e_os.h ../../include/openssl/bio.h
191bss_bio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 163bss_bio.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
192bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 164bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
193bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 165bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
194bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 166bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
195bss_bio.o: ../../include/openssl/symhacks.h 167bss_bio.o: ../../include/openssl/symhacks.h bss_bio.c
196bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 168bss_conn.o: ../../e_os.h ../../include/openssl/bio.h
197bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 169bss_conn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
198bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 170bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
199bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 171bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
200bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 172bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
201bss_conn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 173bss_conn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
202bss_conn.o: ../cryptlib.h 174bss_conn.o: ../cryptlib.h bss_conn.c
203bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 175bss_fd.o: ../../e_os.h ../../include/openssl/bio.h
204bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 176bss_fd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
205bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 177bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
206bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 178bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
207bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 179bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
208bss_fd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 180bss_fd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
209bss_fd.o: ../cryptlib.h bss_sock.c 181bss_fd.o: ../cryptlib.h bss_fd.c
210bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 182bss_file.o: ../../e_os.h ../../include/openssl/bio.h
211bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 183bss_file.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
212bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 184bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
213bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 185bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
214bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 186bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
215bss_file.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 187bss_file.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
216bss_file.o: ../cryptlib.h 188bss_file.o: ../cryptlib.h bss_file.c
217bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 189bss_log.o: ../../e_os.h ../../include/openssl/bio.h
218bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 190bss_log.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
219bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 191bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
220bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 192bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
221bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 193bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
222bss_log.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 194bss_log.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
223bss_log.o: ../cryptlib.h 195bss_log.o: ../cryptlib.h bss_log.c
224bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 196bss_mem.o: ../../e_os.h ../../include/openssl/bio.h
225bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 197bss_mem.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
226bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 198bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
227bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 199bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
228bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 200bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
229bss_mem.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 201bss_mem.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
230bss_mem.o: ../cryptlib.h 202bss_mem.o: ../cryptlib.h bss_mem.c
231bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 203bss_null.o: ../../e_os.h ../../include/openssl/bio.h
232bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 204bss_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
233bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 205bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
234bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 206bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
235bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 207bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
236bss_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 208bss_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
237bss_null.o: ../cryptlib.h 209bss_null.o: ../cryptlib.h bss_null.c
238bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 210bss_sock.o: ../../e_os.h ../../include/openssl/bio.h
239bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 211bss_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
240bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 212bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
241bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 213bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
242bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 214bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
243bss_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 215bss_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
244bss_sock.o: ../cryptlib.h 216bss_sock.o: ../cryptlib.h bss_sock.c
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index 91a049406e..b7e268f092 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -109,7 +109,7 @@
109#endif 109#endif
110 110
111#if HAVE_LONG_LONG 111#if HAVE_LONG_LONG
112# if defined(WIN32) && !defined(__GNUC__) 112# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__)
113# define LLONG _int64 113# define LLONG _int64
114# else 114# else
115# define LLONG long long 115# define LLONG long long
@@ -569,7 +569,7 @@ pow10(int exp)
569} 569}
570 570
571static long 571static long
572round(LDOUBLE value) 572roundv(LDOUBLE value)
573{ 573{
574 long intpart; 574 long intpart;
575 intpart = (long) value; 575 intpart = (long) value;
@@ -621,7 +621,7 @@ fmtfp(
621 621
622 /* we "cheat" by converting the fractional part to integer by 622 /* we "cheat" by converting the fractional part to integer by
623 multiplying by a factor of 10 */ 623 multiplying by a factor of 10 */
624 fracpart = round((pow10(max)) * (ufvalue - intpart)); 624 fracpart = roundv((pow10(max)) * (ufvalue - intpart));
625 625
626 if (fracpart >= pow10(max)) { 626 if (fracpart >= pow10(max)) {
627 intpart++; 627 intpart++;
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 62cc3f1a0c..dcaef68ea7 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SOCK 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <stdlib.h> 62#include <stdlib.h>
@@ -65,21 +65,21 @@
65#include "cryptlib.h" 65#include "cryptlib.h"
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67 67
68#ifdef WIN16 68#ifdef OPENSSL_SYS_WIN16
69#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 69#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
70#else 70#else
71#define SOCKET_PROTOCOL IPPROTO_TCP 71#define SOCKET_PROTOCOL IPPROTO_TCP
72#endif 72#endif
73 73
74#ifdef SO_MAXCONN 74#ifdef SO_MAXCONN
75#define MAX_LISTEN SOMAXCONN
76#elif defined(SO_MAXCONN)
77#define MAX_LISTEN SO_MAXCONN 75#define MAX_LISTEN SO_MAXCONN
76#elif defined(SOMAXCONN)
77#define MAX_LISTEN SOMAXCONN
78#else 78#else
79#define MAX_LISTEN 32 79#define MAX_LISTEN 32
80#endif 80#endif
81 81
82#ifdef WINDOWS 82#ifdef OPENSSL_SYS_WINDOWS
83static int wsa_init_done=0; 83static int wsa_init_done=0;
84#endif 84#endif
85 85
@@ -95,8 +95,10 @@ static struct ghbn_cache_st
95 } ghbn_cache[GHBN_NUM]; 95 } ghbn_cache[GHBN_NUM];
96 96
97static int get_ip(const char *str,unsigned char *ip); 97static int get_ip(const char *str,unsigned char *ip);
98#if 0
98static void ghbn_free(struct hostent *a); 99static void ghbn_free(struct hostent *a);
99static struct hostent *ghbn_dup(struct hostent *a); 100static struct hostent *ghbn_dup(struct hostent *a);
101#endif
100int BIO_get_host_ip(const char *str, unsigned char *ip) 102int BIO_get_host_ip(const char *str, unsigned char *ip)
101 { 103 {
102 int i; 104 int i;
@@ -266,6 +268,7 @@ long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
266 return(1); 268 return(1);
267 } 269 }
268 270
271#if 0
269static struct hostent *ghbn_dup(struct hostent *a) 272static struct hostent *ghbn_dup(struct hostent *a)
270 { 273 {
271 struct hostent *ret; 274 struct hostent *ret;
@@ -343,20 +346,27 @@ static void ghbn_free(struct hostent *a)
343 OPENSSL_free(a); 346 OPENSSL_free(a);
344 } 347 }
345 348
349#endif
350
346struct hostent *BIO_gethostbyname(const char *name) 351struct hostent *BIO_gethostbyname(const char *name)
347 { 352 {
353#if 1
354 /* Caching gethostbyname() results forever is wrong,
355 * so we have to let the true gethostbyname() worry about this */
356 return gethostbyname(name);
357#else
348 struct hostent *ret; 358 struct hostent *ret;
349 int i,lowi=0,j; 359 int i,lowi=0,j;
350 unsigned long low= (unsigned long)-1; 360 unsigned long low= (unsigned long)-1;
351 361
352/* return(gethostbyname(name)); */
353 362
354#if 0 /* It doesn't make sense to use locking here: The function interface 363# if 0
355 * is not thread-safe, because threads can never be sure when 364 /* It doesn't make sense to use locking here: The function interface
356 * some other thread destroys the data they were given a pointer to. 365 * is not thread-safe, because threads can never be sure when
357 */ 366 * some other thread destroys the data they were given a pointer to.
367 */
358 CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); 368 CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME);
359#endif 369# endif
360 j=strlen(name); 370 j=strlen(name);
361 if (j < 128) 371 if (j < 128)
362 { 372 {
@@ -384,20 +394,21 @@ struct hostent *BIO_gethostbyname(const char *name)
384 * parameter is 'char *', instead of 'const char *' 394 * parameter is 'char *', instead of 'const char *'
385 */ 395 */
386 ret=gethostbyname( 396 ret=gethostbyname(
387#ifndef CONST_STRICT 397# ifndef CONST_STRICT
388 (char *) 398 (char *)
389#endif 399# endif
390 name); 400 name);
391 401
392 if (ret == NULL) 402 if (ret == NULL)
393 goto end; 403 goto end;
394 if (j > 128) /* too big to cache */ 404 if (j > 128) /* too big to cache */
395 { 405 {
396#if 0 /* If we were trying to make this function thread-safe (which 406# if 0
397 * is bound to fail), we'd have to give up in this case 407 /* If we were trying to make this function thread-safe (which
398 * (or allocate more memory). */ 408 * is bound to fail), we'd have to give up in this case
409 * (or allocate more memory). */
399 ret = NULL; 410 ret = NULL;
400#endif 411# endif
401 goto end; 412 goto end;
402 } 413 }
403 414
@@ -421,15 +432,17 @@ struct hostent *BIO_gethostbyname(const char *name)
421 ghbn_cache[i].order=BIO_ghbn_miss+BIO_ghbn_hits; 432 ghbn_cache[i].order=BIO_ghbn_miss+BIO_ghbn_hits;
422 } 433 }
423end: 434end:
424#if 0 435# if 0
425 CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); 436 CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME);
426#endif 437# endif
427 return(ret); 438 return(ret);
439#endif
428 } 440 }
429 441
442
430int BIO_sock_init(void) 443int BIO_sock_init(void)
431 { 444 {
432#ifdef WINDOWS 445#ifdef OPENSSL_SYS_WINDOWS
433 static struct WSAData wsa_state; 446 static struct WSAData wsa_state;
434 447
435 if (!wsa_init_done) 448 if (!wsa_init_done)
@@ -449,13 +462,13 @@ int BIO_sock_init(void)
449 return(-1); 462 return(-1);
450 } 463 }
451 } 464 }
452#endif /* WINDOWS */ 465#endif /* OPENSSL_SYS_WINDOWS */
453 return(1); 466 return(1);
454 } 467 }
455 468
456void BIO_sock_cleanup(void) 469void BIO_sock_cleanup(void)
457 { 470 {
458#ifdef WINDOWS 471#ifdef OPENSSL_SYS_WINDOWS
459 if (wsa_init_done) 472 if (wsa_init_done)
460 { 473 {
461 wsa_init_done=0; 474 wsa_init_done=0;
@@ -465,7 +478,7 @@ void BIO_sock_cleanup(void)
465#endif 478#endif
466 } 479 }
467 480
468#if !defined(VMS) || __VMS_VER >= 70000000 481#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000
469 482
470int BIO_socket_ioctl(int fd, long type, unsigned long *arg) 483int BIO_socket_ioctl(int fd, long type, unsigned long *arg)
471 { 484 {
@@ -494,16 +507,16 @@ static int get_ip(const char *str, unsigned char ip[4])
494 { 507 {
495 ok=1; 508 ok=1;
496 tmp[num]=tmp[num]*10+c-'0'; 509 tmp[num]=tmp[num]*10+c-'0';
497 if (tmp[num] > 255) return(-1); 510 if (tmp[num] > 255) return(0);
498 } 511 }
499 else if (c == '.') 512 else if (c == '.')
500 { 513 {
501 if (!ok) return(-1); 514 if (!ok) return(-1);
502 if (num == 3) break; 515 if (num == 3) return(0);
503 num++; 516 num++;
504 ok=0; 517 ok=0;
505 } 518 }
506 else if ((num == 3) && ok) 519 else if (c == '\0' && (num == 3) && ok)
507 break; 520 break;
508 else 521 else
509 return(0); 522 return(0);
@@ -661,6 +674,7 @@ int BIO_accept(int sock, char **addr)
661 ret=accept(sock,(struct sockaddr *)&from,(void *)&len); 674 ret=accept(sock,(struct sockaddr *)&from,(void *)&len);
662 if (ret == INVALID_SOCKET) 675 if (ret == INVALID_SOCKET)
663 { 676 {
677 if(BIO_sock_should_retry(ret)) return -2;
664 SYSerr(SYS_F_ACCEPT,get_last_socket_error()); 678 SYSerr(SYS_F_ACCEPT,get_last_socket_error());
665 BIOerr(BIO_F_BIO_ACCEPT,BIO_R_ACCEPT_ERROR); 679 BIOerr(BIO_F_BIO_ACCEPT,BIO_R_ACCEPT_ERROR);
666 goto end; 680 goto end;
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c
index c90238bae1..6ccda06596 100644
--- a/src/lib/libcrypto/bio/bf_buff.c
+++ b/src/lib/libcrypto/bio/bf_buff.c
@@ -60,7 +60,6 @@
60#include <errno.h> 60#include <errno.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/bio.h> 62#include <openssl/bio.h>
63#include <openssl/evp.h>
64 63
65static int buffer_write(BIO *h, const char *buf,int num); 64static int buffer_write(BIO *h, const char *buf,int num);
66static int buffer_read(BIO *h, char *buf, int size); 65static int buffer_read(BIO *h, char *buf, int size);
diff --git a/src/lib/libcrypto/bio/bf_lbuf.c b/src/lib/libcrypto/bio/bf_lbuf.c
index 7bcf8ed941..ec0f7eb0b7 100644
--- a/src/lib/libcrypto/bio/bf_lbuf.c
+++ b/src/lib/libcrypto/bio/bf_lbuf.c
@@ -200,7 +200,7 @@ static int linebuffer_write(BIO *b, const char *in, int inl)
200 } 200 }
201 } 201 }
202 202
203#ifdef DEBUG 203#if 0
204BIO_write(b->next_bio, "<*<", 3); 204BIO_write(b->next_bio, "<*<", 3);
205#endif 205#endif
206 i=BIO_write(b->next_bio, 206 i=BIO_write(b->next_bio,
@@ -210,13 +210,13 @@ BIO_write(b->next_bio, "<*<", 3);
210 ctx->obuf_len = orig_olen; 210 ctx->obuf_len = orig_olen;
211 BIO_copy_next_retry(b); 211 BIO_copy_next_retry(b);
212 212
213#ifdef DEBUG 213#if 0
214BIO_write(b->next_bio, ">*>", 3); 214BIO_write(b->next_bio, ">*>", 3);
215#endif 215#endif
216 if (i < 0) return((num > 0)?num:i); 216 if (i < 0) return((num > 0)?num:i);
217 if (i == 0) return(num); 217 if (i == 0) return(num);
218 } 218 }
219#ifdef DEBUG 219#if 0
220BIO_write(b->next_bio, ">*>", 3); 220BIO_write(b->next_bio, ">*>", 3);
221#endif 221#endif
222 if (i < ctx->obuf_len) 222 if (i < ctx->obuf_len)
@@ -229,20 +229,20 @@ BIO_write(b->next_bio, ">*>", 3);
229 buffer if a NL was found and there is anything to write. */ 229 buffer if a NL was found and there is anything to write. */
230 if ((foundnl || p - in > ctx->obuf_size) && p - in > 0) 230 if ((foundnl || p - in > ctx->obuf_size) && p - in > 0)
231 { 231 {
232#ifdef DEBUG 232#if 0
233BIO_write(b->next_bio, "<*<", 3); 233BIO_write(b->next_bio, "<*<", 3);
234#endif 234#endif
235 i=BIO_write(b->next_bio,in,p - in); 235 i=BIO_write(b->next_bio,in,p - in);
236 if (i <= 0) 236 if (i <= 0)
237 { 237 {
238 BIO_copy_next_retry(b); 238 BIO_copy_next_retry(b);
239#ifdef DEBUG 239#if 0
240BIO_write(b->next_bio, ">*>", 3); 240BIO_write(b->next_bio, ">*>", 3);
241#endif 241#endif
242 if (i < 0) return((num > 0)?num:i); 242 if (i < 0) return((num > 0)?num:i);
243 if (i == 0) return(num); 243 if (i == 0) return(num);
244 } 244 }
245#ifdef DEBUG 245#if 0
246BIO_write(b->next_bio, ">*>", 3); 246BIO_write(b->next_bio, ">*>", 3);
247#endif 247#endif
248 num+=i; 248 num+=i;
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c
index 413ef5c4c5..c193e9debf 100644
--- a/src/lib/libcrypto/bio/bf_nbio.c
+++ b/src/lib/libcrypto/bio/bf_nbio.c
@@ -61,7 +61,6 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/evp.h>
65 64
66/* BIO_put and BIO_get both add to the digest, 65/* BIO_put and BIO_get both add to the digest,
67 * BIO_gets returns the digest */ 66 * BIO_gets returns the digest */
diff --git a/src/lib/libcrypto/bio/bf_null.c b/src/lib/libcrypto/bio/bf_null.c
index 2678a1a85d..c1bf39a904 100644
--- a/src/lib/libcrypto/bio/bf_null.c
+++ b/src/lib/libcrypto/bio/bf_null.c
@@ -60,7 +60,6 @@
60#include <errno.h> 60#include <errno.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/bio.h> 62#include <openssl/bio.h>
63#include <openssl/evp.h>
64 63
65/* BIO_put and BIO_get both add to the digest, 64/* BIO_put and BIO_get both add to the digest,
66 * BIO_gets returns the digest */ 65 * BIO_gets returns the digest */
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index 97003b503c..b122c7069d 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -59,12 +59,13 @@
59#ifndef HEADER_BIO_H 59#ifndef HEADER_BIO_H
60#define HEADER_BIO_H 60#define HEADER_BIO_H
61 61
62#ifndef NO_FP_API 62#ifndef OPENSSL_NO_FP_API
63# include <stdio.h> 63# include <stdio.h>
64#endif 64#endif
65#include <stdarg.h> 65#include <stdarg.h>
66 66
67#include <openssl/crypto.h> 67#include <openssl/crypto.h>
68#include <openssl/e_os2.h>
68 69
69#ifdef __cplusplus 70#ifdef __cplusplus
70extern "C" { 71extern "C" {
@@ -179,7 +180,7 @@ extern "C" {
179#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS) 180#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS)
180#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY) 181#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY)
181 182
182/* The next two are used in conjunction with the 183/* The next three are used in conjunction with the
183 * BIO_should_io_special() condition. After this returns true, 184 * BIO_should_io_special() condition. After this returns true,
184 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO 185 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
185 * stack and return the 'reason' for the special and the offending BIO. 186 * stack and return the 'reason' for the special and the offending BIO.
@@ -188,6 +189,8 @@ extern "C" {
188#define BIO_RR_SSL_X509_LOOKUP 0x01 189#define BIO_RR_SSL_X509_LOOKUP 0x01
189/* Returned from the connect BIO when a connect would have blocked */ 190/* Returned from the connect BIO when a connect would have blocked */
190#define BIO_RR_CONNECT 0x02 191#define BIO_RR_CONNECT 0x02
192/* Returned from the accept BIO when an accept would have blocked */
193#define BIO_RR_ACCEPT 0x03
191 194
192/* These are passed by the BIO callback */ 195/* These are passed by the BIO callback */
193#define BIO_CB_FREE 0x01 196#define BIO_CB_FREE 0x01
@@ -215,7 +218,7 @@ typedef struct bio_st BIO;
215 218
216typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); 219typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
217 220
218#ifndef WIN16 221#ifndef OPENSSL_SYS_WIN16
219typedef struct bio_method_st 222typedef struct bio_method_st
220 { 223 {
221 int type; 224 int type;
@@ -356,8 +359,8 @@ typedef struct bio_f_buffer_ctx_struct
356#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) 359#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
357#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) 360#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
358#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) 361#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
359#define BIO_get_conn_ip(b,ip) BIO_ptr_ctrl(b,BIO_C_SET_CONNECT,2) 362#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
360#define BIO_get_conn_int_port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port) 363#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3)
361 364
362 365
363#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) 366#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
@@ -431,7 +434,7 @@ int BIO_read_filename(BIO *b,const char *name);
431#define BIO_set_ssl_renegotiate_bytes(b,num) \ 434#define BIO_set_ssl_renegotiate_bytes(b,num) \
432 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); 435 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
433#define BIO_get_num_renegotiates(b) \ 436#define BIO_get_num_renegotiates(b) \
434 BIO_ctrl(b,BIO_C_SET_SSL_NUM_RENEGOTIATES,0,NULL); 437 BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
435#define BIO_set_ssl_renegotiate_timeout(b,seconds) \ 438#define BIO_set_ssl_renegotiate_timeout(b,seconds) \
436 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); 439 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
437 440
@@ -464,8 +467,9 @@ int BIO_read_filename(BIO *b,const char *name);
464size_t BIO_ctrl_pending(BIO *b); 467size_t BIO_ctrl_pending(BIO *b);
465size_t BIO_ctrl_wpending(BIO *b); 468size_t BIO_ctrl_wpending(BIO *b);
466#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) 469#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
467#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(bio_info_cb **)(cbp)) 470#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
468#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(bio_info_cb *)(cb)) 471 cbp)
472#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
469 473
470/* For the BIO_f_buffer() type */ 474/* For the BIO_f_buffer() type */
471#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) 475#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
@@ -493,8 +497,8 @@ int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
493unsigned long BIO_number_read(BIO *bio); 497unsigned long BIO_number_read(BIO *bio);
494unsigned long BIO_number_written(BIO *bio); 498unsigned long BIO_number_written(BIO *bio);
495 499
496# ifndef NO_FP_API 500# ifndef OPENSSL_NO_FP_API
497# if defined(WIN16) && defined(_WINDLL) 501# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL)
498BIO_METHOD *BIO_s_file_internal(void); 502BIO_METHOD *BIO_s_file_internal(void);
499BIO *BIO_new_file_internal(char *filename, char *mode); 503BIO *BIO_new_file_internal(char *filename, char *mode);
500BIO *BIO_new_fp_internal(FILE *stream, int close_flag); 504BIO *BIO_new_fp_internal(FILE *stream, int close_flag);
@@ -536,7 +540,7 @@ int BIO_nread(BIO *bio, char **buf, int num);
536int BIO_nwrite0(BIO *bio, char **buf); 540int BIO_nwrite0(BIO *bio, char **buf);
537int BIO_nwrite(BIO *bio, char **buf, int num); 541int BIO_nwrite(BIO *bio, char **buf, int num);
538 542
539#ifndef WIN16 543#ifndef OPENSSL_SYS_WIN16
540long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, 544long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
541 long argl,long ret); 545 long argl,long ret);
542#else 546#else
@@ -555,7 +559,7 @@ BIO_METHOD *BIO_s_bio(void);
555BIO_METHOD *BIO_s_null(void); 559BIO_METHOD *BIO_s_null(void);
556BIO_METHOD *BIO_f_null(void); 560BIO_METHOD *BIO_f_null(void);
557BIO_METHOD *BIO_f_buffer(void); 561BIO_METHOD *BIO_f_buffer(void);
558#ifdef VMS 562#ifdef OPENSSL_SYS_VMS
559BIO_METHOD *BIO_f_linebuffer(void); 563BIO_METHOD *BIO_f_linebuffer(void);
560#endif 564#endif
561BIO_METHOD *BIO_f_nbio_test(void); 565BIO_METHOD *BIO_f_nbio_test(void);
@@ -588,8 +592,6 @@ int BIO_sock_init(void );
588void BIO_sock_cleanup(void); 592void BIO_sock_cleanup(void);
589int BIO_set_tcp_ndelay(int sock,int turn_on); 593int BIO_set_tcp_ndelay(int sock,int turn_on);
590 594
591void ERR_load_BIO_strings(void );
592
593BIO *BIO_new_socket(int sock, int close_flag); 595BIO *BIO_new_socket(int sock, int close_flag);
594BIO *BIO_new_fd(int fd, int close_flag); 596BIO *BIO_new_fd(int fd, int close_flag);
595BIO *BIO_new_connect(char *host_port); 597BIO *BIO_new_connect(char *host_port);
@@ -615,6 +617,7 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
615/* The following lines are auto generated by the script mkerr.pl. Any changes 617/* The following lines are auto generated by the script mkerr.pl. Any changes
616 * made after this point may be overwritten when the script is next run. 618 * made after this point may be overwritten when the script is next run.
617 */ 619 */
620void ERR_load_BIO_strings(void);
618 621
619/* Error codes for the BIO functions. */ 622/* Error codes for the BIO functions. */
620 623
@@ -670,6 +673,7 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
670#define BIO_R_NO_HOSTNAME_SPECIFIED 112 673#define BIO_R_NO_HOSTNAME_SPECIFIED 112
671#define BIO_R_NO_PORT_DEFINED 113 674#define BIO_R_NO_PORT_DEFINED 113
672#define BIO_R_NO_PORT_SPECIFIED 114 675#define BIO_R_NO_PORT_SPECIFIED 114
676#define BIO_R_NO_SUCH_FILE 128
673#define BIO_R_NULL_PARAMETER 115 677#define BIO_R_NULL_PARAMETER 115
674#define BIO_R_TAG_MISMATCH 116 678#define BIO_R_TAG_MISMATCH 116
675#define BIO_R_UNABLE_TO_BIND_SOCKET 117 679#define BIO_R_UNABLE_TO_BIND_SOCKET 117
@@ -684,4 +688,3 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
684} 688}
685#endif 689#endif
686#endif 690#endif
687
diff --git a/src/lib/libcrypto/bio/bio_cb.c b/src/lib/libcrypto/bio/bio_cb.c
index 37c7c22666..0ffa4d2136 100644
--- a/src/lib/libcrypto/bio/bio_cb.c
+++ b/src/lib/libcrypto/bio/bio_cb.c
@@ -125,7 +125,7 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
125 b=(BIO *)bio->cb_arg; 125 b=(BIO *)bio->cb_arg;
126 if (b != NULL) 126 if (b != NULL)
127 BIO_write(b,buf,strlen(buf)); 127 BIO_write(b,buf,strlen(buf));
128#if !defined(NO_STDIO) && !defined(WIN16) 128#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
129 else 129 else
130 fputs(buf,stderr); 130 fputs(buf,stderr);
131#endif 131#endif
diff --git a/src/lib/libcrypto/bio/bio_err.c b/src/lib/libcrypto/bio/bio_err.c
index bb815fb1e6..99ca3cd0da 100644
--- a/src/lib/libcrypto/bio/bio_err.c
+++ b/src/lib/libcrypto/bio/bio_err.c
@@ -63,7 +63,7 @@
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA BIO_str_functs[]= 67static ERR_STRING_DATA BIO_str_functs[]=
68 { 68 {
69{ERR_PACK(0,BIO_F_ACPT_STATE,0), "ACPT_STATE"}, 69{ERR_PACK(0,BIO_F_ACPT_STATE,0), "ACPT_STATE"},
@@ -120,6 +120,7 @@ static ERR_STRING_DATA BIO_str_reasons[]=
120{BIO_R_NO_HOSTNAME_SPECIFIED ,"no hostname specified"}, 120{BIO_R_NO_HOSTNAME_SPECIFIED ,"no hostname specified"},
121{BIO_R_NO_PORT_DEFINED ,"no port defined"}, 121{BIO_R_NO_PORT_DEFINED ,"no port defined"},
122{BIO_R_NO_PORT_SPECIFIED ,"no port specified"}, 122{BIO_R_NO_PORT_SPECIFIED ,"no port specified"},
123{BIO_R_NO_SUCH_FILE ,"no such file"},
123{BIO_R_NULL_PARAMETER ,"null parameter"}, 124{BIO_R_NULL_PARAMETER ,"null parameter"},
124{BIO_R_TAG_MISMATCH ,"tag mismatch"}, 125{BIO_R_TAG_MISMATCH ,"tag mismatch"},
125{BIO_R_UNABLE_TO_BIND_SOCKET ,"unable to bind socket"}, 126{BIO_R_UNABLE_TO_BIND_SOCKET ,"unable to bind socket"},
@@ -141,7 +142,7 @@ void ERR_load_BIO_strings(void)
141 if (init) 142 if (init)
142 { 143 {
143 init=0; 144 init=0;
144#ifndef NO_ERR 145#ifndef OPENSSL_NO_ERR
145 ERR_load_strings(ERR_LIB_BIO,BIO_str_functs); 146 ERR_load_strings(ERR_LIB_BIO,BIO_str_functs);
146 ERR_load_strings(ERR_LIB_BIO,BIO_str_reasons); 147 ERR_load_strings(ERR_LIB_BIO,BIO_str_reasons);
147#endif 148#endif
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 381afc9b8e..50df2238fa 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -63,9 +63,6 @@
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/stack.h> 64#include <openssl/stack.h>
65 65
66static STACK_OF(CRYPTO_EX_DATA_FUNCS) *bio_meth=NULL;
67static int bio_meth_num=0;
68
69BIO *BIO_new(BIO_METHOD *method) 66BIO *BIO_new(BIO_METHOD *method)
70 { 67 {
71 BIO *ret=NULL; 68 BIO *ret=NULL;
@@ -100,10 +97,14 @@ int BIO_set(BIO *bio, BIO_METHOD *method)
100 bio->references=1; 97 bio->references=1;
101 bio->num_read=0L; 98 bio->num_read=0L;
102 bio->num_write=0L; 99 bio->num_write=0L;
103 CRYPTO_new_ex_data(bio_meth,bio,&bio->ex_data); 100 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
104 if (method->create != NULL) 101 if (method->create != NULL)
105 if (!method->create(bio)) 102 if (!method->create(bio))
103 {
104 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio,
105 &bio->ex_data);
106 return(0); 106 return(0);
107 }
107 return(1); 108 return(1);
108 } 109 }
109 110
@@ -129,7 +130,7 @@ int BIO_free(BIO *a)
129 ((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))
130 return(i); 131 return(i);
131 132
132 CRYPTO_free_ex_data(bio_meth,a,&a->ex_data); 133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);
133 134
134 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); 135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
135 ret=a->method->destroy(a); 136 ret=a->method->destroy(a);
@@ -482,7 +483,8 @@ BIO *BIO_dup_chain(BIO *in)
482 } 483 }
483 484
484 /* copy app data */ 485 /* copy app data */
485 if (!CRYPTO_dup_ex_data(bio_meth,&new->ex_data,&bio->ex_data)) 486 if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new->ex_data,
487 &bio->ex_data))
486 goto err; 488 goto err;
487 489
488 if (ret == NULL) 490 if (ret == NULL)
@@ -512,9 +514,8 @@ void BIO_copy_next_retry(BIO *b)
512int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 514int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
513 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 515 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
514 { 516 {
515 bio_meth_num++; 517 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, argl, argp,
516 return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, 518 new_func, dup_func, free_func);
517 argl,argp,new_func,dup_func,free_func));
518 } 519 }
519 520
520int BIO_set_ex_data(BIO *bio, int idx, void *data) 521int BIO_set_ex_data(BIO *bio, int idx, void *data)
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index 4da5822062..8ea1db158b 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SOCK 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <errno.h> 62#include <errno.h>
@@ -64,13 +64,13 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifdef WIN16 67#ifdef OPENSSL_SYS_WIN16
68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
69#else 69#else
70#define SOCKET_PROTOCOL IPPROTO_TCP 70#define SOCKET_PROTOCOL IPPROTO_TCP
71#endif 71#endif
72 72
73#if (defined(VMS) && __VMS_VER < 70000000) 73#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
75#undef FIONBIO 75#undef FIONBIO
76#endif 76#endif
@@ -236,8 +236,20 @@ again:
236 c->state=ACPT_S_OK; 236 c->state=ACPT_S_OK;
237 goto again; 237 goto again;
238 } 238 }
239 BIO_clear_retry_flags(b);
240 b->retry_reason=0;
239 i=BIO_accept(c->accept_sock,&(c->addr)); 241 i=BIO_accept(c->accept_sock,&(c->addr));
242
243 /* -2 return means we should retry */
244 if(i == -2)
245 {
246 BIO_set_retry_special(b);
247 b->retry_reason=BIO_RR_ACCEPT;
248 return -1;
249 }
250
240 if (i < 0) return(i); 251 if (i < 0) return(i);
252
241 bio=BIO_new_socket(i,BIO_CLOSE); 253 bio=BIO_new_socket(i,BIO_CLOSE);
242 if (bio == NULL) goto err; 254 if (bio == NULL) goto err;
243 255
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index 78c6ab4fdd..a5da473031 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -22,7 +22,12 @@
22#include <openssl/err.h> 22#include <openssl/err.h>
23#include <openssl/crypto.h> 23#include <openssl/crypto.h>
24 24
25#include "openssl/e_os.h" 25#include "e_os.h"
26
27/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */
28#if defined(OPENSSL_SYS_VSWORKS)
29# undef SSIZE_MAX
30#endif
26#ifndef SSIZE_MAX 31#ifndef SSIZE_MAX
27# define SSIZE_MAX INT_MAX 32# define SSIZE_MAX INT_MAX
28#endif 33#endif
@@ -474,7 +479,8 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
474 break; 479 break;
475 480
476 case BIO_C_GET_WRITE_BUF_SIZE: 481 case BIO_C_GET_WRITE_BUF_SIZE:
477 num = (long) b->size; 482 ret = (long) b->size;
483 break;
478 484
479 case BIO_C_MAKE_BIO_PAIR: 485 case BIO_C_MAKE_BIO_PAIR:
480 { 486 {
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index a6b77a2cb9..f91ae4c8c6 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SOCK 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <errno.h> 62#include <errno.h>
@@ -64,13 +64,13 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifdef WIN16 67#ifdef OPENSSL_SYS_WIN16
68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
69#else 69#else
70#define SOCKET_PROTOCOL IPPROTO_TCP 70#define SOCKET_PROTOCOL IPPROTO_TCP
71#endif 71#endif
72 72
73#if (defined(VMS) && __VMS_VER < 70000000) 73#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
75#undef FIONBIO 75#undef FIONBIO
76#endif 76#endif
@@ -95,7 +95,7 @@ typedef struct bio_connect_st
95 /* called when the connection is initially made 95 /* called when the connection is initially made
96 * callback(BIO,state,ret); The callback should return 96 * callback(BIO,state,ret); The callback should return
97 * 'ret'. state is for compatibility with the ssl info_callback */ 97 * 'ret'. state is for compatibility with the ssl info_callback */
98 int (*info_callback)(); 98 int (*info_callback)(const BIO *bio,int state,int ret);
99 } BIO_CONNECT; 99 } BIO_CONNECT;
100 100
101static int conn_write(BIO *h, const char *buf, int num); 101static int conn_write(BIO *h, const char *buf, int num);
@@ -236,7 +236,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
236 } 236 }
237 c->state=BIO_CONN_S_CONNECT; 237 c->state=BIO_CONN_S_CONNECT;
238 238
239#if defined(SO_KEEPALIVE) && !defined(MPE) 239#if defined(SO_KEEPALIVE) && !defined(OPENSSL_SYS_MPE)
240 i=1; 240 i=1;
241 i=setsockopt(b->num,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i)); 241 i=setsockopt(b->num,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
242 if (i < 0) 242 if (i < 0)
@@ -574,7 +574,8 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
574 if (data->param_hostname) 574 if (data->param_hostname)
575 BIO_set_conn_hostname(dbio,data->param_hostname); 575 BIO_set_conn_hostname(dbio,data->param_hostname);
576 BIO_set_nbio(dbio,data->nbio); 576 BIO_set_nbio(dbio,data->nbio);
577 (void)BIO_set_info_callback(dbio,data->info_callback); 577 /* FIXME: the cast of the function seems unlikely to be a good idea */
578 (void)BIO_set_info_callback(dbio,(bio_info_cb *)data->info_callback);
578 } 579 }
579 break; 580 break;
580 case BIO_CTRL_SET_CALLBACK: 581 case BIO_CTRL_SET_CALLBACK:
@@ -613,7 +614,7 @@ static long conn_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
613 { 614 {
614 case BIO_CTRL_SET_CALLBACK: 615 case BIO_CTRL_SET_CALLBACK:
615 { 616 {
616 data->info_callback=(int (*)())fp; 617 data->info_callback=(int (*)(const struct bio_st *, int, int))fp;
617 } 618 }
618 break; 619 break;
619 default: 620 default:
diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c
index 686c4909a2..5e3e187de6 100644
--- a/src/lib/libcrypto/bio/bss_fd.c
+++ b/src/lib/libcrypto/bio/bss_fd.c
@@ -56,7 +56,227 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#define BIO_FD 59#include <stdio.h>
60#include "bss_sock.c" 60#include <errno.h>
61#undef BIO_FD 61#define USE_SOCKETS
62#include "cryptlib.h"
63#include <openssl/bio.h>
62 64
65static int fd_write(BIO *h, const char *buf, int num);
66static int fd_read(BIO *h, char *buf, int size);
67static int fd_puts(BIO *h, const char *str);
68static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
69static int fd_new(BIO *h);
70static int fd_free(BIO *data);
71int BIO_fd_should_retry(int s);
72
73static BIO_METHOD methods_fdp=
74 {
75 BIO_TYPE_FD,"file descriptor",
76 fd_write,
77 fd_read,
78 fd_puts,
79 NULL, /* fd_gets, */
80 fd_ctrl,
81 fd_new,
82 fd_free,
83 NULL,
84 };
85
86BIO_METHOD *BIO_s_fd(void)
87 {
88 return(&methods_fdp);
89 }
90
91BIO *BIO_new_fd(int fd,int close_flag)
92 {
93 BIO *ret;
94 ret=BIO_new(BIO_s_fd());
95 if (ret == NULL) return(NULL);
96 BIO_set_fd(ret,fd,close_flag);
97 return(ret);
98 }
99
100static int fd_new(BIO *bi)
101 {
102 bi->init=0;
103 bi->num=0;
104 bi->ptr=NULL;
105 bi->flags=0;
106 return(1);
107 }
108
109static int fd_free(BIO *a)
110 {
111 if (a == NULL) return(0);
112 if (a->shutdown)
113 {
114 if (a->init)
115 {
116 close(a->num);
117 }
118 a->init=0;
119 a->flags=0;
120 }
121 return(1);
122 }
123
124static int fd_read(BIO *b, char *out,int outl)
125 {
126 int ret=0;
127
128 if (out != NULL)
129 {
130 clear_sys_error();
131 ret=read(b->num,out,outl);
132 BIO_clear_retry_flags(b);
133 if (ret <= 0)
134 {
135 if (BIO_fd_should_retry(ret))
136 BIO_set_retry_read(b);
137 }
138 }
139 return(ret);
140 }
141
142static int fd_write(BIO *b, const char *in, int inl)
143 {
144 int ret;
145 clear_sys_error();
146 ret=write(b->num,in,inl);
147 BIO_clear_retry_flags(b);
148 if (ret <= 0)
149 {
150 if (BIO_fd_should_retry(ret))
151 BIO_set_retry_write(b);
152 }
153 return(ret);
154 }
155
156static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
157 {
158 long ret=1;
159 int *ip;
160
161 switch (cmd)
162 {
163 case BIO_CTRL_RESET:
164 num=0;
165 case BIO_C_FILE_SEEK:
166 ret=(long)lseek(b->num,num,0);
167 break;
168 case BIO_C_FILE_TELL:
169 case BIO_CTRL_INFO:
170 ret=(long)lseek(b->num,0,1);
171 break;
172 case BIO_C_SET_FD:
173 fd_free(b);
174 b->num= *((int *)ptr);
175 b->shutdown=(int)num;
176 b->init=1;
177 break;
178 case BIO_C_GET_FD:
179 if (b->init)
180 {
181 ip=(int *)ptr;
182 if (ip != NULL) *ip=b->num;
183 ret=b->num;
184 }
185 else
186 ret= -1;
187 break;
188 case BIO_CTRL_GET_CLOSE:
189 ret=b->shutdown;
190 break;
191 case BIO_CTRL_SET_CLOSE:
192 b->shutdown=(int)num;
193 break;
194 case BIO_CTRL_PENDING:
195 case BIO_CTRL_WPENDING:
196 ret=0;
197 break;
198 case BIO_CTRL_DUP:
199 case BIO_CTRL_FLUSH:
200 ret=1;
201 break;
202 default:
203 ret=0;
204 break;
205 }
206 return(ret);
207 }
208
209static int fd_puts(BIO *bp, const char *str)
210 {
211 int n,ret;
212
213 n=strlen(str);
214 ret=fd_write(bp,str,n);
215 return(ret);
216 }
217
218int BIO_fd_should_retry(int i)
219 {
220 int err;
221
222 if ((i == 0) || (i == -1))
223 {
224 err=get_last_sys_error();
225
226#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
227 if ((i == -1) && (err == 0))
228 return(1);
229#endif
230
231 return(BIO_fd_non_fatal_error(err));
232 }
233 return(0);
234 }
235
236int BIO_fd_non_fatal_error(int err)
237 {
238 switch (err)
239 {
240
241#ifdef EWOULDBLOCK
242# ifdef WSAEWOULDBLOCK
243# if WSAEWOULDBLOCK != EWOULDBLOCK
244 case EWOULDBLOCK:
245# endif
246# else
247 case EWOULDBLOCK:
248# endif
249#endif
250
251#if defined(ENOTCONN)
252 case ENOTCONN:
253#endif
254
255#ifdef EINTR
256 case EINTR:
257#endif
258
259#ifdef EAGAIN
260#if EWOULDBLOCK != EAGAIN
261 case EAGAIN:
262# endif
263#endif
264
265#ifdef EPROTO
266 case EPROTO:
267#endif
268
269#ifdef EINPROGRESS
270 case EINPROGRESS:
271#endif
272
273#ifdef EALREADY
274 case EALREADY:
275#endif
276 return(1);
277 /* break; */
278 default:
279 break;
280 }
281 return(0);
282 }
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 1f770b390f..8b3ff278d9 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -71,7 +71,7 @@
71#include <openssl/bio.h> 71#include <openssl/bio.h>
72#include <openssl/err.h> 72#include <openssl/err.h>
73 73
74#if !defined(NO_STDIO) 74#if !defined(OPENSSL_NO_STDIO)
75 75
76static int MS_CALLBACK file_write(BIO *h, const char *buf, int num); 76static int MS_CALLBACK file_write(BIO *h, const char *buf, int num);
77static int MS_CALLBACK file_read(BIO *h, char *buf, int size); 77static int MS_CALLBACK file_read(BIO *h, char *buf, int size);
@@ -103,7 +103,10 @@ BIO *BIO_new_file(const char *filename, const char *mode)
103 { 103 {
104 SYSerr(SYS_F_FOPEN,get_last_sys_error()); 104 SYSerr(SYS_F_FOPEN,get_last_sys_error());
105 ERR_add_error_data(5,"fopen('",filename,"','",mode,"')"); 105 ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");
106 BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB); 106 if (errno == ENOENT)
107 BIOerr(BIO_F_BIO_NEW_FILE,BIO_R_NO_SUCH_FILE);
108 else
109 BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
107 return(NULL); 110 return(NULL);
108 } 111 }
109 if ((ret=BIO_new(BIO_s_file_internal())) == NULL) 112 if ((ret=BIO_new(BIO_s_file_internal())) == NULL)
@@ -204,12 +207,17 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
204 b->shutdown=(int)num&BIO_CLOSE; 207 b->shutdown=(int)num&BIO_CLOSE;
205 b->ptr=(char *)ptr; 208 b->ptr=(char *)ptr;
206 b->init=1; 209 b->init=1;
207#if defined(MSDOS) || defined(WINDOWS) 210#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
208 /* Set correct text/binary mode */ 211 /* Set correct text/binary mode */
209 if (num & BIO_FP_TEXT) 212 if (num & BIO_FP_TEXT)
210 _setmode(fileno((FILE *)ptr),_O_TEXT); 213 _setmode(fileno((FILE *)ptr),_O_TEXT);
211 else 214 else
212 _setmode(fileno((FILE *)ptr),_O_BINARY); 215 _setmode(fileno((FILE *)ptr),_O_BINARY);
216#elif defined(OPENSSL_SYS_OS2)
217 if (num & BIO_FP_TEXT)
218 setmode(fileno((FILE *)ptr), O_TEXT);
219 else
220 setmode(fileno((FILE *)ptr), O_BINARY);
213#endif 221#endif
214 break; 222 break;
215 case BIO_C_SET_FILENAME: 223 case BIO_C_SET_FILENAME:
@@ -233,7 +241,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
233 ret=0; 241 ret=0;
234 break; 242 break;
235 } 243 }
236#if defined(MSDOS) || defined(WINDOWS) 244#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
237 if (!(num & BIO_FP_TEXT)) 245 if (!(num & BIO_FP_TEXT))
238 strcat(p,"b"); 246 strcat(p,"b");
239 else 247 else
@@ -303,7 +311,7 @@ static int MS_CALLBACK file_puts(BIO *bp, const char *str)
303 return(ret); 311 return(ret);
304 } 312 }
305 313
306#endif /* NO_STDIO */ 314#endif /* OPENSSL_NO_STDIO */
307 315
308#endif /* HEADER_BSS_FILE_C */ 316#endif /* HEADER_BSS_FILE_C */
309 317
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index 1edf16a76f..a39d95297c 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -66,26 +66,27 @@
66#include <stdio.h> 66#include <stdio.h>
67#include <errno.h> 67#include <errno.h>
68 68
69#if defined(WIN32) 69#include "cryptlib.h"
70
71#if defined(OPENSSL_SYS_WIN32)
70# include <process.h> 72# include <process.h>
71#elif defined(VMS) || defined(__VMS) 73#elif defined(OPENSSL_SYS_VMS)
72# include <opcdef.h> 74# include <opcdef.h>
73# include <descrip.h> 75# include <descrip.h>
74# include <lib$routines.h> 76# include <lib$routines.h>
75# include <starlet.h> 77# include <starlet.h>
76#elif defined(__ultrix) 78#elif defined(__ultrix)
77# include <sys/syslog.h> 79# include <sys/syslog.h>
78#elif !defined(MSDOS) /* Unix */ 80#elif !defined(MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) /* Unix */
79# include <syslog.h> 81# include <syslog.h>
80#endif 82#endif
81 83
82#include "cryptlib.h"
83#include <openssl/buffer.h> 84#include <openssl/buffer.h>
84#include <openssl/err.h> 85#include <openssl/err.h>
85 86
86#ifndef NO_SYSLOG 87#ifndef NO_SYSLOG
87 88
88#if defined(WIN32) 89#if defined(OPENSSL_SYS_WIN32)
89#define LOG_EMERG 0 90#define LOG_EMERG 0
90#define LOG_ALERT 1 91#define LOG_ALERT 1
91#define LOG_CRIT 2 92#define LOG_CRIT 2
@@ -96,7 +97,7 @@
96#define LOG_DEBUG 7 97#define LOG_DEBUG 7
97 98
98#define LOG_DAEMON (3<<3) 99#define LOG_DAEMON (3<<3)
99#elif defined(VMS) 100#elif defined(OPENSSL_SYS_VMS)
100/* On VMS, we don't really care about these, but we need them to compile */ 101/* On VMS, we don't really care about these, but we need them to compile */
101#define LOG_EMERG 0 102#define LOG_EMERG 0
102#define LOG_ALERT 1 103#define LOG_ALERT 1
@@ -118,7 +119,7 @@ static int MS_CALLBACK slg_free(BIO *data);
118static void xopenlog(BIO* bp, char* name, int level); 119static void xopenlog(BIO* bp, char* name, int level);
119static void xsyslog(BIO* bp, int priority, const char* string); 120static void xsyslog(BIO* bp, int priority, const char* string);
120static void xcloselog(BIO* bp); 121static void xcloselog(BIO* bp);
121#ifdef WIN32 122#ifdef OPENSSL_SYS_WIN32
122LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx; 123LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx;
123HANDLE (WINAPI *register_event_source)() = NULL; 124HANDLE (WINAPI *register_event_source)() = NULL;
124BOOL (WINAPI *deregister_event_source)() = NULL; 125BOOL (WINAPI *deregister_event_source)() = NULL;
@@ -241,7 +242,7 @@ static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
241 return(ret); 242 return(ret);
242 } 243 }
243 244
244#if defined(WIN32) 245#if defined(OPENSSL_SYS_WIN32)
245 246
246static void xopenlog(BIO* bp, char* name, int level) 247static void xopenlog(BIO* bp, char* name, int level)
247{ 248{
@@ -313,7 +314,7 @@ static void xcloselog(BIO* bp)
313 bp->ptr= NULL; 314 bp->ptr= NULL;
314} 315}
315 316
316#elif defined(VMS) 317#elif defined(OPENSSL_SYS_VMS)
317 318
318static int VMS_OPC_target = LOG_DAEMON; 319static int VMS_OPC_target = LOG_DAEMON;
319 320
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c
index 50c6744c06..fdabd16d7e 100644
--- a/src/lib/libcrypto/bio/bss_sock.c
+++ b/src/lib/libcrypto/bio/bss_sock.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#if !defined(NO_SOCK) || defined(BIO_FD) 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <errno.h> 62#include <errno.h>
@@ -64,7 +64,6 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifndef BIO_FD
68static int sock_write(BIO *h, const char *buf, int num); 67static int sock_write(BIO *h, const char *buf, int num);
69static int sock_read(BIO *h, char *buf, int size); 68static int sock_read(BIO *h, char *buf, int size);
70static int sock_puts(BIO *h, const char *str); 69static int sock_puts(BIO *h, const char *str);
@@ -72,18 +71,7 @@ static long sock_ctrl(BIO *h, int cmd, long arg1, void *arg2);
72static int sock_new(BIO *h); 71static int sock_new(BIO *h);
73static int sock_free(BIO *data); 72static int sock_free(BIO *data);
74int BIO_sock_should_retry(int s); 73int BIO_sock_should_retry(int s);
75#else
76 74
77static int fd_write(BIO *h, const char *buf, int num);
78static int fd_read(BIO *h, char *buf, int size);
79static int fd_puts(BIO *h, const char *str);
80static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
81static int fd_new(BIO *h);
82static int fd_free(BIO *data);
83int BIO_fd_should_retry(int s);
84#endif
85
86#ifndef BIO_FD
87static BIO_METHOD methods_sockp= 75static BIO_METHOD methods_sockp=
88 { 76 {
89 BIO_TYPE_SOCKET, 77 BIO_TYPE_SOCKET,
@@ -102,49 +90,18 @@ BIO_METHOD *BIO_s_socket(void)
102 { 90 {
103 return(&methods_sockp); 91 return(&methods_sockp);
104 } 92 }
105#else
106static BIO_METHOD methods_fdp=
107 {
108 BIO_TYPE_FD,"file descriptor",
109 fd_write,
110 fd_read,
111 fd_puts,
112 NULL, /* fd_gets, */
113 fd_ctrl,
114 fd_new,
115 fd_free,
116 NULL,
117 };
118
119BIO_METHOD *BIO_s_fd(void)
120 {
121 return(&methods_fdp);
122 }
123#endif
124 93
125#ifndef BIO_FD
126BIO *BIO_new_socket(int fd, int close_flag) 94BIO *BIO_new_socket(int fd, int close_flag)
127#else
128BIO *BIO_new_fd(int fd,int close_flag)
129#endif
130 { 95 {
131 BIO *ret; 96 BIO *ret;
132 97
133#ifndef BIO_FD
134 ret=BIO_new(BIO_s_socket()); 98 ret=BIO_new(BIO_s_socket());
135#else
136 ret=BIO_new(BIO_s_fd());
137#endif
138 if (ret == NULL) return(NULL); 99 if (ret == NULL) return(NULL);
139 BIO_set_fd(ret,fd,close_flag); 100 BIO_set_fd(ret,fd,close_flag);
140 return(ret); 101 return(ret);
141 } 102 }
142 103
143#ifndef BIO_FD
144static int sock_new(BIO *bi) 104static int sock_new(BIO *bi)
145#else
146static int fd_new(BIO *bi)
147#endif
148 { 105 {
149 bi->init=0; 106 bi->init=0;
150 bi->num=0; 107 bi->num=0;
@@ -153,23 +110,14 @@ static int fd_new(BIO *bi)
153 return(1); 110 return(1);
154 } 111 }
155 112
156#ifndef BIO_FD
157static int sock_free(BIO *a) 113static int sock_free(BIO *a)
158#else
159static int fd_free(BIO *a)
160#endif
161 { 114 {
162 if (a == NULL) return(0); 115 if (a == NULL) return(0);
163 if (a->shutdown) 116 if (a->shutdown)
164 { 117 {
165 if (a->init) 118 if (a->init)
166 { 119 {
167#ifndef BIO_FD
168 SHUTDOWN2(a->num); 120 SHUTDOWN2(a->num);
169#else /* BIO_FD */
170 close(a->num);
171#endif
172
173 } 121 }
174 a->init=0; 122 a->init=0;
175 a->flags=0; 123 a->flags=0;
@@ -177,70 +125,40 @@ static int fd_free(BIO *a)
177 return(1); 125 return(1);
178 } 126 }
179 127
180#ifndef BIO_FD
181static int sock_read(BIO *b, char *out, int outl) 128static int sock_read(BIO *b, char *out, int outl)
182#else
183static int fd_read(BIO *b, char *out,int outl)
184#endif
185 { 129 {
186 int ret=0; 130 int ret=0;
187 131
188 if (out != NULL) 132 if (out != NULL)
189 { 133 {
190#ifndef BIO_FD
191 clear_socket_error(); 134 clear_socket_error();
192 ret=readsocket(b->num,out,outl); 135 ret=readsocket(b->num,out,outl);
193#else
194 clear_sys_error();
195 ret=read(b->num,out,outl);
196#endif
197 BIO_clear_retry_flags(b); 136 BIO_clear_retry_flags(b);
198 if (ret <= 0) 137 if (ret <= 0)
199 { 138 {
200#ifndef BIO_FD
201 if (BIO_sock_should_retry(ret)) 139 if (BIO_sock_should_retry(ret))
202#else
203 if (BIO_fd_should_retry(ret))
204#endif
205 BIO_set_retry_read(b); 140 BIO_set_retry_read(b);
206 } 141 }
207 } 142 }
208 return(ret); 143 return(ret);
209 } 144 }
210 145
211#ifndef BIO_FD
212static int sock_write(BIO *b, const char *in, int inl) 146static int sock_write(BIO *b, const char *in, int inl)
213#else
214static int fd_write(BIO *b, const char *in, int inl)
215#endif
216 { 147 {
217 int ret; 148 int ret;
218 149
219#ifndef BIO_FD
220 clear_socket_error(); 150 clear_socket_error();
221 ret=writesocket(b->num,in,inl); 151 ret=writesocket(b->num,in,inl);
222#else
223 clear_sys_error();
224 ret=write(b->num,in,inl);
225#endif
226 BIO_clear_retry_flags(b); 152 BIO_clear_retry_flags(b);
227 if (ret <= 0) 153 if (ret <= 0)
228 { 154 {
229#ifndef BIO_FD
230 if (BIO_sock_should_retry(ret)) 155 if (BIO_sock_should_retry(ret))
231#else
232 if (BIO_fd_should_retry(ret))
233#endif
234 BIO_set_retry_write(b); 156 BIO_set_retry_write(b);
235 } 157 }
236 return(ret); 158 return(ret);
237 } 159 }
238 160
239#ifndef BIO_FD
240static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) 161static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
241#else
242static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
243#endif
244 { 162 {
245 long ret=1; 163 long ret=1;
246 int *ip; 164 int *ip;
@@ -250,26 +168,14 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
250 case BIO_CTRL_RESET: 168 case BIO_CTRL_RESET:
251 num=0; 169 num=0;
252 case BIO_C_FILE_SEEK: 170 case BIO_C_FILE_SEEK:
253#ifdef BIO_FD
254 ret=(long)lseek(b->num,num,0);
255#else
256 ret=0; 171 ret=0;
257#endif
258 break; 172 break;
259 case BIO_C_FILE_TELL: 173 case BIO_C_FILE_TELL:
260 case BIO_CTRL_INFO: 174 case BIO_CTRL_INFO:
261#ifdef BIO_FD
262 ret=(long)lseek(b->num,0,1);
263#else
264 ret=0; 175 ret=0;
265#endif
266 break; 176 break;
267 case BIO_C_SET_FD: 177 case BIO_C_SET_FD:
268#ifndef BIO_FD
269 sock_free(b); 178 sock_free(b);
270#else
271 fd_free(b);
272#endif
273 b->num= *((int *)ptr); 179 b->num= *((int *)ptr);
274 b->shutdown=(int)num; 180 b->shutdown=(int)num;
275 b->init=1; 181 b->init=1;
@@ -305,69 +211,38 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
305 return(ret); 211 return(ret);
306 } 212 }
307 213
308#ifdef undef
309static int sock_gets(BIO *bp, char *buf,int size)
310 {
311 return(-1);
312 }
313#endif
314
315#ifndef BIO_FD
316static int sock_puts(BIO *bp, const char *str) 214static int sock_puts(BIO *bp, const char *str)
317#else
318static int fd_puts(BIO *bp, const char *str)
319#endif
320 { 215 {
321 int n,ret; 216 int n,ret;
322 217
323 n=strlen(str); 218 n=strlen(str);
324#ifndef BIO_FD
325 ret=sock_write(bp,str,n); 219 ret=sock_write(bp,str,n);
326#else
327 ret=fd_write(bp,str,n);
328#endif
329 return(ret); 220 return(ret);
330 } 221 }
331 222
332#ifndef BIO_FD
333int BIO_sock_should_retry(int i) 223int BIO_sock_should_retry(int i)
334#else
335int BIO_fd_should_retry(int i)
336#endif
337 { 224 {
338 int err; 225 int err;
339 226
340 if ((i == 0) || (i == -1)) 227 if ((i == 0) || (i == -1))
341 { 228 {
342#ifndef BIO_FD
343 err=get_last_socket_error(); 229 err=get_last_socket_error();
344#else
345 err=get_last_sys_error();
346#endif
347 230
348#if defined(WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ 231#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
349 if ((i == -1) && (err == 0)) 232 if ((i == -1) && (err == 0))
350 return(1); 233 return(1);
351#endif 234#endif
352 235
353#ifndef BIO_FD
354 return(BIO_sock_non_fatal_error(err)); 236 return(BIO_sock_non_fatal_error(err));
355#else
356 return(BIO_fd_non_fatal_error(err));
357#endif
358 } 237 }
359 return(0); 238 return(0);
360 } 239 }
361 240
362#ifndef BIO_FD
363int BIO_sock_non_fatal_error(int err) 241int BIO_sock_non_fatal_error(int err)
364#else
365int BIO_fd_non_fatal_error(int err)
366#endif
367 { 242 {
368 switch (err) 243 switch (err)
369 { 244 {
370#if !defined(BIO_FD) && defined(WINDOWS) 245#if defined(OPENSSL_SYS_WINDOWS)
371# if defined(WSAEWOULDBLOCK) 246# if defined(WSAEWOULDBLOCK)
372 case WSAEWOULDBLOCK: 247 case WSAEWOULDBLOCK:
373# endif 248# endif