IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 16, 2008, 9:16:26 AM (18 years ago)
Author:
eugene
Message:

adding mmextract and supporting api changes to dbCmdlineField.c functions

File:
1 edited

Legend:

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

    r19571 r19579  
    11# include "dvoshell.h"
    22
    3 // identify the fields to be extracted (test for where, check syntax)
     3// check for 'where' or 'matched to'; return first field after the word, and the value
     4int dbCmdlineConditions (int argc, char **argv, int first, int *nextField) {
     5
     6  int isWhere, isMatch;
     7
     8  *nextField = argc;
     9
     10  // require 'where' or 'matched to' before boolean math
     11  if (first == argc) return DVO_DB_CMDLINE_IS_END;
     12
     13  isWhere = !strcasecmp(argv[first], "where");
     14  isMatch = !strcasecmp(argv[first], "match");
     15   
     16  if (!isMatch && !isWhere) {
     17    gprint (GP_ERR, "WHERE or MATCH TO\n");
     18    return DVO_DB_CMDLINE_ERROR;
     19  }
     20  if (isMatch && ((first + 1 >= argc - 1) || strcasecmp(argv[first+1], "to"))) {
     21    gprint (GP_ERR, "missing boolean expression\n");
     22    return DVO_DB_CMDLINE_ERROR;
     23  }
     24  if (isWhere && (first >= argc - 1)) {
     25    gprint (GP_ERR, "missing boolean expression\n");
     26    return DVO_DB_CMDLINE_ERROR;
     27  }
     28
     29  if (isWhere) {
     30    *nextField = first + 1;
     31    return DVO_DB_CMDLINE_IS_WHERE;
     32  }
     33
     34  if (isMatch) {
     35    *nextField = first + 2;
     36    return DVO_DB_CMDLINE_IS_MATCH;
     37  }
     38
     39  gprint (GP_ERR, "programming error?\n");
     40  return DVO_DB_CMDLINE_ERROR;
     41}
     42
     43// identify the fields to be extracted (check syntax)
     44// the 'last' pointer ends on the first word after the fields (where, match or EOL)
    445dbField *dbCmdlineFields (int argc, char **argv, int table, int *last, int *nfields) {
    546
     
    1556
    1657  // examine each argv[i] entry until we reach a 'where' or a 'matched'
    17   for (i = 1; (i < argc) && strcasecmp (argv[i], "where") && strcasecmp (argv[i], "matched"); i++) {
     58  for (i = 1; (i < argc) && strcasecmp (argv[i], "where") && strcasecmp (argv[i], "match"); i++) {
    1859    // split the word by ","
    1960    p = argv[i];
     
    5091  }
    5192
    52   // require 'where' or 'matched to' before boolean math
    53   // XXX push this to a test up one level
    54   if (i != argc) {
    55     if (strcasecmp(argv[i], "where")) {
    56       gprint (GP_ERR, "syntax error\n");
    57       free (fields);
    58       return (NULL);
    59     }
    60     if (i > argc - 2) {
    61       gprint (GP_ERR, "missing boolean expression\n");
    62       free (fields);
    63       return (NULL);
    64     }
    65     i++; // skip over the 'where'
    66   }
    67 
    6893  *last = i;
    6994  *nfields = Nfields;
Note: See TracChangeset for help on using the changeset viewer.