Exemple #1
0
int log_print(char *mesh_iface, int argc, char **argv)
{
	int optchar, res, read_opt = USE_BAT_HOSTS | LOG_MODE;
	char full_path[MAX_PATH+1];
	char *debugfs_mnt;

	while ((optchar = getopt(argc, argv, "hn")) != -1) {
		switch (optchar) {
		case 'h':
			log_usage();
			return EXIT_SUCCESS;
		case 'n':
			read_opt &= ~USE_BAT_HOSTS;
			break;
		default:
			log_usage();
			return EXIT_FAILURE;
		}
	}

	debugfs_mnt = debugfs_mount(NULL);
	if (!debugfs_mnt) {
		fprintf(stderr, "Error - can't mount or find debugfs\n");
		return EXIT_FAILURE;
	}

	debugfs_make_path(DEBUG_BATIF_PATH_FMT "/", mesh_iface, full_path, sizeof(full_path));
	res = read_file(full_path, DEBUG_LOG, read_opt, 0, 0, 0);
	return res;
}
int main (void)
#endif // __ANDROID__
{
  char version_string [80];

  /* We need to install a handler for SIGSEGV and friends so rowan and his
     friends can't drop a core file! */

  signal (SIGSEGV, signal_handler);
  signal (SIGBUS, signal_handler);
  signal (SIGQUIT, signal_handler);

  store_term_default ();
  set_term_raw ();

#ifndef __ANDROID__
  log_usage ();
#endif
  init_level_maps ();

  draw_frame ();
  put_screen (intro_pixmap);
  
  sprintf (version_string, "Version %s - %s %d, %d", GLIDER_VERSION, GLIDER_MONTHSTR, GLIDER_DAY, GLIDER_YEAR);
  centre_text (version_string, 12, MAX_SCR_COLS);
  
  park_cursor ();
  wait_for_key ();
  put_screen (notes_0);
  park_cursor ();
  wait_for_key ();
  put_screen (notes_1);
  park_cursor ();
  wait_for_key ();
  put_screen (notes_2);
  park_cursor ();
  wait_for_key ();

  menu ();

  ansi_Position (1, 1);
  ansi_ClearScreen ();
  set_term_default ();

  return (0); /* Exit cleanly */
}
Exemple #3
0
int main(int argc, char *argv[])
{
	int i=0, opt = 0;
	const char *opt_str = "vht:";
	
	iv_conv_t *worker = NULL;

	file_list_t *files = NULL, *lastfile = NULL;

	if(argc == 1) 
	{
		log_usage(1);
		exit(-1);
	}

	while( -1 != (opt = getopt(argc, argv, opt_str)) )
	{
		switch(opt)
		{
			case 'v':
				vlog("imgveil: v%s, build on %s\n", IVVersion, IVBuildVer);
				exit(0);
				break;
			case 'h':
				log_usage(0);
				exit(0);
				break;
			case 't':
				if(search_type(optarg) == NULL)
				{
					vlog("imgveil: unknown target....\n");
				}
				else
				{
					worker = search_worker(optarg);
				}
				break;
			default:
				log_usage(1);		
				break;
		}
	}
	
	for(i=optind; i<argc; i++)
	{
		char *path = argv[i];
		struct file_path *afile = (struct file_path*)malloc(sizeof(struct file_path));
		
		afile->path = (char*)malloc(strlen(path)+1);
		sprintf(afile->path, "%s", path);
		afile->next = NULL;

		if(files == NULL)
		{
			files = afile;
		}
		else
		{
			lastfile->next = afile;
		}

		lastfile = afile;
	}
	
	void *cocoactx = worker->iv_init();
	char *desc = worker->iv_convert(cocoactx, files);
	worker->iv_uninit(cocoactx);
    vlog("%s", desc);
    free(desc);
	destroy_file_path_list(files);
	
	return 0;
}
Exemple #4
0
static void
get_log(int argCount, char** args)
{
	bool raw = false;
	bool userOnly = false;
	bool systemOnly = false;
	int32 limit = 0;
	const char* event = NULL;
	const char* job = NULL;

	optind = 0;
	int c;
	while ((c = getopt_long(argCount, args, "hruse:l:", kLogLongOptions, NULL))
			!= -1) {
		switch (c) {
			case 0:
				break;
			case 'h':
				log_usage(0);
				break;
			case 'r':
				raw = true;
				break;
			case 'u':
				userOnly = true;
				break;
			case 's':
				systemOnly = true;
				break;
			case 'e':
				event = optarg;
				break;
			case 'l':
				limit = strtol(optarg, NULL, 0);
				break;
		}
	}

	if (argCount - optind >= 1)
		job = args[optind];

	BLaunchRoster roster;
	BMessage filter;
	if (userOnly)
		filter.AddBool("userOnly", true);
	if (systemOnly)
		filter.AddBool("systemOnly", true);
	if (event != NULL)
		filter.AddString("event", event);
	if (job != NULL)
		filter.AddString("job", job);
	if (limit != 0)
		filter.AddInt32("limit", limit);

	BMessage info;
	status_t status = roster.GetLog(filter, info);
	if (status != B_OK) {
		fprintf(stderr, "%s: Could not get log: %s\n", kProgramName,
			strerror(status));
		exit(EXIT_FAILURE);
	}

	if (raw) {
		info.PrintToStream();
		return;
	}

	print_log(info);

	BMessage user;
	if (info.FindMessage("user", &user) == B_OK) {
		if (user.HasMessage("item"))
			puts("User log:");
		print_log(user);
	}
}