Changeset 23 for trunk/src/helpers/winh.c
- Timestamp:
- Jan 16, 2001, 8:49:10 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/winh.c
r21 r23 2432 2432 * 2433 2433 *@@added V0.9.6 (2000-10-16) [umoeller] 2434 *@@changed V0.9.7 (2001-01-15) [umoeller]: now using XSTRING 2434 2435 */ 2435 2436 2436 2437 VOID CallBatchCorrectly(PPROGDETAILS pProgDetails, 2437 P SZ *ppszParams,// in/out: modified parameters (reallocated)2438 PXSTRING pstrParams, // in/out: modified parameters (reallocated) 2438 2439 const char *pcszEnvVar, // in: env var spec'g command proc 2439 2440 // (e.g. "OS2_SHELL"); can be NULL … … 2442 2443 // XXX.CMD file as executable: 2443 2444 // fix args to /C XXX.CMD 2444 XSTRING strNewParams; 2445 xstrInit(&strNewParams, 200); 2446 xstrcpy(&strNewParams, "/C "); 2447 xstrcat(&strNewParams, pProgDetails->pszExecutable); 2448 if (*ppszParams) 2449 { 2450 // append old params 2451 xstrcat(&strNewParams, " "); 2452 xstrcat(&strNewParams, *ppszParams); 2453 free(*ppszParams); 2454 } 2455 *ppszParams = strNewParams.psz; 2456 // freed by caller 2445 2446 PSZ pszOldParams = NULL; 2447 ULONG ulOldParamsLength = pstrParams->ulLength; 2448 if (ulOldParamsLength) 2449 // we have parameters already: 2450 // make a backup... we'll append that later 2451 pszOldParams = strdup(pstrParams->psz); 2452 2453 // set new params to "/C filename.cmd" 2454 xstrcpy(pstrParams, "/C ", 0); 2455 xstrcat(pstrParams, 2456 pProgDetails->pszExecutable, 2457 0); 2458 2459 if (pszOldParams) 2460 { 2461 // .cmd had params: 2462 // append space and old params 2463 xstrcatc(pstrParams, ' '); 2464 xstrcat(pstrParams, 2465 pszOldParams, 2466 ulOldParamsLength); 2467 free(pszOldParams); 2468 } 2457 2469 2458 2470 // set executable to $(OS2_SHELL) … … 2508 2520 { 2509 2521 HAPP happ = NULLHANDLE; 2510 PSZ pszParamsPatched = NULL;2522 XSTRING strParamsPatched; 2511 2523 BOOL fIsWindowsApp = FALSE, 2512 2524 fIsWindowsEnhApp = FALSE; … … 2527 2539 // we need this for string manipulations below... 2528 2540 if (ProgDetails.pszParameters) 2529 pszParamsPatched = strdup(ProgDetails.pszParameters); 2541 xstrInitCopy(&strParamsPatched, 2542 ProgDetails.pszParameters, 2543 100); 2544 else 2545 // no old params: 2546 xstrInit(&strParamsPatched, 100); 2530 2547 2531 2548 // _Pmpf((__FUNCTION__ ": old progc: 0x%lX", pcProgDetails->progt.progc)); … … 2587 2604 { 2588 2605 // enhanced Win-OS/2 session: 2589 XSTRING str2; 2590 xstrInit(&str2, 200); 2591 xstrcpy(&str2, "/3 "); 2592 if (pszParamsPatched) 2606 PSZ psz = NULL; 2607 if (strParamsPatched.ulLength) 2608 // "/3 " + existing params 2609 psz = strdup(strParamsPatched.psz); 2610 2611 xstrcpy(&strParamsPatched, "/3 ", 0); 2612 2613 if (psz) 2593 2614 { 2594 // append existing params 2595 xstrcat(&str2, pszParamsPatched); 2596 free(pszParamsPatched); 2615 xstrcat(&strParamsPatched, psz, 0); 2616 free(psz); 2597 2617 } 2598 2599 pszParamsPatched = str2.psz;2600 2618 } 2601 2619 … … 2633 2651 { 2634 2652 CallBatchCorrectly(&ProgDetails, 2635 & pszParamsPatched,2653 &strParamsPatched, 2636 2654 "OS2_SHELL", 2637 2655 "CMD.EXE"); … … 2649 2667 { 2650 2668 CallBatchCorrectly(&ProgDetails, 2651 & pszParamsPatched,2669 &strParamsPatched, 2652 2670 NULL, 2653 2671 "COMMAND.COM"); … … 2716 2734 // _Pmpf((" new progc: 0x%lX", ProgDetails.progt.progc)); 2717 2735 2718 ProgDetails.pszParameters = pszParamsPatched;2736 ProgDetails.pszParameters = strParamsPatched.psz; 2719 2737 2720 2738 happ = WinStartApp(hwndNotify, 2721 2739 // receives WM_APPTERMINATENOTIFY 2722 2740 &ProgDetails, 2723 pszParamsPatched,2741 strParamsPatched.psz, 2724 2742 NULL, // "reserved", PMREF says... 2725 2743 SAF_INSTALLEDCMDLINE); … … 2734 2752 // _Pmpf((__FUNCTION__ ": got happ 0x%lX", happ)); 2735 2753 2736 if (pszParamsPatched) 2737 free(pszParamsPatched); 2754 xstrClear(&strParamsPatched); 2738 2755 if (pszWinOS2Env) 2739 2756 free(pszWinOS2Env); … … 3068 3085 *@@ winhReplaceWindowText: 3069 3086 * this is a combination of winhQueryWindowText 3070 * and xstrrpl (stringh.c) to replace substrings 3071 * in a window. 3087 * and strhFindReplace to replace substrings in a window. 3072 3088 * 3073 3089 * This is useful for filling in placeholders … … 3093 3109 { 3094 3110 ULONG ulOfs = 0; 3095 if (strh rpl(&pszText, &ulOfs, pszSearch, pszReplaceWith) > 0)3111 if (strhFindReplace(&pszText, &ulOfs, pszSearch, pszReplaceWith) > 0) 3096 3112 { 3097 3113 WinSetWindowText(hwnd, pszText);
Note:
See TracChangeset
for help on using the changeset viewer.