summaryrefslogtreecommitdiffstats
path: root/src/bfstd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-04-24 12:47:12 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-04-24 12:48:05 -0400
commit3a72b93d26ad2bb06ea0b7d39257130084b1ee1e (patch)
treeb476e317185f9d26038007507dc4a1fbd7f5070b /src/bfstd.c
parent98a026cf8b9d5da7730d5d4d1c88ba35d94771b2 (diff)
downloadbfs-3a72b93d26ad2bb06ea0b7d39257130084b1ee1e.tar.xz
printf: Refactor %y/%Y implementation
Diffstat (limited to 'src/bfstd.c')
-rw-r--r--src/bfstd.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/bfstd.c b/src/bfstd.c
index 1144380..f8ce871 100644
--- a/src/bfstd.c
+++ b/src/bfstd.c
@@ -252,40 +252,6 @@ int ynprompt(void) {
return ret;
}
-/** Get the single character describing the given file type. */
-static char type_char(mode_t mode) {
- switch (mode & S_IFMT) {
- case S_IFREG:
- return '-';
- case S_IFBLK:
- return 'b';
- case S_IFCHR:
- return 'c';
- case S_IFDIR:
- return 'd';
- case S_IFLNK:
- return 'l';
- case S_IFIFO:
- return 'p';
- case S_IFSOCK:
- return 's';
-#ifdef S_IFDOOR
- case S_IFDOOR:
- return 'D';
-#endif
-#ifdef S_IFPORT
- case S_IFPORT:
- return 'P';
-#endif
-#ifdef S_IFWHT
- case S_IFWHT:
- return 'w';
-#endif
- }
-
- return '?';
-}
-
void *xmemdup(const void *src, size_t size) {
void *ret = malloc(size);
if (ret) {
@@ -356,6 +322,40 @@ const char *xstrerror(int errnum) {
return ret;
}
+/** Get the single character describing the given file type. */
+static char type_char(mode_t mode) {
+ switch (mode & S_IFMT) {
+ case S_IFREG:
+ return '-';
+ case S_IFBLK:
+ return 'b';
+ case S_IFCHR:
+ return 'c';
+ case S_IFDIR:
+ return 'd';
+ case S_IFLNK:
+ return 'l';
+ case S_IFIFO:
+ return 'p';
+ case S_IFSOCK:
+ return 's';
+#ifdef S_IFDOOR
+ case S_IFDOOR:
+ return 'D';
+#endif
+#ifdef S_IFPORT
+ case S_IFPORT:
+ return 'P';
+#endif
+#ifdef S_IFWHT
+ case S_IFWHT:
+ return 'w';
+#endif
+ }
+
+ return '?';
+}
+
void xstrmode(mode_t mode, char str[11]) {
strcpy(str, "----------");