Skip to content

Commit 15a5d6f

Browse files
committed
Make FINGER client take an optional argument for passing to the server.
1 parent 3efb016 commit 15a5d6f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/finger.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
int main (int argc, char **argv)
99
{
10-
char *command;
10+
char command[1000];
1111
char reply[1000];
1212
int host, connection, size;
1313

14-
if (argc != 2) {
15-
fprintf (stderr, "Usage: %s host\n", argv[0]);
14+
if (argc < 2 || argc > 3) {
15+
fprintf (stderr, "Usage: %s host [user(s)]\n", argv[0]);
1616
exit (1);
1717
}
1818

@@ -39,8 +39,8 @@ int main (int argc, char **argv)
3939
exit (1);
4040
}
4141

42-
command = "Sample Finger command from client.\r\n";
43-
size = strlen (command);
42+
size = snprintf (command, sizeof command, "%s\r\n",
43+
argc == 3 ? argv[2] : "");
4444
if (ncp_write (connection, command, &size) == -1) {
4545
fprintf (stderr, "NCP write error.\n");
4646
exit (1);

test/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ echo "Test ICP and simple data transfer using the Finger protocol."
3838
NCP=ncp2 ../src/finser &
3939
PID=$!
4040
sleep 1
41-
NCP=ncp3 ../src/finger 002 &
41+
NCP=ncp3 ../src/finger 002 "Sample Finger command from client." &
4242
sleep 10
4343
kill $! $PID 2>/dev/null || :
4444

0 commit comments

Comments
 (0)