home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 8 / 08.iso / d / d026 / 25.ddi / NET / WNETPRNT.AS_ / WNETPRNT.AS
Encoding:
Text File  |  1991-04-19  |  7.3 KB  |  272 lines

  1. page        60, 132
  2. title        Windows Network Printing Functions
  3. ;===============================================================================
  4. ;        Filename    WNETPRNT.ASM
  5. ;        Copyright    (C) 1989 by Research Machines
  6. ;                (C) 1989-1990 Microsoft Corp.
  7. ;===============================================================================
  8. ; REVISIONS:    24/02/1989    Initial version
  9. ;        15/03/1989    Update to spec 0.56
  10. ;                Add WNetOpenJob and WNetCloseJob
  11. ;        16/03/1989    Change to STANDARD procedures (save si, di, ds)
  12. ;        23/03/1989    Change to segment name / file name
  13. ;                Update to spec 0.58
  14. ;        29/03/1989    Change smbPQEOriginatorName to offset
  15. ;        31/03/1989    Added WNetWatchQueue.
  16. ;                Tidied up comments.
  17. ;                Called ERRSetErrorCode.
  18. ;        04/04/1989    Bug fix to WNetWatchQueue
  19. ;                Add WNetUnwatchQueue
  20. ;                Add WNetLockQueueData
  21. ;                Add WNetUnlockQueueData
  22. ;        ever since    Make it work
  23. ;===============================================================================
  24.  
  25.         memM    equ    1        ; Middle memory model
  26.         ?WIN    =    1        ; Windows prolog/epilog
  27.         ?PLM    =    1        ; Pascal calling convention
  28.  
  29.         .xlist
  30. include     cmacros.inc
  31. include     windows.inc
  32. include     smb.inc
  33. include     wnet.inc
  34. include     wnetcaps.inc
  35. include     wnetprnt.inc
  36.         .list
  37.  
  38.         .sall
  39.  
  40. externFP    MSNetFindLocalSession            ; In file MSNET.ASM
  41. externFP    MSNetMakeAssignListEntry        ; In file MSNET.ASM
  42. externFP    MSNetCancelAssignListEntry        ; In file MSNET.ASM
  43. externFP    MSNetCreateHandle            ; In file MSNET.ASM
  44. externFP    MSNetCloseHandle            ; In file MSNET.ASM
  45.  
  46. externFP    WNetGetConnection
  47.  
  48. externFP    UTLMemMove                ; In file UTILS.ASM
  49. externFP    UTLRemoveTrailingSpaces         ; In file UTILS.ASM
  50. externFP    UTLRemoveTrailingColon            ; In file UTILS.ASM
  51. externFP    UTLIsSerialDevice
  52.  
  53. externFP    lstrcpy
  54. externFP    GetCurrentTask
  55.  
  56. ;===============================================================================
  57. ; ============= DATA SEGMENT ===================================================
  58. ;===============================================================================
  59.  
  60. sBegin        DATA
  61.  
  62. externW     rgfWatch
  63.  
  64. staticW     hTimer, 0, 1
  65. staticW     nWatchedQueues, 0, 1
  66. globalW     QueueHandleTable, 0, MAX_WATCH_QUEUE
  67.  
  68. sEnd        DATA
  69.  
  70. ;===============================================================================
  71. ; ============= CODE SEGMENT ===================================================
  72. ;===============================================================================
  73.  
  74. createSeg    _PRNT, PRNTCODE, BYTE, PUBLIC, CODE
  75. sBegin        PRNTCODE
  76.         assumes CS, PRNTCODE
  77.         assumes DS, DATA
  78.  
  79.  
  80. ;===============================================================================
  81. subttl        WNetOpenJob
  82. page
  83. ;===============================================================================
  84.  
  85. cProc        WNetOpenJob, <FAR, PUBLIC>, <si, di>
  86.  
  87.         parmD    lpszQueue
  88.         parmD    lpszJobTitle
  89.         parmW    nCopies
  90.         parmD    lphPrintFile
  91.  
  92.         localV    szPort, 64
  93. cBegin
  94.  
  95. ;---------------------------------------------------------------
  96. ; Determine if the the port is a redirected port
  97. ;---------------------------------------------------------------
  98.  
  99.         push    seg_lpszQueue
  100.         push    off_lpszQueue
  101.         call    UTLIsSerialDevice
  102.         or    ax, ax
  103.         jz    OJ_BadQueue
  104.  
  105.         mov    di, ax
  106.         cmp    [di].hTask, 0
  107.         jz    OJ_CheckRedir
  108.  
  109.         mov    ax, WN_ALREADY_LOCKED
  110.         jmp    short WNOJExit
  111.  
  112. OJ_CheckRedir:
  113.         lea    si,szPort
  114.         les    bx, lphPrintFile
  115.         mov    word ptr es:[bx],64
  116.         cCall    WNetGetConnection,<lpszQueue,RegPairSSSI,RegPairESBX>
  117.         or    ax,ax
  118.         jnz    WNOJExit        ; if not redir'd, return error.
  119.  
  120. ;---------------------------------------------------------------
  121. ; Copy the queue name to the local heap in case we need to alter it.
  122. ;---------------------------------------------------------------
  123.  
  124.  
  125. DuplicateName:    Arg    RegPairSSSI
  126.         Arg    lpszQueue
  127.         cCall    LStrcpy
  128.  
  129. ;---------------------------------------------------------------
  130. ; lpszQueue may be a device name (LPT1, LPT2...), in which case
  131. ; we must remove the trailing colon.
  132. ;---------------------------------------------------------------
  133.  
  134.         Arg    RegPairSSSI
  135.         cCall    UTLRemoveTrailingColon
  136.  
  137. ;---------------------------------------------------------------
  138. ; Open the print job with DosCreateHandle.
  139. ;---------------------------------------------------------------
  140.  
  141.         mov    ax, 0                    ; File attribute (NORMAL)
  142.         Arg    RegPairSSSI                ;
  143.         Arg    ax                    ;
  144.         cCall    MSNetCreateHandle            ;
  145.         or    ax, ax
  146.         jns    ReturnHandle
  147.  
  148.         neg    ax            ; make error positive
  149.         jmp    WNOJExit
  150. OJ_BadQueue:
  151.         mov    ax, WN_BAD_QUEUE
  152.         jmp    WNOJExit
  153.  
  154. ;---------------------------------------------------------------
  155. ; Return the DOS file handle in pFH
  156. ;---------------------------------------------------------------
  157.  
  158. ReturnHandle:    les    bx, ( lphPrintFile )
  159.         mov    es: [ bx ], ax
  160.  
  161. ;---------------------------------------------------------------
  162. ; Only one task should have a net port open at any given time.
  163. ; Enforce this.
  164. ;---------------------------------------------------------------
  165.         mov    [di].hf, ax                 ; save handle for close
  166.         call    GetCurrentTask
  167.         mov    [di].hTask, ax                    ; save current task handle
  168.         sub    ax,ax                    ; return success
  169.  
  170. ;---------------------------------------------------------------
  171. ; If ( nCopies ) == 1 then we have succeeded.
  172. ; If ( nCopies ) != 1 then return WN_CANT_SET_COPIES.
  173. ;---------------------------------------------------------------
  174.  
  175. WNOJSuccess:    cmp    ( nCopies ), 1
  176.         je    WNOJExit
  177.  
  178.         mov    ax, WN_CANT_SET_COPIES
  179.  
  180. WNOJExit:
  181. cEnd
  182.  
  183. ;===============================================================================
  184. subttl        WNetCloseJob
  185. page
  186. ;===============================================================================
  187. ;
  188. ; DESCRIPTION .
  189. ; ENTRY .......
  190. ; EXIT ........
  191. ; COMMENTS ....
  192. ;
  193. ;===============================================================================
  194.  
  195. cProc        WNetCloseJob, <FAR, PUBLIC>
  196.  
  197.         parmW    hPrintFile
  198.         parmD    lpJobID
  199.         parmD    lpszQueue
  200.         localW    nReturnCode
  201. cBegin
  202.         mov    ( nReturnCode ), WN_SUCCESS        ; Ever optimistic
  203.  
  204.         call    GetCurrentTask
  205.         mov    dx, hPrintFile
  206.         mov    bx, dataoffset rgfWatch
  207.         mov    cx, 4
  208. find_handle_loop:
  209.         cmp    [bx].hTask, ax
  210.         jnz    loopit
  211.         cmp    [bx].hf, dx
  212.         jz    found_handle
  213. loopit:
  214.         add    bx, size WatchEntry
  215.         loop    find_handle_loop
  216.  
  217.         mov    ax, WN_BAD_FILE_HANDLE
  218.  
  219.         jmp    short WNCJExitNow
  220.  
  221. found_handle:
  222.         mov    [bx].hTask, 0
  223.  
  224. ;---------------------------------------------------------------
  225. ; Close file with DosCloseHandle.
  226. ;---------------------------------------------------------------
  227.  
  228.         Arg    hPrintFile                ;
  229.         cCall    MSNetCloseHandle            ;
  230.  
  231.         cmp    ax, WN_SUCCESS                ;
  232.         je    WNCJExitNow
  233.         mov    ( nReturnCode ), WN_NET_ERROR        ; Set return code
  234. WNCJExitNow:
  235. cEnd
  236.  
  237. ;=============================================================================
  238. ;
  239. ;
  240.  
  241. cProc    WNetWriteJob, <FAR, PUBLIC>
  242.  
  243.     parmW   hJob
  244.     parmD   lpData
  245.     parmD   lpcb
  246.  
  247. cBegin
  248.     push    ds
  249.     lds     dx, lpData
  250.     les     bx, lpcb
  251.     mov     cx, es:[bx]
  252.     mov     bx, hJob
  253.     mov     ah, 40h
  254.     call    dos3call
  255.     pop     ds
  256.     jc        wj_error
  257.     les     bx, lpcb
  258.     mov     es:[bx], ax
  259.     sub     ax, ax
  260.     jmp     short wj_exit
  261. wj_error:
  262.     mov     ax, WN_NET_ERROR
  263. wj_exit:
  264. cEnd
  265.  
  266. ;===============================================================================
  267. ; ============= END OF WNETPRNT ================================================
  268. ;===============================================================================
  269.  
  270. sEnd        PRNTCODE
  271.         end
  272.