#ifndef lint
static char rcsid[] = "$Id: byteorder.c,v 1.5 1994/07/15 11:02:36 gkim Exp $";
#endif

#include "../include/config.h"
#include <stdio.h>
#ifdef STDLIBH
#include <stdlib.h>
#endif

/*
 * byteorder.c
 *
 *	lifted and hacked from Larry Wall's Configure program.
 *
 * Gene Kim
 * Purdue University
 * October 14, 1992
 */

void header_print();

void
main()
{
    int i;
    union {
	uint32 l;
	char c[sizeof(int32)];
    } u;

    /* print out machine-generated banner for .h file */
    header_print();

    if (sizeof(int32) > 4)
	u.l = (0x08070605L << 32) | 0x04030201L;
    else
	u.l = 0x04030201L;

    (void)printf("#define BYTEORDER 0x");
    for (i=0; i < sizeof(int32); i++)
	(void)printf("%c",u.c[i]+'0');
    (void)printf("\n");

    exit(0);
    /*NOTREACHED*/
}

void
header_print()
{
    printf("/*\n");
    printf(" * byteorder.h\n");
    printf(" *\n");
    printf(" * 	Do not modify this file.  This file was automatically \n");
    printf(" * 	generated by the Tripwire makefile.\n");
    printf(" *\n");
    printf(" */\n");
    printf("\n");
}
