IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20818


Ignore:
Timestamp:
Nov 24, 2008, 10:43:03 AM (17 years ago)
Author:
eugene
Message:

handle named photcodes, error handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/dbCheckStack.c

    r20583 r20818  
    2323      }
    2424
     25      // the value might be a special type of number: RA,DEC in sexigesimal or
     26      // time in YYYY/MM/DD, etc
     27      // status = ohana_str_to_time (stack[i].name, &seconds);
     28      // keep as time_t
     29      // status = ohana_dms_to_ddd (&ddd, stack[i].name);
     30      // keep as either hours (RA) or deg (DEC).
     31
     32      // strings protected by double quotes should parse to be special types of numbers
     33      // (photcodes, dates, ra / dec)
     34      if (stack[i].name[0] == '"') {
     35          if (stack[i].name[strlen(stack[i].name) - 1] != '"') {
     36              gprint (GP_ERR, "syntax error for field %s\n", stack[i].name);
     37              goto failure;
     38          }
     39          char *tmpstring;
     40          tmpstring = strncreate (&stack[i].name[1], strlen(stack[i].name) - 2);
     41
     42          // attempt to parse the string as a special word:
     43          PhotCode *code;
     44          code = GetPhotcodebyName (tmpstring);
     45          if (code) {
     46              stack[i].Float = code->code;
     47              stack[i].type  = 'S';
     48              continue;
     49          }
     50
     51          // add in tests for sexigesimal, date/time
     52          // TimeRefPM = ohana_date_to_sec ("2000/01/01");
     53         
     54          gprint (GP_ERR, "syntax error for field %s\n", stack[i].name);
     55          goto failure;
     56      }
     57
    2558      // this must be a field : is it already in the list?
    2659      for (j = 0; (j < Nfields) && strcasecmp (stack[i].name, fields[j].name); j++);
     
    3366      }
    3467
    35       // the value might be a special type of number: RA,DEC in sexigesimal or
    36       // time in YYYY/MM/DD, etc
    37       // status = ohana_str_to_time (stack[i].name, &seconds);
    38       // keep as time_t
    39       // status = ohana_dms_to_ddd (&ddd, stack[i].name);
    40       // keep as either hours (RA) or deg (DEC).
    41 
    4268      // this must be a field : is it a valid name?
    4369      if (table == DVO_TABLE_MEASURE) {
     
    4975      if (!status) {
    5076        gprint (GP_ERR, "unknown database field %s\n", stack[i].name);
    51         return (FALSE);
     77        goto failure;
    5278      }
    5379      stack[i].field = Nfields;
     
    6389  *inNfields = Nfields;
    6490  *inFields = fields;
     91  return (TRUE);
    6592
    66   return (TRUE);
     93failure:
     94  *inNfields = Nfields;
     95  *inFields = fields;
     96  return (FALSE);
    6797}
    6898
Note: See TracChangeset for help on using the changeset viewer.