home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / afpmfl.exe / AFPMF.C next >
Text File  |  1995-06-05  |  6KB  |  183 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:AFPMF.C   
  22. **
  23. **   Desc: This program will create a MACINTOSH file in a mac directory.  
  24. **
  25. **        
  26. **   Programmers:
  27. **   Ini   Who         Firm
  28. **   ------------------------------------------------------------------
  29. **   ARM   A. Ray Maxwell     Novell Developer Support.
  30. **
  31. **   History:
  32. **
  33. **   ------------------------------------------------------------------
  34. **   02-13-94   ARM   First code.
  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>           /* printf()              */
  46.    #include <string.h>          /* strcpy()              */
  47.    #include <conio.h>           /* clrscr()              */
  48.    #include <mem.h>             /* memset()              */
  49.    /*------------------------------------------------------------------
  50.    **   NetWare
  51.    */
  52.    #include <nwcalls.h>      
  53.  
  54.  
  55.  
  56. #include <stdio.h>
  57. #include <stdlib.h>
  58. #include <string.h>
  59. #include <nwcalls.h>
  60.  
  61. /****************************************************************************
  62. **   Program Start
  63. */
  64. void main(int argc, char *argv[])
  65. {
  66.    NWAFP_FILE_INFO    fileInfo;
  67.    NWAFP_ENTRY_ID     entryID1, entryID2;
  68.    NWDIR_HANDLE       dirHandle;
  69.    NWCONN_HANDLE      conn;
  70.    NWVOL_NUM          volNumber;
  71.    NWCCODE            ccode;
  72.    char               AFPPathString[32];
  73.    char               path[256] = "";
  74.    char               volName[16];
  75.    char               serverName[48];
  76.    int                i;
  77.  
  78.  
  79.    if(argc < 3){
  80.       clrscr();
  81.       printf("Usage: AFPMF <server\\path> <file name>\n");
  82.       printf("       server\path : servername\\volume:dir\\dir...\n");
  83.       printf("       file name   : test file name\n");
  84.  
  85.       exit(1);
  86.    }
  87.  
  88.    strcpy(AFPPathString + 1, argv[2]);
  89.    for (i = 3; i < argc; i++){
  90.       strcat(AFPPathString + 1, " ");
  91.       strcat(AFPPathString + 1, argv[i]);
  92.    }
  93.  
  94.    AFPPathString[0] = strlen(AFPPathString + 1);
  95.  
  96.    ccode = NWCallsInit(NULL, NULL);
  97.    if (ccode){
  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.       printf("\nNWParseNetWarePath returned %04X\n", ccode);
  112.       exit(1);
  113.    }
  114.  
  115.    ccode = NWParsePath(
  116.            /* > Path to parse                */ path,
  117.            /* < server name (optional)       */ serverName,
  118.            /* < connection handle (optional) */ NULL,
  119.            /* < volume name (optional)       */ volName,
  120.            /* < directory path (optional)    */ NULL);
  121.  
  122.    if (ccode){
  123.       printf("\nNWParsePath returned %04X\n", ccode);
  124.       exit(1);
  125.    }
  126.  
  127.    printf("\nVolume name = %s\n", volName);
  128.  
  129.    ccode = NWGetVolumeNumber(
  130.            /* > connection Handle    */ conn,
  131.            /* > volume name          */ volName,
  132.            /* < volume Number        */ &volNumber);
  133.  
  134.    printf("\nVolume number = %d\n", volNumber);
  135.  
  136.  
  137.    printf("\nFile Server name associated with this handle %s\n", serverName);
  138.       
  139.  
  140.    ccode = NWAFPGetEntryIDFromPathName(
  141.            /* > connection handle  */ conn,
  142.            /* > directory handle   */ dirHandle,
  143.            /* > path               */ path, 
  144.            /* < AFP base ID        */ &entryID1);
  145.    if (ccode){
  146.       printf("\nNWAFPGetEntryIDFromPathName returned %04X\n", ccode);
  147.       exit(1);
  148.    }
  149.    
  150.    memset(&fileInfo,'\0',sizeof(fileInfo));
  151.  
  152.    strcpy(fileInfo.finderInfo,"This is test finder information");
  153.    fileInfo.entryID=entryID1;
  154.    fileInfo.parentID=entryID1;
  155.    fileInfo.dataForkLength=0x20;
  156.    fileInfo.resourceForkLength=0x40;
  157.  
  158.  
  159.    ccode=NWAFPCreateFile(
  160.          /* > connection handle                       */ conn,
  161.          /* > Volume Number                           */ volNumber,
  162.          /* > AFP base ID                             */ entryID1,
  163.          /* > delete existinf file 0= do not delete   */ 1,
  164.          /* > points to NW_AFP_FILE_INFO              */ &fileInfo,
  165.          /* > points to AFP stype directory path rel-
  166.               ative to entryID2                       */ AFPPathString,
  167.          /* < new AFPEntryID                          */ &entryID2);
  168.    if (ccode){
  169.       printf("Unable to create \"%s\".\n",AFPPathString);
  170.       exit(1);
  171.    }
  172.  
  173.    printf("\nFile name is : %s\t Length = %d\n", (AFPPathString + 1), AFPPathString[0]);
  174.  
  175.    if (ccode){
  176.       printf("Unable to create \"%s\".\n CCODE = %04X", (AFPPathString + 1), ccode);
  177.       exit(1);
  178.    }
  179.  
  180.    printf("File \"%s\" created successfully. \n", AFPPathString + 1);
  181.  
  182. }
  183.