home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / CW GUSI 1.6.4 / doc / pod / GUSI_PAP.pod < prev    next >
Encoding:
Text File  |  1995-03-15  |  2.5 KB  |  55 lines  |  [TEXT/CWIE]

  1. =head1 PAP sockets
  2.  
  3. PAP, the AppleTalk Printer Access Protocol is a protocol which is 
  4. almost exclusively used to access networked printers. The current implementation of 
  5. PAP in C<GUSI> is quite narrow in that it only implements the workstation side of
  6. PAP and only in communication to the currently selected LaserWriter. It is also 
  7. doomed, as it depends on Apple system resources that probably are not supported
  8. anymore in Apple's Quickdraw GX printing architecture, but if there is enough
  9. interest, the current implementation might be replaced some time.
  10.  
  11. =head2 Routines specific to PAP sockets
  12.  
  13. While PAP sockets behave in most respects like
  14. other sockets, they can currently not be created with the C<socket()> call, but are
  15. opened with C<open()>.
  16.  
  17. C<int open("Dev:Printer", int flags)> opens a connection to the last selected 
  18. LaserWriter. C<flags> is currently ignored. 
  19.  
  20. Communication with LaserWriters is somewhat strange. The three main uses of PAP
  21. sockets are probably interactive sessions, queries, and downloads, which will be 
  22. discussed in the following sections. As in all other socket families, C<GUSI> does
  23. no filtering of the transmitted data, which means that lines sent by the LaserWriter 
  24. will be separated by linefeeds (ASCII 10) rather than carriage returns (ASCII 13), 
  25. which are used for this purpose in most other Mac contexts. For data you I<send>, it 
  26. doesn't matter which one you use.
  27.  
  28. You start an I<interactive session> by sending a line C<"executive"> after 
  29. opening the socket. This will put lots of LaserWriters (certainly all manufactured 
  30. by Apple, but probably not a Linotronic) into interactive mode. If you want to, you
  31. can now play terminal emulator and use your LaserWriter as an expensive desk calculator.
  32.  
  33. A I<query> is some PostScript code you send to a LaserWriter that you expect 
  34. to be answered. This is quite straightforward, except that LaserWriters don't seem
  35. to answer until you have indicated to them that no more data from you will be coming.
  36. Therefore, you have to call C<shutdown(s,1)> to shut the socket down for writing after
  37. you have written your query and before you try to read the answer. The following
  38. code demonstrates how to send a query to the printer:
  39.  
  40.  
  41.     int s = open("Dev:Printer", O_RDWR);
  42.  
  43.     write(s, "FontDirectory /Gorilla-SemiBold exch known...", len);
  44.  
  45.     /* We won't write any more */
  46.     shutdown(s, 1);   
  47.  
  48.     while(read(s, buf, len) > 0)
  49.        do_something();
  50.  
  51.     close(s);
  52.  
  53. If you want to simply I<download> a file, you can also ignore the LaserWriter's 
  54. response and simply close the socket after downloading.
  55.