Esempio n. 1
0
/**
 *	Set specified bin's value to an NULL terminated string.
 *	as_record_set_str(rec, "bin", "abc");
 *	@param rec 	- the record containing the bin
 *	@param name 	- the name of the bin
 *	@param value - the value of the bin
 *	@return true on success, false on failure.
 */
bool as_record_set_strp(as_record * rec, const as_bin_name name, const char * value, bool free) 
{
	as_bin * bin = as_record_bin_forupdate(rec, name);
	if ( !bin ) return false;
	as_bin_init_str(bin, name, value, free);
	return true;
}
/**
 *	Add a AS_OPERATOR_APPEND bin operation with a NULL-terminated string value.
 *
 *	@param ops			The `as_operations` to append the operation to.
 *	@param name 		The name of the bin to perform the operation on.
 *	@param value 		The value to be used in the operation.
 *	@param free			If true, then the value will be freed when the operations is destroyed.
 *
 *	@return true on success. Otherwise an error occurred.
 */
bool as_operations_add_append_strp(as_operations * ops, const as_bin_name name, const char * value, bool free)
{
	as_binop * binop = as_binop_forappend(ops, AS_OPERATOR_APPEND, name);
	if ( !binop ) return false;
	as_bin_init_str(&binop->bin, name, value, free);
	return true;
}