home *** CD-ROM | disk | FTP | other *** search
- /*
- **
- ** This example shows how to use the
- ** PrintManager v39 API
- **
- ** Currently only @{PMCMD:NAMEJOB/}
- ** is available
- **
- */
-
- #include <exec/execbase.h>
- #include <devices/printer.h>
-
- #include <pragma/exec_lib.h>
- #include <pragma/dos_lib.h>
-
- /****************************************************************************/
-
- struct Library *SysBase,
- *DOSBase;
-
- /****************************************************************************/
-
- void main( void )
- {
- /*
- ** some boring stuff
- */
- SysBase = (*(struct Library **)4L);
-
- if( DOSBase = OpenLibrary( "dos.library", 0L ) )
- {
- /*
- ** allocate msgport, ioreq and finally open printer.device
- */
- struct MsgPort *mp;
- struct IOStdReq *ior;
-
- mp = CreateMsgPort();
-
- if( ior = (struct IOStdReq *) CreateIORequest( mp, sizeof(struct IODRPReq) ) )
- {
- if( !OpenDevice( "printer.device", 0L, (struct IORequest *)ior, 0L ) )
- {
- /*
- ** now check if printmanager is running.
- ** because of speed reasons we can only send
- ** commands at the beginning of a job.
- */
- struct Device *dev;
-
- dev = (struct Device *)FindName( &((struct ExecBase *)SysBase)->DeviceList, "spool.device" );
- /*
- ** only spool.device v40+ has this feature,
- ** so make sure we've the right beast
- */
- if( dev && ((struct Library *)dev)->lib_Version >= 40L )
- {
- /*
- ** now send the name
- ** the name is limited to 25 chars and MUST NOT
- ** contain ':/#?*' ...
- */
- ior->io_Data = "@{PMCMD:NAMEJOB/ALotOfBuckets.txt}";
- ior->io_Length = -1L; // I am a lazy bone ;)
- ior->io_Command = PRD_RAWWRITE; // Must be a raw write !!!
- DoIO( (struct IORequest *)ior );
- }
- /*
- ** continue as usual - here we just write some text ...
- */
- ior->io_Data = "100 buckets of bits on the bus\n"
- "100 buckets of bits\n"
- "Take one down, short it to ground\n"
- "FF buckets of bits on the bus\n"
- "\n"
- "FF buckets of bits on the bus\n"
- "FF buckets of bits\n"
- "Take one down, short it to ground\n"
- "FE buckets of bits on the bus\n"
- "\n"
- "ad infinitum...\f";
- ior->io_Length = -1L;
- ior->io_Command = CMD_WRITE;
- DoIO( (struct IORequest *)ior );
-
- CloseDevice( (struct IORequest *)ior );
- }
- else PutStr( "Cannot open printer.device\n" );
-
- DeleteIORequest( (struct IORequest *)ior );
- }
- else PrintFault( ERROR_NO_FREE_STORE, NULL );
-
- DeleteMsgPort( mp );
-
- CloseLibrary( DOSBase );
- }
- }
-
- /****************************************************************************/
-