version 2.11, 1994/11/24 21:11:22
|
version 2.11.2.2, 1995/03/09 18:25:26
|
Line 9
|
Line 9
|
** multiformat handling would be a mess in VMS. |
** multiformat handling would be a mess in VMS. |
*/ |
*/ |
|
|
|
/* Library include files */ |
|
#include "tcp.h" |
|
#include "HTUtils.h" |
|
#include "HTString.h" |
#include "HTMulti.h" |
#include "HTMulti.h" |
#include "HTFile.h" |
#include "HTFile.h" |
#include "HTList.h" |
#include "HTList.h" |
Line 115 PRIVATE HTList * dir_matches ARGS1(char
|
Line 119 PRIVATE HTList * dir_matches ARGS1(char
|
|
|
dp = opendir(dirname); |
dp = opendir(dirname); |
if (!dp) { |
if (!dp) { |
CTRACE(stderr,"Warning..... Can't open directory %s\n", |
if (PROT_TRACE) |
dirname); |
fprintf(TDEST,"Warning..... Can't open directory %s\n", dirname); |
goto dir_match_failed; |
goto dir_match_failed; |
} |
} |
|
|
Line 179 PRIVATE char * HTGetBest ARGS2(HTRequest
|
Line 183 PRIVATE char * HTGetBest ARGS2(HTRequest
|
HTContentDescription * best = NULL; |
HTContentDescription * best = NULL; |
char * best_path = NULL; |
char * best_path = NULL; |
|
|
|
if (!path || !*path) return NULL; |
if (!path || !*path) return NO; |
|
|
|
matches = dir_matches(path); |
matches = dir_matches(path); |
if (!matches) { |
if (!matches) { |
CTRACE(stderr, "No matches.. for \"%s\"\n", path); |
if (PROT_TRACE) |
return NO; |
fprintf(TDEST, "No matches.. for \"%s\"\n", path); |
|
return NULL; |
} |
} |
|
|
/* BEGIN DEBUG */ |
/* BEGIN DEBUG */ |
cur = matches; |
cur = matches; |
CTRACE(stderr, "Multi....... Possibilities for \"%s\"\n", path); |
if (PROT_TRACE) |
CTRACE(stderr, "\nCONTENT-TYPE LANGUAGE ENCODING QUALITY FILE\n"); |
fprintf(TDEST, "Multi....... Possibilities for \"%s\"\n", path); |
|
if (PROT_TRACE) |
|
fprintf(TDEST, "\nCONTENT-TYPE LANGUAGE ENCODING QUALITY FILE\n"); |
while ((cd = (HTContentDescription*)HTList_nextObject(cur))) { |
while ((cd = (HTContentDescription*)HTList_nextObject(cur))) { |
CTRACE(stderr, "%s\t%s\t%s\t %.5f %s\n", |
if (PROT_TRACE) |
cd->content_type ?HTAtom_name(cd->content_type) :"-\t", |
fprintf(TDEST, "%s\t%s\t%s\t %.5f %s\n", |
cd->content_language?HTAtom_name(cd->content_language):"-", |
cd->content_type ?HTAtom_name(cd->content_type) :"-\t", |
cd->content_encoding?HTAtom_name(cd->content_encoding):"-", |
cd->content_language?HTAtom_name(cd->content_language):"-", |
cd->quality, |
cd->content_encoding?HTAtom_name(cd->content_encoding):"-", |
cd->filename ?cd->filename :"-"); |
cd->quality, |
|
cd->filename ?cd->filename :"-"); |
} |
} |
CTRACE(stderr, "\n"); |
if (PROT_TRACE) fprintf(TDEST, "\n"); |
/* END DEBUG */ |
/* END DEBUG */ |
|
|
/* |
/* |
Line 213 PRIVATE char * HTGetBest ARGS2(HTRequest
|
Line 220 PRIVATE char * HTGetBest ARGS2(HTRequest
|
if (access(best->filename, R_OK) != -1) { |
if (access(best->filename, R_OK) != -1) { |
StrAllocCopy(best_path, best->filename); |
StrAllocCopy(best_path, best->filename); |
break; |
break; |
} |
} else if (PROT_TRACE) |
else CTRACE(stderr, "Bad News.... \"%s\" is not readable\n", |
fprintf(TDEST, "Bad News.... \"%s\" is not readable\n", |
best->filename); |
best->filename); |
} |
} |
} |
} |
Line 268 PRIVATE char * get_best_welcome ARGS1(ch
|
Line 275 PRIVATE char * get_best_welcome ARGS1(ch
|
dp = opendir(path); |
dp = opendir(path); |
if (last && last!=path) *last='/'; |
if (last && last!=path) *last='/'; |
if (!dp) { |
if (!dp) { |
CTRACE(stderr, "Warning..... Can't open directory %s\n",path); |
if (PROT_TRACE) |
|
fprintf(TDEST, "Warning..... Can't open directory %s\n",path); |
return NULL; |
return NULL; |
} |
} |
while ((dirbuf = readdir(dp))) { |
while ((dirbuf = readdir(dp))) { |
Line 292 PRIVATE char * get_best_welcome ARGS1(ch
|
Line 300 PRIVATE char * get_best_welcome ARGS1(ch
|
if (!welcome) outofmem(__FILE__, "get_best_welcome"); |
if (!welcome) outofmem(__FILE__, "get_best_welcome"); |
sprintf(welcome, "%s%s%s", path, last ? "" : "/", best_welcome); |
sprintf(welcome, "%s%s%s", path, last ? "" : "/", best_welcome); |
free(best_welcome); |
free(best_welcome); |
CTRACE(stderr,"Welcome..... \"%s\"\n",welcome); |
if (PROT_TRACE) |
|
fprintf(TDEST,"Welcome..... \"%s\"\n",welcome); |
return welcome; |
return welcome; |
} |
} |
return NULL; |
return NULL; |
Line 338 PUBLIC char * HTMulti ARGS3(HTRequest *,
|
Line 347 PUBLIC char * HTMulti ARGS3(HTRequest *,
|
else{ |
else{ |
char * multi = strrchr(path, MULTI_SUFFIX[0]); |
char * multi = strrchr(path, MULTI_SUFFIX[0]); |
if (multi && !strcasecomp(multi, MULTI_SUFFIX)) { |
if (multi && !strcasecomp(multi, MULTI_SUFFIX)) { |
CTRACE(stderr, "Multi....... by %s suffix\n", MULTI_SUFFIX); |
if (PROT_TRACE) |
|
fprintf(TDEST, "Multi....... by %s suffix\n", MULTI_SUFFIX); |
if (!(new_path = HTGetBest(req, path))) { |
if (!(new_path = HTGetBest(req, path))) { |
CTRACE(stderr, "Multi....... failed -- giving up\n"); |
if (PROT_TRACE) |
|
fprintf(TDEST, "Multi....... failed -- giving up\n"); |
return NULL; |
return NULL; |
} |
} |
path = new_path; |
path = new_path; |
Line 348 PUBLIC char * HTMulti ARGS3(HTRequest *,
|
Line 359 PUBLIC char * HTMulti ARGS3(HTRequest *,
|
else { |
else { |
stat_status = HTStat(path, stat_info); |
stat_status = HTStat(path, stat_info); |
if (stat_status == -1) { |
if (stat_status == -1) { |
CTRACE(stderr, |
if (PROT_TRACE) |
"AutoMulti... because can't stat \"%s\" (errno %d)\n", |
fprintf(TDEST, |
path, errno); |
"AutoMulti... can't stat \"%s\"(errno %d)\n", |
|
path, errno); |
if (!(new_path = HTGetBest(req, path))) { |
if (!(new_path = HTGetBest(req, path))) { |
CTRACE(stderr, "AutoMulti... failed -- giving up\n"); |
if (PROT_TRACE) |
|
fprintf(TDEST, "AutoMulti... failed -- giving up\n"); |
return NULL; |
return NULL; |
} |
} |
path = new_path; |
path = new_path; |
Line 364 PUBLIC char * HTMulti ARGS3(HTRequest *,
|
Line 377 PUBLIC char * HTMulti ARGS3(HTRequest *,
|
if (stat_status == -1) |
if (stat_status == -1) |
stat_status = HTStat(path, stat_info); |
stat_status = HTStat(path, stat_info); |
if (stat_status == -1) { |
if (stat_status == -1) { |
CTRACE(stderr, "Stat fails.. on \"%s\" -- giving up (errno %d)\n", |
if (PROT_TRACE) |
path, errno); |
fprintf(TDEST, "Stat fails.. on \"%s\" -- giving up (errno %d)\n", |
|
path, errno); |
return NULL; |
return NULL; |
} |
} |
else { |
else { |