summaryrefslogtreecommitdiffstats
path: root/src/bfstd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-25 11:55:36 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-25 11:55:36 -0400
commitca02fe9b77037d56dd01ea7b5d33eebb62983e44 (patch)
treebec5ea0b7366669261a931a82c80b6c0d92bec3e /src/bfstd.c
parent598422e7678a719b37cc4221c637b840f4e13fcc (diff)
downloadbfs-ca02fe9b77037d56dd01ea7b5d33eebb62983e44.tar.xz
bfstd: New helper for open(ctermid())
Diffstat (limited to 'src/bfstd.c')
-rw-r--r--src/bfstd.c10
1 files changed, 10 insertions, 0 deletions
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