Exemple #1
0
putv(struct ocx *ocx, enum ocx_chan chan, const char *fmt, va_list ap)
{
	FILE *dst = getdst(chan);
	va_list ap2;

	va_copy(ap2, ap);
	AZ(ocx);
	if (dst != NULL)
		(void)vfprintf(dst, fmt, ap);
	if (chan == OCX_DIAG)
		vsyslog(LOG_ERR, fmt, ap2);
	va_end(ap2);
}
Exemple #2
0
static inline int write_chunk(ratt_table_t *table, void const *src,
                              int (*getdst)(ratt_table_t *, void **))
{
	void *dst = NULL, *curr = NULL;
	int retval;

	if (!getdst) {
		debug("getdst is NULL, using get_tail_next");
		getdst = ratt_table_get_tail_next;
	}

	retval = ratt_table_satisfy_constrains(table, src);
	if (retval != OK && !table->on_constrains) {
		debug("ratt_table_satisfy_constrains() failed");
		return FAIL;
	} else if (retval != OK) {
		curr = ratt_table_current(table);
		if (!curr) {
			debug("ratt_table_current() failed");
			return FAIL;
		}
		retval = table->on_constrains(curr, src);
		if (retval != OK) {
			debug("table->on_constrains() failed");
			return FAIL;
		}
		debug("constrains have been resolved");
		return OK;
	}

	retval = getdst(table, &dst);
	if (retval != OK) {
		debug("getdst() failed");
		return FAIL;
	}

	memcpy(dst, src, table->chunk_size);

	debug("chunk at %p written to %p, slot %u", src, dst,
	    ratt_table_pos_current(table));
	return OK;
}