summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-01-23 17:35:59 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-01-23 17:35:59 +0100
commit014a1f01fc512fb08023e1c3062653b3183e9b93 (patch)
treea9b908fe2c0606480a269ac677d9bca38f178f82 /utils
parent3d8aba71b6170148c7271fb828fc106721e18602 (diff)
Add -s option to rpctrace
* utils/rpctrace.c (strsize): New variable, defaults to 80. (options): Add 's' option. (main): Store 's' option value into `strsize'. (print_data): Limit the amount of printed characters to strsize.
Diffstat (limited to 'utils')
-rw-r--r--utils/rpctrace.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index e75bd0df..996d4bae 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -1,6 +1,6 @@
/* Trace RPCs sent to selected ports
- Copyright (C) 1998, 1999, 2001, 2002, 2003, 2005, 2006, 2009
+ Copyright (C) 1998, 1999, 2001, 2002, 2003, 2005, 2006, 2009, 2011
Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -44,6 +44,8 @@ const char *argp_program_version = STANDARD_HURD_VERSION (rpctrace);
#define STD_MSGIDS_DIR DATADIR "/msgids/"
+static unsigned strsize = 80;
+
#define OPT_NOSTDINC -1
static const struct argp_option options[] =
{
@@ -56,6 +58,7 @@ static const struct argp_option options[] =
{0, 'I', "DIR", 0,
"Add the directory DIR to the list of directories to be searched for files "
"containing message ID numbers."},
+ {0, 's', "SIZE", 0, "Specify the maximum string size to print (the default is 80)."},
{0}
};
@@ -957,6 +960,8 @@ print_data (mach_msg_type_name_t type,
case MACH_MSG_TYPE_STRING:
case MACH_MSG_TYPE_CHAR:
+ if (nelt > strsize)
+ nelt = strsize;
fprintf (ostream, "\"%.*s\"",
(int) (nelt * eltsize), (const char *) data);
return;
@@ -1151,6 +1156,10 @@ main (int argc, char **argv, char **envp)
arg, TRUE);
break;
+ case 's':
+ strsize = atoi (arg);
+ break;
+
case ARGP_KEY_NO_ARGS:
argp_usage (state);
return EINVAL;