void cell_zone_class_lookup(CDR_DATA_STRUCT *cdr) { ZONE_ID_STRUCT *zone_id_list; short num_zone_id_list; tiny priority = 0; int i, n = -1; /* Get the zone id list for the given zone id from cache. */ valid_cell_id(cdr->cell_id_origin, &zone_id_list, &num_zone_id_list); /* * There may be more than one zone class for the given cell id and * we need to get the one with the highest priority. */ for ( i = 0; i < num_zone_id_list; i++ ) { if ( zone_id_list[i].zone_priority >= priority ) { n = i; priority = zone_id_list[i].zone_priority; } } if ( n >= 0 ) /* zone_class is found for the cell_id */ cdr->cell_zone_class = zone_id_list[n].zone_class; else cdr->cell_zone_class = 0; }
static cell_type_e parsearg(char *arg) { if (arg == NULL) return BAD_CELL; int is_double = 0, has_period = 0, has_negative = 0; int is_hard_string = 0, is_soft_string = 0; char *beg_arg = arg; while (*arg != '\0') { if (*arg >= '0' && *arg <= '9') { is_double++; } else if (*arg == '-') { is_double++; has_negative++; } else if (*arg == '.') { is_double++; has_period++; } else if (*arg == '"') { is_hard_string++; } else { is_soft_string++; } arg++; } arg = beg_arg; if (is_hard_string) { if (is_hard_string == 2 && *(--arg) == '"') return QUOTED_STRING; else return STRING; } else if (is_soft_string) { if (has_period > 1 || has_negative > 1) return STRING; if (valid_cell_id(arg) == 0) return CELL_ID; if (get_op(arg) != NULL) return FUNCTION; return STRING; } else if (is_double) { if (has_period > 1 || has_negative > 1) return STRING; if ((has_period && is_double == 1) || (has_period && has_negative && is_double == 2)) return STRING; if (has_negative && is_double == 1) return FUNCTION; return DOUBLE; } else { return BAD_CELL; } }