mirror of
https://github.com/NishiOwO/ncsa-httpd.git
synced 2025-04-21 16:54:46 +00:00
130 lines
3.5 KiB
Plaintext
130 lines
3.5 KiB
Plaintext
9a10
|
|
> #define ROOT_MENU "Root Menu"
|
|
11d11
|
|
<
|
|
149a150,165
|
|
> /* /gopher-data/ hack by Ian C Blenke */
|
|
> if(ar[i]->host[0]) {
|
|
> char host[MAX_STRING_LEN];
|
|
>
|
|
> HOSTNAME(host,MAX_STRING_LEN);
|
|
> if(strncmp(ar[i]->host, host, strlen(host))==0)
|
|
> /* problem: if we fall through here we may get // */
|
|
> if(ar[i]->path[0]) {
|
|
> fprintf(fd,
|
|
> "<LI> <A NAME=%d HREF=\"/gopher-data%s\"",
|
|
> lnum++, (ar[i]->path)+1);
|
|
> fprintf(fd,">%s</A>%c",ar[i]->name,LINEFEED);
|
|
> break;
|
|
> } /* fall through if not type 0 or 1 */
|
|
> }
|
|
>
|
|
291a308,359
|
|
> /* GN - Patch #1 - for looks - Ian C. Blenke */
|
|
> void get_link_name_from_dir(char *dir, char *munge, char *return_name)
|
|
> {
|
|
> char munged_name[MAX_STRING_LEN];
|
|
> int i, len, count;
|
|
> char dir_name[MAX_STRING_LEN];
|
|
> gopher_ent head;
|
|
> gopher_ent *p, *r;
|
|
>
|
|
> /* strip out the actual parent path name */
|
|
> len=strlen(dir);
|
|
> while(len>0)
|
|
> {
|
|
> if(dir[len]=='/') break;
|
|
> len--;
|
|
> }
|
|
> strncpy(dir_name, dir, len);
|
|
> dir_name[len]='\0';
|
|
> /* strip out the virtual parent path name */
|
|
> strcpy(munged_name, munge+GOPHER_LOC_LEN);
|
|
> len=strlen(munged_name);
|
|
> if((len==0)||(len==1))
|
|
> {
|
|
> strcpy(return_name, ROOT_MENU);
|
|
> return;
|
|
> }
|
|
> while(len>1)
|
|
> {
|
|
> if(munged_name[len]=='/') break;
|
|
> len--;
|
|
> }
|
|
> munged_name[len-1]='\0';
|
|
> strcpy(munged_name, munged_name+len);
|
|
>
|
|
> /* parse the parent menu file */
|
|
> head.next=NULL;
|
|
> count=add_links_from_file(dir_name, "menu", &head);
|
|
> p=&head;
|
|
>
|
|
> /* loop through the chain */
|
|
> for(i=0; i<count; i++)
|
|
> {
|
|
> if(strcmp((p->path)+2, munged_name)==0)
|
|
> strcpy(return_name, p->name);
|
|
> r=p->next;
|
|
> free(p);
|
|
> p=r;
|
|
> if(p==NULL) break;
|
|
> }
|
|
> return;
|
|
> }
|
|
>
|
|
293,294c361
|
|
< DIR *d;
|
|
< struct DIR_TYPE *dstruct;
|
|
---
|
|
> FILE *fmenu;
|
|
298a366,367
|
|
> char menu_name[MAX_STRING_LEN];
|
|
> char parent_name[MAX_STRING_LEN];
|
|
305a375
|
|
> make_full_path(name, "menu", menu_name);
|
|
307,308c377,378
|
|
< if(!(d=opendir(name)))
|
|
< client_error(fd,BAD_FILE);
|
|
---
|
|
> if(!(fmenu=fopen(menu_name, "r")))
|
|
> client_error(fd, BAD_FILE);
|
|
310,311c380
|
|
< while(dstruct=readdir(d)) {
|
|
< char *fn;
|
|
---
|
|
> fclose(fmenu);
|
|
313,315c382
|
|
< fn=dstruct->d_name;
|
|
< if(ignore(fn))
|
|
< continue;
|
|
---
|
|
> num_entries=add_links_from_file(name, "menu", &head);
|
|
317,329c384,391
|
|
< if(fn[0]=='.') {
|
|
< if(!strcmp(fn,".cap"))
|
|
< cap_file=1;
|
|
< else
|
|
< num_entries+=add_links_from_file(name,fn,&head);
|
|
< }
|
|
< else {
|
|
< add_local_link(fn,&head);
|
|
< num_entries++;
|
|
< }
|
|
< }
|
|
< fprintf(fd,"<TITLE> Gopher Index of %s</TITLE>%c",unmunged_name,LINEFEED);
|
|
< fprintf(fd,"<H1>Gopher Index of %s</H1>%c",unmunged_name,LINEFEED);
|
|
---
|
|
> get_link_name_from_dir(name, unmunged_name, parent_name);
|
|
> fprintf(fd,"<HEADER>%c",LINEFEED);
|
|
> fprintf(fd,"<TITLE> %s </TITLE>%c",parent_name,LINEFEED);
|
|
> fprintf(fd,"<BASE HREF=\"http://su102w.ess.harris.com\">%c", LINEFEED);
|
|
> fprintf(fd,"</HEADER>%c",LINEFEED);
|
|
> fprintf(fd,"<BODY>%c", LINEFEED);
|
|
> fprintf(fd,"<H1>Harris ESS InfoServer Gopher</H1>%c",LINEFEED);
|
|
> fprintf(fd,"<H2> %s </H2>%c", parent_name, LINEFEED);
|
|
338c400
|
|
< closedir(d);
|
|
---
|
|
> fprintf(fd,"</BODY>%c", LINEFEED);
|
|
|