---
name: "xo_set_writer"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/xo_set_writer"
---

# xo\_set\_writer(3)

set custom writer functions for a libxo handle

## NAME

**xo\_set\_writer** – set custom writer functions for a libxo handle

## LIBRARY

library “libxo”

## SYNOPSIS

**#include \<libxo/xo.h\>**

*void*\
 **typedef** **xo\_ssize\_t** **(\*xo\_write\_func\_t)(void** **\*,** **const** **char** **\*);**

**typedef** **void** **(\*xo\_close\_func\_t)(void** **\*);**

**typedef** **int** **(\*xo\_flush\_func\_t)(void** **\*);**

**xo\_set\_writer**(*xo\_handle\_t \*handle*, *void \*opaque*);\
                         "xo\_write\_func\_t write\_func"\
                         "xo\_close\_func\_t close\_func"\
                         "xo\_flush\_func\_t flush\_func"

## DESCRIPTION

The **xo\_set\_writer**() function allows custom “write” functions which can tailor how **libxo** writes data. An *opaque* argument is recorded and passed back to the *write\_func* function, allowing the function to acquire context information. The *close\_func* function can release this opaque data and any other resources as needed. The *flush\_func* function should flush any pending data associated with the opaque pointer.

## SEE ALSO

[xo\_emit(3)](/xo_emit/3.md), [libxo(3)](/libxo/3.md)

## HISTORY

The **libxo** library first appeared in FreeBSD 11.0.

## AUTHORS

**libxo** was written by Phil Shafer ⟨*phil@freebsd.org*⟩.
