Explorar el Código

Method test program
Author: jgg
Date: 1998-11-03 01:39:43 GMT
Method test program

Arch Librarian hace 22 años
padre
commit
8bb5959b7e
Se han modificado 2 ficheros con 26 adiciones y 0 borrados
  1. 6 0
      test/makefile
  2. 20 0
      test/mthdcat.cc

+ 6 - 0
test/makefile

@@ -5,6 +5,12 @@ SUBDIR=test
 # Bring in the default rules
 include ../buildlib/defaults.mak
 
+# Program for testing methods
+PROGRAM=mthdcat
+SLIBS = 
+SOURCE = mthdcat.cc
+include $(PROGRAM_H)
+
 # Scratch program to test incomplete code fragments in
 PROGRAM=scratch-test
 SLIBS = -lapt-pkg 

+ 20 - 0
test/mthdcat.cc

@@ -0,0 +1,20 @@
+/* Usage, mthdcat < cmds | methods/mthd
+   All this does is cat a file into the method without closing the FD when
+   the file ends */
+
+#include <unistd.h>
+
+int main()
+{
+   char Buffer[4096];
+   
+   while (1)
+   {
+      int Res = read(STDIN_FILENO,Buffer,sizeof(Buffer));
+      if (Res <= 0)
+	 while (1) sleep(100);
+      if (write(STDOUT_FILENO,Buffer,Res) != Res)
+	 break;
+   }
+   return 0;
+}