--- /dev/null
+/*
+ * triv-sound-d.c
+ * writebuffer adapted for sound-playing
+ *
+ * readbuffer and writebuffer are:
+ * Copyright (C) 1997-1998,2000-2001 Ian Jackson <ian@chiark.greenend.org.uk>
+ *
+ * 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 <ian@chiark.greenend.org.uk>
+ * Copyright (C) 1999 Peter Maydell <pmaydell@chiark.greenend.org.uk>
+ *
+ * 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 <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+#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);
+}