Skip to content

Custom context

Julien edited this page Mar 17, 2020 · 2 revisions

Introduction

Sometimes you want to associate some information with a twirc state, so that you can later refer to it again in your callback functions. This can be achieved with the twirc_set_context() and twirc_get_context() functions.

twirc_set_context()

This functions allows you to store a pointer in the twirc state and retrieve it later. Its signature is as follows:

void twirc_set_context(twirc_state_t *s, void *ctx);

twirc_get_context()

This function allows you to retrieve the pointer that you stored in the state with twirc_set_context() earlier. Here is its signature:

void *twirc_get_context(twirc_state_t *s);
Clone this wiki locally