limb 0.2.0

2024-01-09

die(3)
limb manual
die(3)

NAME

die, dief, diefu, diesys, diefsys, diefusys - write a message to stderr and terminate

SYNOPSIS

#include <limb/output.h>
extern const char *PROG;
void die(exit, ...)
void dief(exit, ...)
void diefu(exit, ...)
void diesys(exit, ...)
void diefsys(exit, ...)
void diefusys(exit, ...)

void dieusage(exit, usage)
void diehelp(exit, usage, help)

void errhelp(exit, usage, help)

void diecmdusage(exit, usage, command)
void diecmdhelp(exit, usage, command)

void dieversion(version, year1, year2, author, url, license)

DESCRIPTION

All of those are implemented as macros (to err_putmsgdie(3) or out_putmsgdie(3) for dieversion()) and will write the specified strings to stderr (or stdout for dieversion()), with a new line added at the end, then terminate the calling process via _exit(3) using exit as return/status code.

One exception is errhelp() which is the same as diehelp() only based on err_putmsg(3), so it will not end program execution. It is mainly intended for internal use through dienocommand(3).

output buffers

All of those are using output buffers obuffer_1 or obuffer_2 to write to stdout or stderr respectively. As such, data will also be written to any & all output buffers attached to the corresponding output buffer. See obuffer_attach(3) for more.

All messages will be prefixed by the program's name (i.e. value of PROG), a colon and a space.

dief() will add "fatal: " after the prefix and before the given strings.

diefu() will also add "unable to " before the specified strings.

The diesys(), diefsys() and diefusys() macros are similar, only the specified strings will be followed by a colon, a space and the error description provided by strerror(3) according to errno.

Hint

Some special features are supported, to e.g. easily include a number or perform escaping of some strings. Refer to out(3), or directly buffer_putmsg(3), for more.

The dieusage() macro writes the word "usage: " followed by the program's name and a space as prefix, then the usage string.

The diehelp() macro is similar to dieusage(), only adding two new lines followed by the string help.

The diecmdusage() macro is similar to dieusage() but will add the command's name and usage line. The command must be a struct command as defined in command.h(0).

The diecmdhelp() macro is similar to diehelp() bit will add the command's name and usage, and show its own help screen. As with diecmdusage() the command must be a struct command as defined in command.h(0).

The dieversion() macro writes the program's name (i.e. value of PROG), the string " version " then the specified version and a new line. On a second line is written "Copyright (C) " then year1, followed by a dash and year2 if it differs from year1, then ' - ' followed by url Lastly, if license is not NULL it is written, else on a new line a line for "License GPL-2.0" is written.

limb 0.1.0
2023-07-24
die(3)