source: trunk/include/helpers/dosh.h@ 204

Last change on this file since 204 was 200, checked in by umoeller, 23 years ago

More fixes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 35.1 KB
Line 
1
2/*
3 *@@sourcefile dosh.h:
4 * header file for dosh.c. See remarks there.
5 *
6 * Note: Version numbering in this file relates to XWorkplace version
7 * numbering.
8 *
9 *@@include #define INCL_DOSPROCESS
10 *@@include #define INCL_DOSDEVIOCTL // for doshQueryDiskParams only
11 *@@include #include <os2.h>
12 *@@include #include "helpers\dosh.h"
13 */
14
15/* This file Copyright (C) 1997-2001 Ulrich M”ller,
16 * Dmitry A. Steklenev.
17 * This file is part of the "XWorkplace helpers" source package.
18 * This is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published
20 * by the Free Software Foundation, in version 2 as it comes in the
21 * "COPYING" file of the XWorkplace main distribution.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 */
27
28#if __cplusplus
29extern "C" {
30#endif
31
32#ifndef DOSH_HEADER_INCLUDED
33 #define DOSH_HEADER_INCLUDED
34
35 /* ******************************************************************
36 *
37 * Wrappers
38 *
39 ********************************************************************/
40
41 // if DOSH_STANDARDWRAPPERS is #define'd before including dosh.h,
42 // all the following Dos* API calls are redirected to the dosh*
43 // counterparts
44
45 #ifdef DOSH_STANDARDWRAPPERS
46
47 #ifdef INCL_DOSPROCESS
48
49 APIRET XWPENTRY doshSleep(ULONG msec);
50 #define DosSleep(a) doshSleep((a))
51
52 #endif
53
54 #ifdef INCL_DOSSEMAPHORES
55
56 APIRET XWPENTRY doshCreateMutexSem(PSZ pszName,
57 PHMTX phmtx,
58 ULONG flAttr,
59 BOOL32 fState);
60 #define DosCreateMutexSem(a, b, c, d) doshCreateMutexSem((a), (b), (c), (d))
61
62 APIRET XWPENTRY doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
63 #define DosRequestMutexSem(h, t) doshRequestMutexSem((h), (t))
64
65 APIRET XWPENTRY doshReleaseMutexSem(HMTX hmtx);
66 #define DosReleaseMutexSem(h) doshReleaseMutexSem((h))
67
68 #endif
69
70 #ifdef INCL_DOSEXCEPTIONS
71
72 APIRET XWPENTRY doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
73 #define DosSetExceptionHandler(a) doshSetExceptionHandler((a))
74
75 APIRET XWPENTRY doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
76 #define DosUnsetExceptionHandler(a) doshUnsetExceptionHandler((a))
77
78 #endif
79
80 #endif
81
82 /* ******************************************************************
83 *
84 * Miscellaneous
85 *
86 ********************************************************************/
87
88 CHAR doshGetChar(VOID);
89
90 BOOL doshQueryShiftState(VOID);
91
92 ULONG doshIsWarp4(VOID);
93
94 PSZ doshQuerySysErrorMsg(APIRET arc);
95
96 ULONG doshQuerySysUptime(VOID);
97
98 /* ******************************************************************
99 *
100 * Memory helpers
101 *
102 ********************************************************************/
103
104 PVOID doshMalloc(ULONG cb,
105 APIRET *parc);
106
107 APIRET doshAllocArray(ULONG c,
108 ULONG cbArrayItem,
109 PBYTE *ppv,
110 PULONG pcbAllocated);
111
112 PVOID doshAllocSharedMem(ULONG ulSize,
113 const char* pcszName);
114
115 PVOID doshRequestSharedMem(PCSZ pcszName);
116
117 /* ******************************************************************
118 *
119 * Drive helpers
120 *
121 ********************************************************************/
122
123 APIRET doshIsFixedDisk(ULONG ulLogicalDrive,
124 PBOOL pfFixed);
125
126 #ifdef INCL_DOSDEVIOCTL
127
128 // #pragma pack(1)
129
130 /*
131 * DRIVEPARAMS:
132 * structure used for doshQueryDiskParams.
133 * removed this, we can directly use BIOSPARAMETERBLOCK
134 * V0.9.13 (2001-06-14) [umoeller]
135 */
136
137 /* typedef struct _DRIVEPARAMS
138 {
139 BIOSPARAMETERBLOCK bpb;
140 // BIOS parameter block. This is the first sector
141 // (at byte 0) in each partition. This is defined
142 // in the OS2 headers as follows:
143
144 typedef struct _BIOSPARAMETERBLOCK {
145 0 USHORT usBytesPerSector;
146 // Number of bytes per sector.
147 2 BYTE bSectorsPerCluster;
148 // Number of sectors per cluster.
149 3 USHORT usReservedSectors;
150 // Number of reserved sectors.
151 5 BYTE cFATs;
152 // Number of FATs.
153 6 USHORT cRootEntries;
154 // Number of root directory entries.
155 8 USHORT cSectors;
156 // Number of sectors.
157 10 BYTE bMedia;
158 // Media descriptor.
159 11 USHORT usSectorsPerFAT;
160 // Number of secctors per FAT.
161 13 USHORT usSectorsPerTrack;
162 // Number of sectors per track.
163 15 USHORT cHeads;
164 // Number of heads.
165 17 ULONG cHiddenSectors;
166 // Number of hidden sectors.
167 21 ULONG cLargeSectors;
168 // Number of large sectors.
169 25 BYTE abReserved[6];
170 // Reserved.
171 31 USHORT cCylinders;
172 // Number of cylinders defined for the physical
173 // device.
174 33 BYTE bDeviceType;
175 // Physical layout of the specified device.
176 34 USHORT fsDeviceAttr;
177 // A bit field that returns flag information
178 // about the specified drive.
179 } BIOSPARAMETERBLOCK;
180
181 // removed the following fields... these are already
182 // in the extended BPB structure, as defined in the
183 // Toolkit's BIOSPARAMETERBLOCK struct. Checked this,
184 // the definition is the same for the Toolkit 3 and 4.5.
185
186 USHORT usCylinders;
187 // no. of cylinders
188 UCHAR ucDeviceType;
189 // device type; according to the IBM Control
190 // Program Reference (see DSK_GETDEVICEPARAMS),
191 // this value can be:
192 // -- 0: 48 TPI low-density diskette drive
193 // -- 1: 96 TPI high-density diskette drive
194 // -- 2: 3.5-inch 720KB diskette drive
195 // -- 3: 8-Inch single-density diskette drive
196 // -- 4: 8-Inch double-density diskette drive
197 // -- 5: Fixed disk
198 // -- 6: Tape drive
199 // -- 7: Other (includes 1.44MB 3.5-inch diskette drive
200 // and CD-ROMs)
201 // -- 8: R/W optical disk
202 // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)
203 USHORT usDeviceAttrs;
204 // DEVATTR_* flags
205 } DRIVEPARAMS, *PDRIVEPARAMS;
206 #pragma pack() */
207
208 APIRET doshQueryDiskParams(ULONG ulLogicalDrive,
209 PBIOSPARAMETERBLOCK pdp);
210
211 BYTE doshQueryDriveType(ULONG ulLogicalDrive,
212 PBIOSPARAMETERBLOCK pdp,
213 BOOL fFixed);
214
215 APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive,
216 HFILE hfDrive,
217 BOOL fMixedModeCD,
218 PBOOL pfAudio);
219
220 #endif
221
222 VOID XWPENTRY doshEnumDrives(PSZ pszBuffer,
223 PCSZ pcszFileSystem,
224 BOOL fSkipRemoveables);
225 typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer,
226 PCSZ pcszFileSystem,
227 BOOL fSkipRemoveables);
228 typedef DOSHENUMDRIVES *PDOSHENUMDRIVES;
229
230 CHAR doshQueryBootDrive(VOID);
231
232 #define ERROR_AUDIO_CD_ROM 10000
233
234 #define DRVFL_MIXEDMODECD 0x0001
235 #define DRVFL_TOUCHFLOPPIES 0x0002
236 #define DRVFL_CHECKEAS 0x0004
237 #define DRVFL_CHECKLONGNAMES 0x0008
238
239 APIRET doshAssertDrive(ULONG ulLogicalDrive,
240 ULONG fl);
241
242 #ifdef INCL_DOSDEVIOCTL
243
244 /*
245 *@@ XDISKINFO:
246 *
247 *@@added V0.9.16 (2002-01-13) [umoeller]
248 */
249
250 typedef struct _XDISKINFO
251 {
252 CHAR cDriveLetter; // drive letter
253 CHAR cLogicalDrive; // logical drive no.
254
255 BOOL fPresent; // if FALSE, drive does not exist
256
257 // the following are only valid if fPresent == TRUE
258
259 BIOSPARAMETERBLOCK bpb;
260 // 0x00 USHORT usBytesPerSector;
261 // 0x02 BYTE bSectorsPerCluster;
262 // 0x03 USHORT usReservedSectors;
263 // 0x05 BYTE cFATs;
264 // 0x06 USHORT cRootEntries;
265 // 0x08 USHORT cSectors;
266 // 0x0a BYTE bMedia;
267 // 0x0b USHORT usSectorsPerFAT;
268 // 0x0d USHORT usSectorsPerTrack;
269 // 0x0f USHORT cHeads;
270 // 0x11 ULONG cHiddenSectors;
271 // 0x15 ULONG cLargeSectors;
272 // 0x19 BYTE abReserved[6];
273 // 0x1a USHORT cCylinders;
274 // 0x1c BYTE bDeviceType;
275 #ifndef DEVTYPE_48TPI
276 #define DEVTYPE_48TPI 0x0000
277 #define DEVTYPE_96TPI 0x0001
278 #define DEVTYPE_35 0x0002
279 #define DEVTYPE_8SD 0x0003
280 #define DEVTYPE_8DD 0x0004
281 #define DEVTYPE_FIXED 0x0005
282 #define DEVTYPE_TAPE 0x0006
283 #endif
284 #define DEVTYPE_OTHER 0x0007
285 // includes 1.44 3.5" floppy
286 #define DEVTYPE_RWOPTICAL 0x0008
287 #define DEVTYPE_35_288MB 0x0009
288 // 0x1d USHORT fsDeviceAttr;
289 #define DEVATTR_REMOVEABLE 0x0001
290 // drive is removeable
291 #define DEVATTR_CHANGELINE 0x0002
292 // device can determine whether media has
293 // been removed since last I/O operation
294 #define DEVATTR_GREATER16MB 0x0004
295 // physical device driver supports physical
296 // addresses > 16 MB
297 #define DEVATTR_PARTITIONALREMOVEABLE 0x0008
298 // undocumented flag; set for ZIP drives
299
300 BYTE bType;
301 // do not change these codes, XWorkplace relies
302 // on them too to parse WPDisk data
303 #define DRVTYPE_HARDDISK 0
304 #define DRVTYPE_FLOPPY 1
305 #define DRVTYPE_TAPE 2
306 #define DRVTYPE_VDISK 3
307 #define DRVTYPE_CDROM 4
308 #define DRVTYPE_LAN 5
309 #define DRVTYPE_PARTITIONABLEREMOVEABLE 6
310 #define DRVTYPE_UNKNOWN 255
311
312 ULONG flDevice;
313 // any combination of the following:
314 #define DFL_REMOTE 0x0001
315 // drive is remote (not local)
316 #define DFL_FIXED 0x0002
317 // drive is fixed; otherwise it is removeable!
318 // always set for harddisks and zip drives
319 #define DFL_PARTITIONABLEREMOVEABLE 0x0004
320 // set for zip drives;
321 // in that case, DFL_FIXED is set also
322 #define DFL_BOOTDRIVE 0x0008
323 // drive was booted from
324
325 // media flags:
326
327 #define DFL_MEDIA_PRESENT 0x1000
328 // media is present in drive;
329 // -- always set for harddisks,
330 // unless the file system is not
331 // understood
332 // -- always set for remove drives
333 // -- always set for A: and B:
334 // -- set for CD-ROMS only if data
335 // CD-ROM is inserted
336 #define DFL_AUDIO_CD 0x2000
337 // set for CD-ROMs only, if an audio CD
338 // is currently inserted; in that case,
339 // DFL_MEDIA_PRESENT is _not_ set
340 #define DFL_SUPPORTS_EAS 0x4000
341 // drive supports extended attributes
342 // (assumption based on DosFSCtl,
343 // might not be correct for remote drives;
344 // reports correctly for FAT32 though)
345 #define DFL_SUPPORTS_LONGNAMES 0x8000
346 // drive supports long names; this does not
347 // necessarily mean that we support all IFS
348 // characters also
349
350 // the following are only valid if DFL_MEDIA_PRESENT is set;
351 // they are always set for drives A: and B:
352
353 CHAR szFileSystem[30];
354 // e.g. "FAT" or "HPFS" or "JFS" or "CDFS"
355
356 LONG lFileSystem;
357 // do not change these codes, XWorkplace relies
358 // on them too to parse WPDisk data
359 #define FSYS_UNKNOWN 0
360 // drive not formatted, or unknown file system
361 #define FSYS_FAT 1
362 #define FSYS_HPFS_JFS 2
363 #define FSYS_CDFS 3
364 #define FSYS_CDWFS 6 // not used by WPS!
365 // added V0.9.19 (2002-04-25) [umoeller]
366 #define FSYS_TVFS 7 // not used by WPS!
367 #define FSYS_FAT32_EXT2 8 // not used by WPS!
368 #define FSYS_RAMFS 9 // not used by WPS!
369 #define FSYS_REMOTE 10
370 // NOTE: if this has a negative value, this is
371 // the APIRET code from DosQueryFSAttach
372
373 // error codes for various operations
374 APIRET arcIsFixedDisk,
375 arcQueryDiskParams,
376 arcQueryMedia,
377 arcOpenLongnames;
378
379 } XDISKINFO, *PXDISKINFO;
380
381 APIRET doshGetDriveInfo(ULONG ulLogicalDrive,
382 ULONG fl,
383 PXDISKINFO pdi);
384
385 #endif
386
387 APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
388
389 APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize);
390 typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize);
391 typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE;
392
393 APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree);
394 typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree);
395 typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE;
396
397 APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
398 typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
399 typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE;
400
401 APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
402 PSZ pszVolumeLabel);
403
404 APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
405 PSZ pszNewLabel);
406
407 /* ******************************************************************
408 *
409 * Module handling helpers
410 *
411 ********************************************************************/
412
413 APIRET doshQueryProcAddr(PCSZ pcszModuleName,
414 ULONG ulOrdinal,
415 PFN *ppfn);
416
417 /*
418 *@@ RESOLVEFUNCTION:
419 * one of these structures each define
420 * a single function import to doshResolveImports.
421 *
422 *@@added V0.9.3 (2000-04-25) [umoeller]
423 */
424
425 typedef struct _RESOLVEFUNCTION
426 {
427 const char *pcszFunctionName;
428 PFN *ppFuncAddress;
429 } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
430
431 typedef const struct _RESOLVEFUNCTION *PCRESOLVEFUNCTION;
432
433 APIRET doshResolveImports(PCSZ pcszModuleName,
434 HMODULE *phmod,
435 PCRESOLVEFUNCTION paResolves,
436 ULONG cResolves);
437
438 /* ******************************************************************
439 *
440 * Performance Counters (CPU Load)
441 *
442 ********************************************************************/
443
444 #define CMD_PERF_INFO 0x41
445 #define CMD_KI_ENABLE 0x60
446 #define CMD_KI_DISABLE 0x61
447 #ifndef CMD_KI_RDCNT
448 #define CMD_KI_RDCNT 0x63
449 typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand,
450 ULONG ulParm1,
451 ULONG ulParm2,
452 ULONG ulParm3);
453 typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL;
454 #endif
455
456 typedef struct _CPUUTIL
457 {
458 ULONG ulTimeLow; // low 32 bits of time stamp
459 ULONG ulTimeHigh; // high 32 bits of time stamp
460 ULONG ulIdleLow; // low 32 bits of idle time
461 ULONG ulIdleHigh; // high 32 bits of idle time
462 ULONG ulBusyLow; // low 32 bits of busy time
463 ULONG ulBusyHigh; // high 32 bits of busy time
464 ULONG ulIntrLow; // low 32 bits of interrupt time
465 ULONG ulIntrHigh; // high 32 bits of interrupt time
466 } CPUUTIL, *PCPUUTIL;
467
468 // macro to convert 8-byte (low, high) time value to double
469 #define LL2F(high, low) (4294967296.0*(high)+(low))
470
471 /*
472 *@@ DOSHPERFSYS:
473 * structure used with doshPerfOpen.
474 *
475 *@@added V0.9.7 (2000-12-02) [umoeller]
476 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
477 */
478
479 typedef struct _DOSHPERFSYS
480 {
481 // output: no. of processors on the system
482 ULONG cProcessors;
483 // output: one CPU load for each CPU
484 PLONG palLoads;
485
486 // output: one CPU interrupt load for each CPU
487 PLONG palIntrs;
488
489 // each of the following ptrs points to an array of cProcessors items
490 PCPUUTIL paCPUUtils; // CPUUTIL structures
491 double *padBusyPrev; // previous "busy" calculations
492 double *padTimePrev; // previous "time" calculations
493 double *padIntrPrev; // previous "intr" calculations
494
495 // private stuff
496 HMODULE hmod;
497 BOOL fInitialized;
498 PFNDOSPERFSYSCALL pDosPerfSysCall;
499 } DOSHPERFSYS, *PDOSHPERFSYS;
500
501 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
502
503 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
504
505 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
506
507 /* ******************************************************************
508 *
509 * File name parsing
510 *
511 ********************************************************************/
512
513 APIRET doshGetDriveSpec(PCSZ pcszFullFile,
514 PSZ pszDrive,
515 PULONG pulDriveLen,
516 PBOOL pfIsUNC);
517
518 PSZ doshGetExtension(PCSZ pcszFilename);
519
520 /* ******************************************************************
521 *
522 * File helpers
523 *
524 ********************************************************************/
525
526 BOOL doshIsFileOnFAT(const char* pcszFileName);
527
528 APIRET doshIsValidFileName(const char* pcszFile,
529 BOOL fFullyQualified);
530
531 BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
532
533 APIRET doshQueryFileSize(HFILE hFile,
534 PULONG pulSize);
535
536 APIRET doshQueryPathSize(PCSZ pcszFile,
537 PULONG pulSize);
538
539 APIRET doshQueryPathAttr(const char* pcszFile,
540 PULONG pulAttr);
541
542 APIRET doshSetPathAttr(const char* pcszFile,
543 ULONG ulAttr);
544
545 /* ******************************************************************
546 *
547 * XFILEs
548 *
549 ********************************************************************/
550
551 /*
552 *@@ XFILE:
553 *
554 *@@added V0.9.16 (2001-10-19) [umoeller]
555 */
556
557 typedef struct _XFILE
558 {
559 HFILE hf;
560
561 PSZ pszFilename; // as given to doshOpen
562 ULONG flOpenMode; // as given to doshOpen
563
564 ULONG cbInitial, // intial file size on open (can be 0 if new)
565 cbCurrent; // current file size (raised with each write)
566
567 PBYTE pbCache; // if != NULL, cached data from doshReadAt
568 ULONG cbCache, // size of data in cbCache
569 ulReadFrom; // file offset where pbCache was read from
570 } XFILE, *PXFILE;
571
572 #define XOPEN_READ_EXISTING 0x0001
573 #define XOPEN_READWRITE_EXISTING 0x0002
574 #define XOPEN_READWRITE_APPEND 0x0003
575 #define XOPEN_READWRITE_NEW 0x0004
576 #define XOPEN_ACCESS_MASK 0xffff
577
578 #define XOPEN_BINARY 0x10000000
579
580 APIRET doshOpen(PCSZ pcszFilename,
581 ULONG flOpenMode,
582 PULONG pcbFile,
583 PXFILE *ppFile);
584
585 #define DRFL_NOCACHE 0x0001
586 #define DRFL_FAILIFLESS 0x0002
587
588 APIRET doshReadAt(PXFILE pFile,
589 ULONG ulOffset,
590 PULONG pcb,
591 PBYTE pbData,
592 ULONG fl);
593
594 APIRET doshWrite(PXFILE pFile,
595 ULONG cb,
596 PCSZ pbData);
597
598 APIRET doshWriteAt(PXFILE pFile,
599 ULONG ulOffset,
600 ULONG cb,
601 PCSZ pbData);
602
603 APIRET doshWriteLogEntry(PXFILE pFile,
604 const char* pcszFormat,
605 ...);
606
607 APIRET doshClose(PXFILE *ppFile);
608
609 APIRET doshReadText(PXFILE pFile,
610 PSZ* ppszContent,
611 PULONG pcbRead);
612
613 APIRET doshLoadTextFile(PCSZ pcszFile,
614 PSZ* ppszContent,
615 PULONG pcbRead);
616
617 PSZ doshCreateBackupFileName(const char* pszExisting);
618
619 APIRET doshCreateTempFileName(PSZ pszTempFileName,
620 PCSZ pcszDir,
621 PCSZ pcszPrefix,
622 PCSZ pcszExt);
623
624 APIRET doshWriteTextFile(const char* pszFile,
625 const char* pszContent,
626 PULONG pulWritten,
627 PSZ pszBackup);
628
629
630 /* ******************************************************************
631 *
632 * Directory helpers
633 *
634 ********************************************************************/
635
636 BOOL doshQueryDirExist(PCSZ pcszDir);
637
638 APIRET doshCreatePath(PCSZ pcszPath,
639 BOOL fHidden);
640
641 APIRET doshQueryCurrentDir(PSZ pszBuf);
642
643 APIRET doshSetCurrentDir(PCSZ pcszDir);
644
645 #define DOSHDELDIR_RECURSE 0x0001
646 #define DOSHDELDIR_DELETEFILES 0x0002
647
648 APIRET doshDeleteDir(PCSZ pcszDir,
649 ULONG flFlags,
650 PULONG pulDirs,
651 PULONG pulFiles);
652
653 APIRET doshCanonicalize(PCSZ pcszFileIn,
654 PSZ pszFileOut,
655 ULONG cbFileOut);
656
657 /* ******************************************************************
658 *
659 * Process helpers
660 *
661 ********************************************************************/
662
663 ULONG XWPENTRY doshMyPID(VOID);
664 typedef ULONG XWPENTRY DOSHMYPID(VOID);
665 typedef DOSHMYPID *PDOSHMYPID;
666
667 ULONG XWPENTRY doshMyTID(VOID);
668 typedef ULONG XWPENTRY DOSHMYTID(VOID);
669 typedef DOSHMYTID *PDOSHMYTID;
670
671 APIRET doshExecVIO(PCSZ pcszExecWithArgs,
672 PLONG plExitCode);
673
674 APIRET doshQuickStartSession(PCSZ pcszPath,
675 PCSZ pcszParams,
676 BOOL fForeground,
677 USHORT usPgmCtl,
678 BOOL fWait,
679 PULONG pulSID,
680 PPID ppid,
681 PUSHORT pusReturn);
682
683 APIRET doshSearchPath(PCSZ pcszPath,
684 PCSZ pcszFile,
685 PSZ pszExecutable,
686 ULONG cbExecutable);
687
688 APIRET doshFindExecutable(PCSZ pcszCommand,
689 PSZ pszExecutable,
690 ULONG cbExecutable,
691 PCSZ *papcszExtensions,
692 ULONG cExtensions);
693
694 /********************************************************************
695 *
696 * Partition functions
697 *
698 ********************************************************************/
699
700 /*
701 *@@ LVMINFO:
702 * informational structure created by
703 * doshQueryLVMInfo.
704 *
705 *@@added V0.9.9 (2001-04-07) [umoeller]
706 */
707
708 typedef struct _LVMINFO
709 {
710 HMODULE hmodLVM;
711
712 } LVMINFO, *PLVMINFO;
713
714 /* #define DOSH_PARTITIONS_LIMIT 10
715
716 #define PAR_UNUSED 0x00 // Unused
717 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
718 #define PAR_XENIXROOT 0x02 // XENIX root
719 #define PAR_XENIXUSER 0x03 // XENIX user
720 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
721 #define PAR_EXTENDED 0x05 // Extended partition
722 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
723 #define PAR_HPFS 0x07 // OS/2 HPFS
724 #define PAR_AIXBOOT 0x08 // AIX bootable partition
725 #define PAR_AIXDATA 0x09 // AIX bootable partition
726 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
727 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
728 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
729 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
730 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
731 #define PAR_OPUS 0x10 // OPUS
732 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
733 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
734 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
735 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
736 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
737 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
738 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
739 #define PAR_THEOS 0x38 // THEOS
740 #define PAR_VENIX 0x40 // VENIX
741 #define PAR_RISCBOOT 0x41 // Personal RISC boot
742 #define PAR_SFS 0x42 // SFS
743 #define PAR_ONTRACK 0x50 // Ontrack
744 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
745 #define PAR_CPM 0x52 // CP/M
746 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
747 #define PAR_NOVELL_64 0x64 // Novell
748 #define PAR_NOVELL_65 0x65 // Novell
749 #define PAR_NOVELL_67 0x67 // Novell
750 #define PAR_NOVELL_68 0x68 // Novell
751 #define PAR_NOVELL_69 0x69 // Novell
752 #define PAR_PCIX 0x75 // PCIX
753 #define PAR_MINIX 0x80 // MINIX
754 #define PAR_LINUX 0x81 // Linux
755 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
756 #define PAR_LINUXFILE 0x83 // Linux File System
757 #define PAR_FREEBSD 0xA5 // FreeBSD
758 #define PAR_BBT 0xFF // BBT
759 */
760
761 // one-byte alignment
762 #pragma pack(1)
763
764 /*
765 *@@ PAR_INFO:
766 * partition table
767 */
768
769 typedef struct _PAR_INFO
770 {
771 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
772 BYTE bBeginHead; // partition begins at this head...
773 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
774 BYTE bFileSysCode; // file system type
775 BYTE bEndHead; // partition ends at this head...
776 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
777 ULONG lBeginAbsSec; // partition begins at this absolute sector #
778 ULONG lTotalSects; // total sectors in this partition
779 } PAR_INFO, *PPAR_INFO;
780
781 /*
782 *@@ MBR_INFO:
783 * master boot record table.
784 * This has the four primary partitions.
785 */
786
787 typedef struct _MBR_INFO // MBR
788 {
789 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
790 PAR_INFO sPrtnInfo[4]; // primary partition entries
791 USHORT wPrtnTblSig; // partition table signature (aa55H)
792 } MBR_INFO, *PMBR_INFO;
793
794 /*
795 *@@ SYS_INFO:
796 *
797 */
798
799 typedef struct _SYS_INFO
800 {
801 BYTE startable;
802 BYTE unknown[3];
803 BYTE bootable;
804 BYTE name[8];
805 BYTE reservd[3];
806 } SYS_INFO, *PSYS_INFO;
807
808 /*
809 *@@ SYE_INFO:
810 *
811 */
812
813 typedef struct _SYE_INFO
814 {
815 BYTE bootable;
816 BYTE name[8];
817 } SYE_INFO, *PSYE_INFO;
818
819 /*
820 *@@ EXT_INFO:
821 *
822 */
823
824 typedef struct _EXT_INFO
825 {
826 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
827 SYE_INFO sBmNames[4]; // System Names
828 BYTE bReserved[16]; // reserved
829 PAR_INFO sPrtnInfo[4]; // partitioms entrys
830 USHORT wPrtnTblSig; // partition table signature (aa55H)
831 } EXT_INFO, *PEXT_INFO;
832
833 typedef struct _PARTITIONINFO *PPARTITIONINFO;
834
835 /*
836 *@@ PARTITIONINFO:
837 * informational structure returned
838 * by doshGetPartitionsList. One of
839 * these items is created for each
840 * bootable partition.
841 */
842
843 typedef struct _PARTITIONINFO
844 {
845 BYTE bDisk; // drive number
846 CHAR cLetter; // probable drive letter or ' ' if none
847 BYTE bFSType; // file system type
848 PCSZ pcszFSType; // file system name (as returned by
849 // doshType2FSName, can be NULL!)
850 BOOL fPrimary; // primary partition?
851 BOOL fBootable; // bootable by Boot Manager?
852 CHAR szBootName[21]; // Boot Manager name, if (fBootable)
853 // extended for LVM names V0.9.20 (2002-08-10) [umoeller]
854 ULONG ulSize; // size MBytes
855 PPARTITIONINFO pNext; // next info or NULL if last
856 } PARTITIONINFO;
857
858 UINT doshQueryDiskCount(VOID);
859
860 APIRET doshReadSector(USHORT disk,
861 void *buff,
862 USHORT head,
863 USHORT cylinder,
864 USHORT sector);
865
866 // restore original alignment
867 #pragma pack()
868
869 const char* doshType2FSName(unsigned char bFSType);
870
871 APIRET doshGetBootManager(USHORT *pusDisk,
872 USHORT *pusPart,
873 PAR_INFO *BmInfo);
874
875 typedef struct _PARTITIONSLIST
876 {
877 PLVMINFO pLVMInfo; // != NULL if LVM is installed
878
879 // partitions array
880 PPARTITIONINFO pPartitionInfo;
881 USHORT cPartitions;
882 } PARTITIONSLIST, *PPARTITIONSLIST;
883
884 APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
885 PUSHORT pusContext);
886
887 APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
888
889 APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
890
891 APIRET doshReadLVMPartitions(PLVMINFO pInfo,
892 PPARTITIONINFO *ppPartitionInfo,
893 PUSHORT pcPartitions);
894
895 VOID doshFreeLVMInfo(PLVMINFO pInfo);
896
897 /* ******************************************************************
898 *
899 * Wildcard matching
900 *
901 ********************************************************************/
902
903 BOOL doshMatchCase(PCSZ pcszMask,
904 PCSZ pcszName);
905
906 BOOL doshMatchCaseNoPath(const char *pcszMask,
907 const char *pcszName);
908
909 BOOL doshMatch(PCSZ pcszMask,
910 PCSZ pcszName);
911
912#endif
913
914#if __cplusplus
915}
916#endif
917
Note: See TracBrowser for help on using the repository browser.