From 5c3011ee1de9a9b231270044ea52649f84cdac66 Mon Sep 17 00:00:00 2001 From: "Alfred M. Szmidt" Date: Tue, 26 Jul 2005 19:32:07 +0000 Subject: 2005-07-26 Alfred M. Szmidt * rpctrace.c: Include , , and . (main, options): Renamed the option `-I' to `-i', and reimplemented `-I' to search a given directory for message ID files. (main): Variable `err' removed. --- utils/ChangeLog | 8 ++++++++ utils/rpctrace.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) (limited to 'utils') diff --git a/utils/ChangeLog b/utils/ChangeLog index e22fab2c..4b02f072 100644 --- a/utils/ChangeLog +++ b/utils/ChangeLog @@ -1,3 +1,11 @@ +2005-07-26 Alfred M. Szmidt + + * rpctrace.c: Include , , and . + (main, options): Renamed the option `-I' to `-i', and + reimplemented `-I' to search a given directory for message ID + files. + (main): Variable `err' removed. + 2004-09-21 Alfred M. Szmidt * fsysopts.c (doc): Changed `--remount' to `--update'. diff --git a/utils/rpctrace.c b/utils/rpctrace.c index ea06b1b7..7646bb94 100644 --- a/utils/rpctrace.c +++ b/utils/rpctrace.c @@ -1,6 +1,6 @@ /* Trace RPCs sent to selected ports - Copyright (C) 1998,99,2001,02,03 Free Software Foundation, Inc. + Copyright (C) 1998,99,2001,02,03,05 Free Software Foundation, Inc. This file is part of the GNU Hurd. @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -39,8 +42,10 @@ const char *argp_program_version = STANDARD_HURD_VERSION (rpctrace); static const struct argp_option options[] = { {"output", 'o', "FILE", 0, "Send trace output to FILE instead of stderr."}, - {"rpc-list", 'I', "FILE", 0, + {"rpc-list", 'i', "FILE", 0, "Read FILE for assocations of message ID numbers to names."}, + {0, 'I', "DIR", 0, + "Add the directory DIR to the list of directories to be searched for files containing message ID numbers."}, {0} }; @@ -1059,7 +1064,6 @@ main (int argc, char **argv, char **envp) { const char *outfile = 0; char **cmd_argv = 0; - error_t err; /* Parse our options... */ error_t parse_opt (int key, char *arg, struct argp_state *state) @@ -1070,10 +1074,42 @@ main (int argc, char **argv, char **envp) outfile = arg; break; - case 'I': + case 'i': parse_msgid_list (arg); break; + case 'I': + { + struct dirent **eps; + int n; + + static int + msgids_file_p (const struct dirent *eps) + { + if (fnmatch ("*.msgids", eps->d_name, 0) != FNM_NOMATCH) + return 1; + return 0; + } + + n = scandir (arg, &eps, msgids_file_p, NULL); + if (n >= 0) + { + for (int cnt = 0; cnt < n; ++cnt) + { + char *msgids_file; + struct stat st; + if (asprintf (&msgids_file, + "%s/%s", arg, eps[cnt]->d_name) < 0) + error (1, errno, "asprintf"); + parse_msgid_list (msgids_file); + free (msgids_file); + } + } + /* If the directory couldn't be scanned for whatever + reason, just ignore it. */ + } + break; + case ARGP_KEY_NO_ARGS: argp_usage (state); return EINVAL; -- cgit v1.2.3