resolved-dns-search-domain.c revision a51c10485af349eb15faa4d1a63b9818bcf3e589
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2015 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 "alloc-util.h"
#include "dns-domain.h"
#include "resolved-dns-search-domain.h"
Manager *m,
Link *l,
const char *name) {
DnsSearchDomain *d, *tail;
int r;
assert(m);
if (r < 0)
return r;
r = dns_name_root(normalized);
if (r < 0)
return r;
if (r > 0)
return -EINVAL;
if (!d)
return -ENOMEM;
d->n_ref = 1;
d->manager = m;
d->name = normalized;
normalized = NULL;
switch (type) {
case DNS_SEARCH_DOMAIN_LINK:
d->link = l;
break;
case DNS_SERVER_SYSTEM:
break;
default:
assert_not_reached("Unknown search domain type");
}
d->linked = true;
if (ret)
*ret = d;
return 0;
}
if (!d)
return NULL;
d->n_ref++;
return d;
}
if (!d)
return NULL;
d->n_ref--;
if (d->n_ref > 0)
return NULL;
free(d);
return NULL;
}
void dns_search_domain_unlink(DnsSearchDomain *d) {
assert(d);
if (!d->linked)
return;
switch (d->type) {
case DNS_SEARCH_DOMAIN_LINK:
break;
case DNS_SEARCH_DOMAIN_SYSTEM:
break;
}
d->linked = false;
}
assert(d);
if (!d->marked)
return;
d->marked = false;
if (!d->linked || !d->domains_next)
return;
switch (d->type) {
case DNS_SEARCH_DOMAIN_LINK:
break;
case DNS_SEARCH_DOMAIN_SYSTEM:
break;
default:
assert_not_reached("Unknown search domain type");
}
}
if (!first)
return;
}
if (!first)
return;
}
if (!first)
return;
}
DnsSearchDomain *d;
int r;
if (r < 0)
return r;
if (r > 0) {
*ret = d;
return 1;
}
}
return 0;
}