---
name: "xdf_add_event"
section: "3"
platform: "linux"
package: "libxdffileio-dev"
version: "0.3-4+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/xdf_add_event"
---

# xdf\_add\_event(3)

Appends an event to the data file

## NAME

xdf\_add\_event - Appends an event to the data file

## SYNOPSIS

**#include \<xdfio.h\>**

**int xdf\_add\_event(struct xdf\*** *xdf***, int** *evttype***,**\
                   **double** *onset***, double** *dur***);**\

## DESCRIPTION

**xdf\_add\_event**() appends to the file referenced by the handle *xdf* opened for writing an event of type *evttype* at time *onset* lasting for a duration *dur* expressed in seconds. If the event has no notion of duration, *dur* should be set to 0. *evttype* should be a value returned by a successful call to [**xdf\_add\_evttype**(3)](/xdf_add_evttype/3.md).

## RETURN VALUE

**xdf\_add\_event**() returns 0 in case of success. Otherwise -1 is returned and *errno* is set appropriately.

## ERRORS

- **EINVAL**

  *xdf* is NULL or *evttype* has not been previously created by [**xdf\_add\_evttype**(3)](/xdf_add_evttype/3.md)

- **ENOMEM**

  The system is unable to allocate resources.

- **EPERM**

  The file referenced by *xdf* has not been opened for writing or its file format does not support events.

## SEE ALSO

[**xdf\_add\_evttype**(3)](/xdf_add_evttype/3.md)
