home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / phylck.exe / SCANLOCK.C < prev    next >
C/C++ Source or Header  |  1995-06-06  |  4KB  |  146 lines

  1.  
  2. /****************************************************************************
  3. ** DISCLAIMER
  4. **
  5. ** Novell, Inc. makes no representations or warranties with respect to
  6. ** any NetWare software, and specifically disclaims any express or
  7. ** implied warranties of merchantability, title, or fitness for a
  8. ** particular purpose.
  9. **
  10. ** Distribution of any NetWare software is forbidden without the
  11. ** express written consent of Novell, Inc.  Further, Novell reserves
  12. ** the right to discontinue distribution of any NetWare software.
  13. **
  14. ** Novell is not responsible for lost profits or revenue, loss of use
  15. ** of the software, loss of data, costs of re-creating lost data, the
  16. ** cost of any substitute equipment or program, or claims by any party
  17. ** other than you.  Novell strongly recommends a backup be made before
  18. ** any software is installed.   Technical support for this software
  19. ** may be provided at the discretion of Novell.
  20. ****************************************************************************
  21. **
  22. ** File:  SCANLOCK.C
  23. **
  24. ** Desc:  This program will take a file name on the command line in the
  25. **                format of VOLUME:PATH and scan the file for physical record
  26. **                locks.  The locks are displayed in a simmilar format to the
  27. **                monitor NLM that ships with NetWare.
  28. **
  29. **
  30. ** Netware API Calls:   NWCallsInit()
  31. **                                            NWGetDefaultConnectionID()
  32. **                                            NWScanPhysicalLocksByFile()
  33. **
  34. ** Programmers:
  35. ** Ini  Who                 Firm
  36. ** ------------------------------------------------------------------
  37. ** CRG  Calvin R. Gaisford  Novell Developer Support.
  38. **
  39. ** History:
  40. **
  41. ** ------------------------------------------------------------------
  42. ** 06-06-95 CRG  First code.
  43. */
  44.  
  45. /****************************************************************************
  46. **   Include headers, macros, function prototypes, etc.
  47. */
  48.  
  49.  
  50.      /*------------------------------------------------------------------
  51.      **   ANSI
  52.      */
  53.      #include <stdlib.h>
  54.      #include <stdio.h>
  55.      #include <string.h>
  56.  
  57.      /*------------------------------------------------------------------
  58.      **   NetWare
  59.      */
  60.      #include <nwcalls.h>
  61.  
  62.      /*------------------------------------------------------------------
  63.      **   Defines
  64.      */
  65.      #define NWDOS
  66.  
  67.      /*------------------------------------------------------------------
  68.      **   Prototypes
  69.      */
  70.      /* Entire program contained in main() */
  71.  
  72.  
  73. /****************************************************************************
  74. **   Program Start
  75. */
  76. int main(int argc, char *argv[])
  77. {
  78.     NWCONN_HANDLE                defaultConnID;
  79.     NWCCODE                            ccode;
  80.     NWLAST_RECORD                lastRecord;
  81.     PHYSICAL_LOCK                lock;
  82.     PHYSICAL_LOCKS            locks;
  83.  
  84.  
  85.     if(argc < 2)
  86.     {
  87.         printf("Usage: filelock <filename (VOL:PATH)>\n");
  88.         return 1;
  89.     }
  90.  
  91.     ccode=NWCallsInit(NULL,NULL);
  92.     if(ccode)
  93.     {
  94.         printf("Unable to intialize Shell/Requester tables.  Status = %04X\n");
  95.         return 1;
  96.     }
  97.  
  98.     ccode=NWGetDefaultConnectionID(&defaultConnID);
  99.     if(ccode)
  100.     {
  101.         printf("Error in NWGetDefaultConnectionID.  Status = %04X\n",ccode);
  102.         return 1;
  103.     }
  104.  
  105.     lastRecord = 0;
  106.  
  107.     printf("Conn Start    End      Physical Record Locks\n");
  108.     do
  109.     {
  110.         ccode = NWScanPhysicalLocksByFile(
  111.                         /* Connection Handle */            defaultConnID,
  112.                         /* Directory Handle  */            0,
  113.                         /* File Path         */            argv[1],
  114.                         /* DataStream        */            0,
  115.                         /* last record       */            &lastRecord,
  116.                         /* PHYSICAL_LOCK info*/            &lock,
  117.                         /* PHYSICAL_LOCKS inf*/            &locks);
  118.  
  119.         if(ccode == 0x88FF)
  120.         {
  121.             /* File Scan is done */
  122.             return 0;
  123.         }
  124.         if(ccode)
  125.         {
  126.             printf("NWScanPhysicalLocksByFile Failed with status = %04X\n", ccode);
  127.             return ccode;
  128.         }
  129.  
  130.         printf("%-4d %08lX %08lX ",lock.connNumber, lock.recordStart, lock.recordEnd);
  131.  
  132.         if(lock.loggedCount)
  133.             printf("Logged     ");
  134.         else
  135.             printf("Not Logged ");
  136.  
  137.         if(lock.lockType)
  138.             printf("Locked    \n");
  139.         else
  140.             printf("Not Locked\n");
  141.     }
  142.     while(lastRecord != -1);
  143.         return 0;
  144. }
  145.  
  146.