[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do cvs client server communicate

From: Jim Hyslop
Subject: Re: How do cvs client server communicate
Date: Wed, 22 Mar 2006 12:11:39 -0500
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Hash: SHA1

PJP wrote:
> Jim Hyslop wrote:
>>None. The server takes its input from stdin, and sends its output to
>>stdout and stderr. I believe linking the TCP/IP socket to std[*] is
>>handled by (x)inetd (I'm not a UNIX expert, so don't quote me on that :=)
>    Hey thanks !,
> I think I should better state my problem, I'm tring to add a new commad
> to cvs. This command is supposed to read input from stdin on client
> side and send it over to cvs server. I've already reached the first
> half. But now where should I receive that data on server side, and do
> further processing ?

First thing you need to do (if you haven't already) is to study the
client-server protocol in doc/cvsclient.texi.

Next, examine how an existing command, such as 'cvs commit' works.
You'll notice that all CVS command handler functions expect *everything*
to be passed in via argc and argv.

On the server side, all you have to do is parse argc and argv. On the
client side, you have to write your function so that it passes
everything to the server as arguments. This is accomplished by using the
functions send_to_server, send_arg, option_with_arg, and so on.

So, you need to write your function so that it expects the text to be
one of the arguments passed via the command-line. For example, if on the
client side the user types:

cvs yourcommand[enter]
blah blah blah[ctrl-D]

then you need to process it as if the user typed:

cvs yourcommand -t "blah blah blah"

(this also makes it more flexible for the users - they can now actually
type 'cvs yourcommand -t "blah blah blah"' and it will work).

Inside your command handler function, add an #ifdef block which tests to
see if it's on the client side:

  if ( current_parsed_root->isremote )
    start_server(); /* establish a link to the server */
    [retrieve user input into a buffer (Watch for overflow!) and
    send the buffer to the server]
    option_with_arg("-t", buffer);
    set_to_server("yourcommand\012", 1);
    [clean up and return]

Then simply parse argc and argv, looking for your -t parameter with its
associated text.

As I said, examine how existing commands work, and you should be able to
fill in any gaps I've left.

- --
Jim Hyslop
Dreampossible: Better software. Simply.
                 Consulting * Mentoring * Training in
    C/C++ * OOD * SW Development & Practices * Version Management
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Thunderbird -


reply via email to

[Prev in Thread] Current Thread [Next in Thread]