Browse Source

* bug/endianfix to hosttonet nettohost

marco 21 years ago
parent
commit
81074127e3
1 changed files with 20 additions and 9 deletions
  1. 20 9
      packages/base/inet/inet.pp

+ 20 - 9
packages/base/inet/inet.pp

@@ -500,19 +500,27 @@ end;
 Function HostToNet (Host : Longint) : Longint;
 Function HostToNet (Host : Longint) : Longint;
 
 
 begin
 begin
-  HostToNet:=THostAddr(host)[1];
-  HostToNEt:=HostTONet or ( (THostAddr(host)[2]) shl 8);
-  HostToNEt:=HostToNet or ( (THostAddr(host)[3]) shl 16);
-  HostToNEt:=HostToNet or ( (THostAddr(host)[4]) shl 24);
+{$ifdef FPC_BIG_ENDIAN}
+  hosttonet:=host;
+{$else}
+  HostToNet:=THostAddr(host)[4];
+  HostToNEt:=HostTONet or ( (THostAddr(host)[3]) shl 8);
+  HostToNEt:=HostToNet or ( (THostAddr(host)[2]) shl 16);
+  HostToNEt:=HostToNet or ( (THostAddr(host)[1]) shl 24);
+{$endif}
 end;
 end;
 
 
 Function NetToHost (Net : Longint) : Longint;
 Function NetToHost (Net : Longint) : Longint;
 
 
 begin
 begin
-  NetToHost:=THostAddr(Net)[1];
-  NetToHost:=NetToHost or ( (THostAddr(Net)[2]) shl 8);
-  NetToHost:=NetToHost or ( (THostAddr(Net)[3]) shl 16);
-  NetToHost:=NetToHost or ( (THostAddr(Net)[4]) shl 24);
+{$ifdef FPC_BIG_ENDIAN}
+  nettohost:=host;
+{$else}
+  NetToHost:=THostAddr(Net)[4];
+  NetToHost:=NetToHost or ( (THostAddr(Net)[3]) shl 8);
+  NetToHost:=NetToHost or ( (THostAddr(Net)[2]) shl 16);
+  NetToHost:=NetToHost or ( (THostAddr(Net)[1]) shl 24);
+{$endif}
 end;
 end;
 
 
 Function ShortHostToNet (Host : Word) : Word;
 Function ShortHostToNet (Host : Word) : Word;
@@ -531,7 +539,10 @@ end.
 
 
 
 
    $Log$
    $Log$
-   Revision 1.3  2003-12-10 12:16:14  marco
+   Revision 1.4  2004-04-10 15:37:57  marco
+    * bug/endianfix to hosttonet nettohost
+
+   Revision 1.3  2003/12/10 12:16:14  marco
     * now uses initc
     * now uses initc
 
 
    Revision 1.2  2002/09/07 15:42:52  peter
    Revision 1.2  2002/09/07 15:42:52  peter