home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / printj.exe / PRINTJOB.C < prev    next >
C/C++ Source or Header  |  1995-01-13  |  7KB  |  185 lines

  1. /****************************************************************************
  2. **      DISCLAIMER  
  3. **  
  4. **   Novell, Inc. makes no representations or warranties with respect to
  5. **   any NetWare software, and specifically disclaims any express or
  6. **   implied warranties of merchantability, title, or fitness for a
  7. **   particular purpose.  
  8. **
  9. **   Distribution of any NetWare software is forbidden without the
  10. **   express written consent of Novell, Inc.  Further, Novell reserves
  11. **   the right to discontinue distribution of any NetWare software.
  12. **
  13. **   Novell is not responsible for lost profits or revenue, loss of use
  14. **   of the software, loss of data, costs of re-creating lost data, the
  15. **   cost of any substitute equipment or program, or claims by any party
  16. **   other than you.  Novell strongly recommends a backup be made before
  17. **   any software is installed.   Technical support for this software
  18. **   may be provided at the discretion of Novell.
  19. ****************************************************************************
  20. **   File:   PRINTJOB.C
  21. **
  22. **   Desc: This program will search for a print job record in the PRINTCON 
  23. **         database. It will print out information then modify the job and 
  24. **         save it to the same job name.
  25. **   NOTE: The dbOwner must be found for each call to find the printcon
  26. **         information so a loop will be needed to access the bindery
  27. **         and find each user. 
  28. **
  29. **
  30. **   Parameter descriptions:    > input
  31. **                              < output
  32. **
  33. **   Programmers:
  34. **   Ini   Who                  Firm
  35. **   -----------------------------------------------------------------------
  36. **   ARM   A. Ray Maxwell         Novell Developer Support.
  37. **
  38. **   History:
  39. **
  40. **   When      Who   What
  41. **   -----------------------------------------------------------------------
  42. **   08-02-94   ARM   First code.
  43. */
  44.  
  45. /****************************************************************************
  46. **   Include headers, macros, function prototypes, etc.
  47. */
  48.  
  49.  
  50.  
  51.    /*------------------------------------------------------------------------
  52.    **   ANSI
  53.    */
  54.    #include <stdio.h>
  55.    #include <stdlib.h>
  56.    #include <string.h>
  57.  
  58.    /*------------------------------------------------------------------------
  59.    **   NetWare
  60.    */
  61.    #include <nwcalls.h>
  62.    #include <nwps_job.h>
  63.    #include <nwps_err.h>
  64.  
  65.    /*------------------------------------------------------------------------
  66.    ** Defines
  67.    */
  68.    #define NWDOS
  69.  
  70. /****************************************************************************
  71. **   Main program start
  72. */
  73. void main(int argc,char *argv[])
  74. {
  75.  
  76.    /*--------------------------------------------------------------------------
  77.    ** NWPSJobGetFirstJob
  78.    */
  79.    NWCONN_HANDLE  connHandle;
  80.    NWPS_Job_Rec   pJobRecord;
  81.    NWPSListHandle hListHandle;
  82.    char             dbOwner[48];
  83.    char             pJobName[48];
  84.    WORD             defaultPJ;
  85.    WORD             ccode;
  86.    int             globalConnType;
  87.    /*--------------------------------------------------------------------------
  88.    ** NOTE: The following parameter has been added to the SDK with the 4.1 
  89.    **       release which is in beta as of 8/18/94 it was not available with
  90.    **       the SDK v1.0e and therefore the functions wouldn't work with 3.x
  91.    **       servers. i.e NWPS_BINDERY_SERVICE_PRE_40.(it is available with the
  92.    **       4.02 sdk)
  93.    */
  94.    globalConnType=NWPS_BINDERY_SERVICE_PRE_40;
  95.  
  96.  
  97.    ccode=NWCallsInit(NULL,NULL);
  98.    if (ccode)
  99.       exit(1);
  100.  
  101.     ccode = NWGetConnectionHandle(
  102.             /* > server name        */ "PRV-DEVSUP",
  103.             /*   Novell Reserved1   */ 0,
  104.             /* < conn Handle        */ &connHandle,
  105.             /*   Novell Reserved2   */ NULL);
  106.    if (ccode)
  107.       exit(1);
  108.  
  109.    strcpy (dbOwner,"SUPERVISOR"); /*user name of the printcon.dat file owner*/
  110.  
  111.    /*------------------------------------------------------------------------
  112.    ** to get all the users on the server you will need to put a loop in that
  113.    ** will find the username (dbOwner) then call the code listed below to
  114.    ** get the printjob information.
  115.    */
  116.  
  117.    if (globalConnType == NWPS_BINDERY_SERVICE_PRE_40)
  118.    {
  119.       ccode=NWPSJobGetFirstJob(
  120.             /* > connType               */ globalConnType,
  121.             /* > conn Handle            */ connHandle,
  122.             /* > search flag            */ NWPS_EXTENDED_SEARCH,
  123.             /* < pointer to handle
  124.                  to be passed to  
  125.                  NWPSJobGetNextJob      */ &hListHandle,
  126.             /* <>pointer to start
  127.                  point of the search
  128.                  Output actual
  129.                  location of job        */ dbOwner,
  130.             /* < Pointer to first job   */ pJobName,
  131.             /* < Default print job flag */ &defaultPJ);
  132.       if(!ccode){
  133.          do{
  134.             ccode = NWPSJobRead(
  135.                     /* > connType                 */ globalConnType,
  136.                     /* > conn Handle              */ connHandle,
  137.                     /* > username of owner of DB  */ dbOwner,
  138.                     /* > ponter to name of job    */ pJobName,
  139.                     /* < pointer to NWPS_Job_Rec  */ &pJobRecord);
  140.             if (ccode)
  141.                exit(1);
  142.  
  143.             printf("copies=%d\nlocalprinter=%d\nformname=%s\nbannerName=%s\n",
  144.               pJobRecord.copies,
  145.               pJobRecord.localPrinter,
  146.               pJobRecord.formName,
  147.               pJobRecord.bannerName);
  148.               printf("printserver name %s\n",pJobRecord.u.nonDS.printServer);
  149.            /*----------------------------------------------------------------
  150.            ** Change the print job record 
  151.            */
  152.            pJobRecord.copies=2;
  153.            strcpy(pJobRecord.bannerName,"Rays_Banner");
  154.  
  155.            /*----------------------------------------------------------------
  156.            ** If a print job record with the same name already exists, it is 
  157.            ** overwritten with the data pointed to by the info in the pointer
  158.            ** to name of print job record.
  159.            */
  160.            ccode=NWPSJobWrite(
  161.                         /* > connType                           */ globalConnType,
  162.                   /* > conn Handle                        */ connHandle,
  163.                   /* > pointer to username of owner of DB */ dbOwner,
  164.                   /* > pointer to name of print job record*/ pJobName,
  165.                   /* > pointer to NWPS_Job_Rec            */ &pJobRecord);
  166.  
  167.             printf("copies=%d\nlocalprinter=%d\nformname=%s\nbannerName=%s\n",
  168.               pJobRecord.copies,
  169.               pJobRecord.localPrinter,
  170.               pJobRecord.formName,
  171.               pJobRecord.bannerName);
  172.  
  173.  
  174.          } while (!NWPSJobGetNextJob(
  175.                     /* > value from NWPSJobGetFirstJob     */ hListHandle, 
  176.                     /* < pointer to username ofowner of DB */ dbOwner,
  177.                     /* < pointer to print job record found */ pJobName,
  178.                     /* < pointer to defualt job flag       */ &defaultPJ));
  179.  
  180.          NWPSJobEndNextJob(hListHandle);
  181.       }
  182.    }
  183.  
  184. }
  185.