From a6f8e0df69734c853b4dbf3b53771860ed128596 Mon Sep 17 00:00:00 2001 From: srikar76 Date: Tue, 29 Mar 2016 16:42:54 -0500 Subject: [PATCH 1/4] Delete facilities.c --- individual-files/facilities.c | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 individual-files/facilities.c diff --git a/individual-files/facilities.c b/individual-files/facilities.c deleted file mode 100644 index 84dbccf..0000000 --- a/individual-files/facilities.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -char *sequence = "class department college office field library"; -void unique( const char *list, char *buf ) -{ - char name[100]; - int k; - buf[0] = 0; - for(;;) - { - while( *list == ' ' ) list++; - k = sscanf( list, "%s", name ); - if( k != 1 ) break; - if( !strstr( buf, name ) ) - { strcat( buf, " " ); - strcat( buf, name ); } - list += strlen(name); - } -} - -int main() -{ - char types[1000]; - unique( types, sequence ); - printf( "Facilities used: %s\n", types ); - return 0; -} From ff83479106cc16769c4e01e1467f63fb628a7272 Mon Sep 17 00:00:00 2001 From: srikar76 Date: Wed, 30 Mar 2016 13:18:58 -0500 Subject: [PATCH 2/4] Delete command.py --- individual-files/command.py | 159 ------------------------------------ 1 file changed, 159 deletions(-) delete mode 100755 individual-files/command.py diff --git a/individual-files/command.py b/individual-files/command.py deleted file mode 100755 index 2894408..0000000 --- a/individual-files/command.py +++ /dev/null @@ -1,159 +0,0 @@ -import abc -import os - - -class Command(object): - """The command interface.""" - - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def execute(self): - """Method to execute the command.""" - pass - - @abc.abstractmethod - def undo(self): - """A method to undo the command.""" - pass - - -class LsCommand(Command): - """Concrete command that emulates ls unix command behavior.""" - - def __init__(self, receiver): - self.receiver = receiver - - def execute(self): - """The command delegates the call to its receiver.""" - self.receiver.show_current_dir() - - def undo(self): - """Can not undo ls command.""" - pass - - -class LsReceiver(object): - def show_current_dir(self): - """The receiver knows how to execute the command.""" - - cur_dir = './' - - filenames = [] - for filename in os.listdir(cur_dir): - if os.path.isfile(os.path.join(cur_dir, filename)): - filenames.append(filename) - - print 'Content of dir: ', ' '.join(filenames) - - -class TouchCommand(Command): - """Concrete command that emulates touch unix command behavior.""" - - def __init__(self, receiver): - self.receiver = receiver - - def execute(self): - self.receiver.create_file() - - def undo(self): - self.receiver.delete_file() - - -class TouchReceiver(object): - def __init__(self, filename): - self.filename = filename - - def create_file(self): - """Actual implementation of unix touch command.""" - with file(self.filename, 'a'): - os.utime(self.filename, None) - - def delete_file(self): - """Undo unix touch command. Here we simply delete the file.""" - os.remove(self.filename) - - -class RmCommand(Command): - """Concrete command that emulates rm unix command behavior.""" - - def __init__(self, receiver): - self.receiver = receiver - - def execute(self): - self.receiver.delete_file() - - def undo(self): - self.receiver.undo() - - -class RmReceiver(object): - def __init__(self, filename): - self.filename = filename - self.backup_name = None - - def delete_file(self): - """Deletes file with creating backup to restore it in undo method.""" - self.backup_name = '.' + self.filename - os.rename(self.filename, self.backup_name) - - def undo(self): - """Restores the deleted file.""" - original_name = self.backup_name[1:] - os.rename(self.backup_name, original_name) - self.backup_name = None - - -class Invoker(object): - def __init__(self, create_file_commands, delete_file_commands): - self.create_file_commands = create_file_commands - self.delete_file_commands = delete_file_commands - - def create_file(self): - print 'Creating file...' - - for command in self.create_file_commands: - command.execute() - self.history.append(command) - - print 'File created.\n' - - def delete_file(self): - print 'Deleting file...' - for command in self.delete_file_commands: - command.execute() - self.history.append(command) - print 'File deleted.\n' - - def undo_all(self): - print 'Undo all...' - - for command in reversed(self.history): - command.undo() - - print 'Undo all finished.' - - -if __name__ == '__main__': - # Client - - # List files in current directory - ls_receiver = LsReceiver() - ls_command = LsCommand(ls_receiver) - - # Create a file - touch_receiver = TouchReceiver('test_file') - touch_command = TouchCommand(touch_receiver) - - # Delete created file - rm_receiver = RmReceiver('test_file') - rm_command = Rm - Command(rm_receiver) - - create_file_commands = [ls_command, touch_command, ls_command] - delete_file_commands = [ls_command, rm_command, ls_command] - - invoker = Invoker(create_file_commands, delete_file_commands) - - invoker.make_file() - invoker.delete_file() - invoker.undo_all() From 715fa8e744b00ca401cad5801c288dcba87954bd Mon Sep 17 00:00:00 2001 From: srikar76 Date: Wed, 30 Mar 2016 19:43:54 -0500 Subject: [PATCH 3/4] Delete ServerThread.java --- individual-files/ServerThread.java | 49 ------------------------------ 1 file changed, 49 deletions(-) delete mode 100644 individual-files/ServerThread.java diff --git a/individual-files/ServerThread.java b/individual-files/ServerThread.java deleted file mode 100644 index 9d9e6e2..0000000 --- a/individual-files/ServerThread.java +++ /dev/null @@ -1,49 +0,0 @@ -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.net.Socket; -import java.util.ArrayList; -import java.util.List; - -import java.io.*; -import java.net.*; -import java.util.*; - -public class ServerThread { - public static void main(String args[]) throws Exception { - int PORT = 5555; // Open port 5555 - - //open socket to listen - ServerSocket server = new ServerSocket(PORT); - Socket client = null; - - while (true) { - System.out.println("Waiting for client..."); - - // open client socket to accept connection - client = server.accept(); - - System.out.println(client.getInetAddress()+" contacted "); - System.out.println("Creating thread to serve request"); - - SThread student = new SThread(client); - student.start(); - } - } -} - -public class SThread extends Thread { - Socket client; - - public SThread(Socket x) { - client = x; - } - - public void run() { - // create object to send information to client - PrintWriter out = new PrintWriter(client.getOutputStream(),true); - - out.println("Student name: ");//send text to client; - } -} - From 55f2922757c6830c9f8724888f2c6e47881bc449 Mon Sep 17 00:00:00 2001 From: srikar76 Date: Wed, 30 Mar 2016 19:57:01 -0500 Subject: [PATCH 4/4] Delete Procedure.java --- individual-files/Procedure.java | 38 --------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 individual-files/Procedure.java diff --git a/individual-files/Procedure.java b/individual-files/Procedure.java deleted file mode 100644 index 6d2a348..0000000 --- a/individual-files/Procedure.java +++ /dev/null @@ -1,38 +0,0 @@ -import java.lang.Runtime; -import java.io.*; - -public class Procedure extends HttpServlet -{ - public void doGet(HttpServletRequest req, HttpServletResponse res) - throws ServletException, IOException - { - res.setContentType("text/html"); - ServletOutputStream out = res.getOutputStream(); - out.println("Test
");
-        
-        String user = req.getParameter("user");
-        if(user != null) {
-            try {
-                 String[] args = { "/bin/sh", "-c", "finger " + user };
-                Process p = Runtime.getRuntime().exec(args);
-                BufferedReader fingdata = new BufferedReader(new InputStreamReader(p.getInputStream()));
-                String line;
-                while((line = fingdata.readLine()) != null)
-                    out.println(line);
-                p.waitFor();
-                catch(Exception e) {
-                    throw new ServletException(e);
-                
-                    else {
-                        out.println("specify a user");
-            
-        
-                        out.println("
"); - out.close(); - - } - } - } - } - } -}