Changeset 116 for trunk/src/helpers/dosh.c
- Timestamp:
- Nov 1, 2001, 6:43:18 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dosh.c
r113 r116 64 64 #include <stdio.h> 65 65 #include <stdarg.h> 66 #include <ctype.h> 66 67 67 68 #include "setup.h" // code generation and debugging options … … 357 358 */ 358 359 359 PVOID doshRequestSharedMem( const char *pcszName)360 PVOID doshRequestSharedMem(PCSZ pcszName) 360 361 { 361 362 PVOID pvrc = NULL; … … 682 683 683 684 VOID doshEnumDrives(PSZ pszBuffer, // out: drive letters 684 const char *pcszFileSystem, // in: FS's to match or NULL685 PCSZ pcszFileSystem, // in: FS's to match or NULL 685 686 BOOL fSkipRemoveables) // in: if TRUE, only non-removeable disks will be returned 686 687 { … … 1191 1192 1192 1193 /* 1193 *@@category: Helpers\Control program helpers\File management1194 *@@category: Helpers\Control program helpers\File name parsing 1194 1195 */ 1195 1196 1196 1197 /* ****************************************************************** 1197 1198 * 1198 * File helpers1199 * File name parsing 1199 1200 * 1200 1201 ********************************************************************/ 1202 1203 /* 1204 *@@ doshGetDriveSpec: 1205 * returns the drive specification in pcszFullFile, 1206 * if any is present. This is useful for UNC support. 1207 * 1208 * This returns: 1209 * 1210 * -- NO_ERROR: drive spec was given, and the output 1211 * fields have been set. 1212 * 1213 * -- ERROR_INVALID_NAME: incorrect UNC syntax. 1214 * 1215 * -- ERROR_INVALID_DRIVE: second char is ':', but 1216 * drive letter is not in the range [A-Z]. 1217 * 1218 * -- ERROR_INVALID_PARAMETER: no drive spec given 1219 * at all; apparently pcszFullFile is not fully 1220 * qualified in the first place, or it is NULL, 1221 * or its length is <= 2. 1222 * 1223 *@@added V0.9.16 (2001-10-25) [umoeller] 1224 */ 1225 1226 APIRET doshGetDriveSpec(PCSZ pcszFullFile, // in: fully q'fied file spec 1227 PSZ pszDrive, // out: drive spec ("C:" or "\\SERVER\RESOURCE"; ptr can be NULL) 1228 PULONG pulDriveLen, // out: length of drive spec (2 if local drive; ptr can be NULL) 1229 PBOOL pfIsUNC) // out: set to TRUE if UNC name, FALSE otherwise (ptr can be NULL) 1230 { 1231 APIRET arc = NO_ERROR; 1232 ULONG ulFileSpecLength; 1233 1234 if ( (pcszFullFile) 1235 && (ulFileSpecLength = strlen(pcszFullFile)) 1236 && (ulFileSpecLength >= 2) 1237 ) 1238 { 1239 // upper-case the drive letter 1240 if (pcszFullFile[1] == ':') 1241 { 1242 CHAR cDrive = toupper(*pcszFullFile); 1243 // local drive specified: 1244 if ( (cDrive >= 'A') 1245 && (cDrive <= 'Z') 1246 ) 1247 { 1248 if (pszDrive) 1249 { 1250 pszDrive[0] = cDrive; 1251 pszDrive[1] = ':'; 1252 pszDrive[2] = '\0'; 1253 } 1254 1255 if (pulDriveLen) 1256 *pulDriveLen = 2; 1257 if (pfIsUNC) 1258 *pfIsUNC = FALSE; 1259 } 1260 else 1261 // this is not a valid drive: 1262 arc = ERROR_INVALID_DRIVE; 1263 } 1264 else if ( (pcszFullFile[0] == '\\') 1265 && (pcszFullFile[1] == '\\') 1266 ) 1267 { 1268 // UNC drive specified: 1269 // this better be a full \\SERVER\RESOURCE string 1270 PCSZ pResource; 1271 if (pResource = strchr(pcszFullFile + 3, '\\')) 1272 { 1273 // we got at least \\SERVER\: 1274 ULONG ulLength; 1275 PCSZ p; 1276 1277 // check if more stuff is coming 1278 if (p = strchr(pResource + 1, '\\')) 1279 { 1280 // yes: copy server and resource excluding that backslash 1281 if (p == pResource + 1) 1282 // "\\SERVER\\" is invalid 1283 arc = ERROR_INVALID_NAME; 1284 else 1285 // we got "\\SERVER\something\": 1286 // drop the last backslash 1287 ulLength = p - pcszFullFile; 1288 } 1289 else 1290 // "\\SERVER\something" only: 1291 ulLength = ulFileSpecLength; 1292 1293 if (!arc) 1294 { 1295 if (pszDrive) 1296 { 1297 memcpy(pszDrive, 1298 pcszFullFile, 1299 ulLength); 1300 pszDrive[ulLength] = '\0'; 1301 } 1302 1303 if (pulDriveLen) 1304 *pulDriveLen = ulLength; 1305 if (pfIsUNC) 1306 *pfIsUNC = TRUE; 1307 } 1308 } 1309 else 1310 // invalid UNC name: 1311 arc = ERROR_INVALID_NAME; 1312 } 1313 else 1314 // neither local, nor UNC: 1315 arc = ERROR_INVALID_PARAMETER; 1316 } 1317 else 1318 arc = ERROR_INVALID_PARAMETER; 1319 1320 return (arc); 1321 } 1201 1322 1202 1323 /* … … 1216 1337 */ 1217 1338 1218 PSZ doshGetExtension( const char *pcszFilename)1339 PSZ doshGetExtension(PCSZ pcszFilename) 1219 1340 { 1220 1341 PSZ pReturn = NULL; … … 1223 1344 { 1224 1345 // find filename 1225 const char *p2 = strrchr(pcszFilename + 2, '\\'),1346 PCSZ p2 = strrchr(pcszFilename + 2, '\\'), 1226 1347 // works on "C:\blah" or "\\unc\blah" 1227 *pStartOfName = NULL,1228 *pExtension = NULL;1348 pStartOfName = NULL, 1349 pExtension = NULL; 1229 1350 1230 1351 if (p2) … … 1234 1355 // no backslash found: 1235 1356 // maybe only a drive letter was specified: 1236 if ( *(pcszFilename + 1)== ':')1357 if (pcszFilename[1] == ':') 1237 1358 // yes: 1238 1359 pStartOfName = pcszFilename + 2; … … 1251 1372 return (pReturn); 1252 1373 } 1374 1375 /* 1376 *@@category: Helpers\Control program helpers\File management 1377 */ 1378 1379 /* ****************************************************************** 1380 * 1381 * File helpers 1382 * 1383 ********************************************************************/ 1253 1384 1254 1385 /* … … 1445 1576 */ 1446 1577 1447 APIRET doshOpenExisting( const char *pcszFilename, // in: file name1578 APIRET doshOpenExisting(PCSZ pcszFilename, // in: file name 1448 1579 ULONG ulOpenFlags, // in: open flags 1449 1580 HFILE *phf) // out: OS/2 file handle … … 1552 1683 */ 1553 1684 1554 APIRET doshOpen( const char *pcszFilename, // in: filename to open1685 APIRET doshOpen(PCSZ pcszFilename, // in: filename to open 1555 1686 ULONG ulOpenMode, // in: XOPEN_* mode 1556 1687 PULONG pcbFile, // in: new file size (if new file is created) … … 1756 1887 1757 1888 arc = doshWrite(pFile, 1758 (P VOID)szTemp,1889 (PCSZ)szTemp, 1759 1890 ulLength); 1760 1891 } … … 1823 1954 */ 1824 1955 1825 APIRET doshLoadTextFile( const char *pcszFile, // in: file name to read1956 APIRET doshLoadTextFile(PCSZ pcszFile, // in: file name to read 1826 1957 PSZ* ppszContent) // out: newly allocated buffer with file's content 1827 1958 { … … 1960 2091 1961 2092 APIRET doshCreateTempFileName(PSZ pszTempFileName, // out: fully q'fied temp file name 1962 const char *pcszDir, // in: dir or NULL for %TEMP%1963 const char *pcszPrefix, // in: prefix for temp file or NULL1964 const char *pcszExt) // in: extension (without dot) or NULL2093 PCSZ pcszDir, // in: dir or NULL for %TEMP% 2094 PCSZ pcszPrefix, // in: prefix for temp file or NULL 2095 PCSZ pcszExt) // in: extension (without dot) or NULL 1965 2096 { 1966 2097 APIRET arc = NO_ERROR; … … 2172 2303 */ 2173 2304 2174 BOOL doshQueryDirExist( const char *pcszDir)2305 BOOL doshQueryDirExist(PCSZ pcszDir) 2175 2306 { 2176 2307 FILESTATUS3 fs3; … … 2195 2326 */ 2196 2327 2197 APIRET doshCreatePath( const char *pcszPath,2328 APIRET doshCreatePath(PCSZ pcszPath, 2198 2329 BOOL fHidden) // in: if TRUE, the new directories will get FILE_HIDDEN 2199 2330 { … … 2304 2435 */ 2305 2436 2306 APIRET doshDeleteDir( const char *pcszDir,2437 APIRET doshDeleteDir(PCSZ pcszDir, 2307 2438 ULONG flFlags, 2308 2439 PULONG pulDirs, // out: directories found … … 2844 2975 */ 2845 2976 2846 APIRET doshExecVIO( const char *pcszExecWithArgs,2977 APIRET doshExecVIO(PCSZ pcszExecWithArgs, 2847 2978 PLONG plExitCode) // out: exit code (ptr can be NULL) 2848 2979 { … … 2926 3057 */ 2927 3058 2928 APIRET doshQuickStartSession( const char *pcszPath, // in: program to start2929 const char *pcszParams, // in: parameters for program3059 APIRET doshQuickStartSession(PCSZ pcszPath, // in: program to start 3060 PCSZ pcszParams, // in: parameters for program 2930 3061 BOOL fForeground, // in: if TRUE, session will be in foreground 2931 3062 USHORT usPgmCtl, // in: STARTDATA.PgmControl
Note:
See TracChangeset
for help on using the changeset viewer.