Annotation of OpenXM_contrib2/asir2000/io/biovar.c, Revision 1.4
1.2 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.3 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.2 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
1.4 ! noro 47: * $OpenXM: OpenXM_contrib2/asir2000/io/biovar.c,v 1.3 2000/08/22 05:04:17 noro Exp $
1.2 noro 48: */
1.1 noro 49: #include "ca.h"
50: #include "parse.h"
51: #include "ox.h"
52:
53: static V *vtab;
54: VL file_vl;
55:
56: void savevl(s,vl)
57: FILE *s;
58: VL vl;
59: {
60: int n,i;
61: VL tvl;
62:
63: for ( tvl = vl, n = 0; tvl; tvl = NEXT(tvl))
64: if ( tvl->v->attr != (pointer)V_UC && tvl->v->attr != (pointer)V_PF )
65: n++;
66: write_int(s,&n);
67: vtab = (V *)CALLOC(n,sizeof(V));
68: for ( tvl = vl, i = 0; i < n; tvl = NEXT(tvl) )
69: if ( tvl->v->attr != (pointer)V_UC && tvl->v->attr != (pointer)V_PF ) {
70: vtab[i] = tvl->v; savev(s,vtab[i]); i++;
71: }
72: }
73:
74: void loadvl(s)
75: FILE *s;
76: {
77: int n,i,need_reorder;
78: V v1,v2;
79: VL t,t1;
80:
81: read_int(s,&n);
82: vtab = (V *)CALLOC(n,sizeof(V));
83: for ( i = 0; i < n; i++ )
84: loadv(s,&vtab[i]);
85: need_reorder = 0;
86: for ( i = 0; i < n-1; i++ ) {
87: v1 = vtab[i]; v2 = vtab[i+1];
88: for ( t = CO; t->v != v1 && t->v != v2; t = NEXT(t) );
89: if ( t->v == v2 ) {
90: need_reorder = 1; break;
91: }
92: }
93: if ( need_reorder ) {
94: for ( i = n-1, t = 0; i >= 0; i-- ) {
95: NEWVL(t1); t1->v = vtab[i]; NEXT(t1) = t; t = t1;
96: }
97: file_vl = t;
98: } else
99: file_vl = 0;
100: }
101:
102: void skipvl(s)
103: FILE *s;
104: {
105: int n,i,size,len;
106:
107: read_int(s,&n);
108: for ( i = 0, size = 0; i < n; i++ ) {
109: read_int(s,&len); size += len;
110: }
111: fseek(s,size,1L);
112: }
113:
114: void savev(s,v)
115: FILE *s;
116: V v;
117: {
118: savestr(s,NAME(v));
119: }
120:
121: void loadv(s,vp)
122: FILE *s;
123: V *vp;
124: {
125: P p;
126: char *name;
127:
128: loadstr(s,&name);
129: if ( name ) {
130: makevar(name,&p);
131: *vp = VR(p);
132: } else
133: *vp = 0;
134: }
135:
136: int save_convv(v)
137: V v;
138: {
139: int i;
140:
141: if ( ox_do_count )
142: return 0;
143: if ( v->attr == (pointer)V_PF )
144: return -1;
145: for ( i = 0; vtab[i]; i++ )
146: if ( vtab[i] == v )
147: return i;
1.4 ! noro 148: error("save_convv : cannot happen");
! 149: /* NOTREACHED */
! 150: return -1;
1.1 noro 151: }
152:
153: V load_convv(vindex)
154: int vindex;
155: {
156: return vtab[vindex];
157: }
158:
159: void swap_bytes(ptr,unit,size)
160: char *ptr;
161: int unit,size;
162: {
163: char *p;
164: int i,j,hunit;
165: char t;
166:
167: for ( i = 0, p = ptr, hunit = unit/2; i < size; i++, p += unit )
168: for ( j = 0; j < hunit; j++ ) {
169: t = p[j]; p[j] = p[unit-j-1]; p[unit-j-1] = t;
170: }
171: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>