[Mew-dist 13588] patch mewls

SAKAI Kiyotaka ksakai at example.com
2000年 7月 10日 (月) 22:19:03 JST


mewls で

・--src 複数の folder を指定できるようにする。
・range を指定できるようにする。

ことをできるようにするためのパッチです。

range の方は

  first-last
  130-140
  first-130
  140-last
  all

のような形式のみ指定可能となっています。(Mew 本体の方もこれに合わせて
直す必要がありますが、これはまだです。)

あと、mewls でやらなければいけないことで気が付いたのは、

  ・Body の表示
  ・"Mail" がハードコードディングされているので、これをオプションで指
    定できるようにする。

というのがあります。 
-- 
酒井 清隆 (E-mail: ksakai at example.com)
-------------- next part --------------
Index: Makefile.in
===================================================================
RCS file: /home/ksakai/cvsroot/mew-1.95b45/bin/Makefile.in,v
retrieving revision 1.1.1.1
diff -u -c -r1.1.1.1 Makefile.in
*** Makefile.in	2000/07/10 06:34:01	1.1.1.1
--- Makefile.in	2000/07/10 11:08:23
***************
*** 13,20 ****
  OBJ1 = mewencode.o getopt.o
  PRG1 = mewencode at example.com@
  ALT  = mewdecode at example.com@ mewcat at example.com@
! SRC2 = mewls.c
! OBJ2 = mewls.o
  PRG2 = mewls at example.com@
  
  CNF = config.h config.status config.cache config.log
--- 13,20 ----
  OBJ1 = mewencode.o getopt.o
  PRG1 = mewencode at example.com@
  ALT  = mewdecode at example.com@ mewcat at example.com@
! SRC2 = mewls.c getopt.c
! OBJ2 = mewls.o getopt.o
  PRG2 = mewls at example.com@
  
  CNF = config.h config.status config.cache config.log
Index: mewls.c
===================================================================
RCS file: /home/ksakai/cvsroot/mew-1.95b45/bin/mewls.c,v
retrieving revision 1.1.1.1
diff -u -c -r1.1.1.1 mewls.c
*** mewls.c	2000/07/10 06:34:02	1.1.1.1
--- mewls.c	2000/07/10 13:14:59
***************
*** 1,5 ****
--- 1,12 ----
+ /*
+  * mewls --- Internet Message List for Mew
+  */
+ static char version_message[] = "mewls version x.xx 200007xx Kazu Yamamoto";
+ 
  #include "config.h"
  
+ #include "getopt.h"
+ 
  #if HAVE_UNISTD_H
  #include <sys/types.h>
  #include <unistd.h>
***************
*** 33,38 ****
--- 40,46 ----
  #define MAILHOME "Mail"
  #define BSIZ 8192
  #define FIELD_MAX_LEN 3
+ #define MAX_FOLDER 12
  
  #define N 6
  char *FIELDS[] = {"To", "From", "Subject", "Date",
***************
*** 44,50 ****
  
  char hbuf[BSIZ];
  
! int GreaterThan=0;
  
  char *
  expandfolder(char *fld) {
--- 52,58 ----
  
  char hbuf[BSIZ];
  
! int First = 0, Last = 0;
  
  char *
  expandfolder(char *fld) {
***************
*** 160,169 ****
  		s++;
  	}
  
! 	if (GreaterThan == 0)
  		return 1;
- 	else if (num > GreaterThan)
- 		return 1;
  	else
  		return 0;
  }
--- 168,175 ----
  		s++;
  	}
  
! 	if (num >= First && (Last == 0 || num <= Last))
  		return 1;
  	else
  		return 0;
  }
***************
*** 238,267 ****
  }
  
  void
! usage () {
! 	fprintf(stderr, "Usage: mewls [folder] [num]\n");
! 	exit(EXIT_FAILURE);
  }
! 	
  int
  main (int argc, char **argv)
  {
! 	char *dir = NULL;
  
! 	switch (argc) {
! 	case 1:
! 		dir = "+inbox";
! 		break;
! 	case 2:
! 		dir = argv[1];
! 		break;
! 	case 3:
! 		dir = argv[1];
! 		GreaterThan = atoi(argv[2]);
! 		break;
! 	default:
! 		usage();
  	}
! 	scanfolder(dir);
  	exit(EXIT_SUCCESS);
  }
--- 244,365 ----
  }
  
  void
! scanfolders(char **flds) {
! 	while (*flds != NULL) {
! 		scanfolder(*flds);
! 		flds++;
! 	}
  }
! 
! /*
!  *  Parse Range
!  */
! void
! parserange(char *range) {
! 	char *first, *last, *s;
! 
! 	if (range == NULL)
! 		return;
! 
! 	if ((s = strchr(range, '-')) != NULL) {
! 		first = range;
! 		last = s + 1;
! 		*s  = '\0';
! 
! 		First = atoi(first);
! 		Last = atoi(last);
! 	} else {
! 		First = Last = atoi(range);
! 	}
! }
! 
! /*
!  *  Help and version information
!  */
! void
! usage (char* progname) {
! 	fprintf(stderr, "Usage: %s [options] [folder] [range]\n", progname);
! }
! 
! char *help_message[] = {
! 	" -s  --src              Message source.",
! 	" -h  --help             Display this help message.",
! 	" -v  --version          Display the version.",
! 	NULL
! };
! 
! void
! help(char *progname) {
! 	char **p = help_message;
! 
! 	fprintf(stderr, "help: %s\n\n", progname);
! 	fprintf(stderr, " Internet Message List.\n\n");
! 	usage(progname);
! 	while (*p) fprintf(stderr, "%s\n", *p++);
! }
! 
! void
! version(char *progname) {
! 	fprintf(stderr, "version of %s: %s\n", progname, version_message);
! }
! 
! struct option longopts [] = {
! 	{"src",      1, 0, 's'},
! 	{"help",     0, 0, 'h'},
! 	{"version",  0, 0, 'v'},    
! 	{0, 0, 0, 0}
! };
! 
! /*
!  *  main routine
!  */
  int
  main (int argc, char **argv)
  {
! 	int optc;
! 	char *dir[MAX_FOLDER + 1];
! 	char *progname = "mewls";
! 	/*char *progname = argv[0];*/
! 	int index = 0;
! 
! 	while ((optc = getopt_long(argc, argv, "shv", longopts, (int *)0)) != EOF)
! 	{
! 		switch (optc) {
! 		case 's':
! 			if (index < MAX_FOLDER)
! 				dir[index++] = optarg;
! 			break;
! 		case 'h':
! 			help(progname);
! 			exit(EXIT_SUCCESS);
! 			break;
! 		case 'v':
! 			version(progname);
! 			exit(EXIT_SUCCESS);
! 			break;
! 		default:
! 			usage(progname);
! 			exit(EXIT_FAILURE);
! 		}
! 	}
  
! 	while (optind < argc) {
! 		if (argv[optind][0] == '+') {
! 			if (index < MAX_FOLDER)
! 				dir[index++] = argv[optind];
! 		} else if (First == 0 && Last == 0) {
! 			parserange(argv[optind]);
! 		} else {
! 			usage(progname);
! 			exit(EXIT_FAILURE);
! 		}
! 		optind++;
  	}
! 
! 	if (index == 0)
! 		dir[index++] = "+inbox";
! 	dir[index] = NULL;
! 
! 	scanfolders(dir);
  	exit(EXIT_SUCCESS);
  }


Mew-dist メーリングリストの案内