TERMKEY_PUSH_BYTES(3)

πŸ’– TERMKEY_PUSH_BYTES πŸ’–

okay bestie, welcome to the Library Functions Manual ✨ this is TERMKEY_PUSH_BYTES(3) and she is lowkey the plug for feeding bytes into your termkey instance 🫢


🌸 NAME 🌸

termkey_push_bytes β€” supply more bytes to the input buffer πŸ’…


✨ SYNOPSIS ✨

#include <termkey.h>

size_t termkey_push_bytes(TermKey *tk, const char *bytes, size_t len);

Link with -ltermkey.


πŸ¦‹ DESCRIPTION πŸ¦‹

so termkey_push_bytes() lets you yeet more bytes of input directly into the input buffer of your termkey(7) instance πŸ’– no middleman, no drama, just bytes going straight in.

but fr fr, if there was no buffer space remaining, then -1 gets returned with errno set to ENOMEM 😭 the buffer said "I'm full bestie" and honestly? respect.

this function, hanging out with termkey_getkey(3), is literally what makes it possible to use the termkey instance with a source of bytes other than reading a filehandle πŸ‘‘ it's giving flexible, it's giving versatile.

for synchronous usage, termkey_waitkey(3) is the one doing the input blocking task πŸ’… she blocks, she waits, she serves.

and for use against a regular stream filehandle that supports read(2), go check termkey_advisereadable(3) 🌈 different vibe, same energy.


πŸ’€ RETURN VALUE πŸ’€

termkey_push_bytes() returns the number of bytes consumed from the input β€” and ngl, that number may be smaller than the length provided, if the buffer runs out of space πŸ™ˆ β€” or -1 cast to size_t if an error occurs, in which case errno is set accordingly.

not me returning -1 cast to size_t 😭 that's the cursed-but-canonical way and we respect the bit.

πŸ‘‘ SEE ALSO πŸ‘‘


sign-off time πŸŽ€ this whole thing lives in the Library Functions Manual, under the name TERMKEY_PUSH_BYTES(3), and the footer said TERMKEY_PUSH_BYTES(3) too β€” periodt πŸ’œ go push some bytes, bestie, you got this πŸ¦‹βœ¨