}
}
+/* Ensure buffer->dptr points to the end of the buffer. */
+void mutt_buffer_fix_dptr (BUFFER *buf)
+{
+ buf->dptr = buf->data;
+
+ if (buf->data)
+ {
+ buf->data[buf->dsize - 1] = '\0';
+ buf->dptr = strchr (buf->data, '\0');
+ }
+}
+
static int _mutt_buffer_add_printf (BUFFER* buf, const char* fmt, va_list ap)
{
va_list ap_retry;
void mutt_buffer_clear (BUFFER *);
void mutt_buffer_increase_size (BUFFER *, size_t);
+void mutt_buffer_fix_dptr (BUFFER *);
/* These two replace the buffer contents. */
int mutt_buffer_printf (BUFFER*, const char*, ...);
#include <errno.h>
#include <unistd.h>
+int mutt_buffer_rfc1524_expand_command (BODY *a, const char *filename, const char *_type,
+ BUFFER *command)
+{
+ int rc;
+
+ mutt_buffer_increase_size (command, LONG_STRING);
+ rc = rfc1524_expand_command (a, filename, _type, command->data, command->dsize);
+ mutt_buffer_fix_dptr (command);
+
+ return rc;
+}
+
/* The command semantics include the following:
* %s is the filename that contains the mail body data
* %t is the content type, like text/plain
* In addition, this function returns a 0 if the command works on a file,
* and 1 if the command works on a pipe.
*/
-int rfc1524_expand_command (BODY *a, char *filename, char *_type,
+int rfc1524_expand_command (BODY *a, const char *filename, const char *_type,
char *command, int clen)
{
int x=0,y=0;
* Returns 1 if newfile specified
*/
-static void strnfcpy(char *d, char *s, size_t siz, size_t len)
+static void strnfcpy(char *d, const char *s, size_t siz, size_t len)
{
if(len > siz)
len = siz - 1;
strfcpy(d, s, len);
}
-int rfc1524_expand_filename (char *nametemplate,
- char *oldfile,
+int mutt_buffer_rfc1524_expand_filename (const char *nametemplate,
+ const char *oldfile,
+ BUFFER *newfile)
+{
+ int rc;
+
+ mutt_buffer_increase_size (newfile, LONG_STRING);
+ rc = rfc1524_expand_filename (nametemplate, oldfile, newfile->data, newfile->dsize);
+ mutt_buffer_fix_dptr (newfile);
+
+ return rc;
+}
+
+int rfc1524_expand_filename (const char *nametemplate,
+ const char *oldfile,
char *newfile,
size_t nflen)
{
rfc1524_entry *rfc1524_new_entry (void);
void rfc1524_free_entry (rfc1524_entry **);
-int rfc1524_expand_command (BODY *, char *, char *, char *, int);
-int rfc1524_expand_filename (char *, char *, char *, size_t);
+int rfc1524_expand_command (BODY *, const char *, const char *, char *, int);
+int rfc1524_expand_filename (const char *, const char *, char *, size_t);
int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
int mutt_rename_file (char *, char *);
+
+/* Temporary BUFFER transition functions */
+int mutt_buffer_rfc1524_expand_command (BODY *, const char *, const char *, BUFFER *);
+int mutt_buffer_rfc1524_expand_filename (const char *, const char *, BUFFER *);
+
#endif /* _RFC1524_H */