[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mpop-users] [PATCH 6/9] New escape codes %A (account name) and %I (message UID)



---
 src/tools.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/tools.c b/src/tools.c
index 715ab28..f63aed4 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -805,12 +805,34 @@ char *expand_session_variables(const char *string, pop3_session_t *session,
             } else {
                 switch (string[++i])
                 {
+                    case 'A': /* Account name */
+                    {
+                        char *acct_name = session->account->id ?
+                                session->account->id : "";
+                        if (step)
+                            strcpy(newstr + len, acct_name);
+
+                        len += strlen(acct_name);
+                        break;
+                    }
+
                     case 'F': /* Envelope */
                         if (step)
                             strcpy(newstr + len, from);
                         
                         len += strlen(from);
                         break;
+
+                    case 'I': /* Email UID */
+                    {
+                        char *uid = session->msg_uid ? session->msg_uid[recv_index] : "";
+                        if (step)
+                            strcpy(newstr + len, uid);
+
+                        len += strlen(uid);
+                        break;
+                    }
+
                     case 'H': /* Hostname */
                         if (step)
                             strcpy(newstr + len, session->account->host);
-- 
2.1.1