[123] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: eas.c 1207 2008-09-13 06:49:41Z jbs $
|
---|
| 5 |
|
---|
[347] | 6 | Display/edit EAs
|
---|
| 7 |
|
---|
[123] | 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[347] | 9 | Copyright (c) 2004, 2006 Steven H. Levine
|
---|
[123] | 10 |
|
---|
[193] | 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 12 | 06 Jun 05 SHL Indent -i2
|
---|
[207] | 13 | 06 Jun 05 SHL Rework DisplayEAsProc for VAC3.65 compat
|
---|
| 14 | 06 Jun 05 SHL Drop unused variables
|
---|
[347] | 15 | 17 Jul 06 SHL Use Runtime_Error
|
---|
[574] | 16 | 22 Mar 07 GKY Use QWL_USER
|
---|
[725] | 17 | 05 Jul 07 SHL GetFileEAs: avoid heap corruption
|
---|
[730] | 18 | 15 Jul 07 GKY Allow subject edit of up to 256 chars
|
---|
[755] | 19 | 03 Aug 07 GKY Remove surrious error message
|
---|
[775] | 20 | 06 Aug 07 GKY Increase Subject EA to 1024
|
---|
[795] | 21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[827] | 22 | 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
|
---|
[985] | 23 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[123] | 24 |
|
---|
| 25 | ***********************************************************************/
|
---|
| 26 |
|
---|
[907] | 27 | #include <stdlib.h>
|
---|
| 28 | #include <stdio.h>
|
---|
| 29 | #include <string.h>
|
---|
| 30 | #include <ctype.h>
|
---|
| 31 |
|
---|
[2] | 32 | #define INCL_WIN
|
---|
| 33 | #define INCL_DOS
|
---|
| 34 | #define INCL_DOSERRORS
|
---|
[841] | 35 | #define INCL_LONGLONG
|
---|
[2] | 36 |
|
---|
[1179] | 37 | #include "fm3dll.h"
|
---|
[1207] | 38 | #include "notebook.h" // Data declaration(s)
|
---|
| 39 | #include "info.h" // Data declaration(s)
|
---|
| 40 | #include "init.h" // Data declaration(s)
|
---|
| 41 | #include "mainwnd.h" // Data declaration(s)
|
---|
| 42 | #include "newview.h" // Data declarations
|
---|
[2] | 43 | #include "fm3dlg.h"
|
---|
| 44 | #include "fm3str.h"
|
---|
| 45 | #include "mle.h"
|
---|
[1157] | 46 | #include "errutil.h" // Dos_Error...
|
---|
| 47 | #include "strutil.h" // GetPString
|
---|
| 48 | #include "defview.h" // QuickView
|
---|
[1179] | 49 | #include "subj.h" // Subject
|
---|
| 50 | #include "wrappers.h" // xDosSetPathInfo
|
---|
[1157] | 51 | #include "eas.h"
|
---|
[1179] | 52 | #include "strips.h" // bstrip
|
---|
| 53 | #include "valid.h" // IsFile
|
---|
| 54 | #include "misc.h" // PaintRecessedWindow
|
---|
[1039] | 55 | #include "fortify.h"
|
---|
[2] | 56 |
|
---|
| 57 | #pragma data_seg(DATA1)
|
---|
[347] | 58 |
|
---|
| 59 | static PSZ pszSrcFile = __FILE__;
|
---|
| 60 |
|
---|
[1157] | 61 | static PVOID SaveEA(CHAR * filename, HOLDFEA * current, CHAR * newdata,
|
---|
| 62 | BOOL silentfail);
|
---|
[2] | 63 |
|
---|
[193] | 64 | typedef struct
|
---|
| 65 | {
|
---|
[2] | 66 | CHAR *name;
|
---|
[193] | 67 | INT type;
|
---|
| 68 | }
|
---|
| 69 | RESERVEDEAS;
|
---|
[2] | 70 |
|
---|
[193] | 71 | typedef struct
|
---|
| 72 | {
|
---|
| 73 | CHAR *filename;
|
---|
[2] | 74 | HOLDFEA *head;
|
---|
[193] | 75 | }
|
---|
| 76 | ADDEA;
|
---|
[2] | 77 |
|
---|
[193] | 78 | HOLDFEA *CheckEA(HOLDFEA * head, CHAR * eaname)
|
---|
| 79 | {
|
---|
[2] | 80 | /* return pointer to ea named eaname if found in linked list */
|
---|
| 81 |
|
---|
| 82 | register HOLDFEA *info = NULL;
|
---|
| 83 |
|
---|
[551] | 84 | if (eaname && *eaname) {
|
---|
[2] | 85 | info = head;
|
---|
[551] | 86 | while (info) {
|
---|
| 87 | if (!strcmp(info->name, eaname))
|
---|
[1157] | 88 | return info;
|
---|
[551] | 89 | info = info->next;
|
---|
[2] | 90 | }
|
---|
| 91 | }
|
---|
| 92 | return info;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[193] | 95 | MRESULT EXPENTRY AddEAProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 96 | {
|
---|
| 97 | ADDEA *add;
|
---|
| 98 | HOLDFEA *head;
|
---|
| 99 | CHAR *filename;
|
---|
[551] | 100 | static CHAR *forbidden[] = { ".ASSOCTABLE",
|
---|
| 101 | ".CLASSINFO",
|
---|
| 102 | ".ICON",
|
---|
| 103 | ".CODEPAGE",
|
---|
| 104 | ""
|
---|
| 105 | };
|
---|
| 106 | static RESERVEDEAS restypes[] = { ".TYPE", EAT_MVMT,
|
---|
| 107 | ".SUBJECT", EAT_ASCII,
|
---|
| 108 | ".COMMENTS", EAT_MVMT,
|
---|
| 109 | ".KEYPHRASES", EAT_MVMT,
|
---|
| 110 | ".HISTORY", EAT_MVMT,
|
---|
| 111 | ".LONGNAME", EAT_ASCII,
|
---|
| 112 | ".VERSION", EAT_ASCII,
|
---|
| 113 | "", 0
|
---|
| 114 | };
|
---|
[2] | 115 |
|
---|
[551] | 116 | switch (msg) {
|
---|
[193] | 117 | case WM_INITDLG:
|
---|
[551] | 118 | if (!mp2) {
|
---|
[193] | 119 | WinDismissDlg(hwnd, 0);
|
---|
[2] | 120 | break;
|
---|
[193] | 121 | }
|
---|
[574] | 122 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
|
---|
[193] | 123 | WinSendDlgItemMsg(hwnd, EAC_NAME, EM_SETTEXTLIMIT,
|
---|
[1157] | 124 | MPFROM2SHORT(1024, 0), MPVOID);
|
---|
[193] | 125 | WinCheckButton(hwnd, EAC_ASCII, TRUE);
|
---|
| 126 | break;
|
---|
[2] | 127 |
|
---|
[193] | 128 | case WM_PAINT:
|
---|
| 129 | PostMsg(hwnd, UM_PAINT, MPVOID, MPVOID);
|
---|
| 130 | break;
|
---|
[2] | 131 |
|
---|
[193] | 132 | case UM_PAINT:
|
---|
[551] | 133 | PaintRecessedWindow(WinWindowFromID(hwnd, EAC_TEXT), (HPS) 0, FALSE,
|
---|
[1157] | 134 | FALSE);
|
---|
[193] | 135 | return 0;
|
---|
[2] | 136 |
|
---|
[193] | 137 | case WM_CONTROL:
|
---|
| 138 | return 0;
|
---|
[2] | 139 |
|
---|
[193] | 140 | case WM_COMMAND:
|
---|
[551] | 141 | switch (SHORT1FROMMP(mp1)) {
|
---|
[193] | 142 | case DID_OK:
|
---|
| 143 | add = INSTDATA(hwnd);
|
---|
[551] | 144 | head = add->head;
|
---|
| 145 | filename = add->filename;
|
---|
[193] | 146 | {
|
---|
[1157] | 147 | CHAR s[1025];
|
---|
| 148 | INT x;
|
---|
| 149 | USHORT type = EAT_ASCII;
|
---|
[2] | 150 |
|
---|
[1157] | 151 | *s = 0;
|
---|
| 152 | WinQueryDlgItemText(hwnd, EAC_NAME, 1024, s);
|
---|
| 153 | bstrip(s);
|
---|
| 154 | if (!*s)
|
---|
| 155 | WinDismissDlg(hwnd, 0);
|
---|
| 156 | else {
|
---|
| 157 | if (CheckEA(head, s)) {
|
---|
| 158 | DosBeep(50, 100);
|
---|
| 159 | WinSetDlgItemText(hwnd, EAC_TEXT,
|
---|
| 160 | GetPString(IDS_EANAMEEXISTSTEXT));
|
---|
| 161 | break;
|
---|
| 162 | }
|
---|
| 163 | for (x = 0; *forbidden[x]; x++) {
|
---|
| 164 | if (!strcmp(forbidden[x], s)) {
|
---|
| 165 | DosBeep(50, 100);
|
---|
| 166 | WinSetDlgItemText(hwnd, EAC_TEXT,
|
---|
| 167 | GetPString(IDS_EANAMERESERVEDTEXT));
|
---|
| 168 | return 0;
|
---|
| 169 | }
|
---|
| 170 | }
|
---|
| 171 | if (WinQueryButtonCheckstate(hwnd, EAC_MVST))
|
---|
| 172 | type = EAT_MVST;
|
---|
| 173 | else if (WinQueryButtonCheckstate(hwnd, EAC_MVMT))
|
---|
| 174 | type = EAT_MVMT;
|
---|
| 175 | for (x = 0; *restypes[x].name; x++) {
|
---|
| 176 | if (!strcmp(restypes[x].name, s)) {
|
---|
| 177 | if (type != restypes[x].type) {
|
---|
| 178 | DosBeep(50, 100);
|
---|
| 179 | WinSetDlgItemText(hwnd, EAC_TEXT,
|
---|
| 180 | GetPString(IDS_EAWRONGTYPETEXT));
|
---|
| 181 | return 0;
|
---|
| 182 | }
|
---|
| 183 | break;
|
---|
| 184 | }
|
---|
| 185 | }
|
---|
| 186 | /* if we get here, create dummy ea */
|
---|
| 187 | {
|
---|
| 188 | PFEA2LIST pfealist = NULL;
|
---|
| 189 | EAOP2 eaop;
|
---|
| 190 | ULONG ealen;
|
---|
| 191 | CHAR *eaval;
|
---|
| 192 | APIRET rc;
|
---|
[2] | 193 |
|
---|
[1157] | 194 | ealen = sizeof(FEA2LIST) + strlen(s) + 64;
|
---|
| 195 | rc = DosAllocMem((PPVOID) & pfealist, ealen + 1,
|
---|
| 196 | OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
|
---|
| 197 | if (rc)
|
---|
| 198 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 199 | GetPString(IDS_OUTOFMEMORY));
|
---|
| 200 | else {
|
---|
| 201 | memset(pfealist, 0, ealen + 1);
|
---|
| 202 | pfealist->cbList = ealen;
|
---|
| 203 | pfealist->list[0].oNextEntryOffset = 0;
|
---|
| 204 | pfealist->list[0].fEA = 0;
|
---|
| 205 | pfealist->list[0].cbName = strlen(s);
|
---|
| 206 | strcpy(pfealist->list[0].szName, s);
|
---|
| 207 | eaval = pfealist->list[0].szName + strlen(s) + 1;
|
---|
| 208 | *(USHORT *) eaval = (USHORT) type;
|
---|
| 209 | eaval += sizeof(USHORT);
|
---|
| 210 | if (type == EAT_MVST || type == EAT_MVMT) {
|
---|
| 211 | *(USHORT *) eaval = (USHORT) 0; /* codepage */
|
---|
| 212 | eaval += sizeof(USHORT);
|
---|
| 213 | *(USHORT *) eaval = (USHORT) 1; /* number */
|
---|
| 214 | eaval += sizeof(USHORT);
|
---|
| 215 | *(USHORT *) eaval = (USHORT) EAT_ASCII; /* type */
|
---|
| 216 | eaval += sizeof(USHORT);
|
---|
| 217 | }
|
---|
| 218 | *(USHORT *) eaval = (USHORT) 4;
|
---|
| 219 | eaval += sizeof(USHORT);
|
---|
| 220 | memcpy(eaval, GetPString(IDS_FAKETEXT), 4);
|
---|
| 221 | pfealist->list[0].cbValue = 4 + (sizeof(USHORT) * 2) +
|
---|
| 222 | ((type == EAT_MVST ||
|
---|
| 223 | type == EAT_MVMT) ? sizeof(USHORT) * 3 : 0);
|
---|
| 224 | eaop.fpGEA2List = (PGEA2LIST) 0;
|
---|
| 225 | eaop.fpFEA2List = pfealist;
|
---|
| 226 | eaop.oError = 0;
|
---|
| 227 | xDosSetPathInfo(filename, FIL_QUERYEASIZE,
|
---|
| 228 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
| 229 | WinDismissDlg(hwnd, 1);
|
---|
| 230 | }
|
---|
| 231 | }
|
---|
| 232 | }
|
---|
[193] | 233 | }
|
---|
| 234 | break;
|
---|
[2] | 235 |
|
---|
[193] | 236 | case DID_CANCEL:
|
---|
| 237 | WinDismissDlg(hwnd, 0);
|
---|
| 238 | break;
|
---|
[2] | 239 |
|
---|
[193] | 240 | case IDM_HELP:
|
---|
| 241 | if (hwndHelp)
|
---|
[1157] | 242 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 243 | MPFROM2SHORT(HELP_ADDEA, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
[193] | 244 | break;
|
---|
| 245 | }
|
---|
| 246 | return 0;
|
---|
[2] | 247 | }
|
---|
[193] | 248 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 249 | }
|
---|
| 250 |
|
---|
[193] | 251 | static VOID HexDumpEA(HWND hwnd, HOLDFEA * info)
|
---|
| 252 | {
|
---|
| 253 | if (info)
|
---|
[551] | 254 | HexDump(WinWindowFromID(hwnd, EA_HEXDUMP), info->value, info->cbValue);
|
---|
[2] | 255 | }
|
---|
| 256 |
|
---|
[193] | 257 | VOID HexDump(HWND hwnd, CHAR * value, ULONG cbValue)
|
---|
| 258 | {
|
---|
[2] | 259 | /* display a hexdump of a binary 'string' in listbox hwnd */
|
---|
| 260 |
|
---|
[193] | 261 | CHAR s[132];
|
---|
| 262 | register CHAR *p, *pp, *a;
|
---|
| 263 | register ULONG x = 0, y, z;
|
---|
[2] | 264 |
|
---|
[193] | 265 | WinSendMsg(hwnd, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[551] | 266 | if (cbValue) {
|
---|
[2] | 267 | pp = p = value;
|
---|
[551] | 268 | while (x < cbValue) {
|
---|
[2] | 269 | y = x;
|
---|
[193] | 270 | sprintf(s, "%04lx ", x);
|
---|
[2] | 271 | a = s + 6;
|
---|
[551] | 272 | do {
|
---|
[1157] | 273 | sprintf(a, "%02x ", (UCHAR)*p);
|
---|
| 274 | a += 3;
|
---|
| 275 | p++;
|
---|
| 276 | x++;
|
---|
[2] | 277 | }
|
---|
[193] | 278 | while (x < cbValue && (x % 16));
|
---|
[551] | 279 | if (x % 16) {
|
---|
[1157] | 280 | z = x;
|
---|
| 281 | while (z % 16) {
|
---|
| 282 | *a++ = ' ';
|
---|
| 283 | *a++ = ' ';
|
---|
| 284 | *a++ = ' ';
|
---|
| 285 | z++;
|
---|
| 286 | }
|
---|
[193] | 287 | }
|
---|
[2] | 288 | *a++ = ' ';
|
---|
| 289 | p = pp;
|
---|
[551] | 290 | do {
|
---|
[1157] | 291 | if (*p)
|
---|
| 292 | *a++ = *p++;
|
---|
| 293 | else {
|
---|
| 294 | *a++ = '.';
|
---|
| 295 | p++;
|
---|
| 296 | }
|
---|
| 297 | *a = 0;
|
---|
| 298 | y++;
|
---|
[193] | 299 | }
|
---|
| 300 | while (y < x);
|
---|
| 301 | if ((SHORT) WinSendMsg(hwnd, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
|
---|
[1157] | 302 | MPFROMP(s)) < 0)
|
---|
| 303 | break;
|
---|
[2] | 304 | pp = p;
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[193] | 309 | typedef struct
|
---|
| 310 | {
|
---|
| 311 | USHORT size;
|
---|
| 312 | USHORT flags;
|
---|
| 313 | HOLDFEA *head, *current;
|
---|
| 314 | CHAR **list;
|
---|
| 315 | CHAR filename[CCHMAXPATH];
|
---|
| 316 | }
|
---|
| 317 | EAPROCDATA;
|
---|
[2] | 318 |
|
---|
[193] | 319 | MRESULT EXPENTRY DisplayEAsProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 320 | {
|
---|
| 321 | EAPROCDATA *eap;
|
---|
| 322 | HOLDFEA *info;
|
---|
| 323 | static HPOINTER hptrIcon = (HPOINTER) 0;
|
---|
[2] | 324 |
|
---|
[193] | 325 | if (msg != WM_INITDLG)
|
---|
[574] | 326 | eap = (EAPROCDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 327 |
|
---|
[551] | 328 | switch (msg) {
|
---|
[193] | 329 | case WM_INITDLG:
|
---|
[551] | 330 | if (!mp2) {
|
---|
[193] | 331 | WinDismissDlg(hwnd, 0);
|
---|
| 332 | break;
|
---|
| 333 | }
|
---|
[564] | 334 | eap = xmallocz(sizeof(EAPROCDATA), pszSrcFile, __LINE__);
|
---|
[551] | 335 | if (!eap) {
|
---|
[193] | 336 | WinDismissDlg(hwnd, 0);
|
---|
| 337 | break;
|
---|
| 338 | }
|
---|
| 339 | hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, EA_FRAME);
|
---|
| 340 | WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPVOID);
|
---|
[551] | 341 | eap->size = sizeof(EAPROCDATA);
|
---|
| 342 | eap->list = (CHAR **) mp2;
|
---|
[574] | 343 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) eap);
|
---|
[193] | 344 | WinSendDlgItemMsg(hwnd,
|
---|
[1157] | 345 | EA_ENTRY, EM_SETTEXTLIMIT, MPFROM2SHORT(40, 0), MPVOID);
|
---|
[770] | 346 | MLEsetlimit(WinWindowFromID(hwnd, EA_MLE), 32767);
|
---|
[551] | 347 | MLEsetformat(WinWindowFromID(hwnd, EA_MLE), MLFIE_NOTRANS);
|
---|
[193] | 348 | {
|
---|
| 349 | INT x;
|
---|
| 350 | SHORT sSelect;
|
---|
| 351 | CHAR s[CCHMAXPATH];
|
---|
[2] | 352 |
|
---|
[551] | 353 | for (x = 0; eap->list[x]; x++) {
|
---|
[1157] | 354 | if (DosQueryPathInfo(eap->list[x], FIL_QUERYFULLNAME, s, sizeof(s)))
|
---|
| 355 | strcpy(s, eap->list[x]);
|
---|
| 356 | if (IsFile(s) != -1)
|
---|
| 357 | WinSendDlgItemMsg(hwnd,
|
---|
| 358 | EA_NAMES,
|
---|
| 359 | LM_INSERTITEM,
|
---|
| 360 | MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s));
|
---|
[193] | 361 | }
|
---|
| 362 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
[1157] | 363 | EA_NAMES,
|
---|
| 364 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
[193] | 365 | if (sSelect > 0)
|
---|
[1157] | 366 | WinSendDlgItemMsg(hwnd,
|
---|
| 367 | EA_NAMES,
|
---|
| 368 | LM_SELECTITEM,
|
---|
| 369 | MPFROM2SHORT(0, 0), MPFROMSHORT(TRUE));
|
---|
[193] | 370 | else
|
---|
[1157] | 371 | WinDismissDlg(hwnd, 0);
|
---|
[193] | 372 | }
|
---|
| 373 | break;
|
---|
[2] | 374 |
|
---|
[193] | 375 | case UM_SETDIR:
|
---|
[551] | 376 | if (*eap->filename) {
|
---|
| 377 | if (eap->head)
|
---|
[1157] | 378 | Free_FEAList(eap->head);
|
---|
[551] | 379 | eap->head = GetFileEAs(eap->filename, FALSE, FALSE);
|
---|
| 380 | if (!isalpha(*eap->filename) ||
|
---|
[1157] | 381 | (driveflags[toupper(*eap->filename) - 'A'] & DRIVE_NOTWRITEABLE)) {
|
---|
| 382 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE);
|
---|
| 383 | WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), FALSE);
|
---|
| 384 | WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE);
|
---|
[2] | 385 | }
|
---|
[551] | 386 | else {
|
---|
[1157] | 387 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE);
|
---|
| 388 | WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), TRUE);
|
---|
| 389 | WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), TRUE);
|
---|
[2] | 390 | }
|
---|
[193] | 391 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 392 | }
|
---|
| 393 | break;
|
---|
| 394 |
|
---|
| 395 | case UM_SETUP:
|
---|
| 396 | WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 397 | WinShowWindow(WinWindowFromID(hwnd, EA_ENTRY), FALSE);
|
---|
| 398 | WinSetDlgItemText(hwnd, EA_ENTRY, NullStr);
|
---|
| 399 | WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE);
|
---|
| 400 | MLEclearall(WinWindowFromID(hwnd, EA_MLE));
|
---|
| 401 | WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), FALSE);
|
---|
| 402 | WinSendDlgItemMsg(hwnd, EA_HEXDUMP, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 403 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE);
|
---|
| 404 | WinShowWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE);
|
---|
[551] | 405 | eap->current = NULL;
|
---|
| 406 | if (eap->head) {
|
---|
[193] | 407 | WinSetDlgItemText(hwnd, EA_TEXT, NullStr);
|
---|
[551] | 408 | info = eap->head;
|
---|
| 409 | while (info) {
|
---|
[1157] | 410 | WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_INSERTITEM,
|
---|
| 411 | MPFROM2SHORT(LIT_END, 0), MPFROMP(info->name));
|
---|
| 412 | info = info->next;
|
---|
[2] | 413 | }
|
---|
[193] | 414 | WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_SELECTITEM,
|
---|
[1157] | 415 | MPFROM2SHORT(0, 0), MPFROM2SHORT(TRUE, 0));
|
---|
[193] | 416 | }
|
---|
| 417 | else
|
---|
[551] | 418 | WinSetDlgItemText(hwnd, EA_TEXT, GetPString(IDS_EANOEAS));
|
---|
[193] | 419 | return 0;
|
---|
[2] | 420 |
|
---|
[193] | 421 | case WM_PAINT:
|
---|
| 422 | PostMsg(hwnd, UM_PAINT, MPVOID, MPVOID);
|
---|
| 423 | break;
|
---|
[2] | 424 |
|
---|
[193] | 425 | case UM_PAINT:
|
---|
| 426 | PaintRecessedWindow(WinWindowFromID(hwnd, EA_HELP), (HPS) 0, FALSE, TRUE);
|
---|
[551] | 427 | PaintRecessedWindow(WinWindowFromID(hwnd, EA_TEXT), (HPS) 0, FALSE,
|
---|
[1157] | 428 | FALSE);
|
---|
[193] | 429 | return 0;
|
---|
[2] | 430 |
|
---|
[193] | 431 | case WM_CONTROL:
|
---|
[551] | 432 | switch (SHORT1FROMMP(mp1)) {
|
---|
[193] | 433 | case EA_NAMES:
|
---|
[551] | 434 | switch (SHORT2FROMMP(mp1)) {
|
---|
[193] | 435 | case LN_SETFOCUS:
|
---|
[1157] | 436 | WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EAFILENAMESHELPTEXT));
|
---|
| 437 | break;
|
---|
[193] | 438 | case LN_KILLFOCUS:
|
---|
[1157] | 439 | WinSetDlgItemText(hwnd, EA_HELP, NullStr);
|
---|
| 440 | break;
|
---|
[193] | 441 | case LN_ENTER:
|
---|
| 442 | case LN_SELECT:
|
---|
[1157] | 443 | {
|
---|
| 444 | CHAR s[1025];
|
---|
| 445 | SHORT sSelect;
|
---|
[193] | 446 |
|
---|
[1157] | 447 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, EA_NAMES,
|
---|
| 448 | LM_QUERYSELECTION,
|
---|
| 449 | MPFROM2SHORT(LIT_FIRST, 0),
|
---|
| 450 | MPVOID);
|
---|
| 451 | if (sSelect >= 0) {
|
---|
| 452 | *s = 0;
|
---|
| 453 | WinSendDlgItemMsg(hwnd, EA_NAMES, LM_QUERYITEMTEXT,
|
---|
| 454 | MPFROM2SHORT(sSelect, 1024), MPFROMP(s));
|
---|
| 455 | if (*s) {
|
---|
| 456 | strcpy(eap->filename, s);
|
---|
| 457 | if (SHORT2FROMMP(mp1) == LN_SELECT)
|
---|
| 458 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 459 | else
|
---|
| 460 | QuickView(hwnd, eap->filename);
|
---|
| 461 | }
|
---|
| 462 | }
|
---|
| 463 | }
|
---|
| 464 | break;
|
---|
[2] | 465 | }
|
---|
| 466 | break;
|
---|
| 467 |
|
---|
[193] | 468 | case EA_LISTBOX:
|
---|
[551] | 469 | switch (SHORT2FROMMP(mp1)) {
|
---|
[193] | 470 | case LN_SETFOCUS:
|
---|
[1157] | 471 | WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EATYPESHELPTEXT));
|
---|
| 472 | break;
|
---|
[193] | 473 | case LN_KILLFOCUS:
|
---|
[1157] | 474 | WinSetDlgItemText(hwnd, EA_HELP, NullStr);
|
---|
| 475 | break;
|
---|
[193] | 476 | case LN_SELECT:
|
---|
[1157] | 477 | {
|
---|
| 478 | CHAR s[1024];
|
---|
| 479 | SHORT sSelect;
|
---|
[2] | 480 |
|
---|
[1157] | 481 | eap->current = NULL;
|
---|
| 482 | if (eap->head) {
|
---|
| 483 | WinSetDlgItemText(hwnd, EA_TEXT, NullStr);
|
---|
| 484 | WinShowWindow(WinWindowFromID(hwnd, EA_ENTRY), FALSE);
|
---|
| 485 | WinSetDlgItemText(hwnd, EA_ENTRY, NullStr);
|
---|
| 486 | MLEclearall(WinWindowFromID(hwnd, EA_MLE));
|
---|
| 487 | WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE);
|
---|
| 488 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE);
|
---|
| 489 | WinShowWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE);
|
---|
| 490 | WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), FALSE);
|
---|
| 491 | WinSendDlgItemMsg(hwnd, EA_HEXDUMP, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 492 | *s = 0;
|
---|
| 493 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd, EA_LISTBOX,
|
---|
| 494 | LM_QUERYSELECTION,
|
---|
| 495 | MPFROMSHORT(LIT_FIRST),
|
---|
| 496 | MPVOID);
|
---|
| 497 | if (sSelect >= 0) {
|
---|
| 498 | WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_QUERYITEMTEXT,
|
---|
| 499 | MPFROM2SHORT(sSelect, 1024), MPFROMP(s));
|
---|
| 500 | if (*s) {
|
---|
[2] | 501 |
|
---|
[1157] | 502 | USHORT len, num, type;
|
---|
| 503 | CHAR *data;
|
---|
| 504 | CHAR last = '\n';
|
---|
| 505 | const CHAR *linefeed = "\n";
|
---|
| 506 | BOOL alltext;
|
---|
| 507 | IPT pos = 0;
|
---|
[2] | 508 |
|
---|
[1157] | 509 | info = eap->head;
|
---|
| 510 | while (info) {
|
---|
| 511 | if (!strcmp(s, info->name)) {
|
---|
| 512 | eap->current = info;
|
---|
| 513 | WinShowWindow(WinWindowFromID(hwnd, EA_DELETE), TRUE);
|
---|
| 514 | switch (*(USHORT *) info->value) {
|
---|
| 515 | case EAT_EA:
|
---|
| 516 | case EAT_ASCII:
|
---|
| 517 | if (!strcmp(info->name, SUBJECT))
|
---|
| 518 | WinSendDlgItemMsg(hwnd, EA_ENTRY,
|
---|
| 519 | EM_SETTEXTLIMIT,
|
---|
| 520 | MPFROM2SHORT(1024, 0), MPVOID);
|
---|
| 521 | else
|
---|
| 522 | WinSendDlgItemMsg(hwnd, EA_ENTRY,
|
---|
| 523 | EM_SETTEXTLIMIT,
|
---|
| 524 | MPFROM2SHORT(1024, 0), MPVOID);
|
---|
| 525 | WinSetDlgItemText(hwnd, EA_ENTRY,
|
---|
| 526 | info->value + (sizeof(USHORT) * 2));
|
---|
| 527 | WinShowWindow(WinWindowFromID(hwnd, EA_ENTRY), TRUE);
|
---|
| 528 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE),
|
---|
| 529 | FALSE);
|
---|
| 530 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE);
|
---|
| 531 | {
|
---|
| 532 | CHAR str[81];
|
---|
[2] | 533 |
|
---|
[1157] | 534 | sprintf(str,
|
---|
| 535 | GetPString(IDS_DATAANDBYTESTEXT),
|
---|
| 536 | (*(USHORT *) info->value == EAT_ASCII) ?
|
---|
| 537 | GetPString(IDS_TEXTTEXT) :
|
---|
| 538 | GetPString(IDS_EAREFTEXT), info->cbValue);
|
---|
| 539 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 540 | }
|
---|
| 541 | break;
|
---|
| 542 | case EAT_MVST:
|
---|
| 543 | MLEclearall(WinWindowFromID(hwnd, EA_MLE));
|
---|
| 544 | num = *(USHORT *) (info->value + (sizeof(USHORT) * 2));
|
---|
| 545 | type = *(USHORT *) (info->value + (sizeof(USHORT) * 3));
|
---|
| 546 | if (type == EAT_ASCII) {
|
---|
| 547 | data = info->value + (sizeof(USHORT) * 4);
|
---|
| 548 | len = *(USHORT *) data;
|
---|
| 549 | data += sizeof(USHORT);
|
---|
| 550 | while ((data - info->value) + len <= info->cbValue) {
|
---|
| 551 | if (last != '\n') {
|
---|
| 552 | WinSendDlgItemMsg(hwnd,
|
---|
| 553 | EA_MLE,
|
---|
| 554 | MLM_SETIMPORTEXPORT,
|
---|
| 555 | MPFROMP(linefeed),
|
---|
| 556 | MPFROMLONG(1));
|
---|
| 557 | WinSendDlgItemMsg(hwnd,
|
---|
| 558 | EA_MLE,
|
---|
| 559 | MLM_IMPORT,
|
---|
| 560 | MPFROMP(&pos), MPFROMLONG(1));
|
---|
| 561 | }
|
---|
| 562 | WinSendDlgItemMsg(hwnd,
|
---|
| 563 | EA_MLE,
|
---|
| 564 | MLM_SETIMPORTEXPORT,
|
---|
| 565 | MPFROMP(data),
|
---|
| 566 | MPFROMLONG((ULONG) len));
|
---|
| 567 | WinSendDlgItemMsg(hwnd,
|
---|
| 568 | EA_MLE,
|
---|
| 569 | MLM_IMPORT,
|
---|
| 570 | MPFROMP(&pos),
|
---|
| 571 | MPFROMLONG((ULONG) len));
|
---|
| 572 | data += len;
|
---|
| 573 | last = *(data - 1);
|
---|
| 574 | if (data - info->value >= info->cbValue)
|
---|
| 575 | break;
|
---|
| 576 | len = *(USHORT *) data;
|
---|
| 577 | data += sizeof(USHORT);
|
---|
| 578 | }
|
---|
| 579 | WinShowWindow(WinWindowFromID(hwnd, EA_MLE), TRUE);
|
---|
| 580 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE),
|
---|
| 581 | FALSE);
|
---|
| 582 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE);
|
---|
| 583 | }
|
---|
| 584 | else {
|
---|
| 585 | WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE);
|
---|
| 586 | HexDumpEA(hwnd, info);
|
---|
| 587 | WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP),
|
---|
| 588 | TRUE);
|
---|
| 589 | }
|
---|
| 590 | {
|
---|
| 591 | CHAR str[81];
|
---|
[2] | 592 |
|
---|
[1157] | 593 | sprintf(str,
|
---|
| 594 | GetPString(IDS_MVSTTEXT),
|
---|
| 595 | num,
|
---|
| 596 | (num == 1) ?
|
---|
| 597 | GetPString(IDS_YTEXT) :
|
---|
| 598 | GetPString(IDS_IESTEXT), info->cbValue);
|
---|
| 599 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 600 | }
|
---|
| 601 | break;
|
---|
| 602 | case EAT_MVMT:
|
---|
| 603 | MLEclearall(WinWindowFromID(hwnd, EA_MLE));
|
---|
| 604 | num = *(USHORT *) (info->value + (sizeof(USHORT) * 2));
|
---|
| 605 | data = info->value + (sizeof(USHORT) * 3);
|
---|
| 606 | type = *(USHORT *) data;
|
---|
| 607 | data += sizeof(USHORT);
|
---|
| 608 | len = *(USHORT *) data;
|
---|
| 609 | data += sizeof(USHORT);
|
---|
| 610 | alltext = TRUE;
|
---|
| 611 | while ((data - info->value) - len <= info->cbValue) {
|
---|
| 612 | if (type != EAT_ASCII) {
|
---|
| 613 | alltext = FALSE;
|
---|
| 614 | break;
|
---|
| 615 | }
|
---|
| 616 | data += len;
|
---|
| 617 | if (data - info->value >= info->cbValue)
|
---|
| 618 | break;
|
---|
| 619 | type = *(USHORT *) data;
|
---|
| 620 | data += sizeof(USHORT);
|
---|
| 621 | len = *(USHORT *) data;
|
---|
| 622 | data += sizeof(USHORT);
|
---|
| 623 | }
|
---|
| 624 | if (alltext) {
|
---|
| 625 | data = info->value + (sizeof(USHORT) * 3);
|
---|
| 626 | type = *(USHORT *) data;
|
---|
| 627 | data += sizeof(USHORT);
|
---|
| 628 | len = *(USHORT *) data;
|
---|
| 629 | data += sizeof(USHORT);
|
---|
| 630 | while ((data - info->value) - len <= info->cbValue) {
|
---|
| 631 | if (last != '\n') {
|
---|
| 632 | WinSendDlgItemMsg(hwnd,
|
---|
| 633 | EA_MLE,
|
---|
| 634 | MLM_SETIMPORTEXPORT,
|
---|
| 635 | MPFROMP(linefeed),
|
---|
| 636 | MPFROMLONG(1));
|
---|
| 637 | WinSendDlgItemMsg(hwnd,
|
---|
| 638 | EA_MLE,
|
---|
| 639 | MLM_IMPORT,
|
---|
| 640 | MPFROMP(&pos), MPFROMLONG(1));
|
---|
| 641 | }
|
---|
| 642 | WinSendDlgItemMsg(hwnd,
|
---|
| 643 | EA_MLE,
|
---|
| 644 | MLM_SETIMPORTEXPORT,
|
---|
| 645 | MPFROMP(data),
|
---|
| 646 | MPFROMLONG((ULONG) len));
|
---|
| 647 | WinSendDlgItemMsg(hwnd,
|
---|
| 648 | EA_MLE,
|
---|
| 649 | MLM_IMPORT,
|
---|
| 650 | MPFROMP(&pos),
|
---|
| 651 | MPFROMLONG((ULONG) len));
|
---|
| 652 | data += len;
|
---|
| 653 | last = *(data - 1);
|
---|
| 654 | if (data - info->value >= info->cbValue)
|
---|
| 655 | break;
|
---|
| 656 | type = *(USHORT *) data;
|
---|
| 657 | data += sizeof(USHORT);
|
---|
| 658 | len = *(USHORT *) data;
|
---|
| 659 | data += sizeof(USHORT);
|
---|
| 660 | }
|
---|
| 661 | }
|
---|
| 662 | if (alltext) {
|
---|
| 663 | WinShowWindow(WinWindowFromID(hwnd, EA_MLE), TRUE);
|
---|
| 664 | WinEnableWindow(WinWindowFromID(hwnd,
|
---|
| 665 | EA_CHANGE), FALSE);
|
---|
| 666 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE);
|
---|
| 667 | }
|
---|
| 668 | else {
|
---|
| 669 | WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE);
|
---|
| 670 | HexDumpEA(hwnd, info);
|
---|
| 671 | WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP),
|
---|
| 672 | TRUE);
|
---|
| 673 | }
|
---|
| 674 | {
|
---|
| 675 | CHAR str[81];
|
---|
[2] | 676 |
|
---|
[1157] | 677 | sprintf(str,
|
---|
| 678 | GetPString(IDS_MVMTTEXT),
|
---|
| 679 | num,
|
---|
| 680 | (num == 1) ?
|
---|
| 681 | GetPString(IDS_YTEXT) :
|
---|
| 682 | GetPString(IDS_IESTEXT),
|
---|
| 683 | info->cbValue,
|
---|
| 684 | (alltext) ?
|
---|
| 685 | GetPString(IDS_ALLTEXTTEXT) :
|
---|
| 686 | GetPString(IDS_MIXEDTYPESTEXT));
|
---|
| 687 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 688 | }
|
---|
| 689 | break;
|
---|
| 690 | default:
|
---|
| 691 | HexDumpEA(hwnd, info);
|
---|
| 692 | WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), TRUE);
|
---|
| 693 | switch (*(USHORT *) info->value) {
|
---|
| 694 | case EAT_BINARY:
|
---|
| 695 | {
|
---|
| 696 | CHAR str[81];
|
---|
[2] | 697 |
|
---|
[1157] | 698 | sprintf(str,
|
---|
| 699 | GetPString(IDS_BINARYBYTESTEXT),
|
---|
| 700 | info->cbValue);
|
---|
| 701 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 702 | }
|
---|
| 703 | break;
|
---|
| 704 | case EAT_BITMAP:
|
---|
| 705 | {
|
---|
| 706 | CHAR str[81];
|
---|
[2] | 707 |
|
---|
[1157] | 708 | sprintf(str,
|
---|
| 709 | GetPString(IDS_BITMAPBYTESTEXT),
|
---|
| 710 | info->cbValue);
|
---|
| 711 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 712 | }
|
---|
| 713 | break;
|
---|
| 714 | case EAT_METAFILE:
|
---|
| 715 | {
|
---|
| 716 | CHAR str[81];
|
---|
[2] | 717 |
|
---|
[1157] | 718 | sprintf(str,
|
---|
| 719 | GetPString(IDS_METAFILEBYTESTEXT),
|
---|
| 720 | info->cbValue);
|
---|
| 721 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 722 | }
|
---|
| 723 | break;
|
---|
| 724 | case EAT_ICON:
|
---|
| 725 | {
|
---|
| 726 | CHAR str[81];
|
---|
[2] | 727 |
|
---|
[1157] | 728 | sprintf(str,
|
---|
| 729 | GetPString(IDS_ICONBYTESTEXT),
|
---|
| 730 | info->cbValue);
|
---|
| 731 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 732 | }
|
---|
| 733 | break;
|
---|
| 734 | case EAT_ASN1:
|
---|
| 735 | {
|
---|
| 736 | CHAR str[81];
|
---|
[2] | 737 |
|
---|
[1157] | 738 | sprintf(str,
|
---|
| 739 | GetPString(IDS_ASN1BYTESTEXT),
|
---|
| 740 | info->cbValue);
|
---|
| 741 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 742 | }
|
---|
| 743 | break;
|
---|
| 744 | default:
|
---|
| 745 | {
|
---|
| 746 | CHAR str[81];
|
---|
[2] | 747 |
|
---|
[1157] | 748 | sprintf(str,
|
---|
| 749 | GetPString(IDS_UNKNOWNBYTESTEXT),
|
---|
| 750 | *(USHORT *) info->value, info->cbValue);
|
---|
| 751 | WinSetDlgItemText(hwnd, EA_TEXT, str);
|
---|
| 752 | }
|
---|
| 753 | break;
|
---|
| 754 | }
|
---|
| 755 | break;
|
---|
| 756 | }
|
---|
| 757 | }
|
---|
| 758 | info = info->next;
|
---|
| 759 | }
|
---|
| 760 | }
|
---|
| 761 | }
|
---|
| 762 | }
|
---|
| 763 | if (!isalpha(*eap->filename) ||
|
---|
| 764 | (driveflags[toupper(*eap->filename) - 'A'] &
|
---|
| 765 | DRIVE_NOTWRITEABLE)) {
|
---|
| 766 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE);
|
---|
| 767 | WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), FALSE);
|
---|
| 768 | WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE);
|
---|
| 769 | }
|
---|
| 770 | else {
|
---|
| 771 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE);
|
---|
| 772 | WinEnableWindow(WinWindowFromID(hwnd, EA_ADD), TRUE);
|
---|
| 773 | WinEnableWindow(WinWindowFromID(hwnd, EA_DELETE), TRUE);
|
---|
| 774 | }
|
---|
| 775 | }
|
---|
| 776 | break;
|
---|
[193] | 777 | }
|
---|
| 778 | break;
|
---|
[2] | 779 |
|
---|
[193] | 780 | case EA_ENTRY:
|
---|
[551] | 781 | switch (SHORT2FROMMP(mp1)) {
|
---|
[193] | 782 | case EN_SETFOCUS:
|
---|
[1157] | 783 | WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EADATAHELPTEXT));
|
---|
| 784 | break;
|
---|
[193] | 785 | case EN_KILLFOCUS:
|
---|
[1157] | 786 | WinSetDlgItemText(hwnd, EA_HELP, NullStr);
|
---|
| 787 | break;
|
---|
[193] | 788 | case EN_CHANGE:
|
---|
[1157] | 789 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE);
|
---|
| 790 | break;
|
---|
[193] | 791 | }
|
---|
| 792 | break;
|
---|
[2] | 793 |
|
---|
[193] | 794 | case EA_HEXDUMP:
|
---|
[551] | 795 | switch (SHORT2FROMMP(mp1)) {
|
---|
[193] | 796 | case LN_SETFOCUS:
|
---|
[1157] | 797 | WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EADATAHELPTEXT));
|
---|
| 798 | break;
|
---|
[193] | 799 | case LN_KILLFOCUS:
|
---|
[1157] | 800 | WinSetDlgItemText(hwnd, EA_HELP, NullStr);
|
---|
| 801 | break;
|
---|
[193] | 802 | }
|
---|
| 803 | break;
|
---|
[2] | 804 |
|
---|
[193] | 805 | case EA_MLE:
|
---|
[551] | 806 | switch (SHORT2FROMMP(mp1)) {
|
---|
[193] | 807 | case MLN_SETFOCUS:
|
---|
[1157] | 808 | WinSetDlgItemText(hwnd, EA_HELP, GetPString(IDS_EADATAHELPTEXT));
|
---|
| 809 | break;
|
---|
[193] | 810 | case MLN_KILLFOCUS:
|
---|
[1157] | 811 | WinSetDlgItemText(hwnd, EA_HELP, NullStr);
|
---|
| 812 | break;
|
---|
[193] | 813 | case MLN_CHANGE:
|
---|
[1157] | 814 | WinEnableWindow(WinWindowFromID(hwnd, EA_CHANGE), TRUE);
|
---|
| 815 | break;
|
---|
[193] | 816 | }
|
---|
| 817 | break;
|
---|
| 818 | }
|
---|
| 819 | return 0;
|
---|
[2] | 820 |
|
---|
[193] | 821 | case WM_COMMAND:
|
---|
[551] | 822 | switch (SHORT1FROMMP(mp1)) {
|
---|
[193] | 823 | case EA_ADD:
|
---|
| 824 | {
|
---|
[1157] | 825 | ADDEA add;
|
---|
[2] | 826 |
|
---|
[1157] | 827 | add.filename = eap->filename;
|
---|
| 828 | add.head = eap->head;
|
---|
| 829 | if (WinDlgBox(HWND_DESKTOP, hwnd, AddEAProc, FM3ModHandle,
|
---|
| 830 | EAC_FRAME, &add)) {
|
---|
| 831 | Free_FEAList(eap->head);
|
---|
| 832 | eap->head = GetFileEAs(eap->filename, FALSE, FALSE);
|
---|
| 833 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 834 | }
|
---|
[2] | 835 | }
|
---|
[193] | 836 | break;
|
---|
| 837 | case EA_CHANGE:
|
---|
[551] | 838 | if (!eap->current)
|
---|
[1157] | 839 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE);
|
---|
[551] | 840 | else {
|
---|
[2] | 841 |
|
---|
[1157] | 842 | CHAR *s;
|
---|
| 843 | USHORT control;
|
---|
[2] | 844 |
|
---|
[1157] | 845 | if (!eap->head || !*eap->filename)
|
---|
| 846 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 847 | else {
|
---|
| 848 | switch (*(USHORT *) eap->current->value) {
|
---|
| 849 | case EAT_EA:
|
---|
| 850 | case EAT_ASCII:
|
---|
| 851 | control = EA_ENTRY;
|
---|
| 852 | break;
|
---|
| 853 | case EAT_MVMT:
|
---|
| 854 | control = EA_MLE;
|
---|
| 855 | break;
|
---|
| 856 | case EAT_MVST:
|
---|
| 857 | control = EA_MLE;
|
---|
| 858 | break;
|
---|
| 859 | default:
|
---|
| 860 | Runtime_Error(pszSrcFile, __LINE__, "unexpected type");
|
---|
| 861 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE);
|
---|
| 862 | control = 0;
|
---|
| 863 | }
|
---|
| 864 | if (control) {
|
---|
| 865 | s = xmalloc(32768, pszSrcFile, __LINE__);
|
---|
| 866 | if (s) {
|
---|
| 867 | *s = 0;
|
---|
| 868 | WinQueryDlgItemText(hwnd, control, 32767, (PCH) s);
|
---|
| 869 | if (!*s)
|
---|
| 870 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 871 | else {
|
---|
| 872 | PFEA2LIST pfealist;
|
---|
[2] | 873 |
|
---|
[1157] | 874 | pfealist = SaveEA(eap->filename, eap->current, s, FALSE);
|
---|
| 875 | if (!pfealist)
|
---|
| 876 | Runtime_Error(pszSrcFile, __LINE__, "SaveEA");
|
---|
| 877 | else {
|
---|
| 878 | PFEA2 pfea;
|
---|
[2] | 879 |
|
---|
[1157] | 880 | pfea = xmalloc(pfealist->cbList, pszSrcFile, __LINE__);
|
---|
| 881 | if (pfea) {
|
---|
| 882 | memcpy(pfea, pfealist->list,
|
---|
| 883 | pfealist->cbList - sizeof(ULONG));
|
---|
| 884 | free(eap->current->pfea);
|
---|
| 885 | eap->current->pfea = pfea;
|
---|
| 886 | eap->current->name = eap->current->pfea->szName;
|
---|
| 887 | eap->current->cbName = eap->current->pfea->cbName;
|
---|
| 888 | eap->current->cbValue = eap->current->pfea->cbValue;
|
---|
| 889 | eap->current->value = eap->current->pfea->szName +
|
---|
| 890 | eap->current->pfea->cbName + 1;
|
---|
| 891 | eap->current->value[eap->current->cbValue] = 0;
|
---|
| 892 | PostMsg(hwnd, WM_CONTROL,
|
---|
| 893 | MPFROM2SHORT(EA_LISTBOX, LN_SELECT), MPVOID);
|
---|
| 894 | }
|
---|
| 895 | DosFreeMem(pfealist);
|
---|
| 896 | }
|
---|
| 897 | }
|
---|
| 898 | free(s);
|
---|
| 899 | }
|
---|
| 900 | }
|
---|
| 901 | }
|
---|
[193] | 902 | }
|
---|
| 903 | break;
|
---|
[2] | 904 |
|
---|
[193] | 905 | case EA_DELETE:
|
---|
[551] | 906 | if (eap->head && eap->current) {
|
---|
[2] | 907 |
|
---|
[1157] | 908 | EAOP2 eaop;
|
---|
| 909 | PFEA2LIST pfealist;
|
---|
| 910 | GEA2LIST gealist;
|
---|
| 911 | APIRET rc;
|
---|
| 912 | SHORT sSelect;
|
---|
[2] | 913 |
|
---|
[1157] | 914 | pfealist =
|
---|
| 915 | xmallocz(sizeof(FEA2LIST) + eap->current->cbName + 1, pszSrcFile,
|
---|
| 916 | __LINE__);
|
---|
| 917 | if (pfealist) {
|
---|
| 918 | pfealist->cbList = sizeof(FEA2LIST) + eap->current->cbName + 1;
|
---|
| 919 | pfealist->list[0].cbName = eap->current->cbName;
|
---|
| 920 | strcpy(pfealist->list[0].szName, eap->current->name);
|
---|
| 921 | pfealist->list[0].cbValue = 0;
|
---|
| 922 | memset(&gealist, 0, sizeof(GEA2LIST));
|
---|
| 923 | gealist.cbList = sizeof(GEA2LIST);
|
---|
| 924 | eaop.fpGEA2List = &gealist;
|
---|
| 925 | eaop.fpFEA2List = pfealist;
|
---|
| 926 | eaop.oError = 0;
|
---|
| 927 | rc = xDosSetPathInfo(eap->filename, FIL_QUERYEASIZE,
|
---|
| 928 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
| 929 | free(pfealist);
|
---|
| 930 | if (rc)
|
---|
| 931 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
| 932 | "xDosSetPathInfo");
|
---|
| 933 | else {
|
---|
| 934 | sSelect = 0;
|
---|
| 935 | if (eap->current == eap->head) {
|
---|
| 936 | eap->head = eap->head->next;
|
---|
| 937 | free(eap->current->pfea);
|
---|
| 938 | free(eap->current);
|
---|
| 939 | eap->current = NULL;
|
---|
| 940 | }
|
---|
| 941 | else {
|
---|
| 942 | info = eap->head;
|
---|
| 943 | while (info) {
|
---|
| 944 | if (info->next == eap->current) {
|
---|
| 945 | sSelect++;
|
---|
| 946 | info->next = eap->current->next;
|
---|
| 947 | free(eap->current->pfea);
|
---|
| 948 | free(eap->current);
|
---|
| 949 | eap->current = NULL;
|
---|
| 950 | break;
|
---|
| 951 | }
|
---|
| 952 | sSelect++;
|
---|
| 953 | info = info->next;
|
---|
| 954 | }
|
---|
| 955 | }
|
---|
| 956 | WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_DELETEITEM,
|
---|
| 957 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
| 958 | WinShowWindow(WinWindowFromID(hwnd, EA_ENTRY), FALSE);
|
---|
| 959 | WinShowWindow(WinWindowFromID(hwnd, EA_MLE), FALSE);
|
---|
| 960 | WinShowWindow(WinWindowFromID(hwnd, EA_CHANGE), FALSE);
|
---|
| 961 | WinShowWindow(WinWindowFromID(hwnd, EA_DELETE), FALSE);
|
---|
| 962 | WinShowWindow(WinWindowFromID(hwnd, EA_HEXDUMP), FALSE);
|
---|
| 963 | WinSetDlgItemText(hwnd, EA_ENTRY, NullStr);
|
---|
| 964 | MLEclearall(WinWindowFromID(hwnd, EA_MLE));
|
---|
| 965 | WinSendDlgItemMsg(hwnd, EA_HEXDUMP, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 966 | if (sSelect && (SHORT) WinSendDlgItemMsg(hwnd, EA_LISTBOX,
|
---|
| 967 | LM_QUERYITEMCOUNT,
|
---|
| 968 | MPVOID, MPVOID) <=
|
---|
| 969 | sSelect)
|
---|
| 970 | sSelect--;
|
---|
| 971 | WinSendDlgItemMsg(hwnd, EA_LISTBOX, LM_SELECTITEM,
|
---|
| 972 | MPFROM2SHORT(sSelect, 0),
|
---|
| 973 | MPFROM2SHORT(TRUE, 0));
|
---|
| 974 | }
|
---|
| 975 | }
|
---|
[193] | 976 | }
|
---|
[551] | 977 | if (!eap->head)
|
---|
[1157] | 978 | WinSetDlgItemText(hwnd, EA_TEXT, GetPString(IDS_EANOEAS));
|
---|
[193] | 979 | break;
|
---|
[2] | 980 |
|
---|
[193] | 981 | case IDM_HELP:
|
---|
| 982 | if (hwndHelp)
|
---|
[1157] | 983 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 984 | MPFROM2SHORT(HELP_EAS, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
[193] | 985 | break;
|
---|
[2] | 986 |
|
---|
[193] | 987 | case DID_OK:
|
---|
| 988 | WinDismissDlg(hwnd, 1);
|
---|
| 989 | break;
|
---|
[2] | 990 |
|
---|
[193] | 991 | case DID_CANCEL:
|
---|
| 992 | WinDismissDlg(hwnd, 0);
|
---|
| 993 | break;
|
---|
| 994 | }
|
---|
| 995 | return 0;
|
---|
[2] | 996 |
|
---|
[193] | 997 | case WM_CLOSE:
|
---|
| 998 | break;
|
---|
[2] | 999 |
|
---|
[193] | 1000 | case WM_DESTROY:
|
---|
[551] | 1001 | if (eap) {
|
---|
| 1002 | if (eap->head)
|
---|
[1157] | 1003 | Free_FEAList(eap->head);
|
---|
[1039] | 1004 | free(eap);
|
---|
[193] | 1005 | if (hptrIcon)
|
---|
[1157] | 1006 | WinDestroyPointer(hptrIcon);
|
---|
[193] | 1007 | hptrIcon = (HPOINTER) 0;
|
---|
| 1008 | }
|
---|
| 1009 | break;
|
---|
[1157] | 1010 | } // switch
|
---|
[193] | 1011 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1012 | }
|
---|
| 1013 |
|
---|
[193] | 1014 | PVOID SaveEA(CHAR * filename, HOLDFEA * current, CHAR * newdata,
|
---|
[1157] | 1015 | BOOL silentfail)
|
---|
[193] | 1016 | {
|
---|
[2] | 1017 | /* save an ea to disk */
|
---|
| 1018 |
|
---|
| 1019 | PFEA2LIST pfealist = NULL;
|
---|
[193] | 1020 | EAOP2 eaop;
|
---|
| 1021 | APIRET rc;
|
---|
| 1022 | ULONG ealen;
|
---|
| 1023 | USHORT len, *num, *plen;
|
---|
| 1024 | CHAR *p, *eaval;
|
---|
[2] | 1025 |
|
---|
[193] | 1026 | if (!filename || !current)
|
---|
| 1027 | return (PVOID) pfealist;
|
---|
[2] | 1028 | len = strlen(newdata);
|
---|
[725] | 1029 | ealen = sizeof(FEA2LIST) + 24 + (ULONG) current->cbName + 1 +
|
---|
[1157] | 1030 | (ULONG)len + 4;
|
---|
[551] | 1031 | switch (*(USHORT *) current->value) {
|
---|
[193] | 1032 | case EAT_EA:
|
---|
| 1033 | case EAT_ASCII:
|
---|
| 1034 | break;
|
---|
| 1035 | case EAT_MVST:
|
---|
| 1036 | ealen += sizeof(USHORT) * 5;
|
---|
| 1037 | p = newdata;
|
---|
| 1038 | while (*p == '\n')
|
---|
| 1039 | p++;
|
---|
[551] | 1040 | while (*p) {
|
---|
[193] | 1041 | if (*p == '\n' && *(p + 1))
|
---|
[1157] | 1042 | ealen += sizeof(USHORT);
|
---|
[193] | 1043 | p++;
|
---|
| 1044 | }
|
---|
| 1045 | break;
|
---|
| 1046 | case EAT_MVMT:
|
---|
| 1047 | ealen += sizeof(USHORT) * 5;
|
---|
| 1048 | p = newdata;
|
---|
| 1049 | while (*p == '\n')
|
---|
| 1050 | p++;
|
---|
[551] | 1051 | while (*p) {
|
---|
[193] | 1052 | if (*p == '\n' && *(p + 1))
|
---|
[1157] | 1053 | ealen += (sizeof(USHORT) * 2);
|
---|
[193] | 1054 | p++;
|
---|
| 1055 | }
|
---|
| 1056 | break;
|
---|
| 1057 | default:
|
---|
| 1058 | return (PVOID) pfealist;
|
---|
| 1059 | }
|
---|
| 1060 |
|
---|
[347] | 1061 | rc = DosAllocMem((PPVOID) & pfealist, ealen,
|
---|
[1157] | 1062 | OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
|
---|
[347] | 1063 | if (rc)
|
---|
[551] | 1064 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
[1157] | 1065 | GetPString(IDS_OUTOFMEMORY));
|
---|
[551] | 1066 | else {
|
---|
[193] | 1067 | memset(pfealist, 0, ealen);
|
---|
[725] | 1068 | pfealist->list[0].oNextEntryOffset = 0;
|
---|
[1157] | 1069 | pfealist->list[0].fEA = 0; //current->fEA;
|
---|
[193] | 1070 |
|
---|
[551] | 1071 | pfealist->list[0].cbName = current->cbName;
|
---|
| 1072 | memcpy(pfealist->list[0].szName, current->name,
|
---|
[1157] | 1073 | pfealist->list[0].cbName + 1);
|
---|
[551] | 1074 | eaval = pfealist->list[0].szName + pfealist->list[0].cbName + 1;
|
---|
| 1075 | switch (*(USHORT *) current->value) {
|
---|
[2] | 1076 | case EAT_EA:
|
---|
| 1077 | case EAT_ASCII:
|
---|
[551] | 1078 | *(USHORT *) eaval = *(USHORT *) current->value;
|
---|
[193] | 1079 | eaval += sizeof(USHORT);
|
---|
| 1080 | *(USHORT *) eaval = (USHORT) len;
|
---|
| 1081 | eaval += sizeof(USHORT);
|
---|
| 1082 | memcpy(eaval, newdata, len);
|
---|
| 1083 | eaval += len;
|
---|
[2] | 1084 | break;
|
---|
| 1085 | case EAT_MVST:
|
---|
[193] | 1086 | *(USHORT *) eaval = (USHORT) EAT_MVST;
|
---|
| 1087 | eaval += sizeof(USHORT);
|
---|
[551] | 1088 | *(USHORT *) eaval = *(USHORT *) (current->value + sizeof(USHORT));
|
---|
[193] | 1089 | eaval += sizeof(USHORT);
|
---|
| 1090 | num = (USHORT *) eaval;
|
---|
| 1091 | *num = 0;
|
---|
| 1092 | eaval += sizeof(USHORT);
|
---|
| 1093 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 1094 | eaval += sizeof(USHORT);
|
---|
| 1095 | plen = (USHORT *) eaval;
|
---|
| 1096 | *plen = 0;
|
---|
| 1097 | eaval += sizeof(USHORT);
|
---|
[2] | 1098 | p = newdata;
|
---|
[193] | 1099 | while (*p == '\n')
|
---|
[1157] | 1100 | p++;
|
---|
[551] | 1101 | while (*p) {
|
---|
[1157] | 1102 | while (*p) {
|
---|
| 1103 | if (*p == '\n')
|
---|
| 1104 | p++;
|
---|
| 1105 | *eaval++ = *p++;
|
---|
| 1106 | (*plen)++;
|
---|
| 1107 | }
|
---|
| 1108 | if (*p || *plen)
|
---|
| 1109 | (*num)++;
|
---|
| 1110 | if (*p) {
|
---|
| 1111 | plen = (USHORT *) eaval;
|
---|
| 1112 | *plen = 0;
|
---|
| 1113 | eaval += sizeof(USHORT);
|
---|
| 1114 | }
|
---|
[2] | 1115 | }
|
---|
| 1116 | break;
|
---|
[193] | 1117 | /*
|
---|
| 1118 | cbList nextoffset fea cb cbval name.......
|
---|
| 1119 | 000000 3C 00 00 00 00 00 00 00 6F 0B 24 00 2E 4B 45 59 < o |
---|
| 1120 | $ .KEY
|
---|
| 1121 | .................... eat code num eat
|
---|
| 1122 | 000010 50 48 52 41 53 45 53 00 DF FF 00 00 02 00 FD FF PHRASES ßÿ ýÿ
|
---|
| 1123 | len.. phrase1............................ eat
|
---|
| 1124 | 000020 0C 00 4B 65 79 20 70 68 72 61 73 65 20 31 FD FF |
---|
| 1125 | Key phrase 1ýÿ
|
---|
| 1126 | len.. phrase2......................
|
---|
[2] | 1127 | 000030 0A 00 4B 65 79 20 70 68 72 61 73 65 Key phrase
|
---|
[193] | 1128 | */
|
---|
| 1129 | case EAT_MVMT:
|
---|
[551] | 1130 | *(USHORT *) eaval = (USHORT) EAT_MVMT;
|
---|
[193] | 1131 | eaval += sizeof(USHORT);
|
---|
| 1132 | *(USHORT *) eaval = *(USHORT *) (current->value + sizeof(USHORT));
|
---|
| 1133 | eaval += sizeof(USHORT);
|
---|
| 1134 | num = (USHORT *) eaval;
|
---|
| 1135 | *num = 0;
|
---|
| 1136 | eaval += sizeof(USHORT);
|
---|
| 1137 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 1138 | eaval += sizeof(USHORT);
|
---|
| 1139 | plen = (USHORT *) eaval;
|
---|
[2] | 1140 | *plen = 0;
|
---|
[193] | 1141 | eaval += sizeof(USHORT);
|
---|
[1157] | 1142 | p = newdata;
|
---|
[551] | 1143 | while (*p == '\n')
|
---|
[1157] | 1144 | p++;
|
---|
| 1145 | while (*p) {
|
---|
| 1146 | while (*p) {
|
---|
| 1147 | if (*p == '\n')
|
---|
| 1148 | p++;
|
---|
| 1149 | *eaval++ = *p++;
|
---|
| 1150 | (*plen)++;
|
---|
| 1151 | }
|
---|
| 1152 | if (*p || *plen)
|
---|
| 1153 | (*num)++;
|
---|
| 1154 | if (*p) {
|
---|
| 1155 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 1156 | eaval += sizeof(USHORT);
|
---|
| 1157 | plen = (USHORT *) eaval;
|
---|
| 1158 | *plen = 0;
|
---|
[2] | 1159 | eaval += sizeof(USHORT);
|
---|
| 1160 | }
|
---|
| 1161 | }
|
---|
[1029] | 1162 | break;
|
---|
[1157] | 1163 | }
|
---|
| 1164 | pfealist->list[0].cbValue = /*(ULONG)*/ (eaval -
|
---|
[193] | 1165 | (pfealist->list[0].szName +
|
---|
[2] | 1166 | pfealist->list[0].cbName + 1));
|
---|
[725] | 1167 | eaop.fpGEA2List = (PGEA2LIST) 0;
|
---|
| 1168 | eaop.fpFEA2List = pfealist;
|
---|
[1157] | 1169 | eaop.oError = 0;
|
---|
[2] | 1170 | pfealist->cbList = 13 + (ULONG) pfealist->list[0].cbName +
|
---|
[827] | 1171 | (ULONG)pfealist->list[0].cbValue;
|
---|
[1157] | 1172 |
|
---|
[551] | 1173 | rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
|
---|
[2] | 1174 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
| 1175 | if (rc) {
|
---|
| 1176 | DosFreeMem(pfealist);
|
---|
[551] | 1177 | pfealist = NULL;
|
---|
[347] | 1178 | }
|
---|
[1157] | 1179 | if (rc && !silentfail) {
|
---|
| 1180 | if (rc == ERROR_ACCESS_DENIED || rc == ERROR_SHARING_VIOLATION) {
|
---|
| 1181 | saymsg(MB_ENTER,
|
---|
| 1182 | HWND_DESKTOP,
|
---|
[347] | 1183 | GetPString(IDS_OOPSTEXT),
|
---|
| 1184 | GetPString(IDS_CANTWRITEEATEXT), current->name, filename);
|
---|
[1157] | 1185 | }
|
---|
| 1186 | else {
|
---|
| 1187 | Dos_Error(MB_ENTER,
|
---|
| 1188 | rc,
|
---|
| 1189 | HWND_DESKTOP,
|
---|
| 1190 | pszSrcFile,
|
---|
| 1191 | __LINE__,
|
---|
[347] | 1192 | GetPString(IDS_ERRORWRITEEATEXT),
|
---|
[2] | 1193 | current->name, filename, eaop.oError);
|
---|
| 1194 | }
|
---|
[193] | 1195 | }
|
---|
[2] | 1196 | }
|
---|
| 1197 | return (PVOID) pfealist;
|
---|
[193] | 1198 | }
|
---|
| 1199 |
|
---|
[2] | 1200 | HOLDFEA *GetFileEAs(CHAR * filename, BOOL ishandle, BOOL silentfail)
|
---|
| 1201 | {
|
---|
[193] | 1202 | /* load eas from disk into HOLDFEA linked list */
|
---|
[847] | 1203 |
|
---|
[193] | 1204 | HOLDFEA *head = NULL, *info, *last = NULL;
|
---|
| 1205 | FILESTATUS4 fsa4;
|
---|
| 1206 | HFILE handle;
|
---|
[2] | 1207 | ULONG action;
|
---|
[193] | 1208 | APIRET rc;
|
---|
[2] | 1209 |
|
---|
[844] | 1210 | if (!filename)
|
---|
[1157] | 1211 | return head;
|
---|
| 1212 | if (ishandle || !DosOpen(filename, &handle, &action, 0, 0,
|
---|
| 1213 | OPEN_ACTION_FAIL_IF_NEW |
|
---|
| 1214 | OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
| 1215 | OPEN_FLAGS_NOINHERIT |
|
---|
[193] | 1216 | OPEN_SHARE_DENYREADWRITE |
|
---|
| 1217 | OPEN_ACCESS_READWRITE, (PEAOP2)0)) {
|
---|
[847] | 1218 | if (ishandle)
|
---|
[1157] | 1219 | handle = *(HFILE *) filename;
|
---|
| 1220 | if (!DosQueryFileInfo(handle, FIL_QUERYEASIZE, (PVOID)&fsa4,
|
---|
[725] | 1221 | (ULONG) sizeof(fsa4)) &&
|
---|
[193] | 1222 | fsa4.cbList > 4)
|
---|
| 1223 | {
|
---|
[2] | 1224 | PDENA2 pdena;
|
---|
| 1225 | EAOP2 eaop;
|
---|
[193] | 1226 | PGEA2LIST pgealist;
|
---|
[1157] | 1227 | PFEA2LIST pfealist;
|
---|
| 1228 | PGEA2 pgea;
|
---|
[2] | 1229 | ULONG ulEntry = 1; // Ordinal of EA to return
|
---|
[551] | 1230 | ULONG ulCount = 1; // # of EAs to return
|
---|
| 1231 |
|
---|
[1157] | 1232 | pdena = xmalloc(65536 + 1024, pszSrcFile, __LINE__);
|
---|
| 1233 | if (pdena) {
|
---|
| 1234 | while (!DosEnumAttribute(ENUMEA_REFTYPE_FHANDLE,
|
---|
| 1235 | &handle,
|
---|
| 1236 | ulEntry,
|
---|
| 1237 | (PVOID)pdena,
|
---|
| 1238 | (ULONG)65536,
|
---|
| 1239 | &ulCount,
|
---|
| 1240 | ENUMEA_LEVEL_NO_VALUE) &&
|
---|
| 1241 | ulCount)
|
---|
| 1242 | {
|
---|
| 1243 | // 64 is for header and spare - fixme to allocate smarter
|
---|
| 1244 | pgealist = xmalloc(64 + pdena->cbName, pszSrcFile, __LINE__);
|
---|
| 1245 | if (pgealist) {
|
---|
| 1246 | pgealist->cbList = 64 + pdena->cbName;
|
---|
| 1247 | pgea = pgealist->list;
|
---|
| 1248 | pgea->oNextEntryOffset = 0;
|
---|
| 1249 | pgea->cbName = pdena->cbName;
|
---|
| 1250 | memcpy(pgea->szName, pdena->szName, pdena->cbName + 1);
|
---|
| 1251 | pfealist = xmallocz(64 + pdena->cbName + pdena->cbValue,
|
---|
| 1252 | pszSrcFile, __LINE__);
|
---|
| 1253 | if (pfealist) {
|
---|
| 1254 | pfealist->cbList = 64 + pdena->cbName + pdena->cbValue;
|
---|
| 1255 | eaop.fpGEA2List = pgealist;
|
---|
| 1256 | eaop.fpFEA2List = pfealist;
|
---|
| 1257 | eaop.oError = 0;
|
---|
| 1258 | // saymsg(MB_ENTER,HWND_DESKTOP,"Debug1","\"%s\" %ld",pdena->szName,ulEntry);
|
---|
| 1259 | rc =
|
---|
| 1260 | DosQueryFileInfo(handle, FIL_QUERYEASFROMLIST, (PVOID) & eaop,
|
---|
| 1261 | (ULONG) sizeof(EAOP2));
|
---|
| 1262 | if (rc) {
|
---|
| 1263 | if (!silentfail) {
|
---|
| 1264 | Dos_Error(MB_ENTER,
|
---|
| 1265 | rc,
|
---|
| 1266 | HWND_DESKTOP,
|
---|
| 1267 | pszSrcFile,
|
---|
| 1268 | __LINE__,
|
---|
| 1269 | GetPString(IDS_ERRORREADEATEXT), pdena->szName);
|
---|
| 1270 | }
|
---|
| 1271 | }
|
---|
| 1272 | else {
|
---|
| 1273 | info = xmalloc(sizeof(HOLDFEA), pszSrcFile, __LINE__);
|
---|
| 1274 | if (info) {
|
---|
| 1275 | // 05 Jul 07 SHL was one short
|
---|
| 1276 | info->pfea = xmalloc(eaop.fpFEA2List->cbList - sizeof(ULONG) + 1,
|
---|
| 1277 | pszSrcFile, __LINE__);
|
---|
| 1278 | memcpy(info->pfea, eaop.fpFEA2List->list,
|
---|
| 1279 | eaop.fpFEA2List->cbList - sizeof(ULONG));
|
---|
| 1280 | info->name = info->pfea->szName;
|
---|
| 1281 | info->cbName = info->pfea->cbName;
|
---|
| 1282 | info->cbValue = info->pfea->cbValue;
|
---|
| 1283 | info->value = info->pfea->szName + info->pfea->cbName + 1;
|
---|
| 1284 | info->value[info->cbValue] = 0;
|
---|
| 1285 | info->next = NULL;
|
---|
| 1286 | if (!head)
|
---|
| 1287 | head = info;
|
---|
| 1288 | else
|
---|
| 1289 | last->next = info;
|
---|
| 1290 | last = info;
|
---|
| 1291 | }
|
---|
| 1292 | }
|
---|
| 1293 | free(pfealist);
|
---|
| 1294 | }
|
---|
| 1295 | free(pgealist);
|
---|
| 1296 | }
|
---|
| 1297 | ulEntry += ulCount;
|
---|
| 1298 | } // while
|
---|
[2] | 1299 | free(pdena);
|
---|
| 1300 | DosPostEventSem(CompactSem);
|
---|
[193] | 1301 | }
|
---|
[2] | 1302 | }
|
---|
| 1303 | if (!ishandle)
|
---|
[551] | 1304 | DosClose(handle);
|
---|
[755] | 1305 | }
|
---|
| 1306 | else {
|
---|
[193] | 1307 | //Runtime_Error(pszSrcFile, __LINE__, "why here", filename);
|
---|
[847] | 1308 | //03 AUG 07 GKY This isn't an error it is for processing Readonly files
|
---|
[1157] | 1309 | /* try it without opening it */
|
---|
| 1310 | if (!DosQueryPathInfo(filename, FIL_QUERYEASIZE, (PVOID) & fsa4,
|
---|
[725] | 1311 | (ULONG) sizeof(fsa4)) &&
|
---|
[193] | 1312 | fsa4.cbList > 4)
|
---|
| 1313 | {
|
---|
[2] | 1314 | PDENA2 pdena;
|
---|
| 1315 | EAOP2 eaop;
|
---|
[193] | 1316 | PGEA2LIST pgealist;
|
---|
[725] | 1317 | PFEA2LIST pfealist;
|
---|
[2] | 1318 | PGEA2 pgea;
|
---|
[551] | 1319 | ULONG ulEntry = 1, ulCount = 1;
|
---|
| 1320 |
|
---|
[1157] | 1321 | pdena = xmalloc(65536 + 1024, pszSrcFile, __LINE__);
|
---|
| 1322 | if (pdena) {
|
---|
| 1323 | while (!DosEnumAttribute
|
---|
| 1324 | (ENUMEA_REFTYPE_PATH, filename, ulEntry, (PVOID) pdena,
|
---|
| 1325 | (ULONG) 65536, &ulCount, ENUMEA_LEVEL_NO_VALUE) && ulCount)
|
---|
| 1326 | {
|
---|
| 1327 | pgealist = xmalloc(64 + pdena->cbName, pszSrcFile, __LINE__);
|
---|
| 1328 | if (pgealist) {
|
---|
| 1329 | pgealist->cbList = 64 + pdena->cbName;
|
---|
| 1330 | pgea = pgealist->list;
|
---|
| 1331 | pgea->oNextEntryOffset = 0;
|
---|
| 1332 | pgea->cbName = pdena->cbName;
|
---|
| 1333 | memcpy(pgea->szName, pdena->szName, pdena->cbName + 1);
|
---|
| 1334 | pfealist =
|
---|
| 1335 | xmallocz(64 + pdena->cbName + pdena->cbValue, pszSrcFile,
|
---|
| 1336 | __LINE__);
|
---|
| 1337 | if (pfealist) {
|
---|
| 1338 | pfealist->cbList = 64 + pdena->cbName + pdena->cbValue;
|
---|
| 1339 | eaop.fpGEA2List = pgealist;
|
---|
| 1340 | eaop.fpFEA2List = pfealist;
|
---|
| 1341 | eaop.oError = 0;
|
---|
| 1342 | // saymsg(MB_ENTER,HWND_DESKTOP,"Debug2","\"%s\" %ld",pdena->szName,ulEntry);
|
---|
| 1343 | rc = DosQueryPathInfo(filename, FIL_QUERYEASFROMLIST,
|
---|
| 1344 | (PVOID) & eaop, (ULONG) sizeof(EAOP2));
|
---|
| 1345 | if (!rc) {
|
---|
[880] | 1346 | info = xmalloc(sizeof(HOLDFEA), pszSrcFile, __LINE__);
|
---|
[1157] | 1347 | if (info) {
|
---|
| 1348 | // 29 Nov 07 GKY One short (EA search crash)
|
---|
| 1349 | info->pfea =
|
---|
| 1350 | xmalloc(eaop.fpFEA2List->cbList - sizeof(ULONG) + 1,
|
---|
| 1351 | pszSrcFile, __LINE__);
|
---|
| 1352 | memcpy(info->pfea, eaop.fpFEA2List->list,
|
---|
| 1353 | eaop.fpFEA2List->cbList - sizeof(ULONG));
|
---|
| 1354 | info->name = info->pfea->szName;
|
---|
| 1355 | info->cbName = info->pfea->cbName;
|
---|
| 1356 | info->cbValue = info->pfea->cbValue;
|
---|
| 1357 | info->value = info->pfea->szName + info->pfea->cbName + 1;
|
---|
| 1358 | info->value[info->cbValue] = 0;
|
---|
| 1359 | info->next = NULL;
|
---|
| 1360 | if (!head)
|
---|
| 1361 | head = info;
|
---|
| 1362 | else
|
---|
| 1363 | last->next = info;
|
---|
| 1364 | last = info;
|
---|
| 1365 | }
|
---|
| 1366 | else
|
---|
| 1367 | free(pfealist);
|
---|
| 1368 | }
|
---|
| 1369 | else {
|
---|
| 1370 | free(pfealist);
|
---|
| 1371 | if (!silentfail) {
|
---|
| 1372 | if (rc == ERROR_ACCESS_DENIED
|
---|
| 1373 | || rc == ERROR_SHARING_VIOLATION) {
|
---|
| 1374 | rc =
|
---|
| 1375 | saymsg(MB_ENTER | MB_CANCEL, HWND_DESKTOP,
|
---|
| 1376 | GetPString(IDS_OOPSTEXT),
|
---|
| 1377 | GetPString(IDS_CANTREADEATEXT), filename,
|
---|
| 1378 | pdena->szName);
|
---|
| 1379 | if (rc == MBID_CANCEL) {
|
---|
| 1380 | free(pgealist);
|
---|
| 1381 | break;
|
---|
| 1382 | }
|
---|
| 1383 | }
|
---|
| 1384 | else {
|
---|
| 1385 | Dos_Error(MB_ENTER,
|
---|
| 1386 | rc,
|
---|
| 1387 | HWND_DESKTOP,
|
---|
| 1388 | pszSrcFile,
|
---|
| 1389 | __LINE__,
|
---|
| 1390 | GetPString(IDS_ERRORREADEATEXT), pdena->szName);
|
---|
| 1391 | }
|
---|
| 1392 | }
|
---|
| 1393 | }
|
---|
| 1394 | }
|
---|
| 1395 | free(pgealist);
|
---|
| 1396 | }
|
---|
| 1397 | ulEntry += ulCount;
|
---|
| 1398 | } // while
|
---|
[2] | 1399 | free(pdena);
|
---|
| 1400 | DosPostEventSem(CompactSem);
|
---|
| 1401 | }
|
---|
| 1402 | }
|
---|
| 1403 | }
|
---|
| 1404 | return head;
|
---|
[193] | 1405 | }
|
---|
| 1406 |
|
---|
[2] | 1407 | VOID Free_FEAList(HOLDFEA * pFEA)
|
---|
| 1408 | {
|
---|
| 1409 | /* free a linked list of HOLDFEAs */
|
---|
| 1410 |
|
---|
[551] | 1411 | register HOLDFEA *next;
|
---|
[193] | 1412 |
|
---|
[551] | 1413 | while (pFEA) {
|
---|
[1009] | 1414 | /* Free linked list */
|
---|
[1039] | 1415 | next = pFEA->next;
|
---|
[2] | 1416 | xfree(pFEA->pfea, pszSrcFile, __LINE__);
|
---|
| 1417 | free(pFEA);
|
---|
| 1418 | pFEA = next;
|
---|
| 1419 | }
|
---|
[795] | 1420 | DosPostEventSem(CompactSem);
|
---|
| 1421 | }
|
---|
| 1422 |
|
---|
| 1423 | #pragma alloc_text(EAS,DisplayEAsProc,SaveEA,HexDumpEA,CheckEA,AddEAProc)
|
---|
| 1424 | #pragma alloc_text(EAS1,HexDump,GetFileEAs,Free_FEAList)
|
---|
| 1425 |
|
---|