Go to the previous, next section.
It's the usual simple twelve step process. Let's say you're making
the existing cvs fix command work remotely.
fix function, which already implements
the cvs fix command, to `server.c'.
client_fix to `client.c', which calls
parse_cvsroot and then calls the usual fix function.
client_fix to `client.h'.
client_fix to the "fix" entry in the table of commands in
`main.c'.
serve_fix routine to `server.c'; make it do:
static void
serve_fix (arg)
char *arg;
{
do_cvs_command (fix);
}
"fix" to the table of requests in `server.c'.
fix function can now be entered in three different situations:
local (the old situation), client, and server. On the server side it probably
will not need any changes to cope.
Modify the fix function so that if it is run when the variable
client_active is set, it starts the server, sends over parsed
arguments and possibly files, sends a "fix" command to the server,
and handles responses from the server. Sample code:
if (!client_active) {
/* Do whatever you used to do */
} else {
/* We're the local client. Fire up the remote server. */
start_server ();
if (local)
if (fprintf (to_server, "Argument -l\n") == EOF)
error (1, errno, "writing to server");
send_option_string (options);
send_files (argc, argv, local);
if (fprintf (to_server, "fix\n") == EOF)
error (1, errno, "writing to server");
err = get_responses_and_close ();
}
rsh host cvs finds it.
Now you can test it.
CVS_CLIENT_PORT to
-1 to prevent the client from contacting the server via a direct TCP
link. That will force the client to fall back to using rsh,
which will run your new binary.
CVS_CLIENT_LOG to a filename prefix
such as `/tmp/cvslog'. Whenever you run a remote CVS command,
the commands and responses sent across the client/server connection
will be logged in `/tmp/cvslog.in' and `/tmp/cvslog.out'.
Examine them for problems while you're testing.
This should produce a good first cut at a working remote cvs fix
command. You may have to change exactly how arguments are passed,
whether files or just their names are sent, and how some of the deeper
infrastructure of your command copes with remoteness.
Go to the previous, next section.