-
Notifications
You must be signed in to change notification settings - Fork 3
/
AppInfo.c
215 lines (180 loc) · 5.11 KB
/
AppInfo.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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**************************************************
*** Project Title: Command Post (KFLASH) ***
*** Author: Greg Dietsche ***
*** Date: 07/23/2002 ***
*** Description: An application designed for ***
*** use with the TI-89 and TI-92 Plus Graphing ***
*** calculators during the testing and ***
*** debugging phases of FLASH APPS and RAM ***
*** programs ***
***************************************************/
// $Id: AppInfo.c 4 2004-08-05 19:06:59Z dietsche $
#include <tiams.h>
#include "KFLASH.h"
#include "KFLASHr1.H"
#include "AppInfo.h"
char* AppACB(AppID app);
char* AppHDR(AppID app);
char* AppFlags(AppID app);
//callback routine for dlgLeakWatch
DWORD cbAppInfoSelect(WORD DlgId, DWORD dValue)
{
APP_INFO_DAT *d=&global.app_info_dat;
static WINDOW *win=NULL;
static WIN_RECT wr={0,29,0,0};
AppID app;
char *pupText;
short lastkey;
switch(DlgId)
{
case 0: //Dynamic Text
win=((OWNER_DRAW_STRUCT *) dValue)->pW;
if(strlen(pupText=PopupText(d->pupApps, d->optList[0])))
{
app=OO_AppNameToACB((UCHAR *)pupText,TRUE);
wr.x1=WinWidth(win);
wr.y1=WinHeight(win)-12;
WinFill(win, &wr, A_REVERSE);
if(d->page==KB_F2)
WinStrXYWrap(win, 8, 19+(1*10), AppACB(app),WWF_DRAW);
else if(d->page==KB_F3)
WinStrXYWrap(win, 8, 19+(1*10), AppHDR(app),WWF_DRAW);
else if(d->page==KB_F4)
WinStrXYWrap(win, 8, 19+(1*10), AppFlags(app),WWF_DRAW);
}
else
{
d->page=KB_F1;
}
break;
case 4: //Menu
lastkey=d->page;
switch(d->page=LO_WORD(dValue))
{
case KB_F2:
case KB_F3:
case KB_F4:
return 1;
case KB_F1:
if(win)
WinFill(win, &wr, A_REVERSE);
return 0;
default:
d->page=lastkey;
return lastkey==KB_F1?0:1;
};
break;
};
return TRUE;
}
char * AppHDR(AppID app)
{
AppHdr const *head=((ACB*)(HeapDeref((HANDLE)(app))))->appHeader;
char name[9]={' '};
char *buff=gBuff;
memcpy(name,head->name,8);
sprintf(buff,XR_stringPtr(XR_APP_HDR),
head->magic,name,head->flags,head->dataLen,head->codeOffset,
head->initDataOffset,head->initDataLen,head->optlen);
#ifdef DEBUG
if(strlen(buff)>MISC_BUFF_LEN)
DlgNotice("Debug Error","AppHDR buffer overflowed!");
#endif
return buff;
}
char * AppFlags(AppID app)
{
ACB *acb=HeapDeref((HANDLE)app);
USHORT flags=acb->flags;
char *flagstr=gBuff;
strcpy(flagstr, XR_stringPtr(XR_ACBFlags));
if(flags&ACB_BUILTIN)
strcat(flagstr,XR_stringPtr(XR_BUILTIN));
if(flags&ACB_INSTALLED)
strcat(flagstr,XR_stringPtr(XR_INSTALLED));
if(flags&ACB_LOCALIZER)
strcat(flagstr,XR_stringPtr(XR_LOCALIZER));
if(flags&ACB_LOCK)
strcat(flagstr,XR_stringPtr(XR_LOCK));
if(flags&ACB_JT_VERSION)
strcat(flagstr,XR_stringPtr(XR_JT_VERSION));
if(flags&ACB_SELECTED)
strcat(flagstr,XR_stringPtr(XR_SELECTED));
if(flags&ACB_COLLAPSE)
strcat(flagstr,XR_stringPtr(XR_COLLAPSE));
if(flags&ACB_BG)
strcat(flagstr,XR_stringPtr(XR_BG));
if(flags&ACB_COMPRESS)
strcat(flagstr,XR_stringPtr(XR_COMPRESS));
if(flags&ACB_DELETE)
strcat(flagstr,XR_stringPtr(XR_DELETE));
flagstr[strlen(flagstr)-1]=0;
strcat(flagstr,XR_stringPtr(XR_nAppHeaderFlagsn));
flags=acb->appHeader->flags;
if(flags&APPHDR_LOCALIZER)
strcat(flagstr,XR_stringPtr(XR_Localizer));
strcat(flagstr,XR_stringPtr(XR_nAppFlags));
flags=GetAppFlags(app);
if(flags&APP_INTERACTIVE)
strcat(flagstr,XR_stringPtr(XR_Interactive));
if(flags&APP_CON)
strcat(flagstr,XR_stringPtr(XR_Con));
if(flags&APP_ACCESS_SYSVARS)
strcat(flagstr,XR_stringPtr(XR_AccessSysVars));
if(flags&APP_BACKGROUND)
strcat(flagstr,XR_stringPtr(XR_Background));
flagstr[strlen(flagstr)-1]=0;
strcat(flagstr," }");
#ifdef DEBUG
if(strlen(flagstr)>MISC_BUFF_LEN)
DlgNotice("Debug Error","AppFlags buffer overflowed! ref: 1");
#endif
return flagstr;
}
char* AppACB(AppID app)
{
ACB *acb=HeapDeref((HANDLE)app);
char *buff=gBuff;
sprintf(buff,XR_stringPtr(XR_APP_ACB),
acb->flags,acb->myID,acb->next,acb->prev,acb->publicstorage,
acb->appHeader,acb->certhdr,acb->appData);
#ifdef DEBUG
if(strlen(buff)>MISC_BUFF_LEN)
DlgNotice("Debug Error","AppACB buffer overflowed! ref: 2");
#endif
return buff;
}
void DoAppInfoDialog(void)
{
Access_AMS_Global_Variables;
char *pupText;
char buff[250];
APP_INFO_DAT *d=&global.app_info_dat;
//force these as default settings for each instance
if(!d->optList[0])d->optList[0]=1;
d->page=KB_F1;
TRY
switch(Dialog(&dlgAppInfoSelect, -1, -1, NULL, d->optList))
{
case DB_MEMFULL: //handle low memory error
EV_errorCode=ER_MEMORY;
break;
}
ONERR
EV_errorCode=errCode;
ENDTRY
HeapFreeIndir(&d->pupApps);
}
HANDLE pupAppInfoApps(WORD index)
{
Access_AMS_Global_Variables;
HANDLE *h=&global.app_info_dat.pupApps;
AppID appid;
HeapFreeIndir(h);
*h=PopupNew(NULL, 0);
for(appid=OO_firstACB; appid; appid=OO_NextACB(appid))
{
PopupAddText(*h, -1, (char *)GetAppName(appid), 0);
}
return *h;
}