示例#1
0
文件: main.c 项目: alukichev/bannerd
static int init(int argc, char **argv, struct animation *banner)
{
	int i;
	struct string_list *filenames = NULL, *filenames_tail = NULL;
	int filenames_count = 0;

	init_log();

	i = get_options(argc, argv);
	if (i < 0)
		return usage(argv[0], NULL);

	for ( ; i < argc; ++i) {
		if (banner->interval == (unsigned int)-1)
			if (!parse_interval(argv[i], &banner->interval))
				continue;

		filenames_tail = string_list_add(&filenames, filenames_tail,
				argv[i]);
		if (!filenames_tail)
			return 1;
		else
			filenames_count++;
	}

	if (!filenames_count)
		return usage(argv[0], "No filenames specified");

	if (fb_init(&_Fb))
		return 1;
	if (init_proper_exit())
		return 1;
	if (animation_init(filenames, filenames_count, &_Fb, banner))
		return 1;
	string_list_destroy(filenames);

	if (banner->frame_count == 1 && RunCount == 1)
		banner->interval = 0; /* Single frame, exit after showing it */
	else if (banner->interval == (unsigned int)-1)
		banner->interval = 1000 / 24; /* 24fps */

	if (!Interactive && daemonify())
		ERR_RET(1, "could not create a daemon");

	return 0;
}
示例#2
0
/* Return a freshly allocated string obtained by concatenating all the
   strings in the list, and destroy the list.  */
char *
string_list_concat_destroy (string_list_ty *slp)
{
  char *result;

  /* Optimize the most frequent case.  */
  if (slp->nitems == 1)
    {
      result = (char *) slp->item[0];
      free (slp->item);
    }
  else
    {
      result = string_list_concat (slp);
      string_list_destroy (slp);
    }
  return result;
}