[BACK]Return to io.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / io

Diff for /OpenXM_contrib2/asir2000/io/io.c between version 1.1 and 1.23

version 1.1, 1999/12/03 07:39:11 version 1.23, 2018/03/29 01:32:53
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/asir99/io/io.c,v 1.1.1.1 1999/11/10 08:12:30 noro Exp $ */  /*
    * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
    * All rights reserved.
    *
    * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
    * non-exclusive and royalty-free license to use, copy, modify and
    * redistribute, solely for non-commercial and non-profit purposes, the
    * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
    * conditions of this Agreement. For the avoidance of doubt, you acquire
    * only a limited right to use the SOFTWARE hereunder, and FLL or any
    * third party developer retains all rights, including but not limited to
    * copyrights, in and to the SOFTWARE.
    *
    * (1) FLL does not grant you a license in any way for commercial
    * purposes. You may use the SOFTWARE only for non-commercial and
    * non-profit purposes only, such as academic, research and internal
    * business use.
    * (2) The SOFTWARE is protected by the Copyright Law of Japan and
    * international copyright treaties. If you make copies of the SOFTWARE,
    * with or without modification, as permitted hereunder, you shall affix
    * to all such copies of the SOFTWARE the above copyright notice.
    * (3) An explicit reference to this SOFTWARE and its copyright owner
    * shall be made on your publication or presentation in any form of the
    * results obtained by use of the SOFTWARE.
    * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
    * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
    * for such modification or the source code of the modified part of the
    * SOFTWARE.
    *
    * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
    * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
    * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
    * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
    * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
    * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
    * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
    * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
    * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
    * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
    * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
    * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
    * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
    * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
    * 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.22 2017/08/31 09:11:04 noro Exp $
   */
 #include <stdio.h>  #include <stdio.h>
 #include "ca.h"  #include "ca.h"
 #if defined(VISUAL) || MPI  #include "parse.h"
   #if defined(VISUAL) || defined(__MINGW32__) || defined(MPI)
 #include "wsio.h"  #include "wsio.h"
 #endif  #endif
   
 extern int little_endian;  extern int little_endian,lib_ox_need_conv;
 extern int ox_do_copy, ox_do_count, ox_count_length, ox_file_io, ox_need_conv;  extern int ox_do_copy, ox_do_count, ox_count_length, ox_file_io, ox_need_conv;
 extern char *ox_copy_bptr;  extern char *ox_copy_bptr;
   extern int ox_get_pari_result;
   
   /* XXX */
   void write_cmo(pointer,Obj);
   
 void reset_io()  void reset_io()
 {  {
         ox_file_io = 0;    ox_file_io = 0;
     if ( ox_get_pari_result ) reset_ox_pari();
 }  }
   
 void endian_init()  void endian_init()
 {  {
         unsigned int et = 0xff;    unsigned int et = 0xff;
   
         if ( *((char *)&et) )    if ( *((char *)&et) )
                 little_endian = 1;      little_endian = 1;
         else    else
                 little_endian = 0;      little_endian = 0;
         ox_need_conv = 1;    ox_need_conv = 1;
 }  }
   
 int countobj(p)  int countobj(Obj p)
 Obj p;  
 {  {
         ox_count_length = 0;    ox_count_length = 0;
         ox_do_count = 1; saveobj(0,p); ox_do_count = 0;    ox_do_count = 1; saveobj(0,p); ox_do_count = 0;
         return ox_count_length;    return ox_count_length;
 }  }
   
 int countvl(vl)  int count_as_cmo(Obj p)
 VL vl;  
 {  {
         ox_count_length = 0;    ox_count_length = 0;
         ox_do_count = 1; savevl(0,vl); ox_do_count = 0;    ox_do_count = 1; write_cmo(0,p); ox_do_count = 0;
         return ox_count_length;    return ox_count_length;
 }  }
   
 void ox_copy_init(s)  int countvl(VL vl)
 char *s;  
 {  {
         ox_copy_bptr = s;    ox_count_length = 0;
     ox_do_count = 1; savevl(0,vl); ox_do_count = 0;
     return ox_count_length;
 }  }
   
 void ox_obj_to_buf(p)  void ox_copy_init(char *s)
 Obj p;  
 {  {
         ox_do_copy = 1; saveobj(0,p); ox_do_copy = 0;    ox_copy_bptr = s;
 }  }
   
 void ox_buf_to_obj(p)  #if !defined(VISUAL) && !defined(__MINGW32__)
 Obj *p;  /*
    * library mode functions
    * byte order is controlled by lib_ox_need_conv.
    */
   
   void ox_obj_to_buf_as_cmo(Obj p)
 {  {
         ox_do_copy = 1; loadobj(0,p); ox_do_copy = 0;    ox_need_conv = lib_ox_need_conv;
     ox_do_copy = 1; write_cmo(0,p); ox_do_copy = 0;
 }  }
   
 void ox_vl_to_buf(vl)  void ox_buf_to_obj_as_cmo(Obj *p)
 VL vl;  
 {  {
         ox_do_copy = 1; savevl(0,vl); ox_do_copy = 0;    ox_need_conv = lib_ox_need_conv;
     ox_do_copy = 1; read_cmo(0,p); ox_do_copy = 0;
 }  }
   
 int gen_fread (ptr,size,nitems,stream)  void ox_vl_to_buf(VL vl)
 char *ptr;  
 int size,nitems;  
 FILE *stream;  
 {  {
         int n;    ox_do_copy = 1; savevl(0,vl); ox_do_copy = 0;
   }
   #endif
   
         if ( ox_do_copy ) {  int gen_fread (char *ptr,int size,int nitems,FILE *stream)
                 n = size*nitems;  {
                 memcpy(ptr,ox_copy_bptr,n);    int n;
                 ox_copy_bptr += n;  
         } else {    if ( ox_do_copy ) {
 #if defined(VISUAL)      n = size*nitems;
                 if ( _fileno(stream) < 0 )      memcpy(ptr,ox_copy_bptr,n);
                         n = cread(ptr,size,nitems,(STREAM *)stream);      ox_copy_bptr += n;
                 else      /* dummy return */
 #elif MPI      return 0;
                 if ( (char)fileno(stream) < 0 )    } else {
                         n = cread(ptr,size,nitems,(STREAM *)stream);  #if defined(VISUAL) || defined(__MINGW32__)
                 else      if ( _fileno(stream) < 0 )
         n = cread(ptr,size,nitems,(STREAM *)stream);
       else
   #elif defined(MPI)
       if ( (char)fileno(stream) < 0 )
         n = cread(ptr,size,nitems,(STREAM *)stream);
       else
 #endif  #endif
                 n = fread(ptr,size,nitems,stream);      n = fread(ptr,size,nitems,stream);
                 if ( !n )      if ( !n ) {
                         ExitAsir();        ExitAsir();
                 else        /* NOTREACHED */
                         return n;        return 0;
         }      } else
         return n;
     }
 }  }
   
 int gen_fwrite (ptr,size,nitems,stream)  int gen_fwrite (char *ptr,int size,int nitems,FILE *stream)
 char *ptr;  
 int size,nitems;  
 FILE *stream;  
 {  {
         int n;    int n;
   
         if ( ox_do_count )    if ( ox_do_count ) {
                 ox_count_length += size*nitems;      ox_count_length += size*nitems;
         else if ( ox_do_copy ) {      /* dummy return  */
                 n = size*nitems;      return 0;
                 memcpy(ox_copy_bptr,ptr,n);    } else if ( ox_do_copy ) {
                 ox_copy_bptr += n;      n = size*nitems;
         } else      memcpy(ox_copy_bptr,ptr,n);
 #if defined(VISUAL)      ox_copy_bptr += n;
         if ( _fileno(stream) < 0 )      /* dummy return  */
                 return cwrite(ptr,size,nitems,(STREAM *)stream);      return 0;
         else    } else
 #elif MPI  #if defined(VISUAL) || defined(__MINGW32__)
         if ( (char)fileno(stream) < 0 )    if ( _fileno(stream) < 0 )
                 return cwrite(ptr,size,nitems,(STREAM *)stream);      return cwrite(ptr,size,nitems,(STREAM *)stream);
         else    else
   #elif defined(MPI)
     if ( (char)fileno(stream) < 0 )
       return cwrite(ptr,size,nitems,(STREAM *)stream);
     else
 #endif  #endif
                 return fwrite(ptr,size,nitems,stream);      return fwrite(ptr,size,nitems,stream);
 }  }
   
 void write_char(f,p)  void write_char(FILE *f,unsigned char *p)
 FILE *f;  
 unsigned char *p;  
 {  {
         gen_fwrite(p,sizeof(unsigned char),1,f);    gen_fwrite(p,sizeof(unsigned char),1,f);
 }  }
   
 void write_short(f,p)  void write_short(FILE *f,unsigned short *p)
 FILE *f;  
 unsigned short *p;  
 {  {
         unsigned short t;    unsigned short t;
   
         if ( little_endian && (ox_file_io || ox_need_conv) ) {    if ( little_endian && (ox_file_io || ox_need_conv) ) {
                 t = htons(*p);      t = htons(*p);
                 gen_fwrite(&t,sizeof(unsigned short),1,f);      gen_fwrite((char *)&t,sizeof(unsigned short),1,f);
         } else    } else
                 gen_fwrite(p,sizeof(unsigned short),1,f);      gen_fwrite((char *)p,sizeof(unsigned short),1,f);
 }  }
   
 void write_int(f,p)  void write_int(FILE *f,unsigned int *p)
 FILE *f;  
 unsigned int *p;  
 {  {
         unsigned int t;    unsigned int t;
   
         if ( little_endian && (ox_file_io || ox_need_conv) ) {    if ( little_endian && (ox_file_io || ox_need_conv) ) {
                 t = htonl(*p);      t = htonl(*p);
                 gen_fwrite(&t,sizeof(unsigned int),1,f);      gen_fwrite((char *)&t,sizeof(unsigned int),1,f);
         } else    } else
                 gen_fwrite(p,sizeof(unsigned int),1,f);      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;  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];
   
 void init_deskey()  void init_deskey()
 {  {
         static int deskey_initialized = 0;    static int deskey_initialized = 0;
   
         if ( !deskey_initialized ) {    if ( !deskey_initialized ) {
                 key_schedule(asir_deskey,deskey_string);      key_schedule(asir_deskey,deskey_string);
                 deskey_initialized = 1;      deskey_initialized = 1;
         }    }
 }  }
   #endif
   
 void write_intarray(f,p,l)  void write_intarray(FILE *f,unsigned int *p,int l)
 FILE *f;  
 unsigned int *p;  
 int l;  
 {  {
         int i;    int i;
         unsigned int t;    unsigned int t;
 #if defined(VISUAL)  #if defined(DES_ENC)
         int l2;    int l2;
         unsigned int plain[2],encrypted[2];    unsigned int plain[2],encrypted[2];
   
         if ( des_encryption ) {    if ( des_encryption ) {
                 l2 = l>>1;      l2 = l>>1;
                 for ( i = 0; i < l2; i++ ) {      for ( i = 0; i < l2; i++ ) {
                         plain[0] = *p++;        plain[0] = *p++;
                         plain[1] = *p++;        plain[1] = *p++;
                         des_enc(plain,deskey_string,encrypted);        des_enc(plain,deskey_string,encrypted);
                         encrypted[0] = htonl(encrypted[0]);        encrypted[0] = htonl(encrypted[0]);
                         encrypted[1] = htonl(encrypted[1]);        encrypted[1] = htonl(encrypted[1]);
                         gen_fwrite(encrypted,sizeof(unsigned int),2,f);        gen_fwrite((char *)encrypted,sizeof(unsigned int),2,f);
                 }      }
                 if ( (l2<<1) < l ) {      if ( (l2<<1) < l ) {
                         plain[0] = *p;        plain[0] = *p;
                         plain[1] = 0;        plain[1] = 0;
                         des_enc(plain,deskey_string,encrypted);        des_enc(plain,deskey_string,encrypted);
                         encrypted[0] = htonl(encrypted[0]);        encrypted[0] = htonl(encrypted[0]);
                         encrypted[1] = htonl(encrypted[1]);        encrypted[1] = htonl(encrypted[1]);
                         gen_fwrite(encrypted,sizeof(unsigned int),2,f);        gen_fwrite((char *)encrypted,sizeof(unsigned int),2,f);
                 }      }
         } else    } else
 #endif  #endif
         if ( little_endian && (ox_file_io || ox_need_conv) )    if ( little_endian && (ox_file_io || ox_need_conv) )
                 for ( i = 0; i < l; i++, p++) {      for ( i = 0; i < l; i++, p++) {
                         t = htonl(*p);        t = htonl(*p);
                         gen_fwrite(&t,sizeof(unsigned int),1,f);        gen_fwrite((char *)&t,sizeof(unsigned int),1,f);
                 }      }
         else    else
                 gen_fwrite(p,sizeof(unsigned int),l,f);      gen_fwrite((char *)p,sizeof(unsigned int),l,f);
 }  }
   
 #if defined(LONG_IS_64BIT)  #if SIZEOF_LONG == 8
 void write_longarray(f,p,l)  /* write l word (1word=4bytes) */
 FILE *f;  /* l even : low 32of p[0] | high32 of p[0] | ... */
 unsigned long *p;  /* l odd :  high32 of p[0] | ... */
 int l;  void write_longarray(FILE *f,unsigned long *p,int l)
 {  {
         int i;    int i;
         unsigned long w;    unsigned long w;
         unsigned int hi,lo;    unsigned int hi,lo;
   
         if ( little_endian && (ox_file_io || ox_need_conv) )    if ( l%2 ) {
                 for ( i = 0; i < l; i++, p++) {      w = p[0]; hi = w>>32;
                         w = *p; hi = w>>32; lo = w&0xffffffff;    if ( little_endian && (ox_file_io || ox_need_conv) )
                         hi = htonl(hi); lo = htonl(lo);        hi = htonl(hi);
                         gen_fwrite(&hi,sizeof(unsigned int),1,f);      gen_fwrite((char *)&hi,sizeof(unsigned int),1,f);
                         gen_fwrite(&lo,sizeof(unsigned int),1,f);      i = 1;
                 }    } else
         else      i = 0;
                 gen_fwrite(p,sizeof(unsigned long),l,f);    l = (l+1)/2;
     for ( ; i < l; i++ ) {
       w = p[i]; hi = w>>32; lo = w&0xffffffff;
     if ( little_endian && (ox_file_io || ox_need_conv) ) {
         hi = htonl(hi); lo = htonl(lo);
     }
       gen_fwrite((char *)&lo,sizeof(unsigned int),1,f);
       gen_fwrite((char *)&hi,sizeof(unsigned int),1,f);
     }
 }  }
 #endif  #endif
   
 void write_double(f,p)  #if defined(_WIN64)
 FILE *f;  /* write l word (1word=4bytes) */
 double *p;  /* l even : low 32of p[0] | high32 of p[0] | ... */
   /* l odd :  high32 of p[0] | ... */
   void write_longarray(FILE *f,unsigned long long *p,int l)
 {  {
         unsigned int t;    int i;
     unsigned long long w;
     unsigned int hi,lo;
   
         if ( little_endian && (ox_file_io || ox_need_conv) ) {    if ( l%2 ) {
                 t = htonl(((unsigned int *)p)[1]);      w = p[0]; hi = w>>32;
                 gen_fwrite(&t,sizeof(unsigned int),1,f);    if ( little_endian && (ox_file_io || ox_need_conv) )
                 t = htonl(((unsigned int *)p)[0]);        hi = htonl(hi);
                 gen_fwrite(&t,sizeof(unsigned int),1,f);      gen_fwrite((char *)&hi,sizeof(unsigned int),1,f);
         } else      i = 1;
                 gen_fwrite(p,sizeof(double),1,f);    } else
       i = 0;
     l = (l+1)/2;
     for ( ; i < l; i++ ) {
       w = p[i]; hi = w>>32; lo = w&0xffffffff;
     if ( little_endian && (ox_file_io || ox_need_conv) ) {
         hi = htonl(hi); lo = htonl(lo);
     }
       gen_fwrite((char *)&lo,sizeof(unsigned int),1,f);
       gen_fwrite((char *)&hi,sizeof(unsigned int),1,f);
     }
 }  }
   #endif
   
 void write_string(f,p,l)  void write_double(FILE *f,double *p)
 FILE *f;  
 unsigned char *p;  
 {  {
         gen_fwrite(p,sizeof(unsigned char),l,f);    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(double),1,f);
 }  }
   
 void read_char(f,p)  void write_string(FILE *f,unsigned char *p,int l)
 FILE *f;  
 unsigned char *p;  
 {  {
         gen_fread((char *)p,sizeof(unsigned char),1,f);    gen_fwrite(p,sizeof(unsigned char),l,f);
 }  }
   
 void read_short(f,p)  void read_char(FILE *f,unsigned char *p)
 FILE *f;  
 unsigned short *p;  
 {  {
         gen_fread(p,sizeof(unsigned short),1,f);    gen_fread((char *)p,sizeof(unsigned char),1,f);
         if ( little_endian && (ox_file_io || ox_need_conv) )  
                 *p = ntohs(*p);  
 }  }
   
 void read_int(f,p)  void read_short(FILE *f,unsigned short *p)
 FILE *f;  
 unsigned int *p;  
 {  {
         gen_fread(p,sizeof(unsigned int),1,f);    gen_fread((char *)p,sizeof(unsigned short),1,f);
         if ( little_endian && (ox_file_io || ox_need_conv) )    if ( little_endian && (ox_file_io || ox_need_conv) )
                 *p = ntohl(*p);      *p = ntohs(*p);
 }  }
   
 void read_intarray(f,p,l)  void read_int(FILE *f,unsigned int *p)
 FILE *f;  
 unsigned int *p;  
 int l;  
 {  {
         int i;    gen_fread((char *)p,sizeof(unsigned int),1,f);
         unsigned int t;    if ( little_endian && (ox_file_io || ox_need_conv) )
 #if defined(VISUAL)      *p = ntohl(*p);
         int l2;  }
         unsigned int plain[2],encrypted[2];  
   
         if ( des_encryption ) {  void read_int64(FILE *f,UL *p)
                 l2 = l>>1;  {
                 for ( i = 0; i < l2; i++ ) {    unsigned int t;
                         gen_fread((char *)encrypted,sizeof(unsigned int),2,f);  
                         encrypted[0] = ntohl(encrypted[0]);    if ( little_endian && (ox_file_io || ox_need_conv) ) {
                         encrypted[1] = ntohl(encrypted[1]);      gen_fread((char *)&t,sizeof(unsigned int),1,f);
                         des_dec(encrypted,deskey_string,plain);      ((unsigned int *)p)[1] = ntohl(t);
                         *p++ = plain[0];      gen_fread((char *)&t,sizeof(unsigned int),1,f);
                         *p++ = plain[1];      ((unsigned int *)p)[0] = ntohl(t);
                 }    } else
                 if ( (l2<<1) < l ) {      gen_fread((char *)p,sizeof(UL),1,f);
                         gen_fread((char *)encrypted,sizeof(unsigned int),2,f);  }
                         encrypted[0] = ntohl(encrypted[0]);  
                         encrypted[1] = ntohl(encrypted[1]);  void read_intarray(FILE *f,unsigned int *p,int l)
                         des_dec(encrypted,deskey_string,plain);  {
                         *p = plain[0];    int i;
                 }  #if defined(DES_ENC)
         } else    int l2;
     unsigned int plain[2],encrypted[2];
   
     if ( des_encryption ) {
       l2 = l>>1;
       for ( i = 0; i < l2; i++ ) {
         gen_fread((char *)encrypted,sizeof(unsigned int),2,f);
         encrypted[0] = ntohl(encrypted[0]);
         encrypted[1] = ntohl(encrypted[1]);
         des_dec(encrypted,deskey_string,plain);
         *p++ = plain[0];
         *p++ = plain[1];
       }
       if ( (l2<<1) < l ) {
         gen_fread((char *)encrypted,sizeof(unsigned int),2,f);
         encrypted[0] = ntohl(encrypted[0]);
         encrypted[1] = ntohl(encrypted[1]);
         des_dec(encrypted,deskey_string,plain);
         *p = plain[0];
       }
     } else
 #endif  #endif
         {    {
                 gen_fread(p,sizeof(unsigned int),l,f);      gen_fread((char *)p,sizeof(unsigned int),l,f);
                 if ( little_endian && (ox_file_io || ox_need_conv) )      if ( little_endian && (ox_file_io || ox_need_conv) )
                         for ( i = 0; i < l; i++, p++ )        for ( i = 0; i < l; i++, p++ )
                                 *p = ntohl(*p);          *p = ntohl(*p);
         }    }
 }  }
   
 #if defined(LONG_IS_64BIT)  #if SIZEOF_LONG == 8
 void read_longarray(f,p,l)  /* read l word (1word=4bytes) */
 FILE *f;  /* pad 0 at low 32 of p[0] if l is odd */
 unsigned long *p;  /* low 32 of p[0] | high32 of p[0] | ... */
 int l;  void read_longarray(FILE *f,unsigned long *p,int l)
 {  {
         int i;    int i;
         unsigned int hi,lo;    unsigned int hi,lo;
       unsigned int *q;
   
         if ( little_endian && (ox_file_io || ox_need_conv) ) {    q = (unsigned int *)p;
                 for ( i = l; i > 1; i -= 2, p++ ) {    if ( l%2 ) {
                         gen_fread(&hi,sizeof(unsigned int),1,f);      gen_fread((char *)&hi,sizeof(unsigned int),1,f);
                         gen_fread(&lo,sizeof(unsigned int),1,f);      if ( little_endian && (ox_file_io || ox_need_conv) )
                         hi = ntohl(hi); lo = ntohl(lo);        hi = ntohl(hi);
                         *p = (((unsigned long)hi)<<32)|((unsigned long)lo);      *p = (((unsigned long)hi)<<32);
                 }      p++; l--;
                 if ( i == 1 ) {    }
                         gen_fread(&hi,sizeof(unsigned int),1,f);    for ( i = 0; i < l; i += 2, p++ ) {
                         hi = ntohl(hi); *p = (((unsigned long)hi)<<32);      gen_fread((char *)&lo,sizeof(unsigned int),1,f);
                 }      gen_fread((char *)&hi,sizeof(unsigned int),1,f);
         } else        if ( little_endian && (ox_file_io || ox_need_conv) ) {
                 gen_fread(p,sizeof(unsigned int),l,f);          hi = ntohl(hi); lo = ntohl(lo);
       }
       *p = (((unsigned long)hi)<<32)|((unsigned long)lo);
     }
 }  }
 #endif  #endif
   
 void read_string(f,p,l)  #if defined(_WIN64)
 FILE *f;  /* read l word (1word=4bytes) */
 unsigned char *p;  /* pad 0 at low 32 of p[0] if l is odd */
   /* low 32 of p[0] | high32 of p[0] | ... */
   void read_longarray(FILE *f,unsigned long long *p,int l)
 {  {
         gen_fread((char *)p,sizeof(unsigned char),l,f);    int i;
     unsigned int hi,lo;
       unsigned int *q;
   
     q = (unsigned int *)p;
     if ( l%2 ) {
       gen_fread((char *)&hi,sizeof(unsigned int),1,f);
       if ( little_endian && (ox_file_io || ox_need_conv) )
         hi = ntohl(hi);
       *p = (((unsigned long long)hi)<<32);
       p++; l--;
     }
     for ( i = 0; i < l; i += 2, p++ ) {
       gen_fread((char *)&lo,sizeof(unsigned int),1,f);
       gen_fread((char *)&hi,sizeof(unsigned int),1,f);
         if ( little_endian && (ox_file_io || ox_need_conv) ) {
           hi = ntohl(hi); lo = ntohl(lo);
       }
       *p = (((unsigned long long)hi)<<32)|((unsigned long long)lo);
     }
 }  }
   #endif
   
 void read_double(f,p)  void read_string(FILE *f,unsigned char *p,int l)
 FILE *f;  
 double *p;  
 {  {
         unsigned int t;    gen_fread((char *)p,sizeof(unsigned char),l,f);
   }
   
         if ( little_endian && (ox_file_io || ox_need_conv) ) {  void read_double(FILE *f,double *p)
                 gen_fread((char *)&t,sizeof(unsigned int),1,f);  {
                 ((unsigned int *)p)[1] = ntohl(t);    unsigned int t;
                 gen_fread((char *)&t,sizeof(unsigned int),1,f);  
                 ((unsigned int *)p)[0] = ntohl(t);    if ( little_endian && (ox_file_io || ox_need_conv) ) {
         } else      gen_fread((char *)&t,sizeof(unsigned int),1,f);
                 gen_fread((char *)p,sizeof(double),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(double),1,f);
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.23

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>