]> git.saurik.com Git - apt.git/commitdiff
Method test program
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:17 +0000 (16:51 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:17 +0000 (16:51 +0000)
Author: jgg
Date: 1998-11-03 01:39:43 GMT
Method test program

test/makefile
test/mthdcat.cc [new file with mode: 0644]

index 299389873d16098393732f9a884c7df12c8174ba..bf1b1834c311f0b00a3dbfe47302ebd8f557341f 100644 (file)
@@ -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 
diff --git a/test/mthdcat.cc b/test/mthdcat.cc
new file mode 100644 (file)
index 0000000..25d09a3
--- /dev/null
@@ -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;
+}