/************************************************************************/ /* Build_SEED - Build SEED volumes from user request. */ /* Runs programs: netdc2meta */ /* meta2seed (which runs read_POD_Request) */ /* pod */ /* Input: netdc request file and/or POD request file OR */ /* command line channel and time specification. */ /************************************************************************/ #include #include #include #include #include #include #include #include #include #include #define WORKDIR "/tmp" char *syntax[] = { "%s [-h] [-n netdc_file | [-f date -t date | -s interval] ", " [-S station] [-N network] [-C channel] [-L location]", " [-p pod_file] [-D datapath] [-o seed_file] [-I] ", " [-w workdir] [-b poddir] [-d n]", " where:", " -h Prints out a summary of the available options.", " -n filename Specifies the name of the NetDC requests file.", " -f date From date - ignore data before this date.", " -t date To date - ignore data from this date on.", " Date can be in formats:", " yyyy/mm/dd/hh:mm:ss.ffff", " yyyy/mm/dd.hh:mm:ss.ffff", " yyyy/mm/dd,hh:mm:ss.ffff", " yyyy.ddd,hh:mm:ss.ffff", " yyyy,ddd,hh:mm:ss.ffff", " You may leave off any trailing 0 components of the time.", " -s interval span interval. Alternate way of specifying end time.", " Interval can be an integer followed immediately by", " s, m, h, or d for seconds, minutes, hours, or days.", " -S station_list", " A comma-delimited list of station names for the specified time.", " -N network_list", " A comma-delimited list of network names for the specified time.", " -C channel_list", " A comma-delimited list of channel names for the specified time.", " -L locationlist", " A list of location names for the specified time.", " -p filename Specifies the name of an additional POD requests file.", " -D datapath Additional explicit POD DATA_PATH entry.", " -o filename Specifies the name of the output SEED volume.", " -I Generates a Dataless SEED volume.", " -w dir Specifies the path of the working directory.", " If none specified, a temporary working directory", " will be created in /tmp and deleted when done.", " -b dir Specifies the path and name of the POD request", " directory structure (HAR000).", " -d n Debug option (may be added)", " 1-3 POD debug flags", " 4 Print commands", " 8 Keep query directory", " 16 Keep waveform directory", NULL }; #define DEBUG(val) (debug_flag & val) #define DEBUG_POD 3 #define DEBUG_CMD 4 #define DEBUG_KEEP 8 #define METAFILE "Query.in" #define MAXJOINLEN 65536 char *cmdname; typedef struct _listhead { char **name; int n; } LISTHEAD; LISTHEAD station; LISTHEAD channel; LISTHEAD location; LISTHEAD network; LISTHEAD add_to_list (LISTHEAD l, char *clist) { char *str = strdup(clist); char *p = str; char *pc; char *e; while (p != NULL && *p != 0) { e = strchr(p,','); if (e != NULL) *e = '\0'; if (l.name == NULL) l.name = (char **)malloc((l.n+1) * sizeof(char **)); else l.name = (char **)realloc(l.name, (l.n+1) * sizeof(char **)); l.name[l.n] = strdup(p); for (pc=l.name[l.n]; *pc; pc++) { /* 1. Replace "-" with blank (for location code). */ if (*pc == '-') *pc = ' '; /* 2. Replace "*" with "%" for unix->sql 0-n char wildcard. */ if (*pc == '*') *pc = '%'; /* 3. Replace "?" with "_" for unix->sql 1 char wildcard. */ if (*pc == '?') *pc = '_'; } l.n++; p = (e!=NULL) ? e+1 : NULL; } free(str); /*:: Debug {int i;for (i=0;i