home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / linux / apache / contrib / patches / 1.2 / variable-dir.patch < prev   
Encoding:
Text File  |  1998-06-11  |  4.7 KB  |  147 lines

  1. Title: Variable-length fields in FancyIndexing output in mod_dir.
  2. Submitter: Brian Behlendorf <brian@organic.com>
  3.  
  4. This patch allows the fields for file name and description to be
  5. resized at compile time.  There may be some other buffers which need
  6. to be adjusted for large values, I'm not sure, but for pumping up the
  7. file name field to say 40 or 50 this seems to work fine.  Of course a
  8. further refinement of this would be to make the sizes configurable by
  9. runtime directives.
  10.  
  11.     Brian
  12.  
  13.  
  14. Index: mod_dir.c
  15. ===================================================================
  16. RCS file: /export/home/cvs/apache/src/mod_dir.c,v
  17. retrieving revision 1.15
  18. diff -C3 -r1.15 mod_dir.c
  19. *** mod_dir.c    1996/11/03 20:48:33    1.15
  20. --- mod_dir.c    1996/11/17 22:19:26
  21. ***************
  22. *** 82,87 ****
  23. --- 82,91 ----
  24.   #define SUPPRESS_SIZE 16
  25.   #define SUPPRESS_DESC 32
  26.   
  27. + #define MAX_FNAME_LENGTH 23     /* Maximum length of tile name field
  28. +                    must not be shorter than 16! */
  29. + #define MAX_DESCR_LENGTH 23     /* Maximum length of file description field */
  30.   struct item {
  31.       char *type;
  32.       char *apply_to;
  33. ***************
  34. *** 536,542 ****
  35.   }
  36.   
  37.   char *terminate_description(dir_config_rec *d, char *desc, int dir_opts) {
  38. !     int maxsize = 23;
  39.       register int x;
  40.       
  41.       if(dir_opts & SUPPRESS_LAST_MOD) maxsize += 17;
  42. --- 540,546 ----
  43.   }
  44.   
  45.   char *terminate_description(dir_config_rec *d, char *desc, int dir_opts) {
  46. !     int maxsize = MAX_DESCR_LENGTH;
  47.       register int x;
  48.       
  49.       if(dir_opts & SUPPRESS_LAST_MOD) maxsize += 17;
  50. ***************
  51. *** 572,582 ****
  52.       if(name[0] == '\0') name = "/";
  53.   
  54.       if(dir_opts & FANCY_INDEXING) {
  55.           rputs("<PRE>", r);
  56.           if((tp = find_default_icon(d,"^^BLANKICON^^")))
  57.               rvputs(r, "<IMG SRC=\"", escape_html(scratch, tp),
  58.              "\" ALT=\"     \"> ", NULL);
  59. !         rputs("Name                   ", r);
  60.           if(!(dir_opts & SUPPRESS_LAST_MOD))
  61.               rputs("Last modified     ", r);
  62.           if(!(dir_opts & SUPPRESS_SIZE))
  63. --- 576,591 ----
  64.       if(name[0] == '\0') name = "/";
  65.   
  66.       if(dir_opts & FANCY_INDEXING) {
  67. +         char buff[MAX_FNAME_LENGTH-3];
  68.           rputs("<PRE>", r);
  69.           if((tp = find_default_icon(d,"^^BLANKICON^^")))
  70.               rvputs(r, "<IMG SRC=\"", escape_html(scratch, tp),
  71.              "\" ALT=\"     \"> ", NULL);
  72. !         rputs("Name", r);
  73. !     memset(buff, ' ', MAX_FNAME_LENGTH-4);
  74. !     buff[MAX_FNAME_LENGTH-4] = '\0';
  75. !     rputs(buff, r);
  76.           if(!(dir_opts & SUPPRESS_LAST_MOD))
  77.               rputs("Last modified     ", r);
  78.           if(!(dir_opts & SUPPRESS_SIZE))
  79. ***************
  80. *** 595,623 ****
  81.       clear_pool (scratch);
  82.       
  83.           if((!strcmp(ar[x]->name,"../")) || (!strcmp(ar[x]->name,".."))) {
  84.               char *t = make_full_path (scratch, name, "../");
  85.               getparents(t);
  86.               if(t[0] == '\0') t = "/";
  87.           anchor = pstrcat (scratch, "<A HREF=\"",
  88.                     escape_html(scratch, os_escape_path(scratch, t, 0)),
  89.                     "\">", NULL);
  90. !         t2 = "Parent Directory</A>       ";
  91.           }
  92.           else {
  93.           t = ar[x]->name;
  94.           len = strlen(t);
  95. !             if(len > 23) {
  96.           t2 = pstrdup(scratch, t);
  97. !         t2[21] = '.';
  98. !         t2[22] = '.';
  99. !                 t2[23] = '\0';
  100.           t2 = escape_html(scratch, t2);
  101.           t2 = pstrcat(scratch, t2, "</A>", NULL);
  102.               } else 
  103.           {
  104. !         char buff[24]="                       ";
  105.           t2 = escape_html(scratch, t);
  106. !         buff[23-len] = '\0';
  107.           t2 = pstrcat(scratch, t2, "</A>", buff, NULL);
  108.           }
  109.           anchor = pstrcat (scratch, "<A HREF=\"",
  110. --- 604,637 ----
  111.       clear_pool (scratch);
  112.       
  113.           if((!strcmp(ar[x]->name,"../")) || (!strcmp(ar[x]->name,".."))) {
  114. +         char buff[MAX_FNAME_LENGTH-15];
  115.               char *t = make_full_path (scratch, name, "../");
  116.               getparents(t);
  117.               if(t[0] == '\0') t = "/";
  118.           anchor = pstrcat (scratch, "<A HREF=\"",
  119.                     escape_html(scratch, os_escape_path(scratch, t, 0)),
  120.                     "\">", NULL);
  121. !         memset(buff, ' ', MAX_FNAME_LENGTH-15);
  122. !         buff[MAX_FNAME_LENGTH-16] = '\0';
  123. !         t2 = pstrcat(scratch, "Parent Directory</A>", buff, NULL);
  124.           }
  125.           else {
  126.           t = ar[x]->name;
  127.           len = strlen(t);
  128. !             if(len > MAX_FNAME_LENGTH) {
  129.           t2 = pstrdup(scratch, t);
  130. !         t2[MAX_FNAME_LENGTH-2] = '.';
  131. !         t2[MAX_FNAME_LENGTH-1] = '.';
  132. !                 t2[MAX_FNAME_LENGTH] = '\0';
  133.           t2 = escape_html(scratch, t2);
  134.           t2 = pstrcat(scratch, t2, "</A>", NULL);
  135.               } else 
  136.           {
  137. !         char buff[MAX_FNAME_LENGTH+1];
  138. !         memset(buff, ' ', MAX_FNAME_LENGTH+1);
  139.           t2 = escape_html(scratch, t);
  140. !         buff[MAX_FNAME_LENGTH-len] = '\0';
  141.           t2 = pstrcat(scratch, t2, "</A>", buff, NULL);
  142.           }
  143.           anchor = pstrcat (scratch, "<A HREF=\"",
  144.