Possibility of an extra device?

Maarten Bezemer m.m.bezemer at student.utwente.nl
Wed Feb 5 09:10:24 PST 2003


On 5 Feb 2003 "Alex Waugh" <alex at alexwaugh.com> wrote:

> Maarten Bezemer wrote:
> > On 5 Feb 2003 "Alex Waugh" <alex at alexwaugh.com> wrote:
> > 
> > 
> >>Maarten Bezemer wrote:
> >>
> >>>On 5 Feb 2003 "Nick Burrett" <nick at dsvr.net> wrote:
> >>>
> >>>
> >>>
> >>>>Maarten Bezemer wrote:
> >>>>
> >>>>
> >>>>
> >>>>>Hereby a patch for a user definable device. I think it may be handy for
> >>>>>some particular situations. At least it gets used by CVS :-)
> >>>>
> >>>>So what are the benefits of having a user definable device ? I can't 
> >>>>think of any applications off the top of my head.
> >>>
> >>>
> >>>I use it for CVS to connect a file stream (stdout, stdin) to a
> >>>socket (via a buffer). So all data send to stdout won't be visible on
> >>>the screen, but will be sended trough a given socketed with the right
> >>>protocol.
> >>>CVS was build this way and I had to continue it.
> >>
> >>How are you making use of the device? Is your program modifying the 
> >>device structure to point reads/writes to the user device to it's own 
> >>routines? What interface does CVS use to set things up on unix?
> > 
> > 
> > CVS on unix runs a thread with the ssh protocol (or another) running
> > and opens a pipe to it and send/received all its data trought it.
> 
> Do you really mean a thread, or a separate process?

My mistake! I meant process instead of thread.

> > But running different threads at the same time on the commandline it
> > quite impossible right now. So a pipe is not a option...
> > So I had to think of some other possibilities and for sending/receiving
> > ssh data for the client I managed to create a special buffer and
> > connect it to the stdin/stdout but for the server side it would be
> > sufficient because CVS is runned from another program (CVSServer) and
> > the Socket must be passed on also. So I put the socket number in my new
> > device and my function used that number to read/send data and passes it
> > on the the stdout or receives it from the stdin.
> 
> I think I understand, I'm just a little concerned that to use this new 
> device you have to modify internal unixlib structures, which could 
> easily break if unixlib changes.

I modify it run-time by setting new pointers to (the needed) functions.
And I used the DEV_USER macro to determin which device has to be used.
So when this gets changed (eg from position in the struct) in a newer
version, it changes automaticly when the CVS source gets recompiled and
linked again.

But you're right it has to done with great care, or else things go
horribly wrong!

Maarten

-- 
Maarten Bezemer

http://home.student.utwente.nl/m.m.bezemer/



More information about the gcc mailing list