---
name: "pappl-mainloop"
section: "3"
platform: "linux"
package: "pappl"
version: "1.4.12-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pappl-mainloop"
---

# pappl-mainloop(3)

pappl main loop functions

## NAME

pappl-mainloop - pappl main loop functions

## LIBRARY

Printer Application Framework (libpappl, "pkg-config --cflags --libs pappl")

## SYNOPSIS

**#include \<pappl/pappl.h\>**

*int*\
 **papplMainloop***(int argc, char \*argv\[\], const char \*version, const char \*footer\_html, int num\_drivers, pappl\_driver\_t \*drivers, pappl\_driver\_cb\_t driver\_cb, pappl\_ml\_autoadd\_cb\_t autoadd\_cb, const char \*subcmd\_name, pappl\_ml\_subcmd\_cb\_t subcmd\_cb, pappl\_ml\_system\_cb\_t system\_cb, pappl\_ml\_usage\_cb\_t usage\_cb, void \*data);*

## DESCRIPTION

The

mainloop function starts the printer application and supports standard command-line arguments and behaviors.

## FUNCTIONS

### papplMainloop

Run a standard main loop for printer applications.

```
int  papplMainloop (
    int argc,
    char *argv[],
    const char *version,
    const char *footer_html,
    int num_drivers,
    pappl_pr_driver_t *drivers,
    pappl_pr_autoadd_cb_t autoadd_cb,
    pappl_pr_driver_cb_t driver_cb,
    const char *subcmd_name,
    pappl_ml_subcmd_cb_t subcmd_cb,
    pappl_ml_system_cb_t system_cb,
    pappl_ml_usage_cb_t usage_cb,
    void *data
);
```

This function runs a standard main loop for a printer application.  The "argc" and "argv" arguments are those provided to the **main** function.

The "version" argument specifies a numeric version number for the printer application that conforms to semantic versioning guidelines with up to four numbers, for example "1.2.3.4".

The "footer\_html" argument specifies HTML text to use in the footer of the web interface.  If **NULL**, the footer is omitted.

The "num\_drivers", "drivers", and "driver\_cb" arguments specify a list of drivers and the driver callback for printers.  Specify **0** and **NULL** if the drivers are configured in the system callback.  The "autoadd\_cb" argument specifies a callback for automatically adding new printers with the "autoadd" sub-command and for auto-detecting the driver when adding manually.

The "usage\_cb" argument specifies a callback that displays a usage/help summary.  If **NULL**, a generic summary is shown as needed.

The "subcmd\_name" and "subcmd\_cb" arguments specify the name and a callback for a custom sub-command.  If **NULL**, no custom sub-commands will be supported.

The "system\_cb" argument specifies a function that will create a new **pappl\_system\_t** object.  If **NULL**, a default system object is created.

The "data" argument provides application-specific data for each of the callbacks.

### papplMainloopShutdown

Request a shutdown of a running system.

```
void papplMainloopShutdown (void);
```

This function requests that the system started by *papplMainloop* be shutdown.

## TYPES

### pappl\_ml\_subcmd\_cb\_t

Sub-command callback

```
typedef int (*pappl_ml_subcmd_cb_t)(const char *base_name, int num_options, cups_option_t *options, int num_files, char **files, void *data);
```

### pappl\_ml\_system\_cb\_t

System callback

```
typedef pappl_system_t * (*pappl_ml_system_cb_t)(int num_options, cups_option_t *options, void *data);
```

### pappl\_ml\_usage\_cb\_t

Program usage callback

```
typedef void (*pappl_ml_usage_cb_t)(void *data);
```

## SEE ALSO

[**pappl**(1)](/pappl/1.md), [**pappl-client**(3)](/pappl-client/3.md), [**pappl-device**(3)](/pappl-device/3.md), [**pappl-job**(3)](/pappl-job/3.md), [**pappl-log**(3)](/pappl-log/3.md), **pappl-mainline**(3), [**pappl-makeresheader**(1)](/pappl-makeresheader/1.md), [**pappl-printer**(3)](/pappl-printer/3.md), [**pappl-resource**(3)](/pappl-resource/3.md), [**pappl-system**(3)](/pappl-system/3.md), https://www.msweet.org/pappl

## COPYRIGHT

Copyright © 2019-2022 by Michael R Sweet.

**PAPPL** is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software (like older versions of CUPS), so it can be used *freely* in any project you'd like. See the files "LICENSE" and "NOTICE" in the source distribution for more information.
