add stringlist_t errorstack to session and functions to deal with it, when -DDEBUG_ERRORSTACK

doc_update_sequoia
Roker 6 years ago
parent 497b72c132
commit de260127c3

@ -234,6 +234,10 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
_session->version = PEP_ENGINE_VERSION;
#ifdef DEBUG_ERRORSTACK
_session->errorstack = new_stringlist(NULL);
#endif
assert(LOCAL_DB);
if (LOCAL_DB == NULL) {
status = PEP_INIT_CANNOT_OPEN_DB;
@ -749,6 +753,9 @@ DYNAMIC_API void release(PEP_SESSION session)
release_transport_system(session, out_last);
release_cryptotech(session, out_last);
#ifdef DEBUG_ERRORSTACK
free_stringlist(session->errorstack);
#endif
free(session);
}
}
@ -2272,3 +2279,39 @@ DYNAMIC_API PEP_STATUS reset_peptest_hack(PEP_SESSION session)
return PEP_STATUS_OK;
}
#ifdef DEBUG_ERRORSTACK
PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status)
{
char logline[48];
if(status>0)
{
snprintf(logline,47, "%24s:%u status=%u (0x%x)", file, line, status, status);
}else{
snprintf(logline,47, "%24s:%u status=%i.", file, line, status);
}
stringlist_add(session->errorstack, logline); // logline is copied! :-)
return status;
}
DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session)
{
return session->errorstack;
}
#else
static stringlist_t* dummy_errorstack = NULL;
DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session)
{
if(dummy_errorstack == NULL)
{
dummy_errorstack = new_stringlist("( Please recompile pEpEngine with -DDEBUG_ERRORSTACK )");
}
return dummy_errorstack;
}
#endif

@ -147,6 +147,17 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session);
DYNAMIC_API void release(PEP_SESSION session);
// const stringlist_t* get_errorstack(PEP_SESSION) - get the error stack for that session, if any
//
// parameters:
// session (in) session handle
//
// caveat:
// To get a useful error stack you have to compile with -DDEBUG_ERRORSTACK
// The error stack belongs to the session. Do no not change it!
DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session);
// config_passive_mode() - enable passive mode
//
// parameters:

@ -162,8 +162,12 @@ struct _pEpSession {
bool use_only_own_private_keys;
bool keep_sync_msg;
#ifdef DEBUG_ERRORSTACK
stringlist_t* errorstack;
#endif
};
PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first);
void release_transport_system(PEP_SESSION session, bool out_last);
@ -229,3 +233,11 @@ static inline int _same_fpr(
return ai == fpras && bi == fprbs;
}
#ifdef DEBUG_ERRORSTACK
PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);
#define ERROR(status) session_add_error(session, __FILE__, __LINE__, (status))
#else
#define ERROR(status) (status)
#endif

Loading…
Cancel
Save