📄 output_seed.c
字号:
int output_list(type55_ptr, fptr)struct type55 *type55_ptr;FILE *fptr;{ char *ch_ptr; char wrkstr[10]; char *buff; int i; while (type55_ptr) { /* allocate room for response */ buff = malloc(19 + /* type + size + seq # + in + out units + # resps */ (60 * type55_ptr->number_responses) + 1); if (buff == NULL) return 1; /* error condition */ memset(buff, 0, 19 + (60 * type55_ptr->number_responses) + 1); /* --------------------------------------- */ sprintf(buff, "0550000%2d%03d%03d%04d", type55_ptr->stage, type55_ptr->input_units_code, type55_ptr->output_units_code, type55_ptr->number_responses); ch_ptr = buff + strlen(buff); for (i = 0; i < type55_ptr->number_responses; i++) { sprintf(ch_ptr, "%12.5e%12.5e%12.5e%12.5e%12.5e", type55_ptr->response[i].frequency, type55_ptr->response[i].amplitude, type55_ptr->response[i].amplitude_error, type55_ptr->response[i].phase, type55_ptr->response[i].phase_error); /* moves to the end */ ch_ptr += 60; } /* fix up the blockette length field */ sprintf(wrkstr, "%04d", strlen(buff)); memcpy(&buff[3], wrkstr, strlen(wrkstr)); /* out to file */ if (!out_to_disk(fptr, buff, strlen(buff), 'S')) { free(buff); return 1; /* error */ } /* --------------------------------------- */ free(buff); type55_ptr = type55_ptr->next; } /* while type 55 */ return 0; /* no error */} /* output_responses *//* ------------------------------------------------------------------------- */int output_generic(type56_ptr, fptr)struct type56 *type56_ptr;FILE *fptr; { char *ch_ptr; char wrkstr[10]; char *buff; int i; while (type56_ptr) { /* allocate room */ buff = malloc(19 + (24 * type56_ptr->number_corners) + 1); if (buff == NULL) return 1; /* error condition */ memset(buff, 0, 19 + (24 * type56_ptr->number_corners) + 1); /* --------------------------------------- */ sprintf(buff, "0560000%2d%03d%03d%04d", type56_ptr->stage, type56_ptr->input_units_code, type56_ptr->output_units_code, type56_ptr->number_corners); ch_ptr = buff + strlen(buff); for (i = 0; i < type56_ptr->number_corners; i++) { sprintf(ch_ptr, "%12.5e%12.5e", type56_ptr->corner[i].frequency, type56_ptr->corner[i].slope); /* moves to the end */ ch_ptr += 24; } /* fix up the blockette length field */ sprintf(wrkstr, "%04d", strlen(buff)); memcpy(&buff[3], wrkstr, strlen(wrkstr)); /* out to file */ if (!out_to_disk(fptr, buff, strlen(buff), 'S')) { free(buff); return 1; /* error */ } /* --------------------------------------- */ free(buff); type56_ptr = type56_ptr->next; } /* while type 56 */ return 0; /* no error condition */ }/* ------------------------------------------------------------------------- */int output_decimations(type57_ptr, fptr)struct type57 *type57_ptr;FILE *fptr; { char buff[80]; while (type57_ptr) { /* as of dec 9th, 94, this record is always 51 bytes long */ sprintf(buff, "0570051%02d%10.4e%05d%05d%11.4e%11.4e", type57_ptr->stage, type57_ptr->input_sample_rate, type57_ptr->decimation_factor, type57_ptr->decimation_offset, type57_ptr->delay, type57_ptr->correction); if (!out_to_disk(fptr, buff, strlen(buff), 'S')) return 1; /* error condition */ type57_ptr = type57_ptr->next; } return 0; /* no error condition */ }/* ------------------------------------------------------------------------- */int output_sensitivity(type58_ptr, fptr)struct type58 *type58_ptr;FILE *fptr; { char *ch_ptr; char wrkstr[10]; char *buff; int i; while (type58_ptr) { /* allocate room for history values */ buff = malloc(35 + (47 * type58_ptr->number_calibrations) + 1); if (buff == NULL) return 1; /* error condition */ memset(buff, 0, 35 + (47 * type58_ptr->number_calibrations) + 1); /* --------------------------------------- */ sprintf(buff, "0580000%02d%12.5e%12.5e%02d", type58_ptr->stage, type58_ptr->sensitivity, type58_ptr->frequency, type58_ptr->number_calibrations); ch_ptr = buff + strlen(buff); for (i = 0; i < type58_ptr->number_calibrations; i++) { sprintf(ch_ptr, "%12.5e%12.5e%-22s~", type58_ptr->calibration[i].sensitivity, type58_ptr->calibration[i].frequency, type58_ptr->calibration[i].time); /* moves to the end */ ch_ptr = buff + strlen(buff); } /* fix up the blockette length field */ sprintf(wrkstr, "%04d", strlen(buff)); memcpy(&buff[3], wrkstr, strlen(wrkstr)); /* out to file */ if (!out_to_disk(fptr, buff, strlen(buff), 'S')) { free(buff); return 1; /* error */ } /* --------------------------------------- */ free(buff); type58_ptr = type58_ptr->next; } /* while type 58 */ return 0; /* no error condition */ }/* ------------------------------------------------------------------------- */int output_channel_comment(type59_ptr, fptr)struct type59 *type59_ptr;FILE *fptr;{ char buff[200]; while (type59_ptr) { sprintf(buff, "0590000%s~%s~%04d%06d", type59_ptr->start == NULL ? "" : type59_ptr->start, type59_ptr->end == NULL ? "" : type59_ptr->end, type59_ptr->comment_code, type59_ptr->level_code); fix_rec_length(buff); if (!out_to_disk(fptr, buff, strlen(buff), 'S')) { fprintf(stderr, "Error! output_channel_comment: unable to write channel comment to output file!\n"); perror("output_channel_comment"); return 0; /* error condition */ } type59_ptr = type59_ptr->next; } return 1; /* no error */}/* ------------------------------------------------------------------------- */int output_FIR(type61_ptr, fptr)struct type61 *type61_ptr;FILE *fptr;{ char *ch_ptr; char wrkstr[20]; char *buff; int i; while (type61_ptr) { /* allocate room for FIR values */ buff = malloc(9 + strlen(type61_ptr->name ? type61_ptr->name : "") + 11 + (14 * type61_ptr->number_numerators) + 1); if (buff == NULL) return 1; /* error condition */ memset(buff, 0, 9 + strlen(type61_ptr->name ? type61_ptr->name : "") + 11 + (14 * type61_ptr->number_numerators) + 1); /* --------------------------------------- */ sprintf(buff, "0610000%02d%s~%c%03d%03d%04d", type61_ptr->stage, type61_ptr->name == NULL ? "" : type61_ptr->name, type61_ptr->symmetry_code, type61_ptr->input_units_code, type61_ptr->output_units_code, type61_ptr->number_numerators); ch_ptr = buff + strlen(buff); for (i = 0; i < type61_ptr->number_numerators; i++) { sprintf(ch_ptr, "%14.7e", type61_ptr->numerator[i]); /* moves to the end */ ch_ptr += 14; } /* fix up the blockette length field */ sprintf(wrkstr, "%04d", strlen(buff)); memcpy(&buff[3], wrkstr, strlen(wrkstr)); /* out to file */ if (!out_to_disk(fptr, buff, strlen(buff), 'S')) { free(buff); return 1; /* error */ } /* --------------------------------------- */ free(buff); type61_ptr = type61_ptr->next; } /* while type 61 */ return 0; /* no error condition */}/* ------------------------------------------------------------------------- */int output_poly(type62_ptr, fptr)struct type62 *type62_ptr;FILE *fptr;{ char *ch_ptr; char wrkstr[20]; char *buff; int i; while (type62_ptr) { /* allocate room for coefficient values */ buff = malloc(81 + (24 * type62_ptr->number_coefficients) + 1); if (buff == NULL) return 1; /* error condition */ memset(buff, 0, 81 + (24 * type62_ptr->number_coefficients) + 1); /* --------------------------------------- */ sprintf(buff, "0620000%c%02d%03d%03d%c%c%12.5e%12.5e%12.5e%12.5e%12.5e%03d", type62_ptr->transfer_fct_type, type62_ptr->stage, type62_ptr->input_units_code, type62_ptr->output_units_code, type62_ptr->poly_approx_type, type62_ptr->valid_freq_units, type62_ptr->lower_valid_freq, type62_ptr->upper_valid_freq, type62_ptr->lower_bound_approx, type62_ptr->upper_bound_approx, type62_ptr->max_abs_error, type62_ptr->number_coefficients); ch_ptr = buff + strlen(buff); for (i = 0; i < type62_ptr->number_coefficients; i++) { sprintf(ch_ptr, "%12.5e%12.5e", type62_ptr->coefficient[i].coefficient, type62_ptr->coefficient[i].error); /* moves to the end */ ch_ptr += 24; } /* fix up the blockette length field */ sprintf(wrkstr, "%04d", strlen(buff)); memcpy(&buff[3], wrkstr, strlen(wrkstr)); /* out to file */ if (!out_to_disk(fptr, buff, strlen(buff), 'S')) { free(buff); return 1; /* error */ } /* --------------------------------------- */ free(buff); type62_ptr = type62_ptr->next; } /* while type 62 */ return 0; /* no error condition */}/* ------------------------------------------------------------------------- */int output_abbrev_headers(){ FILE *fptr; char wrkstr[200]; char buff[5000]; char *ch_ptr = buff; int i; struct type30 *type30_ptr = type30_head; /* type 030 blockette */ struct type31 *type31_ptr = type31_head; /* type 031 blockette */ struct type32 *type32_ptr = type32_head; /* type 032 blockette */ struct type33 *type33_ptr = type33_head; /* type 033 blockette */ struct type34 *type34_ptr = type34_head; /* type 034 blockette */ struct type35 *type35_ptr = type35_head; /* type 035 blockette */ if ((fptr = fopen(ABBREV_FNAME, "w")) == NULL) { fprintf(stderr, "output_abbrev_header: Unable to open output file!\n"); perror("output_abbrev_header"); return 0; } while (type30_ptr) { sprintf(ch_ptr, "0300000%s~%04d%03d%02d", type30_ptr->name == NULL ? "" : type30_ptr->name, type30_ptr->code, type30_ptr->family, type30_ptr->number_keys); ch_ptr = buff + strlen(buff); for (i = 0; i < type30_ptr->number_keys; i++) { sprintf(ch_ptr, "%s~", type30_ptr->decoder_key[i] == NULL ? "" : type30_ptr->decoder_key[i]); ch_ptr = buff + strlen(buff); } fix_rec_length(buff); /* out to disk */ if (!out_to_disk(fptr, buff, strlen(buff), 'A')) { fprintf(stderr, "output_abbrev_header: Unable to open output file!\n"); perror("output_abbrev_header"); fclose(fptr); return 0; } type30_ptr = type30_ptr->next; ch_ptr = buff; memset(buff, 0, sizeof(buff)); } /* while type 30 */ ch_ptr = buff; memset(buff, 0, sizeof(buff)); while (type31_ptr) { sprintf(buff, "0310000%04d%s%s~%03d", type31_ptr->code, type31_ptr->class, type31_ptr->comment == NULL ? "" : type31_ptr->comment, type31_ptr->units); fix_rec_length(buff); /* out to disk */ if (!out_to_disk(fptr, buff, strlen(buff), 'A')) { fprintf(stderr, "output_abbrev_header: Unable to open output file!\n"); perror("output_abbrev_header"); fclose(fptr); return 0; } type31_ptr = type31_ptr->next; memset(buff, 0, sizeof(buff)); } /* while type31_ptr */ while (type32_ptr) { sprintf(buff, "0320000%02d%s~%s~%s~", type32_ptr->code, type32_ptr->author == NULL ? "" : type32_ptr->author, type32_ptr->catalog == NULL ? "" : type32_ptr->catalog, type32_ptr->publisher == NULL ? "" : type32_ptr->publisher); fix_rec_length(buff); /* out to disk */ if (!out_to_disk(fptr, buff, strlen(buff), 'A')) { fprintf(stderr, "output_abbrev_header: Unable to open output file!\n"); perror("output_abbrev_header"); fclose(fptr); return 0; } type32_ptr = type32_ptr->next; memset(buff, 0, sizeof(buff)); } /* while type32_ptr */ while (type33_ptr) { sprintf(buff, "0330000%03d%s~", type33_ptr->code, type33_ptr->abbreviation == NULL ? "" : type33_ptr->abbreviation); fix_rec_length(buff); /* out to disk */ if (!out_to_disk(fptr, buff, strlen(buff), 'A')) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -