aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-01-23 17:31:32 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2015-01-23 17:31:32 +0200
commit4bb887c83013cd00b297cf22d311202c0e4ef9e0 (patch)
treecf6c12b637b6a8b7de704c8e434f5b2ee90791db
parent034b32134de9aad30f82858cf77dfbfc306a7805 (diff)
downloadeclat-4bb887c83013cd00b297cf22d311202c0e4ef9e0.tar.gz
eclat-4bb887c83013cd00b297cf22d311202c0e4ef9e0.tar.bz2
Improve ispeek
* src/ispeek.c (is_user_data): New function (print_dir,ispeek_do): Always treat user-data as file.
-rw-r--r--src/ispeek.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/ispeek.c b/src/ispeek.c
index 2c518cb..efd18cd 100644
--- a/src/ispeek.c
+++ b/src/ispeek.c
@@ -47,6 +47,19 @@ struct closure {
char **argv;
};
+static int
+is_user_data(const char *s)
+{
+ size_t len;
+
+ while (*s == '/')
+ ++s;
+ len = strlen(s);
+ while (len > 0 && s[len-1] == '/')
+ --len;
+ return len && memcmp(s, "user-data", len) == 0;
+}
+
static char *
read_from(const char *path, CURL *curl, struct grecs_txtacc *acc)
{
@@ -83,7 +96,7 @@ print_dir(const char *path, struct closure *cl)
struct wordsplit ws;
size_t i;
int isroot = strcmp(path, "/") == 0;
-
+
ws.ws_delim = "\r\n";
if (wordsplit(text, &ws,
WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_SQUEEZE_DELIMS |
@@ -92,9 +105,10 @@ print_dir(const char *path, struct closure *cl)
for (i = 0; i < ws.ws_wordc; i++) {
printf("%s%s\n", path, ws.ws_wordv[i]);
- if (recursive) {
+ if (recursive && !is_user_data(ws.ws_wordv[i])) {
if (isroot) {
- char *p = path_concat(path, ws.ws_wordv[i]);
+ char *p = path_concat(path,
+ ws.ws_wordv[i]);
url = path_concat(p, "/");
free(p);
} else if (ws.ws_wordv[i][strlen(ws.ws_wordv[i]) - 1] == '/') {
@@ -202,7 +216,7 @@ ispeek_do(char **argv)
void (*printer)(const char *, struct closure *);
/* Decide how to print the data */
- if (text[0] == '{')
+ if (text[0] == '{' || is_user_data(path))
printer = print_file;
else {
CURLcode res;

Return to:

Send suggestions and report system problems to the System administrator.