Changeset 989 for trunk/dll/command.c
- Timestamp:
- Mar 2, 2008, 12:34:12 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/command.c
r985 r989 43 43 #include "fm3dll.h" 44 44 #include "pathutil.h" // NormalizeCmdLine 45 #include "command.h" 45 46 46 47 typedef struct … … 308 309 next = info->next; 309 310 xfree(info->title); 310 xfree(info-> cl);311 xfree(info->pszCmdLine); 311 312 xfree(info); 312 313 info = next; … … 319 320 FILE *fp; 320 321 LINKCMDS *info; 321 CHAR cl[1024];322 PSZ pszCmdLine; 322 323 CHAR title[100]; 323 324 CHAR flags[72]; … … 326 327 free_commands(); 327 328 cmdloaded = TRUE; 328 save_dir2(cl); 329 if (cl[strlen(cl) - 1] != '\\') 330 strcat(cl, "\\"); 331 strcat(cl, "COMMANDS.DAT"); 332 fp = _fsopen(cl, "r", SH_DENYWR); 333 if (fp) { 334 while (!feof(fp)) { 335 if (!xfgets_bstripcr(title, sizeof(title), fp, pszSrcFile, __LINE__)) 336 break; 337 title[34] = 0; // fixme to know why chopped this way? 338 bstripcr(title); 339 if (!*title || *title == ';') 340 continue; 341 if (!xfgets(cl, sizeof(cl), fp, pszSrcFile, __LINE__)) 342 break; /* error! */ 343 if (!xfgets(flags, 72, fp, pszSrcFile, __LINE__)) 344 break; /* error! */ 345 cl[1000] = 0; // fixme to know why chopped this way? 346 bstripcr(cl); 347 flags[34] = 0; 348 bstripcr(flags); 349 if (!*cl) 350 continue; 351 info = xmallocz(sizeof(LINKCMDS), pszSrcFile, __LINE__); 352 if (info) { 353 info->cl = xstrdup(cl, pszSrcFile, __LINE__); 354 info->title = xstrdup(title, pszSrcFile, __LINE__); 355 info->flags = atol(flags); 356 if (!info->cl || !info->title) { 357 xfree(info->cl); 358 xfree(info->title); 359 xfree(info); 360 break; 361 } 362 if (!cmdhead) 363 cmdhead = info; 364 else { 365 cmdtail->next = info; 366 info->prev = cmdtail; 367 } 368 cmdtail = info; 369 } 370 } 371 fclose(fp); 329 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 330 if (pszCmdLine) { 331 save_dir2(pszCmdLine); 332 if (pszCmdLine[strlen(pszCmdLine) - 1] != '\\') 333 strcat(pszCmdLine, "\\"); 334 strcat(pszCmdLine, "COMMANDS.DAT"); 335 fp = _fsopen(pszCmdLine, "r", SH_DENYWR); 336 if (fp) { 337 while (!feof(fp)) { 338 if (!xfgets_bstripcr(title, sizeof(title), fp, pszSrcFile, __LINE__)) 339 break; 340 title[34] = 0; // fixme to know why chopped this way? 341 bstripcr(title); 342 if (!*title || *title == ';') 343 continue; 344 if (!xfgets(pszCmdLine, MaxComLineStrg, fp, pszSrcFile, __LINE__)) 345 break; /* error! */ 346 if (!xfgets(flags, 72, fp, pszSrcFile, __LINE__)) 347 break; /* error! */ 348 pszCmdLine[MaxComLineStrg - 1] = 0; // fixme to know why chopped this way? 349 bstripcr(pszCmdLine); 350 flags[34] = 0; 351 bstripcr(flags); 352 if (!pszCmdLine) 353 continue; 354 info = xmallocz(sizeof(LINKCMDS), pszSrcFile, __LINE__); 355 if (info) { 356 info->pszCmdLine = xstrdup(pszCmdLine, pszSrcFile, __LINE__); 357 info->title = xstrdup(title, pszSrcFile, __LINE__); 358 info->flags = atol(flags); 359 if (!info->pszCmdLine || !info->title) { 360 xfree(info->pszCmdLine); 361 xfree(info->title); 362 xfree(info); 363 break; 364 } 365 if (!cmdhead) 366 cmdhead = info; 367 else { 368 cmdtail->next = info; 369 info->prev = cmdtail; 370 } 371 cmdtail = info; 372 } 373 } 374 xfree(pszCmdLine); 375 fclose(fp); 376 } 372 377 } 373 378 } … … 392 397 while (info) { 393 398 fprintf(fp, 394 ";\n%0.34s\n%0. 1000s\n%lu\n",395 info->title, info->cl, info->flags);399 ";\n%0.34s\n%0.*s\n%lu\n", 400 info->title, MaxComLineStrg, info->pszCmdLine, info->flags); 396 401 info = info->next; 397 402 } … … 417 422 if (!info) 418 423 return NULL; 419 info-> cl= xstrdup(addme->pszCmdLine, pszSrcFile, __LINE__);424 info->pszCmdLine = xstrdup(addme->pszCmdLine, pszSrcFile, __LINE__); 420 425 info->title = xstrdup(addme->title, pszSrcFile, __LINE__); 421 426 if (addme->flags) 422 427 info->flags = addme->flags; 423 if (!info-> cl|| !info->title) {424 xfree(info-> cl);428 if (!info->pszCmdLine || !info->title) { 429 xfree(info->pszCmdLine); 425 430 xfree(info->title); 426 431 xfree(info); … … 459 464 cmdtail = info->prev; 460 465 } 461 xfree(info-> cl);466 xfree(info->pszCmdLine); 462 467 xfree(info->title); 463 468 xfree(info); … … 525 530 break; 526 531 } 527 WinSetDlgItemText(hwnd, CMD_CL, info-> cl);532 WinSetDlgItemText(hwnd, CMD_CL, info->pszCmdLine); 528 533 if (!(info->flags & 1023)) 529 534 WinCheckButton(hwnd, CMD_DEFAULT, TRUE); … … 548 553 *env = 0; 549 554 size = sizeof(env) - 1; 550 if (PrfQueryProfileData(fmprof, FM3Str, info-> cl, env, &size) &&555 if (PrfQueryProfileData(fmprof, FM3Str, info->pszCmdLine, env, &size) && 551 556 *env) 552 557 WinSetDlgItemText(hwnd, CMD_ENVIRON, env); … … 1020 1025 fakelist[1] = NULL; 1021 1026 ExecOnList(hwnd, 1022 info-> cl,1027 info->pszCmdLine, 1023 1028 flags, NULL, fakelist, GetPString(IDS_EXECCMDTITLETEXT), 1024 1029 pszSrcFile, __LINE__); … … 1027 1032 else 1028 1033 ExecOnList(hwnd, 1029 info-> cl,1034 info->pszCmdLine, 1030 1035 flags, NULL, list, GetPString(IDS_EXECCMDTITLETEXT), 1031 1036 pszSrcFile, __LINE__);
Note:
See TracChangeset
for help on using the changeset viewer.