Ejemplo n.º 1
0
Archivo: test.c Proyecto: cliffeh/clog
int main(int argc, char *argv[])
{
  int level = CLOG_DEFAULT;
  const char *lname = "DEFAULT";

  clog_init(stdout, level, CLOG_DEFAULT_TS_FMT);

  if(argc == 2) {
    if(!strcmp("FATAL", argv[1])) { clog_set_level(level = CLOG_FATAL); lname = "FATAL"; }
    if(!strcmp("ERROR", argv[1])) { clog_set_level(level = CLOG_ERROR); lname = "ERROR"; }
    if(!strcmp("WARN", argv[1]))  { clog_set_level(level = CLOG_WARN);  lname = "WARN";  }
    if(!strcmp("INFO", argv[1]))  { clog_set_level(level = CLOG_INFO);  lname = "INFO";  }
    if(!strcmp("DEBUG", argv[1])) { clog_set_level(level = CLOG_DEBUG); lname = "DEBUG"; }
    if(!strcmp("TRACE", argv[1])) { clog_set_level(level = CLOG_TRACE); lname = "TRACE"; }
  }

  fprintf(stdout, "--- %s ---\n", lname);
  clog_fatal("this is %s log",  "fatal");
  clog_error("this is %s log",  "error");
  clog_warn("this is %s log",    "warn");
  clog_info("this is %s log",    "info");
  clog_debug("this is %s log",  "debug");
  clog_trace("this is %s log",  "trace");

  return 0;
}
Ejemplo n.º 2
0
int
main(int argc, char *argv[])
{
	char		*executablepath, *executablename, *executablestem;

	setlocale(LC_ALL, "");

	ct_savecore();

	clog_init(1);
	if (clog_set_flags(CLOG_F_ENABLE | CLOG_F_STDERR))
		errx(1, "illegal clog flags");

	assl_initialize();

	executablepath = strdup(argv[0]);
	executablename = basename(executablepath);
	executablestem = ct_remove_ext(executablename);

	if (!strcmp(executablestem, "ct") ||
	    !strcmp(executablestem, "cyphertite"))
		return (ct_main(argc, argv));
	if (!strcmp(executablestem, "ctctl") ||
	    !strcmp(executablestem, "cyphertitectl"))
		return (ctctl_main(argc, argv));
	if (!strcmp(executablestem, "ctfb") ||
	    !strcmp(executablestem, "cyphertitefb"))
		return (ctfb_main(argc, argv));
	else
		CFATALX("invalid executable name");


	/* NOTREACHED */
	return (0);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	signal(SIGPIPE, SIG_IGN);
	signal(SIGCHLD, sig_child);
	clog_init();
	us_mon_init();
	dbg_init();
	us_mon_register_notifier(&mn);
	us_mon_register_notifier(&mn1);
	us_mon_enum_dev();
	us_loop();
	us_mod_release();
	clog_release();
	
	return 0;
}
Ejemplo n.º 4
0
int
main(int argc, char *argv[])
{
	struct ct_match		*ctm = NULL;
	uint32_t		cflags;
	int			c, imode;
	char			*mode = NULL, *match = NULL;

	clog_init(1);
	cflags = CLOG_F_ENABLE | CLOG_F_STDERR;
	cflags |= CLOG_F_DBGENABLE | CLOG_F_FILE | CLOG_F_FUNC | CLOG_F_LINE |
	    CLOG_F_DTIME;
	if (clog_set_flags(cflags))
		errx(1, "illegal clog flags");
	CINFO("start");

	while ((c = getopt(argc, argv, "m:M:")) != -1) {
		switch (c) {
		case 'm':
			mode = optarg;
			break;
		case 'M':
			match = optarg;
			break;
		default:
			CFATALX("invalid option");
		}
	}
	argc -= optind;
	argv += optind;

	if (mode) {
		if (!strcmp(mode, "regex"))
			imode = CT_MATCH_REGEX;
		else if (!strcmp(mode, "rb"))
			imode = CT_MATCH_RB;
		else if (!strcmp(mode, "glob"))
			imode = CT_MATCH_GLOB;
		else
			CFATALX("invalid mode %s", mode);
	} else
		CFATALX("no mode");

	if (match == NULL)
		CFATALX("no match");

	CDBG("mode: %s", mode);

	ct_match_compile(&ctm, imode, argv);

	if (ct_match(ctm, match))
		printf("%s not matched\n", match);
	else
		printf("%s matched\n", match);

	ct_match_unwind(ctm);

	e_check_memory();

	return (0);
}