userdb-blocking.c revision 2e29e4797a48d78d669821722bdb54fd0a1d3b94
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen/* Copyright (C) 2005 Timo Sirainen */
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen#include "common.h"
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen#include "str.h"
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen#include "auth-worker-server.h"
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen#include "userdb.h"
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen#include "userdb-blocking.h"
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen#include <stdlib.h>
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainenstatic void user_callback(struct auth_request *request, const char *reply)
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen{
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen request->private_callback.userdb(reply, request);
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen}
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainenvoid userdb_blocking_lookup(struct auth_request *request,
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen userdb_callback_t *callback)
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen{
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen string_t *str;
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen request->private_callback.userdb = callback;
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen str = t_str_new(64);
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen str_append(str, "USER\t");
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen auth_request_export(request, str);
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen auth_worker_call(request, str_c(str), user_callback);
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen}