home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / ms_sh16.lzh / ms_sh.2 < prev    next >
Text File  |  1990-05-06  |  39KB  |  1,817 lines

  1.  
  2. #!/bin/sh
  3. # this is part 2 of a multipart archive
  4. # do not concatenate these parts, unpack them in order with /bin/sh
  5. # file Patch1.6 continued
  6. #
  7. CurArch=2
  8. if test ! -r s2_seq_.tmp
  9. then echo "Please unpack part 1 first!"
  10.      exit 1; fi
  11. ( read Scheck
  12.   if test "$Scheck" != $CurArch
  13.   then echo "Please unpack part $Scheck next!"
  14.        exit 1;
  15.   else exit 0; fi
  16. ) < s2_seq_.tmp || exit 1
  17. echo "x - Continuing file Patch1.6"
  18. sed 's/^X//' << 'SHAR_EOF' >> Patch1.6
  19. X  
  20. X  ;
  21. X  ; Some addition variables
  22. X--- 88,118 ----
  23. X          public    _SW_fp
  24. X          public    _SW_I0_V
  25. X          public    _SW_I23_V
  26. X          public    _SW_EMstart
  27. X          public    _SW_Mode
  28. X          public    _SW_EMSFrame
  29. X          public    _SW_Int24
  30. X+         public    _SW_XMS_Driver
  31. X+         public    _SW_XMS_Gversion
  32. X+         public    _SW_XMS_Allocate
  33. X+         public    _SW_XMS_Free
  34. X  
  35. X+ 
  36. X  _cmd_line    db    129 dup (?)    ; Command line
  37. X  _path_line    db    80 dup (?)    ; Path line
  38. X  _SW_Blocks    dw    0        ; Number of blocks to read/write
  39. X  _SW_fp        dw    0        ; File ID
  40. X  _SW_I0_V    dd    0        ; Our Interrupt Zero address
  41. X  _SW_I23_V    dd    0        ; Our Interrupt 23 address
  42. X  _SW_EMstart    dd    0100000H    ; Default Extended Mem start
  43. X  _SW_Mode    dw    0        ; Type of swapping to do
  44. X                      ;   1 - disk
  45. X                      ;   2 - Extended memory
  46. X!                     ;   3 - EMS driver
  47. X!                     ;   4 - XMS driver
  48. X  _SW_EMSFrame    dw    0        ; EMS Frame segment
  49. X  _SW_intr    dw    0        ; Interrupt 23 detected.
  50. X+ _SW_XMS_Driver    dd    0        ; XMS Driver Interface
  51. X  
  52. X  ;
  53. X  ; Some addition variables
  54. X***************
  55. X*** 120,128 ****
  56. X  FCB2        dw    16    dup (?)
  57. X  
  58. X  ;
  59. X! ; Extended Memory Global Descriptor tables
  60. X  ;
  61. X  
  62. X  GD_table    equ    $
  63. X  GDT_Dummy    dw    4    dup (0)        ; Dummy
  64. X  GDT_self    dw    4    dup (0)        ; For self
  65. X--- 141,160 ----
  66. X  FCB2        dw    16    dup (?)
  67. X  
  68. X  ;
  69. X! ; XMS Driver Move structure
  70. X  ;
  71. X  
  72. X+ XMS_DIF        equ    $
  73. X+ XMS_Length    dd    0            ; Number of bytes
  74. X+ XMS_SHandle    dw    0            ; Source Handler
  75. X+ XMS_Soffset    dd    0            ; Source Offset
  76. X+ XMS_DHandle    dw    0            ; Destination Handler
  77. X+ XMS_Doffset    dd    0            ; Destination Offset
  78. X+ 
  79. X+ ;
  80. X+ ; Extended Memory Global Descriptor tables
  81. X+ ;
  82. X+         org    XMS_DIF
  83. X  GD_table    equ    $
  84. X  GDT_Dummy    dw    4    dup (0)        ; Dummy
  85. X  GDT_self    dw    4    dup (0)        ; For self
  86. X***************
  87. X*** 297,315 ****
  88. X  
  89. X  $Write_loop:
  90. X      or    si, si
  91. X!     je    $Write_Complete
  92. X  
  93. X  ; OK - Copy next 0x4000 bytes - switch on device
  94. X  
  95. X      mov    ax, word ptr cs: _SW_Mode
  96. X      dec    ax
  97. X      jz    $Write_disk
  98. X      dec    ax
  99. X!     jz    $W_extend
  100. X      jmp    $W_expand
  101. X  
  102. X! ; Write to disk
  103. X  
  104. X  $Write_disk:
  105. X      mov    ax, 04000H        ; Set up to write
  106. X      mov    cx, ax            ; Load count
  107. X--- 329,396 ----
  108. X  
  109. X  $Write_loop:
  110. X      or    si, si
  111. X!     jnz    $Write_L1
  112. X!     jmp    $Write_Complete
  113. X  
  114. X  ; OK - Copy next 0x4000 bytes - switch on device
  115. X  
  116. X+ $Write_L1:
  117. X      mov    ax, word ptr cs: _SW_Mode
  118. X      dec    ax
  119. X      jz    $Write_disk
  120. X      dec    ax
  121. X!     jnz    $Write_L2
  122. X!     jmp    $W_extend
  123. X! $Write_L2:
  124. X!     dec    ax
  125. X!     jnz    $W_xms
  126. X      jmp    $W_expand
  127. X  
  128. X! ;
  129. X! ; Write to XMS driver.  In this case, we do one write and let the driver
  130. X! ; sort out the blocking
  131. X! ;
  132. X! $W_xms:
  133. X!     xor    ax, ax
  134. X!     mov    word ptr cs:XMS_SHandle, ax    ; Source - normal memory
  135. X!     mov    word ptr cs:XMS_DHandle, bx    ; Dest - XMS
  136. X  
  137. X+     mov    word ptr cs:XMS_Doffset, ax    ; Dest offset - zero
  138. X+     mov    word ptr cs:XMS_Doffset + 2, ax
  139. X+ 
  140. X+     mov    word ptr cs:XMS_Soffset, ax    ; Source offset DS:0
  141. X+     mov    ax, ds
  142. X+     mov    word ptr cs:XMS_Soffset + 2, ax
  143. X+ 
  144. X+ ;
  145. X+ ; Set up number of bytes SW_Block * 16 * 1024
  146. X+ ;
  147. X+ 
  148. X+     mov    ax, si
  149. X+     mov    dx, si
  150. X+     mov    cl, 14
  151. X+     shl    ax, cl
  152. X+     mov    cl, 2
  153. X+     shr    dx, cl
  154. X+     mov    word ptr cs:XMS_Length, ax    ; Load number of bytes
  155. X+     mov    word ptr cs:XMS_Length + 2, dx
  156. X+ 
  157. X+     mov    ah, 0BH                ; Set up parameters
  158. X+     mov    dx, cs
  159. X+     mov    ds, dx
  160. X+     mov    si, offset XMS_DIF
  161. X+     call    cs:[_SW_XMS_Driver]
  162. X+     or    ax, ax
  163. X+     jnz     $Write_Complete
  164. X+ 
  165. X+ ; XMS error - abort
  166. X+     
  167. X+     mov    ah, bl
  168. X+     jmp    $Write_error
  169. X+ 
  170. X+ ;
  171. X+ ; Write to disk
  172. X+ ;
  173. X  $Write_disk:
  174. X      mov    ax, 04000H        ; Set up to write
  175. X      mov    cx, ax            ; Load count
  176. X***************
  177. X*** 321,328 ****
  178. X  
  179. X      pop    si            ; Restore Regs
  180. X      pop    bx
  181. X!     jc    $Write_error        ; NO - abort
  182. X  
  183. X  $Write_Incr:
  184. X      dec    si            ; Decrement block count
  185. X      mov    ax, ds            ; Increment offset
  186. X--- 402,425 ----
  187. X  
  188. X      pop    si            ; Restore Regs
  189. X      pop    bx
  190. X!     jnc    $Write_disk1        ; NO error - continue
  191. X  
  192. X+ ;
  193. X+ ; Error - abort
  194. X+ ;
  195. X+     mov    ds, word ptr cs:S_ds    ; Restore DS
  196. X+     mov    ah, al
  197. X+     call    far ptr __maperror    ; Map the error
  198. X+     jmp    $Write_Error1
  199. X+ 
  200. X+ ; Check for 16K write
  201. X+ 
  202. X+ $Write_disk1:
  203. X+     cmp    ax, 04000H
  204. X+     jz    $Write_Incr
  205. X+     mov    ax,01c1cH        ; Set disk full
  206. X+     jmp    $Write_error        ; NO - abort
  207. X+ 
  208. X  $Write_Incr:
  209. X      dec    si            ; Decrement block count
  210. X      mov    ax, ds            ; Increment offset
  211. X***************
  212. X*** 372,377 ****
  213. X--- 469,475 ----
  214. X      mov    al, ah
  215. X      xor    ah, ah
  216. X      mov    word ptr ds:_errno, ax    ; Save error code
  217. X+ $Write_Error1:
  218. X      mov    ax, 0FFFEH
  219. X      jmp    $SA_spawn_Exit        ; Exit
  220. X  
  221. X***************
  222. X*** 642,651 ****
  223. X      jz    $R_disk
  224. X      dec    ax
  225. X      jz    $R_extend
  226. X!     jmp    $R_expand
  227. X  
  228. X! ; Read from disk
  229. X  
  230. X  $R_disk:
  231. X      call    $Read_disk
  232. X      jmp    $Read_loop
  233. X--- 740,757 ----
  234. X      jz    $R_disk
  235. X      dec    ax
  236. X      jz    $R_extend
  237. X!     dec    ax
  238. X!     jz    $R_expand
  239. X  
  240. X! ;
  241. X! ; Read from XMS driver.  In this case, we do one read and let the driver
  242. X! ; sort out the blocking
  243. X! ;
  244. X!     call    $Read_XMS
  245. X!     jmp     $Read_Complete
  246. X  
  247. X+ ; Read from disk
  248. X+ 
  249. X  $R_disk:
  250. X      call    $Read_disk
  251. X      jmp    $Read_loop
  252. X***************
  253. X*** 676,681 ****
  254. X--- 782,788 ----
  255. X  ;  Save exit code
  256. X  
  257. X      push    word ptr cs:Result        ; Save response
  258. X+     push    word ptr cs:_SW_intr        ; and interrupt flag
  259. X  
  260. X  ;
  261. X  ; Read in the first block - BX - File Handler
  262. X***************
  263. X*** 702,709 ****
  264. X      jz    $R1_Disk
  265. X      dec    ax
  266. X      jz    $R1_Extend
  267. X!     jmp    $R1_Expand
  268. X  
  269. X  $R1_Disk:
  270. X      call    $Read_disk
  271. X      jmp    $Read1_OK
  272. X--- 809,821 ----
  273. X      jz    $R1_Disk
  274. X      dec    ax
  275. X      jz    $R1_Extend
  276. X!     dec    ax
  277. X!     jz    $R1_Expand
  278. X  
  279. X+     mov    si, 1                ; Read one block
  280. X+     call    $Read_XMS
  281. X+     jmp    $Read1_OK
  282. X+ 
  283. X  $R1_Disk:
  284. X      call    $Read_disk
  285. X      jmp    $Read1_OK
  286. X***************
  287. X*** 721,726 ****
  288. X--- 833,839 ----
  289. X  ;
  290. X  
  291. X  $Read1_OK:
  292. X+     pop    word ptr cs:_SW_intr        ; Restore interrupt flag
  293. X      pop    ax
  294. X  
  295. X  ;
  296. X***************
  297. X*** 757,776 ****
  298. X  
  299. X  $SA_Exit1:
  300. X      pop    ax                ; Restore result
  301. X!     mov    sp,bp
  302. X      pop    bp
  303. X      ret
  304. X  
  305. X  _SA_spawn    endp
  306. X  
  307. X  ;
  308. X! ; READ DISK FUNCTION
  309. X  ;
  310. X  ;    BX - file handler
  311. X  ;    SI - Block count
  312. X  ;    DS - Output data segement
  313. X  ;
  314. X  
  315. X  $Read_disk    proc    near
  316. X  
  317. X      mov    ax, 03f00H        ; Set up to read
  318. X--- 870,941 ----
  319. X  
  320. X  $SA_Exit1:
  321. X      pop    ax                ; Restore result
  322. X!     mov    sp, bp
  323. X      pop    bp
  324. X      ret
  325. X  
  326. X  _SA_spawn    endp
  327. X  
  328. X  ;
  329. X! ; READ XMS DRIVER FUNCTION
  330. X  ;
  331. X  ;    BX - file handler
  332. X  ;    SI - Block count
  333. X  ;    DS - Output data segement
  334. X  ;
  335. X+ $Read_XMS    proc    near
  336. X+     xor    ax, ax
  337. X+     mov    word ptr cs:XMS_SHandle, bx    ; Source - XMS
  338. X+     mov    word ptr cs:XMS_DHandle, ax    ; Dest - normal memory
  339. X  
  340. X+     mov    word ptr cs:XMS_Soffset, ax    ; Source offset - zero
  341. X+     mov    word ptr cs:XMS_Soffset + 2, ax
  342. X+ 
  343. X+     mov    word ptr cs:XMS_Doffset, ax    ; Dest offset DS:0
  344. X+     mov    ax, ds
  345. X+     mov    word ptr cs:XMS_Doffset + 2, ax
  346. X+ 
  347. X+     cmp    si, 1                ; If first block, the
  348. X+     jz    $Read_X1            ; source offset is
  349. X+                         ; 4000H
  350. X+     mov    word ptr cs:XMS_Soffset, 04000H
  351. X+ 
  352. X+ ;
  353. X+ ; Set up number of bytes: si * 16 * 1024
  354. X+ ;
  355. X+ 
  356. X+ $Read_X1:
  357. X+     mov    ax, si
  358. X+     mov    dx, si
  359. X+     mov    cl, 14
  360. X+     shl    ax, cl
  361. X+     mov    cl, 2
  362. X+     shr    dx, cl
  363. X+     mov    word ptr cs:XMS_Length, ax    ; Load number of bytes
  364. X+     mov    word ptr cs:XMS_Length + 2, dx
  365. X+ 
  366. X+     mov    ah, 0BH                ; Set up parameters
  367. X+     mov    dx, cs
  368. X+     mov    ds, dx
  369. X+     mov    si, offset XMS_DIF
  370. X+     call    cs:[_SW_XMS_Driver]
  371. X+     or    ax, ax
  372. X+     jnz     $Read_XMS1
  373. X+     jmp    Load_Error            ; XMS error - abort
  374. X+ 
  375. X+ $Read_XMS1:
  376. X+     ret
  377. X+ 
  378. X+ $Read_XMS    endp
  379. X+ 
  380. X+ ;
  381. X+ ; READ DISK FUNCTION
  382. X+ ;
  383. X+ ;    BX - file handler
  384. X+ ;    SI - Block count
  385. X+ ;    DS - Output data segement
  386. X+ ;
  387. X+ 
  388. X  $Read_disk    proc    near
  389. X  
  390. X      mov    ax, 03f00H        ; Set up to read
  391. X***************
  392. X*** 872,882 ****
  393. X  
  394. X  Load_Error    proc    near
  395. X  
  396. X!     mov    ax, 00900H
  397. X!     mov    dx, offset Swap_PANIC
  398. X      mov    bx, cs
  399. X      mov    ds, bx
  400. X!     int    021H
  401. X  $Wait_L:
  402. X      sti
  403. X      hlt
  404. X--- 1037,1046 ----
  405. X  
  406. X  Load_Error    proc    near
  407. X  
  408. X!     mov    di, offset Swap_PANIC
  409. X      mov    bx, cs
  410. X      mov    ds, bx
  411. X!     call    I24_Display
  412. X  $Wait_L:
  413. X      sti
  414. X      hlt
  415. X***************
  416. X*** 1021,1059 ****
  417. X  ;
  418. X  ; INTERRUPT 24 - ERROR HANDLER - Output message
  419. X  ;
  420. X  
  421. X! _SW_Int24    proc    far
  422. X!     pushf                ; Save flags
  423. X!     call    dword ptr cs:_SW_I24_V 
  424. X  
  425. X!     cmp    byte ptr cs:InShell, 0    ; Are we in the shell ? 
  426. X!     jnz    $SW_int24c        ; No - no processing
  427. X  
  428. X!     test    ah, 010h
  429. X!     jnz    $SW_int24a
  430. X!     test    ah, 008h
  431. X!     jnz    $SW_int24b
  432. X  
  433. X!     mov    al, 003h        ; Fail system call
  434. X  
  435. X- $SW_int24c:
  436. X-     iret
  437. X- 
  438. X  ;
  439. X! $SW_int24a:
  440. X!     xor    al, al            ; Ignore error
  441. X!     iret
  442. X! 
  443. X  ;
  444. X! $SW_int24b:
  445. X!     mov    al, 001h        ; Retry error
  446. X      iret
  447. X  _SW_Int24    endp
  448. X  
  449. X  ;
  450. X! ;  Start of overwrite area for environment.  Align on a paragraph
  451. X  ;
  452. X          ALIGN    16
  453. X  Env_OWrite:
  454. X  SH0_TEXT    ends
  455. X          end
  456. X--- 1185,1690 ----
  457. X  ;
  458. X  ; INTERRUPT 24 - ERROR HANDLER - Output message
  459. X  ;
  460. X+ ;    AH - Bit  7    = 0 Disk error
  461. X+ ;            = 1 FAT error if block device
  462. X+ ;                Error code in DI if character device
  463. X+ ;      Bit  6    UNUSED
  464. X+ ;      Bit  5    = 1 Ignore allowed
  465. X+ ;      Bit  4    = 1 Retry allowed
  466. X+ ;      Bit  3    = 1 Fail allowed
  467. X+ ;      Bits 2 & 1    = Disk Area
  468. X+ ;      Bit  0    = 1 Writing error
  469. X+ ;    AL         = Disk drive number
  470. X+ ;    DI            = Error code
  471. X+ ;    BP:SI        = Header of device driver for which error occured
  472. X+ ;
  473. X+ ;
  474. X+ ; Return
  475. X+ ;    AL            = 0 Ignore Error
  476. X+ ;            = 1 Retry operation
  477. X+ ;            = 2 Abort program
  478. X+ ;            = 3 Fail system call
  479. X+ ;
  480. X  
  481. X! I24_Errors    equ    $
  482. X! I24_EC00:    db    'Write protect error$'
  483. X! I24_EC01:    db    'Unknown unit$'
  484. X! I24_EC02:    db    'Drive not ready$'
  485. X! I24_EC03:    db    'Unknown command$'
  486. X! I24_EC04:    db    'Data error$'
  487. X! I24_EC05:    db    'Bad request$'
  488. X! I24_EC06:    db    'Seek error$'
  489. X! I24_EC07:    db    'Unknown media type$'
  490. X! I24_EC08:    db    'Sector not found$'
  491. X! I24_EC09:    db    'Paper out$'
  492. X! I24_EC0A:    db    'Write fault$'
  493. X! I24_EC0B:    db    'Read fault$'
  494. X! I24_EC0C:    db    'General failure$'
  495. X! I24_EC0D:    db    'Unknown code$'
  496. X! I24_EC0F:    db    'Invalid disk change$'
  497. X! I24_EC10:    db    'FCB unavailable$'
  498. X! I24_EC11:    db    'Sharing buffer overflow$'
  499. X  
  500. X! ;
  501. X! ; Error message address table
  502. X! ;
  503. X  
  504. X! I24_ECTABLE:    dw    offset I24_EC00
  505. X!         dw    offset I24_EC01
  506. X!         dw    offset I24_EC02
  507. X!         dw    offset I24_EC03
  508. X!         dw    offset I24_EC04
  509. X!         dw    offset I24_EC05
  510. X!         dw    offset I24_EC06
  511. X!         dw    offset I24_EC07
  512. X!         dw    offset I24_EC08
  513. X!         dw    offset I24_EC09
  514. X!         dw    offset I24_EC0A
  515. X!         dw    offset I24_EC0B
  516. X!         dw    offset I24_EC0C
  517. X!         dw    offset I24_EC0D
  518. X!         dw    offset I24_EC0D        ; 0E - no message
  519. X!         dw    offset I24_EC0F
  520. X!         dw    offset I24_EC10
  521. X!         dw    offset I24_EC11
  522. X  
  523. X! I24_ECON:    db    ' when $'
  524. X! I24_ECREAD:    db    'reading $'
  525. X! I24_ECWRITE:    db    'writing $'
  526. X! I24_ECDEVICE:    db    'device $'
  527. X! I24_ECDISK:    db    'disk $'
  528. X! I24_EABORT:    db    'Abort$'
  529. X! I24_EFAIL:    db    ', Fail$'
  530. X! I24_EIGNORE:    db    ', Ignore$'
  531. X! I24_ERETRY:    db    ', Retry$'
  532. X! I24_EDRIVE:    db    '?$'
  533. X! I24_EQUESTION    db    '? $'
  534. X! I24_RESPONSE:    db    ' '
  535. X! I24_ENL:    db    0dH, 0aH, '$'
  536. X! I24_EBELL:    db    07H, '$'
  537. X! I24_EDNAME:    db    '12345678$'
  538. X! I24_EXTECODE:    db    0dH, 0aH, '(Extended Code: '
  539. X! I24_E_AL:    db    '  '
  540. X!         db    ' Class: '
  541. X! I24_E_BH:    db    '  '
  542. X!         db    ' Action: '
  543. X! I24_E_BL:    db    '  '
  544. X!         db    ' Locus: '
  545. X! I24_E_CH:    db    '  )', 0dH, 0aH, '$'
  546. X  
  547. X  ;
  548. X! ; Save DS, ES, BX, CX, DX
  549. X  ;
  550. X! _SW_Int24    proc    far
  551. X!     push    ds        ; Save registers
  552. X!     push    es
  553. X!     push    bx
  554. X!     push    cx
  555. X!     push    dx
  556. X! 
  557. X!     push    cs        ; Set up data segment
  558. X!     pop    ds
  559. X! 
  560. X!     mov    cx, ax        ; Save the error information in CX
  561. X! 
  562. X!     push    di
  563. X!     mov    di, offset I24_ENL
  564. X!     call    I24_Display
  565. X!     pop    di
  566. X! 
  567. X! ;
  568. X! ;  Check inside message range
  569. X! ;
  570. X!     cmp    di, 012H
  571. X!     jb    SWI24a
  572. X!     mov    di, 0dH
  573. X! 
  574. X! ;
  575. X! ; Write the error message
  576. X! ;
  577. X! 
  578. X! SWI24a:
  579. X!     add    di, di
  580. X! 
  581. X!     mov    di, word ptr ds:I24_ECTABLE[di]
  582. X!     call    I24_Display
  583. X! 
  584. X! ;
  585. X! ; Output on message
  586. X! ;
  587. X! 
  588. X!     mov    di, offset I24_ECON
  589. X!     call    I24_Display
  590. X! 
  591. X! ;
  592. X! ; Output reading or write message
  593. X! ;
  594. X! 
  595. X!     mov    di, offset I24_ECWRITE
  596. X!     test    ch, 01H
  597. X!     jnz    SWI24b
  598. X!     mov    di, offset I24_ECREAD
  599. X! 
  600. X! SWI24b:
  601. X!     call    I24_Display
  602. X! 
  603. X! ;
  604. X! ; Output device message
  605. X! ;
  606. X! 
  607. X!     test    ch, 080H
  608. X!     jz    SWI24c
  609. X! 
  610. X!     mov    di, offset I24_ECDEVICE
  611. X!     call    I24_Display
  612. X! 
  613. X! ;
  614. X! ; Output device name - up to eight characters
  615. X! ;
  616. X! 
  617. X!     add    si, 0aH            ; Move to device name
  618. X!     push    ds
  619. X!     mov    ds, bp
  620. X!     xor    di, di            ; Set counter
  621. X! 
  622. X! SWI24b1:
  623. X!     mov    dl, byte ptr ds:[si]    ; Get next character in name
  624. X!     cmp    dl, ' '
  625. X!     jz    SWI24d
  626. X! 
  627. X!     mov    byte ptr cs:[I24_EDNAME + di], dl
  628. X! 
  629. X!     inc    si
  630. X!     inc    di
  631. X!     cmp    di, 8
  632. X!     jnz    SWI24b1
  633. X! ;
  634. X! ; Append a $
  635. X! ; 
  636. X! 
  637. X! SWI24d:
  638. X!     pop    ds
  639. X!     mov    byte ptr cs:[I24_EDNAME + di], '$'
  640. X!     mov    di, offset I24_EDNAME
  641. X!     jmp    SWI24e
  642. X! 
  643. X! ;
  644. X! ; Write disk error
  645. X! ;
  646. X! SWI24c:
  647. X!     mov    di, offset I24_ECDISK
  648. X!     call    I24_Display
  649. X! 
  650. X!     mov    dl, cl
  651. X!     add    dl, 'A'
  652. X!     mov    byte ptr cs:I24_EDRIVE, dl
  653. X! 
  654. X!     mov    di, offset I24_EDRIVE
  655. X! SWI24e:
  656. X!     call    I24_Display
  657. X! 
  658. X! ;
  659. X! ; Get extended error codes
  660. X! ;
  661. X!     push    cx
  662. X!     push    ds
  663. X!     mov    ah, 059H
  664. X!     xor    bx, bx
  665. X!     int    021H
  666. X! 
  667. X! ;
  668. X! ; Save responses
  669. X! ;
  670. X! 
  671. X!     mov    byte ptr cs:I24_E_AL, al
  672. X!     mov    byte ptr cs:I24_E_BL, bl
  673. X!     mov    byte ptr cs:I24_E_BH, bh
  674. X!     mov    byte ptr cs:I24_E_CH, ch
  675. X!     pop    ds
  676. X!     pop    cx
  677. X! 
  678. X! ; Convert to display Hex.
  679. X! 
  680. X!     mov    di, offset I24_E_AL
  681. X!     call    I24_Convert
  682. X!     mov    di, offset I24_E_BL
  683. X!     call    I24_Convert
  684. X!     mov    di, offset I24_E_BH
  685. X!     call    I24_Convert
  686. X!     mov    di, offset I24_E_CH
  687. X!     call    I24_Convert
  688. X!     mov    di, offset I24_EXTECODE
  689. X!     call    I24_Display
  690. X! ;
  691. X! ; Output Options 
  692. X! ;
  693. X!     mov    di, offset I24_EABORT
  694. X!     call    I24_Display
  695. X! 
  696. X!     test    ch, 020H        ; Ignore allowed ?
  697. X!     jz    SWI24f
  698. X!     mov    di, offset I24_EIGNORE
  699. X!     call    I24_Display
  700. X! 
  701. X! SWI24f:
  702. X!     test    ch, 010H        ; Retry allowed ?
  703. X!     jz    SWI24g
  704. X!     mov    di, offset I24_ERETRY
  705. X!     call    I24_Display
  706. X! 
  707. X! SWI24g:
  708. X!     test    ch, 08H            ; Fail allowed ?
  709. X!     jz    SWI24h
  710. X!     mov    di, offset I24_EFAIL
  711. X!     call    I24_Display
  712. X! 
  713. X! ;
  714. X! ; Append a question mark.
  715. X! ;
  716. X! 
  717. X! SWI24h:
  718. X!     mov    di, offset I24_EQUESTION
  719. X!     call    I24_Display
  720. X! 
  721. X! ;
  722. X! ; Get the valid key codes
  723. X! ;
  724. X! SWI24j:
  725. X!     xor    ax, ax            ; Read a keyboard character
  726. X!     int    16H
  727. X!     and    al, 05fH        ; Upper case
  728. X! 
  729. X!     xor    ah, ah            ; Clear counter
  730. X!     cmp    al, 'I'            ; Ignore ?
  731. X!     jnz    SWI24k
  732. X!     test    ch, 020H
  733. X!     jnz    SWI24n
  734. X! SWI24k:
  735. X!     inc    ah
  736. X!     cmp    al, 'R'            ; Retry ?
  737. X!     jnz    SWI24l
  738. X!     test    ch, 010H
  739. X!     jnz    SWI24n
  740. X! SWI24l:
  741. X!     inc    ah
  742. X!     cmp    al, 'A'            ; Abort ?
  743. X!     jz    SWI24n
  744. X! 
  745. X!     inc    ah
  746. X!     cmp    al, 'F'            ; Fail ?
  747. X!     jnz    SWI24m
  748. X!     test    ch, 08H
  749. X!     jnz    SWI24n
  750. X! SWI24m:
  751. X!     mov    di, offset I24_EBELL
  752. X!     call    I24_Display
  753. X!     jmp    SWI24j
  754. X! 
  755. X! ;
  756. X! ; OK - got code
  757. X! ;
  758. X! SWI24n:
  759. X!     mov    cl, ah
  760. X!     mov    byte ptr ds:I24_RESPONSE, al
  761. X!     mov    di, offset I24_RESPONSE
  762. X!     call    I24_Display
  763. X!     mov    ax, cx
  764. X! 
  765. X! ;
  766. X! ; Are we in the shell ?
  767. X! ;
  768. X!     cmp    byte ptr cs:InShell, 0    ; Are we in the shell ? 
  769. X!     jnz    $SW_int24a        ; No - no processing
  770. X! 
  771. X!     cmp    al, 02H            ; Abort?
  772. X!     jnz    $SW_int24a        ; No - exit
  773. X! 
  774. X!     test    ah, 008h        ; If fail allowed - convert to fail
  775. X!     jz    $SW_int24a
  776. X! 
  777. X!     mov    al, 003h        ; Fail system call
  778. X! 
  779. X! $SW_int24a:
  780. X!     pop    dx            ; Restore registers
  781. X!     pop    cx
  782. X!     pop    bx
  783. X!     pop    es
  784. X!     pop    ds        
  785. X      iret
  786. X  _SW_Int24    endp
  787. X  
  788. X  ;
  789. X! ; Convert Hex code to display code
  790. X  ;
  791. X+ ; ds:di Offset of code to replace
  792. X+ ; ax is available
  793. X+ ;
  794. X+ I24_Convert    proc    near
  795. X+     push    cx
  796. X+     mov    al, byte ptr ds:[di]    ; Get the code
  797. X+     mov    ah, al
  798. X+     mov    cl, 4
  799. X+     shr    ah, cl
  800. X+     and    ah, 0fh
  801. X+ 
  802. X+     cmp    ah, 10
  803. X+     jb    I24_C1
  804. X+     add    ah, 'A' - 10
  805. X+     jmp    I24_C2
  806. X+ I24_C1:
  807. X+     add    ah, '0'
  808. X+ I24_C2:
  809. X+     mov    byte ptr ds:[di], ah
  810. X+ 
  811. X+ ; Now LSB
  812. X+ 
  813. X+     and    al, 0fh
  814. X+     cmp    al, 10
  815. X+     jb    I24_C3
  816. X+     add    al, 'A' - 10
  817. X+     jmp    I24_C4
  818. X+ I24_C3:
  819. X+     add    al, '0'
  820. X+ I24_C4:
  821. X+     mov    byte ptr ds:[di + 1], al
  822. X+     pop    cx
  823. X+     ret
  824. X+ I24_Convert    endp
  825. X+ ;
  826. X+ ;  Display message function for Interrupt 24 processing
  827. X+ ;
  828. X+ ;  DS:DI message
  829. X+ ;  AX is available
  830. X+ ;
  831. X+ 
  832. X+ I24_Display    proc    near
  833. X+     mov    ah, 08H            ; Get foreground colour
  834. X+     xor    bx, bx
  835. X+     int    10H
  836. X+     mov    bl, ah
  837. X+     and    bl, 07h
  838. X+ 
  839. X+ ;
  840. X+ ; Loop until a $ is hit, outputting the characters
  841. X+ ;
  842. X+ I24D:
  843. X+     mov    al, byte ptr ds:[di]
  844. X+     cmp    al, '$'
  845. X+     jnz    I24Da
  846. X+     ret
  847. X+ 
  848. X+ I24Da:
  849. X+     push    di
  850. X+     mov    ah, 0EH
  851. X+     int    10H
  852. X+     pop    di
  853. X+     inc    di
  854. X+     jmp    I24D
  855. X+ 
  856. X+ I24_Display    endp
  857. X+ 
  858. X+ ;
  859. X+ ;  Start of overwrite area for environment.  Align on a paragraph
  860. X+ ;
  861. X+ ;  Also the XMS driver functions used by SH3.C live here
  862. X+ ;
  863. X          ALIGN    16
  864. X  Env_OWrite:
  865. X+ 
  866. X+ ;
  867. X+ ; XMS INTERFACE
  868. X+ ;
  869. X+ ; Get Version number.  Return the release number in AX
  870. X+ ;
  871. X+ 
  872. X+ _SW_XMS_Gversion    proc    far
  873. X+ 
  874. X+     push    bp            ; Save stack info
  875. X+     mov    bp, sp
  876. X+ 
  877. X+     xor    ax, ax
  878. X+     call    cs:[_SW_XMS_Driver]
  879. X+ 
  880. X+     mov    sp, bp
  881. X+     pop    bp
  882. X+     ret
  883. X+ 
  884. X+ _SW_XMS_Gversion    endp
  885. X+ 
  886. X+ ;
  887. X+ ; Allocate N kbytes.  Return the Handler in AX or -1 and error code in
  888. X+ ; errno.
  889. X+ ;
  890. X+ ; Size will be in bp + 6.
  891. X+ ;
  892. X+ 
  893. X+ _SW_XMS_Allocate    proc    far
  894. X+ 
  895. X+     push    bp            ; Save stack info
  896. X+     mov    bp, sp
  897. X+ 
  898. X+     mov    dx, word ptr ss:[bp + 6]
  899. X+     mov    ah, 09H
  900. X+     call    cs:[_SW_XMS_Driver]
  901. X+     or    ax, ax
  902. X+     jnz    $SW_A1
  903. X+ 
  904. X+ ;
  905. X+ ; Allocate Failed - return error code
  906. X+ ;
  907. X+     xor    ax, ax
  908. X+     neg    ax
  909. X+     xor    bh, bh
  910. X+     mov    word ptr ds:_errno, bx    ; Save error code
  911. X+     jmp    $SW_F2
  912. X+ 
  913. X+ ;
  914. X+ ; Allocate OK - return handler
  915. X+ ;
  916. X+ 
  917. X+ $SW_A1:
  918. X+     mov    ax, dx
  919. X+ 
  920. X+ $SW_A2:
  921. X+     mov    sp, bp
  922. X+     pop    bp
  923. X+     ret
  924. X+ 
  925. X+ _SW_XMS_Allocate    endp
  926. X+ 
  927. X+ ;
  928. X+ ; Release handler.  Return 0 or error code.
  929. X+ ;
  930. X+ ; Handler will be in bp + 6.
  931. X+ ;
  932. X+ 
  933. X+ _SW_XMS_Free         proc    far
  934. X+ 
  935. X+     push    bp            ; Save stack info
  936. X+     mov    bp, sp
  937. X+ 
  938. X+     mov    dx, word ptr ss:[bp + 6]
  939. X+     mov    ah, 0AH
  940. X+     call    cs:[_SW_XMS_Driver]
  941. X+     or    ax, ax
  942. X+     jnz    $SW_F1
  943. X+ ;
  944. X+ ; Free Failed - return error code
  945. X+ ;
  946. X+     mov    al, bl
  947. X+     jmp    $SW_F2
  948. X+ 
  949. X+ ;
  950. X+ ; Free OK - return zero
  951. X+ ;
  952. X+ $SW_F1:
  953. X+     xor    ax, ax
  954. X+ 
  955. X+ $SW_F2:
  956. X+     mov    sp, bp
  957. X+     pop    bp
  958. X+     ret
  959. X+ 
  960. X+ _SW_XMS_Free         endp
  961. X  SH0_TEXT    ends
  962. X          end
  963. XIndex: shell/sh2.c
  964. XPrereq: 1.1
  965. X*** ../sh15/shell/sh2.c    Fri Feb 16 19:22:55 1990
  966. X--- shell/sh2.c    Tue May  1 19:48:35 1990
  967. X***************
  968. X*** 13,21 ****
  969. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  970. X   *     (or parts of sources) cannot be sold under any circumstances.
  971. X   *
  972. X!  *    $Header: sh2.c 1.1 90/01/25 13:41:12 MS_user Exp $
  973. X   *
  974. X   *    $Log:    sh2.c $
  975. X   * Revision 1.1  90/01/25  13:41:12  MS_user
  976. X   * Initial revision
  977. X   * 
  978. X--- 13,34 ----
  979. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  980. X   *     (or parts of sources) cannot be sold under any circumstances.
  981. X   *
  982. X!  *    $Header: sh2.c 1.5 90/04/25 09:18:38 MS_user Exp $
  983. X   *
  984. X   *    $Log:    sh2.c $
  985. X+  * Revision 1.5  90/04/25  09:18:38  MS_user
  986. X+  * Fix for ... do to not require terminating colon
  987. X+  * 
  988. X+  * Revision 1.4  90/03/14  19:30:06  MS_user
  989. X+  * Make collect a global for here document processing.
  990. X+  * Add IOTHERE support to detect <<- redirection
  991. X+  * 
  992. X+  * Revision 1.3  90/03/06  16:49:42  MS_user
  993. X+  * Add disable history option
  994. X+  * 
  995. X+  * Revision 1.2  90/03/05  13:49:41  MS_user
  996. X+  * Change talking checks
  997. X+  * 
  998. X   * Revision 1.1  90/01/25  13:41:12  MS_user
  999. X   * Initial revision
  1000. X   * 
  1001. X***************
  1002. X*** 98,104 ****
  1003. X  static IO_Actions    *io (int, int, char *);
  1004. X  static void        yyerror (char *);
  1005. X  static int        yylex (int);
  1006. X- static int        collect (int, int);
  1007. X  static int        dual (int);
  1008. X  static void        diag (int);
  1009. X  static char        *tree (unsigned int);
  1010. X--- 111,116 ----
  1011. X***************
  1012. X*** 339,347 ****
  1013. X          multiline++;
  1014. X          t->words = wordlist ();
  1015. X  
  1016. X!         if (((c = yylex (0)) != NL) && (c != ';'))
  1017. X!         yyerror (syntax_err);
  1018. X  
  1019. X          t->left = dogroup (0);
  1020. X          multiline--;
  1021. X          break;
  1022. X--- 351,366 ----
  1023. X          multiline++;
  1024. X          t->words = wordlist ();
  1025. X  
  1026. X! /* CHeck for "for word in word...; do" versus "for word do" */
  1027. X  
  1028. X+         c = yylex (0);
  1029. X+ 
  1030. X+         if ((t->words == (char **)NULL) && (c != NL))
  1031. X+         peeksym = c;
  1032. X+         
  1033. X+         else if ((t->words != (char **)NULL) && (c != NL) && (c != ';'))
  1034. X+         yyerror (syntax_err);
  1035. X+ 
  1036. X          t->left = dogroup (0);
  1037. X          multiline--;
  1038. X          break;
  1039. X***************
  1040. X*** 353,359 ****
  1041. X          t->type = (c == WHILE) ? TWHILE : TUNTIL;
  1042. X          t->left = c_list (FALSE);
  1043. X          t->right = dogroup (1);
  1044. X!         t->words = NULL;
  1045. X          multiline--;
  1046. X          break;
  1047. X  
  1048. X--- 372,378 ----
  1049. X          t->type = (c == WHILE) ? TWHILE : TUNTIL;
  1050. X          t->left = c_list (FALSE);
  1051. X          t->right = dogroup (1);
  1052. X!         t->words = (char **)NULL;
  1053. X          multiline--;
  1054. X          break;
  1055. X  
  1056. X***************
  1057. X*** 531,537 ****
  1058. X  
  1059. X  static C_Op    *block (type, t1, t2, wp)
  1060. X  C_Op        *t1, *t2;
  1061. X! char            **wp;
  1062. X  {
  1063. X      register C_Op *t = (C_Op *)tree (sizeof (C_Op));
  1064. X  
  1065. X--- 550,556 ----
  1066. X  
  1067. X  static C_Op    *block (type, t1, t2, wp)
  1068. X  C_Op        *t1, *t2;
  1069. X! char        **wp;
  1070. X  {
  1071. X      register C_Op *t = (C_Op *)tree (sizeof (C_Op));
  1072. X  
  1073. X***************
  1074. X*** 643,649 ****
  1075. X  {
  1076. X      yynerrs++;
  1077. X  
  1078. X!     if (talking && e.iop <= iostack) 
  1079. X      {
  1080. X      multiline = 0;
  1081. X  
  1082. X--- 662,668 ----
  1083. X  {
  1084. X      yynerrs++;
  1085. X  
  1086. X!     if (Interactive ())
  1087. X      {
  1088. X      multiline = 0;
  1089. X  
  1090. X***************
  1091. X*** 759,767 ****
  1092. X  
  1093. X          if (multiline || (cf & CONTIN))
  1094. X          {
  1095. X!         if (talking && e.iop <= iostack)
  1096. X          {
  1097. X              Add_History (FALSE);
  1098. X              put_prompt (ps2->value);
  1099. X          }
  1100. X  
  1101. X--- 778,788 ----
  1102. X  
  1103. X          if (multiline || (cf & CONTIN))
  1104. X          {
  1105. X!         if (Interactive ())
  1106. X          {
  1107. X+ #ifndef NO_HISTORY
  1108. X              Add_History (FALSE);
  1109. X+ #endif
  1110. X              put_prompt (ps2->value);
  1111. X          }
  1112. X  
  1113. X***************
  1114. X*** 801,816 ****
  1115. X      return WORD;
  1116. X  }
  1117. X  
  1118. X! static int    collect (c, c1)
  1119. X  register int    c, c1;
  1120. X  {
  1121. X      char *s = "x\n";
  1122. X  
  1123. X!     *e.linep++ = (char)c;
  1124. X  
  1125. X      while ((c = Getc (c1)) != c1) 
  1126. X      {
  1127. X!     if (c == 0) 
  1128. X      {
  1129. X          unget (c);
  1130. X          *s = (char)c1;
  1131. X--- 822,839 ----
  1132. X      return WORD;
  1133. X  }
  1134. X  
  1135. X! /* Read input until we read the specified end character */
  1136. X! 
  1137. X! int        collect (c, c1)
  1138. X  register int    c, c1;
  1139. X  {
  1140. X      char *s = "x\n";
  1141. X  
  1142. X!     *e.linep++ = (char)c;        /* Save the current character    */
  1143. X  
  1144. X      while ((c = Getc (c1)) != c1) 
  1145. X      {
  1146. X!     if (c == 0)             /* End of file - abort        */
  1147. X      {
  1148. X          unget (c);
  1149. X          *s = (char)c1;
  1150. X***************
  1151. X*** 819,827 ****
  1152. X          return YYERRCODE;
  1153. X      }
  1154. X  
  1155. X!     if (talking && (c == NL) && (e.iop <= iostack))
  1156. X      {
  1157. X          Add_History (FALSE);
  1158. X          put_prompt (ps2->value);
  1159. X      }
  1160. X  
  1161. X--- 842,852 ----
  1162. X          return YYERRCODE;
  1163. X      }
  1164. X  
  1165. X!     if (Interactive () && (c == NL))
  1166. X      {
  1167. X+ #ifndef NO_HISTORY
  1168. X          Add_History (FALSE);
  1169. X+ #endif
  1170. X          put_prompt (ps2->value);
  1171. X      }
  1172. X  
  1173. X***************
  1174. X*** 873,879 ****
  1175. X      else
  1176. X      yylval.i = (ec == '>') ? IOWRITE : IOREAD;
  1177. X  
  1178. X!     if ((c != '&') || (yylval.i == IOHERE))
  1179. X      unget (c);
  1180. X  
  1181. X      else
  1182. X--- 898,909 ----
  1183. X      else
  1184. X      yylval.i = (ec == '>') ? IOWRITE : IOREAD;
  1185. X  
  1186. X! /* Check for >&, <& and <<- */
  1187. X! 
  1188. X!     if ((c == '-') && (yylval.i == IOHERE))
  1189. X!     yylval.i |= IOTHERE;
  1190. X! 
  1191. X!     else if ((c != '&') || (yylval.i == IOHERE))
  1192. X      unget (c);
  1193. X  
  1194. X      else
  1195. XIndex: shell/sh3.c
  1196. XPrereq: 1.2
  1197. X*** ../sh15/shell/sh3.c    Fri Feb 16 19:10:04 1990
  1198. X--- shell/sh3.c    Tue May  1 19:48:50 1990
  1199. X***************
  1200. X*** 13,21 ****
  1201. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  1202. X   *     (or parts of sources) cannot be sold under any circumstances.
  1203. X   *
  1204. X!  *    $Header: sh3.c 1.2 90/02/14 04:47:06 MS_user Exp $
  1205. X   *
  1206. X   *    $Log:    sh3.c $
  1207. X   * Revision 1.2  90/02/14  04:47:06  MS_user
  1208. X   * Clean up Interrupt 23 and 0 processing, change EMS version error message
  1209. X   * 
  1210. X--- 13,67 ----
  1211. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  1212. X   *     (or parts of sources) cannot be sold under any circumstances.
  1213. X   *
  1214. X!  *    $Header: sh3.c 1.15 90/04/30 19:50:11 MS_user Exp $
  1215. X   *
  1216. X   *    $Log:    sh3.c $
  1217. X+  * Revision 1.15  90/04/30  19:50:11  MS_user
  1218. X+  * Stop search path if second character of name is colon
  1219. X+  * 
  1220. X+  * Revision 1.14  90/04/26  17:27:52  MS_user
  1221. X+  * Fix problem with Picnix Utilities - full path name of executable required
  1222. X+  * 
  1223. X+  * Revision 1.13  90/04/25  22:34:39  MS_user
  1224. X+  * Fix case in TELIF where then and else parts are not defined
  1225. X+  * Fix rsh check for execution path declared
  1226. X+  * 
  1227. X+  * Revision 1.12  90/04/11  19:49:35  MS_user
  1228. X+  * Another problem with new command line processing
  1229. X+  * 
  1230. X+  * Revision 1.11  90/04/11  12:55:49  MS_user
  1231. X+  * Change command line to look exactly like COMMAND.COM
  1232. X+  * 
  1233. X+  * Revision 1.10  90/03/27  20:33:10  MS_user
  1234. X+  * Clear extended file name on interrupt
  1235. X+  * 
  1236. X+  * Revision 1.9  90/03/27  20:09:21  MS_user
  1237. X+  * Clear_Extended_File required in SH1 for interrupt clean up
  1238. X+  * 
  1239. X+  * Revision 1.8  90/03/26  20:57:14  MS_user
  1240. X+  * Change I/O restore so that "exec >filename" works
  1241. X+  * 
  1242. X+  * Revision 1.7  90/03/22  13:47:24  MS_user
  1243. X+  * MSDOS does not handle /dev/ files after find_first correctly
  1244. X+  * 
  1245. X+  * Revision 1.6  90/03/14  16:44:49  MS_user
  1246. X+  * Add quoting of arguments with white space on command line
  1247. X+  * Add IOTHERE processing to iosetup
  1248. X+  * 
  1249. X+  * Revision 1.5  90/03/06  15:10:28  MS_user
  1250. X+  * Get doeval, dodot and runtrap working correctly in run so that a sub-shell
  1251. X+  * is not created and environment variables can be changed.
  1252. X+  * 
  1253. X+  * Revision 1.4  90/03/05  13:50:04  MS_user
  1254. X+  * Add XMS driver
  1255. X+  * Fix bug with extended line file not being deleted
  1256. X+  * Get run to support eval and dot functionality correctly
  1257. X+  * Get trap processing to work
  1258. X+  * Add COMMAND.COM support for .bat files
  1259. X+  * 
  1260. X+  * Revision 1.3  90/02/22  16:38:20  MS_user
  1261. X+  * Add XMS support
  1262. X+  * 
  1263. X   * Revision 1.2  90/02/14  04:47:06  MS_user
  1264. X   * Clean up Interrupt 23 and 0 processing, change EMS version error message
  1265. X   * 
  1266. X***************
  1267. X*** 38,43 ****
  1268. X--- 84,91 ----
  1269. X  #include <stdlib.h>
  1270. X  #include <fcntl.h>
  1271. X  #include <limits.h>
  1272. X+ #include <dirent.h>
  1273. X+ #include <ctype.h>
  1274. X  
  1275. X  #include "sh.h"
  1276. X  
  1277. X***************
  1278. X*** 48,69 ****
  1279. X  static C_Op    **find1case (C_Op *, char *);
  1280. X  static C_Op    *findcase (C_Op *, char *);
  1281. X  static void    echo (char **);
  1282. X- static void    setsig (int, int (*)());
  1283. X  static int    rexecve (char *, char **, char **, bool);
  1284. X  static int    Execute_program (char *, char **, char **, bool);
  1285. X  static int    S_spawnve (char *, char **, char **);
  1286. X! static void    get_sys_info (void);
  1287. X! static void    EMS_error (char *, int);
  1288. X  static int    EMS_Close (void);
  1289. X  static int    build_command_line (char *, char **, char **);
  1290. X- static void    Clear_Extended_File (void);
  1291. X  static int    setstatus (int);
  1292. X  
  1293. X  static char    *AE2big = "arg/env list too big";
  1294. X  static char    *EMS_emsg = "Warning: EMS Error (%x)\n";
  1295. X              /* Extended Command line processing file name    */
  1296. X  static char        *Extend_file = (char *)NULL;
  1297. X- static unsigned int    SW_EMsize;    /* Number of extend memory blks    */
  1298. X  
  1299. X  /*
  1300. X   * execute tree recursively
  1301. X--- 96,121 ----
  1302. X  static C_Op    **find1case (C_Op *, char *);
  1303. X  static C_Op    *findcase (C_Op *, char *);
  1304. X  static void    echo (char **);
  1305. X  static int    rexecve (char *, char **, char **, bool);
  1306. X  static int    Execute_program (char *, char **, char **, bool);
  1307. X  static int    S_spawnve (char *, char **, char **);
  1308. X! static bool    Get_EMS_Driver (void);
  1309. X! static bool    Get_XMS_Driver (void);
  1310. X! static bool    EMS_error (char *, int);
  1311. X  static int    EMS_Close (void);
  1312. X+ static bool    XMS_error (char *, int);
  1313. X+ static int    XMS_Close (void);
  1314. X  static int    build_command_line (char *, char **, char **);
  1315. X  static int    setstatus (int);
  1316. X+ static bool    Check_for_bat_file (char *);
  1317. X+ static size_t    white_space_len (char *, bool *);
  1318. X+ static char    *Gen_Full_Path_Name (char *);
  1319. X  
  1320. X  static char    *AE2big = "arg/env list too big";
  1321. X  static char    *EMS_emsg = "Warning: EMS Error (%x)\n";
  1322. X+ static char    *XMS_emsg = "Warning: XMS Error (%x)\n";
  1323. X              /* Extended Command line processing file name    */
  1324. X  static char        *Extend_file = (char *)NULL;
  1325. X  
  1326. X  /*
  1327. X   * execute tree recursively
  1328. X***************
  1329. X*** 301,307 ****
  1330. X  
  1331. X      case TIF:            /* IF and ELSE IF functions    */
  1332. X      case TELIF:
  1333. X!         rv = !execute (t->left, pin, pout, 0)
  1334. X                  ? execute (t->right->left, pin, pout, 0)
  1335. X               : execute (t->right->right, pin, pout, 0);
  1336. X          break;
  1337. X--- 353,360 ----
  1338. X  
  1339. X      case TIF:            /* IF and ELSE IF functions    */
  1340. X      case TELIF:
  1341. X!         if (t->right != (C_Op *)NULL)
  1342. X!         rv = !execute (t->left, pin, pout, 0)
  1343. X                  ? execute (t->right->left, pin, pout, 0)
  1344. X               : execute (t->right->right, pin, pout, 0);
  1345. X          break;
  1346. X***************
  1347. X*** 334,347 ****
  1348. X  
  1349. X      areanum        = Local_areanum;
  1350. X  
  1351. X- /* Check for interrupts */
  1352. X- 
  1353. X-     if (talking && SW_intr)
  1354. X-     {
  1355. X-     closeall ();
  1356. X-     fail ();
  1357. X-     }
  1358. X- 
  1359. X  /* Check for traps */
  1360. X  
  1361. X      if ((i = trapset) != 0)
  1362. X--- 387,392 ----
  1363. X***************
  1364. X*** 350,355 ****
  1365. X--- 395,408 ----
  1366. X      runtrap (i);
  1367. X      }
  1368. X  
  1369. X+ /* Check for interrupts */
  1370. X+ 
  1371. X+     if (Interactive () && SW_intr)
  1372. X+     {
  1373. X+     closeall ();
  1374. X+     fail ();
  1375. X+     }
  1376. X+ 
  1377. X      return rv;
  1378. X  }
  1379. X  
  1380. X***************
  1381. X*** 387,392 ****
  1382. X--- 440,446 ----
  1383. X      char    *cp;
  1384. X      IO_Actions    **iopp;
  1385. X      int        resetsig = 0;
  1386. X+     void    (*sig_int)();
  1387. X      char    **owp = wp;
  1388. X      bool    spawn = FALSE;
  1389. X      Fun_Ops    *fop;
  1390. X***************
  1391. X*** 426,437 ****
  1392. X      {
  1393. X      spawn = TRUE;
  1394. X  
  1395. X!     if (talking)
  1396. X      {
  1397. X  #ifdef SIGQUIT
  1398. X          signal (SIGQUIT, SIG_IGN);
  1399. X  #endif
  1400. X!         signal (SIGINT, SIG_IGN);
  1401. X          resetsig = 1;
  1402. X      }
  1403. X      }
  1404. X--- 480,491 ----
  1405. X      {
  1406. X      spawn = TRUE;
  1407. X  
  1408. X!     if (Interactive ())
  1409. X      {
  1410. X  #ifdef SIGQUIT
  1411. X          signal (SIGQUIT, SIG_IGN);
  1412. X  #endif
  1413. X!         sig_int = signal (SIGINT, SIG_IGN);
  1414. X          resetsig = 1;
  1415. X      }
  1416. X      }
  1417. X***************
  1418. X*** 472,478 ****
  1419. X      }
  1420. X  
  1421. X      if (shcom)
  1422. X!     return restore_std (setstatus ((*shcom)(t)));
  1423. X  
  1424. X  /* All fids above 10 are autoclosed in the exec file because we have used
  1425. X   * the O_NOINHERIT flag.  Note I patched open.obj to pass this flag to the
  1426. X--- 526,532 ----
  1427. X      }
  1428. X  
  1429. X      if (shcom)
  1430. X!     return restore_std (setstatus ((*shcom)(t)), TRUE);
  1431. X  
  1432. X  /* All fids above 10 are autoclosed in the exec file because we have used
  1433. X   * the O_NOINHERIT flag.  Note I patched open.obj to pass this flag to the
  1434. X***************
  1435. X*** 484,501 ****
  1436. X  #ifdef SIGQUIT
  1437. X      signal (SIGQUIT, SIG_IGN);
  1438. X  #endif
  1439. X!     signal (SIGINT, onintr);
  1440. X      }
  1441. X  
  1442. X      if (t->type == TPAREN)
  1443. X!     return restore_std (execute (t->left, NOPIPE, NOPIPE, FEXEC));
  1444. X  
  1445. X  /* Are we just changing the I/O re-direction for the shell ? */
  1446. X  
  1447. X      if (wp[0] == NULL)
  1448. X      {
  1449. X      if (spawn)
  1450. X!         restore_std (0);
  1451. X  
  1452. X      return 0;
  1453. X      }
  1454. X--- 538,555 ----
  1455. X  #ifdef SIGQUIT
  1456. X      signal (SIGQUIT, SIG_IGN);
  1457. X  #endif
  1458. X!     signal (SIGINT, sig_int);
  1459. X      }
  1460. X  
  1461. X      if (t->type == TPAREN)
  1462. X!     return restore_std (execute (t->left, NOPIPE, NOPIPE, FEXEC), TRUE);
  1463. X  
  1464. X  /* Are we just changing the I/O re-direction for the shell ? */
  1465. X  
  1466. X      if (wp[0] == NULL)
  1467. X      {
  1468. X      if (spawn)
  1469. X!         restore_std (0, TRUE);
  1470. X  
  1471. X      return 0;
  1472. X      }
  1473. X***************
  1474. X*** 548,556 ****
  1475. X      return rv;
  1476. X      }
  1477. X  
  1478. X! /* Ok - execute the program */
  1479. X  
  1480. X!     return restore_std (rexecve (wp[0], wp, makenv (), spawn));
  1481. X  }
  1482. X  
  1483. X  /*
  1484. X--- 602,615 ----
  1485. X      return rv;
  1486. X      }
  1487. X  
  1488. X! /* Check for another drive or directory in the restricted shell */
  1489. X  
  1490. X!     if (anys (":/\\", wp[0]) && check_rsh (wp[0]))
  1491. X!     return restore_std (-1, TRUE);
  1492. X! 
  1493. X! /* Ok - execute the program */
  1494. X! 
  1495. X!     return restore_std (rexecve (wp[0], wp, makenv (), spawn), TRUE);
  1496. X  }
  1497. X  
  1498. X  /*
  1499. X***************
  1500. X*** 564,570 ****
  1501. X      Execute_stack_depth = stack;
  1502. X      Delete_G_VL ();
  1503. X      Restore_Dir ();
  1504. X!     restore_std (setstatus (retval));
  1505. X  }
  1506. X  
  1507. X  /*
  1508. X--- 623,629 ----
  1509. X      Execute_stack_depth = stack;
  1510. X      Delete_G_VL ();
  1511. X      Restore_Dir ();
  1512. X!     restore_std (setstatus (retval), TRUE);
  1513. X  }
  1514. X  
  1515. X  /*
  1516. X***************
  1517. X*** 613,628 ****
  1518. X      iop->io_flag &= ~(IOREAD | IOWRITE);
  1519. X      }
  1520. X  
  1521. X! /* Open the file in the appropriate mode */
  1522. X  
  1523. X!     switch (iop->io_flag)
  1524. X      {
  1525. X      case IOREAD:                /* <            */
  1526. X          u = S_open (FALSE, cp, O_RDONLY);
  1527. X          break;
  1528. X  
  1529. X      case IOHERE:                /* <<            */
  1530. X-     case IOHERE | IOXHERE:
  1531. X          u = herein (iop->io_name, iop->io_flag & IOXHERE);
  1532. X          cp = "here file";
  1533. X          break;
  1534. X--- 672,695 ----
  1535. X      iop->io_flag &= ~(IOREAD | IOWRITE);
  1536. X      }
  1537. X  
  1538. X! /*
  1539. X!  * When writing to /dev/???, we have to cheat because MSDOS appears to
  1540. X!  * have a problem with /dev/ files after find_first/find_next.
  1541. X!  */
  1542. X  
  1543. X!     if (((iop->io_flag & ~(IOXHERE | IOTHERE)) == IOWRITE) &&
  1544. X!     (strnicmp (cp, "/dev/", 5) == 0))
  1545. X!     iop->io_flag |= IOCAT;
  1546. X! 
  1547. X! /* Open the file in the appropriate mode */
  1548. X! 
  1549. X!     switch (iop->io_flag & ~(IOXHERE | IOTHERE))
  1550. X      {
  1551. X      case IOREAD:                /* <            */
  1552. X          u = S_open (FALSE, cp, O_RDONLY);
  1553. X          break;
  1554. X  
  1555. X      case IOHERE:                /* <<            */
  1556. X          u = herein (iop->io_name, iop->io_flag & IOXHERE);
  1557. X          cp = "here file";
  1558. X          break;
  1559. X***************
  1560. X*** 748,755 ****
  1561. X  }
  1562. X  
  1563. X  /*
  1564. X!  * PATH-searching interface to execve.  If getenv ("PATH") were kept
  1565. X!  * up-to-date, execvp might be used.
  1566. X   */
  1567. X  
  1568. X  static int    rexecve (c, v, envp, d_flag)
  1569. X--- 815,821 ----
  1570. X  }
  1571. X  
  1572. X  /*
  1573. X!  * PATH-searching interface to execve.
  1574. X   */
  1575. X  
  1576. X  static int    rexecve (c, v, envp, d_flag)
  1577. X***************
  1578. X*** 759,782 ****
  1579. X  bool        d_flag;
  1580. X  {
  1581. X      register char    *sp;
  1582. X!     int            res;
  1583. X!     char        *em;
  1584. X!     bool        eloop;
  1585. X  
  1586. X  /* If the environment is null - It is too big - error */
  1587. X  
  1588. X      if (envp == (char **)NULL)
  1589. X      em = AE2big;
  1590. X  
  1591. X      else
  1592. X      {
  1593. X-     sp = any ('/', c) ? null : path->value;
  1594. X  
  1595. X      do
  1596. X      {
  1597. X!         sp = path_append (sp, c, e.linep);
  1598. X  
  1599. X!         if ((res = Execute_program (e.linep, v, envp, d_flag)) != -1)
  1600. X          return res;
  1601. X  
  1602. X          eloop = TRUE;
  1603. X--- 825,869 ----
  1604. X  bool        d_flag;
  1605. X  {
  1606. X      register char    *sp;
  1607. X!     int            res;            /* Result        */
  1608. X!     char        *em;            /* Exit error message    */
  1609. X!     bool        eloop;            /* Re-try flag        */
  1610. X!     char        **new_argv;
  1611. X!     int            batfile;        /* .bat file flag    */
  1612. X!     int            argc = 0;        /* Original # of argcs    */
  1613. X!     char        *params;        /* Script parameters    */
  1614. X!     int            nargc = 0;        /* # script args    */
  1615. X!     char        *p_name;        /* Program name        */
  1616. X!     int            i;
  1617. X  
  1618. X  /* If the environment is null - It is too big - error */
  1619. X  
  1620. X      if (envp == (char **)NULL)
  1621. X      em = AE2big;
  1622. X  
  1623. X+     else if ((p_name = getcell (FFNAME_MAX)) == (char *)NULL)
  1624. X+     em = strerror (ENOMEM);
  1625. X+     
  1626. X      else
  1627. X      {
  1628. X  
  1629. X+ /* Count the number of arguments to the program in case of shell script or
  1630. X+  * bat file
  1631. X+  */
  1632. X+ 
  1633. X+     while (v[argc++] != (char *)NULL);
  1634. X+ 
  1635. X+     ++argc;                /* Including the null        */
  1636. X+ 
  1637. X+ /* Start off on the search path for the executable file */
  1638. X+ 
  1639. X+     sp = (any ('/', c) || (*(c + 1) == ':')) ? null : path->value;
  1640. X+ 
  1641. X      do
  1642. X      {
  1643. X!         sp = path_append (sp, c, p_name);
  1644. X  
  1645. X!         if ((res = Execute_program (p_name, v, envp, d_flag)) != -1)
  1646. X          return res;
  1647. X  
  1648. X          eloop = TRUE;
  1649. X***************
  1650. X*** 788,812 ****
  1651. X   * script
  1652. X   */
  1653. X          case ENOENT:
  1654. X!             if ((res = O_for_execute (e.linep)) >= 0)
  1655. X              {
  1656. X              S_close (res, TRUE);
  1657. X-             *v = e.linep;
  1658. X-             em = *--v;
  1659. X-             *v = e.linep;
  1660. X-                 res = Execute_program (lookup (shell, FALSE)->value,
  1661. X-                            v, envp, d_flag);
  1662. X-             *v = em;
  1663. X- 
  1664. X-             if (res != -1)
  1665. X-             return res;
  1666. X- 
  1667. X-             em = "no Shell";
  1668. X              }
  1669. X  
  1670. X!             else
  1671. X              em = "not found";
  1672. X  
  1673. X              eloop = FALSE;
  1674. X              break;
  1675. X  
  1676. X--- 875,963 ----
  1677. X   * script
  1678. X   */
  1679. X          case ENOENT:
  1680. X!             if ((res = O_for_execute (p_name, ¶ms, &nargc)) >= 0)
  1681. X              {
  1682. X+             batfile = 1;
  1683. X              S_close (res, TRUE);
  1684. X              }
  1685. X  
  1686. X!             else if (!Check_for_bat_file (p_name))
  1687. X!             {
  1688. X              em = "not found";
  1689. X+             eloop = FALSE;
  1690. X+             break;
  1691. X+             }
  1692. X  
  1693. X+             else
  1694. X+             {
  1695. X+             Convert_Slashes (p_name);
  1696. X+             batfile = 0;
  1697. X+             nargc = 0;
  1698. X+             }
  1699. X+ 
  1700. X+ /* Ok - either a shell script or a bat file (batfile = 0) */
  1701. X+ 
  1702. X+             nargc = (nargc < 2) ? 0 : nargc - 1;
  1703. X+             if ((new_argv = (char **)getcell (sizeof (char *) *
  1704. X+                                 (argc + nargc + 2)))
  1705. X+                   == (char **)NULL)
  1706. X+             {
  1707. X+             em = strerror (ENOMEM);
  1708. X+             break;
  1709. X+             }
  1710. X+ 
  1711. X+             memcpy (&new_argv[2 + nargc], &v[0], sizeof(char *) * argc);
  1712. X+ 
  1713. X+ /* If BAT file, use command.com else use sh */
  1714. X+ 
  1715. X+             if (!batfile)
  1716. X+             {
  1717. X+             new_argv[0] = lookup ("COMSPEC", FALSE)->value;
  1718. X+             new_argv[1] = "/c";
  1719. X+             }
  1720. X+ 
  1721. X+ /* Stick in the pre-fix arguments */
  1722. X+ 
  1723. X+             else if (nargc)
  1724. X+             {
  1725. X+             i = 1;
  1726. X+             em = params;
  1727. X+ 
  1728. X+             while (*em)
  1729. X+             {
  1730. X+                 while (isspace (*em))
  1731. X+                 *(em++) = 0;
  1732. X+                 
  1733. X+                 if (*em)
  1734. X+                 new_argv[i++] = em;
  1735. X+ 
  1736. X+                 while (!isspace (*em) && *em)
  1737. X+                 ++em;
  1738. X+             }
  1739. X+             }
  1740. X+ 
  1741. X+             else if (params != null)
  1742. X+             new_argv[1] = params;
  1743. X+ 
  1744. X+             else
  1745. X+             new_argv[1] = lookup (shell, FALSE)->value;
  1746. X+ 
  1747. X+             new_argv[2 + nargc] = p_name;
  1748. X+ 
  1749. X+             res = rexecve (new_argv[batfile], &new_argv[batfile],
  1750. X+                     envp, d_flag);
  1751. X+ /* Release allocated space */
  1752. X+ 
  1753. X+             DELETE (new_argv);
  1754. X+ 
  1755. X+             if (params != null)
  1756. X+             DELETE (params);
  1757. X+ 
  1758. X+             if (res != -1)
  1759. X+             return res;
  1760. X+ /* No - shell */
  1761. X+ 
  1762. X+             em = "no Shell";
  1763. X              eloop = FALSE;
  1764. X              break;
  1765. X  
  1766. X***************
  1767. X*** 838,850 ****
  1768. X      return -1;
  1769. X  }
  1770. X  
  1771. X  /*
  1772. X   * Run the command produced by generator `f' applied to stream `arg'.
  1773. X   */
  1774. X  
  1775. X! int        run (argp, f)
  1776. X  IO_Args        *argp;
  1777. X  int        (*f)(IO_State *);
  1778. X  {
  1779. X      Word_B        *swdlist = wdlist;
  1780. X      Word_B        *siolist = iolist;
  1781. X--- 989,1036 ----
  1782. X      return -1;
  1783. X  }
  1784. X  
  1785. X+ /* Check to see if this is a bat file */
  1786. X+ 
  1787. X+ static bool    Check_for_bat_file (name)
  1788. X+ char        *name;
  1789. X+ {
  1790. X+     char    *local_path;
  1791. X+     char    *cp;
  1792. X+     bool    res;
  1793. X+ 
  1794. X+     if ((local_path = getcell (strlen (name) + 5)) == (char *)NULL)
  1795. X+     return FALSE;
  1796. X+ 
  1797. X+ /* Work on a copy of the path */
  1798. X+ 
  1799. X+     if ((cp = strrchr (strcpy (local_path, name), '/')) == (char *)NULL)
  1800. X+     cp = local_path;
  1801. X+     
  1802. X+     else
  1803. X+     ++cp;
  1804. X+ 
  1805. X+     if ((cp = strrchr (cp, '.')) == (char *)NULL)
  1806. X+     strcat (local_path, ".bat");
  1807. X+     
  1808. X+     else if (stricmp (cp, ".bat") != 0)
  1809. X+     {
  1810. SHAR_EOF
  1811. echo "End of part 2"
  1812. echo "File Patch1.6 is continued in part 3"
  1813. echo "3" > s2_seq_.tmp
  1814. exit 0
  1815.  
  1816.  
  1817.