glibs:(getln)

πŸ“¦ version 31, in alpine 3.24

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

  • getln normally returns 0. If it runs out of memory, or encounters an error from sa, it returns -1, setting errno appropriately.
  • getln2 normally returns 0. If it runs out of memory, or encounters an error from sa, it returns -1, setting errno appropriately.
those -1 returns are the not-slay outcome, and errno is 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