_Titanium and the NTC Ship Manager Application_ by Evan Michaelides Listing One /******************************* * This file redefines all the MDBS functions as calls to the Command * Shell. This shell uses the function dms_call(), declared as follows. * int dms_call (fptr, arg1, arg2, fnum, filename, linenumb) * int (far pascal *fptr)(); * char *arg1, *arg2; * int fnum; * char *filename; * unsigned int linenumb; * fptr is a pointer to the MDBS function * arg1 and arg2 are pointers to the arguments which get passed to fptr * (If there are fewer than 2 arguments, a pointer to bl_p, * which is defined as " ", pads the unnecessary arguments.) * fnum is a unique number assigned to each MDBS function * (for debugging) * filename is a pointer to the filename returned by the preprocessor * (This string is only included when DEBUG is defined, in * order to save space; otherwise the null pointer is passed.) * linenumb is the line number within the file (as determined by the * preprocessor) * N.B.: Because all MDBS functions use the pascal calling convention, * it was necessary to reverse the 2nd and 3rd arguments in dms_call * (i.e., "a, NULL" becomes "NULL, a") so that functions which * expect only a single argument will find it in the correct place * on the stack. *******************************/ #ifndef NTC_DMS_FILENAME static char *sourcefilename = NULL; #endif typedef ushort UI; // user indicator #define DMS_INVALID_OWNER 5 // DMS error for invalid owner #define DMS_INVALID_MEMBER 6 // DMS error for invalid member //NULL, 0 NULL, NULL, #define DMS_AMM 1 #define DMS_AMO 2 #define DMS_AOM 3 #define DMS_AOO 4 #define DMS_AUI 5 #define DMS_CCU 6 #define DMS_CRA 7 #define DMS_CRS 8 #define DMS_DBCLS 9 #define DMS_DBCLSA 10 #define DMS_DBENV 11 #define DMS_DBOPN 12 #define DMS_DBOPNA 13 #define DMS_DBSAVE 14 #define DMS_DBSTAT 15 #define DMS_DRC 16 #define DMS_DRM 17 #define DMS_DRO 18 #define DMS_FDRK 19 #define DMS_FFM 20 #define DMS_FFO 21 #define DMS_FFS 22 #define DMS_FLM 23 #define DMS_FLO 24 #define DMS_FMI 25 #define DMS_FMSK 26 #define DMS_FNM 27 #define DMS_FNMI 28 #define DMS_FNMSK 29 #define DMS_FNO 30 #define DMS_FNOI 31 #define DMS_FNOSK 32 #define DMS_FNS 33 #define DMS_FOI 34 #define DMS_FOSK 35 #define DMS_FPM 36 #define DMS_FPO 37 #define DMS_FRK 38 #define DMS_DBGETC 39 #define DMS_GETM 40 #define DMS_GETO 41 #define DMS_GFC 42 #define DMS_GFM 43 #define DMS_GFO 44 #define DMS_GMC 45 #define DMS_GOC 46 #define DMS_GTC 47 #define DMS_GTM 48 #define DMS_GTO 49 #define DMS_IMS 50 #define DMS_IOS 51 #define DMS_MAU 52 #define DMS_MCC 53 #define DMS_LGFILE 54 #define DMS_LGFLSH 55 #define DMS_LGMSG 56 #define DMS_NCI 57 #define DMS_PFC 58 #define DMS_PFM 59 #define DMS_PFO 60 #define DMS_PIFD 61 #define DMS_DBPUTC 62 #define DMS_PUTM 63 #define DMS_PUTO 64 #define DMS_RMS 65 #define DMS_ROS 66 #define DMS_RSM 67 #define DMS_RSO 68 #define DMS_SCM 69 #define DMS_SCN 70 #define DMS_SCO 71 #define DMS_SCU 72 //NULL, 73 NULL, NULL, #define DMS_SMC 74 #define DMS_SME 75 #define DMS_SMM 76 #define DMS_SMN 77 #define DMS_SMO 78 #define DMS_SMU 79 #define DMS_SOC 80 #define DMS_SOE 81 #define DMS_SOM 82 #define DMS_SON 83 #define DMS_SOO 84 #define DMS_SOU 85 #define DMS_SUC 86 #define DMS_SUM 87 #define DMS_SUN 88 #define DMS_SUO 89 #define DMS_SUU 90 #define DMS_TCT 91 #define DMS_TMT 92 #define DMS_TOT 93 #define DMS_TRABT 94 #define DMS_TRBGN 95 #define DMS_TRCOM 96 #define DMS_XMM 97 #define DMS_XMO 98 #define DMS_XOM 99 #define DMS_XOO 100 #define DMS_MCF 101 #define DMS_MCP 102 #define DMS_MRTF 103 #define DMS_MRTP 104 #define DMS_MSF 105 #define DMS_MSP 106 #define DMS_TCN 107 #define DMS_TMN 108 #define DMS_TON 109 #define DMS_DBCNV 110 #define DMS_ALTEOS 111 //NULL, 112 NULL, NULL, //NULL, 113 NULL, NULL, //NULL, 114 NULL, NULL, //NULL, 115 NULL, NULL, //NULL, 116 NULL, NULL, //NULL, 117 NULL, NULL, //NULL, 118 NULL, NULL, #define DMS_TUN 119 #define DMS_FPMI 120 #define DMS_FPOI 121 #define DMS_FPMSK 122 #define DMS_FPOSK 123 #define DMS_OFM 124 #define DMS_OFO 125 #define DMS_OLM 126 #define DMS_OLO 127 #define DMS_OMSK 128 #define DMS_ONM 129 #define DMS_ONMSK 130 #define DMS_ONO 131 #define DMS_ONOSK 132 #define DMS_OOSK 133 #define DMS_OPM 134 #define DMS_OPO 135 #define DMS_ODRK 136 #define DMS_ORK 137 #define DMS_OPMSK 138 #define DMS_OPOSK 139 #define DMS_OMI 140 #define DMS_ONMI 141 #define DMS_OPMI 142 #define DMS_OOI 143 #define DMS_ONOI 144 #define DMS_OPOI 145 #define DMS_SDC 146 #define DMS_SCD 147 #define DMS_MRID 148 #define DMS_GDC 149 #define DMS_GVLC 150 #define DMS_GII 151 #define DMS_GKI 152 #define DMS_GRI 153 #define DMS_GLRV 154 #define DMS_GHRV 155 #define DMS_GSI 156 #define DMS_GTT 157 //NULL, 158 NULL, NULL, //NULL, 159 NULL, NULL, #define DMS_GFLI 160 #define DMS_GAI 161 //NULL, 162 NULL, NULL, //NULL, 163 NULL, NULL, //NULL, 164 NULL, NULL, //NULL, 165 NULL, NULL, #define DMS_GAFN 166 //NULL, 167 NULL, NULL, #define DMS_TRSYNC 168 #define DMS_MCM 169 #define DMS_MRTM 170 #define DMS_MSM 171 #define DMS_MMU 172 #define DMS_NAL 173 #define DMS_FRM 174 #define DMS_FRO 175 #define DMS_GFS 176 #define DMS_DBXPND 177 #define DMS_GEI 178 #define DMS_DBSEL 179 #define DMS_VRDEF 180 #define DMS_VROF 181 #define DMS_VRON 182 #define DMS_GVII 183 #define DMS_GVRI 184 #define DMS_VRDEL 185 #define DMS_DBMEMU 186 #define DMS_TRBGNA 187 //NULL, 188 NULL, NULL, //NULL, 189 NULL, NULL, //NULL, 190 NULL, NULL, //"GKV", gkv, #define DMS_DMSSJP 191 #define DMS_DBFILE 192 #define DMS_GXERR 193 #define DMS_GXSTR 194 #define DMS_DBALIGN 195 #define DMS_DBAU 196 #define DMS_DBFU 197 #define DMS_DBSU 198 #define DMS_DBAVAIL 199 #define DMS_DBSRV 200 #define DMS_DBSTART 201 #define DMS_DBSTOP 202 #define DMS_DBUSR 203 //NULL, 204 NULL, NULL, //"SDM", scm, //NULL, 205 NULL, NULL, //"SDO", sco, //NULL, 206 NULL, NULL, //"SMD", smd, //NULL, 207 NULL, NULL, //"SOD", sod, #define DMS_DBEMS 208 #define DMS_FDB 209 #define DMS_IDB 210 #define amm(a) dms_call(NULL, a, DMS_AMM, sourcefilename, __LINE__) #define amo(a) dms_call(NULL, a, DMS_AMO, sourcefilename, __LINE__) #define aom(a) dms_call(NULL, a, DMS_AOM, sourcefilename, __LINE__) #define aoo(a) dms_call(NULL, a, DMS_AOO, sourcefilename, __LINE__) #define aui(a) dms_call(NULL, a, DMS_AUI, sourcefilename, __LINE__) #define ccu(a) dms_call(NULL, a, DMS_CCU, sourcefilename, __LINE__) #define cra(a,b) dms_call(a, b, DMS_CRA, sourcefilename, __LINE__) #define crs(a,b) dms_call(a, b, DMS_CRS, sourcefilename, __LINE__) #define dbcls() dms_call(NULL, NULL, DMS_DBCLS, sourcefilename, __LINE__) #define dbclsa(a) dms_call(NULL, a, DMS_DBCLSA, sourcefilename, __LINE__) #define dbenv(a) dms_call(NULL, a, DMS_DBENV, sourcefilename, __LINE__) #define dbopn(a) dms_call(NULL, a, DMS_DBOPN, sourcefilename, __LINE__) #define dbopna(a,b)dms_call(a, b, DMS_DBOPNA, sourcefilename, __LINE__) #define dbsave() dms_call(NULL, NULL, DMS_DBSAVE, sourcefilename, __LINE__) #define dbstat(a) dms_call(NULL, a, DMS_DBSTAT, sourcefilename, __LINE__) #define drc() dms_call(NULL, NULL, DMS_DRC, sourcefilename, __LINE__) #define drm(a) dms_call(NULL, a, DMS_DRM, sourcefilename, __LINE__) #define dro(a) dms_call(NULL, a, DMS_DRO, sourcefilename, __LINE__) #define fdrk(a,b) dms_call(a, b, DMS_FDRK, sourcefilename, __LINE__) #define ffm(a) dms_call(NULL, a, DMS_FFM, sourcefilename, __LINE__) #define ffo(a) dms_call(NULL, a, DMS_FFO, sourcefilename, __LINE__) #define ffs(a) dms_call(NULL, a, DMS_FFS, sourcefilename, __LINE__) #define flm(a) dms_call(NULL, a, DMS_FLM, sourcefilename, __LINE__) #define flo(a) dms_call(NULL, a, DMS_FLO, sourcefilename, __LINE__) #define fmi(a,b) dms_call(a, b, DMS_FMI, sourcefilename, __LINE__) #define fmsk(a,b) dms_call(a, b, DMS_FMSK, sourcefilename, __LINE__) #define fnm(a) dms_call(NULL, a, DMS_FNM, sourcefilename, __LINE__) #define fnmi(a,b) dms_call(a, b, DMS_FNMI, sourcefilename, __LINE__) #define fnmsk(a,b) dms_call(a, b, DMS_FNMSK, sourcefilename, __LINE__) #define fno(a) dms_call(NULL, a, DMS_FNO, sourcefilename, __LINE__) #define fnoi(a,b) dms_call(a, b, DMS_FNOI, sourcefilename, __LINE__) #define fnosk(a,b) dms_call(a, b, DMS_FNOSK, sourcefilename, __LINE__) #define fns(a) dms_call(NULL, a, DMS_FNS, sourcefilename, __LINE__) #define foi(a,b) dms_call(a, b, DMS_FOI, sourcefilename, __LINE__) #define fosk(a,b) dms_call(a, b, DMS_FOSK, sourcefilename, __LINE__) #define fpm(a) dms_call(NULL, a, DMS_FPM, sourcefilename, __LINE__) #define fpo(a) dms_call(NULL, a, DMS_FPO, sourcefilename, __LINE__) #define frk(a,b) dms_call(a, b, DMS_FRK, sourcefilename, __LINE__) #define dbgetc(a) dms_call(NULL, a, DMS_DBGETC, sourcefilename, __LINE__) #define getm(a,b) dms_call(a, b, DMS_GETM, sourcefilename, __LINE__) #define geto(a,b) dms_call(a, b, DMS_GETO, sourcefilename, __LINE__) #define gfc(a,b) dms_call(a, b, DMS_GFC, sourcefilename, __LINE__) #define gfm(a,b) dms_call(a, b, DMS_GFM, sourcefilename, __LINE__) #define gfo(a,b) dms_call(a, b, DMS_GFO, sourcefilename, __LINE__) #define gmc(a,b) dms_call(a, b, DMS_GMC, sourcefilename, __LINE__) #define goc(a,b) dms_call(a, b, DMS_GOC, sourcefilename, __LINE__) #define gtc(a) dms_call(NULL, a, DMS_GTC, sourcefilename, __LINE__) #define gtm(a,b) dms_call(a, b, DMS_GTM, sourcefilename, __LINE__) #define gto(a,b) dms_call(a, b, DMS_GTO, sourcefilename, __LINE__) #define ims(a) dms_call(NULL, a, DMS_IMS, sourcefilename, __LINE__) #define ios(a) dms_call(NULL, a, DMS_IOS, sourcefilename, __LINE__) #define mau(a) dms_call(NULL, a, DMS_MAU, sourcefilename, __LINE__) #define mcc(a) dms_call(NULL, a, DMS_MCC, sourcefilename, __LINE__) #define lgfile(a) dms_call(NULL, a, DMS_LGFILE, sourcefilename, __LINE__) #define lgflsh() dms_call(NULL, NULL, DMS_LGFLSH, sourcefilename, __LINE__) #define lgmsg(a) dms_call(NULL, a, DMS_LGMSG, sourcefilename, __LINE__) #define nci() dms_call(NULL, NULL, DMS_NCI, sourcefilename, __LINE__) #define pfc(a,b) dms_call(a, b, DMS_PFC, sourcefilename, __LINE__) #define pfm(a,b) dms_call(a, b, DMS_PFM, sourcefilename, __LINE__) #define pfo(a,b) dms_call(a, b, DMS_PFO, sourcefilename, __LINE__) #define pifd(a) dms_call(NULL, a, DMS_PIFD, sourcefilename, __LINE__) #define dbputc(a) dms_call(NULL, a, DMS_DBPUTC, sourcefilename, __LINE__) #define putm(a,b) dms_call(a, b, DMS_PUTM, sourcefilename, __LINE__) #define puto(a,b) dms_call(a, b, DMS_PUTO, sourcefilename, __LINE__) #define rms(a) dms_call(NULL, a, DMS_RMS, sourcefilename, __LINE__) #define ros(a) dms_call(NULL, a, DMS_ROS, sourcefilename, __LINE__) #define rsm(a) dms_call(NULL, a, DMS_RSM, sourcefilename, __LINE__) #define rso(a) dms_call(NULL, a, DMS_RSO, sourcefilename, __LINE__) #define scm(a) dms_call(NULL, a, DMS_SCM, sourcefilename, __LINE__) #define scn() dms_call(NULL, NULL, DMS_SCN, sourcefilename, __LINE__) #define sco(a) dms_call(NULL, a, DMS_SCO, sourcefilename, __LINE__) #define scu(a) dms_call(NULL, a, DMS_SCU, sourcefilename, __LINE__) #define smc(a) dms_call(NULL, a, DMS_SMC, sourcefilename, __LINE__) #define sme(a) dms_call(NULL, a, DMS_SME, sourcefilename, __LINE__) #define smm(a) dms_call(NULL, a, DMS_SMM, sourcefilename, __LINE__) #define smn(a) dms_call(NULL, a, DMS_SMN, sourcefilename, __LINE__) #define smo(a) dms_call(NULL, a, DMS_SMO, sourcefilename, __LINE__) #define smu(a,b) dms_call(a, b, DMS_SMU, sourcefilename, __LINE__) #define soc(a) dms_call(NULL, a, DMS_SOC, sourcefilename, __LINE__) #define soe(a) dms_call(NULL, a, DMS_SOE, sourcefilename, __LINE__) #define som(a) dms_call(NULL, a, DMS_SOM, sourcefilename, __LINE__) #define son(a) dms_call(NULL, a, DMS_SON, sourcefilename, __LINE__) #define soo(a) dms_call(NULL, a, DMS_SOO, sourcefilename, __LINE__) #define sou(a,b) dms_call(a, b, DMS_SOU, sourcefilename, __LINE__) #define suc(a) dms_call(NULL, a, DMS_SUC, sourcefilename, __LINE__) #define sum(a,b) dms_call(a, b, DMS_SUM, sourcefilename, __LINE__) #define sun(a) dms_call(NULL, a, DMS_SUN, sourcefilename, __LINE__) #define suo(a,b) dms_call(a, b, DMS_SUO, sourcefilename, __LINE__) #define suu(a) dms_call(NULL, a, DMS_SUU, sourcefilename, __LINE__) #define tct(a) dms_call(NULL, a, DMS_TCT, sourcefilename, __LINE__) #define tmt(a) dms_call(NULL, a, DMS_TMT, sourcefilename, __LINE__) #define tot(a) dms_call(NULL, a, DMS_TOT, sourcefilename, __LINE__) #define trabt() dms_call(NULL, NULL, DMS_TRABT, sourcefilename, __LINE__) #define trbgn() dms_call(NULL, NULL, DMS_TRBGN, sourcefilename, __LINE__) #define trcom() dms_call(NULL, NULL, DMS_TRCOM, sourcefilename, __LINE__) #define xmm(a) dms_call(NULL, a, DMS_XMM, sourcefilename, __LINE__) #define xmo(a) dms_call(NULL, a, DMS_XMO, sourcefilename, __LINE__) #define xom(a) dms_call(NULL, a, DMS_XOM, sourcefilename, __LINE__) #define xoo(a) dms_call(NULL, a, DMS_XOO, sourcefilename, __LINE__) #define mcf() dms_call(NULL, NULL, DMS_MCF, sourcefilename, __LINE__) #define mcp() dms_call(NULL, NULL, DMS_MCP, sourcefilename, __LINE__) #define mrtf(a) dms_call(NULL, a, DMS_MRTF, sourcefilename, __LINE__) #define mrtp(a) dms_call(NULL, a, DMS_MRTP, sourcefilename, __LINE__) #define msf(a) dms_call(NULL, a, DMS_MSF, sourcefilename, __LINE__) #define msp(a) dms_call(NULL, a, DMS_MSP, sourcefilename, __LINE__) #define tcn() dms_call(NULL, NULL, DMS_TCN, sourcefilename, __LINE__) #define tmn(a) dms_call(NULL, a, DMS_TMN, sourcefilename, __LINE__) #define ton(a) dms_call(NULL, a, DMS_TON, sourcefilename, __LINE__) #define dbcnv(a) dms_call(NULL, a, DMS_DBCNV, sourcefilename, __LINE__) #define alteos() dms_call(NULL, NULL, DMS_ALTEOS, sourcefilename, __LINE__) #define tun(a) dms_call(NULL, a, DMS_TUN, sourcefilename, __LINE__) #define fpmi(a,b) dms_call(a, b, DMS_FPMI, sourcefilename, __LINE__) #define fpoi(a,b) dms_call(a, b, DMS_FPOI, sourcefilename, __LINE__) #define fpmsk(a,b) dms_call(a, b, DMS_FPMSK, sourcefilename, __LINE__) #define fposk(a,b) dms_call(a, b, DMS_FPOSK, sourcefilename, __LINE__) #define ofm(a,b) dms_call(a, b, DMS_OFM, sourcefilename, __LINE__) #define ofo(a,b) dms_call(a, b, DMS_OFO, sourcefilename, __LINE__) #define olm(a,b) dms_call(a, b, DMS_OLM, sourcefilename, __LINE__) #define olo(a,b) dms_call(a, b, DMS_OLO, sourcefilename, __LINE__) #define omsk(a,b) dms_call(a, b, DMS_OMSK, sourcefilename, __LINE__) #define onm(a,b) dms_call(a, b, DMS_ONM, sourcefilename, __LINE__) #define onmsk(a,b) dms_call(a, b, DMS_ONMSK, sourcefilename, __LINE__) #define ono(a,b) dms_call(a, b, DMS_ONO, sourcefilename, __LINE__) #define onosk(a,b) dms_call(a, b, DMS_ONOSK, sourcefilename, __LINE__) #define oosk(a,b) dms_call(a, b, DMS_OOSK, sourcefilename, __LINE__) #define opm(a,b) dms_call(a, b, DMS_OPM, sourcefilename, __LINE__) #define opo(a,b) dms_call(a, b, DMS_OPO, sourcefilename, __LINE__) #define odrk(a,b) dms_call(a, b, DMS_ODRK, sourcefilename, __LINE__) #define ork(a,b) dms_call(a, b, DMS_ORK, sourcefilename, __LINE__) #define opmsk(a,b) dms_call(a, b, DMS_OPMSK, sourcefilename, __LINE__) #define oposk(a,b) dms_call(a, b, DMS_OPOSK, sourcefilename, __LINE__) #define omi(a,b) dms_call(a, b, DMS_OMI, sourcefilename, __LINE__) #define onmi(a,b) dms_call(a, b, DMS_ONMI, sourcefilename, __LINE__) #define opmi(a,b) dms_call(a, b, DMS_OPMI, sourcefilename, __LINE__) #define ooi(a,b) dms_call(a, b, DMS_OOI, sourcefilename, __LINE__) #define onoi(a,b) dms_call(a, b, DMS_ONOI, sourcefilename, __LINE__) #define opoi(a,b) dms_call(a, b, DMS_OPOI, sourcefilename, __LINE__) #define sdc(a) dms_call(NULL, a, DMS_SDC, sourcefilename, __LINE__) #define scd(a) dms_call(NULL, a, DMS_SCD, sourcefilename, __LINE__) #define mrid(a) dms_call(NULL, a, DMS_MRID, sourcefilename, __LINE__) #define gdc(a) dms_call(NULL, a, DMS_GDC, sourcefilename, __LINE__) #define gvlc(a,b) dms_call(a, b, DMS_GVLC, sourcefilename, __LINE__) #define gii(a,b) dms_call(a, b, DMS_GII, sourcefilename, __LINE__) #define gki(a,b) dms_call(a, b, DMS_GKI, sourcefilename, __LINE__) #define gri(a,b) dms_call(a, b, DMS_GRI, sourcefilename, __LINE__) #define glrv(a,b) dms_call(a, b, DMS_GLRV, sourcefilename, __LINE__) #define ghrv(a,b) dms_call(a, b, DMS_GHRV, sourcefilename, __LINE__) #define gsi(a,b) dms_call(a, b, DMS_GSI, sourcefilename, __LINE__) #define gtt(a,b) dms_call(a, b, DMS_GTT, sourcefilename, __LINE__) #define gfli(a) dms_call(NULL, a, DMS_GFLI, sourcefilename, __LINE__) #define gai(a,b) dms_call(a, b, DMS_GAI, sourcefilename, __LINE__) #define gafn(a,b) dms_call(a, b, DMS_GAFN, sourcefilename, __LINE__) #define trsync(a) dms_call(NULL, a, DMS_TRSYNC, sourcefilename, __LINE__) #define mcm() dms_call(NULL, NULL, DMS_MCM, sourcefilename, __LINE__) #define mrtm(a) dms_call(NULL, a, DMS_MRTM, sourcefilename, __LINE__) #define msm(a) dms_call(NULL, a, DMS_MSM, sourcefilename, __LINE__) #define mmu(a) dms_call(NULL, a, DMS_MMU, sourcefilename, __LINE__) #define nal() dms_call(NULL, NULL, DMS_NAL, sourcefilename, __LINE__) #define frm(a,b) dms_call(a, b, DMS_FRM, sourcefilename, __LINE__) #define fro(a,b) dms_call(a, b, DMS_FRO, sourcefilename, __LINE__) #define gfs(a,b) dms_call(a, b, DMS_GFS, sourcefilename, __LINE__) #define dbxpnd(a,b)dms_call(a, b, DMS_DBXPND, sourcefilename, __LINE__) #define gei(a) dms_call(NULL, a, DMS_GEI, sourcefilename, __LINE__) #define dbsel(a) dms_call(NULL, a, DMS_DBSEL, sourcefilename, __LINE__) #define vrdef(a,b) dms_call(a, b, DMS_VRDEF, sourcefilename, __LINE__) #define vrof(a,b) dms_call(a, b, DMS_VROF, sourcefilename, __LINE__) #define vron(a,b) dms_call(a, b, DMS_VRON, sourcefilename, __LINE__) #define gvii(a,b) dms_call(a, b, DMS_GVII, sourcefilename, __LINE__) #define gvri(a,b) dms_call(a, b, DMS_GVRI, sourcefilename, __LINE__) #define vrdel(a) dms_call(NULL, a, DMS_VRDEL, sourcefilename, __LINE__) #define dbmemu(a) dms_call(NULL, a, DMS_DBMEMU, sourcefilename, __LINE__) #define trbgna() dms_call(NULL, NULL, DMS_TRBGNA, sourcefilename, __LINE__) #define dmssjp(a,b)dms_call(a, b, DMS_DMSSJP, sourcefilename, __LINE__) #define dbfile(a) dms_call(NULL, a, DMS_DBFILE, sourcefilename, __LINE__) #define gxerr(a) dms_call(NULL, a, DMS_GXERR, sourcefilename, __LINE__) #define gxstr(a) dms_call(NULL, a, DMS_GXSTR, sourcefilename, __LINE__) #define dbalign() dms_call(NULL, NULL, DMS_DBALIGN,sourcefilename, __LINE__) #define dbau() dms_call(NULL, NULL, DMS_DBAU, sourcefilename, __LINE__) #define dbsu(a) dms_call(NULL, a, DMS_DBSU, sourcefilename, __LINE__) #define dbfu() dms_call(NULL, NULL, DMS_DBFU, sourcefilename, __LINE__) #define dbavail(a) dms_call(NULL, a, DMS_DBAVAIL,sourcefilename, __LINE__) #define dbsrv(a) dms_call(NULL, a, DMS_DBSRV, sourcefilename, __LINE__) #define dbstart(a) dms_call(NULL, a, DMS_DBSTART,sourcefilename, __LINE__) #define dbstop(a) dms_call(NULL, a, DMS_DBSTOP, sourcefilename, __LINE__) #define dbusr(a,b) dms_call(a, b, DMS_DBUSR, sourcefilename, __LINE__) #define dbems(a) dms_call(NULL, a, DMS_DBEMS, sourcefilename, __LINE__) /* Eof. DMSFUNC.H */ Listing Two /************************** * Module Name: DMSCALL.c **************************/ #define NTC_DMS_FILENAME static char sourcefilename[] = "DMSCALL"; #include "mmsys.h" #include "codedef.h" /* ** The next two constants define the number of times the error-64-handler ** will retry the call before asking the user whether to continue, and ** the number of 10ths of a second between retries. */ #define MAX_ERR64_RETRIES 15 #define ERR64_RETRY_INTERVAL 20 #define DOT_SYMBOL '+' extern short dmserrs[]; void dms_error(int, int, char *, unsigned int, BOOL, BOOL); /****************************** * DESCRIPTION: * This function replaces all calls to MDBS functions. Macros redefine * the DMS calls to call this function instead. * For example, * #define crs(a,b) dms_call(crs,(char *)a,(char *)b,8,__FILE__,__LINE__) * the argument fnum is MDBS's unique number for the function. * filename and linenumb are the name of the file and the line number as * determined by the preprocessor and set as replacements for __FILE__ and * __LINE__, respectively. * Benign command status values are returned to the calling function. More * serious values are given to dms_error() which displays the information * and exits to DOS. ******************************/ int NTC_PASCAL dms_call (arg1, arg2, fnum, filename, linenumb) char *arg1, *arg2; int fnum; char *filename; unsigned int linenumb; { int error, nwindow; int i, ntries; BOOL dbbusy_window_open; char dots_array[80]; int last_dot; char context_buffer[80], logmsg[100]; struct lock_msg_struct msgbuf; static char context_fmtstr[] = "(status: %d, fn: %d, file: %s %u)"; MSG msg; /* ** ntries is set at MAX_ERR64_RETRIES, in the case that an error 64 ** occurs. If it is error 64, ntries will be decremented each time ** the function is retried. */ ntries = MAX_ERR64_RETRIES; /* ** dbbusy_window_open is used to track whether the "DB Busy" window ** has been opened or not. */ dbbusy_window_open = FALSE; /* ** last_dot is an index to the array of dots which increments with each ** retry. Used with error 64. */ last_dot = 0; /* ** nwindow indicates how many windows are opened. ** It has to be initialized here because in the case of error 64 it ** is necessary to close the DB BUSY window if that window is open and on ** the retry an error other than 64 occurs. ** In this case it is necessary that we ** close no windows if the error 64 case has not opened any. */ nwindow = 0; do { /* ** Call the DMS function, and return immediately if ** the command status is 0. */ error = (*(get_dmsfptr(fnum)))(arg1, arg2); /* ** See note for nwindow above. */ if ((nwindow) && (error != 64)) { ntc_close_window (nwindow, &nwindow); spi_flush_screen(); } if (error == 0) { /* ** Close DB Busy window if it is open. */ if (dbbusy_window_open) { ntc_close_window (nwindow, &nwindow); spi_flush_screen(); } return (0); } /* ** Check the array of allowable errors. Return if the non-zero ** error from *fptr is in the array; else go to the switch below. ** The variable pass_array is a global array. */ for (i = 0; dmserrs[i]; ++i) { if (error == dmserrs[i]) { if ((dbbusy_window_open)) { ntc_close_window (nwindow, &nwindow); spi_flush_screen(); } return (error); } } switch (error) { case 255: /* ** End-of-set condition. This is not really an error at all. ** Return the end-of-set result code to the caller. */ if (dbbusy_window_open) { ntc_close_window (nwindow, &nwindow); spi_flush_screen(); } return(255); case 62: case 63: case 68: /* ** Record-locking conflict */ clearstruct(msgbuf); sprintf(msgbuf.msg[0], "Status: %d fn: %d File: %s Line: %d", error, fnum, filename, linenumb); /* Give user option of retrying or aborting */ switch (retry_dms_msg("xusertry", &msgbuf)) { case RETRY_YES: break; case RETRY_NO: dms_error(error, fnum, filename, linenumb, FALSE, TRUE); break; // dms_error should never return. } break; case 64: /* ** Our operation was rejected because another user has an ** abortable transaction in progress. */ if (! dbbusy_window_open) { ntc_open_std_window ("xdbbusy", 5, 13, &nwindow); spi_string_tofield_byname("fil", filename); spi_int_tofield_byname("lin", linenumb); spi_flush_screen(); dbbusy_window_open = TRUE; } else { /* ** If the xdbbusy window is already open, write a dot to ** the window. */ dots_array[last_dot] = DOT_SYMBOL; dots_array[++last_dot] = '\0'; spi_string_tofield_byname("dbbusy", dots_array); spi_flush_screen(); } spi_keyhit(ERR64_RETRY_INTERVAL); // Wait 2 seconds. if (ntries--) continue; last_dot = 0; *dots_array = '\0'; sprintf (context_buffer, context_fmtstr, error, fnum, filename, linenumb); switch (retry_dms ("xdb64ask", context_buffer)) { case RETRY_YES: ntries = MAX_ERR64_RETRIES; continue; case RETRY_NO: dms_error(error, fnum, filename, linenumb, FALSE, TRUE); break; // dms_error should never return. } break; default: if (dbbusy_window_open) { ntc_close_window (nwindow, &nwindow); spi_flush_screen(); } dms_error(error, fnum, filename, linenumb, TRUE, TRUE); break; /* dms_error should never return. */ } /* end of switch (error) */ } while (TRUE); /* end of while; will always loop again */ } Listing Three /****************** * Insert the current record into the specified set. * Handles the case where the record is already a member of the set. * Return Values: * 0 Record inserted into set successfully. * 1 Record was already a member of the set. ******************/ void InsertRecord(char *setname) { int ret; passerr(11); /* Tell the DMS error handler not to trap error 11 */ ret = ims(setname); /* Attempt insertion of record into set */ passerr(-11); /* Restore default trapping of DMS Error 11 */ return((ret == 11) ? 1 : 0); }