diff options
-rw-r--r-- | link.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -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; +} |