=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/io.c,v retrieving revision 1.11 retrieving revision 1.15 diff -u -p -r1.11 -r1.15 --- OpenXM_contrib2/asir2000/io/io.c 2003/03/07 03:12:28 1.11 +++ OpenXM_contrib2/asir2000/io/io.c 2015/08/04 06:20:45 1.15 @@ -44,12 +44,12 @@ * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. - * $OpenXM: OpenXM_contrib2/asir2000/io/io.c,v 1.10 2003/02/14 22:29:15 ohara Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/io.c,v 1.14 2009/03/16 16:43:03 ohara Exp $ */ #include #include "ca.h" #include "parse.h" -#if defined(VISUAL) || MPI +#if defined(VISUAL) || defined(MPI) #include "wsio.h" #endif @@ -141,7 +141,7 @@ int gen_fread (char *ptr,int size,int nitems,FILE *str if ( _fileno(stream) < 0 ) n = cread(ptr,size,nitems,(STREAM *)stream); else -#elif MPI +#elif defined(MPI) if ( (char)fileno(stream) < 0 ) n = cread(ptr,size,nitems,(STREAM *)stream); else @@ -175,7 +175,7 @@ int gen_fwrite (char *ptr,int size,int nitems,FILE *st if ( _fileno(stream) < 0 ) return cwrite(ptr,size,nitems,(STREAM *)stream); else -#elif MPI +#elif defined(MPI) if ( (char)fileno(stream) < 0 ) return cwrite(ptr,size,nitems,(STREAM *)stream); else @@ -210,7 +210,20 @@ void write_int(FILE *f,unsigned int *p) gen_fwrite((char *)p,sizeof(unsigned int),1,f); } -#if defined(VISUAL) && defined(DES_ENC) +void write_int64(FILE *f,UL *p) +{ + unsigned int t; + + if ( little_endian && (ox_file_io || ox_need_conv) ) { + t = htonl(((unsigned int *)p)[1]); + gen_fwrite((char *)&t,sizeof(unsigned int),1,f); + t = htonl(((unsigned int *)p)[0]); + gen_fwrite((char *)&t,sizeof(unsigned int),1,f); + } else + gen_fwrite((char *)p,sizeof(UL),1,f); +} + +#if defined(DES_ENC) int des_encryption; static unsigned char asir_deskey[8] = {0xc7,0xe0,0xfc,0xb5,0xc3,0xad,0x8e,0x3a}; static unsigned char deskey_string[96]; @@ -230,7 +243,7 @@ void write_intarray(FILE *f,unsigned int *p,int l) { int i; unsigned int t; -#if defined(VISUAL) && defined(DES_ENC) +#if defined(DES_ENC) int l2; unsigned int plain[2],encrypted[2]; @@ -263,7 +276,8 @@ void write_intarray(FILE *f,unsigned int *p,int l) gen_fwrite((char *)p,sizeof(unsigned int),l,f); } -#if defined(LONG_IS_64BIT) +#if SIZEOF_LONG == 8 +/* write l longword (1longword=8bytes) */ void write_longarray(FILE *f,unsigned long *p,int l) { int i; @@ -319,10 +333,23 @@ void read_int(FILE *f,unsigned int *p) *p = ntohl(*p); } +void read_int64(FILE *f,UL *p) +{ + unsigned int t; + + if ( little_endian && (ox_file_io || ox_need_conv) ) { + gen_fread((char *)&t,sizeof(unsigned int),1,f); + ((unsigned int *)p)[1] = ntohl(t); + gen_fread((char *)&t,sizeof(unsigned int),1,f); + ((unsigned int *)p)[0] = ntohl(t); + } else + gen_fread((char *)p,sizeof(UL),1,f); +} + void read_intarray(FILE *f,unsigned int *p,int l) { int i; -#if defined(VISUAL) && defined(DES_ENC) +#if defined(DES_ENC) int l2; unsigned int plain[2],encrypted[2]; @@ -353,7 +380,8 @@ void read_intarray(FILE *f,unsigned int *p,int l) } } -#if defined(LONG_IS_64BIT) +#if SIZEOF_LONG == 8 +/* read l word (1word=4bytes) */ void read_longarray(FILE *f,unsigned long *p,int l) { int i;