File: context.c

package info (click to toggle)
owl 2.1.8-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,816 kB
  • ctags: 3,421
  • sloc: ansic: 34,004; perl: 246; makefile: 140; sh: 43
file content (100 lines) | stat: -rw-r--r-- 2,149 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <string.h>
#include "owl.h"

static const char fileIdent[] = "$Id: context.c,v 1.6 2003/06/30 22:12:40 kretch Exp $";

#define SET_ACTIVE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_ACTIVE_BITS)|new
#define SET_MODE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_MODE_BITS)|new

int owl_context_init(owl_context *ctx)
{
  ctx->mode = OWL_CTX_STARTUP;
  ctx->data = NULL;
  return 0;
}


/* returns whether test matches the current context */
int owl_context_matches(owl_context *ctx, int test)
{
  /*owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);*/
  if ((((ctx->mode&OWL_CTX_MODE_BITS) & test)
       || !(test&OWL_CTX_MODE_BITS))
      && 
      (((ctx->mode&OWL_CTX_ACTIVE_BITS) & test) 
       || !(test&OWL_CTX_ACTIVE_BITS))) {
    return 1;
  } else {
    return 0;
  }
}

void *owl_context_get_data(owl_context *ctx)
{
  return ctx->data;
}

int owl_context_get_mode(owl_context *ctx)
{
  return ctx->mode & OWL_CTX_MODE_BITS;
}

int owl_context_get_active(owl_context *ctx)
{
  return ctx->mode & OWL_CTX_ACTIVE_BITS;
}

int owl_context_is_startup(owl_context *ctx)
{
  return (ctx->mode & OWL_CTX_STARTUP)?1:0;
}

int owl_context_is_interactive(owl_context *ctx)
{
  return(ctx->mode & OWL_CTX_INTERACTIVE)?1:0;
}

void owl_context_set_startup(owl_context *ctx)
{
  SET_MODE(ctx, OWL_CTX_STARTUP);
}

void owl_context_set_readconfig(owl_context *ctx)
{
  SET_MODE(ctx, OWL_CTX_READCONFIG);
}

void owl_context_set_interactive(owl_context *ctx)
{
  SET_MODE(ctx, OWL_CTX_INTERACTIVE);
}

void owl_context_set_popless(owl_context *ctx, owl_viewwin *vw)
{
  ctx->data = (void*)vw;
  SET_ACTIVE(ctx, OWL_CTX_POPLESS);
}

void owl_context_set_recv(owl_context *ctx)
{
  SET_ACTIVE(ctx, OWL_CTX_RECV);
}

void owl_context_set_editmulti(owl_context *ctx, owl_editwin *ew)
{
  ctx->data = (void*)ew;
  SET_ACTIVE(ctx, OWL_CTX_EDITMULTI);
}

void owl_context_set_editline(owl_context *ctx, owl_editwin *ew)
{
  ctx->data = (void*)ew;
  SET_ACTIVE(ctx, OWL_CTX_EDITLINE);
}

void owl_context_set_editresponse(owl_context *ctx, owl_editwin *ew)
{
  ctx->data = (void*)ew;
  SET_ACTIVE(ctx, OWL_CTX_EDITRESPONSE);
}