source:
context.c
@
7a70e26
Last change on this file since 7a70e26 was 2a17b63, checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago | |
---|---|
|
|
File size: 1.2 KB |
Rev | Line | |
---|---|---|
[7d4fbcd] | 1 | #include <string.h> |
[1aee7d9] | 2 | #include "owl.h" |
3 | ||
[7d4fbcd] | 4 | #define SET_ACTIVE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_ACTIVE_BITS)|new |
5 | #define SET_MODE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_MODE_BITS)|new | |
6 | ||
[53f421b] | 7 | int owl_context_init(owl_context *ctx) |
8 | { | |
[7d4fbcd] | 9 | ctx->mode = OWL_CTX_STARTUP; |
10 | ctx->data = NULL; | |
11 | return 0; | |
12 | } | |
13 | ||
14 | ||
15 | /* returns whether test matches the current context */ | |
[3f8514b] | 16 | int owl_context_matches(const owl_context *ctx, int test) |
[53f421b] | 17 | { |
[10b866d] | 18 | /*owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);*/ |
[7d4fbcd] | 19 | if ((((ctx->mode&OWL_CTX_MODE_BITS) & test) |
20 | || !(test&OWL_CTX_MODE_BITS)) | |
21 | && | |
22 | (((ctx->mode&OWL_CTX_ACTIVE_BITS) & test) | |
23 | || !(test&OWL_CTX_ACTIVE_BITS))) { | |
24 | return 1; | |
25 | } else { | |
26 | return 0; | |
27 | } | |
28 | } | |
29 | ||
[3f8514b] | 30 | void *owl_context_get_data(const owl_context *ctx) |
[53f421b] | 31 | { |
[7d4fbcd] | 32 | return ctx->data; |
33 | } | |
34 | ||
[3f8514b] | 35 | int owl_context_get_mode(const owl_context *ctx) |
[53f421b] | 36 | { |
[7d4fbcd] | 37 | return ctx->mode & OWL_CTX_MODE_BITS; |
38 | } | |
39 | ||
[3f8514b] | 40 | int owl_context_get_active(const owl_context *ctx) |
[53f421b] | 41 | { |
[7d4fbcd] | 42 | return ctx->mode & OWL_CTX_ACTIVE_BITS; |
43 | } | |
44 | ||
[3f8514b] | 45 | int owl_context_is_startup(const owl_context *ctx) |
[53f421b] | 46 | { |
[7d4fbcd] | 47 | return (ctx->mode & OWL_CTX_STARTUP)?1:0; |
48 | } | |
49 | ||
[3f8514b] | 50 | int owl_context_is_interactive(const owl_context *ctx) |
[53f421b] | 51 | { |
[ecd5dc5] | 52 | return(ctx->mode & OWL_CTX_INTERACTIVE)?1:0; |
53 | } |
Note: See TracBrowser
for help on using the repository browser.