www.pudn.com > tdi_fw.rar > sock.c, change:2009-04-28,size:1046b


/* Copyright (c) 2002-2005 Vladislav Goncharov. 
 * 
 * Redistribution and use in source forms, with and without modification, 
 * are permitted provided that this entire comment appears intact. 
 * 
 * Redistribution in binary form may occur without any restrictions. 
 * 
 * This software is provided ``AS IS'' without any warranties of any kind. 
 */ 
  
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs) 
// 
// $Id: sock.c,v 1.1 2009/04/28 12:53:28 tanwen Exp $ 
 
/* 
 * Some helpers from sockets 
 */ 
 
#include <stdlib.h> 
#include <string.h> 
#include "sock.h" 
 
u_long 
ntohl (u_long netlong) 
{ 
	u_long result = 0; 
	((char *)&result)[0] = ((char *)&netlong)[3]; 
	((char *)&result)[1] = ((char *)&netlong)[2]; 
	((char *)&result)[2] = ((char *)&netlong)[1]; 
	((char *)&result)[3] = ((char *)&netlong)[0]; 
	return result; 
} 
 
u_short 
ntohs (u_short netshort) 
{ 
	u_short result = 0; 
	((char *)&result)[0] = ((char *)&netshort)[1]; 
	((char *)&result)[1] = ((char *)&netshort)[0]; 
	return result; 
}