Lines 182-189
Link Here
|
182 |
* the getattr type functions. |
182 |
* the getattr type functions. |
183 |
*/ |
183 |
*/ |
184 |
|
184 |
|
185 |
#define fetchattr_soft_d(st, attr, defa) \ |
185 |
// <spaghetti_code> (sorry ...) |
186 |
fetchattr_soft(st, attr) else st->attr = defa |
186 |
|
|
|
187 |
#define good(attr) _GOOD_SPAGHETTI_ ## attr |
188 |
#define bad(attr) _BAD_SPAGHETTI_ ## attr |
189 |
|
190 |
/* |
191 |
* This macro checks whether an attribute is available and not None. |
192 |
* Success --> set attribute and goto _GOOD_SPAGHETTI |
193 |
* Failure --> goto _BAD_SPAGHETTI |
194 |
* Error --> goto OUT_DECREF |
195 |
*/ |
196 |
#define fetchattr_soft_none_pre(st, attr) \ |
197 |
if (PyObject_HasAttrString(v, #attr)) { \ |
198 |
if (!(pytmp = PyObject_GetAttrString(v, #attr))) \ |
199 |
goto OUT_DECREF; \ |
200 |
else if (pytmp != Py_None) { \ |
201 |
py2attr(st, attr) \ |
202 |
goto good(attr); \ |
203 |
} \ |
204 |
else { \ |
205 |
Py_DECREF(pytmp); \ |
206 |
goto bad(attr); \ |
207 |
} \ |
208 |
} \ |
209 |
goto bad(attr); |
210 |
|
211 |
/** |
212 |
* Calls fetchattr_soft_none_pre and ignores failure. |
213 |
*/ |
214 |
#define fetchattr_soft_none(st, attr) \ |
215 |
fetchattr_soft_none_pre(st, attr); \ |
216 |
good(attr): ; \ |
217 |
bad(attr): ; |
218 |
|
219 |
/** |
220 |
* Calls fetchattr_soft_none_pre and sets a default value on failure. |
221 |
*/ |
222 |
#define fetchattr_soft_d(st, attr, defa) \ |
223 |
fetchattr_soft_none_pre(st, attr); \ |
224 |
bad(attr): \ |
225 |
st->attr = defa; \ |
226 |
good(attr): ; |
227 |
|
228 |
// </spaghetti_code> |
187 |
|
229 |
|
188 |
#define FETCH_STAT_DATA() \ |
230 |
#define FETCH_STAT_DATA() \ |
189 |
fetchattr(st, st_mode); \ |
231 |
fetchattr(st, st_mode); \ |
Lines 206-212
Link Here
|
206 |
* autotools so we just dare to throw these in as is. \ |
248 |
* autotools so we just dare to throw these in as is. \ |
207 |
*/ \ |
249 |
*/ \ |
208 |
\ |
250 |
\ |
209 |
fetchattr_soft(st, st_rdev); \ |
251 |
fetchattr_soft_none(st, st_rdev); \ |
210 |
fetchattr_soft_d(st, st_blksize, 4096); \ |
252 |
fetchattr_soft_d(st, st_blksize, 4096); \ |
211 |
fetchattr_soft_d(st, st_blocks, (st->st_size + 511)/512) |
253 |
fetchattr_soft_d(st, st_blocks, (st->st_size + 511)/512) |
212 |
|
254 |
|
Lines 245-250
Link Here
|
245 |
#endif |
287 |
#endif |
246 |
|
288 |
|
247 |
#undef fetchattr_soft_d |
289 |
#undef fetchattr_soft_d |
|
|
290 |
#undef fetchattr_soft_none |
291 |
#undef fetchattr_soft_none_pre |
292 |
#undef good |
293 |
#undef bad |
248 |
#undef FETCH_STAT_DATA |
294 |
#undef FETCH_STAT_DATA |
249 |
|
295 |
|
250 |
static int |
296 |
static int |