summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--examples/lsf.c2
-rw-r--r--include/mailutils/cpp/folder.h4
-rw-r--r--include/mailutils/folder.h9
-rw-r--r--libmailutils/mailbox/folder.c8
-rw-r--r--libmailutils/mailbox/fsfolder.c12
-rw-r--r--libmailutils/tests/fsfolder.c8
-rw-r--r--libmu_cpp/folder.cc8
-rw-r--r--libproto/imap/folder.c4
-rw-r--r--libproto/imap/genlist.c12
-rw-r--r--libproto/imap/tests/imapfolder.c2
-rw-r--r--libproto/nntp/folder.c2
-rw-r--r--mu/libexec/imap.c2
-rw-r--r--python/2/libmu_py/folder.c8
-rw-r--r--python/2/mailutils/folder.py4
-rw-r--r--python/3/libmu_py/folder.c10
-rw-r--r--python/3/mailutils/folder.py4
16 files changed, 50 insertions, 49 deletions
diff --git a/examples/lsf.c b/examples/lsf.c
index cba79d3..c386893 100644
--- a/examples/lsf.c
+++ b/examples/lsf.c
@@ -26,13 +26,13 @@ static int
enumfun (mu_folder_t folder, struct mu_list_response *resp, void *data)
{
printf ("%c%c %c %4d %s\n",
(resp->type & MU_FOLDER_ATTRIBUTE_DIRECTORY) ? 'd' : '-',
(resp->type & MU_FOLDER_ATTRIBUTE_FILE) ? 'f' : '-',
resp->separator,
- resp->level,
+ resp->depth,
resp->name);
return 0;
}
int
ls_folders (char *fname, char *ref, char *pattern, int level)
diff --git a/include/mailutils/cpp/folder.h b/include/mailutils/cpp/folder.h
index fe4ed77..97c6d0f 100644
--- a/include/mailutils/cpp/folder.h
+++ b/include/mailutils/cpp/folder.h
@@ -40,15 +40,15 @@ class Folder
~Folder ();
void open ();
void open (int flag);
void close ();
- List& list (const std::string& dirname, void* pattern, size_t max_level);
+ List& list (const std::string& dirname, void* pattern, size_t max_depth);
List& enumerate (const std::string& name, void* pattern,
- int flags, size_t max_level,
+ int flags, size_t max_depth,
mu_folder_enumerate_fp enumfun, void* enumdata);
Url& get_url ();
};
}
diff --git a/include/mailutils/folder.h b/include/mailutils/folder.h
index 4ca4b92..ceb54dd 100644
--- a/include/mailutils/folder.h
+++ b/include/mailutils/folder.h
@@ -24,15 +24,15 @@
extern "C" {
#endif
struct mu_list_response
{
int type; /* MU_FOLDER_ATTRIBUTE_.* flags */
- int level;
- int separator;
- char *name;
+ int depth; /* Item depth within the hierarchy */
+ int separator; /* Directory separator character */
+ char *name; /* Item name */
mu_record_t format; /* Associated mailbox format record */
};
typedef int (*mu_folder_match_fp) (const char *, void *, int);
typedef int (*mu_folder_enumerate_fp) (mu_folder_t, struct mu_list_response *,
void *data);
@@ -63,13 +63,14 @@ extern int mu_folder_is_local (mu_folder_t folder);
*/
struct mu_folder_scanner
{
char const *refname; /* Reference name */
void *pattern; /* Matching pattern */
int match_flags; /* Matching flags */
- size_t max_level; /* Max. nesting level to descend */
+ size_t max_depth; /* Max. depth to descend
+ (1-based, 0 means 'unlimited') */
mu_folder_enumerate_fp enumfun; /* Enumeration function */
void *enumdata; /* Data for enumfun */
mu_list_t records; /* List of allowed records */
mu_list_t result; /* Result list */
};
diff --git a/libmailutils/mailbox/folder.c b/libmailutils/mailbox/folder.c
index 8a474c8..d22bb33 100644
--- a/libmailutils/mailbox/folder.c
+++ b/libmailutils/mailbox/folder.c
@@ -353,24 +353,24 @@ mu_folder_scan (mu_folder_t folder, struct mu_folder_scanner *scn)
mu_list_set_destroy_item (scn->result, mu_list_response_free);
return folder->_list (folder, scn);
}
int
mu_folder_list (mu_folder_t folder, const char *dirname, void *pattern,
- size_t max_level,
+ size_t max_depth,
mu_list_t *pflist)
{
return mu_folder_enumerate (folder, dirname, pattern,
- MU_FOLDER_ATTRIBUTE_ALL, max_level,
+ MU_FOLDER_ATTRIBUTE_ALL, max_depth,
pflist, NULL, NULL);
}
int
mu_folder_enumerate (mu_folder_t folder, const char *name,
void *pattern, int flags,
- size_t max_level,
+ size_t max_depth,
mu_list_t *pflist,
mu_folder_enumerate_fp enumfun, void *enumdata)
{
int status;
if (folder == NULL || (!pflist && !enumfun))
return EINVAL;
@@ -380,13 +380,13 @@ mu_folder_enumerate (mu_folder_t folder, const char *name,
{
struct mu_folder_scanner scn;
scn.refname = name;
scn.pattern = pattern;
scn.match_flags = flags;
- scn.max_level = max_level;
+ scn.max_depth = max_depth;
scn.enumfun = enumfun;
scn.enumdata = enumdata;
scn.records = NULL;
if (pflist)
{
status = mu_list_create (&scn.result);
diff --git a/libmailutils/mailbox/fsfolder.c b/libmailutils/mailbox/fsfolder.c
index 553c9fd..4afdbd6 100644
--- a/libmailutils/mailbox/fsfolder.c
+++ b/libmailutils/mailbox/fsfolder.c
@@ -291,19 +291,19 @@ best_match (mu_list_t records, char const *refname,
}
static int
list_helper (struct mu_folder_scanner *scn,
struct folder_scan_data *data,
struct inode_list *ilist,
- const char *dirname, size_t level)
+ const char *dirname, size_t depth)
{
DIR *dirp;
struct dirent *dp;
int stop = 0;
- if (scn->max_level && level >= scn->max_level)
+ if (scn->max_depth && depth >= scn->max_depth)
return 0;
dirp = opendir (dirname);
if (dirp == NULL)
{
mu_debug (MU_DEBCAT_FOLDER, MU_DEBUG_ERROR,
@@ -374,13 +374,13 @@ list_helper (struct mu_folder_scanner *scn,
if (f == MU_FOLDER_ATTRIBUTE_DIRECTORY)
type = f;
}
else
{
resp->name = fname;
- resp->level = level;
+ resp->depth = depth;
resp->separator = '/';
resp->type = type;
resp->format = rec;
if (scn->enumfun)
{
@@ -418,23 +418,23 @@ list_helper (struct mu_folder_scanner *scn,
struct inode_list idata;
idata.inode = st.st_ino;
idata.dev = st.st_dev;
idata.next = ilist;
stop = list_helper (scn, data, &idata, refname,
- level + 1);
+ depth + 1);
}
}
else if (S_ISDIR (st.st_mode))
{
struct inode_list idata;
idata.inode = st.st_ino;
idata.dev = st.st_dev;
idata.next = ilist;
- stop = list_helper (scn, data, &idata, fname, level + 1);
+ stop = list_helper (scn, data, &idata, fname, depth + 1);
}
}
}
else
{
mu_debug (MU_DEBCAT_FOLDER, MU_DEBUG_ERROR,
@@ -505,13 +505,13 @@ _fsfolder_lsub (mu_folder_t folder, const char *ref, const char *name,
{
free (resp);
rc = ENOMEM;
break;
}
resp->type = MU_FOLDER_ATTRIBUTE_FILE;
- resp->level = 0;
+ resp->depth = 0;
resp->separator = '/';
rc = mu_list_append (flist, resp);
if (rc)
{
free (resp);
break;
diff --git a/libmailutils/tests/fsfolder.c b/libmailutils/tests/fsfolder.c
index 5a4d9df..e6c45b7 100644
--- a/libmailutils/tests/fsfolder.c
+++ b/libmailutils/tests/fsfolder.c
@@ -41,15 +41,15 @@ int prefix_len;
static int
compare_response (void const *a, void const *b)
{
struct mu_list_response const *ra = a;
struct mu_list_response const *rb = b;
- if (ra->level < rb->level)
+ if (ra->depth < rb->depth)
return -1;
- if (ra->level > rb->level)
+ if (ra->depth > rb->depth)
return 1;
return strcmp (ra->name, rb->name);
}
static int
_print_list_entry (void *item, void *data)
@@ -57,13 +57,13 @@ _print_list_entry (void *item, void *data)
struct mu_list_response *resp = item;
int len = data ? *(int*) data : 0;
mu_printf ("%c%c %c %4d %s\n",
(resp->type & MU_FOLDER_ATTRIBUTE_DIRECTORY) ? 'd' : '-',
(resp->type & MU_FOLDER_ATTRIBUTE_FILE) ? 'f' : '-',
resp->separator ? resp->separator : ' ',
- resp->level,
+ resp->depth,
resp->name + len);
return 0;
}
static int
com_list (int argc, char **argv, mu_assoc_t options, void *env)
@@ -170,13 +170,13 @@ com_scan (int argc, char **argv, mu_assoc_t options, void *env)
mu_list_create (&scn.result);
if (mu_assoc_lookup (options, "maxdepth", &s) == 0)
{
char *p;
errno = 0;
- scn.max_level = strtoul (s, &p, 10);
+ scn.max_depth = strtoul (s, &p, 10);
if (errno || *p)
{
mu_error ("-maxdepth=%s: invalid depth", s);
return 0;
}
}
diff --git a/libmu_cpp/folder.cc b/libmu_cpp/folder.cc
index ebc7401..cf6857f 100644
--- a/libmu_cpp/folder.cc
+++ b/libmu_cpp/folder.cc
@@ -79,33 +79,33 @@ Folder :: close ()
if (status)
throw Exception ("Folder::close", status);
}
List&
Folder :: list (const std::string& dirname, void* pattern,
- size_t max_level = 0)
+ size_t max_depth = 0)
{
mu_list_t c_list;
int status = mu_folder_list (folder, dirname.c_str (), pattern,
- max_level, &c_list);
+ max_depth, &c_list);
if (status)
throw Exception ("Folder::list", status);
return *new List (c_list);
}
List&
Folder :: enumerate (const std::string& name, void* pattern,
- int flags, size_t max_level,
+ int flags, size_t max_depth,
mu_folder_enumerate_fp enumfun, void* enumdata)
{
mu_list_t c_list;
int status = mu_folder_enumerate (folder, name.c_str (), pattern,
- flags, max_level, &c_list,
+ flags, max_depth, &c_list,
enumfun, enumdata);
if (status)
throw Exception ("Folder::enumerate", status);
return *new List (c_list);
}
diff --git a/libproto/imap/folder.c b/libproto/imap/folder.c
index 5e43312..9e23847 100644
--- a/libproto/imap/folder.c
+++ b/libproto/imap/folder.c
@@ -269,13 +269,13 @@ _mu_imap_folder_list (mu_folder_t folder, struct mu_folder_scanner *scn)
mu_list_t list;
int rc = mu_imap_list_new (imap, scn->refname, scn->pattern, &list);
if (rc)
return rc;
- if (scn->max_level
+ if (scn->max_depth
|| (scn->match_flags & MU_FOLDER_ATTRIBUTE_ALL) != MU_FOLDER_ATTRIBUTE_ALL)
{
/* Filter out the list, eliminating non-matching entries */
mu_iterator_t itr;
rc = mu_list_get_iterator (list, &itr);
@@ -289,13 +289,13 @@ _mu_imap_folder_list (mu_folder_t folder, struct mu_folder_scanner *scn)
mu_iterator_next (itr))
{
struct mu_list_response *rp;
mu_iterator_current (itr, (void**) &rp);
if (!(rp->type & scn->match_flags)
- || (scn->max_level && rp->level > scn->max_level))
+ || (scn->max_depth && rp->depth > scn->max_depth))
mu_iterator_ctl (itr, mu_itrctl_delete, NULL);
}
mu_iterator_destroy (&itr);
}
if (scn->enumfun)
diff --git a/libproto/imap/genlist.c b/libproto/imap/genlist.c
index 1e2de88..13352b6 100644
--- a/libproto/imap/genlist.c
+++ b/libproto/imap/genlist.c
@@ -34,20 +34,20 @@ struct list_closure
int error_code;
mu_list_t retlist;
const char *command;
};
static int
-count_level (const char *name, int delim)
+count_depth (const char *name, int delim)
{
- int level = 0;
+ int depth = 0;
while (*name)
if (*name++ == delim)
- level++;
- return level;
+ depth++;
+ return depth;
}
static int
list_attr_conv (void *item, void *data)
{
struct imap_list_element *elt = item;
@@ -106,20 +106,20 @@ list_untagged_handler (mu_imap_t imap, mu_list_t resp, void *data)
elt = _mu_imap_list_at (resp, 2);
if (!elt)
return;
if (_mu_imap_list_element_is_nil (elt))
{
rp->separator = 0;
- rp->level = 0;
+ rp->depth = 0;
}
else if (elt->type != imap_eltype_string)
return;
else
{
rp->separator = elt->v.string[0];
- rp->level = count_level (rp->name, rp->separator);
+ rp->depth = count_depth (rp->name, rp->separator);
}
if ((clos->error_code = mu_list_append (clos->retlist, rp)))
mu_list_response_free (rp);
}
}
diff --git a/libproto/imap/tests/imapfolder.c b/libproto/imap/tests/imapfolder.c
index 8d3f6ce..2de8506 100644
--- a/libproto/imap/tests/imapfolder.c
+++ b/libproto/imap/tests/imapfolder.c
@@ -34,13 +34,13 @@ _print_list_entry (void *item, void *data)
{
struct mu_list_response *resp = item;
mu_printf ("%c%c %c %4d %s\n",
(resp->type & MU_FOLDER_ATTRIBUTE_DIRECTORY) ? 'd' : '-',
(resp->type & MU_FOLDER_ATTRIBUTE_FILE) ? 'f' : '-',
resp->separator ? resp->separator : ' ',
- resp->level,
+ resp->depth,
resp->name);
return 0;
}
static void
com_list (mu_folder_t folder, char **argv)
diff --git a/libproto/nntp/folder.c b/libproto/nntp/folder.c
index bdc16f5..8919a03 100644
--- a/libproto/nntp/folder.c
+++ b/libproto/nntp/folder.c
@@ -186,13 +186,13 @@ nntp_folder_destroy (mu_folder_t folder)
}
}
static int
nntp_folder_list (mu_folder_t folder, const char *ref, void *pat, int flags,
- size_t max_level, mu_list_t flist,
+ size_t max_depth, mu_list_t flist,
mu_folder_enumerate_fp efp, void *edp)
{
return ENOTSUP;
}
#else
#include <stdio.h>
diff --git a/mu/libexec/imap.c b/mu/libexec/imap.c
index 3496e5b..8136f4b 100644
--- a/mu/libexec/imap.c
+++ b/mu/libexec/imap.c
@@ -1121,13 +1121,13 @@ print_list_item (void *item, void *data)
mu_stream_printf (out,
"%c%c %c %4d %s\n",
(resp->type & MU_FOLDER_ATTRIBUTE_DIRECTORY) ? 'd' : '-',
(resp->type & MU_FOLDER_ATTRIBUTE_FILE) ? 'f' : '-',
resp->separator ?
resp->separator : MU_HIERARCHY_DELIMITER,
- resp->level,
+ resp->depth,
resp->name);
return 0;
}
static int
com_list (int argc, char **argv)
diff --git a/python/2/libmu_py/folder.c b/python/2/libmu_py/folder.c
index cf1ae69..20b731f 100644
--- a/python/2/libmu_py/folder.c
+++ b/python/2/libmu_py/folder.c
@@ -200,27 +200,27 @@ folderdata_extractor (void *data, PyObject **dst)
}
static PyObject *
api_folder_list (PyObject *self, PyObject *args)
{
int status = 0;
- Py_ssize_t max_level = 0;
+ Py_ssize_t max_depth = 0;
char *dirname, *pattern;
PyFolder *py_folder;
PyObject *py_list;
mu_list_t c_list = NULL;
if (!PyArg_ParseTuple (args, "O!zs|n", &PyFolderType, &py_folder,
- &dirname, &pattern, &max_level))
+ &dirname, &pattern, &max_depth))
return NULL;
- if (max_level < 0)
+ if (max_depth < 0)
{
PyErr_SetString (PyExc_RuntimeError, "max level out of range");
return NULL;
}
- status = mu_folder_list (py_folder->folder, dirname, pattern, max_level,
+ status = mu_folder_list (py_folder->folder, dirname, pattern, max_depth,
&c_list);
if (c_list)
py_list = mu_py_mulist_to_pylist (c_list, folderdata_extractor);
else
py_list = PyTuple_New (0);
diff --git a/python/2/mailutils/folder.py b/python/2/mailutils/folder.py
index ecd3fc9..8e33d65 100644
--- a/python/2/mailutils/folder.py
+++ b/python/2/mailutils/folder.py
@@ -63,11 +63,11 @@ class Folder:
def get_url (self):
status, u = folder.get_url (self.folder)
if status:
raise FolderError (status)
return url.Url (u)
- def list (self, dirname, pattern, max_level=0):
- status, lst = folder.list (self.folder, dirname, pattern, max_level)
+ def list (self, dirname, pattern, max_depth=0):
+ status, lst = folder.list (self.folder, dirname, pattern, max_depth)
if status:
raise FolderError (status)
return lst
diff --git a/python/3/libmu_py/folder.c b/python/3/libmu_py/folder.c
index 8b3dc93..b24bd0b 100644
--- a/python/3/libmu_py/folder.c
+++ b/python/3/libmu_py/folder.c
@@ -159,37 +159,37 @@ folderdata_extractor (void *data, PyObject **dst)
(resp->type & MU_FOLDER_ATTRIBUTE_FILE) ? "f" : "-";
snprintf (separator, sizeof (separator), "%c", resp->separator);
*dst = PyTuple_New (4);
PyTuple_SetItem (*dst, 0, PyUnicode_FromString (attr));
- PyTuple_SetItem (*dst, 1, PyLong_FromLong (resp->level));
+ PyTuple_SetItem (*dst, 1, PyLong_FromLong (resp->depth));
PyTuple_SetItem (*dst, 2, PyUnicode_FromString (separator));
PyTuple_SetItem (*dst, 3, PyUnicode_FromString (resp->name));
return 0;
}
static PyObject *
api_folder_list (PyObject *self, PyObject *args)
{
int status = 0;
- Py_ssize_t max_level = 0;
+ Py_ssize_t max_depth = 0;
char *dirname, *pattern;
PyFolder *py_folder;
PyObject *py_list;
mu_list_t c_list = NULL;
if (!PyArg_ParseTuple (args, "O!zs|n", &PyFolderType, &py_folder,
- &dirname, &pattern, &max_level))
+ &dirname, &pattern, &max_depth))
return NULL;
- if (max_level < 0)
+ if (max_depth < 0)
{
PyErr_SetString (PyExc_RuntimeError, "max level out of range");
return NULL;
}
- status = mu_folder_list (py_folder->folder, dirname, pattern, max_level,
+ status = mu_folder_list (py_folder->folder, dirname, pattern, max_depth,
&c_list);
if (c_list)
py_list = mu_py_mulist_to_pylist (c_list, folderdata_extractor);
else
py_list = PyTuple_New (0);
diff --git a/python/3/mailutils/folder.py b/python/3/mailutils/folder.py
index ecd3fc9..8e33d65 100644
--- a/python/3/mailutils/folder.py
+++ b/python/3/mailutils/folder.py
@@ -63,11 +63,11 @@ class Folder:
def get_url (self):
status, u = folder.get_url (self.folder)
if status:
raise FolderError (status)
return url.Url (u)
- def list (self, dirname, pattern, max_level=0):
- status, lst = folder.list (self.folder, dirname, pattern, max_level)
+ def list (self, dirname, pattern, max_depth=0):
+ status, lst = folder.list (self.folder, dirname, pattern, max_depth)
if status:
raise FolderError (status)
return lst

Return to:

Send suggestions and report system problems to the System administrator.