📄 prnt_hdr.c
字号:
/* * This material contains unpublished, proprietary software of * Entropic Research Laboratory, Inc. Any reproduction, distribution, * or publication of this work must be authorized in writing by Entropic * Research Laboratory, Inc., and must bear the notice: * * "Copyright (c) 1986-1990 Entropic Speech, Inc. * "Copyright (c) 1990-1997 Entropic Research Laboratory, Inc. * All rights reserved" * * The copyright notice above does not evidence any actual or intended * publication of this source code. * * Written by: Alan Parker, based on the SDS version by Joe Buck. * Checked by: * Revised by: John Shore for ESPS 3.0 * * Brief description: * support routines for psps; these routines print headers */static char *sccs_id = "%W% %G% ESI/ERL";#include <stdio.h>#include <esps/esps.h>#include <esps/unix.h>void tab(), sort(), print_generic();void print_txtcomment();void pr_full_header();char *file_typeX();int idx_ok();extern vflag;extern full;extern Recursive;extern eflag;voidpr_zfunc(lev,label,zf)int lev;char *label;struct zfunc *zf;{ int i; if(zf == NULL) { tab (lev); (void)printf("No %s zfunc\n",label); return; } tab (lev); (void)printf ("%s: nsiz: %d, dsiz: %d, { ", label,zf->nsiz,zf->dsiz); for (i = 0; i < zf -> nsiz; i++) (void)printf ("%.4g ", zf -> zeros[i]); (void)printf ("} / { "); for (i = 0; i < zf -> dsiz; i++) (void)printf ("%.4g ", zf -> poles[i]); (void)printf ("}\n");}voidtab(indent) { while (indent--) (void)printf(" ");}voidprint_common(indent, hdr)int indent;struct header *hdr;{ int i; char *text = hdr->variable.typtxt; char *comment = hdr->variable.comment; char *refer = hdr->variable.refer; (void)printf("\n"); tab(indent); (void) printf("---Universal Part of Header---\n"); tab(indent); (void) printf("File type: %s\n", file_typeX(hdr->common.type)); tab(indent); (void) printf("File header date: %s, header version: %s\n", hdr->common.date, hdr->common.hdvers); tab(indent); (void) printf("Produced by: %s, version: %s, of: %s, ", hdr->common.prog, hdr->common.vers, hdr->common.progdate); (void) printf("user: %s\n",hdr->common.user); if (hdr->variable.current_path != NULL) { tab(indent); (void) printf("Hostname:path: %s\n",hdr->variable.current_path); } tab(indent); (void) printf("Machine type: %s; file is in %s format.\n", machine_codes[hdr->common.machine_code],hdr->common.edr?"EDR":"NATIVE"); tab(indent); if (hdr->common.ndrec == -1) (void) printf("Number of data records: unknown (input is pipe or record size is variable)\n"); else (void) printf("Number of data records: %d\n",hdr->common.ndrec); tab(indent); (void) printf("Data is %s tagged.\n", (hdr->common.tag ? "" : "not")); if(vflag) { tab(indent); (void) printf("Data format is %d doubles, %d floats, %d longs,\n", hdr->common.ndouble, hdr->common.nfloat, hdr->common.nlong); tab(indent); (void) printf("%d shorts, and %d chars (bytes).\n",hdr->common.nshort, hdr->common.nchar); } if(text != NULL) { tab(indent); (void)printf("typtxt:\n"); print_txtcomment(text, indent + 1); } if(refer != NULL) { tab(indent); (void)printf("refer file: "); (void)fputs(refer,stdout); if(refer[strlen(refer)-1] != '\n') (void)putchar('\n'); } if(comment != NULL) { tab(indent); (void)printf("comment text:\n"); print_txtcomment(comment, indent + 1); } if(hdr->variable.source[0] != NULL) { int j=1; tab(indent); (void)printf("Source files: %s\n",hdr->variable.source[0]); while((hdr->variable.source[j] != NULL) && j < hdr->variable.nnames){ tab(indent); (void)printf(" %s\n",hdr->variable.source[j++]); } } if(hdr->variable.refhd != NULL) { tab(indent); (void)printf("There is a reference header.\n"); } else { tab(indent); (void)printf("There is no reference header.\n"); } for (i=0; i<NSPARES; i++) if (hdr->common.spares[i] != 0) { tab(indent); (void) printf("spares[%d]: 0x%x\n", i, (int) hdr->common.spares[i]); } (void)printf("\n"); return;}voidprint_generic(indent,hdr)int indent;struct header *hdr;{ char **names; int j,i,k=0,num,size,type; int strcmp (); int swap (); if(hdr->variable.ngen == 0) return; (void)printf("\n"); tab(indent); (void) printf("---Generic Part of Header---"); names = genhd_list(&num,hdr); /* sort the generic header names */ sort (names, num, strcmp, swap); for (i=0; i<num; i++) { char *cptr; double *dptr; float *fptr; long *lptr; short *sptr; FILE *Fptr; struct header *hptr; type = genhd_type(names[i],&size,hdr); (void)printf("\n"); tab(indent); if (size > 7 && (type != EFILE && type != AFILE)) (void)printf("%s[0]: %s%s%s ", names[i],vflag ? "(":"", vflag ? type_codes[type]:"", vflag ? ")":""); else (void)printf("%s: %s%s%s ", names[i], vflag ? "(":"", vflag ? type_codes[type]:"", vflag ? ")":""); k=0; cptr = get_genhd(names[i],hdr); if (type == CHAR && size > 1) { (void)printf("%s",cptr); tab(indent); } else if ((type == AFILE || type == EFILE) && !eflag) { (void)printf("%s",cptr); tab(indent); } else if (type == AFILE && eflag) { if ((Fptr = get_genhd_afile(names[i],hdr)) == NULL) (void)printf("Cannot get external file %s.\n",cptr); else { int c; (void)printf("External AFILE: %s\n",cptr); tab(indent+1); while((c=fgetc(Fptr)) != EOF) { (void)putchar(c); if(c == '\n') tab(indent+1); } (void)printf("---EOF on %s---\n",cptr); tab(indent+1); } } else if (type == EFILE && eflag) { if ((hptr = get_genhd_efile(names[i],hdr)) == NULL) (void)printf( "cannot get external file %s, or it is not an ESPS file.\n", cptr); else { (void)printf("External EFILE "); pr_full_header (cptr, hptr, Recursive, indent+1); } } else for (j=0;j<size; j++) { k++; if(k>7) { (void)printf("\n"); tab(indent); (void)printf("%s[%d]: ",names[i],j); k=0; } switch(type) { case DOUBLE: dptr = get_genhd_d(names[i],hdr); (void)printf("%lg ",dptr[j]); break; case FLOAT: fptr = get_genhd_f(names[i],hdr); (void)printf("%g ",fptr[j]); break; case SHORT: sptr = get_genhd_s(names[i],hdr); (void)printf("%d ",sptr[j]); break; case LONG: lptr = get_genhd_l(names[i],hdr); (void)printf("%ld ",lptr[j]); break; case CHAR: cptr = get_genhd(names[i],hdr); (void)printf("0x%x ",cptr[j]); break; case CODED: { char **codes = genhd_codes(names[i],hdr); sptr = get_genhd_s(names[i],hdr); if(idx_ok(sptr[j],codes)) (void)printf("%s ",codes[sptr[j]]); else (void)printf("invalid code %d ",sptr[j]); break; } } } if (vflag && type == CODED) { char **s; tab(indent); (void)printf("\n Possible coded values:"); s = genhd_codes(names[i],hdr); while(*s != NULL) { tab(indent); (void)printf("\n %s",*s++); } } if (vflag && size > 1) { tab(indent); (void)printf("\n Size: %d",size); } } (void)printf("\n");}voidprint_sd(indent, hdr)int indent;struct header *hdr;{ struct sd_header *h = hdr->hd.sd; int i; tab(indent); (void) printf("---Type Specific Part of Header (SD)---\n"); tab(indent); if(idx_ok(h->equip,equip_codes)) (void) printf("equip: %s\n",equip_codes[h->equip]); else (void) printf("equip: invalid code %d\n",(int)h->equip); tab(indent); (void) printf("max_value: %g, sf: %g, src_sf: %g\n", h->max_value, h->sf, h->src_sf); tab(indent); if(idx_ok(h->synt_method,synt_methods)) (void) printf("synt_method: %s\n",synt_methods[h->synt_method]); else (void) printf("synt_method: invalid code %d\n",(int)h->synt_method); tab(indent); (void) printf("scale: %g, dcrem: %g\n",h->scale,h->dcrem); tab(indent); if(idx_ok(h->q_method,synt_methods)) (void) printf("q_method: %s\n",quant_methods[h->q_method]); else (void) printf("q_method: invalid code %d\n",(int)h->q_method); tab(indent); if(idx_ok(h->v_excit_method,excit_methods)) (void) printf("v_excit_method: %s\n",excit_methods[h->v_excit_method]); else (void) printf("v_excit_method: invalid code %d\n",(int)h->v_excit_method); tab(indent); if(idx_ok(h->uv_excit_method,excit_methods)) (void) printf("uv_excit_method: %s\n",excit_methods[h->uv_excit_method]); else (void) printf("uv_excit_method: invalid code %d\n",(int)h->uv_excit_method); tab(indent); (void) printf("spare1: %d, nchan: %d\n",(int)h->spare1,(int)h->nchan); tab(indent); if(idx_ok(h->synt_interp,synt_inter_methods)) (void) printf("synt_interp: %s\n",synt_inter_methods[h->synt_interp]); else (void) printf("synt_interp: invalid code %d\n",(int)h->synt_interp); tab(indent); if(idx_ok(h->synt_pwr,synt_inter_methods)) (void) printf("synt_pwr: %s\n",synt_pwr_codes[h->synt_pwr]); else (void) printf("synt_pwr: invalid code %d\n",(int)h->synt_pwr); tab(indent); if(idx_ok(h->synt_rc,synt_inter_methods)) (void) printf("synt_rc: %s\n",synt_ref_methods[h->synt_rc]); else (void) printf("synt_rc: invalid code %d\n",(int)h->synt_rc); tab(indent); (void) printf("synt_order: %d\n",(int)h->synt_order); tab(indent); (void) printf("start: %ld, nan: %ld\n",h->start,h->nan); for (i=0; i<SD_SPARES; i++) if (h->spares[i] != 0) { tab(indent); (void) printf("spares[%d]: 0x%x\n", i,(int) h->spares[i]); } pr_zfunc(indent,"prefilter",h->prefilter); pr_zfunc(indent,"de_emp",h->de_emp); return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -