• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LOG_UPTO函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LOG_UPTO函数的典型用法代码示例。如果您正苦于以下问题:C++ LOG_UPTO函数的具体用法?C++ LOG_UPTO怎么用?C++ LOG_UPTO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LOG_UPTO函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main_task

/*
 *  メインタスク
 */
void main_task(intptr_t exinf)
{
	char	c;
	ID		tskid = TASK1;
	int_t	tskno = 1;
	ER_UINT	ercd;
	PRI		tskpri;
#ifndef TASK_LOOP
	volatile ulong_t	i;
	SYSTIM	stime1, stime2;
#endif /* TASK_LOOP */
	HRTCNT	hrtcnt1, hrtcnt2;
	T_CTSK	ctsk;
	ID		TASK3 = -1;
	T_CALM	calm;
	ID		ALMHDR1 = -1;

	SVC_PERROR(syslog_msk_log(LOG_UPTO(LOG_INFO), LOG_UPTO(LOG_EMERG)));
	syslog(LOG_NOTICE, "Sample program starts (exinf = %d).", (int_t) exinf);

	/*
	 *  シリアルポートの初期化
	 *
	 *  システムログタスクと同じシリアルポートを使う場合など,シリアル
	 *  ポートがオープン済みの場合にはここでE_OBJエラーになるが,支障は
	 *  ない.
	 */
	ercd = serial_opn_por(TASK_PORTID);
	if (ercd < 0 && MERCD(ercd) != E_OBJ) {
		syslog(LOG_ERROR, "%s (%d) reported by `serial_opn_por'.",
									itron_strerror(ercd), SERCD(ercd));
	}
	SVC_PERROR(serial_ctl_por(TASK_PORTID,
							(IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV)));

	/*
 	 *  ループ回数の設定
	 *
	 *  並行実行されるタスク内での空ループの回数(task_loop)は,空ルー
	 *  プの実行時間が約0.4秒になるように設定する.この設定のために,
	 *  LOOP_REF回の空ループの実行時間を,その前後でget_timを呼ぶことで
	 *  測定し,その測定結果から空ループの実行時間が0.4秒になるループ回
	 *  数を求め,task_loopに設定する.
	 *
	 *  LOOP_REFは,デフォルトでは1,000,000に設定しているが,想定したよ
	 *  り遅いプロセッサでは,サンプルプログラムの実行開始に時間がかか
	 *  りすぎるという問題を生じる.逆に想定したより速いプロセッサでは,
	 *  LOOP_REF回の空ループの実行時間が短くなり,task_loopに設定する値
	 *  の誤差が大きくなるという問題がある.
	 *
	 *  そこで,そのようなターゲットでは,target_test.hで,LOOP_REFを適
	 *  切な値に定義するのが望ましい.
	 *
	 *  また,task_loopの値を固定したい場合には,その値をTASK_LOOPにマ
	 *  クロ定義する.TASK_LOOPがマクロ定義されている場合,上記の測定を
	 *  行わずに,TASK_LOOPに定義された値を空ループの回数とする.
	 *
	 * ターゲットによっては,空ループの実行時間の1回目の測定で,本来よ
	 * りも長めになるものがある.このようなターゲットでは,MEASURE_TWICE
	 * をマクロ定義することで,1回目の測定結果を捨てて,2回目の測定結果
	 * を使う.
	 */
#ifdef TASK_LOOP
	task_loop = TASK_LOOP;
#else /* TASK_LOOP */

#ifdef MEASURE_TWICE
	task_loop = LOOP_REF;
	SVC_PERROR(get_tim(&stime1));
	for (i = 0; i < task_loop; i++);
	SVC_PERROR(get_tim(&stime2));
#endif /* MEASURE_TWICE */

	task_loop = LOOP_REF;
	SVC_PERROR(get_tim(&stime1));
	for (i = 0; i < task_loop; i++);
	SVC_PERROR(get_tim(&stime2));
	task_loop = LOOP_REF * 400LU / (ulong_t)(stime2 - stime1) * 1000LU;

#endif /* TASK_LOOP */

	/*
 	 *  タスクの起動
	 */
	SVC_PERROR(act_tsk(TASK1));
	SVC_PERROR(act_tsk(TASK2));

	/*
 	 *  メインループ
	 */
	do {
		SVC_PERROR(serial_rea_dat(TASK_PORTID, &c, 1));
		switch (c) {
		case 'e':
		case 's':
		case 'S':
		case 'd':
//.........这里部分代码省略.........
开发者ID:morioka,项目名称:toppers-asp3-for-linux,代码行数:101,代码来源:sample1.c


示例2: main


//.........这里部分代码省略.........
		case 'r':
			resource_path = optarg;
			printf("Setting resource path to \"%s\"\n", resource_path);
			break;
		case 'h':
			fprintf(stderr, "Usage: test-server "
					"[--port=<p>] [--ssl] "
					"[-d <log bitfield>] "
					"[--resource_path <path>]\n");
			exit(1);
		}
	}

#if !defined(LWS_NO_DAEMONIZE) && !defined(WIN32)
	/*
	 * normally lock path would be /var/lock/lwsts or similar, to
	 * simplify getting started without having to take care about
	 * permissions or running as root, set to /tmp/.lwsts-lock
	 */
	if (daemonize && lws_daemonize("/tmp/.lwsts-lock")) {
		fprintf(stderr, "Failed to daemonize\n");
		return 1;
	}
#endif

	for (n = 0; n < ARRAY_SIZE(sigs); n++) {
		_ev_init(&signals[n], signal_cb);
		ev_signal_set(&signals[n], sigs[n]);
		ev_signal_start(loop, &signals[n]);
	}

#ifndef _WIN32
	/* we will only try to log things according to our debug_level */
	setlogmask(LOG_UPTO (LOG_DEBUG));
	openlog("lwsts", syslog_options, LOG_DAEMON);
#endif

	/* tell the library what debug level to emit and to send it to syslog */
	lws_set_log_level(debug_level, lwsl_emit_syslog);

	lwsl_notice("libwebsockets test server libev - license LGPL2.1+SLE\n");
	lwsl_notice("(C) Copyright 2010-2016 Andy Green <[email protected]>\n");

	printf("Using resource path \"%s\"\n", resource_path);

	info.iface = iface;
	info.protocols = protocols;
	info.extensions = exts;

	info.ssl_cert_filepath = NULL;
	info.ssl_private_key_filepath = NULL;

	if (use_ssl) {
		if (strlen(resource_path) > sizeof(cert_path) - 32) {
			lwsl_err("resource path too long\n");
			return -1;
		}
		sprintf(cert_path, "%s/libwebsockets-test-server.pem",
								resource_path);
		if (strlen(resource_path) > sizeof(key_path) - 32) {
			lwsl_err("resource path too long\n");
			return -1;
		}
		sprintf(key_path, "%s/libwebsockets-test-server.key.pem",
								resource_path);
开发者ID:bd5times,项目名称:libwebsockets,代码行数:66,代码来源:test-server-libev.c


示例3: main


//.........这里部分代码省略.........
#ifndef LWS_NO_CLIENT
                    "  --client     / -c <server IP>\n"
                    "  --ratems     / -r <rate in ms>\n"
#endif
                    "  --ssl        / -s\n"
                    "  --passphrase / -P <passphrase>\n"
                    "  --interface  / -i <interface>\n"
#ifndef LWS_NO_DAEMONIZE
                    "  --daemonize  / -D\n"
#endif
                   );
            exit(1);
        }
    }

