-
Notifications
You must be signed in to change notification settings - Fork 3
/
olga.c
137 lines (111 loc) · 2.63 KB
/
olga.c
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <stdio.h>
#include <string.h>
#include "olga.h"
#include "global.h"
#include "Location.h"
#include "cache.h"
#include "hwWind.h"
static void send_olga_init(void);
static void send_olga_exit(void);
static int olga_id;
static int olga_active;
static int olga_group = 0;
/* All GLOBAL memory is merged to one block and allocated in main(). */
char *olga_memory; /* HW_PATH_MAX byte */
/*============================================================================*/
static void send_olga_init(void)
{
short msg[8];
msg[0] = OLE_INIT;
msg[1] = gl_apid;
msg[2] = 0;
msg[3] = OL_CLIENT;
msg[4] = msg[5] = msg[6] = msg[7] = 0;
appl_write (olga_id, 16, msg);
}
/*============================================================================*/
static void send_olga_exit(void)
{
short msg[8];
msg[0] = OLE_EXIT;
msg[1] = gl_apid;
msg[2] = msg[3] = msg[4] = msg[5] = msg[6] = msg[7] = 0;
appl_write (olga_id, 16, msg);
}
/*============================================================================*/
void send_olga_link ( const char *s )
{
short msg[8];
if ( olga_active )
{
olga_group++;
strcpy ( olga_memory, s );
msg[0] = OLGA_LINK;
msg[1] = gl_apid;
msg[2] = 0;
*(char**)(msg +3) = olga_memory;
msg[5] = olga_group;
msg[6] = msg[7] = 0;
appl_write (olga_id, 16, msg);
}
}
/*============================================================================*/
void handle_olga( WORD msg[8])
{
switch (msg[0])
{
case OLE_NEW:
olga_id = msg[1];
send_olga_init ();
break;
case OLE_EXIT:
olga_active = FALSE;
break;
case OLGA_INIT:
olga_active = TRUE;
break;
case OLGA_UPDATED:
{
char buf[2 * HW_PATH_MAX];
FRAME frame;
LOCATION loc;
HwWIND wind = hwWind_Top;
strcpy ( olga_memory, *(char**)(msg +3) );
while (wind) {
frame = hwWind_ActiveFrame (wind);
loc = (frame ? frame->Location : NULL);
if (PROTO_isRemote (loc->Proto)) {
CACHED cached = cache_lookup (loc, 0, NULL);
if (cached) {
union { CACHED c; LOCATION l; } u;
u.c = cache_bound (cached, NULL);
loc = u.l;
}
}
location_FullName (loc, buf, sizeof(buf));
if ( strcmp ( olga_memory , buf ) == 0 ) {
hwWind_history (wind, wind->HistMenu, TRUE);
break;
}
wind = hwWind_Next (wind);
}
}
break;
}
}
/*============================================================================*/
void Init_OLGA(void)
{
if (!olga_active)
{
olga_id = appl_find("OLGA ");
if (olga_id > 0)
send_olga_init();
}
}
/*============================================================================*/
void Exit_OLGA(void)
{
if (olga_active)
send_olga_exit();
}