Lines Matching refs:e

195 bool bus_error_is_dirty(sd_bus_error *e) {  in bus_error_is_dirty()  argument
196 if (!e) in bus_error_is_dirty()
199 return e->name || e->message || e->_need_free != 0; in bus_error_is_dirty()
202 _public_ void sd_bus_error_free(sd_bus_error *e) { in sd_bus_error_free() argument
203 if (!e) in sd_bus_error_free()
206 if (e->_need_free > 0) { in sd_bus_error_free()
207 free((void*) e->name); in sd_bus_error_free()
208 free((void*) e->message); in sd_bus_error_free()
211 *e = SD_BUS_ERROR_NULL; in sd_bus_error_free()
214 _public_ int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message) { in sd_bus_error_set() argument
220 if (e) { in sd_bus_error_set()
221 assert_return(!bus_error_is_dirty(e), -EINVAL); in sd_bus_error_set()
223 e->name = strdup(name); in sd_bus_error_set()
224 if (!e->name) { in sd_bus_error_set()
225 *e = BUS_ERROR_OOM; in sd_bus_error_set()
230 e->message = strdup(message); in sd_bus_error_set()
232 e->_need_free = 1; in sd_bus_error_set()
240 int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) { in bus_error_setfv() argument
246 if (e) { in bus_error_setfv()
247 assert_return(!bus_error_is_dirty(e), -EINVAL); in bus_error_setfv()
249 e->name = strdup(name); in bus_error_setfv()
250 if (!e->name) { in bus_error_setfv()
251 *e = BUS_ERROR_OOM; in bus_error_setfv()
262 e->message = TAKE_PTR(mesg); in bus_error_setfv()
265 e->_need_free = 1; in bus_error_setfv()
273 _public_ int sd_bus_error_setf(sd_bus_error *e, const char *name, const char *format, ...) { in sd_bus_error_setf() argument
280 r = bus_error_setfv(e, name, format, ap); in sd_bus_error_setf()
287 r = sd_bus_error_set(e, name, NULL); in sd_bus_error_setf()
292 _public_ int sd_bus_error_copy(sd_bus_error *dest, const sd_bus_error *e) { in sd_bus_error_copy() argument
294 if (!sd_bus_error_is_set(e)) in sd_bus_error_copy()
307 if (e->_need_free == 0) in sd_bus_error_copy()
308 *dest = *e; in sd_bus_error_copy()
310 dest->name = strdup(e->name); in sd_bus_error_copy()
316 if (e->message) in sd_bus_error_copy()
317 dest->message = strdup(e->message); in sd_bus_error_copy()
323 return -bus_error_name_to_errno(e->name); in sd_bus_error_copy()
326 _public_ int sd_bus_error_move(sd_bus_error *dest, sd_bus_error *e) { in sd_bus_error_move() argument
329 if (!sd_bus_error_is_set(e)) { in sd_bus_error_move()
337 r = -bus_error_name_to_errno(e->name); in sd_bus_error_move()
340 *dest = *e; in sd_bus_error_move()
341 *e = SD_BUS_ERROR_NULL; in sd_bus_error_move()
343 sd_bus_error_free(e); in sd_bus_error_move()
348 _public_ int sd_bus_error_set_const(sd_bus_error *e, const char *name, const char *message) { in sd_bus_error_set_const() argument
351 if (!e) in sd_bus_error_set_const()
354 assert_return(!bus_error_is_dirty(e), -EINVAL); in sd_bus_error_set_const()
356 *e = SD_BUS_ERROR_MAKE_CONST(name, message); in sd_bus_error_set_const()
362 _public_ int sd_bus_error_is_set(const sd_bus_error *e) { in sd_bus_error_is_set() argument
363 if (!e) in sd_bus_error_is_set()
366 return !!e->name; in sd_bus_error_is_set()
369 _public_ int sd_bus_error_has_name(const sd_bus_error *e, const char *name) { in sd_bus_error_has_name() argument
370 if (!e) in sd_bus_error_has_name()
373 return streq_ptr(e->name, name); in sd_bus_error_has_name()
376 _public_ int sd_bus_error_has_names_sentinel(const sd_bus_error *e, ...) { in sd_bus_error_has_names_sentinel() argument
377 if (!e || !e->name) in sd_bus_error_has_names_sentinel()
383 va_start(ap, e); in sd_bus_error_has_names_sentinel()
385 if (streq(p, e->name)) in sd_bus_error_has_names_sentinel()
391 _public_ int sd_bus_error_get_errno(const sd_bus_error* e) { in sd_bus_error_get_errno() argument
392 if (!e || !e->name) in sd_bus_error_get_errno()
395 return bus_error_name_to_errno(e->name); in sd_bus_error_get_errno()
398 static void bus_error_strerror(sd_bus_error *e, int error) { in bus_error_strerror() argument
402 assert(e); in bus_error_strerror()
425 if (e->_need_free > 0) { in bus_error_strerror()
427 free((char*) e->message); in bus_error_strerror()
428 e->message = x; in bus_error_strerror()
434 t = strdup(e->name); in bus_error_strerror()
440 e->_need_free = 1; in bus_error_strerror()
441 e->name = t; in bus_error_strerror()
442 e->message = x; in bus_error_strerror()
447 if (e->_need_free > 0) { in bus_error_strerror()
455 free((char*) e->message); in bus_error_strerror()
456 e->message = t; in bus_error_strerror()
459 e->message = x; in bus_error_strerror()
467 _public_ int sd_bus_error_set_errno(sd_bus_error *e, int error) { in sd_bus_error_set_errno() argument
472 if (!e) in sd_bus_error_set_errno()
477 assert_return(!bus_error_is_dirty(e), -EINVAL); in sd_bus_error_set_errno()
480 *e = errno_to_bus_error_const(error); in sd_bus_error_set_errno()
482 if (!sd_bus_error_is_set(e)) { in sd_bus_error_set_errno()
487 k = errno_to_bus_error_name_new(error, (char**) &e->name); in sd_bus_error_set_errno()
489 e->_need_free = 1; in sd_bus_error_set_errno()
491 *e = BUS_ERROR_OOM; in sd_bus_error_set_errno()
494 *e = BUS_ERROR_FAILED; in sd_bus_error_set_errno()
498 bus_error_strerror(e, error); in sd_bus_error_set_errno()
502 _public_ int sd_bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_list ap) { in sd_bus_error_set_errnofv() argument
508 if (!e) in sd_bus_error_set_errnofv()
513 assert_return(!bus_error_is_dirty(e), -EINVAL); in sd_bus_error_set_errnofv()
516 *e = errno_to_bus_error_const(error); in sd_bus_error_set_errnofv()
518 if (!sd_bus_error_is_set(e)) { in sd_bus_error_set_errnofv()
523 k = errno_to_bus_error_name_new(error, (char**) &e->name); in sd_bus_error_set_errnofv()
525 e->_need_free = 1; in sd_bus_error_set_errnofv()
527 *e = BUS_ERROR_OOM; in sd_bus_error_set_errnofv()
530 *e = BUS_ERROR_FAILED; in sd_bus_error_set_errnofv()
542 if (e->_need_free <= 0) { in sd_bus_error_set_errnofv()
545 t = strdup(e->name); in sd_bus_error_set_errnofv()
549 e->_need_free = 1; in sd_bus_error_set_errnofv()
550 e->name = t; in sd_bus_error_set_errnofv()
553 e->message = TAKE_PTR(m); in sd_bus_error_set_errnofv()
559 bus_error_strerror(e, error); in sd_bus_error_set_errnofv()
563 _public_ int sd_bus_error_set_errnof(sd_bus_error *e, int error, const char *format, ...) { in sd_bus_error_set_errnof() argument
569 if (!e) in sd_bus_error_set_errnof()
574 assert_return(!bus_error_is_dirty(e), -EINVAL); in sd_bus_error_set_errnof()
580 r = sd_bus_error_set_errnofv(e, error, format, ap); in sd_bus_error_set_errnof()
586 return sd_bus_error_set_errno(e, error); in sd_bus_error_set_errnof()
589 const char *bus_error_message(const sd_bus_error *e, int error) { in bus_error_message() argument
591 if (e) { in bus_error_message()
594 if (sd_bus_error_has_name(e, SD_BUS_ERROR_ACCESS_DENIED)) in bus_error_message()
597 if (e->message) in bus_error_message()
598 return e->message; in bus_error_message()