www.pudn.com > tdi_fw.zip > sock.c
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs) // // $Id: sock.c,v 1.2 2002/12/03 12:14:28 dev Exp $ /* * Some helpers from sockets */ #include#include #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; }