Changeset 5630

Make callweaver -r -q be quiet

-q causes a remote callweaver to not print connect and disconnect
messages, nor does it receive event messages at all.

Note 1: -q has no effect on the built in console.

Note 2: there is currently no way to enable or disable event reporting
from within a running cli.

Committed by:  mjagdis
Date:  Feb 10 2010 * 19:09 (6 months ago)

Affected files:

callweaver/trunk/corelib/callweaver.c (unified diff)

r5627r5630
14401440 option_highpriority++;
14411441 break;
14421442 case 'v':
1443 option_quiet = 0;
14431444 option_verbose++;
14441445 break;
14451446 case 'M':

callweaver/trunk/corelib/console.c (unified diff)

r5629r5630
346346
347347 set_title(key);
348348
349 putc('\n', stdout);
350 fputs(key, stdout);
351 putc('\n', stdout);
349 if (!option_quiet) {
350 putc('\n', stdout);
351 fputs(key, stdout);
352 putc('\n', stdout);
352353
353 while (lkey > 0) key[--lkey] = '=';
354 fputs(key, stdout);
355 fputs("\n\n", stdout);
354 while (lkey > 0) key[--lkey] = '=';
355 fputs(key, stdout);
356 fputs("\n\n", stdout);
357 }
356358 }
357359 }
358360 msgtype = MSG_UNKNOWN;
------
792794 }
793795
794796 do {
795 if (console_address)
797 if (console_address && !option_quiet)
796798 fprintf(stderr, "Connecting to Callweaver at %s...\n", console_address);
797799
798800 if ((console_sock = console_connect(console_address, EVENT_FLAG_LOG_ALL | EVENT_FLAG_PROGRESS, reconnect_time)) < 0)
------
803805 /* Dump the connection banner. We don't need it here */
804806 while (read(console_sock, &c, 1) == 1 && c != '\n');
805807
806 /* Make sure verbose and debug settings are what we want or higher
807 * and enable events
808 */
809 iov[0].iov_base = (void *)"Action: Version\r\n\r\nAction: Events\r\nEventmask: log,progress\r\n\r\nAction: Command\r\nCommand: set verbose atleast ";
810 iov[0].iov_len = sizeof("Action: Version\r\n\r\nAction: Events\r\nEventmask: log,progress\r\n\r\nAction: Command\r\nCommand: set verbose atleast ") - 1;
811 iov[1].iov_base = buf;
812 iov[1].iov_len = snprintf(buf, sizeof(buf), "%d", option_verbose);
813 iov[2].iov_base = (void *)"\r\n\r\n";
814 iov[2].iov_len = sizeof("\r\n\r\n") - 1;
815 iov[3].iov_base = (void *)"Action: Command\r\nCommand: set debug atleast ";
816 iov[3].iov_len = sizeof("Action: Command\r\nCommand: set debug atleast ") - 1;
817 iov[4].iov_base = buf + iov[1].iov_len;
818 iov[4].iov_len = snprintf(buf + iov[1].iov_len, sizeof(buf) - iov[1].iov_len, "%d", option_debug);
819 iov[5].iov_base = (void *)"\r\n\r\n";
820 iov[5].iov_len = sizeof("\r\n\r\n") - 1;
821 cw_writev_all(console_sock, iov, 6);
822 read_message(console_sock, 4);
808 cw_write_all(console_sock, "Action: Version\r\n\r\n", sizeof("Action: Version\r\n\r\n") - 1);
809 read_message(console_sock, 1);
823810
811 if (!option_quiet) {
812 /* Make sure verbose and debug settings are what we want or higher
813 * and enable events
814 */
815 iov[0].iov_base = (void *)"Action: Events\r\nEventmask: log,progress\r\n\r\nAction: Command\r\nCommand: set verbose atleast ";
816 iov[0].iov_len = sizeof("Action: Events\r\nEventmask: log,progress\r\n\r\nAction: Command\r\nCommand: set verbose atleast ") - 1;
817 iov[1].iov_base = buf;
818 iov[1].iov_len = snprintf(buf, sizeof(buf), "%d", option_verbose);
819 iov[2].iov_base = (void *)"\r\n\r\n";
820 iov[2].iov_len = sizeof("\r\n\r\n") - 1;
821 iov[3].iov_base = (void *)"Action: Command\r\nCommand: set debug atleast ";
822 iov[3].iov_len = sizeof("Action: Command\r\nCommand: set debug atleast ") - 1;
823 iov[4].iov_base = buf + iov[1].iov_len;
824 iov[4].iov_len = snprintf(buf + iov[1].iov_len, sizeof(buf) - iov[1].iov_len, "%d", option_debug);
825 iov[5].iov_base = (void *)"\r\n\r\n";
826 iov[5].iov_len = sizeof("\r\n\r\n") - 1;
827 cw_writev_all(console_sock, iov, 6);
828 read_message(console_sock, 3);
829 }
830
824831 /* Ok, we're ready. If we are the internal console tell the core to boot if it hasn't already */
825832 if (option_console && !fully_booted)
826833 kill(cw_mainpid, SIGHUP);
------
867874
868875 rl_callback_handler_remove();
869876 fflush(stdout);
870 fprintf(stderr, "\nDisconnected from CallWeaver server\n");
877 if (!option_quiet)
878 fprintf(stderr, "\nDisconnected from CallWeaver server\n");
871879 set_title("");
872880 close(console_sock);
873881 console_sock = -1;