src/pEpEngine.c
branchENGINE-199
changeset 1722 1d16b6822287
parent 1670 8e2509f0ddad
child 1730 f8f1a806a051
     1.1 --- a/src/pEpEngine.c	Wed Apr 19 13:42:06 2017 +0200
     1.2 +++ b/src/pEpEngine.c	Wed Apr 19 17:44:19 2017 +0200
     1.3 @@ -234,6 +234,10 @@
     1.4  
     1.5      _session->version = PEP_ENGINE_VERSION;
     1.6  
     1.7 +#ifdef DEBUG_ERRORSTACK
     1.8 +    _session->errorstack = new_stringlist(NULL);
     1.9 +#endif
    1.10 +
    1.11      assert(LOCAL_DB);
    1.12      if (LOCAL_DB == NULL) {
    1.13          status = PEP_INIT_CANNOT_OPEN_DB;
    1.14 @@ -749,6 +753,9 @@
    1.15          release_transport_system(session, out_last);
    1.16          release_cryptotech(session, out_last);
    1.17  
    1.18 +#ifdef DEBUG_ERRORSTACK
    1.19 +        free_stringlist(session->errorstack);
    1.20 +#endif
    1.21          free(session);
    1.22      }
    1.23  }
    1.24 @@ -2272,3 +2279,39 @@
    1.25  
    1.26      return PEP_STATUS_OK;
    1.27  }
    1.28 +
    1.29 +#ifdef DEBUG_ERRORSTACK
    1.30 +PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status)
    1.31 +{
    1.32 +    char logline[48];
    1.33 +    if(status>0)
    1.34 +    {
    1.35 +        snprintf(logline,47, "%24s:%u status=%u (0x%x)", file, line, status, status);
    1.36 +    }else{
    1.37 +        snprintf(logline,47, "%24s:%u status=%i.", file, line, status);
    1.38 +    }
    1.39 +    stringlist_add(session->errorstack, logline); // logline is copied! :-)
    1.40 +    return status;
    1.41 +}
    1.42 +
    1.43 +DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session)
    1.44 +{
    1.45 +    return session->errorstack;
    1.46 +}
    1.47 +
    1.48 +#else
    1.49 +
    1.50 +static stringlist_t* dummy_errorstack = NULL;
    1.51 +
    1.52 +DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session)
    1.53 +{
    1.54 +	if(dummy_errorstack == NULL)
    1.55 +	{
    1.56 +		dummy_errorstack = new_stringlist("( Please recompile pEpEngine with -DDEBUG_ERRORSTACK )");
    1.57 +	}
    1.58 +	
    1.59 +    return dummy_errorstack;
    1.60 +}
    1.61 +
    1.62 +#endif
    1.63 +