Annotation of libwww/Library/src/HTAlert.c, revision 2.8
1.1 timbl 1: /* Displaying messages and getting input for LineMode Browser
2: ** ==========================================================
3: **
4: ** REPLACE THIS MODULE with a GUI version in a GUI environment!
5: **
6: ** History:
7: ** Jun 92 Created May 1992 By C.T. Barker
8: ** Feb 93 Simplified, portablised TBL
2.8 ! luotonen 9: ** Sep 93 Corrected 3 bugs in HTConfirm() :-( AL
1.1 timbl 10: */
11:
12:
13: #include "HTAlert.h"
14:
15: #include "tcp.h" /* for TOUPPER */
16: #include <ctype.h> /* for toupper - should be in tcp.h */
17:
18: PUBLIC void HTAlert ARGS1(CONST char *, Msg)
19: {
2.6 timbl 20: #ifdef NeXTStep
21: NXRunAlertPanel(NULL, "%s", NULL, NULL, NULL, Msg);
22: #else
1.1 timbl 23: fprintf(stderr, "WWW Alert: %s\n", Msg);
2.6 timbl 24: #endif
1.1 timbl 25: }
26:
27:
28: PUBLIC void HTProgress ARGS1(CONST char *, Msg)
29: {
30: fprintf(stderr, " %s ...\n", Msg);
31: }
32:
33:
34: PUBLIC BOOL HTConfirm ARGS1(CONST char *, Msg)
35: {
2.8 ! luotonen 36: char Reply[4]; /* One more for terminating NULL -- AL */
1.1 timbl 37: char *URep;
38:
39: fprintf(stderr, "WWW: %s (y/n) ", Msg);
2.8 ! luotonen 40: /* (y/n) came twice -- AL */
1.1 timbl 41:
42: scanf("%3s",Reply); /* get reply, max 3 characters */
43: URep=Reply;
2.8 ! luotonen 44: while (*URep) {
! 45: *URep=TOUPPER(*URep);
! 46: URep++; /* This was previously embedded in the TOUPPER */
! 47: /* call an it became evaluated twice because */
! 48: /* TOUPPER is a macro -- AL */
! 49: }
! 50:
1.1 timbl 51: if ((strcmp(Reply,"YES")==0) || (strcmp(Reply,"Y")==0))
52: return(YES);
53: else
54: return(NO);
55: }
56:
57: /* Prompt for answer and get text back
58: */
59: PUBLIC char * HTPrompt ARGS2(CONST char *, Msg, CONST char *, deflt)
60: {
61: char Tmp[200];
62: char * rep = 0;
63: fprintf(stderr, "WWW: %s", Msg);
2.8 ! luotonen 64: if (deflt) fprintf(stderr, " (RETURN for [%s]) ", deflt);
1.1 timbl 65:
2.8 ! luotonen 66: scanf("%199s", Tmp); /* fgets()'s does not mix very well with scanf()'s -- AL */
1.1 timbl 67:
68: StrAllocCopy(rep, *Tmp ? Tmp : deflt);
69: return rep;
70: }
2.8 ! luotonen 71:
! 72:
! 73: /* Prompt for password without echoing the reply
! 74: */
! 75: PUBLIC char * HTPromptPassword ARGS1(CONST char *, Msg)
! 76: {
! 77: char *result = NULL;
! 78: char *pw = getpass(Msg ? Msg : "Password: ");
! 79: StrAllocCopy(result, pw);
! 80: return result;
! 81: }
! 82:
Webmaster