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