version 2.20, 1995/03/21 17:33:28
|
version 2.21, 1995/05/04 22:07:17
|
Line 16
|
Line 16
|
#include "tcp.h" |
#include "tcp.h" |
#include "HTUtils.h" |
#include "HTUtils.h" |
#include "HTString.h" |
#include "HTString.h" |
#include "HTAlert.h" |
#include "HTError.h" /* Implemented here */ |
|
#include "HTAlert.h" /* Implemented here */ |
|
|
PUBLIC BOOL HTInteractive=YES; /* Any prompts from the Library? */ |
PUBLIC BOOL HTInteractive=YES; /* Any prompts from the Library? */ |
|
|
|
/* ------------------------------------------------------------------------- */ |
|
|
|
PUBLIC void HTProgress ARGS1(CONST char *, Msg) |
|
{ |
|
fprintf(TDEST, " %s ...\n", Msg ? Msg : "UNKNWON"); |
|
} |
|
|
|
|
PUBLIC void HTAlert ARGS1(CONST char *, Msg) |
PUBLIC void HTAlert ARGS1(CONST char *, Msg) |
{ |
{ |
#ifdef NeXTStep |
#ifdef NeXTStep |
NXRunAlertPanel(NULL, "%s", NULL, NULL, NULL, Msg); |
NXRunAlertPanel(NULL, "%s", NULL, NULL, NULL, Msg); |
#else |
#else |
fprintf(TDEST, "\nWWW Alert: %s\n", Msg); |
fprintf(TDEST, "\nWARNING: %s\n", Msg ? Msg : "UNKNOWN"); |
#endif |
#endif |
} |
} |
|
|
|
|
PUBLIC void HTProgress ARGS1(CONST char *, Msg) |
|
{ |
|
fprintf(TDEST, " %s ...\n", Msg); |
|
} |
|
|
|
|
|
PUBLIC BOOL HTConfirm ARGS1(CONST char *, Msg) |
PUBLIC BOOL HTConfirm ARGS1(CONST char *, Msg) |
{ |
{ |
char Reply[4]; /* One more for terminating NULL -- AL */ |
char Reply[4]; /* One more for terminating NULL -- AL */ |
char *URep; |
char *URep; |
|
|
fprintf(TDEST, "WWW: %s (y/n) ", Msg); /* (y/n) came twice -- AL */ |
fprintf(TDEST, "%s (y/n) ", Msg ? Msg : "UNKNOWN"); |
#ifndef NO_STDIO |
#ifndef NO_STDIO |
if (!HTInteractive || !fgets(Reply, 4, stdin)) /* get reply, max 3 chars */ |
if (!HTInteractive || !fgets(Reply, 4, stdin)) /* get reply, max 3 chars */ |
#endif |
#endif |
Line 71 PUBLIC char * HTPrompt ARGS2(CONST char
|
Line 73 PUBLIC char * HTPrompt ARGS2(CONST char
|
{ |
{ |
char buffer[200]; |
char buffer[200]; |
char *reply = NULL; |
char *reply = NULL; |
fprintf(TDEST, "WWW: %s", Msg); |
fprintf(TDEST, "%s", Msg ? Msg : "UNKNOWN"); |
if (deflt) |
if (deflt) |
fprintf(TDEST, " (RETURN for [%s]) ", deflt); |
fprintf(TDEST, " (RETURN for [%s]) ", deflt); |
|
|
Line 127 PUBLIC void HTPromptUsernameAndPassword
|
Line 129 PUBLIC void HTPromptUsernameAndPassword
|
char **, username, |
char **, username, |
char **, password) |
char **, password) |
{ |
{ |
if (Msg && *Msg) |
fprintf(TDEST, "%s\n", Msg ? Msg : "UNKNOWN"); |
fprintf(TDEST, "WWW: %s\n", Msg); |
|
*username = HTPrompt("Username: ", *username); |
*username = HTPrompt("Username: ", *username); |
*password = HTPromptPassword("Password: "); |
*password = HTPromptPassword("Password: "); |
} |
} |
|
|
|
|
|
/* HTErrorMsg |
|
** |
|
** Default function that creates an error message using HTAlert() to |
|
** put out the contents of the error_stack messages. Furthermore, the |
|
** error_info structure contains a name of a help file that might be put |
|
** up as a link. This file can then be multi-linguistic. |
|
** |
|
** This function might be overwritten by a smart server or client. |
|
*/ |
|
PUBLIC void HTErrorMsg ARGS1(HTRequest *, request) |
|
{ |
|
HTList *cur = request->error_stack; |
|
BOOL highest = YES; |
|
HTChunk *chunk; |
|
HTErrorInfo *pres; |
|
if (!request) { |
|
if (TRACE) fprintf(TDEST, "HTErrorMsg.. Bad argument!\n"); |
|
return; |
|
} |
|
|
|
/* This check is only necessary if the error message is put down the |
|
stream, because we have to know if a stream has been put up and/or |
|
taken down again. Here it is only put as an example */ |
|
#if 0 |
|
if (request->error_block) { |
|
if (TRACE) fprintf(TDEST, "HTErrorMsg.. No messages are printed as no stream is available.\n"); |
|
return; |
|
} |
|
#endif |
|
|
|
/* Output messages */ |
|
chunk = HTChunkCreate(128); |
|
while ((pres = (HTErrorInfo *) HTList_nextObject(cur))) { |
|
|
|
/* Check if we are going to show the message */ |
|
if ((!pres->ignore || HTErrorShowMask & HT_ERR_SHOW_IGNORE) && |
|
(HTErrorShowMask & pres->severity)) { |
|
|
|
/* Output code number */ |
|
if (highest) { /* If first time through */ |
|
if (TRACE) |
|
fprintf(TDEST, |
|
"HTError..... Generating message.\n"); |
|
|
|
/* Output title */ |
|
if (pres->severity == ERR_WARN) |
|
HTChunkPuts(chunk, "Warning "); |
|
else if (pres->severity == ERR_NON_FATAL) |
|
HTChunkPuts(chunk, "Non Fatal Error "); |
|
else if (pres->severity == ERR_FATAL) |
|
HTChunkPuts(chunk, "Fatal Error "); |
|
else if (pres->severity == ERR_INFO) |
|
HTChunkPuts(chunk, "Information "); |
|
else { |
|
if (TRACE) |
|
fprintf(TDEST, "HTError..... Unknown Classification of Error (%d)...\n", pres->severity); |
|
HTChunkFree(chunk); |
|
return; |
|
} |
|
|
|
/* Only output error code if it is a real HTTP code */ |
|
if (pres->element < HTERR_HTTP_CODES_END) { |
|
char codestr[10]; |
|
sprintf(codestr, "%d ", error_info[pres->element].code); |
|
HTChunkPuts(chunk, codestr); |
|
} |
|
highest = NO; |
|
} else |
|
HTChunkPuts(chunk, "\nReason: "); |
|
|
|
/* Output error message */ |
|
if (pres->element != HTERR_SYSTEM) { |
|
HTChunkPuts(chunk, error_info[pres->element].msg); |
|
HTChunkPutc(chunk, ' '); |
|
} |
|
|
|
/* Output parameters */ |
|
if (pres->par && HTErrorShowMask & HT_ERR_SHOW_PARS) { |
|
unsigned int cnt; |
|
char ch; |
|
for (cnt=0; cnt<pres->par_length; cnt++) { |
|
ch = *((char *)(pres->par)+cnt); |
|
if (ch < 0x20 || ch >= 0x7F) |
|
HTChunkPutc(chunk, '#'); /* Can't print real content */ |
|
else |
|
HTChunkPutc(chunk, ch); |
|
} |
|
} |
|
|
|
/* Output location */ |
|
if (pres->where && HTErrorShowMask & HT_ERR_SHOW_LOCATION) { |
|
HTChunkPuts(chunk, "This occured in "); |
|
HTChunkPuts(chunk, pres->where); |
|
HTChunkPutc(chunk, '\n'); |
|
} |
|
|
|
/* We don't want the message more than once */ |
|
HTErrorIgnore(request, pres->handle); |
|
|
|
/* If we only are going to show the higest entry */ |
|
if (HTErrorShowMask & HT_ERR_SHOW_FIRST) |
|
break; |
|
} |
|
} |
|
HTChunkPutc(chunk, '\n'); |
|
HTChunkTerminate(chunk); |
|
if (chunk->size > 2) |
|
HTAlert(chunk->data); |
|
HTChunkFree(chunk); |
|
return; |
|
} |