diff options
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r-- | WWW/Library/Implementation/CommonMakefile | 3 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAABrow.c | 25 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAAServ.c | 6 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAAUtil.c | 3 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAccess.c | 10 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.c | 9 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTDOS.c | 15 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 212 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFWriter.c | 16 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.c | 206 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFinger.c | 34 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFormat.c | 42 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTGopher.c | 231 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTNews.c | 8 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTRules.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTStyle.c | 11 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTP.c | 28 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTVMSUtils.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTWAIS.c | 8 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTWSRC.c | 4 |
20 files changed, 389 insertions, 490 deletions
diff --git a/WWW/Library/Implementation/CommonMakefile b/WWW/Library/Implementation/CommonMakefile index fda9f648..af0d200c 100644 --- a/WWW/Library/Implementation/CommonMakefile +++ b/WWW/Library/Implementation/CommonMakefile @@ -27,6 +27,9 @@ # LIBDIR Directory for installed library #______________________________________________________________________ +# If this env var is set to something else Some makes will use that instead +SHELL = /bin/sh + RANLIB = ranlib # .h files are distributed but originally are made from the diff --git a/WWW/Library/Implementation/HTAABrow.c b/WWW/Library/Implementation/HTAABrow.c index 8ee0731b..ca7979fe 100644 --- a/WWW/Library/Implementation/HTAABrow.c +++ b/WWW/Library/Implementation/HTAABrow.c @@ -632,9 +632,7 @@ PRIVATE char *compose_auth_string ARGS3( theHost = setup->server->hostname; if (setup->server->portnumber > 0 && setup->server->portnumber != 80) { - if (!(thePort = (char *)calloc(1, sizeof(char) * 40))) - outofmem(__FILE__, "compose_auth_string"); - sprintf(thePort, ":%d", setup->server->portnumber); + HTSprintf0(&thePort, ":%d", setup->server->portnumber); } /* * Set up the message for the username prompt, @@ -646,9 +644,7 @@ PRIVATE char *compose_auth_string ARGS3( len = strlen(realm->realmname) + strlen(theHost ? theHost : "??") + 50; - if (!(msg = (char *)calloc(1, sizeof(char) * len))) - outofmem(__FILE__, "compose_auth_string"); - sprintf(msg, gettext("Username for '%s' at %s '%s%s':"), + HTSprintf0(&msg, gettext("Username for '%s' at %s '%s%s':"), realm->realmname, (IsProxy ? "proxy" : "server"), (theHost ? theHost : "??"), @@ -911,11 +907,12 @@ PUBLIC char *HTAA_composeAuth ARGS4( /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */ default: { - char msg[100]; - sprintf(msg, "%s `%s'", + char *msg = NULL; + HTSprintf0(&msg, "%s `%s'", gettext("This client doesn't know how to compose proxy authorization information for scheme"), HTAAScheme_name(scheme)); HTAlert(msg); + FREE(msg); auth_string = NULL; } } /* switch scheme */ @@ -985,11 +982,12 @@ PUBLIC char *HTAA_composeAuth ARGS4( /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */ default: { - char msg[100]; - sprintf(msg, "%s `%s'", + char *msg = 0; + HTSprintf0(&msg, "%s `%s'", gettext("This client doesn't know how to compose authorization information for scheme"), HTAAScheme_name(scheme)); HTAlert(msg); + FREE(msg); auth_string = NULL; } } /* switch scheme */ @@ -1092,12 +1090,7 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4( (!IsProxy && 0==strcasecomp(fieldname, "WWW-Authenticate:"))) { if (!(arg1 && *arg1 && args && *args)) { - temp = (char *)calloc(1, strlen(line) + - (arg1 ? strlen(arg1) : 0) + - (args ? strlen(args) : 0) + 24); - if (!temp) - outofmem(__FILE__, "HTAA_shouldRetryWithAuth"); - sprintf(temp, gettext("Invalid header '%s%s%s%s%s'"), line, + HTSprintf0(&temp, gettext("Invalid header '%s%s%s%s%s'"), line, ((arg1 && *arg1) ? " " : ""), ((arg1 && *arg1) ? arg1 : ""), ((args && *args) ? " " : ""), diff --git a/WWW/Library/Implementation/HTAAServ.c b/WWW/Library/Implementation/HTAAServ.c index c3aebd48..b9a5be73 100644 --- a/WWW/Library/Implementation/HTAAServ.c +++ b/WWW/Library/Implementation/HTAAServ.c @@ -541,8 +541,7 @@ PRIVATE char *compose_scheme_specifics ARGS2(HTAAScheme, scheme, case HTAA_BASIC: { char *realm = HTAssocList_lookup(prot->values, "server"); - result = (char*)malloc(60); - sprintf(result, "realm=\"%s\"", + HTSprintf0(&result, "realm=\"%s\"", (realm ? realm : "UNKNOWN")); return result; } @@ -550,8 +549,7 @@ PRIVATE char *compose_scheme_specifics ARGS2(HTAAScheme, scheme, case HTAA_PUBKEY: { char *realm = HTAssocList_lookup(prot->values, "server"); - result = (char*)malloc(200); - sprintf(result, "realm=\"%s\", key=\"%s\"", + HTSprintf0(&result, "realm=\"%s\", key=\"%s\"", (realm ? realm : "UNKNOWN"), "PUBKEY-NOT-IMPLEMENTED"); return result; diff --git a/WWW/Library/Implementation/HTAAUtil.c b/WWW/Library/Implementation/HTAAUtil.c index f4407fc3..42515c02 100644 --- a/WWW/Library/Implementation/HTAAUtil.c +++ b/WWW/Library/Implementation/HTAAUtil.c @@ -433,8 +433,7 @@ PUBLIC HTAssocList *HTAA_parseArgList ARGS1(char *, str) if (*cur == ',') *(cur++) = '\0'; /* Terminate value */ /* else last value on line (already terminated by NULL) */ - StrAllocCopy(name, "nnn"); /* Room for item order number */ - sprintf(name, "%d", n); /* Item order number for name */ + HTSprintf0(&name, "%d", n); /* Item order number for name */ } HTAssocList_add(assoc_list, name, str); str = cur; diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 946a4a26..402afaaf 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -674,7 +674,7 @@ PRIVATE BOOL HTLoadDocument ARGS4( */ if (redirection_attempts > 10) { redirection_attempts = 0; - HTAlert(gettext("Redirection limit of 10 URL's reached.")); + HTAlert(TOO_MANY_REDIRECTIONS); return NO; } @@ -718,7 +718,7 @@ PRIVATE BOOL HTLoadDocument ARGS4( ** Don't exceed the redirection_attempts limit. - FM */ if (++redirection_attempts > 10) { - HTAlert(gettext("Redirection limit of 10 URL's reached.")); + HTAlert(TOO_MANY_REDIRECTIONS); redirection_attempts = 0; FREE(use_this_url_instead); return NO; @@ -1290,11 +1290,7 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS FILE * fp = NULL; CONST char * home = (CONST char*)getenv("HOME"); if (home != null) { - my_home_document = (char *)calloc(1, - (strlen(home) + 1 + strlen(PERSONAL_DEFAULT) + 1)); - if (my_home_document == NULL) - outofmem(__FILE__, "HTAnchorHome"); - sprintf(my_home_document, "%s/%s", home, PERSONAL_DEFAULT); + HTSprintf0(&my_home_document, "%s/%s", home, PERSONAL_DEFAULT); fp = fopen(my_home_document, "r"); } diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index 0c1eb7dd..53ce0c78 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -798,13 +798,8 @@ PUBLIC char * HTAnchor_address ARGS1( !((HTChildAnchor *)me)->tag) { /* it's an adult or no tag */ StrAllocCopy(addr, me->parent->address); } else { /* it's a named child */ - addr = malloc(2 + - strlen(me->parent->address) + - strlen(((HTChildAnchor *)me)->tag)); - if (addr == NULL) - outofmem(__FILE__, "HTAnchor_address"); - sprintf(addr, "%s#%s", - me->parent->address, ((HTChildAnchor *)me)->tag); + HTSprintf0(&addr, "%s#%s", + me->parent->address, ((HTChildAnchor *)me)->tag); } } return(addr); diff --git a/WWW/Library/Implementation/HTDOS.c b/WWW/Library/Implementation/HTDOS.c index 1d6b4a59..df506cd2 100644 --- a/WWW/Library/Implementation/HTDOS.c +++ b/WWW/Library/Implementation/HTDOS.c @@ -77,22 +77,13 @@ char * HTDOS_name ARGS1(char *, wwwname) if((cp_url[1] == '\\') || (cp_url[0] != '\\')) { -#if 0 - 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); */ + strcpy(wwwname, cp_url); /* 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); */ + strcpy(wwwname, cp_url+1); /* return(cp_url+1); */ } + return (wwwname); } diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index 8348b8f2..2392c439 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -507,6 +507,28 @@ PRIVATE int response ARGS1( return result/100; } +PRIVATE int send_cmd_1 ARGS1(char *, verb) +{ + char command[80]; + + sprintf(command, "%.*s%c%c", (int) sizeof(command)-4, verb, CR, LF); + return response (command); +} + +PRIVATE int send_cmd_2 ARGS2(char *, verb, char *, param) +{ + char *command = 0; + int status; + + HTSprintf0(&command, "%s %s%c%c", verb, param, CR, LF); + status = response (command); + FREE(command); + + return status; +} + +#define send_cwd(path) send_cmd_2("CWD", path) + /* * This function should try to set the macintosh server into binary mode. * Some servers need an additional letter after the MACB command. @@ -601,7 +623,7 @@ PRIVATE int get_connection ARGS2( HTParentAnchor *, anchor) { int status; - char * command; + char * command = 0; connection * con; char * username = NULL; char * password = NULL; @@ -664,9 +686,9 @@ PRIVATE int get_connection ARGS2( * away in a primitive fashion. */ if (!password) { - char tmp[256]; + char *tmp = NULL; - sprintf(tmp, "%s@%s", username, p1); + HTSprintf0(&tmp, "%s@%s", username, p1); /* * If the user@host is not equal to the last time through * or user_entered_password has no data then we need @@ -677,13 +699,14 @@ PRIVATE int get_connection ARGS2( !user_entered_password) { StrAllocCopy(last_username_and_host, tmp); - sprintf(tmp, gettext("Enter password for user %s@%s:"), - username, p1); + HTSprintf0(&tmp, gettext("Enter password for user %s@%s:"), + username, p1); FREE(user_entered_password); - user_entered_password = (char *)HTPromptPassword(tmp); + user_entered_password = HTPromptPassword(tmp); } /* else we already know the password */ password = user_entered_password; + FREE(tmp); } } @@ -756,19 +779,10 @@ PRIVATE int get_connection ARGS2( } StrAllocCopy(anchor->server, cp); - if (username && *username) { - command = (char*)malloc(10+strlen(username)+2+1); - if (command == NULL) - outofmem(__FILE__, "get_connection"); - sprintf(command, "USER %s%c%c", username, CR, LF); - } else { - command = (char*)malloc(24); - if (command == NULL) - outofmem(__FILE__, "get_connection"); - sprintf(command, "USER anonymous%c%c", CR, LF); - } - status = response(command); - FREE(command); + status = send_cmd_2("USER", (username && *username) + ? username + : "anonymous"); + if (status == HT_INTERRUPTED) { CTRACE (tfp, "HTFTP: Interrupted while sending username.\n"); _HTProgress (CONNECTION_INTERRUPTED); @@ -782,10 +796,7 @@ PRIVATE int get_connection ARGS2( /* * We have non-zero length password, so send it. - FM */ - command = (char*)malloc(10+strlen(password)+2+1); - if (command == NULL) - outofmem(__FILE__, "get_connection"); - sprintf(command, "PASS %s%c%c", password, CR, LF); + HTSprintf0(&command, "PASS %s%c%c", password, CR, LF); } else { /* * Create and send a mail address as the password. - FM @@ -824,10 +835,7 @@ PRIVATE int get_connection ARGS2( if (!(host) || strchr(host, '.') == NULL) host = ""; - command = (char*)malloc(10+strlen(user)+1+strlen(host)+2+1); - if (command == NULL) - outofmem(__FILE__, "get_connection"); - sprintf(command, "PASS %s@%s%c%c", user, host, CR, LF); + HTSprintf0(&command, "PASS %s@%s%c%c", user, host, CR, LF); FREE(user); } status = response(command); @@ -844,9 +852,7 @@ PRIVATE int get_connection ARGS2( FREE(username); if (status == 3) { - char temp[80]; - sprintf(temp, "ACCT noaccount%c%c", CR, LF); - status = response(temp); + status = send_cmd_1("ACCT noaccount"); if (status == HT_INTERRUPTED) { CTRACE (tfp, "HTFTP: Interrupted while sending password.\n"); _HTProgress (CONNECTION_INTERRUPTED); @@ -1198,7 +1204,7 @@ PRIVATE void set_years_and_date NOARGS } i++; sprintf(month, "%s%d", (i < 10 ? "0" : ""), i); - sprintf(date, "9999%s%s", month, day); + sprintf(date, "9999%.2s%.2s", month, day); TheDate = atoi(date); strcpy(ThisYear, (char *)ctime(&NowTime)+20); ThisYear[4] = '\0'; @@ -1422,12 +1428,12 @@ PRIVATE void parse_vms_dir_entry ARGS2( i = strlen(entry_info->filename); } else { i = ((strstr(entry_info->filename, "READ") - entry_info->filename) + 4); - if (!strncmp((char *)&entry_info->filename[i], "ME", 2)) { + if (!strncmp(&entry_info->filename[i], "ME", 2)) { i += 2; while (entry_info->filename[i] && entry_info->filename[i] != '.') { i++; } - } else if (!strncmp((char *)&entry_info->filename[i], ".ME", 3)) { + } else if (!strncmp(&entry_info->filename[i], ".ME", 3)) { i = strlen(entry_info->filename); } else { i = 0; @@ -1681,9 +1687,9 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2( if (strcmp((ThisYear+2), cp)) { /* Not this year, so show the year */ if (atoi(cp) < 70) { - sprintf((char *)&date[6], " 20%s", cp); + sprintf(&date[6], " 20%s", cp); } else { - sprintf((char *)&date[6], " 19%s", cp); + sprintf(&date[6], " 19%s", cp); } } else { /* Is this year, so show the time */ @@ -1692,7 +1698,7 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2( if (*(cpd+5) == 'P' || *(cpd+5) == 'p') i += 12; *(cpd+5) = '\0'; - sprintf((char*)&date[6], " %s%d:%s", + sprintf(&date[6], " %s%d:%s", (i < 10 ? "0" : ""), i, (cpd+3)); } StrAllocCopy(entry_info->date, date); @@ -1839,15 +1845,15 @@ PRIVATE void parse_cms_dir_entry ARGS2( if (strcmp((ThisYear+2), cpd)) { /* Not this year, so show the year. */ if (atoi(cpd) < 70) { - sprintf((char *)&date[6], " 20%s", cpd); + sprintf(&date[6], " 20%s", cpd); } else { - sprintf((char *)&date[6], " 19%s", cpd); + sprintf(&date[6], " 19%s", cpd); } } else { /* Is this year, so show the time. */ *(cps+2) = '\0'; /* Hour */ i = atoi(cps); - sprintf((char*)&date[6], " %s%d:%s", + sprintf(&date[6], " %s%d:%s", (i < 10 ? "0" : ""), i, (cps+3)); } StrAllocCopy(entry_info->date, date); @@ -2193,12 +2199,12 @@ PRIVATE int compare_EntryInfo_structs ARGS2( */ if (entry1->date[9] == ':') { strcpy(date1, "9999"); - strcpy(time1, (char *)&entry1->date[7]); + strcpy(time1, &entry1->date[7]); if (time1[0] == ' ') { time1[0] = '0'; } } else { - strcpy(date1, (char *)&entry1->date[8]); + strcpy(date1, &entry1->date[8]); strcpy(time1, "00:00"); } strncpy(month, entry1->date, 3); @@ -2211,7 +2217,7 @@ PRIVATE int compare_EntryInfo_structs ARGS2( i++; sprintf(month, "%s%d", (i < 10 ? "0" : ""), i); strcat(date1, month); - strncat(date1, (char *)&entry1->date[4], 2); + strncat(date1, &entry1->date[4], 2); date1[8] = '\0'; if (date1[6] == ' ' || date1[6] == HT_NON_BREAK_SPACE) { date1[6] = '0'; @@ -2224,12 +2230,12 @@ PRIVATE int compare_EntryInfo_structs ARGS2( strcat(date1, time1); if (entry2->date[9] == ':') { strcpy(date2, "9999"); - strcpy(time2, (char *)&entry2->date[7]); + strcpy(time2, &entry2->date[7]); if (time2[0] == ' ') { time2[0] = '0'; } } else { - strcpy(date2, (char *)&entry2->date[8]); + strcpy(date2, &entry2->date[8]); strcpy(time2, "00:00"); } strncpy(month, entry2->date, 3); @@ -2242,7 +2248,7 @@ PRIVATE int compare_EntryInfo_structs ARGS2( i++; sprintf(month, "%s%d", (i < 10 ? "0" : ""), i); strcat(date2, month); - strncat(date2, (char *)&entry2->date[4], 2); + strncat(date2, &entry2->date[4], 2); date2[8] = '\0'; if (date2[6] == ' ' || date2[6] == HT_NON_BREAK_SPACE) { date2[6] = '0'; @@ -2423,7 +2429,7 @@ AgainForMultiNet: BytesReceived += chunk->size; if (BytesReceived > BytesReported + 1024) { - sprintf(NumBytes,gettext("Transferred %d bytes"),BytesReceived); + sprintf(NumBytes, TRANSFERRED_X_BYTES, BytesReceived); HTProgress(NumBytes); BytesReported = BytesReceived; } @@ -2504,7 +2510,7 @@ unload_btree: else sprintf(string_buffer, " %dKb", entry_info->size/1024); - PUTS(string_buffer); + PUTS(string_buffer); } PUTC('\n'); /* end of this entry */ @@ -2617,8 +2623,7 @@ PUBLIC int HTFTPLoad ARGS4( int status; data_soc = status; - sprintf(command, "PASV%c%c", CR, LF); - status = response(command); + status = send_cmd_1("PASV"); if (status != 2) { if (status < 0) continue; /* retry or Bad return */ @@ -2644,7 +2649,7 @@ PUBLIC int HTFTPLoad ARGS4( /* Open connection for data: */ sprintf(command, - "ftp://%d.%d.%d.%d:%d/",h0,h1,h2,h3,passive_port); + "ftp://%d.%d.%d.%d:%d/",h0,h1,h2,h3,passive_port); status = HTDoConnect(name, "FTP", passive_port, &data_soc); if (status < 0) { @@ -2732,11 +2737,9 @@ PUBLIC int HTFTPLoad ARGS4( if ((cp2 = strchr((filename+1), '/')) != NULL) { *cp2 = '\0'; } - sprintf(command, "PWD%c%c", CR, LF); - status = response(command); + status = send_cmd_1("PWD"); if (status == 2 && response_text[5] == '/') { - sprintf(command, "CWD %s%c%c", (filename+1), CR, LF); - status = response(command); + status = send_cwd(filename+1); if (status == 2) { StrAllocCopy(fn, (filename+1)); if (cp2) { @@ -2813,8 +2816,7 @@ PUBLIC int HTFTPLoad ARGS4( ** Act on our setting if not already set. - FM */ char * mode = binary ? "I" : "A"; - sprintf(command, "TYPE %s%c%c", mode, CR, LF); - status = response(command); + status = send_cmd_2("TYPE", mode); if (status != 2) { init_help_message_cache(); /* to free memory */ return ((status < 0) ? status : -status); @@ -2858,13 +2860,12 @@ PUBLIC int HTFTPLoad ARGS4( filename[i] = '\0'; CTRACE(tfp, "HTFTP: Filename '%s'\n", filename); *cp1 = '\0'; - sprintf(command, "CWD %s%c%c", cp, CR, LF); - status = response (command); + status = send_cwd(cp); if (status != 2) { + char *dotslash = 0; if ((cp1=strchr(cp, '[')) != NULL) { *cp1++ = '\0'; - sprintf(command, "CWD %s%c%c", cp, CR, LF); - status = response (command); + status = send_cwd(cp); if (status != 2) { FREE(fname); init_help_message_cache(); /* to free memory */ @@ -2872,8 +2873,9 @@ PUBLIC int HTFTPLoad ARGS4( control->socket = -1; return ((status < 0) ? status : -status); } - sprintf(command, "CWD [.%s%c%c", cp1, CR, LF); - status = response (command); + HTSprintf0(&dotslash, "[.%s", cp1); + status = send_cwd(dotslash); + FREE(dotslash); if (status != 2) { FREE(fname); init_help_message_cache(); /* to free memory */ @@ -2902,17 +2904,14 @@ PUBLIC int HTFTPLoad ARGS4( strcat(cp, "["); strcat(cp, filename); strcat(cp, "]"); - sprintf(command, "CWD %s%c%c", cp, CR, LF); - status = response (command); + status = send_cwd(cp); if (status != 2) { *cp1 = '\0'; strcat(cp, "[000000]"); - sprintf(command, "CWD %s%c%c", cp, CR, LF); - status = response (command); + status = send_cwd(cp); if (status != 2) { *cp1 = '\0'; - sprintf(command, "CWD %s%c%c", cp, CR, LF); - status = response (command); + status = send_cwd(cp); if (status != 2) { FREE(fname); init_help_message_cache(); @@ -2927,12 +2926,10 @@ PUBLIC int HTFTPLoad ARGS4( } } } else if (0==strcmp(cp, (filename+1))) { - sprintf(command, "CWD %s%c%c", cp, CR, LF); - status = response (command); + status = send_cwd(cp); if (status != 2) { strcat(cp, ":"); - sprintf(command, "CWD %s%c%c", cp, CR, LF); - status = response (command); + status = send_cwd(cp); if (status != 2) { FREE(fname); init_help_message_cache(); /* to free memory */ @@ -2952,8 +2949,7 @@ PUBLIC int HTFTPLoad ARGS4( #ifdef MAINTAIN_CONNECTION /* Don't need this if always new connection - F.M. */ if (!included_device) { /** Get the current default VMS device:[directory] **/ - sprintf(command, "PWD%c%c", CR, LF); - status = response (command); + status = send_cmd_1("PWD"); if (status != 2) { FREE(fname); init_help_message_cache(); /* to free memory */ @@ -2964,12 +2960,21 @@ PUBLIC int HTFTPLoad ARGS4( /** Go to the VMS account's top directory **/ if ((cp=strchr(response_text, '[')) != NULL && (cp1=strrchr(response_text, ']')) != NULL) { - sprintf(command, "CWD %s", cp); - if ((cp2=strchr(cp, '.')) != NULL && cp2 < cp1) - sprintf(command+(cp2-cp)+4, "]%c%c", CR, LF); - else - sprintf(command+(cp1-cp)+4, "]%c%c", CR, LF); - status = response (command); + char *tmp = 0; + unsigned len = 4; + + StrAllocCopy(tmp, cp); + if ((cp2=strchr(cp, '.')) != NULL && cp2 < cp1) { + len += (cp2 - cp); + } else { + len += (cp1 - cp); + } + tmp[len] = 0; + StrAllocCat(tmp, "]"); + + status = send_cwd(tmp); + FREE(tmp); + if (status != 2) { FREE(fname); init_help_message_cache(); /* to free memory */ @@ -2986,8 +2991,7 @@ PUBLIC int HTFTPLoad ARGS4( (included_device && 0==strcmp(filename, "000000")) || (strlen(filename) == 1 && *filename == '/')) { isDirectory = YES; - sprintf(command, "LIST%c%c", CR, LF); - status = response (command); + status = send_cmd_1("LIST"); FREE(fname); if (status != 1) { /* Action not started */ @@ -3005,11 +3009,17 @@ PUBLIC int HTFTPLoad ARGS4( if (!included_device && (cp = strchr(filename, '/')) != NULL && (cp1 = strrchr(cp, '/')) != NULL && cp != cp1) { - sprintf(command, "CWD [.%s", cp+1); - sprintf(command+(cp1-cp)+5, "]%c%c", CR, LF); + char *tmp = 0; + + StrAllocCopy(tmp, cp+1); + strcpy(tmp + (cp1-cp) + 5, "]"); + while ((cp2 = strrchr(command, '/')) != NULL) *cp2 = '.'; - status = response(command); + + status = send_cwd(tmp); + FREE(tmp); + if (status != 2) { FREE(fname); init_help_message_cache(); /* to free memory */ @@ -3039,8 +3049,7 @@ PUBLIC int HTFTPLoad ARGS4( (0 == strncasecomp(filename+1, "anonymou.", 9) && strchr(filename+1, '/') == NULL)) { if (filename[1] != '\0') { - sprintf(command, "CWD %s%c%c", (filename+1), CR, LF); - status = response(command); + status = send_cwd(filename+1); if (status != 2) { /* Action not started */ init_help_message_cache(); /* to free memory */ @@ -3051,10 +3060,9 @@ PUBLIC int HTFTPLoad ARGS4( } isDirectory = YES; if (use_list) - sprintf(command, "LIST%c%c", CR, LF); + status = send_cmd_1("LIST"); else - sprintf(command, "NLST%c%c", CR, LF); - status = response (command); + status = send_cmd_1("NLST"); FREE(fname); if (status != 1) { /* Action not started */ @@ -3071,16 +3079,14 @@ PUBLIC int HTFTPLoad ARGS4( /** Otherwise, go to appropriate directory and adjust filename **/ while ((cp = strchr(filename, '/')) != NULL) { *cp++ = '\0'; - sprintf(command, "CWD %s%c%c", filename, CR, LF); - status = response(command); + status = send_cwd(filename); if (status == 2) { if (*cp == '\0') { isDirectory = YES; if (use_list) - sprintf(command, "LIST%c%c", CR, LF); + status = send_cmd_1("LIST"); else - sprintf(command, "NLST%c%c", CR, LF); - status = response (command); + status = send_cmd_1("NLST"); FREE(fname); if (status != 1) { /** Action not started **/ @@ -3110,8 +3116,7 @@ PUBLIC int HTFTPLoad ARGS4( ** which we're dealing with if we don't know yet. - FM */ if (!(type) || (type && *type != 'D')) { - sprintf(command, "RETR %s%c%c", filename, CR, LF); - status = response(command); + status = send_cmd_2("RETR", filename); } else { status = 5; /* Failed status set as flag. - FM */ } @@ -3120,16 +3125,13 @@ PUBLIC int HTFTPLoad ARGS4( if (strcmp(filename, "/")) init_help_message_cache(); - sprintf(command, "CWD %s%c%c", filename, CR, LF); - status = response(command); - + status = send_cwd(filename); if (status == 2) { /* Succeeded : let's NAME LIST it */ isDirectory = YES; - if (use_list) - sprintf(command, "LIST%c%c", CR, LF); - else - sprintf(command, "NLST%c%c", CR, LF); - status = response (command); + if (use_list) + status = send_cmd_1("LIST"); + else + status = send_cmd_1("NLST"); } } FREE(fname); diff --git a/WWW/Library/Implementation/HTFWriter.c b/WWW/Library/Implementation/HTFWriter.c index 6e4f8e42..d6176af8 100644 --- a/WWW/Library/Implementation/HTFWriter.c +++ b/WWW/Library/Implementation/HTFWriter.c @@ -264,23 +264,15 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( /* Make command to process file */ - me->end_command = (char *)malloc ( - (strlen (pres->command) + 10+ 3*strlen(fnam)) - * sizeof (char)); - if (me == NULL) outofmem(__FILE__, "SaveAndExecute"); - - sprintf (me->end_command, pres->command, fnam, fnam, fnam); + me->end_command = 0; + HTSprintf0(&(me->end_command), pres->command, fnam, fnam, fnam); me->remove_command = NULL; /* If needed, put into end_command */ #ifdef NOPE /* Make command to delete file */ - me->remove_command = (char *)malloc ( - (strlen (REMOVE_COMMAND) + 10+ strlen(fnam)) - * sizeof (char)); - if (me == NULL) outofmem(__FILE__, "SaveAndExecute"); - - sprintf (me->remove_command, REMOVE_COMMAND, fnam); + me->remove_command = 0; + HTSprintf0(&(me->remove_command), REMOVE_COMMAND, fnam); #endif me->announce = NO; diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index a1dc1dfe..f20d744e 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -151,6 +151,28 @@ int exists(char *filename) PRIVATE void free_suffixes NOPARAMS; #ifdef LONG_LIST +PRIVATE char *FormatStr ARGS2( + char *, start, + char *, entry) +{ + char fmt[512]; + char *buf = 0; + sprintf(fmt, "%%%.*ss", (int) sizeof(fmt) - 3, start); + HTSprintf0(&buf, fmt, entry); + return buf; +} + +PRIVATE char *FormatNum ARGS2( + char *, start, + int, entry) +{ + char fmt[512]; + char *buf = 0; + sprintf(fmt, "%%%.*sd", (int) sizeof(fmt) - 3, start); + HTSprintf0(&buf, fmt, entry); + return buf; +} + PRIVATE void LYListFmtParse ARGS5( char *, fmtstr, char *, file, @@ -164,8 +186,8 @@ PRIVATE void LYListFmtParse ARGS5( char *start; char *str = NULL; struct stat st; - char buf[512]; - char fmt[512]; + char *buf = NULL; + char tmp[LY_MAXPATH]; char type; char *name; time_t now; @@ -216,7 +238,6 @@ PRIVATE void LYListFmtParse ARGS5( s++; c = *s; /* the format char. or \0 */ *s = '\0'; - buf[0] = '\0'; switch (c) { case '\0': @@ -225,19 +246,18 @@ PRIVATE void LYListFmtParse ARGS5( case 'A': case 'a': /* anchor */ HTDirEntry(target, tail, entry); - sprintf(fmt, "%%%ss", start); - sprintf(buf, fmt, entry); + buf = FormatStr(start, entry); PUTS(buf); END(HTML_A); + *buf = '\0'; #ifdef S_IFLNK if (c != 'A' && S_ISLNK(st.st_mode) && - (len = readlink(file, buf, sizeof(buf))) >= 0) { + (len = readlink(file, tmp, sizeof(tmp))) >= 0) { PUTS(" -> "); - buf[len] = '\0'; - PUTS(buf); + tmp[len] = '\0'; + PUTS(tmp); } #endif - *buf = '\0'; break; case 'd': /* date */ @@ -247,32 +267,29 @@ PRIVATE void LYListFmtParse ARGS5( /* ** MMM DD HH:MM */ - sprintf(buf, "%.12s", datestr + 4); + sprintf(tmp, "%.12s", datestr + 4); else /* ** MMM DD YYYY */ - sprintf(buf, "%.7s %.4s ", datestr + 4, - datestr + 20); - sprintf(fmt, "%%%ss", start); - sprintf(buf, fmt, buf); + sprintf(tmp, "%.7s %.4s ", datestr + 4, + datestr + 20); + buf = FormatStr(start, tmp); break; case 's': /* size in bytes */ - sprintf(fmt, "%%%sd", start); - sprintf(buf, fmt, st.st_size); + buf = FormatNum(start, st.st_size); break; case 'K': /* size in Kilobytes but not for directories */ if (S_ISDIR(st.st_mode)) { - sprintf(fmt, "%%%ss ", start); - sprintf(buf, fmt, ""); + buf = FormatStr(start, ""); break; } /* FALL THROUGH */ case 'k': /* size in Kilobytes */ - sprintf(fmt, "%%%sdK", start); - sprintf(buf, fmt, (st.st_size+1023)/1024); + buf = FormatNum(start, (st.st_size+1023)/1024); + StrAllocCat(buf, "K"); break; case 'p': /* unix-style permission bits */ @@ -298,41 +315,33 @@ PRIVATE void LYListFmtParse ARGS5( #endif /* S_IFSOCK */ default: type = '?'; break; } - sprintf(buf, "%c%s%s%s", type, - PBIT(st.st_mode, 6, st.st_mode & S_ISUID), - PBIT(st.st_mode, 3, st.st_mode & S_ISGID), - PTBIT(st.st_mode, st.st_mode & S_ISVTX)); - sprintf(fmt, "%%%ss", start); - sprintf(buf, fmt, buf); + sprintf(tmp, "%c%s%s%s", type, + PBIT(st.st_mode, 6, st.st_mode & S_ISUID), + PBIT(st.st_mode, 3, st.st_mode & S_ISGID), + PTBIT(st.st_mode, st.st_mode & S_ISVTX)); + buf = FormatStr(start, tmp); break; case 'o': /* owner */ - sprintf(fmt, "%%%ss", start); name = HTAA_UidToName (st.st_uid); if (*name) { - sprintf(fmt, "%%%ss", start); - sprintf(buf, fmt, name); + buf = FormatStr(start, name); } else { - - sprintf(fmt, "%%%sd", start); - sprintf(buf, fmt, st.st_uid); + buf = FormatNum(start, st.st_uid); } break; case 'g': /* group */ name = HTAA_GidToName(st.st_gid); if (*name) { - sprintf(fmt, "%%%ss", start); - sprintf(buf, fmt, name); + buf = FormatStr(start, name); } else { - sprintf(fmt, "%%%sd", start); - sprintf(buf, fmt, st.st_gid); + buf = FormatNum(start, st.st_gid); } break; case 'l': /* link count */ - sprintf(fmt, "%%%sd", start); - sprintf(buf, fmt, st.st_nlink); + buf = FormatNum(start, st.st_nlink); break; default: @@ -341,6 +350,7 @@ PRIVATE void LYListFmtParse ARGS5( break; } PUTS(buf); + FREE(buf); s++; } @@ -525,14 +535,10 @@ PUBLIC char * HTCacheFileName ARGS1( char * acc_method = HTParse(name, "", PARSE_ACCESS); char * host = HTParse(name, "", PARSE_HOST); char * path = HTParse(name, "", PARSE_PATH+PARSE_PUNCTUATION); + char * result = NULL; + + HTSprintf0(&result, "%s/WWW/%s/%s%s", HTCacheRoot, acc_method, host, path); - char * result; - result = (char *)malloc( - strlen(HTCacheRoot)+strlen(acc_method) - +strlen(host)+strlen(path)+6+1); - if (result == NULL) - outofmem(__FILE__, "HTCacheFileName"); - sprintf(result, "%s/WWW/%s/%s%s", HTCacheRoot, acc_method, host, path); FREE(path); FREE(acc_method); FREE(host); @@ -596,11 +602,7 @@ PUBLIC char * HTnameOfFile_WWW ARGS3( #endif /* __EMX__ */ #endif /* DOSPATH */ } else if (WWW_prefix) { - result = (char *)malloc( - strlen("/Net/")+strlen(host)+strlen(path)+1); - if (result == NULL) - outofmem(__FILE__, "HTLocalName"); - sprintf(result, "%s%s%s", "/Net/", host, path); + HTSprintf0(&result, "%s%s%s", "/Net/", host, path); CTRACE(tfp, "Node `%s' means file `%s'\n", name, result); } else { StrAllocCopy(result, path); @@ -615,11 +617,7 @@ PUBLIC char * HTnameOfFile_WWW ARGS3( if ((home = getenv("HOME")) == 0) home = "/tmp"; #endif /* VMS */ - result = (char *)malloc( - strlen(home)+strlen(acc_method)+strlen(host)+strlen(path)+6+1); - if (result == NULL) - outofmem(__FILE__, "HTLocalName"); - sprintf(result, "%s/WWW/%s/%s%s", home, acc_method, host, path); + HTSprintf0(&result, "%s/WWW/%s/%s%s", home, acc_method, host, path); } else { StrAllocCopy(result, path); } @@ -642,25 +640,16 @@ PUBLIC char * HTnameOfFile_WWW ARGS3( PUBLIC char * WWW_nameOfFile ARGS1( CONST char *, name) { - char * result; + char * result = NULL; #ifdef NeXT if (0 == strncmp("/private/Net/", name, 13)) { - result = (char *)malloc(7+strlen(name+13)+1); - if (result == NULL) - outofmem(__FILE__, "WWW_nameOfFile"); - sprintf(result, "file://%s", name+13); + HTSprintf0(&result, "file://%s", name+13); } else #endif /* NeXT */ if (0 == strncmp(HTMountRoot, name, 5)) { - result = (char *)malloc(7+strlen(name+5)+1); - if (result == NULL) - outofmem(__FILE__, "WWW_nameOfFile"); - sprintf(result, "file://%s", name+5); + HTSprintf0(&result, "file://%s", name+5); } else { - result = (char *)malloc(7+strlen(HTHostName())+strlen(name)+1); - if (result == NULL) - outofmem(__FILE__, "WWW_nameOfFile"); - sprintf(result, "file://%s%s", HTHostName(), name); + HTSprintf0(&result, "file://%s%s", HTHostName(), name); } CTRACE(tfp, "File `%s'\n\tmeans node `%s'\n", name, result); return result; @@ -1155,10 +1144,8 @@ PUBLIC void HTDirEntry ARGS3( /* ** If empty tail, gives absolute ref below. */ - relative = (char*)malloc(strlen(tail) + strlen(escaped)+2); - if (relative == NULL) - outofmem(__FILE__, "HTDirEntry"); - sprintf(relative, "%s%s%s", + relative = 0; + HTSprintf0(&relative, "%s%s%s", tail, (*escaped != '\0' ? "/" : ""), escaped); @@ -1248,8 +1235,8 @@ PUBLIC BOOL HTDirTitles ARGS3( START(HTML_HEAD); PUTS("\n"); START(HTML_TITLE); - PUTS(*printable ? printable : gettext("Welcome")); - PUTS(gettext(" directory")); + PUTS(*printable ? printable : WELCOME_MSG); + PUTS(SEGMENT_DIRECTORY); END(HTML_TITLE); PUTS("\n"); END(HTML_HEAD); @@ -1257,13 +1244,13 @@ PUBLIC BOOL HTDirTitles ARGS3( #ifdef DIRED_SUPPORT START(HTML_H2); - PUTS(*printable ? gettext("Current directory is ") : ""); - PUTS(*printable ? printable : gettext("Welcome")); + PUTS(*printable ? SEGMENT_CURRENT_DIR : ""); + PUTS(*printable ? printable : WELCOME_MSG); END(HTML_H2); PUTS("\n"); #else START(HTML_H1); - PUTS(*printable ? printable : gettext("Welcome")); + PUTS(*printable ? printable : WELCOME_MSG); END(HTML_H1); PUTS("\n"); #endif /* DIRED_SUPPORT */ @@ -1300,10 +1287,8 @@ PUBLIC BOOL HTDirTitles ARGS3( return(need_parent_link); } - relative = (char*) malloc(strlen(current) + 4); - if (relative == NULL) - outofmem(__FILE__, "HTDirTitles"); - sprintf(relative, "%s/..", current); + relative = 0; + HTSprintf0(&relative, "%s/..", current); #ifdef DOSPATH if (local_link) @@ -1373,7 +1358,7 @@ PUBLIC BOOL HTDirTitles ARGS3( HTStartAnchor(target, "", relative); FREE(relative); - PUTS(gettext("Up to ")); + PUTS(SEGMENT_UP_TO); if (parent) { if ((0 == strcmp(current,".")) || (0 == strcmp(current,".."))) { @@ -1504,8 +1489,7 @@ PUBLIC int HTLoadFile ARGS4( if (HTDirAccess == HT_DIR_FORBID) { FREE(filename); FREE(nodename); - return HTLoadError(sink, 403, - gettext("Directory browsing is not allowed.")); + return HTLoadError(sink, 403, DISALLOWED_DIR_SCAN); } if (HTDirAccess == HT_DIR_SELECTIVE) { @@ -1520,8 +1504,7 @@ PUBLIC int HTLoadFile ARGS4( if (HTStat(enable_file_name, &stat_info) == -1) { FREE(filename); FREE(nodename); - return HTLoadError(sink, 403, - gettext("Selective access is not enabled for this directory")); + return HTLoadError(sink, 403, DISALLOWED_SELECTIVE_ACCESS); } } @@ -1681,7 +1664,7 @@ PUBLIC int HTLoadFile ARGS4( } else { status = HTLoadError(NULL, -(HT_ERROR), - gettext("Could not open file for decompression!")); + FAILED_OPEN_COMPRESSED_FILE); } } else #endif /* USE_ZLIB */ @@ -1745,8 +1728,7 @@ PUBLIC int HTLoadFile ARGS4( if (forget_multi || !dp) { FREE(localname); FREE(nodename); - return HTLoadError(sink, 500, - gettext("Multiformat: directory scan failed.")); + return HTLoadError(sink, 500, FAILED_DIR_SCAN); } while ((dirbuf = readdir(dp)) != NULL) { @@ -1835,8 +1817,7 @@ PUBLIC int HTLoadFile ARGS4( } else { /* If not found suitable file */ FREE(localname); FREE(nodename); - return HTLoadError(sink, 403, /* List formats? */ - gettext("Could not find suitable representation for transmission.")); + return HTLoadError(sink, 403, FAILED_NO_REPRESENTATION); } /*NOTREACHED*/ } /* if multi suffix */ @@ -1891,8 +1872,7 @@ PUBLIC int HTLoadFile ARGS4( if (HTDirAccess == HT_DIR_FORBID) { FREE(localname); FREE(nodename); - return HTLoadError(sink, 403, - gettext("Directory browsing is not allowed.")); + return HTLoadError(sink, 403, DISALLOWED_DIR_SCAN); } @@ -1908,8 +1888,7 @@ PUBLIC int HTLoadFile ARGS4( if (stat(enable_file_name, &file_info) != 0) { FREE(localname); FREE(nodename); - return HTLoadError(sink, 403, - gettext("Selective access is not enabled for this directory")); + return HTLoadError(sink, 403, DISALLOWED_SELECTIVE_ACCESS); } } @@ -1917,8 +1896,7 @@ PUBLIC int HTLoadFile ARGS4( if (!dp) { FREE(localname); FREE(nodename); - return HTLoadError(sink, 403, - gettext("This directory is not readable.")); + return HTLoadError(sink, 403, FAILED_DIR_UNREADABLE); } /* @@ -2016,9 +1994,6 @@ PUBLIC int HTLoadFile ARGS4( (no_dotfiles || !show_dotfiles)))) continue; - dirname = (char *)malloc(strlen(dirbuf->d_name) + 4); - if (dirname == NULL) - outofmem(__FILE__, "HTLoadFile"); StrAllocCopy(tmpfilename, localname); if (strcmp(localname, "/")) /* @@ -2030,29 +2005,26 @@ PUBLIC int HTLoadFile ARGS4( stat(tmpfilename, &file_info); if (S_ISDIR(file_info.st_mode)) #ifndef DIRED_SUPPORT - sprintf((char *)dirname, "D%s",dirbuf->d_name); + HTSprintf0(&dirname, "D%s",dirbuf->d_name); else - sprintf((char *)dirname, "F%s",dirbuf->d_name); + HTSprintf0(&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); + HTSprintf0(&dirname, " %s/", dirbuf->d_name); else if (!strcmp(dirbuf->d_name, "..")) - sprintf((char *)dirname, - "A%s", dirbuf->d_name); + HTSprintf0(&dirname, "A%s", dirbuf->d_name); else - sprintf((char *)dirname, - "D%s", dirbuf->d_name); + HTSprintf0(&dirname, "D%s", dirbuf->d_name); } else if (dir_list_style == MIXED_STYLE) - sprintf((char *)dirname, " %s", dirbuf->d_name); + HTSprintf0(&dirname, " %s", dirbuf->d_name); else if (dir_list_style == FILES_FIRST) - sprintf((char *)dirname, "C%s", dirbuf->d_name); + HTSprintf0(&dirname, "C%s", dirbuf->d_name); /* C & D to have first files, then directories */ else - sprintf((char *)dirname, "F%s", dirbuf->d_name); + HTSprintf0(&dirname, "F%s", dirbuf->d_name); #endif /* !DIRED_SUPPORT */ /* ** Sort dirname in the tree bt. @@ -2125,8 +2097,8 @@ PUBLIC int HTLoadFile ARGS4( if (dir_list_style != MIXED_STYLE) { START(HTML_EM); PUTS(state == 'D' - ? gettext("Subdirectories:") - : gettext("Files:")); + ? LABEL_SUBDIRECTORIES + : LABEL_FILES); END(HTML_EM); } END(HTML_H2); @@ -2147,8 +2119,8 @@ PUBLIC int HTLoadFile ARGS4( START(HTML_H2); START(HTML_EM); PUTS(state == 'D' - ? gettext("Subdirectories:") - : gettext("Files:")); + ? LABEL_SUBDIRECTORIES + : LABEL_FILES); END(HTML_EM); END(HTML_H2); #ifndef LONG_LIST @@ -2335,7 +2307,7 @@ PUBLIC int HTLoadFile ARGS4( } else { status = HTLoadError(NULL, -(HT_ERROR), - gettext("Could not open file for decompression!")); + FAILED_OPEN_COMPRESSED_FILE); } } else #endif /* USE_ZLIB */ @@ -2384,7 +2356,7 @@ PUBLIC int HTLoadFile ARGS4( { CTRACE(tfp, "Can't open `%s', errno=%d\n", addr, SOCKET_ERRNO); - return HTLoadError(sink, 403, gettext("Can't access requested file.")); + return HTLoadError(sink, 403, FAILED_FILE_UNREADABLE); } } diff --git a/WWW/Library/Implementation/HTFinger.c b/WWW/Library/Implementation/HTFinger.c index 5485e0af..c99563cc 100644 --- a/WWW/Library/Implementation/HTFinger.c +++ b/WWW/Library/Implementation/HTFinger.c @@ -262,7 +262,7 @@ PUBLIC int HTLoadFinger ARGS4( CTRACE(tfp, "HTFinger: Looking for %s\n", (arg ? arg : "NULL")); if (!(arg && *arg)) { - HTAlert(gettext("Could not load data.")); + HTAlert(COULD_NOT_LOAD_DATA); return HT_NOT_LOADED; /* Ignore if no name */ } @@ -292,7 +292,7 @@ PUBLIC int HTLoadFinger ARGS4( HTUnEscape(slash); if (IsGopherURL) { if (*slash != '0') { - HTAlert(gettext("Could not load data.")); + HTAlert(COULD_NOT_LOAD_DATA); return HT_NOT_LOADED; /* FAIL */ } *slash++ = '\0'; @@ -300,7 +300,7 @@ PUBLIC int HTLoadFinger ARGS4( } if ((at_sign = strchr(sitename, '@')) != NULL) { if (IsGopherURL) { - HTAlert(gettext("Could not load data.")); + HTAlert(COULD_NOT_LOAD_DATA); return HT_NOT_LOADED; /* FAIL */ } *at_sign++ = '\0'; @@ -329,29 +329,25 @@ PUBLIC int HTLoadFinger ARGS4( /* Load the string for making a connection/ */ - str = (char *)calloc(1, (strlen(sitename) + 10)); - if (str == NULL) - outofmem(__FILE__, "HTLoadFinger"); - sprintf(str, "lose://%s/", sitename); + str = 0; + HTSprintf0(&str, "lose://%s/", sitename); /* Load the command for the finger server. */ - command = (char *)calloc(1, (strlen(username) + 10)); - if (command == NULL) - outofmem(__FILE__, "HTLoadFinger"); + command = 0; if (at_sign && slash) { if (*slash == 'w' || *slash == 'W') { - sprintf(command, "/w %s%c%c", username, CR, LF); + HTSprintf0(&command, "/w %s%c%c", username, CR, LF); } else { - sprintf(command, "%s%c%c", username, CR, LF); + HTSprintf0(&command, "%s%c%c", username, CR, LF); } } else if (at_sign) { - sprintf(command, "%s%c%c", username, CR, LF); + HTSprintf0(&command, "%s%c%c", username, CR, LF); } else if (*username == '/') { if ((slash = strchr((username+1), '/')) != NULL) { *slash = ' '; } - sprintf(command, "%s%c%c", username, CR, LF); + HTSprintf0(&command, "%s%c%c", username, CR, LF); } else if ((*username == 'w' || *username == 'W') && *(username+1) == '/') { if (*username+2 != '\0') { @@ -359,19 +355,19 @@ PUBLIC int HTLoadFinger ARGS4( } else { *(username+1) = '\0'; } - sprintf(command, "/%s%c%c", username, CR, LF); + HTSprintf0(&command, "/%s%c%c", username, CR, LF); } else if ((*username == 'w' || *username == 'W') && *(username+1) == '\0') { - sprintf(command, "/%s%c%c", username, CR, LF); + HTSprintf0(&command, "/%s%c%c", username, CR, LF); } else if ((slash = strchr(username, '/')) != NULL) { *slash++ = '\0'; if (*slash == 'w' || *slash == 'W') { - sprintf(command, "/w %s%c%c", username, CR, LF); + HTSprintf0(&command, "/w %s%c%c", username, CR, LF); } else { - sprintf(command, "%s%c%c", username, CR, LF); + HTSprintf0(&command, "%s%c%c", username, CR, LF); } } else { - sprintf(command, "%s%c%c", username, CR, LF); + HTSprintf0(&command, "%s%c%c", username, CR, LF); } } /* scope of p1 */ diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c index deb4e77a..ca065016 100644 --- a/WWW/Library/Implementation/HTFormat.c +++ b/WWW/Library/Implementation/HTFormat.c @@ -682,7 +682,7 @@ PUBLIC int HTCopy ARGS4( } /* next bufferload */ - _HTProgress(gettext("Data transfer complete")); + _HTProgress(TRANSFER_COMPLETE); (void)NETCLOSE(file_number); rv = HT_LOADED; @@ -926,25 +926,25 @@ PUBLIC int HTParseSocket ARGS5( stream = HTStreamStack(rep_in, format_out, sink, anchor); if (!stream) { - char buffer[1024]; /* @@@@@@@@ */ + char *buffer = 0; if (LYCancelDownload) { LYCancelDownload = FALSE; return -1; } - sprintf(buffer, gettext("Sorry, can't convert from %s to %s."), + HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, HTAtom_name(rep_in), HTAtom_name(format_out)); CTRACE(tfp, "HTFormat: %s\n", buffer); - return HTLoadError(sink, 501, buffer); /* returns -501 */ + rv = HTLoadError(sink, 501, buffer); /* returns -501 */ + FREE(buffer); + } else { + /* + ** Push the data, don't worry about CRLF we can strip them later. + */ + targetClass = *(stream->isa); /* Copy pointers to procedures */ + rv = HTCopy(anchor, file_number, NULL, stream); + if (rv != -1 && rv != HT_INTERRUPTED) + (*targetClass._free)(stream); } - - /* - ** Push the data, don't worry about CRLF we can strip them later. - */ - targetClass = *(stream->isa); /* Copy pointers to procedures */ - rv = HTCopy(anchor, file_number, NULL, stream); - if (rv != -1 && rv != HT_INTERRUPTED) - (*targetClass._free)(stream); - return rv; /* Originally: full: HT_LOADED; partial: HT_INTERRUPTED; no bytes: -1 */ } @@ -988,15 +988,17 @@ PUBLIC int HTParseFile ARGS5( sink , anchor); if (!stream) { - char buffer[1024]; /* @@@@@@@@ */ + char *buffer = 0; if (LYCancelDownload) { LYCancelDownload = FALSE; return -1; } - sprintf(buffer, gettext("Sorry, can't convert from %s to %s."), + HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, HTAtom_name(rep_in), HTAtom_name(format_out)); CTRACE(tfp, "HTFormat(in HTParseFile): %s\n", buffer); - return HTLoadError(sink, 501, buffer); + rv = HTLoadError(sink, 501, buffer); + FREE(buffer); + return rv; } /* Push the data down the stream @@ -1071,16 +1073,18 @@ PUBLIC int HTParseGzFile ARGS5( sink , anchor); if (!stream) { - char buffer[1024]; /* @@@@@@@@ */ + char *buffer = 0; HTCloseGzFile(gzfp); if (LYCancelDownload) { LYCancelDownload = FALSE; return -1; } - sprintf(buffer, gettext("Sorry, can't convert from %s to %s."), + HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, HTAtom_name(rep_in), HTAtom_name(format_out)); CTRACE(tfp, "HTFormat(in HTParseGzFile): %s\n", buffer); - return HTLoadError(sink, 501, buffer); + rv = HTLoadError(sink, 501, buffer); + FREE(buffer); + return rv; } /* Push the data down the stream diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c index ba239db4..e2ec7b0f 100644 --- a/WWW/Library/Implementation/HTGopher.c +++ b/WWW/Library/Implementation/HTGopher.c @@ -211,7 +211,6 @@ PRIVATE void parse_menu ARGS2( char gtype; char ch; char line[BIG]; - char address[BIG]; char *name = NULL, *selector = NULL; /* Gopher menu fields */ char *host = NULL; char *port; @@ -233,7 +232,7 @@ PRIVATE void parse_menu ARGS2( if ((title = HTAnchor_title(anAnchor))) PUTS(title); else - PUTS(gettext("Gopher Menu")); + PUTS(GOPHER_MENU_TITLE); END(HTML_TITLE); PUTS("\n"); END(HTML_HEAD); @@ -245,7 +244,7 @@ PRIVATE void parse_menu ARGS2( if ((title = HTAnchor_title(anAnchor))) PUTS(title); else - PUTS(gettext("Gopher Menu")); + PUTS(GOPHER_MENU_TITLE); END(HTML_H1); PUTS("\n"); START(HTML_PRE); @@ -269,7 +268,7 @@ PRIVATE void parse_menu ARGS2( gtype = *p++; if (bytes > BytesReported + 1024) { - sprintf(buffer, gettext("Transferred %d bytes"), bytes); + sprintf(buffer, TRANSFERRED_X_BYTES, bytes); HTProgress(buffer); BytesReported = bytes; } @@ -327,23 +326,26 @@ PRIVATE void parse_menu ARGS2( PUTS(name); } else if (port) { /* Other types need port */ + char *address = 0; + if (gtype == GOPHER_TELNET) { PUTS(" (TEL) "); - if (*selector) sprintf(address, "telnet://%s@%s/", + if (*selector) + HTSprintf0(&address, "telnet://%s@%s/", selector, host); - else sprintf(address, "telnet://%s/", host); + else + HTSprintf0(&address, "telnet://%s/", host); } else if (gtype == GOPHER_TN3270) { PUTS("(3270) "); if (*selector) - sprintf(address, "tn3270://%s@%s/", + HTSprintf0(&address, "tn3270://%s@%s/", selector, host); else - sprintf(address, "tn3270://%s/", host); + HTSprintf0(&address, "tn3270://%s/", host); } else { /* If parsed ok */ - char *q; char *r; switch(gtype) { @@ -398,19 +400,18 @@ PRIVATE void parse_menu ARGS2( break; } - sprintf(address, "//%s/%c", host, gtype); + HTSprintf0(&address, "//%s/%c", host, gtype); - q = address+ strlen(address); - for(r=selector; *r; r++) { /* Encode selector string */ - if (acceptable[(unsigned char)*r]) *q++ = *r; - else { - *q++ = HEX_ESCAPE; /* Means hex coming */ - *q++ = hex[(TOASCII(*r)) >> 4]; - *q++ = hex[(TOASCII(*r)) & 15]; + for(r = selector; *r; r++) { /* Encode selector string */ + if (acceptable[(unsigned char)*r]) { + HTSprintf(&address, "%c", *r); + } else { + HTSprintf(&address, "%c%c%c", + HEX_ESCAPE, /* Means hex coming */ + hex[(TOASCII(*r)) >> 4], + hex[(TOASCII(*r)) & 15]); } } - - *q++ = '\0'; /* terminate address */ } /* Error response from Gopher doesn't deserve to be a hyperlink. */ @@ -418,6 +419,7 @@ PRIVATE void parse_menu ARGS2( write_anchor(name, address); else PUTS(name); + FREE(address); } else { /* parse error */ CTRACE(tfp, "HTGopher: Bad menu item.\n"); PUTS(line); @@ -472,7 +474,7 @@ PRIVATE void parse_cso ARGS2( if ((title = HTAnchor_title(anAnchor))) PUTS(title); else - PUTS(gettext("CSO Search Results")); + PUTS(GOPHER_CSO_SEARCH_RESULTS); END(HTML_TITLE); PUTS("\n"); END(HTML_HEAD); @@ -482,7 +484,7 @@ PRIVATE void parse_cso ARGS2( PUTS(title); else { PUTS(arg); - PUTS(gettext(" Search Results")); + PUTS(GOPHER_SEARCH_RESULTS); } END(HTML_H1); PUTS("\n"); @@ -615,7 +617,7 @@ PRIVATE void display_cso ARGS2( if ((title = HTAnchor_title(anAnchor))) PUTS(title); else - PUTS(gettext("CSO index")); + PUTS(GOPHER_CSO_INDEX); END(HTML_TITLE); PUTS("\n"); START(HTML_ISINDEX); @@ -627,15 +629,15 @@ PRIVATE void display_cso ARGS2( PUTS(title); else { PUTS(arg); - PUTS(gettext(" index")); + PUTS(INDEX_SEGMENT); } END(HTML_H1); - PUTS(gettext("\nThis is a searchable index of a CSO database.\n")); + PUTS(GOPHER_CSO_INDEX_SUBTITLE); START(HTML_P); - PUTS(gettext("\nPress the 's' key and enter search keywords.\n")); + PUTS(GOPHER_CSO_SOLICIT_KEYWORDS); START(HTML_P); - PUTS(gettext("\nThe keywords that you enter will allow you to search on a")); - PUTS(gettext(" person's name in the database.\n")); + PUTS(SEGMENT_KEYWORDS_WILL); + PUTS(SEGMENT_PERSONS_DB_NAME); if (!HTAnchor_title(anAnchor)) HTAnchor_setTitle(anAnchor, arg); @@ -660,7 +662,7 @@ PRIVATE void display_index ARGS2( if ((title = HTAnchor_title(anAnchor))) PUTS(title); else - PUTS(gettext("Gopher index")); + PUTS(GOPHER_INDEX_TITLE); END(HTML_TITLE); PUTS("\n"); START(HTML_ISINDEX); @@ -672,12 +674,12 @@ PRIVATE void display_index ARGS2( PUTS(title); else { PUTS(arg); - PUTS(gettext(" index")); + PUTS(INDEX_SEGMENT); } END(HTML_H1); - PUTS(gettext("\nThis is a searchable Gopher index.\n")); + PUTS(GOPHER_INDEX_SUBTITLE); START(HTML_P); - PUTS(gettext("\nPlease enter search keywords.\n")); + PUTS(GOPHER_SOLICIT_KEYWORDS); if (!HTAnchor_title(anAnchor)) HTAnchor_setTitle(anAnchor, arg); @@ -741,7 +743,7 @@ PRIVATE void free_CSOfields NOPARAMS /* Interpret CSO/PH form template keys. - FM ** ========================================= */ -PRIVATE int interpret_cso_key ARGS5( +PRIVATE void interpret_cso_key ARGS5( char *, key, char *, buf, int *, length, @@ -776,7 +778,7 @@ PRIVATE int interpret_cso_key ARGS5( } if (!error) { *length = strlen(buf); - return -1; + return; } } buf[0] = '\0'; @@ -867,10 +869,10 @@ PRIVATE int interpret_cso_key ARGS5( buf[out++] = ')'; buf[out] = '\0'; *length = strlen(buf); - return -1; + return; } *length = strlen(buf); - return 0; + return; } /* Parse the elements in a CSO/PH fields structure. - FM @@ -1184,11 +1186,8 @@ PRIVATE int generate_cso_form ARGS4( j = 0; } if (ctx.seek) { - char *temp = (char *)malloc(strlen(ctx.seek) + 20); - if (temp) { - outofmem(__FILE__, "HTLoadCSO"); - } - sprintf(temp, gettext("Seek fail on %s\n"), ctx.seek); + char *temp = 0; + HTSprintf0(&temp, GOPHER_CSO_SEEK_FAILED, ctx.seek); (*Target->isa->put_block)(Target, temp, strlen(temp)); FREE(temp); } @@ -1217,12 +1216,12 @@ PRIVATE int generate_cso_form ARGS4( /* Generate a results report for CSO/PH form-based searches. - FM ** ============================================================== */ -PRIVATE int generate_cso_report ARGS2( - char *, buf, +PRIVATE int generate_cso_report ARGS1( HTStream *, Target) { char ch; char line[BIG]; + char *buf = 0; char *p = line, *href = NULL; int len, i, prev_ndx, ndx; char *rcode, *ndx_str, *fname, *fvalue, *l; @@ -1238,7 +1237,6 @@ 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"); _HTProgress (CONNECTION_INTERRUPTED); goto end_CSOreport; @@ -1277,22 +1275,22 @@ PRIVATE int generate_cso_report ARGS2( ndx = atoi(ndx_str); if (prev_ndx != ndx) { if (prev_ndx != -100) { - strcpy(buf, "</DL></DL>\n"); + HTSprintf0(&buf, "</DL></DL>\n"); (*Target->isa->put_block)(Target, buf, strlen(buf)); } if (ndx == 0) { - strcpy(buf, + HTSprintf0(&buf, "<HR><DL><DT>Information/status<DD><DL><DT>\n"); (*Target->isa->put_block)(Target, buf, strlen(buf)); } else { - sprintf(buf, + HTSprintf0(&buf, "<HR><DL><DT>Entry %d:<DD><DL COMPACT><DT>\n", ndx); (*Target->isa->put_block)(Target, buf, strlen(buf)); } prev_ndx = ndx; } } else { - sprintf(buf, "<DD>%s\n", rcode); + HTSprintf0(&buf, "<DD>%s\n", rcode); (*Target->isa->put_block)(Target, buf, strlen(buf)); continue; } @@ -1325,27 +1323,22 @@ PRIVATE int generate_cso_report ARGS2( } } if (fld && fld->url) { - sprintf(buf, + HTSprintf0(&buf, "<DT><I>%s</I><DD><A HREF=\"%s\">%s</A>\n", fname, fvalue, fvalue); (*Target->isa->put_block)(Target, buf, strlen(buf)); } else { - sprintf(buf, "<DT><I>%s</I><DD>", fname); + HTSprintf0(&buf, "<DT><I>%s</I><DD>", fname); (*Target->isa->put_block)(Target, buf, strlen(buf)); - i = 0; - buf[i] = '\0'; + buf[0] = '\0'; l = fvalue; while (*l) { if (*l == '<') { - strcat(buf, "<"); + StrAllocCat(buf, "<"); l++; - i += 4; - buf[i] = '\0'; } else if (*l == '>') { - strcat(buf, ">"); + StrAllocCat(buf, ">"); l++; - i += 4; - buf[i] = '\0'; } else if (strncmp(l, "news:", 5) && strncmp(l, "snews://", 8) && strncmp(l, "nntp://", 7) && @@ -1362,45 +1355,34 @@ PRIVATE int generate_cso_report ARGS2( strncmp(l, "mailto:", 7) && strncmp(l, "cso://", 6) && strncmp(l, "gopher://", 9)) { - buf[i++] = *l++; - buf[i] = '\0'; + HTSprintf(&buf, "%c", *l++); } else { - strcat(buf, "<a href=\""); - i += 9; - buf[i] = '\0'; + StrAllocCat(buf, "<a href=\""); StrAllocCopy(href, l); - strcat(buf, strtok(href, " \r\n\t,>)\"")); - strcat(buf, "\">"); - i = strlen(buf); + StrAllocCat(buf, strtok(href, " \r\n\t,>)\"")); + StrAllocCat(buf, "\">"); while (*l && !strchr(" \r\n\t,>)\"", *l)) { - buf[i++] = *l++; + HTSprintf(&buf, "%c", *l++); } - buf[i] = '\0'; - strcat(buf, "</a>"); - i += 4; + StrAllocCat(buf, "</a>"); FREE(href); } } - strcat(buf, "\n"); + StrAllocCat(buf, "\n"); (*Target->isa->put_block)(Target, buf, strlen(buf)); } } else { - sprintf(buf, "<DD>"); + HTSprintf0(&buf, "<DD>"); (*Target->isa->put_block)(Target, buf, strlen(buf)); - i = 0; - buf[i] = '\0'; + buf[0] = '\0'; l = fvalue; while (*l) { if (*l == '<') { - strcat(buf, "<"); + StrAllocCat(buf, "<"); l++; - i += 4; - buf[i] = '\0'; } else if (*l == '>') { - strcat(buf, ">"); + StrAllocCat(buf, ">"); l++; - i += 4; - buf[i] = '\0'; } else if (strncmp(l, "news:", 5) && strncmp(l, "snews://", 8) && strncmp(l, "nntp://", 7) && @@ -1417,39 +1399,34 @@ PRIVATE int generate_cso_report ARGS2( strncmp(l, "mailto:", 7) && strncmp(l, "cso://", 6) && strncmp(l, "gopher://", 9)) { - buf[i++] = *l++; - buf[i] = '\0'; + HTSprintf(&buf, "%c", *l++); } else { - strcat(buf, "<a href=\""); - i += 9; - buf[i] = '\0'; + StrAllocCat(buf, "<a href=\""); StrAllocCopy(href, l); - strcat(buf, strtok(href, " \r\n\t,>)\"")); - strcat(buf, "\">"); - i = strlen(buf); + StrAllocCat(buf, strtok(href, " \r\n\t,>)\"")); + StrAllocCat(buf, "\">"); while (*l && !strchr(" \r\n\t,>)\"", *l)) { - buf[i++] = *l++; + HTSprintf(&buf, "%c", *l++); } - buf[i] = '\0'; - strcat(buf, "</a>"); - i += 4; + StrAllocCat(buf, "</a>"); FREE(href); } } - strcat(buf, "\n"); + StrAllocCat(buf, "\n"); (*Target->isa->put_block)(Target, buf, strlen(buf)); } } else { - sprintf(buf, "<DD>%s\n", fname ? fname : rcode ); + HTSprintf0(&buf, "<DD>%s\n", fname ? fname : rcode ); (*Target->isa->put_block)(Target, buf, strlen(buf)); } } } end_CSOreport: if (prev_ndx != -100) { - sprintf(buf, "</DL></DL>\n"); + HTSprintf0(&buf, "</DL></DL>\n"); (*Target->isa->put_block)(Target, buf, strlen(buf)); } + FREE(buf); return 0; } @@ -1462,12 +1439,13 @@ PRIVATE int HTLoadCSO ARGS4( HTFormat, format_out, HTStream*, sink) { + static CONST char end_form[] = "</BODY>\n</HTML>\n"; char *host, *cp; int port = CSO_PORT; int status; /* tcp return */ char *command = NULL; char *content = NULL; - int len, i, j, start, finish, flen, ndx, clen; + int len, i, j, start, finish, flen, ndx; int return_type, has_indexed; CSOfield_info *fld; char buf[2048]; @@ -1503,19 +1481,17 @@ PRIVATE int HTLoadCSO ARGS4( HTInitInput(s); /* Set up input buffering */ - if ((command = (char *)malloc(12)) == NULL) - outofmem(__FILE__, "HTLoadCSO"); - sprintf(command, "fields%c%c", CR, LF); + HTSprintf0(&command, "fields%c%c", CR, LF); CTRACE(tfp, "HTLoadCSO: Connected, writing command `%s' to socket %d\n", command, s); - _HTProgress (gettext("Sending CSO/PH request.")); + _HTProgress (GOPHER_SENDING_CSO_REQUEST); status = NETWRITE(s, command, (int)strlen(command)); FREE(command); if (status < 0) { CTRACE(tfp, "HTLoadCSO: Unable to send command.\n"); return HTInetStatus("send"); } - _HTProgress (gettext("CSO/PH request sent; waiting for response.")); + _HTProgress (GOPHER_SENT_CSO_REQUEST); /* ** Now read the data from the socket. @@ -1528,7 +1504,7 @@ PRIVATE int HTLoadCSO ARGS4( } else if (buf[0] != '\0') { HTAlert(buf); } else { - HTAlert(gettext("No response from server!")); + HTAlert(FAILED_NO_RESPONSE); } return HT_NOT_LOADED; } @@ -1536,12 +1512,9 @@ PRIVATE int HTLoadCSO ARGS4( format_out, sink, anAnchor); if (!Target || Target == NULL) { - char *temp = (char *)malloc(256); - if (!temp) { - outofmem(__FILE__, "HTLoadCSO"); - } - sprintf(temp, CANNOT_CONVERT_I_TO_O, - HTAtom_name(format_in), HTAtom_name(format_out)); + char *temp = 0; + HTSprintf0(&temp, CANNOT_CONVERT_I_TO_O, + HTAtom_name(format_in), HTAtom_name(format_out)); HTAlert(temp); FREE(temp); NETCLOSE(s); @@ -1565,11 +1538,14 @@ PRIVATE int HTLoadCSO ARGS4( free_CSOfields(); return HT_LOADED; } - sprintf(buf, + + HTSprintf0(&command, "<HTML>\n<HEAD>\n<TITLE>CSO/PH Results on %s</TITLE>\n</HEAD>\n<BODY>\n", host); - (*Target->isa->put_block)(Target, buf, strlen(buf)); + (*Target->isa->put_block)(Target, command, strlen(command)); + FREE(command); FREE(host); + StrAllocCopy(content, anAnchor->post_data); if (content[strlen(content)-1] != '&') StrAllocCat(content, "&"); @@ -1583,7 +1559,7 @@ PRIVATE int HTLoadCSO ARGS4( len = strlen(content); return_type = 0; has_indexed = 0; - start = finish = clen = 0; + start = finish = 0; for (i = 0; i < len; i++) { if (!content[i] || content[i] == '&') { /* @@ -1616,17 +1592,13 @@ PRIVATE int HTLoadCSO ARGS4( if (fld->lookup) { if (fld->indexed) has_indexed = 1; - if (clen == 0) { + if (command == 0 || *command == 0) { StrAllocCopy(command, "query "); - clen = 6; } else { StrAllocCat(command, " "); - clen++; } - sprintf(buf, "%s=\"%s\"", - fld->name, &content[j+1]); - StrAllocCat(command, buf); - clen += strlen(buf); + HTSprintf(&command, "%s=\"%s\"", + fld->name, &content[j+1]); } else { strcpy(buf, "Warning: non-lookup field ignored<BR>\n"); @@ -1653,7 +1625,7 @@ PRIVATE int HTLoadCSO ARGS4( } } FREE(content); - if ((clen == 0) || !has_indexed) { + if ((command == 0 || *command == 0) || !has_indexed) { NETCLOSE(s); strcpy(buf, "<EM>Error:</EM> At least one indexed field value must be specified!\n"); @@ -1669,39 +1641,32 @@ PRIVATE int HTLoadCSO ARGS4( */ if (return_type == 1) { StrAllocCat(command, " return all"); - clen += 11; } else if (return_type == 2) { StrAllocCat(command, " return"); - clen += 7; for (fld = CSOfields; fld; fld = fld->next) { if (fld->explicit_return) { - sprintf(buf, " %s", fld->name); - StrAllocCat(command, buf); - clen += strlen(buf); + HTSprintf(&command, " %s", fld->name); } } } - sprintf(buf, "%c%c", CR, LF); - StrAllocCat(command, buf); - clen += strlen(buf); + HTSprintf(&command, "%c%c", CR, LF); strcpy(buf, "<H2>\n<EM>CSO/PH command:</EM> "); (*Target->isa->put_block)(Target, buf, strlen(buf)); - (*Target->isa->put_block)(Target, command, clen); + (*Target->isa->put_block)(Target, command, strlen(command)); strcpy(buf, "</H2>\n"); (*Target->isa->put_block)(Target, buf, strlen(buf)); CTRACE(tfp, "HTLoadCSO: Writing command `%s' to socket %d\n", command, s); - status = NETWRITE(s, command, clen); + status = NETWRITE(s, command, strlen(command)); FREE(command); if (status < 0) { CTRACE(tfp, "HTLoadCSO: Unable to send command.\n"); free_CSOfields(); return HTInetStatus("send"); } - generate_cso_report(buf, Target); + generate_cso_report(Target); NETCLOSE(s); - strcpy(buf, "</BODY>\n</HTML>\n"); - (*Target->isa->put_block)(Target, buf, strlen(buf)); + (*Target->isa->put_block)(Target, end_form, sizeof(end_form)-1); (*Target->isa->_free)(Target); FREE(host); free_CSOfields(); @@ -1878,7 +1843,7 @@ PRIVATE int HTLoadGopher ARGS4( } #endif - _HTProgress (gettext("Sending Gopher request.")); + _HTProgress (GOPHER_SENDING_REQUEST); status = NETWRITE(s, command, (int)strlen(command)); FREE(command); @@ -1887,7 +1852,7 @@ PRIVATE int HTLoadGopher ARGS4( return HTInetStatus("send"); } - _HTProgress (gettext("Gopher request sent; waiting for response.")); + _HTProgress (GOPHER_SENT_REQUEST); /* ** Now read the data from the socket. diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c index 966dcdf6..f0490e2c 100644 --- a/WWW/Library/Implementation/HTNews.c +++ b/WWW/Library/Implementation/HTNews.c @@ -360,7 +360,7 @@ PRIVATE NNTPAuthResult HTHandleAuthInfo ARGS1( if (status == HT_INTERRUPTED) _HTProgress(CONNECTION_INTERRUPTED); else - HTAlert(gettext("Connection closed ???")); + HTAlert(FAILED_CONNECTION_CLOSED); if (auth) { if (auth->user != UserName) { FREE(auth->user); @@ -444,7 +444,7 @@ PRIVATE NNTPAuthResult HTHandleAuthInfo ARGS1( if (status == HT_INTERRUPTED) { _HTProgress(CONNECTION_INTERRUPTED); } else { - HTAlert(gettext("Connection closed ???")); + HTAlert(FAILED_CONNECTION_CLOSED); } if (auth) { if (auth->user != UserName) { @@ -823,7 +823,7 @@ PRIVATE void post_article ARGS1( ** nntp headers and message body. - FM */ if ((fd = fopen((postfile ? postfile : ""), "r")) == NULL) { - HTAlert(gettext("Cannot open temporary file for news POST.")); + HTAlert(FAILED_CANNOT_OPEN_POST); return; } @@ -2026,7 +2026,7 @@ PRIVATE int HTLoadNews ARGS4( if (!strncasecomp(arg, "snewspost:", 10) || !strncasecomp(arg, "snewsreply:", 11)) { - HTAlert(gettext("This client does not contain support for posting to news with SSL.")); + HTAlert(FAILED_CANNOT_POST_SSL); return HT_NOT_LOADED; } if (post_wanted || reply_wanted || spost_wanted || sreply_wanted) { diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c index 29235921..d0ff1207 100644 --- a/WWW/Library/Implementation/HTRules.c +++ b/WWW/Library/Implementation/HTRules.c @@ -319,7 +319,7 @@ PUBLIC int HTSetConfiguration ARGS1( word3 = HTNextField(&pointer); /* Just the next word */ if (!word2) { - fprintf(stderr, gettext("HTRule: Insufficient operands: %s\n"), line); + fprintf(stderr, "HTRule: %s %s\n", RULE_NEEDS_DATA, line); FREE(line); return -2; /*syntax error */ } @@ -357,7 +357,7 @@ PUBLIC int HTSetConfiguration ARGS1( : 0==strcasecomp(word1, "protect") ? HT_Protect : HT_Invalid; if (op==HT_Invalid) { - fprintf(stderr, gettext("HTRule: Bad rule `%s'\n"), config); + fprintf(stderr, "HTRule: %s '%s'\n", RULE_INCORRECT, config); } else { HTAddRule(op, word2, word3); } diff --git a/WWW/Library/Implementation/HTStyle.c b/WWW/Library/Implementation/HTStyle.c index 77c63aa8..e4066057 100644 --- a/WWW/Library/Implementation/HTStyle.c +++ b/WWW/Library/Implementation/HTStyle.c @@ -141,27 +141,26 @@ HTStyle * HTStyleDump (HTStyle * style) { int tab; NXTextStyle *p = style->paragraph; - printf(gettext("Style %d `%s' SGML:%s. Font %s %.1f point.\n"), + printf(STYLE_DUMP_FONT, style, style->name, style->SGMLTag, [style->font name], style->fontSize); if (p) { - printf( - gettext("\tIndents: first=%.0f others=%.0f, Height=%.1f Desc=%.1f\n" - "\tAlign=%d, %d tabs. (%.0f before, %.0f after)\n"), + printf(STYLE_DUMP_IDENT, p->indent1st, p->indent2nd, p->lineHt, - p->descentLine, + p->descentLine); + printf(STYLE_DUMP_ALIGN, p->alignment, p->numTabs, style->spaceBefore, style->spaceAfter); for (tab=0; tab < p->numTabs; tab++) { - printf(gettext("\t\tTab kind=%d at %.0f\n"), + printf(STYLE_DUMP_TAB, p->tabs[tab].kind, p->tabs[tab].x); } diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index dd93e142..b7bf5ec7 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -430,13 +430,11 @@ try_again: ** prompt. - FM */ if (!(traversal || dump_output_immediately) && - HTConfirm( - gettext("Proceed without a username and password?"))) { + HTConfirm(CONFIRM_WO_PASSWORD)) { show_401 = TRUE; } else { if (traversal || dump_output_immediately) - HTAlert( - gettext("Can't proceed without a username and password.")); + HTAlert(FAILED_NEED_PASSWD); FREE(command); FREE(hostname); FREE(docname); @@ -526,8 +524,7 @@ try_again: ** cancelled or goofed at the username and password ** prompt. - FM */ - if (!(traversal || dump_output_immediately) && - HTConfirm(gettext("Proceed without a username and password?"))) { + if (!(traversal || dump_output_immediately) && HTConfirm(CONFIRM_WO_PASSWORD)) { if (auth_proxy == TRUE) { show_407 = TRUE; } else { @@ -535,7 +532,7 @@ try_again: } } else { if (traversal || dump_output_immediately) - HTAlert(gettext("Can't proceed without a username and password.")); + HTAlert(FAILED_NEED_PASSWD); FREE(command); FREE(hostname); FREE(docname); @@ -607,7 +604,7 @@ try_again: ** Arrrrgh, HTTP 0/1 compability problem, maybe. */ CTRACE (tfp, "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n"); - _HTProgress (gettext("Retrying as HTTP0 request.")); + _HTProgress (RETRYING_AS_HTTP0); HTTP_NETCLOSE(s, handle); extensions = NO; already_retrying = TRUE; @@ -675,7 +672,7 @@ try_again: extensions = NO; already_retrying = TRUE; - _HTProgress (gettext("Retrying as HTTP0 request.")); + _HTProgress (RETRYING_AS_HTTP0); goto try_again; } else { CTRACE (tfp, "HTTP: Hit unexpected network read error; aborting connection; status %d.\n", @@ -759,7 +756,7 @@ try_again: CTRACE(tfp, "HTTP: close socket %d to retry with HTTP0\n", s); HTTP_NETCLOSE(s, handle); /* print a progress message */ - _HTProgress (gettext("Retrying as HTTP0 request.")); + _HTProgress (RETRYING_AS_HTTP0); goto try_again; } @@ -1495,8 +1492,7 @@ Cookie2_continuation: break; } else { if (traversal || dump_output_immediately) - HTAlert( - gettext("Can't retry with authorization! Contact the server's WebMaster.")); + HTAlert(FAILED_RETRY_WITH_AUTH); HTTP_NETCLOSE(s, handle); status = -1; goto clean_up; @@ -1532,8 +1528,7 @@ Cookie2_continuation: "HTTP: close socket", s, "to retry with Proxy Authorization"); - _HTProgress ( - gettext("Retrying with proxy authorization information.")); + _HTProgress (HTTP_RETRY_WITH_PROXY); FREE(line_buffer); FREE(line_kept_clean); goto try_again; @@ -1551,8 +1546,7 @@ Cookie2_continuation: break; } else { if (traversal || dump_output_immediately) - HTAlert( - gettext("Can't retry with proxy authorization! Contact the server's WebMaster.")); + HTAlert(FAILED_RETRY_WITH_PROXY); HTTP_NETCLOSE(s, handle); status = -1; goto clean_up; @@ -1728,7 +1722,7 @@ Cookie2_continuation: FREE(line_kept_clean); extensions = NO; already_retrying = TRUE; - _HTProgress (gettext("Retrying as HTTP0 request.")); + _HTProgress (RETRYING_AS_HTTP0); goto try_again; } else { status = HT_NOT_LOADED; diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c index 9275176f..7c599386 100644 --- a/WWW/Library/Implementation/HTVMSUtils.c +++ b/WWW/Library/Implementation/HTVMSUtils.c @@ -905,13 +905,13 @@ PUBLIC int HTVMSBrowseDir ARGS4( 0==strncmp((cp+1), "000000", 6)) || (dp=HTVMSopendir(pathname)) == NULL) { FREE(pathname); - return HTLoadError(sink, 403, gettext("Could not access directory.")); + return HTLoadError(sink, 403, COULD_NOT_ACCESS_DIR); } /* * Set up the output stream. */ - _HTProgress (gettext("Building directory listing...")); + _HTProgress (BUILDING_DIR_LIST); if (UCLYhndl_HTFile_for_unspec >= 0) { HTAnchor_setUCInfoStage(anchor, UCLYhndl_HTFile_for_unspec, diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c index b1b42ff2..638a560b 100644 --- a/WWW/Library/Implementation/HTWAIS.c +++ b/WWW/Library/Implementation/HTWAIS.c @@ -759,7 +759,7 @@ PUBLIC int HTLoadWAIS ARGS4( START(HTML_HEAD); PUTS("\n"); - HTStartIsIndex(target, gettext("Enter WAIS query: "), NULL); + HTStartIsIndex(target, HTWAIS_SOLICIT_QUERY , NULL); PUTS("\n"); { @@ -825,7 +825,7 @@ PUBLIC int HTLoadWAIS ARGS4( START(HTML_HEAD); PUTS("\n"); - HTStartIsIndex(target, gettext("Enter WAIS query: "), NULL); + HTStartIsIndex(target, HTWAIS_SOLICIT_QUERY, NULL); PUTS("\n"); START(HTML_TITLE); PUTS(keywords); @@ -882,7 +882,7 @@ PUBLIC int HTLoadWAIS ARGS4( goto CleanUp; } else if (!rv) { #ifdef VMS - HTAlert (gettext("HTWAIS: Return message too large.")); + HTAlert (HTWAIS_MESSAGE_TOO_BIG); return_status = HT_NOT_LOADED; FREE_TARGET; goto CleanUp; @@ -1001,7 +1001,7 @@ PUBLIC int HTLoadWAIS ARGS4( goto CleanUp; } else if (!rv) { #ifdef VMS - HTAlert (gettext("HTWAIS: Return message too large.")); + HTAlert (HTWAIS_MESSAGE_TOO_BIG); return_status = HT_NOT_LOADED; FREE_TARGET; FREE(type); diff --git a/WWW/Library/Implementation/HTWSRC.c b/WWW/Library/Implementation/HTWSRC.c index 85c92af6..83a84b55 100644 --- a/WWW/Library/Implementation/HTWSRC.c +++ b/WWW/Library/Implementation/HTWSRC.c @@ -306,14 +306,14 @@ PRIVATE void WSRC_gen_html ARGS2(HTStream *, me, BOOL, source_file) PUTS("\n"); START(HTML_TITLE); PUTS(shortname); - PUTS(source_file ? gettext(" WAIS source file") : gettext(" index")); + PUTS(source_file ? gettext(" WAIS source file") : INDEX_SEGMENT); END(HTML_TITLE); PUTS("\n"); END(HTML_HEAD); START(HTML_H1); PUTS(shortname); - PUTS(source_file ? gettext(" description") : gettext(" index")); + PUTS(source_file ? gettext(" description") : INDEX_SEGMENT); END(HTML_H1); PUTS("\n"); FREE(shortname); |