summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-03-13 21:34:53 -0400
committerJakob Kaivo <jkk@ung.org>2019-03-13 21:34:53 -0400
commit9f1904aa426aa3d32df647b8d853e57e587a97ec (patch)
treed957efa711ea9dc9cd3a91be7e1b023cd3b1158f
migrate to gitlab
-rw-r--r--link.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/link.c b/link.c
new file mode 100644
index 0000000..defb2ff
--- /dev/null
+++ b/link.c
@@ -0,0 +1,44 @@
+/*
+ * UNG's Not GNU
+ *
+ * Copyright (c) 2011-2017, Jakob Kaivo <jkk@ung.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#define _XOPEN_SOURCE 700
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(int argc, char *argv[])
+{
+ while (getopt(argc, argv, "") != -1) {
+ return 1;
+ }
+
+ if (optind != argc - 2) {
+ fprintf(stderr, "link: Must specify a source and destination\n");
+ return 1;
+ }
+
+ if (link(argv[optind], argv[optind + 1]) != 0) {
+ fprintf(stderr, "link: Couldn't link '%s' to '%s': %s\n",
+ argv[optind], argv[optind + 1], strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}