OPENPAM_STRADDCH(3)

πŸ“¦
version 14.5 Β· 2 versions
, in freebsd 14.5, nixos 26.05, nixpkgs unstable

πŸŽ€ 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