コード例 #1
0
ファイル: virdnsmasq.c プロジェクト: Archer-sys/libvirt
static dnsmasqAddnHostsfile *
addnhostsNew(const char *name,
             const char *config_dir)
{
    dnsmasqAddnHostsfile *addnhostsfile;
    virBuffer buf = VIR_BUFFER_INITIALIZER;

    if (VIR_ALLOC(addnhostsfile) < 0)
        return NULL;

    addnhostsfile->hosts = NULL;
    addnhostsfile->nhosts = 0;

    virBufferAsprintf(&buf, "%s", config_dir);
    virBufferEscapeString(&buf, "/%s", name);
    virBufferAsprintf(&buf, ".%s", DNSMASQ_ADDNHOSTSFILE_SUFFIX);

    if (virBufferCheckError(&buf) < 0)
                goto error;

    if (!(addnhostsfile->path = virBufferContentAndReset(&buf)))
        goto error;

    return addnhostsfile;

 error:
    virBufferFreeAndReset(&buf);
    addnhostsFree(addnhostsfile);
    return NULL;
}
コード例 #2
0
ファイル: dnsmasq.c プロジェクト: xushiwei/libvirt
static dnsmasqAddnHostsfile *
addnhostsNew(const char *name,
             const char *config_dir)
{
    dnsmasqAddnHostsfile *addnhostsfile;

    if (VIR_ALLOC(addnhostsfile) < 0) {
        virReportOOMError();
        return NULL;
    }

    addnhostsfile->hosts = NULL;
    addnhostsfile->nhosts = 0;

    if (virAsprintf(&addnhostsfile->path, "%s/%s.%s", config_dir, name,
                    DNSMASQ_ADDNHOSTSFILE_SUFFIX) < 0) {
        virReportOOMError();
        goto error;
    }

    return addnhostsfile;

 error:
    addnhostsFree(addnhostsfile);
    return NULL;
}
コード例 #3
0
ファイル: virdnsmasq.c プロジェクト: Archer-sys/libvirt
/**
 * dnsmasqContextFree:
 * @ctx: pointer to the dnsmasq context
 *
 * Free the resources associated with a dnsmasq context
 */
void
dnsmasqContextFree(dnsmasqContext *ctx)
{
    if (!ctx)
        return;

    VIR_FREE(ctx->config_dir);

    if (ctx->hostsfile)
        hostsfileFree(ctx->hostsfile);
    if (ctx->addnhostsfile)
        addnhostsFree(ctx->addnhostsfile);

    VIR_FREE(ctx);
}