コード例 #1
0
ファイル: db.c プロジェクト: aderbas/asterisk
static char *handle_cli_database_put(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	int res;

	switch (cmd) {
	case CLI_INIT:
		e->command = "database put";
		e->usage =
			"Usage: database put <family> <key> <value>\n"
			"       Adds or updates an entry in the Asterisk database for\n"
			"       a given family, key, and value.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (a->argc != 5)
		return CLI_SHOWUSAGE;
	res = ast_db_put(a->argv[2], a->argv[3], a->argv[4]);
	if (res)  {
		ast_cli(a->fd, "Failed to update entry\n");
	} else {
		ast_cli(a->fd, "Updated database successfully\n");
	}
	return CLI_SUCCESS;
}
コード例 #2
0
ファイル: config_transport.c プロジェクト: GGGO/asterisk
static char *handle_pjsip_list_ciphers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	pj_ssl_cipher ciphers[100];
	unsigned int cipher_num = PJ_ARRAY_SIZE(ciphers);
	char *buf;

	switch (cmd) {
	case CLI_INIT:
		e->command = "pjsip list ciphers";
		e->usage = "Usage: pjsip list ciphers\n"
			"       List available OpenSSL cipher names.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (pj_ssl_cipher_get_availables(ciphers, &cipher_num) || !cipher_num) {
		buf = NULL;
	} else {
		cipher_to_str(&buf, ciphers, cipher_num);
	}

	if (!ast_strlen_zero(buf)) {
		ast_cli(a->fd, "Available ciphers: '%s'\n", buf);
	} else {
		ast_cli(a->fd, "No available ciphers\n");
	}
	ast_free(buf);
	return CLI_SUCCESS;
}
コード例 #3
0
ファイル: db.c プロジェクト: aderbas/asterisk
static char *handle_cli_database_del(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	int res;

	switch (cmd) {
	case CLI_INIT:
		e->command = "database del";
		e->usage =
			"Usage: database del <family> <key>\n"
			"       Deletes an entry in the Asterisk database for a given\n"
			"       family and key.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (a->argc != 4)
		return CLI_SHOWUSAGE;
	res = ast_db_del(a->argv[2], a->argv[3]);
	if (res) {
		ast_cli(a->fd, "Database entry does not exist.\n");
	} else {
		ast_cli(a->fd, "Database entry removed.\n");
	}
	return CLI_SUCCESS;
}
コード例 #4
0
ファイル: db.c プロジェクト: aderbas/asterisk
static char *handle_cli_database_get(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	int res;
	char tmp[MAX_DB_FIELD];

	switch (cmd) {
	case CLI_INIT:
		e->command = "database get";
		e->usage =
			"Usage: database get <family> <key>\n"
			"       Retrieves an entry in the Asterisk database for a given\n"
			"       family and key.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (a->argc != 4)
		return CLI_SHOWUSAGE;
	res = ast_db_get(a->argv[2], a->argv[3], tmp, sizeof(tmp));
	if (res) {
		ast_cli(a->fd, "Database entry not found.\n");
	} else {
		ast_cli(a->fd, "Value: %s\n", tmp);
	}
	return CLI_SUCCESS;
}
コード例 #5
0
static void cli_display_parking_global(int fd)
{
	ast_cli(fd, "Parking General Options\n"
	            "-----------------------\n");
	ast_cli(fd, "Dynamic Parking     :  %s\n", parking_dynamic_lots_enabled() ? "yes" : "no");
	ast_cli(fd, "\n");
}
コード例 #6
0
ファイル: db.c プロジェクト: aderbas/asterisk
static char *handle_cli_database_deltree(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	int num_deleted;

	switch (cmd) {
	case CLI_INIT:
		e->command = "database deltree";
		e->usage =
			"Usage: database deltree <family> [keytree]\n"
			"   OR: database deltree <family>[/keytree]\n"
			"       Deletes a family or specific keytree within a family\n"
			"       in the Asterisk database.  The two arguments may be\n"
			"       separated by either a space or a slash.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if ((a->argc < 3) || (a->argc > 4))
		return CLI_SHOWUSAGE;
	if (a->argc == 4) {
		num_deleted = ast_db_deltree(a->argv[2], a->argv[3]);
	} else {
		num_deleted = ast_db_deltree(a->argv[2], NULL);
	}
	if (num_deleted < 0) {
		ast_cli(a->fd, "Database unavailable.\n");
	} else if (num_deleted == 0) {
		ast_cli(a->fd, "Database entries do not exist.\n");
	} else {
		ast_cli(a->fd, "%d database entries removed.\n",num_deleted);
	}
	return CLI_SUCCESS;
}
コード例 #7
0
static int handle_chanlist(int fd, int argc, char *argv[])
{
#define FORMAT_STRING  "%15s  (%-10s %-12s %-4d) %7s %-12s  %-15s\n"
#define FORMAT_STRING2 "%15s  (%-10s %-12s %-4s) %7s %-12s  %-15s\n"
#define CONCISE_FORMAT_STRING  "%s:%s:%s:%d:%s:%s:%s:%s:%s:%d\n"

	struct ast_channel *c=NULL;
	int numchans = 0;
	int concise = 0;
	if (argc < 2 || argc > 3)
		return RESULT_SHOWUSAGE;
	
	concise = (argc == 3 && (!strcasecmp(argv[2],"concise")));
	c = ast_channel_walk_locked(NULL);
	if(!concise)
		ast_cli(fd, FORMAT_STRING2, "Channel", "Context", "Extension", "Pri", "State", "Appl.", "Data");
	while(c) {
		if(concise)
			ast_cli(fd, CONCISE_FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state),
					c->appl ? c->appl : "(None)", c->data ? ( !ast_strlen_zero(c->data) ? c->data : "" ): "",
					(c->callerid && !ast_strlen_zero(c->callerid)) ? c->callerid : "",
					(c->accountcode && !ast_strlen_zero(c->accountcode)) ? c->accountcode : "",c->amaflags);
		else
			ast_cli(fd, FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state),
					c->appl ? c->appl : "(None)", c->data ? ( !ast_strlen_zero(c->data) ? c->data : "(Empty)" ): "(None)");

		numchans++;
		ast_mutex_unlock(&c->lock);
		c = ast_channel_walk_locked(c);
	}
	if(!concise)
		ast_cli(fd, "%d active channel(s)\n", numchans);
	return RESULT_SUCCESS;
}
コード例 #8
0
ファイル: aoc.c プロジェクト: bugrahantopall/asterisk
static char *aoc_cli_debug_enable(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	switch (cmd) {
	case CLI_INIT:
		e->command = "aoc set debug";
		e->usage =
			"Usage: 'aoc set debug on' to enable aoc debug, 'aoc set debug off' to disable debug.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	case CLI_HANDLER:
		if (a->argc != 4) {
			return CLI_SHOWUSAGE;
		} else if(ast_true(a->argv[3])) {
			ast_cli(a->fd, "aoc debug enabled\n");
			aoc_debug_enabled = 1;
		} else if (ast_false(a->argv[3])) {
			ast_cli(a->fd, "aoc debug disabled\n");
			aoc_debug_enabled = 0;
		} else {
			return CLI_SHOWUSAGE;
		}
	}

	return CLI_SUCCESS;
}
コード例 #9
0
ファイル: db.c プロジェクト: Evangileon/asterisk
static char *handle_cli_database_showkey(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	char suffix[MAX_DB_FIELD];
	int counter = 0;

	switch (cmd) {
	case CLI_INIT:
		e->command = "database showkey";
		e->usage =
			"Usage: database showkey <keytree>\n"
			"       Shows Asterisk database contents, restricted to a given key.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (a->argc == 3) {
		/* Key only */
		snprintf(suffix, sizeof(suffix), "/%s", a->argv[2]);
	} else {
		return CLI_SHOWUSAGE;
	}

	if ((counter = process_db_keys(db_showkey_cb, a, suffix, 0)) < 0) {
		ast_cli(a->fd, "Database unavailable\n");
		return CLI_SUCCESS;
	}

	ast_cli(a->fd, "%d results found.\n", counter);
	return CLI_SUCCESS;
}
コード例 #10
0
static int handle_set_debug(int fd, int argc, char *argv[])
{
	int val = 0;
	int oldval = 0;

	/* Has a hidden 'at least' argument */
	if ((argc != 3) && (argc != 4))
		return RESULT_SHOWUSAGE;
	if ((argc == 4) && strcasecmp(argv[2], "atleast"))
		return RESULT_SHOWUSAGE;
	oldval = option_debug;
	if (argc == 3)
		option_debug = atoi(argv[2]);
	else {
		val = atoi(argv[3]);
		if (val > option_debug)
			option_debug = val;
	}
	if (oldval != option_debug && option_debug > 0)
		ast_cli(fd, "Core debug was %d and is now %d\n", oldval, option_debug);
	else if (oldval > 0 && option_debug > 0)
		ast_cli(fd, "Core debug is at least %d\n", option_debug);
	else if (oldval > 0 && option_debug == 0)
		ast_cli(fd, "Core debug is now OFF\n");
	return RESULT_SUCCESS;
}
コード例 #11
0
static int handle_context_remove_ignorepat(int fd, int argc, char *argv[])
{
	if (argc != 5) return RESULT_SHOWUSAGE;
	if (strcmp(argv[3], "from")) return RESULT_SHOWUSAGE;

	if (ast_context_remove_ignorepat(argv[4], argv[2], registrar)) {
		switch (errno) {
			case EBUSY:
				ast_cli(fd, "Failed to lock context(s) list, please try again later\n");
				break;

			case ENOENT:
				ast_cli(fd, "There is no existence of '%s' context\n", argv[4]);
				break;

			case EINVAL:
				ast_cli(fd, "There is no existence of '%s' ignore pattern in '%s' context\n",
					argv[2], argv[4]);
				break;

			default:
				ast_cli(fd, "Failed to remove ignore pattern '%s' from '%s' context\n", argv[2], argv[4]);
				break;
		}
		return RESULT_FAILURE;
	}

	ast_cli(fd, "Ignore pattern '%s' removed from '%s' context\n",
		argv[2], argv[4]);
	return RESULT_SUCCESS;
}
コード例 #12
0
static void display_parked_call(struct parked_user *user, int fd)
{
	ast_cli(fd, "  Space               :  %d\n", user->parking_space);
	ast_cli(fd, "  Channel             :  %s\n", ast_channel_name(user->chan));
	ast_cli(fd, "  Parker Dial String  :  %s\n", user->parker_dial_string);
	ast_cli(fd, "\n");
}
コード例 #13
0
ファイル: db.c プロジェクト: abieuzent/iaxproxy
static char *handle_cli_database_deltree(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	int res;

	switch (cmd) {
	case CLI_INIT:
		e->command = "database deltree";
		e->usage =
			"Usage: database deltree <family> [keytree]\n"
			"       Deletes a family or specific keytree within a family\n"
			"       in the Asterisk database.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if ((a->argc < 3) || (a->argc > 4))
		return CLI_SHOWUSAGE;
	if (a->argc == 4) {
		res = ast_db_deltree(a->argv[2], a->argv[3]);
	} else {
		res = ast_db_deltree(a->argv[2], NULL);
	}
	if (res < 0) {
		ast_cli(a->fd, "Database entries do not exist.\n");
	} else {
		ast_cli(a->fd, "%d database entries removed.\n",res);
	}
	return CLI_SUCCESS;
}
コード例 #14
0
ファイル: dump.c プロジェクト: nicolastanski/chan_ss7
int init_dump(int fd, const char* fn, int in, int out, int fisu, int lssu, int msu)
{
  FILE *fh;

  ast_mutex_lock(&dump_mutex);
  if((in && dump_in_fh != NULL) || (out && dump_out_fh != NULL)) {
    ast_cli(fd, "Dump already running, must be stopped (with 'ss7 stop dump') "
            "before new can be started.\n");
    ast_mutex_unlock(&dump_mutex);
    return -1;
  }


  fh = fopen(fn, "w");
  if(fh == NULL) {
    ast_cli(fd, "Error opening file '%s': %s.\n", fn, strerror(errno));
    ast_mutex_unlock(&dump_mutex);
    return -1;
  }

  if(in) {
    dump_in_fh = fh;
  }
  if(out) {
    dump_out_fh = fh;
  }
  dump_do_fisu = fisu;
  dump_do_lssu = lssu;
  dump_do_msu = msu;
  init_pcap_file(fh);


  ast_mutex_unlock(&dump_mutex);
  return 0;
}
コード例 #15
0
/* Commands */
static int h324m_do_debug(int fd, int argc, char *argv[])
{
	int level;

	/* Check number of arguments */
	if (argc != 4)
		return RESULT_SHOWUSAGE;

	/* Get level */
	level = atoi(argv[3]);

	/* Check it's correct */
	if((level < 0) || (level > 9))
		return RESULT_SHOWUSAGE;

	/* Print result */	
	if(level)
		ast_cli(fd, "app_h324m Debugging enabled level: %d\n", level);
	else
		ast_cli(fd, "app_h324m Debugging disabled\n");

	/* Set log level */
	H324MLoggerSetLevel(level);

	/* Exit */
	return RESULT_SUCCESS;
}
コード例 #16
0
ファイル: res_realtime.c プロジェクト: n02018222/asterisk
static char *cli_realtime_update(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	int res = 0;

	switch (cmd) {
	case CLI_INIT:
		e->command = "realtime update";
		e->usage =
			"Usage: realtime update <family> <colmatch> <valuematch> <colupdate> <newvalue>\n"
			"       Update a single variable using the RealTime driver.\n"
			"       You must supply a family name, a column to update on, a new value, column to match, and value to match.\n"
			"       Ex: realtime update sipfriends name bobsphone port 4343\n"
			"       will execute SQL as UPDATE sipfriends SET port = 4343 WHERE name = bobsphone\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (a->argc < 7) 
		return CLI_SHOWUSAGE;

	res = ast_update_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], SENTINEL);

	if (res < 0) {
		ast_cli(a->fd, "Failed to update. Check the debug log for possible SQL related entries.\n");
		return CLI_FAILURE;
	}

	ast_cli(a->fd, "Updated %d RealTime record%s.\n", res, ESS(res));

	return CLI_SUCCESS;
}
コード例 #17
0
ファイル: app_playback.c プロジェクト: adaptiman/asterisk
static char *__say_cli_init(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	const char *old_mode = say_api_buf[0] ? say_new : say_old;
	const char *mode;
	switch (cmd) {
	case CLI_INIT:
		e->command = "say load [new|old]";
		e->usage = 
			"Usage: say load [new|old]\n"
			"       say load\n"
			"           Report status of current say mode\n"
			"       say load new\n"
			"           Set say method, configured in say.conf\n"
			"       say load old\n"
			"           Set old say method, coded in asterisk core\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}
	if (a->argc == 2) {
		ast_cli(a->fd, "say mode is [%s]\n", old_mode);
		return CLI_SUCCESS;
	} else if (a->argc != e->args)
		return CLI_SHOWUSAGE;
	mode = a->argv[2];
	if (!strcmp(mode, old_mode))
		ast_cli(a->fd, "say mode is %s already\n", mode);
	else
		if (say_init_mode(mode) == 0)
			ast_cli(a->fd, "setting say mode from %s to %s\n", old_mode, mode);

	return CLI_SUCCESS;
}
コード例 #18
0
ファイル: clm.c プロジェクト: n02018222/asterisk
static char *ais_clm_show_members(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	int i;
	SaClmClusterNotificationBufferT buf;
	SaClmClusterNotificationT notif[64];
	SaAisErrorT ais_res;

	switch (cmd) {
	case CLI_INIT:
		e->command = "ais show clm members";
		e->usage =
			"Usage: ais show clm members\n"
			"       List members of the cluster using the CLM (Cluster Membership) service.\n";
		return NULL;

	case CLI_GENERATE:
		return NULL;	/* no completion */
	}

	if (a->argc != e->args)
		return CLI_SHOWUSAGE;

	buf.notification = notif;
	buf.numberOfItems = ARRAY_LEN(notif);

	ais_res = saClmClusterTrack(clm_handle, SA_TRACK_CURRENT, &buf);
	if (ais_res != SA_AIS_OK) {
		ast_cli(a->fd, "Error retrieving current cluster members.\n");
		return CLI_FAILURE;
	}

	ast_cli(a->fd, "\n"
	            "=============================================================\n"
	            "=== Cluster Members =========================================\n"
	            "=============================================================\n"
	            "===\n");

	for (i = 0; i < buf.numberOfItems; i++) {
		SaClmClusterNodeT *node = &buf.notification[i].clusterNode;

		ast_cli(a->fd, "=== ---------------------------------------------------------\n"
		               "=== Node Name: %s\n"
		               "=== ==> ID: 0x%x\n"
		               "=== ==> Address: %s\n"
		               "=== ==> Member: %s\n",
		               (char *) node->nodeName.value, (int) node->nodeId,
		               (char *) node->nodeAddress.value,
		               node->member ? "Yes" : "No");

		ast_cli(a->fd, "=== ---------------------------------------------------------\n"
		               "===\n");
	}

	ast_cli(a->fd, "=============================================================\n"
	               "\n");

	return CLI_SUCCESS;
}
コード例 #19
0
ファイル: db.c プロジェクト: abieuzent/iaxproxy
static char *handle_cli_database_showkey(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	char suffix[256];
	DBT key, data;
	char *keys, *values;
	int res;
	int pass;
	int counter = 0;

	switch (cmd) {
	case CLI_INIT:
		e->command = "database showkey";
		e->usage =
			"Usage: database showkey <keytree>\n"
			"       Shows Asterisk database contents, restricted to a given key.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (a->argc == 3) {
		/* Key only */
		snprintf(suffix, sizeof(suffix), "/%s", a->argv[2]);
	} else {
		return CLI_SHOWUSAGE;
	}
	ast_mutex_lock(&dblock);
	if (dbinit()) {
		ast_mutex_unlock(&dblock);
		ast_cli(a->fd, "Database unavailable\n");
		return CLI_SUCCESS;	
	}
	memset(&key, 0, sizeof(key));
	memset(&data, 0, sizeof(data));
	pass = 0;
	while (!(res = astdb->seq(astdb, &key, &data, pass++ ? R_NEXT : R_FIRST))) {
		if (key.size) {
			keys = key.data;
			keys[key.size - 1] = '\0';
		} else {
			keys = "<bad key>";
		}
		if (data.size) {
			values = data.data;
			values[data.size - 1]='\0';
		} else {
			values = "<bad value>";
		}
		if (subkeymatch(keys, suffix)) {
			ast_cli(a->fd, "%-50s: %-25s\n", keys, values);
			counter++;
		}
	}
	ast_mutex_unlock(&dblock);
	ast_cli(a->fd, "%d results found.\n", counter);
	return CLI_SUCCESS;	
}
コード例 #20
0
ファイル: divastatus.c プロジェクト: adlerweb/chan_capi
int pbxcli_capi_ifc_status(int fd, int argc, char *argv[])
#endif
{
	diva_entity_link_t* link;
#ifdef CC_AST_HAS_VERSION_1_6
	int fd = a->fd;

	if (cmd == CLI_INIT) {
		e->command = CC_MESSAGE_NAME " ifcstate";
		e->usage = diva_status_ifc_state_usage;
		return NULL;
	} else if (cmd == CLI_GENERATE)
		return NULL;
	if (a->argc != e->args)
		return CLI_SHOWUSAGE;
#else
	
	if (argc != 2)
		return RESULT_SHOWUSAGE;
#endif

	if ( diva_q_get_head(&controller_q) == NULL) {
		ast_cli(fd, "There are no interraces in " CC_MESSAGE_NAME " instance.\n");
		return RESULT_SUCCESS;
	}

	ast_cli(fd, CC_MESSAGE_NAME " interfaces\n");
	ast_cli(fd, "%s %-9s%-4s%-4s%-4s%-7s%-5s%8s%12s%12s%12s%12s\n",
							"INTERFACE", "State", "L1", "L2", "RED", "YELLOW", "BLUE", "D-Rx-Frames", "D-Rx-Bytes","D-Tx-Frames", "D-Tx-Bytes", "D-Errors");

	for (link = diva_q_get_head(&controller_q); link != 0; link = diva_q_get_next(link)) {
		diva_status_ifc_t *controllerState = DIVAS_CONTAINING_RECORD(link, diva_status_ifc_t, link);
		diva_status_ifc_state_t* state = &controllerState->state[controllerState->currentState];
		ast_cli(fd, "ISDN%-3d%-2s %-9s%-4s%-4s%-4s%-7s%-3s %12d %11d %11d %11d %11d\n",
						controllerState->capiController, "",
						pbxcli_get_visual_ifc_state(state),
						pbxcli_get_visual_ifc_l1_state(state),
						pbxcli_get_visual_ifc_l2_state(state),
						((state->ifcType == DivaStatusIfcPri) && (state->hwState == DivaStatusHardwareStateOK)) ?
												(state->ifcAlarms.Red    != 0 ? "On" : "Off") : "-",
						((state->ifcType == DivaStatusIfcPri) && (state->hwState == DivaStatusHardwareStateOK)) ?
												(state->ifcAlarms.Yellow != 0 ? "On" : "Off") : "-",
						((state->ifcType == DivaStatusIfcPri) && (state->hwState == DivaStatusHardwareStateOK)) ?
												(state->ifcAlarms.Blue   != 0 ? "On" : "Off") : "-",
						state->ifcRxDStatistics.Frames, state->ifcRxDStatistics.Bytes,
						state->ifcTxDStatistics.Frames, state->ifcTxDStatistics.Bytes,
						state->ifcRxDStatistics.Errors + state->ifcTxDStatistics.Errors
						);
	}

#ifdef CC_AST_HAS_VERSION_1_6
	return CLI_SUCCESS;
#else
	return RESULT_SUCCESS;
#endif
}
コード例 #21
0
static int cli_callback(void *pArg, int argc, char **argv, char **columnNames){
	int fd=0;
	int x=0;
	switch_config *config = pArg;

	if (config) {
		fd = config->fd;
	}
	else
		return -1;

	if (vh == 'v') {
		ast_cli(fd,"\n");
		for(x=0;x<argc;x++)
			ast_cli(fd,"%s=%s\n",columnNames[x],argv[x]);
		ast_cli(fd,"\n");
	}
	else {
		if (!config->seeheads) {
			ast_cli(fd,"|");
			for(x=0;x<argc;x++)
				ast_cli(fd,"%s|",columnNames[x]);
			config->seeheads = 1;
			ast_cli(fd,"\n");
		}
		ast_cli(fd,"|");
		for(x=0;x<argc;x++)
			ast_cli(fd,"%s|",argv[x]);
		ast_cli(fd,"\n");
	}

	return 0;
}
コード例 #22
0
ファイル: cel.c プロジェクト: RoyalG41/Asterisk
static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	unsigned int i;
	struct ast_event_sub *sub;

	switch (cmd) {
	case CLI_INIT:
		e->command = "cel show status";
		e->usage =
			"Usage: cel show status\n"
			"       Displays the Channel Event Logging system status.\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	case CLI_HANDLER:
		break;
	}

	if (a->argc > 3) {
		return CLI_SHOWUSAGE;
	}

	ast_cli(a->fd, "CEL Logging: %s\n", cel_enabled ? "Enabled" : "Disabled");

	if (!cel_enabled) {
		return CLI_SUCCESS;
	}

	for (i = 0; i < (sizeof(eventset) * 8); i++) {
		const char *name;

		if (!(eventset & ((int64_t) 1 << i))) {
			continue;
		}

		name = ast_cel_get_type_name(i);
		if (strcasecmp(name, "Unknown")) {
			ast_cli(a->fd, "CEL Tracking Event: %s\n", name);
		}
	}

	ao2_callback(appset, OBJ_NODATA, print_app, a);

	if (!(sub = ast_event_subscribe_new(AST_EVENT_SUB, print_cel_sub, a))) {
		return CLI_FAILURE;
	}
	ast_event_sub_append_ie_uint(sub, AST_EVENT_IE_EVENTTYPE, AST_EVENT_CEL);
	ast_event_report_subs(sub);
	ast_event_sub_destroy(sub);
	sub = NULL;

	return CLI_SUCCESS;
}
コード例 #23
0
ファイル: db.c プロジェクト: aderbas/asterisk
static int display_results(void *arg, int columns, char **values, char **colnames)
{
	struct ast_cli_args *a = arg;
	size_t x;

	for (x = 0; x < columns; x++) {
		ast_cli(a->fd, "%-5s: %-50s\n", colnames[x], values[x]);
	}
	ast_cli(a->fd, "\n");

	return 0;
}
コード例 #24
0
static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
	char status[256], credentials[100] = "";
	int ctime = time(NULL) - connect_time;

	switch (cmd) {
	case CLI_INIT:
		e->command = "realtime pgsql status";
		e->usage =
			"Usage: realtime pgsql status\n"
			"       Shows connection information for the PostgreSQL RealTime driver\n";
		return NULL;
	case CLI_GENERATE:
		return NULL;
	}

	if (a->argc != 3)
		return CLI_SHOWUSAGE;

	if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
		if (!ast_strlen_zero(dbhost))
			snprintf(status, sizeof(status), "Connected to %s@%s, port %d", dbname, dbhost, dbport);
		else if (!ast_strlen_zero(dbsock))
			snprintf(status, sizeof(status), "Connected to %s on socket file %s", dbname, dbsock);
		else
			snprintf(status, sizeof(status), "Connected to %s@%s", dbname, dbhost);

		if (!ast_strlen_zero(dbuser))
			snprintf(credentials, sizeof(credentials), " with username %s", dbuser);

		if (ctime > 31536000)
			ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
					status, credentials, ctime / 31536000, (ctime % 31536000) / 86400,
					(ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
		else if (ctime > 86400)
			ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status,
					credentials, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60,
					ctime % 60);
		else if (ctime > 3600)
			ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, credentials,
					ctime / 3600, (ctime % 3600) / 60, ctime % 60);
		else if (ctime > 60)
			ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials, ctime / 60,
					ctime % 60);
		else
			ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctime);

		return CLI_SUCCESS;
	} else {
		return CLI_FAILURE;
	}
}
コード例 #25
0
ファイル: db.c プロジェクト: BackupTheBerlios/solid-pbx-svn
static int database_put(int fd, int argc, char *argv[])
{
	int res;
	if (argc != 5)
		return RESULT_SHOWUSAGE;
	res = ast_db_put(argv[2], argv[3], argv[4]);
	if (res)  {
		ast_cli(fd, "Failed to update entry\n");
	} else {
		ast_cli(fd, "Updated database successfully\n");
	}
	return RESULT_SUCCESS;
}
コード例 #26
0
ファイル: db.c プロジェクト: BackupTheBerlios/solid-pbx-svn
static int database_del(int fd, int argc, char *argv[])
{
	int res;
	if (argc != 4)
		return RESULT_SHOWUSAGE;
	res = ast_db_del(argv[2], argv[3]);
	if (res) {
		ast_cli(fd, "Database entry does not exist.\n");
	} else {
		ast_cli(fd, "Database entry removed.\n");
	}
	return RESULT_SUCCESS;
}
コード例 #27
0
static void cli_display_parking_lot_list(int fd)
{
	struct ao2_container *lot_container;

	lot_container = get_parking_lot_container();

	if (!lot_container) {
		ast_cli(fd, "Failed to obtain parking lot list.\n\n");
		return;
	}

	ao2_callback(lot_container, OBJ_MULTIPLE | OBJ_NODATA, display_parking_lot_cb, &fd);
	ast_cli(fd, "\n");
}
コード例 #28
0
ファイル: db.c プロジェクト: BackupTheBerlios/solid-pbx-svn
static int database_get(int fd, int argc, char *argv[])
{
	int res;
	char tmp[256];
	if (argc != 4)
		return RESULT_SHOWUSAGE;
	res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
	if (res) {
		ast_cli(fd, "Database entry not found.\n");
	} else {
		ast_cli(fd, "Value: %s\n", tmp);
	}
	return RESULT_SUCCESS;
}
コード例 #29
0
ファイル: db.c プロジェクト: BackupTheBerlios/solid-pbx-svn
static int database_show(int fd, int argc, char *argv[])
{
	char prefix[256];
	DBT key, data;
	char *keys, *values;
	int res;
	int pass;

	if (argc == 4) {
		/* Family and key tree */
		snprintf(prefix, sizeof(prefix), "/%s/%s", argv[2], argv[3]);
	} else if (argc == 3) {
		/* Family only */
		snprintf(prefix, sizeof(prefix), "/%s", argv[2]);
	} else if (argc == 2) {
		/* Neither */
		prefix[0] = '\0';
	} else {
		return RESULT_SHOWUSAGE;
	}
	ast_mutex_lock(&dblock);
	if (dbinit()) {
		ast_mutex_unlock(&dblock);
		ast_cli(fd, "Database unavailable\n");
		return RESULT_SUCCESS;	
	}
	memset(&key, 0, sizeof(key));
	memset(&data, 0, sizeof(data));
	pass = 0;
	while (!(res = astdb->seq(astdb, &key, &data, pass++ ? R_NEXT : R_FIRST))) {
		if (key.size) {
			keys = key.data;
			keys[key.size - 1] = '\0';
		} else {
			keys = "<bad key>";
		}
		if (data.size) {
			values = data.data;
			values[data.size - 1]='\0';
		} else {
			values = "<bad value>";
		}
		if (keymatch(keys, prefix)) {
				ast_cli(fd, "%-50s: %-25s\n", keys, values);
		}
	}
	ast_mutex_unlock(&dblock);
	return RESULT_SUCCESS;	
}
コード例 #30
0
ファイル: image.c プロジェクト: tpenguin/solarisvoip-asterisk
static int show_image_formats(int fd, int argc, char *argv[])
{
#define FORMAT "%10s %10s %50s %10s\n"
#define FORMAT2 "%10s %10s %50s %10s\n"
	struct ast_imager *i;
	if (argc != 3)
		return RESULT_SHOWUSAGE;
	ast_cli(fd, FORMAT, "Name", "Extensions", "Description", "Format");
	i = list;
	while(i) {
		ast_cli(fd, FORMAT2, i->name, i->exts, i->desc, ast_getformatname(i->format));
		i = i->next;
	};
	return RESULT_SUCCESS;
}