Hi,
Attached is a simple patch to memos.c in pilot-link.0.9.3 to
improve the current selection scheme of "all or nothing."
The patch adds the memos command a new option -t, which takes
a query string to be matched against the first line (i.e. title)
of each memo. Then, only the matched memos are saved.
Typically, only one memo is selected because of the simple exact
matching. This selection mechanism works well with the -d
option.
Regards,
--
KAJIYAMA, Tamito <[EMAIL PROTECTED]>
diff -ru pilot-link.0.9.3.orig/memos.c pilot-link.0.9.3/memos.c
--- pilot-link.0.9.3.orig/memos.c Sun May 10 14:34:57 1998
+++ pilot-link.0.9.3/memos.c Sun Mar 18 18:55:32 2001
@@ -52,6 +52,7 @@
fprintf(stderr, " -q = do not prompt for HotSync button press\n");
fprintf(stderr, " -p port = use device file <port> to communicate with
Pilot\n");
fprintf(stderr, " -d dir = save memos in <dir> instead of writing to
stdout\n");
+ fprintf(stderr, " -t title = select memos to be saved by title\n");
fprintf(stderr, " -h|-? = print this help\n");
fprintf(stderr, "\n");
fprintf(stderr, "By default, the contents of your Pilot's memo database will be
written\n");
@@ -93,6 +94,7 @@
int c;
extern char* optarg;
extern int optind;
+ char *title = NULL;
progname = argv[0];
@@ -102,7 +104,7 @@
strcpy(addr.pi_device,PILOTPORT);
}
- while (((c = getopt(argc, argv, "qp:d:h?")) != -1)) {
+ while (((c = getopt(argc, argv, "qp:d:t:h?")) != -1)) {
switch (c) {
case 'q':
quiet = 1;
@@ -116,6 +118,10 @@
strcpy(dirname,optarg);
mode = MEMO_DIRECTORY;
break;
+ case 't':
+ /* optarg is a query to select memos by title */
+ title = optarg;
+ break;
case 'h': case '?':
usage();
}
@@ -182,6 +188,14 @@
continue;
unpack_Memo(&m, buffer, len);
+
+ /* skip memos whose title does not match with the query */
+ if (title != NULL) {
+ for (len = 0; m.text[len] && m.text[len] != '\n'; len++);
+ if (strlen(title) != len || strncmp(title, m.text, len))
+ continue;
+ }
+
switch (mode) {
case MEMO_MBOX_STDOUT:
write_memo_mbox(m, mai, category);
_______________________________________________
Pilot-unix mailing list
[EMAIL PROTECTED]
http://hcirisc.cs.binghamton.edu/mailman/listinfo/pilot-unix