cvsuser     03/10/11 00:08:21

  Modified:    io       io.c io_passdown.c
  Log:
  Beginnings of a network API. Not compiled by default so as not to break
  untested platforms yet. Set PARROT_NET_DEVEL to 1 in io/io_private.h
  to play with it. Currently only a UNIX version, Win32 coming soon.
  
  Revision  Changes    Path
  1.62      +49 -1     parrot/io/io.c
  
  Index: io.c
  ===================================================================
  RCS file: /cvs/public/parrot/io/io.c,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -w -r1.61 -r1.62
  --- io.c      11 Oct 2003 02:15:24 -0000      1.61
  +++ io.c      11 Oct 2003 07:08:20 -0000      1.62
  @@ -1,7 +1,7 @@
   /* io.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *      $Id: io.c,v 1.61 2003/10/11 02:15:24 mrjoltcola Exp $
  + *      $Id: io.c,v 1.62 2003/10/11 07:08:20 mrjoltcola Exp $
    *  Overview:
    *      This is the Parrot IO subsystem API.  Generic IO stuff
    *      goes here, each specific layer goes in its own file...
  @@ -841,6 +841,54 @@
       /* XXX: Maybe use bignums here */
       return VTABLE_get_integer(interpreter, pmc);
   }
  +
  +/*
  + * Networking API
  + */
  +
  +INTVAL
  +PIO_poll(theINTERP, PMC *pmc, INTVAL which, INTVAL sec, INTVAL usec)
  +{
  +    ParrotIOLayer *l = pmc->cache.struct_val;
  +    ParrotIO *io = PMC_data(pmc);
  +    return PIO_poll_down(interpreter, l, io, which, sec, usec);
  +}
  +
  +PMC *
  +PIO_socket(theINTERP, INTVAL fam, INTVAL type, INTVAL proto)
  +{
  +    ParrotIO *io;
  +    ParrotIOLayer *l = GET_INTERP_IO(interpreter);
  +    io = PIO_socket_down(interpreter, l, fam, type, proto);
  +    if(io)
  +        return new_io_pmc(interpreter, io);
  +    return NULL;
  +}
  +
  +INTVAL
  +PIO_recv(theINTERP, PMC *pmc, STRING **buf)
  +{
  +    ParrotIOLayer *l = pmc->cache.struct_val;
  +    ParrotIO *io = PMC_data(pmc);
  +    return PIO_recv_down(interpreter, l, io, buf);
  +}
  +
  +INTVAL
  +PIO_send(theINTERP, PMC *pmc, STRING *buf)
  +{
  +    ParrotIOLayer *l = pmc->cache.struct_val;
  +    ParrotIO *io = PMC_data(pmc);
  +    return PIO_send_down(interpreter, l, io, buf);
  +}
  +
  +INTVAL
  +PIO_connect(theINTERP, PMC *pmc, STRING *address)
  +{
  +    ParrotIOLayer *l = pmc->cache.struct_val;
  +    ParrotIO *io = PMC_data(pmc);
  +    return PIO_connect_down(interpreter, l, io, address);
  +}
  +
   
   /*
    * Local variables:
  
  
  
  1.3       +63 -1     parrot/io/io_passdown.c
  
  Index: io_passdown.c
  ===================================================================
  RCS file: /cvs/public/parrot/io/io_passdown.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- io_passdown.c     10 Oct 2003 13:18:56 -0000      1.2
  +++ io_passdown.c     11 Oct 2003 07:08:21 -0000      1.3
  @@ -1,7 +1,7 @@
   /* io_passdown.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *      $Id: io_passdown.c,v 1.2 2003/10/10 13:18:56 boemmels Exp $
  + *      $Id: io_passdown.c,v 1.3 2003/10/11 07:08:21 mrjoltcola Exp $
    *  Overview:
    *      This is a set of helper functions which search the next implementation
    *      of a function in the layer-stack and call it with the appropriate
  @@ -227,6 +227,68 @@
       /* No layer found */
       return -1;
   }
  +
  +INTVAL
  +PIO_poll_down(theINTERP, ParrotIOLayer *layer, ParrotIO *io,
  +    INTVAL which, INTVAL sec, INTVAL usec)
  +{
  +    while (layer) {
  +        if (layer->api->Poll) {
  +            return layer->api->Poll(interpreter, layer, io, which, sec, usec);
  +        }
  +        layer = PIO_DOWNLAYER(layer);
  +    }
  +    return -1;
  +}
  +
  +ParrotIO *
  +PIO_socket_down(theINTERP, ParrotIOLayer *layer, INTVAL fam, INTVAL type, INTVAL 
proto)
  +{
  +    while (layer) {
  +        if (layer->api->Socket) {
  +            return layer->api->Socket(interpreter, layer, fam, type, proto);
  +        }
  +        layer = PIO_DOWNLAYER(layer);
  +    }
  +    return NULL;
  +}
  +
  +INTVAL
  +PIO_recv_down(theINTERP, ParrotIOLayer *layer, ParrotIO *io, STRING **buf)
  +{
  +    while (layer) {
  +        if (layer->api->Recv) {
  +            return layer->api->Recv(interpreter, layer, io, buf);
  +        }
  +        layer = PIO_DOWNLAYER(layer);
  +    }
  +    return -1;
  +}
  +
  +INTVAL
  +PIO_send_down(theINTERP, ParrotIOLayer *layer, ParrotIO *io, STRING *buf)
  +{
  +    while (layer) {
  +        if (layer->api->Send) {
  +            return layer->api->Send(interpreter, layer, io, buf);
  +        }
  +        layer = PIO_DOWNLAYER(layer);
  +    }
  +    return -1;
  +}
  +
  +INTVAL
  +PIO_connect_down(theINTERP, ParrotIOLayer *layer, ParrotIO *io, STRING *address)
  +{
  +    while (layer) {
  +        if (layer->api->Connect) {
  +            return layer->api->Connect(interpreter, layer, io, address);
  +        }
  +        layer = PIO_DOWNLAYER(layer);
  +    }
  +    return -1;
  +}
  +
   
   /*
    * Local variables:
  
  
  

Reply via email to