/* open output files ---------------------------------------------------------*/ static int openfile(FILE **ofp, char *files[], const char *file, const rnxopt_t *opt, nav_t *nav) { char path[1024]; int i; trace(3,"openfile:\n"); for (i=0;i<NOUTFILE;i++) { if (!*files[i]) continue; strcpy(path,files[i]); /* check overwrite input file and modify output file */ if (!strcmp(path,file)) strcat(path,"_"); /* create directory if not exist */ createdir(path); if (!(ofp[i]=fopen(path,"w"))) { showmsg("file open error: %s",path); for (i--;i>=0;i--) if (ofp[i]) fclose(ofp[i]); return 0; } /* write header to file */ switch (i) { case 0: outrnxobsh (ofp[0],opt,nav); break; case 1: outrnxnavh (ofp[1],opt,nav); break; case 2: outrnxgnavh(ofp[2],opt,nav); break; case 3: outrnxhnavh(ofp[3],opt,nav); break; case 4: outrnxqnavh(ofp[4],opt,nav); break; case 5: outrnxlnavh(ofp[5],opt,nav); break; case 6: outrnxcnavh(ofp[6],opt,nav); break; } } return 1; }
/* close output files --------------------------------------------------------*/ static void closefile(FILE **ofp, const rnxopt_t *opt, nav_t *nav) { int i; trace(3,"closefile:\n"); for (i=0;i<NOUTFILE;i++) { if (!ofp[i]) continue; /* rewrite header to file */ rewind(ofp[i]); switch (i) { case 0: outrnxobsh (ofp[0],opt,nav); break; case 1: outrnxnavh (ofp[1],opt,nav); break; case 2: outrnxgnavh(ofp[2],opt,nav); break; case 3: outrnxhnavh(ofp[3],opt,nav); break; case 4: outrnxqnavh(ofp[4],opt,nav); break; case 5: outrnxlnavh(ofp[5],opt,nav); break; } fclose(ofp[i]); } }