mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
FSP: reduce code redundancy, introducing display_entry().
This commit is contained in:
parent
d07cf588bd
commit
0c4bc5a362
@ -81,6 +81,18 @@ compare(FSP_RDENTRY *a, FSP_RDENTRY *b)
|
|||||||
return strcmp(a->name, b->name);
|
return strcmp(a->name, b->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_entry(FSP_RDENTRY *fentry, unsigned char dircolor[])
|
||||||
|
{
|
||||||
|
printf("%10d\t<a href=\"%s%s\">", fentry->size,
|
||||||
|
fentry->name, fentry->type == FSP_RDTYPE_DIR ? "/" : "");
|
||||||
|
if (fentry->type == FSP_RDTYPE_DIR && *dircolor)
|
||||||
|
printf("<font color=\"%s\"><b>", dircolor);
|
||||||
|
printf("%s", fentry->name);
|
||||||
|
if (fentry->type == FSP_RDTYPE_DIR && *dircolor)
|
||||||
|
printf("</b></font>");
|
||||||
|
puts("</a>");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sort_and_display_entries(FSP_DIR *dir, unsigned char dircolor[])
|
sort_and_display_entries(FSP_DIR *dir, unsigned char dircolor[])
|
||||||
@ -106,14 +118,7 @@ sort_and_display_entries(FSP_DIR *dir, unsigned char dircolor[])
|
|||||||
(int (*)(const void *, const void *)) compare);
|
(int (*)(const void *, const void *)) compare);
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
printf("%10d\t<a href=\"%s%s\">", table[i].size, table[i].name,
|
display_entry(&table[i], dircolor);
|
||||||
table[i].type == FSP_RDTYPE_DIR ? "/" : "");
|
|
||||||
if (table[i].type == FSP_RDTYPE_DIR && *dircolor)
|
|
||||||
printf("<font color=\"%s\"><b>", dircolor);
|
|
||||||
printf("%s", table[i].name);
|
|
||||||
if (table[i].type == FSP_RDTYPE_DIR && *dircolor)
|
|
||||||
printf("</b></font>");
|
|
||||||
puts("</a>");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,14 +158,7 @@ fsp_directory(FSP_SESSION *ses, struct uri *uri)
|
|||||||
|
|
||||||
while (!fsp_readdir_native(dir, &fentry, &fresult)) {
|
while (!fsp_readdir_native(dir, &fentry, &fresult)) {
|
||||||
if (!fresult) break;
|
if (!fresult) break;
|
||||||
printf("%10d\t<a href=\"%s%s\">", fentry.size,
|
display_entry(&fentry, dircolor);
|
||||||
fentry.name, fentry.type == FSP_RDTYPE_DIR ? "/" : "");
|
|
||||||
if (fentry.type == FSP_RDTYPE_DIR && *dircolor)
|
|
||||||
printf("<font color=\"%s\"><b>", dircolor);
|
|
||||||
printf("%s", fentry.name);
|
|
||||||
if (fentry.type == FSP_RDTYPE_DIR && *dircolor)
|
|
||||||
printf("</b></font>");
|
|
||||||
puts("</a>");
|
|
||||||
}
|
}
|
||||||
fsp_closedir(dir);
|
fsp_closedir(dir);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user