---
name: "xo_close_marker"
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_close_marker"
---

# xo\_close\_marker(3)

prevent and allow closing of open constructs

## NAME

**xo\_open\_marker**, **xo\_open\_marker\_h**, **xo\_close\_marker**, **xo\_close\_marker\_h** – prevent and allow closing of open constructs

## LIBRARY

library “libxo”

## SYNOPSIS

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

*xo\_ssize\_t*\

**xo\_open\_marker**(*const char \*name*);

*xo\_ssize\_t*\

**xo\_open\_marker\_h**(*xo\_handle\_t \*handle*, *const char \*name*);

*xo\_ssize\_t*\

**xo\_close\_marker**(*const char \*name*);

*xo\_ssize\_t*\

**xo\_close\_marker\_h**(*xo\_handle\_t \*handle*, *const char \*name*);

## DESCRIPTION

**libxo** represents hierarchy using two constructs: “containers” and “lists”. A marker can be used to affect how open constructs are closed, either by preventing their (implicit or explicit) closure or by forcing their closure. While a marker is open, no other open constructs can be closed.  When a marker is closed, all constructs open since the marker was opened will be closed. A marker is used to "freeze" any open constructs. Calls to **xo\_close\_\***() functions that would normally close them will be ignored, effectively blocking their closure. However when **xo\_close\_marker**() is called, any containers, lists, or leaf-lists open since the matching **xo\_open\_marker**() call will be close and the marker discarded. Markers use names which are not user-visible, allowing the caller to choose appropriate internal names. The marker has no value and is not emitted in any form.

To open a marker, call **xo\_open\_marker**() or **xo\_open\_marker\_h**(). The former uses the default handle and the latter accepts a specific handle.

To close a marker, use the **xo\_close\_marker**() or **xo\_close\_marker\_h**() functions.

Each open call must have a matching close call.

In this example, the **xo\_close\_container**() call on line \[1\] will be ignored, since the open marker "outer" will prevent close of any open constructs that precede it. The **xo\_close\_marker**() call on line \[2\] will close the "system" container, since it was opened after the "outer" marker.

```
    Example:
        xo_open_container("top");
	xo_open_marker("outer");
        xo_open_container("system");
        xo_emit("{:host-name/%s%s%s", hostname,
                domainname ? "." : "", domainname ?: "");
        xo_close_container("top");   /* [1] */
	xo_close_marker("outer");    /* [2] */
        xo_close_container("top");
```

In this example, the code whiffles through a list of fish, calling a function to emit details about each fish.  The marker "fish-guts" is used to ensure that any constructs opened by the function are closed properly.

```
    for (i = 0; fish[i]; i++) {
        xo_open_instance("fish");
        xo_open_marker("fish-guts");
        dump_fish_details(i);
        xo_close_marker("fish-guts");
    }
```

## 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*⟩.
