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

  1. /*
  2.  *    OS/2 Lan Manager NET Api calls for 
  3.  *      using named pipes version of c-tree server
  4.  *
  5.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  6.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  7.  *    transfer of this program is strictly prohibited.
  8.  *
  9.  *      Copyright (c) 1987, 1988, 1989 FairCom Corporation
  10.  *    (Subject to limited distribution and
  11.  *     restricted disclosure only.)
  12.  *    *** ALL RIGHTS RESERVED ***
  13.  *
  14.  *    4006 West Broadway
  15.  *    Columbia, MO 65203
  16.  *
  17.  *
  18.  *    c-tree(R)    Version 4.3
  19.  *            Release C
  20.  *            February 7, 1989 17:30
  21.  *
  22.  */
  23.  
  24. #include <net\netcons.h>
  25. #include <net\neterr.h>
  26. #include <net\wksta.h>
  27.  
  28. #include <stdlib.h>
  29. #include <stdio.h>
  30. #include <string.h>
  31. #include <malloc.h>
  32.  
  33. #include "ctpipes.h"
  34.  
  35. static char   username[UNLEN+1];
  36.  
  37. char* get_net_user_name()
  38. {
  39. unsigned short totalavail;  /* size of avail info */
  40. struct wksta_info_0 *wsi;   /* wksta_info_0 */
  41. int retval;
  42.  
  43.    username[0] = '\0';
  44.    /* get total size of available information */
  45.    /* This is done because of the funny way  NetWkstaGetInfo is
  46.       imlemented. returning a struct with far pointers to the memory
  47.       behind the struct. If you not have reserved a large enough buffer
  48.       no info is supplied */ 
  49.    retval = NetWkstaGetInfo (0L, 0, 0L, 0, &totalavail);
  50.    wsi = (struct wksta_info_0*)alloca((size_t)totalavail);
  51.    if (!wsi)
  52.       return (username);
  53.    retval = NetWkstaGetInfo (0L, 0,              /* this server, infolevel */
  54.                              (char far *)wsi,    /* buffer */
  55.                              totalavail,         /* size of buffer */
  56.                              &totalavail);       /* size of available info */
  57.    if (!retval) { /* if successful call to Net */
  58.       /* copy char far* ASCIZ string to char near buffer */
  59.       stfarmov(wsi->wki0_username,(char far*)username,0);
  60.       /* cpybuf(username, wsi->wki0_username, len+1);*/
  61.    }
  62.    return (username);
  63.  
  64. } /* end get_net_user_name */
  65.  
  66.  
  67. char* get_net_computer_name()
  68. {
  69. unsigned short totalavail;  /* size of avail info */
  70. struct wksta_info_0 *wsi;   /* wksta_info_0 */
  71. int retval;
  72.  
  73.    username[0] = '\0';
  74.    /* get total size of available information */
  75.    /* This is done because of the funny way  NetWkstaGetInfo is
  76.       imlemented. returning a struct with far pointers to the memory
  77.       behind the struct. If you not have reserved a large enough buffer
  78.       no info is supplied */ 
  79.    retval = NetWkstaGetInfo (0L, 0, 0L, 0, &totalavail);
  80.    wsi = (struct wksta_info_0*)alloca((size_t)totalavail);
  81.    if (!wsi)
  82.       return (username);
  83.    retval = NetWkstaGetInfo (0L, 0,              /* this server, infolevel */
  84.                              (char far *)wsi,    /* buffer */
  85.                              totalavail,         /* size of buffer */
  86.                              &totalavail);       /* size of available info */
  87.    if (!retval) { /* if successful call to Net */
  88.       /* copy char far* ASCIZ string to char near buffer */
  89.       stfarmov(wsi->wki0_computername,(char far*)username,0);
  90.       /* cpybuf(username, wsi->wki0_computername, len+1);*/
  91.    }
  92.    return (username);
  93.  
  94. } /* end get_net_computer_name */
  95.  
  96.  
  97.  
  98.