/* * include needed system headers */ #include /* include standard i/o library */ #include /* include standard library */ #include /* include string library */ #include /* include unix standard library */ #include /* */ #include /* */ #include /* */ #include /* error simbol definitions */ #include /* system time definitions */ #include /* math library */ void unpacking(int ndata, unsigned short *output); void dunpacker_(int *l_buffer, unsigned short *buffer, int *error, int *fd) { int i; int nhead,nread; unsigned short word; *error = 0; nhead = 13; /* packed */ // printf("%i \n",*l_buffer); /* /\*** read the data ***\/ */ // if( nhead == 13) *l_buffer = (*l_buffer*13)/16+1; /* packed */ nread=read(*fd, buffer, 2**l_buffer); if( nread==0 ) { // printf("dunpacker: Unexpected end of file %d at %d \n",*fd,nread); *error=1; return ; } if ( nread != 2**l_buffer) { // printf("dunpacker: Error on reading: nread = %d \n",nread); *error=-1; return ; } /*** correct byte ***/ for(i=0; i<*l_buffer; i++) { word = buffer[i]; buffer[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); } /*** unpacking buffer data ***/ if( nhead == 13) unpacking(*l_buffer, buffer); // int num = (*l_buffer-13-1)/13*16+3;//??? // for( i=0; i> 3; *oo++ = ( (*o1 & 0x0007) << 10 ) | ( (*oi & 0xffc0) >> 6); o1 = oi++; *oo++ = ( (*o1 & 0x003f) << 7 ) | ( (*oi & 0xfe00) >> 9); o1 = oi++; *oo++ = ( (*o1 & 0x01ff) << 4 ) | ( (*oi & 0xf000) >> 12); o1 = oi++; *oo++ = ( (*o1 & 0x0fff) << 1 ) | ( (*oi & 0x8000) >> 15); *oo++ = (*oi & 0x7ffc) >> 2; o1 = oi++; *oo++ = ( (*o1 & 0x0003) << 11 ) | ( (*oi & 0xffe0) >> 5); o1 = oi++; *oo++ = ( (*o1 & 0x001f) << 8 ) | ( (*oi & 0xff00) >> 8); o1 = oi++; *oo++ = ( (*o1 & 0x00ff) << 5 ) | ( (*oi & 0xf800) >> 11); o1 = oi++; *oo++ = ( (*o1 & 0x07ff) << 2 ) | ( (*oi & 0xc000) >> 14); *oo++ = (*oi & 0x3ffe) >> 1; o1 = oi++; *oo++ = ( (*o1 & 0x0001) << 12 ) | ( (*oi & 0xfff0) >> 4); o1 = oi++; *oo++ = ( (*o1 & 0x000f) << 9 ) | ( (*oi & 0xff80) >> 7); o1 = oi++; *oo++ = ( (*o1 & 0x007f) << 6 ) | ( (*oi & 0xfc00) >> 10); o1 = oi++; *oo++ = ( (*o1 & 0x03ff) << 3 ) | ( (*oi & 0xe000) >> 13); *oo++ = *oi++ & 0x1fff; } return; }