ATTACHER: Fix #53 - MIME name is now just the filename (no path)

This commit is contained in:
Bobbi Webber-Manners 2021-05-23 19:42:21 -04:00
parent 3189c7a46c
commit a3099887a9
2 changed files with 19 additions and 2 deletions

View File

@ -613,6 +613,23 @@ done:
cursor(1);
}
/*
* Return pointer to start of the filename portion of a full path.
* /FOO/BAR/BAZ -> BAZ
*/
char *shortfilename(char *fullfilename) {
uint8_t i = 0;
int8_t lastslash = -1;
while (fullfilename[i]) {
if (fullfilename[i] == '/')
lastslash = i;
++i;
}
if (lastslash == -1)
return fullfilename;
return fullfilename + lastslash + 1;
}
/*
* Optionally attach files to outgoing email.
* filename - Name of file containing email message
@ -739,7 +756,7 @@ ask:
latest->next = malloc(sizeof(struct attachinfo));
latest = latest->next;
}
strcpy(latest->filename, userentry);
strcpy(latest->filename, shortfilename(userentry));
latest->size = size;
latest->next = NULL;
}

View File

@ -6,7 +6,7 @@
#include <stdint.h>
#define PROGNAME "emai//er v2.1.2"
#define PROGNAME "emai//er v2.1.3"
// Configuration params from EMAIL.CFG
char cfg_server[40]; // IP of POP3 server