[PD-cvs] externals/OSCx/send+dump Makefile.in, 1.3, 1.4 htmsocket.c, 1.7, 1.8

Hans-Christoph Steiner eighthave at users.sourceforge.net
Mon Jan 16 06:56:19 CET 2006


Update of /cvsroot/pure-data/externals/OSCx/send+dump
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5043/send+dump

Modified Files:
	Makefile.in htmsocket.c 
Log Message:
a bunch of things to get the OSCx objects compiling to complete without error on MinGW.  Moved the building of the OSC library to the 'lib' target.  Move the building of the command utils to the 'utils' target.  Neither 'lib' nor 'utils' are built with 'all', but they are built with 'install'.  Copied externals/OSCx/src/htmsocket.c to externals/OSCx/send+dump/htmsocket.c since they seem to be the same file, but the send+dump one was out of date.

Index: Makefile.in
===================================================================
RCS file: /cvsroot/pure-data/externals/OSCx/send+dump/Makefile.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.in	5 Apr 2004 04:26:00 -0000	1.3
--- Makefile.in	16 Jan 2006 05:56:14 -0000	1.4
***************
*** 1,2 ****
--- 1,3 ----
+ LIBS = @LIBS@
  LIBOSCDIR = ../libOSC
  LIBOSC = ${LIBOSCDIR}/libOSC.a
***************
*** 12,22 ****
  
  sendOSC: sendOSC.o htmsocket.o ${LIBOSC}
! 	${CC} ${CFLAGS} $(INCLUDES) -o sendOSC sendOSC.o htmsocket.o  ${LIBOSC}
  
  dumpOSC: ${DUMPOBJS}
! 	${CC} ${CFLAGS} $(INCLUDES) -o $@ ${DUMPOBJS}
  
  dumpUDP: dumpUDP.o
! 	${CC} ${CFLAGS} $(INCLUDES) -o dumpUDP dumpUDP.o
  
  ${LIBOSC}:
--- 13,23 ----
  
  sendOSC: sendOSC.o htmsocket.o ${LIBOSC}
! 	${CC} ${CFLAGS} $(INCLUDES) -o sendOSC sendOSC.o htmsocket.o $(LIBS) ${LIBOSC}
  
  dumpOSC: ${DUMPOBJS}
! 	${CC} ${CFLAGS} $(INCLUDES) -o $@ ${DUMPOBJS} $(LIBS)
  
  dumpUDP: dumpUDP.o
! 	${CC} ${CFLAGS} $(INCLUDES) -o dumpUDP dumpUDP.o $(LIBS)
  
  ${LIBOSC}:

