home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / attprn.exe / ATTR.C < prev   
Text File  |  1994-11-28  |  5KB  |  140 lines

  1. /****************************************************************************
  2. **   File:   ATT.C
  3. **
  4. **   Desc: This program will retrieve the first print server attribute value 
  5. **         for the indicated print server.  The code is written to test what
  6. **         the user needs to be logged in as to use these functions. 
  7. **
  8. **   NOTE: This call can only be made by a supervisor or equivalent.
  9. **
  10. **
  11. **
  12. **
  13. **      DISCLAIMER  
  14. **  
  15. **   Novell, Inc. makes no representations or warranties with respect to
  16. **   any NetWare software, and specifically disclaims any express or
  17. **   implied warranties of merchantability, title, or fitness for a
  18. **   particular purpose.  
  19. **
  20. **   Distribution of any NetWare software is forbidden without the
  21. **   express written consent of Novell, Inc.  Further, Novell reserves
  22. **   the right to discontinue distribution of any NetWare software.
  23. **
  24. **   Novell is not responsible for lost profits or revenue, loss of use
  25. **   of the software, loss of data, costs of re-creating lost data, the
  26. **   cost of any substitute equipment or program, or claims by any party
  27. **   other than you.  Novell strongly recommends a backup be made before
  28. **   any software is installed.   Technical support for this software
  29. **   may be provided at the discretion of Novell.
  30. **
  31. **
  32. **   Programmers:
  33. **
  34. **
  35. **   Ini   Who                  Firm
  36. **   -----------------------------------------------------------------------
  37. **   ARM   A. Ray Maxwell         Novell Developer Support.
  38. **
  39. **   History:
  40. **
  41. **   When      Who   What
  42. **   -----------------------------------------------------------------------
  43. **   11-07-94   ARM   First code.
  44. */
  45.  
  46. /****************************************************************************
  47. **   Include headers, macros, function prototypes, etc.
  48. */
  49.  
  50.  
  51.  
  52.    /*------------------------------------------------------------------------
  53.    **   ANSI
  54.    */
  55.    #include <stdio.h>
  56.     #include <stdlib.h>
  57.     #include <string.h>
  58.  
  59.     /*------------------------------------------------------------------------
  60.     **   NetWare
  61.     */
  62.     #include <nwcalls.h>
  63.     #include <nwnet.h>
  64.     #include <nwpsrv.h>
  65.     //#include <nwps_job.h>
  66.     //#include <nwps_err.h>
  67. /****************************************************************************
  68. **   Main program start
  69. */
  70. void main(int argc,char *argv[])
  71. {
  72.  
  73.     /*--------------------------------------------------------------------------
  74.     ** NWPSJobGetFirstJob
  75.     */
  76.     NWCONN_HANDLE   connHandle;
  77.     char            pServerName[48];
  78.     NWPSListHandle  handle;
  79.     Typed_Name_T    *typedName;
  80.     WORD            attrID;
  81.     WORD            ccode;
  82.     char            serverName[48];
  83.     int             globalConnType;
  84.     /*--------------------------------------------------------------------------
  85.     ** NOTE: The following parameter has been added to the SDK with the 4.1
  86.     **       release which is in beta as of 8/18/94 it was not available with
  87.     **       the SDK v1.0e and therefore the functions wouldn't work with 3.x
  88.     **       servers. i.e NWPS_BINDERY_SERVICE_PRE_40.(it is available with the
  89.     **       4.02 sdk i.e volume 2 of the cdrom)
  90.     */
  91.     //globalConnType=NWPS_BINDERY_SERVICE_PRE_40;
  92.     globalConnType=NWPS_BINDERY_SERVICE;
  93.     typedName=(Typed_Name_T*) malloc (sizeof(Typed_Name_T));
  94.  
  95.    if(argc<2)
  96.       printf("Usage: att <servername> <printserver name>\n");
  97.    else{
  98.       argv++;
  99.       strcpy(serverName,strupr(*argv));
  100.       argv++;
  101.       strcpy(pServerName,strupr(*argv));
  102.     }
  103.    ccode=NWCallsInit(NULL,NULL);
  104.    if (ccode)
  105.         exit(1);
  106.  
  107.    ccode = NWGetConnectionHandle(
  108.            /* > server name        */ serverName,
  109.            /*   Novell Reserved1   */ 0,
  110.            /* < conn Handle        */ &connHandle,
  111.            /*   Novell Reserved2   */ NULL);
  112.    if (ccode)
  113.       exit(1);
  114.  
  115.      attrID = NWPS_ATTR_PRINTER;
  116.    if (globalConnType == NWPS_BINDERY_SERVICE)
  117.    //if (globalConnType == NWPS_BINDERY_SERVICE_PRE_40)
  118.    {
  119.       ccode=NWPSCfgGetFirstPrintServerAttr(
  120.             /* > connType                    */ globalConnType,
  121.             /* > conn Handle                 */ connHandle,
  122.             /* > Pointer to pserver name     */ pServerName,
  123.             /* >Print serverices att id      */ attrID,
  124.             /* < pointer to value to be
  125.                  passed to
  126.                  NWPSCfgGetNextPrintServer   */ &handle,
  127.             /* < Pointer to first att buffer */ typedName);
  128.  
  129.         if(ccode){
  130.          printf("NWPSCfgGetFirstPrintServerAttr failed: %X\n",ccode);
  131.          free(typedName);
  132.          exit(0);
  133.       }
  134.       else
  135.          printf("SUCCESSFUL CODE COMPLETION\n");
  136.       free(typedName);
  137.  
  138.   }
  139. }
  140.