summaryrefslogtreecommitdiffstats
path: root/src/util/windows/libecho.c
diff options
context:
space:
mode:
authorRichard Basch <probe@mit.edu>1997-02-06 02:31:41 +0000
committerRichard Basch <probe@mit.edu>1997-02-06 02:31:41 +0000
commita0b9ce4bee60136363cfff7a93c4e42eab972c02 (patch)
tree400984337fe3766653ff4cc2cb6b7d3d7f87f3f4 /src/util/windows/libecho.c
parenta9266b1dec31de9f33b0d032b885edd377a23ee5 (diff)
downloadkrb5-a0b9ce4bee60136363cfff7a93c4e42eab972c02.tar.gz
krb5-a0b9ce4bee60136363cfff7a93c4e42eab972c02.tar.xz
krb5-a0b9ce4bee60136363cfff7a93c4e42eab972c02.zip
Windows/NT integration (V1_0_WIN32_BRANCH merge)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9788 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/windows/libecho.c')
-rw-r--r--src/util/windows/libecho.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/util/windows/libecho.c b/src/util/windows/libecho.c
new file mode 100644
index 000000000..9fcbe2e98
--- /dev/null
+++ b/src/util/windows/libecho.c
@@ -0,0 +1,76 @@
+/*
+ * libecho.c
+ *
+ * For each argument on the command line, echo it. Should expand
+ * DOS wildcards correctly.
+ *
+ * Syntax: libecho [-p prefix] list...
+ */
+#include <stdio.h>
+#include <io.h>
+#include <string.h>
+
+void echo_files(char *, char *);
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+ char *prefix;
+
+ prefix = "";
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: libecho [-p prefix] list...\n");
+ return 1;
+ }
+
+ for (i = 1 ; i < argc ; i++)
+ if (!stricmp(argv[i], "-p"))
+ prefix = argv[++i];
+ else
+ echo_files(prefix, argv[i]);
+
+ return 0;
+}
+
+void
+echo_files(char *prefix, char *f)
+{
+ long ff;
+ struct _finddata_t fdt;
+ char *slash;
+ char filepath[256];
+
+ /*
+ * We're unix based quite a bit here. Look for normal slashes and
+ * make them reverse slashes.
+ */
+ while((slash = strrchr(f, '/')) != NULL)
+ *slash = '\\';
+
+ strcpy(filepath, f);
+
+ slash = strrchr(filepath, '\\');
+
+ if (slash) {
+ slash++;
+ *slash = 0;
+ } else {
+ filepath[0] = '\0';
+ }
+
+ ff = _findfirst(f, &fdt);
+
+ if (ff < 0)
+ return;
+
+ printf("%s%s%s\n", prefix, filepath, fdt.name);
+
+ for (;;) {
+ if (_findnext(ff, &fdt) < 0)
+ break;
+ printf("%s%s%s\n", prefix, filepath, fdt.name);
+ }
+ _findclose(ff);
+}