Changeset 1750
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/avl.c
r1625 r1750 43 43 26 Aug 11 GKY Add the code to correctly format the date time strings for tar.gz archives 44 44 viewed using tar 1.15+ 45 01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed. 46 So calls to these functions had to be changed. 45 47 46 48 ***********************************************************************/ … … 76 78 #include "wrappers.h" // xfgets 77 79 #include "strips.h" // bstrip 78 #include "srchpath.h" // searchpath80 #include "srchpath.h" // Search*Path*ForFile 79 81 #include "stristr.h" // stristr 80 82 #include "delims.h" // to_delim … … 376 378 arcsigs_trailer_line_num = 0; 377 379 378 //DosEnterCritSec(); //GKY 11-29-08 379 DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT); 380 psz = searchpath(PCSZ_ARCHIVERBB2); 381 if (!psz || !*psz) { 380 { 381 CHAR szFullFilename[CCHMAXPATH]; 382 383 DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT); 384 if (SearchMultiplePathsForFile(PCSZ_ARCHIVERBB2, szFullFilename)) { 385 DosReleaseMutexSem(hmtxFM2Globals); 386 return -1; 387 } 388 stat(szFullFilename, &Archiverbb2Stats); 389 fp = xfsopen(szFullFilename, moder, SH_DENYWR, pszSrcFile, __LINE__, TRUE); 382 390 DosReleaseMutexSem(hmtxFM2Globals); 383 //DosExitCritSec(); 384 return -1; 391 if (!fp) 392 return -2; 393 strcpy(archiverbb2, szFullFilename); // Remember full path 385 394 } 386 stat(psz, &Archiverbb2Stats);387 fp = xfsopen(psz, moder, SH_DENYWR, pszSrcFile, __LINE__, TRUE);388 DosReleaseMutexSem(hmtxFM2Globals);389 //DosExitCritSec();390 if (!fp)391 return -2;392 strcpy(archiverbb2, psz); // Remember full path393 395 394 396 cur_line_num = 0; … … 790 792 struct stat Buffer; 791 793 792 stat(searchpath(PCSZ_ARCHIVERBB2), &Buffer); 794 // stat(searchpath(PCSZ_ARCHIVERBB2), &Buffer); 795 stat(archiverbb2, &Buffer); // jbs: Re-use full name set by load_achivers 793 796 if (Archiverbb2Stats.st_size != Buffer.st_size || 794 Archiverbb2Stats.st_mtime != Buffer.st_mtime) 795 if (saymsg(MB_YESNO, 797 Archiverbb2Stats.st_mtime != Buffer.st_mtime) 798 if (saymsg(MB_YESNO, 796 799 hwnd, 797 800 GetPString(IDS_ADCHANGESONDISKTEXT), … … 887 890 GetPString(IDS_ADCHANGESINMEMTEXT), 888 891 GetPString(IDS_ADREWRITETEXT), NullStr) == MBID_YES) { 889 PSZ ab2 = searchpath(PCSZ_ARCHIVERBB2); // Rewrite without prompting890 891 rewrite_archiverbb2(a b2);892 // 524 PSZ ab2 = searchpath(PCSZ_ARCHIVERBB2); // Rewrite without prompting 893 894 rewrite_archiverbb2(archiverbb2); // jbs: Re-use full path set by load_archivers 892 895 } 893 896 } -
trunk/dll/avv.c
r1746 r1750 34 34 24 Feb 14 JBS Ticket #517: Replaced a call to DosQueryAppType to a call to the wrapped xDosQueryApptType 35 35 24 Feb 14 JBS Ticket #523: Stop considering missing "list", "create" or "extract" commands as errors 36 01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed. 37 So calls to these functions had to be changed and checkfile's signature was changed. 36 38 37 39 ***********************************************************************/ … … 64 66 #include "strips.h" // bstrip 65 67 #include "misc.h" // CheckDriveSpaceAvail 66 #include "srchpath.h" // searchpath68 #include "srchpath.h" // Search*Path*ForFile 67 69 #include "systemf.h" // runemf2 68 70 #include "fortify.h" … … 73 75 static PSZ pszSrcFile = __FILE__; 74 76 75 static PSZ checkfile(PSZ file, INT * error);77 static ULONG checkfile(PSZ file); 76 78 static BOOL check_archiver(HWND hwnd, ARC_TYPE * info); 77 79 static INT get_int_from_window(HWND hwnd, USHORT id); … … 393 395 } 394 396 395 static PSZ checkfile(PSZ file, INT * error) 396 { 397 CHAR *p, *pp = NULL; 398 INT ret; 397 /** 398 * checkfile: Determine if a program is reachable and of an acceptable type. 399 * 400 * @param pFilename: the name of a program file to check (input) 401 * 402 * @return 0 if the program reachable and of an acceptable type 403 * 1 if the program is unreachable (or pFilename is invalid) 404 * 2 if the program is of an unacceptable type 405 * 3 if pFilename is null or points to a null string 406 * 407 */ 408 static ULONG checkfile(PSZ file) 409 { 410 CHAR szFullFilename[CCHMAXPATH], *pp = NULL; 411 ULONG ret; 399 412 ULONG apptype; 400 413 401 414 if (!file || !*file) { 402 *error = 3; 403 return NULL; 415 return 3; 404 416 } 405 417 pp = strchr(file, ' '); 406 418 if (pp) 407 419 *pp = 0; 408 p = searchpath(file);409 if (!p || !*p)410 *error = 1;420 if (SearchPathForFile(PCSZ_PATH, file, szFullFilename)) { 421 ret = 1; 422 } 411 423 else { 412 ret = (INT) xDosQueryAppType(p, &apptype);424 ret = xDosQueryAppType(szFullFilename, &apptype); 413 425 apptype &= (~FAPPTYP_32BIT); 414 426 if (!apptype || … … 417 429 (apptype & FAPPTYP_BOUND) || 418 430 (apptype & FAPPTYP_WINDOWAPI) || (apptype & FAPPTYP_DOS)) { 419 *error= 0;431 ret = 0; 420 432 } 421 433 else 422 *error= 2;434 ret = 2; 423 435 } 424 436 if (pp) 425 437 *pp = ' '; 426 return p;438 return ret; 427 439 } 428 440 … … 444 456 badPos = TRUE; 445 457 if (info->list) 446 checkfile(info->list, &badList);458 badList = checkfile(info->list); 447 459 if (info->create) 448 checkfile(info->create, &badCreate);460 badCreate = checkfile(info->create); 449 461 if (info->extract) 450 checkfile(info->extract, &badExtract);462 badExtract = checkfile(info->extract); 451 463 if (!noStart && !noEnd && !badPos && !badList && !badCreate && !badExtract) 452 464 return TRUE; // OK … … 927 939 MBID_YES) { 928 940 929 PSZ ab2;930 931 ab2 = searchpath(PCSZ_ARCHIVERBB2); // Rewrite without alerting932 rewrite_archiverbb2(a b2);941 // PSZ ab2; 942 943 // ab2 = searchpath(PCSZ_ARCHIVERBB2); // Rewrite without alerting 944 rewrite_archiverbb2(archiverbb2); // jbs: Re-use path set by load_archivers 933 945 } 934 946 } -
trunk/dll/cmdline.c
r1749 r1750 437 437 *p = 0; 438 438 if (IsFile(executable) == -1) { 439 p = searchpath(executable); 440 if (*p) 441 strcpy(executable, p); 442 else { 439 // p = searchpath(executable); 440 // if (*p) 441 if (SearchPathForFile(PCSZ_PATH, executable, executable)) // jbs: OK to have same source and destination? 442 // strcpy(executable, p); 443 // else { 443 444 WinSetDlgItemText(hwnd, 444 445 EXEC_WARNING2, 445 446 (CHAR *) GetPString(IDS_CANTFINDFILETEXT)); 446 447 break; 447 }448 // } 448 449 } 449 450 } -
trunk/dll/init.c
r1743 r1750 124 124 23 Feb 14 JBS Ticket #515: Corrected a mis-coded call to strtol which was causing the traps 125 125 described in this ticket. (Also changed it to strtoul.) 126 01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed. 127 So calls to these functions had to be changed. 126 128 127 129 ***********************************************************************/ … … 196 198 #include "strips.h" // bstrip 197 199 #include "killproc.h" // GetDosPgmName 198 #include "srchpath.h" // searchpath200 #include "srchpath.h" // Search*Path*ForFile 199 201 #include "fortify.h" 200 202 #include "excputil.h" // xbeginthread … … 898 900 } 899 901 else { 900 env = searchpath(profile); 901 if (!env) 902 env = profile; 903 strcpy(inipath, env); 902 CHAR szFullFilename[CCHMAXPATH]; 903 if (!SearchMultiplePathsForFile(profile, szFullFilename)) { 904 strcpy(inipath, szFullFilename); 905 } else { 906 strcpy(inipath, profile); 907 } 904 908 } //fixme the DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11 905 909 if (!*inipath) … … 1211 1215 } 1212 1216 { // Check for the existance of various partitioning tools to set up menu items 1213 CHAR *FullPath;1214 1217 ULONG ulAppType; 1215 1218 1216 FullPath = searchapath(PCSZ_PATH, PCSZ_LVMGUICMD); 1217 if (*FullPath) 1219 if (!SearchPathForFile(PCSZ_PATH, PCSZ_LVMGUICMD, NULL)) 1218 1220 fLVMGui = TRUE; 1219 1221 if (!xDosQueryAppType(PCSZ_DFSOS2EXE, &ulAppType)) -
trunk/dll/pathutil.c
r1699 r1750 19 19 23 Oct 10 GKY Add ForwardslashToBackslash function to streamline code 20 20 17 Sep 11 GKY Fix commandline quoting issues 21 01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed. 22 So calls to these functions had to be changed. 21 23 22 24 ***********************************************************************/ … … 33 35 #include "init.h" // Data declaration(s) 34 36 #include "fm3str.h" 35 #include "srchpath.h" // searchapath37 #include "srchpath.h" // Search*Path*ForFile 36 38 #include "pathutil.h" 37 39 #include "strips.h" // remove_first_occurence_of_character … … 157 159 ULONG ulAppType; 158 160 char *pszChar; 159 char *FullPath;160 161 PSZ pszNewCmdLine = pszWorkBuf; 161 162 … … 210 211 pszCmdLine_); 211 212 if (!offsetexe && !offsetcom) { 212 FullPath = searchapath(PCSZ_PATH, szCmdLine); 213 if (*FullPath) 214 ret = 0; 213 if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) 214 ret = 0; 215 215 } 216 216 else … … 257 257 *offset = 0; 258 258 strcat(szCmdLine, PCSZ_DOTCMD); 259 FullPath = searchapath(PCSZ_PATH, szCmdLine); 260 if (*FullPath) 259 if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) 261 260 ret = 0; 262 261 else { 263 262 *offset = 0; 264 263 strcat(szCmdLine, PCSZ_DOTBAT); 265 FullPath = searchapath(PCSZ_PATH, szCmdLine); 266 if (*FullPath) 264 if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) 267 265 ret = 0; 268 266 else { 269 267 *offset = 0; 270 268 strcat(szCmdLine, PCSZ_DOTBTM); 271 FullPath = searchapath(PCSZ_PATH, szCmdLine); 272 if (*FullPath) 269 if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) 273 270 ret = 0; 274 271 } … … 296 293 *offset = 0; 297 294 strcat(szCmdLine, PCSZ_DOTCMD); 298 FullPath = searchapath(PCSZ_PATH, szCmdLine); 299 if (*FullPath) { 295 if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) { 300 296 ret = 0; 301 297 break; … … 304 300 *offset = 0; 305 301 strcat(szCmdLine, PCSZ_DOTBAT); 306 FullPath = searchapath(PCSZ_PATH, szCmdLine); 307 if (*FullPath) { 302 if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) { 308 303 ret = 0; 309 304 break; … … 312 307 *offset = 0; 313 308 strcat(szCmdLine, PCSZ_DOTBTM); 314 FullPath = searchapath(PCSZ_PATH, szCmdLine); 315 if (*FullPath) { 309 if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) { 316 310 ret = 0; 317 311 break; … … 372 366 GetPString(IDS_QUOTESINARGSTEXT), 373 367 pszCmdLine_); 374 FullPath = searchapath(PCSZ_PATH, szCmdLine);375 368 BldQuotedFileName(pszNewCmdLine, szCmdLine); 376 if ( !*FullPath) {369 if (SearchPathForFile(PCSZ_PATH, szCmdLine, NULL)) { 377 370 ret = saymsg(MB_YESNO, 378 371 HWND_DESKTOP, -
trunk/dll/srchpath.c
r1673 r1750 14 14 04 Oct 08 JBS Make searchapath non-static 15 15 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *. 16 01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed. 16 17 17 18 ***********************************************************************/ … … 21 22 #define INCL_WIN 22 23 #define INCL_DOS 24 #define INCL_DOSERRORS 23 25 #define INCL_LONGLONG // dircnrs.h 24 26 … … 102 104 103 105 /** 104 * Search for file in name PATH env variable 105 * 23 Aug 07 SHL fixme to be MT safe 106 * SearchPathForFile: Search for a file along a path 107 * 108 * @param pPathname: the name of a path environment variable (input) 109 * Used only if pFilename has no directory separators or ':' for a drive sepcification 110 * 111 * @param pFilename: the name of a file to search for (input) 112 * If the file name includes a directory separator or the ':' for a drive specification then 113 * DosQueryPathInfo is used for the search 114 * else 115 * DosSearchPath is used, along with the pPathname parameter 116 * 117 * @param pFullFilename: address of where to place fully-qulified name if search succeeds (output) 118 * This parameter may be NULL if the fully-qualified filename is not desired. 119 * 120 * @return Return code from call to DosQueryPathInfo/DosSearchPath 121 * 106 122 */ 123 APIRET SearchPathForFile(PCSZ pPathname, 124 PCSZ pFilename, 125 PCHAR pFullFilename) 126 { 127 APIRET rc; 128 CHAR szFullFilename[CCHMAXPATH]; 107 129 108 CHAR *searchapath(PCSZ pathvar, PCSZ filename) 109 { 110 static CHAR fbuf[CCHMAXPATH]; 130 if (!pPathname || !*pPathname || !pFilename || !*pFilename) 131 return ERROR_INVALID_PARAMETER; 111 132 112 if (strchr(filename, '\\') || strchr(filename, '/') 113 || strchr(filename, ':')) { 114 115 FILESTATUS3 fsa; 116 117 strcpy(fbuf, filename); 118 if (!DosQueryPathInfo(fbuf, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) 119 return fbuf; 120 *fbuf = 0; 121 return fbuf; 133 if (strchr(pFilename, '\\') || strchr(pFilename, '/') 134 || strchr(pFilename, ':')) { 135 rc = DosQueryPathInfo(pFilename, FIL_QUERYFULLNAME, 136 (PVOID)szFullFilename, (ULONG) CCHMAXPATH-1); 122 137 } 123 *fbuf = 0; 124 if (DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | 125 SEARCH_CUR_DIRECTORY, 126 (CHAR *) pathvar, (CHAR *) filename, (PBYTE)fbuf, CCHMAXPATH - 1)) 127 *fbuf = 0; 128 return fbuf; 138 else { 139 rc = DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | 140 SEARCH_CUR_DIRECTORY, 141 (CHAR *) pPathname, 142 (CHAR *) pFilename, 143 (PBYTE) szFullFilename, 144 CCHMAXPATH - 1); 145 } 146 if (!rc && pFullFilename) { 147 strcpy(pFullFilename, szFullFilename); 148 } 149 return rc; 129 150 } 130 151 131 CHAR *searchpath(PCSZ filename) 152 /** 153 * SearchMultiplePathsForFile: Search for a file along multiple paths. 154 * Currently these paths are hard-coded to: PATH, DPATH and XPATH. 155 * 156 * @param pFilename: the name of a file to search for (input) 157 * 158 * @param pFullFilename: address of where to place fully-qulified name if search succeeds (output) 159 * This parameter may be NULL if the fully-qualified filename is not desired. 160 * 161 * @return Return code from call to SearchPathForFile (DosQueryPathInfo/DosSearchPath) 162 * 163 * @note: The code uses DosSearchPathForFile for all searches. First it searches PATH. 164 * If this fails it searches DPATH. If this fails it seaches XPATH. 165 * 166 */ 167 APIRET SearchMultiplePathsForFile(PCSZ pFilename, 168 PSZ pFullFilename) 132 169 { 133 CHAR *found;170 APIRET rc; 134 171 135 if (!filename) 136 return NullStr; 137 found = searchapath(PCSZ_PATH, filename); 138 if (!*found) { 139 found = searchapath("DPATH", filename); 140 if (!*found) 141 found = searchapath("XPATH", filename); 172 rc = SearchPathForFile(PCSZ_PATH, 173 pFilename, 174 pFullFilename); 175 if (rc && rc != ERROR_INVALID_PARAMETER) { 176 rc = SearchPathForFile("DPATH", 177 pFilename, 178 pFullFilename); 179 if (rc && rc != ERROR_INVALID_PARAMETER) 180 rc = SearchPathForFile("XPATH", 181 pFilename, 182 pFullFilename); 142 183 } 143 return found;184 return rc; 144 185 } 145 186 146 #pragma alloc_text(MISC9,first_path,searchapath,searchpath,RunFM2Util) 187 //#pragma alloc_text(MISC9,first_path,searchapath,searchpath,RunFM2Util) 188 // jbs: first_path seems to be unused 189 #pragma alloc_text(MISC9,first_path,SearchPathForFile,SearchMultiplePathsForFile,RunFM2Util) -
trunk/dll/srchpath.h
r1398 r1750 12 12 13 13 04 Oct 08 JBS Make searchapath function non-static 14 01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed. 15 14 16 ***********************************************************************/ 15 17 … … 18 20 19 21 INT RunFM2Util(PCSZ appname, CHAR *filename); 20 CHAR *searchapath(PCSZ path, PCSZ filename); 21 CHAR *searchpath(PCSZ filename); 22 22 APIRET SearchPathForFile(PCSZ pPathname, 23 PCSZ pFilename, 24 PCHAR pFullFilename); 25 APIRET SearchMultiplePathsForFile(PCSZ pFilename, 26 PSZ pFullFilename); 23 27 24 28 #endif // SRCHPATH_H -
trunk/dll/tools.c
r1673 r1750 25 25 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used) 26 26 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *. 27 01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed. 28 So calls to these functions had to be changed. 27 29 28 30 ***********************************************************************/ … … 54 56 #include "wrappers.h" // xfgets 55 57 #include "misc.h" // CheckDriveSpaceAvail 56 #include "srchpath.h" // searchpath58 #include "srchpath.h" // Search*Path*ForFile 57 59 #include "stristr.h" // stristr 58 60 #include "valid.h" // IsFile … … 141 143 FILE *fp; 142 144 CHAR help[80], text[80], flagstr[80], idstr[80], *fname; 145 CHAR szFullFilename[CCHMAXPATH]; 143 146 TOOL *info; 144 147 CHAR *moder = "r"; … … 150 153 if (!filename || !*filename) 151 154 filename = (*lasttoolbar) ? lasttoolbar : "CMDS.TLS"; 152 if (*filename) 153 fname = searchpath(filename); 154 if (!fname || !*fname) 155 fname = (PSZ) PCSZ_FM3TOOLSDAT; 155 if (SearchMultiplePathsForFile(filename, szFullFilename)) { 156 if (SearchMultiplePathsForFile(PCSZ_FM3TOOLSDAT, szFullFilename)) 157 fname = NULL; 158 else 159 fname = szFullFilename; 160 } 161 else 162 fname = szFullFilename; 156 163 if (fname && *fname) { 157 164 filename = fname; … … 214 221 { 215 222 FILE *fp; 216 CHAR *fname;217 223 TOOL *info; 218 224 CHAR *modew = "w"; 225 CHAR szFullFilename[CCHMAXPATH]; 219 226 220 227 if (!filename) 221 228 filename = lasttoolbar; 222 if (*filename) 223 fname = searchpath(filename); 224 if (fname && *fname) 225 filename = fname; 229 if (!SearchMultiplePathsForFile(filename, szFullFilename)) 230 filename = szFullFilename; 226 231 else { 227 232 if (*lasttoolbar) 228 233 filename = lasttoolbar; 229 234 else 230 filename = "FM3TOOLS.TLS"; 231 fname = searchpath(filename); 232 if (fname && *fname) 233 filename = fname; 235 filename = "FM3TOOLS.TLS"; // jbs: Why not PCSZ_FM3TOOLSDAT? 236 if (!SearchMultiplePathsForFile(filename, szFullFilename)) 237 filename = szFullFilename; 234 238 } 235 239 236 240 if (stristr(filename, PCSZ_FM3TOOLSDAT)) 237 filename = "FM3TOOLS.TLS"; 241 filename = "FM3TOOLS.TLS"; // jbs: Why not PCSZ_FM3TOOLSDAT? 242 // jbs: Why save full name for toolbar files that are not FM3TOOLS.DAT? 238 243 if (toolhead && filename && *filename) { 239 244 strcpy(lasttoolbar, filename); … … 956 961 HDIR hDir; 957 962 ULONG ulSearchCount, x = 0; 958 CHAR *masks[] = { "*.TLS", "FM3TOOLS.DAT", NULL }; 963 CHAR *masks[] = { "*.TLS", "FM3TOOLS.DAT", NULL }; // jbs: Why not PCSZ_FM3TOOLSDAT? 959 964 960 965 if (mp2)
Note:
See TracChangeset
for help on using the changeset viewer.