Skip to content

Commit 6c54bfb

Browse files
committed
pop3: shorten function names
1 parent 6e74b86 commit 6c54bfb

File tree

3 files changed

+31
-43
lines changed

3 files changed

+31
-43
lines changed

mra/pop3/pop3.hpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,9 @@ struct pop3_context final : public schedule_context {
6666
};
6767

6868
using pophnd = int(std::vector<std::string> &&, pop3_context *);
69-
extern pophnd
70-
pop3_cmd_handler_capa,
71-
pop3_cmd_handler_stls,
72-
pop3_cmd_handler_user,
73-
pop3_cmd_handler_pass,
74-
pop3_cmd_handler_stat,
75-
pop3_cmd_handler_uidl,
76-
pop3_cmd_handler_list,
77-
pop3_cmd_handler_retr,
78-
pop3_cmd_handler_rset,
79-
pop3_cmd_handler_noop,
80-
pop3_cmd_handler_dele,
81-
pop3_cmd_handler_top,
82-
pop3_cmd_handler_quit,
83-
pop3_cmd_handler_else;
69+
extern pophnd cmdh_capa, cmdh_stls, cmdh_user, cmdh_pass, cmdh_stat, cmdh_uidl,
70+
cmdh_list, cmdh_retr, cmdh_rset, cmdh_noop, cmdh_dele, cmdh_top,
71+
cmdh_quit, cmdh_else;
8472
extern void pop3_parser_init(int context_num, size_t retrieving_size, gromox::time_duration timeout, int max_auth_times, int block_auth_fail, bool support_tls, bool force_tls, const char *certificate_path, const char *cb_passwd, const char *key_path);
8573
extern int pop3_parser_run();
8674
extern tproc_status pop3_parser_process(schedule_context *);

mra/pop3/pop3_cmd_handler.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ template<typename T> static inline T *sa_get_item(std::vector<T> &arr, size_t id
3838
return idx < arr.size() ? &arr[idx] : nullptr;
3939
}
4040

