aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-12-21 11:13:51 +0000
committermerakor <cem@ckyln.com>2020-12-21 11:13:51 +0000
commit440af4f3ebfecd68dabf8ce5524fd3f953e81c71 (patch)
treed7ceaf1d040bad60822c87ad78ca30de76df1342 /bin
parent36308f68ddd95984c1909c5ca00a6ab70544d15b (diff)
downloadcpt-440af4f3ebfecd68dabf8ce5524fd3f953e81c71.tar.gz
cpt: remove cpt-stat and cpt-readlink, add _stat() and _readlinkf
cpt-readlink and cpt-stat were unnecessary additions for mundane tasks. Since they were binaries instead of scripts, they added an extra layer of complexity to the library. These functions are now included inside the package manager library with the names _readlinkf() and _stat(). FossilOrigin-Name: 7e15e2b57ddcb834c4286c8d1ac0a28031ae4f5d39f3c6a99f5b3aa0e9a83d43
Diffstat (limited to 'bin')
-rw-r--r--bin/all.do2
-rw-r--r--bin/clean.do2
-rw-r--r--bin/cpt-readlink.c47
-rw-r--r--bin/cpt-stat.c41
-rw-r--r--bin/test.do11
5 files changed, 0 insertions, 103 deletions
diff --git a/bin/all.do b/bin/all.do
deleted file mode 100644
index aceda74..0000000
--- a/bin/all.do
+++ /dev/null
@@ -1,2 +0,0 @@
-. ../config.rc
-redo-ifchange cpt-readlink cpt-stat
diff --git a/bin/clean.do b/bin/clean.do
deleted file mode 100644
index 6234248..0000000
--- a/bin/clean.do
+++ /dev/null
@@ -1,2 +0,0 @@
-. ../config.rc
-rm -f -- ./*.o cpt-readlink cpt-stat .dep.*
diff --git a/bin/cpt-readlink.c b/bin/cpt-readlink.c
deleted file mode 100644
index e7cfe50..0000000
--- a/bin/cpt-readlink.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* cpt-readlink --- a utility replacement for readlink
- * See LICENSE for copyright information.
- *
- * This is basically a 'readlink -f' command.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <libgen.h>
-#include <string.h>
-#include <limits.h>
-
-#define DIR_MAX PATH_MAX - NAME_MAX - 1
-
-
-char *realpath(const char *path, char *resolved_path);
-
-int
-main(int argc, char *argv[])
-{
-
- char buf[PATH_MAX];
-
- /* We are going to use these if the file doesn't exist, but we can still
- * use directories above the file. We are using dname and bname so that
- * they don't clash with the functions with the same name.
- */
- char dname[DIR_MAX]; /* directory name */
- char bname[NAME_MAX]; /* base name */
- sprintf(bname, "%s", (basename(argv[1])));
-
- if (argc != 2 || strcmp(argv[1], "--help") == 0) {
- fprintf(stderr, "usage: %s [file]\n", argv[0]);
- return 1;
- }
-
- if (!realpath(argv[1], buf)) {
-
- if (!realpath(dirname(argv[1]), dname)) {
- perror(argv[0]);
- return 1;
- }
- sprintf(buf, "%s/%s", dname, bname);
- }
-
- printf("%s\n", buf);
- return 0;
-}
diff --git a/bin/cpt-stat.c b/bin/cpt-stat.c
deleted file mode 100644
index 584c2df..0000000
--- a/bin/cpt-stat.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* cpt-stat --- a utility for getting the user name of file owner
- * See LICENSE for copyright information
- *
- * The reason this simple tool exists is because 'stat' is not
- * portable and ls is not exactly stable enough for scripting.
- * This program is for outputting the owner name, and that's it.
- */
-
-#include <pwd.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <string.h>
-
-struct passwd *pw;
-struct stat sb;
-
-int
-main (int argc, char *argv[])
-{
- /* Exit if no or multiple arguments are given. */
- if (argc != 2 || strcmp(argv[1], "--help") == 0) {
- fprintf(stderr, "Usage: %s [pathname]\n", argv[0]);
- return 1;
- }
-
- /* Exit if file stat cannot be obtained. */
- if (lstat(argv[1], &sb) == -1) {
- perror(argv[0]);
- return 1;
- }
-
- /* Exit if name of the owner cannot be retrieved. */
- if (!getpwuid(sb.st_uid)) {
- return 1;
- }
-
- /* Print the user name of file owner. */
- pw = getpwuid(sb.st_uid);
- printf("%s\n", pw->pw_name);
- return 0;
-}
diff --git a/bin/test.do b/bin/test.do
deleted file mode 100644
index 4794751..0000000
--- a/bin/test.do
+++ /dev/null
@@ -1,11 +0,0 @@
-. ../config.rc
-redo all
-exec >&2
-
-./cpt-readlink .
-./cpt-readlink ..
-./cpt-readlink /bin
-./cpt-stat /bin
-./cpt-stat cpt-readlink.o
-
-PHONY