Skip to content

Commit bb0218e

Browse files
committed
tools: replace old EXT_ERR_ mnemonic codes
1 parent 25163c3 commit bb0218e

File tree

16 files changed

+95
-95
lines changed

16 files changed

+95
-95
lines changed

php_mapi/ext_pack.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <gromox/util.hpp>
1515
#include <gromox/zcore_types.hpp>
1616
#include "ext.hpp"
17-
#define TRY(expr) do { pack_result klfdv{expr}; if (klfdv != EXT_ERR_SUCCESS) return klfdv; } while (false)
17+
#define TRY(expr) do { pack_result klfdv{expr}; if (klfdv != pack_result::ok) return klfdv; } while (false)
1818
#define GROWING_BLOCK_SIZE 0x1000
1919

2020
static thread_local std::vector<void *> g_allocs;
@@ -88,12 +88,12 @@ pack_result PULL_CTX::g_perm_set(PERMISSION_SET *r)
8888
r->prows = sta_malloc<PERMISSION_ROW>(r->count);
8989
if (NULL == r->prows) {
9090
r->count = 0;
91-
return EXT_ERR_ALLOC;
91+
return pack_result::alloc;
9292
}
9393
for (i=0; i<r->count; i++) {
9494
TRY(ext_pack_pull_permission_row(this, &r->prows[i]));
9595
}
96-
return EXT_ERR_SUCCESS;
96+
return pack_result::ok;
9797
}
9898

9999
static pack_result ext_pack_pull_message_state(PULL_CTX *pctx, MESSAGE_STATE *r)
@@ -107,17 +107,17 @@ pack_result PULL_CTX::g_state_a(STATE_ARRAY *r)
107107
TRY(g_uint32(&r->count));
108108
if (0 == r->count) {
109109
r->pstate = NULL;
110-
return EXT_ERR_SUCCESS;
110+
return pack_result::ok;
111111
}
112112
r->count = std::min(r->count, static_cast<uint32_t>(UINT32_MAX));
113113
r->pstate = sta_malloc<MESSAGE_STATE>(r->count);
114114
if (NULL == r->pstate) {
115115
r->count = 0;
116-
return EXT_ERR_ALLOC;
116+
return pack_result::alloc;
117117
}
118118
for (size_t i = 0; i < r->count; ++i)
119119
TRY(ext_pack_pull_message_state(this, &r->pstate[i]));
120-
return EXT_ERR_SUCCESS;
120+
return pack_result::ok;
121121
}
122122

123123
static pack_result ext_pack_pull_newmail_znotification(PULL_CTX *pctx,
@@ -202,7 +202,7 @@ static pack_result ext_pack_pull_znotification(PULL_CTX *pctx, ZNOTIFICATION *r)
202202
}
203203
default:
204204
r->pnotification_data = NULL;
205-
return EXT_ERR_SUCCESS;
205+
return pack_result::ok;
206206
}
207207
} catch (const std::bad_alloc &) {
208208
return pack_result::alloc;
@@ -238,7 +238,7 @@ pack_result PUSH_CTX::p_perm_set(const PERMISSION_SET *r)
238238
for (i=0; i<r->count; i++) {
239239
TRY(ext_pack_push_permission_row(this, &r->prows[i]));
240240
}
241-
return EXT_ERR_SUCCESS;
241+
return pack_result::ok;
242242
}
243243

244244
pack_result PUSH_CTX::p_rule_data(const RULE_DATA *r)
@@ -252,7 +252,7 @@ pack_result PUSH_CTX::p_rule_list(const RULE_LIST *r)
252252
TRY(p_uint16(r->count));
253253
for (const auto &rule : *r)
254254
TRY(p_rule_data(&rule));
255-
return EXT_ERR_SUCCESS;
255+
return pack_result::ok;
256256
}
257257

258258
static pack_result ext_pack_push_message_state(PUSH_CTX *pctx, const MESSAGE_STATE *r)
@@ -266,5 +266,5 @@ pack_result PUSH_CTX::p_state_a(const STATE_ARRAY *r)
266266
TRY(p_uint32(r->count));
267267
for (size_t i = 0; i < r->count; ++i)
268268
TRY(ext_pack_push_message_state(this, &r->pstate[i]));
269-
return EXT_ERR_SUCCESS;
269+
return pack_result::ok;
270270
}

