Remove dependency on getline.
* gnulib.modules: Remove getline. * pop3d/apop.c [!ENABLE_DBM] Use mu_stream API instead of FILE.
Showing
2 changed files
with
11 additions
and
10 deletions
... | @@ -114,9 +114,9 @@ pop3d_apopuser (const char *user) | ... | @@ -114,9 +114,9 @@ pop3d_apopuser (const char *user) |
114 | #else /* !ENABLE_DBM */ | 114 | #else /* !ENABLE_DBM */ |
115 | { | 115 | { |
116 | char *buf = NULL; | 116 | char *buf = NULL; |
117 | size_t size = 0; | 117 | size_t size = 0, n; |
118 | size_t ulen; | 118 | size_t ulen; |
119 | FILE *apop_file; | 119 | mu_stream_t apop_stream; |
120 | 120 | ||
121 | rc = mu_file_safety_check (apop_database_name, apop_database_safety, | 121 | rc = mu_file_safety_check (apop_database_name, apop_database_safety, |
122 | apop_database_owner, NULL); | 122 | apop_database_owner, NULL); |
... | @@ -127,17 +127,19 @@ pop3d_apopuser (const char *user) | ... | @@ -127,17 +127,19 @@ pop3d_apopuser (const char *user) |
127 | apop_database_name, mu_strerror (rc)); | 127 | apop_database_name, mu_strerror (rc)); |
128 | return NULL; | 128 | return NULL; |
129 | } | 129 | } |
130 | apop_file = fopen (apop_database_name, "r"); | 130 | |
131 | if (apop_file == NULL) | 131 | rc = mu_file_stream_create (&apop_stream, apop_database_name, |
132 | MU_STREAM_READ); | ||
133 | if (rc) | ||
132 | { | 134 | { |
133 | mu_diag_output (MU_DIAG_INFO, | 135 | mu_diag_output (MU_DIAG_INFO, |
134 | _("unable to open APOP password file %s: %s"), | 136 | _("unable to open APOP password file %s: %s"), |
135 | apop_database_name, mu_strerror (errno)); | 137 | apop_database_name, mu_strerror (rc)); |
136 | return NULL; | 138 | return NULL; |
137 | } | 139 | } |
138 | 140 | ||
139 | ulen = strlen (user); | 141 | ulen = strlen (user); |
140 | while (getline (&buf, &size, apop_file) > 0) | 142 | while (mu_stream_getline (apop_stream, &buf, &size, &n) == 0 && n > 0) |
141 | { | 143 | { |
142 | char *p, *start = mu_str_stripws (buf); | 144 | char *p, *start = mu_str_stripws (buf); |
143 | 145 | ||
... | @@ -154,8 +156,8 @@ pop3d_apopuser (const char *user) | ... | @@ -154,8 +156,8 @@ pop3d_apopuser (const char *user) |
154 | break; | 156 | break; |
155 | } | 157 | } |
156 | } | 158 | } |
157 | 159 | free (buf); | |
158 | fclose (apop_file); | 160 | mu_stream_unref (apop_stream); |
159 | return password; | 161 | return password; |
160 | } | 162 | } |
161 | #endif | 163 | #endif | ... | ... |
-
Please register or sign in to post a comment