]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/bio/bio_cb.c
2 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 #include "bio_local.h"
14 #include "internal/cryptlib.h"
15 #include <openssl/err.h>
17 long BIO_debug_callback(BIO
*bio
, int cmd
, const char *argp
,
18 int argi
, long argl
, long ret
)
26 if (BIO_CB_RETURN
& cmd
)
29 len
= BIO_snprintf(buf
, sizeof(buf
), "BIO[%p]: ", (void *)bio
);
31 /* Ignore errors and continue printing the other information. */
35 left
= sizeof(buf
) - len
;
39 BIO_snprintf(p
, left
, "Free - %s\n", bio
->method
->name
);
42 if (bio
->method
->type
& BIO_TYPE_DESCRIPTOR
)
43 BIO_snprintf(p
, left
, "read(%d,%lu) - %s fd=%d\n",
44 bio
->num
, (unsigned long)argi
,
45 bio
->method
->name
, bio
->num
);
47 BIO_snprintf(p
, left
, "read(%d,%lu) - %s\n",
48 bio
->num
, (unsigned long)argi
, bio
->method
->name
);
51 if (bio
->method
->type
& BIO_TYPE_DESCRIPTOR
)
52 BIO_snprintf(p
, left
, "write(%d,%lu) - %s fd=%d\n",
53 bio
->num
, (unsigned long)argi
,
54 bio
->method
->name
, bio
->num
);
56 BIO_snprintf(p
, left
, "write(%d,%lu) - %s\n",
57 bio
->num
, (unsigned long)argi
, bio
->method
->name
);
60 BIO_snprintf(p
, left
, "puts() - %s\n", bio
->method
->name
);
63 BIO_snprintf(p
, left
, "gets(%lu) - %s\n", (unsigned long)argi
,
67 BIO_snprintf(p
, left
, "ctrl(%lu) - %s\n", (unsigned long)argi
,
70 case BIO_CB_RETURN
| BIO_CB_READ
:
71 BIO_snprintf(p
, left
, "read return %ld\n", ret
);
73 case BIO_CB_RETURN
| BIO_CB_WRITE
:
74 BIO_snprintf(p
, left
, "write return %ld\n", ret
);
76 case BIO_CB_RETURN
| BIO_CB_GETS
:
77 BIO_snprintf(p
, left
, "gets return %ld\n", ret
);
79 case BIO_CB_RETURN
| BIO_CB_PUTS
:
80 BIO_snprintf(p
, left
, "puts return %ld\n", ret
);
82 case BIO_CB_RETURN
| BIO_CB_CTRL
:
83 BIO_snprintf(p
, left
, "ctrl return %ld\n", ret
);
86 BIO_snprintf(p
, left
, "bio callback - unknown type (%d)\n", cmd
);
90 b
= (BIO
*)bio
->cb_arg
;
92 BIO_write(b
, buf
, strlen(buf
));
93 #if !defined(OPENSSL_NO_STDIO)