示例#1
0
int main(int argc, char** argv)
{
	const char* configs;
	const char* dirpath;
	char path[128];
	int c;

	while ((c = getopt_long(argc, argv, "shdv", options, NULL)) != EOF) {
		switch (c) {
		case 'd':
			opt_dump = 1;
			break;
		case 's':
			opt_silent = 1;
			break;
		case 'h':
			puts(USAGE);
			return EXIT_SUCCESS;
		case 'v':
			printf("%s\n", "lirc-lsremotes " VERSION);
			return EXIT_SUCCESS;
		case '?':
			fprintf(stderr, "unrecognized option: -%c\n", optopt);
			fputs("Try `lirc-lsremotes -h' for more information.\n",
			      stderr);
			return EXIT_FAILURE;
		}
	}
	if (argc == optind + 2) {
		dirpath = argv[optind];
		configs = argv[optind + 1];
	} else if (argc == optind + 1) {
		dirpath = argv[optind];
		configs = "*";
	} else {
		fputs(USAGE, stderr);
		return EXIT_FAILURE;
	}
	lirc_log_get_clientlog("lirc-lsremotes", path, sizeof(path));
	unlink(path);
	lirc_log_set_file(path);
	lirc_log_open("lirc-lsremotes", 1, LIRC_NOTICE);
	lsremotes(dirpath, configs);
	check_logs(path);
	return 0;
}
示例#2
0
statistics process_file(std::string const& file_path)
{
    file f(file_path);
    if(31 < f.leaf_name().size())
        {
        complain(f, "exceeds 31-character file-name limit.");
        }

    if(f.is_of_phylum(e_expungible))
        {
        complain(f, "ignored as being expungible.");
        return statistics();
        }

    if(f.is_of_phylum(e_binary) || fs::is_directory(f.path()))
        {
        return statistics();
        }

    assay_non_latin         (f);
    assay_whitespace        (f);

    check_config_hpp        (f);
    check_copyright         (f);
    check_cxx               (f);
    check_defect_markers    (f);
    check_include_guards    (f);
    check_label_indentation (f);
    check_logs              (f);
    check_preamble          (f);
    check_reserved_names    (f);

    enforce_taboos          (f);

    return statistics::analyze_file(f);
}
示例#3
0
int run(void)
{
  xmlDocPtr doc;
  xmlNodePtr node;
  int ct  = STACKCT_OPT(OUTPUT);
  char **output = (char **) &STACKLST_OPT(OUTPUT);
  GString *log;
  int i;
  int color;
  int highest_color = STAT_GREEN;
  char buf[24];
extern int forever;

  uw_setproctitle("sleeping");
  for (i=0; i < OPT_VALUE_INTERVAL; i++) { // wait some minutes
    sleep(1);
    if (!forever)  {
      return(0);
    }
  }

  uw_setproctitle("getting system statistics");
  get_stats();
  doc = UpwatchXmlDoc("result", NULL);
  xmlSetDocCompressMode(doc, OPT_VALUE_COMPRESS);

  // do the sysstat
  node = (xmlNodePtr) newnode(doc, "sysstat");
  add_loadavg(node);
  add_cpu(node);
  add_paging(node);
  add_blockio(node);
  add_swap(node);
  add_memory(node);
  add_systemp(node);
  add_sysstat_info(node);
  color = xmlGetPropInt(node, "color");
  if (color > highest_color) highest_color = color;
#if USE_XMBMON|| defined (__OpenBSD__)
  if (OPT_VALUE_HWSTATS ) { 
    // do the hwstat
    get_hwstats();
    node = (xmlNodePtr) newnode(doc, "hwstat");
    add_hwstat(node);
    color = xmlGetPropInt(node, "color");
    if (color > highest_color) highest_color = color;
  }
#endif
  if (OPT_VALUE_LOCALCHECKS ) { 
   // do the local checks
    color = do_local((xmlNodePtr) doc);
    if (color > highest_color) highest_color = color;
  }

#if HAVE_LIBPCRE
  // do the errlog
  node = (xmlNodePtr) newnode(doc, "errlog");
  log = check_logs(&color);
  if (color > highest_color) highest_color = color;
  sprintf(buf, "%u", color);
  xmlSetProp(node, "color", buf);
  if (log) {
    if (log->str && strlen(log->str) > 0) {
      xmlNewTextChild(node, NULL, "info", log->str);
    }
    g_string_free(log, TRUE);
  }
#endif

  // do the diskfree
  uw_setproctitle("checking diskspace");
  node = (xmlNodePtr) newnode(doc, "diskfree");
  add_diskfree_info(node);
  color = xmlGetPropInt(node, "color");

  if (color > highest_color) highest_color = color;

  if (HAVE_OPT(HPQUEUE) && (highest_color != prv_highest_color)) {
    // if status changed, it needs to be sent immediately. So drop into
    // the high priority queue. Else just drop in the normal queue where
    // uw_send in batched mode will pick it up later
    spool_result(OPT_ARG(SPOOLDIR), OPT_ARG(HPQUEUE), doc, NULL);
  } else {
    for (i=0; i < ct; i++) {
      spool_result(OPT_ARG(SPOOLDIR), output[i], doc, NULL);
    }
  }
  prv_highest_color = highest_color; // remember for next time
  xmlFreeDoc(doc);
  return 0;
}