#include "file.h"
#include "../lib/debug.h"
-#include "../lib/str.h"
#ifndef O_NOFOLLOW
# define O_NOFOLLOW 0
return -1;
len = m_strcat(abs_oldpath, sizeof(abs_oldpath), "/");
- if (len >= sizeof(abs_oldpath))
+ if (len >= ssizeof(abs_oldpath))
return -1;
len += m_strcpy(abs_oldpath + len, sizeof(abs_oldpath) - len, oldpath);
- if (len >= sizeof(abs_oldpath))
+ if (len >= ssizeof(abs_oldpath))
return -1;
if (symlink (abs_oldpath, newpath) < 0)
p_clear(buf, sizeof(buf));
while (sb.st_size > 0) {
- fwrite(buf, 1, MIN(sizeof(buf), sb.st_size), f);
- sb.st_size -= MIN(sizeof(buf), sb.st_size);
+ fwrite(buf, 1, MIN(ssizeof(buf), sb.st_size), f);
+ sb.st_size -= MIN(ssizeof(buf), sb.st_size);
}
fclose (f);
}
int mutt_copy_stream(FILE *fin, FILE *fout)
{
char buf[BUFSIZ];
- ssize_t l;
+ size_t l;
while ((l = fread(buf, 1, sizeof (buf), fin)) > 0) {
if (fwrite(buf, 1, l, fout) != l)
char buf[BUFSIZ];
while (size > 0) {
- ssize_t chunk = MIN(size, sizeof(buf));
+ size_t chunk = MIN(size, sizeof(buf));
if ((chunk = fread(buf, 1, chunk, in)) < 1)
break;
char *
mutt_concat_path(char *d, ssize_t n, const char *dir, const char *fname)
{
- const char *fmt = "%s/%s";
+ int pos;
- if (!*fname || (*dir && dir[m_strlen(dir) - 1] == '/'))
- fmt = "%s%s";
+ pos = m_strcpy(d, n, dir);
+ if (pos >= n - 1)
+ return d;
- snprintf(d, n, fmt, dir, fname);
+ if (pos && d[pos - 1] != '/')
+ d[pos++] = '/';
+
+ m_strcpy(d + pos, n - pos, fname);
return d;
}
/* FIXME: API is very wrong */
ssize_t mutt_quote_filename(char *d, ssize_t l, const char *s)
{
- size_t i, j = 0;
+ ssize_t i, j = 0;
if (!s) {
*d = '\0';