Esempio n. 1
0
bool ebml_write_header(struct ebml_writer *writer, const_bstring format_name)
{
    if (!ebml_start_tag(writer, EBML_HEADER_TAG))
        return false;

    bstring name_buf = bfromcstralloc(128, "");
    if (!name_buf)
        return false;

    bool ok = true;
    if (binsertch(name_buf, 0, 32, '\0') != BSTR_OK) {
        fprintf(stderr, "bpattern()\n");
        ok = false;
        goto out;
    }
    if (bsetstr(name_buf, 0, format_name, '\0') != BSTR_OK) {
        fprintf(stderr, "bsetstr()\n");
        ok = false;
        goto out;
    }

    if (!fwrite(name_buf->data, name_buf->slen + 1, 1, writer->f)) {
        perror("fwrite");
        ok = false;
        goto out;
    }

    ebml_end_tag(writer);

out:
    bdestroy(name_buf);
    return ok;
}
Esempio n. 2
0
File: bstraux.c Progetto: adsr/a
/*  int bFill (bstring a, char c, int len)
 *
 *  Fill a given bstring with the character in parameter c, for a length n.
 */
int bFill (bstring b, char c, int len) {
	if (b == NULL || len < 0 || (b->mlen < b->slen && b->mlen > 0)) return -__LINE__;
	b->slen = 0;
	return bsetstr (b, len, NULL, c);
}