apps/app_selective.c
static int selective_clear(struct ast_channel *chan, struct ast_str *strbuf, char *buf, struct selective_proc *f, int flags)
{
	int privates, entries = get_number_entries(chan, strbuf, f, ENTRY_ANY);

	if (!entries) { /* list is empty, there is nothing to clear out from it... */
		ast_verb(3, "User requested clearing all%s entries from %s list, but list is empty", flags == ENTRY_PRIVATE ? " private" : "", f->name);
		return selective_read(chan, buf, BUFFER_SIZE, MAIN_MENU_TERM, MED_WAIT, f->prompt_sorry_no_entries);
	}

	if (flags == ENTRY_PRIVATE) { /* remove only private entries */
		privates = get_number_entries(chan, strbuf, f, ENTRY_PRIVATE);
		/* yes, we're going to crawl the DB twice, effectively.
			However, this allows us to know how many private entries there are this point.
			Yes, that info gets returned as well, however, this allows us to ensure
			we deleted all of them and emit an error if something weird happened. */
		if (privates) {
			int deleted;
			ast_str_reset(strbuf);
			ast_str_substitute_variables(&strbuf, 0, chan, f->astdb_entries);
			deleted = db_crawl(ast_strdupa(ast_str_buffer(strbuf)), delete_private_entries);
			if (deleted != privates) {
				ast_log(LOG_WARNING, "Found %d private entries, but we only deleted %d?\n", privates, deleted);
			}
		}
	} else { /* delete all list entries */
		/* yeah, this is a little sloppy. We could do the DB stuff directly, but DRY, right? */
		ast_str_reset(strbuf);
		ast_str_substitute_variables(&strbuf, 0, chan, f->astdb_entries);
		if (exec_app(chan, "DBDeltree", ast_strdupa(ast_str_buffer(strbuf)))) {
			ast_log(LOG_WARNING, "Failed to remove list entries\n");
			return 0;
		}
	}

	ast_verb(3, "User removed all %d%s entries from %s list\n", flags == ENTRY_PRIVATE ? privates : entries, flags == ENTRY_PRIVATE ? " private" : "", f->name);

	return selective_read(chan, buf, BUFFER_SIZE, MAIN_MENU_TERM, MED_WAIT,
		flags == ENTRY_PRIVATE ? f->prompt_no_more_private : f->prompt_no_more);
}
/*! \brief Remove either all or all private entries from a list */
\brief Remove either all or all private entries from a list
\ brief Remove either all or all private entries from a list
static int selective_clear(struct ast_channel *chan, struct ast_str *strbuf, char *buf, struct selective_proc *f, int flags)
{
	int privates, entries = get_number_entries(chan, strbuf, f, ENTRY_ANY);
	if (!entries) { 
		ast_verb(3, "User requested clearing all%s entries from %s list, but list is empty", flags == ENTRY_PRIVATE ? " private" : "", f->name);
		return selective_read(chan, buf, BUFFER_SIZE, MAIN_MENU_TERM, MED_WAIT, f->prompt_sorry_no_entries);
	}
	if (flags == ENTRY_PRIVATE) { 
		privates = get_number_entries(chan, strbuf, f, ENTRY_PRIVATE);
		if (privates) {
			int deleted;
			ast_str_reset(strbuf);
			ast_str_substitute_variables(&strbuf, 0, chan, f->astdb_entries);
			deleted = db_crawl(ast_strdupa(ast_str_buffer(strbuf)), delete_private_entries);
			if (deleted != privates) {
				ast_log(LOG_WARNING, "Found %d private entries, but we only deleted %d?\n", privates, deleted);
			}
		}
	} else { 
		ast_str_reset(strbuf);
		ast_str_substitute_variables(&strbuf, 0, chan, f->astdb_entries);
		if (exec_app(chan, "DBDeltree", ast_strdupa(ast_str_buffer(strbuf)))) {
			ast_log(LOG_WARNING, "Failed to remove list entries\n");
			return 0;
		}
	}
	ast_verb(3, "User removed all %d%s entries from %s list\n", flags == ENTRY_PRIVATE ? privates : entries, flags == ENTRY_PRIVATE ? " private" : "", f->name);
	return selective_read(chan, buf, BUFFER_SIZE, MAIN_MENU_TERM, MED_WAIT,
		flags == ENTRY_PRIVATE ? f->prompt_no_more_private : f->prompt_no_more);
}
static int selective_clear ( struct ast_channel * chan , struct ast_str * strbuf , char * buf , struct selective_proc * f , int flags ) { int privates , entries = get_number_entries ( chan , strbuf , f , ENTRY_ANY ) ; if ( ! entries ) { ast_verb ( 3 , " " , flags == ENTRY_PRIVATE ? " " : " " , f -> name ) ; return selective_read ( chan , buf , BUFFER_SIZE , MAIN_MENU_TERM , MED_WAIT , f -> prompt_sorry_no_entries ) ; } if ( flags == ENTRY_PRIVATE ) { privates = get_number_entries ( chan , strbuf , f , ENTRY_PRIVATE ) ; if ( privates ) { int deleted ; ast_str_reset ( strbuf ) ; ast_str_substitute_variables ( & strbuf , 0 , chan , f -> astdb_entries ) ; deleted = db_crawl ( ast_strdupa ( ast_str_buffer ( strbuf ) ) , delete_private_entries ) ; if ( deleted != privates ) { ast_log ( LOG_WARNING , " \n " , privates , deleted ) ; } } } else { ast_str_reset ( strbuf ) ; ast_str_substitute_variables ( & strbuf , 0 , chan , f -> astdb_entries ) ; if ( exec_app ( chan , " " , ast_strdupa ( ast_str_buffer ( strbuf ) ) ) ) { ast_log ( LOG_WARNING , " \n " ) ; return 0 ; } } ast_verb ( 3 , " \n " , flags == ENTRY_PRIVATE ? privates : entries , flags == ENTRY_PRIVATE ? " " : " " , f -> name ) ; return selective_read ( chan , buf , BUFFER_SIZE , MAIN_MENU_TERM , MED_WAIT , flags == ENTRY_PRIVATE ? f -> prompt_no_more_private : f -> prompt_no_more ) ; }
\brief Remove either all or all private entries from a list
\ brief Remove either all or all private entries from a list
/* list is empty, there is nothing to clear out from it... */ /* remove only private entries */ /* yes, we're going to crawl the DB twice, effectively.
			However, this allows us to know how many private entries there are this point.
			Yes, that info gets returned as well, however, this allows us to ensure
			we deleted all of them and emit an error if something weird happened. */ /* delete all list entries */ /* yeah, this is a little sloppy. We could do the DB stuff directly, but DRY, right? */