diff options
Diffstat (limited to 'WWW/Library/Implementation')
24 files changed, 148 insertions, 1675 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 21e59efa..4642f279 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -64,8 +64,6 @@ #include <LYUtils.h> #include <LYLeaks.h> -extern HTCJKlang HTCJK; - /* ** These flags may be set to modify the operation of this module */ @@ -491,18 +489,13 @@ PRIVATE int get_physical ARGS2( } if (!override_flag && !using_proxy) { - char * gateway_parameter, *gateway, *proxy; + char * gateway_parameter = NULL, *gateway, *proxy; /* ** Search for gateways. */ - gateway_parameter = (char *)calloc(1, (strlen(acc_method) + 20)); - if (gateway_parameter == NULL) - outofmem(__FILE__, "HTLoad"); - strcpy(gateway_parameter, "WWW_"); - strcat(gateway_parameter, acc_method); - strcat(gateway_parameter, "_GATEWAY"); - gateway = (char *)getenv(gateway_parameter); /* coerce for decstation */ + HTSprintf0(&gateway_parameter, "WWW_%s_GATEWAY", acc_method); + gateway = getenv(gateway_parameter); /* coerce for decstation */ /* ** Search for proxy servers. @@ -511,11 +504,10 @@ PRIVATE int get_physical ARGS2( /* ** If we got to here, a file URL is for ftp on a remote host. - FM */ - strcpy(gateway_parameter, "ftp"); + strcpy(gateway_parameter, "ftp_proxy"); else - strcpy(gateway_parameter, acc_method); - strcat(gateway_parameter, "_proxy"); - proxy = (char *)getenv(gateway_parameter); + sprintf(gateway_parameter, "%s_proxy", acc_method); + proxy = getenv(gateway_parameter); FREE(gateway_parameter); if (gateway) @@ -620,6 +612,9 @@ PUBLIC void LYUCPushAssumed ARGS1( if (anchor_UCI && anchor_UCI->MIMEname) { pushed_assume_MIMEname = UCAssume_MIMEcharset; UCAssume_MIMEcharset = NULL; + if (HTCJK == JAPANESE) + StrAllocCopy(UCAssume_MIMEcharset, pushed_assume_MIMEname); + else StrAllocCopy(UCAssume_MIMEcharset, anchor_UCI->MIMEname); pushed_assume_LYhndl = anchor_LYhndl; /* some diagnostics */ diff --git a/WWW/Library/Implementation/HTCJK.h b/WWW/Library/Implementation/HTCJK.h index 5c2908f0..611aac98 100644 --- a/WWW/Library/Implementation/HTCJK.h +++ b/WWW/Library/Implementation/HTCJK.h @@ -61,6 +61,8 @@ typedef enum _HTkcode {NOKANJI, EUC, SJIS, JIS} HTkcode; typedef enum _HTCJKlang {NOCJK, JAPANESE, CHINESE, KOREAN, TAIPEI} HTCJKlang; +extern HTCJKlang HTCJK; + /* ** Function prototypes. */ diff --git a/WWW/Library/Implementation/HTDOS.c b/WWW/Library/Implementation/HTDOS.c index 68a5c82d..5313f1e5 100644 --- a/WWW/Library/Implementation/HTDOS.c +++ b/WWW/Library/Implementation/HTDOS.c @@ -95,49 +95,48 @@ char * HTDOS_name ARGS1(char *, wwwname) extern char windows_drive[]; char temp_buff[LY_MAXPATH]; #endif - static char *cp_url = NULL; - char *result, *ret; + static char *result = NULL; int joe; - CTRACE((tfp, "HTDOS_name changed `%s'\n", wwwname)); - copy_plus(&cp_url, wwwname); + copy_plus(&result, wwwname); - for (joe = 0; cp_url[joe] != '\0'; joe++) { - if (cp_url[joe] == '/') { - cp_url[joe] = '\\'; /* convert slashes to dos-style */ + for (joe = 0; result[joe] != '\0'; joe++) { + if (result[joe] == '/') { + result[joe] = '\\'; /* convert slashes to dos-style */ } } /* pesky leading slash, rudiment from file://localhost/ */ /* the rest of path may be with or without drive letter */ - if((cp_url[1] == '\\') || (cp_url[0] != '\\')) { - result = cp_url; - } else { - result = cp_url+1; + if((result[1] != '\\') && (result[0] == '\\')) { + for (joe = 0; (result[joe] = result[joe+1]) != 0; joe++) + ; } #ifdef _WINDOWS /* 1998/04/02 (Thu) 08:59:48 */ - if (strchr(result, '\\') && strchr(result, ':')==NULL) { + if (strchr(result, '\\') != NULL + && strchr(result, ':') == NULL) { sprintf(temp_buff, "%.3s\\%.*s", windows_drive, - (int)(sizeof(temp_buff) - sizeof(windows_drive) - 2), result); - ret = NULL; - StrAllocCopy(ret, temp_buff); - free(cp_url); + (int)(sizeof(temp_buff) - 5), result); + StrAllocCopy(result, temp_buff); } else { - char *p; - p = strchr(result, ':'); + char *p = strchr(result, ':'); if (p && (strcmp(p, ":\\") == 0)) { p[2] = '.'; p[3] = '\0'; } - ret = result; } -#else - ret = result; #endif + /* + * If we have only a device, add a trailing slash. Otherwise it just + * refers to the current directory on the given device. + */ + if (strchr(result, '\\') == 0 + && result[1] == ':') + StrAllocCat(result, "\\"); - CTRACE((tfp, "HTDOS_name changed `%s' to `%s'\n", wwwname, ret)); - return (ret); + CTRACE((tfp, "HTDOS_name changed `%s' to `%s'\n", wwwname, result)); + return (result); } #if defined(DJGPP) && defined(DJGPP_KEYHANDLER) diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index b2ceeadb..ac5f14a1 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -2436,16 +2436,16 @@ PRIVATE int compare_EntryInfo_structs ARGS2( } } strcat(date1, time1); - if (entry2->date[9] == ':') { - strcpy(date2, "9999"); - strcpy(time2, &entry2->date[7]); - if (time2[0] == ' ') { - time2[0] = '0'; - } - } else { - strcpy(date2, &entry2->date[8]); - strcpy(time2, "00:00"); + if (entry2->date[9] == ':') { + strcpy(date2, "9999"); + strcpy(time2, &entry2->date[7]); + if (time2[0] == ' ') { + time2[0] = '0'; } + } else { + strcpy(date2, &entry2->date[8]); + strcpy(time2, "00:00"); + } strncpy(month, entry2->date, 3); month[3] = '\0'; for (i = 0; i < 12; i++) { diff --git a/WWW/Library/Implementation/HTFWriter.c b/WWW/Library/Implementation/HTFWriter.c index f85341ce..b5666b44 100644 --- a/WWW/Library/Implementation/HTFWriter.c +++ b/WWW/Library/Implementation/HTFWriter.c @@ -254,7 +254,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( if (fnam == NULL) outofmem(__FILE__, "HTSaveAndExecute"); tmpnam (fnam); - if (suffix) strcat(fnam, suffix); + strcat(fnam, suffix); me->fp = fopen (fnam, "wb"); if (!me->fp) { @@ -326,7 +326,7 @@ PUBLIC HTStream* HTSaveLocally ARGS3( if (fnam == NULL) outofmem(__FILE__, "HTSaveLocally"); tmpnam (fnam); - if (suffix) strcat(fnam, suffix); + strcat(fnam, suffix); /* Save Panel */ answer = HTPrompt(GIVE_FILENAME, fnam); diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index e5596265..571968c9 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -121,7 +121,6 @@ PUBLIC int HTDirReadme = HT_DIR_README_TOP; #endif /* DIRED_SUPPORT */ extern BOOL HTPassEightBitRaw; -extern HTCJKlang HTCJK; PRIVATE char *HTMountRoot = "/Net/"; /* Where to find mounts */ #ifdef VMS @@ -716,6 +715,9 @@ PUBLIC char * HTnameOfFile_WWW ARGS3( FREE(path); FREE(acc_method); + CTRACE((tfp, "HTnameOfFile_WWW(%s,%d,%d) = %s\n", + name, WWW_prefix, expand_all, result)); + return result; } @@ -1445,6 +1447,9 @@ PUBLIC BOOL HTDirTitles ARGS3( /* ** Make link back to parent directory. */ +#ifdef DOSPATH + if (current != path) /* leave "/c:" alone */ +#endif if (current && current[1]) { /* was a slash AND something else too */ char * parent = NULL; char * relative = NULL; @@ -1466,15 +1471,14 @@ PUBLIC BOOL HTDirTitles ARGS3( #ifdef DOSPATH if (local_link) { - if (strlen(parent) == 3 ) + if (parent != 0 && strlen(parent) == 3 ) { StrAllocCat(relative, "/."); + } } + else #endif #if !defined (VMS) -#ifdef DOSPATH - if(!local_link) -#endif { /* ** On Unix, if it's not ftp and the directory cannot @@ -1571,13 +1575,9 @@ PUBLIC BOOL HTDirTitles ARGS3( PRIVATE void do_readme ARGS2(HTStructured *, target, CONST char *, localname) { FILE * fp; - char * readme_file_name = - malloc(strlen(localname)+ 1 + strlen(HT_DIR_README_FILE) + 1); - if (readme_file_name == NULL) - outofmem(__FILE__, "do_readme"); - strcpy(readme_file_name, localname); - strcat(readme_file_name, "/"); - strcat(readme_file_name, HT_DIR_README_FILE); + char * readme_file_name = NULL; + + HTSprintf0(&readme_file_name, "%s/%s", localname, HT_DIR_README_FILE); fp = fopen(readme_file_name, "r"); @@ -1635,6 +1635,7 @@ PRIVATE int print_local_dir ARGS5( BOOL need_parent_link = FALSE; struct stat file_info; int status; + int i; CTRACE((tfp, "print_local_dir() started\n")); @@ -1675,10 +1676,8 @@ PRIVATE int print_local_dir ARGS5( target = HTML_new(anchor, format_out, sink); targetClass = *target->isa; /* Copy routine entry points */ - { int i; - for (i = 0; i < HTML_A_ATTRIBUTES; i++) - present[i] = (BOOL) (i == HTML_A_HREF); - } + for (i = 0; i < HTML_A_ATTRIBUTES; i++) + present[i] = (BOOL) (i == HTML_A_HREF); /* ** The need_parent_link flag will be set if an @@ -2100,14 +2099,9 @@ PUBLIC int HTLoadFile ARGS4( } if (HTDirAccess == HT_DIR_SELECTIVE) { - char * enable_file_name = - malloc(strlen(filename)+ 1 + - strlen(HT_DIR_ENABLE_FILE) + 1); - if (enable_file_name == NULL) - outofmem(__FILE__, "HTLoadFile"); - strcpy(enable_file_name, filename); - strcat(enable_file_name, "/"); - strcat(enable_file_name, HT_DIR_ENABLE_FILE); + char * enable_file_name = NULL; + + HTSprintf0(&enable_file_name, "%s/%s", filename, HT_DIR_ENABLE_FILE); if (HTStat(enable_file_name, &stat_info) == -1) { FREE(filename); FREE(nodename); @@ -2476,14 +2470,9 @@ PUBLIC int HTLoadFile ARGS4( if (HTDirAccess == HT_DIR_SELECTIVE) { - char * enable_file_name = - malloc(strlen(localname)+ 1 + - strlen(HT_DIR_ENABLE_FILE) + 1); - if (enable_file_name == NULL) - outofmem(__FILE__, "HTLoadFile"); - strcpy(enable_file_name, localname); - strcat(enable_file_name, "/"); - strcat(enable_file_name, HT_DIR_ENABLE_FILE); + char * enable_file_name = NULL; + + HTSprintf0(&enable_file_name, "%s/%s", localname, HT_DIR_ENABLE_FILE); if (stat(enable_file_name, &file_info) != 0) { FREE(localname); FREE(nodename); @@ -2492,6 +2481,7 @@ PUBLIC int HTLoadFile ARGS4( } } + CTRACE((tfp, "Opening directory %s\n", localname)); dp = opendir(localname); if (!dp) { FREE(localname); @@ -2535,7 +2525,7 @@ PUBLIC int HTLoadFile ARGS4( CTRACE((tfp, "HTLoadFile: Opening `%s' gives %p\n", localname, (void*)fp)); if (fp) { /* Good! */ - int len; + int len2; char *cp = NULL; if (HTEditable(localname)) { @@ -2571,11 +2561,11 @@ PUBLIC int HTLoadFile ARGS4( StrAllocCopy(anchor->content_encoding, HTAtom_name(myEncoding)); format = HTAtom_for("www/compressed"); } - } else if ((len = strlen(localname)) > 2) { - if (localname[len - 1] == 'Z' && - localname[len - 2] == '.') { + } else if ((len2 = strlen(localname)) > 2) { + if (localname[len2 - 1] == 'Z' && + localname[len2 - 2] == '.') { StrAllocCopy(cp, localname); - cp[len - 2] = '\0'; + cp[len2 - 2] = '\0'; format = HTFileFormat(cp, &encoding, NULL); FREE(cp); format = HTCharsetFormat(format, anchor, @@ -2583,12 +2573,12 @@ PUBLIC int HTLoadFile ARGS4( StrAllocCopy(anchor->content_type, format->name); StrAllocCopy(anchor->content_encoding, "x-compress"); format = HTAtom_for("www/compressed"); - } else if ((len > 3) && - !strcasecomp((char *)&localname[len - 2], + } else if ((len2 > 3) && + !strcasecomp((char *)&localname[len2 - 2], "gz") && - localname[len - 3] == '.') { + localname[len2 - 3] == '.') { StrAllocCopy(cp, localname); - cp[len - 3] = '\0'; + cp[len2 - 3] = '\0'; format = HTFileFormat(cp, &encoding, NULL); FREE(cp); format = HTCharsetFormat(format, anchor, diff --git a/WWW/Library/Implementation/HTLex.c b/WWW/Library/Implementation/HTLex.c index dedf7bc9..9d9412af 100644 --- a/WWW/Library/Implementation/HTLex.c +++ b/WWW/Library/Implementation/HTLex.c @@ -43,7 +43,7 @@ PUBLIC void unlex ARGS1(LexItem, lex_item) PUBLIC LexItem lex ARGS1(FILE *, fp) { - int ch; + int ch = 0; if (fp != cache) { /* This cache doesn't work ok because the system */ cache = fp; /* often assign same FILE structure the next open */ diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index ca024e41..90094b8f 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -27,7 +27,6 @@ #include <LYLeaks.h> extern BOOL HTPassEightBitRaw; -extern HTCJKlang HTCJK; /* MIME Object ** ----------- @@ -1969,8 +1968,10 @@ PUBLIC HTStream* HTMIMERedirect ARGS3( ** ** Written by S. Ichikawa, ** partially inspired by encdec.c of <jh@efd.lth.se>. +** Assume caller's buffer is LINE_LENGTH bytes, these decode to +** no longer than the input strings. */ -#define BUFLEN 1024 +#define LINE_LENGTH 512 /* Maximum length of line of ARTICLE etc */ #ifdef ESC #undef ESC #endif /* ESC */ @@ -1987,7 +1988,7 @@ PUBLIC void HTmmdec_base64 ARGS2( char *, s) { int d, count, j, val; - char buf[BUFLEN], *bp, nw[4], *p; + char buf[LINE_LENGTH], *bp, nw[4], *p; for (bp = buf; *s; s += 4) { val = 0; @@ -2025,7 +2026,7 @@ PUBLIC void HTmmdec_quote ARGS2( char *, t, char *, s) { - char buf[BUFLEN], cval, *bp, *p; + char buf[LINE_LENGTH], cval, *bp, *p; for (bp = buf; *s; ) { if (*s == '=') { @@ -2055,102 +2056,6 @@ PUBLIC void HTmmdec_quote ARGS2( strcpy(t, buf); } -#ifdef NOTDEFINED -/* -** Generalized HTmmdecode for chartrans - K. Weide 1997-03-06 -*/ -PUBLIC void HTmmdecode ARGS2( - char *, trg, - char *, str) -{ - char buf[BUFLEN], mmbuf[BUFLEN]; - char *s, *t, *u, *qm2; - int base64, quote; - - buf[0] = '\0'; - - /* - ** Encoded-words look like - ** =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= - */ - for (s = str, u = buf; *s; ) { - base64 = quote = 0; - if (*s == '=' && s[1] == '?' && - (s == str || *(s-1) == '(' || WHITE(*(s-1)))) - { /* must be beginning of word */ - qm2 = strchr(s+2, '?'); /* 2nd question mark */ - if (qm2 && - (qm2[1] == 'B' || qm2[1] == 'b' || qm2[1] == 'Q' || - qm2[1] == 'q') && - qm2[2] == '?') { /* 3rd question mark */ - char * qm4 = strchr(qm2 + 3, '?'); /* 4th question mark */ - if (qm4 && qm4 - s < 74 && /* RFC 2047 length restriction */ - qm4[1] == '=') { - char *p; - BOOL invalid = NO; - for (p = s+2; p < qm4; p++) - if (WHITE(*p)) { - invalid = YES; - break; - } - if (!invalid) { - int LYhndl; - - *qm2 = '\0'; - invalid = ((LYhndl = UCGetLYhndl_byMIME(s+2)) < 0 || - UCCanTranslateFromTo(LYhndl, - current_char_set)); - *qm2 = '?'; - } - if (!invalid) { - if (qm2[1] == 'B' || qm2[1] == 'b') - base64 = 1; - else if (qm2[1] == 'Q' || qm2[1] == 'q') - quote = 1; - } - } - } - } - if (base64 || quote) { - if (HTmmcont) { - for (t = s - 1; - t >= str && (*t == ' ' || *t == '\t'); t--) { - u--; - } - } - for (s = qm2 + 3, t = mmbuf; *s; ) { - if (s[0] == '?' && s[1] == '=') { - break; - } else { - *t++ = *s++; - } - } - if (s[0] != '?' || s[1] != '=') { - goto end; - } else { - s += 2; - *t = '\0'; - } - if (base64) - HTmmdec_base64(mmbuf, mmbuf); - if (quote) - HTmmdec_quote(mmbuf, mmbuf); - for (t = mmbuf; *t; ) - *u++ = *t++; - HTmmcont = 1; - /* if (*s == ' ' || *s == '\t') *u++ = *s; */ - /* for ( ; *s == ' ' || *s == '\t'; s++) ; */ - } else { - if (*s != ' ' && *s != '\t') - HTmmcont = 0; - *u++ = *s++; - } - } - *u = '\0'; -end: - strcpy(trg, buf); -} -#else /* ** HTmmdecode for ISO-2022-JP - FM */ @@ -2158,7 +2063,7 @@ PUBLIC void HTmmdecode ARGS2( char *, trg, char *, str) { - char buf[BUFLEN], mmbuf[BUFLEN]; + char buf[LINE_LENGTH], mmbuf[LINE_LENGTH]; char *s, *t, *u; int base64, quote; @@ -2214,7 +2119,6 @@ PUBLIC void HTmmdecode ARGS2( end: strcpy(trg, buf); } -#endif /* NOTDEFINED */ /* ** Insert ESC where it seems lost. @@ -2224,7 +2128,7 @@ PUBLIC int HTrjis ARGS2( char *, t, char *, s) { - char *p, buf[BUFLEN]; + char *p, buf[LINE_LENGTH]; int kanji = 0; if (strchr(s, ESC) || !strchr(s, '$')) { diff --git a/WWW/Library/Implementation/HTMLGen.c b/WWW/Library/Implementation/HTMLGen.c index 32e83dde..86f06c2a 100644 --- a/WWW/Library/Implementation/HTMLGen.c +++ b/WWW/Library/Implementation/HTMLGen.c @@ -338,9 +338,9 @@ PRIVATE int HTMLGen_start_element ARGS6( strcpy (myHash, HTML_dtd.tags[element_number].name); if (class_string[0]) { + int len = strlen(myHash); + sprintf (myHash + len, ".%.*s", (int) sizeof(myHash) - len - 2, class_string); HTSprintf (&Style_className, ".%s", class_string); - strcat (myHash, "."); - strcat (myHash, class_string); } class_string[0] = '\0'; strtolower(myHash); diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c index dcde38a3..41506116 100644 --- a/WWW/Library/Implementation/HTNews.c +++ b/WWW/Library/Implementation/HTNews.c @@ -63,7 +63,6 @@ struct _HTStream extern BOOLEAN scan_for_buried_news_references; extern BOOLEAN LYListNewsNumbers; extern BOOLEAN LYListNewsDates; -extern HTCJKlang HTCJK; extern int interrupted_in_htgetcharacter; extern BOOL keep_mime_headers; /* Include mime headers and force raw text */ extern BOOL using_proxy; /* Are we using an NNTP proxy? */ @@ -568,8 +567,9 @@ PRIVATE char * author_name ARGS1 (char *,email) } if ((p = strrchr(name, '<')) && (e = strrchr(name, '>'))) { - if (e > p) { - strcpy(p, e+1); /* Remove <...> */ + if (e++ > p) { + while ((*p++ = *e++) != 0) /* Remove <...> */ + ; return HTStrip(name); /* Remove leading and trailing spaces */ } } @@ -966,7 +966,7 @@ static char *decode_mime(char *str) #else static char *decode_mime(char *str) { - char temp[LINE_LENGTH+256]; /* FIXME: what determines the actual size? */ + char temp[LINE_LENGTH]; /* FIXME: what determines the actual size? */ char *p, *q; if (str == NULL) @@ -975,7 +975,7 @@ static char *decode_mime(char *str) if (HTCJK != JAPANESE) return str; - strcpy(temp, str); + LYstrncpy(temp, str, sizeof(temp) - 1); q = temp; while ((p = strchr(q, '=')) != 0) { if (p[1] == '?') { @@ -1953,7 +1953,7 @@ PRIVATE int read_group ARGS3( case 'S': case 's': if (match(line, "SUBJECT:")) { - strcpy(subject, line+9);/* Save subject */ + LYstrncpy(subject, line+9, sizeof(subject)-1);/* Save subject */ decode_mime(subject); } break; @@ -2052,7 +2052,7 @@ PRIVATE int read_group ARGS3( START(HTML_LI); START(HTML_I); if (LYListNewsNumbers) - strcpy(buffer, "Status:"); + LYstrncpy(buffer, "Status:", sizeof(buffer) - 1); else sprintf(buffer, "Status (ARTICLE %d):", art); PUTS(buffer); @@ -2410,7 +2410,7 @@ PRIVATE int HTLoadNews ARGS4( HTAlert(URL_TOO_LONG); return -400; } - strcpy(groupName, p1); + LYstrncpy(groupName, p1, sizeof(groupName) - 1); *slash = '/'; (void)sscanf(slash+1, "%d-%d", &first, &last); if ((first > 0) && (isdigit(*(slash+1))) && @@ -2432,7 +2432,7 @@ PRIVATE int HTLoadNews ARGS4( HTAlert(URL_TOO_LONG); return -400; } - strcpy(groupName, p1); + LYstrncpy(groupName, p1, sizeof(groupName) - 1); } SnipIn(command, "GROUP %.*s", 9, groupName); } else { diff --git a/WWW/Library/Implementation/HTNews.h b/WWW/Library/Implementation/HTNews.h index 2e017fce..7cd930a4 100644 --- a/WWW/Library/Implementation/HTNews.h +++ b/WWW/Library/Implementation/HTNews.h @@ -13,6 +13,9 @@ #include <HTAccess.h> #include <HTAnchor.h> +extern int HTNewsChunkSize; +extern int HTNewsMaxChunk; + #ifdef GLOBALREF_IS_MACRO extern GLOBALREF(HTProtocol, HTNews); extern GLOBALREF(HTProtocol, HTNNTP); diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c index c3b2a484..4e5cbb56 100644 --- a/WWW/Library/Implementation/HTPlain.c +++ b/WWW/Library/Implementation/HTPlain.c @@ -32,7 +32,6 @@ extern BOOL HTPassEightBitRaw; extern BOOL HTPassHighCtrlRaw; -extern HTCJKlang HTCJK; PUBLIC int HTPlain_lastraw = -1; PRIVATE int HTPlain_bs_pending = 0; /* 1:bs 2:underline 3:underline+bs - kw */ diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c index cc36e8d7..e8177af1 100644 --- a/WWW/Library/Implementation/HTRules.c +++ b/WWW/Library/Implementation/HTRules.c @@ -84,20 +84,15 @@ PUBLIC int HTAddRule ARGS5( CONST char *, cond) { /* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */ rule * temp; - char * pPattern; + char * pPattern = NULL; temp = (rule *)calloc(1, sizeof(*temp)); if (temp==NULL) outofmem(__FILE__, "HTAddRule"); - pPattern = (char *)malloc(strlen(pattern)+1); - if (pPattern==NULL) - outofmem(__FILE__, "HTAddRule"); if (equiv) { /* Two operands */ - char * pEquiv = (char *)malloc(strlen(equiv)+1); - if (pEquiv==NULL) - outofmem(__FILE__, "HTAddRule"); + char * pEquiv = NULL; + StrAllocCopy(pEquiv, equiv); temp->equiv = pEquiv; - strcpy(pEquiv, equiv); } else { temp->equiv = 0; } @@ -105,10 +100,10 @@ PUBLIC int HTAddRule ARGS5( StrAllocCopy(temp->condition_op, cond_op); StrAllocCopy(temp->condition, cond); } + StrAllocCopy(pPattern, pattern); temp->pattern = pPattern; temp->op = op; - strcpy(pPattern, pattern); if (equiv) { CTRACE((tfp, "Rule: For `%s' op %d `%s'", pattern, op, equiv)); } else { @@ -330,24 +325,23 @@ char * HTTranslate ARGS1( } else { char * ins = strchr(r->equiv, '*'); /* Insertion point */ if (ins) { /* Consistent rule!!! */ - char * temp = (char *)malloc( - strlen(r->equiv)-1 + m + 1); - if (temp==NULL) - outofmem(__FILE__, "HTTranslate"); /* NT & AS */ - 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 */ + char * temp = NULL; + + HTSprintf0(&temp, "%.*s%.*s%s", + ins - r->equiv, + r->equiv, + m, + q, + ins + 1); CTRACE((tfp, "For `%s' using `%s'\n", current, temp)); FREE(current); current = temp; /* Use this */ } else { /* No insertion point */ - char * temp = (char *)malloc(strlen(r->equiv)+1); - if (temp==NULL) - outofmem(__FILE__, "HTTranslate"); /* NT & AS */ - strcpy(temp, r->equiv); + char * temp = NULL; + + StrAllocCopy(temp, r->equiv); CTRACE((tfp, "For `%s' using `%s'\n", current, temp)); FREE(current); diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c index cce1039c..89160f16 100644 --- a/WWW/Library/Implementation/HTString.c +++ b/WWW/Library/Implementation/HTString.c @@ -652,11 +652,6 @@ PUBLIC_IF_FIND_LEAKS char * StrAllocVsprintf ARGS4( case 'E': /* FALLTHRU */ case 'g': /* FALLTHRU */ case 'G': /* FALLTHRU */ -#if 0 /* we don't need this, it doesn't work on SunOS 4.x */ - if (type == 'L') - VA_FLOAT(long double); - else -#endif VA_FLOAT(double); used = 'f'; break; diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index 0671371c..0f2c0a28 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -104,7 +104,7 @@ char host[512]; struct hostent *phost; /* Pointer to host - See netdb.h */ int donelookup; -unsigned long _fork_func (void *arglist) +static unsigned long _fork_func (void *arglist) { #ifdef SH_EX unsigned long addr; @@ -1405,7 +1405,7 @@ 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 */ + phost = gethostbyname((CONST char *)name); /* See netdb.h */ if (!OK_HOST(phost)) { CTRACE((tfp, "TCP: Can't find my own internet node address for `%s'!!\n", name)); diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c index df8cda8a..5ec51d5f 100644 --- a/WWW/Library/Implementation/HTVMSUtils.c +++ b/WWW/Library/Implementation/HTVMSUtils.c @@ -19,6 +19,7 @@ #include <UCDefs.h> #include <UCMap.h> #include <UCAux.h> +#include <HTFTP.h> #include <HTVMSUtils.h> #include <ssdef.h> #include <jpidef.h> @@ -324,7 +325,7 @@ PUBLIC int HTStat ARGS2( int Result; int Len; char *Ptr, *Ptr2; -char Name[256]; +static char *Name; /* try normal stat... */ Result = stat((char *)filename,info); @@ -332,32 +333,7 @@ char Name[256]; return(Result); /* make local copy */ - strcpy(Name,filename); - -#ifdef NOT_USED - /* if filename contains a node specification (! or ::), we will try to access - the file via DECNET, but we do not stat it..., just return success - with some fake information... */ - if (HTVMS_checkDecnet(Name)) - { - /* set up fake info, only the one we use... */ - info->st_dev = NULL; - info->st_ino[0] = 0; - info->st_ino[1] = 0; - info->st_ino[2] = 0; - info->st_mode = S_IFREG | S_IREAD; /* assume it is a regular Readable file */ - info->st_nlink = NULL; - info->st_uid = 0; - info->st_gid = 0; - info->st_rdev = 0; - info->st_size = 0; - info->st_atime = time(NULL); - info->st_mtime = time(NULL); - info->st_ctime = time(NULL); - - return(0); - } -#endif /* NOT_USED */ + StrAllocCopy(Name,filename); /* failed,so do device search in case root is requested */ if (!strcmp(Name,"/")) @@ -374,7 +350,7 @@ char Name[256]; Ptr = strchr(Name+1,'/'); if ((Ptr == NULL) && (Name[0] == '/')) { /* device only... */ - strcat(Name,"/000000/000000"); + StrAllocCat(Name, "/000000/000000"); } if (Ptr != NULL) @@ -383,10 +359,10 @@ char Name[256]; if ((Ptr2 == NULL) && (Name[0] == '/')) { char End[256]; - strcpy(End,Ptr); + LYstrncpy(End, Ptr, sizeof(End) - 1); *(Ptr+1) = '\0'; - strcat(Name,"000000"); - strcat(Name,End); + StrAllocCat(Name, "000000"); + StrAllocCat(Name, End); } } @@ -396,7 +372,7 @@ char Name[256]; return(Result); /* add .DIR and try again */ - strcat(Name,".dir"); + StrAllocCat(Name, ".dir"); Result = stat(Name,info); return(Result); } @@ -477,7 +453,7 @@ char *closebracket; long status; struct dsc$descriptor_s entryname_desc; struct dsc$descriptor_s dirname_desc; -char DirEntry[256]; +static char *DirEntry; char VMSentry[256]; char UnixEntry[256]; int index; @@ -488,11 +464,13 @@ char *dot; /* or like /disk$user/duns/www/test/multi/ */ /* DirEntry should look like disk$user:[duns.www.test]multi in both cases */ /* dir.dirname should look like disk$user:[duns.www.test.multi] */ - strcpy(UnixEntry,dirname); + sprintf(UnixEntry, "%.*s", sizeof(UnixEntry) - 2, dirname); if (UnixEntry[strlen(UnixEntry)-1] != '/') strcat(UnixEntry,"/"); - strcpy(DirEntry, HTVMS_name("",UnixEntry)); + StrAllocCopy(DirEntry, HTVMS_name("",UnixEntry)); + if (strlen(DirEntry) > sizeof(dir.dirname) - 1) + return (NULL); strcpy(dir.dirname, DirEntry); index = strlen(DirEntry) - 1; @@ -504,24 +482,25 @@ char *dot; char *openbr = strrchr(DirEntry,'['); if (!openbr) { /* convert disk$user: into disk$user:[000000]000000.dir */ - strcpy(dir.dirname, DirEntry); - strcat(dir.dirname, "[000000]"); - strcat(DirEntry,"[000000]000000.dir"); + if (strlen(dir.dirname) > sizeof(dir.dirname) - 10) + return (NULL); + sprintf(dir.dirname, "%.*s[000000]", sizeof(dir.dirname) - 9, DirEntry); + StrAllocCat(DirEntry,"[000000]000000.dir"); } else { char End[256]; strcpy(End,openbr+1); *(openbr+1) = '\0'; - strcat(DirEntry,"000000]"); - strcat(DirEntry,End); - strcat(DirEntry,".dir"); + StrAllocCat(DirEntry,"000000]"); + StrAllocCat(DirEntry,End); + StrAllocCat(DirEntry,".dir"); } } else { *dot = ']'; - strcat(DirEntry,".dir"); + StrAllocCat(DirEntry,".dir"); } dir.context = 0; @@ -545,16 +524,8 @@ char *dot; return(NULL); } -#if 0 - /* now correct dirname, which looks like disk$user:[duns.www.test]multi */ - /* and should look like disk$user:[duns.www.test.multi] */ - closebracket = strchr(dir.dirname,']'); - *closebracket = '.'; - closebracket = strstr(dir.dirname,".dir"); - *closebracket = '\0'; - strcat(dir.dirname,"]"); -#endif - + if (strlen(dir.dirname) > sizeof(dir.dirname) - 10) + return (NULL); if (HTVMSFileVersions) strcat(dir.dirname,"*.*;*"); else @@ -663,12 +634,6 @@ PRIVATE void free_VMSEntryInfo_contents ARGS1(VMSEntryInfo *,entry_info) /* dont free the struct */ } -#define FILE_BY_NAME 0 -#define FILE_BY_TYPE 1 -#define FILE_BY_SIZE 2 -#define FILE_BY_DATE 3 -extern BOOLEAN HTfileSortMethod; /* specifies the method of sorting */ - PUBLIC int compare_VMSEntryInfo_structs ARGS2(VMSEntryInfo *,entry1, VMSEntryInfo *,entry2) { diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c index ad6f73ba..c5ed3338 100644 --- a/WWW/Library/Implementation/HTWAIS.c +++ b/WWW/Library/Implementation/HTWAIS.c @@ -87,8 +87,6 @@ #define HEX_ESCAPE '%' -extern HTCJKlang HTCJK; - extern int WWW_TraceFlag; /* Control diagnostic output */ extern FILE * logfile; /* Log file output */ @@ -266,7 +264,9 @@ PRIVATE char * WWW_from_WAIS ARGS1( static char buf[BIG]; char * q = buf; char * p = (docid->bytes); + char * result = NULL; int i, l; + if (TRACE) { char *p; fprintf(tfp, "WAIS id (%d bytes) is ", (int)docid->size); @@ -312,13 +312,8 @@ PRIVATE char * WWW_from_WAIS ARGS1( } *q++ = 0; /* Terminate string */ CTRACE((tfp, "WWW form of id: %s\n", buf)); - { - char * result = (char *)malloc(strlen(buf)+1); - if (!result) - outofmem(__FILE__, "WWW_from_WAIS"); - strcpy(result, buf); - return result; - } + StrAllocCopy(result, buf); + return result; } /* WWW_from_WAIS */ /* Transform URL into WAIS document identifier diff --git a/WWW/Library/Implementation/crypt.c b/WWW/Library/Implementation/crypt.c deleted file mode 100644 index 3645f63e..00000000 --- a/WWW/Library/Implementation/crypt.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * UFC-crypt: ultra fast crypt(3) implementation - * - * Copyright (C) 1991, 1992, Free Software Foundation, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * @(#)crypt.c 2.19 5/28/92 - * - * Semiportable C version - * - */ - -#include <HTUtils.h> - -#include <ufc-crypt.h> - -#include <LYLeaks.h> - -#ifdef _UFC_32_ - -/* - * 32 bit version - */ - -extern long32 _ufc_keytab[16][2]; -extern long32 _ufc_sb0[], _ufc_sb1[], _ufc_sb2[], _ufc_sb3[]; - -#define SBA(sb, v) (*(long32*)((char*)(sb)+(v))) - -static ufc_long ary[4]; - -ufc_long *_ufc_doit(l1, l2, r1, r2, itr) - ufc_long l1, l2, r1, r2, itr; - { int i; - long32 s, *k; - register long32 *sb0 = _ufc_sb0; - register long32 *sb1 = _ufc_sb1; - register long32 *sb2 = _ufc_sb2; - register long32 *sb3 = _ufc_sb3; - - while(itr--) { - k = &_ufc_keytab[0][0]; - for(i=8; i--; ) { - s = *k++ ^ r1; - l1 ^= SBA(sb1, s & 0xffff); l2 ^= SBA(sb1, (s & 0xffff)+4); - l1 ^= SBA(sb0, s >>= 16); l2 ^= SBA(sb0, (s) +4); - s = *k++ ^ r2; - l1 ^= SBA(sb3, s & 0xffff); l2 ^= SBA(sb3, (s & 0xffff)+4); - l1 ^= SBA(sb2, s >>= 16); l2 ^= SBA(sb2, (s) +4); - - s = *k++ ^ l1; - r1 ^= SBA(sb1, s & 0xffff); r2 ^= SBA(sb1, (s & 0xffff)+4); - r1 ^= SBA(sb0, s >>= 16); r2 ^= SBA(sb0, (s) +4); - s = *k++ ^ l2; - r1 ^= SBA(sb3, s & 0xffff); r2 ^= SBA(sb3, (s & 0xffff)+4); - r1 ^= SBA(sb2, s >>= 16); r2 ^= SBA(sb2, (s) +4); - } - s=l1; l1=r1; r1=s; s=l2; l2=r2; r2=s; - } - ary[0] = l1; ary[1] = l2; ary[2] = r1; ary[3] = r2; - return ary; - } - -#endif - -#ifdef _UFC_64_ - -/* - * 64 bit version - */ - -extern long64 _ufc_keytab[16]; -extern long64 _ufc_sb0[], _ufc_sb1[], _ufc_sb2[], _ufc_sb3[]; - -#define SBA(sb, v) (*(long64*)((char*)(sb)+(v))) - -static ufc_long ary[4]; - -ufc_long *_ufc_doit(l1, l2, r1, r2, itr) - ufc_long l1, l2, r1, r2, itr; - { int i; - long64 l, r, s, *k; - register long64 *sb0 = _ufc_sb0; - register long64 *sb1 = _ufc_sb1; - register long64 *sb2 = _ufc_sb2; - register long64 *sb3 = _ufc_sb3; - - l = (((long64)l1) << 32) | ((long64)l2); - r = (((long64)r1) << 32) | ((long64)r2); - - while(itr--) { - k = &_ufc_keytab[0]; - for(i=8; i--; ) { - s = *k++ ^ r; - l ^= SBA(sb3, (s >> 0) & 0xffff); - l ^= SBA(sb2, (s >> 16) & 0xffff); - l ^= SBA(sb1, (s >> 32) & 0xffff); - l ^= SBA(sb0, (s >> 48) & 0xffff); - - s = *k++ ^ l; - r ^= SBA(sb3, (s >> 0) & 0xffff); - r ^= SBA(sb2, (s >> 16) & 0xffff); - r ^= SBA(sb1, (s >> 32) & 0xffff); - r ^= SBA(sb0, (s >> 48) & 0xffff); - } - s=l; l=r; r=s; - } - - ary[0] = l >> 32; ary[1] = l & 0xffffffff; - ary[2] = r >> 32; ary[3] = r & 0xffffffff; - return ary; - } - -#endif diff --git a/WWW/Library/Implementation/crypt_util.c b/WWW/Library/Implementation/crypt_util.c deleted file mode 100644 index 8680464a..00000000 --- a/WWW/Library/Implementation/crypt_util.c +++ /dev/null @@ -1,977 +0,0 @@ -/* - * UFC-crypt: ultra fast crypt(3) implementation - * - * Copyright (C) 1991, 1992, Free Software Foundation, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * @(#)crypt_util.c 2.40 09/21/92 - * - * Support routines - * - */ - -#include <HTUtils.h> - -#ifndef STATIC -#define STATIC static -#endif - -#ifndef DOS -#include <patchlevel.h> -#include <ufc-crypt.h> -#else -/* - * Thanks to greg%wind@plains.NoDak.edu (Greg W. Wettstein) - * for DOS patches - */ -#include <pl.h> -#include <ufc.h> -#endif - -#include <LYLeaks.h> - -static char patchlevel_str[] = PATCHLEVEL; - -/* - * Permutation done once on the 56 bit - * key derived from the original 8 byte ASCII key. - */ -static int pc1[56] = { - 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, - 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, - 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, - 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 -}; - -/* - * How much to rotate each 28 bit half of the pc1 permutated - * 56 bit key before using pc2 to give the i' key - */ -static int rots[16] = { - 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 -}; - -/* - * Permutation giving the key - * of the i' DES round - */ -static int pc2[48] = { - 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, - 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, - 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, - 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 -}; - -/* - * The E expansion table which selects - * bits from the 32 bit intermediate result. - */ -static int esel[48] = { - 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, - 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, - 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, - 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1 -}; -static int e_inverse[64]; - -/* - * Permutation done on the - * result of sbox lookups - */ -static int perm32[32] = { - 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, - 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 -}; - -/* - * The sboxes - */ -static int sbox[8][4][16]= { - { { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 }, - { 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 }, - { 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0 }, - { 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 } - }, - - { { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10 }, - { 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 }, - { 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15 }, - { 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 } - }, - - { { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }, - { 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 }, - { 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7 }, - { 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 } - }, - - { { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 }, - { 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 }, - { 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4 }, - { 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 } - }, - - { { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 }, - { 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 }, - { 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14 }, - { 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 } - }, - - { { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 }, - { 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 }, - { 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6 }, - { 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 } - }, - - { { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 }, - { 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 }, - { 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2 }, - { 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 } - }, - - { { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 }, - { 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 }, - { 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8 }, - { 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 } - } -}; - -/* - * This is the initial - * permutation matrix - */ -static int initial_perm[64] = { - 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, - 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 -}; - -/* - * This is the final - * permutation matrix - */ -static int final_perm[64] = { - 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, - 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, - 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, - 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 -}; - -/* - * The 16 DES keys in BITMASK format - */ -#ifdef _UFC_32_ -long32 _ufc_keytab[16][2]; -#endif -#ifdef _UFC_64_ -long64 _ufc_keytab[16]; -#endif - -#define ascii_to_bin(c) ((c)>='a'?(c-59):(c)>='A'?((c)-53):(c)-'.') -#define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.') - -/* Macro to set a bit (0..23) */ -#define BITMASK(i) ( (1L<<(11L-(i)%12L+3L)) << ((i)<12L?16L:0L) ) - -/* - * sb arrays: - * - * Workhorses of the inner loop of the DES implementation. - * They do sbox lookup, shifting of this value, 32 bit - * permutation and E permutation for the next round. - * - * Kept in 'BITMASK' format. - */ - -#ifdef _UFC_32_ -long32 _ufc_sb0[8192], _ufc_sb1[8192], _ufc_sb2[8192], _ufc_sb3[8192]; -static long32 *sb[4] = {_ufc_sb0, _ufc_sb1, _ufc_sb2, _ufc_sb3}; -#endif - -#ifdef _UFC_64_ -long64 _ufc_sb0[4096], _ufc_sb1[4096], _ufc_sb2[4096], _ufc_sb3[4096]; -static long64 *sb[4] = {_ufc_sb0, _ufc_sb1, _ufc_sb2, _ufc_sb3}; -#endif - -/* - * eperm32tab: do 32 bit permutation and E selection - * - * The first index is the byte number in the 32 bit value to be permuted - * - second - is the value of this byte - * - third - selects the two 32 bit values - * - * The table is used and generated internally in init_des to speed it up - */ -static ufc_long eperm32tab[4][256][2]; - -/* - * do_pc1: permform pc1 permutation in the key schedule generation. - * - * The first index is the byte number in the 8 byte ASCII key - * - second - - the two 28 bits halfs of the result - * - third - selects the 7 bits actually used of each byte - * - * The result is kept with 28 bit per 32 bit with the 4 most significant - * bits zero. - */ -static ufc_long do_pc1[8][2][128]; - -/* - * do_pc2: permform pc2 permutation in the key schedule generation. - * - * The first index is the septet number in the two 28 bit intermediate values - * - second - - - septet values - * - * Knowledge of the structure of the pc2 permutation is used. - * - * The result is kept with 28 bit per 32 bit with the 4 most significant - * bits zero. - */ -static ufc_long do_pc2[8][128]; - -/* - * efp: undo an extra e selection and do final - * permutation giving the DES result. - * - * Invoked 6 bit a time on two 48 bit values - * giving two 32 bit longs. - */ -static ufc_long efp[16][64][2]; - -/* - * revfinal: undo final permutation and do E expension. - * - * Invoked 6 bit a time on DES output - * giving 4 32 bit longs. - */ -static ufc_long revfinal[11][64][4]; - - -static unsigned char bytemask[8] = { - 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 -}; - -static ufc_long longmask[32] = { - 0x80000000, 0x40000000, 0x20000000, 0x10000000, - 0x08000000, 0x04000000, 0x02000000, 0x01000000, - 0x00800000, 0x00400000, 0x00200000, 0x00100000, - 0x00080000, 0x00040000, 0x00020000, 0x00010000, - 0x00008000, 0x00004000, 0x00002000, 0x00001000, - 0x00000800, 0x00000400, 0x00000200, 0x00000100, - 0x00000080, 0x00000040, 0x00000020, 0x00000010, - 0x00000008, 0x00000004, 0x00000002, 0x00000001 -}; - -#ifdef DEBUG - -void pr_bits ARGS2( - ufc_long *, a, - int, n) -{ - ufc_long i, j, t, tmp; - n /= 8; - for(i = 0; i < (ufc_long) n; i++) { - tmp=0; - for(j = 0; j < 8; j++) { - t=8*i+j; - tmp|=(a[t/24] & BITMASK(t % 24))?bytemask[j]:0; - } - (void)printf("%02x ",tmp); - } - printf(" "); -} - -static void set_bits ARGS2( - ufc_long, v, - ufc_long *, b) -{ - ufc_long i; - *b = 0; - for(i = 0; i < 24; i++) { - if(v & longmask[8 + i]) - *b |= BITMASK(i); - } -} - -#endif - -/* - * Silly rewrite of 'bzero'. I do so - * because some machines don't have - * bzero and some don't have memset. - */ - -STATIC void clearmem(start, cnt) - char *start; - int cnt; - { while(cnt--) - *start++ = '\0'; - } - -static int initialized = 0; - -/* lookup a 6 bit value in sbox */ - -#define s_lookup(i,s) sbox[(i)][(((s)>>4) & 0x2)|((s) & 0x1)][((s)>>1) & 0xf]; - -/* - * Initialize unit - may be invoked directly - * by fcrypt users. - */ - -void init_des() - { int comes_from_bit; - int bit, sg; - ufc_long j; - ufc_long mask1, mask2; - - /* - * Create the do_pc1 table used - * to affect pc1 permutation - * when generating keys - */ - for(bit = 0; bit < 56; bit++) { - comes_from_bit = pc1[bit] - 1; - mask1 = bytemask[comes_from_bit % 8 + 1]; - mask2 = longmask[bit % 28 + 4]; - for(j = 0; j < 128; j++) { - if(j & mask1) - do_pc1[comes_from_bit / 8][bit / 28][j] |= mask2; - } - } - - /* - * Create the do_pc2 table used - * to affect pc2 permutation when - * generating keys - */ - for(bit = 0; bit < 48; bit++) { - comes_from_bit = pc2[bit] - 1; - mask1 = bytemask[comes_from_bit % 7 + 1]; - mask2 = BITMASK(bit % 24); - for(j = 0; j < 128; j++) { - if(j & mask1) - do_pc2[comes_from_bit / 7][j] |= mask2; - } - } - - /* - * Now generate the table used to do combined - * 32 bit permutation and e expansion - * - * We use it because we have to permute 16384 32 bit - * longs into 48 bit in order to initialize sb. - * - * Looping 48 rounds per permutation becomes - * just too slow... - * - */ - - clearmem((char*)eperm32tab, sizeof(eperm32tab)); - - for(bit = 0; bit < 48; bit++) { - ufc_long mask1,comes_from; - - comes_from = perm32[esel[bit]-1]-1; - mask1 = bytemask[comes_from % 8]; - - for(j = 256; j--;) { - if(j & mask1) - eperm32tab[comes_from / 8][j][bit / 24] |= BITMASK(bit % 24); - } - } - - /* - * Create the sb tables: - * - * For each 12 bit segment of an 48 bit intermediate - * result, the sb table precomputes the two 4 bit - * values of the sbox lookups done with the two 6 - * bit halves, shifts them to their proper place, - * sends them through perm32 and finally E expands - * them so that they are ready for the next - * DES round. - * - */ - for(sg = 0; sg < 4; sg++) { - int j1, j2; - int s1, s2; - - for(j1 = 0; j1 < 64; j1++) { - s1 = s_lookup(2 * sg, j1); - for(j2 = 0; j2 < 64; j2++) { - ufc_long to_permute, inx; - - s2 = s_lookup(2 * sg + 1, j2); - to_permute = (((ufc_long)s1 << 4) | - (ufc_long)s2) << (24 - 8 * (ufc_long)sg); - -#ifdef _UFC_32_ - inx = ((j1 << 6) | j2) << 1; - sb[sg][inx ] = eperm32tab[0][(to_permute >> 24) & 0xff][0]; - sb[sg][inx+1] = eperm32tab[0][(to_permute >> 24) & 0xff][1]; - sb[sg][inx ] |= eperm32tab[1][(to_permute >> 16) & 0xff][0]; - sb[sg][inx+1] |= eperm32tab[1][(to_permute >> 16) & 0xff][1]; - sb[sg][inx ] |= eperm32tab[2][(to_permute >> 8) & 0xff][0]; - sb[sg][inx+1] |= eperm32tab[2][(to_permute >> 8) & 0xff][1]; - sb[sg][inx ] |= eperm32tab[3][(to_permute) & 0xff][0]; - sb[sg][inx+1] |= eperm32tab[3][(to_permute) & 0xff][1]; -#endif -#ifdef _UFC_64_ - inx = ((j1 << 6) | j2); - sb[sg][inx] = - ((long64)eperm32tab[0][(to_permute >> 24) & 0xff][0] << 32) | - (long64)eperm32tab[0][(to_permute >> 24) & 0xff][1]; - sb[sg][inx] |= - ((long64)eperm32tab[1][(to_permute >> 16) & 0xff][0] << 32) | - (long64)eperm32tab[1][(to_permute >> 16) & 0xff][1]; - sb[sg][inx] |= - ((long64)eperm32tab[2][(to_permute >> 8) & 0xff][0] << 32) | - (long64)eperm32tab[2][(to_permute >> 8) & 0xff][1]; - sb[sg][inx] |= - ((long64)eperm32tab[3][(to_permute) & 0xff][0] << 32) | - (long64)eperm32tab[3][(to_permute) & 0xff][1]; -#endif - } - } - } - - /* - * Create an inverse matrix for esel telling - * where to plug out bits if undoing it - */ - for(bit=48; bit--;) { - e_inverse[esel[bit] - 1 ] = bit; - e_inverse[esel[bit] - 1 + 32] = bit + 48; - } - - /* - * create efp: the matrix used to - * undo the E expansion and effect final permutation - */ - clearmem((char*)efp, sizeof efp); - for(bit = 0; bit < 64; bit++) { - int o_bit, o_long; - ufc_long word_value, mask1, mask2; - int comes_from_f_bit, comes_from_e_bit; - int comes_from_word, bit_within_word; - - /* See where bit i belongs in the two 32 bit long's */ - o_long = bit / 32; /* 0..1 */ - o_bit = bit % 32; /* 0..31 */ - - /* - * And find a bit in the e permutated value setting this bit. - * - * Note: the e selection may have selected the same bit several - * times. By the initialization of e_inverse, we only look - * for one specific instance. - */ - comes_from_f_bit = final_perm[bit] - 1; /* 0..63 */ - comes_from_e_bit = e_inverse[comes_from_f_bit]; /* 0..95 */ - comes_from_word = comes_from_e_bit / 6; /* 0..15 */ - bit_within_word = comes_from_e_bit % 6; /* 0..5 */ - - mask1 = longmask[bit_within_word + 26]; - mask2 = longmask[o_bit]; - - for(word_value = 64; word_value--;) { - if(word_value & mask1) - efp[comes_from_word][word_value][o_long] |= mask2; - } - } - - - /* - * Create revfinal: an array to undo final - * the effects of efp - */ - clearmem((char*)revfinal, sizeof(revfinal)); - for(bit = 0; bit < 96; bit++) { - int ibit = initial_perm[esel[bit % 48] - 1 + ((bit >= 48) ? 32 : 0)] - 1; - mask1 = bytemask[ibit % 6 + 2]; - mask2 = BITMASK(bit % 24); - for(j = 64; j--;) { - if(j & mask1) { - revfinal[ibit / 6][j][bit / 24] |= mask2; - } - } - } - - initialized++; - } - -/* - * Process the elements of the sb table permuting the - * bits swapped in the expansion by the current salt. - */ - -#ifdef _UFC_32_ -STATIC void shuffle_sb(k, saltbits) - long32 *k; - ufc_long saltbits; - { ufc_long j; - long32 x; - for(j=4096; j--;) { - x = (k[0] ^ k[1]) & (long32)saltbits; - *k++ ^= x; - *k++ ^= x; - } - } -#endif - -#ifdef _UFC_64_ -STATIC void shuffle_sb(k, saltbits) - long64 *k; - ufc_long saltbits; - { ufc_long j; - long64 x; - for(j=4096; j--;) { - x = ((*k >> 32) ^ *k) & (long64)saltbits; - *k++ ^= (x << 32) | x; - } - } -#endif - -/* - * Setup the unit for a new salt - * Hopefully we'll not see a new salt in each crypt call. - */ - -static unsigned char current_salt[3] = "&&"; /* invalid value */ -static ufc_long current_saltbits = 0; -static int direction = 0; - -STATIC void setup_salt(s) - char *s; - { ufc_long i, j, saltbits; - - if(!initialized) - init_des(); - - if(s[0] == current_salt[0] && s[1] == current_salt[1]) - return; - current_salt[0] = s[0]; current_salt[1] = s[1]; - - /* - * This is the only crypt change to DES: - * entries are swapped in the expansion table - * according to the bits set in the salt. - */ - saltbits = 0; - for(i = 0; i < 2; i++) { - long c=ascii_to_bin(s[i]); -#ifdef notdef - /* - * Some applications do rely on illegal - * salts. It seems that UFC-crypt behaves - * identically to standard crypt - * implementations on illegal salts -- glad - */ - if(c < 0 || c > 63) - c = 0; -#endif - for(j = 0; j < 6; j++) { - if((c >> j) & 0x1) - saltbits |= BITMASK(6 * i + j); - } - } - - /* - * Permute the sb table values - * to reflect the changed e - * selection table - */ - shuffle_sb(_ufc_sb0, current_saltbits ^ saltbits); - shuffle_sb(_ufc_sb1, current_saltbits ^ saltbits); - shuffle_sb(_ufc_sb2, current_saltbits ^ saltbits); - shuffle_sb(_ufc_sb3, current_saltbits ^ saltbits); - - current_saltbits = saltbits; - } - -STATIC void ufc_mk_keytab(key) - char *key; - { ufc_long v1, v2, *k1; - int i; -#ifdef _UFC_32_ - long32 v, *k2 = &_ufc_keytab[0][0]; -#endif -#ifdef _UFC_64_ - long64 v, *k2 = &_ufc_keytab[0]; -#endif - - v1 = v2 = 0; k1 = &do_pc1[0][0][0]; - for(i = 8; i--;) { - v1 |= k1[*key & 0x7f]; k1 += 128; - v2 |= k1[*key++ & 0x7f]; k1 += 128; - } - - for(i = 0; i < 16; i++) { - k1 = &do_pc2[0][0]; - - v1 = (v1 << rots[i]) | (v1 >> (28 - rots[i])); - v = k1[(v1 >> 21) & 0x7f]; k1 += 128; - v |= k1[(v1 >> 14) & 0x7f]; k1 += 128; - v |= k1[(v1 >> 7) & 0x7f]; k1 += 128; - v |= k1[(v1 ) & 0x7f]; k1 += 128; - -#ifdef _UFC_32_ - *k2++ = v; - v = 0; -#endif -#ifdef _UFC_64_ - v <<= 32; -#endif - - v2 = (v2 << rots[i]) | (v2 >> (28 - rots[i])); - v |= k1[(v2 >> 21) & 0x7f]; k1 += 128; - v |= k1[(v2 >> 14) & 0x7f]; k1 += 128; - v |= k1[(v2 >> 7) & 0x7f]; k1 += 128; - v |= k1[(v2 ) & 0x7f]; - - *k2++ = v; - } - - direction = 0; - } - -/* - * Undo an extra E selection and do final permutations - */ - -ufc_long *_ufc_dofinalperm(l1, l2, r1, r2) - ufc_long l1,l2,r1,r2; - { ufc_long v1, v2, x; - static ufc_long ary[2]; - - x = (l1 ^ l2) & current_saltbits; l1 ^= x; l2 ^= x; - x = (r1 ^ r2) & current_saltbits; r1 ^= x; r2 ^= x; - - v1=v2=0; l1 >>= 3; l2 >>= 3; r1 >>= 3; r2 >>= 3; - - v1 |= efp[15][ r2 & 0x3f][0]; v2 |= efp[15][ r2 & 0x3f][1]; - v1 |= efp[14][(r2 >>= 6) & 0x3f][0]; v2 |= efp[14][ r2 & 0x3f][1]; - v1 |= efp[13][(r2 >>= 10) & 0x3f][0]; v2 |= efp[13][ r2 & 0x3f][1]; - v1 |= efp[12][(r2 >>= 6) & 0x3f][0]; v2 |= efp[12][ r2 & 0x3f][1]; - - v1 |= efp[11][ r1 & 0x3f][0]; v2 |= efp[11][ r1 & 0x3f][1]; - v1 |= efp[10][(r1 >>= 6) & 0x3f][0]; v2 |= efp[10][ r1 & 0x3f][1]; - v1 |= efp[ 9][(r1 >>= 10) & 0x3f][0]; v2 |= efp[ 9][ r1 & 0x3f][1]; - v1 |= efp[ 8][(r1 >>= 6) & 0x3f][0]; v2 |= efp[ 8][ r1 & 0x3f][1]; - - v1 |= efp[ 7][ l2 & 0x3f][0]; v2 |= efp[ 7][ l2 & 0x3f][1]; - v1 |= efp[ 6][(l2 >>= 6) & 0x3f][0]; v2 |= efp[ 6][ l2 & 0x3f][1]; - v1 |= efp[ 5][(l2 >>= 10) & 0x3f][0]; v2 |= efp[ 5][ l2 & 0x3f][1]; - v1 |= efp[ 4][(l2 >>= 6) & 0x3f][0]; v2 |= efp[ 4][ l2 & 0x3f][1]; - - v1 |= efp[ 3][ l1 & 0x3f][0]; v2 |= efp[ 3][ l1 & 0x3f][1]; - v1 |= efp[ 2][(l1 >>= 6) & 0x3f][0]; v2 |= efp[ 2][ l1 & 0x3f][1]; - v1 |= efp[ 1][(l1 >>= 10) & 0x3f][0]; v2 |= efp[ 1][ l1 & 0x3f][1]; - v1 |= efp[ 0][(l1 >>= 6) & 0x3f][0]; v2 |= efp[ 0][ l1 & 0x3f][1]; - - ary[0] = v1; ary[1] = v2; - return ary; - } - -/* - * crypt only: convert from 64 bit to 11 bit ASCII - * prefixing with the salt - */ - -STATIC char *output_conversion(v1, v2, salt) - ufc_long v1, v2; - char *salt; - { static char outbuf[14]; - int i, s, shf; - - outbuf[0] = salt[0]; - outbuf[1] = salt[1] ? salt[1] : salt[0]; - - for(i = 0; i < 5; i++) { - shf = (26 - 6 * i); /* to cope with MSC compiler bug */ - outbuf[i + 2] = (char) bin_to_ascii((v1 >> shf) & 0x3f); - } - - s = (v2 & 0xf) << 2; - v2 = (v2 >> 2) | ((v1 & 0x3) << 30); - - for(i = 5; i < 10; i++) { - shf = (56 - 6 * i); - outbuf[i + 2] = (char) bin_to_ascii((v2 >> shf) & 0x3f); - } - - outbuf[12] = (char) bin_to_ascii(s); - outbuf[13] = 0; - - return outbuf; - } - -ufc_long *_ufc_doit(); - -/* - * UNIX crypt function - */ - -char *crypt(key, salt) - char *key, *salt; - { ufc_long *s; - char ktab[9]; - - /* - * Hack DES tables according to salt - */ - setup_salt(salt); - - /* - * Setup key schedule - */ - clearmem(ktab, sizeof ktab); - (void)strncpy(ktab, key, 8); - ufc_mk_keytab(ktab); - - /* - * Go for the 25 DES encryptions - */ - s = _ufc_doit((ufc_long)0, (ufc_long)0, - (ufc_long)0, (ufc_long)0, (ufc_long)25); - /* - * Do final permutations - */ - s = _ufc_dofinalperm(s[0], s[1], s[2], s[3]); - - /* - * And convert back to 6 bit ASCII - */ - return output_conversion(s[0], s[1], salt); - } - -/* - * To make fcrypt users happy. - * They don't need to call init_des. - */ - -char *fcrypt(key, salt) - char *key; - char *salt; - { return crypt(key, salt); - } - -/* - * UNIX encrypt function. Takes a bitvector - * represented by one byte per bit and - * encrypt/decrypt according to edflag - */ - -void encrypt(block, edflag) - char *block; - int edflag; - { ufc_long l1, l2, r1, r2, *s; - int i; - - /* - * Undo any salt changes to E expansion - */ - setup_salt(".."); - - /* - * Reverse key table if - * changing operation (encrypt/decrypt) - */ - if((edflag == 0) != (direction == 0)) { - for(i = 0; i < 8; i++) { -#ifdef _UFC_32_ - long32 x; - x = _ufc_keytab[15-i][0]; - _ufc_keytab[15-i][0] = _ufc_keytab[i][0]; - _ufc_keytab[i][0] = x; - - x = _ufc_keytab[15-i][1]; - _ufc_keytab[15-i][1] = _ufc_keytab[i][1]; - _ufc_keytab[i][1] = x; -#endif -#ifdef _UFC_64_ - long64 x; - x = _ufc_keytab[15-i]; - _ufc_keytab[15-i] = _ufc_keytab[i]; - _ufc_keytab[i] = x; -#endif - } - direction = edflag; - } - - /* - * Do initial permutation + E expansion - */ - i = 0; - for(l1 = 0; i < 24; i++) { - if(block[initial_perm[esel[i]-1]-1]) - l1 |= BITMASK(i); - } - for(l2 = 0; i < 48; i++) { - if(block[initial_perm[esel[i]-1]-1]) - l2 |= BITMASK(i-24); - } - - i = 0; - for(r1 = 0; i < 24; i++) { - if(block[initial_perm[esel[i]-1+32]-1]) - r1 |= BITMASK(i); - } - for(r2 = 0; i < 48; i++) { - if(block[initial_perm[esel[i]-1+32]-1]) - r2 |= BITMASK(i-24); - } - - /* - * Do DES inner loops + final conversion - */ - s = _ufc_doit(l1, l2, r1, r2, (ufc_long)1); - /* - * Do final permutations - */ - s = _ufc_dofinalperm(s[0], s[1], s[2], s[3]); - - /* - * And convert to bit array - */ - l1 = s[0]; r1 = s[1]; - for(i = 0; i < 32; i++) { - *block++ = (l1 & longmask[i]) != 0; - } - for(i = 0; i < 32; i++) { - *block++ = (r1 & longmask[i]) != 0; - } - - } - -/* - * UNIX setkey function. Take a 64 bit DES - * key and setup the machinery. - */ - -void setkey(key) - char *key; - { int i,j; - unsigned char c; - unsigned char ktab[8]; - - setup_salt(".."); /* be sure we're initialized */ - - for(i = 0; i < 8; i++) { - for(j = 0, c = 0; j < 8; j++) - c = (c << 1) | *key++; - ktab[i] = c >> 1; - } - - ufc_mk_keytab(ktab); - } - -/* - * Ultrix crypt16 function, thanks to pcl@convex.oxford.ac.uk (Paul Leyland) - */ - -char *crypt16(key, salt) - char *key, *salt; - { ufc_long *s, *t; - char ktab[9], ttab[9]; - static char q[14], res[25]; - /* - * Hack DES tables according to salt - */ - setup_salt(salt); - - /* - * Setup key schedule - */ - clearmem(ktab, sizeof ktab); - (void)strncpy(ktab, key, 8); - ufc_mk_keytab(ktab); - - /* - * Go for first 20 DES encryptions - */ - s = _ufc_doit((ufc_long)0, (ufc_long)0, - (ufc_long)0, (ufc_long)0, (ufc_long)20); - - /* - * And convert back to 6 bit ASCII - */ - strcpy (res, output_conversion(s[0], s[1], salt)); - - clearmem(ttab, sizeof ttab); - if (strlen (key) > 8) (void)strncpy(ttab, key+8, 8); - ufc_mk_keytab(ttab); - - /* - * Go for second 5 DES encryptions - */ - t = _ufc_doit((ufc_long)0, (ufc_long)0, - (ufc_long)0, (ufc_long)0, (ufc_long)5); - /* - * And convert back to 6 bit ASCII - */ - strcpy (q, output_conversion(t[0], t[1], salt)); - strcpy (res+13, q+2); - - clearmem(ktab, sizeof ktab); - (void)strncpy(ktab, key, 8); - ufc_mk_keytab(ktab); - - return res; - } - -/* - * Experimental -- not supported -- may choke your dog - */ - -void ufc_setup_password(cookie, s) - long *cookie; - char *s; - { char c; - int i; - ufc_long x; - ufc_long dl1, dl2, dr1, dr2; - - setup_salt(s); - dl1 = dl2 = dr1 = dr2 = 0; - for(i = 0, s += 2; (c = *s++) != 0; i++) { - int x = ascii_to_bin(c); - dl1 |= revfinal[i][x][0]; - dl2 |= revfinal[i][x][1]; - dr1 |= revfinal[i][x][2]; - dr2 |= revfinal[i][x][3]; - } - x = (dl1 ^ dl2) & current_saltbits; - x = (dr1 ^ dr2) & current_saltbits; - cookie[0] = dl1 ^ x; cookie[1] = dl2 ^ x; - cookie[2] = dr1 ^ x; cookie[3] = dr2 ^ x; - } - -void ufc_do_pw(cookie, guess) - long *cookie; - char *guess; - { char ktab[9]; - ufc_long *s; - clearmem(ktab, sizeof ktab); - (void)strncpy(ktab, guess, 8); - ufc_mk_keytab(ktab); - s = _ufc_doit((ufc_long)0, (ufc_long)0, - (ufc_long)0, (ufc_long)0, (ufc_long)25); - cookie[0] = s[0]; cookie[1] = s[1]; - cookie[2] = s[2]; cookie[3] = s[3]; - } diff --git a/WWW/Library/Implementation/getline.c b/WWW/Library/Implementation/getline.c deleted file mode 100644 index 370c5a6e..00000000 --- a/WWW/Library/Implementation/getline.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -/* CHANGED FOR VMS */ -/* - * <getline.c> - */ - -#include <HTUtils.h> - -#include <LYLeaks.h> - -/* Read up to (and including) a newline from STREAM into *LINEPTR - (and null-terminate it). *LINEPTR is a pointer returned from malloc (or - NULL), pointing to *N characters of space. It is realloc'd as - necessary. Returns the number of characters read (not including the - null terminator), or -1 on error or EOF. */ - -int getline(char **lineptr, size_t *n, FILE *stream) -{ -static char line[256]; -char *ptr; -unsigned int len; - - if (lineptr == NULL || n == NULL) - { -#ifdef _WINDOWS - WSASetLastError(EINVAL); -#else - SOCKET_ERRNO = EINVAL; -#endif - return -1; - } - - if (ferror (stream)) - return -1; - - if (feof(stream)) - return -1; - - fgets(line,256,stream); - - ptr = strchr(line,'\n'); - if (ptr) - *ptr = '\0'; - - len = strlen(line); - - if ((len+1) < 256) - { - ptr = realloc(*lineptr, 256); - if (ptr == NULL) - return(-1); - *lineptr = ptr; - *n = 256; - } - - strcpy(*lineptr,line); - return(len); -} diff --git a/WWW/Library/Implementation/getpass.c b/WWW/Library/Implementation/getpass.c deleted file mode 100644 index f209da77..00000000 --- a/WWW/Library/Implementation/getpass.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -/* CHANGED FOR VMS */ - -/* - * <getpass.c> - */ - -#include <HTUtils.h> -#include <descrip.h> -#include <psldef.h> -#include <iodef.h> -#include <starlet.h> - -#include <LYLeaks.h> - -PUBLIC char * getpass ARGS1(CONST char *, prompt) -{ - static char *buf; - - int result; - $DESCRIPTOR(devnam,"SYS$INPUT"); - int chan; - int promptlen; - struct { - short result; - short count; - int info; - } iosb; - - promptlen = strlen(prompt); - - buf = (char *)malloc(256); - if (buf == NULL) - return(NULL); - - result = sys$assign(&devnam, &chan, PSL$C_USER, 0, 0); - - result = sys$qiow(0, chan, IO$_READPROMPT | IO$M_PURGE |IO$M_NOECHO, &iosb, 0, 0, - buf, 255, 0, 0, prompt, promptlen); - - buf[iosb.count] = '\0'; - - result = sys$dassgn(chan); - - return buf; -} diff --git a/WWW/Library/Implementation/patchlevel.h b/WWW/Library/Implementation/patchlevel.h deleted file mode 100644 index c37c8654..00000000 --- a/WWW/Library/Implementation/patchlevel.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * UFC-crypt: ultra fast crypt(3) implementation - * - * Copyright (C) 1991, 1992, Free Software Foundation, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * @(#)patchlevel.h 1.11 7/15/92 - * - */ - -#define PATCHLEVEL "UFC-crypt, patchlevel 1e, @(#)patchlevel.h 1.11 7/15/92" diff --git a/WWW/Library/Implementation/ufc-crypt.h b/WWW/Library/Implementation/ufc-crypt.h deleted file mode 100644 index a7cf7d4f..00000000 --- a/WWW/Library/Implementation/ufc-crypt.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * UFC-crypt: ultra fast crypt(3) implementation - * - * Copyright (C) 1991, 1992, Free Software Foundation, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * @(#)ufc-crypt.h 1.16 09/21/92 - * - * Definitions of datatypes - * - */ - -/* - * Requirements for datatypes: - * - * A datatype 'ufc_long' of at least 32 bit - * *and* - * A type 'long32' of exactly 32 bits (_UFC_32_) - * *or* - * A type 'long64' of exactly 64 bits (_UFC_64_) - * - * 'int' is assumed to be at least 8 bit - */ - -/* - * #ifdef's for various architectures - */ - -#ifdef cray -/* thanks to <hutton@opus.sdsc.edu> (Tom Hutton) for testing */ -typedef unsigned long ufc_long; -typedef unsigned long long64; -#define _UFC_64_ -#endif - -#ifdef convex -/* thanks to pcl@convex.oxford.ac.uk (Paul Leyland) for testing */ -typedef unsigned long ufc_long; -typedef long long long64; -#define _UFC_64_ -#endif - -#ifdef ksr -/* - * Note - the KSR machine does not define a unique symbol - * which we can check. So you MUST add '-Dksr' to your Makefile. - * Thanks to lijewski@theory.tc.cornell.edu (Mike Lijewski) for - * the patch. - */ -typedef unsigned long ufc_long; -typedef unsigned long long64; -#define _UFC_64_ -#endif - -/* - * For debugging 64 bit code etc with 'gcc' - */ - -#ifdef GCC3232 -typedef unsigned long ufc_long; -typedef unsigned long long32; -#define _UFC_32_ -#endif - -#ifdef GCC3264 -typedef unsigned long ufc_long; -typedef long long long64; -#define _UFC_64_ -#endif - -#ifdef GCC6432 -typedef long long ufc_long; -typedef unsigned long long32; -#define _UFC_32_ -#endif - -#ifdef GCC6464 -typedef long long ufc_long; -typedef long long long64; -#define _UFC_64_ -#endif - -/* - * Catch all for 99.95% of all UNIX machines - */ - -#ifndef _UFC_64_ -#ifndef _UFC_32_ -#define _UFC_32_ -typedef unsigned long ufc_long; -typedef unsigned long long32; -#endif -#endif - - diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h index 85ac581e..81db0187 100644 --- a/WWW/Library/Implementation/www_tcp.h +++ b/WWW/Library/Implementation/www_tcp.h @@ -112,6 +112,11 @@ typedef struct sockaddr_in SockA; /* See netinet/in.h */ #define AIX #endif /* _AIX */ +#ifdef __CYGWIN__ +#define _WINDOWS_NSL +#define WIN_EX +#endif /* __CYGWIN__ */ + #ifdef HAVE_FCNTL_H #include <fcntl.h> #else @@ -522,6 +527,7 @@ extern int errno; #ifdef word #undef word #endif /* word */ +#define select select_s #endif /* WATT32 */ #undef NETWRITE @@ -779,7 +785,7 @@ typedef unsigned int fd_set; /* * Macro for setting errno - only define this if you really can do it. */ -#if !defined(errno) && (!defined(VMS) || defined(UCX)) +#if defined(CAN_SET_ERRNO) || (!defined(errno) && (!defined(VMS) || defined(UCX))) #define set_errno(value) errno = value #else #define set_errno(value) /* we do not know how */ |