Changeset 212 for trunk/src/helpers/apps.c
- Timestamp:
- Aug 22, 2002, 9:45:41 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/apps.c
r209 r212 801 801 * 802 802 *@@added V0.9.20 (2002-07-03) [umoeller] 803 *@@changed V0.9.21 (2002-08-21) [umoeller]: now allowing for UNC 803 804 */ 804 805 … … 811 812 // check if the executable is fully qualified; if so, 812 813 // check if the executable file exists 813 if ( (pDetails->pszExecutable[1] == ':') 814 && (strchr(pDetails->pszExecutable, '\\')) 814 if ( // allow UNC V0.9.21 (2002-08-21) [umoeller] 815 ( (pDetails->pszExecutable[0] == '\\') 816 && (pDetails->pszExecutable[1] == '\\') 817 ) 818 || ( (pDetails->pszExecutable[1] == ':') 819 && (strchr(pDetails->pszExecutable, '\\')) 820 ) 815 821 ) 816 822 { … … 1180 1186 1181 1187 PROGDETAILS Details; 1188 ULONG ulIsWinApp; 1189 1190 // parameter checking extended V0.9.21 (2002-08-21) [umoeller] 1191 if ( (!pcProgDetails) 1192 || (!pcProgDetails->pszExecutable) 1193 || (!pcProgDetails->pszExecutable[0]) 1194 || (!ppDetails) 1195 ) 1196 return ERROR_INVALID_PARAMETER; 1182 1197 1183 1198 *ppDetails = NULL; 1184 1185 if (!pcProgDetails && !ppDetails)1186 return ERROR_INVALID_PARAMETER;1187 1199 1188 1200 /* … … 1199 1211 Details.progt.fbVisible = SHE_VISIBLE; 1200 1212 1201 // all this only makes sense if this contains something... 1202 // besides, this crashed on string comparisons V0.9.9 (2001-01-27) [umoeller] 1203 if ( (!Details.pszExecutable) 1204 || (!Details.pszExecutable[0]) 1213 // memset(&Details.swpInitial, 0, sizeof(SWP)); 1214 // this wasn't a good idea... WPProgram stores stuff 1215 // in here, such as the "minimize on startup" -> SWP_MINIMIZE 1216 1217 // duplicate parameters... 1218 // we need this for string manipulations below... 1219 if ( (Details.pszParameters) 1220 && (Details.pszParameters[0]) // V0.9.18 1205 1221 ) 1206 arc = ERROR_INVALID_PARAMETER; 1207 else 1208 { 1209 ULONG ulIsWinApp; 1210 1211 // memset(&Details.swpInitial, 0, sizeof(SWP)); 1212 // this wasn't a good idea... WPProgram stores stuff 1213 // in here, such as the "minimize on startup" -> SWP_MINIMIZE 1214 1215 // duplicate parameters... 1216 // we need this for string manipulations below... 1217 if ( (Details.pszParameters) 1218 && (Details.pszParameters[0]) // V0.9.18 1219 ) 1220 xstrcpy(&strParamsPatched, 1221 Details.pszParameters, 1222 0); 1223 1224 #ifdef DEBUG_PROGRAMSTART 1225 _PmpfF((" old progc: 0x%lX", pcProgDetails->progt.progc)); 1226 _Pmpf((" pszTitle: %s", STRINGORNULL(Details.pszTitle))); 1227 _Pmpf((" pszExecutable: %s", STRINGORNULL(Details.pszExecutable))); 1228 _Pmpf((" pszParameters: %s", STRINGORNULL(Details.pszParameters))); 1229 _Pmpf((" pszIcon: %s", STRINGORNULL(Details.pszIcon))); 1230 #endif 1231 1232 // program type fixups 1233 switch (Details.progt.progc) // that's a ULONG 1234 { 1235 case ((ULONG)-1): // we get that sometimes... 1236 case PROG_DEFAULT: 1237 { 1238 // V0.9.12 (2001-05-26) [umoeller] 1239 ULONG ulDosAppType; 1240 appQueryAppType(Details.pszExecutable, 1241 &ulDosAppType, 1242 &Details.progt.progc); 1243 } 1244 break; 1245 } 1246 1247 // set session type from option flags 1222 xstrcpy(&strParamsPatched, 1223 Details.pszParameters, 1224 0); 1225 1226 #ifdef DEBUG_PROGRAMSTART 1227 _PmpfF((" old progc: 0x%lX", pcProgDetails->progt.progc)); 1228 _Pmpf((" pszTitle: %s", STRINGORNULL(Details.pszTitle))); 1229 _Pmpf((" pszExecutable: %s", STRINGORNULL(Details.pszExecutable))); 1230 _Pmpf((" pszParameters: %s", STRINGORNULL(Details.pszParameters))); 1231 _Pmpf((" pszIcon: %s", STRINGORNULL(Details.pszIcon))); 1232 #endif 1233 1234 // program type fixups 1235 switch (Details.progt.progc) // that's a ULONG 1236 { 1237 case ((ULONG)-1): // we get that sometimes... 1238 case PROG_DEFAULT: 1239 { 1240 // V0.9.12 (2001-05-26) [umoeller] 1241 ULONG ulDosAppType; 1242 appQueryAppType(Details.pszExecutable, 1243 &ulDosAppType, 1244 &Details.progt.progc); 1245 } 1246 break; 1247 } 1248 1249 // set session type from option flags 1250 if (ulFlags & APP_RUN_FULLSCREEN) 1251 { 1252 if (Details.progt.progc == PROG_WINDOWABLEVIO) 1253 Details.progt.progc = PROG_FULLSCREEN; 1254 else if (Details.progt.progc == PROG_WINDOWEDVDM) 1255 Details.progt.progc = PROG_VDM; 1256 } 1257 1258 if (ulIsWinApp = appIsWindowsApp(Details.progt.progc)) 1259 { 1248 1260 if (ulFlags & APP_RUN_FULLSCREEN) 1249 { 1250 if (Details.progt.progc == PROG_WINDOWABLEVIO) 1251 Details.progt.progc = PROG_FULLSCREEN; 1252 else if (Details.progt.progc == PROG_WINDOWEDVDM) 1253 Details.progt.progc = PROG_VDM; 1254 } 1255 1256 if (ulIsWinApp = appIsWindowsApp(Details.progt.progc)) 1257 { 1258 if (ulFlags & APP_RUN_FULLSCREEN) 1259 Details.progt.progc = (ulFlags & APP_RUN_ENHANCED) 1260 ? PROG_31_ENH 1261 : PROG_31_STD; 1262 else 1263 { 1264 if (ulFlags & APP_RUN_STANDARD) 1265 Details.progt.progc = (ulFlags & APP_RUN_SEPARATE) 1266 ? PROG_31_STDSEAMLESSVDM 1267 : PROG_31_STDSEAMLESSCOMMON; 1268 else if (ulFlags & APP_RUN_ENHANCED) 1269 Details.progt.progc = (ulFlags & APP_RUN_SEPARATE) 1270 ? PROG_31_ENHSEAMLESSVDM 1271 : PROG_31_ENHSEAMLESSCOMMON; 1272 } 1273 1274 // re-run V0.9.16 (2001-10-19) [umoeller] 1275 ulIsWinApp = appIsWindowsApp(Details.progt.progc); 1276 } 1277 1261 Details.progt.progc = (ulFlags & APP_RUN_ENHANCED) 1262 ? PROG_31_ENH 1263 : PROG_31_STD; 1264 else 1265 { 1266 if (ulFlags & APP_RUN_STANDARD) 1267 Details.progt.progc = (ulFlags & APP_RUN_SEPARATE) 1268 ? PROG_31_STDSEAMLESSVDM 1269 : PROG_31_STDSEAMLESSCOMMON; 1270 else if (ulFlags & APP_RUN_ENHANCED) 1271 Details.progt.progc = (ulFlags & APP_RUN_SEPARATE) 1272 ? PROG_31_ENHSEAMLESSVDM 1273 : PROG_31_ENHSEAMLESSCOMMON; 1274 } 1275 1276 // re-run V0.9.16 (2001-10-19) [umoeller] 1277 ulIsWinApp = appIsWindowsApp(Details.progt.progc); 1278 } 1279 1280 /* 1281 * command lines fixups: 1282 * 1283 */ 1284 1285 if (!strcmp(Details.pszExecutable, "*")) 1286 { 1278 1287 /* 1279 * command lines fixups:1288 * "*" for command sessions: 1280 1289 * 1281 1290 */ 1282 1291 1283 if (!strcmp(Details.pszExecutable, "*")) 1284 { 1285 /* 1286 * "*" for command sessions: 1287 * 1288 */ 1289 1290 if (ulIsWinApp) 1292 if (ulIsWinApp) 1293 { 1294 // cheat: WinStartApp doesn't support NULL 1295 // for Win-OS2 sessions, so manually start winos2.com 1296 Details.pszExecutable = "WINOS2.COM"; 1297 // this is a DOS app, so fix this to DOS fullscreen 1298 Details.progt.progc = PROG_VDM; 1299 1300 if (ulIsWinApp == 2) 1291 1301 { 1292 // cheat: WinStartApp doesn't support NULL 1293 // for Win-OS2 sessions, so manually start winos2.com 1294 Details.pszExecutable = "WINOS2.COM"; 1295 // this is a DOS app, so fix this to DOS fullscreen 1296 Details.progt.progc = PROG_VDM; 1297 1298 if (ulIsWinApp == 2) 1302 // enhanced Win-OS/2 session: 1303 PSZ psz = NULL; 1304 if (strParamsPatched.ulLength) 1305 // "/3 " + existing params 1306 psz = strdup(strParamsPatched.psz); 1307 1308 xstrcpy(&strParamsPatched, "/3 ", 0); 1309 1310 if (psz) 1299 1311 { 1300 // enhanced Win-OS/2 session: 1301 PSZ psz = NULL; 1302 if (strParamsPatched.ulLength) 1303 // "/3 " + existing params 1304 psz = strdup(strParamsPatched.psz); 1305 1306 xstrcpy(&strParamsPatched, "/3 ", 0); 1307 1308 if (psz) 1309 { 1310 xstrcat(&strParamsPatched, psz, 0); 1311 free(psz); 1312 } 1312 xstrcat(&strParamsPatched, psz, 0); 1313 free(psz); 1313 1314 } 1314 1315 } 1315 else 1316 // for all other executable types 1317 // (including OS/2 and DOS sessions), 1318 // set pszExecutable to NULL; this will 1319 // have WinStartApp start a cmd shell 1320 Details.pszExecutable = NULL; 1321 1322 } // end if (strcmp(pProgDetails->pszExecutable, "*") == 0) 1323 1324 // else 1325 1326 // no, this else breaks the WINOS2.COM hack above... we 1327 // need to look for that on the PATH as well 1328 // V0.9.20 (2002-07-03) [umoeller] 1329 if (Details.pszExecutable) 1330 { 1331 // check the executable and look for it on the 1332 // PATH if necessary 1333 if (!(arc = CheckAndQualifyExecutable(&Details, 1334 &strExecutablePatched))) 1316 } 1317 else 1318 // for all other executable types 1319 // (including OS/2 and DOS sessions), 1320 // set pszExecutable to NULL; this will 1321 // have WinStartApp start a cmd shell 1322 Details.pszExecutable = NULL; 1323 1324 } // end if (strcmp(pProgDetails->pszExecutable, "*") == 0) 1325 1326 // else 1327 1328 // no, this else breaks the WINOS2.COM hack above... we 1329 // need to look for that on the PATH as well 1330 // V0.9.20 (2002-07-03) [umoeller] 1331 if (Details.pszExecutable) 1332 { 1333 // check the executable and look for it on the 1334 // PATH if necessary 1335 if (!(arc = CheckAndQualifyExecutable(&Details, 1336 &strExecutablePatched))) 1337 { 1338 PSZ pszExtension; 1339 1340 // make sure startup dir is really a directory 1341 // V0.9.20 (2002-07-03) [umoeller]: moved this down 1342 if (Details.pszStartupDir) 1335 1343 { 1336 PSZ pszExtension; 1337 1338 // make sure startup dir is really a directory 1339 // V0.9.20 (2002-07-03) [umoeller]: moved this down 1340 if (Details.pszStartupDir) 1341 { 1342 ULONG ulAttr; 1343 // it is valid to specify a startup dir of "C:" 1344 if ( (strlen(Details.pszStartupDir) > 2) 1345 && (!(arc = doshQueryPathAttr(Details.pszStartupDir, 1346 &ulAttr))) 1347 && (!(ulAttr & FILE_DIRECTORY)) 1348 ) 1349 arc = ERROR_PATH_NOT_FOUND; 1350 } 1344 ULONG ulAttr; 1345 // it is valid to specify a startup dir of "C:" 1346 if ( (strlen(Details.pszStartupDir) > 2) 1347 && (!(arc = doshQueryPathAttr(Details.pszStartupDir, 1348 &ulAttr))) 1349 && (!(ulAttr & FILE_DIRECTORY)) 1350 ) 1351 arc = ERROR_PATH_NOT_FOUND; 1352 } 1351 1353 1352 1354 // V0.9.21: this define is never set. I have thus completely … … 1361 1363 #ifdef ENABLEBATCHHACKS 1362 1364 1363 // we frequently get here for BAT and CMD files 1364 // with progtype == PROG_DEFAULT, so include 1365 // that in the check, or all BAT files will fail 1366 // V0.9.20 (2002-07-03) [umoeller] 1367 1368 switch (Details.progt.progc) 1365 // we frequently get here for BAT and CMD files 1366 // with progtype == PROG_DEFAULT, so include 1367 // that in the check, or all BAT files will fail 1368 // V0.9.20 (2002-07-03) [umoeller] 1369 1370 switch (Details.progt.progc) 1371 { 1372 /* 1373 * .CMD files fixups 1374 * 1375 */ 1376 1377 case PROG_DEFAULT: // V0.9.20 (2002-07-03) [umoeller] 1378 case PROG_FULLSCREEN: // OS/2 fullscreen 1379 case PROG_WINDOWABLEVIO: // OS/2 window 1369 1380 { 1370 /* 1371 * .CMD files fixups 1372 * 1373 */ 1374 1375 case PROG_DEFAULT: // V0.9.20 (2002-07-03) [umoeller] 1376 case PROG_FULLSCREEN: // OS/2 fullscreen 1377 case PROG_WINDOWABLEVIO: // OS/2 window 1381 if ( (pszExtension = doshGetExtension(Details.pszExecutable)) 1382 && (!stricmp(pszExtension, "CMD")) 1383 ) 1378 1384 { 1379 if ( (pszExtension = doshGetExtension(Details.pszExecutable)) 1380 && (!stricmp(pszExtension, "CMD")) 1381 ) 1382 { 1383 arc = CallBatchCorrectly(&Details, 1384 &strExecutablePatched, 1385 &strParamsPatched, 1386 "OS2_SHELL", 1387 "CMD.EXE"); 1388 } 1385 arc = CallBatchCorrectly(&Details, 1386 &strExecutablePatched, 1387 &strParamsPatched, 1388 "OS2_SHELL", 1389 "CMD.EXE"); 1389 1390 } 1390 break;1391 1391 } 1392 1393 switch (Details.progt.progc) 1392 break; 1393 } 1394 1395 switch (Details.progt.progc) 1396 { 1397 case PROG_DEFAULT: // V0.9.20 (2002-07-03) [umoeller] 1398 case PROG_VDM: // DOS fullscreen 1399 case PROG_WINDOWEDVDM: // DOS window 1394 1400 { 1395 case PROG_DEFAULT: // V0.9.20 (2002-07-03) [umoeller]1396 case PROG_VDM: // DOS fullscreen1397 case PROG_WINDOWEDVDM: // DOS window1401 if ( (pszExtension = doshGetExtension(Details.pszExecutable)) 1402 && (!stricmp(pszExtension, "BAT")) 1403 ) 1398 1404 { 1399 if ( (pszExtension = doshGetExtension(Details.pszExecutable)) 1400 && (!stricmp(pszExtension, "BAT")) 1401 ) 1402 { 1403 arc = CallBatchCorrectly(&Details, 1404 &strExecutablePatched, 1405 &strParamsPatched, 1406 // there is no environment variable 1407 // for the DOS shell 1408 NULL, 1409 "COMMAND.COM"); 1410 } 1405 arc = CallBatchCorrectly(&Details, 1406 &strExecutablePatched, 1407 &strParamsPatched, 1408 // there is no environment variable 1409 // for the DOS shell 1410 NULL, 1411 "COMMAND.COM"); 1411 1412 } 1412 break; 1413 } // end switch (Details.progt.progc) 1413 } 1414 break; 1415 } // end switch (Details.progt.progc) 1414 1416 #endif // ENABLEBATCHHACKS 1417 } 1418 } 1419 1420 if (!arc) 1421 { 1422 if ( (ulIsWinApp) 1423 && ( (!(Details.pszEnvironment)) 1424 || (!(*Details.pszEnvironment)) 1425 ) 1426 ) 1427 { 1428 // this is a windoze app, and caller didn't bother 1429 // to give us an environment: 1430 // we MUST set one then, or we'll get the strangest 1431 // errors, up to system hangs. V0.9.12 (2001-05-26) [umoeller] 1432 1433 DOSENVIRONMENT Env = {0}; 1434 1435 // get standard WIN-OS/2 environment 1436 PSZ pszTemp; 1437 if (!(arc = appQueryDefaultWin31Environment(&pszTemp))) 1438 { 1439 if (!(arc = appParseEnvironment(pszTemp, 1440 &Env))) 1441 { 1442 // now override KBD_CTRL_BYPASS=CTRL_ESC 1443 if ( (!(arc = appSetEnvironmentVar(&Env, 1444 "KBD_CTRL_BYPASS=CTRL_ESC", 1445 FALSE))) // add last 1446 && (!(arc = appConvertEnvironment(&Env, 1447 &pszWinOS2Env, // freed at bottom 1448 NULL))) 1449 ) 1450 Details.pszEnvironment = pszWinOS2Env; 1451 1452 appFreeEnvironment(&Env); 1453 } 1454 1455 free(pszTemp); 1415 1456 } 1416 1457 } … … 1418 1459 if (!arc) 1419 1460 { 1420 if ( (ulIsWinApp) 1421 && ( (!(Details.pszEnvironment)) 1422 || (!(*Details.pszEnvironment)) 1423 ) 1424 ) 1461 // if no title is given, use the executable 1462 if (!Details.pszTitle) 1463 Details.pszTitle = Details.pszExecutable; 1464 1465 // make sure params have a leading space 1466 // V0.9.18 (2002-03-27) [umoeller] 1467 if (strParamsPatched.ulLength) 1425 1468 { 1426 // this is a windoze app, and caller didn't bother 1427 // to give us an environment: 1428 // we MUST set one then, or we'll get the strangest 1429 // errors, up to system hangs. V0.9.12 (2001-05-26) [umoeller] 1430 1431 DOSENVIRONMENT Env = {0}; 1432 1433 // get standard WIN-OS/2 environment 1434 PSZ pszTemp; 1435 if (!(arc = appQueryDefaultWin31Environment(&pszTemp))) 1469 if (strParamsPatched.psz[0] != ' ') 1436 1470 { 1437 if (!(arc = appParseEnvironment(pszTemp, 1438 &Env))) 1439 { 1440 // now override KBD_CTRL_BYPASS=CTRL_ESC 1441 if ( (!(arc = appSetEnvironmentVar(&Env, 1442 "KBD_CTRL_BYPASS=CTRL_ESC", 1443 FALSE))) // add last 1444 && (!(arc = appConvertEnvironment(&Env, 1445 &pszWinOS2Env, // freed at bottom 1446 NULL))) 1447 ) 1448 Details.pszEnvironment = pszWinOS2Env; 1449 1450 appFreeEnvironment(&Env); 1451 } 1452 1453 free(pszTemp); 1471 XSTRING str2; 1472 xstrInit(&str2, 0); 1473 xstrcpy(&str2, " ", 1); 1474 xstrcats(&str2, &strParamsPatched); 1475 xstrcpys(&strParamsPatched, &str2); 1476 xstrClear(&str2); 1477 // we really need xstrInsert or something 1454 1478 } 1479 Details.pszParameters = strParamsPatched.psz; 1455 1480 } 1456 1457 if (!arc) 1458 { 1459 // if no title is given, use the executable 1460 if (!Details.pszTitle) 1461 Details.pszTitle = Details.pszExecutable; 1462 1463 // make sure params have a leading space 1464 // V0.9.18 (2002-03-27) [umoeller] 1465 if (strParamsPatched.ulLength) 1466 { 1467 if (strParamsPatched.psz[0] != ' ') 1468 { 1469 XSTRING str2; 1470 xstrInit(&str2, 0); 1471 xstrcpy(&str2, " ", 1); 1472 xstrcats(&str2, &strParamsPatched); 1473 xstrcpys(&strParamsPatched, &str2); 1474 xstrClear(&str2); 1475 // we really need xstrInsert or something 1476 } 1477 Details.pszParameters = strParamsPatched.psz; 1478 } 1479 else 1480 // never pass null pointers 1481 Details.pszParameters = ""; 1482 1481 else 1483 1482 // never pass null pointers 1484 if (!Details.pszIcon) 1485 Details.pszIcon = ""; 1486 1487 // never pass null pointers 1488 if (!Details.pszStartupDir) 1489 Details.pszStartupDir = ""; 1490 1491 } 1483 Details.pszParameters = ""; 1484 1485 // never pass null pointers 1486 if (!Details.pszIcon) 1487 Details.pszIcon = ""; 1488 1489 // never pass null pointers 1490 if (!Details.pszStartupDir) 1491 Details.pszStartupDir = ""; 1492 1492 1493 } 1493 1494 } … … 2074 2075 CHAR szDir[CCHMAXPATH] = ""; 2075 2076 PCSZ p; 2076 HWND hwndObject ;2077 HWND hwndObject = NULLHANDLE; 2077 2078 2078 2079 pd.Length = sizeof(pd); … … 2092 2093 } 2093 2094 2094 if ( (hwndObject = winhCreateObjectWindow(WC_STATIC, NULL)) 2095 if (pulExitCode) 2096 if (!(hwndObject = winhCreateObjectWindow(WC_STATIC, NULL))) 2097 arc = ERROR_NOT_ENOUGH_MEMORY; 2098 2099 if ( (!arc) 2095 2100 && (!(arc = appStartApp(hwndObject, 2096 2101 &pd, … … 2105 2110 *phapp, 2106 2111 pulExitCode); 2107 2112 } 2113 2114 if (hwndObject) 2108 2115 WinDestroyWindow(hwndObject); // was missing V0.9.20 (2002-08-10) [umoeller] 2109 }2110 2116 2111 2117 return arc; … … 2121 2127 * 2122 2128 *@@added V0.9.20 (2002-08-10) [umoeller] 2129 *@@changed V0.9.21 (2002-08-21) [umoeller]: changed prototype to return browser 2123 2130 */ 2124 2131 2125 2132 APIRET appOpenURL(PCSZ pcszURL, // in: URL to open 2126 PSZ pszAppStarted, // out: application that was started 2133 PSZ pszAppStarted, // out: application that was started (req.) 2127 2134 ULONG cbAppStarted) // in: size of that buffer 2128 2135 { 2129 APIRET arc = NO_ERROR; 2130 2131 CHAR szBrowser[CCHMAXPATH], 2132 szStartupDir[CCHMAXPATH]; 2136 APIRET arc = ERROR_NO_DATA; 2137 2138 CHAR szStartupDir[CCHMAXPATH]; 2133 2139 XSTRING strParameters; 2140 2141 if ( (!pcszURL) 2142 || (!pszAppStarted) 2143 || (!cbAppStarted) 2144 ) 2145 return ERROR_INVALID_PARAMETER; 2134 2146 2135 2147 xstrInit(&strParameters, 0); … … 2139 2151 "DefaultBrowserExe", 2140 2152 "NETSCAPE.EXE", 2141 szBrowser,2142 sizeof(szBrowser)))2153 pszAppStarted, 2154 cbAppStarted)) 2143 2155 { 2144 2156 PSZ pszDefParams; … … 2164 2176 sizeof(szStartupDir)); 2165 2177 2166 2167 arc = appQuickStartApp(szBrowser, 2178 arc = appQuickStartApp(pszAppStarted, 2168 2179 PROG_DEFAULT, 2169 2180 strParameters.psz, … … 2171 2182 &happ, 2172 2183 NULL); // don't wait 2173 2174 if (pszAppStarted)2175 strhncpy0(pszAppStarted,2176 szBrowser,2177 cbAppStarted);2178 2184 } 2179 2185
Note:
See TracChangeset
for help on using the changeset viewer.