home *** CD-ROM | disk | FTP | other *** search
- Title: Variable-length fields in FancyIndexing output in mod_dir.
- Submitter: Brian Behlendorf <brian@organic.com>
-
- This patch allows the fields for file name and description to be
- resized at compile time. There may be some other buffers which need
- to be adjusted for large values, I'm not sure, but for pumping up the
- file name field to say 40 or 50 this seems to work fine. Of course a
- further refinement of this would be to make the sizes configurable by
- runtime directives.
-
- Brian
-
-
- Index: mod_dir.c
- ===================================================================
- RCS file: /export/home/cvs/apache/src/mod_dir.c,v
- retrieving revision 1.15
- diff -C3 -r1.15 mod_dir.c
- *** mod_dir.c 1996/11/03 20:48:33 1.15
- --- mod_dir.c 1996/11/17 22:19:26
- ***************
- *** 82,87 ****
- --- 82,91 ----
- #define SUPPRESS_SIZE 16
- #define SUPPRESS_DESC 32
-
- + #define MAX_FNAME_LENGTH 23 /* Maximum length of tile name field
- + must not be shorter than 16! */
- + #define MAX_DESCR_LENGTH 23 /* Maximum length of file description field */
- +
- struct item {
- char *type;
- char *apply_to;
- ***************
- *** 536,542 ****
- }
-
- char *terminate_description(dir_config_rec *d, char *desc, int dir_opts) {
- ! int maxsize = 23;
- register int x;
-
- if(dir_opts & SUPPRESS_LAST_MOD) maxsize += 17;
- --- 540,546 ----
- }
-
- char *terminate_description(dir_config_rec *d, char *desc, int dir_opts) {
- ! int maxsize = MAX_DESCR_LENGTH;
- register int x;
-
- if(dir_opts & SUPPRESS_LAST_MOD) maxsize += 17;
- ***************
- *** 572,582 ****
- if(name[0] == '\0') name = "/";
-
- if(dir_opts & FANCY_INDEXING) {
- rputs("<PRE>", r);
- if((tp = find_default_icon(d,"^^BLANKICON^^")))
- rvputs(r, "<IMG SRC=\"", escape_html(scratch, tp),
- "\" ALT=\" \"> ", NULL);
- ! rputs("Name ", r);
- if(!(dir_opts & SUPPRESS_LAST_MOD))
- rputs("Last modified ", r);
- if(!(dir_opts & SUPPRESS_SIZE))
- --- 576,591 ----
- if(name[0] == '\0') name = "/";
-
- if(dir_opts & FANCY_INDEXING) {
- + char buff[MAX_FNAME_LENGTH-3];
- +
- rputs("<PRE>", r);
- if((tp = find_default_icon(d,"^^BLANKICON^^")))
- rvputs(r, "<IMG SRC=\"", escape_html(scratch, tp),
- "\" ALT=\" \"> ", NULL);
- ! rputs("Name", r);
- ! memset(buff, ' ', MAX_FNAME_LENGTH-4);
- ! buff[MAX_FNAME_LENGTH-4] = '\0';
- ! rputs(buff, r);
- if(!(dir_opts & SUPPRESS_LAST_MOD))
- rputs("Last modified ", r);
- if(!(dir_opts & SUPPRESS_SIZE))
- ***************
- *** 595,623 ****
- clear_pool (scratch);
-
- if((!strcmp(ar[x]->name,"../")) || (!strcmp(ar[x]->name,".."))) {
- char *t = make_full_path (scratch, name, "../");
- getparents(t);
- if(t[0] == '\0') t = "/";
- anchor = pstrcat (scratch, "<A HREF=\"",
- escape_html(scratch, os_escape_path(scratch, t, 0)),
- "\">", NULL);
- ! t2 = "Parent Directory</A> ";
- }
- else {
- t = ar[x]->name;
- len = strlen(t);
- ! if(len > 23) {
- t2 = pstrdup(scratch, t);
- ! t2[21] = '.';
- ! t2[22] = '.';
- ! t2[23] = '\0';
- t2 = escape_html(scratch, t2);
- t2 = pstrcat(scratch, t2, "</A>", NULL);
- } else
- {
- ! char buff[24]=" ";
- t2 = escape_html(scratch, t);
- ! buff[23-len] = '\0';
- t2 = pstrcat(scratch, t2, "</A>", buff, NULL);
- }
- anchor = pstrcat (scratch, "<A HREF=\"",
- --- 604,637 ----
- clear_pool (scratch);
-
- if((!strcmp(ar[x]->name,"../")) || (!strcmp(ar[x]->name,".."))) {
- + char buff[MAX_FNAME_LENGTH-15];
- char *t = make_full_path (scratch, name, "../");
- +
- getparents(t);
- if(t[0] == '\0') t = "/";
- anchor = pstrcat (scratch, "<A HREF=\"",
- escape_html(scratch, os_escape_path(scratch, t, 0)),
- "\">", NULL);
- ! memset(buff, ' ', MAX_FNAME_LENGTH-15);
- ! buff[MAX_FNAME_LENGTH-16] = '\0';
- ! t2 = pstrcat(scratch, "Parent Directory</A>", buff, NULL);
- }
- else {
- t = ar[x]->name;
- len = strlen(t);
- ! if(len > MAX_FNAME_LENGTH) {
- t2 = pstrdup(scratch, t);
- ! t2[MAX_FNAME_LENGTH-2] = '.';
- ! t2[MAX_FNAME_LENGTH-1] = '.';
- ! t2[MAX_FNAME_LENGTH] = '\0';
- t2 = escape_html(scratch, t2);
- t2 = pstrcat(scratch, t2, "</A>", NULL);
- } else
- {
- ! char buff[MAX_FNAME_LENGTH+1];
- ! memset(buff, ' ', MAX_FNAME_LENGTH+1);
- t2 = escape_html(scratch, t);
- ! buff[MAX_FNAME_LENGTH-len] = '\0';
- t2 = pstrcat(scratch, t2, "</A>", buff, NULL);
- }
- anchor = pstrcat (scratch, "<A HREF=\"",
-