~ubuntu-branches/ubuntu/trusty/cclive/trusty-proposed

« back to all changes in this revision

Viewing changes to cclive/src/error.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alejandro Garrido Mota
  • Date: 2011-03-07 14:37:59 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110307143759-abieei4gsctde1zo
Tags: 0.7.3.1-1
* New upstream release (Closes: #608393, #588795) 
* Remove patch: The changes was included by upstream author.
* Remove two white lines in d/rules 
* d/copyright: Update Copyright years to 2009,2011 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
* Copyright (C) 2010 Toni Gundogdu.
3
 
*
4
 
* This program is free software: you can redistribute it and/or modify
5
 
* it under the terms of the GNU General Public License as published by
6
 
* the Free Software Foundation, either version 3 of the License, or
7
 
* (at your option) any later version.
8
 
*
9
 
* This program is distributed in the hope that it will be useful,
10
 
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
* GNU General Public License for more details.
13
 
*
14
 
* You should have received a copy of the GNU General Public License
15
 
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
*/
17
 
 
18
 
#include "config.h"
19
 
 
20
 
#include <cerrno>
21
 
#include <climits>
22
 
#include <cstring>
23
 
#include <iostream>
24
 
 
25
 
#include "cclive/error.h"
26
 
 
27
 
namespace cclive {
28
 
 
29
 
std::string
30
 
perror (const std::string& p/*=""*/) {
31
 
 
32
 
#if defined (HAVE_STRERROR) || defined (HAVE_STRERROR_R)
33
 
    std::string s;
34
 
 #ifdef HAVE_STRERROR_R
35
 
    char buf[256];
36
 
    s = strerror_r (errno, buf, sizeof(buf));
37
 
 #else
38
 
    s = strerror (errno);
39
 
 #endif
40
 
    return s;
41
 
#else // No strerror or strerror_r.
42
 
    perror (p.c_str ());
43
 
#endif
44
 
 
45
 
}
46
 
 
47
 
} // End namespace.
48
 
 
49