1 | |
---|
2 | /* |
---|
3 | * THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE |
---|
4 | * CHECKED IT OUT USING THE COMMAND CHECKOUT. |
---|
5 | * |
---|
6 | * $Id$ |
---|
7 | * |
---|
8 | * Revision history: |
---|
9 | * $Log$ |
---|
10 | * Revision 1.13 2004/04/12 22:09:30 dietz |
---|
11 | * included string.h |
---|
12 | * |
---|
13 | * Revision 1.12 2002/03/22 20:44:24 lucky |
---|
14 | * pre v6.1 checkin |
---|
15 | * |
---|
16 | * Revision 1.11 2001/08/02 22:40:21 davidk |
---|
17 | * typecast some double to float assignments to eliminate compiler |
---|
18 | * warnings on NT. |
---|
19 | * |
---|
20 | * Revision 1.10 2001/04/17 17:49:37 lucky |
---|
21 | * *** empty log message *** |
---|
22 | * |
---|
23 | * Revision 1.8 2000/10/02 21:29:58 lucky |
---|
24 | * The Debug printout of the entire file is now done only in extreme cases of |
---|
25 | * Debug being set to 10. |
---|
26 | * Changed the max length of phase field to PHA_LEN |
---|
27 | * |
---|
28 | * Revision 1.7 2000/09/12 18:13:25 lucky |
---|
29 | * Plugged memory leak with nsnbuf. |
---|
30 | * |
---|
31 | * Revision 1.6 2000/06/26 20:36:41 lucky |
---|
32 | * NSN deletion now works! |
---|
33 | * |
---|
34 | * Revision 1.5 2000/06/26 20:04:39 lucky |
---|
35 | * When encountering a delete message, we return RETURN_DELETE to the |
---|
36 | * calling program so that it can handle it appropriately. |
---|
37 | * |
---|
38 | * Revision 1.4 2000/05/31 16:16:58 lucky |
---|
39 | * Fixed the check for deletion message -- used to be in line #4, now it |
---|
40 | * #3 |
---|
41 | * |
---|
42 | * Revision 1.3 2000/05/02 19:50:54 lucky |
---|
43 | * Cosmetic fixes needed to have NT compile without warnings. |
---|
44 | * |
---|
45 | * Revision 1.2 2000/04/06 16:03:07 lucky |
---|
46 | * We now check to see if we got a Delete message. For now, we don't do anything |
---|
47 | * about it, only log a message and return FAILURE in hopes that the calling |
---|
48 | * program will deal with the consequences. |
---|
49 | * |
---|
50 | * Revision 1.1 2000/02/14 18:51:48 lucky |
---|
51 | * Initial revision |
---|
52 | * |
---|
53 | * |
---|
54 | */ |
---|
55 | |
---|
56 | /* |
---|
57 | |
---|
58 | parse_usnsn.c |
---|
59 | |
---|
60 | |
---|
61 | Routines used to parse a text message from NEIC. |
---|
62 | |
---|
63 | A successful call to ParseNSNMsg fills the NSNStruct |
---|
64 | with values from the text message contained in NsnMsg. |
---|
65 | |
---|
66 | If debug is not 0, debug info will be written. If debug > 1, |
---|
67 | a file with the parsed values of the message will be |
---|
68 | written in the debug_dir directory. |
---|
69 | |
---|
70 | ParseNSNMsg returns EW_SUCCESS if everything goes well, |
---|
71 | otherwise it returns EW_FAILURE. |
---|
72 | |
---|
73 | Only ParseNSNMsg() should be called from outside of this |
---|
74 | file. All other functions in here are utilities used |
---|
75 | by ParseNSNMsg() |
---|
76 | |
---|
77 | */ |
---|
78 | |
---|
79 | |
---|
80 | #include <stdio.h> |
---|
81 | #include <stdlib.h> |
---|
82 | #include <string.h> |
---|
83 | #include <math.h> |
---|
84 | #include <parse_usnsn.h> |
---|
85 | #include <earthworm.h> |
---|
86 | #include <rw_mag.h> |
---|
87 | |
---|
88 | #define MAX_LINES 1000 |
---|
89 | #define MAX_LINE_SIZE 300 |
---|
90 | |
---|
91 | |
---|
92 | extern int epochsec17 (double *, char *); |
---|
93 | |
---|
94 | static int ConvertNSNMsg (char *, int, char **, int *); |
---|
95 | static int ParsePhaseMagnitude (char *, PhaseMag *); |
---|
96 | static int ParsePhase (char *, Phase *, char *, int *, double *); |
---|
97 | static int ParseMagnitude (char *, OriginMag *); |
---|
98 | static int ParseEllipse (char *, double, Err_Elipse *); |
---|
99 | static int AppendDateStr (char *, char *); |
---|
100 | static int BuildDateStr (char *, char *); |
---|
101 | static int GetNextLine (char **, int *, char *); |
---|
102 | |
---|
103 | /************************************************************************ |
---|
104 | * ParseNSNMsg() - Fill the msg struct from the text supplied in |
---|
105 | * nsnbuf. |
---|
106 | ************************************************************************/ |
---|
107 | int ParseNSNMsg (char *NsnMsg, int msgLen, |
---|
108 | NSNStruct *msgStruct, int debug, char *debug_dir) |
---|
109 | { |
---|
110 | int i, j; |
---|
111 | char datestr[15]; |
---|
112 | char DateStr[20]; |
---|
113 | char tmp1[256]; |
---|
114 | char tmp2[256]; |
---|
115 | char tmp3[256]; |
---|
116 | int lineno; |
---|
117 | FILE *fp; |
---|
118 | char filename[100]; |
---|
119 | char **nsnbuf; |
---|
120 | int nlines; |
---|
121 | int isAuto; |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | if ((NsnMsg == NULL) || (msgStruct == NULL) || (debug_dir == NULL)) |
---|
126 | { |
---|
127 | logit ("e", "Invalid parameters passed in.\n"); |
---|
128 | return EW_FAILURE; |
---|
129 | } |
---|
130 | |
---|
131 | nsnbuf = (char **) malloc (MAX_LINES * sizeof (char *)); |
---|
132 | for (i = 0; i < MAX_LINES; i++) |
---|
133 | nsnbuf[i] = (char *) malloc (MAX_LINE_SIZE * sizeof (char)); |
---|
134 | |
---|
135 | |
---|
136 | /* Create nsnbuf (array of lines) for easier parsing |
---|
137 | ****************************************************/ |
---|
138 | if (ConvertNSNMsg (NsnMsg, msgLen, nsnbuf, &nlines) != EW_SUCCESS) |
---|
139 | { |
---|
140 | logit ("", "Call to ConvertNSNMsg failed\n"); |
---|
141 | return EW_FAILURE; |
---|
142 | } |
---|
143 | |
---|
144 | |
---|
145 | /* skip the first two lines */ |
---|
146 | lineno = 2; |
---|
147 | |
---|
148 | |
---|
149 | /* First, we have to see if this is a deletion message. |
---|
150 | We don't do anything with it, so if we get it, we'll |
---|
151 | just return FAILURE, and let the calling program deal |
---|
152 | with the ramifications. |
---|
153 | ********************************************************/ |
---|
154 | sscanf (nsnbuf[lineno + 3], "%s\n", tmp1); |
---|
155 | if (strcmp (tmp1, "EVENT") == 0) |
---|
156 | { |
---|
157 | /* Yup, it's a deletion message */ |
---|
158 | |
---|
159 | /* extract the NSN event key */ |
---|
160 | strncpy (msgStruct->EventKey, (nsnbuf[lineno + 3] + 21), 4); |
---|
161 | msgStruct->EventKey[4] = '\0'; |
---|
162 | |
---|
163 | return RETURN_DELETE; |
---|
164 | } |
---|
165 | |
---|
166 | /* see if this is an automatic, or a reviewed solution */ |
---|
167 | sscanf (nsnbuf[lineno], "%s\n", tmp1); |
---|
168 | if (strcmp (tmp1, "The") == 0) |
---|
169 | { |
---|
170 | /* Yup, it's an automatic: skip four more lines */ |
---|
171 | lineno = lineno + 4; |
---|
172 | isAuto = 1; |
---|
173 | } |
---|
174 | else |
---|
175 | { |
---|
176 | /* it's a reviewed solution message: we are at the first line */ |
---|
177 | isAuto = 0; |
---|
178 | } |
---|
179 | |
---|
180 | |
---|
181 | /* |
---|
182 | * line 1; extract date, comment, event key, whether it is preliminary |
---|
183 | *********************************************************************/ |
---|
184 | strncpy (datestr, (nsnbuf[lineno] + DATE_BASE), 11); |
---|
185 | datestr[11] = '\0'; |
---|
186 | |
---|
187 | if (BuildDateStr (datestr, msgStruct->EventDate) != EW_SUCCESS) |
---|
188 | { |
---|
189 | logit ("e", "Call to BuildDateStr failed.\n"); |
---|
190 | return EW_FAILURE; |
---|
191 | } |
---|
192 | |
---|
193 | strncpy (msgStruct->EventKey, (nsnbuf[lineno] + EVENT_KEY_BASE), 4); |
---|
194 | msgStruct->EventKey[4] = '\0'; |
---|
195 | |
---|
196 | if (nsnbuf[lineno][PRELIM_BASE] == 'p') |
---|
197 | { |
---|
198 | msgStruct->automatic = 1; |
---|
199 | } |
---|
200 | else |
---|
201 | { |
---|
202 | msgStruct->automatic = 0; |
---|
203 | } |
---|
204 | |
---|
205 | |
---|
206 | /* |
---|
207 | * line 2; extract origin time and error |
---|
208 | *********************************************************************/ |
---|
209 | lineno = lineno + 1; |
---|
210 | if (GetNextLine (nsnbuf, &lineno, "ot") == EW_SUCCESS) |
---|
211 | { |
---|
212 | sscanf (nsnbuf[lineno], " ot = %s +/- %s\n", tmp1, tmp2); |
---|
213 | |
---|
214 | strcpy (DateStr, msgStruct->EventDate); |
---|
215 | if (AppendDateStr (DateStr, tmp1) != EW_SUCCESS) |
---|
216 | { |
---|
217 | logit ("e", "Call to AppendDateStr failed.\n"); |
---|
218 | return EW_FAILURE; |
---|
219 | } |
---|
220 | |
---|
221 | epochsec17 (&msgStruct->ot, DateStr); |
---|
222 | msgStruct->ot_err = (double) atof (tmp2); |
---|
223 | } |
---|
224 | else |
---|
225 | { |
---|
226 | logit ("e", "GetNextLine returned EW_FAILURE; exitting\n"); |
---|
227 | return EW_FAILURE; |
---|
228 | } |
---|
229 | |
---|
230 | /* |
---|
231 | * line 3; extract latitude |
---|
232 | *********************************************************************/ |
---|
233 | lineno = lineno + 1; |
---|
234 | if (GetNextLine (nsnbuf, &lineno, "lat") == EW_SUCCESS) |
---|
235 | { |
---|
236 | sscanf (nsnbuf[lineno], " lat = %s +/- %s\n", tmp1, tmp2); |
---|
237 | |
---|
238 | msgStruct->lat = (float) atof (tmp1); |
---|
239 | msgStruct->lat_err = (float) atof (tmp2); |
---|
240 | } |
---|
241 | else |
---|
242 | { |
---|
243 | logit ("e", "GetNextLine returned EW_FAILURE; exitting\n"); |
---|
244 | return EW_FAILURE; |
---|
245 | } |
---|
246 | |
---|
247 | /* |
---|
248 | * line 4; extract longitude |
---|
249 | *********************************************************************/ |
---|
250 | lineno = lineno + 1; |
---|
251 | if (GetNextLine (nsnbuf, &lineno, "lon") == EW_SUCCESS) |
---|
252 | { |
---|
253 | sscanf (nsnbuf[lineno], " lon = %s +/- %s\n", tmp1, tmp2); |
---|
254 | |
---|
255 | msgStruct->lon = (float) atof (tmp1); |
---|
256 | msgStruct->lon_err = (float) atof (tmp2); |
---|
257 | } |
---|
258 | else |
---|
259 | { |
---|
260 | logit ("e", "GetNextLine returned EW_FAILURE; exitting\n"); |
---|
261 | return EW_FAILURE; |
---|
262 | } |
---|
263 | |
---|
264 | |
---|
265 | /* |
---|
266 | * line 5; extract depth |
---|
267 | *********************************************************************/ |
---|
268 | lineno = lineno + 1; |
---|
269 | if (GetNextLine (nsnbuf, &lineno, "dep") == EW_SUCCESS) |
---|
270 | { |
---|
271 | /* Depth could have an error */ |
---|
272 | if (nsnbuf[lineno][DEPTH_BASE] == '+') |
---|
273 | { |
---|
274 | sscanf (nsnbuf[lineno], " dep = %s +/- %s\n", tmp1, tmp2); |
---|
275 | msgStruct->depth = (float) atof (tmp1); |
---|
276 | msgStruct->depth_err = (float) atof (tmp2); |
---|
277 | |
---|
278 | } |
---|
279 | else |
---|
280 | { |
---|
281 | /* no +/- error, we have some string there */ |
---|
282 | sscanf (nsnbuf[lineno], " dep = %s\n", tmp1); |
---|
283 | msgStruct->depth = (float) atof (tmp1); |
---|
284 | msgStruct->depth_err = (double) 0.0; |
---|
285 | msgStruct->depth_fixed = 1; |
---|
286 | } |
---|
287 | } |
---|
288 | else |
---|
289 | { |
---|
290 | logit ("e", "GetNextLine returned EW_FAILURE; exitting\n"); |
---|
291 | return EW_FAILURE; |
---|
292 | } |
---|
293 | |
---|
294 | /* |
---|
295 | * line 6; extract number of phases and std error |
---|
296 | *********************************************************************/ |
---|
297 | lineno = lineno + 1; |
---|
298 | if (GetNextLine (nsnbuf, &lineno, "nph") == EW_SUCCESS) |
---|
299 | { |
---|
300 | sscanf (nsnbuf[lineno], " nph = %s of %s se = %s \n", tmp1, tmp2, tmp3); |
---|
301 | msgStruct->nph_used = atoi (tmp1); |
---|
302 | msgStruct->nph_assoc = atoi (tmp2); |
---|
303 | msgStruct->std_error = (double) atof (tmp3); |
---|
304 | } |
---|
305 | else |
---|
306 | { |
---|
307 | logit ("e", "GetNextLine returned P3DB_FAILURE; exitting\n"); |
---|
308 | return EW_FAILURE; |
---|
309 | } |
---|
310 | |
---|
311 | |
---|
312 | /* |
---|
313 | * line 7; extract the error elipse |
---|
314 | *********************************************************************/ |
---|
315 | lineno = lineno + 1; |
---|
316 | if (GetNextLine (nsnbuf, &lineno, "error") == EW_SUCCESS) |
---|
317 | { |
---|
318 | strncpy (tmp1, (nsnbuf[lineno] + ELLIPSE_BASE), (size_t) ELLIPSE_LENGTH); |
---|
319 | tmp1[ELLIPSE_LENGTH] ='\0'; |
---|
320 | |
---|
321 | if (ParseEllipse (tmp1, msgStruct->depth_err, &msgStruct->error) != EW_SUCCESS) |
---|
322 | { |
---|
323 | logit ("e", "Call to ParseEllipse failed.\n"); |
---|
324 | return EW_FAILURE; |
---|
325 | } |
---|
326 | } |
---|
327 | else |
---|
328 | { |
---|
329 | logit ("e", "GetNextLine returned EW_FAILURE; exitting\n"); |
---|
330 | return EW_FAILURE; |
---|
331 | } |
---|
332 | |
---|
333 | /* |
---|
334 | * line 8; extract magnitudes |
---|
335 | *********************************************************************/ |
---|
336 | lineno = lineno + 1; |
---|
337 | if (GetNextLine (nsnbuf, &lineno, "mb") == EW_SUCCESS) |
---|
338 | { |
---|
339 | msgStruct->numMags = 5; |
---|
340 | if (ParseMagnitude (nsnbuf[lineno], msgStruct->O_mag) != EW_SUCCESS) |
---|
341 | { |
---|
342 | logit ("e", "Call to ParseMagnitude failed.\n"); |
---|
343 | return EW_FAILURE; |
---|
344 | } |
---|
345 | } |
---|
346 | else |
---|
347 | { |
---|
348 | logit ("e", "GetNextLine returned EW_FAILURE; exitting\n"); |
---|
349 | return EW_FAILURE; |
---|
350 | } |
---|
351 | |
---|
352 | /* |
---|
353 | * line 9; find the beginning of the picks section |
---|
354 | *********************************************************************/ |
---|
355 | lineno = lineno + 1; |
---|
356 | if (GetNextLine (nsnbuf, &lineno, "sta") == EW_SUCCESS) |
---|
357 | { |
---|
358 | |
---|
359 | /* Now, read and parse all the phases */ |
---|
360 | msgStruct->nph_actual = 0; |
---|
361 | msgStruct->Dmin = EARTH_CIRCUM; |
---|
362 | for (i = 0; i < msgStruct->nph_assoc; i++) |
---|
363 | { |
---|
364 | lineno = lineno + 1; |
---|
365 | if (ParsePhase (nsnbuf[lineno], &msgStruct->phases[msgStruct->nph_actual], |
---|
366 | msgStruct->EventDate, &msgStruct->nph_actual, |
---|
367 | &msgStruct->Dmin) != EW_SUCCESS) |
---|
368 | { |
---|
369 | logit ("e", "Call to ParsePhase failed.\n"); |
---|
370 | return EW_FAILURE; |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | |
---|
375 | if (debug > 10) |
---|
376 | { |
---|
377 | /* Print the parsed version of the message |
---|
378 | ********************************************/ |
---|
379 | sprintf (filename, "%s/%s-%s", |
---|
380 | debug_dir, msgStruct->EventDate, msgStruct->EventKey); |
---|
381 | |
---|
382 | fp = fopen (filename, "wt"); |
---|
383 | |
---|
384 | |
---|
385 | /*** This is where we are done ****/ |
---|
386 | fprintf (fp, "\n===> PRINTING SUMMARY FOR EVENT %s \n", msgStruct->EventKey); |
---|
387 | fprintf (fp, "Event Date: %s\n", msgStruct->EventDate); |
---|
388 | fprintf (fp, |
---|
389 | "ot=%0.2f,%0.2f; lat=%0.2f,%0.2f; lon=%0.2f,%0.2f; dep=%0.2f,%0.2f\n", |
---|
390 | msgStruct->ot, msgStruct->ot_err, |
---|
391 | msgStruct->lat, msgStruct->lat_err, |
---|
392 | msgStruct->lon, msgStruct->lon_err, |
---|
393 | msgStruct->depth, msgStruct->depth_err); |
---|
394 | fprintf (fp, "Magnitudes computed: \n"); |
---|
395 | fprintf (fp, "\t %c (%d) = %0.2f from %d phases\n", |
---|
396 | msgStruct->O_mag[0].magLabel, |
---|
397 | msgStruct->O_mag[0].MagType, |
---|
398 | msgStruct->O_mag[0].magAvg, |
---|
399 | msgStruct->O_mag[0].numStas); |
---|
400 | fprintf (fp, "\t %c (%d) = %0.2f from %d phases\n", |
---|
401 | msgStruct->O_mag[1].magLabel, |
---|
402 | msgStruct->O_mag[1].MagType, |
---|
403 | msgStruct->O_mag[1].magAvg, |
---|
404 | msgStruct->O_mag[1].numStas); |
---|
405 | fprintf (fp, "\t %c (%d) = %0.2f from %d phases\n", |
---|
406 | msgStruct->O_mag[2].magLabel, |
---|
407 | msgStruct->O_mag[2].MagType, |
---|
408 | msgStruct->O_mag[2].magAvg, |
---|
409 | msgStruct->O_mag[2].numStas); |
---|
410 | fprintf (fp, "\t %c (%d) = %0.2f from %d phases\n", |
---|
411 | msgStruct->O_mag[3].magLabel, |
---|
412 | msgStruct->O_mag[3].MagType, |
---|
413 | msgStruct->O_mag[3].magAvg, |
---|
414 | msgStruct->O_mag[3].numStas); |
---|
415 | fprintf (fp, "\t %c (%d) = %0.2f from %d phases\n", |
---|
416 | msgStruct->O_mag[4].magLabel, |
---|
417 | msgStruct->O_mag[4].MagType, |
---|
418 | msgStruct->O_mag[4].magAvg, |
---|
419 | msgStruct->O_mag[4].numStas); |
---|
420 | |
---|
421 | fprintf (fp, "\nThere were total of %d phases, of which %d were marked as used\n", |
---|
422 | msgStruct->nph_assoc, msgStruct->nph_used); |
---|
423 | fprintf (fp, "Std error (RMS) was %0.2f: \n", msgStruct->std_error); |
---|
424 | fprintf (fp, "Of those, we parsed the following %d phases: \n", msgStruct->nph_actual); |
---|
425 | for (i = 0; i < msgStruct->nph_actual; i++) |
---|
426 | { |
---|
427 | fprintf (fp, "%s %s (%c %c) %0.2f %0.1f,%0.1f,%d MAGS ", |
---|
428 | msgStruct->phases[i].sta, msgStruct->phases[i].phase, |
---|
429 | msgStruct->phases[i].onset, msgStruct->phases[i].motion, |
---|
430 | msgStruct->phases[i].ot, msgStruct->phases[i].res, |
---|
431 | msgStruct->phases[i].dist, msgStruct->phases[i].azm); |
---|
432 | |
---|
433 | for (j = 0; j < msgStruct->phases[i].num_mags; j++) |
---|
434 | { |
---|
435 | if (msgStruct->phases[i].mag[j].used == 1) |
---|
436 | fprintf (fp, "USED %c (%d),%0.1f,%0.2f ==> %0.1f ", |
---|
437 | msgStruct->phases[i].mag[j].magLabel, |
---|
438 | msgStruct->phases[i].mag[j].MagType, |
---|
439 | msgStruct->phases[i].mag[j].value, |
---|
440 | msgStruct->phases[i].mag[j].period, |
---|
441 | msgStruct->phases[i].mag[j].mag); |
---|
442 | else |
---|
443 | fprintf (fp, "NOT USED %c (%d),%0.1f,%0.2f ==> %0.1f ", |
---|
444 | msgStruct->phases[i].mag[j].magLabel, |
---|
445 | msgStruct->phases[i].mag[j].MagType, |
---|
446 | msgStruct->phases[i].mag[j].value, |
---|
447 | msgStruct->phases[i].mag[j].period, |
---|
448 | msgStruct->phases[i].mag[j].mag); |
---|
449 | } |
---|
450 | fprintf (fp, "\n"); |
---|
451 | |
---|
452 | } |
---|
453 | |
---|
454 | fclose (fp); |
---|
455 | } |
---|
456 | |
---|
457 | } |
---|
458 | else |
---|
459 | { |
---|
460 | logit ("", "GetNextLine returned EW_FAILURE; exitting\n"); |
---|
461 | return EW_FAILURE; |
---|
462 | } |
---|
463 | |
---|
464 | |
---|
465 | /* free up allocated space */ |
---|
466 | for (i = 0; i < MAX_LINES; i++) |
---|
467 | free ((void *) nsnbuf[i]); |
---|
468 | free ((void *) nsnbuf); |
---|
469 | |
---|
470 | /* |
---|
471 | logit ("", "BEFORE RETURN\n"); |
---|
472 | for (i = 0; i < msgStruct->nph_actual; i++) |
---|
473 | logit ("", "Chan %d, <%s>\n", i, msgStruct->phases[i].sta); |
---|
474 | */ |
---|
475 | |
---|
476 | |
---|
477 | return EW_SUCCESS; |
---|
478 | |
---|
479 | } |
---|
480 | |
---|
481 | |
---|
482 | /************************************************************************ |
---|
483 | * ConvertNSNMsg () - fill the buffer with the stuff in msg. |
---|
484 | * set nlines to the number of lines read. |
---|
485 | ************************************************************************/ |
---|
486 | static int ConvertNSNMsg (char *msg, int msgsize, char **buffer, int *nlines) |
---|
487 | { |
---|
488 | |
---|
489 | int i, j, done; |
---|
490 | char *line; |
---|
491 | |
---|
492 | if ((buffer == NULL) || (msg == NULL) || (msgsize < 0)) |
---|
493 | { |
---|
494 | logit ("e", "ConvertNSNMsg: Invalid parameters passed in.\n"); |
---|
495 | return EW_FAILURE; |
---|
496 | } |
---|
497 | |
---|
498 | *nlines = 0; |
---|
499 | |
---|
500 | done = FALSE; |
---|
501 | i = 0; |
---|
502 | j = 0; |
---|
503 | while (done == FALSE) |
---|
504 | { |
---|
505 | |
---|
506 | line = buffer[*nlines]; |
---|
507 | |
---|
508 | while ((msg[i] != '\n') && (i < msgsize)) |
---|
509 | { |
---|
510 | line[j] = msg[i]; |
---|
511 | i = i + 1; |
---|
512 | j = j + 1; |
---|
513 | } |
---|
514 | if (msg[i] == '\n') |
---|
515 | { |
---|
516 | /** |
---|
517 | line[j] = '\0'; |
---|
518 | **/ |
---|
519 | line[j] = '\n'; |
---|
520 | *nlines = *nlines + 1; |
---|
521 | j = 0; |
---|
522 | i = i + 1; |
---|
523 | } |
---|
524 | else |
---|
525 | { |
---|
526 | line[j] = '\0'; |
---|
527 | done = TRUE; |
---|
528 | } |
---|
529 | |
---|
530 | } |
---|
531 | |
---|
532 | return EW_SUCCESS; |
---|
533 | } |
---|
534 | |
---|
535 | |
---|
536 | |
---|
537 | /************************************************************************ |
---|
538 | * GetNextLine () - return the next line from the message (in buffer) |
---|
539 | * where the first word of the line is given by argument word. |
---|
540 | ************************************************************************/ |
---|
541 | static int GetNextLine (char **buffer, int *lineno, char *word) |
---|
542 | { |
---|
543 | |
---|
544 | char tmp[256]; |
---|
545 | int done; |
---|
546 | |
---|
547 | if ((buffer == NULL) || (word == NULL)) |
---|
548 | { |
---|
549 | logit ("", "Invalid arguments passed in.\n"); |
---|
550 | return EW_FAILURE; |
---|
551 | } |
---|
552 | |
---|
553 | done = FALSE; |
---|
554 | while (done == FALSE) |
---|
555 | { |
---|
556 | if (strlen (buffer[*lineno]) == 1) |
---|
557 | ; |
---|
558 | else |
---|
559 | { |
---|
560 | /* Check the first word */ |
---|
561 | |
---|
562 | sscanf (buffer[*lineno], "%s\n", tmp); |
---|
563 | |
---|
564 | if (strcmp (tmp, word) == 0) |
---|
565 | { |
---|
566 | done = TRUE; |
---|
567 | } |
---|
568 | else |
---|
569 | ; |
---|
570 | } |
---|
571 | |
---|
572 | if (done != TRUE) |
---|
573 | *lineno = *lineno + 1; |
---|
574 | } |
---|
575 | |
---|
576 | return EW_SUCCESS; |
---|
577 | } |
---|
578 | |
---|
579 | |
---|
580 | /************************************************************************ |
---|
581 | * BuildDateStr () - Create a date string suitable for a call to |
---|
582 | * epochsec17, from an NSN format date string. |
---|
583 | ************************************************************************/ |
---|
584 | static int BuildDateStr (char *in, char *out) |
---|
585 | { |
---|
586 | |
---|
587 | char year[6]; |
---|
588 | char month[6]; |
---|
589 | char day[6]; |
---|
590 | |
---|
591 | if ((in == NULL) || (out == NULL)) |
---|
592 | { |
---|
593 | logit ("", "Invalid arguments passed in.\n"); |
---|
594 | return EW_FAILURE; |
---|
595 | } |
---|
596 | |
---|
597 | strncpy (day, in, 2); |
---|
598 | day[2] = '\0'; |
---|
599 | |
---|
600 | if (day[0] == ' ') |
---|
601 | day[0] ='0'; |
---|
602 | |
---|
603 | /* figure out the month */ |
---|
604 | if (in[3] == 'J') |
---|
605 | { |
---|
606 | if (in[4] == 'A') |
---|
607 | sprintf (month, "01"); |
---|
608 | else if (in[4] == 'U') |
---|
609 | { |
---|
610 | if (in[5] == 'N') |
---|
611 | sprintf (month, "06"); |
---|
612 | else if (in[5] == 'L') |
---|
613 | sprintf (month, "07"); |
---|
614 | else |
---|
615 | { |
---|
616 | logit ("", "Unknown month %s!\n", month); |
---|
617 | return EW_FAILURE; |
---|
618 | } |
---|
619 | } |
---|
620 | else |
---|
621 | { |
---|
622 | logit ("", "Unknown month %s!\n", month); |
---|
623 | return EW_FAILURE; |
---|
624 | } |
---|
625 | } |
---|
626 | else if (in[3] == 'M') |
---|
627 | { |
---|
628 | if (in[5] == 'R') |
---|
629 | sprintf (month, "03"); |
---|
630 | else if (in[5] == 'Y') |
---|
631 | sprintf (month, "05"); |
---|
632 | else |
---|
633 | { |
---|
634 | logit ("", "Unknown month %s!\n", month); |
---|
635 | return EW_FAILURE; |
---|
636 | } |
---|
637 | } |
---|
638 | else if (in[3] == 'A') |
---|
639 | { |
---|
640 | if (in[4] == 'P') |
---|
641 | sprintf (month, "04"); |
---|
642 | else if (in[4] == 'U') |
---|
643 | sprintf (month, "08"); |
---|
644 | else |
---|
645 | { |
---|
646 | logit ("", "Unknown month %s!\n", month); |
---|
647 | return EW_FAILURE; |
---|
648 | } |
---|
649 | } |
---|
650 | else if (in[3] == 'F') |
---|
651 | sprintf (month, "02"); |
---|
652 | else if (in[3] == 'S') |
---|
653 | sprintf (month, "09"); |
---|
654 | else if (in[3] == 'O') |
---|
655 | sprintf (month, "10"); |
---|
656 | else if (in[3] == 'N') |
---|
657 | sprintf (month, "11"); |
---|
658 | else if (in[3] == 'D') |
---|
659 | sprintf (month, "12"); |
---|
660 | else |
---|
661 | { |
---|
662 | logit ("", "Unknown month %s!\n", month); |
---|
663 | return EW_FAILURE; |
---|
664 | } |
---|
665 | |
---|
666 | strncpy (year, (in + 7), 4); |
---|
667 | year[4] = '\0'; |
---|
668 | |
---|
669 | sprintf (out, "%s%s%s", year, month, day); |
---|
670 | |
---|
671 | |
---|
672 | return EW_SUCCESS; |
---|
673 | |
---|
674 | } |
---|
675 | |
---|
676 | |
---|
677 | /************************************************************************ |
---|
678 | * AppendDateStr () - Append hours, minutes, and seconds to the |
---|
679 | * date, to create a string suitable for a call to epochsec17 |
---|
680 | ************************************************************************/ |
---|
681 | static int AppendDateStr (char *orig, char *append) |
---|
682 | { |
---|
683 | |
---|
684 | int i, j; |
---|
685 | char tmp[10]; |
---|
686 | |
---|
687 | /* strip off ':'s and append to the old date string */ |
---|
688 | |
---|
689 | if ((orig == NULL) || (append == NULL)) |
---|
690 | { |
---|
691 | logit ("", "Invalid arguments passed in.\n"); |
---|
692 | return EW_FAILURE; |
---|
693 | } |
---|
694 | |
---|
695 | i = 0; |
---|
696 | j = 0; |
---|
697 | |
---|
698 | for (i = 0; i < 11; i++) |
---|
699 | { |
---|
700 | if (append[i] == ':') |
---|
701 | ; |
---|
702 | else |
---|
703 | { |
---|
704 | tmp[j] = append[i]; |
---|
705 | j = j + 1; |
---|
706 | } |
---|
707 | } |
---|
708 | tmp[j] = '\0'; |
---|
709 | |
---|
710 | strcat (orig, tmp); |
---|
711 | |
---|
712 | return EW_SUCCESS; |
---|
713 | |
---|
714 | |
---|
715 | } |
---|
716 | |
---|
717 | /************************************************************************ |
---|
718 | * ParseEllipse () - fill the Ellipse structure from the NSN formatted |
---|
719 | * error elipse string |
---|
720 | ************************************************************************/ |
---|
721 | static int ParseEllipse (char *str, double depth_err, Err_Elipse *error) |
---|
722 | { |
---|
723 | |
---|
724 | int i, j, k, l, index; |
---|
725 | double err[9]; |
---|
726 | char tmp[10]; |
---|
727 | |
---|
728 | if ((str == NULL) || (error == NULL)) |
---|
729 | { |
---|
730 | logit ("", "Invalid arguments passed in.\n"); |
---|
731 | return EW_FAILURE; |
---|
732 | } |
---|
733 | |
---|
734 | /* Extract numbers */ |
---|
735 | i = 0; |
---|
736 | index = 0; |
---|
737 | /* Loop over 3 sets of numbers */ |
---|
738 | for (k = 0; k < 3; k++) |
---|
739 | { |
---|
740 | /* Loop over 3 numbers in each set */ |
---|
741 | for (l = 0; l < 3; l++) |
---|
742 | { |
---|
743 | j = 0; |
---|
744 | while ((i < ELLIPSE_LENGTH) && (str[i] != ',') && (str[i] != ';')) |
---|
745 | { |
---|
746 | tmp[j] = str[i]; |
---|
747 | j = j + 1; |
---|
748 | i = i + 1; |
---|
749 | } |
---|
750 | |
---|
751 | /* Got a number, convert it */ |
---|
752 | tmp[j] = '\0'; |
---|
753 | err[index] = atof (tmp); |
---|
754 | index = index + 1; |
---|
755 | i = i + 1; |
---|
756 | } |
---|
757 | } |
---|
758 | |
---|
759 | |
---|
760 | /* For some reason, the meaning of the ellipse changes |
---|
761 | * if depth is fixed: |
---|
762 | * |
---|
763 | * ind 0 = Semi-major strike |
---|
764 | * ind 1 = Semi-minor strike |
---|
765 | * ind 2 = Intermediate strike |
---|
766 | * |
---|
767 | * ind 3 = Semi-major dip |
---|
768 | * ind 4 = Semi-minor dip |
---|
769 | * ind 5 = Intermediate dip |
---|
770 | * |
---|
771 | * ind 6 = Semi-major length |
---|
772 | * ind 7 = Semi-minor length |
---|
773 | * ind 8 = Intermediate length |
---|
774 | * |
---|
775 | * For non-fixed depth, the Semi-minor and intermediate axes |
---|
776 | * are swapped. |
---|
777 | * |
---|
778 | */ |
---|
779 | |
---|
780 | if (depth_err != 0.0) |
---|
781 | { |
---|
782 | error->maj_s = err[0]; |
---|
783 | error->maj_d = err[3]; |
---|
784 | error->maj_l = err[6]; |
---|
785 | |
---|
786 | error->int_s = err[1]; |
---|
787 | error->int_d = err[4]; |
---|
788 | error->int_l = err[7]; |
---|
789 | |
---|
790 | error->min_s = err[2]; |
---|
791 | error->min_d = err[5]; |
---|
792 | error->min_l = err[8]; |
---|
793 | } |
---|
794 | else |
---|
795 | { |
---|
796 | error->maj_s = err[0]; |
---|
797 | error->maj_d = err[3]; |
---|
798 | error->maj_l = err[6]; |
---|
799 | |
---|
800 | error->min_s = err[1]; |
---|
801 | error->min_d = err[4]; |
---|
802 | error->min_l = err[7]; |
---|
803 | |
---|
804 | error->int_s = err[2]; |
---|
805 | error->int_d = err[5]; |
---|
806 | error->int_l = err[8]; |
---|
807 | } |
---|
808 | |
---|
809 | return EW_SUCCESS; |
---|
810 | |
---|
811 | } |
---|
812 | |
---|
813 | /************************************************************************ |
---|
814 | * ParseMagnitude () - fill the Mag structure from the NSN formatted |
---|
815 | * magnitudes string |
---|
816 | ************************************************************************/ |
---|
817 | static int ParseMagnitude (char *str, OriginMag *mag) |
---|
818 | { |
---|
819 | |
---|
820 | char tmp[10]; |
---|
821 | |
---|
822 | if ((str == NULL) || (mag == NULL)) |
---|
823 | { |
---|
824 | logit ("", "Invalid arguments passed in.\n"); |
---|
825 | return EW_FAILURE; |
---|
826 | } |
---|
827 | |
---|
828 | |
---|
829 | /* HACK: we only know about duration and local mags */ |
---|
830 | |
---|
831 | /* Mb */ |
---|
832 | mag[0].magLabel = 'b'; |
---|
833 | mag[0].MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
834 | strncpy (tmp, (str + MB_BASE), MAG_LEN); |
---|
835 | tmp[MAG_LEN] = '\0'; |
---|
836 | mag[0].magAvg = (double) atof (tmp); |
---|
837 | |
---|
838 | strncpy (tmp, (str + MB_DATUM), DATUM_LEN); |
---|
839 | tmp[DATUM_LEN] = '\0'; |
---|
840 | mag[0].numStas = (int) atoi (tmp); |
---|
841 | |
---|
842 | |
---|
843 | /* ML */ |
---|
844 | mag[1].magLabel = 'L'; |
---|
845 | mag[1].MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
846 | strncpy (tmp, (str + ML_BASE), MAG_LEN); |
---|
847 | tmp[MAG_LEN] = '\0'; |
---|
848 | mag[1].magAvg = (double) atof (tmp); |
---|
849 | |
---|
850 | strncpy (tmp, (str + ML_DATUM), DATUM_LEN); |
---|
851 | tmp[DATUM_LEN] = '\0'; |
---|
852 | mag[1].numStas = (int) atoi (tmp); |
---|
853 | |
---|
854 | |
---|
855 | /* Mblg */ |
---|
856 | mag[2].magLabel = 'g'; |
---|
857 | mag[2].MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
858 | strncpy (tmp, (str + MBLG_BASE), MAG_LEN); |
---|
859 | tmp[MAG_LEN] = '\0'; |
---|
860 | mag[2].magAvg = (double) atof (tmp); |
---|
861 | |
---|
862 | strncpy (tmp, (str + MBLG_DATUM), DATUM_LEN); |
---|
863 | tmp[DATUM_LEN] = '\0'; |
---|
864 | mag[2].numStas = (int) atoi (tmp); |
---|
865 | |
---|
866 | |
---|
867 | /* Md */ |
---|
868 | mag[3].magLabel = 'd'; |
---|
869 | mag[3].MagType = MAGTYPE_DURATION; |
---|
870 | strncpy (tmp, (str + MD_BASE), MAG_LEN); |
---|
871 | tmp[MAG_LEN] = '\0'; |
---|
872 | mag[3].magAvg = (double) atof (tmp); |
---|
873 | |
---|
874 | strncpy (tmp, (str + MD_DATUM), DATUM_LEN); |
---|
875 | tmp[DATUM_LEN] = '\0'; |
---|
876 | mag[3].numStas = (int) atoi (tmp); |
---|
877 | |
---|
878 | |
---|
879 | /* MS */ |
---|
880 | mag[4].magLabel = 'S'; |
---|
881 | mag[4].MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
882 | strncpy (tmp, (str + MS_BASE), MAG_LEN); |
---|
883 | tmp[MAG_LEN] = '\0'; |
---|
884 | mag[4].magAvg = (double) atof (tmp); |
---|
885 | |
---|
886 | strncpy (tmp, (str + MS_DATUM), DATUM_LEN); |
---|
887 | tmp[DATUM_LEN] = '\0'; |
---|
888 | mag[4].numStas = (int) atoi (tmp); |
---|
889 | |
---|
890 | return EW_SUCCESS; |
---|
891 | } |
---|
892 | |
---|
893 | /************************************************************************ |
---|
894 | * ParsePhase () - fill the Phase structure from the NSN formatted |
---|
895 | * phase string |
---|
896 | ************************************************************************/ |
---|
897 | static int ParsePhase (char *str, Phase *phase, char *EventDate, |
---|
898 | int *num_phases, double *Dmin) |
---|
899 | { |
---|
900 | char tmp[256]; |
---|
901 | char datestr[256]; |
---|
902 | int i, j; |
---|
903 | |
---|
904 | if ((str == NULL) || (phase == NULL)) |
---|
905 | { |
---|
906 | logit ("", "Invalid arguments passed in\n"); |
---|
907 | return EW_FAILURE; |
---|
908 | } |
---|
909 | |
---|
910 | |
---|
911 | /* ingore phases that don't start with the station name */ |
---|
912 | if (str[1] == ' ') |
---|
913 | { |
---|
914 | return EW_SUCCESS; |
---|
915 | } |
---|
916 | |
---|
917 | |
---|
918 | strncpy (phase->sta, (str + STA_BASE), STA_LEN); |
---|
919 | phase->sta[STA_LEN] = '\0'; |
---|
920 | |
---|
921 | strncpy (tmp, (str + PHA_BASE), PHA_LEN); |
---|
922 | tmp[PHA_LEN] = '\0'; |
---|
923 | |
---|
924 | j = 0; |
---|
925 | phase->onset = ' '; |
---|
926 | phase->motion = ' '; |
---|
927 | for (i = 0; i < PHA_LEN; i++) |
---|
928 | { |
---|
929 | if (tmp[i] == '?') |
---|
930 | phase->automatic = 1; |
---|
931 | /* onset codes */ |
---|
932 | else if (tmp[i] == 'i') |
---|
933 | phase->onset = 'i'; |
---|
934 | else if (tmp[i] == 'e') |
---|
935 | phase->onset = 'e'; |
---|
936 | else if (tmp[i] == 'q') |
---|
937 | phase->onset = 'q'; |
---|
938 | |
---|
939 | /* first motion codes */ |
---|
940 | else if (tmp[i] == 'c') |
---|
941 | phase->motion = 'c'; |
---|
942 | else if (tmp[i] == 'd') |
---|
943 | phase->motion = 'd'; |
---|
944 | else if (tmp[i] == 'u') |
---|
945 | phase->motion = 'u'; |
---|
946 | else if (tmp[i] == 'r') |
---|
947 | phase->motion = 'r'; |
---|
948 | else if (tmp[i] == ' ') |
---|
949 | ; |
---|
950 | |
---|
951 | /* part of the phase code */ |
---|
952 | else |
---|
953 | { |
---|
954 | phase->phase[j] = tmp[i]; |
---|
955 | j = j + 1; |
---|
956 | } |
---|
957 | } |
---|
958 | |
---|
959 | if (j >= PHA_LEN) |
---|
960 | { |
---|
961 | logit ("e", "MAX Phase length (%d) exceeded!\n", PHA_LEN); |
---|
962 | return EW_FAILURE; |
---|
963 | } |
---|
964 | phase->phase[j] = '\0'; |
---|
965 | |
---|
966 | strncpy (tmp, (str + OT_BASE), OT_LEN); |
---|
967 | tmp[OT_LEN] = '\0'; |
---|
968 | |
---|
969 | strcpy (datestr, EventDate); |
---|
970 | if (AppendDateStr (datestr, tmp) != EW_SUCCESS) |
---|
971 | { |
---|
972 | logit ("", "Call to AppendDateStr failed.\n"); |
---|
973 | return EW_FAILURE; |
---|
974 | } |
---|
975 | epochsec17 (&phase->ot, datestr); |
---|
976 | |
---|
977 | |
---|
978 | strncpy (tmp, (str + RES_BASE), RES_LEN); |
---|
979 | tmp[RES_LEN] = '\0'; |
---|
980 | phase->res = (double) atof (tmp); |
---|
981 | |
---|
982 | if (str[RES_USED] == 'X') |
---|
983 | phase->res_used = 1; |
---|
984 | else |
---|
985 | phase->res_used = 0; |
---|
986 | |
---|
987 | strncpy (tmp, (str + DIST_BASE), DIST_LEN); |
---|
988 | tmp[DIST_LEN] = '\0'; |
---|
989 | phase->dist = (double) atof (tmp); |
---|
990 | |
---|
991 | /* convert from degrees to km */ |
---|
992 | phase->dist = (phase->dist * EARTH_CIRCUM)/360.0; |
---|
993 | |
---|
994 | if (phase->dist <= *Dmin) |
---|
995 | { |
---|
996 | *Dmin = phase->dist; |
---|
997 | } |
---|
998 | |
---|
999 | strncpy (tmp, (str + AZM_BASE), AZM_LEN); |
---|
1000 | tmp[AZM_LEN] = '\0'; |
---|
1001 | phase->azm = (int) atoi (tmp); |
---|
1002 | |
---|
1003 | |
---|
1004 | /* magnitudes */ |
---|
1005 | phase->num_mags = 0; |
---|
1006 | if (str[MAG1_BASE] != ' ') |
---|
1007 | { |
---|
1008 | if (ParsePhaseMagnitude ((str+MAG1_BASE), &phase->mag[0]) != EW_SUCCESS) |
---|
1009 | { |
---|
1010 | logit ("", "Call to ParsePhaseMagnitude failed\n"); |
---|
1011 | return EW_FAILURE; |
---|
1012 | } |
---|
1013 | phase->num_mags = phase->num_mags + 1; |
---|
1014 | |
---|
1015 | } |
---|
1016 | if (str[MAG2_BASE] != ' ') |
---|
1017 | { |
---|
1018 | |
---|
1019 | if (ParsePhaseMagnitude ((str+MAG2_BASE), &phase->mag[1]) != EW_SUCCESS) |
---|
1020 | { |
---|
1021 | logit ("", "Call to ParsePhaseMagnitude failed\n"); |
---|
1022 | return EW_FAILURE; |
---|
1023 | } |
---|
1024 | phase->num_mags = phase->num_mags + 1; |
---|
1025 | } |
---|
1026 | |
---|
1027 | *num_phases = *num_phases + 1; |
---|
1028 | return EW_SUCCESS; |
---|
1029 | } |
---|
1030 | |
---|
1031 | /************************************************************************ |
---|
1032 | * ParsePhaseMagnitude () - fill the PhaseMag structure from the NSN |
---|
1033 | * formatted phase string |
---|
1034 | ************************************************************************/ |
---|
1035 | static int ParsePhaseMagnitude (char *str, PhaseMag *mag) |
---|
1036 | { |
---|
1037 | char *ptr; |
---|
1038 | char tmp[5]; |
---|
1039 | int expn, mult; |
---|
1040 | mult = 0; |
---|
1041 | |
---|
1042 | if ((str == NULL) || (mag == NULL)) |
---|
1043 | { |
---|
1044 | logit ("", "Invalid arguments passed in\n"); |
---|
1045 | return EW_FAILURE; |
---|
1046 | } |
---|
1047 | |
---|
1048 | |
---|
1049 | /* Hack: we only know duration and local mags */ |
---|
1050 | mag->magLabel = str[0]; |
---|
1051 | if (mag->magLabel == 'b') |
---|
1052 | mag->MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
1053 | else if (mag->magLabel == 'L') |
---|
1054 | mag->MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
1055 | else if (mag->magLabel == 'g') /* HACK -- we don't have Mblg type yet */ |
---|
1056 | mag->MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
1057 | else if (mag->magLabel == 'd') |
---|
1058 | mag->MagType = MAGTYPE_DURATION; |
---|
1059 | else if (mag->magLabel == 'S') |
---|
1060 | mag->MagType = MAGTYPE_LOCAL_ZERO2PEAK; |
---|
1061 | else |
---|
1062 | { |
---|
1063 | logit ("", "Invalid magnitude type: %c\n", mag->magLabel); |
---|
1064 | return EW_FAILURE; |
---|
1065 | } |
---|
1066 | |
---|
1067 | ptr = str + 2; |
---|
1068 | strncpy (tmp, ptr, 3); |
---|
1069 | tmp[3] = '\0'; |
---|
1070 | mag->value = (double) atof (tmp); |
---|
1071 | |
---|
1072 | ptr = ptr + 3; |
---|
1073 | if (ptr[0] == '+') |
---|
1074 | mult = 1; |
---|
1075 | else if (ptr[0] == '-') |
---|
1076 | mult = -1; |
---|
1077 | |
---|
1078 | ptr = ptr + 1; |
---|
1079 | strncpy (tmp, ptr, 1); |
---|
1080 | tmp[1] = '\0'; |
---|
1081 | expn = mult * ((int) atoi (tmp)); |
---|
1082 | mag->value = (double) (mag->value * pow (10.0, (double) expn)); |
---|
1083 | |
---|
1084 | ptr = ptr + 1; |
---|
1085 | strncpy (tmp, ptr, 4); |
---|
1086 | tmp[4] = '\0'; |
---|
1087 | mag->period = (double) atof (tmp); |
---|
1088 | |
---|
1089 | ptr = ptr + 5; |
---|
1090 | strncpy (tmp, ptr, 3); |
---|
1091 | tmp[3] = '\0'; |
---|
1092 | mag->mag = (double) atof (tmp); |
---|
1093 | |
---|
1094 | ptr = ptr + 3; |
---|
1095 | |
---|
1096 | if (ptr[0] != 'X') |
---|
1097 | mag->used = 1; |
---|
1098 | else |
---|
1099 | mag->used = 0; |
---|
1100 | |
---|
1101 | |
---|
1102 | return EW_SUCCESS; |
---|
1103 | |
---|
1104 | } |
---|
1105 | |
---|
1106 | |
---|
1107 | |
---|