mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -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);
|
||||
}
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
printf("%10d\t<a href=\"%s%s\">", table[i].size, table[i].name,
|
||||
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>");
|
||||
display_entry(&table[i], dircolor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,14 +158,7 @@ fsp_directory(FSP_SESSION *ses, struct uri *uri)
|
||||
|
||||
while (!fsp_readdir_native(dir, &fentry, &fresult)) {
|
||||
if (!fresult) break;
|
||||
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>");
|
||||
display_entry(&fentry, dircolor);
|
||||
}
|
||||
fsp_closedir(dir);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user