/* TU hton */
#include "ed/inc/hton.h"
#include "ed/inc/sys.h"

int main (void)
{
   unsigned host_u = 0xDEAD;
   unsigned long host_ul = 0xDEADBEEFUL;

   printf ("host_u  = %X\n", host_u);
   printf ("host_ul = %lX\n", host_ul);

   puts ("Host");

   SYS_dump (&host_u, sizeof host_u);
   SYS_dump (&host_ul, sizeof host_ul);

   {
      unsigned net_u = htons (host_u);
      unsigned long net_ul = htonl (host_ul);

      puts ("Network");

      SYS_dump (&net_u, sizeof net_u);
      SYS_dump (&net_ul, sizeof net_ul);

      host_u = ntohs (net_u);
      host_ul = ntohl (net_ul);

      puts ("Host");

      SYS_dump (&host_u, sizeof host_u);
      SYS_dump (&host_ul, sizeof host_ul);

      printf ("host_u  = %04X\n", host_u);
      printf ("host_ul = %08lX\n", host_ul);
   }

   puts ("");

   {
      uchar net[8];

      nwrites (net, host_u);
      SYS_dump (net, 2);
      host_u = nreads (net);
      printf ("host_u  = %04X\n", host_u);

      nwritel (net, host_ul);
      SYS_dump (net, 4);
      host_ul = nreadl (net);
      printf ("host_ul = %08lX\n", host_ul);
   }


   return 0;
}
