ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1015 B

  1. #define CPPCMS_SOURCE
  2. #include "cppcms_error.h"
  3. #include "config.h"
  4. #include <iostream>
  5. #include <string.h>
  6. #ifndef HAVE_STRERROR_R
  7. #ifdef CPPCMS_USE_EXTERNAL_BOOST
  8. # include <boost/system/error_code.hpp>
  9. #else // Internal Boost
  10. # include <cppcms_boost/system/error_code.hpp>
  11. namespace boost = cppcms_boost;
  12. #endif
  13. #endif
  14. using namespace std;
  15. namespace cppcms {
  16. cppcms_error::cppcms_error(int err,std::string const &error) :
  17. std::runtime_error(error+":" + strerror(err))
  18. {
  19. }
  20. // Unfortunatly I can't use XSI-compliant strerror_r() under g++
  21. // it always gives GNU strerror_r, thus it is wrapped
  22. namespace {
  23. string strerror_wrapper(int value,char *buf)
  24. {
  25. return buf;
  26. }
  27. string strerror_wrapper(char const *err,char *buf)
  28. {
  29. return err;
  30. }
  31. }
  32. std::string cppcms_error::strerror(int err)
  33. {
  34. #ifdef HAVE_STRERROR_R
  35. char buf[256] = {0};
  36. return strerror_wrapper(strerror_r(err,buf,sizeof(buf)),buf);
  37. #else
  38. return boost::system::error_code(err,boost::system::errno_ecat).message();
  39. #endif
  40. }
  41. }