glibs:(getln)
π NAME π
okay so bestie, welcome to glibs:(getln) β this page is about getln, and it is literally here to read one line of data. π
β¨ SYNTAX β¨
here is the whole lineup, exact vibes only:
#include "getln.h"
int getln(&buf,&sa,&match,sep);
int getln2(&buf,&sa,&cont,&clen,sep);
buffer buf;
stralloc sa;
int match;
int sep;
char *cont;
unsigned int clen;
π¦ DESCRIPTION π¦
getln reads a line of characters from buf, terminated by a sep character. It returns the line in sa and sets match to 1. If getln sees end-of-input before it sees sep, it returns the partial line in sa and sets match to 0. periodt. π
getln2 also reads a line of characters from buf, terminated by a sep character β but bestie, it gives you the line in two pieces. The first piece is stored in sa. The second piece is cont, a pointer to clen characters inside buf. The second piece must be copied somewhere else before sa is used again. If getln2 sees end-of-input before it sees sep, it sets clen to 0 and does not set cont. It puts the partial line into sa. π«Ά
πΈ BUFFER πΈ
buf can be a pre-allocated buffer like buffer_0 reading from STDIN, or any other explicitly generated buffer on a given file descriptor. no cap. β¨
π RETURN CODES π
getlnnormally returns0. If it runs out of memory, or encounters an error fromsa, it returns-1, settingerrnoappropriately.getln2normally returns0. If it runs out of memory, or encounters an error fromsa, it returns-1, settingerrnoappropriately.
those-1returns are the not-slay outcome, anderrnois set appropriately. π
π CREDITS π
The getln and getln2 man page were taken from Bruce Guenther and originally published by Dan Bernstein for qmail-1.03. iconic. π
π SEE ALSO π
okay bye bestie β footer tea: page 3, manual glibs:(getln), mwah πβ¨
π¦ where this page comes from
- alpine 3.24: fehqlibs-doc 31-r0 Β· Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms