/* parse_resources() Processes the services/resources that are part of a request. This method walks through each element from a request and attempts to match each one with the available services on the Arduino. Based on these matches this method also updates the services_xxx_requested and services_set_updated arrays, which identify what services were requested or updated by the current request. Accepts: n/a Returns: n/a */ void RestServer::parse_resources() { int next_start_pos = 0; boolean processing_request = true; while(processing_request == true) { // re-initializing the start and end position of current element int cur_start_pos = next_start_pos; next_start_pos = next_element(cur_start_pos); // if next_start_pos returns a NO_MATCH then we have reached end of resource request if (next_start_pos == NO_MATCH) { next_start_pos = request.length - 1; processing_request = false; } // loop through each resource/service name to look for a match for (int i = 0; i < int(resources_count); i++) { int match_index = service_match(i, cur_start_pos); if (match_index != NO_MATCH) { next_start_pos = match_index; if (next_start_pos >= request.length) break; } } } }
static void service_add(struct connman_service *service, const char *name) { GHashTableIter iter; GSequenceIter *iter_service_list; gpointer key, value; struct connman_session *session; struct service_entry *entry; DBG("service %p", service); g_hash_table_iter_init(&iter, session_hash); while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) { session = value; if (service_match(session, service) == FALSE) continue; entry = create_service_entry(service, name, CONNMAN_SERVICE_STATE_IDLE); if (entry == NULL) continue; iter_service_list = g_sequence_insert_sorted(session->service_list, entry, sort_services, session); g_hash_table_replace(session->service_hash, service, iter_service_list); session_changed(session, CONNMAN_SESSION_TRIGGER_SERVICE); } }