41-
int pop3_cmd_handler_capa(std::vector<std::string> &&argv, pop3_context *pcontext)
41+
int cmdh_capa(std::vector<std::string> &&argv, pop3_context *pcontext)
4242
{
4343
char buff[256];
4444

@@ -59,7 +59,7 @@ int pop3_cmd_handler_capa(std::vector<std::string> &&argv, pop3_context *pcontex
5959
return DISPATCH_CONTINUE;
6060
}
6161

62-
int pop3_cmd_handler_stls(std::vector<std::string> &&argv, pop3_context *pcontext)
62+
int cmdh_stls(std::vector<std::string> &&argv, pop3_context *pcontext)
6363
{
6464
if (pcontext->connection.ssl != nullptr)
6565
return 1703;
@@ -71,7 +71,7 @@ int pop3_cmd_handler_stls(std::vector<std::string> &&argv, pop3_context *pcontex
7171
return 1724;
7272
}
7373

74-
int pop3_cmd_handler_user(std::vector<std::string> &&argv, pop3_context *pcontext)
74+
int cmdh_user(std::vector<std::string> &&argv, pop3_context *pcontext)
7575
{
7676
size_t string_length = 0;
7777
char buff[1024];
@@ -110,7 +110,7 @@ static bool store_owner_over(const char *actor, const char *mbox, const char *mb
110110
return ok;
111111
}
112112

113-
int pop3_cmd_handler_pass(std::vector<std::string> &&argv, pop3_context *pcontext)
113+
int cmdh_pass(std::vector<std::string> &&argv, pop3_context *pcontext)
114114
{
115115
if (argv.size() < 2)
116116
return 1704;
@@ -191,7 +191,7 @@ int pop3_cmd_handler_pass(std::vector<std::string> &&argv, pop3_context *pcontex
191191
return 1700;
192192
}
193193

194-
int pop3_cmd_handler_stat(std::vector<std::string> &&argv, pop3_context *pcontext)
194+
int cmdh_stat(std::vector<std::string> &&argv, pop3_context *pcontext)
195195
{
196196
size_t string_length = 0;
197197
char temp_buff[1024];
@@ -207,7 +207,7 @@ int pop3_cmd_handler_stat(std::vector<std::string> &&argv, pop3_context *pcontex
207207
return DISPATCH_CONTINUE;
208208
}
209209

210-
int pop3_cmd_handler_uidl(std::vector<std::string> &&argv, pop3_context *pcontext)
210+
int cmdh_uidl(std::vector<std::string> &&argv, pop3_context *pcontext)
211211
{
212212
size_t string_length = 0;
213213
char temp_buff[1024];
@@ -254,7 +254,7 @@ int pop3_cmd_handler_uidl(std::vector<std::string> &&argv, pop3_context *pcontex
254254
return 1707;
255255
}
256256

257-
int pop3_cmd_handler_list(std::vector<std::string> &&argv, pop3_context *pcontext)
257+
int cmdh_list(std::vector<std::string> &&argv, pop3_context *pcontext)
258258
{
259259
size_t string_length = 0;
260260
char temp_buff[1024];
@@ -300,7 +300,7 @@ int pop3_cmd_handler_list(std::vector<std::string> &&argv, pop3_context *pcontex
300300
return 1707;
301301
}
302302

303-
int pop3_cmd_handler_retr(std::vector<std::string> &&argv, pop3_context *pcontext)
303+
int cmdh_retr(std::vector<std::string> &&argv, pop3_context *pcontext)
304304
{
305305
if (argv.size() < 2)
306306
return 1704;
@@ -339,7 +339,7 @@ int pop3_cmd_handler_retr(std::vector<std::string> &&argv, pop3_context *pcontex
339339
return DISPATCH_DATA;
340340
}
341341

342-
int pop3_cmd_handler_dele(std::vector<std::string> &&argv, pop3_context *pcontext)
342+
int cmdh_dele(std::vector<std::string> &&argv, pop3_context *pcontext)
343343
{
344344
if (argv.size() < 2)
345345
return 1704;
@@ -360,7 +360,7 @@ int pop3_cmd_handler_dele(std::vector<std::string> &&argv, pop3_context *pcontex
360360
return 1700;
361361
}
362362

363-
int pop3_cmd_handler_top(std::vector<std::string> &&argv, pop3_context *pcontext)
363+
int cmdh_top(std::vector<std::string> &&argv, pop3_context *pcontext)
364364
{
365365
if (argv.size() < 2)
366366
return 1704;
@@ -392,7 +392,7 @@ int pop3_cmd_handler_top(std::vector<std::string> &&argv, pop3_context *pcontext
392392
return DISPATCH_DATA;
393393
}
394394

395-
int pop3_cmd_handler_quit(std::vector<std::string> &&argv, pop3_context *pcontext)
395+
int cmdh_quit(std::vector<std::string> &&argv, pop3_context *pcontext)
396396
{
397397
size_t string_length = 0;
398398
char temp_buff[1024];
@@ -441,7 +441,7 @@ int pop3_cmd_handler_quit(std::vector<std::string> &&argv, pop3_context *pcontex
441441

442442
}
443443

444-
int pop3_cmd_handler_rset(std::vector<std::string> &&argv, pop3_context *pcontext)
444+
int cmdh_rset(std::vector<std::string> &&argv, pop3_context *pcontext)
445445
{
446446
if (argv.size() != 1)
447447
return 1704;
@@ -451,14 +451,14 @@ int pop3_cmd_handler_rset(std::vector<std::string> &&argv, pop3_context *pcontex
451451
return 1700;
452452
}
453453

454-
int pop3_cmd_handler_noop(std::vector<std::string> &&argv, pop3_context *pcontext)
454+
int cmdh_noop(std::vector<std::string> &&argv, pop3_context *pcontext)
455455
{
456456
if (argv.size() != 1)
457457
return 1704;
458458
return 1700;
459459
}
460460

461-
int pop3_cmd_handler_else(std::vector<std::string> &&argv, pop3_context *pcontext)
461+
int cmdh_else(std::vector<std::string> &&argv, pop3_context *pcontext)
462462
{
463463
/* command not implement*/
464464
return 1703;

mra/pop3/pop3_parser.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -560,19 +560,19 @@ static int pop3_parser_dispatch_cmd2(const char *cmd_line, int line_length,
560560
pop3_context *ctx) try
561561
{
562562
static constexpr std::pair<const char *, pophnd *> proc[] = {
563-
{"CAPA", pop3_cmd_handler_capa},
564-
{"DELE", pop3_cmd_handler_dele},
565-
{"LIST", pop3_cmd_handler_list},
566-
{"NOOP", pop3_cmd_handler_noop},
567-
{"PASS", pop3_cmd_handler_pass},
568-
{"QUIT", pop3_cmd_handler_quit},
569-
{"RETR", pop3_cmd_handler_retr},
570-
{"RSET", pop3_cmd_handler_rset},
571-
{"STAT", pop3_cmd_handler_stat},
572-
{"STLS", pop3_cmd_handler_stls},
573-
{"TOP", pop3_cmd_handler_top},
574-
{"UIDL", pop3_cmd_handler_uidl},
575-
{"USER", pop3_cmd_handler_user},
563+
{"CAPA", cmdh_capa},
564+
{"DELE", cmdh_dele},
565+
{"LIST", cmdh_list},
566+
{"NOOP", cmdh_noop},
567+
{"PASS", cmdh_pass},
568+
{"QUIT", cmdh_quit},
569+
{"RETR", cmdh_retr},
570+
{"RSET", cmdh_rset},
571+
{"STAT", cmdh_stat},
572+
{"STLS", cmdh_stls},
573+
{"TOP", cmdh_top},
574+
{"UIDL", cmdh_uidl},
575+
{"USER", cmdh_user},
576576
};
577577
auto argv = gx_split(std::string_view(cmd_line, line_length), ' ');
578578
if (argv.size() < 1)
@@ -581,7 +581,7 @@ static int pop3_parser_dispatch_cmd2(const char *cmd_line, int line_length,
581581
auto it = std::lower_bound(std::begin(proc), std::end(proc), argv[0].c_str(), scmp);
582582
if (it != std::end(proc) && strcasecmp(argv[0].c_str(), it->first) == 0)
583583
return it->second(std::move(argv), ctx);
584-
return pop3_cmd_handler_else(std::move(argv), ctx);
584+
return cmdh_else(std::move(argv), ctx);
585585
} catch (const std::bad_alloc &) {
586586
mlog(LV_ERR, "E-1248: ENOMEM");
587587
return 1730;

0 commit comments

Comments
 (0)