/* * converth * -------- * * Convert Endiannness of an H.DAT File * Takes as command line input the original file * and the new file. * * This program is independent of system * architecture so can be run on either the * system which produced the H.DAT or the system * which is going to utilise the H.DAT file. * * Example: * * sun> stg3r.x < dstg3 * sun> scp H.DAT user@linux:H.SUN * sun> ssh linux * * linux> converth H.SUN H.DAT * linux> stgf.x < dstgf * * Written: Allan Whiteford * 02-Jul-2007 * */ #include FILE *fold, *fnew; int is_little=-1; #define float_block(N) do_size(0,N); do_float(N); do_size(0,N); #define integer_block(N) do_size(N,0); do_integer(N); do_size(N,0); int get_integer() { unsigned char old[4],new[4]; unsigned int cnt; int a,i; a=fread(&old,1,4,fold); for (i=0;i<=3;i++) { new[3-i]=old[i]; } if (is_little==1) cnt = old[0]+256*old[1]+65536*old[2]+16777216*old[3]; if (is_little==0) cnt = old[3]+256*old[2]+65536*old[1]+16777216*old[0]; a=fwrite(&new,1,4,fnew); return(cnt); } int do_integer(int total) { unsigned char old[4],new[4]; int i,j; for (j=0;j