mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-11-23 18:14:25 +08:00
Makefile.pq, libecho.c:
echo function for Windows
This commit is contained in:
parent
291c9049ba
commit
3b12bf9469
12
util/Makefile.pq
Normal file
12
util/Makefile.pq
Normal file
@ -0,0 +1,12 @@
|
||||
TOPSRC=..
|
||||
|
||||
!include $(TOPSRC)\powerquest\MCONFIG
|
||||
|
||||
ALL:: libecho.exe
|
||||
|
||||
libecho.exe: libecho.c
|
||||
|
||||
clean::
|
||||
$(RM) libecho.exe
|
||||
|
||||
!include $(TOPSRC)\powerquest\MAKEFILE.STD
|
78
util/libecho.c
Normal file
78
util/libecho.c
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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) {
|
||||
printf("%s%s\n", prefix, f);
|
||||
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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user