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