home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / sparmp.exe / SPARMAP.C next >
Text File  |  1994-12-29  |  5KB  |  157 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:   SPARMAP.C
  22. **
  23. ** Desc:   This program will allow you to input the file server name
  24. **         and the full path to the sparse file you wish to have the
  25. **         bit map done of.  It will then print out the bit map.
  26. **
  27. ** Parameter descriptions:    > input
  28. **                            < output
  29. **
  30. **
  31. ** Netware API Calls:         NWCallsInit()
  32. **                            
  33. **
  34. **        
  35. ** Programmers:
  36. ** Ini   Who                Firm
  37. ** ------------------------------------------------------------------
  38. ** ARM   A. Ray Maxwell     Novell Developer Support.
  39. **                            
  40. ** History:
  41. **     
  42. ** ------------------------------------------------------------------
  43. ** 06-22-94   ARM   First code.
  44. */
  45.  
  46. /****************************************************************************
  47. ** Include Headers, Macros & function Prototypes.
  48. */
  49.    /*-------------------------------------------------------------------
  50.    ** Borland C.
  51.    */
  52.    #include <stdlib.h>
  53.    #include <stdio.h>
  54.    #include <string.h>      /*strcpy() */
  55.    #include <conio.h>
  56.    #include <fcntl.h>
  57.    #include <sys\stat.h>
  58.    #include <share.h>
  59.    #include <conio.h>
  60.    #include <io.h>
  61.    #include <math.h>
  62.    #include <dos.h>
  63.  
  64.  
  65.    /*-------------------------------------------------------------------
  66.    ** NWCalls
  67.    */
  68.    #define NWDOS
  69.  
  70.    #include <nwcalls.h>
  71.  
  72.    /*------------------------------------------------------------------------
  73.    ** Prototypes
  74.    */
  75.    void usage (void);
  76.    
  77.    /*------------------------------------------------------------------------
  78.    ** Globals
  79.    */
  80.  
  81. /****************************************************************************
  82. ** Program start.
  83. */
  84. void main (int argc, char **argv)
  85. {  
  86.    /*---------------------------------------------------------------------
  87.    **  This line is to increase the stack from 4 (borland) to 16.
  88.    */
  89.  
  90.    int ccode,fh,i,counter;
  91.    NWCONN_HANDLE  conn;
  92.    NWLOCAL_SCOPE scopeFlag;
  93.    NWLOCAL_MODE res1;        /* reserve flags for NWGetConnectionHandle */
  94.    NWLOCAL_SCOPE res2;       /* set to NULL */
  95.    LONG blockSize;
  96.    BYTE bitMap[512];
  97.    char filepath[256];
  98.  
  99.    if (argc == 3){
  100.       ccode = NWCallsInit(NULL, NULL);
  101.       strupr (argv[1]);
  102.       strupr (argv[2]);
  103.       ccode = NWGetConnectionHandle (argv[1],res1,&conn,&res2);
  104.  
  105.       if (ccode != 0){
  106.          printf ("Error in NWGetConnectionHandle. Status = %d\n",ccode);
  107.          exit(-1);
  108.       }
  109.  
  110.       memset (filepath,0x00,256);
  111.       strcpy (filepath, argv[1]);
  112.       strcat (filepath, "\\");
  113.       strcat (filepath,argv[2]);
  114.  
  115.       fh = open (filepath, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE );
  116.  
  117.       if (fh == -1){
  118.          printf ("Error in opening %s\n",argv[1]);
  119.          exit(-1);
  120.       }
  121.  
  122.       ccode = NWGetSparseFileBitMap (conn,fh,0,0x00000000,&blockSize,bitMap);
  123.  
  124.       if (ccode != 0){
  125.          printf ("Error in opening %s\n",argv[1]);
  126.          exit(-1);
  127.       }
  128.  
  129.       clrscr();
  130.       printf ("Sparse file bit map for %s\n\n",filepath);
  131.       counter = 0;
  132.       for (i=0; i<512; i++){
  133.          printf (" %X",bitMap[i]);
  134.          counter++;
  135.          if (counter == 32){
  136.             printf ("\n");
  137.             counter = 0;
  138.          }
  139.       } /* end for */
  140.    } /* end if */
  141.    else
  142.      usage();
  143.  
  144. }
  145.  
  146.  
  147. /****************************************************************************
  148. ** Usage
  149. */
  150. void usage (void)
  151. {
  152. printf ("\n\n");
  153. printf ("Usage: SPARMAP <FILESERVER> <PATH>\n");
  154. printf ("<FILESERVER>: Name of the fileserver bitmap will be created on.\n");
  155. printf ("<PATH>      : Full path to sparse file.(VOLUME:\SUBDIR\FILENAME)\n");
  156. }
  157.