changeset 482:2ea7591584ab

Use fgets() instead of getline() getline() is not provided in FreeBSD (base install at least). Thanks to Vsevolod Stakhov.
author Mikael Berthe <mikael@lilotux.net>
date Wed, 05 Oct 2005 19:30:35 +0200
parents fa9149832af2
children 4a10c04ac2fb
files mcabber/src/main.c
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }