# HG changeset patch # User Mikael Berthe # Date 1128533435 -7200 # Node ID 2ea7591584ab5235f2c571a086613977306e9356 # Parent fa9149832af2a31d3b4385d9bc4a9b55952e990b Use fgets() instead of getline() getline() is not provided in FreeBSD (base install at least). Thanks to Vsevolod Stakhov. diff -r fa9149832af2 -r 2ea7591584ab mcabber/src/main.c --- 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 #include #include @@ -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; }