示例#1
0
/*!
 * \brief Helper function that outputs the dialogs belonging to a given profile via the RPC interface
 * \see rpc_profile_print_dlgs
 * \see rpc_profile_w_value_print_dlgs
 * \param rpc RPC node that should be filled
 * \param c RPC void pointer
 * \param profile_name the given profile
 * \param value the given profile value
 * \param with_context if 1 then the dialog context will be also printed
 */
static void internal_rpc_profile_print_dlgs(rpc_t *rpc, void *c, str *profile_name,
		str *value) {
	dlg_profile_table_t *profile;
	dlg_profile_hash_t *ph;
	unsigned int i;

	profile = search_dlg_profile( profile_name );
	if (!profile) {
		rpc->printf(c, "Non existing profile:%.*s",
			profile_name->len, profile_name->s);
		return;
	}

	/* go through the hash and print the dialogs */
	if (profile->has_value==0 || value==NULL) {
		/* no value */
		lock_get( &profile->lock );
		for ( i=0 ; i< profile->size ; i++ ) {
			ph = profile->entries[i].first;
			if(ph) {
				do {
					/* print dialog */
					internal_rpc_print_dlg(rpc, c, ph->dlg, 0);
					/* next */
					ph=ph->next;
				}while(ph!=profile->entries[i].first);
			}
			lock_release(&profile->lock);
		}
	} else {
		/* check for value also */
		lock_get( &profile->lock );
		for ( i=0 ; i< profile->size ; i++ ) {
			ph = profile->entries[i].first;
			if(ph) {
				do {
					if ( value->len==ph->value.len &&
						memcmp(value->s,ph->value.s,value->len)==0 ) {
						/* print dialog */
						internal_rpc_print_dlg(rpc, c, ph->dlg, 0);
					}
					/* next */
					ph=ph->next;
				}while(ph!=profile->entries[i].first);
			}
			lock_release(&profile->lock);
		}
	}
}
示例#2
0
/*!
 * \brief Helper function that outputs all dialogs via the RPC interface
 * \see rpc_print_dlgs
 * \param rpc RPC node that should be filled
 * \param c RPC void pointer
 * \param with_context if 1 then the dialog context will be also printed
 */
static void internal_rpc_print_dlgs(rpc_t *rpc, void *c)
{
	struct dlg_cell *dlg;
	unsigned int i;

	void *ah;
	void *dh;		/*beginning struct holding dialogs*/

	if (rpc->add(c, "{", &ah) < 0) {
		rpc->fault(c, 500, "Internal error creating top rpc");
		return;
	}
	if (rpc->struct_add(ah, "d{", "Size", (int) d_table->size, "Dialogs", &dh) < 0) {
		rpc->fault(c, 500, "Internal error creating inner struct");
		return;
	}

	for( i=0 ; i<d_table->size ; i++ ) {
		dlg_lock( d_table, &(d_table->entries[i]) );

		for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) {
			internal_rpc_print_dlg(rpc, c, dlg, dh);
		}
		dlg_unlock( d_table, &(d_table->entries[i]) );
	}
}
示例#3
0
/*!
 * \brief Helper function that outputs the dialogs belonging to a given profile via the RPC interface
 * \see rpc_profile_print_dlgs
 * \see rpc_profile_w_value_print_dlgs
 * \param rpc RPC node that should be filled
 * \param c RPC void pointer
 * \param profile_name the given profile
 * \param value the given profile value
 * \param with_context if 1 then the dialog context will be also printed
 */
static void internal_rpc_profile_print_dlgs(rpc_t *rpc, void *c, str *profile_name,
		str *value) {
	dlg_profile_table_t *profile;
	dlg_profile_hash_t *ph;
	unsigned int i;

	profile = search_dlg_profile( profile_name );
	if (!profile) {
		rpc->fault(c, 404, "Profile not found: %.*s",
			profile_name->len, profile_name->s);
		return;
	}

	/* go through the hash and print the dialogs */
	if (profile->has_value==0)
		value=NULL;

	lock_get( &profile->lock );
	for ( i=0 ; i< profile->size ; i++ ) {
		ph = profile->entries[i].first;
		if(ph) {
			do {
				if ((!value || (STR_EQ(*value, ph->value))) && ph->dlg) {
					/* print dialog */
					internal_rpc_print_dlg(rpc, c, ph->dlg, 0);
				}
				/* next */
				ph=ph->next;
			}while(ph!=profile->entries[i].first);
		}
		lock_release(&profile->lock);
	}
}
示例#4
0
/*!
 * \brief Helper function that outputs all dialogs via the RPC interface
 * \see rpc_print_dlgs
 * \param rpc RPC node that should be filled
 * \param c RPC void pointer
 * \param with_context if 1 then the dialog context will be also printed
 */
static void internal_rpc_print_dlgs(rpc_t *rpc, void *c, int with_context)
{
	dlg_cell_t *dlg;
	unsigned int i;

	for( i=0 ; i<d_table->size ; i++ ) {
		dlg_lock( d_table, &(d_table->entries[i]) );

		for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) {
			internal_rpc_print_dlg(rpc, c, dlg, with_context);
		}
		dlg_unlock( d_table, &(d_table->entries[i]) );
	}
}
示例#5
0
/*!
 * \brief Helper function that outputs a dialog via the RPC interface
 * \see rpc_print_dlgs
 * \param rpc RPC node that should be filled
 * \param c RPC void pointer
 * \param with_context if 1 then the dialog context will be also printed
 */
static void internal_rpc_print_single_dlg(rpc_t *rpc, void *c, int with_context) {
	str callid, from_tag;
	dlg_entry_t *d_entry;
	dlg_cell_t *dlg;
	unsigned int h_entry;

	if (rpc->scan(c, ".S.S", &callid, &from_tag) < 2) return;

	h_entry = core_hash( &callid, 0, d_table->size);
	d_entry = &(d_table->entries[h_entry]);
	dlg_lock( d_table, d_entry);
	for( dlg = d_entry->first ; dlg ; dlg = dlg->next ) {
		if (match_downstream_dialog( dlg, &callid, &from_tag)==1) {
			internal_rpc_print_dlg(rpc, c, dlg, with_context);
		}
	}
	dlg_unlock( d_table, d_entry);
}