-
Notifications
You must be signed in to change notification settings - Fork 4
/
gamp.c
97 lines (79 loc) · 2.15 KB
/
gamp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <stdarg.h>
#include "gamp.h"
#define MAXFILE 16 /* max number of input files */
/* show message --------------------------------------------------------------*/
extern int showmsg(char *format, ...)
{
va_list arg;
va_start(arg,format); vfprintf(stderr,format,arg); va_end(arg);
fprintf(stderr,"\r");
return 0;
}
extern void settspan(gtime_t ts, gtime_t te) {}
extern void settime(gtime_t time) {}
static int proccfgfile(char cfgfile[])
{
FILE *fp=NULL;
char *p,tmp[MAXSTRPATH]={'\0'};
//initialization
PPP_Glo.prcType=-1;
PPP_Glo.outFolder[0]='\0';
PPP_Glo.inputPath[0]='\0';
if ((fp=fopen(cfgfile,"r"))==NULL) {
printf("*** ERROR: open configure file failed, please check it!\n");
return 0;
}
while (!feof(fp)) {
tmp[0]='\0';
fgets(tmp,MAXSTRPATH,fp);
if ((tmp!=NULL)&&(tmp[0]=='#')) continue;
if (strstr(tmp,"obs file/folder")) {
p=strrchr(tmp,'=');
sscanf(p+1,"%d",&PPP_Glo.prcType);
tmp[0]='\0';
if (fgets(tmp,MAXSTRPATH,fp)) {
p=strrchr(tmp,'=');
sscanf(p+1,"%[^,]",PPP_Glo.inputPath);
trimSpace(PPP_Glo.inputPath);
cutFilePathSep(PPP_Glo.inputPath);
}
else {
printf("*** ERROR: read obs files path error!");
return 0;
}
break;
}
}
fclose(fp);
if (PPP_Glo.prcType<0||PPP_Glo.prcType>2) {
printf("*** ERROR: read obs files path error!");
return 0;
}
if (PPP_Glo.prcType==0)
procOneFile(PPP_Glo.inputPath,cfgfile,0,1);
else if (PPP_Glo.prcType==1)
batchProc(PPP_Glo.inputPath,cfgfile);
return 1;
}
/* GAMP main -------------------------------------------------------------*/
int main(int argc, char **argv)
{
//char cfgfile[1000]="/data1/PROJECT/projects/gamp_exam/2017244/gamp.cfg";
char *cfgfile;
long t1,t2;
t1=clock();
if (argc==1) {
printf("\n * The input command-line parameter indicating configure file is lost, please check it!\n");
return 0;
}
else {
cfgfile=argv[1];
}
/* find processing configure file */
proccfgfile(cfgfile);
t2=clock();
printf("\n * The total time for running the program: %6.3f seconds\n%c",(double)(t2-t1)/CLOCKS_PER_SEC,'\0');
//printf("Press any key to exit!\n");
//getchar();
return 0;
}