Diagnose EOF on memory BIOs (or you just get mysterious errors with no error
[openssl.git] / crypto / bio / bio.h
index fa4e0e2225f0b900451d55d9034900590a4d840a..0e1a16ce62a96b7f2ef6e4c5a424994fcff8bb55 100644 (file)
@@ -62,6 +62,7 @@
 #ifndef NO_FP_API
 # include <stdio.h>
 #endif
+#include <stdarg.h>
 
 #include <openssl/crypto.h>
 
@@ -211,6 +212,8 @@ extern "C" {
 
 typedef struct bio_st BIO;
 
+typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
+
 #ifndef WIN16
 typedef struct bio_method_st
        {
@@ -223,7 +226,7 @@ typedef struct bio_method_st
        long (*ctrl)(BIO *, int, long, void *);
        int (*create)(BIO *);
        int (*destroy)(BIO *);
-       long (*callback_ctrl)(BIO *, int, void (*)(struct bio_st *, int, const char *, int, long, long));
+        long (*callback_ctrl)(BIO *, int, bio_info_cb *);
        } BIO_METHOD;
 #else
 typedef struct bio_method_st
@@ -264,37 +267,6 @@ struct bio_st
        };
 
 DECLARE_STACK_OF(BIO)
-/* This block of defines is updated by a perl script, please do not touch! */
-#ifndef DEBUG_SAFESTACK
-       #define sk_BIO_new(a) sk_new((int (*) \
-               (const char * const *, const char * const *))(a))
-       #define sk_BIO_new_null() sk_new_null()
-       #define sk_BIO_free(a) sk_free(a)
-       #define sk_BIO_num(a) sk_num(a)
-       #define sk_BIO_value(a,b) ((BIO *) \
-               sk_value((a),(b)))
-       #define sk_BIO_set(a,b,c) ((BIO *) \
-               sk_set((a),(b),(char *)(c)))
-       #define sk_BIO_zero(a) sk_zero(a)
-       #define sk_BIO_push(a,b) sk_push((a),(char *)(b))
-       #define sk_BIO_unshift(a,b) sk_unshift((a),(b))
-       #define sk_BIO_find(a,b) sk_find((a), (char *)(b))
-       #define sk_BIO_delete(a,b) ((BIO *) \
-               sk_delete((a),(b)))
-       #define sk_BIO_delete_ptr(a,b) ((BIO *) \
-               sk_delete_ptr((a),(char *)(b)))
-       #define sk_BIO_insert(a,b,c) sk_insert((a),(char *)(b),(c))
-       #define sk_BIO_set_cmp_func(a,b) ((int (*) \
-               (const BIO * const *,const BIO * const *)) \
-               sk_set_cmp_func((a),(int (*) \
-               (const char * const *, const char * const *))(b)))
-       #define sk_BIO_dup(a) sk_dup(a)
-       #define sk_BIO_pop_free(a,b) sk_pop_free((a),(void (*)(void *))(b))
-       #define sk_BIO_shift(a) ((BIO *)sk_shift(a))
-       #define sk_BIO_pop(a) ((BIO *)sk_pop(a))
-       #define sk_BIO_sort(a) sk_sort(a)
-#endif /* !DEBUG_SAFESTACK */
-/* End of perl script block, you may now edit :-) */
 
 typedef struct bio_f_buffer_ctx_struct
        {
@@ -491,8 +463,8 @@ int BIO_read_filename(BIO *b,const char *name);
 size_t BIO_ctrl_pending(BIO *b);
 size_t BIO_ctrl_wpending(BIO *b);
 #define BIO_flush(b)           (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
-#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(void (**)())(cbp))
-#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(void (*)())(cb))
+#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(bio_info_cb **)(cbp))
+#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(bio_info_cb *)(cb))
 
 /* For the BIO_f_buffer() type */
 #define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
@@ -588,6 +560,7 @@ int BIO_sock_non_fatal_error(int error);
 int BIO_fd_should_retry(int i);
 int BIO_fd_non_fatal_error(int error);
 int BIO_dump(BIO *b,const char *bytes,int len);
+int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
 
 struct hostent *BIO_gethostbyname(const char *name);
 /* We might want a thread-safe interface too:
@@ -628,7 +601,9 @@ void BIO_copy_next_retry(BIO *b);
 long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
 
 int BIO_printf(BIO *bio, const char *format, ...);
+int BIO_vprintf(BIO *bio, const char *format, va_list args);
 int BIO_snprintf(char *buf, size_t n, const char *format, ...);
+int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
 
 /* BEGIN ERROR CODES */
 /* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -663,6 +638,7 @@ int BIO_snprintf(char *buf, size_t n, const char *format, ...);
 #define BIO_F_CONN_CTRL                                         127
 #define BIO_F_CONN_STATE                                115
 #define BIO_F_FILE_CTRL                                         116
+#define BIO_F_MEM_READ                                  128
 #define BIO_F_MEM_WRITE                                         117
 #define BIO_F_SSL_NEW                                   118
 #define BIO_F_WSASTARTUP                                119
@@ -673,6 +649,7 @@ int BIO_snprintf(char *buf, size_t n, const char *format, ...);
 #define BIO_R_BAD_HOSTNAME_LOOKUP                       102
 #define BIO_R_BROKEN_PIPE                               124
 #define BIO_R_CONNECT_ERROR                             103
+#define BIO_R_EOF_ON_MEMORY_BIO                                 127
 #define BIO_R_ERROR_SETTING_NBIO                        104
 #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET     105
 #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET       106