blob: c95ad64033d65383f5ad43ce86ef1b92c97fc5e1 (
plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/***************************************************************************
xsldbgthread.c - basic thread support
-------------------
begin : Thu Dec 20 2001
copyright : (C) 2001 by Keith Isdale
email : k_isdale@tpg.com.au
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "xsldbg.h"
#include "breakpoint.h"
#include "options.h"
#include "xsldbgmsg.h"
#include "xsldbgthread.h"
static void (*cleanupFuncPtr)(void) = 0;
static int threadStatus = XSLDBG_MSG_THREAD_NOTUSED;
static int inputStatus = XSLDBG_MSG_AWAITING_INPUT;
/* is xsldbg ready for input from the application */
static int inputReady = 0;
/* Is the application ready for a notification message */
static int appReady = 0;
static notifyMessageListPtr notifyList;
arrayListPtr msgList = NULL;
int
getAppReady(void)
{
return appReady;
}
void
setAppReady(int ready)
{
appReady = ready;
}
/* the compiler will optimize this function to inline and to keep variable private*/
int
getInputStatus(void)
{
return inputStatus;
}
void
setInputStatus(XsldbgMessageEnum type)
{
switch (type) {
case XSLDBG_MSG_AWAITING_INPUT: /* Waiting for user input */
case XSLDBG_MSG_READ_INPUT: /* Read user input */
case XSLDBG_MSG_PROCESSING_INPUT: /* Processing user's request */
inputStatus = type;
break;
default:
printf("Invalid input status %d\n", type);
}
}
/* the compiler will optimize this function to inline and to keep variable private*/
int
getThreadStatus(void)
{
return threadStatus;
}
/* reset the status to @p type */
void
setThreadStatus(XsldbgMessageEnum type)
{
switch (type) {
case XSLDBG_MSG_THREAD_NOTUSED:
case XSLDBG_MSG_THREAD_INIT:
case XSLDBG_MSG_THREAD_RUN:
threadStatus = type;
break;
case XSLDBG_MSG_THREAD_STOP:
case XSLDBG_MSG_THREAD_DEAD:
xslDebugStatus = DEBUG_TQUIT;
threadStatus = type;
break;
default:
printf("Invalid thread status %d\n", type);
}
}
/* Is input ready yet */
int
getInputReady(void)
{
return inputReady;
}
/* set/clear flag that indicates if input is ready*/
void
setInputReady(int value)
{
inputReady = value;
}
int
notifyListStart(XsldbgMessageEnum type)
{
int result = 0;
switch (type) {
case XSLDBG_MSG_INTOPTION_CHANGE:
case XSLDBG_MSG_STRINGOPTION_CHANGE:
msgList =
arrayListNew(10, (freeItemFunc) optionsParamItemFree);
break;
default:
msgList = arrayListNew(10, NULL);
}
notifyList =
(notifyMessageListPtr) xmlMalloc(sizeof(notifyMessageList));
if (notifyList && msgList) {
notifyList->type = type;
notifyList->list = msgList;
result = 1;
}
return result;
}
int
notifyListQueue(const void *data)
{
int result = 0;
if (msgList) {
arrayListAdd(msgList, (void *) data);
result = 1;
}
return result;
}
int
notifyListSend(void)
{
int result = 0;
if (notifyList && msgList) {
notifyXsldbgApp(XSLDBG_MSG_LIST, notifyList);
result = 1;
}
return result;
}
void xsldbgSetThreadCleanupFunc(void (*cleanupFunc)(void))
{
cleanupFuncPtr = cleanupFunc;
}
void xsldbgThreadCleanup(void)
{
if (cleanupFuncPtr != 0)
(cleanupFuncPtr)();
}
|