#ifndef LWS_NO_DAEMONIZE
    /*
     * normally lock path would be /var/lock/lwsts or similar, to
     * simplify getting started without having to take care about
     * permissions or running as root, set to /tmp/.lwsts-lock
     */
#if defined(WIN32) || defined(_WIN32)
#else
    if (!client && daemonize && lws_daemonize("/tmp/.lwstecho-lock")) {
        fprintf(stderr, "Failed to daemonize\n");
        return 1;
    }
#endif
#endif

#ifdef WIN32
#else
    /* we will only try to log things according to our debug_level */
    setlogmask(LOG_UPTO (LOG_DEBUG));
    openlog("lwsts", syslog_options, LOG_DAEMON);

    /* tell the library what debug level to emit and to send it to syslog */
    lws_set_log_level(debug_level, lwsl_emit_syslog);
#endif
    lwsl_notice("libwebsockets echo test - "
                "(C) Copyright 2010-2015 Andy Green <[email protected]> - "
                "licensed under LGPL2.1\n");
#ifndef LWS_NO_CLIENT
    if (client) {
        lwsl_notice("Running in client mode\n");
        listen_port = CONTEXT_PORT_NO_LISTEN;
        if (use_ssl && !disallow_selfsigned) {
            lwsl_info("allowing selfsigned\n");
            use_ssl = 2;
        } else {
            lwsl_info("requiring server cert validation againts %s\n", ssl_cert);
            info.ssl_ca_filepath = ssl_cert;
        }
    } else {
#endif
#ifndef LWS_NO_SERVER
        lwsl_notice("Running in server mode\n");
        listen_port = port;
#endif
#ifndef LWS_NO_CLIENT
    }
#endif

    info.port = listen_port;
    info.iface = interface;
    info.protocols = protocols;
开发者ID:turol,项目名称:webquake2,代码行数:67,代码来源:test-echo.c


示例4: main

