From ca02fe9b77037d56dd01ea7b5d33eebb62983e44 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 25 May 2024 11:55:36 -0400 Subject: bfstd: New helper for open(ctermid()) --- src/bfstd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/bfstd.c') diff --git a/src/bfstd.c b/src/bfstd.c index ce2218c..44eda7c 100644 --- a/src/bfstd.c +++ b/src/bfstd.c @@ -184,6 +184,16 @@ char *xgetdelim(FILE *file, char delim) { } } +int open_cterm(int flags) { + char path[L_ctermid]; + if (ctermid(path) == NULL || strlen(path) == 0) { + errno = ENOTTY; + return -1; + } + + return open(path, flags); +} + const char *xgetprogname(void) { const char *cmd = NULL; #if BFS_HAS_GETPROGNAME -- cgit v1.2.3