Skip to content

Commit

Permalink
use same values as smtpd for K_*
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-polo committed Apr 30, 2024
1 parent 4bc963b commit 87da70f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 33 deletions.
34 changes: 11 additions & 23 deletions table_stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,6 @@ static char tablename[128];
/* Dummy; just kept for backward compatibility */
static struct dict params;

static const char *
service_name(int service)
{
switch (service) {
case K_ALIAS: return ("alias");
case K_DOMAIN: return ("domain");
case K_CREDENTIALS: return ("credentials");
case K_NETADDR: return ("netaddr");
case K_USERINFO: return ("userinfo");
case K_SOURCE: return ("source");
case K_MAILADDR: return ("mailaddr");
case K_ADDRNAME: return ("addrname");
case K_MAILADDRMAP: return ("mailaddrmap");
}

err(1, "unknown service %d", service);
}

static int
service_id(const char *service)
{
Expand Down Expand Up @@ -141,11 +123,17 @@ table_api_dispatch(void)
* we don't have a clue what the table
* will do.
*/
for (i = 0; i <= K_MAILADDRMAP; ++i) {
printf("register|%s\n",
service_name(i));
}
printf("register|ready\n");
puts("register|alias");
puts("register|domain");
puts("register|credentials");
puts("register|netaddr");
puts("register|userinfo");
puts("register|source");;
puts("register|mailaddr");
puts("register|addrname");
puts("register|mailaddrmap");

puts("register|ready");
if (fflush(stdout) == EOF)
err(1, "fflush");
continue;
Expand Down
20 changes: 10 additions & 10 deletions table_stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
*/

enum table_service {
K_ALIAS, /* returns struct expand */
K_DOMAIN, /* returns struct destination */
K_CREDENTIALS, /* returns struct credentials */
K_NETADDR, /* returns struct netaddr */
K_USERINFO, /* returns struct userinfo */
K_SOURCE, /* returns struct source */
K_MAILADDR, /* returns struct mailaddr */
K_ADDRNAME, /* returns struct addrname */
K_MAILADDRMAP, /* returns struct mailaddr */
K_ANY,
K_ALIAS = 0x001, /* returns struct expand */
K_DOMAIN = 0x002, /* returns struct destination */
K_CREDENTIALS = 0x004, /* returns struct credentials */
K_NETADDR = 0x008, /* returns struct netaddr */
K_USERINFO = 0x010, /* returns struct userinfo */
K_SOURCE = 0x020, /* returns struct source */
K_MAILADDR = 0x040, /* returns struct mailaddr */
K_ADDRNAME = 0x080, /* returns struct addrname */
K_MAILADDRMAP = 0x100, /* returns struct mailaddr */
K_ANY = 0xfff,
};

void table_api_on_update(int(*)(void));
Expand Down

0 comments on commit 87da70f

Please sign in to comment.