diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1998-11-06 16:18:09 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1998-11-06 16:18:09 -0500 |
commit | 18024037b515bfff83e0230b35151babe6005e18 (patch) | |
tree | b8c80055282a00883284722a3dd6bb25234e07f0 /WWW/Library | |
parent | 3d8ecbe48af249fa0d77ce4d273e32ce4b7e6e18 (diff) | |
download | lynx-snapshots-18024037b515bfff83e0230b35151babe6005e18.tar.gz |
snapshot of project "lynx", label v2-8-1dev_4
Diffstat (limited to 'WWW/Library')
97 files changed, 4175 insertions, 2759 deletions
diff --git a/WWW/Library/Implementation/HTAABrow.c b/WWW/Library/Implementation/HTAABrow.c index f4a00dca..4082d96a 100644 --- a/WWW/Library/Implementation/HTAABrow.c +++ b/WWW/Library/Implementation/HTAABrow.c @@ -51,6 +51,7 @@ */ #include <HTUtils.h> +#include <string.h> /* strchr() */ #include <HTString.h> #include <HTParse.h> /* URL parsing function */ #include <HTList.h> /* HTList object */ @@ -340,29 +341,32 @@ PRIVATE HTAASetup *HTAASetup_lookup ARGS4( HTList *cur = server->setups; - CTRACE(tfp, "%s %s (%s:%d:%s)\n", - "HTAASetup_lookup: resolving setup for", - (IsProxy ? "proxy" : "server"), - hostname, portnumber, docname); + if (TRACE) + fprintf(stderr, "%s %s (%s:%d:%s)\n", + "HTAASetup_lookup: resolving setup for", + (IsProxy ? "proxy" : "server"), + hostname, portnumber, docname); while (NULL != (setup = (HTAASetup*)HTList_nextObject(cur))) { if (HTAA_templateMatch(setup->template, docname)) { - CTRACE(tfp, "%s `%s' %s `%s'\n", - "HTAASetup_lookup:", docname, - "matched template", setup->template); + if (TRACE) + fprintf(stderr, "%s `%s' %s `%s'\n", + "HTAASetup_lookup:", docname, + "matched template", setup->template); return setup; - } else { - CTRACE(tfp, "%s `%s' %s `%s'\n", - "HTAASetup_lookup:", docname, - "did NOT match template", setup->template); } + else if (TRACE) + fprintf(stderr, "%s `%s' %s `%s'\n", + "HTAASetup_lookup:", docname, + "did NOT match template", setup->template); } /* while setups remain */ } /* if valid parameters and server found */ - CTRACE(tfp, "%s `%s' %s\n", - "HTAASetup_lookup: No template matched", - (docname ? docname : "(null)"), - "(so probably not protected)"); + if (TRACE) + fprintf(stderr, "%s `%s' %s\n", + "HTAASetup_lookup: No template matched", + (docname ? docname : "(null)"), + "(so probably not protected)"); return NULL; /* NULL in parameters, or not found */ } @@ -599,11 +603,12 @@ PRIVATE char *compose_auth_string ARGS3( realm = HTAARealm_lookup(setup->server->realms, realmname); if (!(realm && realm->username && *realm->username && - realm->password) || setup->retry) { + realm->password && *realm->password) || setup->retry) { if (!realm) { - CTRACE(tfp, "%s `%s' %s\n", - "compose_auth_string: realm:", realmname, - "not found -- creating"); + if (TRACE) + fprintf(stderr, "%s `%s' %s\n", + "compose_auth_string: realm:", realmname, + "not found -- creating"); realm = HTAARealm_new(setup->server->realms, realmname, NULL, NULL); } @@ -670,7 +675,7 @@ PRIVATE char *compose_auth_string ARGS3( * Signals to retry. - FM */ return NULL; - } else if (*realm->username == '\0') { + } else if (*realm->username == '\0' || *realm->password == '\0') { /* * Signals to abort. - FM */ @@ -855,8 +860,9 @@ PUBLIC char *HTAA_composeAuth ARGS4( ** on server-side. Life is hard.) */ if (HTAAForwardAuth) { - CTRACE(tfp, "HTAA_composeAuth: %s\n", - "Forwarding received authorization"); + if (TRACE) + fprintf(stderr, "HTAA_composeAuth: %s\n", + "Forwarding received authorization"); StrAllocCopy(HTAA_composeAuthResult, HTAAForwardAuth); HTAAForwardAuth_reset(); /* Just a precaution */ return HTAA_composeAuthResult; @@ -869,7 +875,9 @@ PUBLIC char *HTAA_composeAuth ARGS4( ** Proxy Authorization required. - AJL */ - CTRACE(tfp, "Composing Proxy Authorization for %s:%d/%s\n", + if (TRACE) + fprintf(stderr, + "Composing Proxy Authorization for %s:%d/%s\n", hostname, portnumber, docname); if (proxy_portnumber != portnumber || @@ -944,7 +952,9 @@ PUBLIC char *HTAA_composeAuth ARGS4( /* ** Normal WWW authorization. */ - CTRACE(tfp, "Composing Authorization for %s:%d/%s\n", + if (TRACE) + fprintf(stderr, + "Composing Authorization for %s:%d/%s\n", hostname, portnumber, docname); if (current_portnumber != portnumber || @@ -1051,9 +1061,10 @@ PUBLIC char *HTAA_composeAuth ARGS4( ** field (in function HTAA_composeAuth()). ** NO, otherwise. */ -PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4( +PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS5( char *, start_of_headers, int, length, + void *, handle, int, soc, BOOL, IsProxy) { @@ -1076,11 +1087,13 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4( /* ** Read server reply header lines */ - CTRACE(tfp, "Server reply header lines:\n"); + if (TRACE) + fprintf(stderr, "Server reply header lines:\n"); - HTAA_setupReader(start_of_headers, length, soc); + HTAA_setupReader(start_of_headers, length, handle, soc); while (NULL != (line = HTAA_getUnfoldedLine()) && *line != '\0') { - CTRACE(tfp, "%s\n", line); + if (TRACE) + fprintf(stderr, "%s\n", line); if (strchr(line, ':')) { /* Valid header line */ @@ -1120,8 +1133,9 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4( } scheme_specifics[scheme] = HTAA_parseArgList(args); num_schemes++; - } else { - CTRACE(tfp, "Unknown scheme `%s' %s\n", + } + else if (TRACE) { + fprintf(stderr, "Unknown scheme `%s' %s\n", (arg1 ? arg1 : "(null)"), (IsProxy ? "in Proxy-Authenticate: field" : @@ -1131,13 +1145,14 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4( else if (!IsProxy && 0==strcasecomp(fieldname, "WWW-Protection-Template:")) { - CTRACE(tfp, "Protection template set to `%s'\n", arg1); + if (TRACE) + fprintf(stderr, "Protection template set to `%s'\n", arg1); StrAllocCopy(template, arg1); } } /* if a valid header line */ - else { - CTRACE(tfp, "Invalid header line `%s' ignored\n", line); + else if (TRACE) { + fprintf(stderr, "Invalid header line `%s' ignored\n", line); } /* else invalid header line */ FREE(line); diff --git a/WWW/Library/Implementation/HTAABrow.h b/WWW/Library/Implementation/HTAABrow.h index 49351cd2..9512603a 100644 --- a/WWW/Library/Implementation/HTAABrow.h +++ b/WWW/Library/Implementation/HTAABrow.h @@ -31,8 +31,12 @@ #ifndef HTAABROW_H #define HTAABROW_H +#ifndef HTUTILS_H +#include <HTUtils.h> /* BOOL, PARAMS, ARGS */ +#endif /* HTUTILS_H */ #include <HTAAUtil.h> /* Common parts of AA */ + #ifdef SHORT_NAMES #define HTAAcoAu HTAA_composeAuth #define HTAAsRWA HTAA_shouldRetryWithAuth @@ -111,6 +115,7 @@ extern char *HTAA_composeAuth PARAMS(( extern BOOL HTAA_shouldRetryWithAuth PARAMS(( char * start_of_headers, int length, + void * handle, int soc, BOOL IsProxy)); diff --git a/WWW/Library/Implementation/HTAAFile.c b/WWW/Library/Implementation/HTAAFile.c index 82da7af9..96b07faa 100644 --- a/WWW/Library/Implementation/HTAAFile.c +++ b/WWW/Library/Implementation/HTAAFile.c @@ -1,3 +1,4 @@ + /* MODULE HTAAFile.c ** FILE ROUTINES FOR AUTHENTICATION ** (PASSWD AND GROUP FILES) AND @@ -13,8 +14,14 @@ ** */ + +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ +#include <tcp.h> /* Macro FROMASCII() */ +/*#include <stdio.h> included by HTUtils.h -- FM *//* FILE */ +#include <string.h> #include <HTAAUtil.h> /* Common utilities used in AA */ #include <HTAAFile.h> /* Implemented here */ diff --git a/WWW/Library/Implementation/HTAAFile.h b/WWW/Library/Implementation/HTAAFile.h index 8986b593..e20735c7 100644 --- a/WWW/Library/Implementation/HTAAFile.h +++ b/WWW/Library/Implementation/HTAAFile.h @@ -15,6 +15,10 @@ #ifndef HTAAFILE_H #define HTAAFILE_H +#ifndef HTUTILS_H +#include <HTUtils.h> /* BOOL, PARAMS, ARGS */ +#endif /* HTUTILS_H */ +/*#include <stdio.h> included by HTUtils.h -- FM *//* FILE */ #include <HTList.h> /* HTList */ #ifdef SHORT_NAMES diff --git a/WWW/Library/Implementation/HTAAProt.c b/WWW/Library/Implementation/HTAAProt.c index 773474a9..6bf8ab3f 100644 --- a/WWW/Library/Implementation/HTAAProt.c +++ b/WWW/Library/Implementation/HTAAProt.c @@ -19,6 +19,7 @@ #include <HTUtils.h> +#include <string.h> #ifndef VMS #ifndef NOUSERS #include <pwd.h> /* Unix password file routine: getpwnam() */ @@ -124,21 +125,22 @@ PUBLIC int HTAA_getUid NOARGS if (current_prot && current_prot->uid_name) { if (isNumber(current_prot->uid_name)) { if (NULL != (pw = getpwuid(atoi(current_prot->uid_name)))) { - CTRACE(tfp, "%s(%s) returned (%s:%s:%d:%d:...)\n", - "HTAA_getUid: getpwuid", - current_prot->uid_name, - pw->pw_name, pw->pw_passwd, - (int) pw->pw_uid, (int) pw->pw_gid); + if (TRACE) fprintf(stderr, + "%s(%s) returned (%s:%s:%d:%d:...)\n", + "HTAA_getUid: getpwuid", + current_prot->uid_name, + pw->pw_name, pw->pw_passwd, + pw->pw_uid, pw->pw_gid); return pw->pw_uid; } } else { /* User name (not a number) */ if (NULL != (pw = getpwnam(current_prot->uid_name))) { - CTRACE(tfp, "%s(\"%s\") %s (%s:%s:%d:%d:...)\n", - "HTAA_getUid: getpwnam", - current_prot->uid_name, "returned", - pw->pw_name, pw->pw_passwd, - (int) pw->pw_uid, (int) pw->pw_gid); + if (TRACE) fprintf(stderr, "%s(\"%s\") %s (%s:%s:%d:%d:...)\n", + "HTAA_getUid: getpwnam", + current_prot->uid_name, "returned", + pw->pw_name, pw->pw_passwd, + pw->pw_uid, pw->pw_gid); return pw->pw_uid; } } @@ -147,8 +149,8 @@ PUBLIC int HTAA_getUid NOARGS ** Ok, then let's get uid for nobody. */ if (NULL != (pw = getpwnam("nobody"))) { - CTRACE(tfp, "HTAA_getUid: Uid for `nobody' is %d\n", - (int) pw->pw_uid); + if (TRACE) fprintf(stderr, "HTAA_getUid: Uid for `nobody' is %d\n", + pw->pw_uid); return pw->pw_uid; } /* @@ -175,10 +177,11 @@ PUBLIC int HTAA_getGid NOARGS if (isNumber(current_prot->gid_name)) { if (NULL != (gr = getgrgid(atoi(current_prot->gid_name)))) { #ifndef __EMX__ /* no gr_passwd */ - CTRACE(tfp, "%s(%s) returned (%s:%s:%d:...)\n", - "HTAA_getGid: getgrgid", - current_prot->gid_name, - gr->gr_name, gr->gr_passwd, (int) gr->gr_gid); + if (TRACE) fprintf(stderr, + "%s(%s) returned (%s:%s:%d:...)\n", + "HTAA_getGid: getgrgid", + current_prot->gid_name, + gr->gr_name, gr->gr_passwd, gr->gr_gid); #endif return gr->gr_gid; } @@ -186,10 +189,11 @@ PUBLIC int HTAA_getGid NOARGS else { /* Group name (not number) */ if (NULL != (gr = getgrnam(current_prot->gid_name))) { #ifndef __EMX__ /* no gr_passwd */ - CTRACE(tfp, "%s(\"%s\") returned (%s:%s:%d:...)\n", - "HTAA_getGid: getgrnam", - current_prot->gid_name, - gr->gr_name, gr->gr_passwd, (int) gr->gr_gid); + if (TRACE) fprintf(stderr, + "%s(\"%s\") returned (%s:%s:%d:...)\n", + "HTAA_getGid: getgrnam", + current_prot->gid_name, + gr->gr_name, gr->gr_passwd, gr->gr_gid); #endif return gr->gr_gid; } @@ -199,8 +203,8 @@ PUBLIC int HTAA_getGid NOARGS ** Ok, then let's get gid for nogroup. */ if (NULL != (gr = getgrnam("nogroup"))) { - CTRACE(tfp, "HTAA_getGid: Gid for `nogroup' is %d\n", - (int) gr->gr_gid); + if (TRACE) fprintf(stderr, "HTAA_getGid: Gid for `nogroup' is %d\n", + gr->gr_gid); return gr->gr_gid; } /* @@ -290,16 +294,15 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot, if (!prot->valid_schemes) prot->valid_schemes = HTList_new(); HTList_addObject(prot->valid_schemes,(void*)scheme); - CTRACE(tfp, "%s %s `%s'\n", - "HTAA_parseProtFile: valid", - "authentication scheme:", - HTAAScheme_name(scheme)); - } else { - CTRACE(tfp, "%s %s `%s'\n", - "HTAA_parseProtFile: unknown", - "authentication scheme:", - HTlex_buffer); + if (TRACE) fprintf(stderr, "%s %s `%s'\n", + "HTAA_parseProtFile: valid", + "authentication scheme:", + HTAAScheme_name(scheme)); } + else if (TRACE) fprintf(stderr, "%s %s `%s'\n", + "HTAA_parseProtFile: unknown", + "authentication scheme:", + HTlex_buffer); if (LEX_ITEM_SEP != (lex_item = lex(fp))) break; @@ -319,10 +322,10 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot, lex_item=LEX_REC_SEP; /*groupdef parser read this already*/ if (TRACE) { if (prot->mask_group) { - fprintf(tfp, + fprintf(stderr, "HTAA_parseProtFile: Mask group:\n"); HTAA_printGroupDef(prot->mask_group); - } else fprintf(tfp, "HTAA_parseProtFile: %s\n", + } else fprintf(stderr, "HTAA_parseProtFile: %s\n", "Mask group syntax error"); } } /* if "Mask" */ @@ -334,19 +337,20 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot, prot->values = HTAssocList_new(); HTAssocList_add(prot->values, fieldname, HTlex_buffer); lex_item = lex(fp); /* Read record separator */ - CTRACE(tfp, "%s `%s' bound to value `%s'\n", - "HTAA_parseProtFile: Name", - fieldname, HTlex_buffer); + if (TRACE) fprintf(stderr, + "%s `%s' bound to value `%s'\n", + "HTAA_parseProtFile: Name", + fieldname, HTlex_buffer); } } /* else name-value pair */ } /* if valid field */ if (lex_item != LEX_EOF && lex_item != LEX_REC_SEP) { - CTRACE(tfp, "%s %s %d (that line ignored)\n", - "HTAA_parseProtFile: Syntax error", - "in protection setup file at line", - HTlex_line); + if (TRACE) fprintf(stderr, "%s %s %d (that line ignored)\n", + "HTAA_parseProtFile: Syntax error", + "in protection setup file at line", + HTlex_line); do { lex_item = lex(fp); } while (lex_item != LEX_EOF && lex_item != LEX_REC_SEP); @@ -401,11 +405,12 @@ PRIVATE HTAAProt *HTAAProt_new ARGS3(CONST char *, cur_docname, } if (cache_item) { prot = cache_item->prot; - CTRACE(tfp, "%s `%s' already in cache\n", - "HTAAProt_new: Protection file", prot_filename); + if (TRACE) fprintf(stderr, "%s `%s' already in cache\n", + "HTAAProt_new: Protection file", prot_filename); } else { - CTRACE(tfp, "HTAAProt_new: Loading protection file `%s'\n", - prot_filename); + if (TRACE) fprintf(stderr, + "HTAAProt_new: Loading protection file `%s'\n", + prot_filename); if (!(prot = (HTAAProt*)calloc(1, sizeof(HTAAProt)))) outofmem(__FILE__, "HTAAProt_new"); @@ -428,11 +433,10 @@ PRIVATE HTAAProt *HTAAProt_new ARGS3(CONST char *, cur_docname, cache_item->prot_filename = NULL; StrAllocCopy(cache_item->prot_filename, prot_filename); HTList_addObject(prot_cache, (void*)cache_item); - } else { - CTRACE(tfp, "HTAAProt_new: %s `%s'\n", - "Unable to open protection setup file", - (prot_filename ? prot_filename : "(null)")); } + else if (TRACE) fprintf(stderr, "HTAAProt_new: %s `%s'\n", + "Unable to open protection setup file", + (prot_filename ? prot_filename : "(null)")); } if (cur_docname) @@ -471,9 +475,9 @@ PUBLIC void HTAA_setDefaultProtection ARGS3(CONST char *, cur_docname, if (prot_filename) { default_prot = HTAAProt_new(cur_docname, prot_filename, ids); } else { - CTRACE(tfp, "%s %s\n", - "HTAA_setDefaultProtection: ERROR: Protection file", - "not specified (obligatory for DefProt rule)!!\n"); + if (TRACE) fprintf(stderr, "%s %s\n", + "HTAA_setDefaultProtection: ERROR: Protection file", + "not specified (obligatory for DefProt rule)!!\n"); } } @@ -509,15 +513,15 @@ PUBLIC void HTAA_setCurrentProtection ARGS3(CONST char *, cur_docname, if (default_prot) { current_prot = default_prot; HTAA_setIds(current_prot, ids); - CTRACE(tfp, "%s %s %s\n", - "HTAA_setCurrentProtection: Protection file", - "not specified for Protect rule", - "-- using default protection"); + if (TRACE) fprintf(stderr, "%s %s %s\n", + "HTAA_setCurrentProtection: Protection file", + "not specified for Protect rule", + "-- using default protection"); } else { - CTRACE(tfp, "%s %s %s\n", - "HTAA_setCurrentProtection: ERROR: Protection", - "file not specified for Protect rule, and", - "default protection is not set!!"); + if (TRACE) fprintf(stderr, "%s %s %s\n", + "HTAA_setCurrentProtection: ERROR: Protection", + "file not specified for Protect rule, and", + "default protection is not set!!"); } } } diff --git a/WWW/Library/Implementation/HTAAProt.h b/WWW/Library/Implementation/HTAAProt.h index ed36f656..b4d00f49 100644 --- a/WWW/Library/Implementation/HTAAProt.h +++ b/WWW/Library/Implementation/HTAAProt.h @@ -5,6 +5,9 @@ #ifndef HTAAPROT_H #define HTAAPROT_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTGroup.h> #include <HTAssoc.h> diff --git a/WWW/Library/Implementation/HTAAServ.c b/WWW/Library/Implementation/HTAAServ.c index c081a3fa..98779830 100644 --- a/WWW/Library/Implementation/HTAAServ.c +++ b/WWW/Library/Implementation/HTAAServ.c @@ -43,6 +43,9 @@ #include <HTUtils.h> +/*#include <stdio.h> included by HTUtils.h -- FM *//* FILE */ +#include <string.h> /* strchr() */ + #include <HTString.h> #include <HTAccess.h> /* HTSecure */ #include <HTFile.h> /* HTLocalName */ @@ -89,34 +92,45 @@ PUBLIC char *HTAA_statusMessage NOARGS /* 401 cases */ case HTAA_NO_AUTH: return "Unauthorized -- authentication failed"; + break; case HTAA_NOT_MEMBER: return "Unauthorized to access the document"; + break; /* 403 cases */ case HTAA_BY_RULE: return "Forbidden -- by rule"; + break; case HTAA_IP_MASK: return "Forbidden -- server refuses to serve to your IP address"; + break; case HTAA_NO_ACL: case HTAA_NO_ENTRY: return "Forbidden -- access to file is never allowed"; + break; case HTAA_SETUP_ERROR: return "Forbidden -- server protection setup error"; + break; case HTAA_DOTDOT: return "Forbidden -- URL containing /../ disallowed"; + break; case HTAA_HTBIN: return "Forbidden -- /htbin feature not enabled on this server"; + break; /* 404 cases */ case HTAA_NOT_FOUND: return "Not found -- file doesn't exist or is read protected"; + break; /* Success */ case HTAA_OK: return "AA: Access should be ok but something went wrong"; + break; case HTAA_OK_GATEWAY: return "AA check bypassed (gatewaying) but something went wrong"; + break; /* Others */ default: @@ -133,34 +147,46 @@ PRIVATE char *status_name ARGS1(HTAAFailReasonType, reason) /* 401 cases */ case HTAA_NO_AUTH: return "NO-AUTHENTICATION"; + break; case HTAA_NOT_MEMBER: return "NOT-AUTHORIZED"; + break; /* 403 cases */ case HTAA_BY_RULE: return "FORB-RULE"; + break; case HTAA_IP_MASK: return "FORB-IP"; + break; case HTAA_NO_ACL: return "NO-ACL-FILE"; + break; case HTAA_NO_ENTRY: return "NO-ACL-ENTRY"; + break; case HTAA_SETUP_ERROR: return "SETUP-ERROR"; + break; case HTAA_DOTDOT: return "SLASH-DOT-DOT"; + break; case HTAA_HTBIN: return "HTBIN-OFF"; + break; /* 404 cases */ case HTAA_NOT_FOUND: return "NOT-FOUND"; + break; /* Success */ case HTAA_OK: return "OK"; + break; case HTAA_OK_GATEWAY: return "OK-GATEWAY"; + break; /* Others */ default: @@ -203,12 +229,14 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, htaa_user = NULL; if (!pathname) { - CTRACE(tfp, "HTAA_checkAuthorization: Forbidden by rule\n"); + if (TRACE) + fprintf(stderr, "HTAA_checkAuthorization: Forbidden by rule\n"); return HTAA_BY_RULE; } - CTRACE(tfp, "%s `%s' %s %s\n", - "HTAA_checkAuthorization: translated path:", - pathname, "method:", HTAAMethod_name(method)); + if (TRACE) + fprintf(stderr, "%s `%s' %s %s\n", + "HTAA_checkAuthorization: translated path:", + pathname, "method:", HTAAMethod_name(method)); /* ** Get protection setting (set up by callbacks from rule system) @@ -235,9 +263,10 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, htaa_user = HTAA_authenticate(scheme, scheme_specifics, prot); - CTRACE(tfp, "Authentication returned: %s\n", - (htaa_user ? htaa_user->username - : "NOT-AUTHENTICATED")); + if (TRACE) + fprintf(stderr, "Authentication returned: %s\n", + (htaa_user ? htaa_user->username + : "NOT-AUTHENTICATED")); } HTAA_resolveGroupReferences(prot->mask_group, group_def_list); reason = HTAA_userAndInetInGroup(prot->mask_group, @@ -245,13 +274,14 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, ? htaa_user->username : "", HTClientHost, NULL); - if (reason != HTAA_OK) { - CTRACE(tfp, "%s %s %s %s\n", + if (TRACE) { + if (reason != HTAA_OK) + fprintf(stderr, "%s %s %s %s\n", "HTAA_checkAuthorization: access denied", "by mask (no ACL, only Protect rule)", "host", HTClientHost); - } else { - CTRACE(tfp, "%s %s %s %s\n", + else + fprintf(stderr, "%s %s %s %s\n", "HTAA_checkAuthorization: request from", HTClientHost, "accepted by only mask match (no ACL, only", @@ -260,15 +290,17 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, return reason; } else { /* 403 Forbidden */ - CTRACE(tfp, "%s %s\n", - "HTAA_checkAuthorization: Protected, but", - "no mask group nor ACL -- forbidden"); + if (TRACE) + fprintf(stderr, "%s %s\n", + "HTAA_checkAuthorization: Protected, but", + "no mask group nor ACL -- forbidden"); return HTAA_NO_ACL; } } else { /* No protect rule and no ACL => OK 200 */ - CTRACE(tfp, "HTAA_checkAuthorization: %s\n", - "no protect rule nor ACL -- ok\n"); + if (TRACE) + fprintf(stderr, "HTAA_checkAuthorization: %s\n", + "no protect rule nor ACL -- ok\n"); return HTAA_OK; } } @@ -277,13 +309,15 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, ** Now we know that ACL exists */ if (!prot) { /* Not protected by "protect" rule */ - CTRACE(tfp, "HTAA_checkAuthorization: default protection\n"); + if (TRACE) + fprintf(stderr, "HTAA_checkAuthorization: default protection\n"); prot = HTAA_getDefaultProtection(); /* Also sets current protection */ if (!prot) { /* @@ Default protection not set ?? */ - CTRACE(tfp, "%s %s\n", - "HTAA_checkAuthorization: default protection", - "not set (internal server error)!!"); + if (TRACE) + fprintf(stderr, "%s %s\n", + "HTAA_checkAuthorization: default protection", + "not set (internal server error)!!"); return HTAA_SETUP_ERROR; } } @@ -303,9 +337,10 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, htaa_user = HTAA_authenticate(scheme, scheme_specifics, prot); - CTRACE(tfp, "Authentication returned: %s\n", - (htaa_user - ? htaa_user->username : "NOT-AUTHENTICATED")); + if (TRACE) + fprintf(stderr, "Authentication returned: %s\n", + (htaa_user + ? htaa_user->username : "NOT-AUTHENTICATED")); } /* ** Check mask group @@ -317,18 +352,20 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, HTClientHost, NULL); if (reason != HTAA_OK) { - CTRACE(tfp, "%s %s %s\n", - "HTAA_checkAuthorization: access denied", - "by mask, host:", HTClientHost); + if (TRACE) + fprintf(stderr, "%s %s %s\n", + "HTAA_checkAuthorization: access denied", + "by mask, host:", HTClientHost); return reason; } else { - CTRACE(tfp, "%s %s %s %s %s\n", - "HTAA_checkAuthorization: request from", - HTClientHost, - "accepted by just mask group match", - "(no ACL, only Protect rule, and only", - "mask enabled)"); + if (TRACE) + fprintf(stderr, "%s %s %s %s %s\n", + "HTAA_checkAuthorization: request from", + HTClientHost, + "accepted by just mask group match", + "(no ACL, only Protect rule, and only", + "mask enabled)"); /* And continue authorization checking */ } } @@ -339,8 +376,9 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *, pathname, */ allowed_groups = HTAA_getAclEntry(acl_file, pathname, method); if (!allowed_groups) { - CTRACE(tfp, "%s `%s' %s\n", - "No entry for file", pathname, "in ACL"); + if (TRACE) + fprintf(stderr, "%s `%s' %s\n", + "No entry for file", pathname, "in ACL"); HTAA_closeAcl(acl_file); return HTAA_NO_ENTRY; /* Forbidden -- no entry in the ACL */ } @@ -420,8 +458,9 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *, url, ** be a security hole. */ if (strstr(local_copy, "/../")) { - CTRACE(tfp, "HTAA_checkAuthorization: %s (`%s')\n", - "Illegal attempt to use /../", url); + if (TRACE) + fprintf(stderr, "HTAA_checkAuthorization: %s (`%s')\n", + "Illegal attempt to use /../", url); HTAAFailReason = HTAA_DOTDOT; } else { @@ -443,7 +482,8 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *, url, } if (!pathname) { /* Forbidden by rule */ - CTRACE(tfp, "HTAA_checkAuthorization: Forbidden by rule\n"); + if (TRACE) + fprintf(stderr, "HTAA_checkAuthorization: Forbidden by rule\n"); HTAAFailReason = HTAA_BY_RULE; } else if (HTAAFailReason != HTAA_HTBIN) { @@ -460,7 +500,9 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *, url, } else { /* Not local access */ HTAAFailReason = HTAA_OK_GATEWAY; - CTRACE(tfp, "HTAA_checkAuthorization: %s (%s access)\n", + if (TRACE) + fprintf(stderr, + "HTAA_checkAuthorization: %s (%s access)\n", "Gatewaying -- skipping authorization check", acc_method); } @@ -479,14 +521,15 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *, url, htaa_user && htaa_user->username ? htaa_user->username : ""); fflush(htaa_logfile); /* Actually update it on disk */ - CTRACE(tfp, "Log: %24.24s %s %s %s %s %s\n", - ctime(&theTime), - HTClientHost ? HTClientHost : "local", - method_name, - url, - status_name(HTAAFailReason), - htaa_user && htaa_user->username - ? htaa_user->username : ""); + if (TRACE) + fprintf(stderr, "Log: %24.24s %s %s %s %s %s\n", + ctime(&theTime), + HTClientHost ? HTClientHost : "local", + method_name, + url, + status_name(HTAAFailReason), + htaa_user && htaa_user->username + ? htaa_user->username : ""); } switch (HTAAFailReason) { @@ -494,6 +537,7 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *, url, case HTAA_NO_AUTH: case HTAA_NOT_MEMBER: return 401; + break; case HTAA_BY_RULE: case HTAA_IP_MASK: @@ -503,13 +547,16 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *, url, case HTAA_DOTDOT: case HTAA_HTBIN: return 403; + break; case HTAA_NOT_FOUND: return 404; + break; case HTAA_OK: case HTAA_OK_GATEWAY: return 200; + break; default: return 500; @@ -546,6 +593,7 @@ PRIVATE char *compose_scheme_specifics ARGS2(HTAAScheme, scheme, (realm ? realm : "UNKNOWN")); return result; } + break; case HTAA_PUBKEY: { @@ -556,6 +604,7 @@ PRIVATE char *compose_scheme_specifics ARGS2(HTAAScheme, scheme, "PUBKEY-NOT-IMPLEMENTED"); return result; } + break; default: return NULL; } @@ -581,28 +630,28 @@ PRIVATE char *compose_scheme_specifics ARGS2(HTAAScheme, scheme, PUBLIC char *HTAA_composeAuthHeaders NOARGS { static char *result = NULL; - int n; + HTAAScheme scheme; char *scheme_name; char *scheme_params; HTAAProt *prot = HTAA_getCurrentProtection(); if (!prot) { - CTRACE(tfp, "%s %s\n", - "HTAA_composeAuthHeaders: Document not protected", - "-- why was this function called??"); + if (TRACE) + fprintf(stderr, "%s %s\n", + "HTAA_composeAuthHeaders: Document not protected", + "-- why was this function called??"); return NULL; - } else { - CTRACE(tfp, "HTAA_composeAuthHeaders: for file `%s'\n", - prot->filename); } + else if (TRACE) + fprintf(stderr, "HTAA_composeAuthHeaders: for file `%s'\n", + prot->filename); FREE(result); /* From previous call */ if (!(result = (char*)malloc(4096))) /* @@ */ outofmem(__FILE__, "HTAA_composeAuthHeaders"); *result = '\0'; - for (n = 0; n < (int) HTAA_MAX_SCHEMES; n++) { - HTAAScheme scheme = (HTAAScheme) n; + for (scheme=0; scheme < HTAA_MAX_SCHEMES; scheme++) { if (-1 < HTList_indexOf(prot->valid_schemes, (void*)scheme)) { if ((scheme_name = HTAAScheme_name(scheme))) { scheme_params = compose_scheme_specifics(scheme,prot); @@ -614,10 +663,9 @@ PUBLIC char *HTAA_composeAuthHeaders NOARGS } strcat(result, "\r\n"); } /* scheme name found */ - else { - CTRACE(tfp, "HTAA_composeAuthHeaders: %s %d\n", - "No name found for scheme number", scheme); - } + else if (TRACE) + fprintf(stderr, "HTAA_composeAuthHeaders: %s %d\n", + "No name found for scheme number", scheme); } /* scheme valid for requested document */ } /* for every scheme */ diff --git a/WWW/Library/Implementation/HTAAServ.h b/WWW/Library/Implementation/HTAAServ.h index a2946ec4..fdee1c2b 100644 --- a/WWW/Library/Implementation/HTAAServ.h +++ b/WWW/Library/Implementation/HTAAServ.h @@ -31,6 +31,10 @@ #ifndef HTAASERV_H #define HTAASERV_H +#ifndef HTUTILS_H +#include <HTUtils.h> /* BOOL, PARAMS, ARGS */ +#endif /* HTUTILS_H */ +/*#include <stdio.h> included by HTUtils.h -- FM *//* FILE */ #include <HTRules.h> /* This module interacts with rule system */ #include <HTAAUtil.h> /* Common parts of AA */ #include <HTAuth.h> /* Authentication */ diff --git a/WWW/Library/Implementation/HTAAUtil.c b/WWW/Library/Implementation/HTAAUtil.c index 05726a8e..b10dcde0 100644 --- a/WWW/Library/Implementation/HTAAUtil.c +++ b/WWW/Library/Implementation/HTAAUtil.c @@ -1,3 +1,4 @@ + /* MODULE HTAAUtil.c ** COMMON PARTS OF ACCESS AUTHORIZATION MODULE ** FOR BOTH SERVER AND BROWSER @@ -44,13 +45,13 @@ */ #include <HTUtils.h> - +#include <tcp.h> /* NETREAD() etc. */ +#include <string.h> #include <HTAAUtil.h> /* Implemented here */ #include <HTAssoc.h> /* Assoc list */ #include <HTTCP.h> #include <HTAlert.h> -#include <LYStrings.h> #include <LYLeaks.h> /* PUBLIC HTAAScheme_enum() @@ -66,12 +67,17 @@ PUBLIC HTAAScheme HTAAScheme_enum ARGS1(CONST char*, name) { char *upcased = NULL; + char *cur; if (!name) return HTAA_UNKNOWN; StrAllocCopy(upcased, name); - LYUpperCase(upcased); + cur = upcased; + while (*cur) { + *cur = TOUPPER(*cur); + cur++; + } if (!strncmp(upcased, "NONE", 4)) { FREE(upcased); @@ -110,16 +116,22 @@ PUBLIC char *HTAAScheme_name ARGS1(HTAAScheme, scheme) switch (scheme) { case HTAA_NONE: return "None"; + break; case HTAA_BASIC: return "Basic"; + break; case HTAA_PUBKEY: return "Pubkey"; + break; case HTAA_KERBEROS_V4: return "KerberosV4"; + break; case HTAA_KERBEROS_V5: return "KerberosV5"; + break; case HTAA_UNKNOWN: return "UNKNOWN"; + break; default: return "THIS-IS-A-BUG"; } @@ -137,12 +149,23 @@ PUBLIC char *HTAAScheme_name ARGS1(HTAAScheme, scheme) */ PUBLIC HTAAMethod HTAAMethod_enum ARGS1(CONST char *, name) { + char tmp[MAX_METHODNAME_LEN+1]; + CONST char *src = name; + char *dest = tmp; + if (!name) return METHOD_UNKNOWN; - if (0==strcasecomp(name, "GET")) + while (*src) { + *dest = TOUPPER(*src); + dest++; + src++; + } + *dest = 0; + + if (0==strcmp(tmp, "GET")) return METHOD_GET; - else if (0==strcasecomp(name, "PUT")) + else if (0==strcmp(tmp, "PUT")) return METHOD_PUT; else return METHOD_UNKNOWN; @@ -164,10 +187,13 @@ PUBLIC char *HTAAMethod_name ARGS1(HTAAMethod, method) switch (method) { case METHOD_GET: return "GET"; + break; case METHOD_PUT: return "PUT"; + break; case METHOD_UNKNOWN: return "UNKNOWN"; + break; default: return "THIS-IS-A-BUG"; } @@ -191,7 +217,8 @@ PUBLIC BOOL HTAAMethod_inList ARGS2(HTAAMethod, method, char *item; while (NULL != (item = (char*)HTList_nextObject(cur))) { - CTRACE(tfp, " %s", item); + if (TRACE) + fprintf(stderr, " %s", item); if (method == HTAAMethod_enum(item)) return YES; } @@ -340,8 +367,9 @@ PUBLIC char *HTAA_makeProtectionTemplate ARGS1(CONST char *, docname) else StrAllocCopy(template, "*"); - CTRACE(tfp, "make_template: made template `%s' for file `%s'\n", - template, docname); + if (TRACE) + fprintf(stderr, "make_template: made template `%s' for file `%s'\n", + template, docname); return template; } @@ -473,8 +501,9 @@ PRIVATE int in_soc = -1; ** will use this buffer first and then ** proceed to read from socket. */ -PUBLIC void HTAA_setupReader ARGS3(char *, start_of_headers, +PUBLIC void HTAA_setupReader ARGS4(char *, start_of_headers, int, length, + void *, handle, int, soc) { start_pointer = buffer; @@ -520,9 +549,10 @@ PUBLIC char *HTAA_getUnfoldedLine NOARGS BOOL peek_for_folding = NO; if (in_soc < 0) { - CTRACE(tfp, "%s %s\n", - "HTAA_getUnfoldedLine: buffer not initialized", - "with function HTAA_setupReader()"); + if (TRACE) + fprintf(stderr, "%s %s\n", + "HTAA_getUnfoldedLine: buffer not initialized", + "with function HTAA_setupReader()"); return NULL; } diff --git a/WWW/Library/Implementation/HTAAUtil.h b/WWW/Library/Implementation/HTAAUtil.h index 059d5b03..2f353a63 100644 --- a/WWW/Library/Implementation/HTAAUtil.h +++ b/WWW/Library/Implementation/HTAAUtil.h @@ -1,35 +1,39 @@ /* Utilities for the Authorization parts of libwww COMMON PARTS OF AUTHORIZATION MODULE TO BOTH SERVER AND BROWSER - + This module is the interface to the common parts of Access Authorization (AA) package for both server and browser. Important to know about memory allocation: - + Routines in this module use dynamic allocation, but free automatically all the memory reserved by them. - + Therefore the caller never has to (and never should) free() any object returned by these functions. - + Therefore also all the strings returned by this package are only valid until the next call to the same function is made. This approach is selected, because of the nature of access authorization: no string returned by the package needs to be valid longer than until the next call. - + This also makes it easy to plug the AA package in: you don't have to ponder whether to free() something here or is it done somewhere else (because it is always done somewhere else). - + The strings that the package needs to store are copied so the original strings given as parameters to AA functions may be freed or modified with no side effects. - + Also note: The AA package does not free() anything else than what it has itself allocated. - + */ #ifndef HTAAUTIL_H #define HTAAUTIL_H +#ifndef HTUTILS_H +#include <HTUtils.h> /* BOOL, PARAMS, ARGS */ +#endif /* HTUTILS_H */ +#include <tcp.h> #include <HTList.h> #ifdef SHORT_NAMES @@ -72,17 +76,22 @@ Default filenames #define MAX_FIELDNAME_LEN 16 /* @@ Longest field name in */ /* protection setup file */ #define MAX_PATHNAME_LEN 80 /* @@ Longest passwd/group file */ - /* pathname to allow */ + /* patname to allow */ + +/* +** Helpful macros +*/ +#define FREE(x) if (x) {free(x); x = NULL;} /* Datatype definitions HTAASCHEME - + The enumeration HTAAScheme represents the possible authentication schemes used by the WWW Access Authorization. - + */ typedef enum { @@ -98,7 +107,7 @@ typedef enum { /* ENUMERATION TO REPRESENT HTTP METHODS - + */ typedef enum { @@ -197,11 +206,11 @@ Match Template Against Filename ** ** ON ENTRY: ** template is a template string to match the file name -** against, may contain a single wildcard +** agaist, may contain a single wildcard ** character * which matches zero or more ** arbitrary characters. ** filename is the filename (or pathname) to be matched -** against the template. +** agaist the template. ** ** ON EXIT: ** returns YES, if filename matches the template. @@ -223,11 +232,11 @@ PUBLIC BOOL HTAA_templateMatch PARAMS((CONST char * template, ** ** ON ENTRY: ** template is a template string to match the file name -** against, may contain a single wildcard +** agaist, may contain a single wildcard ** character * which matches zero or more ** arbitrary characters. ** filename is the filename (or pathname) to be matched -** against the template. +** agaist the template. ** ** ON EXIT: ** returns YES, if filename matches the template. @@ -319,6 +328,7 @@ Header Line Reader */ PUBLIC void HTAA_setupReader PARAMS((char * start_of_headers, int length, + void * handle, int soc)); @@ -346,3 +356,6 @@ PUBLIC void HTAA_setupReader PARAMS((char * start_of_headers, PUBLIC char *HTAA_getUnfoldedLine NOPARAMS; #endif /* NOT HTAAUTIL_H */ +/* + + End of file HTAAUtil.h. */ diff --git a/WWW/Library/Implementation/HTACL.c b/WWW/Library/Implementation/HTACL.c index cca7753f..fe4e02e4 100644 --- a/WWW/Library/Implementation/HTACL.c +++ b/WWW/Library/Implementation/HTACL.c @@ -17,6 +17,10 @@ #include <HTUtils.h> + +/*#include <stdio.h> included by HTUtils.h -- FM *//* FILE */ +#include <string.h> + #include <HTAAFile.h> /* File routines */ #include <HTGroup.h> /* GroupDef */ #include <HTACL.h> /* Implemented here */ @@ -170,17 +174,20 @@ PUBLIC GroupDef *HTAA_getAclEntry ARGS3(FILE *, acl_file, while (EOF != HTAAFile_readField(acl_file, buf, len+1)) { #ifdef VMS - if (HTAA_templateCaseMatch(buf, filename)) + if (HTAA_templateCaseMatch(buf, filename)) { #else /* not VMS */ - if (HTAA_templateMatch(buf, filename)) + if (HTAA_templateMatch(buf, filename)) { #endif /* not VMS */ - { HTList *methods = HTList_new(); HTAAFile_readList(acl_file, methods, MAX_METHODNAME_LEN); - CTRACE(tfp, "Filename '%s' matched template '%s', allowed methods:", + if (TRACE) { + fprintf(stderr, + "Filename '%s' matched template '%s', allowed methods:", filename, buf); + } if (HTAAMethod_inList(method, methods)) { /* right method? */ - CTRACE(tfp, " METHOD OK\n"); + if (TRACE) + fprintf(stderr, " METHOD OK\n"); HTList_delete(methods); methods = NULL; FREE(buf); @@ -190,15 +197,18 @@ PUBLIC GroupDef *HTAA_getAclEntry ARGS3(FILE *, acl_file, ** separator so we don't call HTAAFile_nextRec(). */ return group_def; - } else { - CTRACE(tfp, " METHOD NOT FOUND\n"); + } else if (TRACE) { + fprintf(stderr, " METHOD NOT FOUND\n"); } HTList_delete(methods); methods = NULL; } /* if template match */ else { - CTRACE(tfp, "Filename '%s' didn't match template '%s'\n", + if (TRACE) { + fprintf(stderr, + "Filename '%s' didn't match template '%s'\n", filename, buf); + } } HTAAFile_nextRec(acl_file); @@ -208,3 +218,4 @@ PUBLIC GroupDef *HTAA_getAclEntry ARGS3(FILE *, acl_file, return NULL; /* No entry for requested file */ /* (or an empty entry). */ } + diff --git a/WWW/Library/Implementation/HTACL.h b/WWW/Library/Implementation/HTACL.h index d1431b34..3dfef27c 100644 --- a/WWW/Library/Implementation/HTACL.h +++ b/WWW/Library/Implementation/HTACL.h @@ -5,6 +5,9 @@ #ifndef HTACL_H #define HTACL_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTAAUtil.h> #include <HTGroup.h> diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 12b17d54..df7f99c2 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -60,12 +60,11 @@ #include <UCMap.h> #include <GridText.h> -#include <GridText.h> -#include <LYGlobalDefs.h> #include <LYexit.h> -#include <LYUtils.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + extern HTCJKlang HTCJK; /* @@ -332,10 +331,10 @@ PUBLIC BOOL override_proxy ARGS1( ** ** On entry, ** addr must point to the fully qualified hypertext reference. -** anchor a parent anchor with whose address is addr +** anchor a pareent anchor with whose address is addr ** ** On exit, -** returns HT_NO_ACCESS Error has occurred. +** returns HT_NO_ACCESS Error has occured. ** HT_OK Success */ PRIVATE int get_physical ARGS2( @@ -353,7 +352,8 @@ PRIVATE int get_physical ARGS2( } if (anchor->isISMAPScript == TRUE) { StrAllocCat(physical, "?0,0"); - CTRACE(tfp, "HTAccess: Appending '?0,0' coordinate pair.\n"); + if (TRACE) + fprintf(stderr, "HTAccess: Appending '?0,0' coordinate pair.\n"); } HTAnchor_setPhysical(anchor, physical); FREE(physical); /* free our copy */ @@ -361,7 +361,8 @@ PRIVATE int get_physical ARGS2( if (anchor->isISMAPScript == TRUE) { StrAllocCopy(physical, addr); StrAllocCat(physical, "?0,0"); - CTRACE(tfp, "HTAccess: Appending '?0,0' coordinate pair.\n"); + if (TRACE) + fprintf(stderr, "HTAccess: Appending '?0,0' coordinate pair.\n"); HTAnchor_setPhysical(anchor, physical); FREE(physical); /* free our copy */ } else { @@ -450,10 +451,10 @@ PRIVATE int get_physical ARGS2( proxy = (char *)getenv(gateway_parameter); FREE(gateway_parameter); - if (gateway) - CTRACE(tfp, "Gateway found: %s\n", gateway); - if (proxy) - CTRACE(tfp, "proxy server found: %s\n", proxy); + if (TRACE && gateway) + fprintf(stderr, "Gateway found: %s\n", gateway); + if (TRACE && proxy) + fprintf(stderr, "proxy server found: %s\n", proxy); /* ** Proxy servers have precedence over gateway servers. @@ -579,13 +580,13 @@ PRIVATE int LYUCPopAssumed NOARGS ** ** On entry, ** addr must point to the fully qualified hypertext reference. -** anchor a parent anchor with whose address is addr +** anchor a pareent anchor with whose address is addr ** ** On exit, -** returns <0 Error has occurred. +** returns <0 Error has occured. ** HT_LOADED Success ** HT_NO_DATA Success, but no document loaded. -** (telnet session started etc) +** (telnet sesssion started etc) */ PRIVATE int HTLoad ARGS4( CONST char *, addr, @@ -623,6 +624,8 @@ PUBLIC HTStream *HTSaveStream ARGS1( return (*p->saveStream)(anchor); } +extern char LYinternal_flag; /* from LYMainLoop.c */ + /* Load a document - with logging etc HTLoadDocument() ** ---------------------------------- ** @@ -641,6 +644,16 @@ PUBLIC HTStream *HTSaveStream ARGS1( ** NO Failure */ +extern char LYforce_no_cache; /* from GridText.c */ +extern char LYoverride_no_cache; /* from LYMainLoop.c */ +extern char * HTLoadedDocumentURL NOPARAMS; /* in GridText.c */ +extern BOOL HText_hasNoCacheSet PARAMS((HText *text)); /* in GridText.c */ +extern BOOL reloading; +extern BOOL permanent_redirection; +#ifdef DIRED_SUPPORT +extern BOOLEAN lynx_edit_mode; +#endif + PRIVATE BOOL HTLoadDocument ARGS4( CONST char *, full_address, HTParentAnchor *, anchor, @@ -654,7 +667,8 @@ PRIVATE BOOL HTLoadDocument ARGS4( BOOL ForcingNoCache = LYforce_no_cache; static int redirection_attempts = 0; - CTRACE (tfp, "HTAccess: loading document %s\n", address_to_load); + if (TRACE) + fprintf (stderr, "HTAccess: loading document %s\n", address_to_load); /* ** Free use_this_url_instead and reset permanent_redirection @@ -710,9 +724,11 @@ PRIVATE BOOL HTLoadDocument ARGS4( !strncmp(cp, "Location=", 9)) { DocAddress NewDoc; - CTRACE (tfp, "HTAccess: '%s' is a redirection URL.\n", - anchor->address); - CTRACE (tfp, "HTAccess: Redirecting to '%s'\n", cp+9); + if (TRACE) { + fprintf (stderr, "HTAccess: '%s' is a redirection URL.\n", + anchor->address); + fprintf (stderr, "HTAccess: Redirecting to '%s'\n", cp+9); + } /* ** Don't exceed the redirection_attempts limit. - FM @@ -764,12 +780,12 @@ PRIVATE BOOL HTLoadDocument ARGS4( * If DONT_TRACK_INTERNAL_LINKS is defined, HText_AreDifferent() * is used to determine whether (3) applies. If the target address * differs from that of the current document only by a fragment - * and the target address has an appended fragment, repositioning + * and the taget address has an appended fragment, repositioning * without reloading is always assumed. * Note that HText_AreDifferent() currently always returns TRUE * if the target has a LYNXIMGMAP URL, so that an internally * generated pseudo-document will normally not be re-used unless - * condition (2) applies. (Condition (1) cannot apply since in + * condition (2) appplies. (Condition (1) cannot apply since in * LYMap.c, no_cache is always set in the anchor object). This * doesn't guarantee that the resource from which the MAP element * is taken will be read again (reloaded) when the list of links @@ -810,7 +826,8 @@ PRIVATE BOOL HTLoadDocument ARGS4( strncmp(full_address, "LYNXIMGMAP:", 11))) #endif /* TRACK_INTERNAL_LINKS */ { - CTRACE(tfp, "HTAccess: Document already in memory.\n"); + if (TRACE) + fprintf(stderr, "HTAccess: Document already in memory.\n"); HText_select(text); #ifdef DIRED_SUPPORT @@ -827,7 +844,9 @@ PRIVATE BOOL HTLoadDocument ARGS4( reloading = TRUE; #endif ForcingNoCache = YES; - CTRACE(tfp, "HTAccess: Auto-reloading document.\n"); + if (TRACE) { + fprintf(stderr, "HTAccess: Auto-reloading document.\n"); + } } } @@ -842,7 +861,9 @@ PRIVATE BOOL HTLoadDocument ARGS4( FREE(anchor->title); } status = HTLoad(address_to_load, anchor, format_out, sink); - CTRACE(tfp, "HTAccess: status=%d\n", status); + if (TRACE) { + fprintf(stderr, "HTAccess: status=%d\n", status); + } /* ** Log the access if necessary. @@ -856,7 +877,8 @@ PRIVATE BOOL HTLoadDocument ARGS4( status < 0 ? "FAIL" : "GET", full_address); fflush(HTlogfile); /* Actually update it on disk */ - CTRACE(tfp, "Log: %24.24s %s %s %s\n", + if (TRACE) + fprintf(stderr, "Log: %24.24s %s %s %s\n", ctime(&theTime), HTClientHost ? HTClientHost : "local", status < 0 ? "FAIL" : "GET", @@ -885,10 +907,12 @@ PRIVATE BOOL HTLoadDocument ARGS4( ** in LYGetFile.c when the status is HT_REDIRECTING. This may ** seem bizarre, but it works like a charm! - FM */ - CTRACE(tfp, "HTAccess: '%s' is a redirection URL.\n", - address_to_load); - CTRACE(tfp, "HTAccess: Redirecting to '%s'\n", - redirecting_url); + if (TRACE) { + fprintf(stderr, "HTAccess: '%s' is a redirection URL.\n", + address_to_load); + fprintf(stderr, "HTAccess: Redirecting to '%s'\n", + redirecting_url); + } /* ** Prevent circular references. */ @@ -928,59 +952,73 @@ PRIVATE BOOL HTLoadDocument ARGS4( permanent_redirection = FALSE; if (status == HT_LOADED) { - CTRACE(tfp, "HTAccess: `%s' has been accessed.\n", - full_address); + if (TRACE) { + fprintf(stderr, "HTAccess: `%s' has been accessed.\n", + full_address); + } return YES; } if (status == HT_PARTIAL_CONTENT) { HTAlert("Loading incomplete."); - CTRACE(tfp, "HTAccess: `%s' has been accessed, partial content.\n", - full_address); + if (TRACE) { + fprintf(stderr, "HTAccess: `%s' has been accessed, partial content.\n", + full_address); + } return YES; } if (status == HT_NO_DATA) { - CTRACE(tfp, "HTAccess: `%s' has been accessed, No data left.\n", - full_address); + if (TRACE) { + fprintf(stderr, + "HTAccess: `%s' has been accessed, No data left.\n", + full_address); + } return NO; } if (status == HT_NOT_LOADED) { - CTRACE(tfp, "HTAccess: `%s' has been accessed, No data loaded.\n", - full_address); + if (TRACE) { + fprintf(stderr, + "HTAccess: `%s' has been accessed, No data loaded.\n", + full_address); + } return NO; } if (status == HT_INTERRUPTED) { - CTRACE(tfp, "HTAccess: `%s' has been accessed, transfer interrupted.\n", - full_address); + if (TRACE) { + fprintf(stderr, + "HTAccess: `%s' has been accessed, transfer interrupted.\n", + full_address); + } +/* _HTProgress("Data transfer interrupted."); */ return NO; } - if (status > 0) { - /* - ** If you get this, then please find which routine is returning - ** a positive unrecognized error code! - */ - fprintf(stderr, - "**** HTAccess: socket or file number returned by obsolete load routine!\n"); - fprintf(stderr, - "**** HTAccess: Internal software error. Please mail lynx_dev@sig.net!\n"); - fprintf(stderr, "**** HTAccess: Status returned was: %d\n",status); - exit(-1); + if (status <= 0) { /* Failure in accessing a document */ + char *temp = NULL; + StrAllocCopy(temp, "Can't Access `"); + StrAllocCat(temp, full_address); + StrAllocCat(temp, "'"); + _HTProgress(temp); + FREE(temp); + if (TRACE) fprintf(stderr, + "HTAccess: Can't access `%s'\n", full_address); + HTLoadError(sink, 500, "Unable to access document."); + return NO; } - /* Failure in accessing a document */ - cp = NULL; - StrAllocCopy(cp, "Can't Access `"); - StrAllocCat(cp, full_address); - StrAllocCat(cp, "'"); - _HTProgress(cp); - FREE(cp); + /* + ** If you get this, then please find which routine is returning + ** a positive unrecognised error code! + */ + fprintf(stderr, + "**** HTAccess: socket or file number returned by obsolete load routine!\n"); + fprintf(stderr, + "**** HTAccess: Internal software error. Please mail lynx_dev@sig.net!\n"); + fprintf(stderr, "**** HTAccess: Status returned was: %d\n",status); + exit(-1); - CTRACE(tfp, "HTAccess: Can't access `%s'\n", full_address); - HTLoadError(sink, 500, "Unable to access document."); - return NO; } /* HTLoadDocument */ /* Load a document from absolute name. HTLoadAbsolute() @@ -1078,7 +1116,7 @@ PUBLIC BOOL HTLoadRelative ARGS2( ** ---------------------------------------- ** ** On Entry, -** destination The child or parent anchor to be loaded. +** destination The child or parenet anchor to be loaded. ** ** On Exit, ** returns YES Success @@ -1094,7 +1132,7 @@ PUBLIC BOOL HTLoadAnchor ARGS1( parent = HTAnchor_parent(destination); - if (HTAnchor_document(parent) == NULL) { /* If not already loaded */ + if (HTAnchor_document(parent) == NULL) { /* If not alread loaded */ /* TBL 921202 */ BOOL result; char * address = HTAnchor_address((HTAnchor*) parent); @@ -1220,16 +1258,16 @@ PUBLIC BOOL HTSearch ARGS2( ** the new address. ** ** On Entry, -** *keywords space-separated keyword list or similar search list -** *indexname is name of object search is to be done on. +** *keywords space-separated keyword list or similar search list +** *addres is name of object search is to be done on. */ PUBLIC BOOL HTSearchAbsolute ARGS2( CONST char *, keywords, - char *, indexname) + CONST char *, indexname) { DocAddress abs_doc; HTParentAnchor * anchor; - abs_doc.address = indexname; + abs_doc.address = (char *)indexname; abs_doc.post_data = NULL; abs_doc.post_content_type = NULL; abs_doc.bookmark = NULL; @@ -1247,7 +1285,7 @@ PUBLIC BOOL HTSearchAbsolute ARGS2( ** As it involves file access, this should only be done once ** when the program first runs. ** This is a default algorithm -- browser don't HAVE to use this. -** But consistency between browsers is STRONGLY recommended! +** But consistency betwen browsers is STRONGLY recommended! ** ** Priority order is: ** 1 WWW_HOME environment variable (logical name, etc) @@ -1305,7 +1343,9 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS if (fp) { fclose(fp); } else { - CTRACE(tfp, "HTBrowse: No local home document ~/%s or %s\n", + if (TRACE) + fprintf(stderr, + "HTBrowse: No local home document ~/%s or %s\n", PERSONAL_DEFAULT, LOCAL_DEFAULT_FILE); FREE(my_home_document); } @@ -1317,7 +1357,9 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS "file:", PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION); if (my_home_document) { - CTRACE(tfp, "HTAccess: Using custom home page %s i.e. address %s\n", + if (TRACE) + fprintf(stderr, + "HTAccess: Using custom home page %s i.e. address %s\n", my_home_document, ref); FREE(my_home_document); } diff --git a/WWW/Library/Implementation/HTAccess.h b/WWW/Library/Implementation/HTAccess.h index 32d8e562..1954e6de 100644 --- a/WWW/Library/Implementation/HTAccess.h +++ b/WWW/Library/Implementation/HTAccess.h @@ -15,6 +15,10 @@ extern char * use_this_url_instead; /* Definition uses: */ +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ +#include <tcp.h> #include <HTAnchor.h> #include <HTFormat.h> @@ -259,7 +263,7 @@ Search Given Indexname */ extern BOOL HTSearchAbsolute PARAMS(( CONST char * keywords, - char * indexname)); + CONST char * indexname)); /* diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index ec332eb3..9c8b10cd 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -7,7 +7,7 @@ ** History ** ** Nov 1990 Written in Objective-C for the NeXT browser (TBL) -** 24-Oct-1991 (JFG), written in C, browser-independent +** 24-Oct-1991 (JFG), written in C, browser-independant ** 21-Nov-1991 (JFG), first complete version ** ** (c) Copyright CERN 1991 - See Copyright.html @@ -16,6 +16,8 @@ #define HASH_SIZE 101 /* Arbitrary prime. Memory/speed tradeoff */ #include <HTUtils.h> +#include <tcp.h> +#include <ctype.h> #include <HTAnchor.h> #include <HTParse.h> #include <UCAux.h> @@ -24,6 +26,8 @@ #include <LYCharSets.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + #ifdef NOT_DEFINED /* * This is the hashing function used to determine which list in the @@ -40,12 +44,12 @@ PRIVATE int HASH_FUNCTION ARGS1( CONST char *, cp_address) { int hash; - CONST unsigned char *p; + unsigned char *p; - for (p = (CONST unsigned char *)cp_address, hash = 0; *p; p++) - hash = (int) (hash * 3 + (*(CONST unsigned char *)p)) % HASH_SIZE; + for (p = (unsigned char *)cp_address, hash = 0; *p; p++) + hash = (int) (hash * 3 + (*(unsigned char *)p)) % HASH_SIZE; - return(hash); + return hash; } typedef struct _HyperDoc Hyperdoc; @@ -80,7 +84,7 @@ PRIVATE HTParentAnchor * HTParentAnchor_new NOARGS newAnchor->no_cache = FALSE; /* no-cache? - FM */ newAnchor->content_type = NULL; /* Content-Type. - FM */ newAnchor->content_language = NULL; /* Content-Language. - FM */ - newAnchor->content_encoding = NULL; /* Compression algorithm. - FM */ + newAnchor->content_encoding = NULL; /* Compression algorith. - FM */ newAnchor->content_base = NULL; /* Content-Base. - FM */ newAnchor->content_disposition = NULL; /* Content-Disposition. - FM */ newAnchor->content_location = NULL; /* Content-Location. - FM */ @@ -90,7 +94,7 @@ PRIVATE HTParentAnchor * HTParentAnchor_new NOARGS newAnchor->expires = NULL; /* Expires. - FM */ newAnchor->last_modified = NULL; /* Last-Modified. - FM */ newAnchor->server = NULL; /* Server. - FM */ - return(newAnchor); + return newAnchor; } PRIVATE HTChildAnchor * HTChildAnchor_new NOARGS @@ -116,12 +120,12 @@ PRIVATE BOOL HTEquivalent ARGS2( if (s && t) { /* Make sure they point to something */ for (; *s && *t; s++, t++) { if (TOUPPER(*s) != TOUPPER(*t)) { - return(NO); + return NO; } } - return( TOUPPER(*s) == TOUPPER(*t)); + return TOUPPER(*s) == TOUPPER(*t); } else { - return(s == t); /* Two NULLs are equivalent, aren't they ? */ + return s == t; /* Two NULLs are equivalent, aren't they ? */ } } @@ -143,12 +147,12 @@ PRIVATE BOOL HTIdentical ARGS2( if (s && t) { /* Make sure they point to something */ for (; *s && *t; s++, t++) { if (*s != *t) { - return(NO); + return NO; } } - return(*s == *t); + return *s == *t; } else { - return(s == t); /* Two NULLs are identical, aren't they ? */ + return s == t; /* Two NULLs are identical, aren't they ? */ } } #endif /* CASE_INSENSITIVE_ANCHORS */ @@ -168,8 +172,9 @@ PUBLIC HTChildAnchor * HTAnchor_findChild ARGS2( HTList *kids; if (!parent) { - CTRACE(tfp, "HTAnchor_findChild called with NULL parent.\n"); - return(NULL); + if (TRACE) + fprintf(stderr, "HTAnchor_findChild called with NULL parent.\n"); + return NULL; } if ((kids = parent->children) != 0) { /* @@ -178,14 +183,15 @@ PUBLIC HTChildAnchor * HTAnchor_findChild ARGS2( if (tag && *tag) { /* TBL */ while (NULL != (child=(HTChildAnchor *)HTList_nextObject(kids))) { #ifdef CASE_INSENSITIVE_ANCHORS - if (HTEquivalent(child->tag, tag)) /* Case insensitive */ + if (HTEquivalent(child->tag, tag)) { /* Case insensitive */ #else - if (HTIdentical(child->tag, tag)) /* Case sensitive - FM */ + if (HTIdentical(child->tag, tag)) { /* Case sensitive - FM */ #endif /* CASE_INSENSITIVE_ANCHORS */ - { - CTRACE(tfp, "Child anchor %p of parent %p with name `%s' already exists.\n", + if (TRACE) + fprintf(stderr, + "Child anchor %p of parent %p with name `%s' already exists.\n", (void *)child, (void *)parent, tag); - return(child); + return child; } } } /* end if tag is void */ @@ -194,14 +200,16 @@ PUBLIC HTChildAnchor * HTAnchor_findChild ARGS2( } child = HTChildAnchor_new(); - CTRACE(tfp, "new Anchor %p named `%s' is child of %p\n", + if (TRACE) + fprintf(stderr, + "new Anchor %p named `%s' is child of %p\n", (void *)child, tag ? tag : (CONST char *)"", (void *)parent); /* int for apollo */ HTList_addObject (parent->children, child); child->parent = parent; StrAllocCopy(child->tag, tag); - return(child); + return child; } @@ -220,7 +228,8 @@ PUBLIC HTChildAnchor * HTAnchor_findChildAndLink ARGS4( { HTChildAnchor * child = HTAnchor_findChild(parent, tag); - CTRACE(tfp,"Entered HTAnchor_findChildAndLink\n"); + if (TRACE) + fprintf(stderr,"Entered HTAnchor_findChildAndLink\n"); if (href && *href) { char *relative_to = HTAnchor_address((HTAnchor *)parent); @@ -249,7 +258,7 @@ PUBLIC HTChildAnchor * HTAnchor_findChildAndLink ARGS4( FREE(parsed_doc.address); FREE(relative_to); } - return(child); + return child; } /* @@ -297,7 +306,8 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1( /* Anchor tag specified ? */ char *tag = HTParse(newdoc->address, "", PARSE_ANCHOR); - CTRACE(tfp,"Entered HTAnchor_findAddress\n"); + if (TRACE) + fprintf(stderr,"Entered HTAnchor_findAddress\n"); /* ** If the address represents a sub-anchor, we recursively load its @@ -361,7 +371,9 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1( foundAnchor->isHEAD == newdoc->isHEAD) #endif /* CASE_INSENSITIVE_ANCHORS */ { - CTRACE(tfp, "Anchor %p with address `%s' already exists.\n", + if (TRACE) + fprintf(stderr, + "Anchor %p with address `%s' already exists.\n", (void *)foundAnchor, newdoc->address); return (HTAnchor *)foundAnchor; } @@ -371,7 +383,9 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1( ** Node not found: create new anchor. */ foundAnchor = HTParentAnchor_new(); - CTRACE(tfp, "New anchor %p has hash %d and address `%s'\n", + if (TRACE) + fprintf(stderr, + "New anchor %p has hash %d and address `%s'\n", (void *)foundAnchor, hash, newdoc->address); StrAllocCopy(foundAnchor->address, newdoc->address); if (newdoc->post_data) @@ -717,7 +731,7 @@ PUBLIC void HTAnchor_makeLastChild ARGS1( PUBLIC HTParentAnchor * HTAnchor_parent ARGS1( HTAnchor *, me) { - return( me ? me->parent : NULL); + return me ? me->parent : NULL; } PUBLIC void HTAnchor_setDocument ARGS2( @@ -731,7 +745,7 @@ PUBLIC void HTAnchor_setDocument ARGS2( PUBLIC HyperDoc * HTAnchor_document ARGS1( HTParentAnchor *, me) { - return( me ? me->document : NULL); + return me ? me->document : NULL; } @@ -764,7 +778,7 @@ PUBLIC char * HTAnchor_address ARGS1( me->parent->address, ((HTChildAnchor *)me)->tag); } } - return(addr); + return addr; } PUBLIC void HTAnchor_setFormat ARGS2( @@ -778,7 +792,7 @@ PUBLIC void HTAnchor_setFormat ARGS2( PUBLIC HTFormat HTAnchor_format ARGS1( HTParentAnchor *, me) { - return( me ? me->format : NULL); + return me ? me->format : NULL; } PUBLIC void HTAnchor_setIndex ARGS2( @@ -803,7 +817,7 @@ PUBLIC void HTAnchor_setPrompt ARGS2( PUBLIC BOOL HTAnchor_isIndex ARGS1( HTParentAnchor *, me) { - return( me ? me->isIndex : NO); + return me ? me->isIndex : NO; } /* Whether Anchor has been designated as an ISMAP link @@ -812,13 +826,13 @@ PUBLIC BOOL HTAnchor_isIndex ARGS1( PUBLIC BOOL HTAnchor_isISMAPScript ARGS1( HTAnchor *, me) { - return( me ? me->parent->isISMAPScript : NO); + return me ? me->parent->isISMAPScript : NO; } PUBLIC BOOL HTAnchor_hasChildren ARGS1( HTParentAnchor *, me) { - return( me ? ! HTList_isEmpty(me->children) : NO); + return me ? ! HTList_isEmpty(me->children) : NO; } #if defined(USE_HASH) @@ -827,7 +841,7 @@ PUBLIC BOOL HTAnchor_hasChildren ARGS1( PUBLIC CONST char * HTAnchor_style ARGS1( HTParentAnchor *, me) { - return( me ? me->style : NULL); + return me ? me->style : NULL; } PUBLIC void HTAnchor_setStyle ARGS2( @@ -846,7 +860,7 @@ PUBLIC void HTAnchor_setStyle ARGS2( PUBLIC CONST char * HTAnchor_title ARGS1( HTParentAnchor *, me) { - return( me ? me->title : NULL); + return me ? me->title : NULL; } PUBLIC void HTAnchor_setTitle ARGS2( @@ -888,7 +902,7 @@ PUBLIC void HTAnchor_appendTitle ARGS2( PUBLIC CONST char * HTAnchor_bookmark ARGS1( HTParentAnchor *, me) { - return( me ? me->bookmark : NULL); + return me ? me->bookmark : NULL; } PUBLIC void HTAnchor_setBookmark ARGS2( @@ -904,7 +918,7 @@ PUBLIC void HTAnchor_setBookmark ARGS2( PUBLIC CONST char * HTAnchor_owner ARGS1( HTParentAnchor *, me) { - return( me ? me->owner : NULL); + return (me ? me->owner : NULL); } PUBLIC void HTAnchor_setOwner ARGS2( @@ -921,7 +935,7 @@ PUBLIC void HTAnchor_setOwner ARGS2( PUBLIC CONST char * HTAnchor_RevTitle ARGS1( HTParentAnchor *, me) { - return( me ? me->RevTitle : NULL); + return (me ? me->RevTitle : NULL); } PUBLIC void HTAnchor_setRevTitle ARGS2( @@ -948,7 +962,7 @@ PUBLIC void HTAnchor_setRevTitle ARGS2( PUBLIC CONST char * HTAnchor_SugFname ARGS1( HTParentAnchor *, me) { - return( me ? me->SugFname : NULL); + return me ? me->SugFname : NULL; } /* Content-Encoding handling. - FM @@ -958,7 +972,7 @@ PUBLIC CONST char * HTAnchor_SugFname ARGS1( PUBLIC CONST char * HTAnchor_content_encoding ARGS1( HTParentAnchor *, me) { - return( me ? me->content_encoding : NULL); + return me ? me->content_encoding : NULL; } /* Content-Type handling. - FM @@ -966,7 +980,7 @@ PUBLIC CONST char * HTAnchor_content_encoding ARGS1( PUBLIC CONST char * HTAnchor_content_type ARGS1( HTParentAnchor *, me) { - return( me ? me->content_type : NULL); + return me ? me->content_type : NULL; } /* Last-Modified header handling. - FM @@ -974,7 +988,7 @@ PUBLIC CONST char * HTAnchor_content_type ARGS1( PUBLIC CONST char * HTAnchor_last_modified ARGS1( HTParentAnchor *, me) { - return( me ? me->last_modified : NULL); + return me ? me->last_modified : NULL; } /* Date header handling. - FM @@ -982,7 +996,7 @@ PUBLIC CONST char * HTAnchor_last_modified ARGS1( PUBLIC CONST char * HTAnchor_date ARGS1( HTParentAnchor *, me) { - return( me ? me->date : NULL); + return me ? me->date : NULL; } /* Server header handling. - FM @@ -990,7 +1004,7 @@ PUBLIC CONST char * HTAnchor_date ARGS1( PUBLIC CONST char * HTAnchor_server ARGS1( HTParentAnchor *, me) { - return( me ? me->server : NULL); + return me ? me->server : NULL; } /* Safe header handling. - FM @@ -998,7 +1012,7 @@ PUBLIC CONST char * HTAnchor_server ARGS1( PUBLIC BOOL HTAnchor_safe ARGS1( HTParentAnchor *, me) { - return( me ? me->safe : FALSE); + return me ? me->safe : FALSE; } /* Content-Base header handling. - FM @@ -1006,7 +1020,7 @@ PUBLIC BOOL HTAnchor_safe ARGS1( PUBLIC CONST char * HTAnchor_content_base ARGS1( HTParentAnchor *, me) { - return( me ? me->content_base : NULL); + return me ? me->content_base : NULL; } /* Content-Location header handling. - FM @@ -1014,7 +1028,7 @@ PUBLIC CONST char * HTAnchor_content_base ARGS1( PUBLIC CONST char * HTAnchor_content_location ARGS1( HTParentAnchor *, me) { - return( me ? me->content_location : NULL); + return me ? me->content_location : NULL; } /* Link me Anchor to another given one @@ -1026,8 +1040,10 @@ PUBLIC BOOL HTAnchor_link ARGS3( HTLinkType *, type) { if (!(source && destination)) - return(NO); /* Can't link to/from non-existing anchor */ - CTRACE(tfp, "Linking anchor %p to anchor %p\n", source, destination); + return NO; /* Can't link to/from non-existing anchor */ + if (TRACE) + fprintf(stderr, + "Linking anchor %p to anchor %p\n", source, destination); if (!source->mainLink.dest) { source->mainLink.dest = destination; source->mainLink.type = type; @@ -1044,7 +1060,7 @@ PUBLIC BOOL HTAnchor_link ARGS3( if (!destination->parent->sources) destination->parent->sources = HTList_new(); HTList_addObject (destination->parent->sources, source); - return(YES); /* Success */ + return YES; /* Success */ } @@ -1054,7 +1070,7 @@ PUBLIC BOOL HTAnchor_link ARGS3( PUBLIC HTAnchor * HTAnchor_followMainLink ARGS1( HTAnchor *, me) { - return( me->mainLink.dest); + return me->mainLink.dest; } PUBLIC HTAnchor * HTAnchor_followTypedLink ARGS2( @@ -1062,17 +1078,17 @@ PUBLIC HTAnchor * HTAnchor_followTypedLink ARGS2( HTLinkType *, type) { if (me->mainLink.type == type) - return( me->mainLink.dest); + return me->mainLink.dest; if (me->links) { HTList *links = me->links; HTLink *the_link; while (NULL != (the_link=(HTLink *)HTList_nextObject(links))) { if (the_link->type == type) { - return( the_link->dest); + return the_link->dest; } } } - return(NULL); /* No link of me type */ + return NULL; /* No link of me type */ } @@ -1084,7 +1100,7 @@ PUBLIC BOOL HTAnchor_makeMainLink ARGS2( { /* Check that everything's OK */ if (!(me && HTList_removeObject (me->links, movingLink))) { - return(NO); /* link not found or NULL anchor */ + return NO; /* link not found or NULL anchor */ } else { /* First push current main link onto top of links list */ HTLink *newLink = (HTLink *)calloc (1, sizeof (HTLink)); @@ -1098,7 +1114,7 @@ PUBLIC BOOL HTAnchor_makeMainLink ARGS2( memcpy((void *)&me->mainLink, (CONST void *)movingLink, sizeof (HTLink)); FREE(movingLink); - return(YES); + return YES; } } @@ -1112,7 +1128,7 @@ PUBLIC HTList * HTAnchor_methods ARGS1( if (!me->methods) { me->methods = HTList_new(); } - return( me->methods); + return me->methods; } /* Protocol @@ -1121,7 +1137,7 @@ PUBLIC HTList * HTAnchor_methods ARGS1( PUBLIC void * HTAnchor_protocol ARGS1( HTParentAnchor *, me) { - return( me->protocol); + return me->protocol; } PUBLIC void HTAnchor_setProtocol ARGS2( @@ -1137,7 +1153,7 @@ PUBLIC void HTAnchor_setProtocol ARGS2( PUBLIC char * HTAnchor_physical ARGS1( HTParentAnchor *, me) { - return( me->physical); + return me->physical; } PUBLIC void HTAnchor_setPhysical ARGS2( @@ -1179,7 +1195,7 @@ PUBLIC LYUCcharset * HTAnchor_getUCInfoStage ARGS2( { if (me && !me->UCStages) { int i; - int chndl = UCLYhndl_for_unspec; /* always >= 0 */ + int chndl = UCLYhndl_for_unspec; UCAnchorInfo * stages = (UCAnchorInfo*)calloc(1, sizeof(UCAnchorInfo)); if (stages == NULL) @@ -1190,25 +1206,28 @@ PUBLIC LYUCcharset * HTAnchor_getUCInfoStage ARGS2( } if (me->charset) { chndl = UCGetLYhndl_byMIME(me->charset); - if (chndl < 0) + if (chndl < 0) { chndl = UCLYhndl_for_unrec; - if (chndl < 0) - /* - ** UCLYhndl_for_unrec not defined :-( - ** fallback to UCLYhndl_for_unspec which always valid. - */ - chndl = UCLYhndl_for_unspec; /* always >= 0 */ + } + } + if (chndl >= 0) { + memcpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl], + sizeof(LYUCcharset)); + stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT; + } else { + /* + * Should not happen... + */ + stages->s[UCT_STAGE_MIME].C.UChndl = -1; + stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_NONE; } - memcpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl], - sizeof(LYUCcharset)); - stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT; stages->s[UCT_STAGE_MIME].LYhndl = chndl; me->UCStages = stages; } if (me) { - return( &me->UCStages->s[which_stage].C); + return &me->UCStages->s[which_stage].C; } - return(NULL); + return NULL; } PUBLIC int HTAnchor_getUCLYhndl ARGS2( @@ -1223,10 +1242,10 @@ PUBLIC int HTAnchor_getUCLYhndl ARGS2( (void) HTAnchor_getUCInfoStage(me, which_stage); } if (me->UCStages->s[which_stage].lock > UCT_SETBY_NONE) { - return( me->UCStages->s[which_stage].LYhndl); + return me->UCStages->s[which_stage].LYhndl; } } - return( -1); + return -1; } PUBLIC LYUCcharset * HTAnchor_setUCInfoStage ARGS4( @@ -1252,10 +1271,10 @@ PUBLIC LYUCcharset * HTAnchor_setUCInfoStage ARGS4( else { p->UChndl = -1; } - return(p); + return p; } } - return(NULL); + return NULL; } PUBLIC LYUCcharset * HTAnchor_resetUCInfoStage ARGS4( @@ -1265,10 +1284,10 @@ PUBLIC LYUCcharset * HTAnchor_resetUCInfoStage ARGS4( int, set_by) { if (!me || !me->UCStages) - return(NULL); + return NULL; me->UCStages->s[which_stage].lock = set_by; me->UCStages->s[which_stage].LYhndl = LYhndl; - return( &me->UCStages->s[which_stage].C); + return &me->UCStages->s[which_stage].C; } /* @@ -1299,8 +1318,8 @@ PUBLIC LYUCcharset * HTAnchor_copyUCInfoStage ARGS4( me->UCStages->s[from_stage].LYhndl; if (p_to != p_from) memcpy(p_to, p_from, sizeof(LYUCcharset)); - return(p_to); + return p_to; } } - return(NULL); + return NULL; } diff --git a/WWW/Library/Implementation/HTAssoc.c b/WWW/Library/Implementation/HTAssoc.c index f5dcbf11..0736a269 100644 --- a/WWW/Library/Implementation/HTAssoc.c +++ b/WWW/Library/Implementation/HTAssoc.c @@ -16,8 +16,11 @@ ** */ + #include <HTUtils.h> +#include <string.h> + #include <HTAAUtil.h> #include <HTAssoc.h> #include <HTString.h> @@ -63,8 +66,8 @@ PUBLIC void HTAssocList_add ARGS3(HTAssocList *, alist, if (value) StrAllocCopy(assoc->value, value); HTList_addObject(alist, (void*)assoc); - } else { - CTRACE(tfp, "HTAssoc_add: ERROR: assoc list NULL!!\n"); + } else if (TRACE) { + fprintf(stderr, "HTAssoc_add: ERROR: assoc list NULL!!\n"); } } diff --git a/WWW/Library/Implementation/HTAssoc.h b/WWW/Library/Implementation/HTAssoc.h index 93183302..79cbe557 100644 --- a/WWW/Library/Implementation/HTAssoc.h +++ b/WWW/Library/Implementation/HTAssoc.h @@ -7,8 +7,12 @@ #ifndef HTASSOC_H #define HTASSOC_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTList.h> + #ifdef SHORT_NAMES #define HTAL_new HTAssocList_new #define HTAL_del HTAssocList_delete diff --git a/WWW/Library/Implementation/HTAtom.c b/WWW/Library/Implementation/HTAtom.c index e4af2962..e5aee433 100644 --- a/WWW/Library/Implementation/HTAtom.c +++ b/WWW/Library/Implementation/HTAtom.c @@ -12,17 +12,21 @@ ** (c) Copyright CERN 1991 - See Copyright.html ** */ - #include <HTUtils.h> #define HASH_SIZE 101 /* Tunable */ #include <HTAtom.h> +/*#include <stdio.h> included by HTUtils.h -- FM *//* joe@athena, TBL 921019 */ +#include <string.h> + #include <HTList.h> #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + PRIVATE HTAtom * hash_table[HASH_SIZE]; PRIVATE BOOL initialised = NO; @@ -40,7 +44,7 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string) { int hash; HTAtom * a; - + /* First time around, clear hash table */ /* @@ -54,20 +58,21 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string) initialised = YES; atexit(free_atoms); } - + /* Generate hash function */ hash = HASH_FUNCTION(string); - + /* Search for the string in the list */ for (a = hash_table[hash]; a; a = a->next) { if (0 == strcasecomp(a->name, string)) { - /* CTRACE(tfp, "HTAtom: Old atom %p for `%s'\n", a, string); */ + /* if (TRACE) fprintf(stderr, + "HTAtom: Old atom %p for `%s'\n", a, string); */ return a; /* Found: return it */ } } - + /* Generate a new entry */ a = (HTAtom *)malloc(sizeof(*a)); @@ -80,7 +85,8 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string) a->next = hash_table[hash]; /* Put onto the head of list */ hash_table[hash] = a; #ifdef NOT_DEFINED - CTRACE(tfp, "HTAtom: New atom %p for `%s'\n", a, string); + if (TRACE) + fprintf(stderr, "HTAtom: New atom %p for `%s'\n", a, string); #endif /* NOT_DEFINED */ return a; } @@ -141,7 +147,7 @@ PRIVATE BOOL mime_match ARGS2(CONST char *, name, } return NO; } - + PUBLIC HTList *HTAtom_templateMatches ARGS1(CONST char *, templ) { diff --git a/WWW/Library/Implementation/HTAtom.h b/WWW/Library/Implementation/HTAtom.h index fda46b86..c3319a3d 100644 --- a/WWW/Library/Implementation/HTAtom.h +++ b/WWW/Library/Implementation/HTAtom.h @@ -21,6 +21,9 @@ #ifndef HTATOM_H #define HTATOM_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTList.h> #ifdef SHORT_NAMES diff --git a/WWW/Library/Implementation/HTAuth.c b/WWW/Library/Implementation/HTAuth.c index f1e7efd5..b8b4d010 100644 --- a/WWW/Library/Implementation/HTAuth.c +++ b/WWW/Library/Implementation/HTAuth.c @@ -14,6 +14,7 @@ */ #include <HTUtils.h> +#include <string.h> #include <HTPasswd.h> /* Password file routines */ #include <HTAssoc.h> #include <HTAuth.h> /* Implemented here */ @@ -98,7 +99,8 @@ PRIVATE HTAAUser *decompose_auth_string ARGS2(char *, authstring, */ username = cleartext; if (!(password = strchr(cleartext, ':'))) { - CTRACE(tfp, "%s %s\n", + if (TRACE) + fprintf(stderr, "%s %s\n", "decompose_auth_string: password field", "missing in authentication string.\n"); return NULL; @@ -114,9 +116,9 @@ PRIVATE HTAAUser *decompose_auth_string ARGS2(char *, authstring, (*(timestamp++) ='\0'), !(browsers_key=strchr(timestamp,':')) || (*(browsers_key++)='\0')) { - CTRACE(tfp, "%s %s\n", - "decompose_auth_string: Pubkey scheme", - "fields missing in authentication string"); + if (TRACE) fprintf(stderr, "%s %s\n", + "decompose_auth_string: Pubkey scheme", + "fields missing in authentication string"); return NULL; } } @@ -130,12 +132,13 @@ PRIVATE HTAAUser *decompose_auth_string ARGS2(char *, authstring, user->timestamp = timestamp; user->secret_key = browsers_key; - if (scheme == HTAA_BASIC) { - CTRACE(tfp, "decompose_auth_string: %s (%s,%s)\n", + if (TRACE) { + if (scheme==HTAA_BASIC) + fprintf(stderr, "decompose_auth_string: %s (%s,%s)\n", "Basic scheme authentication string:", username, password); - } else { - CTRACE(tfp, "decompose_auth_string: %s (%s,%s,%s,%s,%s)\n", + else + fprintf(stderr, "decompose_auth_string: %s (%s,%s,%s,%s,%s)\n", "Pubkey scheme authentication string:", username, password, i_net_adr, timestamp, browsers_key); } @@ -145,13 +148,13 @@ PRIVATE HTAAUser *decompose_auth_string ARGS2(char *, authstring, -PRIVATE BOOL HTAA_checkTimeStamp ARGS1(CONST char *, timestamp GCC_UNUSED) +PRIVATE BOOL HTAA_checkTimeStamp ARGS1(CONST char *, timestamp) { return NO; /* This is just a stub */ } -PRIVATE BOOL HTAA_checkInetAddress ARGS1(CONST char *, i_net_adr GCC_UNUSED) +PRIVATE BOOL HTAA_checkInetAddress ARGS1(CONST char *, i_net_adr) { return NO; /* This is just a stub */ } @@ -198,6 +201,7 @@ PUBLIC HTAAUser *HTAA_authenticate ARGS3(HTAAScheme, scheme, else return NULL; } + break; default: /* Other authentication routines go here */ return NULL; diff --git a/WWW/Library/Implementation/HTAuth.h b/WWW/Library/Implementation/HTAuth.h index 0e88131c..f81eb1eb 100644 --- a/WWW/Library/Implementation/HTAuth.h +++ b/WWW/Library/Implementation/HTAuth.h @@ -8,6 +8,9 @@ #ifndef HTAUTH_H #define HTAUTH_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTAAUtil.h> #include <HTAAProt.h> diff --git a/WWW/Library/Implementation/HTBTree.c b/WWW/Library/Implementation/HTBTree.c index c545eb0e..986dfc8b 100644 --- a/WWW/Library/Implementation/HTBTree.c +++ b/WWW/Library/Implementation/HTBTree.c @@ -12,14 +12,18 @@ #ifndef __STRICT_BSD__ #include <stdlib.h> #endif +#include <string.h> #define MAXIMUM(a,b) ((a)>(b)?(a):(b)) #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + + PUBLIC HTBTree * HTBTree_new ARGS1(HTComparer, comp) /********************************************************* - ** This function returns an HTBTree with memory allocated + ** This function returns an HTBTree with memory allocated ** for it when given a mean to compare things */ { @@ -69,7 +73,7 @@ PRIVATE void HTBTElementAndObject_free ARGS1(HTBTElement*, element) if (element) { /* Just in case nothing was in the tree anyway */ if (element->left != NULL) HTBTElementAndObject_free(element->left); - if (element->right != NULL) + if (element->right != NULL) HTBTElementAndObject_free(element->right); FREE(element->object); FREE(element); @@ -106,12 +110,12 @@ PUBLIC void HTBTree_add ARGS2( int depth,depth2,corrections; /* father_of_element is a pointer to the structure that is the father of the ** new object "object". - ** added_element is a pointer to the structure that contains or will contain + ** added_element is a pointer to the structure that contains or will contain ** the new object "object". ** father_of_forefather and forefather_of_element are pointers that are used ** to modify the depths of upper elements, when needed. ** - ** father_found indicates by a value NO when the future father of "object" + ** father_found indicates by a value NO when the future father of "object" ** is found. ** top_found indicates by a value NO when, in case of a difference of depths ** < 2, the top of the tree is encountered and forbids any further try to @@ -142,24 +146,24 @@ PUBLIC void HTBTree_add ARGS2( tree->top->right_depth = 0; } else - { + { father_found = YES; father_of_element = tree->top; added_element = NULL; father_of_forefather = NULL; - forefather_of_element = NULL; + forefather_of_element = NULL; while (father_found) { if (tree->compare(object,father_of_element->object)<0) { if (father_of_element->left != NULL) father_of_element = father_of_element->left; - else + else { father_found = NO; - father_of_element->left = + father_of_element->left = (HTBTElement *)malloc(sizeof(HTBTElement)); - if (father_of_element->left==NULL) + if (father_of_element->left==NULL) outofmem(__FILE__, "HTBTree_add"); added_element = father_of_element->left; added_element->up = father_of_element; @@ -172,14 +176,14 @@ PUBLIC void HTBTree_add ARGS2( } if (tree->compare(object,father_of_element->object)>=0) { - if (father_of_element->right != NULL) + if (father_of_element->right != NULL) father_of_element = father_of_element->right; - else - { + else + { father_found = NO; - father_of_element->right = + father_of_element->right = (HTBTElement *)malloc(sizeof(HTBTElement)); - if (father_of_element->right==NULL) + if (father_of_element->right==NULL) outofmem(__FILE__, "HTBTree_add"); added_element = father_of_element->right; added_element->up = father_of_element; @@ -187,7 +191,7 @@ PUBLIC void HTBTree_add ARGS2( added_element->left = NULL; added_element->left_depth = 0; added_element->right = NULL; - added_element->right_depth = 0; + added_element->right_depth = 0; } } } @@ -201,7 +205,7 @@ PUBLIC void HTBTree_add ARGS2( if (father_of_forefather->left == forefather_of_element) { depth = father_of_forefather->left_depth; - father_of_forefather->left_depth = 1 + father_of_forefather->left_depth = 1 + MAXIMUM(forefather_of_element->right_depth, forefather_of_element->left_depth); depth2 = father_of_forefather->left_depth; @@ -217,7 +221,7 @@ PUBLIC void HTBTree_add ARGS2( forefather_of_element = father_of_forefather; father_of_forefather = father_of_forefather->up; } while ((depth != depth2) && (father_of_forefather != NULL)); - + /* @@ -230,7 +234,7 @@ PUBLIC void HTBTree_add ARGS2( if ((abs(father_of_element->left_depth - father_of_element->right_depth)) < 2) { - if (father_of_element->up != NULL) + if (father_of_element->up != NULL) father_of_element = father_of_element->up; else top_found = NO; } @@ -238,8 +242,8 @@ PUBLIC void HTBTree_add ARGS2( { /* We start the process of balancing */ corrections = corrections + 1; - /* - ** corrections is an integer used to avoid infinite + /* + ** corrections is an integer used to avoid infinite ** loops in cases such as: ** ** 3 3 @@ -247,22 +251,22 @@ PUBLIC void HTBTree_add ARGS2( ** 5 5 ** ** 3 is used to show that it need not be the top of the tree - ** But let's avoid these two exceptions anyhow + ** But let's avoid these two exceptions anyhow ** with the two following conditions (4 March 94 - AS) */ - if ((father_of_element->left == NULL) - && (father_of_element->right->right == NULL) - && (father_of_element->right->left->left == NULL) - && (father_of_element->right->left->right == NULL)) + if ((father_of_element->left == NULL) + && (father_of_element->right->right == NULL) + && (father_of_element->right->left->left == NULL) + && (father_of_element->right->left->right == NULL)) corrections = 7; - if ((father_of_element->right == NULL) - && (father_of_element->left->left == NULL) - && (father_of_element->left->right->right == NULL) + if ((father_of_element->right == NULL) + && (father_of_element->left->left == NULL) + && (father_of_element->left->right->right == NULL) && (father_of_element->left->right->left == NULL)) corrections = 7; - + if (father_of_element->left_depth > father_of_element->right_depth) { @@ -279,7 +283,7 @@ PUBLIC void HTBTree_add ARGS2( father_of_forefather = father_of_element->up; forefather_of_element = added_element; first_time = YES; - do + do { if (father_of_forefather->left == forefather_of_element->up) @@ -308,7 +312,7 @@ PUBLIC void HTBTree_add ARGS2( + MAXIMUM(forefather_of_element->left_depth, forefather_of_element->right_depth); first_time = NO; - } + } else father_of_forefather->right_depth = 1 + MAXIMUM(forefather_of_element->up->left_depth, @@ -317,7 +321,7 @@ PUBLIC void HTBTree_add ARGS2( } forefather_of_element = forefather_of_element->up; father_of_forefather = father_of_forefather->up; - } while ((depth != depth2) && + } while ((depth != depth2) && (father_of_forefather != NULL)); father_of_forefather = father_of_element->up; if (father_of_forefather->left == father_of_element) @@ -330,7 +334,7 @@ PUBLIC void HTBTree_add ARGS2( ** ** 3 is used to show that it may not be the top of the ** tree. - */ + */ father_of_forefather->left = added_element; father_of_element->left = added_element->right; added_element->right = father_of_element; @@ -360,7 +364,7 @@ PUBLIC void HTBTree_add ARGS2( ** When tree 2 3 becomes 4 1 ** 4 5 5 3 ** - ** 1 is used to show that it is the top of the tree + ** 1 is used to show that it is the top of the tree */ added_element->up = NULL; father_of_element->left = added_element->right; @@ -374,7 +378,7 @@ PUBLIC void HTBTree_add ARGS2( { added_element = father_of_element->right; father_of_element->right_depth = added_element->left_depth; - added_element->left_depth = 1 + + added_element->left_depth = 1 + MAXIMUM(father_of_element->right_depth, father_of_element->left_depth); if (father_of_element->up != NULL) @@ -385,9 +389,9 @@ PUBLIC void HTBTree_add ARGS2( father_of_forefather = father_of_element->up; forefather_of_element = added_element; first_time = YES; - do + do { - if (father_of_forefather->left + if (father_of_forefather->left == forefather_of_element->up) { depth = father_of_forefather->left_depth; @@ -422,7 +426,7 @@ PUBLIC void HTBTree_add ARGS2( } father_of_forefather = father_of_forefather->up; forefather_of_element = forefather_of_element->up; - } while ((depth != depth2) && + } while ((depth != depth2) && (father_of_forefather != NULL)); father_of_forefather = father_of_element->up; if (father_of_forefather->left == father_of_element) @@ -492,7 +496,7 @@ PUBLIC HTBTElement * HTBTree_next ARGS2( HTBTElement*, ele) /************************************************************************** ** this function returns a pointer to the leftmost element if ele is NULL, - ** and to the next object to the right otherwise. + ** and to the next object to the right otherways. ** If no elements left, returns a pointer to NULL. */ { @@ -518,7 +522,7 @@ PUBLIC HTBTElement * HTBTree_next ARGS2( else { father_of_forefather = father_of_element->up; - while (father_of_forefather && + while (father_of_forefather && (father_of_forefather->right == father_of_element)) { father_of_element = father_of_forefather; @@ -540,7 +544,7 @@ PUBLIC HTBTElement * HTBTree_next ARGS2( else printf("Pas de Pere\n"); if (father_of_element->left != NULL) printf("Objet du fils gauche = %s\t", - (char *)father_of_element->left->object); + (char *)father_of_element->left->object); else printf("Pas de fils gauche\t"); if (father_of_element->right != NULL) printf("Objet du fils droit = %s\n", @@ -563,7 +567,7 @@ main () { HTBTree * tree; HTBTElement * next_element; - + tree = HTBTree_new((HTComparer)strcasecomp); HTBTree_add(tree,"hypertext"); HTBTree_add(tree,"Addressing"); diff --git a/WWW/Library/Implementation/HTBTree.h b/WWW/Library/Implementation/HTBTree.h index 6facd048..55bfe6ab 100644 --- a/WWW/Library/Implementation/HTBTree.h +++ b/WWW/Library/Implementation/HTBTree.h @@ -9,11 +9,6 @@ part of libWWW */ -#ifndef HTBTREE_H -#define HTBTREE_H 1 - -#include <HTUtils.h> - #ifdef SHORT_NAMES #define HTBTree_new HTBTNew #define HTBTree_free HTBTFree @@ -104,4 +99,6 @@ Find next element in depth-first order */ extern HTBTElement * HTBTree_next PARAMS((HTBTree* tree, HTBTElement * ele)); -#endif /* HTBTREE_H */ +/* + + end */ diff --git a/WWW/Library/Implementation/HTCJK.h b/WWW/Library/Implementation/HTCJK.h index bc2c3aac..c5fa51af 100644 --- a/WWW/Library/Implementation/HTCJK.h +++ b/WWW/Library/Implementation/HTCJK.h @@ -11,8 +11,6 @@ #ifndef HTCJK_H #define HTCJK_H -#include <HTUtils.h> - /* ** STATUS CHANGE CODES */ @@ -98,15 +96,15 @@ extern unsigned char * EUC_TO_JIS PARAMS(( CONST char * toA)); extern unsigned char * TO_EUC PARAMS(( - CONST unsigned char * jis, + unsigned char * jis, unsigned char * euc)); extern void TO_SJIS PARAMS(( - CONST unsigned char * any, + unsigned char * any, unsigned char * sjis)); extern void TO_JIS PARAMS(( - CONST unsigned char * any, + unsigned char * any, unsigned char * jis)); #endif /* HTCJK_H */ diff --git a/WWW/Library/Implementation/HTChunk.c b/WWW/Library/Implementation/HTChunk.c index 7cab693c..db06f64e 100644 --- a/WWW/Library/Implementation/HTChunk.c +++ b/WWW/Library/Implementation/HTChunk.c @@ -5,9 +5,12 @@ #include <HTUtils.h> #include <HTChunk.h> +/*#include <stdio.h> included by HTUtils.h -- FM */ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* Create a chunk with a certain allocation unit ** -------------- */ diff --git a/WWW/Library/Implementation/HTChunk.h b/WWW/Library/Implementation/HTChunk.h index 2afcdd9d..84c12de7 100644 --- a/WWW/Library/Implementation/HTChunk.h +++ b/WWW/Library/Implementation/HTChunk.h @@ -7,10 +7,6 @@ automatically reallocating them as necessary. */ -#ifndef HTCHUNK_H -#define HTCHUNK_H 1 - -#include <HTUtils.h> #include <UCMap.h> typedef struct { @@ -170,4 +166,6 @@ Append a zero character to a chunk extern void HTChunkTerminate PARAMS((HTChunk * ch)); -#endif /* HTCHUNK_H */ +/* + + end */ diff --git a/WWW/Library/Implementation/HTDOS.c b/WWW/Library/Implementation/HTDOS.c index 2004f97b..5e22915b 100644 --- a/WWW/Library/Implementation/HTDOS.c +++ b/WWW/Library/Implementation/HTDOS.c @@ -2,8 +2,9 @@ */ -#include <HTUtils.h> -#include <HTDOS.h> +#include <mem.h> +#include <dos.h> + /* PUBLIC HTDOS_wwwName() ** CONVERTS DOS Name into WWW Name @@ -66,11 +67,10 @@ char * HTDOS_name(char *wwwname) } } - /* Needed to surf the root of a local drive. */ - - if(strlen(cp_url) < 4) cp_url[2] = ':'; +/* if(strlen(cp_url) < 4) cp_url[] = ':'; if(strlen(cp_url) == 3) cp_url[3] = '\\'; - if(strlen(cp_url) == 4) cp_url[4] = '.'; + + if(strlen(cp_url) == 4) cp_url[4] = '.'; */ if((strlen(cp_url) > 2) && (cp_url[1] == '|')) cp_url[1] = ':'; @@ -81,18 +81,14 @@ char * HTDOS_name(char *wwwname) printf("\n\n%s = i%\n\n",cp_url,strlen(cp_url)); sleep(5); #endif - CTRACE(tfp, "HTDOS_name changed `%s' to `%s'\n", - wwwname, cp_url); strcpy(wwwname, cp_url); - return(wwwname); /* return(cp_url); */ + return(wwwname); /* return(cp_url); */ } else { #if 0 printf("\n\n%s = %i\n\n",cp_url+1,strlen(cp_url)); sleep(5); #endif - CTRACE(tfp, "HTDOS_name changed `%s' to `%s'\n", - wwwname, cp_url+1); strcpy(wwwname, cp_url+1); - return(wwwname); /* return(cp_url+1); */ + return(wwwname); /* return(cp_url+1); */ } } diff --git a/WWW/Library/Implementation/HTDOS.h b/WWW/Library/Implementation/HTDOS.h index ff2ba194..d2a2e0be 100644 --- a/WWW/Library/Implementation/HTDOS.h +++ b/WWW/Library/Implementation/HTDOS.h @@ -13,7 +13,7 @@ ** returns WWW file specification ** */ -char * HTDOS_wwwName PARAMS((char * dosname)); +char * HTDOS_wwwName (char * dosname); /* PUBLIC HTDOS_name() @@ -26,7 +26,7 @@ char * HTDOS_wwwName PARAMS((char * dosname)); ** ** Bug: Returns pointer to static -- non-reentrant */ -char * HTDOS_name PARAMS((char * wwwname)); +char * HTDOS_name (char * wwwname); #endif /* HTDOS_H */ diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index bd5a2ce7..48d0aa36 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -76,6 +76,7 @@ BUGS: @@@ Limit connection cache size! #endif #include <HTUtils.h> +#include <tcp.h> #include <HTAlert.h> @@ -109,8 +110,6 @@ BUGS: @@@ Limit connection cache size! #define IPPORT_FTP 21 #endif /* !IPORT_FTP */ -#include <LYUtils.h> -#include <LYStrings.h> #include <LYLeaks.h> typedef struct _connection { @@ -139,10 +138,15 @@ struct _HTStructured { /* ... */ }; +#define FREE(x) if (x) {free(x); x = NULL;} + +extern int HTCheckForInterrupt NOPARAMS; + + /* Global Variables ** --------------------- */ -PUBLIC int HTfileSortMethod = FILE_BY_NAME; +PUBLIC BOOLEAN HTfileSortMethod = FILE_BY_NAME; PRIVATE char ThisYear[8]; PRIVATE char LastYear[8]; PRIVATE int TheDate; @@ -260,15 +264,14 @@ PUBLIC char * HTMake_VMS_name ARGS2( strcpy(nodename, ""); /* On same node? Yes if node names match */ if (strncmp(nn, "localhost", 9)) { CONST char *p; - CONST char *q; - for (p = hostname, q = nn; + char *q; + for (p = hostname, q = (char *)nn; *p && *p != '.' && *q && *q != '.'; p++, q++){ if (TOUPPER(*p) != TOUPPER(*q)) { - char *r; strcpy(nodename, nn); - r = strchr(nodename, '.'); /* Mismatch */ - if (r) - *r = '\0'; /* Chop domain */ + q = strchr(nodename, '.'); /* Mismatch */ + if (q) + *q = '\0'; /* Chop domain */ strcat(nodename, "::"); /* Try decnet anyway */ break; } @@ -335,7 +338,7 @@ PRIVATE int close_connection ARGS1( connection * scan; int status = NETCLOSE(con->socket); if (TRACE) { - CTRACE(tfp, "HTFTP: Closing control socket %d\n", con->socket); + fprintf(stderr, "HTFTP: Closing control socket %d\n", con->socket); #ifdef UNIX if (status != 0) perror("HTFTP:close_connection"); @@ -372,7 +375,8 @@ PRIVATE void help_message_cache_add ARGS1( else StrAllocCopy(help_message_buffer, string); - CTRACE(tfp,"Adding message to help cache: %s\n",string); + if (TRACE) + fprintf(stderr,"Adding message to help cache: %s\n",string); } PRIVATE char *help_message_cache_non_empty NOARGS @@ -413,12 +417,14 @@ PRIVATE int response ARGS1( int status; if (!control) { - CTRACE(tfp, "HTFTP: No control connection set up!!\n"); - return -99; + if (TRACE) + fprintf(stderr, "HTFTP: No control connection set up!!\n"); + return -99; } if (cmd) { - CTRACE(tfp, " Tx: %s", cmd); + if (TRACE) + fprintf(stderr, " Tx: %s", cmd); #ifdef NOT_ASCII { char * p; @@ -429,7 +435,9 @@ PRIVATE int response ARGS1( #endif /* NOT_ASCII */ status = NETWRITE(control->socket, cmd, (int)strlen(cmd)); if (status < 0) { - CTRACE(tfp, "HTFTP: Error %d sending command: closing socket %d\n", + if (TRACE) + fprintf(stderr, + "HTFTP: Error %d sending command: closing socket %d\n", status, control->socket); close_connection(control); return status; @@ -444,15 +452,19 @@ PRIVATE int response ARGS1( char continuation; - if (interrupted_in_htgetcharacter) { - CTRACE (tfp, "HTFTP: Interrupted in HTGetCharacter, apparently.\n"); + if (interrupted_in_htgetcharacter) + { + if (TRACE) + fprintf (stderr, + "HTFTP: Interrupted in HTGetCharacter, apparently.\n"); NETCLOSE (control->socket); control->socket = -1; return HT_INTERRUPTED; - } + } *p = '\0'; /* Terminate the string */ - CTRACE(tfp, " Rx: %s", response_text); + if (TRACE) + fprintf(stderr, " Rx: %s", response_text); /* Check for login or help messages */ if (!strncmp(response_text,"230-",4) || @@ -472,15 +484,19 @@ PRIVATE int response ARGS1( break; } /* if end of line */ - if (interrupted_in_htgetcharacter) { - CTRACE (tfp, "HTFTP: Interrupted in HTGetCharacter, apparently.\n"); - NETCLOSE (control->socket); - control->socket = -1; - return HT_INTERRUPTED; - } + if (interrupted_in_htgetcharacter) + { + if (TRACE) + fprintf (stderr, + "HTFTP: Interrupted in HTGetCharacter, apparently.\n"); + NETCLOSE (control->socket); + control->socket = -1; + return HT_INTERRUPTED; + } if (*(p-1) == (char) EOF) { - CTRACE(tfp, "Error on rx: closing socket %d\n", + if (TRACE) + fprintf(stderr, "Error on rx: closing socket %d\n", control->socket); strcpy(response_text, "000 *** TCP read error on response\n"); close_connection(control); @@ -491,7 +507,8 @@ PRIVATE int response ARGS1( } while (continuation_response != -1); if (result == 421) { - CTRACE(tfp, "HTFTP: They close so we close socket %d\n", + if (TRACE) + fprintf(stderr, "HTFTP: They close so we close socket %d\n", control->socket); close_connection(control); return -1; @@ -547,7 +564,8 @@ PRIVATE void get_ftp_pwd ARGS2( if (*ServerType == TCPC_SERVER) { *ServerType = ((response_text[5] == '/') ? NCSA_SERVER : TCPC_SERVER); - CTRACE(tfp, "HTFTP: Treating as %s server.\n", + if (TRACE) + fprintf(stderr, "HTFTP: Treating as %s server.\n", ((*ServerType == NCSA_SERVER) ? "NCSA" : "TCPC")); } else if (response_text[5] == '/') { @@ -556,21 +574,25 @@ PRIVATE void get_ftp_pwd ARGS2( */ if (set_mac_binary(*ServerType)) { *ServerType = NCSA_SERVER; - CTRACE(tfp, "HTFTP: Treating as NCSA server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as NCSA server.\n"); } else { *ServerType = UNIX_SERVER; *UseList = TRUE; - CTRACE(tfp, "HTFTP: Treating as Unix server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as Unix server.\n"); } return; } else if (response_text[strlen(response_text)-1] == ']') { /* path names ending with ] imply VMS, right? */ *ServerType = VMS_SERVER; *UseList = TRUE; - CTRACE(tfp, "HTFTP: Treating as VMS server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as VMS server.\n"); } else { *ServerType = GENERIC_SERVER; - CTRACE(tfp, "HTFTP: Treating as Generic server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as Generic server.\n"); } if ((*ServerType == NCSA_SERVER) || @@ -691,35 +713,42 @@ PRIVATE int get_connection ARGS2( FREE(p1); } /* scope of p1 */ - status = HTDoConnect (arg, "FTP", IPPORT_FTP, (int *)&con->socket); + status = HTDoConnect (arg, "FTP", IPPORT_FTP, (int *)&con->socket); - if (status < 0) { - if (status == HT_INTERRUPTED) { - CTRACE (tfp, "HTFTP: Interrupted on connect\n"); - } else { - CTRACE(tfp, "HTFTP: Unable to connect to remote host for `%s'.\n", - arg); - } - if (status == HT_INTERRUPTED) { - _HTProgress ("Connection interrupted."); - status = HT_NOT_LOADED; - } else { - HTAlert("Unable to connect to FTP host."); + if (status < 0) + { + if (TRACE) + { + if (status == HT_INTERRUPTED) + fprintf (stderr, + "HTFTP: Interrupted on connect\n"); + else + fprintf(stderr, + "HTFTP: Unable to connect to remote host for `%s'.\n", + arg); } - if (con->socket != -1) + if (status == HT_INTERRUPTED) { + _HTProgress ("Connection interrupted."); + status = HT_NOT_LOADED; + } else { + HTAlert("Unable to connect to FTP host."); + } + if (con->socket != -1) { NETCLOSE(con->socket); } - FREE(username); - if (control == con) - control = NULL; - FREE(con); - return status; /* Bad return */ + FREE(username); + if (control == con) + control = NULL; + FREE(con); + return status; /* Bad return */ } - CTRACE(tfp, "FTP connected, socket %d control %ld\n", - con->socket, (long)con); + if (TRACE) { + fprintf(stderr, "FTP connected, socket %d control %ld\n", + con->socket, (long)con); + } control = con; /* Current control connection */ /* Initialise buffering for control connection */ @@ -731,13 +760,16 @@ PRIVATE int get_connection ARGS2( */ status = response((char *)0); /* Get greeting */ - if (status == HT_INTERRUPTED) { - CTRACE (tfp, "HTFTP: Interrupted at beginning of login.\n"); + if (status == HT_INTERRUPTED) + { + if (TRACE) + fprintf (stderr, + "HTFTP: Interrupted at beginning of login.\n"); _HTProgress ("Connection interrupted."); NETCLOSE(control->socket); control->socket = -1; return HT_INTERRUPTED; - } + } server_type = GENERIC_SERVER; /* reset */ if (status == 2) { /* Send username */ char *cp; /* look at greeting text */ @@ -768,13 +800,16 @@ PRIVATE int get_connection ARGS2( } status = response(command); FREE(command); - if (status == HT_INTERRUPTED) { - CTRACE (tfp, "HTFTP: Interrupted while sending username.\n"); + if (status == HT_INTERRUPTED) + { + if (TRACE) + fprintf (stderr, + "HTFTP: Interrupted while sending username.\n"); _HTProgress ("Connection interrupted."); NETCLOSE(control->socket); control->socket = -1; return HT_INTERRUPTED; - } + } } if (status == 3) { /* Send password */ if (password) { @@ -831,14 +866,16 @@ PRIVATE int get_connection ARGS2( } status = response(command); FREE(command); - if (status == HT_INTERRUPTED) { - CTRACE (tfp, + if (status == HT_INTERRUPTED) + { + if (TRACE) + fprintf (stderr, "HTFTP: Interrupted while sending password.\n"); _HTProgress ("Connection interrupted."); NETCLOSE(control->socket); control->socket = -1; return HT_INTERRUPTED; - } + } } FREE(username); @@ -846,21 +883,25 @@ PRIVATE int get_connection ARGS2( char temp[80]; sprintf(temp, "ACCT noaccount%c%c", CR, LF); status = response(temp); - if (status == HT_INTERRUPTED) { - CTRACE (tfp, "HTFTP: Interrupted while sending password.\n"); + if (status == HT_INTERRUPTED) + { + if (TRACE) + fprintf (stderr, + "HTFTP: Interrupted while sending password.\n"); _HTProgress ("Connection interrupted."); NETCLOSE(control->socket); control->socket = -1; return HT_INTERRUPTED; - } + } } if (status != 2) { - CTRACE(tfp, "HTFTP: Login fail: %s", response_text); + if (TRACE) + fprintf(stderr, "HTFTP: Login fail: %s", response_text); /* if (control->socket > 0) close_connection(control->socket); */ return -1; /* Bad return */ } - CTRACE(tfp, "HTFTP: Logged in.\n"); + if (TRACE) fprintf(stderr, "HTFTP: Logged in.\n"); /** Check for host type **/ if (server_type != NETPRESENZ_SERVER) @@ -872,71 +913,88 @@ PRIVATE int get_connection ARGS2( "UNIX Type: L8 MAC-OS MachTen", 28) == 0) { server_type = MACHTEN_SERVER; use_list = TRUE; - CTRACE(tfp, "HTFTP: Treating as MachTen server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as MachTen server.\n"); } else if (strstr(response_text+4, "UNIX") != NULL || strstr(response_text+4, "Unix") != NULL) { server_type = UNIX_SERVER; use_list = TRUE; - CTRACE(tfp, "HTFTP: Treating as Unix server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as Unix server.\n"); } else if (strstr(response_text+4, "MSDOS") != NULL) { server_type = MSDOS_SERVER; use_list = TRUE; - CTRACE(tfp, "HTFTP: Treating as MSDOS (Unix emulation) server.\n"); + if (TRACE) + fprintf(stderr, + "HTFTP: Treating as MSDOS (Unix emulation) server.\n"); } else if (strncmp(response_text+4, "VMS", 3) == 0) { server_type = VMS_SERVER; use_list = TRUE; - CTRACE(tfp, "HTFTP: Treating as VMS server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as VMS server.\n"); } else if ((strncmp(response_text+4, "VM/CMS", 6) == 0) || (strncmp(response_text+4, "VM ", 3) == 0)) { server_type = CMS_SERVER; use_list = TRUE; - CTRACE(tfp, "HTFTP: Treating as CMS server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as CMS server.\n"); } else if (strncmp(response_text+4, "DCTS", 4) == 0) { server_type = DCTS_SERVER; - CTRACE(tfp, "HTFTP: Treating as DCTS server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as DCTS server.\n"); } else if (strstr(response_text+4, "MAC-OS TCP/Connect II") != NULL) { server_type = TCPC_SERVER; - CTRACE(tfp, "HTFTP: Looks like a TCPC server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Looks like a TCPC server.\n"); get_ftp_pwd(&server_type, &use_list); unsure_type = TRUE; } else if (server_type == NETPRESENZ_SERVER) { /* already set above */ use_list = TRUE; set_mac_binary(server_type); - CTRACE(tfp, "HTFTP: Treating as NetPresenz (MACOS) server.\n"); + if (TRACE) + fprintf(stderr, + "HTFTP: Treating as NetPresenz (MACOS) server.\n"); } else if (strncmp(response_text+4, "MACOS Peter's Server", 20) == 0) { server_type = PETER_LEWIS_SERVER; use_list = TRUE; set_mac_binary(server_type); - CTRACE(tfp, "HTFTP: Treating as Peter Lewis (MACOS) server.\n"); + if (TRACE) + fprintf(stderr, + "HTFTP: Treating as Peter Lewis (MACOS) server.\n"); } else if (strncmp(response_text+4, "Windows_NT", 10) == 0) { server_type = WINDOWS_NT_SERVER; use_list = TRUE; - CTRACE(tfp, "HTFTP: Treating as Window_NT server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as Window_NT server.\n"); } else if (strncmp(response_text+4, "MS Windows", 10) == 0) { server_type = MS_WINDOWS_SERVER; use_list = TRUE; - CTRACE(tfp, "HTFTP: Treating as MS Windows server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Treating as MS Windows server.\n"); } else if (strncmp(response_text+4, "MACOS AppleShare IP FTP Server", 30) == 0) { server_type = APPLESHARE_SERVER; use_list = TRUE; set_mac_binary(server_type); - CTRACE(tfp, "HTFTP: Treating as AppleShare server.\n"); + if (TRACE) + fprintf(stderr, + "HTFTP: Treating as AppleShare server.\n"); } else { server_type = GENERIC_SERVER; - CTRACE(tfp, "HTFTP: Ugh! A Generic server.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Ugh! A Generic server.\n"); get_ftp_pwd(&server_type, &use_list); unsure_type = TRUE; } @@ -955,7 +1013,8 @@ PRIVATE int get_connection ARGS2( close_connection(control->socket); return -status; /* Bad return */ } - CTRACE(tfp, "HTFTP: Port defined.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Port defined.\n"); } #endif /* NOTREPEAT_PORT */ return con->socket; /* Good return */ @@ -974,7 +1033,8 @@ PRIVATE int close_master_socket NOARGS int status; FD_CLR(master_socket, &open_sockets); status = NETCLOSE(master_socket); - CTRACE(tfp, "HTFTP: Closed master socket %d\n", master_socket); + if (TRACE) + fprintf(stderr, "HTFTP: Closed master socket %d\n", master_socket); master_socket = -1; if (status < 0) return HTInetStatus("close master socket"); @@ -1019,7 +1079,8 @@ PRIVATE int get_listen_socket NOARGS if (new_socket < 0) return HTInetStatus("socket for master socket"); - CTRACE(tfp, "HTFTP: Opened master socket number %d\n", new_socket); + if (TRACE) + fprintf(stderr, "HTFTP: Opened master socket number %d\n", new_socket); /* Search for a free port. */ @@ -1054,7 +1115,9 @@ PRIVATE int get_listen_socket NOARGS /* Cast to generic sockaddr */ sizeof(soc_address))) == 0) break; - CTRACE(tfp, "TCP bind attempt to port %d yields %d, errno=%d\n", + if (TRACE) + fprintf(stderr, + "TCP bind attempt to port %d yields %d, errno=%d\n", port_number, status, SOCKET_ERRNO); } /* for */ } @@ -1398,8 +1461,7 @@ PRIVATE void parse_vms_dir_entry ARGS2( char *, line, EntryInfo *, entry_info) { - int i, j; - unsigned int ialloc; + int i, j, ialloc; char *cp, *cpd, *cps, date[16], *sp = " "; /** Get rid of blank lines, and information lines. **/ @@ -1415,8 +1477,8 @@ PRIVATE void parse_vms_dir_entry ARGS2( /** Cast VMS non-README file and directory names to lowercase. **/ if (strstr(entry_info->filename, "READ") == NULL) { - LYLowerCase(entry_info->filename); - i = strlen(entry_info->filename); + for (i = 0; entry_info->filename[i]; i++) + entry_info->filename[i] = TOLOWER(entry_info->filename[i]); } else { i = ((strstr(entry_info->filename, "READ") - entry_info->filename) + 4); if (!strncmp((char *)&entry_info->filename[i], "ME", 2)) { @@ -1429,7 +1491,8 @@ PRIVATE void parse_vms_dir_entry ARGS2( } else { i = 0; } - LYLowerCase(entry_info->filename + i); + for (; entry_info->filename[i]; i++) + entry_info->filename[i] = TOLOWER(entry_info->filename[i]); } /** Uppercase terminal .z's or _z's. **/ @@ -1529,10 +1592,11 @@ PRIVATE void parse_vms_dir_entry ARGS2( } /** Wrap it up **/ - CTRACE(tfp, "HTFTP: VMS filename: %s date: %s size: %d\n", - entry_info->filename, - entry_info->date ? entry_info->date : "", - entry_info->size); + if (TRACE) + fprintf(stderr, "HTFTP: VMS filename: %s date: %s size: %d\n", + entry_info->filename, + entry_info->date ? entry_info->date : "", + entry_info->size); return; } /* parse_vms_dir_entry() */ @@ -1550,22 +1614,28 @@ PRIVATE void parse_ms_windows_dir_entry ARGS2( char *end = line + strlen(line); /** Get rid of blank or junk lines. **/ - cp = LYSkipBlanks(cp); + while (*cp && isspace(*cp)) + cp++; if (!(*cp)) { entry_info->display = FALSE; return; } /** Cut out file or directory name. **/ - cps = LYSkipNonBlanks(cp); + cps = cp; + while (*cps && !isspace(*cps)) + cps++; *cps++ ='\0'; cpd = cps; StrAllocCopy(entry_info->filename, cp); /** Track down the size **/ if (cps < end) { - cps = LYSkipBlanks(cps); - cpd = LYSkipNonBlanks(cps); + while (*cps && isspace(*cps)) + cps++; + cpd = cps; + while (*cpd && !isspace(*cpd)) + cpd++; *cpd++ = '\0'; if (isdigit(*cps)) { entry_info->size = atoi(cps); @@ -1583,7 +1653,8 @@ PRIVATE void parse_ms_windows_dir_entry ARGS2( /** Track down the date. **/ if (cpd < end) { - cpd = LYSkipBlanks(cpd); + while (*cpd && isspace(*cpd)) + cpd++; if (strlen(cpd) > 17) { *(cpd+6) = '\0'; /* Month and Day */ *(cpd+11) = '\0'; /* Year */ @@ -1602,10 +1673,11 @@ PRIVATE void parse_ms_windows_dir_entry ARGS2( } /** Wrap it up **/ - CTRACE(tfp, "HTFTP: MS Windows filename: %s date: %s size: %d\n", - entry_info->filename, - entry_info->date ? entry_info->date : "", - entry_info->size); + if (TRACE) + fprintf(stderr, "HTFTP: MS Windows filename: %s date: %s size: %d\n", + entry_info->filename, + entry_info->date ? entry_info->date : "", + entry_info->size); return; } /* parse_ms_windows_dir_entry */ @@ -1625,7 +1697,8 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2( int i; /** Get rid of blank or junk lines. **/ - cp = LYSkipBlanks(cp); + while (*cp && isspace(*cp)) + cp++; if (!(*cp)) { entry_info->display = FALSE; return; @@ -1633,7 +1706,9 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2( /** Cut out file or directory name. **/ cpd = cp; - cps = LYSkipNonBlanks(end-1); + cps = (end-1); + while (cps >= cpd && !isspace(*cps)) + cps--; cp = (cps+1); if (!strcmp(cp, ".") || !strcmp(cp, "..")) { entry_info->display = FALSE; @@ -1652,14 +1727,18 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2( /** Cut out the date. **/ cp = cps = cpd; - cps = LYSkipNonBlanks(cps); + while (*cps && !isspace(*cps)) + cps++; *cps++ ='\0'; if (cps > end) { entry_info->display = FALSE; return; } - cps = LYSkipBlanks(cps); - cpd = LYSkipNonBlanks(cps); + while (*cps && isspace(*cps)) + cps++; + cpd = cps; + while (*cps && !isspace(*cps)) + cps++; *cps++ ='\0'; if (cps > end || cpd == cps || strlen(cpd) < 7) { entry_info->display = FALSE; @@ -1700,8 +1779,11 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2( /** Track down the size **/ if (cps < end) { - cps = LYSkipBlanks(cps); - cpd = LYSkipNonBlanks(cps); + while (*cps && isspace(*cps)) + cps++; + cpd = cps; + while (*cpd && !isspace(*cpd)) + cpd++; *cpd = '\0'; if (isdigit(*cps)) { entry_info->size = atoi(cps); @@ -1713,10 +1795,11 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2( } /** Wrap it up **/ - CTRACE(tfp, "HTFTP: Windows NT filename: %s date: %s size: %d\n", - entry_info->filename, - entry_info->date ? entry_info->date : "", - entry_info->size); + if (TRACE) + fprintf(stderr, "HTFTP: Windows NT filename: %s date: %s size: %d\n", + entry_info->filename, + entry_info->date ? entry_info->date : "", + entry_info->size); return; } /* parse_windows_nt_dir_entry */ #endif /* NOTDEFINED */ @@ -1738,20 +1821,25 @@ PRIVATE void parse_cms_dir_entry ARGS2( int i; /** Get rid of blank or junk lines. **/ - cp = LYSkipBlanks(cp); + while (*cp && isspace(*cp)) + cp++; if (!(*cp)) { entry_info->display = FALSE; return; } /** Cut out file or directory name. **/ - cps = LYSkipNonBlanks(cp); + cps = cp; + while (*cps && !isspace(*cps)) + cps++; *cps++ ='\0'; StrAllocCopy(entry_info->filename, cp); if (strchr(entry_info->filename, '.') != NULL) /** If we already have a dot, we did an NLST. **/ return; - cp = LYSkipBlanks(cps); + cp = cps; + while (*cp && isspace(*cp)) + cp++; if (!(*cp)) { /** If we don't have more, we've misparsed. **/ FREE(entry_info->filename); @@ -1759,7 +1847,9 @@ PRIVATE void parse_cms_dir_entry ARGS2( entry_info->display = FALSE; return; } - cps = LYSkipNonBlanks(cp); + cps = cp; + while (*cps && !isspace(*cps)) + cps++; *cps++ ='\0'; if ((0 == strcasecomp(cp, "DIR")) && (cp - line) > 17) { /** It's an SFS directory. **/ @@ -1774,8 +1864,11 @@ PRIVATE void parse_cms_dir_entry ARGS2( /** Track down the VM/CMS RECFM or type. **/ cp = cps; if (cp < end) { - cp = LYSkipBlanks(cp); - cps = LYSkipNonBlanks(cp); + while (*cp && isspace(*cp)) + cp++; + cps = cp; + while (*cps && !isspace(*cps)) + cps++; *cps++ = '\0'; /** Check cp here, if it's relevant someday. **/ } @@ -1784,8 +1877,11 @@ PRIVATE void parse_cms_dir_entry ARGS2( /** Track down the record length or dash. **/ cp = cps; if (cp < end) { - cp = LYSkipBlanks(cp); - cps = LYSkipNonBlanks(cp); + while (*cp && isspace(*cp)) + cp++; + cps = cp; + while (*cps && !isspace(*cps)) + cps++; *cps++ = '\0'; if (isdigit(*cp)) { RecordLength = atoi(cp); @@ -1795,8 +1891,11 @@ PRIVATE void parse_cms_dir_entry ARGS2( /** Track down the number of records or the dash. **/ cp = cps; if (cps < end) { - cp = LYSkipBlanks(cp); - cps = LYSkipNonBlanks(cp); + while (*cp && isspace(*cp)) + cp++; + cps = cp; + while (*cps && !isspace(*cps)) + cps++; *cps++ = '\0'; if (isdigit(*cp)) { Records = atoi(cp); @@ -1855,10 +1954,11 @@ PRIVATE void parse_cms_dir_entry ARGS2( } /** Wrap it up. **/ - CTRACE(tfp, "HTFTP: VM/CMS filename: %s date: %s size: %d\n", - entry_info->filename, - entry_info->date ? entry_info->date : "", - entry_info->size); + if (TRACE) + fprintf(stderr, "HTFTP: VM/CMS filename: %s date: %s size: %d\n", + entry_info->filename, + entry_info->date ? entry_info->date : "", + entry_info->size); return; } /* parse_cms_dir_entry */ @@ -2092,6 +2192,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2( */ StrAllocCopy(entry_info->filename, entry); return(entry_info); /* mostly empty info */ + break; /* not needed */ } /* switch (server_type) */ @@ -2158,6 +2259,7 @@ PRIVATE int compare_EntryInfo_structs ARGS2( return(1); else return(-1); + break; case FILE_BY_TYPE: if (entry1->type && entry2->type) { @@ -2167,6 +2269,7 @@ PRIVATE int compare_EntryInfo_structs ARGS2( /* else fall to filename comparison */ } return (strcmp(entry1->filename, entry2->filename)); + break; case FILE_BY_DATE: if (entry1->date && entry2->date) { @@ -2258,6 +2361,7 @@ PRIVATE int compare_EntryInfo_structs ARGS2( /* else fall to filename comparison */ } return (strcmp(entry1->filename, entry2->filename)); + break; case FILE_BY_NAME: default: @@ -2427,13 +2531,15 @@ AgainForMultiNet: if (c == (char) EOF && chunk->size == 1) /* 1 means empty: includes terminating 0 */ break; - CTRACE(tfp, "HTFTP: Line in %s is %s\n", - lastpath, chunk->data); + if (TRACE) + fprintf(stderr, "HTFTP: Line in %s is %s\n", + lastpath, chunk->data); entry_info = parse_dir_entry(chunk->data, &first); if (entry_info->display) { - CTRACE(tfp, "Adding file to BTree: %s\n", - entry_info->filename); + if (TRACE) + fprintf(stderr, "Adding file to BTree: %s\n", + entry_info->filename); HTBTree_add(bt, (EntryInfo *)entry_info); } else { FREE(entry_info); @@ -2589,19 +2695,22 @@ PUBLIC int HTFTPLoad ARGS4( { status = response(port_command); if (status == HT_INTERRUPTED) { - CTRACE (tfp, "HTFTP: Interrupted in response (port_command)\n"); - _HTProgress ("Connection interrupted."); - NETCLOSE (control->socket); - control->socket = -1; - close_master_socket (); - return HT_INTERRUPTED; + if (TRACE) + fprintf (stderr, + "HTFTP: Interrupted in response (port_command)\n"); + _HTProgress ("Connection interrupted."); + NETCLOSE (control->socket); + control->socket = -1; + close_master_socket (); + return HT_INTERRUPTED; } if (status != 2) { /* Could have timed out */ if (status < 0) continue; /* try again - net error*/ return -status; /* bad reply */ } - CTRACE(tfp, "HTFTP: Port defined.\n"); + if (TRACE) + fprintf(stderr, "HTFTP: Port defined.\n"); } #endif /* REPEAT_PORT */ #else /* Use PASV */ @@ -2629,12 +2738,13 @@ PUBLIC int HTFTPLoad ARGS4( status = sscanf(p+1, "%d,%d,%d,%d,%d,%d", &h0, &h1, &h2, &h3, &p0, &p1); if (status < 4) { - fprintf(tfp, "HTFTP: PASV reply has no inet address!\n"); + fprintf(stderr, "HTFTP: PASV reply has no inet address!\n"); return -99; } passive_port = (p0<<8) + p1; - CTRACE(tfp, "HTFTP: Server is listening on port %d\n", - passive_port); + if (TRACE) + fprintf(stderr, "HTFTP: Server is listening on port %d\n", + passive_port); /* Open connection for data: @@ -2649,7 +2759,8 @@ PUBLIC int HTFTPLoad ARGS4( return status; /* Bad return */ } - CTRACE(tfp, "FTP data connected, socket %d\n", data_soc); + if (TRACE) + fprintf(stderr, "FTP data connected, socket %d\n", data_soc); } #endif /* use PASV */ status = 0; @@ -2676,7 +2787,10 @@ PUBLIC int HTFTPLoad ARGS4( init_help_message_cache(); /* to free memory */ NETCLOSE(control->socket); control->socket = -1; - CTRACE(tfp, "HTFTP: Rejecting path due to illegal escaped slash.\n"); + if (TRACE) { + fprintf(stderr, + "HTFTP: Rejecting path due to illegal escaped slash.\n"); + } return -1; } } @@ -2711,12 +2825,13 @@ PUBLIC int HTFTPLoad ARGS4( *(filename+1) = '\0'; } } - if (*type != '\0') { - CTRACE(tfp, "HTFTP: type=%s\n", type); + if (TRACE && *type != '\0') { + fprintf(stderr, "HTFTP: type=%s\n", type); } } HTUnEscape(filename); - CTRACE(tfp, "HTFTP: UnEscaped %s\n", filename); + if (TRACE) + fprintf(stderr, "HTFTP: UnEscaped %s\n", filename); if (filename[1] == '~') { /* ** Check if translation of HOME as tilde is supported, @@ -2834,7 +2949,10 @@ PUBLIC int HTFTPLoad ARGS4( init_help_message_cache(); /* to free memory */ NETCLOSE(control->socket); control->socket = -1; - CTRACE(tfp, "HTFTP: Rejecting path due to non-Unix-style syntax.\n"); + if (TRACE) { + fprintf(stderr, + "HTFTP: Rejecting path due to non-Unix-style syntax.\n"); + } return -1; } /** Handle any unescaped "/%2F" path **/ @@ -2844,15 +2962,21 @@ PUBLIC int HTFTPLoad ARGS4( for (i = 0; filename[(i+1)]; i++) filename[i] = filename[(i+1)]; filename[i] = '\0'; - CTRACE(tfp, "HTFTP: Trimmed '%s'\n", filename); + if (TRACE) { + fprintf(stderr, "HTFTP: Trimmed '%s'\n", filename); + } cp = HTMake_VMS_name("", filename); - CTRACE(tfp, "HTFTP: VMSized '%s'\n", cp); + if (TRACE) { + fprintf(stderr, "HTFTP: VMSized '%s'\n", cp); + } if ((cp1=strrchr(cp, ']')) != NULL) { cp1++; for (i = 0; cp1[i]; i++) filename[i] = cp1[i]; filename[i] = '\0'; - CTRACE(tfp, "HTFTP: Filename '%s'\n", filename); + if (TRACE) { + fprintf(stderr, "HTFTP: Filename '%s'\n", filename); + } *cp1 = '\0'; sprintf(command, "CWD %s%c%c", cp, CR, LF); status = response (command); @@ -2893,7 +3017,9 @@ PUBLIC int HTFTPLoad ARGS4( for (i = 0; cp1[i]; i++) filename[i] = cp1[i]; filename[i] = '\0'; - CTRACE(tfp, "HTFTP: Filename '%s'\n", filename); + if (TRACE) { + fprintf(stderr, "HTFTP: Filename '%s'\n", filename); + } *cp1 = '\0'; strcat(cp, "["); strcat(cp, filename); @@ -3233,7 +3359,8 @@ listen: /* Reset buffering to control connection DD 921208 */ status = NETCLOSE(data_soc); - CTRACE(tfp, "HTFTP: Closing data socket %d\n", data_soc); + if (TRACE) + fprintf(stderr, "HTFTP: Closing data socket %d\n", data_soc); if (status < 0 && rv != HT_INTERRUPTED && rv != -1) { (void) HTInetStatus("close"); /* Comment only */ data_soc = -1; /* invalidate it */ diff --git a/WWW/Library/Implementation/HTFTP.h b/WWW/Library/Implementation/HTFTP.h index 7b857076..6bcec339 100644 --- a/WWW/Library/Implementation/HTFTP.h +++ b/WWW/Library/Implementation/HTFTP.h @@ -10,6 +10,9 @@ #ifndef HTFTP_H #define HTFTP_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTAnchor.h> #include <HTStream.h> #include <HTParse.h> @@ -18,7 +21,7 @@ #define FILE_BY_TYPE 1 #define FILE_BY_SIZE 2 #define FILE_BY_DATE 3 -extern int HTfileSortMethod; /* specifies the method of sorting */ +extern BOOLEAN HTfileSortMethod; /* specifies the method of sorting */ /* PUBLIC HTMake_VMS_name() diff --git a/WWW/Library/Implementation/HTFWriter.c b/WWW/Library/Implementation/HTFWriter.c index 435fd3e8..8de75085 100644 --- a/WWW/Library/Implementation/HTFWriter.c +++ b/WWW/Library/Implementation/HTFWriter.c @@ -16,9 +16,10 @@ #include <HTAlert.h> #include <HTFile.h> -#include <LYUtils.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* Stream Object ** ------------ */ @@ -152,7 +153,8 @@ PRIVATE void HTFWriter_abort ARGS2(HTStream *, me, HTError, e) { fclose(me->fp); if (me->end_command) { /* Temp file */ - CTRACE(tfp, "HTFWriter: Aborting: file not executed.\n"); + if (TRACE) fprintf(stderr, + "HTFWriter: Aborting: file not executed.\n"); FREE(me->end_command); if (me->remove_command) { system(me->remove_command); @@ -248,7 +250,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( /* Save the file under a suitably suffixed name */ - suffix = HTFileSuffix(pres->rep, anchor->content_encoding); + suffix = HTFileSuffix(pres->rep); fnam = (char *)malloc (L_tmpnam + 16 + strlen(suffix)); tmpnam (fnam); @@ -326,7 +328,7 @@ PUBLIC HTStream* HTSaveLocally ARGS3( /* Save the file under a suitably suffixed name */ - suffix = HTFileSuffix(pres->rep, anchor->content_encoding); + suffix = HTFileSuffix(pres->rep); fnam = (char *)malloc (L_tmpnam + 16 + strlen(suffix)); tmpnam (fnam); diff --git a/WWW/Library/Implementation/HTFWriter.h b/WWW/Library/Implementation/HTFWriter.h index 089ad0fb..334169e7 100644 --- a/WWW/Library/Implementation/HTFWriter.h +++ b/WWW/Library/Implementation/HTFWriter.h @@ -8,7 +8,11 @@ #ifndef HTFWRITE_H #define HTFWRITE_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTStream.h> +/*#include <stdio.h> included by HTUtils.h -- FM */ #include <HTFormat.h> #ifdef SHORT_NAMES diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index d04b2013..039e9b65 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -20,8 +20,6 @@ ** the device or top directory. */ -#include <HTUtils.h> - #ifndef VMS /* #define LONG_LIST */ /* Define this for long style unix listings (ls -l) */ /* #define NO_PARENT_DIR_REFERENCE */ /* Define this for no parent links */ @@ -29,10 +27,13 @@ #ifdef DOSPATH #define HAVE_READDIR 1 +#include <dirent.h> #define USE_DIRENT #include <HTDOS.h> #endif /* DOSPATH */ +#include <HTUtils.h> +#include <tcp.h> #include <HTFile.h> /* Implemented here */ #ifdef VMS #include <stat.h> @@ -52,6 +53,14 @@ #define INFINITY 512 /* file name length @@ FIXME */ #define MULTI_SUFFIX ".multi" /* Extension for scanning formats */ +#define HT_EM_SPACE ((char)2) + +#define FREE(x) if (x) {free(x); x = NULL;} + +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ + #include <HTParse.h> #include <HTTCP.h> #ifndef DECNET @@ -72,7 +81,6 @@ #include <LYexit.h> #include <LYCharSets.h> #include <LYGlobalDefs.h> -#include <LYStrings.h> #include <LYUtils.h> #include <LYLeaks.h> @@ -92,10 +100,6 @@ typedef struct _HTSuffix { #endif /* NGROUPS_MAX */ #endif /* NGROUPS */ -#ifndef GETGROUPS_T -#define GETGROUPS_T int -#endif - #include <HTML.h> /* For directory object building */ #define PUTC(c) (*target->isa->put_character)(target, c) @@ -117,10 +121,15 @@ PUBLIC int HTDirAccess = HT_DIR_OK; #ifdef DIRED_SUPPORT PUBLIC int HTDirReadme = HT_DIR_README_NONE; +#define FILES_FIRST 1 +#define MIXED_STYLE 2 +extern BOOLEAN lynx_edit_mode; +extern BOOLEAN dir_list_style; #else PUBLIC int HTDirReadme = HT_DIR_README_TOP; #endif /* DIRED_SUPPORT */ +extern BOOLEAN LYRawMode; extern BOOL HTPassEightBitRaw; extern HTCJKlang HTCJK; @@ -214,7 +223,6 @@ PRIVATE void LYListFmtParse ARGS5( s++; c = *s; /* the format char. or \0 */ *s = '\0'; - buf[0] = '\0'; switch (c) { case '\0': @@ -228,7 +236,7 @@ PRIVATE void LYListFmtParse ARGS5( PUTS(buf); END(HTML_A); #ifdef S_IFLNK - if (c != 'A' && S_ISLNK(st.st_mode) && + if (c != 'A' && (st.st_mode & S_IFMT) == S_IFLNK && (len = readlink(file, buf, sizeof(buf))) >= 0) { PUTS(" -> "); buf[len] = '\0'; @@ -262,7 +270,7 @@ PRIVATE void LYListFmtParse ARGS5( break; case 'K': /* size in Kilobytes but not for directories */ - if (S_ISDIR(st.st_mode)) { + if ((st.st_mode & S_IFMT) == S_IFDIR) { sprintf(fmt, "%%%ss ", start); sprintf(buf, fmt, ""); break; @@ -557,60 +565,59 @@ PRIVATE int HTCreatePath ARGS1(CONST char *,path) ** On exit: ** Returns a malloc'ed string which must be freed by the caller. */ -PUBLIC char * HTnameOfFile_WWW ARGS3( - CONST char *, name, - BOOL, WWW_prefix, - BOOL, expand_all) +PUBLIC char * HTLocalName ARGS1( + CONST char *, name) { char * acc_method = HTParse(name, "", PARSE_ACCESS); char * host = HTParse(name, "", PARSE_HOST); char * path = HTParse(name, "", PARSE_PATH+PARSE_PUNCTUATION); - char * home; - char * result = NULL; - if (expand_all) - HTUnEscape(path); /* Interpret all % signs */ - else - HTUnEscapeSome(path, "/"); /* Interpret % signs for path delims */ + HTUnEscape(path); /* Interpret % signs */ - if (0 == strcmp(acc_method, "file") /* local file */ - || !*acc_method) { /* implicitly local? */ + if (0 == strcmp(acc_method, "file")) { /* local file */ + FREE(acc_method); if ((0 == strcasecomp(host, HTHostName())) || (0 == strcasecomp(host, "localhost")) || !*host) { - CTRACE(tfp, "Node `%s' means path `%s'\n", name, path); + FREE(host); + if (TRACE) + fprintf(stderr, "Node `%s' means path `%s'\n", name, path); #ifdef DOSPATH - StrAllocCopy(result, HTDOS_name(path)); -#else -#ifdef __EMX__ - if (path[0] == '/' - && isalpha(path[1]) - && path[2] == ':') /* pesky leading slash */ - StrAllocCopy(result, path+1); - else - StrAllocCopy(result, path); - CTRACE(tfp, "EMX hack changed `%s' to `%s'\n", path, result); + { + char *ret_path = NULL; + StrAllocCopy(ret_path, HTDOS_name(path)); + if (TRACE) { + fprintf(stderr, "HTDOS_name changed `%s' to `%s'\n", + path, ret_path); + } + FREE(path); + return(ret_path); + } #else - StrAllocCopy(result, path); -#endif /* __EMX__ */ + return(path); #endif /* DOSPATH */ - } else if (WWW_prefix) { - result = (char *)malloc( + } else { + char * result = (char *)malloc( strlen("/Net/")+strlen(host)+strlen(path)+1); - if (result == NULL) - outofmem(__FILE__, "HTLocalName"); + if (result == NULL) + outofmem(__FILE__, "HTLocalName"); sprintf(result, "%s%s%s", "/Net/", host, path); - CTRACE(tfp, "Node `%s' means file `%s'\n", name, result); - } else { - StrAllocCopy(result, path); + FREE(host); + FREE(path); + if (TRACE) + fprintf(stderr, "Node `%s' means file `%s'\n", name, result); + return result; } - } else if (WWW_prefix) { /* other access */ + } else { /* other access */ + char * result; #ifdef VMS - if ((home = getenv("HOME")) == 0) + char * home = getenv("HOME"); + if (!home) home = HTCacheRoot; else home = HTVMS_wwwName(home); #else - if ((home = getenv("HOME")) == 0) + CONST char * home = (CONST char*)getenv("HOME"); + if (!home) home = "/tmp"; #endif /* VMS */ result = (char *)malloc( @@ -618,15 +625,11 @@ PUBLIC char * HTnameOfFile_WWW ARGS3( if (result == NULL) outofmem(__FILE__, "HTLocalName"); sprintf(result, "%s/WWW/%s/%s%s", home, acc_method, host, path); - } else { - StrAllocCopy(result, path); + FREE(path); + FREE(acc_method); + FREE(host); + return result; } - - FREE(host); - FREE(path); - FREE(acc_method); - - return result; } /* Make a WWW name from a full local path name. @@ -660,7 +663,8 @@ PUBLIC char * WWW_nameOfFile ARGS1( outofmem(__FILE__, "WWW_nameOfFile"); sprintf(result, "file://%s%s", HTHostName(), name); } - CTRACE(tfp, "File `%s'\n\tmeans node `%s'\n", name, result); + if (TRACE) + fprintf(stderr, "File `%s'\n\tmeans node `%s'\n", name, result); return result; } @@ -855,13 +859,17 @@ PUBLIC HTFormat HTCharsetFormat ARGS3( char *cp = NULL, *cp1, *cp2, *cp3 = NULL, *cp4; BOOL chartrans_ok = FALSE; int chndl = -1; + int i; FREE(anchor->charset); StrAllocCopy(cp, format->name); - LYLowerCase(cp); + for (i = 0; cp[i]; i++) + cp[i] = TOLOWER(cp[i]); if (((cp1 = strchr(cp, ';')) != NULL) && (cp2 = strstr(cp1, "charset")) != NULL) { - CTRACE(tfp, "HTCharsetFormat: Extended MIME Content-Type is %s\n", + if (TRACE) + fprintf(stderr, + "HTCharsetFormat: Extended MIME Content-Type is %s\n", format->name); cp2 += 7; while (*cp2 == ' ' || *cp2 == '=') @@ -888,12 +896,6 @@ PUBLIC HTFormat HTCharsetFormat ARGS3( ** Got something but we don't recognize it. */ chndl = UCLYhndl_for_unrec; - if (chndl < 0) - /* - ** UCLYhndl_for_unrec not defined :-( - ** fallback to UCLYhndl_for_unspec which always valid. - */ - chndl = UCLYhndl_for_unspec; /* always >= 0 */ if (UCCanTranslateFromTo(chndl, current_char_set)) { chartrans_ok = YES; HTAnchor_setUCInfoStage(anchor, chndl, @@ -938,9 +940,35 @@ PUBLIC HTFormat HTCharsetFormat ARGS3( HTPassEightBitRaw = TRUE; } } else if (p_out->enc == UCT_ENC_CJK) { - Set_HTCJK(p_in->MIMEname, p_out->MIMEname); + if (LYRawMode) { + if ((!strcmp(p_in->MIMEname, "euc-jp") || + !strcmp(p_in->MIMEname, "shift_jis")) && + (!strcmp(p_out->MIMEname, "euc-jp") || + !strcmp(p_out->MIMEname, "shift_jis"))) { + HTCJK = JAPANESE; + } else if (!strcmp(p_in->MIMEname, "euc-cn") && + !strcmp(p_out->MIMEname, "euc-cn")) { + HTCJK = CHINESE; + } else if (!strcmp(p_in->MIMEname, "big-5") && + !strcmp(p_out->MIMEname, "big-5")) { + HTCJK = TAIPEI; + } else if (!strcmp(p_in->MIMEname, "euc-kr") && + !strcmp(p_out->MIMEname, "euc-kr")) { + HTCJK = KOREAN; + } else { + HTCJK = NOCJK; + } + } else { + HTCJK = NOCJK; + } } - } else { + /* + ** Check for an iso-8859-# we don't know. - FM + */ + } else if (!strncmp(cp4, "iso-8859-", 9) && + isdigit((unsigned char)cp4[9]) && + !strncmp(LYchar_set_names[current_char_set], + "Other ISO Latin", 15)) { /* ** Hope it's a match, for now. - FM */ @@ -1005,8 +1033,9 @@ PUBLIC float HTFileValue ARGS1( suff = (HTSuffix *)HTList_objectAt(HTSuffixes, i); ls = strlen(suff->suffix); if ((ls <= lf) && 0==strcmp(suff->suffix, filename + lf - ls)) { - CTRACE(tfp, "File: Value of %s is %.3f\n", - filename, suff->quality); + if (TRACE) + fprintf(stderr, "File: Value of %s is %.3f\n", + filename, suff->quality); return suff->quality; /* OK -- found */ } } @@ -1053,7 +1082,11 @@ PUBLIC BOOL HTEditable ARGS1( #ifdef NO_GROUPS return NO; /* Safe answer till we find the correct algorithm */ #else - GETGROUPS_T groups[NGROUPS]; +#ifdef NeXT + int groups[NGROUPS]; +#else + gid_t groups[NGROUPS]; +#endif /* NeXT */ uid_t myUid; int ngroups; /* The number of groups */ struct stat fileStatus; @@ -1067,16 +1100,14 @@ PUBLIC BOOL HTEditable ARGS1( if (TRACE) { int i2; - fprintf(tfp, + fprintf(stderr, "File mode is 0%o, uid=%d, gid=%d. My uid=%d, %d groups (", - (unsigned int) fileStatus.st_mode, - (int) fileStatus.st_uid, - (int) fileStatus.st_gid, - (int) myUid, - (int) ngroups); + (unsigned int) fileStatus.st_mode, fileStatus.st_uid, + fileStatus.st_gid, + myUid, ngroups); for (i2 = 0; i2 < ngroups; i2++) - fprintf(tfp, " %d", (int) groups[i2]); - fprintf(tfp, ")\n"); + fprintf(stderr, " %d", groups[i2]); + fprintf(stderr, ")\n"); } if (fileStatus.st_mode & 0002) /* I can write anyway? */ @@ -1093,7 +1124,8 @@ PUBLIC BOOL HTEditable ARGS1( return YES; } } - CTRACE(tfp, "\tFile is not editable.\n"); + if (TRACE) + fprintf(stderr, "\tFile is not editable.\n"); return NO; /* If no excuse, can't do */ #endif /* NO_GROUPS */ } @@ -1228,11 +1260,11 @@ PUBLIC BOOL HTDirTitles ARGS3( char * printable = NULL; #ifdef DIRED_SUPPORT - printable = HTfullURL_toFile( - (0 == strncasecomp(path, "/%2F", 4)) /* "//" ? */ - ? (path+1) - : path); - if (0 == strncasecomp(printable, "/vmsysu:", 8) || + if (0 == strncasecomp(path, "/%2F", 4)) + StrAllocCopy(printable, (path+1)); + else + StrAllocCopy(printable, path); + if (0 == strncasecomp(printable, "/vmsysu%2b", 10) || 0 == strncasecomp(printable, "/anonymou.", 10)) { StrAllocCopy(cp, (printable+1)); StrAllocCopy(printable, cp); @@ -1240,11 +1272,11 @@ PUBLIC BOOL HTDirTitles ARGS3( } #else StrAllocCopy(printable, (current ? current + 1 : "")); - HTUnEscape(printable); #endif /* DIRED_SUPPORT */ START(HTML_HEAD); PUTS("\n"); + HTUnEscape(printable); START(HTML_TITLE); PUTS(*printable ? printable : "Welcome"); PUTS(" directory"); @@ -1496,9 +1528,10 @@ PUBLIC int HTLoadFile ARGS4( ** to the directories or files listed. */ if (HTStat(filename, &stat_info) == -1) { - CTRACE(tfp, "HTLoadFile: Can't stat %s\n", filename); + if (TRACE) + fprintf(stderr, "HTLoadFile: Can't stat %s\n", filename); } else { - if (S_ISDIR(stat_info.st_mode)) { + if (((stat_info.st_mode) & S_IFMT) == S_IFDIR) { if (HTDirAccess == HT_DIR_FORBID) { FREE(filename); FREE(nodename); @@ -1544,12 +1577,14 @@ PUBLIC int HTLoadFile ARGS4( */ if (!fp) { char ultrixname[INFINITY]; - CTRACE(tfp, "HTLoadFile: Can't open as %s\n", vmsname); + if (TRACE) + fprintf(stderr, "HTLoadFile: Can't open as %s\n", vmsname); sprintf(ultrixname, "%s::\"%s\"", nodename, filename); fp = fopen(ultrixname, "r", "shr=put", "shr=upd"); if (!fp) { - CTRACE(tfp, "HTLoadFile: Can't open as %s\n", - ultrixname); + if (TRACE) + fprintf(stderr, "HTLoadFile: Can't open as %s\n", + ultrixname); } } if (fp) { @@ -1589,7 +1624,9 @@ PUBLIC int HTLoadFile ARGS4( *semicolon = ';'; gzfp = gzopen(vmsname, "rb"); - CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n", + if (TRACE) + fprintf(stderr, + "HTLoadFile: gzopen of `%s' gives %p\n", vmsname, (void*)gzfp); use_gzread = YES; } else @@ -1635,7 +1672,9 @@ PUBLIC int HTLoadFile ARGS4( *semicolon = ';'; gzfp = gzopen(vmsname, "rb"); - CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n", + if (TRACE) + fprintf(stderr, + "HTLoadFile: gzopen of `%s' gives %p\n", vmsname, (void*)gzfp); use_gzread = YES; } @@ -1718,7 +1757,7 @@ PUBLIC int HTLoadFile ARGS4( if ((strlen(localname) > strlen(MULTI_SUFFIX)) && (0 == strcmp(localname + strlen(localname) - strlen(MULTI_SUFFIX), MULTI_SUFFIX))) { - DIR *dp = 0; + DIR *dp; BOOL forget_multi = NO; STRUCT_DIRENT * dirbuf; @@ -1808,7 +1847,9 @@ PUBLIC int HTLoadFile ARGS4( } } if (value != NO_VALUE_FOUND) { - CTRACE(tfp, "HTLoadFile: value of presenting %s is %f\n", + if (TRACE) + fprintf(stderr, + "HTLoadFile: value of presenting %s is %f\n", HTAtom_name(rep), value); if (value > best) { best_rep = rep; @@ -1854,7 +1895,8 @@ PUBLIC int HTLoadFile ARGS4( #endif { /* if can't read file information */ - CTRACE(tfp, "HTLoadFile: can't stat %s\n", localname); + if (TRACE) + fprintf(stderr, "HTLoadFile: can't stat %s\n", localname); } else { /* Stat was OK */ @@ -1862,7 +1904,7 @@ PUBLIC int HTLoadFile ARGS4( if (stat(localname,&dir_info) == -1) dir_info.st_mode = S_IFDIR; #endif - if (S_ISDIR(dir_info.st_mode)) { + if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) { /* ** If localname is a directory. */ @@ -1878,7 +1920,8 @@ PUBLIC int HTLoadFile ARGS4( BOOL need_parent_link = FALSE; struct stat file_info; - CTRACE(tfp, "%s is a directory\n", localname); + if (TRACE) + fprintf(stderr, "%s is a directory\n", localname); /* ** Check directory access. @@ -2024,14 +2067,13 @@ PUBLIC int HTLoadFile ARGS4( StrAllocCat(tmpfilename, dirbuf->d_name); stat(tmpfilename, &file_info); - if (S_ISDIR(file_info.st_mode)) + if (((file_info.st_mode) & S_IFMT) == S_IFDIR) #ifndef DIRED_SUPPORT sprintf((char *)dirname, "D%s",dirbuf->d_name); else sprintf((char *)dirname, "F%s",dirbuf->d_name); /* D & F to have first directories, then files */ #else - { if (dir_list_style == MIXED_STYLE) sprintf((char *)dirname, " %s/", dirbuf->d_name); @@ -2041,7 +2083,6 @@ PUBLIC int HTLoadFile ARGS4( else sprintf((char *)dirname, "D%s", dirbuf->d_name); - } else if (dir_list_style == MIXED_STYLE) sprintf((char *)dirname, " %s", dirbuf->d_name); else if (dir_list_style == FILES_FIRST) @@ -2204,7 +2245,8 @@ PUBLIC int HTLoadFile ARGS4( { FILE * fp = fopen(localname, "r"); - CTRACE (tfp, "HTLoadFile: Opening `%s' gives %p\n", + if (TRACE) + fprintf (stderr, "HTLoadFile: Opening `%s' gives %p\n", localname, (void*)fp); if (fp) { /* Good! */ int len; @@ -2233,7 +2275,9 @@ PUBLIC int HTLoadFile ARGS4( fclose(fp); gzfp = gzopen(localname, "rb"); - CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n", + if (TRACE) + fprintf(stderr, + "HTLoadFile: gzopen of `%s' gives %p\n", localname, (void*)gzfp); use_gzread = YES; } else @@ -2272,7 +2316,9 @@ PUBLIC int HTLoadFile ARGS4( fclose(fp); gzfp = gzopen(localname, "rb"); - CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n", + if (TRACE) + fprintf(stderr, + "HTLoadFile: gzopen of `%s' gives %p\n", localname, (void*)gzfp); use_gzread = YES; } @@ -2359,7 +2405,8 @@ PUBLIC int HTLoadFile ARGS4( ** All attempts have failed. */ { - CTRACE(tfp, "Can't open `%s', errno=%d\n", addr, SOCKET_ERRNO); + if (TRACE) + fprintf(stderr, "Can't open `%s', errno=%d\n", addr, SOCKET_ERRNO); return HTLoadError(sink, 403, "Can't access requested file."); } diff --git a/WWW/Library/Implementation/HTFile.h b/WWW/Library/Implementation/HTFile.h index 9c7686f1..867e00d7 100644 --- a/WWW/Library/Implementation/HTFile.h +++ b/WWW/Library/Implementation/HTFile.h @@ -42,10 +42,7 @@ extern int HTDirReadme; /* Include readme files in listing? */ /* ** Convert filenames between local and WWW formats */ -extern char * HTnameOfFile_WWW PARAMS((CONST char * name, BOOL WWW_prefix, BOOL expand_all)); -#define HTLocalName(name) HTnameOfFile_WWW(name,TRUE,TRUE) -#define HTfullURL_toFile(name) HTnameOfFile_WWW(name,FALSE,TRUE) -#define HTpartURL_toFile(name) HTnameOfFile_WWW(name,FALSE,FALSE) +extern char * HTLocalName PARAMS((CONST char * name)); /* ** Make a WWW name from a full local path name diff --git a/WWW/Library/Implementation/HTFinger.c b/WWW/Library/Implementation/HTFinger.c index 91b8d40e..042d137c 100644 --- a/WWW/Library/Implementation/HTFinger.c +++ b/WWW/Library/Implementation/HTFinger.c @@ -26,6 +26,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTAlert.h> #include <HTML.h> #include <HTParse.h> @@ -34,12 +35,15 @@ #include <HTString.h> #include <HTFinger.h> -#include <LYUtils.h> #include <LYLeaks.h> +/* #define TRACE 1 */ + #define FINGER_PORT 79 /* See rfc742 */ #define BIG 1024 /* Bug */ +#define FREE(x) if (x) {free(x); x = NULL;} + #define PUTC(c) (*targetClass.put_character)(target, c) #define PUTS(s) (*targetClass.put_string)(target, s) #define START(e) (*targetClass.start_element)(target, e, 0, 0, -1, 0) @@ -125,10 +129,13 @@ PRIVATE int response ARGS5( /* Send the command. */ - CTRACE(tfp, "HTFinger command to be sent: %s", command); + if (TRACE) + fprintf(stderr, "HTFinger command to be sent: %s", command); status = NETWRITE(s, (char *)command, length); if (status < 0) { - CTRACE(tfp, "HTFinger: Unable to send command. Disconnecting.\n"); + if (TRACE) + fprintf(stderr, + "HTFinger: Unable to send command. Disconnecting.\n"); NETCLOSE(s); s = -1; return status; @@ -141,7 +148,8 @@ PRIVATE int response ARGS5( /* Create the results report. */ - CTRACE(tfp,"HTFinger: Reading finger information\n"); + if (TRACE) + fprintf(stderr,"HTFinger: Reading finger information\n"); START(HTML_HTML); PUTS("\n"); START(HTML_HEAD); @@ -182,7 +190,10 @@ PRIVATE int response ARGS5( while ((ch=NEXT_CHAR) != (char)EOF) { if (interrupted_in_htgetcharacter) { - CTRACE(tfp, "HTFinger: Interrupted in HTGetCharacter, apparently.\n"); + if (TRACE) { + fprintf(stderr, + "HTFinger: Interrupted in HTGetCharacter, apparently.\n"); + } _HTProgress ("Connection interrupted."); goto end_html; } @@ -259,7 +270,9 @@ PUBLIC int HTLoadFinger ARGS4( int port; /* Port number from URL */ int status; /* tcp return */ - CTRACE(tfp, "HTFinger: Looking for %s\n", (arg ? arg : "NULL")); + if (TRACE) { + fprintf(stderr, "HTFinger: Looking for %s\n", (arg ? arg : "NULL")); + } if (!(arg && *arg)) { HTAlert("Could not load data."); @@ -378,13 +391,17 @@ PUBLIC int HTLoadFinger ARGS4( /* Now, let's get a stream setup up from the FingerHost: ** CONNECTING to finger host */ - CTRACE(tfp, "HTFinger: doing HTDoConnect on '%s'\n", str); + if (TRACE) + fprintf(stderr, "HTFinger: doing HTDoConnect on '%s'\n", str); status = HTDoConnect(str, "finger", FINGER_PORT, &s); - CTRACE(tfp, "HTFinger: Done DoConnect; status %d\n", status); + if (TRACE) + fprintf(stderr, "HTFinger: Done DoConnect; status %d\n", status); if (status == HT_INTERRUPTED) { /* Interrupt cleanly */ - CTRACE(tfp, "HTFinger: Interrupted on connect; recovering cleanly.\n"); + if (TRACE) + fprintf(stderr, + "HTFinger: Interrupted on connect; recovering cleanly.\n"); HTProgress ("Connection interrupted."); FREE(str); FREE(command); @@ -393,13 +410,15 @@ PUBLIC int HTLoadFinger ARGS4( if (status < 0) { NETCLOSE(s); s = -1; - CTRACE(tfp, "HTFinger: Unable to connect to finger host.\n"); + if (TRACE) + fprintf(stderr, "HTFinger: Unable to connect to finger host.\n"); HTAlert("Could not access finger host."); FREE(str); FREE(command); return HT_NOT_LOADED; /* FAIL */ } - CTRACE(tfp, "HTFinger: Connected to finger host '%s'.\n", str); + if (TRACE) + fprintf(stderr, "HTFinger: Connected to finger host '%s'.\n", str); FREE(str); /* Send the command, and process response if successful. diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c index 859934e8..baffca71 100644 --- a/WWW/Library/Implementation/HTFormat.c +++ b/WWW/Library/Implementation/HTFormat.c @@ -11,6 +11,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTAccess.h> /* Implements: @@ -47,10 +48,13 @@ PUBLIC long int HTMaxBytes = 0; /* No effective limit */ #include <LYexit.h> #include <LYUtils.h> -#include <GridText.h> #include <LYGlobalDefs.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + +extern int HTCheckForInterrupt NOPARAMS; + PUBLIC BOOL HTOutputSource = NO; /* Flag: shortcut parser to stdout */ /* extern BOOL interactive; LJM */ @@ -231,11 +235,14 @@ PUBLIC char HTGetCharacter NOARGS if (status == 0) return (char)EOF; if (status == HT_INTERRUPTED) { - CTRACE(tfp, "HTFormat: Interrupted in HTGetCharacter\n"); + if (TRACE) + fprintf(stderr, + "HTFormat: Interrupted in HTGetCharacter\n"); interrupted_in_htgetcharacter = 1; return (char)EOF; } - CTRACE(tfp, "HTFormat: File read error %d\n", status); + if (TRACE) + fprintf(stderr, "HTFormat: File read error %d\n", status); return (char)EOF; /* -1 is returned by UCX at end of HTTP link */ } @@ -259,8 +266,9 @@ PRIVATE int half_match ARGS2(char *,trial_type, char *,target) if (!cp || *(cp+1) != '*') return 0; - CTRACE(tfp, "HTFormat: comparing %s and %s for half match\n", - trial_type, target); + if (TRACE) + fprintf(stderr,"HTFormat: comparing %s and %s for half match\n", + trial_type, target); /* main type matches */ if (!strncmp(trial_type, target, (cp-trial_type)-1)) @@ -287,7 +295,9 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3( { HTAtom * wildcard = HTAtom_for("*"); - CTRACE(tfp, "HTFormat: Looking up presentation for %s to %s\n", + if (TRACE) + fprintf(stderr, + "HTFormat: Looking up presentation for %s to %s\n", HTAtom_name(rep_in), HTAtom_name(rep_out)); /* don't do anymore do it in the Lynx code at startup LJM */ @@ -306,7 +316,9 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3( pres = (HTPresentation *)HTList_objectAt(HTPresentations, i); if (pres->rep == rep_in) { if (pres->rep_out == rep_out) { - CTRACE(tfp, "FindPresentation: found exact match: %s\n", + if (TRACE) + fprintf(stderr, + "FindPresentation: found exact match: %s\n", HTAtom_name(pres->rep)); return pres; @@ -316,7 +328,9 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3( if (!strong_wildcard_match) strong_wildcard_match = pres; /* otherwise use the first one */ - CTRACE(tfp, "StreamStack: found strong wildcard match: %s\n", + if (TRACE) + fprintf(stderr, + "StreamStack: found strong wildcard match: %s\n", HTAtom_name(pres->rep)); } @@ -329,7 +343,9 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3( if (!strong_subtype_wildcard_match) strong_subtype_wildcard_match = pres; /* otherwise use the first one */ - CTRACE(tfp, "StreamStack: found strong subtype wildcard match: %s\n", + if (TRACE) + fprintf(stderr, + "StreamStack: found strong subtype wildcard match: %s\n", HTAtom_name(pres->rep)); } } @@ -339,7 +355,9 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3( if (!weak_wildcard_match) weak_wildcard_match = pres; /* otherwise use the first one */ - CTRACE(tfp, "StreamStack: found weak wildcard match: %s\n", + if (TRACE) + fprintf(stderr, + "StreamStack: found weak wildcard match: %s\n", HTAtom_name(pres->rep_out)); } if (pres->rep_out == wildcard) { @@ -385,7 +403,9 @@ PUBLIC HTStream * HTStreamStack ARGS4( HTPresentation temp; HTPresentation *match; - CTRACE(tfp, "HTFormat: Constructing stream stack for %s to %s\n", + if (TRACE) + fprintf(stderr, + "HTFormat: Constructing stream stack for %s to %s\n", HTAtom_name(rep_in), HTAtom_name(rep_out)); /* don't return on WWW_SOURCE some people might like @@ -399,9 +419,13 @@ PUBLIC HTStream * HTStreamStack ARGS4( if ((match = HTFindPresentation(rep_in, rep_out, &temp))) { if (match == &temp) { - CTRACE(tfp, "StreamStack: Using %s\n", HTAtom_name(temp.rep_out)); + if (TRACE) + fprintf(stderr, + "StreamStack: Using %s\n", HTAtom_name(temp.rep_out)); } else { - CTRACE(tfp, "StreamStack: found exact match: %s\n", + if (TRACE) + fprintf(stderr, + "StreamStack: found exact match: %s\n", HTAtom_name(match->rep)); } return (*match->converter)(match, anchor, sink); @@ -442,7 +466,9 @@ PUBLIC float HTStackValue ARGS4( { HTAtom * wildcard = HTAtom_for("*"); - CTRACE(tfp, "HTFormat: Evaluating stream stack for %s worth %.3f to %s\n", + if (TRACE) + fprintf(stderr, + "HTFormat: Evaluating stream stack for %s worth %.3f to %s\n", HTAtom_name(rep_in), initial_value, HTAtom_name(rep_out)); if (rep_out == WWW_SOURCE || rep_out == rep_in) @@ -472,61 +498,13 @@ PUBLIC float HTStackValue ARGS4( } -/* Display the page while transfer in progress -** ------------------------------------------- -** -** Repaint the page only when necessary. -** -*/ -#ifdef DISP_PARTIAL -PRIVATE void HTDisplayPartial NOARGS -{ - if (display_partial) { - /* - ** HText_getNumOfLines() = "current" number of lines received - ** NumOfLines_partial = number of lines at the moment of last repaint. - ** - ** We update NumOfLines_partial only when we repaint the display. - ** -1 is the special value: - ** This is a synchronization flag switched to 0 when HText_new() - ** starts a new HTMainText object - all hypertext functions use it, - ** lines counter in particular [we call it from HText_getNumOfLines()]. - ** - ** Otherwise HTMainText holds info from the previous document - ** and we may repaint it instead of the new one: - ** prev doc scrolled to the first line (=Newline_partial) - ** is not good looking :-) 23 Aug 1998 Leonid Pauzner - ** - ** So repaint the page only when necessary: - */ - if ((NumOfLines_partial != -1) - /* new hypertext document available */ - && ((Newline_partial + display_lines) > NumOfLines_partial) - /* current page not complete... */ - && (partial_threshold > 0 ? ((Newline_partial + partial_threshold) < HText_getNumOfLines()) : - ((Newline_partial + display_lines) < HText_getNumOfLines()))) { - /* - * Originally we rendered by increments of 2 lines, - * but that got annoying on slow network connections. - * Then we switched to full-pages. Now it's configurable. - * If partial_threshold < 0, then it's a full page - */ - NumOfLines_partial = HText_getNumOfLines(); - HText_pageDisplay(Newline_partial, ""); - } - } -} -#else -#define HTDisplayPartial() /*nothing*/ -#endif - /* Push data from a socket down a stream ** ------------------------------------- ** ** This routine is responsible for creating and PRESENTING any ** graphic (or other) objects described by the file. ** -** The file number given is assumed to be a TELNET stream, i.e., containing +** The file number given is assumed to be a TELNET stream ie containing ** CRLF at the end of lines which need to be stripped to LF for unix ** when the format is textual. ** @@ -538,7 +516,8 @@ PUBLIC int HTCopy ARGS4( HTStream*, sink) { HTStreamClass targetClass; - int bytes; + char line[256]; + int bytes = 0; int rv = 0; /* Push the data down the stream @@ -549,7 +528,6 @@ PUBLIC int HTCopy ARGS4( ** ** This operation could be put into a main event loop */ - HTReadProgress(bytes = 0, 0); for (;;) { int status; @@ -587,7 +565,7 @@ PUBLIC int HTCopy ARGS4( SOCKET_ERRNO == ECONNRESET || SOCKET_ERRNO == EPIPE) { /* - * Arrrrgh, HTTP 0/1 compatibility problem, maybe. + * Arrrrgh, HTTP 0/1 compability problem, maybe. */ if (bytes <= 0) { /* @@ -601,7 +579,8 @@ PUBLIC int HTCopy ARGS4( * Treat what we've gotten already * as the complete transmission. - FM */ - CTRACE(tfp, + if (TRACE) + fprintf(stderr, "HTCopy: Unexpected server disconnect. Treating as completed.\n"); status = 0; break; @@ -620,9 +599,14 @@ PUBLIC int HTCopy ARGS4( #endif /* NOT_ASCII */ (*targetClass.put_block)(sink, input_buffer, status); + bytes += status; - HTReadProgress(bytes, anchor ? anchor->content_length : 0); - HTDisplayPartial(); + if (anchor && anchor->content_length > 0) + sprintf(line, "Read %d of %d bytes of data.", + bytes, anchor->content_length); + else + sprintf(line, "Read %d bytes of data.", bytes); + HTProgress(line); } /* next bufferload */ @@ -647,7 +631,8 @@ PUBLIC int HTFileCopy ARGS2( HTStream*, sink) { HTStreamClass targetClass; - int status, bytes; + char line[256]; + int status, bytes = 0, nreads = 0, nprogr = 0; int rv = HT_OK; /* Push the data down the stream @@ -656,15 +641,17 @@ PUBLIC int HTFileCopy ARGS2( /* Push binary from socket down sink */ - HTReadProgress(bytes = 0, 0); for (;;) { status = fread(input_buffer, 1, INPUT_BUFFER_SIZE, fp); + nreads++; if (status == 0) { /* EOF or error */ if (ferror(fp) == 0) { rv = HT_LOADED; break; } - CTRACE(tfp, "HTFormat: Read error, read returns %d\n", + if (TRACE) + fprintf(stderr, + "HTFormat: Read error, read returns %d\n", ferror(fp)); if (bytes) { rv = HT_PARTIAL_CONTENT; @@ -673,20 +660,41 @@ PUBLIC int HTFileCopy ARGS2( } break; } - (*targetClass.put_block)(sink, input_buffer, status); - bytes += status; - HTReadProgress(bytes, 0); - HTDisplayPartial(); - if (HTCheckForInterrupt()) { - _HTProgress ("Data transfer interrupted."); - if (bytes) { - rv = HT_INTERRUPTED; + bytes += status; + if (nreads >= 100) { + /* + ** Show progress messages for local files, and check for + ** user interruption. Start doing so only after a certain + ** number of reads have been done, and don't update it on + ** every read (normally reading in a local file should be + ** speedy). - KW + */ + if (nprogr == 0) { + if (bytes < 1024000) { + sprintf(line, "Read %d bytes of data.", bytes); + } else { + sprintf(line, "Read %d KB of data. %s", + bytes/1024, + "(Press 'z' if you want to abort loading.)"); + } + HTProgress(line); + if (HTCheckForInterrupt()) { + _HTProgress ("Data transfer interrupted."); + if (bytes) { + rv = HT_INTERRUPTED; + } else { + rv = -1; + } + break; + } + nprogr++; + } else if (nprogr == 25) { + nprogr = 0; } else { - rv = -1; + nprogr++; } - break; } } /* next bufferload */ @@ -707,7 +715,8 @@ PRIVATE int HTGzFileCopy ARGS2( HTStream*, sink) { HTStreamClass targetClass; - int status, bytes; + char line[256]; + int status, bytes = 0, nreads = 0, nprogr = 0; int gzerrnum; int rv = HT_OK; @@ -715,21 +724,23 @@ PRIVATE int HTGzFileCopy ARGS2( */ targetClass = *(sink->isa); /* Copy pointers to procedures */ - /* read and inflate gzip'd file, and push binary down sink + /* read and inflate gzipped file, and push binary down sink */ - HTReadProgress(bytes = 0, 0); for (;;) { status = gzread(gzfp, input_buffer, INPUT_BUFFER_SIZE); + nreads++; if (status <= 0) { /* EOF or error */ if (status == 0) { rv = HT_LOADED; break; } - CTRACE(tfp, "HTGzFileCopy: Read error, gzread returns %d\n", + if (TRACE) { + fprintf(stderr, + "HTGzFileCopy: Read error, gzread returns %d\n", status); - CTRACE(tfp, "gzerror : %s\n", + fprintf(stderr, + "gzerror : %s\n", gzerror(gzfp, &gzerrnum)); - if (TRACE) { if (gzerrnum == Z_ERRNO) perror("gzerror "); } @@ -740,20 +751,42 @@ PRIVATE int HTGzFileCopy ARGS2( } break; } - (*targetClass.put_block)(sink, input_buffer, status); - bytes += status; - HTReadProgress(bytes, -1); - HTDisplayPartial(); - if (HTCheckForInterrupt()) { - _HTProgress ("Data transfer interrupted."); - if (bytes) { - rv = HT_INTERRUPTED; + bytes += status; + if (nreads >= 100) { + /* + ** Show progress messages for local files, and check for + ** user interruption. Start doing so only after a certain + ** number of reads have been done, and don't update it on + ** every read (normally reading in a local file should be + ** speedy). - KW + */ + if (nprogr == 0) { + if (bytes < 1024000) { + sprintf(line, + "Read %d uncompressed bytes of data.", bytes); + } else { + sprintf(line, "Read %d uncompressed KB of data. %s", + bytes/1024, + "(Press 'z' to abort.)"); + } + HTProgress(line); + if (HTCheckForInterrupt()) { + _HTProgress ("Data transfer interrupted."); + if (bytes) { + rv = HT_INTERRUPTED; + } else { + rv = -1; + } + break; + } + nprogr++; + } else if (nprogr == 25) { + nprogr = 0; } else { - rv = -1; + nprogr++; } - break; } } /* next bufferload */ @@ -829,7 +862,8 @@ PUBLIC int HTParseSocket ARGS5( } sprintf(buffer, "Sorry, can't convert from %s to %s.", HTAtom_name(rep_in), HTAtom_name(format_out)); - CTRACE(tfp, "HTFormat: %s\n", buffer); + if (TRACE) + fprintf(stderr, "HTFormat: %s\n", buffer); return HTLoadError(sink, 501, buffer); /* returns -501 */ } @@ -877,7 +911,8 @@ PUBLIC int HTParseFile ARGS5( } sprintf(buffer, "Sorry, can't convert from %s to %s.", HTAtom_name(rep_in), HTAtom_name(format_out)); - CTRACE(tfp, "HTFormat(in HTParseFile): %s\n", buffer); + if (TRACE) + fprintf(stderr, "HTFormat(in HTParseFile): %s\n", buffer); return HTLoadError(sink, 501, buffer); } @@ -915,7 +950,7 @@ PRIVATE int HTCloseGzFile ARGS1( if (gzres == Z_ERRNO) { perror("gzclose "); } else if (gzres != Z_OK) { - CTRACE(tfp, "gzclose : error number %d\n", gzres); + fprintf(stderr, "gzclose : error number %d\n", gzres); } } return(gzres); @@ -938,6 +973,7 @@ PUBLIC int HTParseGzFile ARGS5( if (!stream) { char buffer[1024]; /* @@@@@@@@ */ + extern char LYCancelDownload; HTCloseGzFile(gzfp); if (LYCancelDownload) { LYCancelDownload = FALSE; @@ -945,7 +981,8 @@ PUBLIC int HTParseGzFile ARGS5( } sprintf(buffer, "Sorry, can't convert from %s to %s.", HTAtom_name(rep_in), HTAtom_name(format_out)); - CTRACE(tfp, "HTFormat(in HTParseGzFile): %s\n", buffer); + if (TRACE) + fprintf(stderr, "HTFormat(in HTParseGzFile): %s\n", buffer); return HTLoadError(sink, 501, buffer); } diff --git a/WWW/Library/Implementation/HTFormat.h b/WWW/Library/Implementation/HTFormat.h index 0e5c4634..866174a9 100644 --- a/WWW/Library/Implementation/HTFormat.h +++ b/WWW/Library/Implementation/HTFormat.h @@ -14,6 +14,9 @@ Preamble #ifndef HTFORMAT_H #define HTFORMAT_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTStream.h> #include <HTAtom.h> #include <HTList.h> diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c index d6790693..e168ac8e 100644 --- a/WWW/Library/Implementation/HTGopher.c +++ b/WWW/Library/Implementation/HTGopher.c @@ -16,6 +16,7 @@ */ #include <HTUtils.h> /* Coding convention macros */ +#include <tcp.h> #include <HTAlert.h> #include <HTParse.h> #include <HTTCP.h> @@ -26,6 +27,8 @@ */ #include <HTGopher.h> +#define HT_EM_SPACE ((char)2) /* For now */ + #define GOPHER_PORT 70 /* See protocol spec */ #define CSO_PORT 105 /* See protocol spec */ #define BIG 1024 /* Bug */ @@ -58,17 +61,19 @@ #define GOPHER_PLUS_SOUND '<' #define GOPHER_PLUS_PDF 'P' +#include <ctype.h> + #include <HTParse.h> #include <HTFormat.h> #include <HTTCP.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* ** Hypertext object building machinery. */ #include <HTML.h> -#include <LYStrings.h> -#include <LYUtils.h> #include <LYLeaks.h> #define PUTC(c) (*targetClass.put_character)(target, c) @@ -191,7 +196,8 @@ PRIVATE void write_anchor ARGS2(CONST char *,text, CONST char *,addr) present[HTML_A_TITLE] = YES; ((CONST char **)value)[HTML_A_TITLE] = text; - CTRACE(tfp,"HTGopher: adding URL: %s\n",addr); + if(TRACE) + fprintf(stderr,"HTGopher: adding URL: %s\n",addr); HT_Is_Gopher_URL = TRUE; /* tell HTML.c that this is a Gopher URL */ (*targetClass.start_element)(target, HTML_A, present, @@ -252,7 +258,9 @@ PRIVATE void parse_menu ARGS2( while ((ch=NEXT_CHAR) != (char)EOF) { if (interrupted_in_htgetcharacter) { - CTRACE(tfp, "HTGopher: Interrupted in HTGetCharacter, apparently.\n"); + if (TRACE) + fprintf(stderr, + "HTGopher: Interrupted in HTGetCharacter, apparently.\n"); goto end_html; } @@ -265,7 +273,8 @@ PRIVATE void parse_menu ARGS2( bytes += p-line; /* add size */ p = line; /* Scan it to parse it */ port = 0; /* Flag "not parsed" */ - CTRACE(tfp, "HTGopher: Menu item: %s\n", line); + if (TRACE) + fprintf(stderr, "HTGopher: Menu item: %s\n", line); gtype = *p++; if (bytes > BytesReported + 1024) { @@ -419,7 +428,8 @@ PRIVATE void parse_menu ARGS2( else PUTS(name); } else { /* parse error */ - CTRACE(tfp, "HTGopher: Bad menu item.\n"); + if (TRACE) + fprintf(stderr, "HTGopher: Bad menu item.\n"); PUTS(line); } /* parse error */ @@ -879,6 +889,7 @@ PRIVATE int interpret_cso_key ARGS5( PRIVATE int parse_cso_field_info ARGS1( CSOfield_info *, blk) { + int i; char *info, *max_spec; /* @@ -892,7 +903,8 @@ PRIVATE int parse_cso_field_info ARGS1( ** are converted to all lower-case for comparison. */ info = blk->attributes; - LYLowerCase(info); + for (i = 0; info[i]; i++) + info[i] = TOLOWER(info[i]); if (strstr(info, "indexed ")) blk->indexed = 1; if (strstr(info, "default ")) @@ -938,7 +950,10 @@ PRIVATE int parse_cso_fields ARGS2( */ while ((ch = NEXT_CHAR) != (char)EOF) { if (interrupted_in_htgetcharacter) { - CTRACE(tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"); + if (TRACE) { + fprintf(stderr, + "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"); + } free_CSOfields(); buf[0] = '\0'; return HT_INTERRUPTED; @@ -1239,7 +1254,10 @@ PRIVATE int generate_cso_report ARGS2( while (!stop && (ch = NEXT_CHAR) != (char)EOF) { if (interrupted_in_htgetcharacter) { buf[0] = '\0'; - CTRACE(tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"); + if (TRACE) { + fprintf(stderr, + "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"); + } _HTProgress ("Connection interrupted."); goto end_CSOreport; } @@ -1481,7 +1499,8 @@ PRIVATE int HTLoadCSO ARGS4( return -3; /* Bad if no name sepcified */ if (!*arg) return -2; /* Bad if name had zero length */ - CTRACE(tfp, "HTLoadCSO: Looking for %s\n", arg); + if (TRACE) + fprintf(stderr, "HTLoadCSO: Looking for %s\n", arg); /* ** Set up a socket to the server for the data. @@ -1491,12 +1510,16 @@ PRIVATE int HTLoadCSO ARGS4( /* ** Interrupt cleanly. */ - CTRACE(tfp, "HTLoadCSO: Interrupted on connect; recovering cleanly.\n"); + if (TRACE) + fprintf(stderr, + "HTLoadCSO: Interrupted on connect; recovering cleanly.\n"); _HTProgress ("Connection interrupted."); return HT_NOT_LOADED; } if (status < 0) { - CTRACE(tfp, "HTLoadCSO: Unable to connect to remote host for `%s'.\n", + if (TRACE) + fprintf(stderr, + "HTLoadCSO: Unable to connect to remote host for `%s'.\n", arg); return HTInetStatus("connect"); } @@ -1506,13 +1529,16 @@ PRIVATE int HTLoadCSO ARGS4( if ((command = (char *)malloc(12)) == NULL) outofmem(__FILE__, "HTLoadCSO"); sprintf(command, "fields%c%c", CR, LF); - CTRACE(tfp, "HTLoadCSO: Connected, writing command `%s' to socket %d\n", + if (TRACE) + fprintf(stderr, + "HTLoadCSO: Connected, writing command `%s' to socket %d\n", command, s); _HTProgress ("Sending CSO/PH request."); status = NETWRITE(s, command, (int)strlen(command)); FREE(command); if (status < 0) { - CTRACE(tfp, "HTLoadCSO: Unable to send command.\n"); + if (TRACE) + fprintf(stderr, "HTLoadCSO: Unable to send command.\n"); return HTInetStatus("send"); } _HTProgress ("CSO/PH request sent; waiting for response."); @@ -1689,12 +1715,15 @@ PRIVATE int HTLoadCSO ARGS4( (*Target->isa->put_block)(Target, command, clen); strcpy(buf, "</H2>\n"); (*Target->isa->put_block)(Target, buf, strlen(buf)); - CTRACE(tfp, "HTLoadCSO: Writing command `%s' to socket %d\n", + if (TRACE) + fprintf(stderr, + "HTLoadCSO: Writing command `%s' to socket %d\n", command, s); status = NETWRITE(s, command, clen); FREE(command); if (status < 0) { - CTRACE(tfp, "HTLoadCSO: Unable to send command.\n"); + if (TRACE) + fprintf(stderr, "HTLoadCSO: Unable to send command.\n"); free_CSOfields(); return HTInetStatus("send"); } @@ -1732,7 +1761,8 @@ PRIVATE int HTLoadGopher ARGS4( return -3; /* Bad if no name sepcified */ if (!*arg) return -2; /* Bad if name had zero length */ - CTRACE(tfp, "HTGopher: Looking for %s\n", arg); + if (TRACE) + fprintf(stderr, "HTGopher: Looking for %s\n", arg); /* ** If it's a port 105 GOPHER_CSO gtype with no ISINDEX token ('?'), @@ -1745,7 +1775,8 @@ PRIVATE int HTLoadGopher ARGS4( if ((len = strlen(arg)) > 5) { if (0 == strcmp((CONST char *)&arg[len-6], ":105/2")) { /* Use CSO gateway. */ - CTRACE(tfp, "HTGopher: Passing to CSO/PH gateway.\n"); + if (TRACE) + fprintf(stderr, "HTGopher: Passing to CSO/PH gateway.\n"); return HTLoadCSO(arg, anAnchor, format_out, sink); } } @@ -1755,7 +1786,8 @@ PRIVATE int HTLoadGopher ARGS4( ** If it's a port 79/0[/...] URL, use the finger gateway. - FM */ if (strstr(arg, ":79/0") != NULL) { - CTRACE(tfp, "HTGopher: Passing to finger gateway.\n"); + if (TRACE) + fprintf(stderr, "HTGopher: Passing to finger gateway.\n"); return HTLoadFinger(arg, anAnchor, format_out, sink); } @@ -1852,13 +1884,17 @@ PRIVATE int HTLoadGopher ARGS4( /* ** Interrupt cleanly. */ - CTRACE(tfp, "HTGopher: Interrupted on connect; recovering cleanly.\n"); + if (TRACE) + fprintf(stderr, + "HTGopher: Interrupted on connect; recovering cleanly.\n"); _HTProgress ("Connection interrupted."); FREE(command); return HT_NOT_LOADED; } if (status < 0) { - CTRACE(tfp, "HTGopher: Unable to connect to remote host for `%s'.\n", + if (TRACE) + fprintf(stderr, + "HTGopher: Unable to connect to remote host for `%s'.\n", arg); FREE(command); return HTInetStatus("connect"); @@ -1866,7 +1902,9 @@ PRIVATE int HTLoadGopher ARGS4( HTInitInput(s); /* Set up input buffering */ - CTRACE(tfp, "HTGopher: Connected, writing command `%s' to socket %d\n", + if (TRACE) + fprintf(stderr, + "HTGopher: Connected, writing command `%s' to socket %d\n", command, s); #ifdef NOT_ASCII @@ -1883,7 +1921,8 @@ PRIVATE int HTLoadGopher ARGS4( status = NETWRITE(s, command, (int)strlen(command)); FREE(command); if (status < 0) { - CTRACE(tfp, "HTGopher: Unable to send command.\n"); + if (TRACE) + fprintf(stderr, "HTGopher: Unable to send command.\n"); return HTInetStatus("send"); } diff --git a/WWW/Library/Implementation/HTGroup.c b/WWW/Library/Implementation/HTGroup.c index a1b6fa4a..d48c298d 100644 --- a/WWW/Library/Implementation/HTGroup.c +++ b/WWW/Library/Implementation/HTGroup.c @@ -42,8 +42,9 @@ */ -#include <HTUtils.h> +#include <HTUtils.h> +#include <string.h> #include <HTAAUtil.h> #include <HTLex.h> /* Lexical analysor */ #include <HTGroup.h> /* Implemented here */ @@ -81,7 +82,8 @@ PRIVATE void syntax_error ARGS3(FILE *, fp, if (cnt < 40) buffer[cnt++] = ch; buffer[cnt] = (char)0; - CTRACE(tfp, "%s %d before: '%s'\nHTGroup.c: %s (got %s)\n", + if (TRACE) + fprintf(stderr, "%s %d before: '%s'\nHTGroup.c: %s (got %s)\n", "HTGroup.c: Syntax error in rule file at line", HTlex_line, buffer, msg, lex_verbose(lex_item)); HTlex_line++; @@ -395,7 +397,7 @@ PRIVATE GroupDefList *parse_group_file ARGS1(FILE *, fp) PRIVATE void print_item ARGS1(Item *, item) { if (!item) - fprintf(tfp, "\tNULL-ITEM\n"); + fprintf(stderr, "\tNULL-ITEM\n"); else { UserDefList *cur1 = item->user_def_list; AddressDefList *cur2 = item->address_def_list; @@ -403,20 +405,20 @@ PRIVATE void print_item ARGS1(Item *, item) Ref *addr_ref = (Ref*)HTList_nextObject(cur2); if (user_ref) { - fprintf(tfp, "\t[%s%s", user_ref->name, + fprintf(stderr, "\t[%s%s", user_ref->name, (user_ref->translation ? "*REF*" : "")); while (NULL != (user_ref = (Ref*)HTList_nextObject(cur1))) - fprintf(tfp, "; %s%s", user_ref->name, + fprintf(stderr, "; %s%s", user_ref->name, (user_ref->translation ? "*REF*" : "")); - fprintf(tfp, "] "); - } else fprintf(tfp, "\tANYBODY "); + fprintf(stderr, "] "); + } else fprintf(stderr, "\tANYBODY "); if (addr_ref) { - fprintf(tfp, "@ [%s", addr_ref->name); + fprintf(stderr, "@ [%s", addr_ref->name); while (NULL != (addr_ref = (Ref*)HTList_nextObject(cur2))) - fprintf(tfp, "; %s", addr_ref->name); - fprintf(tfp, "]\n"); - } else fprintf(tfp, "@ ANYADDRESS\n"); + fprintf(stderr, "; %s", addr_ref->name); + fprintf(stderr, "]\n"); + } else fprintf(stderr, "@ ANYADDRESS\n"); } } @@ -427,7 +429,7 @@ PRIVATE void print_item_list ARGS1(ItemList *, item_list) Item *item; if (!item_list) - fprintf(tfp, "EMPTY"); + fprintf(stderr, "EMPTY"); else while (NULL != (item = (Item*)HTList_nextObject(cur))) print_item(item); } @@ -436,15 +438,15 @@ PRIVATE void print_item_list ARGS1(ItemList *, item_list) PUBLIC void HTAA_printGroupDef ARGS1(GroupDef *, group_def) { if (!group_def) { - fprintf(tfp, "\nNULL RECORD\n"); + fprintf(stderr, "\nNULL RECORD\n"); return; } - fprintf(tfp, "\nGroup %s:\n", + fprintf(stderr, "\nGroup %s:\n", (group_def->group_name ? group_def->group_name : "NULL")); print_item_list(group_def->item_list); - fprintf(tfp, "\n"); + fprintf(stderr, "\n"); } @@ -481,7 +483,6 @@ PRIVATE BOOL part_match ARGS2(CONST char *, tcur, char actual[4]; CONST char *cur; int cnt; - BOOL status; if (!tcur || !icur) return NO; @@ -497,11 +498,14 @@ PRIVATE BOOL part_match ARGS2(CONST char *, tcur, actual[cnt++] = *(cur++); actual[cnt] = (char)0; - status = HTAA_templateMatch(required, actual); - CTRACE(tfp, "part_match: req: '%s' act: '%s' match: %s\n", + if (TRACE) { + BOOL status = HTAA_templateMatch(required, actual); + fprintf(stderr, "part_match: req: '%s' act: '%s' match: %s\n", required, actual, (status ? "yes" : "no")); + return status; + } - return status; + return HTAA_templateMatch(required, actual); } @@ -652,21 +656,21 @@ PUBLIC GroupDefList *HTAA_readGroupFile ARGS1(CONST char *, filename) while (NULL != (group_cache = (GroupCache*)HTList_nextObject(cur))) { if (!strcmp(filename, group_cache->group_filename)) { - CTRACE(tfp, "%s '%s' %s\n", - "HTAA_readGroupFile: group file", - filename, "already found in cache"); + if (TRACE) fprintf(stderr, "%s '%s' %s\n", + "HTAA_readGroupFile: group file", + filename, "already found in cache"); return group_cache->group_list; } /* if cache match */ } /* while cached files remain */ } /* cache exists */ - CTRACE(tfp, "HTAA_readGroupFile: reading group file `%s'\n", - filename); + if (TRACE) fprintf(stderr, "HTAA_readGroupFile: reading group file `%s'\n", + filename); if (!(fp = fopen(filename, "r"))) { - CTRACE(tfp, "%s '%s'\n", - "HTAA_readGroupFile: unable to open group file", - filename); + if (TRACE) fprintf(stderr, "%s '%s'\n", + "HTAA_readGroupFile: unable to open group file", + filename); return NULL; } @@ -679,9 +683,10 @@ PUBLIC GroupDefList *HTAA_readGroupFile ARGS1(CONST char *, filename) HTList_addObject(group_cache_list, (void*)group_cache); fclose(fp); - CTRACE(tfp, "Read group file '%s', results follow:\n", filename); - if (TRACE) + if (TRACE) { + fprintf(stderr, "Read group file '%s', results follow:\n", filename); print_group_def_list(group_cache->group_list); + } return group_cache->group_list; } diff --git a/WWW/Library/Implementation/HTGroup.h b/WWW/Library/Implementation/HTGroup.h index c578d3c3..398aa0bf 100644 --- a/WWW/Library/Implementation/HTGroup.h +++ b/WWW/Library/Implementation/HTGroup.h @@ -5,6 +5,9 @@ #ifndef HTGROUP_H #define HTGROUP_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTList.h> #ifdef SHORT_NAMES diff --git a/WWW/Library/Implementation/HTHistory.c b/WWW/Library/Implementation/HTHistory.c index fab1edc5..232e4341 100644 --- a/WWW/Library/Implementation/HTHistory.c +++ b/WWW/Library/Implementation/HTHistory.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> /* for standard io */ #include <HTHistory.h> @@ -70,9 +71,10 @@ HTAnchor * HTHistory_moveBy } return destination; } else { - CTRACE(tfp, "HTHistory_moveBy: offset by %+d goes out of list %p.\n", - offset, (void*)kids); - return NULL; + if (TRACE) fprintf(stderr, + "HTHistory_moveBy: offset by %+d goes out of list %p.\n", + offset, (void*)kids); + return NULL; } } else { /* Was a parent */ return NULL; /* FIXME we could possibly follow the next link... */ @@ -146,11 +148,10 @@ int HTHistory_count */ void HTHistory_leavingFrom - ARGS1 (HTAnchor *,anchor) + ARGS1 (HTAnchor *,anchor) { - if (HTList_removeLastObject (history)) { - HTList_addObject (history, anchor); - } else { - CTRACE(tfp, "HTHistory_leavingFrom: empty history !\n"); - } + if (HTList_removeLastObject (history)) + HTList_addObject (history, anchor); + else + if (TRACE) fprintf(stderr, "HTHistory_leavingFrom: empty history !\n"); } diff --git a/WWW/Library/Implementation/HTInit.c b/WWW/Library/Implementation/HTInit.c new file mode 100644 index 00000000..d367ca06 --- /dev/null +++ b/WWW/Library/Implementation/HTInit.c @@ -0,0 +1,176 @@ +/* Configuration-specific Initialialization HTInit.c +** ---------------------------------------- +*/ + +/* Define a basic set of suffixes and presentations +** ------------------------------------------------ +** +*/ + +#include <HTUtils.h> + +/* Implements: +*/ +#include <HTInit.h> + +#include <HTML.h> +#include <HTPlain.h> +#include <HTMLGen.h> +#include <HTFile.h> +#include <HTFormat.h> +#include <HTMIME.h> +#include <HTWSRC.h> +#include <HTFWriter.h> + +#include <LYLeaks.h> + +PUBLIC void HTFormatInit NOARGS +{ +#ifdef NeXT + HTSetPresentation("application/postscript", "open %s", 1.0, 2.0, 0.0, 0); + /* The following needs the GIF previewer -- you might not have it. */ + HTSetPresentation("image/gif", "open %s", 0.3, 2.0, 0.0, 0); + HTSetPresentation("image/x-tiff", "open %s", 1.0, 2.0, 0.0, 0); + HTSetPresentation("audio/basic", "open %s", 1.0, 2.0, 0.0, 0); + HTSetPresentation("*", "open %s", 1.0, 0.0, 0.0, 0); +#else + if (getenv("DISPLAY")) { /* Must have X11 */ + HTSetPresentation("application/postscript", "ghostview %s", + 1.0, 3.0, 0.0, 0); + HTSetPresentation("image/gif", "xv %s", 1.0, 3.0, 0.0, 0); + HTSetPresentation("image/x-tiff", "xv %s", 1.0, 3.0, 0.0, 0); + HTSetPresentation("image/jpeg", "xv %s", 1.0, 3.0, 0.0, 0); + } +#endif + HTSetConversion("www/mime", "*", HTMIMEConvert, + 1.0, 0.0, 0.0, 0); + HTSetConversion("application/x-wais-source","*", HTWSRCConvert, + 1.0, 0.0, 0.0, 0); + HTSetConversion("text/html", "text/x-c", HTMLToC, + 0.5, 0.0, 0.0, 0); + HTSetConversion("text/html", "text/plain", HTMLToPlain, + 0.5, 0.0, 0.0, 0); + HTSetConversion("text/html", "www/present", HTMLPresent, + 1.0, 0.0, 0.0, 0); + HTSetConversion("text/plain", "text/html", HTPlainToHTML, + 1.0, 0.0, 0.0, 0); + HTSetConversion("text/plain", "www/present", HTPlainPresent, + 1.0, 0.0, 0.0, 0); + HTSetConversion("application/octet-stream", "www/present", HTSaveLocally, + 0.1, 0.0, 0.0, 0); + HTSetConversion("www/unknown", "www/present", HTSaveLocally, + 0.3, 0.0, 0.0, 0); + HTSetConversion("www/source", "www/present", HTSaveLocally, + 0.3, 0.0, 0.0, 0); +} + + + +/* Define a basic set of suffixes +** ------------------------------ +** +** The LAST suffix for a type is that used for temporary files +** of that type. +** The quality is an apriori bias as to whether the file should be +** used. Not that different suffixes can be used to represent files +** which are of the same format but are originals or regenerated, +** with different values. +*/ + +#ifndef NO_INIT +PUBLIC void HTFileInit NOARGS +{ + /* Suffix Contenet-Type Content-Encoding Quality */ + + HTSetSuffix(".mime", "www/mime", "8bit", 1.0); /* Internal -- MIME is */ + /* not recursive */ + HTSetSuffix(".bin", "application/octet-stream", "binary", 1.0); /* Uninterpreted binary */ + HTSetSuffix(".oda", "application/oda", "binary", 1.0); + HTSetSuffix(".pdf", "application/pdf", "binary", 1.0); + HTSetSuffix(".ai", "application/postscript", "8bit", 0.5); /* Adobe Illustrator */ + HTSetSuffix(".PS", "application/postscript", "8bit", 0.8); /* PostScript */ + HTSetSuffix(".eps", "application/postscript", "8bit", 0.8); + HTSetSuffix(".ps", "application/postscript", "8bit", 0.8); + HTSetSuffix(".rtf", "application/x-rtf", "7bit", 1.0); /* RTF */ + HTSetSuffix(".Z", "application/x-compressed", "binary", 1.0); /* Compressed data */ + HTSetSuffix(".csh", "application/x-csh", "7bit", 0.5); /* C-shell script */ + HTSetSuffix(".dvi", "application/x-dvi", "binary", 1.0); /* TeX DVI */ + HTSetSuffix(".hdf", "application/x-hdf", "binary", 1.0); /* NCSA HDF data file */ + HTSetSuffix(".latex", "application/x-latex", "8bit", 1.0); /* LaTeX source */ + HTSetSuffix(".nc", "application/x-netcdf", "binary", 1.0); /* Unidata netCDF data */ + HTSetSuffix(".cdf", "application/x-netcdf", "binary", 1.0); + HTSetSuffix(".sh", "application/x-sh", "7bit", 0.5); /* Shell-script */ + HTSetSuffix(".tcl", "application/x-tcl", "7bit", 0.5); /* TCL-script */ + HTSetSuffix(".tex", "application/x-tex", "8bit", 1.0); /* TeX source */ + HTSetSuffix(".texi", "application/x-texinfo", "7bit", 1.0); /* Texinfo */ + HTSetSuffix(".texinfo","application/x-texinfo", "7bit", 1.0); + HTSetSuffix(".t", "application/x-troff", "7bit", 0.5); /* Troff */ + HTSetSuffix(".roff", "application/x-troff", "7bit", 0.5); + HTSetSuffix(".tr", "application/x-troff", "7bit", 0.5); + HTSetSuffix(".man", "application/x-troff-man", "7bit", 0.5); /* Troff with man macros*/ + HTSetSuffix(".me", "application/x-troff-me", "7bit", 0.5); /* Troff with me macros */ + HTSetSuffix(".ms", "application/x-troff-ms", "7bit", 0.5); /* Troff with ms macros */ + HTSetSuffix(".src", "application/x-wais-source", "7bit", 1.0); /* WAIS source */ + HTSetSuffix(".zip", "application/zip", "binary", 1.0); /* PKZIP */ + HTSetSuffix(".bcpio", "application/x-bcpio", "binary", 1.0); /* Old binary CPIO */ + HTSetSuffix(".cpio", "application/x-cpio", "binary", 1.0); /* POSIX CPIO */ + HTSetSuffix(".gtar", "application/x-gtar", "binary", 1.0); /* Gnu tar */ + HTSetSuffix(".shar", "application/x-shar", "8bit", 1.0); /* Shell archive */ + HTSetSuffix(".sv4cpio","application/x-sv4cpio", "binary", 1.0); /* SVR4 CPIO */ + HTSetSuffix(".sv4crc", "application/x-sv4crc", "binary", 1.0); /* SVR4 CPIO with CRC */ + HTSetSuffix(".tar", "application/x-tar", "binary", 1.0); /* 4.3BSD tar */ + HTSetSuffix(".ustar", "application/x-ustar", "binary", 1.0); /* POSIX tar */ + HTSetSuffix(".snd", "audio/basic", "binary", 1.0); /* Audio */ + HTSetSuffix(".au", "audio/basic", "binary", 1.0); + HTSetSuffix(".aiff", "audio/x-aiff", "binary", 1.0); + HTSetSuffix(".aifc", "audio/x-aiff", "binary", 1.0); + HTSetSuffix(".aif", "audio/x-aiff", "binary", 1.0); + HTSetSuffix(".wav", "audio/x-wav", "binary", 1.0); /* Windows+ WAVE format */ + HTSetSuffix(".gif", "image/gif", "binary", 1.0); /* GIF */ + HTSetSuffix(".ief", "image/ief", "binary", 1.0); /* Image Exchange fmt */ + HTSetSuffix(".jpg", "image/jpeg", "binary", 1.0); /* JPEG */ + HTSetSuffix(".JPG", "image/jpeg", "binary", 1.0); + HTSetSuffix(".JPE", "image/jpeg", "binary", 1.0); + HTSetSuffix(".jpe", "image/jpeg", "binary", 1.0); + HTSetSuffix(".JPEG", "image/jpeg", "binary", 1.0); + HTSetSuffix(".jpeg", "image/jpeg", "binary", 1.0); + HTSetSuffix(".tif", "image/tiff", "binary", 1.0); /* TIFF */ + HTSetSuffix(".tiff", "image/tiff", "binary", 1.0); + HTSetSuffix(".ras", "image/cmu-raster", "binary", 1.0); + HTSetSuffix(".pnm", "image/x-portable-anymap", "binary", 1.0); /* PBM Anymap format */ + HTSetSuffix(".pbm", "image/x-portable-bitmap", "binary", 1.0); /* PBM Bitmap format */ + HTSetSuffix(".pgm", "image/x-portable-graymap", "binary", 1.0); /* PBM Graymap format */ + HTSetSuffix(".ppm", "image/x-portable-pixmap", "binary", 1.0); /* PBM Pixmap format */ + HTSetSuffix(".rgb", "image/x-rgb", "binary", 1.0); + HTSetSuffix(".xbm", "image/x-xbitmap", "binary", 1.0); /* X bitmap */ + HTSetSuffix(".xpm", "image/x-xpixmap", "binary", 1.0); /* X pixmap format */ + HTSetSuffix(".xwd", "image/x-xwindowdump", "binary", 1.0); /* X window dump (xwd) */ + HTSetSuffix(".html", "text/html", "8bit", 1.0); /* HTML */ + HTSetSuffix(".c", "text/plain", "7bit", 0.5); /* C source */ + HTSetSuffix(".h", "text/plain", "7bit", 0.5); /* C headers */ + HTSetSuffix(".C", "text/plain", "7bit", 0.5); /* C++ source */ + HTSetSuffix(".cc", "text/plain", "7bit", 0.5); /* C++ source */ + HTSetSuffix(".hh", "text/plain", "7bit", 0.5); /* C++ headers */ + HTSetSuffix(".m", "text/plain", "7bit", 0.5); /* Objective-C source */ + HTSetSuffix(".f90", "text/plain", "7bit", 0.5); /* Fortran 90 source */ + HTSetSuffix(".txt", "text/plain", "7bit", 0.5); /* Plain text */ + HTSetSuffix(".rtx", "text/richtext", "7bit", 1.0); /* MIME Richtext format */ + HTSetSuffix(".tsv", "text/tab-separated-values", "7bit", 1.0); /* Tab-separated values */ + HTSetSuffix(".etx", "text/x-setext", "7bit", 0.9); /* Struct Enchanced Txt */ + HTSetSuffix(".MPG", "video/mpeg", "binary", 1.0); /* MPEG */ + HTSetSuffix(".mpg", "video/mpeg", "binary", 1.0); + HTSetSuffix(".MPE", "video/mpeg", "binary", 1.0); + HTSetSuffix(".mpe", "video/mpeg", "binary", 1.0); + HTSetSuffix(".MPEG", "video/mpeg", "binary", 1.0); + HTSetSuffix(".mpeg", "video/mpeg", "binary", 1.0); + HTSetSuffix(".qt", "video/quicktime", "binary", 1.0); /* QuickTime */ + HTSetSuffix(".mov", "video/quicktime", "binary", 1.0); + HTSetSuffix(".avi", "video/x-msvideo", "binary", 1.0); /* MS Video for Windows */ + HTSetSuffix(".movie", "video/x-sgi-movie", "binary", 1.0); /* SGI "moviepalyer" */ + + HTSetSuffix("*.*", "application/octet-stream", "binary", 0.1); + HTSetSuffix("*", "text/plain", "7bit", 0.5); + +} +#endif /* NO_INIT */ + diff --git a/WWW/Library/Implementation/HTInit.h b/WWW/Library/Implementation/HTInit.h index 4785f3e8..a003a6b5 100644 --- a/WWW/Library/Implementation/HTInit.h +++ b/WWW/Library/Implementation/HTInit.h @@ -10,14 +10,14 @@ Implemented by HTInit.c by default. */ - -#ifndef HTINIT_H -#define HTINIT_H 1 - +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ extern void HTFormatInit NOPARAMS; extern void HTPreparsedFormatInit NOPARAMS; extern void HTFileInit NOPARAMS; -#endif /* HTINIT_H */ +/* + + */ diff --git a/WWW/Library/Implementation/HTLex.c b/WWW/Library/Implementation/HTLex.c index e7568ea6..6cffe648 100644 --- a/WWW/Library/Implementation/HTLex.c +++ b/WWW/Library/Implementation/HTLex.c @@ -14,7 +14,6 @@ */ #include <HTUtils.h> - #include <HTAAUtil.h> #include <HTLex.h> /* Implemented here */ @@ -78,14 +77,14 @@ PUBLIC LexItem lex ARGS1(FILE *, fp) else return LEX_ALPH_STR; } else switch(ch) { - case EOF: return LEX_EOF; + case EOF: return LEX_EOF; break; case '\n': - HTlex_line++; return LEX_REC_SEP; - case ':': return LEX_FIELD_SEP; - case ',': return LEX_ITEM_SEP; - case '(': return LEX_OPEN_PAREN; - case ')': return LEX_CLOSE_PAREN; - case '@': return LEX_AT_SIGN; + HTlex_line++; return LEX_REC_SEP; break; + case ':': return LEX_FIELD_SEP; break; + case ',': return LEX_ITEM_SEP; break; + case '(': return LEX_OPEN_PAREN; break; + case ')': return LEX_CLOSE_PAREN; break; + case '@': return LEX_AT_SIGN; break; default: ; /* Leading white space ignored (SP,TAB,CR) */ } break; @@ -105,28 +104,39 @@ PUBLIC char *lex_verbose ARGS1(LexItem, lex_item) switch (lex_item) { case LEX_NONE: /* Internally used */ return "NO-LEX-ITEM"; + break; case LEX_EOF: /* End of file */ return "end-of-file"; + break; case LEX_REC_SEP: /* Record separator */ return "record separator (newline)"; + break; case LEX_FIELD_SEP: /* Field separator */ return "field separator ':'"; + break; case LEX_ITEM_SEP: /* List item separator */ return "item separator ','"; + break; case LEX_OPEN_PAREN: /* Group start tag */ return "'('"; + break; case LEX_CLOSE_PAREN: /* Group end tag */ return "')'"; + break; case LEX_AT_SIGN: /* Address qualifier */ return "address qualifier '@'"; + break; case LEX_ALPH_STR: /* Alphanumeric string */ sprintf(msg, "alphanumeric string '%s'", HTlex_buffer); return msg; + break; case LEX_TMPL_STR: /* Template string */ sprintf(msg, "template string '%s'", HTlex_buffer); return msg; + break; default: return "UNKNOWN-LEX-ITEM"; + break; } } diff --git a/WWW/Library/Implementation/HTLex.h b/WWW/Library/Implementation/HTLex.h index 205d6b19..dd02c3ae 100644 --- a/WWW/Library/Implementation/HTLex.h +++ b/WWW/Library/Implementation/HTLex.h @@ -5,12 +5,16 @@ #ifndef HTLEX_H #define HTLEX_H +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ + #ifdef SHORT_NAMES #define lex_verb lex_verbose #endif /*SHORT_NAMES*/ + typedef enum { LEX_NONE, /* Internally used */ LEX_EOF, /* End of file */ @@ -55,3 +59,6 @@ PUBLIC char *lex_verbose PARAMS((LexItem lex_item)); */ #endif /* not HTLEX_H */ +/* + + End of file HTLex.h. */ diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c index 939af95b..28958181 100644 --- a/WWW/Library/Implementation/HTList.c +++ b/WWW/Library/Implementation/HTList.c @@ -9,8 +9,13 @@ #include <HTUtils.h> #include <HTList.h> +/*#include <stdio.h> included by HTUtils.h -- FM *//* joe@athena, TBL 921019 */ + #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + + /* Create list. */ PUBLIC HTList * HTList_new NOARGS @@ -58,9 +63,10 @@ PUBLIC void HTList_addObject ARGS2( newNode->next = me->next; me->next = newNode; - } else { - CTRACE(tfp, "HTList: Trying to add object %p to a nonexisting list\n", - newObject); + } else if (TRACE) { + fprintf(stderr, + "HTList: Trying to add object %p to a nonexisting list\n", + newObject); } return; @@ -100,14 +106,20 @@ PUBLIC void HTList_insertObjectAt ARGS3( int Pos = pos; if (!temp) { - CTRACE(tfp, "HTList: Trying to add object %p to a nonexisting list\n", + if (TRACE) { + fprintf(stderr, + "HTList: Trying to add object %p to a nonexisting list\n", newObject); + } return; } if (Pos < 0) { Pos = 0; - CTRACE(tfp, "HTList: Treating negative object position %d as %d.\n", + if (TRACE) { + fprintf(stderr, + "HTList: Treating negative object position %d as %d.\n", pos, Pos); + } } prevNode = temp; diff --git a/WWW/Library/Implementation/HTList.h b/WWW/Library/Implementation/HTList.h index c02c58af..095308c1 100644 --- a/WWW/Library/Implementation/HTList.h +++ b/WWW/Library/Implementation/HTList.h @@ -7,7 +7,9 @@ #ifndef HTLIST_H #define HTLIST_H -#include <HTUtils.h> +#ifndef HTUTILS_H +#include <HTUtils.h> /* for BOOL type and PARAMS and ARGS*/ +#endif /* HTUTILS_H */ typedef struct _HTList HTList; diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index c518cba7..44a554eb 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -19,15 +19,23 @@ #include <UCDefs.h> #include <UCAux.h> -#include <LYCookie.h> #include <LYCharSets.h> -#include <LYStrings.h> -#include <LYUtils.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + +extern CONST char *LYchar_set_names[]; +extern BOOLEAN LYRawMode; extern BOOL HTPassEightBitRaw; extern HTCJKlang HTCJK; +extern void LYSetCookie PARAMS(( + CONST char * SetCookie, + CONST char * SetCookie2, + CONST char * address)); +extern time_t LYmktime PARAMS((char *string, BOOL absolute)); + + /* MIME Object ** ----------- */ @@ -224,13 +232,17 @@ PRIVATE void HTMIME_put_character ARGS2( case 'a': case 'A': me->state = miA; - CTRACE(tfp, "HTMIME: Got 'A' at beginning of line, state now A\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Got 'A' at beginning of line, state now A\n"); break; case 'c': case 'C': me->state = miC; - CTRACE (tfp, "HTMIME: Got 'C' at beginning of line, state now C\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'C' at beginning of line, state now C\n"); break; case 'd': @@ -238,13 +250,17 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ate:"; me->if_ok = miDATE; me->state = miCHECK; - CTRACE (tfp, "HTMIME: Got 'D' at beginning of line, checking for 'ate:'\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'D' at beginning of line, checking for 'ate:'\n"); break; case 'e': case 'E': me->state = miE; - CTRACE (tfp, "HTMIME: Got 'E' at beginning of line, state now E\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'E' at beginning of line, state now E\n"); break; case 'k': @@ -252,19 +268,25 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "eep-alive:"; me->if_ok = miKEEP_ALIVE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Got 'K' at beginning of line, checking for 'eep-alive:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Got 'K' at beginning of line, checking for 'eep-alive:'\n"); break; case 'l': case 'L': me->state = miL; - CTRACE (tfp, "HTMIME: Got 'L' at beginning of line, state now L\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'L' at beginning of line, state now L\n"); break; case 'p': case 'P': me->state = miP; - CTRACE (tfp, "HTMIME: Got 'P' at beginning of line, state now P\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'P' at beginning of line, state now P\n"); break; case 'r': @@ -272,37 +294,49 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "etry-after:"; me->if_ok = miRETRY_AFTER; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Got 'R' at beginning of line, checking for 'etry-after'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Got 'R' at beginning of line, checking for 'etry-after'\n"); break; case 's': case 'S': me->state = miS; - CTRACE (tfp, "HTMIME: Got 'S' at beginning of line, state now S\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'S' at beginning of line, state now S\n"); break; case 't': case 'T': me->state = miT; - CTRACE (tfp, "HTMIME: Got 'T' at beginning of line, state now T\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'T' at beginning of line, state now T\n"); break; case 'u': case 'U': me->state = miU; - CTRACE (tfp, "HTMIME: Got 'U' at beginning of line, state now U\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'U' at beginning of line, state now U\n"); break; case 'v': case 'V': me->state = miV; - CTRACE (tfp, "HTMIME: Got 'V' at beginning of line, state now V\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'V' at beginning of line, state now V\n"); break; case 'w': case 'W': me->state = miW; - CTRACE (tfp, "HTMIME: Got 'W' at beginning of line, state now W\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Got 'W' at beginning of line, state now W\n"); break; case '\n': /* Blank line: End of Header! */ @@ -311,7 +345,9 @@ PRIVATE void HTMIME_put_character ARGS2( if (strchr(HTAtom_name(me->format), ';') != NULL) { char *cp = NULL, *cp1, *cp2, *cp3 = NULL, *cp4; - CTRACE(tfp, "HTMIME: Extended MIME Content-Type is %s\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Extended MIME Content-Type is %s\n", HTAtom_name(me->format)); StrAllocCopy(cp, HTAtom_name(me->format)); /* @@ -323,7 +359,8 @@ PRIVATE void HTMIME_put_character ARGS2( ** we'll make sure they're still gone from any ** charset parameter we check. - FM */ - LYLowerCase(cp); + for (i = 0; cp[i]; i++) + cp[i] = TOLOWER(cp[i]); if ((cp1 = strchr(cp, ';')) != NULL) { BOOL chartrans_ok = NO; if ((cp2 = strstr(cp1, "charset")) != NULL) { @@ -353,13 +390,6 @@ PRIVATE void HTMIME_put_character ARGS2( else if (chndl < 0) {/* got something but we don't recognize it */ chndl = UCLYhndl_for_unrec; - if (chndl < 0) - /* - ** UCLYhndl_for_unrec not defined :-( - ** fallback to UCLYhndl_for_unspec - ** which always valid. - */ - chndl = UCLYhndl_for_unspec; /* always >= 0 */ if (UCCanTranslateFromTo(chndl, current_char_set)) { chartrans_ok = YES; @@ -414,9 +444,46 @@ PRIVATE void HTMIME_put_character ARGS2( HTPassEightBitRaw = TRUE; } } else if (p_out->enc == UCT_ENC_CJK) { - Set_HTCJK(p_in->MIMEname, p_out->MIMEname); + if (LYRawMode) { + if ((!strcmp(p_in->MIMEname, + "euc-jp") || + !strcmp(p_in->MIMEname, + "shift_jis")) && + (!strcmp(p_out->MIMEname, + "euc-jp") || + !strcmp(p_out->MIMEname, + "shift_jis"))) { + HTCJK = JAPANESE; + } else if (!strcmp(p_in->MIMEname, + "euc-cn") && + !strcmp(p_out->MIMEname, + "euc-cn")) { + HTCJK = CHINESE; + } else if (!strcmp(p_in->MIMEname, + "big-5") && + !strcmp(p_out->MIMEname, + "big-5")) { + HTCJK = TAIPEI; + } else if (!strcmp(p_in->MIMEname, + "euc-kr") && + !strcmp(p_out->MIMEname, + "euc-kr")) { + HTCJK = KOREAN; + } else { + HTCJK = NOCJK; + } + } else { + HTCJK = NOCJK; + } } - } else { + /* + ** Check for an iso-8859-# we don't know. - FM + */ + } else if + (!strncmp(cp4, "iso-8859-", 9) && + isdigit((unsigned char)cp4[9]) && + !strncmp(LYchar_set_names[current_char_set], + "Other ISO Latin", 15)) { /* ** Hope it's a match, for now. - FM */ @@ -479,17 +546,26 @@ PRIVATE void HTMIME_put_character ARGS2( StrAllocCopy(me->anchor->content_type, HTAtom_name(me->format)); if (!me->compression_encoding) { - CTRACE(tfp, "HTMIME: MIME Content-Type is '%s', converting to '%s'\n", - HTAtom_name(me->format), HTAtom_name(me->targetRep)); + if (TRACE) { + fprintf(stderr, + "HTMIME: MIME Content-Type is '%s', converting to '%s'\n", + HTAtom_name(me->format), HTAtom_name(me->targetRep)); + } } else { /* ** Change the format to that for "www/compressed" ** and set up a stream to deal with it. - FM */ - CTRACE(tfp, "HTMIME: MIME Content-Type is '%s',\n", HTAtom_name(me->format)); + if (TRACE) { + fprintf(stderr, + "HTMIME: MIME Content-Type is '%s',\n", HTAtom_name(me->format)); + } me->format = HTAtom_for("www/compressed"); - CTRACE(tfp, " Treating as '%s'. Converting to '%s'\n", - HTAtom_name(me->format), HTAtom_name(me->targetRep)); + if (TRACE) { + fprintf(stderr, + " Treating as '%s'. Converting to '%s'\n", + HTAtom_name(me->format), HTAtom_name(me->targetRep)); + } } if (me->set_cookie != NULL || me->set_cookie2 != NULL) { LYSetCookie(me->set_cookie, @@ -501,7 +577,8 @@ PRIVATE void HTMIME_put_character ARGS2( me->target = HTStreamStack(me->format, me->targetRep, me->sink , me->anchor); if (!me->target) { - CTRACE(tfp, "HTMIME: Can't translate! ** \n"); + if (TRACE) + fprintf(stderr, "HTMIME: Can't translate! ** \n"); me->target = me->sink; /* Cheat */ } if (me->target) { @@ -521,6 +598,7 @@ PRIVATE void HTMIME_put_character ARGS2( default: goto bad_field_name; + break; } /* switch on character */ break; @@ -532,7 +610,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "cept-ranges:"; me->if_ok = miACCEPT_RANGES; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was A, found C, checking for 'cept-ranges:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was A, found C, checking for 'cept-ranges:'\n"); break; case 'g': @@ -540,19 +620,25 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "e:"; me->if_ok = miAGE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was A, found G, checking for 'e:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was A, found G, checking for 'e:'\n"); break; case 'l': case 'L': me->state = miAL; - CTRACE(tfp, "HTMIME: Was A, found L, state now AL'\n"); + if (TRACE) + fprintf(stderr, "HTMIME: Was A, found L, state now AL'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", - c, "'g' or 'l'"); + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", + c, "'g' or 'l'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -564,7 +650,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ow:"; me->if_ok = miALLOW; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was AL, found L, checking for 'ow:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was AL, found L, checking for 'ow:'\n"); break; case 't': @@ -572,13 +660,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ernates:"; me->if_ok = miALTERNATES; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was AL, found T, checking for 'ernates:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was AL, found T, checking for 'ernates:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'l' or 't'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -590,19 +683,25 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "che-control:"; me->if_ok = miCACHE_CONTROL; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was C, found A, checking for 'che-control:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was C, found A, checking for 'che-control:'\n"); break; case 'o': case 'O': me->state = miCO; - CTRACE(tfp, "HTMIME: Was C, found O, state now CO'\n"); + if (TRACE) + fprintf(stderr, "HTMIME: Was C, found O, state now CO'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", - c, "'a' or 'o'"); + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", + c, "'a' or 'o'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -612,7 +711,9 @@ PRIVATE void HTMIME_put_character ARGS2( case 'n': case 'N': me->state = miCON; - CTRACE(tfp, "HTMIME: Was CO, found N, state now CON\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CO, found N, state now CON\n"); break; case 'o': @@ -620,13 +721,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "kie:"; me->if_ok = miCOOKIE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CO, found O, checking for 'kie:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CO, found O, checking for 'kie:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'n' or 'o'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -638,7 +744,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ection:"; me->if_ok = miCONNECTION; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CON, found N, checking for 'ection:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CON, found N, checking for 'ection:'\n"); break; case 't': @@ -646,13 +754,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ent-"; me->if_ok = miCONTENT_; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CON, found T, checking for 'ent-'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CON, found T, checking for 'ent-'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'n' or 't'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -664,7 +777,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ag:"; me->if_ok = miETAG; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was E, found T, checking for 'ag:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was E, found T, checking for 'ag:'\n"); break; case 'x': @@ -672,13 +787,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "pires:"; me->if_ok = miEXPIRES; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was E, found X, checking for 'pires:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was E, found X, checking for 'pires:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'t' or 'x'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -690,7 +810,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "st-modified:"; me->if_ok = miLAST_MODIFIED; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was L, found A, checking for 'st-modified:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was L, found A, checking for 'st-modified:'\n"); break; case 'i': @@ -698,7 +820,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "nk:"; me->if_ok = miLINK; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was L, found I, checking for 'nk:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was L, found I, checking for 'nk:'\n"); break; case 'o': @@ -706,13 +830,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "cation:"; me->if_ok = miLOCATION; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was L, found O, checking for 'cation:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was L, found O, checking for 'cation:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'a', 'i' or 'o'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -722,7 +851,8 @@ PRIVATE void HTMIME_put_character ARGS2( case 'r': case 'R': me->state = miPR; - CTRACE(tfp, "HTMIME: Was P, found R, state now PR'\n"); + if (TRACE) + fprintf(stderr, "HTMIME: Was P, found R, state now PR'\n"); break; case 'u': @@ -730,13 +860,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "blic:"; me->if_ok = miPUBLIC; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was P, found U, checking for 'blic:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was P, found U, checking for 'blic:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'r' or 'u'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -748,7 +883,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "gma:"; me->if_ok = miPRAGMA; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was PR, found A, checking for 'gma'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was PR, found A, checking for 'gma'\n"); break; case 'o': @@ -756,13 +893,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "xy-authenticate:"; me->if_ok = miPROXY_AUTHENTICATE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was PR, found O, checking for 'xy-authenticate'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was PR, found O, checking for 'xy-authenticate'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'a' or 'o'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -774,19 +916,24 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "fe:"; me->if_ok = miSAFE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was S, found A, checking for 'fe:'\n"); + if (TRACE) + fprintf(stderr, "HTMIME: Was S, found A, checking for 'fe:'\n"); break; case 'e': case 'E': me->state = miSE; - CTRACE(tfp, "HTMIME: Was S, found E, state now SE'\n"); + if (TRACE) + fprintf(stderr, "HTMIME: Was S, found E, state now SE'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'a' or 'e'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -798,7 +945,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ver:"; me->if_ok = miSERVER; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was SE, found R, checking for 'ver'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was SE, found R, checking for 'ver'\n"); break; case 't': @@ -806,13 +955,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "-cookie"; me->if_ok = miSET_COOKIE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was SE, found T, checking for '-cookie'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was SE, found T, checking for '-cookie'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'r' or 't'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -822,20 +976,27 @@ PRIVATE void HTMIME_put_character ARGS2( case ':': me->field = miSET_COOKIE1; /* remember it */ me->state = miSKIP_GET_VALUE; - CTRACE(tfp, "HTMIME: Was SET_COOKIE, found :, processing\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was SET_COOKIE, found :, processing\n"); break; case '2': me->check_pointer = ":"; me->if_ok = miSET_COOKIE2; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was SET_COOKIE, found 2, checking for ':'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was SET_COOKIE, found 2, checking for ':'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "':' or '2'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -847,7 +1008,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "tle:"; me->if_ok = miTITLE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was T, found I, checking for 'tle:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was T, found I, checking for 'tle:'\n"); break; case 'r': @@ -855,13 +1018,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ansfer-encoding:"; me->if_ok = miTRANSFER_ENCODING; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was T, found R, checking for 'ansfer-encoding'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was T, found R, checking for 'ansfer-encoding'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'i' or 'r'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -873,7 +1041,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "grade:"; me->if_ok = miUPGRADE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was U, found P, checking for 'grade:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was U, found P, checking for 'grade:'\n"); break; case 'r': @@ -881,13 +1051,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "i:"; me->if_ok = miURI; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was U, found R, checking for 'i:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was U, found R, checking for 'i:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'p' or 'r'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -899,7 +1074,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ry:"; me->if_ok = miVARY; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was V, found A, checking for 'ry:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was V, found A, checking for 'ry:'\n"); break; case 'i': @@ -907,13 +1084,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "a:"; me->if_ok = miVIA; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was V, found I, checking for 'a:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was V, found I, checking for 'a:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'a' or 'i'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -925,7 +1107,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "rning:"; me->if_ok = miWARNING; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was W, found A, checking for 'rning:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was W, found A, checking for 'rning:'\n"); break; case 'w': @@ -933,13 +1117,18 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "w-authenticate:"; me->if_ok = miWWW_AUTHENTICATE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was W, found W, checking for 'w-authenticate:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was W, found W, checking for 'w-authenticate:'\n"); break; default: - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, "'a' or 'w'"); goto bad_field_name; + break; } /* switch on character */ break; @@ -949,22 +1138,27 @@ PRIVATE void HTMIME_put_character ARGS2( if (!*me->check_pointer) me->state = me->if_ok; } else { /* Error */ - CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + if (TRACE) + fprintf(stderr, + "HTMIME: Bad character `%c' found where `%s' expected\n", c, me->check_pointer - 1); goto bad_field_name; } break; case miCONTENT_: - CTRACE (tfp, "HTMIME: in case CONTENT_\n"); - + if (TRACE) + fprintf (stderr, + "HTMIME: in case CONTENT_\n"); switch(c) { case 'b': case 'B': me->check_pointer = "ase:"; me->if_ok = miCONTENT_BASE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_, found B, checking for 'ase:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found B, checking for 'ase:'\n"); break; case 'd': @@ -972,7 +1166,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "isposition:"; me->if_ok = miCONTENT_DISPOSITION; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_, found D, checking for 'isposition:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found D, checking for 'isposition:'\n"); break; case 'e': @@ -980,7 +1176,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ncoding:"; me->if_ok = miCONTENT_ENCODING; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_, found E, checking for 'ncoding:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found E, checking for 'ncoding:'\n"); break; case 'f': @@ -988,13 +1186,17 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "eatures:"; me->if_ok = miCONTENT_FEATURES; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_, found F, checking for 'eatures:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found F, checking for 'eatures:'\n"); break; case 'l': case 'L': me->state = miCONTENT_L; - CTRACE (tfp, "HTMIME: Was CONTENT_, found L, state now CONTENT_L\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Was CONTENT_, found L, state now CONTENT_L\n"); break; case 'm': @@ -1002,7 +1204,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "d5:"; me->if_ok = miCONTENT_MD5; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_, found M, checking for 'd5:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found M, checking for 'd5:'\n"); break; case 'r': @@ -1010,32 +1214,42 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ange:"; me->if_ok = miCONTENT_RANGE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_, found R, checking for 'ange:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found R, checking for 'ange:'\n"); break; case 't': case 'T': me->state = miCONTENT_T; - CTRACE(tfp, "HTMIME: Was CONTENT_, found T, state now CONTENT_T\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found T, state now CONTENT_T\n"); break; default: - CTRACE(tfp, "HTMIME: Was CONTENT_, found nothing; bleah\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_, found nothing; bleah\n"); goto bad_field_name; + break; } /* switch on character */ break; case miCONTENT_L: - CTRACE (tfp, "HTMIME: in case CONTENT_L\n"); - + if (TRACE) + fprintf (stderr, + "HTMIME: in case CONTENT_L\n"); switch(c) { case 'a': case 'A': me->check_pointer = "nguage:"; me->if_ok = miCONTENT_LANGUAGE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_L, found A, checking for 'nguage:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_L, found A, checking for 'nguage:'\n"); break; case 'e': @@ -1043,7 +1257,9 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "ngth:"; me->if_ok = miCONTENT_LENGTH; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_L, found E, checking for 'ngth:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_L, found E, checking for 'ngth:'\n"); break; case 'o': @@ -1051,26 +1267,34 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "cation:"; me->if_ok = miCONTENT_LOCATION; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_L, found O, checking for 'cation:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_L, found O, checking for 'cation:'\n"); break; default: - CTRACE (tfp, "HTMIME: Was CONTENT_L, found nothing; bleah\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Was CONTENT_L, found nothing; bleah\n"); goto bad_field_name; + break; } /* switch on character */ break; case miCONTENT_T: - CTRACE (tfp, "HTMIME: in case CONTENT_T\n"); - + if (TRACE) + fprintf (stderr, + "HTMIME: in case CONTENT_T\n"); switch(c) { case 'r': case 'R': me->check_pointer = "ansfer-encoding:"; me->if_ok = miCONTENT_TRANSFER_ENCODING; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_T, found R, checking for 'ansfer-encoding:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_T, found R, checking for 'ansfer-encoding:'\n"); break; case 'y': @@ -1078,12 +1302,17 @@ PRIVATE void HTMIME_put_character ARGS2( me->check_pointer = "pe:"; me->if_ok = miCONTENT_TYPE; me->state = miCHECK; - CTRACE(tfp, "HTMIME: Was CONTENT_T, found Y, checking for 'pe:'\n"); + if (TRACE) + fprintf(stderr, + "HTMIME: Was CONTENT_T, found Y, checking for 'pe:'\n"); break; default: - CTRACE (tfp, "HTMIME: Was CONTENT_T, found nothing; bleah\n"); + if (TRACE) + fprintf (stderr, + "HTMIME: Was CONTENT_T, found nothing; bleah\n"); goto bad_field_name; + break; } /* switch on character */ break; @@ -1162,34 +1391,45 @@ PRIVATE void HTMIME_put_character ARGS2( switch (me->field) { case miACCEPT_RANGES: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Accept-Ranges: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Accept-Ranges: '%s'\n", me->value); break; case miAGE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Age: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Age: '%s'\n", me->value); break; case miALLOW: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Allow: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Allow: '%s'\n", me->value); break; case miALTERNATES: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Alternates: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Alternates: '%s'\n", me->value); break; case miCACHE_CONTROL: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Cache-Control: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Cache-Control: '%s'\n", me->value); if (!(me->value && *me->value)) break; /* ** Convert to lowercase and indicate in anchor. - FM */ - LYLowerCase(me->value); + for (i = 0; me->value[i]; i++) + me->value[i] = TOLOWER(me->value[i]); StrAllocCopy(me->anchor->cache_control, me->value); /* ** Check whether to set no_cache for the anchor. - FM @@ -1234,17 +1474,23 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miCOOKIE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Cookie: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Cookie: '%s'\n", me->value); break; case miCONNECTION: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Connection: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Connection: '%s'\n", me->value); break; case miCONTENT_BASE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Base: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Base: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1255,7 +1501,9 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miCONTENT_DISPOSITION: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Disposition: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Disposition: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1305,7 +1553,9 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miCONTENT_ENCODING: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Encoding: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Encoding: '%s'\n", me->value); if (!(me->value && *me->value) || !strcasecomp(me->value, "identity")) @@ -1313,7 +1563,8 @@ PRIVATE void HTMIME_put_character ARGS2( /* ** Convert to lowercase and indicate in anchor. - FM */ - LYLowerCase(me->value); + for (i = 0; me->value[i]; i++) + me->value[i] = TOLOWER(me->value[i]); StrAllocCopy(me->anchor->content_encoding, me->value); FREE(me->compression_encoding); if (!strcmp(me->value, "8bit") || @@ -1323,7 +1574,9 @@ PRIVATE void HTMIME_put_character ARGS2( ** Some server indicated "8bit", "7bit" or "binary" ** inappropriately. We'll ignore it. - FM */ - CTRACE(tfp, " Ignoring it!\n"); + if (TRACE) + fprintf(stderr, + " Ignoring it!\n"); } else { /* ** Save it to use as a flag for setting @@ -1334,24 +1587,31 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miCONTENT_FEATURES: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Features: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Features: '%s'\n", me->value); break; case miCONTENT_LANGUAGE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Language: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Language: '%s'\n", me->value); if (!(me->value && *me->value)) break; /* ** Convert to lowercase and indicate in anchor. - FM */ - LYLowerCase(me->value); + for (i = 0; me->value[i]; i++) + me->value[i] = TOLOWER(me->value[i]); StrAllocCopy(me->anchor->content_language, me->value); break; case miCONTENT_LENGTH: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Length: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Length: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1361,12 +1621,16 @@ PRIVATE void HTMIME_put_character ARGS2( me->anchor->content_length = atoi(me->value); if (me->anchor->content_length < 0) me->anchor->content_length = 0; - CTRACE(tfp, " Converted to integer: '%d'\n", + if (TRACE) + fprintf(stderr, + " Converted to integer: '%d'\n", me->anchor->content_length); break; case miCONTENT_LOCATION: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Location: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Location: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1377,7 +1641,9 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miCONTENT_MD5: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-MD5: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-MD5: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1388,12 +1654,16 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miCONTENT_RANGE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Range: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Range: '%s'\n", me->value); break; case miCONTENT_TRANSFER_ENCODING: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Transfer-Encoding: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Transfer-Encoding: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1401,12 +1671,15 @@ PRIVATE void HTMIME_put_character ARGS2( ** Force the Content-Transfer-Encoding value ** to all lower case. - FM */ - LYLowerCase(me->value); + for (i = 0; me->value[i]; i++) + me->value[i] = TOLOWER(me->value[i]); me->encoding = HTAtom_for(me->value); break; case miCONTENT_TYPE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Content-Type: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Content-Type: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1424,7 +1697,9 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miDATE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Date: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Date: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1435,12 +1710,16 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miETAG: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP ETag: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP ETag: '%s'\n", me->value); break; case miEXPIRES: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Expires: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Expires: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1451,12 +1730,16 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miKEEP_ALIVE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Keep-Alive: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Keep-Alive: '%s'\n", me->value); break; case miLAST_MODIFIED: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Last-Modified: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Last-Modified: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1467,17 +1750,23 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miLINK: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Link: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Link: '%s'\n", me->value); break; case miLOCATION: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Location: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Location: '%s'\n", me->value); break; case miPRAGMA: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Pragma: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Pragma: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1489,22 +1778,30 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miPROXY_AUTHENTICATE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Proxy-Authenticate: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Proxy-Authenticate: '%s'\n", me->value); break; case miPUBLIC: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Public: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Public: '%s'\n", me->value); break; case miRETRY_AFTER: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Retry-After: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Retry-After: '%s'\n", me->value); break; case miSAFE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Safe: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Safe: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1518,7 +1815,9 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miSERVER: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Server: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Server: '%s'\n", me->value); if (!(me->value && *me->value)) break; @@ -1529,7 +1828,9 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miSET_COOKIE1: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Set-Cookie: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Set-Cookie: '%s'\n", me->value); if (me->set_cookie == NULL) { StrAllocCopy(me->set_cookie, me->value); @@ -1540,7 +1841,9 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miSET_COOKIE2: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Set-Cookie2: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Set-Cookie2: '%s'\n", me->value); if (me->set_cookie2 == NULL) { StrAllocCopy(me->set_cookie2, me->value); @@ -1551,42 +1854,58 @@ PRIVATE void HTMIME_put_character ARGS2( break; case miTITLE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Title: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Title: '%s'\n", me->value); break; case miTRANSFER_ENCODING: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Transfer-Encoding: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Transfer-Encoding: '%s'\n", me->value); break; case miUPGRADE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Upgrade: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Upgrade: '%s'\n", me->value); break; case miURI: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP URI: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP URI: '%s'\n", me->value); break; case miVARY: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Vary: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Vary: '%s'\n", me->value); break; case miVIA: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Via: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Via: '%s'\n", me->value); break; case miWARNING: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP Warning: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP Warning: '%s'\n", me->value); break; case miWWW_AUTHENTICATE: HTMIME_TrimDoubleQuotes(me->value); - CTRACE(tfp, "HTMIME: PICKED UP WWW-Authenticate: '%s'\n", + if (TRACE) + fprintf(stderr, + "HTMIME: PICKED UP WWW-Authenticate: '%s'\n", me->value); break; default: /* Should never get here */ @@ -1615,7 +1934,8 @@ PRIVATE void HTMIME_put_character ARGS2( return; value_too_long: - CTRACE(tfp, "HTMIME: *** Syntax error. (string too long)\n"); + if (TRACE) + fprintf(stderr, "HTMIME: *** Syntax error. (string too long)\n"); bad_field_name: /* Ignore it */ me->state = miJUNK_LINE; @@ -1640,7 +1960,8 @@ PRIVATE void HTMIME_put_string ARGS2( (*me->targetClass.put_string)(me->target,s); } else if (me->state != MIME_IGNORE) { - CTRACE(tfp, "HTMIME: %s\n", s); + if (TRACE) + fprintf(stderr, "HTMIME: %s\n", s); for (p=s; *p; p++) HTMIME_put_character(me, *p); @@ -1662,7 +1983,8 @@ PRIVATE void HTMIME_write ARGS3( (*me->targetClass.put_block)(me->target, s, l); } else { - CTRACE(tfp, "HTMIME: %.*s\n", l, s); + if (TRACE) + fprintf(stderr, "HTMIME: %.*s\n", l, s); for (p = s; p < s+l; p++) HTMIME_put_character(me, *p); @@ -1823,6 +2145,9 @@ PUBLIC HTStream* HTNetMIME ARGS3( ** Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* #include <stdio.h> */ /* Included via previous headers. - FM */ +/* #include <string.h> */ /* Included via previous headers. - FM */ + /* ** MIME decoding routines ** @@ -1955,7 +2280,8 @@ PUBLIC void HTmmdecode ARGS2( int LYhndl; *qm2 = '\0'; - LYLowerCase(s+2); + for (p = s+2; *p; p++) + *p = TOLOWER(*p); invalid = ((LYhndl = UCGetLYhndl_byMIME(s+2)) < 0 || UCCanTranslateFromTo(LYhndl, current_char_set)); diff --git a/WWW/Library/Implementation/HTMLDTD.c b/WWW/Library/Implementation/HTMLDTD.c index 966697a8..bf7a54b7 100644 --- a/WWW/Library/Implementation/HTMLDTD.c +++ b/WWW/Library/Implementation/HTMLDTD.c @@ -1597,17 +1597,16 @@ PUBLIC void HTSwitchDTD ARGS1( BOOL, new) { if (TRACE) - CTRACE(tfp,"HTMLDTD: Copying DTD element info of size %d, %d * %d\n", - (int) (new ? sizeof(tags_new) : sizeof(tags_old)), - HTML_ELEMENTS, - (int) sizeof(HTTag)); + fprintf(stderr,"HTMLDTD: Copying DTD element info of size %d, %d * %d\n", + new ? sizeof(tags_new) : sizeof(tags_old), + HTML_ELEMENTS, sizeof(HTTag)); if (new) memcpy(tags, tags_new, HTML_ELEMENTS * sizeof(HTTag)); else memcpy(tags, tags_old, HTML_ELEMENTS * sizeof(HTTag)); } -PUBLIC HTTag HTTag_unrecognized = +PUBLIC CONST HTTag HTTag_unrecognized = { NULL, NULL, 0, SGML_EMPTY,T__UNREC_}; /* diff --git a/WWW/Library/Implementation/HTMLDTD.h b/WWW/Library/Implementation/HTMLDTD.h index a112b7e5..07ce5195 100644 --- a/WWW/Library/Implementation/HTMLDTD.h +++ b/WWW/Library/Implementation/HTMLDTD.h @@ -12,6 +12,9 @@ #ifndef HTMLDTD_H #define HTMLDTD_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <SGML.h> /* @@ -953,7 +956,7 @@ extern CONST SGML_dtd HTML_dtd; extern void HTSwitchDTD PARAMS(( BOOL new)); -extern HTTag HTTag_unrecognized; +extern CONST HTTag HTTag_unrecognized; /* diff --git a/WWW/Library/Implementation/HTMLGen.c b/WWW/Library/Implementation/HTMLGen.c index 9581081f..da2b63e5 100644 --- a/WWW/Library/Implementation/HTMLGen.c +++ b/WWW/Library/Implementation/HTMLGen.c @@ -13,6 +13,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #define BUFFER_SIZE 200 /* Line buffer attempts to make neat breaks */ #define MAX_CLEANNESS 20 @@ -21,6 +22,7 @@ */ #include <HTMLGen.h> +#include <stdio.h> #include <HTMLDTD.h> #include <HTStream.h> #include <SGML.h> @@ -28,6 +30,8 @@ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + #define PUTC(c) (*me->targetClass.put_character)(me->target, c) /* #define PUTS(s) (*me->targetClass.put_string)(me->target, s) */ #define PUTB(s,l) (*me->targetClass.put_block)(me->target, s, l) diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c index 331b4fa7..89048385 100644 --- a/WWW/Library/Implementation/HTNews.c +++ b/WWW/Library/Implementation/HTNews.c @@ -7,6 +7,7 @@ */ #include <HTUtils.h> /* Coding convention macros */ +#include <tcp.h> /* Implements: */ @@ -15,7 +16,8 @@ #include <HTCJK.h> #include <HTMIME.h> #include <HTTCP.h> -#include <LYUtils.h> + +#define FREE(x) if (x) {free(x); x = NULL;} /* this define should be in HTFont.h :( */ #define HT_NON_BREAK_SPACE ((char)1) /* For now */ @@ -37,6 +39,8 @@ PUBLIC int HTNewsMaxChunk = 40; /* Largest number of articles in one window */ #define NEWS_NETCLOSE NETCLOSE #define NEXT_CHAR HTGetCharacter() +#include <ctype.h> + #include <HTML.h> #include <HTParse.h> #include <HTFormat.h> @@ -185,16 +189,17 @@ PRIVATE BOOL initialize NOARGS #else if (getenv("NNTPSERVER")) { StrAllocCopy(HTNewsHost, (char *)getenv("NNTPSERVER")); - CTRACE(tfp, "HTNews: NNTPSERVER defined as `%s'\n", - HTNewsHost); + if (TRACE) fprintf(stderr, "HTNews: NNTPSERVER defined as `%s'\n", + HTNewsHost); } else { char server_name[256]; FILE* fp = fopen(SERVER_FILE, "r"); if (fp) { if (fscanf(fp, "%s", server_name)==1) { StrAllocCopy(HTNewsHost, server_name); - CTRACE(tfp, "HTNews: File %s defines news host as `%s'\n", - SERVER_FILE, HTNewsHost); + if (TRACE) fprintf(stderr, + "HTNews: File %s defines news host as `%s'\n", + SERVER_FILE, HTNewsHost); } fclose(fp); } @@ -227,7 +232,7 @@ PRIVATE int response ARGS1(CONST char *,command) if (command) { int status; int length = strlen(command); - CTRACE(tfp, "NNTP command to be sent: %s", command); + if (TRACE) fprintf(stderr, "NNTP command to be sent: %s", command); #ifdef NOT_ASCII { CONST char * p; @@ -242,7 +247,8 @@ PRIVATE int response ARGS1(CONST char *,command) status = NEWS_NETWRITE(s, (char *)command, length); #endif /* NOT_ASCII */ if (status < 0){ - CTRACE(tfp, "HTNews: Unable to send command. Disconnecting.\n"); + if (TRACE) fprintf(stderr, + "HTNews: Unable to send command. Disconnecting.\n"); NEWS_NETCLOSE(s); s = -1; return status; @@ -253,19 +259,24 @@ PRIVATE int response ARGS1(CONST char *,command) if (((*p++ = NEXT_CHAR) == LF) || (p == &response_text[LINE_LENGTH])) { *--p = '\0'; /* Terminate the string */ - CTRACE(tfp, "NNTP Response: %s\n", response_text); + if (TRACE) + fprintf(stderr, "NNTP Response: %s\n", response_text); sscanf(response_text, "%d", &result); return result; } /* if end of line */ if ((ch = *(p-1)) == (char)EOF) { *(p-1) = '\0'; - if (interrupted_in_htgetcharacter) { - CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n", + if (TRACE) { + if (interrupted_in_htgetcharacter) { + fprintf(stderr, + "HTNews: Interrupted on read, closing socket %d\n", s); - } else { - CTRACE(tfp, "HTNews: EOF on read, closing socket %d\n", + } else { + fprintf(stderr, + "HTNews: EOF on read, closing socket %d\n", s); + } } NEWS_NETCLOSE(s); /* End of file, close socket */ s = -1; @@ -549,7 +560,8 @@ PRIVATE char * author_name ARGS1 (char *,email) char *p, *e; StrAllocCopy(name, email); - CTRACE(tfp,"Trying to find name in: %s\n",name); + if (TRACE) + fprintf(stderr,"Trying to find name in: %s\n",name); if ((p = strchr(name, '(')) && (e = strchr(name, ')'))) { if (e > p) { @@ -586,7 +598,8 @@ PRIVATE char * author_address ARGS1(char *,email) char *p, *at, *e; StrAllocCopy(address, email); - CTRACE(tfp,"Trying to find address in: %s\n",address); + if (TRACE) + fprintf(stderr,"Trying to find address in: %s\n",address); if ((p = strchr(address, '<'))) { if ((e = strchr(p, '>')) && (at = strchr(p, '@'))) { @@ -757,7 +770,9 @@ PRIVATE void write_anchors ARGS1 (char *,text) */ PRIVATE void abort_socket NOARGS { - CTRACE(tfp, "HTNews: EOF on read, closing socket %d\n", s); + if (TRACE) + fprintf(stderr, + "HTNews: EOF on read, closing socket %d\n", s); NEWS_NETCLOSE(s); /* End of file, close socket */ PUTS("Network Error: connection lost"); PUTC('\n'); @@ -894,7 +909,12 @@ PRIVATE void post_article ARGS1( } } fclose(fd); - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ /* ** Send the nntp EOF and get the server's response. - FM @@ -963,7 +983,9 @@ PRIVATE int read_article NOARGS if (ch == (char)EOF) { if (interrupted_in_htgetcharacter) { interrupted_in_htgetcharacter = 0; - CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n", + if (TRACE) + fprintf(stderr, + "HTNews: Interrupted on read, closing socket %d\n", s); NEWS_NETCLOSE(s); s = -1; @@ -974,7 +996,8 @@ PRIVATE int read_article NOARGS } if ((ch == LF) || (p == &line[LINE_LENGTH])) { *--p = '\0'; /* Terminate the string */ - CTRACE(tfp, "H %s\n", line); + if (TRACE) + fprintf(stderr, "H %s\n", line); if (line[0] == '\t' || line[0] == ' ') { int i = 0; @@ -1230,7 +1253,9 @@ PRIVATE int read_article NOARGS if (ch == (char)EOF) { if (interrupted_in_htgetcharacter) { interrupted_in_htgetcharacter = 0; - CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n", + if (TRACE) + fprintf(stderr, + "HTNews: Interrupted on read, closing socket %d\n", s); NEWS_NETCLOSE(s); s = -1; @@ -1241,7 +1266,8 @@ PRIVATE int read_article NOARGS } if ((ch == LF) || (p == &line[LINE_LENGTH])) { *p++ = '\0'; /* Terminate the string */ - CTRACE(tfp, "B %s", line); + if (TRACE) + fprintf(stderr, "B %s", line); if (line[0] == '.') { /* ** End of article? @@ -1434,7 +1460,9 @@ PRIVATE int read_list ARGS1(char *, arg) if (ch == (char)EOF) { if (interrupted_in_htgetcharacter) { interrupted_in_htgetcharacter = 0; - CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n", + if (TRACE) + fprintf(stderr, + "HTNews: Interrupted on read, closing socket %d\n", s); NEWS_NETCLOSE(s); s = -1; @@ -1454,7 +1482,9 @@ PRIVATE int read_list ARGS1(char *, arg) continue; } } else if (p == &line[LINE_LENGTH]) { - CTRACE(tfp, "b %.*s%c[...]\n", (LINE_LENGTH), line, ch); + if (TRACE) { + fprintf(stderr, "b %.*s%c[...]\n", (LINE_LENGTH), line, ch); + } *p = '\0'; if (ch == LF) { ; /* Will be dealt with below */ @@ -1464,7 +1494,9 @@ PRIVATE int read_list ARGS1(char *, arg) } else if (strchr(line, ' ') == NULL && strchr(line, '\t') == NULL) { /* No separator found */ - CTRACE(tfp, "HTNews..... group name too long, discarding.\n"); + if (TRACE) + fprintf(stderr, + "HTNews..... group name too long, discarding.\n"); skip_this_line = YES; /* ignore whole line */ continue; } else { @@ -1476,7 +1508,8 @@ PRIVATE int read_list ARGS1(char *, arg) if (ch == LF) { skip_rest_of_line = NO; /* done, reset flag */ *p = '\0'; /* Terminate the string */ - CTRACE(tfp, "B %s", line); + if (TRACE) + fprintf(stderr, "B %s", line); if (line[0] == '.') { /* ** End of article? @@ -1584,7 +1617,9 @@ PRIVATE int read_group ARGS3( PUTC('\n'); sscanf(response_text, " %d %d %d %d", &status, &count, &first, &last); - CTRACE(tfp, "Newsgroup status=%d, count=%d, (%d-%d) required:(%d-%d)\n", + if (TRACE) + fprintf(stderr, + "Newsgroup status=%d, count=%d, (%d-%d) required:(%d-%d)\n", status, count, first, last, first_required, last_required); if (last == 0) { PUTS("\nNo articles in this group.\n"); @@ -1607,8 +1642,9 @@ PRIVATE int read_group ARGS3( if (last_required-first_required+1 > HTNewsMaxChunk) { /* Trim this block */ first_required = last_required-HTNewsChunkSize+1; } - CTRACE(tfp, " Chunk will be (%d-%d)\n", - first_required, last_required); + if (TRACE) + fprintf(stderr, " Chunk will be (%d-%d)\n", + first_required, last_required); /* ** Set window title. @@ -1631,7 +1667,8 @@ PRIVATE int read_group ARGS3( before = first_required-HTNewsChunkSize; sprintf(buffer, "%s%s/%d-%d", NewsHREF, groupName, before, first_required-1); - CTRACE(tfp, " Block before is %s\n", buffer); + if (TRACE) + fprintf(stderr, " Block before is %s\n", buffer); PUTC('('); start_anchor(buffer); PUTS("Earlier articles"); @@ -1659,7 +1696,9 @@ PRIVATE int read_group ARGS3( if (ch == (char)EOF) { if (interrupted_in_htgetcharacter) { interrupted_in_htgetcharacter = 0; - CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n", + if (TRACE) + fprintf(stderr, + "HTNews: Interrupted on read, closing socket %d\n", s); NEWS_NETCLOSE(s); s = -1; @@ -1670,7 +1709,8 @@ PRIVATE int read_group ARGS3( } if ((ch == '\n') || (p == &line[LINE_LENGTH])) { *p = '\0'; /* Terminate the string */ - CTRACE(tfp, "X %s", line); + if (TRACE) + fprintf(stderr, "X %s", line); if (line[0] == '.') { /* ** End of article? @@ -1762,7 +1802,9 @@ PRIVATE int read_group ARGS3( if (ch == (char)EOF) { if (interrupted_in_htgetcharacter) { interrupted_in_htgetcharacter = 0; - CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n", + if (TRACE) + fprintf(stderr, + "HTNews: Interrupted on read, closing socket %d\n", s); NEWS_NETCLOSE(s); s = -1; @@ -1776,7 +1818,8 @@ PRIVATE int read_group ARGS3( *--p = '\0'; /* Terminate & chop LF*/ p = line; /* Restart at beginning */ - CTRACE(tfp, "G %s\n", line); + if (TRACE) + fprintf(stderr, "G %s\n", line); switch(line[0]) { case '.': @@ -1870,7 +1913,9 @@ PRIVATE int read_group ARGS3( */ } else if (status == HT_INTERRUPTED) { interrupted_in_htgetcharacter = 0; - CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n", + if (TRACE) + fprintf(stderr, + "HTNews: Interrupted on read, closing socket %d\n", s); NEWS_NETCLOSE(s); s = -1; @@ -1912,7 +1957,8 @@ PRIVATE int read_group ARGS3( else sprintf(buffer, "%s%s/%d-%d", NewsHREF, groupName, last_required+1, after); - CTRACE(tfp, " Block after is %s\n", buffer); + if (TRACE) + fprintf(stderr, " Block after is %s\n", buffer); PUTC('('); start_anchor(buffer); PUTS("Later articles"); @@ -1983,7 +2029,7 @@ PRIVATE int HTLoadNews ARGS4( format_out == HTAtom_for("www/dump")); rawtext = NO; - CTRACE(tfp, "HTNews: Looking for %s\n", arg); + if (TRACE) fprintf(stderr, "HTNews: Looking for %s\n", arg); if (!initialized) initialized = initialize(); @@ -2184,7 +2230,9 @@ PRIVATE int HTLoadNews ARGS4( command[258] = '\0'; FREE(cp); sprintf(proxycmd, "GET %.251s%c%c%c%c", command, CR, LF, CR, LF); - CTRACE(tfp, "HTNews: Proxy command is '%.*s'\n", + if (TRACE) + fprintf(stderr, + "HTNews: Proxy command is '%.*s'\n", (int)(strlen(proxycmd) - 4), proxycmd); strcat(command, "/"); StrAllocCopy(ProxyHREF, NewsHREF); @@ -2326,7 +2374,8 @@ PRIVATE int HTLoadNews ARGS4( } else { sprintf (url, "%.259s", NewsHREF); } - CTRACE (tfp, "News: doing HTDoConnect on '%s'\n", url); + if (TRACE) + fprintf (stderr, "News: doing HTDoConnect on '%s'\n", url); _HTProgress("Connecting to NewsHost ..."); @@ -2335,7 +2384,9 @@ PRIVATE int HTLoadNews ARGS4( /* ** Interrupt cleanly. */ - CTRACE(tfp, "HTNews: Interrupted on connect; recovering cleanly.\n"); + if (TRACE) + fprintf(stderr, + "HTNews: Interrupted on connect; recovering cleanly.\n"); _HTProgress("Connection interrupted."); if (!(post_wanted || reply_wanted || spost_wanted || sreply_wanted)) { @@ -2347,7 +2398,12 @@ PRIVATE int HTLoadNews ARGS4( FREE(ProxyHREF); FREE(ListArg); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ FREE(postfile); } return HT_NOT_LOADED; @@ -2356,7 +2412,9 @@ PRIVATE int HTLoadNews ARGS4( char message[256]; NEWS_NETCLOSE(s); s = -1; - CTRACE(tfp, "HTNews: Unable to connect to news host.\n"); + if (TRACE) + fprintf(stderr, + "HTNews: Unable to connect to news host.\n"); if (retries < 1) continue; sprintf(message, "Could not access %s.", NewsHost); @@ -2366,17 +2424,25 @@ PRIVATE int HTLoadNews ARGS4( FREE(ProxyHREF); FREE(ListArg); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ FREE(postfile); } return HTLoadError(stream, 500, message); } else { - CTRACE(tfp, "HTNews: Connected to news host %s.\n", - NewsHost); + if (TRACE) + fprintf(stderr, "HTNews: Connected to news host %s.\n", + NewsHost); HTInitInput(s); /* set up buffering */ if (proxycmd[0]) { status = NEWS_NETWRITE(s, proxycmd, strlen(proxycmd)); - CTRACE(tfp, "HTNews: Proxy command returned status '%d'.\n", + if (TRACE) + fprintf(stderr, + "HTNews: Proxy command returned status '%d'.\n", status); } if (((status = response(NULL)) / 100) != 2) { @@ -2395,7 +2461,12 @@ PRIVATE int HTLoadNews ARGS4( FREE(ProxyHREF); FREE(ListArg); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ FREE(postfile); } return(HT_NOT_LOADED); @@ -2422,7 +2493,12 @@ PRIVATE int HTLoadNews ARGS4( } FREE(ListArg); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ FREE(postfile); } return(HT_NOT_LOADED); @@ -2443,7 +2519,12 @@ PRIVATE int HTLoadNews ARGS4( } FREE(ListArg); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ FREE(postfile); } return(HT_NOT_LOADED); @@ -2588,7 +2669,12 @@ Send_NNTP_command: if (status != 340) { HTAlert("Cannot POST to this host."); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ } } else { post_article(postfile); @@ -2650,7 +2736,12 @@ Send_NNTP_command: } FREE(ListArg); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ FREE(postfile); } return status; @@ -2673,7 +2764,12 @@ Send_NNTP_command: } FREE(ListArg); if (postfile) { - HTSYS_remove(postfile); +#ifdef VMS + while (remove(postfile) == 0) + ; /* loop through all versions */ +#else + remove(postfile); +#endif /* VMS */ FREE(postfile); } return HT_NOT_LOADED; diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c index 7362a59a..97d3f5ea 100644 --- a/WWW/Library/Implementation/HTParse.c +++ b/WWW/Library/Implementation/HTParse.c @@ -3,10 +3,13 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTParse.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + #define HEX_ESCAPE '%' struct struct_parts { @@ -187,7 +190,9 @@ PUBLIC char * HTParse ARGS3( char * acc_method; struct struct_parts given, related; - CTRACE(tfp, "HTParse: aName:%s relatedName:%s\n", aName, relatedName); + if (TRACE) + fprintf(stderr, + "HTParse: aName:%s relatedName:%s\n", aName, relatedName); /* ** Allocate the output string. @@ -245,7 +250,7 @@ PUBLIC char * HTParse ARGS3( ** this is back to inheriting for identical ** schemes whether or not they are "file". ** If you want to try it again yourself, - ** uncomment the strcasecomp() below. - FM + ** uncomment the strncasecomp() below. - FM */ if ((given.access && related.access) && (/* strcasecomp(given.access, "file") || */ @@ -360,7 +365,8 @@ PUBLIC char * HTParse ARGS3( if (wanted & PARSE_PUNCTUATION) strcat(result, "/"); strcat(result, given.absolute); - CTRACE(tfp, "1\n"); + if (TRACE) + fprintf(stderr, "1\n"); } else if (related.absolute) { /* Adopt path not name */ strcat(result, "/"); strcat(result, related.absolute); @@ -374,13 +380,16 @@ PUBLIC char * HTParse ARGS3( strcat(result, given.relative); /* Add given one */ HTSimplify (result); } - CTRACE(tfp, "2\n"); + if (TRACE) + fprintf(stderr, "2\n"); } else if (given.relative) { strcat(result, given.relative); /* what we've got */ - CTRACE(tfp, "3\n"); + if (TRACE) + fprintf(stderr, "3\n"); } else if (related.relative) { strcat(result, related.relative); - CTRACE(tfp, "4\n"); + if (TRACE) + fprintf(stderr, "4\n"); } else { /* No inheritance */ if (strncasecomp(aName, "lynxcgi:", 8) && strncasecomp(aName, "lynxexec:", 9) && @@ -389,7 +398,8 @@ PUBLIC char * HTParse ARGS3( } if (!strcmp(result, "news:/")) result[5] = '*'; - CTRACE(tfp, "5\n"); + if (TRACE) + fprintf(stderr, "5\n"); } } @@ -404,7 +414,8 @@ PUBLIC char * HTParse ARGS3( strcat(result, (given.anchor) ? given.anchor : related.anchor); } - CTRACE(tfp, "HTParse: result:%s\n", result); + if (TRACE) + fprintf(stderr, "HTParse: result:%s\n", result); FREE(rel); FREE(name); @@ -636,7 +647,8 @@ PUBLIC char * HTRelative ARGS2( strcat(result, "../"); strcat(result, last_slash+1); } - CTRACE(tfp, "HT: `%s' expressed relative to\n `%s' is\n `%s'.", + if (TRACE) + fprintf(stderr, "HT: `%s' expressed relative to\n `%s' is\n `%s'.", aName, relatedName, result); return result; } diff --git a/WWW/Library/Implementation/HTParse.h b/WWW/Library/Implementation/HTParse.h index bea789d0..cf42d97b 100644 --- a/WWW/Library/Implementation/HTParse.h +++ b/WWW/Library/Implementation/HTParse.h @@ -8,7 +8,9 @@ #ifndef HTPARSE_H #define HTPARSE_H +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ /* ** The following are flag bits which may be ORed together to form diff --git a/WWW/Library/Implementation/HTPasswd.c b/WWW/Library/Implementation/HTPasswd.c index 764882d4..45a53aee 100644 --- a/WWW/Library/Implementation/HTPasswd.c +++ b/WWW/Library/Implementation/HTPasswd.c @@ -15,8 +15,10 @@ ** */ -#include <HTUtils.h> +#include <HTUtils.h> +#include <tcp.h> /* FROMASCII() */ +#include <string.h> #include <HTAAUtil.h> /* Common parts of AA */ #include <HTAAFile.h> /* File routines */ #include <HTAAServ.h> /* Server routines */ @@ -136,7 +138,7 @@ PUBLIC BOOL HTAA_passwdMatch ARGS2(CONST char *, password, CONST char *, encrypted) { char *result; - size_t len; + int len; int status; if (!password || !encrypted) @@ -150,7 +152,7 @@ PUBLIC BOOL HTAA_passwdMatch ARGS2(CONST char *, password, outofmem(__FILE__, "HTAA_encryptPasswd"); *result = (char)0; - while (len != 0) { + while (len > 0) { char salt[3]; char chunk[9]; CONST char *cur1 = password; @@ -174,7 +176,9 @@ PUBLIC BOOL HTAA_passwdMatch ARGS2(CONST char *, password, status = strncmp(result, encrypted, strlen(encrypted)); - CTRACE(tfp, "%s `%s' (encrypted: `%s') with: `%s' => %s\n", + if (TRACE) + fprintf(stderr, + "%s `%s' (encrypted: `%s') with: `%s' => %s\n", "HTAA_passwdMatch: Matching password:", password, result, encrypted, (status==0 ? "OK" : "INCORRECT")); @@ -262,14 +266,16 @@ PUBLIC BOOL HTAA_checkPassword ARGS3(CONST char *, username, else fp = fopen(PASSWD_FILE,"r"); if (!fp) { - CTRACE(tfp, "%s `%s'\n", - "HTAA_checkPassword: Unable to open password file", - (filename && *filename ? filename : PASSWD_FILE)); + if (TRACE) fprintf(stderr, "%s `%s'\n", + "HTAA_checkPassword: Unable to open password file", + (filename && *filename ? filename : PASSWD_FILE)); return NO; } do { if (2 == (status = HTAAFile_readPasswdRec(fp,user,pw))) { - CTRACE(tfp, "HTAAFile_validateUser: %s \"%s\" %s \"%s:%s\"\n", + if (TRACE) + fprintf(stderr, + "HTAAFile_validateUser: %s \"%s\" %s \"%s:%s\"\n", "Matching username:", username, "against passwd record:", user, pw); if (username && user && !strcmp(username,user)) { @@ -286,7 +292,7 @@ PUBLIC BOOL HTAA_checkPassword ARGS3(CONST char *, username, fclose(fp); - CTRACE(tfp, "HTAAFile_checkPassword: (%s,%s) %scorrect\n", + if (TRACE) fprintf(stderr, "HTAAFile_checkPassword: (%s,%s) %scorrect\n", username, password, ((status != EOF) ? "" : "in")); if (status == EOF) return NO; /* We traversed to the end without luck */ diff --git a/WWW/Library/Implementation/HTPasswd.h b/WWW/Library/Implementation/HTPasswd.h index 09007192..b82d1d4e 100644 --- a/WWW/Library/Implementation/HTPasswd.h +++ b/WWW/Library/Implementation/HTPasswd.h @@ -5,6 +5,9 @@ #ifndef HTPASSWD_H #define HTPASSWD_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTList.h> #ifdef SHORT_NAMES diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c index 81e46d72..14b89bf8 100644 --- a/WWW/Library/Implementation/HTPlain.c +++ b/WWW/Library/Implementation/HTPlain.c @@ -7,8 +7,8 @@ ** Bugs: ** strings written must be less than buffer size. */ - #include <HTUtils.h> +#include <tcp.h> #include <HTPlain.h> @@ -31,6 +31,9 @@ #include <LYCharSets.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + +extern BOOLEAN LYRawMode; extern BOOL HTPassEightBitRaw; extern BOOL HTPassHighCtrlRaw; extern HTCJKlang HTCJK; @@ -51,7 +54,6 @@ struct _HTStream { /* ** The node_anchor UCInfo and handle for the output (HTEXT) stage. - FM */ - LYUCcharset * outUCI; int outUCLYhndl; /* ** Counter, value, buffer and pointer for UTF-8 handling. - FM @@ -89,7 +91,6 @@ PRIVATE void HTPlain_getChartransInfo ARGS2( me->outUCLYhndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_HTEXT); } me->inUCI = HTAnchor_getUCInfoStage(anchor, UCT_STAGE_PARSER); - me->outUCI = HTAnchor_getUCInfoStage(anchor, UCT_STAGE_HTEXT); } /* Write the buffer out to the socket @@ -135,14 +136,14 @@ PRIVATE void HTPlain_put_character ARGS2( HTPlain_lastraw = c; if (c == '\r') { HText_appendCharacter(me->text, '\n'); + } else if (HTCJK != NOCJK) { + HText_appendCharacter(me->text, c); } else if ((unsigned char)c >= 127) { /* ** For now, don't repeat everything here ** that has been done below - KW */ HTPlain_write(me, &c, 1); - } else if (HTCJK != NOCJK) { - HText_appendCharacter(me->text, c); } else if ((unsigned char)c >= 127 && (unsigned char)c < 161 && HTPassHighCtrlRaw) { HText_appendCharacter(me->text, c); @@ -155,9 +156,9 @@ PRIVATE void HTPlain_put_character ARGS2( HText_appendCharacter(me->text, c); } else if ((unsigned char)c > 160) { if (!HTPassEightBitRaw && - !((me->outUCLYhndl == LATIN1) || - (me->outUCI->enc & (UCT_CP_SUPERSETOF_LAT1)))) { - int len, high, low, i, diff = 1; + current_char_set != 0) { + size_t len, high, low, i; + int diff = 1; CONST char * name; UCode_t value = (UCode_t)((unsigned char)c - 160); @@ -171,7 +172,7 @@ PRIVATE void HTPlain_put_character ARGS2( diff = strncmp(HTML_dtd.entity_names[i], name, len); if (diff == 0) { HText_appendText(me->text, - LYCharSets[me->outUCLYhndl][i]); + LYCharSets[current_char_set][i]); break; } } @@ -217,8 +218,8 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) char c; unsigned char c_unsign; BOOL chk; - UCode_t code, uck = -1; - char saved_char_in = '\0'; + UCode_t code; + long uck = 0; for (p = s; p < e; p++) { #ifdef REMOVE_CR_ONLY @@ -251,7 +252,6 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) c = *p; c_unsign = (unsigned char)c; code = (UCode_t)c_unsign; - saved_char_in = '\0'; /* ** Combine any UTF-8 multibytes into Unicode ** to check for special characters. - FM @@ -282,9 +282,8 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) */ *(me->utf_buf_p) = '\0'; code = me->utf_char; - if (code > 0 && code < 256) { + if (code < 256) { c = FROMASCII((char)code); - c_unsign = (unsigned char)c; } } else { /* @@ -296,8 +295,9 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) /* ** Start handling a new multibyte character. - FM */ + me->utf_buf_p = me->utf_buf; me->utf_buf_p[0] = c; - me->utf_buf_p = &me->utf_buf[1]; + (me->utf_buf_p)++; if ((*p & 0xe0) == 0xc0) { me->utf_count = 1; me->utf_char = (c & 0x1f); @@ -318,45 +318,26 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) * We got garbage, so ignore it. - FM */ me->utf_count = 0; - me->utf_buf_p[0] = '\0'; me->utf_buf_p = me->utf_buf; + me->utf_buf_p[0] = '\0'; } /* ** Get the next byte. - FM */ continue; } - } else if (me->utf_count > 0) { + } else { /* - ** Got an ASCII character when expecting - ** UTF-8 multibytes, so ignore the buffered - ** multibye characters and fall through with - ** the current ASCII character. - FM + ** Got an ASCII character. */ me->utf_count = 0; me->utf_buf[0] = '\0'; me->utf_buf_p = me->utf_buf; - code = (UCode_t)c_unsign; - } else { - /* - ** Got a valid ASCII character, so fall - ** through with it. - FM - */ - code = (UCode_t)c_unsign; } } - /* - ** Convert characters from non-UTF-8 charsets - ** to Unicode (if appropriate). - FM - */ - if (!(me->T.decode_utf8 && - (unsigned char)(*p) > 127)) { -#ifdef NOTDEFINED - if (me->T.strip_raw_char_in) - saved_char_in = c; -#endif /* NOTDEFINED */ + if (me->T.trans_to_uni && - (code >= LYlowest_eightbit[me->inUCLYhndl] || + (code >= 127 || (code < 32 && code != 0 && me->T.trans_C0_to_uni))) { /* @@ -364,58 +345,10 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) */ code = (UCode_t)UCTransToUni(c, me->inUCLYhndl); if (code > 0) { - saved_char_in = c; if (code < 256) { - c = FROMASCII((char)code); - c_unsign = (unsigned char)c; + c = FROMASCII((char)code); } } - } else if (code < 32 && code != 0 && - me->T.trans_C0_to_uni) { - /* - ** Quote from SGML.c: - ** "This else if may be too ugly to keep. - KW" - */ - if (me->T.trans_from_uni && - (((code = UCTransToUni(c, me->inUCLYhndl)) >= 32) || - (me->T.transp && - (code = UCTransToUni(c, me->inUCLYhndl)) > 0))) { - saved_char_in = c; - if (code < 256) { - c = FROMASCII((char)code); - c_unsign = (unsigned char)c; - } - } else { - uck = -1; - if (me->T.transp) { - uck = UCTransCharStr(replace_buf, 60, c, - me->inUCLYhndl, - me->inUCLYhndl, NO); - } - if (!me->T.transp || uck < 0) { - uck = UCTransCharStr(replace_buf, 60, c, - me->inUCLYhndl, - me->outUCLYhndl, YES); - } - if (uck == 0) { - continue; - } else if (uck < 0) { - me->utf_buf[0] = '\0'; - code = (unsigned char)c; - } else { - c = replace_buf[0]; - if (c && replace_buf[1]) { - HText_appendText(me->text, replace_buf); - continue; - } - } - me->utf_buf[0] = '\0'; - code = (unsigned char)c; - } /* Next line end of ugly stuff for C0. - KW */ - } else { - me->utf_buf[0] = '\0'; - code = (unsigned char)c; - } } /* ** At this point we have either code in Unicode @@ -466,16 +399,17 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) c >= LYlowest_eightbit[me->outUCLYhndl]) || *p == '\n' || *p == '\t') { HText_appendCharacter(me->text, c); + + } else if (me->T.use_raw_char_in) { + HText_appendCharacter(me->text, *p); +#ifdef NOTDEFINED /* ** Use an ASCII space (32) for ensp, emsp or thinsp. - FM */ } else if (code == 8194 || code == 8195 || code == 8201) { HText_appendCharacter(me->text, ' '); - /* - ** If we want the raw character, pass it now. - FM - */ - } else if (me->T.use_raw_char_in && saved_char_in) { - HText_appendCharacter(me->text, saved_char_in); +#endif /* NOTDEFINED */ + /****************************************************************** * I. LATIN-1 OR UCS2 TO DISPLAY CHARSET ******************************************************************/ @@ -483,8 +417,11 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) (uck = UCTransUniChar(code, me->outUCLYhndl)) >= 32 && uck < 256) { - CTRACE(tfp, "UCTransUniChar returned 0x%.2lX:'%c'.\n", + if (TRACE) { + fprintf(stderr, + "UCTransUniChar returned 0x%.2lX:'%c'.\n", uck, FROMASCII((char)uck)); + } HText_appendCharacter(me->text, ((char)(uck & 0xff))); } else if (chk && (uck == -4 || @@ -526,29 +463,23 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) ** (somewhat) readable ASCII. */ HText_appendCharacter(me->text, (char)(*p & 0x7f)); -#endif /* NOTDEFINED */ - /* - ** If we don't actually want the character, - ** make it safe and output that now. - FM - */ - } else if ((c_unsign > 0 && - c_unsign < LYlowest_eightbit[me->outUCLYhndl]) || - (me->T.trans_from_uni && !HTPassEightBitRaw)) { /* ** If we do not have the "7-bit approximations" as our ** output character set (in which case we did it already) ** seek a translation for that. Otherwise, or if the ** translation fails, use UHHH notation. - FM */ - if ((chk = (me->outUCLYhndl != - UCGetLYhndl_byMIME("us-ascii"))) && + } else if (chk && + (chk = (!HTPassEightBitRaw && + (me->outUCLYhndl != + UCGetLYhndl_byMIME("us-ascii")))) && (uck = UCTransUniChar(code, UCGetLYhndl_byMIME("us-ascii"))) >= 32 && uck < 127) { /* ** Got an ASCII character (yippey). - FM */ - c = FROMASCII((char)uck); + c = ((char)(uck & 0xff)); HText_appendCharacter(me->text, c); } else if ((chk && uck == -4) && (uck = UCTransUniCharStr(replace_buf, @@ -558,33 +489,110 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) /* ** Got a repacement string (yippey). - FM */ - HText_appendText(me->text, replace_buf); - } else if (code == 8204 || code == 8205) { - /* - ** Ignore 8204 (zwnj) or 8205 (zwj), if we get to here. - FM - */ - CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code); - } else if (code == 8206 || code == 8207) { - /* - ** Ignore 8206 (lrm) or 8207 (rlm), if we get to here. - FM - */ - CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code); + HText_appendText(me->text, replace_buf); + } else if (code == 8204 || code == 8205) { + /* + ** Ignore 8204 (zwnj) or 8205 (zwj), if we get to here. - FM + */ + if (TRACE) { + fprintf(stderr, + "HTPlain_write: Ignoring '%ld'.\n", code); + } + } else if (code == 8206 || code == 8207) { + /* + ** Ignore 8206 (lrm) or 8207 (rlm), if we get to here. - FM + */ + if (TRACE) { + fprintf(stderr, + "HTPlain_write: Ignoring '%ld'.\n", code); + } +#endif /* NOTDEFINED */ + } else if (me->T.trans_from_uni && code > 255) { + if (PASSHI8BIT && PASSHICTRL && LYRawMode && + (unsigned char)*p >= LYlowest_eightbit[me->outUCLYhndl]) { + HText_appendCharacter(me->text, *p); } else { + sprintf(replace_buf, "U%.2lX", code); + HText_appendText(me->text, replace_buf); + } + /* + ** If we get to here and HTPassEightBitRaw or the + ** selected character set is not "ISO Latin 1", + ** use the translation tables for 161-255 8-bit + ** characters (173 was handled above). - FM + */ + } else if (code > 160) { + if (!HTPassEightBitRaw && code <= 255 && + me->outUCLYhndl != 0) { /* ** Out of luck, so use the UHHH notation (ugh). - FM */ - /* do not print UHHH for now + size_t len, high, low, i; + int diff = 1; + CONST char * name; + int value = (int)(code - 160); + + name = HTMLGetEntityName(value); + len = strlen(name); + for(low = 0, high = HTML_dtd.number_of_entities; + high > low; + diff < 0 ? (low = i+1) : (high = i)) { + /* Binary search */ + i = (low + (high-low)/2); + diff = strncmp(HTML_dtd.entity_names[i], name, len); + if (diff == 0) { + HText_appendText(me->text, + LYCharSets[me->outUCLYhndl][i]); + break; + } + } + if (diff) { + /* + ** Something went wrong in the translation, so + ** either output as UTF8 or a hex representation or + ** pass the raw character and hope it's OK. + */ + if (!PASSHI8BIT) + c = FROMASCII((char)code); + if (me->T.output_utf8 && + *me->utf_buf) { + HText_appendText(me->text, me->utf_buf); + me->utf_buf_p = me->utf_buf; + *(me->utf_buf_p) = '\0'; + + } else if (me->T.trans_from_uni) { sprintf(replace_buf, "U%.2lX", code); HText_appendText(me->text, replace_buf); - */ + } else + HText_appendCharacter(me->text, c); } + } else { /* - ** If we get to here and have a monobyte character, - ** pass it. - FM + ** Didn't attempt a translation. - FM */ - } else if (c_unsign != 0 && c_unsign < 256) { + /* Either output as UTF8 or a hex representation or + ** pass the raw character and hope it's OK. + */ + if (code <= 255 && !PASSHI8BIT) + c = FROMASCII((char)code); + if (code > 127 && me->T.output_utf8 && *me->utf_buf) { + HText_appendText(me->text, me->utf_buf); + me->utf_buf_p = me->utf_buf; + *(me->utf_buf_p) = '\0'; + + } else if (LYRawMode && + me->inUCLYhndl != me->outUCLYhndl && + (PASSHI8BIT || PASSHICTRL) && + (unsigned char)c >= + LYlowest_eightbit[me->outUCLYhndl]) { + HText_appendCharacter(me->text, c); + } else if (me->T.trans_from_uni && code >= 127) { + sprintf(replace_buf, "U%.2lX", code); + HText_appendText(me->text, replace_buf); + } else HText_appendCharacter(me->text, c); } + } #endif /* REMOVE_CR_ONLY */ } } @@ -650,7 +658,7 @@ PUBLIC HTStream* HTPlainPresent ARGS3( HTAnchor_getUCInfoStage(anchor,UCT_STAGE_HTEXT)); me->text = HText_new(anchor); - HText_setStyle(me->text, LYstyles(HTML_XMP) ); + HText_setStyle(me->text, styles[HTML_XMP] ); HText_beginAppend(me->text); return (HTStream*) me; diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c index e666618f..24604e29 100644 --- a/WWW/Library/Implementation/HTRules.c +++ b/WWW/Library/Implementation/HTRules.c @@ -7,10 +7,10 @@ ** 10 Aug 91 Authorisation added after Daniel Martin (pass, fail) ** Rule order in file changed ** Comments allowed with # on 1st char of rule line -** 17 Jun 92 Bug fix: pass and fail failed if didn't contain '*' TBL -** 1 Sep 93 Bug fix: no memory check - Nathan Torkington -** BYTE_ADDRESSING removed - Arthur Secret -** 11 Sep 93 MD Changed %i into %d in debug printf. +** 17 Jun 92 Bug fix: pass and fail failed if didn't contain '*' TBL +** 1 Sep 93 Bug fix: no memory check - Nathan Torkington +** BYTE_ADDRESSING removed - Arthur Secret +** 11 Sep 93 MD Changed %i into %d in debug printf. ** VMS does not recognize %i. ** Bug Fix: in case of PASS, only one parameter to printf. ** 19 Sep 93 AL Added Access Authorization stuff. @@ -18,11 +18,12 @@ ** */ -#include <HTUtils.h> - /* (c) CERN WorldWideWeb project 1990,91. See Copyright.html for details */ #include <HTRules.h> +#include <HTUtils.h> +#include <tcp.h> +/*#include <stdio.h> included by HTUtils.h -- FM */ #include <HTFile.h> #include <HTAAServ.h> /* Access Authorization */ @@ -42,7 +43,7 @@ typedef struct _rule { ** ---------------- */ PUBLIC char *HTBinDir = NULL; /* Physical /htbin directory path. */ - /* In future this should not be global. */ + /* In future this should not be global. */ PUBLIC char *HTSearchScript = NULL; /* Search script name. */ @@ -60,11 +61,11 @@ PRIVATE rule * rule_tail = 0; /* Pointer to last on list */ ** -------------------- ** ** On entry, -** pattern points to 0-terminated string containing a single "*" +** pattern points to 0-terminated string containing a single "*" ** equiv points to the equivalent string with * for the ** place where the text matched by * goes. ** On exit, -** returns 0 if success, -1 if error. +** returns 0 if success, -1 if error. */ #ifdef __STDC__ @@ -76,32 +77,33 @@ int HTAddRule(op, pattern, equiv) char * equiv; #endif { /* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */ - rule * temp; - char * pPattern; + rule * temp; + char * pPattern; temp = (rule *)malloc(sizeof(*temp)); - if (temp==NULL) - outofmem(__FILE__, "HTAddRule"); + if (temp==NULL) + outofmem(__FILE__, "HTAddRule"); pPattern = (char *)malloc(strlen(pattern)+1); - if (pPattern==NULL) - outofmem(__FILE__, "HTAddRule"); + if (pPattern==NULL) + outofmem(__FILE__, "HTAddRule"); if (equiv) { /* Two operands */ char * pEquiv = (char *)malloc(strlen(equiv)+1); - if (pEquiv==NULL) - outofmem(__FILE__, "HTAddRule"); - temp->equiv = pEquiv; - strcpy(pEquiv, equiv); + if (pEquiv==NULL) + outofmem(__FILE__, "HTAddRule"); + temp->equiv = pEquiv; + strcpy(pEquiv, equiv); } else { - temp->equiv = 0; + temp->equiv = 0; } temp->pattern = pPattern; temp->op = op; strcpy(pPattern, pattern); - if (equiv) { - CTRACE(tfp, "Rule: For `%s' op %d `%s'\n", pattern, op, equiv); - } else { - CTRACE(tfp, "Rule: For `%s' op %d\n", pattern, op); + if (TRACE) { + if (equiv) + fprintf(stderr, "Rule: For `%s' op %d `%s'\n", pattern, op, equiv); + else + fprintf(stderr, "Rule: For `%s' op %d\n", pattern, op); } #ifdef PUT_ON_HEAD @@ -114,17 +116,17 @@ int HTAddRule(op, pattern, equiv) rule_tail = temp; #endif - + return 0; } -/* Clear all rules HTClearRules() +/* Clear all rules HTClearRules() ** --------------- ** ** On exit, ** There are no rules -** returns 0 if success, -1 if error. +** returns 0 if success, -1 if error. ** ** See also ** HTAddRule() @@ -136,7 +138,7 @@ int HTClearRules() #endif { while (rules) { - rule * temp = rules; + rule * temp = rules; rules = temp->next; FREE(temp->pattern); FREE(temp->equiv); @@ -158,7 +160,7 @@ int HTClearRules() ** On entry, ** required points to a string whose equivalent value is neeed ** On exit, -** returns the address of the equivalent string allocated from +** returns the address of the equivalent string allocated from ** the heap which the CALLER MUST FREE. If no translation ** occured, then it is a copy of te original. ** NEW FEATURES: @@ -183,7 +185,7 @@ char * HTTranslate(required) HTAA_clearProtections(); /* Reset from previous call -- AL */ for(r = rules; r; r = r->next) { - char * p = r->pattern; + char * p = r->pattern; int m=0; /* Number of characters matched against wildcard */ CONST char * q = current; for(;*p && *q; p++, q++) { /* Find first mismatch */ @@ -192,9 +194,9 @@ char * HTTranslate(required) if (*p == '*') { /* Match up to wildcard */ m = strlen(q) - strlen(p+1); /* Amount to match to wildcard */ - if(m<0) continue; /* tail is too short to match */ + if(m<0) continue; /* tail is too short to match */ if (0!=strcmp(q+m, p+1)) continue; /* Tail mismatch */ - } else /* Not wildcard */ + } else /* Not wildcard */ if (*p != *q) continue; /* plain mismatch: go to next rule */ switch (r->op) { /* Perform operation */ @@ -208,12 +210,13 @@ char * HTTranslate(required) char *eff_ids = NULL; char *prot_file = NULL; - CTRACE(tfp, "HTRule: `%s' matched %s %s: `%s'\n", - current, - (r->op==HT_Protect ? "Protect" : "DefProt"), - "rule, setup", - (r->equiv ? r->equiv : - (r->op==HT_Protect ?"DEFAULT" :"NULL!!"))); + if (TRACE) fprintf(stderr, + "HTRule: `%s' matched %s %s: `%s'\n", + current, + (r->op==HT_Protect ? "Protect" : "DefProt"), + "rule, setup", + (r->equiv ? r->equiv : + (r->op==HT_Protect ?"DEFAULT" :"NULL!!"))); if (r->equiv) { StrAllocCopy(local_copy, r->equiv); @@ -235,55 +238,57 @@ char * HTTranslate(required) #endif /* ACCESS_AUTH */ case HT_Pass: /* Authorised */ - if (!r->equiv) { - CTRACE(tfp, "HTRule: Pass `%s'\n", current); + if (!r->equiv) { + if (TRACE) fprintf(stderr, "HTRule: Pass `%s'\n", current); return current; - } + } /* Else fall through ...to map and pass */ - + case HT_Map: if (*p == *q) { /* End of both strings, no wildcard */ - CTRACE(tfp, "For `%s' using `%s'\n", current, r->equiv); - StrAllocCopy(current, r->equiv); /* use entire translation */ + if (TRACE) fprintf(stderr, + "For `%s' using `%s'\n", current, r->equiv); + StrAllocCopy(current, r->equiv); /* use entire translation */ } else { char * ins = strchr(r->equiv, '*'); /* Insertion point */ - if (ins) { /* Consistent rule!!! */ + if (ins) { /* Consistent rule!!! */ char * temp = (char *)malloc( strlen(r->equiv)-1 + m + 1); - if (temp==NULL) + if (temp==NULL) outofmem(__FILE__, "HTTranslate"); /* NT & AS */ - strncpy(temp, r->equiv, ins-r->equiv); + strncpy(temp, r->equiv, ins-r->equiv); /* Note: temp may be unterminated now! */ strncpy(temp+(ins-r->equiv), q, m); /* Matched bit */ strcpy (temp+(ins-r->equiv)+m, ins+1); /* Last bit */ - CTRACE(tfp, "For `%s' using `%s'\n", - current, temp); + if (TRACE) fprintf(stderr, "For `%s' using `%s'\n", + current, temp); FREE(current); - current = temp; /* Use this */ + current = temp; /* Use this */ } else { /* No insertion point */ char * temp = (char *)malloc(strlen(r->equiv)+1); - if (temp==NULL) + if (temp==NULL) outofmem(__FILE__, "HTTranslate"); /* NT & AS */ strcpy(temp, r->equiv); - CTRACE(tfp, "For `%s' using `%s'\n", + if (TRACE) fprintf(stderr, "For `%s' using `%s'\n", current, temp); FREE(current); - current = temp; /* Use this */ + current = temp; /* Use this */ } /* If no insertion point exists */ } if (r->op == HT_Pass) { - CTRACE(tfp, "HTRule: ...and pass `%s'\n", - current); + if (TRACE) fprintf(stderr, "HTRule: ...and pass `%s'\n", + current); return current; } break; case HT_Invalid: case HT_Fail: /* Unauthorised */ - CTRACE(tfp, "HTRule: *** FAIL `%s'\n", - current); - return (char *)0; + if (TRACE) fprintf(stderr, "HTRule: *** FAIL `%s'\n", + current); + return (char *)0; + } /* if tail matches ... switch operation */ } /* loop over rules */ @@ -308,7 +313,7 @@ PUBLIC int HTSetConfiguration ARGS1(CONST char *, config) float quality, secs, secs_per_byte; int maxbytes; int status; - + StrAllocCopy(line, config); { char * p = strchr(line, '#'); /* Chop off comments */ @@ -317,9 +322,9 @@ PUBLIC int HTSetConfiguration ARGS1(CONST char *, config) pointer = line; word1 = HTNextField(&pointer); if (!word1) { - FREE(line); + FREE(line); return 0; - } ; /* Comment only or blank */ + } ; /* Comment only or blank */ word2 = HTNextField(&pointer); @@ -336,7 +341,7 @@ PUBLIC int HTSetConfiguration ARGS1(CONST char *, config) } if (0==strcasecomp(word1, "suffix")) { - char * encoding = HTNextField(&pointer); + char * encoding = HTNextField(&pointer); if (pointer) status = sscanf(pointer, "%f", &quality); else status = 0; HTSetSuffix(word2, word3, @@ -344,12 +349,12 @@ PUBLIC int HTSetConfiguration ARGS1(CONST char *, config) status >= 1? quality : 1.0); } else if (0==strcasecomp(word1, "presentation")) { - if (pointer) status = sscanf(pointer, "%f%f%f%d", + if (pointer) status = sscanf(pointer, "%f%f%f%d", &quality, &secs, &secs_per_byte, &maxbytes); - else status = 0; + else status = 0; HTSetPresentation(word2, word3, - status >= 1? quality : 1.0, - status >= 2 ? secs : 0.0, + status >= 1? quality : 1.0, + status >= 2 ? secs : 0.0, status >= 3 ? secs_per_byte : 0.0, status >= 4 ? maxbytes : 0 ); @@ -361,17 +366,17 @@ PUBLIC int HTSetConfiguration ARGS1(CONST char *, config) StrAllocCopy(HTSearchScript, word2); /* Search script name */ } else { - op = 0==strcasecomp(word1, "map") ? HT_Map - : 0==strcasecomp(word1, "pass") ? HT_Pass - : 0==strcasecomp(word1, "fail") ? HT_Fail - : 0==strcasecomp(word1, "defprot") ? HT_DefProt + op = 0==strcasecomp(word1, "map") ? HT_Map + : 0==strcasecomp(word1, "pass") ? HT_Pass + : 0==strcasecomp(word1, "fail") ? HT_Fail + : 0==strcasecomp(word1, "defprot") ? HT_DefProt : 0==strcasecomp(word1, "protect") ? HT_Protect : HT_Invalid; if (op==HT_Invalid) { fprintf(stderr, "HTRule: Bad rule `%s'\n", config); - } else { + } else { HTAddRule(op, word2, word3); - } + } } FREE(line); return 0; @@ -386,7 +391,7 @@ PUBLIC int HTSetConfiguration ARGS1(CONST char *, config) ** On exit, ** Any existing rules will have been kept. ** Any new rules will have been loaded. -** Returns 0 if no error, 0 if error! +** Returns 0 if no error, 0 if error! ** ** Bugs: ** The strings may not contain spaces. @@ -396,9 +401,10 @@ int HTLoadRules ARGS1(CONST char *, filename) { FILE * fp = fopen(filename, "r"); char line[LINE_LENGTH+1]; - + if (!fp) { - CTRACE(tfp, "HTRules: Can't open rules file %s\n", filename); + if (TRACE) fprintf(stderr, + "HTRules: Can't open rules file %s\n", filename); return -1; /* File open error */ } for(;;) { diff --git a/WWW/Library/Implementation/HTRules.h b/WWW/Library/Implementation/HTRules.h index 3eb37169..d19b8a4b 100644 --- a/WWW/Library/Implementation/HTRules.h +++ b/WWW/Library/Implementation/HTRules.h @@ -16,7 +16,9 @@ #ifndef HTRULE_H #define HTRULE_H +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ typedef enum _HTRuleOp { HT_Invalid, diff --git a/WWW/Library/Implementation/HTStream.h b/WWW/Library/Implementation/HTStream.h index d2025274..5892a1a1 100644 --- a/WWW/Library/Implementation/HTStream.h +++ b/WWW/Library/Implementation/HTStream.h @@ -13,7 +13,9 @@ #ifndef HTSTREAM_H #define HTSTREAM_H +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ typedef struct _HTStream HTStream; @@ -23,7 +25,7 @@ typedef struct _HTStream HTStream; for end_document which must be called before free. It should be merged with free in fact: it should be dummy for new streams. - The put_block method was write, but this upset systems which had macros for write(). + The put_block method was write, but this upset systems whiuch had macros for write(). */ typedef struct _HTStreamClass { diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c index 00f70a6c..b669c379 100644 --- a/WWW/Library/Implementation/HTString.c +++ b/WWW/Library/Implementation/HTString.c @@ -6,12 +6,15 @@ ** 23 Jan 92 (TBL) Changed strallocc* to 8 char HTSAC* for VM and suchlike ** 6 Oct 92 (TBL) Moved WWW_TraceFlag in here to be in library */ - +#include <ctype.h> #include <HTUtils.h> +#include <tcp.h> #include <LYLeaks.h> #include <LYStrings.h> +#define FREE(x) if (x) {free(x); x = NULL;} + PUBLIC int WWW_TraceFlag = 0; /* Global trace flag for ALL W3 code */ #ifndef VC diff --git a/WWW/Library/Implementation/HTString.h b/WWW/Library/Implementation/HTString.h index 0609cb00..25c57002 100644 --- a/WWW/Library/Implementation/HTString.h +++ b/WWW/Library/Implementation/HTString.h @@ -7,7 +7,9 @@ #ifndef HTSTRING_H #define HTSTRING_H +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ extern int WWW_TraceFlag; /* Global flag for all W3 trace */ diff --git a/WWW/Library/Implementation/HTStyle.c b/WWW/Library/Implementation/HTStyle.c index 3469e44a..8fc72093 100644 --- a/WWW/Library/Implementation/HTStyle.c +++ b/WWW/Library/Implementation/HTStyle.c @@ -8,12 +8,13 @@ ** translation necessary to ** represent a document. It is a linked list of styles. */ - #include <HTUtils.h> #include <HTStyle.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* Create a new style */ PUBLIC HTStyle* HTStyleNew NOARGS @@ -183,7 +184,7 @@ HTStyle * HTStyleNamed ARGS2 (HTStyleSheet *,self, CONST char *,name) HTStyle * scan; for (scan=self->styles; scan; scan=scan->next) if (0==strcmp(scan->name, name)) return scan; - CTRACE(tfp, "StyleSheet: No style named `%s'\n", name); + if (TRACE) fprintf(stderr, "StyleSheet: No style named `%s'\n", name); return NULL; } @@ -234,8 +235,8 @@ HTStyle * HTStyleForRun (HTStyleSheet *self, NXRun *run) } } } - CTRACE(tfp, "HTStyleForRun: Best match for style is %d out of 18\n", - bestMatch); + if (TRACE) fprintf(stderr, "HTStyleForRun: Best match for style is %d out of 18\n", + bestMatch); return best; } #endif /* NEXT_SUPRESS */ @@ -324,7 +325,7 @@ HTStyleSheet * HTStyleSheetRead(HTStyleSheet * self, NXStream * stream) HTStyle * style; char styleName[80]; NXScanf(stream, " %d ", &numStyles); - CTRACE(tfp, "Stylesheet: Reading %d styles\n", numStyles); + if (TRACE) fprintf(stderr, "Stylesheet: Reading %d styles\n", numStyles); for (i=0; i<numStyles; i++) { NXScanf(stream, "%s", styleName); style = HTStyleNamed(self, styleName); @@ -352,7 +353,7 @@ HTStyleSheet * HTStyleSheetWrite(HTStyleSheet * self, NXStream * stream) for(style=self->styles; style; style=style->next) numStyles++; NXPrintf(stream, "%d\n", numStyles); - CTRACE(tfp, "StyleSheet: Writing %d styles\n", numStyles); + if (TRACE) fprintf(stderr, "StyleSheet: Writing %d styles\n", numStyles); for (style=self->styles; style; style=style->next) { NXPrintf(stream, "%s ", style->name); (void) HTStyleWrite(style, stream); diff --git a/WWW/Library/Implementation/HTStyle.h b/WWW/Library/Implementation/HTStyle.h index b4fcedaa..ae3e5d54 100644 --- a/WWW/Library/Implementation/HTStyle.h +++ b/WWW/Library/Implementation/HTStyle.h @@ -32,6 +32,9 @@ Overriding this module #ifndef HTStyle_H #define HTStyle_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTAnchor.h> typedef long int HTFont; /* Dummy definition instead */ diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index ba4a4b0f..56243a70 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -17,18 +17,20 @@ */ #include <HTUtils.h> +#include <tcp.h> /* Defines SHORT_NAMES if necessary */ #include <HTAccess.h> #include <HTParse.h> #include <HTAlert.h> #include <HTTCP.h> -#include <LYUtils.h> #ifdef NSL_FORK #include <signal.h> #include <sys/wait.h> #endif /* NSL_FORK */ -#define OK_HOST(p) ((p) != 0 && (p->h_length) != 0) +#define FREE(x) if (x) {free(x); x = NULL;} + +extern int HTCheckForInterrupt NOPARAMS; #ifdef SVR4_BSDSELECT PUBLIC int BSDselect PARAMS(( @@ -117,14 +119,11 @@ extern int sys_nerr; #ifdef _WINDOWS_NSL char host[512]; - struct hostent *phost; /* Pointer to host - See netdb.h */ - int donelookup; + struct hostent *phost; /* Pointer to host - See netdb.h */ unsigned long _fork_func (void *arglist) { - phost = gethostbyname(host); - donelookup = TRUE; - return (unsigned long)(phost); + return (unsigned long)(phost = gethostbyname(host)); } #endif /* _WINDOWS_NSL */ @@ -309,19 +308,6 @@ PUBLIC CONST char * HTInetString ARGS1( } #endif /* !DECNET */ -#ifdef NSL_FORK -/* -** Function to allow us to be killed with a normal signal (not -** SIGKILL), but don't go through normal libc exit() processing, which -** would screw up parent's stdio. -BL -*/ -PRIVATE void quench ARGS1( - int, sig GCC_UNUSED) -{ - _exit(2); -} -#endif /* NSL_FORK */ - /* Parse a network node address and port ** ------------------------------------- ** @@ -342,15 +328,19 @@ PUBLIC int HTParseInet ARGS2( int dotcount_ip = 0; /* for dotted decimal IP addr */ #ifndef _WINDOWS_NSL char *host = NULL; + struct hostent *phost; /* Pointer to host - See netdb.h */ #endif /* _WINDOWS_NSL */ if (!str) { - CTRACE(tfp, "HTParseInet: Can't parse `NULL'.\n"); + if (TRACE) { + fprintf(stderr, "HTParseInet: Can't parse `NULL'.\n"); + } return -1; } - CTRACE(tfp, "HTParseInet: parsing `%s'.\n", str); if (HTCheckForInterrupt()) { - CTRACE (tfp, "HTParseInet: INTERRUPTED for '%s'.\n", str); + if (TRACE) { + fprintf (stderr, "HTParseInet: INTERRUPTED for '%s'.\n", str); + } return -1; } #ifdef _WINDOWS_NSL @@ -378,8 +368,8 @@ PUBLIC int HTParseInet ARGS2( struct servent * serv = getservbyname(port, (char*)0); if (serv) { soc_in->sin_port = serv->s_port; - } else { - CTRACE(tfp, "TCP: Unknown service %s\n", port); + } else if (TRACE) { + fprintf(stderr, "TCP: Unknown service %s\n", port); } #endif /* SUPPRESS */ } @@ -392,8 +382,11 @@ PUBLIC int HTParseInet ARGS2( */ soc_in->sdn_nam.n_len = min(DN_MAXNAML, strlen(host)); /* <=6 in phase 4 */ strncpy(soc_in->sdn_nam.n_name, host, soc_in->sdn_nam.n_len + 1); - CTRACE(tfp, "DECnet: Parsed address as object number %d on host %.6s...\n", + if (TRACE) { + fprintf(stderr, + "DECnet: Parsed address as object number %d on host %.6s...\n", soc_in->sdn_objnum, host); + } #else /* parse Internet host: */ if (*host >= '0' && *host <= '9') { /* Test for numeric node address: */ @@ -434,7 +427,10 @@ PUBLIC int HTParseInet ARGS2( #endif /* _WINDOWS_NSL */ } else { /* Alphanumeric node name: */ #ifdef MVS /* Outstanding problem with crash in MVS gethostbyname */ - CTRACE(tfp, "HTParseInet: Calling gethostbyname(%s)\n", host); + if (TRACE) { + fprintf(stderr, + "HTParseInet: Calling gethostbyname(%s)\n", host); + } #endif /* MVS */ #ifdef NSL_FORK @@ -443,208 +439,160 @@ PUBLIC int HTParseInet ARGS2( ** checks for interrupts. - Tom Zerucha (tz@execpc.com) & FM */ { - int success = 0; /* - ** Pipe, child pid, status buffers, cycle count, select() - ** control variables. + ** Pipe, child pid, and status buffers. */ - pid_t fpid, waitret; - int pfd[2], h_length, selret, readret, waitstat = 0, cycle = 0; - fd_set readfds; - struct timeval timeout; - int dns_patience = 30; /* how many seconds will we wait for DNS? */ - int child_exited = 0; - - /* - ** Reap any children that have terminated since last time - ** through. This might include children that we killed, - ** then waited with WNOHANG before they were actually ready - ** to be reaped. (Should be max of 1 in this state, but - ** the loop is safe if waitpid() is implemented correctly: - ** returns 0 when children exist but none have exited; -1 - ** with errno == ECHILD when no children.) -BL - */ - do { - waitret = waitpid(-1, 0, WNOHANG); - } while (waitret > 0 || (waitret == -1 && errno == EINTR)); - waitret = 0; + pid_t fpid, waitret = (pid_t)0; + int pfd[2], cstat, cst1 = 0; pipe(pfd); if ((fpid = fork()) == 0 ) { - struct hostent *phost; /* Pointer to host - See netdb.h */ /* ** Child - for the long call. - ** - ** Make sure parent can kill us at will. -BL - */ - (void) signal(SIGTERM, quench); - - /* - ** Child won't use read side. -BL */ - close(pfd[0]); phost = gethostbyname(host); -#ifdef MVS - CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost); -#endif /* MVS */ - + cst1 = 0; /* - ** Send length of subsequent value to parent (as a - ** native int). + ** Return value (or nulls). */ - if (OK_HOST(phost)) - h_length = phost->h_length; - else - h_length = 0; - write(pfd[1], &h_length, sizeof h_length); - - if (h_length) { - /* - ** Return value through pipe... - */ + if (phost != NULL) write(pfd[1], phost->h_addr, phost->h_length); - _exit(0); - } else { - /* - ** ... or return error as exit code. - */ - _exit(1); - } + else + write(pfd[1], &cst1, 4); + /* + ** Return an error code. + */ + _exit(phost == NULL); } /* - ** (parent) Wait until lookup finishes, or interrupt, - ** or cycled too many times (just in case) -BL + ** (parent) Wait until lookup finishes, or interrupt. */ - - close(pfd[1]); /* parent won't use write side -BL */ - - while (cycle < dns_patience) { - /* - ** Avoid infinite loop in the face of the unexpected. -BL - */ - cycle++; - - timeout.tv_sec = 1; - timeout.tv_usec = 0; - FD_ZERO(&readfds); - FD_SET(pfd[0], &readfds); -#ifndef USE_SLANG - /* - ** This allows us to abort immediately, not after 1-second - ** timeout, when user hits abort key. Can't do this when - ** using SLANG (or at least I don't know how), so SLANG - ** users must live with up-to-1s timeout. -BL - */ - FD_SET(0, &readfds); /* stdin -BL */ -#endif /* USE_SLANG */ - + cstat = 0; + while (cstat <= 0) { /* - ** Return when data received, interrupted, or failed. - ** If nothing is waiting, we sleep for 1 second in - ** select(), to be nice to the system. -BL + ** Exit when data sent. */ -#ifdef SOCKS - if (socks_flag) - selret = Rselect(pfd[0] + 1, (void *)&readfds, NULL, NULL, &timeout); - else -#endif /* SOCKS */ - selret = select(pfd[0] + 1, (void *)&readfds, NULL, NULL, &timeout); - - if ((selret > 0) && FD_ISSET(pfd[0], &readfds)) { - /* - ** First get length of address. -BL - */ - readret = read(pfd[0], (void *)&h_length, sizeof h_length); - if (readret == sizeof h_length && - h_length == sizeof soc_in->sin_addr) { - /* - ** Then get address itself. -BL - */ - readret = read(pfd[0], (void *)&soc_in->sin_addr, h_length); - if (readret == h_length) success = 1; - } - /* - ** Make sure child is cleaned up. -BL - */ - if (!child_exited) - waitret = waitpid(fpid, &waitstat, WNOHANG); - if (!WIFEXITED(waitstat) && !WIFSIGNALED(waitstat)) { - kill(fpid, SIGTERM); - waitret = waitpid(fpid, &waitstat, WNOHANG); - } + IOCTL(pfd[0], FIONREAD, &cstat); + if (cstat > 0) break; - } - /* - ** Clean up if child exited before & no data received. -BL + ** Exit if child exited. */ - if (child_exited) { - waitret = waitpid(fpid, &waitstat, WNOHANG); + if ((waitret = waitpid(fpid, &cst1, WNOHANG)) > 0) { break; } /* - ** If child exited, loop once more looking for data. -BL - */ - if ((waitret = waitpid(fpid, &waitstat, WNOHANG)) > 0) { - /* - ** Data will be arriving right now, so make sure we - ** don't short-circuit out for too many loops, and - ** skip the interrupt check. -BL - */ - child_exited = 1; - cycle--; - continue; - } - - /* ** Abort if interrupt key pressed. */ if (HTCheckForInterrupt()) { - CTRACE(tfp, "HTParseInet: INTERRUPTED gethostbyname.\n"); - kill(fpid, SIGTERM); - waitpid(fpid, NULL, WNOHANG); + if (TRACE) { + fprintf(stderr, + "HTParseInet: INTERRUPTED gethostbyname.\n"); + } + kill(fpid , SIGKILL); + waitpid(fpid, NULL, 0); FREE(host); close(pfd[0]); + close(pfd[1]); return HT_INTERRUPTED; } + /* + ** Be nice to the system. + */ + sleep(1); } - close(pfd[0]); if (waitret <= 0) { - kill(fpid, SIGTERM); - waitret = waitpid(fpid, &waitstat, WNOHANG); + waitret = waitpid(fpid, &cst1, WNOHANG); } - if (waitret > 0) { - if (WIFEXITED(waitstat)) { - CTRACE(tfp, "HTParseInet: NSL_FORK child %d exited, status 0x%x.\n", - (int)waitret, waitstat); - } else if (WIFSIGNALED(waitstat)) { - CTRACE(tfp, "HTParseInet: NSL_FORK child %d got signal, status 0x%x!\n", - (int)waitret, waitstat); + if (TRACE) { + if (WIFEXITED(cst1)) { + fprintf(stderr, + "HTParseInet: NSL_FORK child %d exited, status 0x%x.\n", + (int)waitret, cst1); + } else if (WIFSIGNALED(cst1)) { + fprintf(stderr, + "HTParseInet: NSL_FORK child %d got signal, status 0x%x!\n", + (int)waitret, cst1); #ifdef WCOREDUMP - if (WCOREDUMP(waitstat)) { - CTRACE(tfp, "HTParseInet: NSL_FORK child %d dumped core!\n", - (int)waitret); + if (WCOREDUMP(cst1)) { + fprintf(stderr, + "HTParseInet: NSL_FORK child %d dumped core!\n", + (int)waitret); } #endif /* WCOREDUMP */ - } else if (WIFSTOPPED(waitstat)) { - CTRACE(tfp, "HTParseInet: NSL_FORK child %d is stopped, status 0x%x!\n", - (int)waitret, waitstat); + } else if (WIFSTOPPED(cst1)) { + fprintf(stderr, + "HTParseInet: NSL_FORK child %d is stopped, status 0x%x!\n", + (int)waitret, cst1); } } - if (!success) { - memset((void *)&soc_in->sin_addr, 0, sizeof(soc_in->sin_addr)); - goto failed; + /* + ** Read as much as we can - should be the address. + */ + IOCTL(pfd[0], FIONREAD, &cstat); + if (cstat < 4) { + if (TRACE) { + fprintf(stderr, + "HTParseInet: NSL_FORK child returns only %d bytes.\n", + cstat); + fprintf(stderr, + " Trying again without forking.\n"); + } + phost = gethostbyname(host); /* See netdb.h */ + if (!phost) { + if (TRACE) { + fprintf(stderr, + "HTParseInet: Can't find internet node name `%s'.\n", + host); + } + memset((void *)&soc_in->sin_addr, 0, sizeof(soc_in->sin_addr)); + } else { + memcpy((void *)&soc_in->sin_addr, + phost->h_addr, phost->h_length); + } +#ifdef NOTDEFINED + cstat = read(pfd[0], (void *)&soc_in->sin_addr , 4); +#endif /* NOTDEFINED */ + } else { + cstat = read(pfd[0], (void *)&soc_in->sin_addr , cstat); } + close(pfd[0]); + close(pfd[1]); } + if (soc_in->sin_addr.s_addr == 0) { + if (TRACE) { + fprintf(stderr, + "HTParseInet: Can't find internet node name `%s'.\n", + host); + } +#ifndef _WINDOWS_NSL + FREE(host); +#endif /* _WINDOWS_NSL */ + return -1; + } +#ifndef _WINDOWS_NSL + FREE(host); +#endif /* _WINDOWS_NSL */ +#ifdef MVS + if (TRACE) { + fprintf(stderr, + "HTParseInet: gethostbyname() returned %d\n", phost); + } +#endif /* MVS */ + #else /* Not NSL_FORK: */ #ifdef DJGPP soc_in->sin_addr.s_addr = htonl(resolve(host)); + FREE(host); if (soc_in->sin_addr.s_addr == 0) { - goto failed; + if (TRACE) + fprintf(stderr, + "HTTPAccess: Can't find internet node name `%s'.\n",host); + return -1; /* Fail? */ } -#else /* !NSL_FORK, !DJGPP: */ +#else #ifdef _WINDOWS_NSL { #ifdef __BORLANDC__ @@ -663,9 +611,7 @@ PUBLIC int HTParseInet ARGS2( if (!hThread) MessageBox((void *)NULL, "CreateThread", "CreateThread Failed", 0L); - - donelookup = FALSE; - while (!donelookup) + while (!phost) if (HTCheckForInterrupt()) { /* Note that host is a character array and is not freed */ @@ -676,56 +622,54 @@ PUBLIC int HTParseInet ARGS2( return HT_INTERRUPTED; }; }; - if (!phost) goto failed; - memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); -#else /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL: */ - { - struct hostent *phost; - phost = gethostbyname(host); /* See netdb.h */ +#else /* !_WINDOWS_NSL */ + phost = gethostbyname(host); /* See netdb.h */ +#endif /* _WINDOWS_NSL */ #ifdef MVS - CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost); + if (TRACE) { + fprintf(stderr, + "HTParseInet: gethostbyname() returned %d\n", phost); + } #endif /* MVS */ - if (!phost) goto failed; + if (!phost) { + if (TRACE) { + fprintf(stderr, + "HTParseInet: Can't find internet node name `%s'.\n", + host); + } + FREE(host); + return -1; /* Fail? */ + } + FREE(host); #if defined(VMS) && defined(CMU_TCP) - /* - ** In LIBCMU, phost->h_length contains not the length of one address - ** (four bytes) but the number of bytes in *h_addr, i.e. some multiple - ** of four. Thus we need to hard code the value here, and remember to - ** change it if/when IP addresses change in size. :-( LIBCMU is no - ** longer supported, and CMU users are encouraged to obtain and use - ** SOCKETSHR/NETLIB instead. - S. Bjorndahl - */ - memcpy((void *)&soc_in->sin_addr, phost->h_addr, 4); + /* + ** In LIBCMU, phost->h_length contains not the length of one address + ** (four bytes) but the number of bytes in *h_addr, i.e. some multiple + ** of four. Thus we need to hard code the value here, and remember to + ** change it if/when IP addresses change in size. :-( LIBCMU is no + ** longer supported, and CMU users are encouraged to obtain and use + ** SOCKETSHR/NETLIB instead. - S. Bjorndahl + */ + memcpy((void *)&soc_in->sin_addr, phost->h_addr, 4); #else - memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); + memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); #endif /* VMS && CMU_TCP */ - } -#endif /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL */ -#endif /* !NSL_FORK, !DJGPP */ -#endif /* !NSL_FORK */ -#ifndef _WINDOWS_NSL - FREE(host); -#endif /* _WINDOWS_NSL */ - +#endif /* DJGPP */ +#endif /* NSL_FORK */ } - CTRACE(tfp, "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n", + if (TRACE) { + fprintf(stderr, + "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n", (int)ntohs(soc_in->sin_port), (int)*((unsigned char *)(&soc_in->sin_addr)+0), (int)*((unsigned char *)(&soc_in->sin_addr)+1), (int)*((unsigned char *)(&soc_in->sin_addr)+2), (int)*((unsigned char *)(&soc_in->sin_addr)+3)); + } #endif /* Internet vs. Decnet */ return 0; /* OK */ - -failed: - CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n", - host); -#ifndef _WINDOWS_NSL - FREE(host); -#endif /* _WINDOWS_NSL */ - return -1; } /* Free our name for the host on which we are - FM @@ -779,15 +723,16 @@ PRIVATE void get_host_details NOARGS #ifndef DECNET /* Decnet ain't got no damn name server 8#OO */ #ifdef NEED_HOST_ADDRESS /* no -- needs name server! */ phost = gethostbyname(name); /* See netdb.h */ - if (!OK_HOST(phost)) { - CTRACE(tfp, "TCP: Can't find my own internet node address for `%s'!!\n", - name); + if (!phost) { + if (TRACE) fprintf(stderr, + "TCP: Can't find my own internet node address for `%s'!!\n", + name); return; /* Fail! */ } StrAllocCopy(hostname, phost->h_name); memcpy(&HTHostAddress, &phost->h_addr, phost->h_length); - CTRACE(tfp, " Name server says that I am `%s' = %s\n", - hostname, HTInetString(&HTHostAddress)); + if (TRACE) fprintf(stderr, " Name server says that I am `%s' = %s\n", + hostname, HTInetString(&HTHostAddress)); #endif /* NEED_HOST_ADDRESS */ #endif /* !DECNET */ @@ -821,7 +766,6 @@ PUBLIC int HTDoConnect ARGS4( /* ** Set up defaults. */ - memset(soc_in, 0, sizeof(*soc_in)); soc_in->sin_family = AF_INET; soc_in->sin_port = htons(default_port); @@ -1046,7 +990,8 @@ PUBLIC int HTDoConnect ARGS4( } } if (HTCheckForInterrupt()) { - CTRACE(tfp, "*** INTERRUPTED in middle of connect.\n"); + if (TRACE) + fprintf(stderr, "*** INTERRUPTED in middle of connect.\n"); status = HT_INTERRUPTED; SOCKET_ERRNO = EINTR; break; diff --git a/WWW/Library/Implementation/HTTCP.h b/WWW/Library/Implementation/HTTCP.h index 05e8278f..c7f16dcc 100644 --- a/WWW/Library/Implementation/HTTCP.h +++ b/WWW/Library/Implementation/HTTCP.h @@ -7,7 +7,10 @@ #ifndef HTTCP_H #define HTTCP_H +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ +#include <tcp.h> #ifdef SHORT_NAMES #define HTInetStatus HTInStat @@ -112,3 +115,6 @@ extern int HTDoRead PARAMS(( unsigned nbyte)); #endif /* HTTCP_H */ +/* + + End. */ diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index 4d128c81..996ebd4b 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -7,8 +7,9 @@ */ #include <HTUtils.h> +#include <tcp.h> + #include <HTTP.h> -#include <LYUtils.h> #define HTTP_VERSION "HTTP/1.0" @@ -24,18 +25,18 @@ #include <HTTCP.h> #include <HTFormat.h> #include <HTFile.h> +#include <ctype.h> #include <HTAlert.h> #include <HTMIME.h> #include <HTML.h> #include <HTInit.h> #include <HTAABrow.h> -#include <LYCookie.h> #include <LYGlobalDefs.h> -#include <GridText.h> -#include <LYStrings.h> #include <LYLeaks.h> +/* #define TRACE 1 */ + struct _HTStream { HTStreamClass * isa; @@ -64,6 +65,18 @@ extern char *http_error_file; /* Store HTTP status code in this file */ extern BOOL traversal; /* TRUE if we are doing a traversal */ extern BOOL dump_output_immediately; /* TRUE if no interactive user */ +extern char * HTLoadedDocumentURL NOPARAMS; +extern int HTCheckForInterrupt NOPARAMS; +extern void LYSetCookie PARAMS(( + CONST char * SetCookie, + CONST char * SetCookie2, + CONST char * address)); +extern char * LYCookie PARAMS(( + CONST char * hostname, + CONST char * path, + int port, + BOOL secure)); + #define HTTP_NETREAD(a, b, c, d) NETREAD(a, b, c) #define HTTP_NETWRITE(a, b, c, d) NETWRITE(a, b, c) #define HTTP_NETCLOSE(a, b) (void)NETCLOSE(a) @@ -152,6 +165,7 @@ try_again: ** so we can start over here... */ eol = 0; + bytes_already_read = 0; had_header = NO; length = 0; doing_redirect = FALSE; @@ -172,13 +186,17 @@ try_again: /* ** Interrupt cleanly. */ - CTRACE (tfp, "HTTP: Interrupted on connect; recovering cleanly.\n"); - _HTProgress ("Connection interrupted."); - status = HT_NOT_LOADED; - goto done; - } - if (status < 0) { - CTRACE(tfp, "HTTP: Unable to connect to remote host for `%s' (errno = %d).\n", + if (TRACE) + fprintf (stderr, + "HTTP: Interrupted on connect; recovering cleanly.\n"); + _HTProgress ("Connection interrupted."); + status = HT_NOT_LOADED; + goto done; + } + if (status < 0) { + if (TRACE) + fprintf(stderr, + "HTTP: Unable to connect to remote host for `%s' (errno = %d).\n", url, SOCKET_ERRNO); HTAlert("Unable to connect to remote host."); status = HT_NOT_LOADED; @@ -295,7 +313,8 @@ try_again: strcpy(line, pref_charset); if (line[strlen(line)-1] == ',') line[strlen(line)-1] = '\0'; - LYLowerCase(line); + for (i = 0; line[i]; i++) + line[i] = TOLOWER(line[i]); if (strstr(line, "iso-8859-1") == NULL) strcat(line, ", iso-8859-1;q=0.01"); if (strstr(line, "us-ascii") == NULL) @@ -422,7 +441,8 @@ try_again: */ sprintf(line, "%s%c%c", auth, CR, LF); StrAllocCat(command, line); - CTRACE(tfp, "HTTP: Sending authorization: %s\n", auth); + if (TRACE) + fprintf(stderr, "HTTP: Sending authorization: %s\n", auth); } else if (auth && *auth == '\0') { /* ** If auth is a zero-length string, the user either @@ -446,7 +466,9 @@ try_again: goto done; } } else { - CTRACE(tfp, "HTTP: Not sending authorization (yet).\n"); + if (TRACE) + fprintf(stderr, + "HTTP: Not sending authorization (yet).\n"); } /* ** Add 'Cookie:' header, if it's HTTP or HTTPS @@ -479,7 +501,9 @@ try_again: */ StrAllocCat(command, "Cookie2: $Version=\"1\""); StrAllocCat(command, crlf); - CTRACE(tfp, "HTTP: Sending Cookie2: $Version =\"1\"\n"); + if (TRACE) + fprintf(stderr, + "HTTP: Sending Cookie2: $Version =\"1\"\n"); } if (*cookie != '\0') { /* @@ -490,7 +514,8 @@ try_again: StrAllocCat(command, "Cookie: "); StrAllocCat(command, cookie); StrAllocCat(command, crlf); - CTRACE(tfp, "HTTP: Sending Cookie: %s\n", cookie); + if (TRACE) + fprintf(stderr, "HTTP: Sending Cookie: %s\n", cookie); } FREE(cookie); } @@ -515,7 +540,9 @@ try_again: */ sprintf(line, "%s%c%c", auth, CR, LF); StrAllocCat(command, line); - CTRACE(tfp, (auth_proxy ? + if (TRACE) + fprintf(stderr, + (auth_proxy ? "HTTP: Sending proxy authorization: %s\n" : "HTTP: Sending authorization: %s\n"), auth); @@ -542,7 +569,9 @@ try_again: goto done; } } else { - CTRACE(tfp, (auth_proxy ? + if (TRACE) + fprintf(stderr, + (auth_proxy ? "HTTP: Not sending proxy authorization (yet).\n" : "HTTP: Not sending authorization (yet).\n")); } @@ -552,10 +581,12 @@ try_again: auth_proxy = NO; } - if (do_post) { - CTRACE (tfp, "HTTP: Doing post, content-type '%s'\n", - anAnchor->post_content_type ? anAnchor->post_content_type - : "lose"); + if (do_post) + { + if (TRACE) + fprintf (stderr, "HTTP: Doing post, content-type '%s'\n", + anAnchor->post_content_type ? anAnchor->post_content_type + : "lose"); sprintf (line, "Content-type: %s%c%c", anAnchor->post_content_type ? anAnchor->post_content_type : "lose", CR, LF); @@ -578,9 +609,12 @@ try_again: else StrAllocCat(command, crlf); /* Blank line means "end" of headers */ - CTRACE (tfp, "Writing:\n%s%s----------------------------------\n", + if (TRACE) { + fprintf (stderr, + "Writing:\n%s%s----------------------------------\n", command, (anAnchor->post_data ? crlf : "")); + } _HTProgress ("Sending HTTP request."); @@ -588,7 +622,8 @@ try_again: FREE(command); if (status <= 0) { if (status == 0) { - CTRACE (tfp, "HTTP: Got status 0 in initial write\n"); + if (TRACE) + fprintf (stderr, "HTTP: Got status 0 in initial write\n"); /* Do nothing. */ } else if ((SOCKET_ERRNO == ENOTCONN || SOCKET_ERRNO == ECONNRESET || @@ -598,14 +633,18 @@ try_again: /* ** Arrrrgh, HTTP 0/1 compability problem, maybe. */ - CTRACE (tfp, "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n"); + if (TRACE) + fprintf (stderr, + "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n"); _HTProgress ("Retrying as HTTP0 request."); HTTP_NETCLOSE(s, handle); extensions = NO; already_retrying = TRUE; goto try_again; } else { - CTRACE (tfp, "HTTP: Hit unexpected network WRITE error; aborting connection.\n"); + if (TRACE) + fprintf (stderr, + "HTTP: Hit unexpected network WRITE error; aborting connection.\n"); HTTP_NETCLOSE(s, handle); status = -1; HTAlert("Unexpected network write error; connection aborted."); @@ -613,7 +652,8 @@ try_again: } } - CTRACE (tfp, "HTTP: WRITE delivered OK\n"); + if (TRACE) + fprintf (stderr, "HTTP: WRITE delivered OK\n"); _HTProgress ("HTTP request sent; waiting for response."); /* Read the first line of the response @@ -626,7 +666,6 @@ try_again: line_buffer = (char *)calloc(1, (buffer_length * sizeof(char))); - HTReadProgress (bytes_already_read = 0, 0); do {/* Loop to read in the first line */ /* ** Extend line buffer if necessary for those crazy WAIS URLs ;-) @@ -636,18 +675,21 @@ try_again: line_buffer = (char *)realloc(line_buffer, (buffer_length * sizeof(char))); } - CTRACE (tfp, "HTTP: Trying to read %d\n", + if (TRACE) + fprintf (stderr, "HTTP: Trying to read %d\n", buffer_length - length - 1); status = HTTP_NETREAD(s, line_buffer + length, buffer_length - length - 1, handle); - CTRACE (tfp, "HTTP: Read %d\n", status); + if (TRACE) + fprintf (stderr, "HTTP: Read %d\n", status); if (status <= 0) { /* * Retry if we get nothing back too. * Bomb out if we get nothing twice. */ if (status == HT_INTERRUPTED) { - CTRACE (tfp, "HTTP: Interrupted initial read.\n"); + if (TRACE) + fprintf (stderr, "HTTP: Interrupted initial read.\n"); _HTProgress ("Connection interrupted."); HTTP_NETCLOSE(s, handle); status = HT_NO_DATA; @@ -660,7 +702,9 @@ try_again: /* ** Arrrrgh, HTTP 0/1 compability problem, maybe. */ - CTRACE (tfp, "HTTP: BONZO Trying again with HTTP0 request.\n"); + if (TRACE) + fprintf (stderr, + "HTTP: BONZO Trying again with HTTP0 request.\n"); HTTP_NETCLOSE(s, handle); FREE(line_buffer); FREE(line_kept_clean); @@ -670,7 +714,9 @@ try_again: _HTProgress ("Retrying as HTTP0 request."); goto try_again; } else { - CTRACE (tfp, "HTTP: Hit unexpected network read error; aborting connection; status %d.\n", + if (TRACE) + fprintf (stderr, + "HTTP: Hit unexpected network read error; aborting connection; status %d.\n", status); HTAlert("Unexpected network read error; connection aborted."); HTTP_NETCLOSE(s, handle); @@ -680,7 +726,8 @@ try_again: } bytes_already_read += status; - HTReadProgress (bytes_already_read, 0); + sprintf (line, "Read %d bytes of data.", bytes_already_read); + HTProgress (line); #ifdef UCX /* UCX returns -1 on EOF */ if (status == 0 || status == -1) @@ -724,7 +771,8 @@ try_again: /* We now have a terminated unfolded line. Parse it. ** ------------------------------------------------- */ - CTRACE(tfp, "HTTP: Rx: %s\n", line_buffer); + if (TRACE) + fprintf(stderr, "HTTP: Rx: %s\n", line_buffer); /* ** Kludge to work with old buggy servers and the VMS Help gateway. @@ -740,7 +788,8 @@ try_again: FREE(line_kept_clean); extensions = NO; already_retrying = TRUE; - CTRACE(tfp, "HTTP: close socket %d to retry with HTTP0\n", s); + if (TRACE) + fprintf(stderr, "HTTP: close socket %d to retry with HTTP0\n", s); HTTP_NETCLOSE(s, handle); /* print a progress message */ _HTProgress ("Retrying as HTTP0 request."); @@ -759,7 +808,8 @@ try_again: server_version, &server_status); - CTRACE (tfp, "HTTP: Scanned %d fields from line_buffer\n", fields); + if (TRACE) + fprintf (stderr, "HTTP: Scanned %d fields from line_buffer\n", fields); if (http_error_file) { /* Make the status code externally available */ FILE *error_file; @@ -791,7 +841,8 @@ try_again: */ HTAtom * encoding; - CTRACE (tfp, "--- Talking HTTP0.\n"); + if (TRACE) + fprintf (stderr, "--- Talking HTTP0.\n"); format_in = HTFileFormat(url, &encoding, NULL); /* @@ -800,19 +851,27 @@ try_again: ** without looking at content. */ if (!strncmp(HTAtom_name(format_in), "text/plain",10)) { - CTRACE(tfp, "HTTP: format_in being changed to text/HTML\n"); + if (TRACE) + fprintf(stderr, + "HTTP: format_in being changed to text/HTML\n"); format_in = WWW_HTML; } if (!IsUnityEnc(encoding)) { /* ** Change the format to that for "www/compressed". */ - CTRACE(tfp, "HTTP: format_in is '%s',\n", HTAtom_name(format_in)); + if (TRACE) { + fprintf(stderr, + "HTTP: format_in is '%s',\n", HTAtom_name(format_in)); + } StrAllocCopy(anAnchor->content_type, HTAtom_name(format_in)); StrAllocCopy(anAnchor->content_encoding, HTAtom_name(encoding)); format_in = HTAtom_for("www/compressed"); - CTRACE(tfp, " Treating as '%s' with encoding '%s'\n", + if (TRACE) { + fprintf(stderr, + " Treating as '%s' with encoding '%s'\n", "www/compressed", HTAtom_name(encoding)); + } } start_of_data = line_kept_clean; @@ -821,7 +880,8 @@ try_again: ** Set up to decode full HTTP/1.n response. - FM */ format_in = HTAtom_for("www/mime"); - CTRACE (tfp, "--- Talking HTTP1.\n"); + if (TRACE) + fprintf (stderr, "--- Talking HTTP1.\n"); /* ** We set start_of_data to "" when !eol here because there @@ -881,6 +941,7 @@ try_again: HTTP_NETCLOSE(s, handle); status = HT_NO_DATA; goto clean_up; + break; case 205: /* @@ -894,6 +955,7 @@ try_again: HTTP_NETCLOSE(s, handle); status = HT_NO_DATA; goto clean_up; + break; case 206: /* @@ -906,6 +968,7 @@ try_again: HTTP_NETCLOSE(s, handle); status = HT_NO_DATA; goto clean_up; + break; default: /* @@ -1070,7 +1133,8 @@ try_again: /* * Impatient user. - FM */ - CTRACE (tfp, "HTTP: Interrupted followup read.\n"); + if (TRACE) + fprintf (stderr, "HTTP: Interrupted followup read.\n"); _HTProgress ("Connection interrupted."); status = HT_INTERRUPTED; goto clean_up; @@ -1083,7 +1147,9 @@ try_again: * Don't make the redirection permanent * if we have POST content. - FM */ - CTRACE(tfp, "HTTP: Have POST content. Treating 301 (Permanent) as Temporary.\n"); + if (TRACE) + fprintf(stderr, + "HTTP: Have POST content. Treating 301 (Permanent) as Temporary.\n"); HTAlert( "Have POST content. Treating Permanent Redirection as Temporary.\n"); } else { @@ -1301,7 +1367,9 @@ Cookie2_continuation: * thus is probably something in the body, so * we'll show the user what was returned. - FM */ - CTRACE(tfp, "HTTP: 'Location:' is zero-length!\n"); + if (TRACE) + fprintf(stderr, + "HTTP: 'Location:' is zero-length!\n"); if (cp1) *cp1 = LF; if (cp2) @@ -1320,7 +1388,9 @@ Cookie2_continuation: * seek the document at that Location. - FM */ HTProgress(line_buffer); - CTRACE(tfp, "HTTP: Picked up location '%s'\n", + if (TRACE) + fprintf(stderr, + "HTTP: Picked up location '%s'\n", redirecting_url); if (cp1) *cp1 = LF; @@ -1338,7 +1408,9 @@ Cookie2_continuation: * Append our URL. - FM */ StrAllocCat(redirecting_url, anAnchor->address); - CTRACE(tfp, "HTTP: Proxy URL is '%s'\n", + if (TRACE) + fprintf(stderr, + "HTTP: Proxy URL is '%s'\n", redirecting_url); } if (!do_post || @@ -1402,7 +1474,8 @@ Cookie2_continuation: * header, so we'll show the user what we got, if * anything. - FM */ - CTRACE (tfp, "HTTP: Failed to pick up location.\n"); + if (TRACE) + fprintf (stderr, "HTTP: Failed to pick up location.\n"); doing_redirect = FALSE; permanent_redirection = FALSE; start_of_data = line_kept_clean; @@ -1446,7 +1519,8 @@ Cookie2_continuation: */ if (show_401) break; - if (HTAA_shouldRetryWithAuth(start_of_data, length, s, NO)) { + if (HTAA_shouldRetryWithAuth(start_of_data, length, + (void *)handle, s, NO)) { HTTP_NETCLOSE(s, handle); if (dump_output_immediately && !authentication_info[0]) { @@ -1458,15 +1532,17 @@ Cookie2_continuation: goto clean_up; } - CTRACE(tfp, "%s %d %s\n", - "HTTP: close socket", s, - "to retry with Access Authorization"); + if (TRACE) + fprintf(stderr, "%s %d %s\n", + "HTTP: close socket", s, + "to retry with Access Authorization"); _HTProgress ( "Retrying with access authorization information."); FREE(line_buffer); FREE(line_kept_clean); goto try_again; + break; } else if (!(traversal || dump_output_immediately) && HTConfirm("Show the 401 message body?")) { break; @@ -1478,6 +1554,7 @@ Cookie2_continuation: status = -1; goto clean_up; } + break; case 407: /* @@ -1493,7 +1570,8 @@ Cookie2_continuation: */ if (!using_proxy || show_407) break; - if (HTAA_shouldRetryWithAuth(start_of_data, length, s, YES)) { + if (HTAA_shouldRetryWithAuth(start_of_data, length, + (void *)handle, s, YES)) { HTTP_NETCLOSE(s, handle); if (dump_output_immediately && !proxyauth_info[0]) { @@ -1505,15 +1583,17 @@ Cookie2_continuation: goto clean_up; } - CTRACE(tfp, "%s %d %s\n", - "HTTP: close socket", s, - "to retry with Proxy Authorization"); + if (TRACE) + fprintf(stderr, "%s %d %s\n", + "HTTP: close socket", s, + "to retry with Proxy Authorization"); _HTProgress ( "Retrying with proxy authorization information."); FREE(line_buffer); FREE(line_kept_clean); goto try_again; + break; } else if (!(traversal || dump_output_immediately) && HTConfirm("Show the 407 message body?")) { if (!dump_output_immediately && @@ -1534,6 +1614,7 @@ Cookie2_continuation: status = -1; goto clean_up; } + break; case 408: /* @@ -1544,6 +1625,7 @@ Cookie2_continuation: HTTP_NETCLOSE(s, handle); status = HT_NO_DATA; goto done; + break; default: /* @@ -1697,7 +1779,8 @@ Cookie2_continuation: (*target->isa->_abort)(target, NULL); HTTP_NETCLOSE(s, handle); if (!already_retrying && !do_post) { - CTRACE (tfp, "HTTP: Trying again with HTTP0 request.\n"); + if (TRACE) + fprintf (stderr, "HTTP: Trying again with HTTP0 request.\n"); /* ** May as well consider it an interrupt -- right? */ diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c index 5de48da1..3a03eb33 100644 --- a/WWW/Library/Implementation/HTTelnet.c +++ b/WWW/Library/Implementation/HTTelnet.c @@ -14,7 +14,7 @@ */ #include <HTUtils.h> -#include <LYUtils.h> +#include <tcp.h> /* Implements: */ @@ -24,6 +24,8 @@ #include <HTAnchor.h> #include <HTTP.h> #include <HTFile.h> +/*#include <errno.h> included by tcp.h -- FM */ +/*#include <stdio.h> included by HTUtils.h -- FM */ #include <HText.h> @@ -32,9 +34,10 @@ #include <userdefs.h> /* for TELNET_COMMAND and RLOGIN_COMMAND */ -#include <LYStrings.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + #define HT_NO_DATA -9999 @@ -52,6 +55,10 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) enum _login_protocol { telnet, rlogin, tn3270 } login_protocol = strcmp(acc_method, "rlogin") == 0 ? rlogin : strcmp(acc_method, "tn3270") == 0 ? tn3270 : telnet; +#ifdef VMS + extern int DCLsystem PARAMS((char *command)); +#define system(a) DCLsystem(a) /* use LYCurses.c routines for spawns */ +#endif /* VMS */ /* * Modified to allow for odd chars in a username only if exists. @@ -84,7 +91,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) *port++ = '\0'; /* Split */ if (!hostname || *hostname == '\0') { - CTRACE(tfp, "HTTelnet: No host specified!\n"); + if (TRACE) + fprintf(stderr, "HTTelnet: No host specified!\n"); return HT_NO_DATA; } @@ -141,7 +149,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) hostname, port ? port : ""); - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE @@ -167,7 +176,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) port ? port : ""); } - CTRACE(tfp, "HTTelnet: Normal: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Normal: Command is: %s\n\n", command); #ifdef __DJGPP__ __djgpp_set_ctrl_c(0); _go32_want_ctrl_break(1); @@ -206,7 +216,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) hostname); } - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE @@ -261,7 +272,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) } } - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } @@ -288,7 +300,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) port ? port : ""); } - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ #define TELNET_DONE @@ -300,10 +313,12 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) port ? "/PORT=" : "", port ? port : "", hostname); - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); } else { + extern int LYgetch NOPARAMS; extern BOOLEAN HadVMSInterrupt; printf( @@ -343,7 +358,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) hostname); } - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } @@ -384,7 +400,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) } } - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } @@ -407,7 +424,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) port ? port : ""); } - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } @@ -417,10 +435,12 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) port ? "/PORT=" : "", port ? port : "", hostname); - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); } else { + extern int LYgetch NOPARAMS; extern BOOLEAN HadVMSInterrupt; printf( @@ -438,10 +458,12 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) port ? "/PORT=" : "", port ? port : "", hostname); - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); } else { + extern int LYgetch NOPARAMS; extern BOOLEAN HadVMSInterrupt; printf( @@ -464,7 +486,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) if (login_protocol == telnet) { /* telnet only */ sprintf(command, "TELNET %s", /* @@ Bug: port ignored */ hostname); - CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command); + if (TRACE) + fprintf(stderr, "HTTelnet: Command is: %s\n\n", command); system(command); return HT_NO_DATA; /* Ok - it was done but no data */ } @@ -482,6 +505,8 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) printf("\nlogging in with username %s", user); printf(".\n"); { + extern int LYgetch NOPARAMS; + printf("\nPress <return> to return to Lynx."); fflush(stdout); LYgetch(); @@ -524,7 +549,9 @@ ARGS4 int status; if (sink) { - CTRACE(tfp, "HTTelnet: Can't output a live session -- must be interactive!\n"); + if (TRACE) + fprintf(stderr, + "HTTelnet: Can't output a live session -- must be interactive!\n"); return HT_NO_DATA; } acc_method = HTParse(addr, "file:", PARSE_ACCESS); @@ -532,7 +559,8 @@ ARGS4 host = HTParse(addr, "", PARSE_HOST); if (!host || *host == '\0') { status = HT_NO_DATA; - CTRACE(tfp, "HTTelnet: No host specified!\n"); + if (TRACE) + fprintf(stderr, "HTTelnet: No host specified!\n"); } else { status = remote_session(acc_method, host); } diff --git a/WWW/Library/Implementation/HTUU.h b/WWW/Library/Implementation/HTUU.h index 3594b276..9c72a115 100644 --- a/WWW/Library/Implementation/HTUU.h +++ b/WWW/Library/Implementation/HTUU.h @@ -11,7 +11,9 @@ #ifndef HTUU_H #define HTUU_H +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ PUBLIC int HTUU_encode PARAMS((unsigned char *bufin, unsigned int nbytes, @@ -22,3 +24,6 @@ PUBLIC int HTUU_decode PARAMS((char *bufcoded, int outbufsize)); #endif +/* + + End of file. */ diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h index 16fc0eb2..d96a6cb7 100644 --- a/WWW/Library/Implementation/HTUtils.h +++ b/WWW/Library/Implementation/HTUtils.h @@ -1,7 +1,9 @@ -/* Utility macros for the W3 code library +/* Utitlity macros for the W3 code library MACROS FOR GENERAL USE - See also: the system dependent file "tcp.h", which is included here. + Generates: HTUtils.h + + See also: the system dependent file "tcp.h" */ @@ -15,12 +17,8 @@ #ifdef HAVE_CONFIG_H #include <lynx_cfg.h> /* generated by autoconf 'configure' script */ #include <sys/types.h> -#include <stdio.h> - #else -#include <stdio.h> - #define DONT_TRACK_INTERNAL_LINKS 1 /* Explicit system-configure */ @@ -29,7 +27,6 @@ #define NO_UNISTD_H #define NO_KEYPAD #define NO_UTMP -#define NO_FILIO_H #endif /* FIXME: these will be removed after completing auto-configure script */ @@ -77,10 +74,6 @@ #define HAVE_UTMP 1 #endif -#endif /* HAVE_CONFIG_H */ - -#ifndef LY_MAXPATH -#define LY_MAXPATH 256 #endif #ifndef GCC_UNUSED @@ -95,15 +88,6 @@ #define popen _popen #define pclose _pclose #endif /* _WINDOWS */ - -#ifdef __EMX__ -#include <unistd.h> /* should be re-include protected under EMX */ -#include <stdlib.h> /* should be re-include protected under EMX */ -#define getcwd _getcwd2 -#define chdir _chdir2 - -#endif - #ifdef SHORT_NAMES #define WWW_TraceFlag HTTrFlag @@ -114,6 +98,10 @@ Debug message control. */ +#ifndef STDIO_H +#include <stdio.h> +#define STDIO_H +#endif #ifdef DEBUG #define TRACE (WWW_TraceFlag) @@ -124,6 +112,9 @@ Debug message control. #define PROGRESS(str) /* nothing for now */ #endif +#define CTRACE if(TRACE)fprintf +#define tfp stderr + /* ERROR TYPE @@ -166,6 +157,7 @@ Standard C library for malloc() etc #include <malloc.h> #include <memory.h> +#include <stdio.h> #include <stdlib.h> /* ANSI */ /* BSN */ #endif /* !ultrix */ @@ -173,6 +165,7 @@ Standard C library for malloc() etc #include <stdlib.h> #include <unixlib.h> +#include <ctype.h> #if defined(VAXC) && !defined(__DECC) #define malloc VAXC$MALLOC_OPT #define calloc VAXC$CALLOC_OPT @@ -311,7 +304,6 @@ Sucess (>=0) and failure (<0) codes #define HT_ERROR -1 /* Generic failure */ -#define HT_CANNOT_TRANSLATE -4 #define HT_NO_ACCESS -10 /* Access not available */ #define HT_FORBIDDEN -11 /* Access forbidden */ #define HT_INTERNAL -12 /* Weird -- should never happen. */ @@ -321,12 +313,10 @@ Sucess (>=0) and failure (<0) codes #include <HTString.h> /* String utilities */ #ifndef va_arg -#if defined(__STDC__) || defined(VMS) +#ifdef __STDC__ #include <stdarg.h> -#define LYva_start(ap,format) va_start(ap,format) #else #include <varargs.h> -#define LYva_start(ap,format) va_start(ap) #endif #endif @@ -342,7 +332,11 @@ Out Of Memory checking for malloc() return: #include <LYexit.h> -extern void outofmem PARAMS((CONST char *fname, CONST char *func)); +#define outofmem(file, func)\ + { fprintf(stderr,\ + "\r\n\r\n\r\n%s %s: out of memory. Aborting...\r\n", file, func);\ + LYOutOfMemory = TRUE; exit(-1);} +/* extern void outofmem PARAMS((const char *fname, const char *func)); */ /* @@ -362,8 +356,6 @@ Upper- and Lowercase macros #define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : ((unsigned char)c)) #endif /* TOLOWER */ -#define FREE(x) if (x) {free(x); x = NULL;} - /* The local equivalents of CR and LF @@ -376,40 +368,8 @@ The local equivalents of CR and LF #define LF FROMASCII('\012') /* ASCII line feed LOCAL EQUIVALENT */ #define CR FROMASCII('\015') /* Will be converted to ^M for transmission */ -#define CTRACE if(TRACE)fprintf -#define tfp TraceFP() -#define CTRACE_SLEEP(secs) if (TRACE && LYTraceLogFP == 0) sleep(secs) -#define CTRACE_FLUSH(fp) if(TRACE) fflush(fp) - -extern FILE *TraceFP NOPARAMS; - -#include <tcp.h> - -/* - * We force this include-ordering since socks.h contains redefinitions of - * functions that probably are prototyped via other includes. The socks.h - * definitions have to be included everywhere, since they're making wrappers - * for the stdio functions as well as the network functions. - */ -#if defined(USE_SOCKS5) && !defined(DONT_USE_SOCKS5) -#define SOCKS4TO5 /* turn on the Rxxxx definitions used in Lynx */ -#include <socks.h> +#endif /* HTUTILS_H */ /* - * The AIX- and SOCKS4-specific definitions in socks.h are inconsistent. - * Repair them so they're consistent (and usable). - */ -#if defined(_AIX) && !defined(USE_SOCKS4_PREFIX) -#undef Raccept -#define Raccept accept -#undef Rgetsockname -#define Rgetsockname getsockname -#undef Rgetpeername -#define Rgetpeername getpeername -#endif -#endif /* USE_SOCKS5 */ - -#define SHORTENED_RBIND /* FIXME: do this in configure-script */ - -#endif /* HTUTILS_H */ + end of utilities */ diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c index 7f49ff67..ca800517 100644 --- a/WWW/Library/Implementation/HTVMSUtils.c +++ b/WWW/Library/Implementation/HTVMSUtils.c @@ -14,12 +14,15 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTFormat.h> #include <HTStream.h> #include <UCDefs.h> #include <UCMap.h> #include <UCAux.h> #include <HTVMSUtils.h> +/*#include <stdio.h> included by HTUtils.h -- FM */ +/*#include <unixlib.h> included by HTUtils.h -- FM */ #include <ssdef.h> #include <jpidef.h> #include <prvdef.h> @@ -30,7 +33,6 @@ #include <starlet.h> #include <rmsdef.h> -#include <LYUtils.h> #include <LYLeaks.h> #define FREE(x) if (x) {free(x); x = NULL;} @@ -104,10 +106,12 @@ unsigned long Prv[2], PreviousPrv[2]; Prv[1] = 0; Result = sys$setprv(1,&Prv,0,&PreviousPrv); - if (Result == SS$_NORMAL) { - if (!(PreviousPrv[0] & PRV$M_SYSPRV)) { - CTRACE(tfp, "HTVMS_enableSysPrv: Enabled SYSPRV\n"); - } + if (TRACE) { + if (Result == SS$_NORMAL) { + if (!(PreviousPrv[0] & PRV$M_SYSPRV)) { + fprintf(stderr, "HTVMS_enableSysPrv: Enabled SYSPRV\n"); + } + } } } @@ -130,10 +134,12 @@ unsigned long Prv[2], PreviousPrv[2]; Prv[1] = 0; Result = sys$setprv(0,&Prv,0,&PreviousPrv); - if (Result == SS$_NORMAL) { - if (PreviousPrv[0] & PRV$M_SYSPRV) { - CTRACE(tfp, "HTVMS_disableSysPrv: Disabled SYSPRV\n"); - } + if (TRACE) { + if (Result == SS$_NORMAL) { + if (PreviousPrv[0] & PRV$M_SYSPRV) { + fprintf(stderr, "HTVMS_disableSysPrv: Disabled SYSPRV\n"); + } + } } } @@ -377,7 +383,7 @@ PUBLIC char * HTVMS_name ARGS2( */ PUBLIC int HTStat ARGS2( CONST char *, filename, - struct stat *, info) + stat_t *, info) { /* the following stuff does not work in VMS with a normal stat... @@ -473,6 +479,9 @@ char Name[256]; return(Result); } +/*** "dirent.h" ***/ +/* #include <types.h> already in tcp.h */ + #ifndef _POSIX_SOURCE #define d_ino d_fileno /* compatability */ #ifndef NULL @@ -725,7 +734,7 @@ typedef struct _VMSEntryInfo { BOOLEAN display; /* show this entry? */ } VMSEntryInfo; -PRIVATE void free_VMSEntryInfo_contents ARGS1(VMSEntryInfo *,entry_info) +PRIVATE void free_VMSEntryInfo_struct_contents ARGS1(VMSEntryInfo *,entry_info) { if (entry_info) { FREE(entry_info->filename); @@ -891,7 +900,7 @@ PUBLIC int HTVMSBrowseDir ARGS4( extern BOOLEAN no_dotfiles, show_dotfiles; HTUnEscape(pathname); - CTRACE(tfp,"HTVMSBrowseDir: Browsing `%s\'\n", pathname); + CTRACE(stderr,"HTVMSBrowseDir: Browsing `%s\'\n", pathname); /* * Require at least two elements (presumably a device and directory) @@ -1104,13 +1113,17 @@ PUBLIC int HTVMSBrowseDir ARGS4( StrAllocCopy(entry_info->type, cp); StrAllocCopy(entry_info->filename, dirbuf->d_name); - if (S_ISDIR(file_info.st_mode)) { + if ((file_info.st_mode & S_IFMT) == S_IFDIR) { /* strip .DIR part... */ char *dot; dot = strstr(entry_info->filename, ".DIR"); if (dot) *dot = '\0'; - LYLowerCase(entry_info->filename); + cp = entry_info->filename; + while (cp && *cp) { + *cp = TOLOWER(*cp); + cp++; + } StrAllocCopy(entry_info->type, "Directory"); } else { if ((cp = strstr(entry_info->filename, "READ")) == NULL) { @@ -1129,7 +1142,10 @@ PUBLIC int HTVMSBrowseDir ARGS4( cp = entry_info->filename; } } - LYLowerCase(cp); + while (cp && *cp) { + *cp = TOLOWER(*cp); + cp++; + } if (((len = strlen(entry_info->filename)) > 2) && entry_info->filename[len-1] == 'z') { if (entry_info->filename[len-2] == '.' || @@ -1154,7 +1170,7 @@ PUBLIC int HTVMSBrowseDir ARGS4( } /* Get the size */ - if (!S_ISDIR(file_info.st_mode)) + if ((file_info.st_mode & S_IFMT) != S_IFDIR) entry_info->size = (unsigned int)file_info.st_size; else entry_info->size = 0; @@ -1162,7 +1178,7 @@ PUBLIC int HTVMSBrowseDir ARGS4( /* Now, update the BTree etc. */ if(entry_info->display) { - CTRACE(tfp,"Adding file to BTree: %s\n", + CTRACE(stderr,"Adding file to BTree: %s\n", entry_info->filename); HTBTree_add(bt, (VMSEntryInfo *)entry_info); } @@ -1223,7 +1239,7 @@ PUBLIC int HTVMSBrowseDir ARGS4( PUTC('\n'); /* end of this entry */ - free_VMSEntryInfo_contents(entry_info); + free_VMSEntryInfo_struct_contents(entry_info); } } @@ -1246,33 +1262,3 @@ PUBLIC int HTVMSBrowseDir ARGS4( return HT_LOADED; } /* End of directory reading section */ - -/* - * Remove all versions of the given file. We assume there are no permissions - * problems, since we do this mainly for removing temporary files. - */ -int HTVMS_remove(char *filename) -{ - int code = remove(filename); /* return the first status code */ - while (remove(filename) == 0) - ; - return code; -} - -/* - * Remove all older versions of the given file. We may fail to remove some - * version due to permissions -- the loop stops either at that point, or when - * we run out of older versions to remove. - */ -void HTVMS_purge(char *filename) -{ - char *older_file = 0; - - StrAllocCopy(older_file, filename); - StrAllocCat(older_file, ";-1"); - - while (remove(older_file) == 0) - ; - - FREE(older_file); -} diff --git a/WWW/Library/Implementation/HTVMSUtils.h b/WWW/Library/Implementation/HTVMSUtils.h index 25fd5adb..e055d672 100644 --- a/WWW/Library/Implementation/HTVMSUtils.h +++ b/WWW/Library/Implementation/HTVMSUtils.h @@ -5,8 +5,7 @@ #ifndef HTVMSUTIL_H #define HTVMSUTIL_H -#include <HTUtils.h> -#include <HTAnchor.h> +#include <stat.h> extern BOOL HTVMSFileVersions; /* Include version numbers in listing? */ @@ -103,7 +102,7 @@ PUBLIC char * HTVMS_name PARAMS(( PUBLIC int HTStat PARAMS(( CONST char * filename, - struct stat * info)); + stat_t * info)); PUBLIC int HTVMSBrowseDir PARAMS(( CONST char * address, @@ -111,7 +110,7 @@ PUBLIC int HTVMSBrowseDir PARAMS(( HTFormat format_out, HTStream * sink)); -extern int HTVMS_remove(char *filename); -extern void HTVMS_purge(char *filename); - #endif /* not HTVMSUTIL_H */ +/* + + End of file HTVMSUtil.h. */ diff --git a/WWW/Library/Implementation/HTVMS_WaisProt.c b/WWW/Library/Implementation/HTVMS_WaisProt.c index 76081407..543de7ad 100644 --- a/WWW/Library/Implementation/HTVMS_WaisProt.c +++ b/WWW/Library/Implementation/HTVMS_WaisProt.c @@ -32,6 +32,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTVMS_WaisUI.h> #include <HTVMS_WaisProt.h> @@ -57,7 +58,7 @@ /*----------------------------------------------------------------------*/ -static unsigned long userInfoTagSize PARAMS((data_tag tag, +static unsigned long userInfoTagSize _AP((data_tag tag, unsigned long length)); static unsigned long @@ -79,7 +80,7 @@ unsigned long length; /*----------------------------------------------------------------------*/ -static char* writeUserInfoHeader PARAMS((data_tag tag,long infoSize, +static char* writeUserInfoHeader _AP((data_tag tag,long infoSize, long estHeaderSize,char* buffer, long* len)); @@ -126,7 +127,7 @@ long* len; /*----------------------------------------------------------------------*/ -static char* readUserInfoHeader PARAMS((data_tag* tag,unsigned long* num, +static char* readUserInfoHeader _AP((data_tag* tag,unsigned long* num, char* buffer)); static char* @@ -227,8 +228,8 @@ char* buffer; char* buf = buffer; unsigned long size; unsigned long headerSize; + data_tag tag; long chunkCode,chunkIDLen; - data_tag tag1; char* chunkMarker = NULL; char* highlightMarker = NULL; char* deHighlightMarker = NULL; @@ -236,7 +237,7 @@ char* buffer; chunkCode = chunkIDLen = UNUSED; - buf = readUserInfoHeader(&tag1,&size,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; while (buf < (buffer + size + headerSize)) @@ -435,7 +436,7 @@ DocObj* doc; /*----------------------------------------------------------------------*/ -static char* writeDocObj PARAMS((DocObj* doc,char* buffer,long* len)); +static char* writeDocObj _AP((DocObj* doc,char* buffer,long* len)); static char* writeDocObj(doc,buffer,len) @@ -482,7 +483,7 @@ long* len; /*----------------------------------------------------------------------*/ -static char* readDocObj PARAMS((DocObj** doc,char* buffer)); +static char* readDocObj _AP((DocObj** doc,char* buffer)); static char* readDocObj(doc,buffer) @@ -609,7 +610,7 @@ char* buffer; { char* buf = buffer; unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; char* seedWords = NULL; char* beginDateRange = NULL; char* endDateRange = NULL; @@ -623,7 +624,7 @@ char* buffer; dateFactor = maxDocsRetrieved = UNUSED; - buf = readUserInfoHeader(&tag1,&size,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; while (buf < (buffer + size + headerSize)) @@ -768,7 +769,7 @@ long* len; unsigned long header_len = userInfoTagSize(DT_DocumentHeaderGroup , DefWAISDocHeaderSize); char* buf = buffer + header_len; - unsigned long size1; + unsigned long size; RESERVE_SPACE_FOR_WAIS_HEADER(len); @@ -799,8 +800,8 @@ long* len; buf = writeString(header->OriginCity,DT_OriginCity,buf,len); /* now write the header and size */ - size1 = buf - buffer; - buf = writeUserInfoHeader(DT_DocumentHeaderGroup,size1,header_len,buffer,len); + size = buf - buffer; + buf = writeUserInfoHeader(DT_DocumentHeaderGroup,size,header_len,buffer,len); return(buf); } @@ -813,9 +814,9 @@ WAISDocumentHeader** header; char* buffer; { char* buf = buffer; - unsigned long size1; + unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; any* docID = NULL; long versionNumber,score,bestMatch,docLength,lines; char** types = NULL; @@ -826,10 +827,10 @@ char* buffer; versionNumber = score = bestMatch = docLength = lines = UNUSED; - buf = readUserInfoHeader(&tag1,&size1,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; - while (buf < (buffer + size1 + headerSize)) + while (buf < (buffer + size + headerSize)) { data_tag tag = peekTag(buf); switch (tag) { case DT_DocumentID: @@ -976,13 +977,13 @@ char* buffer; char* buf = buffer; unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; any* docID = NULL; long versionNumber,score,bestMatch,docLength,lines; versionNumber = score = bestMatch = docLength = lines = UNUSED; - buf = readUserInfoHeader(&tag1,&size,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; while (buf < (buffer + size + headerSize)) @@ -1104,7 +1105,7 @@ long* len; unsigned long header_len = userInfoTagSize(DT_DocumentLongHeaderGroup , DefWAISLongHeaderSize); char* buf = buffer + header_len; - unsigned long size1; + unsigned long size; RESERVE_SPACE_FOR_WAIS_HEADER(len); @@ -1138,8 +1139,8 @@ long* len; buf = writeString(header->IndustryCodes,DT_IndustryCodes,buf,len); /* now write the header and size */ - size1 = buf - buffer; - buf = writeUserInfoHeader(DT_DocumentLongHeaderGroup,size1,header_len,buffer,len); + size = buf - buffer; + buf = writeUserInfoHeader(DT_DocumentLongHeaderGroup,size,header_len,buffer,len); return(buf); } @@ -1152,9 +1153,9 @@ WAISDocumentLongHeader** header; char* buffer; { char* buf = buffer; - unsigned long size1; + unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; any* docID; long versionNumber,score,bestMatch,docLength,lines; char **types; @@ -1165,10 +1166,10 @@ char* buffer; types = NULL; source = date = headline = originCity = stockCodes = companyCodes = industryCodes = NULL; - buf = readUserInfoHeader(&tag1,&size1,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; - while (buf < (buffer + size1 + headerSize)) + while (buf < (buffer + size + headerSize)) { data_tag tag = peekTag(buf); switch (tag) { case DT_DocumentID: @@ -1395,7 +1396,7 @@ long* len; /*----------------------------------------------------------------------*/ static void -cleanUpWaisSearchResponse PARAMS((char* buf,char* seedWordsUsed, +cleanUpWaisSearchResponse _AP((char* buf,char* seedWordsUsed, WAISDocumentHeader** docHeaders, WAISDocumentShortHeader** shortHeaders, WAISDocumentLongHeader** longHeaders, @@ -1473,7 +1474,7 @@ char* buffer; char* buf = buffer; unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; void* header = NULL; WAISDocumentHeader** docHeaders = NULL; WAISDocumentShortHeader** shortHeaders = NULL; @@ -1490,7 +1491,7 @@ char* buffer; numDocHeaders = numLongHeaders = numShortHeaders = numText = numHeadlines = numCodes = 0; - buf = readUserInfoHeader(&tag1,&size,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; while (buf < (buffer + size + headerSize)) @@ -1671,14 +1672,14 @@ char* buffer; char* buf = buffer; unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; any *docID,*documentText; long versionNumber; docID = documentText = NULL; versionNumber = UNUSED; - buf = readUserInfoHeader(&tag1,&size,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; while (buf < (buffer + size + headerSize)) @@ -1787,7 +1788,7 @@ char* buffer; char* buf = buffer; unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; any* docID; long versionNumber; char *source,*date,*headline,*originCity; @@ -1796,7 +1797,7 @@ char* buffer; versionNumber = UNUSED; source = date = headline = originCity = NULL; - buf = readUserInfoHeader(&tag1,&size,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; while (buf < (buffer + size + headerSize)) @@ -1912,7 +1913,7 @@ char* buffer; char* buf = buffer; unsigned long size; unsigned long headerSize; - data_tag tag1; + data_tag tag; any* docID; long versionNumber; char *stockCodes,*companyCodes,*industryCodes; @@ -1921,7 +1922,7 @@ char* buffer; versionNumber = UNUSED; stockCodes = companyCodes = industryCodes = NULL; - buf = readUserInfoHeader(&tag1,&size,buf); + buf = readUserInfoHeader(&tag,&size,buf); headerSize = buf - buffer; while (buf < (buffer + size + headerSize)) @@ -1961,9 +1962,9 @@ char* buffer; char* writePresentInfo(present,buffer,len) -PresentAPDU* present GCC_UNUSED; +PresentAPDU* present; char* buffer; -long* len GCC_UNUSED; +long* len; { /* The WAIS protocol doesn't use present info */ return(buffer); @@ -1985,9 +1986,9 @@ char* buffer; char* writePresentResponseInfo(response,buffer,len) -PresentResponseAPDU* response GCC_UNUSED; +PresentResponseAPDU* response; char* buffer; -long* len GCC_UNUSED; +long* len; { /* The WAIS protocol doesn't use presentResponse info */ return(buffer); @@ -2044,7 +2045,7 @@ char* buffer; ( XXX return type could be in the element set) */ -static query_term** makeWAISQueryTerms PARAMS((DocObj** docs)); +static query_term** makeWAISQueryTerms _AP((DocObj** docs)); static query_term** makeWAISQueryTerms(docs) @@ -2163,7 +2164,7 @@ DocObj** docs; /*----------------------------------------------------------------------*/ -static DocObj** makeWAISQueryDocs PARAMS((query_term** terms)); +static DocObj** makeWAISQueryDocs _AP((query_term** terms)); static DocObj** makeWAISQueryDocs(terms) diff --git a/WWW/Library/Implementation/HTVMS_WaisProt.h b/WWW/Library/Implementation/HTVMS_WaisProt.h index 1b2329b1..1a4e83d5 100644 --- a/WWW/Library/Implementation/HTVMS_WaisProt.h +++ b/WWW/Library/Implementation/HTVMS_WaisProt.h @@ -29,10 +29,8 @@ */ #ifndef _H_WAIS_protocol_ -#define _H_WAIS_protocol_ -#include <HTUtils.h> -#include <HTVMS_WaisUI.h> +#define _H_WAIS_protocol_ /*----------------------------------------------------------------------*/ /* Data types / constants */ @@ -220,97 +218,88 @@ typedef struct WAISSearchResponse { /*----------------------------------------------------------------------*/ /* Functions */ -char * -generate_search_apdu PARAMS((char* buff, /* buffer to hold the apdu */ - long *buff_len, /* number of bytes written to the buffer */ - char *seed_words, /* string of the seed words */ - char *database_name, - DocObj** docobjs, - long maxDocsRetrieved - )); - -DocObj* makeDocObjUsingWholeDocument PARAMS((any* aDocID,char* type)); -DocObj* makeDocObjUsingBytes PARAMS((any* aDocID,char* type,long start,long end)); -DocObj* makeDocObjUsingLines PARAMS((any* aDocID,char* type,long start,long end)); -DocObj* makeDocObjUsingParagraphs PARAMS((any* aDocID,char* type,any* start,any* end)); -void freeDocObj PARAMS((DocObj* doc)); - -WAISInitResponse* makeWAISInitResponse PARAMS((long chunkCode,long chunkIDLen, +DocObj* makeDocObjUsingWholeDocument _AP((any* aDocID,char* type)); +DocObj* makeDocObjUsingBytes _AP((any* aDocID,char* type,long start,long end)); +DocObj* makeDocObjUsingLines _AP((any* aDocID,char* type,long start,long end)); +DocObj* makeDocObjUsingParagraphs _AP((any* aDocID,char* type,any* start,any* end)); +void freeDocObj _AP((DocObj* doc)); + +WAISInitResponse* makeWAISInitResponse _AP((long chunkCode,long chunkIDLen, char* chunkMarker,char* highlightMarker, char* deHighlightMarker,char* newLineChars)); -void freeWAISInitResponse PARAMS((WAISInitResponse* init)); +void freeWAISInitResponse _AP((WAISInitResponse* init)); -WAISSearch* makeWAISSearch PARAMS(( +WAISSearch* makeWAISSearch _AP(( char* seedWords,DocObj** docs,char** textList, long dateFactor,char* beginDateRange,char* endDateRange, long maxDocsRetrieved)); -void freeWAISSearch PARAMS((WAISSearch* query)); +void freeWAISSearch _AP((WAISSearch* query)); -WAISDocumentHeader* makeWAISDocumentHeader PARAMS(( +WAISDocumentHeader* makeWAISDocumentHeader _AP(( any* aDocID,long versionNumber,long score,long bestMatch,long docLen, long lines,char** types,char* source,char* date,char* headline,char* originCity)); -void freeWAISDocumentHeader PARAMS((WAISDocumentHeader* header)); -char* writeWAISDocumentHeader PARAMS((WAISDocumentHeader* header,char* buffer,long* len)); -char* readWAISDocumentHeader PARAMS((WAISDocumentHeader** header,char* buffer)); +void freeWAISDocumentHeader _AP((WAISDocumentHeader* header)); +char* writeWAISDocumentHeader _AP((WAISDocumentHeader* header,char* buffer,long* len)); +char* readWAISDocumentHeader _AP((WAISDocumentHeader** header,char* buffer)); -WAISDocumentShortHeader* makeWAISDocumentShortHeader PARAMS(( +WAISDocumentShortHeader* makeWAISDocumentShortHeader _AP(( any* aDocID,long versionNumber,long score,long bestMatch,long docLen,long lines)); -void freeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header)); -char* writeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header, +void freeWAISDocumentShortHeader _AP((WAISDocumentShortHeader* header)); +char* writeWAISDocumentShortHeader _AP((WAISDocumentShortHeader* header, char* buffer,long* len)); -char* readWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader** header,char* buffer)); +char* readWAISDocumentShortHeader _AP((WAISDocumentShortHeader** header,char* buffer)); -WAISDocumentLongHeader* makeWAISDocumentLongHeader PARAMS(( +WAISDocumentLongHeader* makeWAISDocumentLongHeader _AP(( any* aDocID,long versionNumber,long score,long bestMatch,long docLen, long lines,char** types,char* source,char* date, char* headline,char* originCity, char* stockCodes,char* companyCodes,char* industryCodes)); -void freeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header)); -char* writeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header,char* buffer,long* len)); -char* readWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader** header,char* buffer)); +void freeWAISDocumentLongHeader _AP((WAISDocumentLongHeader* header)); +char* writeWAISDocumentLongHeader _AP((WAISDocumentLongHeader* header,char* buffer,long* len)); +char* readWAISDocumentLongHeader _AP((WAISDocumentLongHeader** header,char* buffer)); -WAISSearchResponse* makeWAISSearchResponse PARAMS(( +WAISSearchResponse* makeWAISSearchResponse _AP(( char* seedWordsUsed,WAISDocumentHeader** docHeaders, WAISDocumentShortHeader** shortHeaders, WAISDocumentLongHeader** longHeaders, WAISDocumentText** text,WAISDocumentHeadlines** headlines, WAISDocumentCodes** codes, diagnosticRecord** diagnostics)); -void freeWAISSearchResponse PARAMS((WAISSearchResponse* response)); +void freeWAISSearchResponse _AP((WAISSearchResponse* response)); -WAISDocumentText* makeWAISDocumentText PARAMS((any* aDocID,long versionNumber, +WAISDocumentText* makeWAISDocumentText _AP((any* aDocID,long versionNumber, any* documentText)); -void freeWAISDocumentText PARAMS((WAISDocumentText* docText)); -char* writeWAISDocumentText PARAMS((WAISDocumentText* docText,char* buffer,long* len)); -char* readWAISDocumentText PARAMS((WAISDocumentText** docText,char* buffer)); +void freeWAISDocumentText _AP((WAISDocumentText* docText)); +char* writeWAISDocumentText _AP((WAISDocumentText* docText,char* buffer,long* len)); +char* readWAISDocumentText _AP((WAISDocumentText** docText,char* buffer)); -WAISDocumentHeadlines* makeWAISDocumentHeadlines PARAMS(( +WAISDocumentHeadlines* makeWAISDocumentHeadlines _AP(( any* aDocID,long versionNumber,char* source,char* date,char* headline, char* originCity)); -void freeWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines* docHeadline)); -char* writeWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines* docHeadline,char* buffer,long* len)); -char* readWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines** docHeadline,char* buffer)); +void freeWAISDocumentHeadlines _AP((WAISDocumentHeadlines* docHeadline)); +char* writeWAISDocumentHeadlines _AP((WAISDocumentHeadlines* docHeadline,char* buffer,long* len)); +char* readWAISDocumentHeadlines _AP((WAISDocumentHeadlines** docHeadline,char* buffer)); -WAISDocumentCodes* makeWAISDocumentCodes PARAMS(( +WAISDocumentCodes* makeWAISDocumentCodes _AP(( any* aDocID,long versionNumber,char* stockCodes,char* companyCodes, char* industryCodes)); -void freeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes)); -char* writeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes,char* buffer,long* len)); -char* readWAISDocumentCodes PARAMS((WAISDocumentCodes** docCodes,char* buffer)); - -any* makeWAISTextQuery PARAMS((DocObj** docs)); -DocObj** readWAISTextQuery PARAMS((any* terms)); - -void CSTFreeWAISInitResponse PARAMS((WAISInitResponse* init)); -void CSTFreeWAISSearch PARAMS((WAISSearch* query)); -void CSTFreeDocObj PARAMS((DocObj* doc)); -void CSTFreeWAISDocumentHeader PARAMS((WAISDocumentHeader* header)); -void CSTFreeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header)); -void CSTFreeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header)); -void CSTFreeWAISSearchResponse PARAMS((WAISSearchResponse* response)); -void CSTFreeWAISDocumentText PARAMS((WAISDocumentText* docText)); -void CSTFreeWAISDocHeadlines PARAMS((WAISDocumentHeadlines* docHeadline)); -void CSTFreeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes)); -void CSTFreeWAISTextQuery PARAMS(( any* query)); +void freeWAISDocumentCodes _AP((WAISDocumentCodes* docCodes)); +char* writeWAISDocumentCodes _AP((WAISDocumentCodes* docCodes,char* buffer,long* len)); +char* readWAISDocumentCodes _AP((WAISDocumentCodes** docCodes,char* buffer)); + +any* makeWAISTextQuery _AP((DocObj** docs)); +DocObj** readWAISTextQuery _AP((any* terms)); + +void CSTFreeWAISInitResponse _AP((WAISInitResponse* init)); +void CSTFreeWAISSearch _AP((WAISSearch* query)); +void CSTFreeDocObj _AP((DocObj* doc)); +void CSTFreeWAISDocumentHeader _AP((WAISDocumentHeader* header)); +void CSTFreeWAISDocumentShortHeader _AP((WAISDocumentShortHeader* header)); +void CSTFreeWAISDocumentLongHeader _AP((WAISDocumentLongHeader* header)); +void CSTFreeWAISSearchResponse _AP((WAISSearchResponse* response)); +void CSTFreeWAISDocumentText _AP((WAISDocumentText* docText)); +void CSTFreeWAISDocHeadlines _AP((WAISDocumentHeadlines* docHeadline)); +void CSTFreeWAISDocumentCodes _AP((WAISDocumentCodes* docCodes)); +void CSTFreeWAISTextQuery _AP(( any* query)); /*----------------------------------------------------------------------*/ @@ -345,9 +334,6 @@ void CSTFreeWAISTextQuery PARAMS(( any* query)); #ifndef WMESSAGE_H #define WMESSAGE_H -#include <HTUtils.h> -#include <HTVMS_WaisUI.h> - typedef struct wais_header { char msg_len[10]; /* length in bytes of following message */ char msg_type; /* type of message: 'z'=Z39.50 APDU, @@ -381,9 +367,9 @@ typedef struct wais_header { #define UUENCODE 'u' -void readWAISPacketHeader PARAMS((char* msgBuffer,WAISMessage *header_struct)); -long getWAISPacketLength PARAMS((WAISMessage* header)); -void writeWAISPacketHeader PARAMS((char* header,long dataLen,long type, +void readWAISPacketHeader _AP((char* msgBuffer,WAISMessage *header_struct)); +long getWAISPacketLength _AP((WAISMessage* header)); +void writeWAISPacketHeader _AP((char* header,long dataLen,long type, char* server,long compression, long encoding,long version)); diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.c b/WWW/Library/Implementation/HTVMS_WaisUI.c index 2301cbd6..f8f88da3 100644 --- a/WWW/Library/Implementation/HTVMS_WaisUI.c +++ b/WWW/Library/Implementation/HTVMS_WaisUI.c @@ -17,10 +17,10 @@ Brewster@think.com */ -/* +/* * this is a simple ui toolkit for building other ui's on top. * -brewster - * + * * top level functions: * generate_search_apdu * generate_retrieval_apdu @@ -32,22 +32,26 @@ * generate multiple queries for long documents. * this will crash if the file being retrieved is larger than 100k. * do log_write() - * + * */ #include <HTUtils.h> +#include <tcp.h> #include <HTVMS_WaisUI.h> #include <HTVMS_WaisProt.h> #include <HTTCP.h> - -#undef MAXINT /* we don't need it here, and tcp.h may conflict */ +/*#include <stdio> included by HTUtils.h -- FM */ +#include <string.h> +#include <ctype.h> #include <math.h> +#include <stdarg.h> #include <LYexit.h> #include <LYLeaks.h> void -log_write(char *s GCC_UNUSED) +log_write(s) +char *s; { return; } @@ -55,16 +59,21 @@ log_write(char *s GCC_UNUSED) /*----------------------------------------------------------------------*/ /* returns a pointer in the buffer of the first free byte. - if it overflows, then NULL is returned + if it overflows, then NULL is returned */ char * -generate_search_apdu( -char* buff, /* buffer to hold the apdu */ -long *buff_len, /* length of the buffer changed to reflect new data written */ -char *seed_words, /* string of the seed words */ -char *database_name, -DocObj** docobjs, -long maxDocsRetrieved) +generate_search_apdu(buff, + buff_len, + seed_words, + database_name, + docobjs, + maxDocsRetrieved) +char* buff; /* buffer to hold the apdu */ +long *buff_len; /* length of the buffer changed to reflect new data written */ +char *seed_words; /* string of the seed words */ +char *database_name; +DocObj** docobjs; +long maxDocsRetrieved; { /* local variables */ @@ -86,12 +95,12 @@ long maxDocsRetrieved) maxDocsRetrieved ); - search3 = makeSearchAPDU(30, + search3 = makeSearchAPDU(30, 5000, /* should be large */ 30, 1, /* replace indicator */ "", /* result set name */ - database_names, /* database name */ + database_names, /* database name */ QT_RelevanceFeedbackQuery, /* query_type */ 0, /* element name */ NULL, /* reference ID */ @@ -111,15 +120,22 @@ long maxDocsRetrieved) */ char * -generate_retrieval_apdu( -char *buff, -long *buff_len, /* length of the buffer changed to reflect new data written */ -any *docID, -long chunk_type, -long start, -long end, -char *type, -char *database_name) +generate_retrieval_apdu(buff, + buff_len, + docID, + chunk_type, + start, + end, + type, + database_name) +char *buff; +long *buff_len; /* length of the buffer changed to reflect new data written */ +any *docID; +long chunk_type; +long start; +long end; +char *type; +char *database_name; { SearchAPDU *search; char *end_ptr; @@ -143,9 +159,9 @@ char *database_name) refID.size = 1; refID.bytes = "3"; - + switch(chunk_type){ - case CT_line: + case CT_line: DocObjs[0] = makeDocObjUsingLines(docID, type, start, end); break; case CT_byte: @@ -154,11 +170,11 @@ char *database_name) } DocObjs[1] = NULL; - query = makeWAISTextQuery(DocObjs); - search = makeSearchAPDU( 10, 16, 15, + query = makeWAISTextQuery(DocObjs); + search = makeSearchAPDU( 10, 16, 15, 1, /* replace indicator */ "FOO", /* result set name */ - database_names, /* database name */ + database_names, /* database name */ QT_TextRetrievalQuery, /* query_type */ element_names, /* element name */ &refID, /* reference ID */ @@ -176,7 +192,10 @@ char *database_name) * to those trying to modify the transport code to use non-UNIX streams: * This is the function to modify! */ -PRIVATE long read_from_stream(int d, char *buf, long nbytes) +long read_from_stream(d,buf,nbytes) +int d; /* this is the stream */ +char *buf; +long nbytes; { long didRead; long toRead = nbytes; @@ -195,7 +214,7 @@ PRIVATE long read_from_stream(int d, char *buf, long nbytes) totalRead += didRead; } if(totalRead != nbytes) /* we overread for some reason */ - return(- totalRead); /* bad news */ + return(- totalRead); /* bad news */ return(totalRead); } @@ -203,21 +222,25 @@ PRIVATE long read_from_stream(int d, char *buf, long nbytes) /* returns the length of the response, 0 if an error */ -PRIVATE long -transport_message( - long connection, - char *request_message, - long request_length, - char *response_message, - long response_buffer_length) +long +transport_message(connection, + request_message, + request_length, + response_message, + response_buffer_length) +int connection; +char *request_message; +long request_length; +char *response_message; +long response_buffer_length; { WAISMessage header; long response_length; int rv; - + /* Write out message. Read back header. Figure out response length. */ - + if( request_length + HEADER_LENGTH != NETWRITE(connection,request_message, (int)( request_length +HEADER_LENGTH)) ) @@ -249,7 +272,7 @@ transport_message( response_length = atol(length_array); /* if(verbose){ - printf("WAIS header: '%s' length_array: '%s'\n", + printf("WAIS header: '%s' length_array: '%s'\n", response_message, length_array); } */ @@ -258,7 +281,7 @@ transport_message( and return 0 */ long i; for(i = 0; i < response_length; i++){ - rv = read_from_stream(connection, + rv = read_from_stream(connection, response_message + HEADER_LENGTH, 1); if (rv == HT_INTERRUPTED) @@ -269,7 +292,7 @@ transport_message( return(0); } } - rv = read_from_stream(connection, + rv = read_from_stream(connection, response_message + HEADER_LENGTH, response_length); if (rv == HT_INTERRUPTED) @@ -281,15 +304,19 @@ transport_message( /*----------------------------------------------------------------------*/ -/* returns the number of bytes written. 0 if an error */ +/* returns the number of bytes writen. 0 if an error */ long -interpret_message( - char *request_message, - long request_length, /* length of the buffer */ - char *response_message, - long response_buffer_length, - long connection, - boolean verbose GCC_UNUSED) +interpret_message(request_message,request_length, + response_message, + response_buffer_length, + connection, + verbose) +char *request_message; +long request_length; /* length of the buffer */ +char *response_message; +long response_buffer_length; +int connection; +boolean verbose; { long response_length; @@ -301,7 +328,7 @@ interpret_message( if(service_name && strlen(service_name) > 0) printf(" for service %s", service_name); printf("\n"); - twais_dsply_rsp_apdu(request_message + HEADER_LENGTH, + twais_dsply_rsp_apdu(request_message + HEADER_LENGTH, request_length); } @@ -331,7 +358,9 @@ interpret_message( /* modifies the string to exclude all seeker codes. sets length to the new length. */ -PRIVATE char *delete_seeker_codes(char *string, long *length) +char *delete_seeker_codes(string,length) +char *string; +long *length; { long original_count; /* index into the original string */ long new_count = 0; /* index into the collapsed string */ @@ -349,7 +378,7 @@ PRIVATE char *delete_seeker_codes(char *string, long *length) *length = new_count; return(string); } - + /*----------------------------------------------------------------------*/ #if defined(VMS) && defined(__GNUC__) /* 10-AUG-1995 [pr] */ @@ -369,10 +398,11 @@ static __const void *__const ctype_dummy[] = { &_ctype_, &ctype_dummy }; #endif /* VMS && __GNUC__ */ /* returns a pointer to a string with good stuff */ -char *trim_junk(char *headline) +char *trim_junk(headline) +char *headline; { long length = strlen(headline) + 1; /* include the trailing null */ - size_t i; + long i; headline = delete_seeker_codes(headline, &length); /* delete leading spaces */ for(i=0; i < strlen(headline); i++){ @@ -400,8 +430,8 @@ char *trim_junk(char *headline) **----------------------------------------------------------------------*/ /* WIDE AREA INFORMATION SERVER SOFTWARE:` No guarantees or restrictions. See the readme file for the full standard - disclaimer. - + disclaimer. + 3.26.90 Harry Morris, morris@think.com 3.30.90 Harry Morris - Changed any->bits to any->bytes 4.11.90 HWM - generalized conditional includes (see c-dialect.h) @@ -409,31 +439,44 @@ char *trim_junk(char *headline) #define RESERVE_SPACE_FOR_HEADER(spaceLeft) \ *spaceLeft -= HEADER_LEN; - + #define RELEASE_HEADER_SPACE(spaceLeft) \ if (*spaceLeft > 0) \ *spaceLeft += HEADER_LEN; - -/*----------------------------------------------------------------------*/ - -InitResponseAPDU* -makeInitResponseAPDU( -boolean result, -boolean search, -boolean present, -boolean deleteIt, -boolean accessControl, -boolean resourceControl, -long prefSize, -long maxMsgSize, -char* auth, -char* id, -char* name, -char* version, -any* refID, -void* userInfo) + +/*----------------------------------------------------------------------*/ + +InitResponseAPDU* +makeInitResponseAPDU(result, + search, + present, + deleteIt, + accessControl, + resourceControl, + prefSize, + maxMsgSize, + auth, + id, + name, + version, + refID, + userInfo) +boolean result; +boolean search; +boolean present; +boolean deleteIt; +boolean accessControl; +boolean resourceControl; +long prefSize; +long maxMsgSize; +char* auth; +char* id; +char* name; +char* version; +any* refID; +void* userInfo; /* build an initResponse APDU with user specified information */ -{ +{ InitResponseAPDU* init = (InitResponseAPDU*)s_malloc((size_t)sizeof(InitResponseAPDU)); init->PDUType = initResponseAPDU; @@ -451,14 +494,15 @@ void* userInfo) init->ImplementationVersion = s_strdup(version); init->ReferenceID = duplicateAny(refID); init->UserInformationField = userInfo; /* not copied! */ - + return(init); } /*----------------------------------------------------------------------*/ -void -freeInitResponseAPDU(InitResponseAPDU* init) +void +freeInitResponseAPDU(init) +InitResponseAPDU* init; /* free an initAPDU */ { s_free(init->IDAuthentication); @@ -471,20 +515,23 @@ freeInitResponseAPDU(InitResponseAPDU* init) /*----------------------------------------------------------------------*/ -char* -writeInitResponseAPDU(InitResponseAPDU* init, char* buffer, long* len) +char* +writeInitResponseAPDU(init,buffer,len) +InitResponseAPDU* init; +char* buffer; +long* len; /* write the initResponse to a buffer, adding system information */ -{ +{ char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */ long size; bit_map* optionsBM = NULL; RESERVE_SPACE_FOR_HEADER(len); - + buf = writePDUType(init->PDUType,buf,len); buf = writeBoolean(init->Result,buf,len); buf = writeProtocolVersion(buf,len); - + optionsBM = makeBitMap((unsigned long)5,init->willSearch,init->willPresent, init->willDelete,init->supportAccessControl, init->supportResourceControl); @@ -498,56 +545,58 @@ writeInitResponseAPDU(InitResponseAPDU* init, char* buffer, long* len) buf = writeString(init->ImplementationName,DT_ImplementationName,buf,len); buf = writeString(init->ImplementationVersion,DT_ImplementationVersion,buf,len); buf = writeAny(init->ReferenceID,DT_ReferenceID,buf,len); - + /* go back and write the header-length-indicator */ RELEASE_HEADER_SPACE(len); - size = buf - buffer - HEADER_LEN; + size = buf - buffer - HEADER_LEN; writeBinaryInteger(size,HEADER_LEN,buffer,len); if (init->UserInformationField != NULL) - buf = writeInitResponseInfo(init,buf,len); - + buf = writeInitResponseInfo(init,buf,len); + return(buf); } /*----------------------------------------------------------------------*/ -char* -readInitResponseAPDU(InitResponseAPDU** init, char* buffer) +char* +readInitResponseAPDU(init,buffer) +InitResponseAPDU** init; +char* buffer; { char* buf = buffer; boolean search,present,delete,accessControl,resourceControl; long prefSize,maxMsgSize; char *auth,*id,*name,*version; - long size; + long size; pdu_type pduType; bit_map* versionBM = NULL; bit_map* optionsBM = NULL; boolean result; any *refID = NULL; void* userInfo = NULL; - + auth = id = name = version = NULL; refID = NULL; - + /* read required part */ - buf = readBinaryInteger(&size,HEADER_LEN,buf); + buf = readBinaryInteger(&size,HEADER_LEN,buf); buf = readPDUType(&pduType,buf); buf = readBoolean(&result,buf); - buf = readBitMap(&versionBM,buf); + buf = readBitMap(&versionBM,buf); buf = readBitMap(&optionsBM,buf); buf = readNum(&prefSize,buf); buf = readNum(&maxMsgSize,buf); - + /* decode optionsBM */ search = bitAtPos(0,optionsBM); present = bitAtPos(1,optionsBM); delete = bitAtPos(2,optionsBM); accessControl = bitAtPos(3,optionsBM); resourceControl = bitAtPos(4,optionsBM); - + /* read optional part */ - while (buf < (buffer + size + HEADER_LEN)) + while (buf < (buffer + size + HEADER_LEN)) { data_tag tag = peekTag(buf); switch (tag) { case DT_IDAuthentication: @@ -589,12 +638,12 @@ readInitResponseAPDU(InitResponseAPDU** init, char* buffer) freeAny(refID); } RETURN_ON_NULL(buf); - + /* construct the basic init object */ *init = makeInitResponseAPDU(result, search,present,delete,accessControl,resourceControl, prefSize,maxMsgSize,auth,id,name,version,refID,userInfo); - + freeBitMap(versionBM); freeBitMap(optionsBM); s_free(auth); @@ -602,16 +651,19 @@ readInitResponseAPDU(InitResponseAPDU** init, char* buffer) s_free(name); s_free(version); freeAny(refID); - + return(buf); } /*----------------------------------------------------------------------*/ -InitResponseAPDU* -replyToInitAPDU(InitAPDU* init, boolean result, void* userInfo) +InitResponseAPDU* +replyToInitAPDU(init,result,userInfo) +InitAPDU* init; +boolean result; +void* userInfo; /* respond to an init message in the default way - echoing back - the init info + the init info */ { InitResponseAPDU* initResp; @@ -627,18 +679,27 @@ replyToInitAPDU(InitAPDU* init, boolean result, void* userInfo) /*----------------------------------------------------------------------*/ -SearchAPDU* -makeSearchAPDU( -long small, -long large, -long medium, -boolean replace, -char* name, -char** databases, -char* type, -char** elements, -any* refID, -void* queryInfo) +SearchAPDU* +makeSearchAPDU(small, + large, + medium, + replace, + name, + databases, + type, + elements, + refID, + queryInfo) +long small; +long large; +long medium; +boolean replace; +char* name; +char** databases; +char* type; +char** elements; +any* refID; +void* queryInfo; { char* ptr = NULL; long i; @@ -649,7 +710,7 @@ void* queryInfo) query->MediumSetPresentNumber = medium; query->ReplaceIndicator = replace; query->ResultSetName = s_strdup(name); - query->DatabaseNames = NULL; + query->DatabaseNames = NULL; if (databases != NULL) { for (i = 0, ptr = databases[i]; ptr != NULL; ptr = databases[++i]) { if (query->DatabaseNames == NULL) @@ -662,7 +723,7 @@ void* queryInfo) } } query->QueryType = s_strdup(type); - query->ElementSetNames = NULL; + query->ElementSetNames = NULL; if (elements != NULL) { for (i = 0, ptr = elements[i]; ptr != NULL; ptr = elements[++i]) { if (query->ElementSetNames == NULL) @@ -681,8 +742,9 @@ void* queryInfo) /*----------------------------------------------------------------------*/ -void -freeSearchAPDU(SearchAPDU* query) +void +freeSearchAPDU(query) +SearchAPDU* query; { s_free(query->ResultSetName); s_free(query->QueryType); @@ -700,16 +762,19 @@ freeSearchAPDU(SearchAPDU* query) #define ES_DELIMITER_1 "\037" /* separates database name from element name */ #define ES_DELIMITER_2 "\036" /* hex 1E separates <db,es> groups from one another */ -char* -writeSearchAPDU(SearchAPDU* query, char* buffer, long* len) -{ +char* +writeSearchAPDU(query,buffer,len) +SearchAPDU* query; +char* buffer; +long* len; +{ char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */ long size,i; char* ptr = NULL; char* scratch = NULL; RESERVE_SPACE_FOR_HEADER(len); - + buf = writePDUType(query->PDUType,buf,len); buf = writeBinaryInteger(query->SmallSetUpperBound,(size_t)3,buf,len); buf = writeBinaryInteger(query->LargeSetLowerBound,(size_t)3,buf,len); @@ -747,7 +812,7 @@ writeSearchAPDU(SearchAPDU* query, char* buffer, long* len) ptr = query->ElementSetNames[++i]; /* the element set name */ scratch = (char*)s_realloc(scratch,newScratchSize); s_strncat(scratch,ES_DELIMITER_1,2,newScratchSize); - s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize); + s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize); } } else @@ -757,37 +822,38 @@ writeSearchAPDU(SearchAPDU* query, char* buffer, long* len) s_strncat(scratch,ES_DELIMITER_2,2,newScratchSize); s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize); s_strncat(scratch,ES_DELIMITER_1,2,newScratchSize); - s_strncat(scratch,esPtr,strlen(esPtr) + 1,newScratchSize); + s_strncat(scratch,esPtr,strlen(esPtr) + 1,newScratchSize); } } buf = writeString(scratch,DT_ElementSetNames,buf,len); s_free(scratch); - } + } buf = writeAny(query->ReferenceID,DT_ReferenceID,buf,len); - + /* go back and write the header-length-indicator */ RELEASE_HEADER_SPACE(len); - size = buf - buffer - HEADER_LEN; + size = buf - buffer - HEADER_LEN; writeBinaryInteger(size,HEADER_LEN,buffer,len); if (query->Query != NULL) - buf = writeSearchInfo(query,buf,len); - + buf = writeSearchInfo(query,buf,len); + return(buf); } /*----------------------------------------------------------------------*/ -SearchResponseAPDU* -makeSearchResponseAPDU( -long result, -long count, -long recordsReturned, -long nextPos, -long resultStatus, -long presentStatus, -any* refID, -void* records) +SearchResponseAPDU* +makeSearchResponseAPDU(result,count,recordsReturned,nextPos,resultStatus, + presentStatus,refID,records) +long result; +long count; +long recordsReturned; +long nextPos; +long resultStatus; +long presentStatus; +any* refID; +void* records; { SearchResponseAPDU* query = (SearchResponseAPDU*)s_malloc((size_t)sizeof(SearchResponseAPDU)); query->PDUType = searchResponseAPDU; @@ -799,13 +865,14 @@ void* records) query->PresentStatus = presentStatus; query->ReferenceID = duplicateAny(refID); query->DatabaseDiagnosticRecords = records; - return(query); + return(query); } /*----------------------------------------------------------------------*/ -void -freeSearchResponseAPDU(SearchResponseAPDU* queryResponse) +void +freeSearchResponseAPDU(queryResponse) +SearchResponseAPDU* queryResponse; { freeAny(queryResponse->ReferenceID); s_free(queryResponse); @@ -813,14 +880,17 @@ freeSearchResponseAPDU(SearchResponseAPDU* queryResponse) /*----------------------------------------------------------------------*/ -char* -writeSearchResponseAPDU(SearchResponseAPDU* queryResponse, char* buffer, long* len) +char* +writeSearchResponseAPDU(queryResponse,buffer,len) +SearchResponseAPDU* queryResponse; +char* buffer; +long* len; { char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */ long size; RESERVE_SPACE_FOR_HEADER(len); - + buf = writePDUType(queryResponse->PDUType,buf,len); buf = writeBinaryInteger(queryResponse->SearchStatus,(size_t)1,buf,len); buf = writeBinaryInteger(queryResponse->ResultCount,(size_t)3,buf,len); @@ -829,22 +899,24 @@ writeSearchResponseAPDU(SearchResponseAPDU* queryResponse, char* buffer, long* l buf = writeNum(queryResponse->ResultSetStatus,DT_ResultSetStatus,buf,len); buf = writeNum(queryResponse->PresentStatus,DT_PresentStatus,buf,len); buf = writeAny(queryResponse->ReferenceID,DT_ReferenceID,buf,len); - + /* go back and write the header-length-indicator */ RELEASE_HEADER_SPACE(len); - size = buf - buffer - HEADER_LEN; + size = buf - buffer - HEADER_LEN; writeBinaryInteger(size,HEADER_LEN,buffer,len); if (queryResponse->DatabaseDiagnosticRecords != NULL) - buf = writeSearchResponseInfo(queryResponse,buf,len); - + buf = writeSearchResponseInfo(queryResponse,buf,len); + return(buf); } /*----------------------------------------------------------------------*/ -char* -readSearchResponseAPDU(SearchResponseAPDU** queryResponse, char* buffer) +char* +readSearchResponseAPDU(queryResponse,buffer) +SearchResponseAPDU** queryResponse; +char* buffer; { char* buf = buffer; long size; @@ -853,20 +925,20 @@ readSearchResponseAPDU(SearchResponseAPDU** queryResponse, char* buffer) long resultStatus,presentStatus; any *refID = NULL; void* userInfo = NULL; - + /* read required part */ - buf = readBinaryInteger(&size,HEADER_LEN,buf); + buf = readBinaryInteger(&size,HEADER_LEN,buf); buf = readPDUType(&pduType,buf); buf = readBinaryInteger(&result,(size_t)1,buf); buf = readBinaryInteger(&count,(size_t)3,buf); buf = readBinaryInteger(&recordsReturned,(size_t)3,buf); buf = readBinaryInteger(&nextPos,(size_t)3,buf); - + resultStatus = presentStatus = UNUSED; refID = NULL; /* read optional part */ - while (buf < (buffer + size + HEADER_LEN)) + while (buf < (buffer + size + HEADER_LEN)) { data_tag tag = peekTag(buf); switch (tag) { case DT_ResultSetStatus: @@ -884,18 +956,18 @@ readSearchResponseAPDU(SearchResponseAPDU** queryResponse, char* buffer) break; } } - + buf = readSearchResponseInfo(&userInfo,buf); if (buf == NULL) freeAny(refID); RETURN_ON_NULL(buf); - + /* construct the search object */ *queryResponse = makeSearchResponseAPDU(result,count,recordsReturned,nextPos, (long)resultStatus,(long)presentStatus,refID,userInfo); freeAny(refID); - + return(buf); } @@ -906,11 +978,11 @@ readSearchResponseAPDU(SearchResponseAPDU** queryResponse, char* buffer) **----------------------------------------------------------------------*/ /* WIDE AREA INFORMATION SERVER SOFTWARE: No guarantees or restrictions. See the readme file for the full standard - disclaimer. - + disclaimer. + 3.26.90 Harry Morris, morris@think.com 3.30.90 Harry Morris - Changed any->bits to any->bytes - 4.11.90 HWM - fixed include file names, changed + 4.11.90 HWM - fixed include file names, changed - writeCompressedIntegerWithPadding() to writeCompressedIntWithPadding() - generalized conditional includes (see c-dialect.h) @@ -920,39 +992,43 @@ readSearchResponseAPDU(SearchResponseAPDU** queryResponse, char* buffer) char* readErrorPosition = NULL; /* pos where buf stoped making sense */ /*----------------------------------------------------------------------*/ -/* A note on error handling +/* A note on error handling read - these are low level routines, they do not check the type tags which (sometimes) preceed the data (this is done by the higher - level functions which call these functions). There is no + level functions which call these functions). There is no attempt made to check that the reading does not exceed the read - buffer. Such cases should be very rare and usually will be - caught by the calling functions. (note - it is unlikely that + buffer. Such cases should be very rare and usually will be + caught by the calling functions. (note - it is unlikely that a series of low level reads will go far off the edge without triggering a type error. However, it is possible for a single - bad read in an array function (eg. readAny) to attempt to read a + bad read in an array function (eg. readAny) to attempt to read a large ammount, possibly causing a segmentation violation or out of memory condition. */ /*----------------------------------------------------------------------*/ -diagnosticRecord* -makeDiag(boolean surrogate, char* code, char* addInfo) +diagnosticRecord* +makeDiag(surrogate,code,addInfo) +boolean surrogate; +char* code; +char* addInfo; { - diagnosticRecord* diag = + diagnosticRecord* diag = (diagnosticRecord*)s_malloc((size_t)sizeof(diagnosticRecord)); - + diag->SURROGATE = surrogate; memcpy(diag->DIAG,code,DIAGNOSTIC_CODE_SIZE); - diag->ADDINFO = s_strdup(addInfo); + diag->ADDINFO = s_strdup(addInfo); return(diag); } /*----------------------------------------------------------------------*/ -void -freeDiag(diagnosticRecord* diag) -{ +void +freeDiag(diag) +diagnosticRecord* diag; +{ if (diag != NULL) { if (diag->ADDINFO != NULL) s_free(diag->ADDINFO); @@ -964,50 +1040,53 @@ freeDiag(diagnosticRecord* diag) #define END_OF_RECORD 0x1D -char* -writeDiag(diagnosticRecord* diag, char* buffer, long* len) +char* +writeDiag(diag,buffer,len) +diagnosticRecord* diag; +char* buffer; +long* len; /* diagnostics (as per Appendix D) have a very weird format - this changes in SR-1 */ { char* buf = buffer; long length; - + if (diag == NULL) /* handle unspecified optional args */ return(buf); buf = writeTag(DT_DatabaseDiagnosticRecords,buf,len); CHECK_FOR_SPACE_LEFT(0,len); - - length = 3; + + length = 3; if (diag->ADDINFO != NULL) length += strlen(diag->ADDINFO); - + if (length >= 0xFFFF ) /* make sure the length is reasonable */ { length = 0xFFFF - 1; diag->ADDINFO[0xFFFF - 3 - 1] = '\0'; } - + buf = writeBinaryInteger(length,2,buf,len); CHECK_FOR_SPACE_LEFT(1,len); - buf[0] = diag->DIAG[0]; + buf[0] = diag->DIAG[0]; buf++; - + CHECK_FOR_SPACE_LEFT(1,len); buf[0] = diag->DIAG[1]; buf++; - + if (length > 3) { CHECK_FOR_SPACE_LEFT(3,len); memcpy(buf,diag->ADDINFO,(size_t)length - 3); buf += length - 3; } - + CHECK_FOR_SPACE_LEFT(1,len); buf[0] = diag->SURROGATE; buf++; - + CHECK_FOR_SPACE_LEFT(1,len); buf[0] = END_OF_RECORD; buf++; @@ -1017,23 +1096,25 @@ writeDiag(diagnosticRecord* diag, char* buffer, long* len) /*----------------------------------------------------------------------*/ -char* -readDiag(diagnosticRecord** diag, char* buffer) +char* +readDiag(diag,buffer) +diagnosticRecord** diag; +char* buffer; { char* buf = buffer; - diagnosticRecord* d + diagnosticRecord* d = (diagnosticRecord*)s_malloc((size_t)sizeof(diagnosticRecord)); data_tag tag; long len; - + buf = readTag(&tag,buf); - + buf = readBinaryInteger(&len,2,buf); - + d->DIAG[0] = buf[0]; d->DIAG[1] = buf[1]; d->DIAG[2] = '\0'; - + if (len > 3) { d->ADDINFO = (char*)s_malloc((size_t)(len - 3 + 1)); memcpy(d->ADDINFO,(char*)(buf + 2),(size_t)(len - 3)); @@ -1041,9 +1122,9 @@ readDiag(diagnosticRecord** diag, char* buffer) } else d->ADDINFO = NULL; - + d->SURROGATE = buf[len - 1]; - + *diag = d; return(buf + len + 1); @@ -1056,43 +1137,48 @@ readDiag(diagnosticRecord** diag, char* buffer) #define dataBits 7 char* -writeCompressedInteger(unsigned long num, char* buf, long* len) +writeCompressedInteger(num,buf,len) +unsigned long num; +char* buf; +long* len; /* write a binary integer in the format described on p. 40. - this might be sped up + this might be sped up */ { char byte; - unsigned long i; + long i; unsigned long size; - + size = writtenCompressedIntSize(num); CHECK_FOR_SPACE_LEFT(size,len); - - for (i = size - 1; i != 0; i--) + + for (i = size - 1; i >= 0; i--) { byte = num & dataMask; if (i != (size-1)) /* turn on continue bit */ byte = (char)(byte | continueBit); buf[i] = byte; num = num >> dataBits; /* don't and here */ } - + return(buf + size); -} +} /*----------------------------------------------------------------------*/ char* -readCompressedInteger(unsigned long *num, char* buf) +readCompressedInteger(num,buf) +unsigned long *num; +char* buf; /* read a binary integer in the format described on p. 40. - this might be sped up + this might be sped up */ { long i = 0; unsigned char byte; *num = 0; - - do + + do { byte = buf[i++]; *num = *num << dataBits; *num += (byte & dataMask); @@ -1100,29 +1186,29 @@ readCompressedInteger(unsigned long *num, char* buf) while (byte & continueBit); return(buf + i); -} +} /*----------------------------------------------------------------------*/ #define pad 128 /* high bit is set */ char* -writeCompressedIntWithPadding( -unsigned long num, -unsigned long size, -char* buffer, -long* len) +writeCompressedIntWithPadding(num,size,buffer,len) +unsigned long num; +unsigned long size; +char* buffer; +long* len; /* Like writeCompressedInteger, except writes padding (128) to make - sure that size bytes are used. This can be read correctly by + sure that size bytes are used. This can be read correctly by readCompressedInteger() */ { char* buf = buffer; unsigned long needed,padding; long i; - + CHECK_FOR_SPACE_LEFT(size,len); - + needed = writtenCompressedIntSize(num); padding = size - needed; i = padding - 1; @@ -1130,71 +1216,81 @@ long* len) for (i = padding - 1;i >= 0;i--) { buf[i] = pad; } - + buf = writeCompressedInteger(num,buf + padding,len); - + return(buf); -} +} /*----------------------------------------------------------------------*/ unsigned long -writtenCompressedIntSize(unsigned long num) +writtenCompressedIntSize(num) +unsigned long num; /* return the number of bytes needed to represnet the value num in compressed format. curently limited to 4 bytes */ { - if (num < CompressedInt1Byte) + if (num < CompressedInt1Byte) return(1); - else if (num < CompressedInt2Byte) + else if (num < CompressedInt2Byte) return(2); else if (num < CompressedInt3Byte) return(3); else - return(4); + return(4); } /*----------------------------------------------------------------------*/ char* -writeTag(data_tag tag, char* buf, long* len) +writeTag(tag,buf,len) +data_tag tag; +char* buf; +long* len; /* write out a data tag */ -{ +{ return(writeCompressedInteger(tag,buf,len)); -} +} /*----------------------------------------------------------------------*/ char* -readTag(data_tag* tag, char* buf) +readTag(tag,buf) +data_tag* tag; +char* buf; /* read a data tag */ -{ +{ return(readCompressedInteger(tag,buf)); -} +} /*----------------------------------------------------------------------*/ -unsigned long -writtenTagSize(data_tag tag) -{ +unsigned long +writtenTagSize(tag) +data_tag tag; +{ return(writtenCompressedIntSize(tag)); } /*----------------------------------------------------------------------*/ data_tag -peekTag(char* buf) +peekTag(buf) +char* buf; /* read a data tag without advancing the buffer */ { data_tag tag; readTag(&tag,buf); return(tag); -} +} /*----------------------------------------------------------------------*/ -any* -makeAny(unsigned long size, char* data) +any* +makeAny(size,data) +unsigned long size; +char* data; { any* a = (any*)s_malloc((size_t)sizeof(any)); a->size = size; @@ -1205,9 +1301,10 @@ makeAny(unsigned long size, char* data) /*----------------------------------------------------------------------*/ void -freeAny(any* a) +freeAny(a) +any* a; /* destroy an any and its associated data. Assumes a->bytes was - allocated using the s_malloc family of libraries + allocated using the s_malloc family of libraries */ { if (a != NULL) @@ -1219,8 +1316,9 @@ freeAny(any* a) /*----------------------------------------------------------------------*/ -any* -duplicateAny(any* a) +any* +duplicateAny(a) +any* a; { any* copy = NULL; @@ -1240,15 +1338,19 @@ duplicateAny(any* a) /*----------------------------------------------------------------------*/ -char* -writeAny(any* a, data_tag tag, char* buffer, long* len) +char* +writeAny(a,tag,buffer,len) +any* a; +data_tag tag; +char* buffer; +long* len; /* write an any + tag and size info */ { char* buf = buffer; if (a == NULL) /* handle unspecified optional args */ return(buf); - + /* write the tags */ buf = writeTag(tag,buf,len); buf = writeCompressedInteger(a->size,buf,len); @@ -1263,7 +1365,9 @@ writeAny(any* a, data_tag tag, char* buffer, long* len) /*----------------------------------------------------------------------*/ -char *readAny(any** anAny, char* buffer) +char *readAny(anAny,buffer) +any** anAny; +char* buffer; /* read an any + tag and size info */ { char *buf; @@ -1275,9 +1379,9 @@ char *readAny(any** anAny, char* buffer) a=(any*)s_malloc((size_t)sizeof(any)); buf=buffer; - + buf = readTag(&tag,buf); - + buf = readCompressedInteger(&a->size,buf); /* now simply copy the bytes */ @@ -1290,8 +1394,10 @@ a=(any*)s_malloc((size_t)sizeof(any)); /*----------------------------------------------------------------------*/ -unsigned long -writtenAnySize(data_tag tag, any* a) +unsigned long +writtenAnySize(tag,a) +data_tag tag; +any* a; { unsigned long size; @@ -1307,13 +1413,14 @@ writtenAnySize(data_tag tag, any* a) /*----------------------------------------------------------------------*/ any* -stringToAny(char* s) +stringToAny(s) +char* s; { any* a = NULL; - + if (s == NULL) return(NULL); - + a = (any*)s_malloc((size_t)sizeof(any)); a->size = strlen(s); a->bytes = (char*)s_malloc((size_t)a->size); @@ -1324,13 +1431,14 @@ stringToAny(char* s) /*----------------------------------------------------------------------*/ char* -anyToString(any* a) +anyToString(a) +any* a; { char* s = NULL; - + if (a == NULL) return(NULL); - + s = s_malloc((size_t)(a->size + 1)); memcpy(s,a->bytes,(size_t)a->size); s[a->size] = '\0'; @@ -1339,11 +1447,15 @@ anyToString(any* a) /*----------------------------------------------------------------------*/ -char* -writeString(char* s, data_tag tag, char* buffer, long* len) -/* Write a C style string. The terminating null is not written. +char* +writeString(s,tag,buffer,len) +char* s; +data_tag tag; +char* buffer; +long* len; +/* Write a C style string. The terminating null is not written. This function is not part of the Z39.50 spec. It is provided - for the convienience of those wishing to pass C strings in + for the convienience of those wishing to pass C strings in the place of an any. */ { @@ -1351,7 +1463,7 @@ writeString(char* s, data_tag tag, char* buffer, long* len) any* data = NULL; if (s == NULL) return(buffer); /* handle unused optional item before making an any */ - data = (any*)s_malloc((size_t)sizeof(any)); + data = (any*)s_malloc((size_t)sizeof(any)); data->size = strlen(s); data->bytes = s; /* save a copy here by not using stringToAny() */ buf = writeAny(data,tag,buf,len); @@ -1361,12 +1473,14 @@ writeString(char* s, data_tag tag, char* buffer, long* len) /*----------------------------------------------------------------------*/ -char* -readString(char** s, char* buffer) +char* +readString(s ,buffer) +char** s ; +char* buffer; /* Read an any and convert it into a C style string. This function is not part of the Z39.50 spec. It is provided - for the convienience of those wishing to pass C strings in - the place of an any. + for the convienience of those wishing to pass C strings in + the place of an any. */ { any* data = NULL; @@ -1378,8 +1492,10 @@ readString(char** s, char* buffer) /*----------------------------------------------------------------------*/ -unsigned long -writtenStringSize(data_tag tag, char* s) +unsigned long +writtenStringSize(tag,s) +data_tag tag; +char* s; { unsigned long size; @@ -1394,21 +1510,23 @@ writtenStringSize(data_tag tag, char* s) /*----------------------------------------------------------------------*/ -any* -longToAny(long num) +any* +longToAny(num) +long num; /* a convienience function */ { char s[40]; sprintf(s,"%ld",num); - + return(stringToAny(s)); } /*----------------------------------------------------------------------*/ long -anyToLong(any* a) +anyToLong(a) +any* a; /* a convienience function */ { long num; @@ -1419,7 +1537,7 @@ anyToLong(any* a) s_free(str); return(num); } - + /*----------------------------------------------------------------------*/ #define bitsPerByte 8 @@ -1429,22 +1547,22 @@ makeBitMap(unsigned long numBits, ...) /* construct and return a bitmap with numBits elements */ { va_list ap; - unsigned long i,j; + long i,j; bit_map* bm = NULL; - LYva_start(ap,numBits); - + va_start(ap,numBits); + bm = (bit_map*)s_malloc((size_t)sizeof(bit_map)); - bm->size = (unsigned long)(ceil((double)numBits / bitsPerByte)); + bm->size = (unsigned long)ceil((double)numBits / bitsPerByte); bm->bytes = (char*)s_malloc((size_t)bm->size); - + /* fill up the bits */ for (i = 0; i < bm->size; i++) /* iterate over bytes */ { char byte = 0; for (j = 0; j < bitsPerByte; j++) /* iterate over bits */ { if ((i * bitsPerByte + j) < numBits) { boolean bit = false; - bit = (boolean)va_arg(ap,boolean); + bit = (boolean)va_arg(ap,boolean); if (bit) { byte = byte | (1 << (bitsPerByte - j - 1)); } @@ -1461,7 +1579,8 @@ makeBitMap(unsigned long numBits, ...) /*----------------------------------------------------------------------*/ void -freeBitMap(bit_map* bm) +freeBitMap(bm) +bit_map* bm; /* destroy a bit map created by makeBitMap() */ { s_free(bm->bytes); @@ -1470,18 +1589,20 @@ freeBitMap(bit_map* bm) /*----------------------------------------------------------------------*/ -/* use this routine to interpret a bit map. pos specifies the bit - number. bit 0 is the Leftmost bit of the first byte. +/* use this routine to interpret a bit map. pos specifies the bit + number. bit 0 is the Leftmost bit of the first byte. Could do bounds checking. */ boolean -bitAtPos(unsigned long pos, bit_map* bm) +bitAtPos(pos,bm) +long pos; +bit_map* bm; { if (pos > bm->size*bitsPerByte) return false; else - return((bm->bytes[(pos / bitsPerByte)] & + return((bm->bytes[(pos / bitsPerByte)] & (0x80>>(pos % bitsPerByte))) ? true : false); } @@ -1489,27 +1610,40 @@ bitAtPos(unsigned long pos, bit_map* bm) /*----------------------------------------------------------------------*/ char* -writeBitMap(bit_map* bm, data_tag tag, char* buffer, long* len) +writeBitMap(bm,tag,buffer,len) +bit_map* bm; +data_tag tag; +char* buffer; +long* len; /* write a bitmap + type and size info */ -{ +{ return(writeAny((any*)bm,tag,buffer,len)); } /*----------------------------------------------------------------------*/ char* -readBitMap(bit_map** bm, char* buffer) +readBitMap(bm,buffer) +bit_map** bm; +char* buffer; /* read a bitmap + type and size info */ { - char *c; - c = readAny((any**)bm,buffer); - return(c); + char *c; + + + +c=readAny((any**)bm,buffer); + + return(c); } /*----------------------------------------------------------------------*/ -char* -writeByte(unsigned long byte, char* buf, long* len) +char* +writeByte(byte,buf,len) +unsigned long byte; +char* buf; +long* len; { CHECK_FOR_SPACE_LEFT(1,len); buf[0] = byte & 0xFF; /* we really only want the first byte */ @@ -1518,8 +1652,10 @@ writeByte(unsigned long byte, char* buf, long* len) /*----------------------------------------------------------------------*/ -char* -readByte(unsigned char* byte, char* buf) +char* +readByte(byte,buf) +unsigned char* byte; +char* buf; { *byte = buf[0]; return(buf + 1); @@ -1527,16 +1663,21 @@ readByte(unsigned char* byte, char* buf) /*----------------------------------------------------------------------*/ -char* -writeBoolean(boolean flag, char* buf, long* len) +char* +writeBoolean(flag,buf,len) +boolean flag; +char* buf; +long* len; { return(writeByte(flag,buf,len)); } /*----------------------------------------------------------------------*/ -char* -readBoolean(boolean* flag, char* buffer) +char* +readBoolean(flag,buffer) +boolean* flag; +char* buffer; { unsigned char byte; char* buf = readByte(&byte,buffer); @@ -1547,26 +1688,32 @@ readBoolean(boolean* flag, char* buffer) /*----------------------------------------------------------------------*/ char* -writePDUType(pdu_type pduType, char* buf, long* len) +writePDUType(pduType,buf,len) +pdu_type pduType; +char* buf; +long* len; /* PDUType is a single byte */ { return(writeBinaryInteger((long)pduType,(unsigned long)1,buf,len)); -} +} /*----------------------------------------------------------------------*/ char* -readPDUType(pdu_type* pduType, char* buf) +readPDUType(pduType,buf) +pdu_type* pduType; +char* buf; /* PDUType is a single byte */ { return(readBinaryInteger((long*)pduType,(unsigned long)1,buf)); -} +} /*----------------------------------------------------------------------*/ pdu_type -peekPDUType(char* buf) -/* read the next pdu without advancing the buffer, Note that this +peekPDUType(buf) +char* buf; +/* read the next pdu without advancing the buffer, Note that this function is to be used on a buffer that is known to contain an APDU. The pdu_type is written HEADER_LEN bytes into the buffer */ @@ -1581,7 +1728,11 @@ peekPDUType(char* buf) #define BINARY_INTEGER_BYTES sizeof(long) /* the number of bytes used by a "binary integer" */ char* -writeBinaryInteger(long num, unsigned long size, char* buf, long* len) +writeBinaryInteger(num,size,buf,len) +long num; +unsigned long size; +char* buf; +long* len; /* write out first size bytes of num - no type info XXX should this take unsigned longs instead ??? */ { @@ -1605,11 +1756,14 @@ writeBinaryInteger(long num, unsigned long size, char* buf, long* len) /*----------------------------------------------------------------------*/ char* -readBinaryInteger(long* num, unsigned long size, char* buf) +readBinaryInteger(num,size,buf) +long* num; +unsigned long size; +char* buf; /* read in first size bytes of num - no type info XXX this should take unsigned longs instead !!! */ { - unsigned long i; + long i; unsigned char byte; if (size < 1 || size > BINARY_INTEGER_BYTES) @@ -1627,10 +1781,11 @@ readBinaryInteger(long* num, unsigned long size, char* buf) /*----------------------------------------------------------------------*/ -unsigned long -writtenCompressedBinIntSize(long num) +unsigned long +writtenCompressedBinIntSize(num) +long num; /* return the number of bytes needed to represent the value num. - currently limited to max of 4 bytes + currently limited to max of 4 bytes Only compresses for positive nums - negatives get whole 4 bytes */ { @@ -1645,36 +1800,42 @@ writtenCompressedBinIntSize(long num) else return(4); } - + /*----------------------------------------------------------------------*/ char* -writeNum(long num, data_tag tag, char* buffer, long* len) +writeNum(num,tag,buffer,len) +long num; +data_tag tag; +char* buffer; +long* len; /* write a binary integer + size and tag info */ { char* buf = buffer; long size = writtenCompressedBinIntSize(num); - + if (num == UNUSED) return(buffer); - + buf = writeTag(tag,buf,len); - buf = writeCompressedInteger(size,buf,len); - buf = writeBinaryInteger(num,(unsigned long)size,buf,len); + buf = writeCompressedInteger(size,buf,len); + buf = writeBinaryInteger(num,(unsigned long)size,buf,len); return(buf); } /*----------------------------------------------------------------------*/ char* -readNum(long* num, char* buffer) +readNum(num,buffer) +long* num; +char* buffer; /* read a binary integer + size and tag info */ { char* buf = buffer; data_tag tag; unsigned long size; unsigned long val; - + buf = readTag(&tag,buf); buf = readCompressedInteger(&val,buf); size = (unsigned long)val; @@ -1684,25 +1845,29 @@ readNum(long* num, char* buffer) /*----------------------------------------------------------------------*/ -unsigned long -writtenNumSize(data_tag tag, long num) +unsigned long +writtenNumSize(tag,num) +data_tag tag; +long num; { long dataSize = writtenCompressedBinIntSize(num); long size; - + size = writtenTagSize(tag); /* space for the tag */ size += writtenCompressedIntSize(dataSize); /* space for the size */ size += dataSize; /* space for the data */ - + return(size); } /*----------------------------------------------------------------------*/ -typedef void (voidfunc)(void *); +typedef void (voidfunc)(); void -doList(void** list, voidfunc *func) +doList(list,func) +void** list; +voidfunc *func; /* call func on each element of the NULL terminated list of pointers */ { register long i; @@ -1715,8 +1880,10 @@ doList(void** list, voidfunc *func) /*----------------------------------------------------------------------*/ -char* -writeProtocolVersion(char* buf, long* len) +char* +writeProtocolVersion(buf,len) +char* buf; +long* len; /* write a bitmap describing the protocols available */ { static bit_map* version = NULL; @@ -1724,14 +1891,14 @@ writeProtocolVersion(char* buf, long* len) if (version == NULL) { version = makeBitMap((unsigned long)1,true); /* version 1! */ } - + return(writeBitMap(version,DT_ProtocolVersion,buf,len)); } /*----------------------------------------------------------------------*/ char* -defaultImplementationID(void) +defaultImplementationID() { static char ImplementationID[] = "TMC"; return(ImplementationID); @@ -1740,7 +1907,7 @@ defaultImplementationID(void) /*----------------------------------------------------------------------*/ char* -defaultImplementationName(void) +defaultImplementationName() { static char ImplementationName[] = "Thinking Machines Corporation Z39.50"; return(ImplementationName); @@ -1749,7 +1916,7 @@ defaultImplementationName(void) /*----------------------------------------------------------------------*/ char* -defaultImplementationVersion(void) +defaultImplementationVersion() { static char ImplementationVersion[] = "2.0A"; return(ImplementationVersion); @@ -1764,22 +1931,28 @@ defaultImplementationVersion(void) **----------------------------------------------------------------------*/ /* WIDE AREA INFORMATION SERVER SOFTWARE: No guarantees or restrictions. See the readme file for the full standard - disclaimer. - + disclaimer. + 3.26.90 Harry Morris, morris@think.com 4.11.90 HWM - generalized conditional includes (see c-dialect.h) */ /*----------------------------------------------------------------------*/ query_term* -makeAttributeTerm( -char* use, -char* relation, -char* position, -char* structure, -char* truncation, -char* completeness, -any* term) +makeAttributeTerm(use, + relation, + position, + structure, + truncation, + completeness, + term) +char* use; +char* relation; +char* position; +char* structure; +char* truncation; +char* completeness; +any* term; { query_term* qt = (query_term*)s_malloc((size_t)sizeof(query_term)); @@ -1803,8 +1976,9 @@ any* term) /*----------------------------------------------------------------------*/ query_term* -makeResultSetTerm(any* resultSet) -{ +makeResultSetTerm(resultSet) +any* resultSet; +{ query_term* qt = (query_term*)s_malloc((size_t)sizeof(query_term)); qt->TermType = TT_ResultSetID; @@ -1812,14 +1986,15 @@ makeResultSetTerm(any* resultSet) qt->ResultSetID = duplicateAny(resultSet); qt->Term = NULL; - + return(qt); } /*----------------------------------------------------------------------*/ -query_term* -makeOperatorTerm(char* operatorCode) +query_term* +makeOperatorTerm(operatorCode) +char* operatorCode; { query_term* qt = (query_term*)s_malloc((size_t)sizeof(query_term)); @@ -1835,10 +2010,10 @@ makeOperatorTerm(char* operatorCode) /*----------------------------------------------------------------------*/ -void -freeTerm(void* param) +void +freeTerm(qt) +query_term* qt; { - query_term* qt = (query_term*)param; switch (qt->TermType) { case TT_Attribute: freeAny(qt->Term); @@ -1862,23 +2037,26 @@ freeTerm(void* param) #define ATTRIBUTE_LIST_SIZE ATTRIBUTE_SIZE * 6 #define AT_DELIMITER " " -char* -writeQueryTerm(query_term* qt, char* buffer, long* len) +char* +writeQueryTerm(qt,buffer,len) +query_term* qt; +char* buffer; +long* len; { char* buf = buffer; char attributes[ATTRIBUTE_LIST_SIZE]; switch (qt->TermType) { case TT_Attribute: - strncpy(attributes,qt->Use,ATTRIBUTE_LIST_SIZE); + strncpy(attributes,qt->Use,ATTRIBUTE_LIST_SIZE); s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE); - s_strncat(attributes,qt->Relation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); + s_strncat(attributes,qt->Relation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE); - s_strncat(attributes,qt->Position,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); + s_strncat(attributes,qt->Position,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE); - s_strncat(attributes,qt->Structure,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); + s_strncat(attributes,qt->Structure,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE); - s_strncat(attributes,qt->Truncation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); + s_strncat(attributes,qt->Truncation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE); s_strncat(attributes,qt->Completeness,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); buf = writeString(attributes,DT_AttributeList,buf,len); @@ -1901,8 +2079,10 @@ writeQueryTerm(query_term* qt, char* buffer, long* len) /*----------------------------------------------------------------------*/ -char* -readQueryTerm(query_term** qt, char* buffer) +char* +readQueryTerm(qt,buffer) +query_term** qt; +char* buffer; { char* buf = buffer; char *attributeList = NULL; @@ -1917,7 +2097,7 @@ readQueryTerm(query_term** qt, char* buffer) any* resultSetID = NULL; data_tag tag; - + tag = peekTag(buffer); switch(tag) @@ -1937,7 +2117,7 @@ readQueryTerm(query_term** qt, char* buffer) break; case DT_ResultSetID: buf = readAny(&resultSetID,buf); - *qt = makeResultSetTerm(resultSetID); + *qt = makeResultSetTerm(resultSetID); freeAny(resultSetID); break; case DT_Operator: @@ -1949,20 +2129,21 @@ readQueryTerm(query_term** qt, char* buffer) REPORT_READ_ERROR(buf); break; } - + return(buf); } /*----------------------------------------------------------------------*/ -static unsigned long getQueryTermSize PARAMS((query_term* qt)); +static unsigned long getQueryTermSize _AP((query_term* qt)); static unsigned long -getQueryTermSize(query_term* qt) +getQueryTermSize(qt) +query_term* qt; /* figure out how many bytes it will take to write this query */ { - unsigned long size = 0; - static char attributes[] = "11 22 33 44 55 66"; /* we just need this to + unsigned long size; + static char attributes[] = "11 22 33 44 55 66"; /* we just need this to calculate its written size */ @@ -1988,12 +2169,13 @@ getQueryTermSize(query_term* qt) /*----------------------------------------------------------------------*/ -/* A query is simply a null terminated list of query terms. For +/* A query is simply a null terminated list of query terms. For transmission, a query is written into an any which is sent as the user information field. */ any* -writeQuery(query_term** terms) +writeQuery(terms) +query_term** terms; { any* info = NULL; char* writePos = NULL; @@ -2026,7 +2208,8 @@ writeQuery(query_term** terms) /*----------------------------------------------------------------------*/ query_term** -readQuery(any *info) +readQuery(info) +any *info; { char* readPos = info->bytes; query_term** terms = NULL; @@ -2044,7 +2227,7 @@ log_write(tmp); { terms = (query_term**)s_malloc((size_t)(sizeof(query_term*)*2)); } else - { terms = + { terms = (query_term**)s_realloc((char*)terms, (size_t)(sizeof(query_term*)*(numTerms+2))); } @@ -2075,13 +2258,14 @@ if(qt==NULL) * up a little window to explain the problem. * On a unix box, it will print out the error and call perror() */ - + /*----------------------------------------------------------------------*/ -static void exitAction PARAMS((long error)); +static void exitAction _AP((long error)); static void -exitAction(long error GCC_UNUSED) +exitAction(error) +long error; { long i; for (i = 0; i < 100000; i++) @@ -2099,11 +2283,11 @@ panic(char *format, ...) va_list ap; /* the variable arguments */ fprintf(stderr,PANIC_HEADER); - LYva_start(ap, format); /* init ap */ + va_start(ap, format); /* init ap */ vfprintf(stderr,format,ap); /* print the contents */ va_end(ap); /* free ap */ fflush(stderr); - + exitAction(0); } @@ -2114,20 +2298,24 @@ panic(char *format, ...) ** Routines originally from cutil.c -- FM ** **----------------------------------------------------------------------*/ -/* Wide AREA INFORMATION SERVER SOFTWARE +/* Wide AREA INFORMATION SERVER SOFTWARE No guarantees or restrictions. See the readme file for the full standard - disclaimer. - + disclaimer. + 3.26.90 Harry Morris, morris@think.com 4.11.90 HWM - generalized conditional includes (see c-dialect.h) */ +#include <varargs.h> + + /*----------------------------------------------------------------------*/ void -fs_checkPtr(void* ptr) +fs_checkPtr(ptr) +void* ptr; /* If the ptr is NULL, give an error */ -{ +{ if (ptr == NULL) panic("checkPtr found a NULL pointer"); } @@ -2135,41 +2323,45 @@ fs_checkPtr(void* ptr) /*----------------------------------------------------------------------*/ void* -fs_malloc(size_t size) +fs_malloc(size) +size_t size; /* does safety checks and optional accounting */ -{ +{ register void* ptr = NULL; ptr = (void*)calloc((size_t)size,(size_t)1); s_checkPtr(ptr); - + return(ptr); } /*----------------------------------------------------------------------*/ void* -fs_realloc(void* ptr, size_t size) -/* does safety checks and optional accounting +fs_realloc(ptr,size) +void* ptr; +size_t size; +/* does safety checks and optional accounting note - we don't know how big ptr's memory is, so we can't ensure that any new memory allocated is NULLed! */ -{ +{ register void* nptr = NULL; - + if (ptr == NULL) /* this is really a malloc */ return(s_malloc(size)); - + nptr = (void*)realloc(ptr,size); s_checkPtr(ptr); - + return(nptr); } /*----------------------------------------------------------------------*/ void -fs_free(void* ptr) +fs_free(ptr) +void* ptr; /* does safety checks and optional accounting */ { if (ptr != NULL) /* some non-ansi compilers/os's cant handle freeing null */ @@ -2182,19 +2374,20 @@ fs_free(void* ptr) /*----------------------------------------------------------------------*/ char* -s_strdup(char* s) +s_strdup(s) +char* s; /* return a copy of s. This is identical to the standard library routine - strdup(), except that it is safe. If s == NULL or malloc fails, + strdup(), except that it is safe. If s == NULL or malloc fails, appropriate action is taken. */ { unsigned long len; char* copy = NULL; - + if (s == NULL) /* saftey check to postpone stupid errors */ return(NULL); - + len = strlen(s); /* length of string - terminator */ copy = (char*)s_malloc((size_t)(sizeof(char)*(len + 1))); strncpy(copy,s,len + 1); @@ -2204,15 +2397,19 @@ s_strdup(char* s) /*----------------------------------------------------------------------*/ char* -fs_strncat(char* dst, char* src, size_t maxToAdd, size_t maxTotal) +fs_strncat(dst,src,maxToAdd,maxTotal) +char* dst; + char* src; + size_t maxToAdd; + size_t maxTotal; -/* like strncat, except the fourth argument limits the maximum total +/* like strncat, except the fourth argument limits the maximum total length of the resulting string */ { size_t dstSize = strlen(dst); size_t srcSize = strlen(src); - + if (dstSize + srcSize < maxTotal) /* use regular old strncat */ return(strncat(dst,src,maxToAdd)); else @@ -2228,14 +2425,16 @@ fs_strncat(char* dst, char* src, size_t maxToAdd, size_t maxTotal) /*----------------------------------------------------------------------*/ -char char_downcase(unsigned long long_ch) +char char_downcase(long_ch) +unsigned long long_ch; { unsigned char ch = long_ch & 0xFF; /* just want one byte */ /* when ansi is the way of the world, this can be tolower */ return (((ch >= 'A') && (ch <= 'Z')) ? (ch + 'a' -'A') : ch); } -char *string_downcase(char *word) +char *string_downcase(word) +char *word; { long i = 0; while(word[i] != '\0'){ diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.h b/WWW/Library/Implementation/HTVMS_WaisUI.h index caa5d892..6f492b87 100644 --- a/WWW/Library/Implementation/HTVMS_WaisUI.h +++ b/WWW/Library/Implementation/HTVMS_WaisUI.h @@ -8,9 +8,13 @@ #ifndef HTVMSWAIS_H #define HTVMSWAIS_H -#include <HTUtils.h> +#ifndef __STDLIB_LOADED +#include <stdlib.h> +#endif /* __STDLIB_LOADED */ -void log_write PARAMS((char *)); +#define _AP(args) () + +void log_write _AP((char *)); /* ** Routines originally from Panic.h -- FM @@ -55,11 +59,11 @@ void panic (char* format,...); /* enhanced memory handling functions - don't call them directly, use the macros below */ -void fs_checkPtr PARAMS((void* ptr)); -void* fs_malloc PARAMS((size_t size)); -void* fs_realloc PARAMS((void* ptr,size_t size)); -void fs_free PARAMS((void* ptr)); -char* fs_strncat PARAMS((char* dst,char* src,size_t maxToAdd,size_t maxTotal)); +void fs_checkPtr _AP((void* ptr)); +void* fs_malloc _AP((size_t size)); +void* fs_realloc _AP((void* ptr,size_t size)); +void fs_free _AP((void* ptr)); +char* fs_strncat _AP((char* dst,char* src,size_t maxToAdd,size_t maxTotal)); /* macros for memory functions. call these in your program. */ #define s_checkPtr(ptr) fs_checkPtr(ptr) @@ -68,13 +72,13 @@ char* fs_strncat PARAMS((char* dst,char* src,size_t maxToAdd,size_t maxTotal)); #define s_free(ptr) { fs_free((char*)ptr); ptr = NULL; } #define s_strncat(dst,src,maxToAdd,maxTotal) fs_strncat((dst),(src),(maxToAdd),(maxTotal)) -char* s_strdup PARAMS((char* s)); +char* s_strdup _AP((char* s)); #define IS_DELIMITER 1 #define NOT_DELIMITER !IS_DELIMITER -char char_downcase PARAMS((unsigned long ch)); -char *string_downcase PARAMS((char* word)); +char char_downcase _AP((unsigned long ch)); +char *string_downcase _AP((char* word)); /*----------------------------------------------------------------------*/ @@ -279,71 +283,71 @@ extern char* readErrorPosition; /* pos where buf stoped making sense */ /*----------------------------------------------------------------------*/ -diagnosticRecord* makeDiag PARAMS((boolean surrogate,char* code,char* addInfo)); -void freeDiag PARAMS((diagnosticRecord* diag)); -char* writeDiag PARAMS((diagnosticRecord* diag,char* buffer,long* len)); -char* readDiag PARAMS((diagnosticRecord** diag,char* buffer)); +diagnosticRecord* makeDiag _AP((boolean surrogate,char* code,char* addInfo)); +void freeDiag _AP((diagnosticRecord* diag)); +char* writeDiag _AP((diagnosticRecord* diag,char* buffer,long* len)); +char* readDiag _AP((diagnosticRecord** diag,char* buffer)); -char* writeCompressedInteger PARAMS((unsigned long num,char* buf,long* len)); -char* readCompressedInteger PARAMS((unsigned long *num,char* buf)); -char* writeCompressedIntWithPadding PARAMS((unsigned long num,unsigned long size, +char* writeCompressedInteger _AP((unsigned long num,char* buf,long* len)); +char* readCompressedInteger _AP((unsigned long *num,char* buf)); +char* writeCompressedIntWithPadding _AP((unsigned long num,unsigned long size, char* buffer,long* len)); -unsigned long writtenCompressedIntSize PARAMS((unsigned long num)); +unsigned long writtenCompressedIntSize _AP((unsigned long num)); -char* writeTag PARAMS((data_tag tag,char* buf,long* len)); -char* readTag PARAMS((data_tag* tag,char* buf)); -data_tag peekTag PARAMS((char* buf)); -unsigned long writtenTagSize PARAMS((data_tag tag)); +char* writeTag _AP((data_tag tag,char* buf,long* len)); +char* readTag _AP((data_tag* tag,char* buf)); +data_tag peekTag _AP((char* buf)); +unsigned long writtenTagSize _AP((data_tag tag)); -any* makeAny PARAMS((unsigned long size,char* data)); -void freeAny PARAMS((any* a)); -any* duplicateAny PARAMS((any* a)); -char* writeAny PARAMS((any* a,data_tag tag,char* buffer,long* len)); -char* readAny PARAMS((any** anAny,char* buffer)); -unsigned long writtenAnySize PARAMS((data_tag tag,any* a)); +any* makeAny _AP((unsigned long size,char* data)); +void freeAny _AP((any* a)); +any* duplicateAny _AP((any* a)); +char* writeAny _AP((any* a,data_tag tag,char* buffer,long* len)); +char* readAny _AP((any** anAny,char* buffer)); +unsigned long writtenAnySize _AP((data_tag tag,any* a)); -any* stringToAny PARAMS((char* s)); -char* anyToString PARAMS((any* a)); -unsigned long writtenStringSize PARAMS((data_tag tag,char* s)); +any* stringToAny _AP((char* s)); +char* anyToString _AP((any* a)); +unsigned long writtenStringSize _AP((data_tag tag,char* s)); -any* longToAny PARAMS((long Num)); -long anyToLong PARAMS((any* a)); +any* longToAny _AP((long Num)); +long anyToLong _AP((any* a)); -char* writeString PARAMS((char* s,data_tag tag,char* buffer,long* len)); -char* readString PARAMS((char** s,char* buffer)); +char* writeString _AP((char* s,data_tag tag,char* buffer,long* len)); +char* readString _AP((char** s,char* buffer)); bit_map* makeBitMap (unsigned long numBits,...); -void freeBitMap PARAMS((bit_map* bm)); -boolean bitAtPos PARAMS((unsigned long pos,bit_map* bm)); -char* writeBitMap PARAMS((bit_map* bm,data_tag tag,char* buffer,long* len)); -char* readBitMap PARAMS((bit_map** bm,char* buffer)); +void freeBitMap _AP((bit_map* bm)); +boolean bitAtPos _AP((long pos,bit_map* bm)); +char* writeBitMap _AP((bit_map* bm,data_tag tag,char* buffer,long* len)); +char* readBitMap _AP((bit_map** bm,char* buffer)); -char* writeByte PARAMS((unsigned long byte,char* buf,long* len)); -char* readByte PARAMS((unsigned char* byte,char* buf)); +char* writeByte _AP((unsigned long byte,char* buf,long* len)); +char* readByte _AP((unsigned char* byte,char* buf)); -char* writeBoolean PARAMS((boolean flag,char* buf,long* len)); -char* readBoolean PARAMS((boolean* flag,char* buf)); +char* writeBoolean _AP((boolean flag,char* buf,long* len)); +char* readBoolean _AP((boolean* flag,char* buf)); -char* writePDUType PARAMS((pdu_type pduType,char* buf,long* len)); -char* readPDUType PARAMS((pdu_type* pduType,char* buf)); -pdu_type peekPDUType PARAMS((char* buf)); +char* writePDUType _AP((pdu_type pduType,char* buf,long* len)); +char* readPDUType _AP((pdu_type* pduType,char* buf)); +pdu_type peekPDUType _AP((char* buf)); -char* writeBinaryInteger PARAMS((long num,unsigned long size, +char* writeBinaryInteger _AP((long num,unsigned long size, char* buf,long* len)); -char* readBinaryInteger PARAMS((long* num,unsigned long size,char* buf)); -unsigned long writtenCompressedBinIntSize PARAMS((long num)); +char* readBinaryInteger _AP((long* num,unsigned long size,char* buf)); +unsigned long writtenCompressedBinIntSize _AP((long num)); -char* writeNum PARAMS((long num,data_tag tag,char* buffer,long* len)); -char* readNum PARAMS((long* num,char* buffer)); -unsigned long writtenNumSize PARAMS((data_tag tag,long num)); +char* writeNum _AP((long num,data_tag tag,char* buffer,long* len)); +char* readNum _AP((long* num,char* buffer)); +unsigned long writtenNumSize _AP((data_tag tag,long num)); -void doList PARAMS((void** list,void (*func)(void *))); +void doList _AP((void** list,void (*func)())); -char* writeProtocolVersion PARAMS((char* buf,long* len)); -char* defaultImplementationID PARAMS((void)); -char* defaultImplementationName PARAMS((void)); -char* defaultImplementationVersion PARAMS((void)); +char* writeProtocolVersion _AP((char* buf,long* len)); +char* defaultImplementationID _AP((void)); +char* defaultImplementationName _AP((void)); +char* defaultImplementationVersion _AP((void)); /*----------------------------------------------------------------------*/ @@ -458,16 +462,16 @@ typedef struct query_term { /*----------------------------------------------------------------------*/ /* functions */ -query_term* makeAttributeTerm PARAMS(( +query_term* makeAttributeTerm _AP(( char* use,char* relation,char* position,char* structure, char* truncation,char* completeness,any* term)); -query_term* makeResultSetTerm PARAMS((any* resultSet)); -query_term* makeOperatorTerm PARAMS((char* operatorCode)); -void freeTerm PARAMS((void* qt)); -char* writeQueryTerm PARAMS((query_term* qt,char* buffer,long* len)); -char* readQueryTerm PARAMS((query_term** qt,char* buffer)); -any* writeQuery PARAMS((query_term** terms)); -query_term** readQuery PARAMS((any* info)); +query_term* makeResultSetTerm _AP((any* resultSet)); +query_term* makeOperatorTerm _AP((char* operatorCode)); +void freeTerm _AP((query_term* qt)); +char* writeQueryTerm _AP((query_term* qt,char* buffer,long* len)); +char* readQueryTerm _AP((query_term** qt,char* buffer)); +any* writeQuery _AP((query_term** terms)); +query_term** readQuery _AP((any* info)); /*----------------------------------------------------------------------*/ @@ -478,7 +482,16 @@ query_term** readQuery PARAMS((any* info)); **----------------------------------------------------------------------*/ char * -generate_retrieval_apdu PARAMS((char *buff, +generate_search_apdu _AP((char* buff, /* buffer to hold the apdu */ + long *buff_len, /* number of bytes written to the buffer */ + char *seed_words, /* string of the seed words */ + char *database_name, + DocObj** docobjs, + long maxDocsRetrieved + )); + +char * +generate_retrieval_apdu _AP((char *buff, long *buff_len, any *docID, long chunk_type, @@ -488,14 +501,19 @@ generate_retrieval_apdu PARAMS((char *buff, long -interpret_message PARAMS((char *request_message, +interpret_message _AP((char *request_message, long request_length, char *response_message, long response_buffer_length, /* length of the buffer (modified)*/ - long connection, + FILE *connection, boolean verbose)); -char *trim_junk PARAMS((char *headline)); + +void +display_text_record_completely _AP((WAISDocumentText *record, + boolean quote_string_quotes)); + +char *trim_junk _AP((char *headline)); @@ -583,74 +601,74 @@ typedef struct PresentResponseAPDU { /*----------------------------------------------------------------------*/ /* Functions */ -InitAPDU* makeInitAPDU PARAMS((boolean search,boolean present,boolean deleteIt, +InitAPDU* makeInitAPDU _AP((boolean search,boolean present,boolean deleteIt, boolean accessControl,boolean resourceControl, long prefMsgSize,long maxMsgSize, char* auth,char* id,char* name, char* version, any* refID,void* userInfo)); -void freeInitAPDU PARAMS((InitAPDU* init)); -char* writeInitAPDU PARAMS((InitAPDU* init,char* buffer,long* len)); -char* readInitAPDU PARAMS((InitAPDU** init,char* buffer)); +void freeInitAPDU _AP((InitAPDU* init)); +char* writeInitAPDU _AP((InitAPDU* init,char* buffer,long* len)); +char* readInitAPDU _AP((InitAPDU** init,char* buffer)); -InitResponseAPDU* makeInitResponseAPDU PARAMS((boolean result, +InitResponseAPDU* makeInitResponseAPDU _AP((boolean result, boolean search,boolean present,boolean deleteIt, boolean accessControl,boolean resourceControl, long prefMsgSize,long maxMsgSize, char* auth,char* id,char* name, char* version, any* refID,void* userInfo)); -void freeInitResponseAPDU PARAMS((InitResponseAPDU* init)); -char* writeInitResponseAPDU PARAMS((InitResponseAPDU* init,char* buffer,long* len)); -char* readInitResponseAPDU PARAMS((InitResponseAPDU** init,char* buffer)); -InitResponseAPDU* replyToInitAPDU PARAMS((InitAPDU* init,boolean result,void* userInfo)); +void freeInitResponseAPDU _AP((InitResponseAPDU* init)); +char* writeInitResponseAPDU _AP((InitResponseAPDU* init,char* buffer,long* len)); +char* readInitResponseAPDU _AP((InitResponseAPDU** init,char* buffer)); +InitResponseAPDU* replyToInitAPDU _AP((InitAPDU* init,boolean result,void* userInfo)); -SearchAPDU* makeSearchAPDU PARAMS((long small,long large, long medium, +SearchAPDU* makeSearchAPDU _AP((long small,long large, long medium, boolean replace,char* name,char** databases, char* type,char** elements,any* refID,void* queryInfo)); -void freeSearchAPDU PARAMS((SearchAPDU* query)); -char* writeSearchAPDU PARAMS((SearchAPDU* query,char* buffer,long* len)); -char* readSearchAPDU PARAMS((SearchAPDU** query,char* buffer)); +void freeSearchAPDU _AP((SearchAPDU* query)); +char* writeSearchAPDU _AP((SearchAPDU* query,char* buffer,long* len)); +char* readSearchAPDU _AP((SearchAPDU** query,char* buffer)); -SearchResponseAPDU* makeSearchResponseAPDU PARAMS((long result,long count, +SearchResponseAPDU* makeSearchResponseAPDU _AP((long result,long count, long recordsReturned,long nextPos, long resultStatus,long presentStatus, any* refID,void* records)); -void freeSearchResponseAPDU PARAMS((SearchResponseAPDU* queryResponse)); -char* writeSearchResponseAPDU PARAMS((SearchResponseAPDU* queryResponse,char* buffer,long* len)); -char* readSearchResponseAPDU PARAMS((SearchResponseAPDU** queryResponse,char* buffer)); +void freeSearchResponseAPDU _AP((SearchResponseAPDU* queryResponse)); +char* writeSearchResponseAPDU _AP((SearchResponseAPDU* queryResponse,char* buffer,long* len)); +char* readSearchResponseAPDU _AP((SearchResponseAPDU** queryResponse,char* buffer)); -PresentAPDU* makePresentAPDU PARAMS((long recsReq, long startPos, +PresentAPDU* makePresentAPDU _AP((long recsReq, long startPos, char* resultID,any* refID,void* info)); -void freePresentAPDU PARAMS((PresentAPDU* present)); -char* writePresentAPDU PARAMS((PresentAPDU* present,char* buffer,long* len)); -char* readPresentAPDU PARAMS((PresentAPDU** present,char* buffer)); +void freePresentAPDU _AP((PresentAPDU* present)); +char* writePresentAPDU _AP((PresentAPDU* present,char* buffer,long* len)); +char* readPresentAPDU _AP((PresentAPDU** present,char* buffer)); -PresentResponseAPDU* makePresentResponseAPDU PARAMS((boolean status,long recsRet, +PresentResponseAPDU* makePresentResponseAPDU _AP((boolean status,long recsRet, long nextPos,any* refID, void* records)); -void freePresentResponseAPDU PARAMS((PresentResponseAPDU* present)); -char* writePresentResponseAPDU PARAMS((PresentResponseAPDU* present,char* buffer,long* len)); -char* readPresentResponseAPDU PARAMS((PresentResponseAPDU** present,char* buffer)); +void freePresentResponseAPDU _AP((PresentResponseAPDU* present)); +char* writePresentResponseAPDU _AP((PresentResponseAPDU* present,char* buffer,long* len)); +char* readPresentResponseAPDU _AP((PresentResponseAPDU** present,char* buffer)); /*----------------------------------------------------------------------*/ /* user extension hooks: */ -extern char* writeInitInfo PARAMS((InitAPDU* init,char* buffer,long* len)); -extern char* readInitInfo PARAMS((void** info,char* buffer)); +extern char* writeInitInfo _AP((InitAPDU* init,char* buffer,long* len)); +extern char* readInitInfo _AP((void** info,char* buffer)); -extern char* writeInitResponseInfo PARAMS((InitResponseAPDU* init,char* buffer,long* len)); -extern char* readInitResponseInfo PARAMS((void** info,char* buffer)); +extern char* writeInitResponseInfo _AP((InitResponseAPDU* init,char* buffer,long* len)); +extern char* readInitResponseInfo _AP((void** info,char* buffer)); -extern char* writeSearchInfo PARAMS((SearchAPDU* query,char* buffer,long* len)); -extern char* readSearchInfo PARAMS((void** info,char* buffer)); +extern char* writeSearchInfo _AP((SearchAPDU* query,char* buffer,long* len)); +extern char* readSearchInfo _AP((void** info,char* buffer)); -extern char* writeSearchResponseInfo PARAMS((SearchResponseAPDU* query,char* buffer,long* len)); -extern char* readSearchResponseInfo PARAMS((void** info,char* buffer)); +extern char* writeSearchResponseInfo _AP((SearchResponseAPDU* query,char* buffer,long* len)); +extern char* readSearchResponseInfo _AP((void** info,char* buffer)); -extern char* writePresentInfo PARAMS((PresentAPDU* present,char* buffer,long* len)); -extern char* readPresentInfo PARAMS((void** info,char* buffer)); +extern char* writePresentInfo _AP((PresentAPDU* present,char* buffer,long* len)); +extern char* readPresentInfo _AP((void** info,char* buffer)); -extern char* writePresentResponseInfo PARAMS((PresentResponseAPDU* present,char* buffer,long* len)); -extern char* readPresentResponseInfo PARAMS((void** info,char* buffer)); +extern char* writePresentResponseInfo _AP((PresentResponseAPDU* present,char* buffer,long* len)); +extern char* readPresentResponseInfo _AP((void** info,char* buffer)); #endif /* HTVMSWAIS_H */ diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c index 81d7239a..627086ab 100644 --- a/WWW/Library/Implementation/HTWAIS.c +++ b/WWW/Library/Implementation/HTWAIS.c @@ -49,6 +49,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTParse.h> #include <HTAccess.h> /* We implement a protocol */ #include <HTML.h> /* The object we will generate */ @@ -77,6 +78,10 @@ */ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + +extern int HTCheckForInterrupt NOPARAMS; + #define DIRECTORY "/cnidr.org:210/directory-of-servers" /* #define DIRECTORY "/quake.think.com:210/directory-of-servers" */ @@ -267,20 +272,22 @@ PRIVATE char * WWW_from_WAIS ARGS1( int i, l; if (TRACE) { char *p; - fprintf(tfp, "WAIS id (%d bytes) is ", (int)docid->size); + fprintf(stderr, "WAIS id (%d bytes) is ", (int)docid->size); for (p = docid->bytes; p < docid->bytes+docid->size; p++) { if ((*p >= ' ') && (*p<= '~')) /* Assume ASCII! */ - fprintf(tfp, "%c", *p); + fprintf(stderr, "%c", *p); else - fprintf(tfp, "<%x>", (unsigned)*p); + fprintf(stderr, "<%x>", (unsigned)*p); } - fprintf(tfp, "\n"); + fprintf(stderr, "\n"); } for (p = docid->bytes; (p < docid->bytes+docid->size) && (q < &buf[BIG]);) { - CTRACE(tfp, " Record type %d, length %d\n", p[0], p[1]); + if (TRACE) + fprintf(stderr, " Record type %d, length %d\n", p[0], p[1]); if (*p > 10) { - CTRACE(tfp, "Eh? DOCID record type of %d!\n", *p); + if (TRACE) + fprintf(stderr, "Eh? DOCID record type of %d!\n", *p); return 0; } { /* Bug fix -- allow any byte value 15 Apr 93 */ @@ -309,7 +316,8 @@ PRIVATE char * WWW_from_WAIS ARGS1( *q++= ';'; /* Terminate field */ } *q++ = 0; /* Terminate string */ - CTRACE(tfp, "WWW form of id: %s\n", buf); + if (TRACE) + fprintf(stderr, "WWW form of id: %s\n", buf); { char * result = (char *)malloc(strlen(buf)+1); if (!result) @@ -339,8 +347,8 @@ PRIVATE any * WAIS_from_WWW ARGS2( char *q; /* Poisition of "=" */ char *s; /* Position of semicolon */ int n; /* size */ - - CTRACE(tfp, "WWW id (to become WAIS id): %s\n", docname); + if (TRACE) + fprintf(stderr, "WWW id (to become WAIS id): %s\n", docname); for (n = 0, p = docname; *p; p++) { /* Count sizes of strings */ n++; if (*p == ';') @@ -396,14 +404,14 @@ PRIVATE any * WAIS_from_WWW ARGS2( if (TRACE) { char *p; - fprintf(tfp, "WAIS id (%d bytes) is ", (int)docid->size); + fprintf(stderr, "WAIS id (%d bytes) is ", (int)docid->size); for (p = docid->bytes; p < docid->bytes+docid->size; p++) { if ((*p >= ' ') && (*p<= '~')) /* Assume ASCII! */ - fprintf(tfp, "%c", *p); + fprintf(stderr, "%c", *p); else - fprintf(tfp, "<%x>", (unsigned)*p); + fprintf(stderr, "<%x>", (unsigned)*p); } - fprintf(tfp, "\n"); + fprintf(stderr, "\n"); } return docid; /* Ok */ @@ -465,7 +473,8 @@ PRIVATE void display_search_response ARGS4( BOOL archie = strstr(database, "archie")!=0; /* Specical handling */ - CTRACE(tfp, "HTWAIS: Displaying search response\n"); + if (TRACE) + fprintf(stderr, "HTWAIS: Displaying search response\n"); PUTS("Index "); START(HTML_EM); PUTS(database); @@ -503,7 +512,9 @@ PRIVATE void display_search_response ARGS4( /* ** Make a printable string out of the document id. */ - CTRACE(tfp, "HTWAIS: %2ld: Score: %4ld, lines:%4ld '%s'\n", + if (TRACE) + fprintf(stderr, + "HTWAIS: %2ld: Score: %4ld, lines:%4ld '%s'\n", i, (long int)(info->DocHeaders[k]->Score), (long int)(info->DocHeaders[k]->Lines), @@ -695,7 +706,8 @@ PUBLIC int HTLoadWAIS ARGS4( if (!ok) return HTLoadError(sink, 500, "Syntax error in WAIS URL"); - CTRACE(tfp, "HTWAIS: Parsed OK\n"); + if (TRACE) + fprintf(stderr, "HTWAIS: Parsed OK\n"); service = strchr(names, ':'); if (service) @@ -712,16 +724,19 @@ PUBLIC int HTLoadWAIS ARGS4( } else if (!(key && !*key)) { int status; - CTRACE (tfp, "===WAIS=== calling mosaic_connect_to_server\n"); + if (TRACE) + fprintf (stderr, "===WAIS=== calling mosaic_connect_to_server\n"); status = mosaic_connect_to_server(server_name, atoi(service), &connection); if (status == 0) { - CTRACE (tfp, "===WAIS=== connection failed\n"); + if (TRACE) + fprintf (stderr, "===WAIS=== connection failed\n"); FREE(names); return HT_NOT_LOADED; } else if (status == -1) { - CTRACE (tfp, "===WAIS=== connection interrupted\n"); + if (TRACE) + fprintf (stderr, "===WAIS=== connection interrupted\n"); FREE(names); return HT_NOT_LOADED; } @@ -794,9 +809,10 @@ PUBLIC int HTLoadWAIS ARGS4( server_name, service, www_database); fp = fopen(filename, "r"); /* Have we found this already? */ - CTRACE(tfp, "HTWAIS: Description of server %s %s.\n", - filename, - fp ? "exists already" : "does NOT exist!"); + if (TRACE) fprintf(stderr, + "HTWAIS: Description of server %s %s.\n", + filename, + fp ? "exists already" : "does NOT exist!"); if (fp) { char c; @@ -805,7 +821,6 @@ PUBLIC int HTLoadWAIS ARGS4( while((c=getc(fp))!=EOF) PUTC(c); /* Transfer file */ END(HTML_PRE); fclose(fp); - } #endif START(HTML_P); PUTS("\nEnter the 's'earch command and then specify search words.\n"); @@ -850,8 +865,8 @@ PUBLIC int HTLoadWAIS ARGS4( PUTS("\n"); request_buffer_length = MAX_MESSAGE_LEN; /* Amount left */ - CTRACE(tfp, "HTWAIS: Search for `%s' in `%s'\n", - keywords, wais_database); + if (TRACE) fprintf(stderr, "HTWAIS: Search for `%s' in `%s'\n", + keywords, wais_database); if(NULL == generate_search_apdu(request_message + HEADER_LENGTH, &request_buffer_length, @@ -909,8 +924,9 @@ PUBLIC int HTLoadWAIS ARGS4( any doc_chunk; any * docid = &doc_chunk; - CTRACE(tfp, "HTWAIS: Retrieve document id `%s' type `%s' length %ld\n", - docname, doctype, document_length); + if (TRACE) fprintf(stderr, + "HTWAIS: Retrieve document id `%s' type `%s' length %ld\n", + docname, doctype, document_length); format_in = !strcmp(doctype, "WSRC") ? HTAtom_for("application/x-wais-source") : @@ -946,7 +962,8 @@ PUBLIC int HTLoadWAIS ARGS4( char *type = s_strdup(doctype); /* Gets freed I guess */ #endif /* VMS */ request_buffer_length = MAX_MESSAGE_LEN; /* Amount left */ - CTRACE(tfp, "HTWAIS: Slice number %ld\n", count); + if (TRACE) + fprintf(stderr, "HTWAIS: Slice number %ld\n", count); if (HTCheckForInterrupt()) { HTAlert ("Data transfer interrupted."); diff --git a/WWW/Library/Implementation/HTWAIS.h b/WWW/Library/Implementation/HTWAIS.h index e8a6b7f2..fe203ef9 100644 --- a/WWW/Library/Implementation/HTWAIS.h +++ b/WWW/Library/Implementation/HTWAIS.h @@ -25,6 +25,9 @@ #ifndef HTWAIS_H #define HTWAIS_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTAccess.h> #ifdef GLOBALREF_IS_MACRO diff --git a/WWW/Library/Implementation/HTWSRC.c b/WWW/Library/Implementation/HTWSRC.c index 8b764a73..baf759c9 100644 --- a/WWW/Library/Implementation/HTWSRC.c +++ b/WWW/Library/Implementation/HTWSRC.c @@ -9,6 +9,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTWSRC.h> @@ -18,6 +19,8 @@ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + #define BIG 10000 /* Arbitrary limit to value length */ #define PARAM_MAX BIG #define CACHE_PERIOD (7*86400) /* Time to keep .src file in seconds */ @@ -159,8 +162,9 @@ PRIVATE void WSRCParser_put_character ARGS2(HTStream*, me, char, c) } } if (!par_name[me->param_number]) { /* Unknown field */ - CTRACE(tfp, "HTWSRC: Unknown field `%s' in source file\n", - me->param); + if (TRACE) fprintf(stderr, + "HTWSRC: Unknown field `%s' in source file\n", + me->param); me->param_number = PAR_UNKNOWN; me->state = before_value; /* Could be better ignore */ return; diff --git a/WWW/Library/Implementation/HTWSRC.h b/WWW/Library/Implementation/HTWSRC.h index 62617022..cde25467 100644 --- a/WWW/Library/Implementation/HTWSRC.h +++ b/WWW/Library/Implementation/HTWSRC.h @@ -11,6 +11,10 @@ #ifndef HTWSRC_H #define HTWSRC_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ + #include <HTFormat.h> extern char from_hex PARAMS((char c)); diff --git a/WWW/Library/Implementation/HTWriter.c b/WWW/Library/Implementation/HTWriter.c index c4dba35b..601bdb0a 100644 --- a/WWW/Library/Implementation/HTWriter.c +++ b/WWW/Library/Implementation/HTWriter.c @@ -2,15 +2,19 @@ ** =========== ** */ - #include <HTUtils.h> +#include <tcp.h> #include <HTWriter.h> #define BUFFER_SIZE 4096 /* Tradeoff */ +/*#include <stdio.h> included by HTUtils.h -- FM */ + #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* HTML Object ** ----------- */ @@ -48,7 +52,8 @@ PRIVATE void flush ARGS1(HTStream *, me) status = NETWRITE(me->soc, me->buffer, /* Put timeout? @@@ */ write_pointer - read_pointer); if (status<0) { - CTRACE(tfp, "HTWrite: Error: write() on socket returns %d !!!\n", status); + if(TRACE) fprintf(stderr, + "HTWrite: Error: write() on socket returns %d !!!\n", status); return; } read_pointer = read_pointer + status; @@ -103,7 +108,8 @@ PRIVATE void HTWriter_write ARGS3(HTStream *, me, CONST char*, s, int, l) int status = NETWRITE(me->soc, (char *)read_pointer, write_pointer - read_pointer); if (status<0) { - CTRACE(tfp, "HTWriter_write: Error on socket output stream!!!\n"); + if(TRACE) fprintf(stderr, + "HTWriter_write: Error on socket output stream!!!\n"); return; } read_pointer = read_pointer + status; diff --git a/WWW/Library/Implementation/LYLeaks.h b/WWW/Library/Implementation/LYLeaks.h index 19fc69f4..91bfbaac 100644 --- a/WWW/Library/Implementation/LYLeaks.h +++ b/WWW/Library/Implementation/LYLeaks.h @@ -41,6 +41,7 @@ /* ** Required includes */ +#include <stdlib.h> #include <HTUtils.h> /* diff --git a/WWW/Library/Implementation/LYexit.h b/WWW/Library/Implementation/LYexit.h index f53561a4..93bc8070 100644 --- a/WWW/Library/Implementation/LYexit.h +++ b/WWW/Library/Implementation/LYexit.h @@ -19,6 +19,7 @@ /* * Required includes */ +#include <stdlib.h> #include <HTUtils.h> /* diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c index 7f6324a0..91c1b00d 100644 --- a/WWW/Library/Implementation/SGML.c +++ b/WWW/Library/Implementation/SGML.c @@ -4,12 +4,13 @@ ** This module implements an HTStream object. To parse an ** SGML file, create this object which is a parser. The object ** is (currently) created by being passed a DTD structure, -** and a target HTStructured object at which to throw the parsed stuff. +** and a target HTStructured oject at which to throw the parsed stuff. ** -** 6 Feb 93 Binary searches used. Interface modified. +** 6 Feb 93 Binary seraches used. Intreface modified. */ #include <HTUtils.h> +#include <tcp.h> /* For FROMASCII */ /* Remove the following to disable the experimental HTML DTD parsing. Currently only used in this source file. - kw */ @@ -25,21 +26,24 @@ #include <UCDefs.h> #include <UCAux.h> +#include <ctype.h> +/*#include <stdio.h> included in HTUtils.h -- FM */ #include <HTChunk.h> #include <LYCharSets.h> -#include <LYStrings.h> #include <LYLeaks.h> #define INVALID (-1) +#define FREE(x) if (x) {free(x); x = NULL;} + PUBLIC HTCJKlang HTCJK = NOCJK; /* CJK enum value. */ PUBLIC BOOL HTPassEightBitRaw = FALSE; /* Pass 161-172,174-255 raw. */ PUBLIC BOOL HTPassEightBitNum = FALSE; /* Pass ^ numeric entities raw. */ PUBLIC BOOL HTPassHighCtrlRaw = FALSE; /* Pass 127-160,173, raw. */ PUBLIC BOOL HTPassHighCtrlNum = FALSE; /* Pass €-Ÿ raw. */ -/* extern int LYlowest_eightbit[]; for completeness here */ +extern int LYlowest_eightbit[]; /* The State (context) of the parser ** @@ -52,7 +56,7 @@ PUBLIC BOOL HTPassHighCtrlNum = FALSE; /* Pass €-Ÿ raw. */ /* Element Stack ** ------------- -** This allows us to return down the stack reselecting styles. +** This allows us to return down the stack reselcting styles. ** As we return, attribute values will be garbage in general. */ typedef struct _HTElement HTElement; @@ -70,7 +74,7 @@ struct _HTStream { CONST HTStreamClass * isa; /* inherited from HTStream */ CONST SGML_dtd *dtd; - CONST HTStructuredClass *actions; /* target class */ + HTStructuredClass *actions; /* target class */ HTStructured *target; /* target object */ HTTag *current_tag; @@ -196,7 +200,7 @@ PRIVATE void set_chartrans_handling ARGS3( context->T.trans_from_uni) { context->current_tag_charset = UCGetLYhndl_byMIME("utf-8"); } else { - context->current_tag_charset = LATIN1; + context->current_tag_charset = 0; } } @@ -278,15 +282,17 @@ PRIVATE void handle_attribute_name ARGS2( FREE(context->value[i]); #ifdef USE_COLOR_STYLE current_is_class=(!strcasecomp("class", s)); - CTRACE(tfp, "SGML: found attribute %s, %d\n", s, current_is_class); + if (TRACE) + fprintf(stderr, "SGML: found attribute %s, %d\n", s, current_is_class); #endif return; } /* if */ } /* for */ - CTRACE(tfp, "SGML: Unknown attribute %s for tag %s\n", - s, context->current_tag->name); + if (TRACE) + fprintf(stderr, "SGML: Unknown attribute %s for tag %s\n", + s, context->current_tag->name); context->current_attribute_number = INVALID; /* Invalid */ } @@ -304,15 +310,18 @@ PRIVATE void handle_attribute_value ARGS2( if (current_is_class) { strncpy (class_string, s, TEMPSTRINGSIZE); - CTRACE(tfp, "SGML: class is '%s'\n", s); + if (TRACE) + fprintf(stderr, "SGML: class is '%s'\n", s); } else { - CTRACE(tfp, "SGML: attribute value is '%s'\n", s); + if (TRACE) + fprintf(stderr, "SGML: attribute value is '%s'\n", s); } #endif } else { - CTRACE(tfp, "SGML: Attribute value %s ignored\n", s); + if (TRACE) + fprintf(stderr, "SGML: Attribute value %s ignored\n", s); } context->current_attribute_number = INVALID; /* can't have two assignments! */ } @@ -322,10 +331,9 @@ PRIVATE void handle_attribute_value ARGS2( ** Translate some Unicodes to Lynx special codes and output them. ** Special codes - ones those output depend on parsing. ** -** Additional issue, like handling bidirectional text if necessary +** Additional issue, like handling bidirectional text if nesseccery ** may be called from here: zwnj (8204), zwj (8205), lrm (8206), rlm (8207) -** - currently they are ignored in SGML.c and LYCharUtils.c -** but also in UCdomap.c because they are non printable... +** - currently they are passed to def7_uni.tbl as regular characters. ** */ PRIVATE BOOL put_special_unicodes ARGS2( @@ -353,7 +361,10 @@ PRIVATE BOOL put_special_unicodes ARGS2( ** in the context of line wrapping. Unfortunately, if we use ** HT_EM_SPACE we override the chartrans tables for those spaces ** (e.g., emsp= double space) with a single '32' for all (but do line - ** wrapping more fancy). So we probably need HT_EN_SPACE etc... + ** wrapping more fancy). In the future we need HT_SPACE with a + ** transferred parameter (Unicode number) which falls back to + ** chartrans if line wrapping is not the case. + ** */ PUTC(HT_EM_SPACE); #ifdef NOTUSED_FOTEMODS @@ -392,6 +403,11 @@ PRIVATE BOOL put_special_unicodes ARGS2( PRIVATE char replace_buf [64]; /* buffer for replacement strings */ PRIVATE BOOL FoundEntity = FALSE; +#define IncludesLatin1Enc \ + (context->outUCLYhndl == 0 || \ + (context->outUCI && \ + (context->outUCI->enc & (UCT_CP_SUPERSETOF_LAT1)))) + PRIVATE void handle_entity ARGS2( HTStream *, context, char, term) @@ -400,6 +416,9 @@ PRIVATE void handle_entity ARGS2( long uck; CONST char *p; CONST char *s = context->string->data; +#ifdef NOTUSED_FOTEMODS + int high, low, i, diff; +#endif /* @@ -453,32 +472,89 @@ PRIVATE void handle_entity ARGS2( FoundEntity = TRUE; return; } +#ifdef NOTUSED_FOTEMODS /* - ** Ignore zwnj (8204) and zwj (8205), if we get to here. - ** Note that zwnj may have been handled as <WBR> - ** by the calling function. - FM + ** If the value is greater than 255 and we do not + ** have the "7-bit approximations" as our output + ** character set (in which case we did it already) + ** seek a translation for that. - FM */ - if (!strcmp(s, "zwnj") || - !strcmp(s, "zwj")) { - CTRACE(tfp, "handle_entity: Ignoring '%s'.\n", s); + if ((chk = ((code > 255) && + context->outUCLYhndl != + UCGetLYhndl_byMIME("us-ascii"))) && + (uck = UCTransUniChar(code, + UCGetLYhndl_byMIME("us-ascii")))>= 32 && + uck < 127) { + /* + ** Got an ASCII character (yippey). - FM + */ + PUTC(((char)(uck & 0xff))); + FoundEntity = TRUE; + return; + } else if ((chk && uck == -4) && + (uck = UCTransUniCharStr(replace_buf, + 60, code, + UCGetLYhndl_byMIME("us-ascii"), + 0) >= 0)) { + /* + ** Got a replacement string (yippey). - FM + */ + for (p = replace_buf; *p; p++) + PUTC(*p); FoundEntity = TRUE; return; } - /* - ** Ignore lrm (8206), and rln (8207), if we get to here. - FM - */ - if (!strcmp(s, "lrm") || - !strcmp(s, "rlm")) { - CTRACE(tfp, "handle_entity: Ignoring '%s'.\n", s); + } + /* + ** Ignore zwnj (8204) and zwj (8205), if we get to here. + ** Note that zwnj may have been handled as <WBR> + ** by the calling function. - FM + */ + if (!strcmp(s, "zwnj") || + !strcmp(s, "zwj")) { + if (TRACE) { + fprintf(stderr, "handle_entity: Ignoring '%s'.\n", s); + } + FoundEntity = TRUE; + return; + } + + /* + ** Ignore lrm (8206), and rln (8207), if we get to here. - FM + */ + if (!strcmp(s, "lrm") || + !strcmp(s, "rlm")) { + if (TRACE) { + fprintf(stderr, "handle_entity: Ignoring '%s'.\n", s); + } + FoundEntity = TRUE; + return; + } + + /* + ** We haven't succeeded yet, so try the old LYCharSets + ** arrays for translation strings. - FM + */ + for (low = 0, high = context->dtd->number_of_entities; + high > low; + diff < 0 ? (low = i+1) : (high = i)) { /* Binary search */ + i = (low + (high-low)/2); + diff = strcmp(entities[i], s); /* Case sensitive! */ + if (diff == 0) { /* success: found it */ + for (p = LYCharSets[context->outUCLYhndl][i]; *p; p++) { + PUTC(*p); + } FoundEntity = TRUE; return; } +#endif } /* ** If entity string not found, display as text. */ - CTRACE(tfp, "SGML: Unknown entity '%s'\n", s); + if (TRACE) + fprintf(stderr, "SGML: Unknown entity '%s'\n", s); PUTC('&'); for (p = s; *p; p++) { PUTC(*p); @@ -496,7 +572,8 @@ PRIVATE void handle_comment ARGS1( { CONST char *s = context->string->data; - CTRACE(tfp, "SGML Comment:\n<%s>\n", s); + if (TRACE) + fprintf(stderr, "SGML Comment:\n<%s>\n", s); if (context->csi == NULL && strncmp(s, "!--#", 4) == 0 && @@ -516,7 +593,8 @@ PRIVATE void handle_identifier ARGS1( { CONST char *s = context->string->data; - CTRACE(tfp, "SGML Identifier\n<%s>\n", s); + if (TRACE) + fprintf(stderr, "SGML Identifier\n<%s>\n", s); return; } @@ -530,7 +608,8 @@ PRIVATE void handle_doctype ARGS1( { CONST char *s = context->string->data; - CTRACE(tfp, "SGML Doctype\n<%s>\n", s); + if (TRACE) + fprintf(stderr, "SGML Doctype\n<%s>\n", s); return; } @@ -544,7 +623,8 @@ PRIVATE void handle_marked ARGS1( { CONST char *s = context->string->data; - CTRACE(tfp, "SGML Marked Section:\n<%s>\n", s); + if (TRACE) + fprintf(stderr, "SGML Marked Section:\n<%s>\n", s); return; } @@ -558,7 +638,8 @@ PRIVATE void handle_sgmlent ARGS1( { CONST char *s = context->string->data; - CTRACE(tfp, "SGML Entity Declaration:\n<%s>\n", s); + if (TRACE) + fprintf(stderr, "SGML Entity Declaration:\n<%s>\n", s); return; } @@ -572,7 +653,8 @@ PRIVATE void handle_sgmlele ARGS1( { CONST char *s = context->string->data; - CTRACE(tfp, "SGML Element Declaration:\n<%s>\n", s); + if (TRACE) + fprintf(stderr, "SGML Element Declaration:\n<%s>\n", s); return; } @@ -586,7 +668,8 @@ PRIVATE void handle_sgmlatt ARGS1( { CONST char *s = context->string->data; - CTRACE(tfp, "SGML Attribute Declaration:\n<%s>\n", s); + if (TRACE) + fprintf(stderr, "SGML Attribute Declaration:\n<%s>\n", s); return; } @@ -633,7 +716,6 @@ PRIVATE canclose_t can_close ARGS2( return ((stacked_tag->tagclass & new_tag->canclose) ? close_error : close_NO); } - PRIVATE void do_close_stacked ARGS1( HTStream *, context) { @@ -650,7 +732,6 @@ PRIVATE void do_close_stacked ARGS1( context->element_stack = stacked->next; FREE(stacked); } - PRIVATE int is_on_stack ARGS2( HTStream *, context, HTTag *, old_tag) @@ -684,7 +765,8 @@ PRIVATE void end_element ARGS2( (stackpos > 1 || (!extra_action_taken && stackpos == 0))) { canclose_check = can_close(old_tag, context->element_stack->tag); if (canclose_check != close_NO) { - CTRACE(tfp, "SGML: End </%s> \t<- %s end </%s>\n", + if (TRACE) + fprintf(stderr, "SGML: End </%s> \t<- %s end </%s>\n", context->element_stack->tag->name, canclose_check == close_valid ? "supplied," : "forced by", old_tag->name); @@ -692,7 +774,8 @@ PRIVATE void end_element ARGS2( extra_action_taken = YES; stackpos = is_on_stack(context, old_tag); } else { - CTRACE(tfp, "SGML: Still open %s \t<- invalid end </%s>\n", + if (TRACE) + fprintf(stderr, "SGML: Still open %s \t<- invalid end </%s>\n", context->element_stack->tag->name, old_tag->name); return; @@ -700,7 +783,8 @@ PRIVATE void end_element ARGS2( } if (stackpos == 0 && old_tag->contents != SGML_EMPTY) { - CTRACE(tfp, "SGML: Still open %s, no open %s for </%s>\n", + if (TRACE) + fprintf(stderr, "SGML: Still open %s, no open %s for </%s>\n", context->element_stack ? context->element_stack->tag->name : "none", old_tag->name, @@ -708,7 +792,8 @@ PRIVATE void end_element ARGS2( return; } if (stackpos > 1) { - CTRACE(tfp, "SGML: Nesting <%s>...<%s> \t<- invalid end </%s>\n", + if (TRACE) + fprintf(stderr, "SGML: Nesting <%s>...<%s> \t<- invalid end </%s>\n", old_tag->name, context->element_stack->tag->name, old_tag->name); @@ -733,36 +818,42 @@ PRIVATE void end_element ARGS2( /* ** Ignore the end tag. - FM */ - CTRACE(tfp, "SGML: Ignoring end tag </%s> in SELECT block.\n", + if (TRACE) { + fprintf(stderr, + "SGML: Ignoring end tag </%s> in SELECT block.\n", old_tag->name); + } return; } } /* ** Handle the end tag. - FM */ - CTRACE(tfp, "SGML: End </%s>\n", old_tag->name); + if (TRACE) + fprintf(stderr, "SGML: End </%s>\n", old_tag->name); if (old_tag->contents == SGML_EMPTY) { - CTRACE(tfp, "SGML: Illegal end tag </%s> found.\n", - old_tag->name); + if (TRACE) + fprintf(stderr, "SGML: Illegal end tag </%s> found.\n", + old_tag->name); return; } #ifdef WIND_DOWN_STACK - while (context->element_stack) /* Loop is error path only */ + while (context->element_stack) { /* Loop is error path only */ #else - if (context->element_stack) /* Substitute and remove one stack element */ + if (context->element_stack) { /* Substitute and remove one stack element */ #endif /* WIND_DOWN_STACK */ - { HTElement * N = context->element_stack; HTTag * t = N->tag; if (old_tag != t) { /* Mismatch: syntax error */ if (context->element_stack->next) { /* This is not the last level */ - CTRACE(tfp, "SGML: Found </%s> when expecting </%s>. </%s> assumed.\n", - old_tag->name, t->name, t->name); + if (TRACE) fprintf(stderr, + "SGML: Found </%s> when expecting </%s>. </%s> assumed.\n", + old_tag->name, t->name, t->name); } else { /* last level */ - CTRACE(tfp, "SGML: Found </%s> when expecting </%s>. </%s> Ignored.\n", - old_tag->name, t->name, old_tag->name); + if (TRACE) fprintf(stderr, + "SGML: Found </%s> when expecting </%s>. </%s> Ignored.\n", + old_tag->name, t->name, old_tag->name); return; /* Ignore */ } } @@ -781,8 +872,9 @@ PRIVATE void end_element ARGS2( /* Syntax error path only */ } - CTRACE(tfp, "SGML: Extra end tag </%s> found and ignored.\n", - old_tag->name); + if (TRACE) + fprintf(stderr, "SGML: Extra end tag </%s> found and ignored.\n", + old_tag->name); } @@ -809,7 +901,8 @@ PRIVATE void start_element ARGS1( direct_container))) { canclose_check = can_close(new_tag, context->element_stack->tag); if (canclose_check != close_NO) { - CTRACE(tfp, "SGML: End </%s> \t<- %s start <%s>\n", + if (TRACE) + fprintf(stderr, "SGML: End </%s> \t<- %s start <%s>\n", context->element_stack->tag->name, canclose_check == close_valid ? "supplied," : "forced by", new_tag->name); @@ -818,7 +911,8 @@ PRIVATE void start_element ARGS1( if (canclose_check == close_error) direct_container = NO; } else { - CTRACE(tfp, "SGML: Still open %s \t<- invalid start <%s>\n", + if (TRACE) + fprintf(stderr, "SGML: Still open %s \t<- invalid start <%s>\n", context->element_stack->tag->name, new_tag->name); } @@ -827,7 +921,8 @@ PRIVATE void start_element ARGS1( (context->element_stack->tag->flags & Tgf_strict) && !(valid = element_valid_within(new_tag, context->element_stack->tag, direct_container))) { - CTRACE(tfp, "SGML: Still open %s \t<- ignoring start <%s>\n", + if (TRACE) + fprintf(stderr, "SGML: Still open %s \t<- ignoring start <%s>\n", context->element_stack->tag->name, new_tag->name); return; @@ -840,7 +935,8 @@ PRIVATE void start_element ARGS1( for (; i< new_tag->number_of_attributes && !has_attributes; i++) has_attributes = context->present[i]; if (!has_attributes) { - CTRACE(tfp, "SGML: Still open %s, converting invalid <%s> to </%s>\n", + if (TRACE) + fprintf(stderr, "SGML: Still open %s, converting invalid <%s> to </%s>\n", context->element_stack->tag->name, new_tag->name, new_tag->name); @@ -855,7 +951,8 @@ PRIVATE void start_element ARGS1( new_tag, context->element_stack->tag, direct_container))) { - CTRACE(tfp, "SGML: Still open %s \t<- invalid start <%s>\n", + if (TRACE) + fprintf(stderr, "SGML: Still open %s \t<- invalid start <%s>\n", context->element_stack->tag->name, new_tag->name); } @@ -901,14 +998,18 @@ PRIVATE void start_element ARGS1( ** It is another form-related start tag, so terminate ** the current SELECT block and fall through. - FM */ - CTRACE(tfp, "SGML: Faking SELECT end tag before <%s> start tag.\n", + if (TRACE) + fprintf(stderr, + "SGML: Faking SELECT end tag before <%s> start tag.\n", new_tag->name); end_element(context, SGMLFindTag(context->dtd, "SELECT")); } else { /* ** Ignore the start tag. - FM */ - CTRACE(tfp, "SGML: Ignoring start tag <%s> in SELECT block.\n", + if (TRACE) + fprintf(stderr, + "SGML: Ignoring start tag <%s> in SELECT block.\n", new_tag->name); return; } @@ -917,7 +1018,8 @@ PRIVATE void start_element ARGS1( /* ** Handle the start tag. - FM */ - CTRACE(tfp, "SGML: Start <%s>\n", new_tag->name); + if (TRACE) + fprintf(stderr, "SGML: Start <%s>\n", new_tag->name); (*context->actions->start_element)( context->target, new_tag - context->dtd->tags, @@ -945,7 +1047,7 @@ PRIVATE void start_element ARGS1( ** ------------------------ ** ** On entry, -** dtd points to dtd structure including valid tag list +** dtd points to dtd structire including valid tag list ** string points to name of tag in question ** ** On exit, @@ -971,7 +1073,7 @@ PUBLIC HTTag * SGMLFindTag ARGS2( /* ** Unrecognized, but may be valid. - KW */ - return &HTTag_unrecognized; + return (HTTag *)&HTTag_unrecognized; } return NULL; } @@ -1097,7 +1199,7 @@ PRIVATE void SGML_character ARGS2( CONST char * EntityName; char * p; BOOLEAN chk; /* Helps (?) walk through all the else ifs... */ - UCode_t clong, uck = 0; /* Enough bits for UCS4 ... */ + UCode_t clong, uck; /* Enough bits for UCS4 ... */ char c; char saved_char_in = '\0'; @@ -1206,7 +1308,7 @@ PRIVATE void SGML_character ARGS2( ** to Unicode, try that now. - FM */ if (context->T.trans_to_uni && - ((unsign_c >= LYlowest_eightbit[context->inUCLYhndl]) || + ((unsign_c >= 127) || (unsign_c < 32 && unsign_c != 0 && context->T.trans_C0_to_uni))) { /* @@ -1301,7 +1403,7 @@ top0a: ** which unsign_c has been defined), and from below ** when we are recycling a character (e.g., because ** it terminated an entity but is not the standard -** semi-colon). The character will already have +** semi-colon). The chararcter will already have ** been put through the Unicode conversions. - FM */ top1: @@ -1431,8 +1533,11 @@ top1: (uck = UCTransUniChar(unsign_c, context->outUCLYhndl)) >= 32 && uck < 256) { - CTRACE(tfp, "UCTransUniChar returned 0x%.2lX:'%c'.\n", + if (TRACE) { + fprintf(stderr, + "UCTransUniChar returned 0x%.2lX:'%c'.\n", uck, FROMASCII((char)uck)); + } /* ** We got one octet from the conversions, so use it. - FM */ @@ -1449,7 +1554,7 @@ top1: 0) >= 0)) { /* ** Got a replacement string. - ** No further tests for validity - assume that whoever + ** No further tests for valididy - assume that whoever ** defined replacement strings knew what she was doing. - KW */ for (p = replace_buf; *p; p++) @@ -1460,19 +1565,13 @@ top1: } else if (context->T.output_utf8 && PUTUTF8(clong)) { ; /* do nothing more */ /* - ** If it's any other (> 160) 8-bit character, and + ** If it's any other (> 160) 8-bit chararcter, and ** we have not set HTPassEightBitRaw nor HTCJK, nor ** have the "ISO Latin 1" character set selected, ** back translate for our character set. - FM */ -#define IncludesLatin1Enc \ - (context->outUCLYhndl == LATIN1 || \ - (context->outUCI && \ - (context->outUCI->enc & (UCT_CP_SUPERSETOF_LAT1)))) - #define PASSHI8BIT (HTPassEightBitRaw || \ (context->T.do_8bitraw && !context->T.trans_from_uni)) - } else if (unsign_c > 160 && unsign_c < 256 && !(PASSHI8BIT || HTCJK != NOCJK) && !IncludesLatin1Enc) { @@ -1553,16 +1652,14 @@ top1: for (p = replace_buf; *p; p++) PUTC(*p); } else { -#endif /* NOTUSED_FOTEMODS */ /* ** Out of luck, so use the UHHH notation (ugh). - FM */ - /* do not print UHHH for now +#endif /* NOTUSED_FOTEMODS */ sprintf(replace_buf, "U%.2lX", unsign_c); for (p = replace_buf; *p; p++) { PUTC(*p); } - */ #ifdef NOTUSED_FOTEMODS } #endif /* NOTUSED_FOTEMODS */ @@ -1652,8 +1749,10 @@ top1: */ char temp[8]; - CTRACE(tfp, "SGML_character: Handling 'zwnj' entity as 'WBR' element.\n"); - + if (TRACE) { + fprintf(stderr, + "SGML_character: Handling 'zwnj' entity as 'WBR' element.\n"); + } if (c != ';') { sprintf(temp, "<WBR>%c", c); } else { @@ -1742,7 +1841,7 @@ top1: if ((context->isHex ? sscanf(string->data, "%lx", &code) : sscanf(string->data, "%ld", &code)) == 1) { if ((code == 1) || - (code > 127 && code < 156)) { + (code > 129 && code < 156)) { /* ** Assume these are Microsoft code points, ** inflicted on us by FrontPage. - FM @@ -1758,12 +1857,6 @@ top1: */ code = 0x263a; break; - case 128: - /* - ** EURO currency sign - */ - code = 0x20ac; - break; case 130: /* ** SINGLE LOW-9 QUOTATION MARK (sbquo) @@ -1888,8 +1981,10 @@ top1: */ char temp[8]; - CTRACE(tfp, "SGML_character: Handling '8204' (zwnj) reference as 'WBR' element.\n"); - + if (TRACE) { + fprintf(stderr, + "SGML_character: Handling '8204' (zwnj) reference as 'WBR' element.\n"); + } /* ** Include the terminator if it is not ** the standard semi-colon. - FM @@ -1978,7 +2073,6 @@ top1: */ for (p = replace_buf; *p; p++) PUTC(*p); -#endif /* NOTUSED_FOTEMODS */ /* ** Ignore 8205 (zwj), ** 8206 (lrm), and 8207 (rln), if we get to here. - FM @@ -1991,7 +2085,7 @@ top1: LYstrncpy(replace_buf, string->data, (string->size < 64 ? string->size : 63)); - fprintf(tfp, + fprintf(stderr, "SGML_character: Ignoring '%s%s'.\n", (context->isHex ? "&#x" : "&#"), replace_buf); @@ -2002,6 +2096,7 @@ top1: if (c != ';') goto top1; break; +#endif /* NOTUSED_FOTEMODS */ /* ** Show the numeric entity if we get to here ** and the value: @@ -2171,8 +2266,9 @@ top1: */ HTTag * t; if (c == '/') { - if (string->size != 0) - CTRACE(tfp,"SGML: `<%s/' found!\n", string->data); + if (TRACE) + if (string->size!=0) + fprintf(stderr,"SGML: `<%s/' found!\n", string->data); context->state = S_end; break; } @@ -2190,18 +2286,21 @@ top1: for (i = 0; i < 3; i++) /* recover */ PUTC(string->data[i]); PUTC(c); - CTRACE(tfp, "SGML: Treating <%s%c as text\n", + if (TRACE) + fprintf(stderr, "SGML: Treating <%s%c as text\n", string->data, c); string->size = 0; context->state = S_text; break; } else if (!t) { - CTRACE(tfp, "SGML: *** Invalid element %s\n", + if (TRACE) + fprintf(stderr, "SGML: *** Invalid element %s\n", string->data); context->state = (c == '>') ? S_text : S_junk_tag; break; } else if (t == context->unknown_tag) { - CTRACE(tfp, "SGML: *** Unknown element %s\n", + if (TRACE) + fprintf(stderr, "SGML: *** Unknown element %s\n", string->data); /* ** Fall through and treat like valid @@ -2556,7 +2655,8 @@ top1: if (WHITE(c)) break; /* Before attribute value */ if (c == '>') { /* End of tag */ - CTRACE(tfp, "SGML: found = but no value\n"); + if (TRACE) + fprintf(stderr, "SGML: found = but no value\n"); if (context->current_tag->name) start_element(context); context->state = S_text; @@ -2702,7 +2802,8 @@ top1: t = SGMLFindTag(dtd, string->data); } if (!t || t == context->unknown_tag) { - CTRACE(tfp, "Unknown end tag </%s>\n", string->data); + if (TRACE) + fprintf(stderr, "Unknown end tag </%s>\n", string->data); } else { BOOL tag_OK = (c == '>' || WHITE(c)); context->current_tag = t; @@ -2730,7 +2831,9 @@ top1: ** Don't treat these end tags as invalid, ** nor act on them. - FM */ - CTRACE(tfp, "SGML: `</%s%c' found! Ignoring it.\n", + if (TRACE) + fprintf(stderr, + "SGML: `</%s%c' found! Ignoring it.\n", string->data, c); string->size = 0; context->current_attribute_number = INVALID; @@ -2768,19 +2871,27 @@ top1: /* ** It is not at FORM end tag, so ignore it. - FM */ - CTRACE(tfp, "SGML: Ignoring end tag </%s> in SELECT block.\n", + if (TRACE) { + fprintf(stderr, + "SGML: Ignoring end tag </%s> in SELECT block.\n", string->data); + } } else { /* ** End the SELECT block and then ** handle the FORM end tag. - FM */ - CTRACE(tfp, "SGML: Faking SELECT end tag before </%s> end tag.\n", + if (TRACE) { + fprintf(stderr, + "SGML: Faking SELECT end tag before </%s> end tag.\n", string->data); + } end_element(context, SGMLFindTag(context->dtd, "SELECT")); - CTRACE(tfp, "SGML: End </%s>\n", string->data); - + if (TRACE) { + fprintf(stderr, + "SGML: End </%s>\n", string->data); + } (*context->actions->end_element) (context->target, (context->current_tag - context->dtd->tags), @@ -2791,7 +2902,9 @@ top1: ** Treat a P end tag like a P start tag (Ugh, ** what a hack! 8-). - FM */ - CTRACE(tfp, "SGML: `</%s%c' found! Treating as '<%s%c'.\n", + if (TRACE) + fprintf(stderr, + "SGML: `</%s%c' found! Treating as '<%s%c'.\n", string->data, c, string->data, c); { int i; @@ -2804,8 +2917,10 @@ top1: if (context->current_tag->name) start_element(context); } else { - CTRACE(tfp, "SGML: End </%s>\n", string->data); - + if (TRACE) { + fprintf(stderr, + "SGML: End </%s>\n", string->data); + } (*context->actions->end_element) (context->target, (context->current_tag - context->dtd->tags), @@ -2830,8 +2945,8 @@ top1: string->size = 0; context->current_attribute_number = INVALID; if (c != '>') { - if (!WHITE(c)) - CTRACE(tfp,"SGML: `</%s%c' found!\n", string->data, c); + if (TRACE && !WHITE(c)) + fprintf(stderr,"SGML: `</%s%c' found!\n", string->data, c); context->state = S_junk_tag; } else { context->state = S_text; @@ -3093,7 +3208,7 @@ PUBLIC HTStream* SGML_new ARGS3( context->string = HTChunkCreate(128); /* Grow by this much */ context->dtd = dtd; context->target = target; - context->actions = (CONST HTStructuredClass*)(((HTStream*)target)->isa); + context->actions = (HTStructuredClass*)(((HTStream*)target)->isa); /* Ugh: no OO */ context->unknown_tag = &HTTag_unrecognized; context->state = S_text; @@ -3150,7 +3265,7 @@ PUBLIC HTStream* SGML_new ARGS3( ** Added 24-Mar-96 by FM, based on: ** //////////////////////////////////////////////////////////////////////// -Copyright (c) 1993 Electrotechnical Laboratory (ETL) +Copyright (c) 1993 Electrotechnical Laboratry (ETL) Permission to use, copy, modify, and distribute this material for any purpose and without fee is hereby granted, provided @@ -3181,69 +3296,19 @@ PUBLIC void JISx0201TO0208_EUC ARGS4( register unsigned char *, OLO) { static char *table[] = { - "\241\243", /* A1,A3 */ - "\241\326", /* A1,D6 */ - "\241\327", /* A1,D7 */ - "\241\242", /* A1,A2 */ - "\241\246", /* A1,A6 */ - "\245\362", /* A5,F2 */ - "\245\241", /* A5,A1 */ - "\245\243", /* A5,A3 */ - "\245\245", /* A5,A5 */ - "\245\247", /* A5,A7 */ - "\245\251", /* A5,A9 */ - "\245\343", /* A5,E3 */ - "\245\345", /* A5,E5 */ - "\245\347", /* A5,E7 */ - "\245\303", /* A5,C3 */ - "\241\274", /* A1,BC */ - "\245\242", /* A5,A2 */ - "\245\244", /* A5,A4 */ - "\245\246", /* A5,A6 */ - "\245\250", /* A5,A8 */ - "\245\252", /* A5,AA */ - "\245\253", /* A5,AB */ - "\245\255", /* A5,AD */ - "\245\257", /* A5,AF */ - "\245\261", /* A5,B1 */ - "\245\263", /* A5,B3 */ - "\245\265", /* A5,B5 */ - "\245\267", /* A5,B7 */ - "\245\271", /* A5,B9 */ - "\245\273", /* A5,BB */ - "\245\275", /* A5,BD */ - "\245\277", /* A5,BF */ - "\245\301", /* A5,C1 */ - "\245\304", /* A5,C4 */ - "\245\306", /* A5,C6 */ - "\245\310", /* A5,C8 */ - "\245\312", /* A5,CA */ - "\245\313", /* A5,CB */ - "\245\314", /* A5,CC */ - "\245\315", /* A5,CD */ - "\245\316", /* A5,CE */ - "\245\317", /* A5,CF */ - "\245\322", /* A5,D2 */ - "\245\325", /* A5,D5 */ - "\245\330", /* A5,D8 */ - "\245\333", /* A5,DB */ - "\245\336", /* A5,DE */ - "\245\337", /* A5,DF */ - "\245\340", /* A5,E0 */ - "\245\341", /* A5,E1 */ - "\245\342", /* A5,E2 */ - "\245\344", /* A5,E4 */ - "\245\346", /* A5,E6 */ - "\245\350", /* A5,E8 */ - "\245\351", /* A5,E9 */ - "\245\352", /* A5,EA */ - "\245\353", /* A5,EB */ - "\245\354", /* A5,EC */ - "\245\355", /* A5,ED */ - "\245\357", /* A5,EF */ - "\245\363", /* A5,F3 */ - "\241\253", /* A1,AB */ - "\241\254" /* A1,AC */ + "\xA1\xA3", "\xA1\xD6", "\xA1\xD7", "\xA1\xA2", "\xA1\xA6", "\xA5\xF2", + "\xA5\xA1", "\xA5\xA3", "\xA5\xA5", "\xA5\xA7", "\xA5\xA9", + "\xA5\xE3", "\xA5\xE5", "\xA5\xE7", "\xA5\xC3", "\xA1\xBC", + "\xA5\xA2", "\xA5\xA4", "\xA5\xA6", "\xA5\xA8", "\xA5\xAA", + "\xA5\xAB", "\xA5\xAD", "\xA5\xAF", "\xA5\xB1", "\xA5\xB3", + "\xA5\xB5", "\xA5\xB7", "\xA5\xB9", "\xA5\xBB", "\xA5\xBD", + "\xA5\xBF", "\xA5\xC1", "\xA5\xC4", "\xA5\xC6", "\xA5\xC8", + "\xA5\xCA", "\xA5\xCB", "\xA5\xCC", "\xA5\xCD", "\xA5\xCE", + "\xA5\xCF", "\xA5\xD2", "\xA5\xD5", "\xA5\xD8", "\xA5\xDB", + "\xA5\xDE", "\xA5\xDF", "\xA5\xE0", "\xA5\xE1", "\xA5\xE2", + "\xA5\xE4", "\xA5\xE6", "\xA5\xE8", "\xA5\xE9", "\xA5\xEA", + "\xA5\xEB", "\xA5\xEC", "\xA5\xED", "\xA5\xEF", "\xA5\xF3", + "\xA1\xAB", "\xA1\xAC" }; if ((IHI == 0x8E) && (ILO >= 0xA1) && (ILO <= 0xDF)) { @@ -3312,7 +3377,7 @@ PUBLIC void JISx0201TO0208_SJIS ARGS3( { unsigned char SJCODE[2]; - JISx0201TO0208_EUC('\216', I, OHI, OLO); + JISx0201TO0208_EUC('\x8E', I, OHI, OLO); JIS_TO_SJIS1(*OHI&0x7F, *OLO&0x7F, SJCODE); *OHI = SJCODE[0]; *OLO = SJCODE[1]; @@ -3422,11 +3487,10 @@ PUBLIC unsigned char * EUC_TO_JIS ARGS4( } PUBLIC unsigned char * TO_EUC ARGS2( - CONST unsigned char *, jis, + unsigned char *, jis, unsigned char *, euc) { - register CONST unsigned char *s; - register unsigned char *d, c, jis_stat; + register unsigned char *s, *d, c, jis_stat; register int to1B, to2B; register int in_sjis = 0; @@ -3476,7 +3540,7 @@ PUBLIC unsigned char * TO_EUC ARGS2( } PUBLIC void TO_SJIS ARGS2( - CONST unsigned char *, any, + unsigned char *, any, unsigned char *, sjis) { unsigned char *euc; @@ -3494,7 +3558,7 @@ PUBLIC void TO_SJIS ARGS2( } PUBLIC void TO_JIS ARGS2( - CONST unsigned char *, any, + unsigned char *, any, unsigned char *, jis) { unsigned char *euc; diff --git a/WWW/Library/Implementation/SGML.h b/WWW/Library/Implementation/SGML.h index 22f4bded..fd0bf759 100644 --- a/WWW/Library/Implementation/SGML.h +++ b/WWW/Library/Implementation/SGML.h @@ -20,6 +20,9 @@ #ifndef SGML_H #define SGML_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* HTUTILS_H */ #include <HTStream.h> #include <HTAnchor.h> diff --git a/WWW/Library/Implementation/UCAux.h b/WWW/Library/Implementation/UCAux.h index 3b1df229..a1e3df46 100644 --- a/WWW/Library/Implementation/UCAux.h +++ b/WWW/Library/Implementation/UCAux.h @@ -1,8 +1,6 @@ #ifndef UCAUX_H #define UCAUX_H -#include <HTUtils.h> - extern BOOL UCCanUniTranslateFrom PARAMS((int from)); extern BOOL UCCanTranslateUniTo PARAMS((int to)); extern BOOL UCCanTranslateFromTo PARAMS((int from, int to)); diff --git a/WWW/Library/Implementation/UCDefs.h b/WWW/Library/Implementation/UCDefs.h index 0da30713..ac2dc3bc 100644 --- a/WWW/Library/Implementation/UCDefs.h +++ b/WWW/Library/Implementation/UCDefs.h @@ -3,29 +3,21 @@ #ifndef UCDEFS_H #define UCDEFS_H -#include <HTUtils.h> - typedef struct _LYUCcharset { int UChndl; CONST char * MIMEname; int enc; - - /* parameters below are not used by chartrans mechanism, */ - /* they describe some relationships against built-in Latin1 charset...*/ - int repertoire; /* unused */ - int codepoints; /* subset/superset of Latin1 ? */ - int cpranges; /* unused, obsolete by LYlowest_eightbit; - "which ranges have valid displayable chars - (including nbsp and shy)" */ - int like8859; /* currently used for nbsp and shy only - (but UCT_R_8859SPECL assumed for any UCT_R_8BIT...); - "for which ranges is it like 8859-1" */ + int repertoire; + int codepoints; + int cpranges; /* which ranges have valid displayable chars + (including nbsp and shy) */ + int like8859; /* for which ranges is it like 8859-1 */ } LYUCcharset; #define UCT_ENC_7BIT 0 #define UCT_ENC_8BIT 1 -#define UCT_ENC_8859 2 /* no displayable chars in 0x80-0x9F */ -#define UCT_ENC_8BIT_C0 3 /* 8-bit + some chars in C0 control area */ +#define UCT_ENC_8859 2 +#define UCT_ENC_8BIT_C0 3 /* 8-bit some chars in C0 control area */ #define UCT_ENC_MAYBE2022 4 #define UCT_ENC_CJK 5 #define UCT_ENC_16BIT 6 @@ -53,13 +45,13 @@ typedef struct _LYUCcharset { * More specific bitflags for practically important code point ranges: */ #define UCT_R_LOWCTRL 0x08 /* 0x00-0x1F, for completeness */ -#define UCT_R_7BITINV 0x10 /* invariant???, displayable 7bit chars */ -#define UCT_R_7BITNAT 0x20 /* displayable 7bit, national??? */ -#define UCT_R_HIGHCTRL 0x40 /* chars in 0x80-0x9F range */ +#define UCT_R_7BITINV 0x10 /* invariant, displayable 7bit chars */ +#define UCT_R_7BITNAT 0x20 /* displayable 7bit, national */ +#define UCT_R_HIGHCTRL 0x40 #define UCT_R_8859SPECL 0x80 /* special chars in 8859-x sets: nbsp and shy*/ #define UCT_R_HIGH8BIT 0x100 /* rest of 0xA0-0xFF range */ -#define UCT_R_ASCII UCT_R_7BITINV | UCT_R_7BITNAT /* displayable US-ASCII */ +#define UCT_R_ASCII UCT_R_7BITINV | UCT_R_7BITNAT /*displayable US-ASCII*/ #define UCT_R_LAT1 UCT_R_ASCII | UCT_R_8859SPECL | UCT_R_HIGH8BIT #define UCT_R_8BIT UCT_R_LAT1 | UCT_R_HIGHCTRL /* full 8bit range */ diff --git a/WWW/Library/Implementation/UCMap.h b/WWW/Library/Implementation/UCMap.h index 15df5f02..e634f760 100644 --- a/WWW/Library/Implementation/UCMap.h +++ b/WWW/Library/Implementation/UCMap.h @@ -1,8 +1,7 @@ + #ifndef UCMAP_H #define UCMAP_H -#include <HTUtils.h> - typedef long UCode_t; extern int UCTransUniChar PARAMS(( @@ -32,52 +31,18 @@ extern int UCTransCharStr PARAMS(( extern UCode_t UCTransToUni PARAMS(( char ch_in, int charset_in)); +extern int UCGetLYhndl_byMIME PARAMS(( + CONST char * p)); extern int UCGetRawUniMode_byLYhndl PARAMS(( int i)); -extern int UCGetLYhndl_byMIME PARAMS(( - CONST char * p)); /* returns -1 if name not recognized */ -extern int safeUCGetLYhndl_byMIME PARAMS(( - CONST char * p)); /* returns LATIN1 if name not recognized */ extern int UCLYhndl_for_unspec; extern int UCLYhndl_for_unrec; extern int UCLYhndl_HTFile_for_unspec; extern int UCLYhndl_HTFile_for_unrec; -/* easy to type: */ -#define LATIN1 UCGetLYhndl_byMIME("iso-8859-1") -#define US_ASCII UCGetLYhndl_byMIME("us-ascii") - -/* -In general, Lynx translates letters from document charset to display charset. -If document charset is not specified or not recognized by Lynx, we fall back -to different assumptions below, read also lynx.cfg for info. - -UCLYhndl_for_unspec - assume this as charset for documents that don't - specify a charset parameter in HTTP headers or via META - this corresponds to "assume_charset" - -UCLYhndl_HTFile_for_unspec - assume this as charset of local file - this corresponds to "assume_local_charset" - -UCLYhndl_for_unrec - in case a charset parameter is not recognized; - this corresponds to "assume_unrec_charset" - -UCLYhndl_HTFile_for_unrec - the same but only for local files, - currently not used. - - -current_char_set - this corresponds to "display charset", - declared in LYCharSets.c and really important. - -All external charset information is available in so called MIME format. -For internal needs Lynx uses charset handlers as integers -from UCGetLYhndl_byMIME(). However, there is no way to recover -from user's error in configuration file lynx.cfg or command line switches, -those unrecognized MIME names are assumed as LATIN1 (via safeUCGetLYhndl...). -*/ - - #define UCTRANS_NOTFOUND (-4) +#define HT_CANNOT_TRANSLATE -4 /* could go into HTUtils.h */ + #endif /* UCMAP_H */ diff --git a/WWW/Library/Implementation/crypt.c b/WWW/Library/Implementation/crypt.c index 3645f63e..1a01711c 100644 --- a/WWW/Library/Implementation/crypt.c +++ b/WWW/Library/Implementation/crypt.c @@ -23,7 +23,9 @@ * */ +#ifndef HTUTILS_H #include <HTUtils.h> +#endif #include <ufc-crypt.h> diff --git a/WWW/Library/Implementation/crypt_util.c b/WWW/Library/Implementation/crypt_util.c index 91868b75..bdec6f7b 100644 --- a/WWW/Library/Implementation/crypt_util.c +++ b/WWW/Library/Implementation/crypt_util.c @@ -23,7 +23,13 @@ * */ +#ifndef HTUTILS_H #include <HTUtils.h> +#endif + +#ifdef DEBUG +/*#include <stdio.h> included by HTUTils.h - FM */ +#endif #ifndef STATIC #define STATIC static diff --git a/WWW/Library/Implementation/entities.h b/WWW/Library/Implementation/entities.h index a6ca7c1d..55ce977b 100644 --- a/WWW/Library/Implementation/entities.h +++ b/WWW/Library/Implementation/entities.h @@ -15,12 +15,6 @@ * Why keep two structures for entities? Backward compatibility.. */ -#ifndef ENTITIES_H -#define ENTITIES_H 1 - -#include <HTUtils.h> -#include <SGML.h> - /* UC_entity_info structure is defined in SGML.h. This has to be sorted alphabetically (case-sensitive), bear this in mind when you add some more entities.. */ @@ -1088,5 +1082,3 @@ static CONST UC_entity_info unicode_entities[] = { /* {"scnap", 0x????}, succeeds, not approximately equal to # ISOamsn */ /* {"smid", 0x????}, shortmid # ISOamsr */ }; - -#endif /* ENTITIES_H */ diff --git a/WWW/Library/Implementation/getline.c b/WWW/Library/Implementation/getline.c index 3168b9ec..4ee2e744 100644 --- a/WWW/Library/Implementation/getline.c +++ b/WWW/Library/Implementation/getline.c @@ -17,11 +17,14 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* CHANGED FOR VMS */ + /* * <getline.c> */ #include <HTUtils.h> +#include <tcp.h> +#include <stddef.h> #include <LYLeaks.h> diff --git a/WWW/Library/Implementation/getpass.c b/WWW/Library/Implementation/getpass.c index f209da77..0e8ffdfa 100644 --- a/WWW/Library/Implementation/getpass.c +++ b/WWW/Library/Implementation/getpass.c @@ -23,6 +23,7 @@ Cambridge, MA 02139, USA. */ */ #include <HTUtils.h> +/*#include <stdio.h> included by HTUtils.h -- FM */ #include <descrip.h> #include <psldef.h> #include <iodef.h> diff --git a/WWW/Library/Implementation/tcp.h b/WWW/Library/Implementation/tcp.h index fba85b5b..fc424056 100644 --- a/WWW/Library/Implementation/tcp.h +++ b/WWW/Library/Implementation/tcp.h @@ -1,20 +1,20 @@ /* System dependencies in the W3 library SYSTEM DEPENDENCIES - + System-system differences for TCP include files and macros. This file includes for each system the files necessary for network and file I/O. It should be used in conjunction with HTUtils.h to help ensure portability across as many platforms and flavors of platforms as possible. - + AUTHORS - + TBL Tim Berners-Lee, W3 project, CERN, <timbl@info.cern.ch> EvA Eelco van Asperen <evas@cs.few.eur.nl> MA Marc Andreessen NCSA AT Aleksandar Totic <atotic@ncsa.uiuc.edu> SCW Susan C. Weber <sweber@kyle.eitech.com> - + HISTORY: 22 Feb 91 Written (TBL) as part of the WWW library. 16 Jan 92 PC code from EvA @@ -29,13 +29,17 @@ #ifndef TCP_H #define TCP_H +#ifndef HTUTILS_H +#include <HTUtils.h> +#endif /* !HTUTILS_H */ + /* Default values These values may be reset and altered by system-specific sections later on. there are also a bunch of defaults at the end . - + */ /* Default values of those: */ #define NETCLOSE close /* Routine to close a TCP-IP socket */ @@ -55,61 +59,61 @@ Default values typedef struct sockaddr_in SockA; /* See netinet/in.h */ + +#ifndef STDIO_H +#include <stdio.h> +#define STDIO_H +#endif /* !STDIO_H */ + #ifndef VMS #include <sys/types.h> -#if defined(__DJGPP__) || defined(__BORLANDC__) -#define HAVE_DIRENT_H -#undef HAVE_SYS_FILIO_H -#endif /* DJGPP or __BORLANDC__ */ - -#ifdef HAVE_DIRENT_H +#if HAVE_DIRENT_H # include <dirent.h> # define D_NAMLEN(dirent) strlen((dirent)->d_name) # define STRUCT_DIRENT struct dirent #else # define D_NAMLEN(dirent) (dirent)->d_namlen # define STRUCT_DIRENT struct direct -# ifdef HAVE_SYS_NDIR_H +# if HAVE_SYS_NDIR_H # include <sys/ndir.h> # endif -# ifdef HAVE_SYS_DIR_H +# if HAVE_SYS_DIR_H # include <sys/dir.h> # endif -# ifdef HAVE_NDIR_H +# if HAVE_NDIR_H # include <ndir.h> # endif #endif /* HAVE_DIRENT_H */ #endif /* !VMS */ -#ifdef TIME_WITH_SYS_TIME +#if TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else -# ifdef HAVE_SYS_TIME_H +# if HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> # endif #endif -#if defined(_AIX) && !defined(AIX) +#ifdef _AIX #define AIX #endif /* _AIX */ - -#if defined(AIX) && !defined(unix) +#ifdef AIX #define unix #endif /* AIX */ -#ifdef HAVE_FCNTL_H +#if HAVE_FCNTL_H #include <fcntl.h> #else -#ifdef HAVE_SYS_FCNTL_H +#if HAVE_SYS_FCNTL_H #include <sys/fcntl.h> #endif #endif -#ifdef HAVE_STRING_H +#if HAVE_STRING_H #include <string.h> /* For bzero etc */ #endif /* HAVE_STRING_H */ @@ -149,6 +153,7 @@ IBM-PC running Windows NT #include <time.h> #include <errno.h> #include <direct.h> +#include <stdio.h> #include <winsock.h> typedef struct sockaddr_in SockA; /* See netinet/in.h */ #define EINPROGRESS (WSABASEERR+36) @@ -171,23 +176,23 @@ VAX/VMS Under VMS, there are many versions of TCP-IP. Define one if you do not use Digital's UCX product: - + UCX DEC's "Ultrix connection" (default) CMU_TCP Available via FTP from sacusr.mp.usbr.gov SOCKETSHR Eckhart Meyer's interface to NETLIB WIN_TCP From Wollongong, now GEC software. MULTINET From SRI, became TGV, then Cisco. DECNET Cern's TCP socket emulation over DECnet - + The last three do not interfere with the unix i/o library, and so they need special calls to read, write and close sockets. In these cases the socket number is a VMS channel number, so we make the @@@ HORRIBLE @@@ assumption that a channel number will be greater than 10 but a unix file descriptor less than 10. It works. - + */ -#ifdef VMS +#ifdef VMS #ifdef UCX #undef IOCTL @@ -261,6 +266,11 @@ extern int socket_ioctl(); #include <string.h> +#ifndef STDIO_H +#include <stdio.h> +#define STDIO_H +#endif /* !STDIO_H */ + #include <file.h> #include <stat.h> #include <unixio.h> @@ -279,6 +289,7 @@ extern int socket_ioctl(); */ extern int multinet_accept(); extern int multinet_bind(); +extern int bzero(); extern int multinet_connect(); extern int multinet_gethostname(); extern int multinet_getsockname(); @@ -295,7 +306,6 @@ extern char *vms_errno_string(); #include <time.h> #include <types.h> #ifdef __TIME_T -#undef __TYPES #define __TYPES 1 #define __TYPES_LOADED 1 #endif /* __TIME_T */ @@ -308,11 +318,9 @@ extern char *vms_errno_string(); #endif /* !__SOCKET_TYPEDEFS */ #include "multinet_root:[multinet.include]errno.h" #ifdef __TYPES -#undef __TIME_T #define __TIME_T 1 #endif /* __TYPE */ #ifdef __TIME_LOADED -#undef __TIME #define __TIME 1 /* to avoid double definitions in in.h */ #endif /* __TIME_LOADED */ #include "multinet_root:[multinet.include.sys]time.h" @@ -437,7 +445,7 @@ struct timeval { On VMS machines, the linker needs to be told to put global data sections into a data segment using these storage classes. (MarkDonszelmann) - + */ #if defined(VAXC) && !defined(__DECC) #define GLOBALDEF globaldef @@ -475,14 +483,13 @@ struct timeval { #define NETREAD read_s #undef NETCLOSE #define NETCLOSE close_s -#define getsockname getsockname_s #endif -#ifdef HAVE_UNISTD_H +#if HAVE_UNISTD_H #include <unistd.h> #endif /* HAVE_UNISTD_H */ -#ifdef HAVE_SYS_FILIO_H +#if HAVE_SYS_FILIO_H #include <sys/filio.h> #endif /* HAVE_SYS_FILIO_H */ @@ -501,7 +508,7 @@ Regular BSD unix versions */ #ifndef INCLUDES_DONE #include <sys/types.h> -#ifdef HAVE_STRING_H +#if HAVE_STRING_H #include <string.h> #endif /* HAVE_STRING_H */ #include <errno.h> /* independent */ @@ -526,6 +533,10 @@ typedef unsigned short mode_t; typedef int pid_t; #endif /* !pid_t */ +#ifndef S_ISREG +#define S_ISREG(m) (((m) & 0170000) == 0100000) +#endif /* S_ISREG */ + #ifndef WEXITSTATUS #ifdef sony_news #define WEXITSTATUS(s) WIFEXITED(s) @@ -612,70 +623,6 @@ Defaults #include <netdb.h> #endif /* TCP includes */ -#ifndef S_ISLNK -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -#endif /* S_ISLNK */ - -#ifndef S_ISDIR -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif /* S_ISDIR */ - -#ifndef S_ISREG -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif /* S_ISREG */ - -#ifndef S_ISUID -#define S_ISUID 0004000 -#endif -#ifndef S_ISGID -#define S_ISGID 0002000 -#endif -#ifndef S_ISVTX -#define S_ISVTX 0001000 -#endif - -#ifndef S_IRWXU -#define S_IRWXU 00700 -#endif - -#ifndef S_IRUSR -#define S_IRUSR 00400 -#endif -#ifndef S_IWUSR -#define S_IWUSR 00200 -#endif -#ifndef S_IXUSR -#define S_IXUSR 00100 -#endif - -#ifndef S_IRWXG -#define S_IRWXG 00070 -#endif - -#ifndef S_IRGRP -#define S_IRGRP 00040 -#endif -#ifndef S_IWGRP -#define S_IWGRP 00020 -#endif -#ifndef S_IXGRP -#define S_IXGRP 00010 -#endif - -#ifndef S_IRWXO -#define S_IRWXO 00007 -#endif - -#ifndef S_IROTH -#define S_IROTH 00004 -#endif -#ifndef S_IWOTH -#define S_IWOTH 00002 -#endif -#ifndef S_IXOTH -#define S_IXOTH 00001 -#endif - /* ROUGH ESTIMATE OF MAX PATH LENGTH diff --git a/WWW/Library/djgpp/makefile b/WWW/Library/djgpp/makefile index 71408d21..d7272e45 100644 --- a/WWW/Library/djgpp/makefile +++ b/WWW/Library/djgpp/makefile @@ -7,12 +7,8 @@ WWW_MACH = djgpp # The ASIS repository's name for the machine we are on #ASIS_MACH = hardware/os -CFLAGS = -O3 -DUSE_ZLIB -DDOSPATH -DNOUSERS -DDEBUG -DDISP_PARTIAL \ --I../Implementation \ --I../../../djgpp/tcplib/include \ --I../../../djgpp/tcplib/include/tcp \ --I../../../src \ --I../../.. +CFLAGS = -O3 -DUSE_ZLIB -DDOSPATH -DNOUSERS -DDEBUG -I../../../djgpp/tcplib/include -I../../../djgpp/tcplib/include/tcp \ +-I../../../src -I../../.. LFLAGS = CC = gcc diff --git a/WWW/Library/unix/makefile.in b/WWW/Library/unix/makefile.in index ed69fe50..94918497 100644 --- a/WWW/Library/unix/makefile.in +++ b/WWW/Library/unix/makefile.in @@ -7,7 +7,6 @@ WWW_MACH = unix # The ASIS repository's name for the machine we are on ASIS_MACH = hardware/os -ECHO = @DONT_ECHO_CC@ LFLAGS = prefix = @prefix@ @@ -21,12 +20,7 @@ LYFLAGS = # FIXME: set in parent makefile CC = @CC@ DEFS = @DEFS@ CPPFLAGS = @CPPFLAGS@ -CPPOPTS = $(DEFS) $(CPPFLAGS) $(LYFLAGS) \ - -I../../.. \ - -I../../../src \ - -I$(top_srcdir) \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/WWW/Library/Implementation +CPPOPTS = $(DEFS) $(CPPFLAGS) $(LYFLAGS) -I../../.. -I../../../src -I$(top_srcdir) -I$(top_srcdir)/src LY_CFLAGS = @CFLAGS@ CFLAGS = $(CPPOPTS) $(LY_CFLAGS) diff --git a/WWW/Library/vms/descrip.mms b/WWW/Library/vms/descrip.mms index a6231d02..216e6aee 100644 --- a/WWW/Library/vms/descrip.mms +++ b/WWW/Library/vms/descrip.mms @@ -76,14 +76,12 @@ DEBUGFLAGS = /Debug /NoOptimize .endif -INCLUDES = /Include=([-.Implementation],[---.src],[---]) - ! defines valid for all compilations EXTRADEFINES = DEBUG, ACCESS_AUTH, VC="""$(VC)""" ! DECC flags for all compilations .ifdef DEC_C -DCFLAGS = /NoMember /Warning=(disable=implicitfunc) $(INCLUDES) +DCFLAGS = /NoMember /Warning=(disable=implicitfunc) .endif .ifdef UCX @@ -91,7 +89,7 @@ TCP = UCX .ifdef DEC_C CFLAGS = /decc/Prefix=All $(DEBUGFLAGS) $(DCFLAGS) /Define=($(EXTRADEFINES), UCX) .else -CFLAGS = $(DEBUGFLAGS) /Define=($(EXTRADEFINES), UCX) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define=($(EXTRADEFINES), UCX) .endif .endif @@ -100,7 +98,7 @@ TCP = TCPWARE .ifdef DEC_C CFLAGS = /decc/Prefix=All $(DEBUGFLAGS) $(DCFLAGS) /Define=($(EXTRADEFINES), UCX, TCPWARE) .else -CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), UCX, TCPWARE) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), UCX, TCPWARE) .endif .endif @@ -109,7 +107,7 @@ TCP = MULTINET .ifdef DEC_C CFLAGS = /decc/Prefix=ANSI $(DEBUGFLAGS) $(DCFLAGS) /Define=(_DECC_V4_SOURCE, __SOCKET_TYPEDEFS, $(EXTRADEFINES), MULTINET) .else -CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), MULTINET) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), MULTINET) .endif .endif @@ -118,7 +116,7 @@ TCP = WIN_TCP .ifdef DEC_C CFLAGS = /decc/Prefix=ANSI $(DEBUGFLAGS) $(DCFLAGS) /Define=($(EXTRADEFINES), WIN_TCP) .else -CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), WIN_TCP) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), WIN_TCP) .endif .endif @@ -127,7 +125,7 @@ TCP = CMU_TCP .ifdef DEC_C CFLAGS = /decc/Prefix=ANSI $(DEBUGFLAGS) $(DCFLAGS) /Define=($(EXTRADEFINES), CMU_TCP) .else -CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), CMU_TCP) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), CMU_TCP) .endif .endif @@ -136,7 +134,7 @@ TCP = SOCKETSHR_TCP .ifdef DEC_C CFLAGS = /decc/Prefix=ANSI $(DEBUGFLAGS) $(DCFLAGS) /Define=($(EXTRADEFINES), SOCKETSHR_TCP) .else -CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), SOCKETSHR_TCP) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), SOCKETSHR_TCP) .endif .endif @@ -145,7 +143,7 @@ TCP = DECNET .ifdef DEC_C CFLAGS = /decc/Prefix=All $(DEBUGFLAGS) $(DCFLAGS) /Define=($(EXTRADEFINES), DECNET) .else -CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), DECNET) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), DECNET) .endif .endif @@ -155,7 +153,7 @@ TCP = MULTINET ! (Default to MULTINET) .ifdef DEC_C CFLAGS = /decc/Prefix=ANSI $(DEBUGFLAGS) $(DCFLAGS) /Define=(_DECC_V4_SOURCE, __SOCKET_TYPEDEFS, $(EXTRADEFINES), MULTINET) .else -CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), MULTINET) $(INCLUDES) +CFLAGS = $(DEBUGFLAGS) /Define = ($(EXTRADEFINES), MULTINET) .endif .endif |