📄 output_mini.c
字号:
outfile_name); perror("output_mini()"); fprintf (stderr, "\tExecution continuing.\n"); } current_channel = current_channel->next; } } /* end of big for loop (for k) */ fclose(outfile); chdir(orig_dir); return;} /* output_mini *//* ------------------------------------------------------------------------ */void blockette_swap(b_ptr, base)struct data_blk_hdr *b_ptr;char *base;{ short type, next_blk_byte; while (1) { b_ptr->type = swap_2byte(b_ptr->type); b_ptr->next_blk_byte = swap_2byte(b_ptr->next_blk_byte); switch (b_ptr->type) { case 100 : { char *p; float s_rate; /* must switch the sample rate - float */ p = (char *)&((struct data_blk_100 *)b_ptr)->sample_rate; *((int *)&s_rate)=swap_4byte(*((int *)p)); ((struct data_blk_100 *)b_ptr)->sample_rate = s_rate; } break; case 201: case 300: case 310: case 200: case 320: case 390: case 395: case 400: case 405: break; case 1000: case 1001: break; default : /* oh, oh */ fprintf(stderr, "blockette swapper: Bad blockette scanned\n Blockette = %d\n", b_ptr->type); return; } /* switch */ if (b_ptr->next_blk_byte == 0) return; b_ptr = (struct data_blk_hdr *)(base + b_ptr->next_blk_byte); } /* while */}/* ------------------------------------------------------------------------ */char *scan_for_blk_1000(b_ptr, base)struct data_blk_hdr *b_ptr;char *base; /* start of the logical rec */{ while (1) { if (b_ptr->type == 1000) /* eureka, we've found it */ return (char *)b_ptr; if (b_ptr->next_blk_byte == 0) return (char *) NULL; /* garbage check */ switch (b_ptr->type) { case 100 : case 201: case 300: case 310: case 200: case 320: case 390: case 395: case 400: case 405: case 1001: break; default : /* oh, oh */ fprintf(stderr, "scan_for_blk_1000(): Bad blockette scanned\n Blockette = %d\n", b_ptr->type); return (char *) 0; } /* switch */ b_ptr = (struct data_blk_hdr *)(base + b_ptr->next_blk_byte); } /* while */ /* Should never get here */ return (char *) 0; }/* ----------------------------------------------------------------------- *//* ------------------------------------------------------------------------ */char *scan_for_eob(b_ptr, position)struct data_blk_hdr *b_ptr;int position;{ int count = 0; BOOL finished = FALSE; while (!finished) { count++; if (b_ptr->next_blk_byte == 0) finished = TRUE; switch (b_ptr->type) { /* if finished...then update the next block field so it * points to where the new block 1000 will go. * position is current position from start of data record, * plus the sizeof the blockette just scanned */ case 100 : if (finished) /* update next block field */ b_ptr->next_blk_byte = position + 12; b_ptr = (struct data_blk_hdr *)((char *)b_ptr + 12); position += 12; break; case 201: if (finished) /* update next block field */ b_ptr->next_blk_byte = position + 36; b_ptr = (struct data_blk_hdr *)((char *)b_ptr + 36); position += 36; break; case 300: case 310: if (finished) /* update next block field */ b_ptr->next_blk_byte = position + 32; b_ptr = (struct data_blk_hdr *)((char *)b_ptr + 32); position += 32; break; case 200: case 320: case 390: if (finished) /* update next block field */ b_ptr->next_blk_byte = position + 28; b_ptr = (struct data_blk_hdr *)((char *)b_ptr + 28); position += 28; break; case 395: case 400: if (finished) /* update next block field */ b_ptr->next_blk_byte = position + 16; b_ptr = (struct data_blk_hdr *)((char *)b_ptr + 16); position += 16; break; case 405: if (finished) /* update next block field */ b_ptr->next_blk_byte = position + 6; b_ptr = (struct data_blk_hdr *)((char *)b_ptr + 6); position += 6; break; case 1000: fprintf(stderr, "output mini seed: Found unexpected blockette 1000! Output maybe incorrect.\n"); return (char *) 0; case 1001: break; default : /* oh, oh */ fprintf(stderr, "scan_for_eob(): Bad blockette scanned\n Blockette = %d\n", b_ptr->type); return (char *) 0; } /* switch */ } /* while */ /* Kludge alert: sometime the data header has the wrong count for * number of blockettes that follow. So make consistent here */ mini_data_hdr.hdr.number_blockettes = count; return (char *)b_ptr; }/* ------------------------------------------------------------------------ */char *code_to_english(fmt)char fmt;{ switch (fmt) { case 0: return(""); case 1 : return("16-bit"); case 2 : return(""); case 3: return("32-bit"); case 4 : case 5: return ("SUN I"); case 10: return("STEIM"); case 11: return("STEIM2"); case 12: case 13: case 14: /* need to find a way to differentiate btw 24, 16, etc */ return("GEOSCOPE"); break; case 15: fprintf(stderr, "Unable to support blockette 1000 data type! Found code = %d\n", fmt); return ""; case 16: return("CDSN"); case 17: return("GRAEF"); case 18: fprintf(stderr, "Unable to support blockette 1000 data type! Found code = %d\n", fmt); return ""; case 30: return("SRO G"); case 31: fprintf(stderr, "Unable to support blockette 1000 data type! Found code = %d\n", fmt); return ""; case 32: return("DWWSS"); case 33: return("RSTN"); default: fprintf(stderr, "Unable to support blockette 1000 data type! Found code = %d\n", fmt); return ""; } return "";}/* ------------------------------------------------------------------------ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -