Fix even more warnings in libwww2
Now that -Wall is turned on, it's possible to remove all sort of unused / unread variables and even fix one case of a missing initialization.
This commit is contained in:
parent
39b76427ae
commit
62396c5250
@ -624,9 +624,6 @@ PRIVATE char *compose_auth_string ARGS2(HTAAScheme, scheme,
|
||||
/* for MD5 -- DXP */
|
||||
char * nonce; /* Server specified integer value */
|
||||
char * opaque; /* more random MD5 junk... */
|
||||
BOOL stale; /* flag indicating the previous request
|
||||
from the client was rejected because
|
||||
the nonce value was stale */
|
||||
|
||||
|
||||
FREE(result); /* From previous call */
|
||||
|
@ -139,7 +139,6 @@ PRIVATE int get_physical ARGS3(
|
||||
int, bong)
|
||||
{
|
||||
char * access=NULL; /* Name of access method */
|
||||
char * physical = NULL;
|
||||
char * host = NULL;
|
||||
struct Proxy *GetNoProxy();
|
||||
extern int useKeepAlive;
|
||||
@ -181,7 +180,6 @@ PRIVATE int get_physical ARGS3(
|
||||
if (!GetNoProxy(tmp_access, tmp_host)) {
|
||||
char *gateway_parameter, *gateway, *proxy;
|
||||
struct Proxy *proxent = NULL, *GetProxy();
|
||||
extern struct Proxy *proxy_list;
|
||||
char *proxyentry = NULL;
|
||||
|
||||
proxy_host_fix=strdup(tmp_host);
|
||||
@ -214,9 +212,9 @@ PRIVATE int get_physical ARGS3(
|
||||
scheme_info = HTParse(HTAnchor_physical(anchor), "", PARSE_PATH);
|
||||
fMatchEnd = 0; /* match other scheme_info at beginning*/
|
||||
}
|
||||
|
||||
|
||||
if (bong) { /* this one is bad - disable! */
|
||||
proxent =
|
||||
proxent =
|
||||
GetProxy(tmp_access, scheme_info, fMatchEnd);
|
||||
if (proxent != NULL) proxent->alive = bong;
|
||||
}
|
||||
@ -282,7 +280,7 @@ PRIVATE int get_physical ARGS3(
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Search registered protocols to find suitable one
|
||||
|
@ -50,7 +50,6 @@ void HTCompressedFileToFile (char *fnam, int compressed)
|
||||
{
|
||||
char *znam;
|
||||
char *cmd;
|
||||
int len;
|
||||
|
||||
cmd=NULL;
|
||||
|
||||
@ -177,8 +176,6 @@ void HTCompressedFileToFile (char *fnam, int compressed)
|
||||
void HTCompressedHText (HText *text, int compressed, int plain)
|
||||
{
|
||||
char *fnam;
|
||||
char *znam;
|
||||
char *cmd;
|
||||
FILE *fp;
|
||||
int rv, size_of_data;
|
||||
|
||||
|
132
libwww2/HTFTP.c
132
libwww2/HTFTP.c
@ -254,13 +254,12 @@ PRIVATE int response (cmd)
|
||||
int messageStarted = 0;
|
||||
|
||||
char *ptr;
|
||||
char bytestr[256],*byteptr;
|
||||
int bytes;
|
||||
|
||||
if (!control || control == -1)
|
||||
|
||||
if (!control || control == -1)
|
||||
{
|
||||
#ifndef DISABLE_TRACE
|
||||
if(www2Trace)
|
||||
if(www2Trace)
|
||||
fprintf(stderr, "FTP: No control connection set up!!\n");
|
||||
#endif
|
||||
return -99;
|
||||
@ -1169,12 +1168,11 @@ ARGS4 (
|
||||
HTAtom *pencoding;
|
||||
char *filename = HTParse(address, "", PARSE_PATH + PARSE_PUNCTUATION);
|
||||
char buffer[BUFSIZ];
|
||||
char buf[BUFSIZ];
|
||||
char itemtype;
|
||||
char itemname[BUFSIZ];
|
||||
char itemsize[BUFSIZ];
|
||||
char *full_ftp_name, *ptr;
|
||||
int count, ret, cmpr, c, rv;
|
||||
int count, ret, cmpr, c='\0', rv;
|
||||
extern char *HTgeticonname(HTFormat, char *);
|
||||
char *ellipsis_string=(char *)calloc(1024,sizeof(char));
|
||||
#ifdef NEW_PARSE
|
||||
@ -1182,7 +1180,6 @@ int nTime;
|
||||
char szDate[256];
|
||||
int nStringLen;
|
||||
int nSpaces;
|
||||
int nOldSpaces;
|
||||
char szFileInfo[32];
|
||||
char szMonth[32];
|
||||
char szDay[16];
|
||||
@ -1208,22 +1205,22 @@ char szTime[32];
|
||||
HText_appendText(HT,"<DD>");
|
||||
|
||||
HText_appendText(HT,"<A HREF=\"");
|
||||
|
||||
|
||||
strcpy(buffer,filename);
|
||||
ptr = strrchr(buffer,'/');
|
||||
|
||||
|
||||
if(ptr != NULL) *ptr='\0';
|
||||
|
||||
if(buffer[0] == '\0')
|
||||
|
||||
if(buffer[0] == '\0')
|
||||
HText_appendText(HT,"/");
|
||||
else
|
||||
HText_appendText(HT, buffer);
|
||||
|
||||
|
||||
HText_appendText(HT,"\"><IMG SRC=\"");
|
||||
HText_appendText(HT, HTgeticonname(NULL, "directory"));
|
||||
HText_appendText(HT,"\"> Parent Directory</a>");
|
||||
}
|
||||
|
||||
|
||||
/* Loop until we hit EOF */
|
||||
while(1)
|
||||
{
|
||||
@ -1239,7 +1236,7 @@ char szTime[32];
|
||||
#endif
|
||||
return HT_INTERRUPTED;
|
||||
}
|
||||
|
||||
|
||||
if (c == '\r')
|
||||
{
|
||||
c = next_data_char ();
|
||||
@ -1247,29 +1244,29 @@ char szTime[32];
|
||||
{
|
||||
#ifndef DISABLE_TRACE
|
||||
if (www2Trace)
|
||||
fprintf
|
||||
fprintf
|
||||
(stderr, "FTP: Picked up interrupted_in_next_data_char\n");
|
||||
#endif
|
||||
return HT_INTERRUPTED;
|
||||
}
|
||||
|
||||
if (c != '\n')
|
||||
|
||||
if (c != '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '\n' || c == (char)EOF)
|
||||
|
||||
if (c == '\n' || c == (char)EOF)
|
||||
break;
|
||||
|
||||
|
||||
buffer[count] = c;
|
||||
}
|
||||
|
||||
if(c == (char)EOF)
|
||||
|
||||
if(c == (char)EOF)
|
||||
break;
|
||||
|
||||
|
||||
buffer[count] = 0;
|
||||
|
||||
|
||||
/* Parse the input buffer, extract the item type, and the item size */
|
||||
|
||||
|
||||
#if 0
|
||||
ret=sscanf(buffer,"%c%*9s%*d %*s %*s %s", &itemtype, itemsize);
|
||||
|
||||
@ -1310,9 +1307,7 @@ char szTime[32];
|
||||
}
|
||||
}
|
||||
|
||||
if (!buffer || !*buffer) {
|
||||
continue;
|
||||
}
|
||||
if (!*buffer) continue;
|
||||
|
||||
if (usingNLST==2) { /*only name*/
|
||||
strcpy(itemname,buffer);
|
||||
@ -1356,7 +1351,7 @@ char szTime[32];
|
||||
|
||||
HText_appendText (HT, "<A HREF=\"");
|
||||
/* Assuming it's a relative reference... */
|
||||
if (itemname && itemname[0] != '/')
|
||||
if (itemname[0] != '/')
|
||||
{
|
||||
HText_appendText (HT, filename);
|
||||
if (filename[strlen(filename)-1] != '/')
|
||||
@ -1439,9 +1434,9 @@ char szTime[32];
|
||||
sprintf(buffer,"<code>%s</code>",full_ftp_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
format = HTFileFormat(itemname, &pencoding, WWW_SOURCE, &cmpr);
|
||||
|
||||
|
||||
if (1)
|
||||
{
|
||||
HText_appendText(HT, "<IMG SRC=\"");
|
||||
@ -1450,9 +1445,9 @@ char szTime[32];
|
||||
kind of file it is by extension, throw up the unknown
|
||||
icon; however, if it isn't a link and we can't figure
|
||||
out what it is, throw up the text icon...
|
||||
|
||||
|
||||
Unless it's compressed. */
|
||||
if(itemtype == 'l' && cmpr == COMPRESSED_NOT)
|
||||
if(itemtype == 'l' && cmpr == COMPRESSED_NOT)
|
||||
{
|
||||
/* If it's unknown, let's call it a menu (since symlinks
|
||||
are most commonly used on FTP servers to point to
|
||||
@ -1463,7 +1458,7 @@ char szTime[32];
|
||||
{
|
||||
HText_appendText(HT, HTgeticonname(format, "text"));
|
||||
}
|
||||
|
||||
|
||||
HText_appendText(HT, "\"> ");
|
||||
}
|
||||
else
|
||||
@ -1484,7 +1479,6 @@ char szTime[32];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HText_appendText (HT, buffer);
|
||||
#ifndef NEW_PARSE
|
||||
HText_appendText (HT, "</A>\n");
|
||||
@ -1495,42 +1489,22 @@ char szTime[32];
|
||||
|
||||
nStringLen = strlen(buffer);
|
||||
nSpaces = ftpFilenameLength - nStringLen;
|
||||
/*
|
||||
if (itemtype != 'd') {
|
||||
*/
|
||||
|
||||
if (nTime == 1) {
|
||||
struct tm *ptr;
|
||||
time_t t;
|
||||
|
||||
t=time(0);
|
||||
ptr=localtime(&t);
|
||||
sprintf(szYear,"%d",1900+ptr->tm_year);
|
||||
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, szTime, szMonth, szDay, szYear);
|
||||
}
|
||||
else if (nTime == 0) {
|
||||
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, " ", szMonth, szDay, szYear);
|
||||
}
|
||||
else {
|
||||
/*nSpaces += strlen(itemsize); */
|
||||
sprintf(szDate, "%*s %9.9s %s %s", nSpaces, " ", itemsize, szMonth, szTime);
|
||||
}
|
||||
/*
|
||||
if (nTime == 1) {
|
||||
struct tm *ptr;
|
||||
time_t t;
|
||||
t=time(0);
|
||||
ptr=localtime(&t);
|
||||
sprintf(szYear,"%d",1900+ptr->tm_year);
|
||||
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, szTime, szMonth, szDay, szYear);
|
||||
}
|
||||
else if (nTime == 0) {
|
||||
sprintf(szDate, "%*s%9s %s %s %s %2.2s, %s", nSpaces, " ", itemsize, szFileInfo, " ", szMonth, szDay, szYear);
|
||||
}
|
||||
else {
|
||||
nOldSpaces = nSpaces;
|
||||
nSpaces += 22;
|
||||
if (nTime == 1) {
|
||||
sprintf(szDate, "%*s %s %s %2.2s", nSpaces, szFileInfo, szTime, szMonth, szDay);
|
||||
}
|
||||
else if (nTime == 0) {
|
||||
sprintf(szDate, "%*s %s %s %2.2s, %s", nSpaces, szFileInfo, "00:00", szMonth, szDay, szYear);
|
||||
}
|
||||
else {
|
||||
sprintf(szDate, "%*s %s %s", nOldSpaces, " ", szMonth, szTime);
|
||||
}
|
||||
/*nSpaces += strlen(itemsize); */
|
||||
sprintf(szDate, "%*s %9.9s %s %s", nSpaces, " ", itemsize, szMonth, szTime);
|
||||
}
|
||||
*/
|
||||
|
||||
if (usingNLST!=2) {
|
||||
HText_appendText (HT, szDate);
|
||||
@ -2070,7 +2044,7 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
|
||||
{
|
||||
char *curpath, *path;
|
||||
char command[ LINE_LENGTH+1];
|
||||
int status, method = 0;
|
||||
int status = 0;
|
||||
|
||||
HTProgress ("FTP mkdir in progress");
|
||||
if(fTimerStarted) {
|
||||
@ -2086,7 +2060,7 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
|
||||
return status;
|
||||
}
|
||||
|
||||
/* The remote directory name is in the url, so pull it out
|
||||
/* The remote directory name is in the url, so pull it out
|
||||
i.e. ftp://warez.yomama.com/pub/31337&warez_boy
|
||||
means to make the directory warez_boy at ftp://warez.yomama.com/pub/31337
|
||||
*/
|
||||
@ -2094,14 +2068,14 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
|
||||
close_master_socket ();
|
||||
CLOSE_CONTROL (control);
|
||||
control = -1;
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
*path = '\0'; /* Make the url normal */
|
||||
path++; /* Move to the dirname */
|
||||
/* *path is the directory name to create */
|
||||
|
||||
curpath = HTParse (name, "", PARSE_PATH+PARSE_PUNCTUATION);
|
||||
if (!curpath || !(*curpath))
|
||||
curpath = HTParse (name, "", PARSE_PATH+PARSE_PUNCTUATION);
|
||||
if (!curpath || !(*curpath))
|
||||
curpath = strdup ("/");
|
||||
/* *curpath is the remote directory in which to create *path */
|
||||
|
||||
@ -2112,7 +2086,7 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
|
||||
close_master_socket ();
|
||||
CLOSE_CONTROL (control);
|
||||
control = -1;
|
||||
if (status = HT_INTERRUPTED)
|
||||
if (status = HT_INTERRUPTED)
|
||||
HTProgress ("Connection interrupted");
|
||||
return (status==HT_INTERRUPTED)?-2:-1;
|
||||
}
|
||||
@ -2124,7 +2098,7 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
|
||||
close_master_socket ();
|
||||
CLOSE_CONTROL (control);
|
||||
control = -1;
|
||||
if (status = HT_INTERRUPTED)
|
||||
if (status = HT_INTERRUPTED)
|
||||
HTProgress ("Connection interrupted");
|
||||
return (status==HT_INTERRUPTED)?-2:-1;
|
||||
}
|
||||
@ -2145,7 +2119,7 @@ PUBLIC int HTFTPMkDir ARGS1 ( char *, name )
|
||||
*/
|
||||
PUBLIC int HTFTPRemove ARGS1 ( char *, name )
|
||||
{
|
||||
char *fname, *filename, *path;
|
||||
char *fname, *filename;
|
||||
char command[ LINE_LENGTH+1];
|
||||
int status, method = 0, didIt = 0;
|
||||
|
||||
@ -2165,7 +2139,7 @@ PUBLIC int HTFTPRemove ARGS1 ( char *, name )
|
||||
|
||||
/* Pull out the filename (and path) */
|
||||
fname = HTParse (name, "", PARSE_PATH+PARSE_PUNCTUATION);
|
||||
if(!(*fname))
|
||||
if(!(*fname))
|
||||
StrAllocCopy (filename, "/");
|
||||
|
||||
/* Pull out just the filename */
|
||||
@ -2182,7 +2156,7 @@ PUBLIC int HTFTPRemove ARGS1 ( char *, name )
|
||||
for (method =0; method < 2; method++ ) {
|
||||
switch (method) {
|
||||
|
||||
/* First, attempt to CWD to fname, if successful, fname is a directory.
|
||||
/* First, attempt to CWD to fname, if successful, fname is a directory.
|
||||
So, CDUP to get to the parent and call RMD on filename */
|
||||
case 0:
|
||||
sprintf (command, "CWD %s%c%c", fname, CR, LF);
|
||||
@ -2194,7 +2168,7 @@ PUBLIC int HTFTPRemove ARGS1 ( char *, name )
|
||||
close_master_socket ();
|
||||
CLOSE_CONTROL (control);
|
||||
control = -1;
|
||||
if (status == HT_INTERRUPTED)
|
||||
if (status == HT_INTERRUPTED)
|
||||
HTProgress ("Connection interrupted.");
|
||||
return (status == HT_INTERRUPTED)?-2:-1;
|
||||
}
|
||||
@ -2206,7 +2180,7 @@ PUBLIC int HTFTPRemove ARGS1 ( char *, name )
|
||||
close_master_socket ();
|
||||
CLOSE_CONTROL (control);
|
||||
control = -1;
|
||||
if (status == HT_INTERRUPTED)
|
||||
if (status == HT_INTERRUPTED)
|
||||
HTProgress ("Connection interrupted.");
|
||||
return (status == HT_INTERRUPTED)?-2:-1;
|
||||
}
|
||||
|
@ -355,7 +355,6 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
|
||||
if (binary_transfer)
|
||||
rename_binary_file (me->fnam);
|
||||
|
||||
really_done:
|
||||
free (me->fnam);
|
||||
if (me->mime_type) {
|
||||
free(me->mime_type);
|
||||
|
146
libwww2/HTFile.c
146
libwww2/HTFile.c
@ -116,23 +116,23 @@ PUBLIC void HTSetSuffix ARGS4(
|
||||
WWW_CONST char *, encoding,
|
||||
float, value)
|
||||
{
|
||||
|
||||
|
||||
HTSuffix * suff;
|
||||
|
||||
|
||||
if (strcmp(suffix, "*")==0) suff = &no_suffix;
|
||||
else if (strcmp(suffix, "*.*")==0) suff = &unknown_suffix;
|
||||
else {
|
||||
suff = (HTSuffix*) calloc(1, sizeof(HTSuffix));
|
||||
|
||||
if (suff == NULL) outofmem(__FILE__, "HTSetSuffix");
|
||||
|
||||
if (!HTSuffixes) HTSuffixes = HTList_new();
|
||||
HTList_addObject(HTSuffixes, suff);
|
||||
|
||||
|
||||
StrAllocCopy(suff->suffix, suffix);
|
||||
}
|
||||
|
||||
suff->rep = HTAtom_for(representation);
|
||||
|
||||
|
||||
{
|
||||
char *enc = NULL, *p;
|
||||
StrAllocCopy(enc, encoding);
|
||||
@ -140,7 +140,7 @@ PUBLIC void HTSetSuffix ARGS4(
|
||||
suff->encoding = HTAtom_for(enc);
|
||||
free (enc);
|
||||
}
|
||||
|
||||
|
||||
suff->quality = value;
|
||||
}
|
||||
|
||||
@ -165,10 +165,9 @@ PRIVATE char * vms_name(WWW_CONST char * nn, WWW_CONST char * fn)
|
||||
*/
|
||||
static char vmsname[INFINITY]; /* returned */
|
||||
char * filename = (char*)malloc(strlen(fn)+1);
|
||||
char * nodename = (char*)malloc(strlen(nn)+2+1); /* Copies to hack */
|
||||
char *second; /* 2nd slash */
|
||||
char *last; /* last slash */
|
||||
|
||||
|
||||
char * hostname = HTHostName();
|
||||
|
||||
if (!filename || !nodename) outofmem(__FILE__, "vms_name");
|
||||
@ -189,7 +188,7 @@ PRIVATE char * vms_name(WWW_CONST char * nn, WWW_CONST char * fn)
|
||||
|
||||
second = strchr(filename+1, '/'); /* 2nd slash */
|
||||
last = strrchr(filename, '/'); /* last slash */
|
||||
|
||||
|
||||
if (!second) { /* Only one slash */
|
||||
sprintf(vmsname, "%s%s", nodename, filename + 1);
|
||||
} else if(second==last) { /* Exactly two slashes */
|
||||
@ -215,56 +214,6 @@ PRIVATE char * vms_name(WWW_CONST char * nn, WWW_CONST char * fn)
|
||||
#endif /* vms */
|
||||
|
||||
|
||||
|
||||
/* Send README file
|
||||
**
|
||||
** If a README file exists, then it is inserted into the document here.
|
||||
*/
|
||||
|
||||
#ifdef GOT_READ_DIR
|
||||
PRIVATE void do_readme ARGS2(HTStructured *, target, WWW_CONST char *, localname)
|
||||
{
|
||||
FILE * fp;
|
||||
char * readme_file_name =
|
||||
malloc(strlen(localname)+ 1 + strlen(HT_DIR_README_FILE) + 1);
|
||||
strcpy(readme_file_name, localname);
|
||||
strcat(readme_file_name, "/");
|
||||
strcat(readme_file_name, HT_DIR_README_FILE);
|
||||
|
||||
fp = fopen(readme_file_name, "r");
|
||||
|
||||
if (fp) {
|
||||
HTStructuredClass targetClass;
|
||||
|
||||
targetClass = *target->isa; /* (Can't init agregate in K&R) */
|
||||
START(HTML_PRE);
|
||||
for(;;){
|
||||
char c = fgetc(fp);
|
||||
if (c == (char)EOF) break;
|
||||
switch (c) {
|
||||
case '&':
|
||||
case '<':
|
||||
case '>':
|
||||
PUTC('&');
|
||||
PUTC('#');
|
||||
PUTC((char)(c / 10));
|
||||
PUTC((char) (c % 10));
|
||||
PUTC(';');
|
||||
break;
|
||||
/* case '\n':
|
||||
PUTC('\r');
|
||||
Bug removed thanks to joe@athena.mit.edu */
|
||||
default:
|
||||
PUTC(c);
|
||||
}
|
||||
}
|
||||
END(HTML_PRE);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Make the cache file name for a W3 document
|
||||
** ------------------------------------------
|
||||
** Make up a suitable name for saving the node in
|
||||
@ -280,7 +229,7 @@ PUBLIC char * HTCacheFileName ARGS1(WWW_CONST char *,name)
|
||||
char * access = HTParse(name, "", PARSE_ACCESS);
|
||||
char * host = HTParse(name, "", PARSE_HOST);
|
||||
char * path = HTParse(name, "", PARSE_PATH+PARSE_PUNCTUATION);
|
||||
|
||||
|
||||
char * result;
|
||||
result = (char *)malloc(
|
||||
strlen(HTCacheRoot)+strlen(access)
|
||||
@ -314,14 +263,14 @@ PUBLIC char * HTLocalName ARGS1(WWW_CONST char *,name)
|
||||
char * access = HTParse(name, "", PARSE_ACCESS);
|
||||
char * host = HTParse(name, "", PARSE_HOST);
|
||||
char * path = HTParse(name, "", PARSE_PATH+PARSE_PUNCTUATION);
|
||||
|
||||
|
||||
HTUnEscape(path); /* Interpret % signs */
|
||||
|
||||
|
||||
if (0==strcmp(access, "file"))
|
||||
{
|
||||
free(access);
|
||||
free(access);
|
||||
if (!host || !*host || (0==my_strcasecmp(host, HTHostName())) ||
|
||||
(0==my_strcasecmp(host, "localhost")))
|
||||
(0==my_strcasecmp(host, "localhost")))
|
||||
{
|
||||
if (host)
|
||||
free(host);
|
||||
@ -867,7 +816,7 @@ PUBLIC void HTDirTitles ARGS2(HTStructured *, target,
|
||||
}
|
||||
free(path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Load a document
|
||||
@ -879,7 +828,7 @@ PUBLIC void HTDirTitles ARGS2(HTStructured *, target,
|
||||
**
|
||||
** On exit,
|
||||
** returns <0 Error has occured.
|
||||
** HTLOADED OK
|
||||
** HTLOADED OK
|
||||
**
|
||||
*/
|
||||
PUBLIC int HTLoadFile ARGS4 (
|
||||
@ -891,20 +840,25 @@ PUBLIC int HTLoadFile ARGS4 (
|
||||
{
|
||||
char * filename;
|
||||
HTFormat format;
|
||||
int fd = -1; /* Unix file descriptor number = INVALID */
|
||||
char * nodename = 0;
|
||||
char * newname=0; /* Simplified name of file */
|
||||
HTAtom * encoding; /* @@ not used yet */
|
||||
#ifdef vms
|
||||
char * nodename;
|
||||
int fd = -1; /* Unix file descriptor number = INVALID */
|
||||
#endif
|
||||
int compressed;
|
||||
extern char *HTgeticonname(HTFormat, char *);
|
||||
|
||||
|
||||
/* Reduce the filename to a basic form (hopefully unique!)
|
||||
*/
|
||||
StrAllocCopy(newname, addr);
|
||||
filename=HTParse(newname, "", PARSE_PATH|PARSE_PUNCTUATION);
|
||||
nodename=HTParse(newname, "", PARSE_HOST);
|
||||
#ifdef vms
|
||||
nodename=
|
||||
#endif
|
||||
HTParse(newname, "", PARSE_HOST);
|
||||
free(newname);
|
||||
|
||||
|
||||
format = HTFileFormat(filename, &encoding, WWW_PLAINTEXT, &compressed);
|
||||
|
||||
|
||||
@ -915,7 +869,7 @@ PUBLIC int HTLoadFile ARGS4 (
|
||||
char * vmsname = strchr(filename + 1, '/') ?
|
||||
vms_name(nodename, filename) : filename + 1;
|
||||
fd = open(vmsname, O_RDONLY, 0);
|
||||
|
||||
|
||||
/* If the file wasn't VMS syntax, then perhaps it is ultrix
|
||||
*/
|
||||
if (fd<0) {
|
||||
@ -936,7 +890,7 @@ PUBLIC int HTLoadFile ARGS4 (
|
||||
#else
|
||||
|
||||
free(filename);
|
||||
|
||||
|
||||
/* For unix, we try to translate the name into the name of a transparently
|
||||
** mounted file.
|
||||
**
|
||||
@ -944,14 +898,14 @@ PUBLIC int HTLoadFile ARGS4 (
|
||||
*/
|
||||
#ifndef NO_UNIX_IO
|
||||
/* Need protection here for telnet server but not httpd server */
|
||||
|
||||
|
||||
{ /* try local file system */
|
||||
char * localname = HTLocalName(addr);
|
||||
struct stat dir_info;
|
||||
|
||||
if (!localname)
|
||||
goto suicide;
|
||||
|
||||
|
||||
#ifdef GOT_READ_DIR
|
||||
|
||||
/* Multiformat handling
|
||||
@ -984,13 +938,12 @@ forget_multi:
|
||||
return HTLoadError(sink, 500,
|
||||
"Multiformat: directory scan failed.");
|
||||
}
|
||||
|
||||
while (dirbuf = readdir(dp)) {
|
||||
/* while there are directory entries to be read */
|
||||
if (dirbuf->d_ino == 0) continue;
|
||||
/* if the entry is not being used, skip it */
|
||||
|
||||
if (!strncmp(dirbuf->d_name, base, baselen)) {
|
||||
|
||||
if (!strncmp(dirbuf->d_name, base, baselen)) {
|
||||
HTFormat rep = HTFileFormat(dirbuf->d_name, &encoding,
|
||||
WWW_PLAINTEXT, &compressed);
|
||||
float value = HTStackValue(rep, format_out,
|
||||
@ -1007,19 +960,18 @@ forget_multi:
|
||||
best = value;
|
||||
best_dirbuf = *dirbuf;
|
||||
}
|
||||
} /* if best so far */
|
||||
} /* if match */
|
||||
|
||||
} /* if best so far */
|
||||
} /* if match */
|
||||
|
||||
} /* end while directory entries left to read */
|
||||
closedir(dp);
|
||||
|
||||
|
||||
if (best_rep) {
|
||||
format = best_rep;
|
||||
base[-1] = '/'; /* Restore directory name */
|
||||
base[0] = 0;
|
||||
StrAllocCat(localname, best_dirbuf.d_name);
|
||||
goto open_file;
|
||||
|
||||
} else { /* If not found suitable file */
|
||||
free(localname);
|
||||
return HTLoadError(sink, 403, /* List formats? */
|
||||
@ -1029,25 +981,25 @@ forget_multi:
|
||||
} /* if multi suffix */
|
||||
/*
|
||||
** Check to see if the 'localname' is in fact a directory. If it is
|
||||
** create a new hypertext object containing a list of files and
|
||||
** create a new hypertext object containing a list of files and
|
||||
** subdirectories contained in the directory. All of these are links
|
||||
** to the directories or files listed.
|
||||
** NB This assumes the existance of a type 'STRUCT_DIRENT', which will
|
||||
** hold the directory entry, and a type 'DIR' which is used to point to
|
||||
** the current directory being read.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
if (stat(localname,&dir_info) == -1) { /* get file information */
|
||||
/* if can't read file information */
|
||||
#ifndef DISABLE_TRACE
|
||||
if (www2Trace) fprintf(stderr, "HTFile: can't stat %s\n", localname);
|
||||
#endif
|
||||
} else { /* Stat was OK */
|
||||
|
||||
|
||||
|
||||
if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) {
|
||||
/* if localname is a directory */
|
||||
/* if localname is a directory */
|
||||
|
||||
/*
|
||||
**
|
||||
@ -1073,7 +1025,7 @@ forget_multi:
|
||||
|
||||
char filepath[MAXPATHLEN];
|
||||
char buffer[4096];
|
||||
|
||||
|
||||
char *ptr;
|
||||
char *dataptr;
|
||||
|
||||
@ -1091,7 +1043,7 @@ forget_multi:
|
||||
#ifndef DISABLE_TRACE
|
||||
if (www2Trace)
|
||||
fprintf(stderr,"%s is a directory\n",localname);
|
||||
#endif
|
||||
#endif
|
||||
/* Check directory access.
|
||||
** Selective access means only those directories containing a
|
||||
** marker file can be browsed
|
||||
@ -1104,7 +1056,7 @@ forget_multi:
|
||||
|
||||
|
||||
if (HTDirAccess == HT_DIR_SELECTIVE) {
|
||||
char * enable_file_name =
|
||||
char * enable_file_name =
|
||||
malloc(strlen(localname)+ 1 +
|
||||
strlen(HT_DIR_ENABLE_FILE) + 1);
|
||||
strcpy(enable_file_name, localname);
|
||||
@ -1117,7 +1069,7 @@ forget_multi:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
dfp = opendir(localname);
|
||||
if (!dfp) {
|
||||
free(localname);
|
||||
@ -1136,7 +1088,7 @@ forget_multi:
|
||||
return HTLoadError(sink, 403, "Ran out of memory in directory read!");
|
||||
}
|
||||
strcpy(ptr,dp->d_name);
|
||||
|
||||
|
||||
HTSortAdd(ptr);
|
||||
}
|
||||
|
||||
@ -1153,14 +1105,14 @@ forget_multi:
|
||||
HText_appendText(HT, "<H1>Local Directory ");
|
||||
HText_appendText(HT, localname);
|
||||
HText_appendText(HT, "</H1>\n");
|
||||
HText_appendText(HT,"<DL>\n");
|
||||
HText_appendText(HT,"<DL>\n");
|
||||
|
||||
/* Sort the list and then spit it out in a nice form */
|
||||
|
||||
/* How this for a disgusting loop :) */
|
||||
|
||||
for(count=0,dataptr=HTSortFetch(count);
|
||||
dataptr != NULL;
|
||||
for(count=0,dataptr=HTSortFetch(count);
|
||||
dataptr != NULL;
|
||||
free(dataptr), count++, dataptr=HTSortFetch(count))
|
||||
{
|
||||
|
||||
@ -1180,7 +1132,7 @@ forget_multi:
|
||||
|
||||
ptr = strrchr(buffer, '/');
|
||||
|
||||
if(ptr != NULL) *ptr='\0';
|
||||
if(ptr != NULL) *ptr='\0';
|
||||
|
||||
if(buffer[0] == '\0') strcpy(buffer,"/");
|
||||
|
||||
|
@ -91,7 +91,7 @@ PRIVATE BOOL acceptable_inited = NO;
|
||||
PRIVATE void init_acceptable NOARGS
|
||||
{
|
||||
unsigned int i;
|
||||
char * good =
|
||||
char * good =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./-_$";
|
||||
for(i=0; i<256; i++) acceptable[i] = NO;
|
||||
for(;*good; good++) acceptable[(unsigned int)*good] = YES;
|
||||
@ -100,18 +100,6 @@ PRIVATE void init_acceptable NOARGS
|
||||
|
||||
PRIVATE WWW_CONST char hex[17] = "0123456789abcdef";
|
||||
|
||||
/* Decode one hex character
|
||||
*/
|
||||
|
||||
PRIVATE char from_hex ARGS1(char, c)
|
||||
{
|
||||
return (c>='0')&&(c<='9') ? c-'0'
|
||||
: (c>='A')&&(c<='F') ? c-'A'+10
|
||||
: (c>='a')&&(c<='f') ? c-'a'+10
|
||||
: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Paste in an Anchor
|
||||
** ------------------
|
||||
@ -138,7 +126,7 @@ PRIVATE void write_anchor ARGS3(WWW_CONST char *,text, WWW_CONST char *,addr,
|
||||
PUTS (image_text);
|
||||
PUTS ("\"> ");
|
||||
}
|
||||
|
||||
|
||||
PUTS(text);
|
||||
PUTS("</A>");
|
||||
}
|
||||
@ -171,20 +159,19 @@ PRIVATE int parse_menu ARGS2 (
|
||||
char ch;
|
||||
char line[BIG];
|
||||
char address[BIG];
|
||||
char *name, *selector; /* Gopher menu fields */
|
||||
char *name, *selector = NULL; /* Gopher menu fields */
|
||||
char *host;
|
||||
char *port;
|
||||
char *p = line;
|
||||
extern int interrupted_in_htgetcharacter;
|
||||
WWW_CONST char *title;
|
||||
|
||||
|
||||
#define TAB '\t'
|
||||
#define HEX_ESCAPE '%'
|
||||
|
||||
HTProgress ("Retrieving Gopher menu.");
|
||||
|
||||
PUTS("<H1>Gopher Menu</H1>\n");
|
||||
|
||||
|
||||
START(HTML_DL);
|
||||
while ((ch=HTGetCharacter ()) != (char)EOF)
|
||||
{
|
||||
|
@ -31,10 +31,8 @@ struct _HTStructured
|
||||
|
||||
|
||||
/* Module-wide variables
|
||||
*/
|
||||
*/
|
||||
PRIVATE int s; /* Socket for FingerHost */
|
||||
PRIVATE HTStructured * target; /* The output sink */
|
||||
PRIVATE HTStructuredClass targetClass; /* Copy of fn addresses */
|
||||
|
||||
extern int GetMailtoKludgeInfo();
|
||||
|
||||
|
249
libwww2/HTNews.c
249
libwww2/HTNews.c
@ -246,13 +246,12 @@ PRIVATE BOOL match ARGS2 (WWW_CONST char *,unknown, WWW_CONST char *,template)
|
||||
Returns: pointer to em
|
||||
|
||||
Notes:
|
||||
Parse str for an email address and author name in the email@host (name)
|
||||
or name <email@host> forms. This destroys the source string. If
|
||||
Parse str for an email address and author name in the email@host (name)
|
||||
or name <email@host> forms. This destroys the source string. If
|
||||
either name of em is NULL, the value will not be returned.
|
||||
*/
|
||||
char *parseemail (char *str, char *name, char *em)
|
||||
{
|
||||
char *c, d;
|
||||
char *email, *end;
|
||||
|
||||
/* Pull out email address */
|
||||
@ -400,14 +399,13 @@ static char b64_tab[256] = {
|
||||
|
||||
int base64line(FILE *fp, char *buf)
|
||||
{
|
||||
int last_data = 0;
|
||||
unsigned char *p = (unsigned char *) buf;
|
||||
|
||||
if(!buf || !*buf || isspace(*buf)){
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* The following implementation of the base64 decoding might look
|
||||
a bit clumsy but I only try to follow the POSIX standard:
|
||||
``All line breaks or other characters not found in the table
|
||||
@ -416,35 +414,34 @@ int base64line(FILE *fp, char *buf)
|
||||
while (*p){
|
||||
char c1, c2, c3;
|
||||
|
||||
while ((b64_tab[*p] & '\100') != 0)
|
||||
while ((b64_tab[*p] & '\100') != 0)
|
||||
if (!*p || *p++ == '=') break;
|
||||
|
||||
|
||||
if (!*p) continue; /* This leaves the loop. */
|
||||
|
||||
|
||||
c1 = b64_tab[*p++];
|
||||
|
||||
|
||||
while ((b64_tab[*p] & '\100') != 0) {
|
||||
if (!*p || *p++ == '=') {
|
||||
HTProgress("illegal base64 line");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
c2 = b64_tab[*p++];
|
||||
|
||||
|
||||
while (b64_tab[*p] == '\177') {
|
||||
if (!*p++) {
|
||||
HTProgress("illegal base64 line");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (*p == '=') {
|
||||
fputc(c1 << 2 | c2 >> 4,fp);
|
||||
last_data = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
c3 = b64_tab[*p++];
|
||||
|
||||
while (b64_tab[*p] == '\177') {
|
||||
@ -453,7 +450,7 @@ int base64line(FILE *fp, char *buf)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fputc(c1 << 2 | c2 >> 4,fp);
|
||||
fputc(c2 << 4 | c3 >> 2,fp);
|
||||
if (*p == '=') {
|
||||
@ -464,7 +461,7 @@ int base64line(FILE *fp, char *buf)
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
@ -491,7 +488,7 @@ void freeart(NewsArt *art)
|
||||
PRIVATE void ClearArtList NOARGS
|
||||
{
|
||||
NewsArt *temp,*tnext,*temp2,*tnext2;
|
||||
|
||||
|
||||
temp = FirstArt;
|
||||
while(temp) {
|
||||
tnext = temp->nextt;
|
||||
@ -539,7 +536,7 @@ PRIVATE NewsArt *NewArt NOARGS
|
||||
}
|
||||
|
||||
/* AddArtTop ()
|
||||
Add an Article to the thread chain
|
||||
Add an Article to the thread chain
|
||||
*/
|
||||
PRIVATE void AddArtTop ARGS1(WWW_CONST NewsArt *, add)
|
||||
{
|
||||
@ -574,7 +571,7 @@ PRIVATE void AddArtTop ARGS1(WWW_CONST NewsArt *, add)
|
||||
add->prevt = add->nextt = NULL;
|
||||
add->next = NULL;
|
||||
add->prev = temp;
|
||||
|
||||
|
||||
temp->next = add;
|
||||
} else {
|
||||
/* Otherwise, tack it onto the back of the list */
|
||||
@ -846,12 +843,12 @@ PRIVATE int OpenNNTP NOARGS
|
||||
if ((response(NULL) / 100) !=2) {
|
||||
NETCLOSE(s);
|
||||
s = -1;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Interface with news-gui.c and various others... */
|
||||
@ -865,7 +862,7 @@ static char qline[LINE_LENGTH+1];
|
||||
char *NNTPgetquoteline(char *art)
|
||||
{
|
||||
char *p;
|
||||
int i,f,status ;
|
||||
int i,status;
|
||||
|
||||
if (!initialized)
|
||||
initialized = initialize();
|
||||
@ -876,7 +873,7 @@ char *NNTPgetquoteline(char *art)
|
||||
HTProgress ("Could not set up news connection.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if(s < 0) {
|
||||
HTProgress("Attempting to connect to news server");
|
||||
if(OpenNNTP()){
|
||||
@ -893,7 +890,7 @@ char *NNTPgetquoteline(char *art)
|
||||
HTInitInput(s);
|
||||
sprintf(qline, "BODY <%s>%c%c", art, CR, LF);
|
||||
status = response(qline);
|
||||
|
||||
|
||||
if (status != 222) return NULL;
|
||||
}
|
||||
|
||||
@ -957,9 +954,9 @@ int NNTPgetarthdrs(char *art,char **ref, char **grp, char **subj, char **from)
|
||||
HTInitInput(s);
|
||||
sprintf(buffer, "HEAD <%s>%c%c", art, CR, LF);
|
||||
status = response(buffer);
|
||||
|
||||
|
||||
if (status == 221) { /* Head follows - parse it:*/
|
||||
|
||||
|
||||
p = line; /* Write pointer */
|
||||
done = NO;
|
||||
while(!done){
|
||||
@ -968,27 +965,27 @@ int NNTPgetarthdrs(char *art,char **ref, char **grp, char **subj, char **from)
|
||||
abort_socket(); /* End of file, close socket */
|
||||
return -1; /* End of file on response */
|
||||
}
|
||||
|
||||
|
||||
if ((ch == LF)
|
||||
|| (p == &line[LINE_LENGTH]) ) {
|
||||
|
||||
|
||||
*--p=0; /* Terminate & chop LF*/
|
||||
p = line; /* Restart at beginning */
|
||||
#ifndef DISABLE_TRACE
|
||||
if (www2Trace) fprintf(stderr, "G %s\n", line);
|
||||
#endif
|
||||
switch(line[0]) {
|
||||
|
||||
|
||||
case '.':
|
||||
done = (line[1]<' '); /* End of article? */
|
||||
break;
|
||||
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
if (match(line, "SUBJECT:"))
|
||||
StrAllocCopy(*subj, line+9);/* Save subject */
|
||||
break;
|
||||
|
||||
|
||||
case 'R':
|
||||
case 'r':
|
||||
if (match(line, "REFERENCES:")) {
|
||||
@ -996,7 +993,7 @@ int NNTPgetarthdrs(char *art,char **ref, char **grp, char **subj, char **from)
|
||||
StrAllocCopy(*ref,p+1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'N':
|
||||
case 'n':
|
||||
if (match(line, "NEWSGROUPS:")) {
|
||||
@ -1004,7 +1001,7 @@ int NNTPgetarthdrs(char *art,char **ref, char **grp, char **subj, char **from)
|
||||
StrAllocCopy(*grp,p+1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'f':
|
||||
case 'F':
|
||||
if (match(line, "FROM:")) {
|
||||
@ -1020,9 +1017,9 @@ int NNTPgetarthdrs(char *art,char **ref, char **grp, char **subj, char **from)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
} /* end switch on first character */
|
||||
|
||||
|
||||
p = line; /* Restart at beginning */
|
||||
} /* if end of line */
|
||||
} /* Loop over characters */
|
||||
@ -1034,7 +1031,7 @@ int NNTPgetarthdrs(char *art,char **ref, char **grp, char **subj, char **from)
|
||||
int NNTPpost(char *from, char *subj, char *ref, char *groups, char *msg)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
||||
if (!initialized)
|
||||
initialized = initialize();
|
||||
if (!initialized){
|
||||
@ -1044,7 +1041,7 @@ int NNTPpost(char *from, char *subj, char *ref, char *groups, char *msg)
|
||||
HTProgress ("Could not set up news connection.");
|
||||
return HT_NOT_LOADED; /* FAIL */
|
||||
}
|
||||
|
||||
|
||||
if(s < 0) {
|
||||
HTProgress("Attempting to connect to news server");
|
||||
if(OpenNNTP()){
|
||||
@ -1055,7 +1052,7 @@ int NNTPpost(char *from, char *subj, char *ref, char *groups, char *msg)
|
||||
return HT_NOT_LOADED; /* FAIL */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(response("POST\r\n") != 340) {
|
||||
HTProgress("Server does not allow posting.");
|
||||
return 0;
|
||||
@ -1113,10 +1110,10 @@ NewsArt *is_news_url(char *s)
|
||||
/* These are called by their gui_news_* counterparts in gui-news.c */
|
||||
|
||||
/* Beginning in 2.7b4, these now return the next/prev unread article/thread ,
|
||||
unless newsShowAllArticles is True. The previous unread article/thread
|
||||
is set in the news_next functions.
|
||||
unless newsShowAllArticles is True. The previous unread article/thread
|
||||
is set in the news_next functions.
|
||||
|
||||
news_next will now continue onto the next thread unless newsNoThreadJumping
|
||||
news_next will now continue onto the next thread unless newsNoThreadJumping
|
||||
is True.
|
||||
*/
|
||||
|
||||
@ -1124,7 +1121,7 @@ NewsArt *nextUnreadThread (NewsArt *art);
|
||||
NewsArt *prevUnreadThread (NewsArt *art);
|
||||
|
||||
/* Return first unread article in list (thread) */
|
||||
NewsArt *firstUnread (NewsArt *art)
|
||||
NewsArt *firstUnread (NewsArt *art)
|
||||
{
|
||||
NewsArt *a;
|
||||
newsgroup_t *tempNewsGroupS = NULL;
|
||||
@ -1148,7 +1145,7 @@ NewsArt *firstUnread (NewsArt *art)
|
||||
|
||||
|
||||
/* return next unread article after art */
|
||||
NewsArt *nextUnread (NewsArt *art, int probe)
|
||||
NewsArt *nextUnread (NewsArt *art, int probe)
|
||||
{
|
||||
NewsArt *a;
|
||||
newsgroup_t *tempNewsGroupS = NULL;
|
||||
@ -1175,11 +1172,11 @@ NewsArt *nextUnread (NewsArt *art, int probe)
|
||||
}
|
||||
|
||||
/* Return first unread thread in list */
|
||||
NewsArt *firstUnreadThread (NewsArt *art)
|
||||
NewsArt *firstUnreadThread (NewsArt *art)
|
||||
{
|
||||
NewsArt *t, *a;
|
||||
|
||||
if (!art)
|
||||
if (!art)
|
||||
return NULL;
|
||||
|
||||
if (!newsUseNewsRC || newsShowAllArticles || !newsNextIsUnread)
|
||||
@ -1196,7 +1193,7 @@ NewsArt *firstUnreadThread (NewsArt *art)
|
||||
}
|
||||
|
||||
/* Return next unread thread in list */
|
||||
NewsArt *nextUnreadThread (NewsArt *art)
|
||||
NewsArt *nextUnreadThread (NewsArt *art)
|
||||
{
|
||||
NewsArt *t;
|
||||
|
||||
@ -1265,15 +1262,15 @@ NewsArt *prevUnreadThread (NewsArt *art)
|
||||
|
||||
/* Goto the previous (unread) thread */
|
||||
void news_prevt(char *url)
|
||||
{
|
||||
{
|
||||
NewsArt *art, *p;
|
||||
|
||||
|
||||
if (art = is_news_url (url)) {
|
||||
if ((p = prevUnreadThread (art)) != NULL) {
|
||||
sprintf (url, "news:%s", p->ID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
url[0] = 0;
|
||||
return;
|
||||
}
|
||||
@ -1282,7 +1279,7 @@ void news_prevt(char *url)
|
||||
void news_nextt(char *url)
|
||||
{
|
||||
NewsArt *art, *p;
|
||||
|
||||
|
||||
if ((art = is_news_url(url)) != NULL) {
|
||||
if ((p=nextUnreadThread (art))) {
|
||||
sprintf (url, "news:%s", p->ID);
|
||||
@ -1299,7 +1296,7 @@ void news_prev(char *url)
|
||||
{
|
||||
NewsArt *art, *p;
|
||||
|
||||
if ((art = is_news_url(url)) == NULL) {
|
||||
if ((art = is_news_url(url)) == NULL) {
|
||||
url[0] = 0;
|
||||
return;
|
||||
}
|
||||
@ -1347,24 +1344,24 @@ void news_index(char *url)
|
||||
/* Returns the status of the news buttons */
|
||||
void news_status(char *url, int *prevt, int *nextt, int *prev, int *next, int *follow)
|
||||
{
|
||||
NewsArt *art,*tmp;
|
||||
NewsArt *art;
|
||||
|
||||
if( art = is_news_url(url) ) {
|
||||
if(prevUnread(art,!newsNoThreadJumping))
|
||||
if(prevUnread(art,!newsNoThreadJumping))
|
||||
*prev = 1;
|
||||
else
|
||||
else
|
||||
*prev = 0;
|
||||
|
||||
if(prevUnreadThread(art))
|
||||
|
||||
if(prevUnreadThread(art))
|
||||
*prevt = 1;
|
||||
else
|
||||
*prevt = 0;
|
||||
|
||||
|
||||
if (nextUnread (art,!newsNoThreadJumping))
|
||||
*next = 1;
|
||||
else
|
||||
*next = 0;
|
||||
|
||||
|
||||
if (nextUnreadThread (art))
|
||||
*nextt = 1;
|
||||
else
|
||||
@ -1389,7 +1386,7 @@ void news_status(char *url, int *prevt, int *nextt, int *prev, int *next, int *f
|
||||
|
||||
Returns: pointer to a static spaces string, each call to make spaces will
|
||||
overwrite this buffer.
|
||||
|
||||
|
||||
Notes: this takes the string in str and makes a string of spaces that will
|
||||
(when concatenated with str) form a string len spaces long.
|
||||
*/
|
||||
@ -1435,21 +1432,21 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
char *references=NULL; /* Hrefs for other articles */
|
||||
char *newsgroups=NULL; /* Newsgroups list */
|
||||
char *from=NULL,*subj=NULL,*org=NULL,*date=NULL;
|
||||
char *filename;
|
||||
char *filename=NULL;
|
||||
char *l = line;
|
||||
int f; /* ':' flag */
|
||||
int decode=0; /*uudecoding...*/
|
||||
FILE *fp;
|
||||
|
||||
FILE *fp = NULL;
|
||||
|
||||
char *p = line,*pp,*m;
|
||||
BOOL done = NO;
|
||||
|
||||
NewsArt *art,*art2,*art_t, *next;
|
||||
NewsArt *art,*art2,*next;
|
||||
int ll;
|
||||
|
||||
|
||||
|
||||
HTMeter(0,NULL);
|
||||
|
||||
|
||||
ll= strlen(artID)-3; /* ">\n\r" should be stripped outside !!! */
|
||||
for(art = FirstArt; art; art = art -> nextt){
|
||||
if(!strncmp(art->ID,artID,ll)) break;
|
||||
@ -1462,16 +1459,16 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(art) {
|
||||
CurrentArt = art;
|
||||
} else {
|
||||
CurrentArt = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Read in the HEADer of the article:
|
||||
**
|
||||
** The header fields are either ignored, or formatted
|
||||
** The header fields are either ignored, or formatted
|
||||
** and put into the text.
|
||||
*/
|
||||
while(!done){
|
||||
@ -1480,7 +1477,7 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
abort_socket(); /* End of file, close socket */
|
||||
return; /* End of file on response */
|
||||
}
|
||||
if ((ch == LF) || (p == &line[LINE_LENGTH])) {
|
||||
if ((ch == LF) || (p == &line[LINE_LENGTH])) {
|
||||
*--p=0; /* Terminate the string */
|
||||
#ifndef DISABLE_TRACE
|
||||
if (www2Trace) fprintf(stderr, "H %s\n", line);
|
||||
@ -1529,16 +1526,16 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
references = strdup(&line[11]);
|
||||
break;
|
||||
default:
|
||||
|
||||
|
||||
/* unknown headers ignored */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
p = line; /* Restart at beginning */
|
||||
} /* if end of line */
|
||||
} /* Loop over characters */
|
||||
|
||||
|
||||
if(subj) {
|
||||
PUTS("<H2>");
|
||||
PUTS(subj);
|
||||
@ -1557,15 +1554,15 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
PUTS(", ");
|
||||
PUTS(org);
|
||||
free(org);
|
||||
}
|
||||
}
|
||||
PUTS("</I><BR>\n");
|
||||
}
|
||||
if(from) {
|
||||
PUTS("<B>From:</B> <I>");
|
||||
if (parseemail (from,duff,buf)) {
|
||||
sprintf (line, "<A HREF=\"mailto:%s\"> %s </A> ", buf, duff);
|
||||
sprintf (line, "<A HREF=\"mailto:%s\"> %s </A> ", buf, duff);
|
||||
PUTS (line);
|
||||
} else
|
||||
} else
|
||||
PUTS (from);
|
||||
PUTS("</I><BR>");
|
||||
free(from);
|
||||
@ -1592,7 +1589,7 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
PUTS(line);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!*p) break;
|
||||
@ -1601,18 +1598,18 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
free(references);
|
||||
PUTS("</I><BR>\n");
|
||||
}
|
||||
|
||||
|
||||
if(linecount) {
|
||||
lineinc = linecount/100;
|
||||
if(lineinc < 1) lineinc = 1;
|
||||
}
|
||||
|
||||
|
||||
PUTS("<HR>\n");
|
||||
|
||||
|
||||
/* Read in the BODY of the Article:
|
||||
*/
|
||||
(*targetClass.start_element)(target, HTML_PRE , 0, 0);
|
||||
|
||||
|
||||
p = line;
|
||||
done = 0;
|
||||
while(!done){
|
||||
@ -1808,15 +1805,15 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
#endif
|
||||
p = line; /* Restart at beginning */
|
||||
}
|
||||
|
||||
|
||||
} /* Loop over characters */
|
||||
|
||||
|
||||
(*targetClass.end_element)(target, HTML_PRE);
|
||||
|
||||
/* Mark this article read in all the groups we care about
|
||||
Also figure out the next article to read
|
||||
|
||||
/* Mark this article read in all the groups we care about
|
||||
Also figure out the next article to read
|
||||
*/
|
||||
|
||||
|
||||
if ((next = nextUnread (CurrentArt,0)) == NULL) {
|
||||
if ((next = nextUnreadThread (CurrentArt)) == NULL) {
|
||||
next = CurrentArt;
|
||||
@ -1828,7 +1825,7 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
|
||||
NextArt = next;
|
||||
if (CurrentArt) {
|
||||
char *tok, d, *last;
|
||||
char *tok;
|
||||
newsgroup_t *ng;
|
||||
|
||||
if (newsgroups) {
|
||||
@ -1840,12 +1837,12 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
tok = strtok (NULL, ", ;:\t\n");
|
||||
}
|
||||
} else if (NewsGroup) {
|
||||
if (ng = findgroup (NewsGroup)) {
|
||||
if (ng = findgroup (NewsGroup)) {
|
||||
markread (ng, CurrentArt->num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HTMeter(100,NULL);
|
||||
}
|
||||
|
||||
@ -1861,19 +1858,18 @@ PRIVATE void read_article ARGS1 (char *, artID)
|
||||
do not handle it here.
|
||||
2.7b4: Added support for newsrc and subscribed news.
|
||||
2.7b5: Made it faster.
|
||||
*/
|
||||
*/
|
||||
PRIVATE void read_list NOARGS
|
||||
{
|
||||
char line[LINE_LENGTH+1], group[LINE_LENGTH], elgroup[LINE_LENGTH],
|
||||
char line[LINE_LENGTH+1], group[LINE_LENGTH], elgroup[LINE_LENGTH],
|
||||
postable, *p;
|
||||
int first, last, junk, m=0, next_m=20, done=0, intr, g=0, next_g = 50, l=0, lastg=0,mark=0;
|
||||
int first, last, junk, m=0, next_m=20, done=0, intr, g=0, next_g = 50, l=0, lastg=0,mark=0;
|
||||
newsgroup_t *n=NULL, *nn=NULL;
|
||||
extern int twirl_increment;
|
||||
|
||||
START (HTML_TITLE);
|
||||
PUTS ("Newsgroup Listing");
|
||||
END (HTML_TITLE);
|
||||
|
||||
|
||||
HTMeter (0,NULL);
|
||||
HTProgress ("Getting newsgroup information from NNTP server");
|
||||
|
||||
@ -2111,20 +2107,18 @@ PRIVATE void XBuildArtList ARGS3(
|
||||
)
|
||||
{
|
||||
NewsArt *art;
|
||||
char *p,*aname=NULL, *author=NULL, *aref, abuf[1024+1];
|
||||
BOOL done;
|
||||
char *p,*aname=NULL, *aref, abuf[1024+1];
|
||||
|
||||
char *num,*title,*date,*msgid,*ref,*bytes,*lines,*from=NULL;
|
||||
|
||||
char buf[2048];
|
||||
|
||||
char *reference=0; /* Href for article */
|
||||
int status, count, first, last; /* Response fields */
|
||||
/* count is only an upper limit */
|
||||
int c,i,lineinc;
|
||||
int lineinc;
|
||||
|
||||
HTMeter(0,NULL);
|
||||
|
||||
|
||||
#ifndef DISABLE_TRACE
|
||||
if(www2Trace) fprintf(stderr,"[%s]\n",response_text);
|
||||
#endif
|
||||
@ -2250,12 +2244,11 @@ PRIVATE void BuildArtList ARGS3(
|
||||
)
|
||||
{
|
||||
NewsArt *art;
|
||||
char *p,*aname, *author, *aref, abuf[1024+1];
|
||||
BOOL done;
|
||||
char *p,*aname, *aref, abuf[1024+1];
|
||||
|
||||
char buffer[LINE_LENGTH];
|
||||
char line[LINE_LENGTH];
|
||||
char *reference=0; /* Href for article */
|
||||
int artno; /* Article number WITHIN GROUP */
|
||||
int status, count, first, last; /* Response fields */
|
||||
/* count is only an upper limit */
|
||||
@ -2266,6 +2259,7 @@ PRIVATE void BuildArtList ARGS3(
|
||||
if(www2Trace) fprintf(stderr,"[%s]",response_text);
|
||||
#endif
|
||||
sscanf(response_text, "%d %d %d %d", &status, &count, &first, &last);
|
||||
|
||||
#ifndef DISABLE_TRACE
|
||||
if(www2Trace) fprintf(stderr,"Newsgroup status=%d, count=%d, (%d-%d)",
|
||||
status, count, first, last);
|
||||
@ -2475,18 +2469,11 @@ PRIVATE void read_group ARGS3(
|
||||
)
|
||||
{
|
||||
NewsArt *art,*art2, *f;
|
||||
char *p;
|
||||
BOOL done;
|
||||
char buffer[LINE_LENGTH], subj[LINE_LENGTH];
|
||||
char line[LINE_LENGTH], from[LINE_LENGTH];
|
||||
char from[LINE_LENGTH];
|
||||
char efrom[LINE_LENGTH], esubj[LINE_LENGTH];
|
||||
char *reference=0;
|
||||
int i,artno, mark=0;
|
||||
int tc=0;
|
||||
int status, count; /* Response fields */
|
||||
/* count is only an upper limit */
|
||||
char em[255+1];
|
||||
|
||||
int i,mark=0;
|
||||
|
||||
if ((NewsGroupS = findgroup (groupName)) == NULL) {
|
||||
/* Add group unsub'd to hash table */
|
||||
if((NewsGroupS = addgroup (groupName, first, last, 1))==NULL) {
|
||||
@ -2605,7 +2592,7 @@ PUBLIC int HTLoadNews ARGS4(
|
||||
{
|
||||
char command[257]; /* The whole command */
|
||||
char groupName[GROUP_NAME_LENGTH]; /* Just the group name */
|
||||
char buf[LINE_LENGTH+1], *pt, *p1;
|
||||
char buf[LINE_LENGTH+1], *p1;
|
||||
int status; /* tcp return */
|
||||
int retries; /* A count of how hard we have tried */
|
||||
BOOL group_wanted; /* Flag: group was asked for, not article */
|
||||
@ -2652,16 +2639,18 @@ PUBLIC int HTLoadNews ARGS4(
|
||||
** xxx@yyy Article
|
||||
** <xxx@yyy> Same article
|
||||
** xxxxx News group (no "@")
|
||||
*/
|
||||
*/
|
||||
group_wanted = (strchr(arg, '@')==0) && (strchr(arg, '*')==0);
|
||||
list_wanted = (strchr(arg, '@')==0) && (strchr(arg, '*')!=0);
|
||||
|
||||
|
||||
/* Don't use HTParse because news: access doesn't follow traditional
|
||||
rules. For instance, if the article reference contains a '#',
|
||||
the rest of it is lost -- JFG 10/7/92, from a bug report
|
||||
the rest of it is lost -- JFG 10/7/92, from a bug report
|
||||
*/
|
||||
if (!my_strncasecmp (arg, "news:", 5))
|
||||
p1 = arg + 5; /* Skip "news:" prefix */
|
||||
else
|
||||
p1 = arg;
|
||||
if (group_wanted) {
|
||||
strcpy (command, "GROUP ");
|
||||
first = 0;
|
||||
@ -2670,37 +2659,37 @@ PUBLIC int HTLoadNews ARGS4(
|
||||
strcat (command, groupName);
|
||||
} else if (!list_wanted) {
|
||||
strcpy (command, "ARTICLE ");
|
||||
if (strchr(p1, '<')==0)
|
||||
if (strchr(p1, '<')==0)
|
||||
strcat(command,"<");
|
||||
strcat(command, p1);
|
||||
if (strchr(p1, '>')==0)
|
||||
if (strchr(p1, '>')==0)
|
||||
strcat(command,">");
|
||||
} else {
|
||||
command[0] = 0;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
char * p = command + strlen(command);
|
||||
*p++ = CR; /* Macros to be correct on Mac */
|
||||
*p++ = LF;
|
||||
*p++ = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!*arg) {
|
||||
HTProgress ("Could not load data.");
|
||||
return HT_NOT_LOADED; /* Ignore if no name */
|
||||
}
|
||||
|
||||
/* Make a hypertext object with an anchor list. */
|
||||
|
||||
/* Make a hypertext object with an anchor list. */
|
||||
node_anchor = anAnchor;
|
||||
target = HTML_new(anAnchor, format_out, stream);
|
||||
targetClass = *target->isa;
|
||||
|
||||
/* Now, let's get a stream setup up from the NewsHost: */
|
||||
targetClass = *target->isa;
|
||||
|
||||
/* Now, let's get a stream setup up from the NewsHost: */
|
||||
for (retries=0; retries<2; retries++) {
|
||||
target = HTML_new(anAnchor, format_out, stream);
|
||||
targetClass = *target->isa; /* Copy routine entry points */
|
||||
if (s < 0)
|
||||
if (s < 0)
|
||||
if(status = OpenNNTP()){
|
||||
char message[256];
|
||||
switch(status){
|
||||
@ -2724,21 +2713,21 @@ PUBLIC int HTLoadNews ARGS4(
|
||||
HTProgress ("Could not access news host.");
|
||||
sprintf(message,"\nCould not access news host %s. "
|
||||
"Try setting environment variable <code>NNTPSERVER</code> "
|
||||
"to the name of your news host, and restart Mosaic.",
|
||||
"to the name of your news host, and restart Mosaic.",
|
||||
HTNewsHost);
|
||||
|
||||
|
||||
PUTS(message);
|
||||
(*targetClass.end_document)(target);
|
||||
(*targetClass.free)(target);
|
||||
return HT_LOADED;
|
||||
case 3:
|
||||
HTProgress ("Connection interrupted.");
|
||||
(*targetClass.handle_interrupt)(target);
|
||||
|
||||
(*targetClass.handle_interrupt)(target);
|
||||
|
||||
return HT_INTERRUPTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = response("XOVER\r\n");
|
||||
if(status != 500)
|
||||
has_xover = 1;
|
||||
|
@ -115,8 +115,7 @@ PUBLIC int HTLoadHTTP ARGS4 (
|
||||
char crlf[3]; /* A CR LF equivalent string */
|
||||
HTStream *target; /* Unconverted data */
|
||||
HTFormat format_in; /* Format arriving in the message */
|
||||
|
||||
BOOL had_header; /* Have we had at least one header? */
|
||||
|
||||
char *line_buffer;
|
||||
char *line_kept_clean;
|
||||
BOOL extensions; /* Assume good HTTP server */
|
||||
@ -133,10 +132,6 @@ PUBLIC int HTLoadHTTP ARGS4 (
|
||||
|
||||
/*SWP*/
|
||||
int statusError=0;
|
||||
char tmpbuf[4096];
|
||||
|
||||
char *begin_ptr,*tmp_ptr;
|
||||
int env_length;
|
||||
|
||||
if (!arg)
|
||||
{
|
||||
@ -161,7 +156,6 @@ PUBLIC int HTLoadHTTP ARGS4 (
|
||||
so we can start over here... */
|
||||
eol = 0;
|
||||
bytes_already_read = 0;
|
||||
had_header = NO;
|
||||
length = 0;
|
||||
doing_redirect = 0;
|
||||
compressed = 0;
|
||||
@ -621,7 +615,6 @@ PUBLIC int HTLoadHTTP ARGS4 (
|
||||
{
|
||||
/* Get numeric status etc */
|
||||
BOOL end_of_file = NO;
|
||||
HTAtom * encoding = HTAtom_for("8bit");
|
||||
int buffer_length = INIT_LINE_SIZE;
|
||||
|
||||
line_buffer = (char *) malloc(buffer_length * sizeof(char));
|
||||
|
@ -226,8 +226,13 @@ customflags =
|
||||
# ---------------------- END OF CUSTOMIZABLE OPTIONS -------------------------
|
||||
|
||||
# Disable certain warnings as we don't care for them
|
||||
CWARNINGS = -Wno-parentheses -Wno-switch-enum
|
||||
CFLAGS = -g $(sysconfigflags) $(prereleaseflags) $(CWARNINGS)
|
||||
CWARNINGS = -Wall \
|
||||
-Wno-parentheses \
|
||||
-Wno-switch -Wno-switch-enum \
|
||||
-Wno-char-subscripts \
|
||||
-Wno-unused-result
|
||||
|
||||
CFLAGS = -g $(sysconfigflags) $(prereleaseflags) $(CWARNINGS) $(customflags)
|
||||
|
||||
# Don't worry about these -- for development purposes only.
|
||||
PURIFY = purify
|
||||
|
Loading…
Reference in New Issue
Block a user