Don't use reserved identifiers for include guards.
[2oom.git] / src / sys / loop.h
blobfb63769138a1f22f9b984d4780e4793673422bcc
1 /** @file loop.h
2 * Declarations for program main loop
3 */
4 /* 2ooM: The Master of Orion II Reverse Engineering Project
5 * Copyright (C) 2006 Nick Bowler
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef LOOP_H_
23 #define LOOP_H_
25 /** Adds a procedure to the main loop.
26 * The procedure is added to an internal list and is then called as part of the
27 * program main loop. If the callback procedure returns a non-zero value, the
28 * main loop will end.
30 * @see loop_delfunc
31 * @param callback Procedure to add to main loop.
32 * @return An identifier for the added procedure, or -1 on failure.
34 int loop_addfunc(int (*callback)(void));
36 /** Removes a procedure from the main loop.
37 * The specified procedure which was previously added to the main loop is
38 * removed from the internal list. It will no longer be called as part of the
39 * program main loop.
41 * @see loop_addfunc
42 * @param entry Identifier for the procedure, as returned by loop_addfunc().
43 * @return 0 if successful, otherwise -1.
45 int loop_delfunc(int entry);
47 /** Starts the program main loop.
48 * Begins executing procedures added to the internal list. At least one
49 * procedure must be added prior to calling this routine. The loop ends when
50 * one of the procedures returns a nonzero value. Note that if no procedure
51 * in the list blocks, this loop will not be friendly towards the scheduler...
53 * @see loop_addfunc
54 * @see loop_delfunc
55 * @return 0 on normal loop exit, -1 if the procedure list was empty.
57 int loop_run(void);
59 #endif