Changeset 116
- Timestamp:
- Nov 1, 2001, 6:43:18 PM (24 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/comctl.c
r111 r116 133 133 * 134 134 *@@added V0.9.13 (2001-06-21) [umoeller] 135 *@@changed V0.9.16 (2001-10-24) [umoeller]: fixed wrong hatch color and paint offset 136 *@@changed V0.9.16 (2001-10-28) [umoeller]: added bitmap support, fixed bad clip rectangle 135 137 */ 136 138 … … 172 174 { 173 175 // button border: 174 175 176 // now paint button frame 177 178 // make rcl inclusive 176 179 rclWin.xRight--; 177 180 rclWin.yTop--; … … 203 206 cy = rclWin.yTop - rclWin.yBottom; 204 207 205 ptl.x = rclWin.xLeft + ((cx - pxbd->cx MiniIcon) / 2);206 ptl.y = rclWin.yBottom + ((cy - pxbd->c xMiniIcon) / 2);208 ptl.x = rclWin.xLeft + ((cx - pxbd->cxIconOrBitmap) / 2); 209 ptl.y = rclWin.yBottom + ((cy - pxbd->cyIconOrBitmap) / 2); 207 210 208 211 if (fl & XBF_INUSE) … … 214 217 ptl2.y = ptl.y - 2; 215 218 GpiMove(hps, 216 &ptl); 219 &ptl2); // &ptl 220 // duh, typo V0.9.16 (2001-10-24) [umoeller] 217 221 GpiSetPattern(hps, PATSYM_DIAG1); 218 ptl2.x = ptl.x + pxbd->cxMiniIcon + 1; // inclusive! 219 ptl2.y = ptl.y + pxbd->cxMiniIcon + 1; // inclusive! 222 GpiSetColor(hps, RGBCOL_BLACK); // V0.9.16 (2001-10-24) [umoeller] 223 ptl2.x = ptl.x + pxbd->cxIconOrBitmap + 1; // inclusive! 224 ptl2.y = ptl.y + pxbd->cyIconOrBitmap + 1; // inclusive! 220 225 GpiBox(hps, 221 226 DRO_FILL, … … 226 231 227 232 // now paint icon 228 GpiIntersectClipRectangle(hps, &rclWin); // exclusive! 229 WinDrawPointer(hps, 230 // center this in remaining rectl 231 ptl.x + ulOfs, 232 ptl.y - ulOfs, 233 pxbd->hptr, 234 DP_MINI); 233 234 // make rcl inclusive // V0.9.16 (2001-10-28) [umoeller] 235 rclWin.xRight--; 236 rclWin.yTop--; 237 GpiIntersectClipRectangle(hps, 238 &rclWin); // inclusive! 239 240 // center this in remaining rectl 241 ptl.x += ulOfs; 242 ptl.y -= ulOfs; 243 if (fl & XBF_BITMAP) 244 // V0.9.16 (2001-10-28) [umoeller] 245 WinDrawBitmap(hps, 246 pxbd->hptr, // a bitmap really 247 NULL, // entire bitmap 248 &ptl, 249 0, 250 0, 251 DBM_NORMAL); 252 else 253 WinDrawPointer(hps, 254 // center this in remaining rectl 255 ptl.x + ulOfs, 256 ptl.y - ulOfs, 257 pxbd->hptr, 258 DP_MINI); 235 259 } 236 260 } -
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 -
trunk/src/helpers/lan.c
r114 r116 145 145 PSERVER pBuf; 146 146 ULONG cb = 4096; // set this fixed, can't get it to work otherwise 147 if (pBuf = doshMalloc(cb,148 &arc))147 if (pBuf = (PSERVER)doshMalloc(cb, 148 &arc)) 149 149 { 150 150 if (!(arc = pNet32ServerEnum2(NULL, 151 151 1, // ulLevel 152 (P BYTE)pBuf, // pbBuffer152 (PUCHAR)pBuf, // pbBuffer 153 153 cb, // cbBuffer, 154 154 &ulEntriesRead, // *pcEntriesRead, -
trunk/src/helpers/nls.c
r113 r116 39 39 // as unsigned char 40 40 41 #define INCL_DOSNLS 42 #define INCL_DOSERRORS 41 43 #define INCL_WINSHELLDATA 42 44 #include <os2.h> … … 455 457 } 456 458 459 460 /* 461 *@@ nlsUpper: 462 * quick hack for upper-casing a string. 463 * 464 * This uses DosMapCase with the default system country 465 * code and the process's codepage. 466 * 467 *@@added V0.9.16 (2001-10-25) [umoeller] 468 */ 469 470 APIRET nlsUpper(PSZ psz, // in/out: string 471 ULONG ulLength) // in: string length; if 0, we run strlen(psz) 472 { 473 COUNTRYCODE cc; 474 475 if (psz) 476 { 477 if (!ulLength) 478 ulLength = strlen(psz); 479 480 if (ulLength) 481 { 482 cc.country = 0; // use system country code 483 cc.codepage = 0; // use process default codepage 484 return (DosMapCase(ulLength, 485 &cc, 486 psz)); 487 } 488 } 489 490 return (ERROR_INVALID_PARAMETER); 491 } -
trunk/src/helpers/stringh.c
r108 r116 95 95 96 96 PSZ strhdupDebug(const char *pszSource, 97 unsigned long *pulLength, 97 98 const char *pcszSourceFile, 98 99 unsigned long ulLine, 99 100 const char *pcszFunction) 100 101 { 101 if (pszSource) 102 { 103 PSZ p = (PSZ)memdMalloc(strlen(pszSource) + 1, 104 pcszSourceFile, 105 ulLine, 106 pcszFunction); 107 strcpy(p, pszSource); 108 return (p); 109 } 110 else 111 return (0); 102 PSZ pszReturn = NULL; 103 ULONG ulLength = 0; 104 105 if ( (pcszSource) 106 && (ulLength = strlen(pcszSource)) 107 ) 108 { 109 if (pszReturn = (PSZ)memdMalloc(ulLength + 1, 110 pcszSourceFile, 111 ulLine, 112 pcszFunction)) 113 memcpy(pszReturn, pcszSource, ulLength + 1); 114 } 115 116 if (pulLength) 117 *pulLength = ulLength; 118 119 return (pszReturn); 112 120 } 113 121 … … 116 124 /* 117 125 *@@ strhdup: 118 * like strdup, but this one doesn't crash if pszSource is NULL, 119 * but returns NULL also. 126 * like strdup, but this one doesn't crash if pszSource 127 * is NULL, but returns NULL also. In addition, this 128 * can report the length of the string (V0.9.16). 120 129 * 121 130 *@@added V0.9.0 [umoeller] 122 */ 123 124 PSZ strhdup(const char *pszSource) 125 { 126 if (pszSource) 127 return (strdup(pszSource)); 128 else 129 return (0); 131 *@@changed V0.9.16 (2001-10-25) [umoeller]: added pulLength 132 */ 133 134 PSZ strhdup(const char *pcszSource, 135 unsigned long *pulLength) // out: length of string excl. null terminator (ptr can be NULL) 136 { 137 PSZ pszReturn = NULL; 138 ULONG ulLength = 0; 139 140 if ( (pcszSource) 141 && (ulLength = strlen(pcszSource)) 142 ) 143 { 144 if (pszReturn = (PSZ)malloc(ulLength + 1)) 145 memcpy(pszReturn, pcszSource, ulLength + 1); 146 } 147 148 if (pulLength) 149 *pulLength = ulLength; 150 151 return (pszReturn); 130 152 } 131 153 -
trunk/src/helpers/threads.c
r100 r116 146 146 // run thread func 147 147 ((PTHREADFUNC)pti->pThreadFunc)(pti); 148 149 148 WinDestroyMsgQueue(pti->hmq); 150 151 149 } 152 150 WinTerminate(pti->hab); … … 247 245 * the HMQ in its THREADINFO. These are automatically 248 246 * destroyed when the thread terminates. 247 * 248 * WARNING: Be careful with this setting for short-lived 249 * threads which are started synchronously while some 250 * other thread is locking PM, e.g. in a WinSendMsg 251 * call. While creation of the thread will still 252 * succeed, the thread will _not_ terminate properly 253 * while PM is locked, so do not wait for such a thread 254 * to terminate!! (V0.9.16) 249 255 * 250 256 * -- THRF_WAIT: if this is set, thrCreate does not … … 288 294 *@@changed V0.9.9 (2001-03-14) [umoeller]: added THRF_WAIT_EXPLICIT 289 295 *@@changed V0.9.12 (2001-05-20) [umoeller]: changed pfRunning to ptidRunning 296 *@@changed V0.9.16 (2001-10-28) [umoeller]: made ptidRunning volatile to prohibit compiler optimizations 290 297 */ 291 298 292 299 ULONG thrCreate(PTHREADINFO pti, // out: THREADINFO data 293 300 PTHREADFUNC pfn, // in: _Optlink thread function 294 PULONG ptidRunning, // out: variable set to TID while thread is running; 301 volatile unsigned long *ptidRunning, 302 // out: variable set to TID while thread is running; 295 303 // ptr can be NULL 296 304 const char *pcszThreadName, // in: thread name (for identification) -
trunk/src/helpers/tmsgfile.c
r113 r116 292 292 pNew->cbText = strlen(pStartOfText); 293 293 294 // remove trailing newlines 295 while ( (pNew->cbText) 296 && (pStartOfText[pNew->cbText-1] == '\n') 297 ) 298 (pNew->cbText)--; 299 294 300 // store this thing 295 301 if (!treeInsert(&pFile->IDsTreeRoot, -
trunk/src/helpers/tree.c
r113 r116 285 285 * initializes the root of a tree. 286 286 * 287 * If (plCount != NULL), *plCount is set to null also. 288 * This same plCount pointer can then be passed to 289 * treeInsert and treeDelete also to automatically 290 * maintain a tree item count. 291 * 287 292 *@@changed V0.9.16 (2001-10-19) [umoeller]: added plCount 288 293 */ … … 509 514 * "x" specifies the new tree node which must 510 515 * have been allocated by the caller. x->ulKey 511 * must already contain the node's key (data). 516 * must already contain the node's key (data) 517 * which the sort function can understand. 518 * 512 519 * This function will then set the parent, 513 * left, right, and color members. 520 * left, right, and color members. In addition, 521 * if (plCount != NULL), *plCount is raised by 522 * one. 514 523 * 515 524 * Returns 0 if no error. Might return … … 521 530 522 531 int treeInsert(TREE **root, // in: root of the tree 523 PLONG plCount, // in/out: item count (ptr can be NULL)532 PLONG plCount, // in/out: item count (ptr can be NULL) 524 533 TREE *x, // in: new node to insert 525 534 FNTREE_COMPARE *pfnCompare) // in: comparison func … … 750 759 * Does not free() the node though. 751 760 * 761 * In addition, if (plCount != NULL), *plCount is 762 * decremented. 763 * 752 764 * Returns 0 if the node was deleted or 753 765 * STATUS_INVALID_NODE if not. … … 757 769 758 770 int treeDelete(TREE **root, // in: root of the tree 759 PLONG plCount, // in/out: item count (ptr can be NULL)771 PLONG plCount, // in/out: item count (ptr can be NULL) 760 772 TREE *tree) // in: tree node to delete 761 773 { -
trunk/src/helpers/wphandle.c
r113 r116 996 996 NULL); 997 997 998 _Pmpf((__FUNCTION__ ": wphFindPartName returned %d", arc));998 // _Pmpf((__FUNCTION__ ": wphFindPartName returned %d", arc)); 999 999 } 1000 1000
Note:
See TracChangeset
for help on using the changeset viewer.