--- a/mcabber/src/main.c Wed Oct 05 19:23:54 2005 +0200
+++ b/mcabber/src/main.c Wed Oct 05 19:30:35 2005 +0200
@@ -20,7 +20,6 @@
* USA
*/
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -143,7 +142,8 @@
char *password, *p;
size_t passsize = 128;
struct termios orig, new;
- int nread;
+
+ password = g_new0(char, passsize);
/* Turn echoing off and fail if we can't. */
if (tcgetattr(fileno(stdin), &orig) != 0) return;
@@ -152,23 +152,20 @@
if (tcsetattr(fileno(stdin), TCSAFLUSH, &new) != 0) return;
/* Read the password. */
- password = NULL;
printf("Please enter password: ");
- nread = getline(&password, &passsize, stdin);
+ fgets(password, passsize, stdin);
/* Restore terminal. */
tcsetattr(fileno(stdin), TCSAFLUSH, &orig);
printf("\n");
- if (nread == -1 || !password) return;
-
for (p = (char*)password; *p; p++)
;
for ( ; p > (char*)password ; p--)
if (*p == '\n' || *p == '\r') *p = 0;
settings_set(SETTINGS_TYPE_OPTION, "password", password);
- free(password);
+ g_free(password);
return;
}