static int cavan_ext4_find_file_handler(struct ext2_desc *desc, void *block, size_t count, struct cavan_ext2_traversal_option *_option) { struct ext2_directory_entry *entry, *entry_end; struct cavan_ext4_find_file_option *option = (struct cavan_ext4_find_file_option *) _option; entry = block; entry_end = ADDR_ADD(entry, desc->block_size * count); while (entry < entry_end) { entry->name[entry->name_len] = 0; #if CAVAN_EXT2_DEBUG show_ext2_directory_entry(entry); #endif if (text_cmp(option->filename, entry->name) == 0) { mem_copy(option->entry, entry, EXT2_DIR_ENTRY_HEADER_SIZE); text_ncopy(option->entry->name, entry->name, entry->name_len); return CAVAN_EXT2_TRAVERSAL_FOUND; } entry = ADDR_ADD(entry, entry->rec_len); } return CAVAN_EXT2_TRAVERSAL_CONTINUE; }
static int modem_if_need_upgrade(const char *dirname, int retry) { char new_version[512], old_version[512]; if (modem_read_new_version(dirname, new_version, sizeof(new_version)) == NULL) { error_msg("modem_read_new_version"); return -EFAULT; } println("new version = %s", new_version); while (retry-- && modem_read_old_version(old_version, sizeof(old_version)) == NULL); if (retry < 0) { error_msg("modem_read_old_version"); return -EFAULT; } println("old version = %s", old_version); #if 0 return text_version_cmp(new_version, old_version, '.') > 0 #else return text_cmp(new_version, old_version) != 0; #endif }
struct cavan_xml_attribute *cavan_xml_attribute_find(struct cavan_xml_attribute *head, const char *name) { while (head) { if (text_cmp(head->name, name) == 0) { return head; } head = head->next; } return NULL; }
Datum bttextcmp(PG_FUNCTION_ARGS) { text *arg1 = PG_GETARG_TEXT_PP(0); text *arg2 = PG_GETARG_TEXT_PP(1); int32 result; result = text_cmp(arg1, arg2, PG_GET_COLLATION()); PG_FREE_IF_COPY(arg1, 0); PG_FREE_IF_COPY(arg2, 1); PG_RETURN_INT32(result); }
Datum text_ge(PG_FUNCTION_ARGS) { text *arg1 = PG_GETARG_TEXT_PP(0); text *arg2 = PG_GETARG_TEXT_PP(1); bool result; result = (text_cmp(arg1, arg2, PG_GET_COLLATION()) >= 0); PG_FREE_IF_COPY(arg1, 0); PG_FREE_IF_COPY(arg2, 1); PG_RETURN_BOOL(result); }
static struct modem_prop *modem_find_prop(struct modem_prop *props, size_t size, const char *prop_name) { struct modem_prop *prop_end; for (prop_end = props + size; props < prop_end; props++) { if (text_cmp(prop_name, props->name) == 0) { return props; } } return NULL; }
static void swan_keypad_handler(cavan_input_message_t *message, void *data) { struct cavan_input_message_key *key; if (message->type != CAVAN_INPUT_MESSAGE_KEY) { return; } key = &message->key; if (text_cmp(key->name, "POWER") == 0 || key->code == SWAN_KEY_POWER) { print_string("Power key was pressed, reset the system ..."); sync(); reboot(RB_AUTOBOOT); } }
int cavan_inotify_unregister_watch(struct cavan_inotify_descriptor *desc, const char *pathname) { struct cavan_inotify_watch *p, *p_end; for (p = desc->watchs, p_end = p + NELEM(desc->watchs); p < p_end; p++) { if (text_cmp(p->pathname, pathname) == 0) { inotify_rm_watch(desc->fd, p->wd); p->wd = -1; desc->watch_count--; return 0; } } return -ENOENT; }
int cavan_xml_tag_remove_all_by_name(struct cavan_xml_tag **head, const char *name, bool recursion) { int count = 0; while (*head) { if (text_cmp((*head)->name, name) == 0) { struct cavan_xml_tag *tag; tag = *head; *head = (*head)->next; cavan_xml_tag_free(tag); count++; } else { if (recursion) { count += cavan_xml_tag_remove_all_by_name(&(*head)->child, name, recursion); } head = &(*head)->next; } } return count; }