Browse Source

Fixed crash. Added some comments.

dvh-chacham15-master
Hoa V. DINH 9 years ago
parent
commit
7f6b8051eb
3 changed files with 15 additions and 11 deletions
  1. +3
    -2
      src/data-types/mailstream.c
  2. +9
    -9
      src/data-types/mailstream_low.c
  3. +3
    -0
      src/data-types/mailstream_types.h

+ 3
- 2
src/data-types/mailstream.c View File

@ -282,8 +282,9 @@ mailstream_low * mailstream_get_low(mailstream * s)
static void low_logger(mailstream_low * s, int log_type,
const char * str, size_t size, void * context)
{
if (s->logger != NULL) {
s->logger(context, log_type, str, size, s->logger_context);
mailstream * stream = context;
if (stream->logger != NULL) {
stream->logger(context, log_type, str, size, stream->logger_context);
}
}


+ 9
- 9
src/data-types/mailstream_low.c View File

@ -71,10 +71,9 @@ void (* mailstream_logger_id)(mailstream_low * s, int is_stream_data, int direct
static inline void mailstream_logger_internal(mailstream_low * s, int is_stream_data, int direction,
const char * buffer, size_t size);
// Will log a buffer.
#define STREAM_LOG_ERROR(low, direction, buf, size) \
if (low->logger != NULL) { \
mailstream_logger_internal(low, 2, direction, buf, size); \
} \
mailstream_logger_internal(low, 2, direction, buf, size); \
if (mailstream_debug) { \
if (mailstream_logger_id != NULL) { \
mailstream_logger_id(low, 2, direction, buf, size); \
@ -99,10 +98,9 @@ static inline void mailstream_logger_internal(mailstream_low * s, int is_stream_
} \
}
// Will log a buffer.
#define STREAM_LOG_BUF(low, direction, buf, size) \
if (low->logger != NULL) { \
mailstream_logger_internal(low, 1, direction, buf, size); \
} \
mailstream_logger_internal(low, 1, direction, buf, size); \
if (mailstream_debug) { \
if (mailstream_logger_id != NULL) { \
mailstream_logger_id(low, 1, direction, buf, size); \
@ -127,10 +125,9 @@ static inline void mailstream_logger_internal(mailstream_low * s, int is_stream_
} \
}
// Will log some log text string.
#define STREAM_LOG(low, direction, str) \
if (low->logger != NULL) { \
mailstream_logger_internal(low, 0, direction, buf, strlen(str)); \
} \
mailstream_logger_internal(low, 0, direction, buf, strlen(str)); \
if (mailstream_debug) { \
if (mailstream_logger_id != NULL) { \
mailstream_logger_id(low, 0, direction, str, strlen(str)); \
@ -332,6 +329,9 @@ static inline void mailstream_logger_internal(mailstream_low * s, int is_stream_
{
int log_type = -1;
if (s->logger == NULL)
return;
/*
stream data:
0: log


+ 3
- 0
src/data-types/mailstream_types.h View File

@ -55,14 +55,17 @@ struct _mailstream_low;
typedef struct _mailstream_low mailstream_low;
enum {
// Buffer is a log text string.
MAILSTREAM_LOG_TYPE_INFO_GENERIC,
MAILSTREAM_LOG_TYPE_INFO_RECEIVED,
MAILSTREAM_LOG_TYPE_INFO_SENT,
// Buffer is data sent over the network.
MAILSTREAM_LOG_TYPE_ERROR_GENERIC,
MAILSTREAM_LOG_TYPE_ERROR_RECEIVED,
MAILSTREAM_LOG_TYPE_ERROR_SENT,
// Buffer is data sent over the network.
MAILSTREAM_LOG_TYPE_DATA_RECEIVED,
MAILSTREAM_LOG_TYPE_DATA_SENT,
MAILSTREAM_LOG_TYPE_DATA_SENT_PRIVATE,


Loading…
Cancel
Save