home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / afpmdr.exe / AFPMD.C next >
C/C++ Source or Header  |  1995-06-05  |  5KB  |  175 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 Machintosh directory on a server volume under the dos
  24. **         environment.   
  25. **
  26. **        
  27. **   Programmers:
  28. **   Ini   Who         Firm
  29. **   ------------------------------------------------------------------
  30. **   KB    Karl Bunnell       Novell Developer Support.
  31. **   ARM   A. Ray Maxwell     Novell Developer Support.
  32. **
  33. **   History:
  34. **       
  35. **   ------------------------------------------------------------------
  36. **   02-14-94   ARM   Added the header, comments and disclaimer.
  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>           /* sprintf()             */
  48.    #include <string.h>
  49.  
  50.    /*------------------------------------------------------------------
  51.    **   NetWare
  52.    */
  53.    #include <nwcalls.h>      
  54.  
  55.  
  56.  
  57. /****************************************************************************
  58. **   Program Start
  59. */
  60.  
  61. void main(int argc, char *argv[])
  62. {
  63.     NWAFP_FILE_INFO    fileInfo;
  64.     NWAFP_ENTRY_ID        entryID1, entryID2;
  65.     NWFINDER_INFO        finderInfo = 0;
  66.     NWDIR_HANDLE         dirHandle;
  67.     NWCONN_HANDLE        conn;
  68.     NWVOL_NUM            volNumber;
  69.     NWCCODE                ccode;
  70.     char                    afpPathString[32];
  71.     char                    path[256] = "";
  72.     char                    volName[16];
  73.     char                    serverName[48];
  74.     int                    i;
  75.  
  76.  
  77.     if(argc < 3)
  78.         {
  79.         printf("Usage: AFPMD <server\path> <directory name> \n");
  80.         printf("       server\path= servername\sys:\n");
  81.       printf("       directory name= Whatever you want the name to be\n");
  82.  
  83.         exit(1);
  84.         }
  85.  
  86.     strcpy(afpPathString + 1, argv[2]);
  87.     for (i = 3; i < argc; i++)
  88.         {
  89.         strcat(afpPathString + 1, " ");
  90.         strcat(afpPathString + 1, argv[i]);
  91.         }
  92.  
  93.     afpPathString[0] = strlen(afpPathString + 1);
  94.  
  95.     ccode = NWCallsInit(NULL, NULL);
  96.     if (ccode)
  97.         {
  98.         printf("\nNWCallsInit returned %04X\n", ccode);
  99.         exit(1);
  100.         }
  101.  
  102.  
  103.     strupr(argv[1]);
  104.     ccode = NWParseNetWarePath(
  105.            /* > path to parse                        */ argv[1],
  106.            /* < server connection Handle             */ &conn,
  107.            /* < directory Handle                     */ &dirHandle,
  108.            /* <new path relative to directory Handle */ path);
  109.  
  110.     if (ccode)
  111.         {
  112.         printf("\nNWParseNetWarePath returned %04X\n", ccode);
  113.         exit(1);
  114.         }
  115.  
  116.     ccode = NWParsePath(
  117.               /* > Path to parse                */ path,
  118.               /* < server name (optional)       */ serverName,
  119.               /* < connection handle (optional) */ NULL,
  120.               /* < volume name (optional)       */ volName,
  121.               /* < directory path (optional)    */ NULL);
  122.  
  123.     if (ccode)
  124.         {
  125.         printf("\nNWParsePath returned %04X\n", ccode);
  126.         exit(1);
  127.         }
  128.  
  129.     printf("\nVolume name = %s\n", volName);
  130.  
  131.     ccode = NWGetVolumeNumber(
  132.               /* > connection Handle    */ conn,
  133.               /* > volume name          */ volName,
  134.               /* < volume Number        */ &volNumber);
  135.  
  136.     printf("\nVolume number = %d\n", volNumber);
  137.  
  138.  
  139.     printf("\nFile Server name associated with this handle %s\n", serverName);
  140.  
  141.     ccode = NWAFPGetEntryIDFromPathName(
  142.            /* > connection handle  */ conn,
  143.            /* > directory handle   */ dirHandle,
  144.            /* > path               */ path, 
  145.            /* < AFP base ID        */ &entryID1);
  146.  
  147.     if (ccode)
  148.         {
  149.         printf("\nNWAFPGetEntryIDFromPathName returned %04X\n", ccode);
  150.         exit(1);
  151.         }
  152.  
  153.  
  154.     ccode = NWAFPCreateDirectory(
  155.            /* > connection Handle                */ conn,
  156.            /* > volume number                    */ volNumber,
  157.            /* > AFP base ID                      */ entryID1,
  158.            /* > pointer to finder info           */ &finderInfo,
  159.               /* > AFP dir path relative to entryID */ afpPathString,
  160.            /* < ID of newly created directory    */ &entryID2);
  161.  
  162.     printf("\nDirectory name is : %s\t Length = %d\n", 
  163.            (afpPathString + 1), afpPathString[0]);
  164.  
  165.     if (ccode)
  166.         {
  167.         printf("Unable to create \"%s\".\n CCODE = %04X", 
  168.               (afpPathString + 1), ccode);
  169.         exit(1);
  170.         }
  171.  
  172.     printf("Directory \"%s\" created successfully. \n", afpPathString + 1);
  173.  
  174. }
  175.