home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.eri.u-tokyo.ac.jp
/
2014.03.ftp.eri.u-tokyo.ac.jp.zip
/
ftp.eri.u-tokyo.ac.jp
/
pub
/
seisv
/
src
/
2.01
/
retrv.c
< prev
next >
Wrap
Text File
|
1994-01-08
|
3KB
|
111 lines
/* SeisView alone/client Copyright (C) 1992,1994 K.Koketsu */
/* This is the common retrieving kernel for `select.c' and `seisvd.c'. */
unsigned retrv(ismap, total, tomax, js1, js2)
int *total, ismap;
short tomax;
unsigned js1, js2;
{
long lon;
short lat, mag, i;
unsigned I, J, pag, si, yy, md, hm, sc, dep;
unsigned char *sg1, *sg2;
I = 0;
J = *total % 4095;
pag = *total / 4095;
sg1 = (unsigned char *)iseg[js1];
sg2 = (unsigned char *)iseg[js2+pag] + 4;
Rvp:
si = I*16 + 4;
yy = sg1[si] + (sg1[si+1] << 8);
if(yy >= 0xff00) {
sg2[J*16 ] = sg1[si ];
sg2[J*16+1] = sg1[si+1];
/* A dummy function is necessary in select.c. */
send_client(sg2, J);
return( yy );
}
if(sg1[si] == 0xff) {
yy = sg1[si+13] + (sg1[si+14] << 8);
}
else {
if(sg1[si] >= 155) yy = sg1[si] + 1800 - 155;
else yy = sg1[si] + 1900;
}
if(yy > iyy2) goto Rv9;
if(yy == iyy2) {
md = (sg1[si+1] << 8) + sg1[si+2];
if(md > imd2) goto Rv9;
if(md == imd2) {
hm = (sg1[si+3] << 8) + sg1[si+4];
if(hm > ihm2) goto Rv9;
sc = sg1[si+5] + (sg1[si+6] << 8);
if(hm==ihm2 && sc>isc2) goto Rv9;
}
}
if(yy < iyy1) goto Rv9;
if(yy == iyy1) {
md = (sg1[si+1] << 8) + sg1[si+2];
if(md < imd1) goto Rv9;
if(md == imd1) {
hm = (sg1[si+3] << 8) + sg1[si+4];
if(hm < ihm1) goto Rv9;
sc = sg1[si+5] + (sg1[si+6] << 8);
if(hm==ihm1 && sc<isc1) goto Rv9;
}
}
if(sg1[si+ 8] & 0x80)
lon = - (((long)sg1[si+7] << 8) + ((long)sg1[si+8] & 0x7f));
else lon = ((long)sg1[si+ 7] << 8) + (long)sg1[si+ 8];
if(wrap && lon<lo1) { lon = lon + (long)360*256; }
if(lon<lo1 || lon>lo2) goto Rv9;
if(lon==lo2 && sg1[si+ 9]>0) goto Rv9;
if(lon==lo1 && sg1[si+ 9]>0 && lo1<0) goto Rv9;
if(sg1[si+11] & 0x80) lat = - ((sg1[si+10] << 8) + (sg1[si+11] & 0x7f));
else lat = (sg1[si+10] << 8) + sg1[si+11];
if(lat<la1 || lat>la2) goto Rv9;
if(lat==la2 && sg1[si+12]>0) goto Rv9;
if(lat==la1 && sg1[si+12]>0 && la1<0) goto Rv9;
if(sg1[si] == 0xff) {
if(*ynh$ == 'N') goto Rv9;
}
else {
dep = sg1[si+13] + (sg1[si+14] << 8);
if(dep == 0xffff) { if(*ynh$ == 'N') goto Rv9; }
else if(dep<ih1 || dep>ih2) goto Rv9;
}
if(sg1[si+15] == 0) {
if(*ynm$ == 'N') goto Rv9;
}
else {
if(sg1[si+15] & 0x80) mag = -(sg1[si+15] & 0x7f);
else mag = sg1[si+15];
if(mag<m1 || mag>m2) goto Rv9;
}
if( ismap ) { if(! checkpixel(si,js1)) goto Rv9; }
for(i=0; i<16; i++) sg2[J*16+i] = sg1[si+i];
(*total)++;
J++;
/* The following part is meaningless in seisvd.c, but a very large
value should be given. */
if(*total == tomax) return( 0xffff );
if(J == 4095) {
sg2[J*16 ] = 0xfe;
sg2[J*16+1] = 0xff;
J = 0; pag++;
sg2 = (unsigned char *)iseg[js2+pag] + 4;
}
Rv9:
I++;
goto Rvp;
}