diff --git a/apps/attacher.c b/apps/attacher.c index 9f30e80..f12c5d8 100644 --- a/apps/attacher.c +++ b/apps/attacher.c @@ -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; } diff --git a/apps/email_common.h b/apps/email_common.h index 4751686..8f5b15f 100644 --- a/apps/email_common.h +++ b/apps/email_common.h @@ -6,7 +6,7 @@ #include -#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