home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / CNFIG218.ZIP / NETINFO.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1992-10-26  |  8.5 KB  |  200 lines

  1. unit netInfo;
  2. {
  3. written by Michael D. McCall  ==>  M-McCall@bgu.edu
  4. }
  5. interface
  6.  
  7. FUNCTION netInformation (var connectionNumber  : byte;
  8.                          var socketNumber      : word;    {hi-lo}
  9.                          var nodeAddress       : string;
  10.                          var netAddress        : string;
  11.                          var userID            : string;
  12.                          var fullName          : string;
  13.                          var year              : byte;
  14.                          var month             : byte;
  15.                          var day               : byte;
  16.                          var hour              : byte;
  17.                          var minute            : byte) : byte;
  18.  
  19. implementation
  20.  
  21. CONST
  22.   HexCh : array[0..15] of char = '0123456789ABCDEF'; {Used by Hex functions}
  23.  
  24. VAR
  25.   dta : array [0..511] of byte;
  26.  
  27. FUNCTION netInformation (var connectionNumber  : byte;
  28.                          var socketNumber      : word;
  29.                          var nodeAddress       : string;
  30.                          var netAddress        : string;
  31.                          var userID            : string;
  32.                          var fullName          : string;
  33.                          var year              : byte;
  34.                          var month             : byte;
  35.                          var day               : byte;
  36.                          var hour              : byte;
  37.                          var minute            : byte) : byte;
  38.  
  39. VAR
  40.   requestBuffer : string absolute dta;
  41.   connectionInformationReplyBuffer : record
  42.       length : word;                     {lo-hi}
  43.       objectID : array [1..4] of byte;   {hi-lo}
  44.       objectType : byte;  {really a word, but second byte is used as
  45.                            length byte for following string}
  46.       objectName : string [48];          {ASCIIz string format}
  47.       year : byte;                       {0..99}
  48.       month : byte;                      {1..12}
  49.       day : byte;                        {1..31}
  50.       hour : byte;                       {0..23}
  51.       minute : byte;                     {0..59}
  52.       second : byte;                     {0..59}
  53.       dayOfWeek : byte;                  {0..6, 0=Sunday}
  54.       end absolute dta;
  55.   fullNameReplyBuffer : record
  56.       length : byte;      {really a word in lo-hi format but the second
  57.                byte is used for length of following string}
  58.       name : string [128];               {ASCIIz string format}
  59.       moreSegments : byte;               {FF=true, 00=false}
  60.       propertyFlags : byte;              {1=set, 0=item}
  61.       end absolute dta;
  62.   internetAddressReplyBuffer : record
  63.       length : word;                         {lo-hi}
  64.       netAddress : array [1..4] of byte;     {hi-lo}
  65.       nodeAddress : array [1..6] of byte;    {hi-lo}
  66.       socketNumber : word;                   {hi-lo}
  67.       end absolute dta;
  68.  
  69.   highestCompletionCode : byte;
  70.   ii : byte;
  71.  
  72.   begin { netInformation }
  73.  
  74.   {********************************************************************}
  75.   { Get connection number of user logged into station making the call. }
  76.   {********************************************************************}
  77.  
  78.   inline (
  79.     $B4/$DC/                { mov ah, dc                        }
  80.     $CD/$21/                { int 21                            }
  81.     $A2/dta);               { mov dta [0], al                   }
  82.     {
  83.     The connection number is returned via AL and is stored in completionCode.
  84.     }
  85.  
  86.     connectionNumber := dta [0];
  87.  
  88.   {********************************************************************}
  89.   { Get login name & time of user logged into station making the call. }
  90.   {********************************************************************}
  91.  
  92.                      { lo order byte is requestBuffer [0] }
  93.     requestBuffer := { hi order byte of length of buffer }          #0   +
  94.                      { get connection information is sub function } #$16 +
  95.                                                    chr (connectionNumber);
  96.  
  97.   inline (
  98.     $1E/                    { push ds                            }
  99.     $07/                    { pop es                             }
  100.     $BE/dta/                { mov si, offset of requestBuffer    }
  101.     $BF/dta/                { mov di, offset of replyBuffer      }
  102.     $B4/$E3/                { mov ah,E3                          }
  103.     $CD/$21/                { int 21                             }
  104.     $A2/dta);               { mov dta [0], al                    }
  105.  
  106.   highestCompletionCode := dta [0];
  107.   if dta [0] = 0 then
  108.     begin {if}
  109.       year := connectionInformationReplyBuffer.year;
  110.       month := connectionInformationReplyBuffer.month;
  111.       day := connectionInformationReplyBuffer.day;
  112.       hour := connectionInformationReplyBuffer.hour;
  113.       minute := connectionInformationReplyBuffer.minute;
  114.       for ii := 1 to 48 do
  115.         if connectionInformationReplyBuffer.objectName [ii] = #0 then
  116.           begin {if}
  117.             connectionInformationReplyBuffer.objectName [0] := chr(ii - 1);
  118.             ii := 48
  119.           end; {if}
  120.       userID := connectionInformationReplyBuffer.objectName;
  121.     end; {if}
  122.  
  123.  
  124.   {********************************************************************}
  125.   { Get full name of user logged into station making the call.         }
  126.   {********************************************************************}
  127.  
  128.                    {lo order byte is requestBuffer [0]  }
  129.   requestBuffer := {hi order byte of length of buffer   } #0 +
  130.                    {read property value sub function    } #$3D +
  131.                    {hi order byte of bindery object type} #0 +
  132.                    {lo order byte of bindery object type} #1 +
  133.                    {length of object name               } userID [0] +
  134.                    {must be in upper case               } userID +
  135.                    {segment number of property          } #1 +
  136.                    {property name length                } #14 +
  137.                    {Novell property name                } 'IDENTIFICATION';
  138.  
  139.   inline(
  140.     $1E/                 {push ds                            }
  141.     $07/                 {pop es                             }
  142.     $BE/dta/             {mov si, offset of requestBuffer    }
  143.     $BF/dta/             {mov di, offset of replyBuffer      }
  144.     $B4/$E3/             {mov ah,E3                          }
  145.     $CD/$21/             {int 21                             }
  146.     $A2/dta);            {mov dta [0], al                    }
  147.  
  148.   if dta [0] > highestCompletionCode then
  149.       highestCompletionCode := dta [0];
  150.   if dta [0] = 0 then
  151.     begin {if}
  152.       for ii := 1 to 128 do
  153.         if fullNameReplyBuffer.name [ii] = #0 then
  154.           begin {if}
  155.             fullNameReplyBuffer.name [0] := chr(ii - 1);
  156.             ii := 128;
  157.           end; {if}
  158.         fullName := fullNameReplyBuffer.name;
  159.     end; {if}
  160.  
  161.   {********************************************************************}
  162.   { Get internetwork address of station making the call.               }
  163.   {********************************************************************}
  164.  
  165.                      { lo order byte is requestBuffer [0] }
  166.     requestBuffer := { hi order byte of length of buffer }          #0 +
  167.                      { get internet address is sub function }     #$13 +
  168.                                                  chr (connectionNumber);
  169.  
  170.   inline (
  171.     $1E/                    { push ds                            }
  172.     $07/                    { pop es                             }
  173.     $BE/dta/                { mov si, offset of requestBuffer    }
  174.     $BF/dta/                { mov di, offset of replyBuffe       }
  175.     $B4/$E3/                { mov ah,E3                          }
  176.     $CD/$21/                { int 21                             }
  177.     $A2/dta);               { mov dta [0], al                    }
  178.  
  179.   if dta [0] > highestCompletionCode then
  180.       highestCompletionCode := dta [0];
  181.   if dta [0] = 0 then
  182.     begin {if}
  183.       netAddress := '';
  184.       for ii := 1 to 4 do
  185.         netAddress := netAddress +
  186.                 hexCh [internetAddressReplyBuffer.netAddress [ii] SHR 4] +
  187.         hexCh [internetAddressReplyBuffer.netAddress [ii] AND $0F];
  188.       nodeAddress := '';
  189.       for ii := 1 to 6 do
  190.         nodeAddress := nodeAddress +
  191.         hexCh [internetAddressReplyBuffer.nodeAddress [ii] SHR 4] +
  192.                 hexCh [internetAddressReplyBuffer.nodeAddress [ii] AND $0F];
  193.       socketNumber := internetAddressReplyBuffer.socketNumber;
  194.     end; {if}
  195.  
  196.   netInformation := highestCompletionCode;
  197.  
  198.   end; { netInformation }
  199.  
  200. end.