Reinstate some lost functions.
authorPierre Habouzit <madcoder@debian.org>
Mon, 26 Mar 2007 23:50:48 +0000 (01:50 +0200)
committerPierre Habouzit <madcoder@debian.org>
Mon, 26 Mar 2007 23:50:48 +0000 (01:50 +0200)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
lib-lua/madmutt.cpkg

index 10cb39f..65ad756 100644 (file)
@@ -176,6 +176,48 @@ static char *madmutt_init_homedir(void)
         getcwd(path, sizeof(path));
         RETURN(path);
     };
         getcwd(path, sizeof(path));
         RETURN(path);
     };
+
+    /*
+     ** .pp
+     ** \fIThis is a read-only system property and, at runtime,
+     ** specifies the full path or URI of the folder currently
+     ** open (if any).\fP
+     */
+    const string_t folder_path(void) {
+        RETURN(CurrentFolder);
+    };
+
+    /*
+     ** .pp
+     ** \fIThis is a read-only system property and, at runtime,
+     ** specifies the actual name of the folder as far as it could
+     ** be detected.\fP
+     ** .pp
+     ** For detection, $$$folder is first taken into account
+     ** and simply stripped to form the result when a match is found. For
+     ** example, with $$$folder being \fTimap://host\fP and the folder is
+     ** \fTimap://host/INBOX/foo\fP, $$$madmutt_folder_name will be just
+     ** \fTINBOX/foo\fP.)
+     ** .pp
+     ** Second, if the initial portion of a name is not $$$folder,
+     ** the result will be everything after the last ``/''.
+     ** .pp
+     ** Third and last, the result will be just the name if neither
+     ** $$$folder nor a ``/'' were found in the name.
+     */
+    const string_t folder_name(void) {
+        const char *p;
+
+        if (!m_strisempty(Maildir)
+        &&  m_strstart(CurrentFolder, Maildir, &p) && *p) {
+            while (*p == '/')
+                p++;
+            RETURN(p);
+        } else {
+            p = strchr(CurrentFolder ?: "", '/');
+            RETURN(p ? p + 1 : (CurrentFolder ?: ""));
+        }
+    };
 };
 
 @package MTransport {
 };
 
 @package MTransport {