version 1.11, 2003/03/07 03:12:28 |
version 1.16, 2015/08/06 10:01:52 |
|
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* 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.15 2015/08/04 06:20:45 noro Exp $ |
*/ |
*/ |
#include <stdio.h> |
#include <stdio.h> |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#if defined(VISUAL) || MPI |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) || defined(MPI) |
#include "wsio.h" |
#include "wsio.h" |
#endif |
#endif |
|
|
Line 102 void ox_copy_init(char *s) |
|
Line 102 void ox_copy_init(char *s) |
|
ox_copy_bptr = s; |
ox_copy_bptr = s; |
} |
} |
|
|
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) |
/* |
/* |
* library mode functions |
* library mode functions |
* byte order is controlled by lib_ox_need_conv. |
* byte order is controlled by lib_ox_need_conv. |
Line 137 int gen_fread (char *ptr,int size,int nitems,FILE *str |
|
Line 137 int gen_fread (char *ptr,int size,int nitems,FILE *str |
|
/* dummy return */ |
/* dummy return */ |
return 0; |
return 0; |
} else { |
} else { |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
if ( _fileno(stream) < 0 ) |
if ( _fileno(stream) < 0 ) |
n = cread(ptr,size,nitems,(STREAM *)stream); |
n = cread(ptr,size,nitems,(STREAM *)stream); |
else |
else |
#elif MPI |
#elif defined(MPI) |
if ( (char)fileno(stream) < 0 ) |
if ( (char)fileno(stream) < 0 ) |
n = cread(ptr,size,nitems,(STREAM *)stream); |
n = cread(ptr,size,nitems,(STREAM *)stream); |
else |
else |
Line 171 int gen_fwrite (char *ptr,int size,int nitems,FILE *st |
|
Line 171 int gen_fwrite (char *ptr,int size,int nitems,FILE *st |
|
/* dummy return */ |
/* dummy return */ |
return 0; |
return 0; |
} else |
} else |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
if ( _fileno(stream) < 0 ) |
if ( _fileno(stream) < 0 ) |
return cwrite(ptr,size,nitems,(STREAM *)stream); |
return cwrite(ptr,size,nitems,(STREAM *)stream); |
else |
else |
#elif MPI |
#elif defined(MPI) |
if ( (char)fileno(stream) < 0 ) |
if ( (char)fileno(stream) < 0 ) |
return cwrite(ptr,size,nitems,(STREAM *)stream); |
return cwrite(ptr,size,nitems,(STREAM *)stream); |
else |
else |
Line 210 void write_int(FILE *f,unsigned int *p) |
|
Line 210 void write_int(FILE *f,unsigned int *p) |
|
gen_fwrite((char *)p,sizeof(unsigned int),1,f); |
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; |
int des_encryption; |
static unsigned char asir_deskey[8] = {0xc7,0xe0,0xfc,0xb5,0xc3,0xad,0x8e,0x3a}; |
static unsigned char asir_deskey[8] = {0xc7,0xe0,0xfc,0xb5,0xc3,0xad,0x8e,0x3a}; |
static unsigned char deskey_string[96]; |
static unsigned char deskey_string[96]; |
Line 230 void write_intarray(FILE *f,unsigned int *p,int l) |
|
Line 243 void write_intarray(FILE *f,unsigned int *p,int l) |
|
{ |
{ |
int i; |
int i; |
unsigned int t; |
unsigned int t; |
#if defined(VISUAL) && defined(DES_ENC) |
#if defined(DES_ENC) |
int l2; |
int l2; |
unsigned int plain[2],encrypted[2]; |
unsigned int plain[2],encrypted[2]; |
|
|
Line 263 void write_intarray(FILE *f,unsigned int *p,int l) |
|
Line 276 void write_intarray(FILE *f,unsigned int *p,int l) |
|
gen_fwrite((char *)p,sizeof(unsigned int),l,f); |
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) |
void write_longarray(FILE *f,unsigned long *p,int l) |
{ |
{ |
int i; |
int i; |
Line 319 void read_int(FILE *f,unsigned int *p) |
|
Line 333 void read_int(FILE *f,unsigned int *p) |
|
*p = ntohl(*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) |
void read_intarray(FILE *f,unsigned int *p,int l) |
{ |
{ |
int i; |
int i; |
#if defined(VISUAL) && defined(DES_ENC) |
#if defined(DES_ENC) |
int l2; |
int l2; |
unsigned int plain[2],encrypted[2]; |
unsigned int plain[2],encrypted[2]; |
|
|
Line 353 void read_intarray(FILE *f,unsigned int *p,int l) |
|
Line 380 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) |
void read_longarray(FILE *f,unsigned long *p,int l) |
{ |
{ |
int i; |
int i; |