Skip to content

Commit 80119bc

Browse files
committed
mt2exm: support folder lookup by EID
The mbop utility supported folder specification by number, mt2exm did not. But then, the mt2exm manpage was edited to simply refer to the mbop manpage, causing documented behavior to no longer match with actual program behavior. Move the number parse logic into lookup_eid_by_name and call it a day. References: DESK-3426
1 parent cd10848 commit 80119bc

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

doc/gromox-mbop.8

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -371,22 +371,33 @@ Issue the SQLite ".vacuum" command on the user's exchange.sqlite3 file in an
371371
attempt to reclaim unused disk space and shrink it. This operation can
372372
potentially run for quite some time, during which the mailbox is inaccessible.
373373
.SH Folder specification
374-
\fIfolder_spec\fP can either be a numeric identifier, or a path-like
375-
specification into the folder hierarchy. If the name starts with the slash
376-
character '/', it is interpreted as starting from the root; otherwise, the
377-
first component must be a special fixed name (untranslated) (CALENDAR,
378-
COMMON_VIEWS, CONFLICTS, CONTACTS, DEFERRED_ACTION, DELETED (TRASH,
379-
WASTEBASKET), DRAFT, FINDER, INBOX, IPM_SUBTREE, JOURNAL, JUNK, LOCAL_FAILURES,
380-
NOTES, OUTBOX, SENT, SERVER_FAILURES, SHORTCUTS, SYNC_ISSUES, TASKS, VIEWS).
381-
These special names can be used with private stores only; there are no names
382-
defined for public folder contents at this time. There is also no parsing
383-
support for slashes in folder names currently in mbop; the slash character is
384-
always treated as a hierarchy separator. Examples:
385-
.IP \(bu 4
386-
/Top of Information Store/Sent Items/2022
387-
.IP \(bu 4
388-
IPM_SUBTREE/Sent Items/2022
389-
.IP \(bu 4
390-
SENT/2022
374+
\fIfolder_spec\fP must conform to one of three forms. Either:
375+
.IP \(bu 4
376+
a numeric identifer (e.g. 13, 0xd)
377+
.IP \(bu 4
378+
a folder path starting with a slash, optionally followed by a slash-separated
379+
sequence of subordinate folder names
380+
.IP \(bu 4
381+
a folder path starting with a fixed symbolic name, optionally followed by a
382+
slash-separated sequence of subordinate folder names
383+
.PP
384+
The recognized strings are: CALENDAR, COMMON_VIEWS, CONFLICTS, CONTACTS,
385+
DEFERRED_ACTION, DELETED (TRASH, WASTEBASKET), DRAFT, FINDER, INBOX,
386+
IPM_SUBTREE, JOURNAL, JUNK, LOCAL_FAILURES, NOTES, OUTBOX, SENT,
387+
SERVER_FAILURES, SHORTCUTS, SYNC_ISSUES, TASKS, VIEWS.
388+
.PP
389+
The purpose of these names is for referencing a built-in folder irrespective of
390+
its assigned name, which is dependent upon translation settings. The symbolic
391+
names can be used with private stores only; there are no names defined for
392+
public folder contents at this time. There is also no parsing support for
393+
slashes in folder names. The slash character is always treated as a hierarchy
394+
separator.
395+
.SS Examples
396+
.IP \(bu 4
397+
Using the MAPI root: /Top of Information Store/Sent Items/2022
398+
.IP \(bu 4
399+
Using a symbolic name: IPM_SUBTREE/Sent Items/2022
400+
.IP \(bu 4
401+
Using a symbolic name: SENT/2022
391402
.SH See also
392403
\fBgromox\fP(7)

tools/genimport.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,11 @@ static constexpr std::pair<const char *, uint8_t> fld_special_names[] = {
600600

601601
eid_t gi_lookup_eid_by_name(const char *dir, const char *name)
602602
{
603+
char *end = nullptr;
604+
auto pure_id = strtoull(name, &end, 0);
605+
if (end != name && *znul(end) == '\0')
606+
return rop_util_make_eid_ex(1, pure_id);
607+
603608
auto pathcomp = gx_split(name, '/');
604609
if (pathcomp.size() == 0)
605610
return 0;

tools/mbop_delmsg.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ int main(int argc, char **argv)
5252
return help();
5353
std::vector<uint64_t> eids;
5454
while (*++argv != nullptr) {
55-
uint64_t id = strtoull(*argv, nullptr, 0);
56-
eid_t eid = id == 0 ? gi_lookup_eid_by_name(g_storedir, *argv) :
57-
rop_util_make_eid_ex(1, id);
55+
eid_t eid = gi_lookup_eid_by_name(g_storedir, *argv);
5856
if (eid == 0) {
5957
fprintf(stderr, "Not recognized/found: \"%s\"\n", *argv);
6058
return EXIT_FAILURE;

tools/mbop_emptyfld.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ int main(int argc, char **argv)
204204
while (*++argv != nullptr) {
205205
BOOL partial = false;
206206
uint64_t id = strtoull(*argv, nullptr, 0);
207-
eid_t eid = id == 0 ? gi_lookup_eid_by_name(g_storedir, *argv) :
208-
rop_util_make_eid_ex(1, id);
207+
eid_t eid = gi_lookup_eid_by_name(g_storedir, *argv);
209208
if (eid == 0) {
210209
fprintf(stderr, "Not recognized/found: \"%s\"\n", *argv);
211210
return EXIT_FAILURE;

tools/mbop_purge.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ int main(int argc, char **argv)
3535
fprintf(stderr, "mbop/purge: No folders specified, no action taken.\n");
3636
auto age = rop_util_unix_to_nttime(time(nullptr) - HX_strtoull_sec(znul(g_age_str), nullptr));
3737
while (*++argv != nullptr) {
38-
uint64_t id = strtoull(*argv, nullptr, 0);
39-
eid_t eid = id == 0 ? gi_lookup_eid_by_name(g_storedir, *argv) :
40-
rop_util_make_eid_ex(1, id);
38+
eid_t eid = gi_lookup_eid_by_name(g_storedir, *argv);
4139
if (eid == 0) {
4240
fprintf(stderr, "Not recognized/found: \"%s\"\n", *argv);
4341
return EXIT_FAILURE;

0 commit comments

Comments
 (0)