int length; /* of attachment header field name */
char *p; /* miscellaneous string pointer */
struct stat st; /* file status buffer */
- FILE *fp; /* pointer for mhn.defaults */
FILE *body_file = NULL; /* body file pointer */
FILE *draft_file; /* draft file pointer */
int field_size; /* size of header field buffer */
* Make names for the temporary files.
*/
- (void)strncpy(body_file_name,
- m_mktemp(m_maildir(invo_name), NULL, NULL),
- body_file_name_len);
- (void)strncpy(composition_file_name,
- m_mktemp(m_maildir(invo_name), NULL, NULL),
- composition_file_name_len);
+ if ((p = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ (void)strncpy(body_file_name, p, body_file_name_len);
+ if ((p = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+ unlink(body_file_name);
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ (void)strncpy(composition_file_name, p, composition_file_name_len);
if (has_body)
body_file = fopen(body_file_name, "w");
* composition file for each.
*/
- if ((fp = fopen (p = etcpath ("mhn.defaults"), "r"))) {
- readconfig ((struct node **) NULL, fp, p, 0);
- fclose(fp);
- }
-
rewind(draft_file);
while (get_line(draft_file, field, field_size) != EOF && *field != '\0' &&
*/
static char *
get_file_info(const char *proc, const char *file_name) {
- char buf[BUFSIZ >= 2048 ? BUFSIZ : 2048];
char *cmd, *cp;
char *quotec = "'";
- FILE *fp;
if ((cp = strchr(file_name, '\''))) {
/* file_name contains a single quote. */
cmd = concat(proc, " ", quotec, file_name, quotec, NULL);
if ((cmd = concat(proc, " ", quotec, file_name, quotec, NULL))) {
+ FILE *fp;
+
if ((fp = popen(cmd, "r")) != NULL) {
+ char buf[BUFSIZ >= 2048 ? BUFSIZ : 2048];
+
+ buf[0] = '\0';
if (fgets(buf, sizeof buf, fp)) {
char *eol;
if ((eol = strpbrk(cp, "\n\r")) != NULL) {
*eol = '\0';
}
- } else {
- advise(NULL, "unable to read mime type");
+ } else if (buf[0] == '\0') {
+ /* This can happen on Cygwin if the popen()
+ mysteriously fails. Return NULL so that the caller
+ will use another method to determine the info. */
+ free (cp);
+ cp = NULL;
}
(void) pclose(fp);
char cmd[PATH_MAX + 8]; /* file command buffer */
struct stat st; /* file status buffer */
char *p; /* miscellaneous temporary variables */
- FILE *fp;
int c; /* current character */
if ((content_type = mime_type (file_name)) == NULL) {
* have the suffix in the field, including the dot.
*/
struct node *np; /* context scan node pointer */
+ static FILE *fp = NULL; /* pointer for mhn.defaults */
+
+ if (fp == NULL && (fp = fopen (p = etcpath ("mhn.defaults"), "r"))) {
+ readconfig ((struct node **) NULL, fp, p, 0);
+ fclose(fp);
+ }
if ((p = strrchr(file_name, '.')) != NULL) {
for (np = m_defs; np; np = np->n_next) {
*/
if (content_type == NULL) {
int binary; /* binary character found flag */
+ FILE *fp;
if ((fp = fopen(file_name, "r")) == (FILE *)0) {
advise(NULL, "unable to access file \"%s\"", file_name);
switch (attachformat) {
case 0: {
struct stat st;
+ FILE *fp;
char m[4];
/* Insert name, file mode, and Content-Id. */