Logo Search packages:      
Sourcecode: ksh version File versions

csto.c

/***********************************************************************
*                                                                      *
*               This software is part of the ast package               *
*           Copyright (c) 1990-2007 AT&T Knowledge Ventures            *
*                      and is licensed under the                       *
*                  Common Public License, Version 1.0                  *
*                      by AT&T Knowledge Ventures                      *
*                                                                      *
*                A copy of the License is available at                 *
*            http://www.opensource.org/licenses/cpl1.0.txt             *
*         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
*                                                                      *
*              Information and Software Systems Research               *
*                            AT&T Research                             *
*                           Florham Park NJ                            *
*                                                                      *
*                 Glenn Fowler <gsf@research.att.com>                  *
*                                                                      *
***********************************************************************/
#pragma prototyped
/*
 * Glenn Fowler
 * AT&T Research
 *
 * write datagram
 */

#include "cslib.h"

ssize_t
csto(register Cs_t* state, int fd, const void* buf, size_t siz, Csaddr_t* addr)
{

#if CS_LIB_V10

      struct udpaddr    udp;

      udp.host = addr->addr[0];
      udp.port = addr->addr[1];
      if (cswrite(state, fd, &udp, sizeof(udp)) != sizeof(udp))
      {
            messagef((state->id, NiL, -1, "to: %d: hdr write error", fd));
            return -1;
      }
      return cswrite(state, fd, buf, siz);

#else

#if CS_LIB_SOCKET

      struct sockaddr_in      nam;

      memzero(&nam, sizeof(nam));
      nam.sin_family = AF_INET;
      nam.sin_addr.s_addr = addr->addr[0];
      nam.sin_port = addr->addr[1];
      return sendto(fd, buf, siz, 0, (struct sockaddr*)&nam, sizeof(nam));

#else

      errno = EINVAL;
      messagef((state->id, NiL, -1, "to: %d: not supported", fd));
      return -1;

#endif

#endif

}

ssize_t
_cs_to(int fd, const void* buf, size_t siz, Csaddr_t* addr)
{
      return csto(&cs, fd, buf, siz, addr);
}

Generated by  Doxygen 1.6.0   Back to index