📄 atospsg.c
字号:
if (type == FT_SD) geth(h->hd.sd->uv_excit_method); break; case TAG_spare1: if (type == FT_SD) geth(h->hd.sd->spare1); break; case TAG_nchan: if (type == FT_SD) geth(h->hd.sd->nchan); break; case TAG_synt_interp: if (type == FT_SD) geth(h->hd.sd->synt_interp); break; case TAG_synt_pwr: if (type == FT_SD) geth(h->hd.sd->synt_pwr); break; case TAG_synt_rc: if (type == FT_SD) geth(h->hd.sd->synt_rc); break; case TAG_synt_order: if (type == FT_SD) geth(h->hd.sd->synt_order); break; case TAG_prefilter: if(type == FT_SD) h->hd.sd->prefilter = make_z (buf + 3); break; case TAG_de_emp: if (type == FT_SD) h->hd.sd->de_emp = make_z (buf + 3); break; case TAG_Fea: cvt_feahdr(in, h); break; case TAG_gen: sscanf(buf+3,"%s %d %ld",gen_name,&gen_type,&gen_size); if (gen_type == CODED) { code_list = (char **)malloc(1); code_list[0] = NULL; } break; case TAG_coded: if (gen_type == CODED) addstr(savestring(buf+3), &code_list); break; case TAG_gen_value: (void) add_genhd(gen_name,gen_type,(int)gen_size,NULL,code_list,h); make_gens(gen_name,h,buf+3); break; case TAG_max_num: if(type == FT_FILT) geth(h->hd.filt->max_num); break; case TAG_max_den: if(type == FT_FILT) geth(h->hd.filt->max_den); break; case TAG_func_spec: if(type == FT_FILT) geth(h->hd.filt->func_spec); break; case TAG_nbands: if(type == FT_FILT) geth(h->hd.filt->nbands); break; case TAG_npoints: if(type == FT_FILT) geth(h->hd.filt->npoints); break; case TAG_g_size: if(type == FT_FILT) geth(h->hd.filt->g_size); break; case TAG_nbits: if(type == FT_FILT) geth(h->hd.filt->nbits); break; case TAG_filttype: if(type == FT_FILT) geth(h->hd.filt->type); break; case TAG_filtmethod: if(type == FT_FILT) geth(h->hd.filt->method); break; case TAG_bandedges: if(type == FT_FILT) { h->hd.filt->bandedges = malloc_f(h->hd.filt->nbands*2); spsassert(h->hd.filt->bandedges,"calloc failed"); get_array_f(buf+3,h->hd.filt->bandedges,h->hd.filt->nbands*2); } break; case TAG_points: if(type == FT_FILT) { h->hd.filt->points = malloc_f(h->hd.filt->npoints); spsassert(h->hd.filt->points,"calloc failed"); get_array_f(buf+3,h->hd.filt->points,h->hd.filt->npoints); } break; case TAG_gains: if(type == FT_FILT && h->hd.filt->func_spec == BAND) { h->hd.filt->gains = malloc_f(h->hd.filt->nbands); spsassert(h->hd.filt->gains,"calloc failed"); get_array_f(buf+3,h->hd.filt->gains,h->hd.filt->nbands); } if(type == FT_FILT && h->hd.filt->func_spec == POINT) { h->hd.filt->gains = malloc_f(h->hd.filt->npoints); spsassert(h->hd.filt->gains,"calloc failed"); get_array_f(buf+3,h->hd.filt->gains,h->hd.filt->npoints); } break; case TAG_wts: if(type == FT_FILT && h->hd.filt->func_spec == BAND) { h->hd.filt->wts = malloc_f(h->hd.filt->nbands); spsassert(h->hd.filt->wts,"calloc failed"); get_array_f(buf+3,h->hd.filt->wts,h->hd.filt->nbands); } if(type == FT_FILT && h->hd.filt->func_spec == POINT) { h->hd.filt->wts = malloc_f(h->hd.filt->npoints); spsassert(h->hd.filt->wts,"calloc failed"); get_array_f(buf+3,h->hd.filt->wts,h->hd.filt->npoints); } break; default: Fprintf (stderr, "%s: Bad tag code (%x) in %s\n", ProgName, tag, in_file); exit (1); } /* end switch (tag) */ } /* end if else clause */ } /* end while (1) */} /* end readhead () */static voidmake_gens(name, hd, str)char *name, *str;struct header *hd;{ int i,size, type; char *c_ptr = get_genhd(name,hd); double *d_ptr; float *f_ptr; long *l_ptr; short *s_ptr; d_ptr = (double *)c_ptr; f_ptr = (float *)c_ptr; l_ptr = (long *)c_ptr; s_ptr = (short *)c_ptr; type = genhd_type(name, &size, hd); for (i = 0; i < size; i++) { switch (type) { case DOUBLE: *d_ptr++ = atof (str); break; case FLOAT: *f_ptr++ = atof (str); break; case LONG: *l_ptr++ = atoi (str); break; case SHORT: case CODED: *s_ptr++ = atoi (str); break; } str = nextval (str); }} static intatoh (str)char *str;{ long tmp = 0; (void) sscanf (str, "%lx", &tmp); return tmp;}readrec (in, out, h)FILE *in, *out;struct header *h;{ long tag; register int i; static recnum = 0; recnum += 1; if (BOOL (h->common.tag)) { if (fscanf (in, "%lx", &tag) != 1) synerr ("bad record tag", recnum); (void) fwrite ((char *) & tag, sizeof tag, (int) 1, out); } if (h->common.ndouble) { double *dbuf = malloc_d(h->common.ndouble); spsassert(dbuf,"malloc failed"); for (i = 0; i < h->common.ndouble; i++) { if (fscanf (in, "%lf", &dbuf[i]) != 1) synerr ("bad double datum", recnum); } (void) fwrite((char *)dbuf,sizeof(double), (int)h->common.ndouble,out); } if (h->common.nfloat) { float *fbuf = malloc_f(h->common.nfloat); spsassert(fbuf,"malloc failed"); for (i = 0; i < h->common.nfloat; i++) { if (fscanf (in, "%f", &fbuf[i]) != 1) synerr ("bad float datum", recnum); } (void) fwrite ((char *)fbuf,sizeof (float), (int)h->common.nfloat,out); } if (h->common.nlong) { long *lbuf = malloc_l(h->common.nlong); spsassert(lbuf,"malloc failed"); for (i = 0; i < h->common.nlong; i++) { if (fscanf (in, "%ld", &lbuf[i]) != 1) synerr ("bad long datum", recnum); } (void) fwrite ((char *)lbuf, sizeof (long), (int)h->common.nlong, out); } if (h->common.nshort) { short *sbuf = malloc_s(h->common.nshort); long *lbuf = malloc_l(h->common.nshort); spsassert(sbuf,"malloc failed"); spsassert(lbuf,"malloc failed"); for (i = 0; i < h->common.nshort; i++) { if (fscanf (in, "%ld", &lbuf[i]) != 1) synerr ("bad short datum", recnum); } for (i = 0; i < h->common.nshort; i++) sbuf[i] = lbuf[i]; (void) fwrite ((char *)sbuf,sizeof (short), (int)h->common.nshort,out); } if (h->common.nchar) { char *cbuf = malloc(h->common.nchar); spsassert(cbuf,"malloc failed"); for (i = 0; i < h->common.nchar; i++) { if (fscanf (in, "%x", &cbuf[i]) != 1) synerr ("bad char datum", recnum); } (void) fwrite ((char *)cbuf,sizeof (char), (int)h->common.nchar,out); }} /* end readrec() */struct zfunc *make_z (str)register char *str;{ register int i; int nz, np; float *num; float *den; nz = atoi (str); str = nextval (str); np = atoi (str); num = (float *)malloc(nz*sizeof(float)); den = (float *)malloc(np*sizeof(float)); for (i = 0; i < nz; i++) { str = nextval (str); num[i] = atof (str); } for (i = 0; i < np; i++) { str = nextval (str); den[i] = atof (str); } return new_zfunc (nz, np, num, den);}get_array_f(str, ptr, size)char *str;float *ptr;int size;{ int i; assert(size && ptr && str); for (i = 0; i <size; i++) { ptr[i] = atof (str); str = nextval (str); }} char *nextval (s)char *s;{ if ((s = index (s, ' ')) != NULL) { while (*s == ' ') s++; if (*s != 0) return s; } Fprintf (stderr, "%s: data syntax error in %s\n", ProgName, in_file); Fprintf (stderr, "nextval: remaining buffer: %s\n",s); exit (1); /* NOTREACHED */}char *cvt_typtxt (s)char *s;{ register char *p = s; while (*p) { if (*p == '\r') *p = '\n'; p++; } return s;}synerr (txt, n)char *txt;int n;{ if (n < 0) Fprintf (stderr, "%s: syntax error in %s: %s, header level %d\n", ProgName, in_file, txt, -n); else Fprintf (stderr, "%s: syntax error in %s: %s, record %d\n", ProgName, in_file, txt, n); exit (1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -