home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / rndos.exe / RENDOS.C next >
Text File  |  1995-06-23  |  4KB  |  115 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:RENDOS.C   
  22. **
  23. **   Desc: This program will rename a DOS file.  You can rename the file
  24. **         in the same directory or give a path to another directory and 
  25. **         file name as long as the directory is on the same server and
  26. **         same volume.  
  27. **
  28. **        
  29. **   Programmers:
  30. **   Ini   Who         Firm
  31. **   ------------------------------------------------------------------
  32. **   ARM   A. Ray Maxwell     Novell Developer Support.
  33. **
  34. **   History:
  35. **
  36. **   ------------------------------------------------------------------
  37. **   03-24-94   ARM   First code.
  38. */
  39.  
  40. /***************************************************************************
  41. **   Include headers, macros, function prototypes, etc.
  42. */
  43.  
  44.     /*------------------------------------------------------------------
  45.     **   ANSI
  46.     */
  47.     #include <stdlib.h>          /* exit(), atol()        */
  48.     #include <stdio.h>           /* printf()              */
  49.     #include <string.h>          /* strcpy()              */
  50.     #include <conio.h>           /* clrscr()              */
  51.    #include <mem.h>             /* memset()              */
  52.     /*------------------------------------------------------------------
  53.    **   NetWare
  54.    */
  55.    #include <nwcalls.h>      
  56.    #define NWDOS
  57.  
  58.  
  59. /****************************************************************************
  60. **   Program Start
  61. */
  62. void main(int argc, char *argv[])
  63. {
  64.     NWDIR_HANDLE       dirHandle;
  65.     NWCONN_HANDLE      connHandle;
  66.     NWCCODE            ccode;
  67.     char               path[256];
  68.     char               newName[32];
  69.     char               pathString[256] = "";
  70.  
  71.     if(argc < 3)
  72.         {
  73.         clrscr();
  74.         printf("Usage: renfile <server\\path> <file name>\n");
  75.         printf("         server\path : servername\\volume:dir\\dir...\\old file name\n");
  76.         printf("       file name   : volume:dir\\dir...\\new file name\n");
  77.  
  78.         exit(1);
  79.         }
  80.  
  81.     strcpy(pathString, strupr(argv[2]));
  82.  
  83.     ccode = NWCallsInit(NULL, NULL);
  84.     if (ccode)
  85.         {
  86.         printf("\nNWCallsInit returned %04X\n", ccode);
  87.         exit(1);
  88.         }
  89.  
  90.     strupr(argv[1]);
  91.     ccode = NWParseNetWarePath(
  92.               /* > path being parsed               */ argv[1],
  93.               /* < server conn Handle              */ &connHandle,
  94.               /* < directory Handle                */ &dirHandle,
  95.               /* < new path relative to dir Handle */ path);
  96.     if (ccode)
  97.         {
  98.         printf("\nNWParseNetWarePath returned %04X\n", ccode);
  99.         exit(1);
  100.         }
  101.  
  102.    ccode=NWRenameFile(
  103.             /* > connection handle */ connHandle,
  104.          /* > Old Dir Handle    */ 0,
  105.             /* > Old File Name     */ path,
  106.             /* > serch Attributes  */ 0,
  107.             /* > New Dir Handle    */ 0,
  108.             /* < new file name     */ pathString);
  109.     if (ccode)
  110.       {
  111.       printf("Unable to rename \"%s\ error code=%X.\n",argv[2],ccode);
  112.       exit(1);
  113.         }
  114. }
  115.