Annotation of libwww/Library/src/HTAlert.c, revision 2.9

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: 
2.9     ! luotonen   42:   fgets(Reply, 4, stdin); /* get reply, max 3 characters */
1.1       timbl      43:   URep=Reply;
2.8       luotonen   44:   while (*URep) {
2.9     ! luotonen   45:     if (*URep == '\n') {
        !            46:        *URep = NULL;   /* Overwrite newline */
        !            47:        break;
        !            48:     }
2.8       luotonen   49:     *URep=TOUPPER(*URep);
                     50:     URep++;    /* This was previously embedded in the TOUPPER */
                     51:                 /* call an it became evaluated twice because   */
                     52:                 /* TOUPPER is a macro -- AL */
                     53:   }
                     54: 
1.1       timbl      55:   if ((strcmp(Reply,"YES")==0) || (strcmp(Reply,"Y")==0))
                     56:     return(YES);
                     57:   else
                     58:     return(NO);
                     59: }
                     60: 
                     61: /*     Prompt for answer and get text back
                     62: */
                     63: PUBLIC char * HTPrompt ARGS2(CONST char *, Msg, CONST char *, deflt)
                     64: {
                     65:     char Tmp[200];
                     66:     char * rep = 0;
                     67:     fprintf(stderr, "WWW: %s", Msg);
2.8       luotonen   68:     if (deflt) fprintf(stderr, " (RETURN for [%s]) ", deflt);
1.1       timbl      69:     
2.9     ! luotonen   70:     fgets(Tmp, 200, stdin);
        !            71:     Tmp[strlen(Tmp)-1] = NULL; /* Overwrite newline */
1.1       timbl      72:    
                     73:     StrAllocCopy(rep, *Tmp ? Tmp : deflt);
                     74:     return rep;
                     75: }
2.8       luotonen   76: 
                     77: 
                     78: /*     Prompt for password without echoing the reply
                     79: */
                     80: PUBLIC char * HTPromptPassword ARGS1(CONST char *, Msg)
                     81: {
                     82:     char *result = NULL;
                     83:     char *pw = getpass(Msg ? Msg : "Password: ");
                     84:     StrAllocCopy(result, pw);
                     85:     return result;
                     86: }
                     87: 

Webmaster