In scheme there's a port-position function that would return the length; it could be exported as s7_port_position. Or a new function, say s7_output_string could return an s7_string (which can contain nulls), rather than a C string, and s7_string_length would give its length. Do these sound usable?