php_mapi/mapi.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static ZEND_FUNCTION(mapi_createoneoff)
631631
tmp_entry.paddress_type = ptype;
632632
tmp_entry.pmail_address = paddress;
633633
if (!push_ctx.init() ||
634-
push_ctx.p_oneoff_eid(tmp_entry) != EXT_ERR_SUCCESS)
634+
push_ctx.p_oneoff_eid(tmp_entry) != pack_result::ok)
635635
pthrow(ecError);
636636
RETVAL_STRINGL(reinterpret_cast<const char *>(push_ctx.m_vdata), push_ctx.m_offset);
637637
MAPI_G(hr) = ecSuccess;
@@ -649,7 +649,7 @@ static ZEND_FUNCTION(mapi_parseoneoff)
649649
pthrow(ecInvalidParam);
650650
pull_ctx.init(pentryid, cbentryid, ext_pack_alloc,
651651
EXT_FLAG_UTF16 | EXT_FLAG_WCOUNT);
652-
if (pull_ctx.g_oneoff_eid(&oneoff_entry) != EXT_ERR_SUCCESS)
652+
if (pull_ctx.g_oneoff_eid(&oneoff_entry) != pack_result::ok)
653653
pthrow(ecError);
654654
zarray_init(return_value);
655655
add_assoc_string(return_value, "name", oneoff_entry.pdisplay_name);
@@ -2471,7 +2471,7 @@ static ZEND_FUNCTION(mapi_openproperty)
24712471
NULL == pzresource || NULL == guidstr)
24722472
pthrow(ecInvalidParam);
24732473
pull_ctx.init(guidstr, sizeof(GUID));
2474-
if (pull_ctx.g_guid(&iid_guid) != EXT_ERR_SUCCESS)
2474+
if (pull_ctx.g_guid(&iid_guid) != pack_result::ok)
24752475
pthrow(ecInvalidParam);
24762476
}
24772477
auto type = Z_RES_TYPE_P(pzresource);
@@ -3966,7 +3966,7 @@ static ZEND_FUNCTION(kc_session_save)
39663966
return;
39673967
}
39683968
if (!push_ctx.init() ||
3969-
push_ctx.p_guid(psession->hsession) != EXT_ERR_SUCCESS) {
3969+
push_ctx.p_guid(psession->hsession) != pack_result::ok) {
39703970
RETVAL_LONG(ecMAPIOOM);
39713971
return;
39723972
}
@@ -3991,7 +3991,7 @@ static ZEND_FUNCTION(kc_session_restore)
39913991
data_bin.pb = reinterpret_cast<uint8_t *>(Z_STRVAL_P(pzdata));
39923992
data_bin.cb = Z_STRLEN_P(pzdata);
39933993
pull_ctx.init(data_bin.pb, data_bin.cb);
3994-
if (pull_ctx.g_guid(&hsession) != EXT_ERR_SUCCESS) {
3994+
if (pull_ctx.g_guid(&hsession) != pack_result::ok) {
39953995
RETVAL_LONG(ecInvalidParam);
39963996
return;
39973997
}

php_mapi/rpc_ext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <gromox/defs.h>
44
#include <gromox/zcore_rpc.hpp>
55
#include "ext.hpp"
6-
#define TRY(expr) do { pack_result klfdv{expr}; if (klfdv != EXT_ERR_SUCCESS) return klfdv; } while (false)
6+
#define TRY(expr) do { pack_result klfdv{expr}; if (klfdv != pack_result::ok) return klfdv; } while (false)
77

88
static pack_result zrpc_push(PUSH_CTX &x, const zcreq_logon_token &d)
99
{

tests/bdump.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ int main(int argc, char **argv)
4545
}
4646
if (g_decode == D_RESTRICT) {
4747
RESTRICTION rs{};
48-
if (ep.g_restriction(&rs) != EXT_ERR_SUCCESS)
48+
if (ep.g_restriction(&rs) != pack_result::ok)
4949
return EXIT_FAILURE;
5050
printf("%s\n", rs.repr().c_str());
5151
} else if (g_decode == D_ACTIONS) {
5252
RULE_ACTIONS ra{};
53-
if (ep.g_rule_actions(&ra) != EXT_ERR_SUCCESS)
53+
if (ep.g_rule_actions(&ra) != pack_result::ok)
5454
return EXIT_FAILURE;
5555
printf("%s\n", ra.repr().c_str());
5656
}

tests/utiltest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ static int t_extpp()
4545
ep.init(s.data(), s.size(), zalloc, 0);
4646
GLOBALOBJECTID goid;
4747
auto ret = ep.g_goid(&goid);
48-
assert(ret == EXT_ERR_SUCCESS && goid.unparsed);
48+
assert(ret == pack_result::ok && goid.unparsed);
4949
#define s_date "0000000066b5d6b711d901010000000000000000"
5050
s = encid + hex2bin(s_date "01000000ffff");
5151
ep.init(s.data(), s.size(), zalloc, 0);
52-
assert(ep.g_goid(&goid) == EXT_ERR_SUCCESS);
52+
assert(ep.g_goid(&goid) == pack_result::ok);
5353
assert((!goid.unparsed && goid.data.cb == 1) ||
5454
(goid.unparsed && goid.data.cb == 6));
5555
s = encid + hex2bin(s_date "02000000ff");
5656
ep.init(s.data(), s.size(), zalloc, 0);
57-
assert(ep.g_goid(&goid) == EXT_ERR_SUCCESS);
57+
assert(ep.g_goid(&goid) == pack_result::ok);
5858
assert(goid.unparsed && goid.data.cb == 5);
5959
#undef s_date
6060
return EXIT_SUCCESS;
@@ -317,7 +317,7 @@ static int t_cmp_guid()
317317
static_assert(std::is_same_v<decltype(PSETID_Address), const GUID>);
318318

319319
ep.init(buf, sizeof(buf), 0);
320-
if (ep.p_guid(muidEMSAB) != EXT_ERR_SUCCESS)
320+
if (ep.p_guid(muidEMSAB) != pack_result::ok)
321321
return EXIT_FAILURE;
322322
assert(memcmp(ep.m_udata, "\xDC\xA7\x40\xC8", 4) == 0);
323323
static_assert(std::is_same_v<decltype(muidEMSAB), const FLATUID>);

tools/edb2mt.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,11 @@ static errno_t do_file(const char *filename) try
624624
fprintf(stderr, "E-2020: ENOMEM\n");
625625
return EXIT_FAILURE;
626626
}
627-
if (ep.p_uint32(static_cast<uint32_t>(MAPI_MESSAGE)) != EXT_ERR_SUCCESS ||
628-
ep.p_uint32(1) != EXT_ERR_SUCCESS ||
629-
ep.p_uint32(static_cast<uint32_t>(parent.type)) != EXT_ERR_SUCCESS ||
630-
ep.p_uint64(parent.folder_id) != EXT_ERR_SUCCESS ||
631-
ep.p_msgctnt(*ctnt) != EXT_ERR_SUCCESS) {
627+
if (ep.p_uint32(static_cast<uint32_t>(MAPI_MESSAGE)) != pack_result::ok ||
628+
ep.p_uint32(1) != pack_result::ok ||
629+
ep.p_uint32(static_cast<uint32_t>(parent.type)) != pack_result::ok ||
630+
ep.p_uint64(parent.folder_id) != pack_result::ok ||
631+
ep.p_msgctnt(*ctnt) != pack_result::ok) {
632632
fprintf(stderr, "E-2021\n");
633633
return EXIT_FAILURE;
634634
}

tools/edb_pack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <climits>
66
#include <gromox/ext_buffer.hpp>
77
#include "edb_pack.hpp"
8-
#define TRY(expr) do { pack_result klfdv{expr}; if (klfdv != EXT_ERR_SUCCESS) return klfdv; } while (false)
8+
#define TRY(expr) do { pack_result klfdv{expr}; if (klfdv != pack_result::ok) return klfdv; } while (false)
99

1010
enum { /* property types (in the metadata) */
1111
EPT_BOOL = 0x08, // mv 0x88

tools/eml2mt.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,11 @@ int main(int argc, char **argv) try
406406
fprintf(stderr, "E-2013: ENOMEM\n");
407407
return EXIT_FAILURE;
408408
}
409-
if (ep.p_uint32(static_cast<uint32_t>(MAPI_MESSAGE)) != EXT_ERR_SUCCESS ||
410-
ep.p_uint32(i + 1) != EXT_ERR_SUCCESS ||
411-
ep.p_uint32(static_cast<uint32_t>(parent.type)) != EXT_ERR_SUCCESS ||
412-
ep.p_uint64(parent.folder_id) != EXT_ERR_SUCCESS ||
413-
ep.p_msgctnt(*msgs[i]) != EXT_ERR_SUCCESS) {
409+
if (ep.p_uint32(static_cast<uint32_t>(MAPI_MESSAGE)) != pack_result::ok ||
410+
ep.p_uint32(i + 1) != pack_result::ok ||
411+
ep.p_uint32(static_cast<uint32_t>(parent.type)) != pack_result::ok ||
412+
ep.p_uint64(parent.folder_id) != pack_result::ok ||
413+
ep.p_msgctnt(*msgs[i]) != pack_result::ok) {
414414
fprintf(stderr, "E-2004\n");
415415
return EXIT_FAILURE;
416416
}

tools/exm2eml.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ int main(int argc, char **argv) try
245245
EXT_PUSH ep;
246246
if (!ep.init(nullptr, 0, EXT_FLAG_WCOUNT))
247247
throw YError("ENOMEM");
248-
if (ep.p_uint32(static_cast<uint32_t>(MAPI_MESSAGE)) != EXT_ERR_SUCCESS ||
249-
ep.p_uint32(msg_id) != EXT_ERR_SUCCESS ||
250-
ep.p_uint32(static_cast<uint32_t>(0)) != EXT_ERR_SUCCESS ||
251-
ep.p_uint64(MAILBOX_FID_UNANCHORED) != EXT_ERR_SUCCESS ||
252-
ep.p_msgctnt(*ctnt) != EXT_ERR_SUCCESS) {
248+
if (ep.p_uint32(static_cast<uint32_t>(MAPI_MESSAGE)) != pack_result::ok ||
249+
ep.p_uint32(msg_id) != pack_result::ok ||
250+
ep.p_uint32(static_cast<uint32_t>(0)) != pack_result::ok ||
251+
ep.p_uint64(MAILBOX_FID_UNANCHORED) != pack_result::ok ||
252+
ep.p_msgctnt(*ctnt) != pack_result::ok) {
253253
fprintf(stderr, "E-2005\n");
254254
return EXIT_FAILURE;
255255
}

tools/genimport.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ void gi_folder_map_read(const void *buf, size_t bufsize, gi_folder_map_t &map)
104104
EXT_PULL ep;
105105
ep.init(buf, bufsize, zalloc, EXT_FLAG_WCOUNT);
106106
uint64_t max = 0;
107-
if (ep.g_uint64(&max) != EXT_ERR_SUCCESS)
107+
if (ep.g_uint64(&max) != pack_result::ok)
108108
throw YError("PG-1100");
109109
for (size_t n = 0; n < max; ++n) {
110110
uint32_t nid;
111111
uint8_t create;
112112
uint64_t fidto;
113113
std::unique_ptr<char[], gi_delete> name;
114-
if (ep.g_uint32(&nid) != EXT_ERR_SUCCESS ||
115-
ep.g_uint8(&create) != EXT_ERR_SUCCESS ||
116-
ep.g_uint64(&fidto) != EXT_ERR_SUCCESS ||
117-
ep.g_str(&unique_tie(name)) != EXT_ERR_SUCCESS)
114+
if (ep.g_uint32(&nid) != pack_result::ok ||
115+
ep.g_uint8(&create) != pack_result::ok ||
116+
ep.g_uint64(&fidto) != pack_result::ok ||
117+
ep.g_str(&unique_tie(name)) != pack_result::ok)
118118
throw YError("PG-1101");
119119
map.insert_or_assign(nid, tgt_folder{static_cast<bool>(create), fidto, name != nullptr ? name.get() : ""});
120120
}
@@ -125,13 +125,13 @@ void gi_folder_map_write(const gi_folder_map_t &map)
125125
EXT_PUSH ep;
126126
if (!ep.init(nullptr, 0, EXT_FLAG_WCOUNT))
127127
throw std::bad_alloc();
128-
if (ep.p_uint64(map.size()) != EXT_ERR_SUCCESS)
128+
if (ep.p_uint64(map.size()) != pack_result::ok)
129129
throw YError("PG-1102");
130130
for (const auto &[nid, tgt] : map)
131-
if (ep.p_uint32(nid) != EXT_ERR_SUCCESS ||
132-
ep.p_uint8(!!tgt.create) != EXT_ERR_SUCCESS ||
133-
ep.p_uint64(tgt.fid_to) != EXT_ERR_SUCCESS ||
134-
ep.p_str(tgt.create_name.c_str()) != EXT_ERR_SUCCESS)
131+
if (ep.p_uint32(nid) != pack_result::ok ||
132+
ep.p_uint8(!!tgt.create) != pack_result::ok ||
133+
ep.p_uint64(tgt.fid_to) != pack_result::ok ||
134+
ep.p_str(tgt.create_name.c_str()) != pack_result::ok)
135135
throw YError("PG-1103");
136136
uint64_t xsize = cpu_to_le64(ep.m_offset);
137137
if (HXio_fullwrite(STDOUT_FILENO, &xsize, sizeof(xsize)) < 0)
@@ -145,13 +145,13 @@ void gi_name_map_read(const void *buf, size_t bufsize, gi_name_map &map)
145145
EXT_PULL ep;
146146
ep.init(buf, bufsize, zalloc, EXT_FLAG_WCOUNT);
147147
uint64_t max = 0;
148-
if (ep.g_uint64(&max) != EXT_ERR_SUCCESS)
148+
if (ep.g_uint64(&max) != pack_result::ok)
149149
throw YError("PG-1108");
150150
for (size_t n = 0; n < max; ++n) {
151151
proptag_t proptag;
152152
PROPERTY_NAME propname{};
153-
if (ep.g_uint32(&proptag) != EXT_ERR_SUCCESS ||
154-
ep.g_propname(&propname) != EXT_ERR_SUCCESS)
153+
if (ep.g_uint32(&proptag) != pack_result::ok ||
154+
ep.g_propname(&propname) != pack_result::ok)
155155
throw YError("PG-1109");
156156
try {
157157
map.insert_or_assign(proptag, propname);
@@ -168,13 +168,13 @@ void gi_name_map_write(const gi_name_map &map)
168168
EXT_PUSH ep;
169169
if (!ep.init(nullptr, 0, EXT_FLAG_WCOUNT))
170170
throw std::bad_alloc();
171-
if (ep.p_uint64(map.size()) != EXT_ERR_SUCCESS)
171+
if (ep.p_uint64(map.size()) != pack_result::ok)
172172
throw YError("PG-1110");
173173
for (const auto &[proptag, xn] : map) {
174174
static_assert(sizeof(gi_name_map::key_type) == sizeof(uint32_t),
175175
"Something is fishy with the definition of gi_name_map");
176176
if (ep.p_uint32(proptag) != pack_result::ok ||
177-
ep.p_propname(static_cast<PROPERTY_NAME>(xn)) != EXT_ERR_SUCCESS)
177+
ep.p_propname(static_cast<PROPERTY_NAME>(xn)) != pack_result::ok)
178178
throw YError("PG-1111");
179179
}
180180
uint64_t xsize = cpu_to_le64(ep.m_offset);
@@ -208,7 +208,7 @@ int exm_set_change_keys(TPROPVAL_ARRAY *props, eid_t change_num)
208208
BINARY bxid;
209209
EXT_PUSH ep;
210210
if (!ep.init(tmp_buff, std::size(tmp_buff), 0) ||
211-
ep.p_xid(zxid) != EXT_ERR_SUCCESS) {
211+
ep.p_xid(zxid) != pack_result::ok) {
212212
fprintf(stderr, "exm: ext_push: ENOMEM\n");
213213
return -ENOMEM;
214214
}
@@ -381,7 +381,7 @@ int exm_create_msg(uint64_t parent_fld, MESSAGE_CONTENT *ctnt)
381381
BINARY bxid;
382382
EXT_PUSH ep;
383383
if (!ep.init(tmp_buff, std::size(tmp_buff), 0) ||
384-
ep.p_xid(zxid) != EXT_ERR_SUCCESS) {
384+
ep.p_xid(zxid) != pack_result::ok) {
385385
fprintf(stderr, "exm: ext_push: ENOMEM\n");
386386
return -ENOMEM;
387387
}

0 commit comments

Comments
 (0)