chiark / gitweb /
move rwbuffer to new cprogs directory
authorianmdlvl <ianmdlvl>
Wed, 21 May 2003 20:47:20 +0000 (20:47 +0000)
committerianmdlvl <ianmdlvl>
Wed, 21 May 2003 20:47:20 +0000 (20:47 +0000)
cprogs/.cvsignore [moved from backup/.cvsignore with 100% similarity]
cprogs/readbuffer.1 [moved from backup/readbuffer.1 with 100% similarity]
cprogs/readbuffer.c [moved from backup/readbuffer.c with 100% similarity]
cprogs/rwbuffer.c [moved from backup/rwbuffer.c with 100% similarity]
cprogs/rwbuffer.h [moved from backup/rwbuffer.h with 100% similarity]
cprogs/trivsoundd.c [new file with mode: 0644]
cprogs/wrbufcore.c [moved from backup/wrbufcore.c with 100% similarity]
cprogs/writebuffer.1 [moved from backup/writebuffer.1 with 100% similarity]
cprogs/writebuffer.c [moved from backup/writebuffer.c with 100% similarity]

similarity index 100%
rename from backup/.cvsignore
rename to cprogs/.cvsignore
similarity index 100%
rename from backup/readbuffer.1
rename to cprogs/readbuffer.1
similarity index 100%
rename from backup/readbuffer.c
rename to cprogs/readbuffer.c
similarity index 100%
rename from backup/rwbuffer.c
rename to cprogs/rwbuffer.c
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 (file)
index 0000000..e3d1acf
--- /dev/null
@@ -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 <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);
+}
similarity index 100%
rename from backup/wrbufcore.c
rename to cprogs/wrbufcore.c
similarity index 100%
rename from backup/writebuffer.1
rename to cprogs/writebuffer.1
similarity index 100%
rename from backup/writebuffer.c
rename to cprogs/writebuffer.c