static void view_initialize(qd_iterator_t *iter) { // // The default behavior is for the view to *not* have a prefix. // We'll add one if it's needed later. // iter->state = STATE_IN_BODY; iter->prefix = '\0'; iter->mode = MODE_TO_END; iter->annotation_length = 0; iter->annotation_remaining = 0; if (iter->view == ITER_VIEW_ALL) return; // // Advance to the node-id. // state_t state = STATE_START; unsigned int octet; pointer_t save_pointer = {0,0,0}; while (!qd_iterator_end(iter) && state != STATE_AT_NODE_ID) { octet = qd_iterator_octet(iter); switch (state) { case STATE_START : if (octet == '/') { state = STATE_SLASH_LEFT; save_pointer = iter->view_pointer; } else state = STATE_SCANNING; break; case STATE_SLASH_LEFT : if (octet == '/') state = STATE_SKIPPING_TO_NEXT_SLASH; else { state = STATE_AT_NODE_ID; iter->view_pointer = save_pointer; } break; case STATE_SKIPPING_TO_NEXT_SLASH : if (octet == '/') state = STATE_AT_NODE_ID; break; case STATE_SCANNING : if (octet == ':') state = STATE_COLON; break; case STATE_COLON : if (octet == '/') { state = STATE_COLON_SLASH; save_pointer = iter->view_pointer; } else state = STATE_SCANNING; break; case STATE_COLON_SLASH : if (octet == '/') state = STATE_SKIPPING_TO_NEXT_SLASH; else { state = STATE_AT_NODE_ID; iter->view_pointer = save_pointer; } break; case STATE_AT_NODE_ID : break; } } if (state != STATE_AT_NODE_ID){ // // The address string was relative, not absolute. The node-id // is at the beginning of the string. // iter->view_pointer = iter->start_pointer; } // // Cursor is now on the first octet of the node-id // if (iter->view == ITER_VIEW_ADDRESS_NO_HOST) return; if (iter->view == ITER_VIEW_ADDRESS_HASH) { qd_iterator_remove_trailing_separator(iter); // FIXME - need this? parse_address_view(iter); return; } if (iter->view == ITER_VIEW_NODE_HASH) { parse_node_view(iter); return; } }
static void view_initialize(qd_field_iterator_t *iter) { // // The default behavior is for the view to *not* have a prefix. // We'll add one if it's needed later. // iter->state = STATE_IN_ADDRESS; iter->view_prefix = false; iter->mode = MODE_TO_END; if (iter->view == ITER_VIEW_ALL) return; // // Advance to the node-id. // state_t state = STATE_START; unsigned int octet; pointer_t save_pointer = {0,0,0}; while (!qd_field_iterator_end(iter) && state != STATE_AT_NODE_ID) { octet = qd_field_iterator_octet(iter); switch (state) { case STATE_START : if (octet == '/') { state = STATE_SLASH_LEFT; save_pointer = iter->pointer; } else state = STATE_SCANNING; break; case STATE_SLASH_LEFT : if (octet == '/') state = STATE_SKIPPING_TO_NEXT_SLASH; else { state = STATE_AT_NODE_ID; iter->pointer = save_pointer; } break; case STATE_SKIPPING_TO_NEXT_SLASH : if (octet == '/') state = STATE_AT_NODE_ID; break; case STATE_SCANNING : if (octet == ':') state = STATE_COLON; break; case STATE_COLON : if (octet == '/') { state = STATE_COLON_SLASH; save_pointer = iter->pointer; } else state = STATE_SCANNING; break; case STATE_COLON_SLASH : if (octet == '/') state = STATE_SKIPPING_TO_NEXT_SLASH; else { state = STATE_AT_NODE_ID; iter->pointer = save_pointer; } break; case STATE_AT_NODE_ID : break; } } if (state != STATE_AT_NODE_ID) { // // The address string was relative, not absolute. The node-id // is at the beginning of the string. // iter->pointer = iter->start_pointer; } // // Cursor is now on the first octet of the node-id // if (iter->view == ITER_VIEW_NODE_ID) { iter->mode = MODE_TO_SLASH; return; } if (iter->view == ITER_VIEW_NO_HOST) { iter->mode = MODE_TO_END; return; } if (iter->view == ITER_VIEW_ADDRESS_HASH) { iter->mode = MODE_TO_END; qd_address_iterator_check_trailing_octet(iter, SEPARATOR); parse_address_view(iter); return; } if (iter->view == ITER_VIEW_NODE_HASH) { iter->mode = MODE_TO_END; parse_node_view(iter); return; } if (iter->view == ITER_VIEW_NODE_SPECIFIC) { iter->mode = MODE_TO_END; while (!qd_field_iterator_end(iter)) { octet = qd_field_iterator_octet(iter); if (octet == '/') break; } return; } }