Index: htmsocket.c
===================================================================
RCS file: /cvsroot/pure-data/externals/OSCx/send+dump/htmsocket.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** htmsocket.c	19 Aug 2004 22:05:58 -0000	1.7
--- htmsocket.c	16 Jan 2006 05:56:17 -0000	1.8
***************
*** 1,238 ****
! /*
! Written by Adrian Freed, The Center for New Music and Audio Technologies,
! University of California, Berkeley.  Copyright (c) 1992,93,94,95,96,97,98,99,2000,01,02,03,04
! The Regents of the University of California (Regents).  
! 
! Permission to use, copy, modify, distribute, and distribute modified versions
! of this software and its documentation without fee and without a signed
! licensing agreement, is hereby granted, provided that the above copyright
! notice, this paragraph and the following two paragraphs appear in all copies,
! modifications, and distributions.
! 
! IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
! SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
! OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
! BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 
! REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
! HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
! MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
! 
! 
! The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
! */
! 
!  /* htmsocket.c
! 
! 	Adrian Freed
!  	send parameters to htm servers by udp or UNIX protocol
! 
!     Modified 6/6/96 by Matt Wright to understand symbolic host names
!     in addition to X.X.X.X addresses.
! 
!     pd ------------
!     -- added BROADCAST socket option jdl
!  */
! 
! 
! #include <stdio.h>
! #include <strings.h>
! #include <unistd.h>
! #include <sys/types.h>
! #include <sys/stat.h>
! #include <netinet/in.h>
! 
! // #include <rpc/rpc.h> l-osc: sendOSC, Date: Fri, 06 Feb 2004 05:02:42 +1100
! #include <sys/socket.h>
! #include <sys/un.h>
! #include <sys/times.h>
! #include <sys/param.h>
! #include <sys/time.h>
! #include <sys/ioctl.h>
! 
! #include <ctype.h>
! #include <arpa/inet.h>
! #include <netdb.h>
! #include <pwd.h>
! #include <signal.h>
! #include <grp.h>
! #include <sys/fcntl.h>
! #include <sys/file.h>
! #include <sys/time.h>
! #include <sys/types.h>
! #ifndef __APPLE__
!   #include <sys/prctl.h>
! #endif
! 
! #include <stdlib.h>
! 
! #define UNIXDG_PATH "/tmp/htm"
! #define UNIXDG_TMP "/tmp/htm.XXXXXX"
! #include "htmsocket.h"                          
! typedef struct
! {
! 	float srate;
! 
! 	struct sockaddr_in serv_addr; /* udp socket */
!         struct sockaddr_un     userv_addr; /* UNIX socket */
! 	int sockfd;		/* socket file descriptor */
! 	int index, len,uservlen;
! 	void *addr;
! 	int id;
! } desc;
! 
! /* open a socket for HTM communication to given  host on given portnumber */
! /* if host is 0 then UNIX protocol is used (i.e. local communication */
! void *OpenHTMSocket(char *host, int portnumber)
! {
! 	int sockfd;
! 	int oval = 1;
! 	struct sockaddr_in  cl_addr;
! 	struct sockaddr_un  ucl_addr;
! 	desc *o;
! 	o = malloc(sizeof(*o));
! 	if(!o)
! 		return 0;
! 	if(!host)
! 	{
! 	   // char *mkstemp(char *);
! 	   int clilen;
! 		  o->len = sizeof(ucl_addr);
! 		/*
! 		         * Fill in the structure "userv_addr" with the address of the
! 		         * server that we want to send to.
! 		*/
! 		
! 		bzero((char *) &o->userv_addr, sizeof(o->userv_addr));
! 		       o->userv_addr.sun_family = AF_UNIX;
! 		strcpy(o->userv_addr.sun_path, UNIXDG_PATH);
! 			sprintf(o->userv_addr.sun_path+strlen(o->userv_addr.sun_path), "%d", portnumber);
! 	        o->uservlen = sizeof(o->userv_addr.sun_family) + strlen(o->userv_addr.sun_path);
! 		o->addr = &(o->userv_addr);
! 		/*
! 		* Open a socket (a UNIX domain datagram socket).
! 		*/
! 		
! 		if ( (sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) >= 0)
! 		{
! 			/*
! 			 * Bind a local address for us.
! 			 * In the UNIX domain we have to choose our own name (that
! 			 * should be unique).  We'll use mktemp() to create a unique
! 			 * pathname, based on our process id.
! 			 */
! 		
! 			bzero((char *) &ucl_addr, sizeof(ucl_addr));    /* zero out */
! 			ucl_addr.sun_family = AF_UNIX;
! 			strcpy(ucl_addr.sun_path, UNIXDG_TMP);
! 
! 			mkstemp(ucl_addr.sun_path);
! 			clilen = sizeof(ucl_addr.sun_family) + strlen(ucl_addr.sun_path);
! 
! 			if (bind(sockfd, (struct sockaddr *) &ucl_addr, clilen) < 0)
! 			{
! 				perror("client: can't bind local address");
! 				close(sockfd);
! 				sockfd = -1;
! 			}
! 		}
! 		else
! 			perror("unable to make socket\n");
! 
! 	}else
! 	{
! 		/*
! 		         * Fill in the structure "serv_addr" with the address of the
! 		         * server that we want to send to.
! 		*/
! 		o->len = sizeof(cl_addr);
! 		bzero((char *)&o->serv_addr, sizeof(o->serv_addr));
! 		o->serv_addr.sin_family = AF_INET;
! 
! 	    /* MW 6/6/96: Call gethostbyname() instead of inet_addr(),
! 	       so that host can be either an Internet host name (e.g.,
! 	       "les") or an Internet address in standard dot notation 
! 	       (e.g., "128.32.122.13") */
! 	    {
! 		struct hostent *hostsEntry;
! 		unsigned long address;
! 
! 		hostsEntry = gethostbyname(host);
! 		if (hostsEntry == NULL) {
! 		    fprintf(stderr, "Couldn't decipher host name \"%s\"\n",
! 			    host);
! 		    herror(NULL);
! 		    return 0;
! 		}
! 		
! 		address = *((unsigned long *) hostsEntry->h_addr_list[0]);
! 		o->serv_addr.sin_addr.s_addr = address;
! 	    }
! 
! 	    /* was: o->serv_addr.sin_addr.s_addr = inet_addr(host); */
! 
! 	    /* End MW changes */
! 
! 			o->serv_addr.sin_port = htons(portnumber);
! 		o->addr = &(o->serv_addr);
! 		/*
! 		* Open a socket (a UDP domain datagram socket).
! 		*/
! 		if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0)
! 		{
! 			bzero((char *)&cl_addr, sizeof(cl_addr));
! 			cl_addr.sin_family = AF_INET;
! 			cl_addr.sin_addr.s_addr = htonl(INADDR_ANY);
! 			cl_addr.sin_port = htons(0);
! 			
! 			if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) {
! 			  perror("setsockopt");
! 			}
! 		
! 			if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0)
! 			{
! 				perror("could not bind\n");
! 				close(sockfd);
! 				sockfd = -1;
! 			}
! 		}
! 		else
! 		{
! 			perror("unable to make socket\n");
! 		}
! 		
! 	}
! 	if(sockfd<0)
! 	{
! 		free(o); o = 0;
! 	}
! 	else
! 		o->sockfd = sockfd;
! 	return o;
! }
! #include <errno.h>
! 
! static  bool sendudp(const struct sockaddr *sp, int sockfd,int length, int count, void  *b)
! {
! 	int rcount;
! 	if((rcount=sendto(sockfd, b, count, 0, sp, length)) != count)
! 	{
! /*	printf("sockfd %d count %d rcount %dlength %d errno %d\n", sockfd,count,rcount,length,
! 			errno); */
! 			return FALSE;
! 	}
! 	return TRUE;
! }
! bool SendHTMSocket(void *htmsendhandle, int length_in_bytes, void *buffer)
! {
! 	desc *o = (desc *)htmsendhandle;
! 	return sendudp(o->addr, o->sockfd, o->len, length_in_bytes, buffer);
! }
! void CloseHTMSocket(void *htmsendhandle)
! {
! 	desc *o = (desc *)htmsendhandle;
! 	close(o->sockfd);
! 	free(o);
! }
--- 1,313 ----
! /*
! Written by Adrian Freed, The Center for New Music and Audio Technologies,
! University of California, Berkeley.  Copyright (c) 1992,93,94,95,96,97,98,99,2000,01,02,03,04
! The Regents of the University of California (Regents).  
! 
! Permission to use, copy, modify, distribute, and distribute modified versions
! of this software and its documentation without fee and without a signed
! licensing agreement, is hereby granted, provided that the above copyright
! notice, this paragraph and the following two paragraphs appear in all copies,
! modifications, and distributions.
! 
! IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
! SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
! OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
! BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 
! REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
! HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
! MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
! 
! 
! The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl
! */
! 
!  /* htmsocket.c
! 
! 	Adrian Freed
!  	send parameters to htm servers by udp or UNIX protocol
! 
!     Modified 6/6/96 by Matt Wright to understand symbolic host names
!     in addition to X.X.X.X addresses.
! 
!     pd: branched jdl
!     -- win additions raf 2002
!     -- enabled broadcast jdl 2003
!  */
! 
! #if HAVE_CONFIG_H 
! #include <config.h> 
! #endif
! 
! #ifdef __APPLE__
!   #include <string.h>
! #endif
! 
! #ifdef _WIN32
! 	#include <sys/types.h>
! 	#include <sys/stat.h>
! 	#include <winsock2.h>	
! 	#include <ctype.h>
! 	#include <signal.h>
! 	#include <sys/types.h>
! 	#include <stdlib.h>
! 	#include "OSC-common.h"
! 	#include <stdio.h>
! #else
! 	#include <stdio.h>
! 	#include <unistd.h>
! 	#include <sys/types.h>
! 	#include <sys/stat.h>
! 	#include <netinet/in.h>
! 
! //	#include <rpc/rpc.h>
! 	#include <sys/socket.h>
! 	#include <sys/un.h>
! 	#include <sys/times.h>
! 	#include <sys/param.h>
! 	#include <sys/time.h>
! 	#include <sys/ioctl.h>
! 
! 	#include <ctype.h>
! 	#include <arpa/inet.h>
! 	#include <netdb.h>
! 	#include <pwd.h>
! 	#include <signal.h>
! 	#include <grp.h>
! 	#include <sys/fcntl.h>
! 	#include <sys/file.h>
! 	#include <sys/time.h>
! 	#include <sys/types.h>
! //	#include <sys/prctl.h>
! 
! 	#include <stdlib.h>
! #endif
! 
! #define UNIXDG_PATH "/tmp/htm"
! #define UNIXDG_TMP "/tmp/htm.XXXXXX"
! #include "htmsocket.h"                          
! typedef struct
! {
! 	float srate;
! 
! 	struct sockaddr_in serv_addr; /* udp socket */
! 	#ifndef WIN32
! 		struct sockaddr_un userv_addr; /* UNIX socket */
! 	#endif
! 	int sockfd;		/* socket file descriptor */
! 	int index, len,uservlen;
! 	void *addr;
! 	int id;
! } desc;
! 
! /* open a socket for HTM communication to given  host on given portnumber */
! /* if host is 0 then UNIX protocol is used (i.e. local communication */
! void *OpenHTMSocket(char *host, int portnumber)
! {
! 	struct sockaddr_in  cl_addr;
! 	#ifndef WIN32
! 		int sockfd;
! 		struct sockaddr_un ucl_addr;
! 	#else
! 		unsigned int sockfd;
! 	#endif
! 
! 	char oval = 1;
! 
! 	desc *o;
! 	o = malloc(sizeof(*o));
! 	if(!o)
! 		return 0;
! 
!   #ifndef WIN32
! 
! 	if(!host)
! 	{
! 		char *mktemp(char *);
! 		int clilen;
! 		  o->len = sizeof(ucl_addr);
! 		/*
! 		         * Fill in the structure "userv_addr" with the address of the
! 		         * server that we want to send to.
! 		*/
! 		
! 		bzero((char *) &o->userv_addr, sizeof(o->userv_addr));
! 		       o->userv_addr.sun_family = AF_UNIX;
! 		strcpy(o->userv_addr.sun_path, UNIXDG_PATH);
! 			sprintf(o->userv_addr.sun_path+strlen(o->userv_addr.sun_path), "%d", portnumber);
! 	        o->uservlen = sizeof(o->userv_addr.sun_family) + strlen(o->userv_addr.sun_path);
! 		o->addr = &(o->userv_addr);
! 		/*
! 		* Open a socket (a UNIX domain datagram socket).
! 		*/
! 		
! 		if ( (sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) >= 0)
! 		{
! 			/*
! 			 * Bind a local address for us.
! 			 * In the UNIX domain we have to choose our own name (that
! 			 * should be unique).  We'll use mktemp() to create a unique
! 			 * pathname, based on our process id.
! 			 */
! 		
! 			bzero((char *) &ucl_addr, sizeof(ucl_addr));    /* zero out */
! 			ucl_addr.sun_family = AF_UNIX;
! 			strcpy(ucl_addr.sun_path, UNIXDG_TMP);
! 
! 			mktemp(ucl_addr.sun_path);
! 			clilen = sizeof(ucl_addr.sun_family) + strlen(ucl_addr.sun_path);
! 		
! 			if (bind(sockfd, (struct sockaddr *) &ucl_addr, clilen) < 0)
! 			{
! 			  perror("client: can't bind local address");
! 			  close(sockfd);
! 			  sockfd = -1;
! 			}
! 		}
! 		else
! 		  perror("unable to make socket\n");
! 		
! 	}else
! 
!   #endif
! 
! 	{
! 		/*
! 		         * Fill in the structure "serv_addr" with the address of the
! 		         * server that we want to send to.
! 		*/
! 		o->len = sizeof(cl_addr);
! 
! 		#ifdef WIN32
! 			ZeroMemory((char *)&o->serv_addr, sizeof(o->serv_addr));
! 		#else
! 			bzero((char *)&o->serv_addr, sizeof(o->serv_addr));
! 		#endif
! 
! 		o->serv_addr.sin_family = AF_INET;
! 
! 	    /* MW 6/6/96: Call gethostbyname() instead of inet_addr(),
! 	       so that host can be either an Internet host name (e.g.,
! 	       "les") or an Internet address in standard dot notation 
! 	       (e.g., "128.32.122.13") */
! 	    {
! 			struct hostent *hostsEntry;
! 			unsigned long address;
! 
! 			hostsEntry = gethostbyname(host);
! 			if (hostsEntry == NULL) {
! 				fprintf(stderr, "Couldn't decipher host name \"%s\"\n", host);
! 				#ifndef WIN32
! 				herror(NULL);
! 				#endif
! 				return 0;
! 			}
! 			
! 			address = *((unsigned long *) hostsEntry->h_addr_list[0]);
! 			o->serv_addr.sin_addr.s_addr = address;
! 	    }
! 
! 	    /* was: o->serv_addr.sin_addr.s_addr = inet_addr(host); */
! 
! 	    /* End MW changes */
! 
! 		/*
! 		 * Open a socket (a UDP domain datagram socket).
! 		 */
! 
! 
! 		#ifdef WIN32
! 			o->serv_addr.sin_port = htons((USHORT)portnumber);
! 			o->addr = &(o->serv_addr);
! 			if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET) {
! 				ZeroMemory((char *)&cl_addr, sizeof(cl_addr));
! 				cl_addr.sin_family = AF_INET;
! 				cl_addr.sin_addr.s_addr = htonl(INADDR_ANY);
! 				cl_addr.sin_port = htons(0);
! 				
! 				// enable broadcast: jdl ~2003
! 				if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) {
! 				  perror("setsockopt");
! 				}
! 
! 				if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0) {
! 					perror("could not bind\n");
! 					closesocket(sockfd);
! 					sockfd = -1;
! 				}
! 			}
! 			else { perror("unable to make socket\n");}
! 		#else
! 			o->serv_addr.sin_port = htons(portnumber);
! 			o->addr = &(o->serv_addr);
! 			if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
! 					bzero((char *)&cl_addr, sizeof(cl_addr));
! 				cl_addr.sin_family = AF_INET;
! 				cl_addr.sin_addr.s_addr = htonl(INADDR_ANY);
! 				cl_addr.sin_port = htons(0);
! 				
! 				// enable broadcast: jdl ~2003
! 				if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) {
! 				  perror("setsockopt");
! 				}
! 
! 				if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0) {
! 					perror("could not bind\n");
! 					close(sockfd);
! 					sockfd = -1;
! 				}
! 			}
! 			else { perror("unable to make socket\n");}
! 		#endif
! 	}
! 	#ifdef WIN32
! 		if(sockfd == INVALID_SOCKET) {
! 	#else
! 		if(sockfd < 0) {
! 	#endif
! 			free(o); 
! 			o = 0;
! 		}
! 		else
! 			o->sockfd = sockfd;
! 	return o;
! }
! 
! 
! #include <errno.h>
! 
! static  bool sendudp(const struct sockaddr *sp, int sockfd,int length, int count, void  *b)
! {
! 	int rcount;
! 	if((rcount=sendto(sockfd, b, count, 0, sp, length)) != count)
! 	{
! 		printf("sockfd %d count %d rcount %dlength %d errno %d\n", sockfd,count,rcount,length, errno); 
! 		return FALSE;
! 	}
! 	return TRUE;
! }
! bool SendHTMSocket(void *htmsendhandle, int length_in_bytes, void *buffer)
! {
! 	desc *o = (desc *)htmsendhandle;
! 	return sendudp(o->addr, o->sockfd, o->len, length_in_bytes, buffer);
! }
! void CloseHTMSocket(void *htmsendhandle)
! {
! 	desc *o = (desc *)htmsendhandle;
! 	#ifdef WIN32
! 	if(SOCKET_ERROR == closesocket(o->sockfd)) {
! 		perror("CloseHTMSocket::closesocket failed\n");
! 		return;
! 	}
! 	#else
! 	if(close(o->sockfd) == -1)
! 	  {
! 	    perror("CloseHTMSocket::closesocket failed");
! 	    return;
! 	  }
! 	#endif
! 
! 	free(o);
! }





More information about the Pd-cvs mailing list