From 9d6d26154ab2dbc2b72b5d37ff4fb65a916deb4e Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sat, 26 Feb 2011 23:43:46 +0100 Subject: [PATCH] added a convenient c++ wrapper for strerror_r as a bonus, it can be used to insulate us from the GNU vs. XSI strerror_r interface differences --- src/CMakeLists.txt | 2 +- src/c++wrap.cc | 34 ++++++++++++++++++++++++++++++++++ src/c++wrap.hh | 31 +++++++++++++++++++++++++++++++ src/update-cb.hh | 2 +- 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/c++wrap.cc create mode 100644 src/c++wrap.hh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 57b1b891..ef40201f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h) message(FATAL_ERROR "You must remove the autotools generated file '${CMAKE_CURRENT_SOURCE_DIR}/build.h' in order to build with CMake.") endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h) -set(conky_sources colours.cc combine.cc common.cc conky.cc core.cc +set(conky_sources c++wrap.cc colours.cc combine.cc common.cc conky.cc core.cc diskio.cc entropy.cc exec.cc fs.cc mail.cc mixer.cc net_stat.cc template.cc mboxscan.cc read_tcpip.cc scroll.cc specials.cc tailhead.cc temphelper.cc text_object.cc timeinfo.cc top.cc algebra.cc prioqueue.cc proc.cc diff --git a/src/c++wrap.cc b/src/c++wrap.cc new file mode 100644 index 00000000..b412b8f7 --- /dev/null +++ b/src/c++wrap.cc @@ -0,0 +1,34 @@ +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp + * + * Conky, a system monitor, based on torsmo + * + * Please see COPYING for details + * + * Copyright (C) 2010 Pavel Labath et al. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "config.h" + +#include "c++wrap.hh" + +#include + +std::string strerror_r(int errnum) +{ + char buf[100]; + return strerror_r(errnum, buf, sizeof buf); +} diff --git a/src/c++wrap.hh b/src/c++wrap.hh new file mode 100644 index 00000000..499ce1e8 --- /dev/null +++ b/src/c++wrap.hh @@ -0,0 +1,31 @@ +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp + * + * Conky, a system monitor, based on torsmo + * + * Please see COPYING for details + * + * Copyright (C) 2010 Pavel Labath et al. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef CPPWRAP_HH +#define CPPWRAP_HH + +#include + +std::string strerror_r(int errnum); + +#endif /* CPPWRAP_HH */ diff --git a/src/update-cb.hh b/src/update-cb.hh index cb6138bc..83e72554 100644 --- a/src/update-cb.hh +++ b/src/update-cb.hh @@ -213,4 +213,4 @@ namespace conky { }; } -#endif /* LUA_CONFIG_HH */ +#endif /* UPDATE_CB_HH */