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