userdb-blocking.c revision 1aad8ad0590bee2d09d5fdb5413af72e2a8e156a
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/* Copyright (c) 2005-2010 Dovecot authors, see the included COPYING file */
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenstatic bool user_callback(const char *reply, void *context)
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen } else if (strncmp(reply, "NOTFOUND\t", 9) == 0) {
0f39a57760d93cddbce3ca43096d78e0fe2f42fdTimo Sirainen i_error("BUG: auth-worker sent invalid user reply");
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen request->userdb_reply = auth_stream_reply_init(request->pool);
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen auth_stream_reply_import(request->userdb_reply, args);
88e9835c4d8973c62cd4db1ec7324ff46dd3ff15Timo Sirainen if (auth_stream_reply_find(request->userdb_reply,
6fabfb7bbfd88d0c1de66981e52850f26067623bTimo Sirainen auth_request_userdb_callback(result, request);
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenvoid userdb_blocking_lookup(struct auth_request *request)
226259ee6fb9830dafc1a5ba1e95bf5a4345b406Timo Sirainen reply = auth_stream_reply_init(pool_datastack_create());
3cf67672fdc87583cb23ce088c95bb5dee60e74dTimo Sirainen auth_stream_reply_add(reply, NULL, dec2str(request->userdb->userdb->id));
1d22eaac93de41319918a1fc6de42bb302e25c1aTimo Sirainen auth_worker_call(request->pool, reply, user_callback, request);
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenstatic bool iter_callback(const char *reply, void *context)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen struct blocking_userdb_iterate_context *ctx = context;
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen ctx->ctx.callback(reply + 2, ctx->ctx.context);
849969f639a00eab26791db3cb1b66430420c0cdTimo Sirainenuserdb_blocking_iter_init(struct userdb_module *userdb,
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen userdb_iter_callback_t *callback, void *context)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen reply = auth_stream_reply_init(pool_datastack_create());
849969f639a00eab26791db3cb1b66430420c0cdTimo Sirainen auth_stream_reply_add(reply, NULL, dec2str(userdb->id));
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen pool = pool_alloconly_create("userdb iter", 512);
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen ctx = p_new(pool, struct blocking_userdb_iterate_context, 1);
1d22eaac93de41319918a1fc6de42bb302e25c1aTimo Sirainen ctx->conn = auth_worker_call(pool, reply, iter_callback, ctx);
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenvoid userdb_blocking_iter_next(struct userdb_iterate_context *_ctx)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen (struct blocking_userdb_iterate_context *)_ctx;
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenint userdb_blocking_iter_deinit(struct userdb_iterate_context **_ctx)