home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / prtatt.exe / PRINTATT.C next >
Text File  |  1995-01-09  |  5KB  |  142 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. ****************************************************************************
  21. **   File:   PRINTATT.C
  22. **
  23. **   Desc: This program will retrieve the first print server attribute value 
  24. **         for the indicated print server.  The code is written to test what
  25. **         the user needs to be logged in as to use these functions. 
  26. **
  27. **   NOTE: This call can only be made by a supervisor or equivalent.
  28. **
  29. **
  30. **   Parameter descriptions:    > input
  31. **                              < output
  32. **
  33. **
  34. **
  35. **   Programmers:
  36. **   Ini   Who                  Firm
  37. **   -----------------------------------------------------------------------
  38. **   ARM   A. Ray Maxwell         Novell Developer Support.
  39. **
  40. **   History:
  41. **
  42. **   When      Who   What
  43. **   -----------------------------------------------------------------------
  44. **   11-07-94   ARM   First code.
  45. */
  46.  
  47. /****************************************************************************
  48. **   Include headers, macros, function prototypes, etc.
  49. */
  50.    /*------------------------------------------------------------------------
  51.    **   ANSI
  52.    */
  53.    #include <stdio.h>
  54.    #include <stdlib.h>
  55.    #include <string.h>
  56.  
  57.    /*------------------------------------------------------------------------
  58.    **   NetWare
  59.    */
  60.    #include <nwcalls.h>
  61.    #include <nwnet.h>
  62.    #include <nwpsrv.h>
  63.         
  64.    /*------------------------------------------------------------------------
  65.    ** Defines
  66.    */
  67.    #define NWDOS
  68.  
  69. /****************************************************************************
  70. **   Main program start
  71. */
  72. void main(int argc,char *argv[])
  73. {
  74.  
  75.    /*--------------------------------------------------------------------------
  76.    ** NWPSJobGetFirstJob
  77.    */
  78.    NWCONN_HANDLE    connHandle;
  79.    char             pServerName[48];
  80.    NWPSListHandle   handle;
  81.    Typed_Name_T     *typedName;
  82.    WORD             attrID;
  83.    WORD             ccode;
  84.    char             serverName[48];
  85.    int              globalConnType;
  86.    /*--------------------------------------------------------------------------
  87.    ** NOTE: The following parameter has been added to the SDK with the 4.1
  88.    **       release which is in beta as of 8/18/94 it was not available with
  89.    **       the SDK v1.0e and therefore the functions wouldn't work with 3.x
  90.    **       servers. i.e NWPS_BINDERY_SERVICE_PRE_40.(it is available with the
  91.    **       volume 2 sdk)
  92.    */
  93.    //globalConnType=NWPS_BINDERY_SERVICE_PRE_40;
  94.    globalConnType=NWPS_BINDERY_SERVICE;
  95.    typedName=(Typed_Name_T*) malloc (sizeof(Typed_Name_T));
  96.  
  97.    if(argc<2)
  98.       printf("Usage: PRINTATT <servername> <printserver name>\n");
  99.    else{
  100.       argv++;
  101.       strcpy(serverName,strupr(*argv));
  102.       argv++;
  103.       strcpy(pServerName,strupr(*argv));
  104.     }
  105.    ccode=NWCallsInit(NULL,NULL);
  106.    if (ccode)
  107.       exit(1);
  108.  
  109.    ccode = NWGetConnectionHandle(
  110.            /* > server name        */ serverName,
  111.            /*   Novell Reserved1   */ 0,
  112.            /* < conn Handle        */ &connHandle,
  113.            /*   Novell Reserved2   */ NULL);
  114.    if (ccode)
  115.       exit(1);
  116.  
  117.    attrID = NWPS_ATTR_PRINTER;
  118.    if (globalConnType == NWPS_BINDERY_SERVICE)
  119.    //if (globalConnType == NWPS_BINDERY_SERVICE_PRE_40)
  120.    {
  121.       ccode=NWPSCfgGetFirstPrintServerAttr(
  122.             /* > connType                    */ globalConnType,
  123.             /* > conn Handle                 */ connHandle,
  124.             /* > Pointer to pserver name     */ pServerName,
  125.             /* >Print serverices att id      */ attrID,
  126.             /* < pointer to value to be
  127.                  passed to
  128.                  NWPSCfgGetNextPrintServer   */ &handle,
  129.             /* < Pointer to first att buffer */ typedName);
  130.  
  131.       if(ccode){
  132.          printf("NWPSCfgGetFirstPrintServerAttr failed: %X\n",ccode);
  133.          free(typedName);
  134.          exit(0);
  135.       }
  136.       else
  137.          printf("SUCCESSFUL CODE COMPLETION\n");
  138.       free(typedName);
  139.  
  140.   }
  141. }
  142.