commit 04d570026a5db997029535d39bd2c8d676a5c9c3
parent 7736b3212145a1617dbd9305f9b43f9a6a5c44b1
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Sat, 21 Jan 2006 15:08:34 +0200
added qsort to xls in wmiir2
Diffstat:
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/cmd/wmiibar2.c b/cmd/wmiibar2.c
@@ -260,10 +260,7 @@ xwalk(IXPServer * s, IXPConn * c)
return -1;
}
}
- /*
- * following condition is required by 9P, a fid will only be valid if
- * the walk was complete
- */
+ /* a fid will only be valid, if the walk was complete */
if(nwqid == s->fcall.nwname) {
Map *m, *maps = c->aux;
if(s->fcall.fid == s->fcall.newfid) {
@@ -353,6 +350,12 @@ xread(IXPServer * s, IXPConn * c)
s->fcall.count += mkstat(&stat, "default", 0, DMDIR);
p = ixp_enc_stat(p, &stat);
/* todo: add all labels */
+ s->fcall.count += mkstat(&stat, "1", 0, DMDIR);
+ p = ixp_enc_stat(p, &stat);
+ s->fcall.count += mkstat(&stat, "2", 0, DMDIR);
+ p = ixp_enc_stat(p, &stat);
+ s->fcall.count += mkstat(&stat, "3", 0, DMDIR);
+ p = ixp_enc_stat(p, &stat);
s->fcall.id = RREAD;
if(s->fcall.offset >= s->fcall.count)
s->fcall.count = 0; /* EOF */
diff --git a/cmd/wmiir2.c b/cmd/wmiir2.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <dirent.h>
#include "../libixp2/ixp.h"
@@ -90,19 +91,28 @@ xwrite(char *file)
}
static void
-print_dir(void *result, unsigned int msize)
+xls(void *result, unsigned int msize)
{
+ static char *dir[IXP_MAX_MSG];
+ size_t i = 0, j;
+ char buf[IXP_MAX_MSG];
void *p = result;
static Stat stat, zerostat = { 0 };
do {
p = ixp_dec_stat(p, &stat);
if(stat.qid.type == IXP_QTDIR)
- fprintf(stdout, "%s/\n", stat.name);
+ snprintf(buf, IXP_MAX_MSG, "%s/", stat.name);
else
- fprintf(stdout, "%s\n", stat.name);
+ snprintf(buf, IXP_MAX_MSG, "%s", stat.name);
+ dir[i++] = cext_estrdup(buf);
stat = zerostat;
}
while(p - result < msize);
+ qsort(dir, i, sizeof(char *), alphasort);
+ for(j = 0; j < i; j++) {
+ fprintf(stdout, "%s\n", dir[j]);
+ free(dir[j]);
+ }
}
static int
@@ -123,7 +133,7 @@ xread(char *file)
/* read */
while((count = ixp_client_read(&c, fid, offset, result, IXP_MAX_MSG)) > 0) {
if(is_directory)
- print_dir(result, count);
+ xls(result, count);
else {
unsigned int i;
for(i = 0; i < count; i++)