From 9ad5fc75b2b3b2cec389b39f904178c147749268 Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 29 Dec 2023 23:21:41 -0700 Subject: [PATCH] helix config --- .helix/languages.toml | 16 ++++++ {scrut => libfileis}/libfileis.c | 0 {scrut => libfileis}/libfileis.h | 0 scrut/Makefile | 7 --- scrut/scrut.c | 80 --------------------------- {sysexits => wip/sysexits}/Makefile | 0 {sysexits => wip/sysexits}/sysexits.c | 0 7 files changed, 16 insertions(+), 87 deletions(-) create mode 100644 .helix/languages.toml rename {scrut => libfileis}/libfileis.c (100%) rename {scrut => libfileis}/libfileis.h (100%) delete mode 100644 scrut/Makefile delete mode 100644 scrut/scrut.c rename {sysexits => wip/sysexits}/Makefile (100%) rename {sysexits => wip/sysexits}/sysexits.c (100%) diff --git a/.helix/languages.toml b/.helix/languages.toml new file mode 100644 index 0000000..5b3442d --- /dev/null +++ b/.helix/languages.toml @@ -0,0 +1,16 @@ +[[language]] +file-types = ["c"] +indent.unit = "\t" +indent.tab-width = 8 +language-id = "C" +name = "C" +roots = ["Makefile"] +scope = "source.c" + +[[language]] +file-types = ["homepage"] +indent.unit = "\t" +indent.tab-width = 8 +name = "homepage" +roots = ["Makefile"] +scope = "homepage" diff --git a/scrut/libfileis.c b/libfileis/libfileis.c similarity index 100% rename from scrut/libfileis.c rename to libfileis/libfileis.c diff --git a/scrut/libfileis.h b/libfileis/libfileis.h similarity index 100% rename from scrut/libfileis.h rename to libfileis/libfileis.h diff --git a/scrut/Makefile b/scrut/Makefile deleted file mode 100644 index 12537e9..0000000 --- a/scrut/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -scrut: scrut.o libfileis.o - $(CC) $(CFLAGS) -o scrut libfileis.o scrut.o - -clean: - $(RM) scrut *.o - -.PHONY: clean diff --git a/scrut/scrut.c b/scrut/scrut.c deleted file mode 100644 index c4b631f..0000000 --- a/scrut/scrut.c +++ /dev/null @@ -1,80 +0,0 @@ -#include /* fprintf(3), stderr, NULL */ -#include /* strchr(3) */ -#ifndef EX_USAGE -# include -#endif -#include /* access(3), getopt(3), F_OK, R_OK, W_OK, X_OK */ -#include /* lstat(3), stat struct, S_ISBLK, S_ISCHR, S_ISDIR, - * S_ISFIFO, S_ISGID, S_ISREG, S_ISLNK, S_ISSOCK, - * S_ISUID, S_ISVTX */ - -static char args[] = "bcdefghkprsuwxLS"; -static char ops[(sizeof args) / (sizeof *args)]; -static char *program_name = "scrut"; - -int main(int argc, char *argv[]){ - struct stat buf; - int c; - size_t i; - - if(argc < 2) - goto usage; - - i = 0; - while((c = getopt(argc, argv, args)) != -1) - if(strchr(args, c) == NULL) - goto usage; - else - ops[i++] = c; - ops[i] = '\0'; - - if(optind == argc) - goto usage; - - argv += optind; - do{ if(access(*argv, F_OK) != 0 || lstat(*argv, &buf) == -1) - return 1; /* doesn't exist or isn't stattable */ - - for(i = 0; ops[i] != '\0'; ++i) - if(ops[i] == 'e') - continue; - else if(ops[i] == 'h'){ -usage: fprintf(stderr, "Usage: %s (-%s) [file...]\n", - argv[0] == NULL - ? program_name - : argv[0], - args); - - return EX_USAGE; - }else if( - (ops[i] == 'b' - && !S_ISBLK(buf.st_mode)) - || (ops[i] == 'c' - && !S_ISCHR(buf.st_mode)) - || (ops[i] == 'd' - && !S_ISDIR(buf.st_mode)) - || (ops[i] == 'f' - && !S_ISREG(buf.st_mode)) - || (ops[i] == 'g' - && !(buf.st_mode & S_ISGID)) - || (ops[i] == 'k' - && !(buf.st_mode & S_ISVTX)) - || (ops[i] == 'p' - && !S_ISFIFO(buf.st_mode)) - || (ops[i] == 'r' - && access(*argv, R_OK) != 0) - || (ops[i] == 'u' - && !(buf.st_mode & S_ISUID)) - || (ops[i] == 'w' - && access(*argv, W_OK) != 0) - || (ops[i] == 'x' - && access(*argv, X_OK) != 0) - || (ops[i] == 'L' - && !S_ISLNK(buf.st_mode)) - || (ops[i] == 'S' - && !S_ISSOCK(buf.st_mode))) - return 1; - }while(*++argv != NULL); - - return 0; -} diff --git a/sysexits/Makefile b/wip/sysexits/Makefile similarity index 100% rename from sysexits/Makefile rename to wip/sysexits/Makefile diff --git a/sysexits/sysexits.c b/wip/sysexits/sysexits.c similarity index 100% rename from sysexits/sysexits.c rename to wip/sysexits/sysexits.c