]> andersk Git - moira.git/blobdiff - clients/userreg/display.c
Replaced all the EQUEL with ESQL. A few lines may not be proper
[moira.git] / clients / userreg / display.c
index 2adb3bab5ea336a490fc7aef224f625057d6c3ce..7a2147f674076108b12cfde65e4356d2d7e57004 100644 (file)
@@ -3,25 +3,29 @@
  *     $Author$
  *     $Locker$
  *     $Header$
+ *
+ *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
+ *  For copying and distribution information, please see the file
+ *  <mit-copyright.h>.
  */
 
 #ifndef lint
 static char *rcsid_display_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include <stdio.h>
 #include <curses.h>
 #include <sys/time.h>
 #include "userreg.h"
 
 #define DESC_WIDTH 18
-#define HEADER "*** Project Athena User Registration ***"
-#ifdef ibm032
-#define HELP   " Press backspace to delete a character.  Press Ctrl-C to start over."
-#else
-#ifdef vax
-#define HELP   " Press the key marked <X| to delete a character.  Press Ctrl-C to start over."
+#define HEADER "*** Athena User Account Registration ***"
+#if defined(vax) || defined(mips)
+#define HELP   " Press the key above RETURN to delete a character.  Press Ctrl-C to start over."
 #endif
+#ifndef HELP
+#define HELP   "    Press backspace to delete a character.  Press Ctrl-C to start over."
 #endif
 #define BORDER_CHAR '-'
 #define MIN_COLS 80
@@ -112,12 +116,15 @@ int   l;
 /* This replaces several "useful" display functions in the old userreg */
 redisp () {
   mvwprintw (fnamew, 0, 0, "%-24s", user.u_first);
+  wrefresh(fnamew);
   mvwprintw (midw, 0, 0, "%-24s", user.u_mid_init);
+  wrefresh(midw);
   mvwprintw (lnamew, 0, 0, "%-24s", user.u_last);
+  wrefresh(lnamew);
   mvwprintw (idw, 0, 0, "%-24s", typed_mit_id);
+  wrefresh(idw);
   mvwprintw (loginw, 0, 0, "%-24s", user.u_login);
-
-  wrefresh (dataw);
+  wrefresh(loginw);
 }
 
 
@@ -157,9 +164,9 @@ query_user (prompt, buf, maxsize, timeout, echop, emptyok, valuep)
 char *prompt;
 char *buf;
 int   maxsize, timeout;
-bool echop, emptyok, valuep;
+int echop, emptyok, valuep;
 {
-  char  c;
+  int  c;
   int   i;
   struct itimerval it;
 
@@ -178,15 +185,15 @@ retry:
   wrefresh (queryw);
 
   i = 0;
-  while ((c = getchar ()) != '\r') {
+  while ((c = getchar ()) != '\r' && c != '\n') {
    switch (c) {
      case '\025':              /* Ctl-U */
        goto retry;
-       break;
       case EOF:
        /* We're in raw mode, so EOF means disaster */
        exit(1);
        break;
+    delchar:
       case '\177':             /* Delete */
       case '\010':             /* Backspace */
        if (i) {
@@ -199,13 +206,9 @@ retry:
        }
        break;
       case '\003':             /* Ctrl-C */
-       if (getuid() != 0) 
-         { clear();            /* Exit if not root. */
-           restore_display();
-           exit(0);
-         }
-       else
-         restart();  
+       clear();
+       restore_display();
+       exit(0);
        break;
       default: 
        if (c >= ' ') {         /* Ignore all other control chars */
@@ -218,11 +221,12 @@ retry:
        break;
     }
     if (valuep && i >= maxsize) {
+      wfeep();
       wprintw (displayw,
   "You are not allowed to type more than %d characters for this answer.\n",
-         maxsize);
+         maxsize-1);
       wrefresh (displayw);
-      goto retry;
+      goto delchar;
     }
  }
 
@@ -260,7 +264,7 @@ askyn(prompt)
   int ypos, xpos;
   int answer;
   struct itimerval it;
-  char c;
+  int c;
 
  start:
   werase (queryw);
@@ -278,7 +282,7 @@ askyn(prompt)
   it.it_value.tv_usec = 0;
   setitimer (ITIMER_REAL, &it, (struct itimerval *) 0);
     
-  while ((c = getchar ()) != '\r') {   /* Wait for CR. */
+  while ((c = getchar ()) != '\r' && c != '\n') {      /* Wait for CR. */
       switch (c) {
       case 'n':                        /* No. */
       case 'N':
@@ -309,11 +313,9 @@ askyn(prompt)
        exit(1);
        break;
       case '\003':             /* Ctrl-C */
-/*     if (getuid() != 0) */
-         { clear();            /* Exit if not root. */
-           restore_display();
-           exit(0);
-         }
+       clear();
+       restore_display();
+       exit(0);
        break;
       default:                 /* Ignore everything else. */
        break;
@@ -335,22 +337,23 @@ display_text_line (line)
 char *line;
 {
   if (line) {
-    waddstr (displayw, line);
-    waddch (displayw, '\n');
-    wrefresh (displayw);
-  }
-  else {
-    werase (displayw);
+      waddstr (displayw, line);
+      waddch (displayw, '\n');
+  } else {
+      werase (displayw);
   }
   wrefresh (displayw);
 }
 
-/* Display_text displays a canned message from a file */
-display_text (filename)
+/* Display_text displays a canned message from a file.  The string
+ * will get imbedded in any %s's in the text.
+ */
+display_text(filename, string)
 char *filename;
+char *string;
 {
   FILE * fp;
-  char  buf[100];
+  char  buf[100], buf1[110];
 
   werase (displayw);
   if ((fp = fopen (filename, "r")) == NULL) {
@@ -359,11 +362,14 @@ char *filename;
   }
 
   while (fgets (buf, 100, fp)) {
-  /* get rid of the newline */
-    buf[strlen (buf) - 1] = 0;
-    display_text_line (buf);
+      /* get rid of the newline */
+      buf[strlen (buf) - 1] = 0;
+      sprintf(buf1, buf, string);
+      waddstr(displayw, buf1);
+      waddch(displayw, '\n');
   }
 
+  wrefresh(displayw);
   fclose (fp);
 }
 
This page took 0.031568 seconds and 4 git commands to generate.