bus-error.c revision de1c301ed165eb4d04a0c9d4babe97912b5233bb
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include "util.h"
#include "sd-bus.h"
#include "bus-error.h"
void sd_bus_error_free(sd_bus_error *e) {
if (!e)
return;
if (e->need_free) {
}
e->need_free = false;
}
char *n, *m = NULL;
int r;
if (!e)
return 0;
if (sd_bus_error_is_set(e))
return -EINVAL;
if (!name)
return -EINVAL;
if (!n)
return -ENOMEM;
if (format) {
if (r < 0) {
free(n);
return -ENOMEM;
}
}
e->name = n;
e->message = m;
e->need_free = true;
return 0;
}
if (!dest)
return 0;
if (sd_bus_error_is_set(dest))
return -EINVAL;
if (!sd_bus_error_is_set(e))
return 0;
if (e->need_free) {
char *x, *y = NULL;
if (!x)
return -ENOMEM;
if (e->message) {
if (!y) {
free(x);
return -ENOMEM;
}
}
} else
*dest = *e;
return 0;
}
if (!e)
return;
if (sd_bus_error_is_set(e))
return;
}
int sd_bus_error_is_set(const sd_bus_error *e) {
if (!e)
return 0;
}
if (!e)
return 0;
}
int bus_error_to_errno(const sd_bus_error* e) {
/* Better replce this with a gperf table */
if (!e->name)
return -EIO;
return -ENOMEM;
return -EPERM;
return -EIO;
}
if (!e)
return error;
else
return error;
}