svn commit: samba r25678 - in branches/SAMBA_4_0/source/lib/replace: .

metze at samba.org metze at samba.org
Wed Oct 17 14:00:11 GMT 2007


Author: metze
Date: 2007-10-17 14:00:09 +0000 (Wed, 17 Oct 2007)
New Revision: 25678

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25678

Log:
reformat getpass() replacement code
metze
(cherry picked from commit 3e8f43e3cf97f10be4717978643ef3edca8650a5)

Modified:
   branches/SAMBA_4_0/source/lib/replace/getpass.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/getpass.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/getpass.c	2007-10-17 13:58:19 UTC (rev 25677)
+++ branches/SAMBA_4_0/source/lib/replace/getpass.c	2007-10-17 14:00:09 UTC (rev 25678)
@@ -140,69 +140,65 @@
 
 char *getsmbpass(const char *prompt)
 {
-  FILE *in, *out;
-  int echo_off;
-  static char buf[256];
-  static size_t bufsize = sizeof(buf);
-  size_t nread;
+	FILE *in, *out;
+	int echo_off;
+	static char buf[256];
+	static size_t bufsize = sizeof(buf);
+	size_t nread;
 
-  /* Catch problematic signals */
-  catch_signal(SIGINT, SIGNAL_CAST SIG_IGN);
+	/* Catch problematic signals */
+	catch_signal(SIGINT, SIGNAL_CAST SIG_IGN);
 
-  /* Try to write to and read from the terminal if we can.
-     If we can't open the terminal, use stderr and stdin.  */
+	/* Try to write to and read from the terminal if we can.
+		If we can't open the terminal, use stderr and stdin.  */
 
-  in = fopen ("/dev/tty", "w+");
-  if (in == NULL)
-    {
-      in = stdin;
-      out = stderr;
-    }
-  else
-    out = in;
+	in = fopen ("/dev/tty", "w+");
+	if (in == NULL) {
+		in = stdin;
+		out = stderr;
+	} else {
+		out = in;
+	}
 
-  setvbuf(in, NULL, _IONBF, 0);
+	setvbuf(in, NULL, _IONBF, 0);
 
-  /* Turn echoing off if it is on now.  */
+	/* Turn echoing off if it is on now.  */
 
-  if (tcgetattr (fileno (in), &t) == 0)
-    {
-	  if (ECHO_IS_ON(t))
-	{
-		TURN_ECHO_OFF(t);
-		echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0;
-		TURN_ECHO_ON(t);
+	if (tcgetattr (fileno (in), &t) == 0) {
+		if (ECHO_IS_ON(t)) {
+			TURN_ECHO_OFF(t);
+			echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0;
+			TURN_ECHO_ON(t);
+		} else {
+			echo_off = 0;
+		}
+	} else {
+		echo_off = 0;
 	}
-      else
-	echo_off = 0;
-    }
-  else
-    echo_off = 0;
 
-  /* Write the prompt.  */
-  fputs (prompt, out);
-  fflush (out);
+	/* Write the prompt.  */
+	fputs(prompt, out);
+	fflush(out);
 
-  /* Read the password.  */
-  buf[0] = 0;
-  fgets(buf, bufsize, in);
-  nread = strlen(buf);
-  if (buf[nread - 1] == '\n')
-    buf[nread - 1] = '\0';
+	/* Read the password.  */
+	buf[0] = 0;
+	fgets(buf, bufsize, in);
+	nread = strlen(buf);
+	if (buf[nread - 1] == '\n')
+		buf[nread - 1] = '\0';
 
-  /* Restore echoing.  */
-  if (echo_off)
-    (void) tcsetattr (fileno (in), TCSANOW, &t);
+	/* Restore echoing.  */
+	if (echo_off)
+		tcsetattr (fileno (in), TCSANOW, &t);
 
-  if (in != stdin)
-    /* We opened the terminal; now close it.  */
-    fclose (in);
+	if (in != stdin) /* We opened the terminal; now close it.  */
+		fclose(in);
 
-  /* Catch problematic signals */
-  catch_signal(SIGINT, SIGNAL_CAST SIG_DFL);
+	/* Catch problematic signals */
+	catch_signal(SIGINT, SIGNAL_CAST SIG_DFL);
 
-  printf("\n");
-  return buf;
+	printf("\n");
+	return buf;
 }
 
 #else



More information about the samba-cvs mailing list