[2] | 1 | #define INCL_DOS
|
---|
| 2 | #define INCL_WIN
|
---|
| 3 |
|
---|
| 4 | #include <os2.h>
|
---|
| 5 | #include <stdio.h>
|
---|
| 6 | #include <stdlib.h>
|
---|
| 7 | #include <string.h>
|
---|
| 8 | #include <ctype.h>
|
---|
| 9 | #include <share.h>
|
---|
| 10 | #include "fm3dll.h"
|
---|
| 11 | #include "fm3dlg.h"
|
---|
| 12 | #include "fm3str.h"
|
---|
| 13 |
|
---|
| 14 | #pragma data_seg(DATA1)
|
---|
| 15 |
|
---|
| 16 | typedef struct {
|
---|
| 17 | CHAR mask[CCHMAXPATH];
|
---|
| 18 | CHAR cl[1001];
|
---|
| 19 | CHAR sig[CCHMAXPATH];
|
---|
| 20 | LONG offset;
|
---|
| 21 | ULONG flags;
|
---|
| 22 | } ASSOC;
|
---|
| 23 |
|
---|
| 24 | typedef struct LINKASSOC {
|
---|
| 25 | CHAR *mask;
|
---|
| 26 | CHAR *cl;
|
---|
| 27 | CHAR *sig;
|
---|
| 28 | LONG offset;
|
---|
| 29 | ULONG flags;
|
---|
| 30 | struct LINKASSOC *prev;
|
---|
| 31 | struct LINKASSOC *next;
|
---|
| 32 | } LINKASSOC;
|
---|
| 33 |
|
---|
| 34 | static LINKASSOC *asshead = NULL,*asstail = NULL;
|
---|
| 35 | static BOOL assloaded = FALSE;
|
---|
| 36 |
|
---|
| 37 | #pragma alloc_text(ASSOC2,free_commands,load_associations,save_associations)
|
---|
| 38 | #pragma alloc_text(ASSOC2,ExecAssociation,AssocTextProc)
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | MRESULT EXPENTRY AssocTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
|
---|
| 42 |
|
---|
| 43 | PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,0);
|
---|
| 44 | static BOOL emphasized = FALSE;
|
---|
| 45 |
|
---|
| 46 | switch(msg) {
|
---|
| 47 | case DM_DRAGOVER:
|
---|
| 48 | if(!emphasized) {
|
---|
| 49 | emphasized = TRUE;
|
---|
| 50 | DrawTargetEmphasis(hwnd,emphasized);
|
---|
| 51 | }
|
---|
| 52 | if(AcceptOneDrop(mp1,mp2))
|
---|
| 53 | return MRFROM2SHORT(DOR_DROP,
|
---|
| 54 | DO_MOVE);
|
---|
| 55 | return MRFROM2SHORT(DOR_NEVERDROP,0);
|
---|
| 56 |
|
---|
| 57 | case DM_DRAGLEAVE:
|
---|
| 58 | if(emphasized) {
|
---|
| 59 | emphasized = FALSE;
|
---|
| 60 | DrawTargetEmphasis(hwnd,emphasized);
|
---|
| 61 | }
|
---|
| 62 | break;
|
---|
| 63 |
|
---|
| 64 | case DM_DROPHELP:
|
---|
| 65 | DropHelp(mp1,mp2,hwnd,GetPString(IDS_ASSOCDROPHELPTEXT));
|
---|
| 66 | return 0;
|
---|
| 67 |
|
---|
| 68 | case DM_DROP:
|
---|
| 69 | {
|
---|
| 70 | char szFrom[CCHMAXPATH + 5];
|
---|
| 71 |
|
---|
| 72 | if(emphasized) {
|
---|
| 73 | emphasized = FALSE;
|
---|
| 74 | DrawTargetEmphasis(hwnd,emphasized);
|
---|
| 75 | }
|
---|
| 76 | if(GetOneDrop(mp1,mp2,szFrom,CCHMAXPATH)) {
|
---|
| 77 | strcat(szFrom," %a");
|
---|
| 78 | WinSetWindowText(hwnd,szFrom);
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | return 0;
|
---|
| 82 | }
|
---|
| 83 | return (oldproc) ? oldproc(hwnd,msg,mp1,mp2) :
|
---|
| 84 | WinDefWindowProc(hwnd,msg,mp1,mp2);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | VOID free_associations (VOID) {
|
---|
| 89 |
|
---|
| 90 | LINKASSOC *info,*next;
|
---|
| 91 |
|
---|
| 92 | info = asshead;
|
---|
| 93 | while(info) {
|
---|
| 94 | next = info->next;
|
---|
| 95 | free(info->mask);
|
---|
| 96 | free(info->cl);
|
---|
| 97 | if(info->sig)
|
---|
| 98 | free(info->sig);
|
---|
| 99 | free(info);
|
---|
| 100 | info = next;
|
---|
| 101 | }
|
---|
| 102 | asshead = asstail = NULL;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | VOID load_associations (VOID) {
|
---|
| 107 |
|
---|
| 108 | FILE *fp;
|
---|
| 109 | LINKASSOC *info;
|
---|
| 110 | CHAR cl[1024];
|
---|
| 111 | CHAR mask[CCHMAXPATH + 24];
|
---|
| 112 | CHAR sig[CCHMAXPATH + 24];
|
---|
| 113 | CHAR offset[72];
|
---|
| 114 | CHAR flags[72];
|
---|
| 115 |
|
---|
| 116 | if(asshead)
|
---|
| 117 | free_associations();
|
---|
| 118 | assloaded = TRUE;
|
---|
| 119 | save_dir2(mask);
|
---|
| 120 | if(mask[strlen(mask) - 1] != '\\')
|
---|
| 121 | strcat(mask,"\\");
|
---|
| 122 | strcat(mask,"ASSOC.DAT");
|
---|
| 123 | fp = _fsopen(mask,"r",SH_DENYWR);
|
---|
| 124 | if(fp) {
|
---|
| 125 | while(!feof(fp)) {
|
---|
| 126 | if(!fgets(mask,CCHMAXPATH + 24,fp))
|
---|
| 127 | break;
|
---|
| 128 | mask[CCHMAXPATH] = 0;
|
---|
| 129 | stripcr(mask);
|
---|
| 130 | lstrip(rstrip(mask));
|
---|
| 131 | if(!*mask || *mask == ';')
|
---|
| 132 | continue;
|
---|
| 133 | if(!fgets(cl,1024,fp) ||
|
---|
| 134 | !fgets(sig,CCHMAXPATH + 24,fp) ||
|
---|
| 135 | !fgets(offset,72,fp) ||
|
---|
| 136 | !fgets(flags,72,fp))
|
---|
| 137 | break; /* error! */
|
---|
| 138 | cl[1000] = 0;
|
---|
| 139 | sig[CCHMAXPATH] = 0;
|
---|
| 140 | offset[34] = 0;
|
---|
| 141 | flags[34] = 0;
|
---|
| 142 | stripcr(cl);
|
---|
| 143 | stripcr(sig);
|
---|
| 144 | stripcr(offset);
|
---|
| 145 | stripcr(flags);
|
---|
| 146 | lstrip(rstrip(cl));
|
---|
| 147 | lstrip(rstrip(sig));
|
---|
| 148 | lstrip(rstrip(offset));
|
---|
| 149 | lstrip(rstrip(flags));
|
---|
| 150 | if(!*cl)
|
---|
| 151 | continue;
|
---|
| 152 | info = malloc(sizeof(LINKASSOC));
|
---|
| 153 | if(info) {
|
---|
| 154 | memset(info,0,sizeof(LINKASSOC));
|
---|
| 155 | info->cl = strdup(cl);
|
---|
| 156 | info->mask = strdup(mask);
|
---|
| 157 | if(*sig)
|
---|
| 158 | info->sig = strdup(sig);
|
---|
| 159 | info->offset = atol(offset);
|
---|
| 160 | info->flags = atol(flags);
|
---|
| 161 | if(!info->cl || !info->mask) {
|
---|
| 162 | if(info->cl)
|
---|
| 163 | free(info->cl);
|
---|
| 164 | if(info->mask)
|
---|
| 165 | free(info->mask);
|
---|
| 166 | free(info);
|
---|
| 167 | break;
|
---|
| 168 | }
|
---|
| 169 | if(!asshead)
|
---|
| 170 | asshead = info;
|
---|
| 171 | else {
|
---|
| 172 | asstail->next = info;
|
---|
| 173 | info->prev = asstail;
|
---|
| 174 | }
|
---|
| 175 | asstail = info;
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 | fclose(fp);
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 |
|
---|
| 183 | VOID save_associations (VOID) {
|
---|
| 184 |
|
---|
| 185 | LINKASSOC *info;
|
---|
| 186 | FILE *fp;
|
---|
| 187 | CHAR s[CCHMAXPATH + 14];
|
---|
| 188 |
|
---|
| 189 | if(!assloaded || !asshead)
|
---|
| 190 | return;
|
---|
| 191 | info = asshead;
|
---|
| 192 | #ifdef NEVER
|
---|
| 193 | while(info) {
|
---|
| 194 | next = info->next;
|
---|
| 195 | if(!strcmp("*",info->mask)) {
|
---|
| 196 | if(info != asshead) { /* already top record */
|
---|
| 197 | if(info->prev)
|
---|
| 198 | (info->prev)->next = info->next;
|
---|
| 199 | if(info->next)
|
---|
| 200 | (info->next)->prev = info->prev;
|
---|
| 201 | if(info == asstail)
|
---|
| 202 | asstail = info->prev;
|
---|
| 203 | info->next = asshead->next;
|
---|
| 204 | info->prev = NULL;
|
---|
| 205 | asshead = info;
|
---|
| 206 | }
|
---|
| 207 | }
|
---|
| 208 | info = next;
|
---|
| 209 | }
|
---|
| 210 | #endif
|
---|
| 211 | save_dir2(s);
|
---|
| 212 | if(s[strlen(s) - 1] != '\\')
|
---|
| 213 | strcat(s,"\\");
|
---|
| 214 | strcat(s,"ASSOC.DAT");
|
---|
| 215 | fp = fopen(s,"w");
|
---|
| 216 | if(fp) {
|
---|
| 217 | fputs(GetPString(IDS_ASSOCFILETEXT),fp);
|
---|
| 218 | info = asshead;
|
---|
| 219 | while(info) {
|
---|
| 220 | fprintf(fp,
|
---|
| 221 | ";\n%0.*s\n%0.1000s\n%0.*s\n%lu\n%lu\n",
|
---|
| 222 | CCHMAXPATH,
|
---|
| 223 | info->mask,
|
---|
| 224 | info->cl,
|
---|
| 225 | CCHMAXPATH,
|
---|
| 226 | (info->sig) ? info->sig : NullStr,
|
---|
| 227 | info->offset,
|
---|
| 228 | info->flags);
|
---|
| 229 | info = info->next;
|
---|
| 230 | }
|
---|
| 231 | fclose(fp);
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 |
|
---|
| 236 | #pragma alloc_text(ASSOC,add_association,kill_association,AssocDlgProc,EditAssociations)
|
---|
| 237 |
|
---|
| 238 |
|
---|
| 239 | LINKASSOC * add_association (ASSOC *addme) {
|
---|
| 240 |
|
---|
| 241 | LINKASSOC *info;
|
---|
| 242 |
|
---|
| 243 | if(addme && *addme->cl && *addme->mask) {
|
---|
| 244 | info = asshead;
|
---|
| 245 | while(info) {
|
---|
| 246 | if(!stricmp(info->mask,addme->mask) &&
|
---|
| 247 | ((!info->sig && !*addme->sig) ||
|
---|
| 248 | (info->sig && !strcmp(addme->sig,info->sig))))
|
---|
| 249 | return NULL;
|
---|
| 250 | info = info->next;
|
---|
| 251 | }
|
---|
| 252 | if(!info) {
|
---|
| 253 | info = malloc(sizeof(LINKASSOC));
|
---|
| 254 | if(info) {
|
---|
| 255 | memset(info,0,sizeof(LINKASSOC));
|
---|
| 256 | info->cl = strdup(addme->cl);
|
---|
| 257 | info->mask = strdup(addme->mask);
|
---|
| 258 | if(*addme->sig)
|
---|
| 259 | info->sig = strdup(addme->sig);
|
---|
| 260 | if(addme->offset)
|
---|
| 261 | info->offset = addme->offset;
|
---|
| 262 | if(addme->flags)
|
---|
| 263 | info->flags = addme->flags;
|
---|
| 264 | if(!info->cl || !info->mask) {
|
---|
| 265 | if(info->cl)
|
---|
| 266 | free(info->cl);
|
---|
| 267 | if(info->mask)
|
---|
| 268 | free(info->mask);
|
---|
| 269 | free(info);
|
---|
| 270 | }
|
---|
| 271 | else {
|
---|
| 272 | if(!asshead) /* only item in list */
|
---|
| 273 | asshead = asstail = info;
|
---|
| 274 | else {
|
---|
| 275 | if(asstail) { /* place at tail */
|
---|
| 276 | asstail->next = info;
|
---|
| 277 | info->prev = asstail;
|
---|
| 278 | }
|
---|
| 279 | asstail = info;
|
---|
| 280 | }
|
---|
| 281 | return info;
|
---|
| 282 | }
|
---|
| 283 | }
|
---|
| 284 | }
|
---|
| 285 | }
|
---|
| 286 | return NULL;
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 |
|
---|
| 290 | BOOL kill_association (ASSOC *killme) {
|
---|
| 291 |
|
---|
| 292 | LINKASSOC *info;
|
---|
| 293 |
|
---|
| 294 | if(killme && *killme->mask) {
|
---|
| 295 | info = asshead;
|
---|
| 296 | while(info) {
|
---|
| 297 | if(!stricmp(info->mask,killme->mask) &&
|
---|
| 298 | info->offset == killme->offset &&
|
---|
| 299 | (((!info->sig || !*info->sig) && !*killme->sig) ||
|
---|
| 300 | (info->sig && !strcmp(killme->sig,info->sig)))) {
|
---|
| 301 | if(info == asshead) {
|
---|
| 302 | asshead = info->next;
|
---|
| 303 | if(info == asstail)
|
---|
| 304 | asstail = info->prev;
|
---|
| 305 | }
|
---|
| 306 | else {
|
---|
| 307 | if(info->next)
|
---|
| 308 | (info->next)->prev = info->prev;
|
---|
| 309 | if(info->prev)
|
---|
| 310 | (info->prev)->next = info->next;
|
---|
| 311 | if(info == asstail)
|
---|
| 312 | asstail = info->prev;
|
---|
| 313 | }
|
---|
| 314 | free(info->cl);
|
---|
| 315 | free(info->mask);
|
---|
| 316 | if(info->sig)
|
---|
| 317 | free(info->sig);
|
---|
| 318 | free(info);
|
---|
| 319 | return TRUE;
|
---|
| 320 | }
|
---|
| 321 | info = info->next;
|
---|
| 322 | }
|
---|
| 323 | }
|
---|
| 324 | return FALSE;
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 |
|
---|
| 328 | INT ExecAssociation (HWND hwnd, CHAR *datafile) {
|
---|
| 329 |
|
---|
| 330 | CHAR *file,sig[CCHMAXPATH],sigl[CCHMAXPATH],mask[CCHMAXPATH],*p;
|
---|
| 331 | FILE *fp;
|
---|
| 332 | BOOL didmatch,exclude;
|
---|
| 333 | ULONG offset;
|
---|
| 334 | LINKASSOC *info;
|
---|
| 335 |
|
---|
| 336 | if(!assloaded)
|
---|
| 337 | load_associations();
|
---|
| 338 | if(!asshead)
|
---|
| 339 | return -1;
|
---|
| 340 | if(!datafile ||
|
---|
| 341 | !*datafile)
|
---|
| 342 | return -1;
|
---|
| 343 | file = strrchr(datafile,'\\');
|
---|
| 344 | if(!file)
|
---|
| 345 | file = strrchr(datafile,':');
|
---|
| 346 | if(file)
|
---|
| 347 | file++;
|
---|
| 348 | else
|
---|
| 349 | file = datafile;
|
---|
| 350 | info = asshead;
|
---|
| 351 | while(info) {
|
---|
| 352 | strcpy(mask,
|
---|
| 353 | info->mask);
|
---|
| 354 | p = strtok(mask,";");
|
---|
| 355 | while(p) {
|
---|
| 356 | if(*p == '/') {
|
---|
| 357 | p++;
|
---|
| 358 | exclude = TRUE;
|
---|
| 359 | }
|
---|
| 360 | else
|
---|
| 361 | exclude = FALSE;
|
---|
| 362 | didmatch = wildcard((strchr(p,'\\') ||
|
---|
| 363 | strchr(p,':')) ?
|
---|
| 364 | datafile :
|
---|
| 365 | file,
|
---|
| 366 | p,
|
---|
| 367 | FALSE);
|
---|
| 368 | if(exclude &&
|
---|
| 369 | didmatch)
|
---|
| 370 | didmatch = FALSE;
|
---|
| 371 | if(didmatch) {
|
---|
| 372 | if(info->sig &&
|
---|
| 373 | *info->sig) {
|
---|
| 374 | strcpy(sigl,
|
---|
| 375 | info->sig);
|
---|
| 376 | literal(sigl);
|
---|
| 377 | fp = _fsopen(datafile,
|
---|
| 378 | "rb",
|
---|
| 379 | SH_DENYNO);
|
---|
| 380 | if(fp) {
|
---|
| 381 | if(info->offset < 0L) {
|
---|
| 382 | fseek(fp,
|
---|
| 383 | 0L,
|
---|
| 384 | SEEK_END);
|
---|
| 385 | offset = ftell(fp) + info->offset;
|
---|
| 386 | }
|
---|
| 387 | else
|
---|
| 388 | offset = info->offset;
|
---|
| 389 | fseek(fp,
|
---|
| 390 | offset,
|
---|
| 391 | SEEK_SET);
|
---|
| 392 | if(fread(sig,
|
---|
| 393 | 1,
|
---|
| 394 | strlen(sigl),
|
---|
| 395 | fp) !=
|
---|
| 396 | strlen(sigl) ||
|
---|
| 397 | strncmp(sigl,
|
---|
| 398 | sig,
|
---|
| 399 | strlen(sigl)))
|
---|
| 400 | didmatch = FALSE;
|
---|
| 401 | fclose(fp);
|
---|
| 402 | }
|
---|
| 403 | }
|
---|
| 404 | }
|
---|
| 405 | if(didmatch) { /* got a match; do it... */
|
---|
| 406 |
|
---|
| 407 | CHAR *list[2];
|
---|
| 408 | INT flags,rc;
|
---|
| 409 | BOOL dieafter = FALSE;
|
---|
| 410 |
|
---|
| 411 | if(fAmAV2) {
|
---|
| 412 | if(stristr(info->cl,"AV2.EXE") ||
|
---|
| 413 | stristr(info->cl,"AV2.CMD") ||
|
---|
| 414 | stristr(info->cl,"<>"))
|
---|
| 415 | return -1;
|
---|
| 416 | }
|
---|
| 417 | if(!strcmp(info->cl,"<>")) {
|
---|
| 418 | OpenObject(datafile,
|
---|
| 419 | Default,
|
---|
| 420 | hwnd);
|
---|
| 421 | return 0;
|
---|
| 422 | }
|
---|
| 423 | list[0] = datafile;
|
---|
| 424 | list[1] = NULL;
|
---|
| 425 | flags = info->flags;
|
---|
| 426 | if(!(flags & FULLSCREEN))
|
---|
| 427 | flags |= WINDOWED;
|
---|
| 428 | if(flags & KEEP)
|
---|
| 429 | flags |= SEPARATEKEEP;
|
---|
| 430 | else
|
---|
| 431 | flags |= SEPARATE;
|
---|
| 432 | flags &= (~KEEP);
|
---|
| 433 | if(flags & DIEAFTER)
|
---|
| 434 | dieafter = TRUE;
|
---|
| 435 | flags &= (~DIEAFTER);
|
---|
| 436 | rc = ExecOnList(hwnd,
|
---|
| 437 | info->cl,
|
---|
| 438 | flags,
|
---|
| 439 | NULL,
|
---|
| 440 | list,
|
---|
| 441 | GetPString(IDS_EXECASSOCTITLETEXT));
|
---|
| 442 | if(rc != -1 &&
|
---|
| 443 | dieafter)
|
---|
| 444 | PostMsg((HWND)0,
|
---|
| 445 | WM_QUIT,
|
---|
| 446 | MPVOID,
|
---|
| 447 | MPVOID);
|
---|
| 448 | return rc;
|
---|
| 449 | }
|
---|
| 450 | p = strtok(0,";");
|
---|
| 451 | }
|
---|
| 452 | info = info->next;
|
---|
| 453 | }
|
---|
| 454 | return -1;
|
---|
| 455 | }
|
---|
| 456 |
|
---|
| 457 |
|
---|
| 458 | MRESULT EXPENTRY AssocDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
|
---|
| 459 |
|
---|
| 460 | LINKASSOC *info;
|
---|
| 461 | SHORT x;
|
---|
| 462 |
|
---|
| 463 | switch(msg) {
|
---|
| 464 | case WM_INITDLG:
|
---|
| 465 | WinSendDlgItemMsg(hwnd,ASS_LISTBOX,LM_DELETEALL,MPVOID,MPVOID);
|
---|
| 466 | WinSendDlgItemMsg(hwnd,ASS_MASK,EM_SETTEXTLIMIT,
|
---|
| 467 | MPFROM2SHORT(CCHMAXPATH,0),MPVOID);
|
---|
| 468 | WinSendDlgItemMsg(hwnd,ASS_CL,EM_SETTEXTLIMIT,
|
---|
| 469 | MPFROM2SHORT(1000,0),MPVOID);
|
---|
| 470 | WinSendDlgItemMsg(hwnd,ASS_SIG,EM_SETTEXTLIMIT,
|
---|
| 471 | MPFROM2SHORT(CCHMAXPATH,0),MPVOID);
|
---|
| 472 | WinSendDlgItemMsg(hwnd,ASS_OFFSET,EM_SETTEXTLIMIT,
|
---|
| 473 | MPFROM2SHORT(34,0),MPVOID);
|
---|
| 474 | WinSetDlgItemText(hwnd,ASS_MASK,NullStr);
|
---|
| 475 | WinSetDlgItemText(hwnd,ASS_CL,NullStr);
|
---|
| 476 | WinSetDlgItemText(hwnd,ASS_SIG,NullStr);
|
---|
| 477 | WinSetDlgItemText(hwnd,ASS_OFFSET,"0");
|
---|
| 478 | WinCheckButton(hwnd,ASS_DEFAULT,TRUE);
|
---|
| 479 | WinCheckButton(hwnd,ASS_PROMPT,FALSE);
|
---|
| 480 | WinCheckButton(hwnd,ASS_KEEP,FALSE);
|
---|
| 481 | WinCheckButton(hwnd,ASS_DIEAFTER,FALSE);
|
---|
| 482 | PostMsg(hwnd,UM_UNDO,MPVOID,MPVOID);
|
---|
| 483 | {
|
---|
| 484 | PFNWP oldproc;
|
---|
| 485 |
|
---|
| 486 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd,ASS_CL),
|
---|
| 487 | (PFNWP)AssocTextProc);
|
---|
| 488 | if(oldproc)
|
---|
| 489 | WinSetWindowPtr(WinWindowFromID(hwnd,ASS_CL),0,(PVOID)oldproc);
|
---|
| 490 | }
|
---|
| 491 | break;
|
---|
| 492 |
|
---|
| 493 | case UM_UNDO:
|
---|
| 494 | {
|
---|
| 495 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
| 496 |
|
---|
| 497 | WinSendDlgItemMsg(hwnd,
|
---|
| 498 | ASS_LISTBOX,
|
---|
| 499 | LM_DELETEALL,
|
---|
| 500 | MPVOID,
|
---|
| 501 | MPVOID);
|
---|
| 502 | info = asshead;
|
---|
| 503 | while(info) {
|
---|
| 504 | sprintf(s,
|
---|
| 505 | "%-12s \x1a %-24s %s%s%s",
|
---|
| 506 | info->mask,
|
---|
| 507 | info->cl,
|
---|
| 508 | (info->sig && *info->sig) ?
|
---|
| 509 | "[" : NullStr,
|
---|
| 510 | (info->sig && *info->sig) ? info->sig : NullStr,
|
---|
| 511 | (info->sig && *info->sig) ? "]" : NullStr);
|
---|
| 512 | x = (SHORT)WinSendDlgItemMsg(hwnd,
|
---|
| 513 | ASS_LISTBOX,
|
---|
| 514 | LM_INSERTITEM,
|
---|
| 515 | MPFROM2SHORT(LIT_END,0),
|
---|
| 516 | MPFROMP(s));
|
---|
| 517 | if(x >= 0)
|
---|
| 518 | WinSendDlgItemMsg(hwnd,
|
---|
| 519 | ASS_LISTBOX,
|
---|
| 520 | LM_SETITEMHANDLE,
|
---|
| 521 | MPFROMSHORT(x),
|
---|
| 522 | MPFROMP(info));
|
---|
| 523 | info = info->next;
|
---|
| 524 | }
|
---|
| 525 | WinSendDlgItemMsg(hwnd,
|
---|
| 526 | ASS_LISTBOX,
|
---|
| 527 | LM_SELECTITEM,
|
---|
| 528 | MPFROMSHORT(0),
|
---|
| 529 | MPFROMSHORT(TRUE));
|
---|
| 530 | }
|
---|
| 531 | return 0;
|
---|
| 532 |
|
---|
| 533 | case WM_CONTROL:
|
---|
| 534 | if(SHORT1FROMMP(mp1) == ASS_LISTBOX) {
|
---|
| 535 | switch(SHORT2FROMMP(mp1)) {
|
---|
| 536 | case LN_ENTER:
|
---|
| 537 | case LN_SELECT:
|
---|
| 538 | x = (SHORT)WinSendDlgItemMsg(hwnd,
|
---|
| 539 | ASS_LISTBOX,
|
---|
| 540 | LM_QUERYSELECTION,
|
---|
| 541 | MPFROMSHORT(LIT_FIRST),
|
---|
| 542 | MPVOID);
|
---|
| 543 | if(x >= 0) {
|
---|
| 544 |
|
---|
| 545 | CHAR s[36];
|
---|
| 546 |
|
---|
| 547 | info = (LINKASSOC *)WinSendDlgItemMsg(hwnd,
|
---|
| 548 | ASS_LISTBOX,
|
---|
| 549 | LM_QUERYITEMHANDLE,
|
---|
| 550 | MPFROMSHORT(x),
|
---|
| 551 | MPVOID);
|
---|
| 552 | if(!info) {
|
---|
| 553 | DosBeep(50,100);
|
---|
| 554 | break;
|
---|
| 555 | }
|
---|
| 556 | WinSetDlgItemText(hwnd,ASS_MASK,info->mask);
|
---|
| 557 | WinSetDlgItemText(hwnd,ASS_CL,info->cl);
|
---|
| 558 | WinSetDlgItemText(hwnd,ASS_SIG,
|
---|
| 559 | (info->sig && *info->sig) ? info->sig : NullStr);
|
---|
| 560 | sprintf(s,"%ld",info->offset);
|
---|
| 561 | WinSetDlgItemText(hwnd,ASS_OFFSET,s);
|
---|
| 562 | if(!(info->flags & 1023))
|
---|
| 563 | WinCheckButton(hwnd,ASS_DEFAULT,TRUE);
|
---|
| 564 | else {
|
---|
| 565 | if(info->flags & FULLSCREEN)
|
---|
| 566 | WinCheckButton(hwnd,ASS_FULLSCREEN,TRUE);
|
---|
| 567 | else if(info->flags & MINIMIZED)
|
---|
| 568 | WinCheckButton(hwnd,ASS_MINIMIZED,TRUE);
|
---|
| 569 | else if(info->flags & MAXIMIZED)
|
---|
| 570 | WinCheckButton(hwnd,ASS_MAXIMIZED,TRUE);
|
---|
| 571 | else if(info->flags & INVISIBLE)
|
---|
| 572 | WinCheckButton(hwnd,ASS_INVISIBLE,TRUE);
|
---|
| 573 | }
|
---|
| 574 | WinCheckButton(hwnd,ASS_KEEP,((info->flags & KEEP) != 0));
|
---|
| 575 | WinCheckButton(hwnd,ASS_DIEAFTER,((info->flags & DIEAFTER) != 0));
|
---|
| 576 | WinCheckButton(hwnd,ASS_PROMPT,((info->flags & PROMPT) != 0));
|
---|
| 577 | {
|
---|
| 578 | CHAR env[1002];
|
---|
| 579 | ULONG size;
|
---|
| 580 |
|
---|
| 581 | *env = 0;
|
---|
| 582 | size = sizeof(env) - 1;
|
---|
| 583 | if(PrfQueryProfileData(fmprof,
|
---|
| 584 | FM3Str,
|
---|
| 585 | info->cl,
|
---|
| 586 | env,
|
---|
| 587 | &size) &&
|
---|
| 588 | *env)
|
---|
| 589 | WinSetDlgItemText(hwnd,
|
---|
| 590 | ASS_ENVIRON,
|
---|
| 591 | env);
|
---|
| 592 | else
|
---|
| 593 | WinSetDlgItemText(hwnd,
|
---|
| 594 | ASS_ENVIRON,
|
---|
| 595 | NullStr);
|
---|
| 596 | }
|
---|
| 597 | }
|
---|
| 598 | break;
|
---|
| 599 | }
|
---|
| 600 | }
|
---|
| 601 | return 0;
|
---|
| 602 |
|
---|
| 603 | case WM_COMMAND:
|
---|
| 604 | switch(SHORT1FROMMP(mp1)) {
|
---|
| 605 | case ASS_TOP:
|
---|
| 606 | x = (SHORT)WinSendDlgItemMsg(hwnd,ASS_LISTBOX,
|
---|
| 607 | LM_QUERYSELECTION,
|
---|
| 608 | MPFROMSHORT(LIT_FIRST),
|
---|
| 609 | MPVOID);
|
---|
| 610 | if(x >= 0) {
|
---|
| 611 | info = (LINKASSOC *)WinSendDlgItemMsg(hwnd,ASS_LISTBOX,
|
---|
| 612 | LM_QUERYITEMHANDLE,
|
---|
| 613 | MPFROMSHORT(x),
|
---|
| 614 | MPVOID);
|
---|
| 615 | if(info) {
|
---|
| 616 | if(info != asshead) {
|
---|
| 617 | if(info->prev)
|
---|
| 618 | info->prev->next = info->next;
|
---|
| 619 | if(info->next)
|
---|
| 620 | info->next->prev = info->prev;
|
---|
| 621 | if(info == asstail)
|
---|
| 622 | asstail = info->prev;
|
---|
| 623 | info->prev = NULL;
|
---|
| 624 | info->next = asshead;
|
---|
| 625 | asshead->prev = info;
|
---|
| 626 | asshead = info;
|
---|
| 627 | WinSendMsg(hwnd,UM_UNDO,MPVOID,MPVOID);
|
---|
| 628 | }
|
---|
| 629 | }
|
---|
| 630 | }
|
---|
| 631 | break;
|
---|
| 632 |
|
---|
| 633 | case ASS_FIND:
|
---|
| 634 | {
|
---|
| 635 | CHAR filename[CCHMAXPATH + 9];
|
---|
| 636 |
|
---|
| 637 | *filename = 0;
|
---|
| 638 | if(insert_filename(hwnd,filename,2,FALSE) && *filename) {
|
---|
| 639 | strcat(filename," %a");
|
---|
| 640 | WinSetDlgItemText(hwnd,ASS_CL,filename);
|
---|
| 641 | }
|
---|
| 642 | }
|
---|
| 643 | break;
|
---|
| 644 |
|
---|
| 645 | case DID_OK:
|
---|
| 646 | WinDismissDlg(hwnd,1);
|
---|
| 647 | break;
|
---|
| 648 |
|
---|
| 649 | case DID_CANCEL:
|
---|
| 650 | WinDismissDlg(hwnd,0);
|
---|
| 651 | break;
|
---|
| 652 |
|
---|
| 653 | case IDM_HELP:
|
---|
| 654 | if(hwndHelp)
|
---|
| 655 | WinSendMsg(hwndHelp,HM_DISPLAY_HELP,
|
---|
| 656 | MPFROM2SHORT(HELP_ASSOC,0),
|
---|
| 657 | MPFROMSHORT(HM_RESOURCEID));
|
---|
| 658 | break;
|
---|
| 659 |
|
---|
| 660 | case ASS_ADD:
|
---|
| 661 | {
|
---|
| 662 | ASSOC temp;
|
---|
| 663 | CHAR dummy[34];
|
---|
| 664 |
|
---|
| 665 | memset(&temp,0,sizeof(ASSOC));
|
---|
| 666 | WinQueryDlgItemText(hwnd,ASS_MASK,sizeof(temp.mask),temp.mask);
|
---|
| 667 | WinQueryDlgItemText(hwnd,ASS_CL,sizeof(temp.cl),temp.cl);
|
---|
| 668 | WinQueryDlgItemText(hwnd,ASS_SIG,sizeof(temp.sig),temp.sig);
|
---|
| 669 | rstrip(temp.sig);
|
---|
| 670 | if(*temp.sig) {
|
---|
| 671 | WinQueryDlgItemText(hwnd,ASS_OFFSET,sizeof(dummy),dummy);
|
---|
| 672 | temp.offset = atol(dummy);
|
---|
| 673 | }
|
---|
| 674 | lstrip(rstrip(temp.mask));
|
---|
| 675 | lstrip(rstrip(temp.cl));
|
---|
| 676 | if(WinQueryButtonCheckstate(hwnd,ASS_DEFAULT))
|
---|
| 677 | temp.flags = 0;
|
---|
| 678 | else if(WinQueryButtonCheckstate(hwnd,ASS_FULLSCREEN))
|
---|
| 679 | temp.flags = FULLSCREEN;
|
---|
| 680 | else if(WinQueryButtonCheckstate(hwnd,ASS_MINIMIZED))
|
---|
| 681 | temp.flags = MINIMIZED;
|
---|
| 682 | else if(WinQueryButtonCheckstate(hwnd,ASS_MAXIMIZED))
|
---|
| 683 | temp.flags = MAXIMIZED;
|
---|
| 684 | else if(WinQueryButtonCheckstate(hwnd,ASS_INVISIBLE))
|
---|
| 685 | temp.flags = INVISIBLE;
|
---|
| 686 | if(WinQueryButtonCheckstate(hwnd,ASS_KEEP))
|
---|
| 687 | temp.flags |= KEEP;
|
---|
| 688 | if(WinQueryButtonCheckstate(hwnd,ASS_DIEAFTER))
|
---|
| 689 | temp.flags |= DIEAFTER;
|
---|
| 690 | if(WinQueryButtonCheckstate(hwnd,ASS_PROMPT))
|
---|
| 691 | temp.flags |= PROMPT;
|
---|
| 692 | info = add_association(&temp);
|
---|
| 693 | if(info) {
|
---|
| 694 |
|
---|
| 695 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
| 696 |
|
---|
| 697 | *s = 0;
|
---|
| 698 | WinQueryDlgItemText(hwnd,ASS_ENVIRON,1000,s);
|
---|
| 699 | stripcr(s);
|
---|
| 700 | lstrip(rstrip(s));
|
---|
| 701 | if(*s)
|
---|
| 702 | PrfWriteProfileString(fmprof,FM3Str,temp.cl,s);
|
---|
| 703 | sprintf(s,"%-12s \x1a %-24s %s%s%s",temp.mask,
|
---|
| 704 | temp.cl,(*temp.sig) ?
|
---|
| 705 | "[" : NullStr,(*temp.sig) ? temp.sig : NullStr,
|
---|
| 706 | (*temp.sig) ? "]" : NullStr);
|
---|
| 707 | x = (SHORT)WinSendDlgItemMsg(hwnd,
|
---|
| 708 | ASS_LISTBOX,
|
---|
| 709 | LM_INSERTITEM,
|
---|
| 710 | MPFROM2SHORT(LIT_END,0),
|
---|
| 711 | MPFROMP(s));
|
---|
| 712 | if(x >= 0) {
|
---|
| 713 | WinSendDlgItemMsg(hwnd,
|
---|
| 714 | ASS_LISTBOX,
|
---|
| 715 | LM_SETITEMHANDLE,
|
---|
| 716 | MPFROMSHORT(x),
|
---|
| 717 | MPFROMP(info));
|
---|
| 718 | WinSendDlgItemMsg(hwnd,
|
---|
| 719 | ASS_LISTBOX,
|
---|
| 720 | LM_SELECTITEM,
|
---|
| 721 | MPFROMSHORT(x),
|
---|
| 722 | MPFROMSHORT(TRUE));
|
---|
| 723 | }
|
---|
| 724 | save_associations();
|
---|
| 725 | }
|
---|
| 726 | else
|
---|
| 727 | DosBeep(50,200);
|
---|
| 728 | }
|
---|
| 729 | break;
|
---|
| 730 |
|
---|
| 731 | case ASS_DELETE:
|
---|
| 732 | {
|
---|
| 733 | ASSOC temp;
|
---|
| 734 | CHAR dummy[34];
|
---|
| 735 |
|
---|
| 736 | memset(&temp,0,sizeof(ASSOC));
|
---|
| 737 | WinQueryDlgItemText(hwnd,ASS_MASK,sizeof(temp.mask),temp.mask);
|
---|
| 738 | WinQueryDlgItemText(hwnd,ASS_SIG,sizeof(temp.sig),temp.sig);
|
---|
| 739 | rstrip(temp.sig);
|
---|
| 740 | if(*temp.sig) {
|
---|
| 741 | WinQueryDlgItemText(hwnd,ASS_OFFSET,sizeof(dummy),dummy);
|
---|
| 742 | temp.offset = atol(dummy);
|
---|
| 743 | }
|
---|
| 744 | lstrip(rstrip(temp.mask));
|
---|
| 745 | PrfWriteProfileData(fmprof,
|
---|
| 746 | FM3Str,
|
---|
| 747 | temp.mask,
|
---|
| 748 | NULL,
|
---|
| 749 | 0L);
|
---|
| 750 | if(kill_association(&temp)) {
|
---|
| 751 | x = (SHORT)WinSendDlgItemMsg(hwnd,
|
---|
| 752 | ASS_LISTBOX,
|
---|
| 753 | LM_QUERYSELECTION,
|
---|
| 754 | MPFROMSHORT(LIT_FIRST),
|
---|
| 755 | MPVOID);
|
---|
| 756 | if(x >= 0) {
|
---|
| 757 | WinSendDlgItemMsg(hwnd,
|
---|
| 758 | ASS_LISTBOX,
|
---|
| 759 | LM_DELETEITEM,
|
---|
| 760 | MPFROMSHORT(x),
|
---|
| 761 | MPVOID);
|
---|
| 762 | WinSendDlgItemMsg(hwnd,ASS_LISTBOX,LM_SELECTITEM,
|
---|
| 763 | MPFROMSHORT(LIT_NONE),
|
---|
| 764 | MPFROMSHORT(FALSE));
|
---|
| 765 | }
|
---|
| 766 | save_associations();
|
---|
| 767 | }
|
---|
| 768 | else
|
---|
| 769 | DosBeep(50,200);
|
---|
| 770 | }
|
---|
| 771 | break;
|
---|
| 772 | }
|
---|
| 773 | return 0;
|
---|
| 774 | }
|
---|
| 775 | return WinDefDlgProc(hwnd,msg,mp1,mp2);
|
---|
| 776 | }
|
---|
| 777 |
|
---|
| 778 |
|
---|
| 779 | VOID EditAssociations (HWND hwnd) {
|
---|
| 780 |
|
---|
| 781 | static CHAR stop = 0;
|
---|
| 782 |
|
---|
| 783 | if(stop)
|
---|
| 784 | return;
|
---|
| 785 | stop++;
|
---|
| 786 | if(!assloaded)
|
---|
| 787 | load_associations();
|
---|
| 788 | WinDlgBox(HWND_DESKTOP,hwnd,AssocDlgProc,FM3ModHandle,ASS_FRAME,NULL);
|
---|
| 789 | stop = 0;
|
---|
| 790 | }
|
---|
| 791 |
|
---|