version 1.5, 2016/03/31 05:30:32 |
version 1.6, 2018/03/29 01:32:53 |
|
|
* 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/biovar.c,v 1.4 2001/10/09 01:36:20 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/io/biovar.c,v 1.5 2016/03/31 05:30:32 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 57 void savevl(s,vl) |
|
Line 57 void savevl(s,vl) |
|
FILE *s; |
FILE *s; |
VL vl; |
VL vl; |
{ |
{ |
int n,i; |
int n,i; |
VL tvl; |
VL tvl; |
|
|
for ( tvl = vl, n = 0; tvl; tvl = NEXT(tvl)) |
for ( tvl = vl, n = 0; tvl; tvl = NEXT(tvl)) |
if ( tvl->v->attr != (pointer)V_UC && tvl->v->attr != (pointer)V_PF ) |
if ( tvl->v->attr != (pointer)V_UC && tvl->v->attr != (pointer)V_PF ) |
n++; |
n++; |
write_int(s,&n); |
write_int(s,&n); |
vtab = (V *)CALLOC(n,sizeof(V)); |
vtab = (V *)CALLOC(n,sizeof(V)); |
for ( tvl = vl, i = 0; i < n; tvl = NEXT(tvl) ) |
for ( tvl = vl, i = 0; i < n; tvl = NEXT(tvl) ) |
if ( tvl->v->attr != (pointer)V_UC && tvl->v->attr != (pointer)V_PF ) { |
if ( tvl->v->attr != (pointer)V_UC && tvl->v->attr != (pointer)V_PF ) { |
vtab[i] = tvl->v; savev(s,vtab[i]); i++; |
vtab[i] = tvl->v; savev(s,vtab[i]); i++; |
} |
} |
} |
} |
|
|
void loadvl(s) |
void loadvl(s) |
FILE *s; |
FILE *s; |
{ |
{ |
int n,i,need_reorder; |
int n,i,need_reorder; |
V v1,v2; |
V v1,v2; |
VL t,t1; |
VL t,t1; |
|
|
read_int(s,&n); |
read_int(s,&n); |
vtab = (V *)CALLOC(n,sizeof(V)); |
vtab = (V *)CALLOC(n,sizeof(V)); |
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
loadv(s,&vtab[i]); |
loadv(s,&vtab[i]); |
need_reorder = 0; |
need_reorder = 0; |
for ( i = 0; i < n-1; i++ ) { |
for ( i = 0; i < n-1; i++ ) { |
v1 = vtab[i]; v2 = vtab[i+1]; |
v1 = vtab[i]; v2 = vtab[i+1]; |
for ( t = CO; t->v != v1 && t->v != v2; t = NEXT(t) ); |
for ( t = CO; t->v != v1 && t->v != v2; t = NEXT(t) ); |
if ( t->v == v2 ) { |
if ( t->v == v2 ) { |
need_reorder = 1; break; |
need_reorder = 1; break; |
} |
} |
} |
} |
if ( need_reorder ) { |
if ( need_reorder ) { |
for ( i = n-1, t = 0; i >= 0; i-- ) { |
for ( i = n-1, t = 0; i >= 0; i-- ) { |
NEWVL(t1); t1->v = vtab[i]; NEXT(t1) = t; t = t1; |
NEWVL(t1); t1->v = vtab[i]; NEXT(t1) = t; t = t1; |
} |
} |
file_vl = t; |
file_vl = t; |
} else |
} else |
file_vl = 0; |
file_vl = 0; |
} |
} |
|
|
void skipvl(s) |
void skipvl(s) |
FILE *s; |
FILE *s; |
{ |
{ |
int n,i,size,len; |
int n,i,size,len; |
|
|
read_int(s,&n); |
read_int(s,&n); |
for ( i = 0, size = 0; i < n; i++ ) { |
for ( i = 0, size = 0; i < n; i++ ) { |
read_int(s,&len); size += len; |
read_int(s,&len); size += len; |
} |
} |
fseek(s,size,1L); |
fseek(s,size,1L); |
} |
} |
|
|
void savev(s,v) |
void savev(s,v) |
FILE *s; |
FILE *s; |
V v; |
V v; |
{ |
{ |
savestr(s,NAME(v)); |
savestr(s,NAME(v)); |
} |
} |
|
|
void loadv(s,vp) |
void loadv(s,vp) |
FILE *s; |
FILE *s; |
V *vp; |
V *vp; |
{ |
{ |
P p; |
P p; |
char *name; |
char *name; |
|
|
loadstr(s,&name); |
loadstr(s,&name); |
if ( name ) { |
if ( name ) { |
FUNC f; |
FUNC f; |
|
|
gen_searchf_searchonly(name,&f,1); |
gen_searchf_searchonly(name,&f,1); |
if ( f ) |
if ( f ) |
makesrvar(f,&p); |
makesrvar(f,&p); |
else |
else |
makevar(name,&p); |
makevar(name,&p); |
*vp = VR(p); |
*vp = VR(p); |
} else |
} else |
*vp = 0; |
*vp = 0; |
} |
} |
|
|
int save_convv(v) |
int save_convv(v) |
V v; |
V v; |
{ |
{ |
int i; |
int i; |
|
|
if ( ox_do_count ) |
if ( ox_do_count ) |
return 0; |
return 0; |
if ( v->attr == (pointer)V_PF ) |
if ( v->attr == (pointer)V_PF ) |
return -1; |
return -1; |
for ( i = 0; vtab[i]; i++ ) |
for ( i = 0; vtab[i]; i++ ) |
if ( vtab[i] == v ) |
if ( vtab[i] == v ) |
return i; |
return i; |
error("save_convv : cannot happen"); |
error("save_convv : cannot happen"); |
/* NOTREACHED */ |
/* NOTREACHED */ |
return -1; |
return -1; |
} |
} |
|
|
V load_convv(vindex) |
V load_convv(vindex) |
int vindex; |
int vindex; |
{ |
{ |
return vtab[vindex]; |
return vtab[vindex]; |
} |
} |
|
|
void swap_bytes(ptr,unit,size) |
void swap_bytes(ptr,unit,size) |
char *ptr; |
char *ptr; |
int unit,size; |
int unit,size; |
{ |
{ |
char *p; |
char *p; |
int i,j,hunit; |
int i,j,hunit; |
char t; |
char t; |
|
|
for ( i = 0, p = ptr, hunit = unit/2; i < size; i++, p += unit ) |
for ( i = 0, p = ptr, hunit = unit/2; i < size; i++, p += unit ) |
for ( j = 0; j < hunit; j++ ) { |
for ( j = 0; j < hunit; j++ ) { |
t = p[j]; p[j] = p[unit-j-1]; p[unit-j-1] = t; |
t = p[j]; p[j] = p[unit-j-1]; p[unit-j-1] = t; |
} |
} |
} |
} |