static size_t internal_trace_cb(const char *buf, size_t cnt,
int category, int cmd, void *vdata)
{
- int ret;
+ int ret = 0;
tracedata *trace_data = vdata;
- int set_prefix = 0;
+ union {
+ CRYPTO_THREAD_ID tid;
+ unsigned long ltid;
+ } tid;
+ char buffer[256];
switch (cmd) {
case OSSL_TRACE_CTRL_BEGIN:
trace_data->ingroup = 1;
- set_prefix = 1;
- break;
- case OSSL_TRACE_CTRL_DURING:
- if (!trace_data->ingroup)
- set_prefix = 1;
- break;
- case OSSL_TRACE_CTRL_END:
- trace_data->ingroup = 0;
- break;
- }
-
- if (set_prefix) {
- union {
- CRYPTO_THREAD_ID tid;
- unsigned long ltid;
- } tid;
- char buffer[256];
tid.ltid = 0;
tid.tid = CRYPTO_THREAD_get_current_id();
OSSL_trace_get_category_name(category));
BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX,
strlen(buffer), buffer);
+ break;
+ case OSSL_TRACE_CTRL_WRITE:
+ ret = BIO_write(trace_data->bio, buf, cnt);
+ break;
+ case OSSL_TRACE_CTRL_END:
+ trace_data->ingroup = 0;
+
+ BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, 0, NULL);
+
+ break;
}
- ret = BIO_write(trace_data->bio, buf, cnt);
return ret < 0 ? 0 : ret;
}
const char *buf, size_t num, size_t *written)
{
struct trace_data_st *ctx = BIO_get_data(channel);
- size_t cnt = ctx->callback(buf, num, ctx->category, OSSL_TRACE_CTRL_DURING,
+ size_t cnt = ctx->callback(buf, num, ctx->category, OSSL_TRACE_CTRL_WRITE,
ctx->data);
*written = cnt;
* Possible |cmd| numbers.
*/
# define OSSL_TRACE_CTRL_BEGIN 0
-# define OSSL_TRACE_CTRL_DURING 1
+# define OSSL_TRACE_CTRL_WRITE 1
# define OSSL_TRACE_CTRL_END 2
/*