void mpd_database_search_field_start(MpdObj *mi, mpd_TagItems field) { /* * Check argument */ if(mi == NULL || field >= MPD_TAG_NUM_OF_ITEM_TYPES || field < 0) { debug_printf(DEBUG_ERROR, "Argument error"); return ; } if(!mpd_check_connected(mi)) { debug_printf(DEBUG_ERROR, "Not Connected\n"); return ; } if(!mpd_server_check_version(mi, 0,12,0)) { debug_printf(DEBUG_ERROR, "Advanced field list requires mpd 0.12.0 or higher"); return ; } /* lock, so we can work on mi->connection */ if(mpd_lock_conn(mi) != MPD_OK) { debug_printf(DEBUG_ERROR, "Failed to lock connection"); return ; } mpd_startFieldSearch(mi->connection, field); /* Set search type */ mi->search_type = MPD_SEARCH_TYPE_LIST; mi->search_field = field; /* unlock, let the error handler handle any possible error. */ mpd_unlock_conn(mi); return; }
int cmd_list ( int argc, char ** argv, mpd_Connection * conn ) { Constraint *constraints; int numconstraints = 0; int type; int i; char *tag; type = get_search_type(argv[0]); if (type < 0) return -1; argc -= 1; argv += 1; if (argc > 0) { if (argc % 2 != 0) { DIE("arguments must be a tag type and " "optional pairs of search types and queries\n"); } numconstraints = get_constraints(argc, argv, &constraints); if (numconstraints < 0) return -1; } mpd_startFieldSearch(conn, type); if (argc > 0) { for (i = 0; i < numconstraints; i++) { mpd_addConstraintSearch(conn, constraints[i].type, charset_to_utf8(constraints[i].query)); } free(constraints); } mpd_commitSearch(conn); printErrorAndExit(conn); while ((tag = mpd_getNextTag(conn, type))) { printErrorAndExit(conn); printf("%s\n", charset_from_utf8(tag)); free(tag); } my_finishCommand(conn); return 0; }