source: branches/branch-1-0/include/helpers/dosh.h@ 311

Last change on this file since 311 was 311, checked in by pr, 19 years ago

Added title parameter to doshQuickStartSession

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