예제 #1
0
void
cf_dyn_buf_append_bool(cf_dyn_buf *db, bool b)
{
	if (b) {
		DB_RESERVE(4);
		memcpy(&db->buf[db->used_sz], "true", 4);
		db->used_sz += 4;
	}
	else {
		DB_RESERVE(5);
		memcpy(&db->buf[db->used_sz], "false", 5);
		db->used_sz += 5;
	}
}
예제 #2
0
int
cf_dyn_buf_append_uint32 (cf_dyn_buf *db, uint32_t i)
{
	DB_RESERVE(12);
	db->used_sz += cf_str_itoa_u32(i, (char *) &db->buf[db->used_sz], 10);
	return( 0 );
}
예제 #3
0
int
cf_dyn_buf_append_uint64_x (cf_dyn_buf *db, uint64_t i)
{
	DB_RESERVE(18);
	db->used_sz += cf_str_itoa_u64(i, (char *) &db->buf[db->used_sz], 16);
	return( 0 );
}
예제 #4
0
void
cf_dyn_buf_append_char(cf_dyn_buf *db, char c)
{
	DB_RESERVE(1);
	db->buf[db->used_sz] = (uint8_t)c;
	db->used_sz++;
}
예제 #5
0
void
cf_dyn_buf_append_buf(cf_dyn_buf *db, uint8_t *buf, size_t sz)
{
	DB_RESERVE(sz);
	memcpy(&db->buf[db->used_sz], buf, sz);
	db->used_sz += sz;
}
예제 #6
0
int
cf_dyn_buf_append_int (cf_dyn_buf *db, int i)
{
	// overreserving isn't a crime
	DB_RESERVE(12);
	db->used_sz += cf_str_itoa(i, (char *) &db->buf[db->used_sz], 10);
	return( 0 );
}
예제 #7
0
int
cf_dyn_buf_append_string(cf_dyn_buf *db, const char *s)
{
	size_t	len = strlen(s);
	DB_RESERVE(len);
	memcpy(&db->buf[db->used_sz], s, len);
	db->used_sz += len;
	return ( 0 );
}
예제 #8
0
int
cf_dyn_buf_reserve(cf_dyn_buf *db, size_t sz, uint8_t **from)
{
	DB_RESERVE(sz);
	if (from) {
		*from = &db->buf[db->used_sz];
	}
	db->used_sz += sz;
	return 0;
}
예제 #9
0
void
cf_dyn_buf_append_format_va(cf_dyn_buf *db, const char *form, va_list va)
{
	DB_RESERVE(MAX_FORMAT + 1);
	int32_t len = vsnprintf((char *)&db->buf[db->used_sz], MAX_FORMAT + 1, form,
			va);

	if (len > MAX_FORMAT) {
		len = MAX_FORMAT;
	}

	db->used_sz += len;
}
예제 #10
0
void
cf_dyn_buf_append_uint64(cf_dyn_buf *db, uint64_t i)
{
	DB_RESERVE(22);
	db->used_sz += cf_str_itoa_u64(i, (char *)&db->buf[db->used_sz], 10);
}
예제 #11
0
void
cf_dyn_buf_append_int(cf_dyn_buf *db, int i)
{
	DB_RESERVE(12);
	db->used_sz += cf_str_itoa(i, (char *)&db->buf[db->used_sz], 10);
}