diff options
Diffstat (limited to 'v4.0/src/INC/CDS.C')
| -rw-r--r-- | v4.0/src/INC/CDS.C | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/v4.0/src/INC/CDS.C b/v4.0/src/INC/CDS.C new file mode 100644 index 0000000..861b42d --- /dev/null +++ b/v4.0/src/INC/CDS.C | |||
| @@ -0,0 +1,132 @@ | |||
| 1 | /* cds utilities */ | ||
| 2 | /* #include "types.h" */ | ||
| 3 | #include "sysvar.h" | ||
| 4 | #include "cds.h" | ||
| 5 | #include "dpb.h" | ||
| 6 | #include <dos.h> | ||
| 7 | #include "jointype.h" | ||
| 8 | |||
| 9 | extern struct sysVarsType SysVars ; | ||
| 10 | |||
| 11 | char fGetCDS(i, pLCDS) | ||
| 12 | int i ; | ||
| 13 | struct CDSType *pLCDS ; | ||
| 14 | { | ||
| 15 | struct CDSType far *cptr ; | ||
| 16 | int j ; | ||
| 17 | /* Get pointer to CDS */ | ||
| 18 | if (i >= 0 && i < SysVars.cCDS) { | ||
| 19 | *(long *)(&cptr) = SysVars.pCDS + (i * sizeof(*pLCDS)) ; | ||
| 20 | |||
| 21 | /* Copy CDS to our program */ | ||
| 22 | for (j=0 ; j < sizeof(*pLCDS) ; j++) | ||
| 23 | *((char *)pLCDS+j) = *((char far *)cptr+j) ; | ||
| 24 | |||
| 25 | return TRUE ; | ||
| 26 | } ; | ||
| 27 | return FALSE ; | ||
| 28 | } | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | char fPutCDS(i, pLCDS) | ||
| 34 | int i ; | ||
| 35 | struct CDSType *pLCDS ; | ||
| 36 | { | ||
| 37 | struct CDSType far *cptr ; | ||
| 38 | int j ; | ||
| 39 | |||
| 40 | if (i >= 0 && i < SysVars.cCDS) { | ||
| 41 | *(long *)(&cptr) = SysVars.pCDS + (i * sizeof(*pLCDS)) ; | ||
| 42 | |||
| 43 | for (j=0 ; j < sizeof(*pLCDS) ; j++) | ||
| 44 | *((char far *)cptr+j) = *((char *)pLCDS+j) ; | ||
| 45 | |||
| 46 | return TRUE ; | ||
| 47 | } ; | ||
| 48 | return FALSE ; | ||
| 49 | } | ||
| 50 | |||
| 51 | /* returns TRUE if drive i is a physical drive. Physical means that logical | ||
| 52 | * drive n corresponds with physical drive n. This is the case ONLY if the | ||
| 53 | * CDS is inuse and the DPB corresponding to the CDS has the physical drive | ||
| 54 | * equal to the original drive. | ||
| 55 | */ | ||
| 56 | |||
| 57 | char fPhysical(i) | ||
| 58 | int i ; | ||
| 59 | { | ||
| 60 | struct DPBType DPB ; | ||
| 61 | struct DPBType *pd = &DPB ; | ||
| 62 | struct DPBType far *dptr ; | ||
| 63 | int j ; | ||
| 64 | |||
| 65 | struct CDSType CDS ; | ||
| 66 | |||
| 67 | if (!fGetCDS(i, &CDS)) | ||
| 68 | return FALSE ; | ||
| 69 | |||
| 70 | if (TESTFLAG(CDS.flags,CDSNET | CDSSPLICE | CDSLOCAL)) | ||
| 71 | return FALSE ; | ||
| 72 | |||
| 73 | *(long *)(&dptr) = CDS.pDPB ; | ||
| 74 | |||
| 75 | for (j=0 ; j < sizeof(DPB) ; j++) | ||
| 76 | *((char *)pd+j) = *((char far *)dptr+j) ; | ||
| 77 | |||
| 78 | return(i == DPB.drive) ; | ||
| 79 | } | ||
| 80 | |||
| 81 | /* return TRUE if the specified drive is a network drive. i is a 0-based | ||
| 82 | * quantity | ||
| 83 | */ | ||
| 84 | |||
| 85 | /* MODIFICATION HISTORY | ||
| 86 | * | ||
| 87 | * M000 June 5/85 Barrys | ||
| 88 | * Removed extra net check. | ||
| 89 | */ | ||
| 90 | |||
| 91 | char fNet(i) | ||
| 92 | int i ; | ||
| 93 | { | ||
| 94 | union REGS ir ; | ||
| 95 | register union REGS *iregs = &ir ; /* Used for DOS calls */ | ||
| 96 | |||
| 97 | struct CDSType CDS ; | ||
| 98 | |||
| 99 | if (!fGetCDS(i, &CDS)) | ||
| 100 | return FALSE ; | ||
| 101 | |||
| 102 | iregs->x.ax = IOCTL9 ; /* Function 0x4409 */ | ||
| 103 | iregs->x.bx = i + 1 ; | ||
| 104 | intdos(iregs, iregs) ; | ||
| 105 | |||
| 106 | /*** M000 | ||
| 107 | return(TESTFLAG(CDS.flags,CDSNET) || TESTFLAG(iregs->x.dx,0x1000)) ; | ||
| 108 | /***/ | ||
| 109 | return(TESTFLAG(CDS.flags,CDSNET)) ; | ||
| 110 | } | ||
| 111 | |||
| 112 | |||
| 113 | /* return TRUE if the specified drive is a shared drive. i is a 0-based | ||
| 114 | * quantity | ||
| 115 | */ | ||
| 116 | char fShared(i) | ||
| 117 | int i ; | ||
| 118 | { | ||
| 119 | struct CDSType CDS ; | ||
| 120 | union REGS ir ; | ||
| 121 | register union REGS *iregs = &ir ; /* Used for DOS calls */ | ||
| 122 | |||
| 123 | if (!fGetCDS(i, &CDS)) | ||
| 124 | return FALSE ; | ||
| 125 | |||
| 126 | iregs->x.ax = IOCTL9 ; /* Function 0x4409 */ | ||
| 127 | iregs->x.bx = i + 1 ; | ||
| 128 | intdos(iregs, iregs) ; | ||
| 129 | |||
| 130 | return TESTFLAG(CDS.flags,CDSNET) || TESTFLAG(iregs->x.dx,0x0200) ; | ||
| 131 | } | ||
| 132 | \ No newline at end of file | ||