Permalink
Browse files

converted some directories from broken submodules to trees

Signed-off-by: Stefan Naewe <stefan.naewe@atlas-elektronik.com>
  • Loading branch information...
Stefan Naewe
Stefan Naewe committed Jun 9, 2009
1 parent 5b31490 commit 9ed255fe2e4c8a1bc7ae17fe58cddfcab48f0e01
Showing 1,405 changed files with 51,066 additions and 5 deletions.
Submodule apue.2e deleted from d247d0
View
@@ -0,0 +1,6 @@
+# git-ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
View
@@ -0,0 +1,11 @@
+ LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY
+
+The author and publisher of the book "Advanced Programming in the
+Unix Environment" have used their best efforts in preparing this
+software. These efforts include the development, research, and
+testing of the theories and programs to determine their effectiveness.
+The author and publisher make no warranty of any kind, express or
+implied, with regard to these programs or the documentation contained
+in the book. The author and publisher shall not be liable in any event
+for incidental or consequential damages in connection with, or arising
+out of, the furnishing, performance, or use of these programs.
@@ -0,0 +1,18 @@
+# Common make definitions, customized for each platform
+
+# Definitions required in all program directories to compile and link
+# C programs using gcc.
+
+WKDIR=/home/sar/apue.2e
+CC=gcc
+COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
+LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDDIR) $(LDFLAGS)
+LDDIR=-L../lib
+LDLIBS=../lib/libapue.a $(EXTRALIBS)
+CFLAGS=-ansi -I$(WKDIR)/include -Wall -DBSD $(EXTRA)
+
+# Our library that almost every program needs.
+LIB=../libapue.a
+
+# Common temp files to delete from each directory.
+TEMPFILES=core core.* *.o temp.* *.out typescript*
View
@@ -0,0 +1,18 @@
+# Common make definitions, customized for each platform
+
+# Definitions required in all program directories to compile and link
+# C programs using gcc.
+
+WKDIR=/home/naewe/src/books/apue.2e
+CC=gcc
+COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
+LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDDIR) $(LDFLAGS)
+LDDIR=-L../lib
+LDLIBS=../lib/libapue.a $(EXTRALIBS)
+CFLAGS=-DLINUX -ansi -I$(WKDIR)/include -Wall -D_GNU_SOURCE $(EXTRA)
+
+# Our library that almost every program needs.
+LIB=../libapue.a
+
+# Common temp files to delete from each directory.
+TEMPFILES=core core.* *.o temp.* *.out typescript*
View
@@ -0,0 +1,18 @@
+# Common make definitions, customized for each platform
+
+# Definitions required in all program directories to compile and link
+# C programs using gcc.
+
+WKDIR=/Users/sar/apue.2e
+CC=gcc
+COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
+LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDDIR) $(LDFLAGS)
+LDDIR=-L../lib
+LDLIBS=../lib/libapue.a
+CFLAGS=-ansi -I$(WKDIR)/include -Wall -DMACOS $(EXTRA)
+
+# Our library that almost every program needs.
+LIB=../libapue.a
+
+# Common temp files to delete from each directory.
+TEMPFILES=core core.* *.o temp.* *.out typescript*
@@ -0,0 +1,18 @@
+# Common make definitions, customized for each platform
+
+# Definitions required in all program directories to compile and link
+# C programs using gcc.
+
+WKDIR=/home/sar/apue.2e
+CC=gcc
+COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
+LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDDIR) $(LDFLAGS)
+LDDIR=-L../lib
+LDLIBS=../lib/libapue.a $(EXTRALIBS)
+CFLAGS=-I$(WKDIR)/include -Wall -DSOLARIS $(EXTRA)
+
+# Our library that almost every program needs.
+LIB=../libapue.a
+
+# Common temp files to delete from each directory.
+TEMPFILES=core core.* *.o temp.* *.out typescript*
View
@@ -0,0 +1,31 @@
+DIRS = lib sockets advio call calld daemons datafiles db environ exercises \
+ file ipc ipp lock mycat open opend opend.fe open.fe proc pty \
+ sess signals std stdio streams termios threadctl threads
+
+all:
+ $(MAKE) `./systype.sh`
+
+clean:
+ for i in $(DIRS); do \
+ (cd $$i && $(MAKE) -f `../systype.sh`.mk clean) || exit 1; \
+ done
+
+freebsd:
+ for i in $(DIRS); do \
+ (cd $$i && $(MAKE) -f freebsd.mk) || exit 1; \
+ done
+
+linux:
+ for i in $(DIRS); do \
+ (cd $$i && $(MAKE) -f linux.mk) || exit 1; \
+ done
+
+macos:
+ for i in $(DIRS); do \
+ (cd $$i && $(MAKE) -f macos.mk) || exit 1; \
+ done
+
+solaris:
+ for i in $(DIRS); do \
+ (cd $$i && $(MAKE) -f solaris.mk) || exit 1; \
+ done
View
@@ -0,0 +1,30 @@
+Read the file called DISCLAIMER.
+
+Some source changes needed to be made after the book went out for the first
+printing. I forgot to make corresponding changes in the source tree on the
+system used to develop the book. The changes are summarized below.
+
+1. lib/recvfd.c and sockets/recvfd.c - needed sys/uio.h on Mac OS X
+2. lib/sendfd.c and sockets/sendfd.c - needed sys/uio.h on Mac OS X
+3. stdio/buf.c - added code for Mac OS X
+4. threadctl/suspend.c - changed wait to waitloc to avoid symbol definition
+ clash on Solaris
+5. include/apue.h - FreeBSD compiles work better if we rely on the default
+ system settings. Solaris needed a different XOPEN_SOURCE definition
+ and also a CMSG_LEN definition.
+
+To build the source, edit the Make.defines.* file for your system and set
+WKDIR to the pathname of the tree containing the source code. Then just
+run "make". It should figure out the system type and build the source for
+that platform automatically. If you are running on a system other than
+FreeBSD, Linux, Mac OS X, or Solaris, you'll need to modify the makefiles
+to include the settings for your system. Also, you'll probably need to
+modify the source code to get it to build on a different operating system.
+The example source was compiled and tested using FreeBSD 5.2.1, Linux 2.4.22,
+Mac OS X 10.3, and Solaris 9.
+
+For FAQs, updated source code, and the lost chapter, see http://www.apuebook.com.
+Please direct questions, suggestions, and bug reports to sar@apuebook.com.
+
+Steve Rago
+May 30, 2005
View
Binary file not shown.
View
@@ -0,0 +1,29 @@
+#include "apue.h"
+#include <stropts.h>
+
+#define BUFFSIZE 4096
+
+int
+main(void)
+{
+ int n, flag;
+ char ctlbuf[BUFFSIZE], datbuf[BUFFSIZE];
+ struct strbuf ctl, dat;
+
+ ctl.buf = ctlbuf;
+ ctl.maxlen = BUFFSIZE;
+ dat.buf = datbuf;
+ dat.maxlen = BUFFSIZE;
+ for ( ; ; ) {
+ flag = 0; /* return any message */
+ if ((n = getmsg(STDIN_FILENO, &ctl, &dat, &flag)) < 0)
+ err_sys("getmsg error");
+ fprintf(stderr, "flag = %d, ctl.len = %d, dat.len = %d\n",
+ flag, ctl.len, dat.len);
+ if (dat.len == 0)
+ exit(0);
+ else if (dat.len > 0)
+ if (write(STDOUT_FILENO, dat.buf, dat.len) != dat.len)
+ err_sys("write error");
+ }
+}
View
Binary file not shown.
View
@@ -0,0 +1,52 @@
+#include "apue.h"
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define NLOOPS 1000
+#define SIZE sizeof(long) /* size of shared memory area */
+
+static int
+update(long *ptr)
+{
+ return((*ptr)++); /* return value before increment */
+}
+
+int
+main(void)
+{
+ int fd, i, counter;
+ pid_t pid;
+ void *area;
+
+ if ((fd = open("/dev/zero", O_RDWR)) < 0)
+ err_sys("open error");
+ if ((area = mmap(0, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, 0)) == MAP_FAILED)
+ err_sys("mmap error");
+ close(fd); /* can close /dev/zero now that it's mapped */
+
+ TELL_WAIT();
+
+ if ((pid = fork()) < 0) {
+ err_sys("fork error");
+ } else if (pid > 0) { /* parent */
+ for (i = 0; i < NLOOPS; i += 2) {
+ if ((counter = update((long *)area)) != i)
+ err_quit("parent: expected %d, got %d", i, counter);
+
+ TELL_CHILD(pid);
+ WAIT_CHILD();
+ }
+ } else { /* child */
+ for (i = 1; i < NLOOPS + 1; i += 2) {
+ WAIT_PARENT();
+
+ if ((counter = update((long *)area)) != i)
+ err_quit("child: expected %d, got %d", i, counter);
+
+ TELL_PARENT(getppid());
+ }
+ }
+
+ exit(0);
+}
View
@@ -0,0 +1,9 @@
+include ../Make.defines.freebsd
+EXTRA=
+
+PROGS = devzero mcopy nonblockw pendlock
+
+all: ${PROGS}
+
+clean:
+ rm -f ${PROGS} ${TEMPFILES} *.o
View
@@ -0,0 +1,9 @@
+include ../Make.defines.linux
+EXTRA=
+
+PROGS = catgetmsg devzero mcopy nonblockw pendlock
+
+all: ${PROGS}
+
+clean:
+ rm -f ${PROGS} ${TEMPFILES} *.o
View
@@ -0,0 +1,9 @@
+include ../Make.defines.macos
+EXTRA=
+
+PROGS = devzero mcopy nonblockw pendlock
+
+all: ${PROGS}
+
+clean:
+ rm -f ${PROGS} ${TEMPFILES} *.o
View
Binary file not shown.
View
@@ -0,0 +1,41 @@
+#include "apue.h"
+#include <fcntl.h>
+#include <sys/mman.h>
+
+int
+main(int argc, char *argv[])
+{
+ int fdin, fdout;
+ void *src, *dst;
+ struct stat statbuf;
+
+ if (argc != 3)
+ err_quit("usage: %s <fromfile> <tofile>", argv[0]);
+
+ if ((fdin = open(argv[1], O_RDONLY)) < 0)
+ err_sys("can't open %s for reading", argv[1]);
+
+ if ((fdout = open(argv[2], O_RDWR | O_CREAT | O_TRUNC,
+ FILE_MODE)) < 0)
+ err_sys("can't creat %s for writing", argv[2]);
+
+ if (fstat(fdin, &statbuf) < 0) /* need size of input file */
+ err_sys("fstat error");
+
+ /* set size of output file */
+ if (lseek(fdout, statbuf.st_size - 1, SEEK_SET) == -1)
+ err_sys("lseek error");
+ if (write(fdout, "", 1) != 1)
+ err_sys("write error");
+
+ if ((src = mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED,
+ fdin, 0)) == MAP_FAILED)
+ err_sys("mmap error for input");
+
+ if ((dst = mmap(0, statbuf.st_size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fdout, 0)) == MAP_FAILED)
+ err_sys("mmap error for output");
+
+ memcpy(dst, src, statbuf.st_size); /* does the file copy */
+ exit(0);
+}
View
Binary file not shown.
View
@@ -0,0 +1,33 @@
+#include "apue.h"
+#include <errno.h>
+#include <fcntl.h>
+
+char buf[500000];
+
+int
+main(void)
+{
+ int ntowrite, nwrite;
+ char *ptr;
+
+ ntowrite = read(STDIN_FILENO, buf, sizeof(buf));
+ fprintf(stderr, "read %d bytes\n", ntowrite);
+
+ set_fl(STDOUT_FILENO, O_NONBLOCK); /* set nonblocking */
+
+ ptr = buf;
+ while (ntowrite > 0) {
+ errno = 0;
+ nwrite = write(STDOUT_FILENO, ptr, ntowrite);
+ fprintf(stderr, "nwrite = %d, errno = %d\n", nwrite, errno);
+
+ if (nwrite > 0) {
+ ptr += nwrite;
+ ntowrite -= nwrite;
+ }
+ }
+
+ clr_fl(STDOUT_FILENO, O_NONBLOCK); /* clear nonblocking */
+
+ exit(0);
+}
View
Binary file not shown.
Oops, something went wrong.

0 comments on commit 9ed255f

Please sign in to comment.