From 420c3e2408e9081e5a0e760993e26e63f2d3a072 Mon Sep 17 00:00:00 2001
From: adash <adash>
Date: Sat, 28 Oct 2006 00:58:05 +0000
Subject: [PATCH] Log the webserver requests Add append functionality in a file
 for logging all requests

---
 Robust/src/ClassLibrary/FileOutputStream.java |  9 +++++++++
 Robust/src/Runtime/file.c                     |  7 +++++++
 Robust/src/Tests/Logger.java                  | 18 ++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 Robust/src/Tests/Logger.java

diff --git a/Robust/src/ClassLibrary/FileOutputStream.java b/Robust/src/ClassLibrary/FileOutputStream.java
index 04c589c3..ed81ed7c 100644
--- a/Robust/src/ClassLibrary/FileOutputStream.java
+++ b/Robust/src/ClassLibrary/FileOutputStream.java
@@ -5,11 +5,20 @@ public class FileOutputStream {
 	fd=nativeOpen(pathname.getBytes());
     }
 
+    public FileOutputStream(String pathname, int mode) {
+	if(mode==0)	
+		fd=nativeAppend(pathname.getBytes());
+    	if(mode==1)
+		fd=nativeOpen(pathname.getBytes());
+    }
+
+
     public FileOutputStream(File path) {
 	fd=nativeOpen(path.getPath().getBytes());
     }
 
     private static native int nativeOpen(byte[] filename);
+    private static native int nativeAppend(byte[] filename);
     private static native void nativeWrite(int fd, byte[] array);
     private static native void nativeClose(int fd);
     
diff --git a/Robust/src/Runtime/file.c b/Robust/src/Runtime/file.c
index bee9b96f..fa8343dc 100644
--- a/Robust/src/Runtime/file.c
+++ b/Robust/src/Runtime/file.c
@@ -24,6 +24,13 @@ int ___FileOutputStream______nativeOpen_____AR_B(struct ArrayObject * ao) {
   return fd;
 }
 
+int ___FileOutputStream______nativeAppend_____AR_B(struct ArrayObject * ao) {
+  int length=ao->___length___;
+  char* filename= (((char *)& ao->___length___)+sizeof(int));
+  int fd=open(filename, O_WRONLY|O_CREAT|O_APPEND, S_IRWXU);
+  return fd;
+}
+
 int ___FileInputStream______nativeOpen_____AR_B(struct ArrayObject * ao) {
   int length=ao->___length___;
   char* filename= (((char *)& ao->___length___)+sizeof(int));
diff --git a/Robust/src/Tests/Logger.java b/Robust/src/Tests/Logger.java
new file mode 100644
index 00000000..0603758e
--- /dev/null
+++ b/Robust/src/Tests/Logger.java
@@ -0,0 +1,18 @@
+public class Logger extends FileOutputStream {
+	//Logging flag
+	flag LogPending;
+	
+	//Constructor
+	public Logger(){
+	}
+
+	public void logrequest(){
+		String filepath = new String("./Tests/htmlfiles/request.log");
+		String request = new String(" New Request received\n");
+		int mode=0;
+		FileOutputStream logfile = new FileOutputStream(filepath,mode);
+		logfile.write(request.getBytes());
+		logfile.close();	
+	}
+
+}
-- 
2.34.1