OPENPAM_STRADDCH(3)
π OPENPAM_STRADDCH π
ok so bestie, welcome to openpam_straddch from the Library Functions Manual β she's a tiny lil OpenPAM helper and honestly she's carrying the whole string-building operation on her back π
β¨ NAME β¨
openpam_straddch β add a character to a string, expanding the buffer if needed π¦
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <security/pam_appl.h>
#include <security/openpam.h>
int
openpam_straddch(char **str, size_t *size, size_t *len, int ch);
π DESCRIPTION π
so the openpam_straddch() function appends a character to a dynamically allocated NUL-terminated buffer, and it reallocates the buffer as needed. lowkey iconic behavior, no cap π₯
the str argument points to a variable containing either a pointer to an existing buffer or NULL. and if the value of the variable pointed to by str is NULL, a new buffer gets allocated. she just manifests one β¨
the size and len argument point to variables used to hold the size of the buffer and the length of the string it contains, respectively. two little sidekicks, two different jobs π«Ά
the final argument, ch, is the character that should be appended to the string. and here's the cute part β if ch is 0, nothing is appended, but a new buffer is still allocated if str is NULL. this can be used to βbootstrapβ the string. honestly? main character energy π
if a new buffer is allocated or an existing buffer is reallocated to make room for the additional character, str and size are updated accordingly. she keeps receipts π
the openpam_straddch() function ensures that the buffer is always NUL-terminated. periodt. that's the promise π
if the openpam_straddch() function is successful, it increments the integer variable pointed to by len (unless ch was 0) and returns 0. otherwise, it leaves the variables pointed to by str, size and len unmodified, sets errno to ENOMEM and returns -1. so if it goes wrong, she doesn't leave you with half-edited variables, she just says nope π
β RETURN VALUES β
the openpam_straddch() function returns 0 on success and -1 on failure. simple as that, bestie π
π¦ SEE ALSO π¦
π STANDARDS π
the openpam_straddch() function is an OpenPAM extension. iykyk π
π AUTHORS π
the openpam_straddch() function and this manual page were developed by Dag-Erling SmΓΈrgrav <des@des.no>. absolute legend behavior, we stan π«Ά
mwah π that's the whole page β brought to you by Debian, dated June 27, 2023, and delivered with love from OPENPAM_STRADDCH(3) herself πΈβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- nixos 26.05: openpam 20230627
- nixpkgs unstable: openpam 20230627
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms