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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>LCOV - lcov.info - /usr/include/apt-pkg/error.h</title>
<link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td class="headerItem" width="20%">Current view:</td>
<td class="headerValue" width="80%" colspan=4><a href="../../../index.html">directory</a> - <a href="index.html">usr/include/apt-pkg</a> - error.h</td>
</tr>
<tr>
<td class="headerItem" width="20%">Test:</td>
<td class="headerValue" width="80%" colspan=4>lcov.info</td>
</tr>
<tr>
<td class="headerItem" width="20%">Date:</td>
<td class="headerValue" width="20%">2008-08-14</td>
<td width="20%"></td>
<td class="headerItem" width="20%">Instrumented lines:</td>
<td class="headerValue" width="20%">2</td>
</tr>
<tr>
<td class="headerItem" width="20%">Code covered:</td>
<td class="headerValue" width="20%">50.0 %</td>
<td width="20%"></td>
<td class="headerItem" width="20%">Executed lines:</td>
<td class="headerValue" width="20%">1</td>
</tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td><pre class="source">
<span class="lineNum"> 1 </span> : // -*- mode: cpp; mode: fold -*-
<span class="lineNum"> 2 </span> : // Description /*{{{*/
<span class="lineNum"> 3 </span> : // $Id: error.h,v 1.8 2001/05/07 05:06:52 jgg Exp $
<span class="lineNum"> 4 </span> : /* ######################################################################
<span class="lineNum"> 5 </span> :
<span class="lineNum"> 6 </span> : Global Erorr Class - Global error mechanism
<span class="lineNum"> 7 </span> :
<span class="lineNum"> 8 </span> : This class has a single global instance. When a function needs to
<span class="lineNum"> 9 </span> : generate an error condition, such as a read error, it calls a member
<span class="lineNum"> 10 </span> : in this class to add the error to a stack of errors.
<span class="lineNum"> 11 </span> :
<span class="lineNum"> 12 </span> : By using a stack the problem with a scheme like errno is removed and
<span class="lineNum"> 13 </span> : it allows a very detailed account of what went wrong to be transmitted
<span class="lineNum"> 14 </span> : to the UI for display. (Errno has problems because each function sets
<span class="lineNum"> 15 </span> : errno to 0 if it didn't have an error thus eraseing erno in the process
<span class="lineNum"> 16 </span> : of cleanup)
<span class="lineNum"> 17 </span> :
<span class="lineNum"> 18 </span> : Several predefined error generators are provided to handle common
<span class="lineNum"> 19 </span> : things like errno. The general idea is that all methods return a bool.
<span class="lineNum"> 20 </span> : If the bool is true then things are OK, if it is false then things
<span class="lineNum"> 21 </span> : should start being undone and the stack should unwind under program
<span class="lineNum"> 22 </span> : control.
<span class="lineNum"> 23 </span> :
<span class="lineNum"> 24 </span> : A Warning should not force the return of false. Things did not fail, but
<span class="lineNum"> 25 </span> : they might have had unexpected problems. Errors are stored in a FIFO
<span class="lineNum"> 26 </span> : so Pop will return the first item..
<span class="lineNum"> 27 </span> :
<span class="lineNum"> 28 </span> : I have some thoughts about extending this into a more general UI<->
<span class="lineNum"> 29 </span> : Engine interface, ie allowing the Engine to say 'The disk is full' in
<span class="lineNum"> 30 </span> : a dialog that says 'Panic' and 'Retry'.. The error generator functions
<span class="lineNum"> 31 </span> : like errno, Warning and Error return false always so this is normal:
<span class="lineNum"> 32 </span> : if (open(..))
<span class="lineNum"> 33 </span> : return _error->Errno(..);
<span class="lineNum"> 34 </span> :
<span class="lineNum"> 35 </span> : This source is placed in the Public Domain, do with it what you will
<span class="lineNum"> 36 </span> : It was originally written by Jason Gunthorpe.
<span class="lineNum"> 37 </span> :
<span class="lineNum"> 38 </span> : ##################################################################### */
<span class="lineNum"> 39 </span> : /*}}}*/
<span class="lineNum"> 40 </span> : #ifndef PKGLIB_ERROR_H
<span class="lineNum"> 41 </span> : #define PKGLIB_ERROR_H
<span class="lineNum"> 42 </span> :
<span class="lineNum"> 43 </span> :
<span class="lineNum"> 44 </span> :
<span class="lineNum"> 45 </span> : #ifdef __GNUG__
<span class="lineNum"> 46 </span> : // Methods have a hidden this parameter that is visible to this attribute
<span class="lineNum"> 47 </span> : #define APT_MFORMAT1 __attribute__ ((format (printf, 2, 3)))
<span class="lineNum"> 48 </span> : #define APT_MFORMAT2 __attribute__ ((format (printf, 3, 4)))
<span class="lineNum"> 49 </span> : #else
<span class="lineNum"> 50 </span> : #define APT_MFORMAT1
<span class="lineNum"> 51 </span> : #define APT_MFORMAT2
<span class="lineNum"> 52 </span> : #endif
<span class="lineNum"> 53 </span> :
<span class="lineNum"> 54 </span> : #include <string>
<span class="lineNum"> 55 </span> :
<span class="lineNum"> 56 </span> : using std::string;
<span class="lineNum"> 57 </span> :
<span class="lineNum"> 58 </span> : class GlobalError
<span class="lineNum"> 59 </span> : {
<span class="lineNum"> 60 </span> : struct Item
<span class="lineNum"> 61 </span> : {
<span class="lineNum"> 62 </span> : string Text;
<span class="lineNum"> 63 </span> : bool Error;
<span class="lineNum"> 64 </span> : Item *Next;
<span class="lineNum"> 65 </span> : };
<span class="lineNum"> 66 </span> :
<span class="lineNum"> 67 </span> : Item *List;
<span class="lineNum"> 68 </span> : bool PendingFlag;
<span class="lineNum"> 69 </span> : void Insert(Item *I);
<span class="lineNum"> 70 </span> :
<span class="lineNum"> 71 </span> : public:
<span class="lineNum"> 72 </span> :
<span class="lineNum"> 73 </span> : // Call to generate an error from a library call.
<span class="lineNum"> 74 </span> : bool Errno(const char *Function,const char *Description,...) APT_MFORMAT2;
<span class="lineNum"> 75 </span> : bool WarningE(const char *Function,const char *Description,...) APT_MFORMAT2;
<span class="lineNum"> 76 </span> :
<span class="lineNum"> 77 </span> : /* A warning should be considered less severe than an error, and may be
<span class="lineNum"> 78 </span> : ignored by the client. */
<span class="lineNum"> 79 </span> : bool Error(const char *Description,...) APT_MFORMAT1;
<span class="lineNum"> 80 </span> : bool Warning(const char *Description,...) APT_MFORMAT1;
<span class="lineNum"> 81 </span> :
<span class="lineNum"> 82 </span> : // Simple accessors
<span class="lineNum"> 83 </span><span class="lineCov"> 3 : inline bool PendingError() {return PendingFlag;};</span>
<span class="lineNum"> 84 </span><span class="lineNoCov"> 0 : inline bool empty() {return List == 0;};</span>
<span class="lineNum"> 85 </span> : bool PopMessage(string &Text);
<span class="lineNum"> 86 </span> : void Discard();
<span class="lineNum"> 87 </span> :
<span class="lineNum"> 88 </span> : // Usefull routine to dump to cerr
<span class="lineNum"> 89 </span> : void DumpErrors();
<span class="lineNum"> 90 </span> :
<span class="lineNum"> 91 </span> : GlobalError();
<span class="lineNum"> 92 </span> : };
<span class="lineNum"> 93 </span> :
<span class="lineNum"> 94 </span> : // The 'extra-ansi' syntax is used to help with collisions.
<span class="lineNum"> 95 </span> : GlobalError *_GetErrorObj();
<span class="lineNum"> 96 </span> : #define _error _GetErrorObj()
<span class="lineNum"> 97 </span> :
<span class="lineNum"> 98 </span> : #undef APT_MFORMAT1
<span class="lineNum"> 99 </span> : #undef APT_MFORMAT2
<span class="lineNum"> 100 </span> :
<span class="lineNum"> 101 </span> : #endif
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
</table>
<br>
</body>
</html>
|