summaryrefslogtreecommitdiff
path: root/pop3d
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-07-16 13:08:17 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-07-16 14:32:38 +0300
commite9871d0f003889c8fff79ee24cb23ae0c1103d5c (patch)
tree01fea129f1376013e05964f1f79fbd77bf916ec9 /pop3d
parent044c35cd493c76f49666ca1fbadb62eb18ac0a23 (diff)
downloadmailutils-e9871d0f003889c8fff79ee24cb23ae0c1103d5c.tar.gz
mailutils-e9871d0f003889c8fff79ee24cb23ae0c1103d5c.tar.bz2
Remove dependency on getline.
* gnulib.modules: Remove getline. * pop3d/apop.c [!ENABLE_DBM] Use mu_stream API instead of FILE.
Diffstat (limited to 'pop3d')
-rw-r--r--pop3d/apop.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/pop3d/apop.c b/pop3d/apop.c
index ee0508024..7dc59ae5f 100644
--- a/pop3d/apop.c
+++ b/pop3d/apop.c
@@ -114,9 +114,9 @@ pop3d_apopuser (const char *user)
#else /* !ENABLE_DBM */
{
char *buf = NULL;
- size_t size = 0;
+ size_t size = 0, n;
size_t ulen;
- FILE *apop_file;
+ mu_stream_t apop_stream;
rc = mu_file_safety_check (apop_database_name, apop_database_safety,
apop_database_owner, NULL);
@@ -127,17 +127,19 @@ pop3d_apopuser (const char *user)
apop_database_name, mu_strerror (rc));
return NULL;
}
- apop_file = fopen (apop_database_name, "r");
- if (apop_file == NULL)
+
+ rc = mu_file_stream_create (&apop_stream, apop_database_name,
+ MU_STREAM_READ);
+ if (rc)
{
mu_diag_output (MU_DIAG_INFO,
_("unable to open APOP password file %s: %s"),
- apop_database_name, mu_strerror (errno));
+ apop_database_name, mu_strerror (rc));
return NULL;
}
-
+
ulen = strlen (user);
- while (getline (&buf, &size, apop_file) > 0)
+ while (mu_stream_getline (apop_stream, &buf, &size, &n) == 0 && n > 0)
{
char *p, *start = mu_str_stripws (buf);
@@ -154,8 +156,8 @@ pop3d_apopuser (const char *user)
break;
}
}
-
- fclose (apop_file);
+ free (buf);
+ mu_stream_unref (apop_stream);
return password;
}
#endif

Return to:

Send suggestions and report system problems to the System administrator.