5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2005, 2006 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
22 /* Halts async operation */
24 SilcBool silc_async_halt(SilcAsyncOperation op)
26 SILC_LOG_DEBUG(("Halting async operation"));
29 return op->pause_cb(op, TRUE, op->context);
34 /* Resumes async operation */
36 SilcBool silc_async_resume(SilcAsyncOperation op)
38 SILC_LOG_DEBUG(("Resuming async operation"));
41 return op->pause_cb(op, FALSE, op->context);
46 /* Aborts async operation */
48 void silc_async_abort(SilcAsyncOperation op,
49 SilcAsyncOperationAbort abort_cb, void *context)
51 SILC_LOG_DEBUG(("Aborting async operation"));
54 op->abort_cb(op, op->context);
57 abort_cb(op, context);
62 /* Creates new async operation */
64 SilcAsyncOperation silc_async_alloc(SilcAsyncOperationAbort abort_cb,
65 SilcAsyncOperationPause pause_cb,
68 SilcAsyncOperation op;
70 SILC_LOG_DEBUG(("Creating new async operation"));
72 op = silc_calloc(1, sizeof(*op));
76 silc_async_init(op, abort_cb, pause_cb, context);
83 /* Creates new async operation */
85 SilcBool silc_async_init(SilcAsyncOperation op,
86 SilcAsyncOperationAbort abort_cb,
87 SilcAsyncOperationPause pause_cb,
90 SILC_ASSERT(abort_cb);
91 op->abort_cb = abort_cb;
92 op->pause_cb = pause_cb;
93 op->context = context;
94 op->allocated = FALSE;
98 /* Stops async operation */
100 void silc_async_free(SilcAsyncOperation op)
103 SILC_LOG_DEBUG(("Stopping async operation"));
110 void *silc_async_get_context(SilcAsyncOperation op)