int main (int argc, char *argv[]) {
	(void)argc;
	(void)argv;
	int ret;
	int dbg = TRUE;

	struct lapb_callbacks lapb_callbacks;
	int res;

	char buffer[2048];

	_uchar lapb_equipment_type = LAPB_DCE;
	_uchar lapb_modulo = LAPB_STANDARD;

	pthread_t server_thread;
	struct tcp_server_struct * server_thread_struct = NULL;

	pthread_t timer_thread;
	struct timer_thread_struct * timer_thread_struct = NULL;

	pthread_t logger_thread;

	printf("*******************************************\n");
	printf("******                               ******\n");
	printf("******  X25 EMULATOR (server side)  ******\n");
	printf("******                               ******\n");
	printf("*******************************************\n");

	/* Initialize syslog */
	setlogmask (LOG_UPTO (LOG_DEBUG));
	openlog ("server_app", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);

	ret = pthread_create(&logger_thread, NULL, logger_function, NULL);
	if (ret) {
		perror("Error - pthread_create()");
		closelog();
		exit(EXIT_FAILURE);
	};
	printf("Logger thread created(code %d)\n", ret);
	while (!is_logger_started())
		sleep_ms(200);
	printf("Logger started\n\n");

	lapb_debug(0, "Program started by User %d", getuid ());

	/* Setup signal handler */
	setup_signals_handler();

	if (dbg)
		goto label_1;

	/* Select program mode */
	printf("\nSelect program mode:\n1. Automatic\n2. Manual\n");
	write(0, ">", 1);
	while (read(0, buffer, sizeof(buffer)) <= 1)
		write(0, ">", 1);
	if (atoi(buffer) == 2)
		AutomaticMode = FALSE;
	else {
		/* Set up equipment mode: DTE or DCE */
		printf("\nSelect equipment type:\n1. DTE\n2. DCE\n");
		write(0, ">", 1);
		while (read(0, buffer, sizeof(buffer)) <= 1)
			write(0, ">", 1);
		if (atoi(buffer) == 1)
			lapb_equipment_type = LAPB_DTE;

		/* Set up lapb modulo: STANDARD or EXTENDED */
		printf("\nSelect modulo value:\n1. STANDARD(8)\n2. EXTENDED(128)\n");
		write(0, ">", 1);
		while (read(0, buffer, sizeof(buffer)) <= 1)
			write(0, ">", 1);
		if (atoi(buffer) == 2)
			lapb_modulo = LAPB_EXTENDED;
	};

label_1:

	/* Create TCP server */
	server_thread_struct = malloc(sizeof(struct tcp_server_struct));

	if (dbg) {
		server_thread_struct->port = 1234;
		goto label_2;
	};

	printf("\nEnter server port[1234]: ");
	fgets(buffer, sizeof(buffer) - 1, stdin);
	int tmp_len = strlen(buffer);
	if (tmp_len == 1)
		server_thread_struct->port = 1234;
	else {
		buffer[strlen(buffer) - 1] = 0;
		server_thread_struct->port = atoi(buffer);
	};

label_2:

	/* TCP server callbacks */
	server_thread_struct->new_data_received = new_data_received;
//.........这里部分代码省略.........
开发者ID:SergeAvdeyev,项目名称:my_project,代码行数:101,代码来源:server_main.c


示例5: log_level

void log_level(int verbosity)
{
    setlogmask(LOG_UPTO(verbosity));
}
开发者ID:heptadecagram,项目名称:dot,代码行数:4,代码来源:log.c


示例6: flow_init

/**
 * Initialize flow-control context and process command-line arguments
 *
 * Sets fc->r to zero upon success, a non-zero errno code, otherwise.
 *
 * @param fc    The flow control context
 * @param argc  The number of command-line arguments
 * @param argv  The command-line arguments
 * @return      Upon success, zero. A non-zero errno code, otherwise.
 */
static void flow_init( struct flow_context *fc ) {

	int r;
	int i;

	struct sockaddr_in sa;
	socklen_t sa_len;
	sighandler_t old_sh;

	// determine the service name
	if ( NULL == fc->ident ) {
		memcpy(
			flow_progname,
			fc->argv[ 0 ],
			MIN(
				strlen( fc->argv[ 0 ] ),
				sizeof( flow_progname - 1 )
			)
		);
		fc->ident = basename( flow_progname );
	}

	// use getopt(3), create a usage(), etc
	// options could include verbosity

#ifdef HAVE_SYSLOG
	// enable logging
	openlog( fc->ident, 0, LOG_DAEMON );
	setlogmask( LOG_UPTO( LOG_INFO ) );
	// could be conditional, e.g. if command-line argument exists to enable / disable debug
	setlogmask( setlogmask( 0 ) | LOG_MASK( LOG_DEBUG ) );
#endif

	// set the global variable for signal handlers
	_fc = fc;

	I( "installing signal handlers.." );

	for( i = 0; i < ARRAY_SIZE( signals_to_catch ); i++ ) {
		old_sh = signal( signals_to_catch[ i ], sighandler );
		if ( SIG_ERR == old_sh ) {
			r = errno;
			E( "signal(2) failed" );
			goto out;
		}
	}

	I( "opening signal pipe.." );
	r = pipe( fc->signal_fd );
	if ( EXIT_SUCCESS != r ) {
		r = errno;
		E( "pipe(2) failed" );
		goto out;
	}
	D( "opened signal pipe as fd's %d, %d", fc->signal_fd[ 0 ], fc->signal_fd[ 1 ] );
	cas( & fc->highest_fd, fc->signal_fd[ 0 ] );

	I( "opening server socket.." );
	r = socket( AF_INET, SOCK_DGRAM, 0 );
	if ( -1 == r ) {
		r = errno;
		E( "socket(2) failed" );
		goto out;
	}
	fc->server_socket = r;
	D( "opened server socket as fd %d", fc->server_socket );

	I( "binding server socket.." );

	sa.sin_family = AF_INET;
	sa.sin_port = htons( fc->server_port );
	sa.sin_addr.s_addr = htonl( INADDR_ANY );
	sa_len = sizeof( sa );

	r = bind( fc->server_socket, (struct sockaddr *) & sa, sa_len );
	if ( -1 == r ) {
		r = errno;
		E( "bind(2) failed" );
		goto out;
	}
	D( "bound server socket to port %d", fc->server_port );
	cas( & fc->highest_fd, fc->server_socket );

out:
	fc->r = r;
}
开发者ID:Syanna,项目名称:firmware,代码行数:96,代码来源:flow.c


示例7: LOG_UPTO

 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/Trace.hh"

Trace trace;

uint8_t trace_log_mask = LOG_UPTO(LOG_INFO);

bool 
Trace::begin(IOStream::Device* dev, const char* banner)
{
  set_device(dev);
  if (banner != NULL) {
    print_P(banner);
    println();
  }
  return (true);
}

void
Trace::fatal_P(const char* file, int line, const char* expr) 
{
开发者ID:Dzenik,项目名称:Cosa,代码行数:31,代码来源:Trace.cpp


示例8: init_logging

/*
 * Initialize the logging
 *
 * Called once per process, including forked children.
 */
void
init_logging(
	const char *	name,
	u_int32		def_syslogmask,
	int		is_daemon
	)
{
	static int	was_daemon;
	const char *	cp;
	const char *	pname;

	/*
	 * ntpd defaults to only logging sync-category events, when
	 * NLOG() is used to conditionalize.  Other libntp clients
	 * leave it alone so that all NLOG() conditionals will fire.
	 * This presumes all bits lit in ntp_syslogmask can't be
	 * configured via logconfig and all lit is thereby a sentinel
	 * that ntp_syslogmask is still at its default from libntp,
	 * keeping in mind this function is called in forked children
	 * where it has already been called in the parent earlier.
	 * Forked children pass 0 for def_syslogmask.
	 */
	if (INIT_NTP_SYSLOGMASK == ntp_syslogmask &&
	    0 != def_syslogmask)
		ntp_syslogmask = def_syslogmask; /* set more via logconfig */

	/*
	 * Logging.  This may actually work on the gizmo board.  Find a name
	 * to log with by using the basename
	 */
	cp = strrchr(name, DIR_SEP);
	if (NULL == cp)
		pname = name;
	else
		pname = 1 + cp;	/* skip DIR_SEP */
	progname = estrdup(pname);
#ifdef SYS_WINNT			/* strip ".exe" */
	cp = strrchr(progname, '.');
	if (NULL != cp && !strcasecmp(cp, ".exe"))
		progname[cp - progname] = '\0';
#endif

#if !defined(VMS)

	if (is_daemon)
		was_daemon = TRUE;
# ifndef LOG_DAEMON
	openlog(progname, LOG_PID);
# else /* LOG_DAEMON */

#  ifndef LOG_NTP
#	define	LOG_NTP LOG_DAEMON
#  endif
	openlog(progname, LOG_PID | LOG_NDELAY, (was_daemon) 
						    ? LOG_NTP
						    : 0);
#  ifdef DEBUG
	if (debug)
		setlogmask(LOG_UPTO(LOG_DEBUG));
	else
#  endif /* DEBUG */
		setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
# endif /* LOG_DAEMON */
#endif	/* !VMS */
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:70,代码来源:msyslog.c


示例9: main

int main(int argc, char **argv)
{
	char cert_path[1024];
	char key_path[1024];
	int n = 0;
	int use_ssl = 0;
	int opts = 0;
	char interface_name[128] = "";
	const char *iface = NULL;
#ifndef WIN32
	int syslog_options = LOG_PID | LOG_PERROR;
#endif
	unsigned int ms, oldms = 0;
	struct lws_context_creation_info info;

	int debug_level = 7;
#ifndef LWS_NO_DAEMONIZE
	int daemonize = 0;
#endif

	memset(&info, 0, sizeof info);
	info.port = 7681;

	while (n >= 0) {
		n = getopt_long(argc, argv, "eci:hsap:d:Dr:", options, NULL);
		if (n < 0)
			continue;
		switch (n) {
		case 'e':
			opts |= LWS_SERVER_OPTION_LIBEV;
			break;
#ifndef LWS_NO_DAEMONIZE
		case 'D':
			daemonize = 1;
			#ifndef WIN32
			syslog_options &= ~LOG_PERROR;
			#endif
			break;
#endif
		case 'd':
			debug_level = atoi(optarg);
			break;
		case 's':
			use_ssl = 1;
			break;
		case 'a':
			opts |= LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT;
			break;
		case 'p':
			info.port = atoi(optarg);
			break;
		case 'i':
			strncpy(interface_name, optarg, sizeof interface_name);
			interface_name[(sizeof interface_name) - 1] = '\0';
			iface = interface_name;
			break;
		case 'c':
			close_testing = 1;
			fprintf(stderr, " Close testing mode -- closes on "
					   "client after 50 dumb increments"
					   "and suppresses lws_mirror spam\n");
			break;
		case 'r':
			resource_path = optarg;
			printf("Setting resource path to \"%s\"\n", resource_path);
			break;
		case 'h':
			fprintf(stderr, "Usage: test-server "
					"[--port=<p>] [--ssl] "
					"[-d <log bitfield>] "
					"[--resource_path <path>]\n");
			exit(1);
		}
	}

#if !defined(LWS_NO_DAEMONIZE) && !defined(WIN32)
	/* 
	 * normally lock path would be /var/lock/lwsts or similar, to
	 * simplify getting started without having to take care about
	 * permissions or running as root, set to /tmp/.lwsts-lock
	 */
	if (daemonize && lws_daemonize("/tmp/.lwsts-lock")) {
		fprintf(stderr, "Failed to daemonize\n");
		return 1;
	}
#endif

	signal(SIGINT, sighandler);

#ifndef WIN32
	/* we will only try to log things according to our debug_level */
	setlogmask(LOG_UPTO (LOG_DEBUG));
	openlog("lwsts", syslog_options, LOG_DAEMON);
#endif

	/* tell the library what debug level to emit and to send it to syslog */
	lws_set_log_level(debug_level, lwsl_emit_syslog);

	lwsl_notice("libwebsockets test server - "
			"(C) Copyright 2010-2014 Andy Green <[email protected]> - "
//.........这里部分代码省略.........
开发者ID:BTCDDev,项目名称:supernet,代码行数:101,代码来源:test-server.c


示例10: main

int
main(int argc, char *argv[])
{
	int s, rtsock, maxfd, ch;
	int once = 0;
	struct timeval *timeout;
	struct fd_set fdset;
	char *argv0;
	const char *opts;

	/*
	 * Initialization
	 */
	argv0 = argv[0];

	/* get option */
	if (argv0 && argv0[strlen(argv0) - 1] != 'd') {
		fflag = 1;
		once = 1;
		opts = "adD";
	} else
		opts = "adDfm1";

	while ((ch = getopt(argc, argv, opts)) != -1) {
		switch (ch) {
		case 'a':
			aflag = 1;
			break;
		case 'd':
			dflag = 1;
			break;
		case 'D':
			dflag = 2;
			break;
		case 'f':
			fflag = 1;
			break;
		case 'm':
			mobile_node = 1;
			break;
		case '1':
			once = 1;
			break;
		default:
			usage(argv0);
			/*NOTREACHED*/
		}
	}
	argc -= optind;
	argv += optind;

	if (aflag) {
		int i;

		if (argc != 0) {
			usage(argv0);
			/*NOTREACHED*/
		}

		argv = autoifprobe();
		if (!argv) {
			errx(1, "could not autoprobe interface");
			/*NOTREACHED*/
		}

		for (i = 0; argv[i]; i++)
			;
		argc = i;
	}
	if (argc == 0) {
		usage(argv0);
		/*NOTREACHED*/
	}

	/* set log level */
	if (dflag == 0)
		log_upto = LOG_NOTICE;
	if (!fflag) {
		char *ident;
		ident = strrchr(argv0, '/');
		if (!ident)
			ident = argv0;
		else
			ident++;
		openlog(ident, LOG_NDELAY|LOG_PID, LOG_DAEMON);
		if (log_upto >= 0)
			setlogmask(LOG_UPTO(log_upto));
	}

#ifndef HAVE_ARC4RANDOM
	/* random value initilization */
	srandom((u_long)time(NULL));
#endif

	/* warn if accept_rtadv is down */
	if (!getinet6sysctl(IPV6CTL_ACCEPT_RTADV))
		warnx("kernel is configured not to accept RAs");
	/* warn if forwarding is up */
	if (getinet6sysctl(IPV6CTL_FORWARDING))
		warnx("kernel is configured as a router, not a host");
//.........这里部分代码省略.........
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:101,代码来源:rtsold.c


示例11: main

int main(int argc, char **argv)
{
	int i;
	struct sigaction sa, osa;
	FILE *pf;
	int r;

	prog_name= strrchr(argv[0], '/');
	if (prog_name == nil) prog_name= argv[0]; else prog_name++;

	i= 1;
	while (i < argc && argv[i][0] == '-') {
		char *opt= argv[i++] + 1;

		if (opt[0] == '-' && opt[1] == 0) break;	/* -- */

		while (*opt != 0) switch (*opt++) {
		case 'd':
			if (*opt == 0) {
				debug= 1;
			} else {
				debug= strtoul(opt, &opt, 10);
				if (*opt != 0) usage();
			}
			break;
		default:
			usage();
		}
	}
	if (i != argc) usage();

	selectlog(SYSLOG);
	openlog(prog_name, LOG_PID, LOG_DAEMON);
	setlogmask(LOG_UPTO(LOG_INFO));

	/* Save process id. */
	if ((pf= fopen(PIDFILE, "w")) == NULL) {
		fprintf(stderr, "%s: %s\n", PIDFILE, strerror(errno));
		exit(1);
	}
	fprintf(pf, "%d\n", getpid());
	if (ferror(pf) || fclose(pf) == EOF) {
		fprintf(stderr, "%s: %s\n", PIDFILE, strerror(errno));
		exit(1);
	}

	sigemptyset(&sa.sa_mask);
	sa.sa_flags= 0;
	sa.sa_handler= handler;

	/* Hangup: Reload crontab files. */
	sigaction(SIGHUP, &sa, nil);

	/* User signal 1 & 2: Raise or reset debug level. */
	sigaction(SIGUSR1, &sa, nil);
	sigaction(SIGUSR2, &sa, nil);

	/* Interrupt and Terminate: Cleanup and exit. */
	if (sigaction(SIGINT, nil, &osa) == 0 && osa.sa_handler != SIG_IGN) {
		sigaction(SIGINT, &sa, nil);
	}
	if (sigaction(SIGTERM, nil, &osa) == 0 && osa.sa_handler != SIG_IGN) {
		sigaction(SIGTERM, &sa, nil);
	}

	/* Alarm: Wake up and run a job. */
	sigaction(SIGALRM, &sa, nil);

	/* Initialize current time and time next to do something. */
	time(&now);
	next= NEVER;

	/* Table load required first time. */
	need_reload= 1;

	do {
		if (need_reload) {
			need_reload= 0;
			load_crontabs();
			busy= 1;
		}

		/* Run jobs whose time has come. */
		if (next <= now) {
			cronjob_t *job;

			if ((job= tab_nextjob()) != nil) run_job(job);
			busy= 1;
		}

		if (busy) {
			/* Did a job finish? */
			r= waitpid(-1, nil, WNOHANG);
			busy= 0;
		} else {
			/* Sleep until the next job must be started. */
			if (next == NEVER) {
				alarm(0);
			} else {
#if __minix_vmd
//.........这里部分代码省略.........
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:101,代码来源:cron.c


示例12: options


//.........这里部分代码省略.........
		{ "listen-ng",	'n', 0, G_OPTION_ARG_STRING,	&listenngs,	"UDP port to listen on, NG protocol", "[IP46:]PORT"	},
		{ "tos",	'T', 0, G_OPTION_ARG_INT,	&tos,		"Default TOS value to set on streams",	"INT"		},
		{ "timeout",	'o', 0, G_OPTION_ARG_INT,	&timeout,	"RTP timeout",			"SECS"		},
		{ "silent-timeout",'s',0,G_OPTION_ARG_INT,	&silent_timeout,"RTP timeout for muted",	"SECS"		},
		{ "pidfile",	'p', 0, G_OPTION_ARG_STRING,	&pidfile,	"Write PID to file",		"FILE"		},
		{ "foreground",	'f', 0, G_OPTION_ARG_NONE,	&foreground,	"Don't fork to background",	NULL		},
		{ "port-min",	'm', 0, G_OPTION_ARG_INT,	&port_min,	"Lowest port to use for RTP",	"INT"		},
		{ "port-max",	'M', 0, G_OPTION_ARG_INT,	&port_max,	"Highest port to use for RTP",	"INT"		},
		{ "redis",	'r', 0, G_OPTION_ARG_STRING,	&redisps,	"Connect to Redis database",	"IP:PORT"	},
		{ "redis-db",	'R', 0, G_OPTION_ARG_INT,	&redis_db,	"Which Redis DB to use",	"INT"	},
		{ "b2b-url",	'b', 0, G_OPTION_ARG_STRING,	&b2b_url,	"XMLRPC URL of B2B UA"	,	"STRING"	},
		{ "log-level",	'L', 0, G_OPTION_ARG_INT,	(void *)&log_level,	"Mask log priorities above this level",	"INT"	},
		{ "log-facility",	0,	0,	G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"},
		{ "log-stderr",	'E', 0, G_OPTION_ARG_NONE,	&_log_stderr,	"Log on stderr instead of syslog",	NULL		},
		{ "xmlrpc-format",	'x', 0, G_OPTION_ARG_INT,	&xmlrpc_fmt,	"XMLRPC timeout request format to use. 0: SEMS DI, 1: call-id only",	"INT"	},
		{ NULL, }
	};

	GOptionContext *c;
	GError *er = NULL;

	c = g_option_context_new(" - next-generation media proxy");
	g_option_context_add_main_entries(c, e, NULL);
	if (!g_option_context_parse(c, argc, argv, &er))
		die("Bad command line: %s\n", er->message);

	if (version)
		die("%s\n", RTPENGINE_VERSION);

	if (!ipv4s)
		die("Missing option --ip\n");
	if (!listenps && !listenudps && !listenngs)
		die("Missing option --listen-tcp, --listen-udp or --listen-ng\n");

	ipv4 = inet_addr(ipv4s);
	if (ipv4 == -1)
		die("Invalid IPv4 address (--ip)\n");

	if (adv_ipv4s) {
		adv_ipv4 = inet_addr(adv_ipv4s);
		if (adv_ipv4 == -1)
			die("Invalid IPv4 address (--advertised-ip)\n");
	}

	if (ipv6s) {
		if (smart_pton(AF_INET6, ipv6s, &ipv6) != 1)
			die("Invalid IPv6 address (--ip6)\n");
	}
	if (adv_ipv6s) {
		if (smart_pton(AF_INET6, adv_ipv6s, &adv_ipv6) != 1)
			die("Invalid IPv6 address (--advertised-ip6)\n");
	}

	if (listenps) {
		if (parse_ip_port(&listenp, &listenport, listenps))
			die("Invalid IP or port (--listen-tcp)\n");
	}
	if (listenudps) {
		if (parse_ip6_port(&udp_listenp, &udp_listenport, listenudps))
			die("Invalid IP or port (--listen-udp)\n");
	}
	if (listenngs) {
		if (parse_ip6_port(&ng_listenp, &ng_listenport, listenngs))
			die("Invalid IP or port (--listen-ng)\n");
	}

	if (tos < 0 || tos > 255)
		die("Invalid TOS value\n");

	if (timeout <= 0)
		timeout = 60;
	if (silent_timeout <= 0)
		silent_timeout = 3600;

	if (redisps) {
		if (parse_ip_port(&redis_ip, &redis_port, redisps) || !redis_ip)
			die("Invalid IP or port (--redis)\n");
		if (redis_db < 0)
			die("Must specify Redis DB number (--redis-db) when using Redis\n");
	}
	
	if (xmlrpc_fmt < 0 || xmlrpc_fmt > 1) {
		die("Invalid XMLRPC format\n");
	}

	if ((log_level < LOG_EMERG) || (log_level > LOG_DEBUG))
	        die("Invalid log level (--log_level)\n");
	setlogmask(LOG_UPTO(log_level));

	if (log_facility_s) {
		if (!parse_log_facility(log_facility_s, &_log_facility)) {
			print_available_log_facilities();
			die ("Invalid log facility '%s' (--log-facility)\n", log_facility_s);
		}
	}

	if (_log_stderr) {
		write_log = log_to_stderr;
	}
}
开发者ID:rockxcn,项目名称:rtpengine,代码行数:101,代码来源:main.c


示例13: main

int
main(int argc, char *argv[])
{
	int _argc = 0;
	char *_argv[5];
	pid_t pid;
	int execed = 0;

	int n, nfd, tflags = 0, ch;
	struct timeval *tvp, waittime;
	struct itimerval itval;
	fd_set ibits;
	sigset_t sigset, osigset;

	while ((ch = getopt(argc, argv, "D012bsqtdg")) != EOF) {
		switch (ch) {
			case 'D':
				execed = 1;
				break;
			case '0': ripversion = 0; break;
			case '1': ripversion = 1; break;
			case '2': ripversion = 2; break;
			case 'b': multicast = 0; break;
			case 's': supplier = 1; break;
			case 'q': supplier = 0; break;
			case 't': 
				tflags++;
				break;
			case 'd': 
				debug++;
				setlogmask(LOG_UPTO(LOG_DEBUG));
				break;
			case 'g': gateway = 1; break;
			default:
				fprintf(stderr, "usage: routed [ -1bsqtdg ]\n");
				exit(1);
		}
	}
	
	// Modified by Mason Yu
	sleep(2);
	/*
	if(!check_pid()) {
		// Commented by Mason Yu
		//write_cfg();
		exit(1);
	}
	*/
	
	if (!execed) {
		if ((pid = vfork()) < 0) {
			fprintf(stderr, "vfork failed\n");
			exit(1);
		} else if (pid != 0) {
			exit(0);
		}
		
		for (_argc=0; _argc < argc; _argc++ )
			_argv[_argc] = argv[_argc];
		_argv[0] = runPath;
		_argv[argc++] = "-D";
		_argv[argc++] = NULL;
		execv(_argv[0], _argv);
		/* Not reached */
		fprintf(stderr, "Couldn't exec\n");
		_exit(1);

	} else {
		setsid();
	}

	getkversion();

	sock = getsocket();
	assert(sock>=0);

	openlog("routed", LOG_PID | LOG_ODELAY, LOG_DAEMON);

#if 0
	if (debug == 0 && tflags == 0) {
#ifndef EMBED
		switch (fork()) {
			case -1: perror("fork"); exit(1);
			case 0: break;  /* child */
			default: exit(0);   /* parent */
		}
#endif
		close(0);
		close(1);
		close(2);
		setsid();
		setlogmask(LOG_UPTO(LOG_WARNING));
	}
	else 
#endif
	{
		setlogmask(LOG_UPTO(LOG_DEBUG));
	}

	/*
//.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:asus-rt-n12-lx,代码行数:101,代码来源:main.c


示例14: openSyslog

void openSyslog()
{
    setlogmask(LOG_UPTO (LOG_INFO));
    openlog(NULL, 0, LOG_USER);
}
开发者ID:Debianguru,项目名称:Raspberry,代码行数:5,代码来源:PiGatewaySerial.cpp


示例15: main


//.........这里部分代码省略.........
				}
				gLogLevel=intarg;
				break;
				
			case 'V':
				// version
				break;
				
			case '?':
			case 'h':
				usage(0);
				break;
			
			default:
				usage(1);
				break;
		}
	}


/* install handlers */
	signal( SIGPIPE, SIG_IGN );
	signal(SIGCHLD,sigchld_handler); /* ignore child */
	signal(SIGHUP,kill_handler); /* catch hangup signal */
	signal(SIGTERM,kill_handler); /* catch kill signal */
	
/*
	Initialize Windows sockets (no-op on other platforms)
*/
	WSAStartup(MAKEWORD(1,1), &wsaData);
	
	if(!nosysl) {
		openlog("matrixtunnel", LOG_PID, LOG_DAEMON);
		setlogmask(LOG_UPTO(gLogLevel));
	}
	
/*
	Initialize the MatrixSSL Library, and read in the public key (certificate)
	and private key.
*/
	if (matrixSslOpen() < 0) {
		ELOG("matrixSslOpen failed, exiting...");
		exit(1);
	}

/*
	Standard PEM files
*/
	if (matrixSslReadKeys(&keys, certfile, keyfile, NULL, NULL) < 0)  {
		ELOG("Error reading or parsing %s or %s, exiting...", 
			certfile, keyfile);
		exit(1);
	}

	// go to background
	if(!nofork) {
		daemonize();
	}

/*
	Create the listen socket
*/
	if ((srv_fd = socketListen(srv_port, &status)) == INVALID_SOCKET) {
		ELOG("Cannot listen on port %d, exiting...", srv_port);
		exit(1);
	}
开发者ID:cmtsij,项目名称:Vizio_XWR100_GPL,代码行数:67,代码来源:matrixtunnel.c


示例16: main

int main(int argc, char **argv)
{
	struct lws_context_creation_info info;
	char interface_name[128] = "";
	uv_timer_t timeout_watcher;
	const char *iface = NULL;
	char cert_path[1024];
	char key_path[1024];
	int use_ssl = 0;
	int opts = 0;
	int n = 0;
#ifndef _WIN32
	int syslog_options = LOG_PID | LOG_PERROR;
#endif
#ifndef LWS_NO_DAEMONIZE
	int daemonize = 0;
#endif

	/*
	 * take care to zero down the info struct, he contains random garbaage
	 * from the stack otherwise
	 */
	memset(&info, 0, sizeof info);
	info.port = 7681;

	while (n >= 0) {
		n = getopt_long(argc, argv, "eci:hsap:d:Dr:", options, NULL);
		if (n < 0)
			continue;
		switch (n) {
		case 'e':
			opts |= LWS_SERVER_OPTION_LIBEV;
			break;
#ifndef LWS_NO_DAEMONIZE
		case 'D':
			daemonize = 1;
			#ifndef _WIN32
			syslog_options &= ~LOG_PERROR;
			#endif
			break;
#endif
		case 'd':
			debug_level = atoi(optarg);
			break;
		case 's':
			use_ssl = 1;
			break;
		case 'a':
			opts |= LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT;
			break;
		case 'p':
			info.port = atoi(optarg);
			break;
		case 'i':
			strncpy(interface_name, optarg, sizeof interface_name);
			interface_name[(sizeof interface_name) - 1] = '\0';
			iface = interface_name;
			break;
		case 'c':
			close_testing = 1;
			fprintf(stderr, " Close testing mode -- closes on "
					   "client after 50 dumb increments"
					   "and suppresses lws_mirror spam\n");
			break;
		case 'r':
			resource_path = optarg;
			printf("Setting resource path to \"%s\"\n", resource_path);
			break;
		case 'h':
			fprintf(stderr, "Usage: test-server "
					"[--port=<p>] [--ssl] "
					"[-d <log bitfield>] "
					"[--resource_path <path>]\n");
			exit(1);
		}
	}

#if !defined(WIN32)
#if !defined(LWS_NO_DAEMONIZE)
	/*
	 * normally lock path would be /var/lock/lwsts or similar, to
	 * simplify getting started without having to take care about
	 * permissions or running as root, set to /tmp/.lwsts-lock
	 */
	if (daemonize && lws_daemonize("/tmp/.lwsts-lock")) {
		fprintf(stderr, "Failed to daemonize\n");
		return 1;
	}
#endif

	/* we will only try to log things according to our debug_level */
	setlogmask(LOG_UPTO (LOG_DEBUG));
	openlog("lwsts", syslog_options, LOG_DAEMON);
#endif

	/* tell the library what debug level to emit and to send it to syslog */
	lws_set_log_level(debug_level, lwsl_emit_syslog);

	lwsl_notice("libwebsockets test server libuv - license LGPL2.1+SLE\n");
	lwsl_notice("(C) Copyright 2010-2016 Andy Green <[email protected]>\n");
//.........这里部分代码省略.........
开发者ID:chenhaifeng2016,项目名称:libwebsockets,代码行数:101,代码来源:test-server-libuv.c


示例17: main

int main(int argc, char **argv)
{
	struct libwebsocket_context *context;
	int opts = 0;
	char interface_name[128] = "";
	const char *interface = NULL;
	int syslog_options = LOG_PID | LOG_PERROR;
	int listen_port = 7681;
	struct lws_context_creation_info info;
	int debug_level = 7;
	int daemonize = 0;

	memset(&info, 0, sizeof info);

	char c;
	int opt_index = 0;
	while ((c = getopt_long(argc, argv, "hd:k:p:i:DK:", long_opts,
					&opt_index)) != -1) {
		switch (c) {
		case 'D':
			daemonize = 1;
			syslog_options &= ~LOG_PERROR;
			break;
		case 'd':
			debug_level = atoi(optarg);
			break;
		case 'p':
			listen_port = atoi(optarg);
			break;
		case 'k':
			strncpy(keyfile,optarg,sizeof(keyfile));
			keyfile[sizeof(keyfile)-1] = 0;
			break;
		case 'K':
			strncpy(knownhostfile,optarg,sizeof(knownhostfile));
			knownhostfile[sizeof(knownhostfile)-1] = 0;
			break;
		case 'i':
			strncpy(interface_name, optarg, sizeof interface_name);
			interface_name[(sizeof interface_name) - 1] = '\0';
			interface = interface_name;
			break;
		case '?':
		case 'h':
			fprintf(stderr,
				"Usage: %s [OPTIONS]...\n"
				"Websocket-speaking daemon to acquire authentication tokens\n"
				"from compatible websites.\n\n"
				"   -p,--port       NUM     listen on port NUM. (default:%i)\n"
				"   -d,--debug      NUM     set debug level to NUM.\n"
				"   -k,--keyfile    FILE    specify IdentityFile for ssh.\n"
				"   -K,--knownhosts FILE    specify special ssh known_hosts file\n"
				"                           to store host keys acquired by authd\n"
				"                           (defaults to %s)\n"
				"   -D,--daemonize          run in background.\n"
				"   --help                  show this message and exit.\n",
					argv[0],listen_port,knownhostfile);
			exit(1);
		}
	}

	/*
	 * normally lock path would be /var/lock/lwsts or similar, to
	 * simplify getting started without having to take care about
	 * permissions or running as root, set to /tmp/.lwsts-lock
	 */
	if (daemonize && lws_daemonize("/tmp/.lwstecho-lock")) {
		fprintf(stderr, "Failed to daemonize\n");
		return 1;
	}

	/* we will only try to log things according to our debug_level */
	setlogmask(LOG_UPTO (LOG_DEBUG));
	openlog("lwsts", syslog_options, LOG_DAEMON);

	/* tell the library what debug level to emit and to send it to syslog */
	lws_set_log_level(debug_level, lwsl_emit_syslog);

	info.port = listen_port;
	info.iface = interface;
	info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
	info.extensions = libwebsocket_get_internal_extensions();
#endif
	info.gid = -1;
	info.uid = -1;
	info.options = opts;

	context = libwebsocket_create_context(&info);

	if (context == NULL) {
		lwsl_err("libwebsocket init failed\n");
		return -1;
	}

	signal(SIGINT, sighandler);

	/* setup temp file: */
	int fd = mkstemp(tfname);
	if (fd == -1) {
//.........这里部分代码省略.........
开发者ID:wes1138,项目名称:webauth-via-ssh,代码行数:101,代码来源:authd.c


示例18: cyg_pppd_main

externC void
cyg_pppd_main(CYG_ADDRWORD arg)
{
    int i;
    struct timeval timo;
    struct protent *protp;
    int connect_attempts = 0;

    phase = PHASE_INITIALIZE;

    cyg_ppp_options_install( ((struct tty *)arg)->options );

    for (i = 0; (protp = protocols[i]) != NULL; ++i)
        (*protp->init)(0);

    if (!ppp_available()) {
	option_error(no_ppp_msg);
	exit(1);
    }
    
    /*
     * Initialize system-dependent stuff and magic number package.
     */
    sys_init();
    magic_init();
    if (debug)
	setlogmask(LOG_UPTO(LOG_DEBUG));

   
    for (;;) {

	need_holdoff = 1;

        {
            Cyg_ErrNo err;
            while ((err = cyg_io_lookup(devnam, &tty_handle)) < 0) {
                if (err != 0)
                    syslog(LOG_ERR, "Failed to open %s: %d", devnam,err);
            }

#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
            if( modem )
            {
                cyg_uint32 len = sizeof(ppp_tty.serial_callbacks);
                ppp_tty.serial_callbacks.fn = cyg_ppp_serial_callback;
                ppp_tty.serial_callbacks.priv = (CYG_ADDRWORD)&ppp_tty;

                
                err = cyg_io_set_config( tty_handle,
                                         CYG_IO_SET_CONFIG_SERIAL_STATUS_CALLBACK,
                                         &ppp_tty.serial_callbacks,
                                         &len);

                if( err != 0 ) {
                    syslog(LOG_ERR, "cyg_io_set_config(serial callbacks): %d",err);
                    die(1);
                }

            }
#endif
        }

	hungup = 0;
	kill_link = 0;

	/* set line speed, flow control, etc.; clear CLOCAL if modem option */
	set_up_tty(tty_handle, 0);

#ifdef CYGPKG_PPP_CHAT          
        if( script != NULL )
        {
            if( !cyg_ppp_chat( devnam, script ) )
            {
                connect_attempts++;
                goto fail;
            }
        }
#endif

#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
        if( modem )
        {
            while( !ppp_tty.carrier_detected )
                cyg_thread_delay(100);
        }
#endif
        
	connect_attempts = 0;	/* we made it through ok */

	/* set up the serial device as a ppp interface */
	establish_ppp(tty_handle);

        syslog(LOG_INFO, "Using interface ppp%d", ifunit);
        (void) sprintf(ifname, "ppp%d", ifunit);
        
	/*
	 * Start opening the connection and wait for
	 * incoming events (reply, timeout, etc.).
	 */
	syslog(LOG_NOTICE, "Connect: %s <--> %s", ifname, devnam);
//.........这里部分代码省略.........
开发者ID:Palantir555,项目名称:ecos-mars-zx3,代码行数:101,代码来源:pppd.c


示例19: reportStats

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LOG_USER函数代码示例发布时间:2022-05-30
下一篇:
C++ LOG_UNIMPLEMENTED函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap