/** * Set specified bin's value to raw bytes of given length. * uint8_t bytes[3] = {1,2,3} * as_record_set_raw(rec, "bin", bytes, 3); * @param rec - the record containing the bin * @param name - the name of the bin * @param value - the value of the bin * @param size - the size of the value * @return true on success, false on failure. */ bool as_record_set_rawp(as_record * rec, const as_bin_name name, const uint8_t * value, uint32_t size, bool free) { as_bin * bin = as_record_bin_forupdate(rec, name); if ( !bin ) return false; as_bin_init_raw(bin, name, value, size, free); return true; }
/** * Add a AS_OPERATOR_APPEND bin operation with a raw bytes 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_rawp(as_operations * ops, const as_bin_name name, const uint8_t * value, uint32_t size, bool free) { as_binop * binop = as_binop_forappend(ops, AS_OPERATOR_APPEND, name); if ( !binop ) return false; as_bin_init_raw(&binop->bin, name, value, size, free); return true; }
/** * Set specified bin's value to raw bytes of given length. * uint8_t bytes[3] = {1,2,3} * as_record_set_raw(rec, "bin", bytes, 3); * @param rec - the record containing the bin * @param name - the name of the bin * @param value - the value of the bin * @param size - the size of the value * @param type - the as_bytes_type designation (AS_BYTES_*) * @return true on success, false on failure. */ bool as_record_set_raw_typep(as_record * rec, const as_bin_name name, const uint8_t * value, uint32_t size, as_bytes_type type, bool free) { as_bin * bin = as_record_bin_forupdate(rec, name); if ( !bin ) return false; as_bin_init_raw(bin, name, value, size, free); as_bytes *bytes_val = (as_bytes*) &bin->value; bytes_val->type = type; return true; }