/* * converto * -------- * * Convert Endiannness of an OMEGA 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> stgf.x < dstgf * sun> scp OMEAGU user@linux:OMEAGU.SUN * sun> ssh linux * * linux> converth OMEAGU.SUN OMEAGU * linux> xtrct.x * * Written: Allan Whiteford * 16-Jun-2008 * */ #include #include FILE *fold, *fnew; int is_little=-1; int me_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); } double get_float() { unsigned char old[8],new[8]; int i,j; int cnt; double *num; void *tst; fread(&old,1,8,fold); for (i=0;i<=7;i++) new[7-i]=old[i]; if (me_little==is_little) num=(void *) &new; else num=(void *) &old; fwrite(&new,1,8,fnew); return *num; } int do_integer(int total) { unsigned char old[4],new[4]; int i,j; for (j=0;j=enat[j-1]) nopen=(j*(j-2*(nzed!=nelc)+1))/2; } if (nomwrt > 0) nopen=nomt; /* printf("%f %d\n",e,nopen); */ do_float(nopen); do_size(0,nopen+1); /* printf("hello %d %d\n",i,mxe); */ } free(enat); fclose(fold); fclose(fnew); }