home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 3.ddi / OS2LAN / CTNETNAM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  2.8 KB  |  100 lines

  1. /*
  2.  *    convert user shared filename to local server file name
  3.  *
  4.  *    uses OS/2 Lan Manager NET Api calls
  5.  *      named pipes version of c-tree server
  6.  *
  7.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  8.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  9.  *    transfer of this program is strictly prohibited.
  10.  *
  11.  *      Copyright (c) 1987, 1988, 1989 FairCom Corporation
  12.  *    (Subject to limited distribution and
  13.  *     restricted disclosure only.)
  14.  *    *** ALL RIGHTS RESERVED ***
  15.  *
  16.  *    4006 West Broadway
  17.  *    Columbia, MO 65203
  18.  *
  19.  *
  20.  *    c-tree(R)    Version 4.3
  21.  *            Release C
  22.  *            February 7, 1989 17:30
  23.  *
  24.  */
  25.  
  26. #include <net\netcons.h>
  27. #include <net\neterr.h>
  28. #include <net\wksta.h>
  29. #include <net\use.h>
  30. #include <net\shares.h>
  31.  
  32. #include <stdlib.h>
  33. #include <stdio.h>
  34. #include <string.h>
  35.  
  36. #include "ctpipes.h"
  37.  
  38. static char full_fil_navn[PATHLEN+1];
  39.  
  40. char *konvert_drive_to_local(char *filename)
  41. {
  42. int ret;           /* return variable for NetServerEnum */
  43. unsigned short avail;         /* size of avail info */
  44. struct use_info_1 *us1;
  45. struct share_info_2 *sh2;
  46. char *cp;
  47. char serv[RMLEN+1],
  48.      name[RMLEN+1],
  49.      shar[NNLEN];
  50. char buffer[256];
  51.  
  52.    strncpy(name,filename,2);
  53.    name[2] = '\0';
  54.    us1 = (struct use_info_1 *)buffer;
  55.    ret = NetUseGetInfo ( 0L,        /* servername (0L=local) */
  56.                          (char far *)name,        /* local name */
  57.                          1,                       /* level of info */
  58.                          (char far *)us1,         /* return buffer */
  59.                          255,                     /* sizeof return buffer */
  60.                          (unsigned short far *)&avail);
  61.    if (ret)
  62.       return 0L;
  63.  
  64.    /* copy char far* ASCIZ string to char near buffer */
  65.    stfarmov(us1->ui1_remote,(char far*)name,0);
  66.    strcpy(serv,name);
  67.    cp = strchr(serv+2,'\\');
  68.    *cp = '\0';
  69.  
  70.    cp = strchr(name+2,'\\');
  71.    strcpy(shar,cp+1);
  72.  
  73.    sh2 = (struct share_info_2 *)buffer;
  74.    ret = NetShareGetInfo ((char far *)serv,        /* servername (0L=local) */
  75.                          shar,                    /* network name */
  76.                          2,                       /* level of info */
  77.                          (char far *)sh2,         /* return buffer */
  78.                          255,                     /* sizeof return buffer */
  79.                          (unsigned short far *)&avail);
  80.  
  81.    if (!ret) {   /* if successful call */
  82.       /* copy char far* ASCIZ string to char near buffer */
  83.       stfarmov(sh2->shi2_path,(char far*)full_fil_navn,0);
  84.       cp = strchr(full_fil_navn,'\0');
  85.       cp--;
  86.       if (*cp != '\\')
  87.          strcat(full_fil_navn,"\\");
  88.       cp = filename+2;
  89.       if (*cp == '\\')
  90.          cp++;
  91.       strcat(full_fil_navn,cp);
  92.       return full_fil_navn;
  93.    }
  94.    else
  95.      return 0L;
  96.  
  97. }
  98.  
  99.  
  100.