/usr/include/binpac_exception.h is in binpac 0.48-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #ifndef binpac_exception_h
#define binpac_exception_h
namespace binpac {
class Exception
{
public:
Exception(const char* m = 0)
: msg_("binpac exception: ")
{
if ( m )
append(m);
// abort();
}
void append(string m) { msg_ += m; }
string msg() const { return msg_; }
const char* c_msg() const { return msg_.c_str(); }
protected:
string msg_;
};
class ExceptionOutOfBound : public Exception
{
public:
ExceptionOutOfBound(const char* where, int len_needed, int len_given)
{
append(binpac_fmt("out_of_bound: %s: %d > %d",
where, len_needed, len_given));
}
};
class ExceptionInvalidCase : public Exception
{
public:
ExceptionInvalidCase(const char* location,
int index,
const char *expected)
: location_(location),
index_(index),
expected_(expected)
{
append(binpac_fmt("invalid case: %s: %d (%s)",
location, index, expected));
}
protected:
const char* location_;
int index_;
string expected_;
};
class ExceptionInvalidCaseIndex : public Exception
{
public:
ExceptionInvalidCaseIndex(const char* location,
int index)
: location_(location),
index_(index)
{
append(binpac_fmt("invalid index for case: %s: %d",
location, index));
}
protected:
const char* location_;
int index_;
};
class ExceptionInvalidOffset : public Exception
{
public:
ExceptionInvalidOffset(const char* location,
int min_offset, int offset)
: location_(location),
min_offset_(min_offset), offset_(offset)
{
append(binpac_fmt("invalid offset: %s: min_offset = %d, offset = %d",
location, min_offset, offset));
}
protected:
const char* location_;
int min_offset_, offset_;
};
class ExceptionStringMismatch : public Exception
{
public:
ExceptionStringMismatch(const char* location,
const char *expected, const char *actual_data)
{
append(binpac_fmt("string mismatch at %s: \nexpected pattern: \"%s\"\nactual data: \"%s\"",
location, expected, actual_data));
}
};
class ExceptionInvalidStringLength : public Exception
{
public:
ExceptionInvalidStringLength(const char* location, int len)
{
append(binpac_fmt("invalid length string: %s: %d",
location, len));
}
};
}
#endif // binpac_exception_h
|