1*0d9d0fd8Schristos.\" $NetBSD: openpam_straddch.3,v 1.8 2023/06/30 21:46:20 christos Exp $ 223e44a77Schristos.\" 38fa0fefeSchristos.\" Generated from openpam_straddch.c by gendoc.pl 4*0d9d0fd8Schristos.Dd June 27, 2023 523e44a77Schristos.Dt OPENPAM_STRADDCH 3 623e44a77Schristos.Os 723e44a77Schristos.Sh NAME 823e44a77Schristos.Nm openpam_straddch 923e44a77Schristos.Nd add a character to a string, expanding the buffer if needed 1023e44a77Schristos.Sh SYNOPSIS 1123e44a77Schristos.In sys/types.h 1223e44a77Schristos.In security/pam_appl.h 1323e44a77Schristos.In security/openpam.h 1423e44a77Schristos.Ft "int" 1523e44a77Schristos.Fn openpam_straddch "char **str" "size_t *size" "size_t *len" "int ch" 1623e44a77Schristos.Sh DESCRIPTION 1723e44a77SchristosThe 1823e44a77Schristos.Fn openpam_straddch 1923e44a77Schristosfunction appends a character to a dynamically 2023e44a77Schristosallocated NUL-terminated buffer, reallocating the buffer as needed. 2123e44a77Schristos.Pp 2223e44a77SchristosThe 2323e44a77Schristos.Fa str 2423e44a77Schristosargument points to a variable containing either a pointer to 2523e44a77Schristosan existing buffer or 2623e44a77Schristos.Dv NULL . 2723e44a77SchristosIf the value of the variable pointed to by 2823e44a77Schristos.Fa str 2923e44a77Schristosis 3023e44a77Schristos.Dv NULL , 3123e44a77Schristosa new buffer 3223e44a77Schristosis allocated. 3323e44a77Schristos.Pp 3423e44a77SchristosThe 3523e44a77Schristos.Fa size 3623e44a77Schristosand 3723e44a77Schristos.Fa len 3823e44a77Schristosargument point to variables used to hold the size 3923e44a77Schristosof the buffer and the length of the string it contains, respectively. 4023e44a77Schristos.Pp 418fa0fefeSchristosThe final argument, 428fa0fefeSchristos.Fa ch , 438fa0fefeSchristosis the character that should be appended to 448fa0fefeSchristosthe string. If 458fa0fefeSchristos.Fa ch 468fa0fefeSchristosis 0, nothing is appended, but a new buffer is 478fa0fefeSchristosstill allocated if 488fa0fefeSchristos.Fa str 498fa0fefeSchristosis NULL. This can be used to 508fa0fefeSchristos.Do 518fa0fefeSchristosbootstrap 528fa0fefeSchristos.Dc 538fa0fefeSchristosthe 548fa0fefeSchristosstring. 558fa0fefeSchristos.Pp 5623e44a77SchristosIf a new buffer is allocated or an existing buffer is reallocated to 5723e44a77Schristosmake room for the additional character, 5823e44a77Schristos.Fa str 5923e44a77Schristosand 6023e44a77Schristos.Fa size 6123e44a77Schristosare updated 6223e44a77Schristosaccordingly. 6323e44a77Schristos.Pp 6423e44a77SchristosThe 6523e44a77Schristos.Fn openpam_straddch 6623e44a77Schristosfunction ensures that the buffer is always 6723e44a77SchristosNUL-terminated. 6823e44a77Schristos.Pp 6923e44a77SchristosIf the 7023e44a77Schristos.Fn openpam_straddch 7123e44a77Schristosfunction is successful, it increments the 7223e44a77Schristosinteger variable pointed to by 7323e44a77Schristos.Fa len 748fa0fefeSchristos(unless 758fa0fefeSchristos.Fa ch 768fa0fefeSchristoswas 0) and returns 0. 7723e44a77SchristosOtherwise, it leaves the variables pointed to by 7823e44a77Schristos.Fa str , 7923e44a77Schristos.Fa size 8023e44a77Schristosand 8123e44a77Schristos.Fa len 8223e44a77Schristosunmodified, sets 8323e44a77Schristos.Va errno 8423e44a77Schristosto 8523e44a77Schristos.Dv ENOMEM 8623e44a77Schristosand returns -1. 8723e44a77Schristos.Pp 8823e44a77Schristos.Sh RETURN VALUES 8923e44a77SchristosThe 9023e44a77Schristos.Fn openpam_straddch 9123e44a77Schristosfunction returns 0 on success and -1 on failure. 9223e44a77Schristos.Sh SEE ALSO 9323e44a77Schristos.Xr pam 3 , 9423e44a77Schristos.Xr pam_strerror 3 9523e44a77Schristos.Sh STANDARDS 9623e44a77SchristosThe 9723e44a77Schristos.Fn openpam_straddch 9823e44a77Schristosfunction is an OpenPAM extension. 9923e44a77Schristos.Sh AUTHORS 10023e44a77SchristosThe 10123e44a77Schristos.Fn openpam_straddch 10223e44a77Schristosfunction and this manual page were 10323e44a77Schristosdeveloped by 104a5684d07Swiz.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no . 105