=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/io.c,v retrieving revision 1.14 retrieving revision 1.16 diff -u -p -r1.14 -r1.16 --- OpenXM_contrib2/asir2000/io/io.c 2009/03/16 16:43:03 1.14 +++ OpenXM_contrib2/asir2000/io/io.c 2015/08/06 10:01:52 1.16 @@ -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.13 2009/03/13 04:45:16 ohara Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/io.c,v 1.15 2015/08/04 06:20:45 noro Exp $ */ #include #include "ca.h" #include "parse.h" -#if defined(VISUAL) || defined(MPI) +#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) || defined(MPI) #include "wsio.h" #endif @@ -102,7 +102,7 @@ void ox_copy_init(char *s) ox_copy_bptr = s; } -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) /* * library mode functions * byte order is controlled by lib_ox_need_conv. @@ -137,7 +137,7 @@ int gen_fread (char *ptr,int size,int nitems,FILE *str /* dummy return */ return 0; } else { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) if ( _fileno(stream) < 0 ) n = cread(ptr,size,nitems,(STREAM *)stream); else @@ -171,7 +171,7 @@ int gen_fwrite (char *ptr,int size,int nitems,FILE *st /* dummy return */ return 0; } else -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) if ( _fileno(stream) < 0 ) return cwrite(ptr,size,nitems,(STREAM *)stream); else @@ -210,6 +210,19 @@ void write_int(FILE *f,unsigned int *p) gen_fwrite((char *)p,sizeof(unsigned int),1,f); } +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}; @@ -264,6 +277,7 @@ void write_intarray(FILE *f,unsigned int *p,int l) } #if SIZEOF_LONG == 8 +/* write l longword (1longword=8bytes) */ void write_longarray(FILE *f,unsigned long *p,int l) { int i; @@ -319,6 +333,19 @@ 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; @@ -354,6 +381,7 @@ void read_intarray(FILE *f,unsigned int *p,int l) } #if SIZEOF_LONG == 8 +/* read l word (1word=4bytes) */ void read_longarray(FILE *f,unsigned long *p,int l) { int i;