---
name: "libmawk_call_function"
section: "3libmawk"
platform: "linux"
package: "libmawk1t64"
version: "1.0.4-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/libmawk_call_function"
---

# libmawk\_call\_function(3libmawk)

call an user defined (script) function

## NAME

libmawk\_call\_function - call an user defined (script) function

## SYNOPSIS

```
#include <libmawk.h>

int libmawk_call_function(mawk_state_t *MAWK, const char *fname, CELL *res, const char *argtpes, ...);
```

**int libmawk\_call\_functionp(mawk\_state\_t \****MAWK***, const char \****fname***, CELL \****res***, const char \****argtpes***, void \*\*args);**

## DESCRIPTION

The **libmawk\_call\_function**() function looks up an user defined awk function called *fname* , fills the stack with arguments converted from the varargs and calls the function. The **libmawk\_call\_functionp**() performs the same action but avoids using vararg by requiring an array of generic pointers to the function arguments.

Argtype is a zero terminated string for both functions, each character corresponding to an argument. Type characters are described in libmawk\_set\_cell() manual page.

If res is non-NULL, it is cell\_destroyed (regardless of errors) and the return value of the user function is copied into it. The caller shall run libmawk\_cell\_destroy on it.

Argument m is a libmawk context previously returned by libmawk\_initialize() or libmawk\_initialize\_stage3().

## RETURN VALUE

A pointer to the cell returned by the user function. The cell returnedmust be destroyed by the application using libmawk\_cell\_destroy.

## SEE ALSO

**libmawk\_initialize\_stage**(3libmawk), **libmawk\_initialize**(3libmawk), **libmawk\_cell\_destroy**(3libmawk), **libmawk\_set\_cell**(3libmawk),
