From: ianmdlvl Date: Wed, 21 May 2003 20:47:20 +0000 (+0000) Subject: move rwbuffer to new cprogs directory X-Git-Tag: branchpoint-trivsoundd~1 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=737b84851cd8b3dd1d9f1920201127eac693dffb;ds=sidebyside move rwbuffer to new cprogs directory --- diff --git a/backup/.cvsignore b/cprogs/.cvsignore similarity index 100% rename from backup/.cvsignore rename to cprogs/.cvsignore diff --git a/backup/readbuffer.1 b/cprogs/readbuffer.1 similarity index 100% rename from backup/readbuffer.1 rename to cprogs/readbuffer.1 diff --git a/backup/readbuffer.c b/cprogs/readbuffer.c similarity index 100% rename from backup/readbuffer.c rename to cprogs/readbuffer.c diff --git a/backup/rwbuffer.c b/cprogs/rwbuffer.c similarity index 100% rename from backup/rwbuffer.c rename to cprogs/rwbuffer.c diff --git a/backup/rwbuffer.h b/cprogs/rwbuffer.h similarity index 100% rename from backup/rwbuffer.h rename to cprogs/rwbuffer.h diff --git a/cprogs/trivsoundd.c b/cprogs/trivsoundd.c new file mode 100644 index 0000000..e3d1acf --- /dev/null +++ b/cprogs/trivsoundd.c @@ -0,0 +1,119 @@ +/* + * triv-sound-d.c + * writebuffer adapted for sound-playing + * + * readbuffer and writebuffer are: + * Copyright (C) 1997-1998,2000-2001 Ian Jackson + * + * readbuffer is part of chiark backup, a system for backing up GNU/Linux and + * other UN*X-compatible machines, as used on chiark.greenend.org.uk. + * chiark backup is: + * Copyright (C) 1997-1998,2000-2001 Ian Jackson + * Copyright (C) 1999 Peter Maydell + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this file; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rwbuffer.h" + +const char *progname= "triv-sound-d"; + +static int master; + +int main(int argc, const char *const *argv) { + const char *bindname; + union { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_un sun; + } su; + socklen_t sulen; + + bindname= *++argv; + if (!bindname) usageerr("need bind argument"); + startup(argv); + + memset(&su,0,sizeof(su)); + + if (bindname[0]=='/' || bindname[0]='.') { + if (strlen(bindname) >= sizeof(su.sun.sun_path)) + usageerr("AF_UNIX bind path too long"); + sulen= sizeof(su.sun); + su.sun.sun_family= AF_UNIX; + strcpy(su.sun.sun_path, bindname); + } else if ((colon= strrchr(bindname,':'))) { + char *copy, *ep; + unsigned long portul; + + sulen= sizeof(su.sin); + su.sin.sin_family= AF_INET; + + copy= xmalloc(colon - bindname + 1); + memcpy(copy,bindname, colon - bindname + 1); + copy[colon - bindname]= 0; + portul= strtoul(colon+1,0,&ep); + if (!*ep) { + if (!portul || portul>=65536) usageerr("invalid port number"); + su.sin.sin_port= htons(portul); + } else { + struct servent *se= getservbyname(colon+1, "tcp"); + if (!se) { fprintf(stderr,"unknown service `%s'\n",colon+1); exit(4); } + su.sin.sin_port= htons(se->s_port); + } + + if (!inet_aton(copy,&su.sin.sin_addr)) { + struct hostent *he= gethostbyname(copy); + if (!he) { herror(copy); exit(4); } + if (he->h_addrtype != AF_INET || + he->h_length != sizeof(su.sin.sin_addr) || + !he->h_addrs[0] || + he->h_addrs[1]) { + fprintf(stderr,"hostname lookup `%s' did not yield" + " exactly one IPv4 address\n",copy); + exit(4); + } + memcpy(su.sin.sin_addr, he->h_addrs[0], sizeof(su.sin.sin_addr)); + } + } + + master= socket(su.sa.sa_family,SOCK_STREAM,0); + if (master<0) { perror("socket"); exit(8); } + + + + if ( + + sdigit((unsigned char)bindname[0])) { + + + if (argv[0] + + startup(argv); + writebuf_startup(); + writebuf_mainloop(); + exit(0); +} diff --git a/backup/wrbufcore.c b/cprogs/wrbufcore.c similarity index 100% rename from backup/wrbufcore.c rename to cprogs/wrbufcore.c diff --git a/backup/writebuffer.1 b/cprogs/writebuffer.1 similarity index 100% rename from backup/writebuffer.1 rename to cprogs/writebuffer.1 diff --git a/backup/writebuffer.c b/cprogs/writebuffer.c similarity index 100% rename from backup/writebuffer.c rename to cprogs/writebuffer.c