home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_11 / 2n11067a < prev    next >
Text File  |  1991-09-06  |  2KB  |  67 lines

  1. /* Written for Borland C */
  2.  
  3. #include <stdio.h>
  4. #include <dos.h>
  5.  
  6. struct                 /* Get Connection Info request struct */
  7. {
  8.   int  length;         /* length of request buffer */
  9.   char sfunction;      /* subfunction number */
  10.   char connection;     /* connection number */
  11. } gci_req;
  12.  
  13. struct                 /* Get Connection Info reply struct */
  14. {
  15.   int  length;         /* length of reply buffer */
  16.   long objectid;       /* Bindery ID */             /* hi-lo! */
  17.   int  objecttype;     /* type of bindery object */ /* hi-lo! */
  18.                        /* 1=USER, 2=GROUP, 3=PRINT SERVER, etc. */
  19.   char objectname[48]; /* name of bindery object */
  20.   char log_year;       /* (80 = 1980, < 80 = 21st century) */
  21.   char log_month;      /* 1..12 */
  22.   char log_day;        /* 1..31 */
  23.   char log_hour;       /* 0..23 */
  24.   char log_min;        /* 0..59 */
  25.   char log_sec;        /* 0..59 */
  26.   char log_daynum;     /* 0..6 (0 = Sunday) */
  27.   char filler;
  28. } gci_rep;
  29.  
  30. struct REGPACK r;      /* make 80x86 registers available */
  31.  
  32. int main(void)
  33. {
  34.   /* Borland-specific; uses pseudoregister _DS */
  35.   r.r_ds = _DS;
  36.   r.r_es = _DS;
  37.  
  38.   r.r_ax = 0xDC00;
  39.   intr(0x21,&r);       /* Get connection number */
  40.  
  41.   gci_req.connection = (char) (r.r_ax & 0x00FF);
  42.   if (gci_req.connection > 0)
  43.   {
  44.     gci_req.sfunction = 0x16;
  45.     gci_req.length    = sizeof(gci_req);
  46.     gci_rep.length    = sizeof(gci_rep);
  47.     r.r_si = (int)&gci_req;
  48.     r.r_di = (int)&gci_rep;
  49.     r.r_ax = 0xE300;
  50.     intr(0x21,&r);     /* Get connection info */
  51.  
  52.     if (gci_rep.objectname[0] != '\0')
  53.       printf("%s has NetWare connection #%d.\n",
  54.           gci_rep.objectname,gci_req.connection);
  55.     else
  56.       gci_req.connection = 0;
  57.   }
  58.  
  59.   if (gci_req.connection == 0)
  60.   {
  61.     puts("You're not logged in to a NetWare LAN.");
  62.     return(1);
  63.   }
  64.  
  65.   return(0);
  66. }
  67.