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