home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dosmd.exe / MDDOS.C < prev    next >
C/C++ Source or Header  |  1995-06-05  |  5KB  |  159 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:AFPMD.C   
  22. **
  23. **   Desc:Creates a Dos directory on a server volume.   
  24. **
  25. **        
  26. **   Programmers:
  27. **   Ini   Who         Firm
  28. **   ------------------------------------------------------------------
  29. **   ARM   A. Ray Maxwell     Novell Developer Support.
  30. **
  31. **   History:
  32. **       
  33. **   ------------------------------------------------------------------
  34. **   04-14-95   ARM   Added the header and disclaimer.
  35. */
  36.  
  37. /***************************************************************************
  38. **   Include headers, macros, function prototypes, etc.
  39. */
  40.  
  41.    /*------------------------------------------------------------------
  42.    **   ANSI
  43.    */
  44.    #include <stdlib.h>          /* exit(), atol()        */
  45.    #include <stdio.h>           /* sprintf()             */
  46.    #include <string.h>
  47.  
  48.    /*------------------------------------------------------------------
  49.    **   NetWare
  50.    */
  51.    #include <nwcalls.h>      
  52.  
  53.  
  54.  
  55. /****************************************************************************
  56. **   Program Start
  57. */
  58.  
  59. void main(int argc, char *argv[])
  60. {
  61.    NWDIR_HANDLE       dirHandle;
  62.    NWCONN_HANDLE      conn;
  63.    NWVOL_NUM          volNumber;
  64.    NWCCODE            ccode;
  65.    char               pathString[32];
  66.    char               path[256] = "";
  67.    char               volName[16];
  68.    char               serverName[48];
  69.    int                i;
  70.  
  71.    if(argc < 3)
  72.       {
  73.       printf("Usage: MDDOS <server\\volume:path> <new directory name> \n");
  74.       printf("       Example: moiraine\\sys:system newdir\n");
  75.       printf("                Server=moiraine\n");
  76.       printf("                volume=sys:\n");
  77.       printf("                directory=system\n");
  78.       printf("                new directory to create=newdir\n");
  79.       exit(1);
  80.       }
  81.  
  82.    strcpy(pathString, strupr(argv[2]));
  83.  
  84.  
  85.    ccode = NWCallsInit(NULL, NULL);
  86.    if (ccode)
  87.       {
  88.       printf("\nNWCallsInit returned %04X\n", ccode);
  89.       exit(1);
  90.       }
  91.  
  92.  
  93.    strupr(argv[1]);
  94.  
  95.    
  96.    ccode = NWParseNetWarePath(
  97.            /* > path to parse                        */ argv[1],
  98.            /* < server connection Handle             */ &conn,
  99.            /* < directory Handle                     */ &dirHandle,
  100.            /* <new path relative to directory Handle */ path);
  101.  
  102.    if (ccode){
  103.       printf("\nNWParseNetWarePath returned %04X\n", ccode);
  104.       exit(1);
  105.    }
  106.  
  107.    ccode = NWParsePath(
  108.            /* > Path to parse                */ path,
  109.            /* < server name (optional)       */ serverName,
  110.            /* < connection handle (optional) */ NULL,
  111.            /* < volume name (optional)       */ volName,
  112.            /* < directory path (optional)    */ NULL);
  113.  
  114.    if (ccode){
  115.       printf("\nNWParsePath returned %04X\n", ccode);
  116.       exit(1);
  117.    }
  118.  
  119.    printf("\nVolume name = %s\n", volName);
  120.  
  121.    ccode = NWGetVolumeNumber(
  122.            /* > connection Handle    */ conn,
  123.            /* > volume name          */ volName,
  124.            /* < volume Number        */ &volNumber);
  125.  
  126.  
  127.    printf("\nVolume number = %d\n", volNumber);
  128.  
  129.    printf("\nFile Server name associated with this handle %s\n", serverName);
  130.    
  131.    /*-----------------------------------------------------------------------
  132.    ** Check to see if the root of the path is a volume if so don't put the 
  133.    ** '\\' in the path.
  134.    */
  135.    i=0;
  136.    while((path[i]!=':') && (path[i]!='\0'))
  137.       i++;
  138.  
  139.    if ((path[i]==':') && (path[i+1]!='\0')){
  140.       strcat(path,"\\");
  141.       strcat(path,pathString);
  142.    }
  143.    else
  144.       strcat(path,pathString);
  145.  
  146.    ccode=NWCreateDirectory(
  147.          /* connection Handle      */ conn,
  148.          /* directory Handle       */ 0,
  149.          /* path                   */ path,
  150.          /* access rights          */ 0xEE);
  151.  
  152.    if(ccode){
  153.       printf("NWCreateDirectory failed %X\n");
  154.       exit(1);
  155.    }
  156.     else
  157.       printf("%s was created sussessfully\n",path);
  158. }
  159.