Ejemplo n.º 1
0
int
main (int argc, char **argv)
{
  int index = 0;
  mu_mailbox_t mbox;
  mh_msgset_t msgset;
  int status;

  /* Native Language Support */
  MU_APP_INIT_NLS ();

  mh_argp_init (program_version);
  mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
		 opt_handler, NULL, &index);

  mbox = mh_open_folder (mh_current_folder (), 0);

  mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");

  status = mh_iterate (mbox, &msgset, rmm, NULL);

  mu_mailbox_expunge (mbox);
  mu_mailbox_close (mbox);
  mu_mailbox_destroy (&mbox);
  return status;
}
Ejemplo n.º 2
0
int
main (int argc, char **argv)
{
  int status;
  int index;
  mu_mailbox_t mbox;
  mu_msgset_t msgset;
  int interactive = mh_interactive_mode_p ();

  MU_APP_INIT_NLS ();

  for (index = 1; index < argc; index++)
    {
      int colon = 0, cpos;
      if (argv[index][0] == '-' && argv[index][1] == '-' &&
	  !strchr (argv[index], '=') &&
	  (!interactive ||
	   (colon = argv[index][cpos = strlen (argv[index]) - 1] == ':') ||
	   *mu_str_skip_class_comp (argv[index], MU_CTYPE_UPPER)) &&
	  index + 1 < argc)
	{
	  if (colon)
	    {
	      cpos -= 2;
	      mu_asprintf (&argv[index], "--component=%*.*s", cpos, cpos,
			   argv[index] + 2);
	    }
	  else
	    mu_asprintf (&argv[index], "--component=%s", argv[index] + 2);
	  mu_asprintf (&argv[index + 1], "--pattern=%s", argv[index + 1]);
	  index++;
	}
    }
  mh_help_hook = pick_help_hook;
  mh_argp_init ();
  mh_argp_parse (&argc, &argv, 0, options, mh_option,
		 args_doc, doc, opt_handler, NULL, &index);
  if (pick_parse (lexlist))
    return 1;

  mbox = mh_open_folder (mh_current_folder (),
			 seq_list ? MU_STREAM_RDWR : MU_STREAM_READ);

  argc -= index;
  argv += index;

  if (seq_list)
    mu_msgset_create (&picked_message_uids, NULL, MU_MSGSET_UID);
  
  mh_msgset_parse (&msgset, mbox, argc, argv, "all");
  status = mu_msgset_foreach_message (msgset, pick_message, NULL);

  if (picked_message_uids)
    mu_list_foreach (seq_list, action_add, mbox);

  mh_global_save_state ();
  mu_mailbox_close (mbox);
  mu_mailbox_destroy (&mbox);
  return status;
}
Ejemplo n.º 3
0
int
main (int argc, char **argv)
{
  int index;
  mu_url_t url;
  
  MU_APP_INIT_NLS ();
  mh_argp_init (program_version);
  mh_argp_parse (&argc, &argv, 0, options, mh_option,
		 args_doc, doc, opt_handler, NULL, &index);
  if (!oplist)
    addop ("date", comp_date);

  if (action == ACTION_LIST && mh_format_parse (format_str, &format))
    {
      mu_error (_("Bad format string"));
      exit (1);
    }
  
  mbox = mh_open_folder (mh_current_folder (), 0);
  mu_mailbox_get_url (mbox, &url);
  mbox_path = mu_url_to_string (url);
  if (memcmp (mbox_path, "mh:", 3) == 0)
    mbox_path += 3;
  
  argc -= index;
  argv += index;

  mh_msgset_parse (mbox, &msgset, argc, argv, "all");
  sort (mbox, msgset);
  return 0;
}
Ejemplo n.º 4
0
int
main (int argc, char **argv)
{
  int index;
  mu_msgset_t msgset;
  mu_mailbox_t mbox;
  mu_url_t url;
  struct mark_closure clos;
  
  MU_APP_INIT_NLS ();
  mh_argp_init ();
  mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
		 opt_handler, NULL, &index);

  mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
  mu_mailbox_get_url (mbox, &url);
  mbox_dir = mu_url_to_string (url);
  if (memcmp (mbox_dir, "mh:", 3) == 0)
    mbox_dir += 3;
	
  argc -= index;
  argv += index;
  mh_msgset_parse (&msgset, mbox, argc, argv, "cur");
  
  clos.mbox = mbox;
  clos.msgset = msgset;
  //FIXME: msgset operates on UIDs but there's no way to inform it about that.
  switch (action)
    {
    case ARG_ADD:
      if (!seq_list)
	{
	  mu_error (_("--add requires at least one --sequence argument"));
	  return 1;
	}
      mu_list_foreach (seq_list, action_add, (void *) &clos);
      mh_global_save_state ();
      break;
      
    case ARG_DELETE:
      if (!seq_list)
	{
	  mu_error (_("--delete requires at least one --sequence argument"));
	  return 1;
	}
      mu_list_foreach (seq_list, action_delete, (void *) &clos);
      mh_global_save_state ();
      break;
      
    case ARG_LIST:
      if (!seq_list)
	list_all (mbox);
      else
	mu_list_foreach (seq_list, action_list, &clos);
      break;
    }
  mu_mailbox_close (mbox);
  mu_mailbox_destroy (&mbox);
  return 0;
}