apps/app_selective.c
static int hear_entry(int crawlindex, char *family, char *key, struct ast_channel *chan, struct ast_str *strbuf, char *buf, struct selective_proc *f)
{
	char *number;
	char value[2];
	int res, len = 2;

	if (ast_db_get(family, key, value, len)) {
		ast_log(LOG_WARNING, "db: %s/%s not found in database.\n", family, key);
		return -1;
	}
	if (get_entry_type(value) == ENTRY_PRIVATE) {
		return 0; /* skip private entries */
	}

	number = key;
	ast_debug(1, "Entry index %d: '%s' (%s/%s = %s)\n", crawlindex, key, family, key, value);
	res = selective_read(chan, buf, BUFFER_SIZE, "", 0,
		crawlindex == 0 ? f->prompt_first_entry_is : f->prompt_next);

	res = say_telephone_number(chan, strbuf, buf, f, number);
	if (res < 0) {
		return -1;
	}

	res = selective_read(chan, buf, BUFFER_SIZE, "", SHORT_WAIT, "");
	ast_debug(1, "Management buffer contains '%s'\n", buf);

	if (IS_MAIN_COMMAND(buf)) {
		return -1; /* end list management */
	} else if (ast_strlen_zero(buf)) { /* no input, go to next entry */
		return res;
	} else if (strcmp(buf, "07")) { /* entered something, but not a valid command */
		memset(buf, 0, BUFFER_SIZE);
		res = selective_read(chan, buf, BUFFER_SIZE, "", MED_WAIT, f->prompt_invalid_command);
		return -1; /* end list management */
	}

	memset(buf, 0, BUFFER_SIZE); /* clear the buffer so it's ready for the next entry */

	if (ast_db_del(family, key)) {
		ast_log(LOG_WARNING, "delete: %s/%s not deleted from database.\n", family, key);
		return -1;
	}
	ast_verb(3, "Deleting entry '%s' from %s list\n", number, f->name);
	res = selective_read(chan, buf, BUFFER_SIZE, "", 0, f->prompt_number_removed_is);

	res = say_telephone_number(chan, strbuf, buf, f, number);
	if (res < 0) {
		return -1;
	}

	res = selective_read(chan, buf, BUFFER_SIZE, "", 0, main_wait);
	return res;
}
/*! \brief Callback function to delete all private entries from a list */
\brief Callback function to delete all private entries from a list
\ brief Callback function to delete all private entries from a list
static int hear_entry(int crawlindex, char *family, char *key, struct ast_channel *chan, struct ast_str *strbuf, char *buf, struct selective_proc *f)
{
	char *number;
	char value[2];
	int res, len = 2;
	if (ast_db_get(family, key, value, len)) {
		ast_log(LOG_WARNING, "db: %s/%s not found in database.\n", family, key);
		return -1;
	}
	if (get_entry_type(value) == ENTRY_PRIVATE) {
		return 0; 
	}
	number = key;
	ast_debug(1, "Entry index %d: '%s' (%s/%s = %s)\n", crawlindex, key, family, key, value);
	res = selective_read(chan, buf, BUFFER_SIZE, "", 0,
		crawlindex == 0 ? f->prompt_first_entry_is : f->prompt_next);
	res = say_telephone_number(chan, strbuf, buf, f, number);
	if (res < 0) {
		return -1;
	}
	res = selective_read(chan, buf, BUFFER_SIZE, "", SHORT_WAIT, "");
	ast_debug(1, "Management buffer contains '%s'\n", buf);
	if (IS_MAIN_COMMAND(buf)) {
		return -1; 
	} else if (ast_strlen_zero(buf)) { 
		return res;
	} else if (strcmp(buf, "07")) { 
		memset(buf, 0, BUFFER_SIZE);
		res = selective_read(chan, buf, BUFFER_SIZE, "", MED_WAIT, f->prompt_invalid_command);
		return -1; 
	}
	memset(buf, 0, BUFFER_SIZE); 
	if (ast_db_del(family, key)) {
		ast_log(LOG_WARNING, "delete: %s/%s not deleted from database.\n", family, key);
		return -1;
	}
	ast_verb(3, "Deleting entry '%s' from %s list\n", number, f->name);
	res = selective_read(chan, buf, BUFFER_SIZE, "", 0, f->prompt_number_removed_is);
	res = say_telephone_number(chan, strbuf, buf, f, number);
	if (res < 0) {
		return -1;
	}
	res = selective_read(chan, buf, BUFFER_SIZE, "", 0, main_wait);
	return res;
}
static int hear_entry ( int crawlindex , char * family , char * key , struct ast_channel * chan , struct ast_str * strbuf , char * buf , struct selective_proc * f ) { char * number ; char value [ 2 ] ; int res , len = 2 ; if ( ast_db_get ( family , key , value , len ) ) { ast_log ( LOG_WARNING , " \n " , family , key ) ; return -1 ; } if ( get_entry_type ( value ) == ENTRY_PRIVATE ) { return 0 ; } number = key ; ast_debug ( 1 , " \n " , crawlindex , key , family , key , value ) ; res = selective_read ( chan , buf , BUFFER_SIZE , " " , 0 , crawlindex == 0 ? f -> prompt_first_entry_is : f -> prompt_next ) ; res = say_telephone_number ( chan , strbuf , buf , f , number ) ; if ( res < 0 ) { return -1 ; } res = selective_read ( chan , buf , BUFFER_SIZE , " " , SHORT_WAIT , " " ) ; ast_debug ( 1 , " \n " , buf ) ; if ( IS_MAIN_COMMAND ( buf ) ) { return -1 ; } else if ( ast_strlen_zero ( buf ) ) { return res ; } else if ( strcmp ( buf , " " ) ) { memset ( buf , 0 , BUFFER_SIZE ) ; res = selective_read ( chan , buf , BUFFER_SIZE , " " , MED_WAIT , f -> prompt_invalid_command ) ; return -1 ; } memset ( buf , 0 , BUFFER_SIZE ) ; if ( ast_db_del ( family , key ) ) { ast_log ( LOG_WARNING , " \n " , family , key ) ; return -1 ; } ast_verb ( 3 , " \n " , number , f -> name ) ; res = selective_read ( chan , buf , BUFFER_SIZE , " " , 0 , f -> prompt_number_removed_is ) ; res = say_telephone_number ( chan , strbuf , buf , f , number ) ; if ( res < 0 ) { return -1 ; } res = selective_read ( chan , buf , BUFFER_SIZE , " " , 0 , main_wait ) ; return res ; }
\brief Callback function to delete all private entries from a list
\ brief Callback function to delete all private entries from a list
/* skip private entries */ /* end list management */ /* no input, go to next entry */ /* entered something, but not a valid command */ /* end list management */ /* clear the buffer so it's ready for the next entry */