[LON-CAPA-cvs] cvs: loncom / lond

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 22 Dec 2003 11:29:59 -0000


foxr		Mon Dec 22 06:29:59 2003 EDT

  Modified files:              
    /loncom	lond 
  Log:
  Add EditFile sub and its top level logic:
  - Split the request into request keyword, edit file specifier and script.
  - Validate request keyword.
  - Validate edit file specifier.
  
  
  
Index: loncom/lond
diff -u loncom/lond:1.166 loncom/lond:1.167
--- loncom/lond:1.166	Mon Dec 22 06:03:37 2003
+++ loncom/lond	Mon Dec 22 06:29:58 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.166 2003/12/22 11:03:37 foxr Exp $
+# $Id: lond,v 1.167 2003/12/22 11:29:58 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -10,7 +10,7 @@
 #
 # LON-CAPA is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 2 of the License, or 
 # (at your option) any later version.
 #
 # LON-CAPA is distributed in the hope that it will be useful,
@@ -52,7 +52,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.166 $'; #' stupid emacs
+my $VERSION='$Revision: 1.167 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -476,7 +476,36 @@
     }
     return 'ok';
 }
+#
+#   Called to edit a file
+#   Parameters:
+#      request           - The entire command/request sent by lonc or lonManage
+#   Return:
+#      The reply to send to the client.
+sub EditFile {
+    my $request = shift;
+
+    #  Split the command into it's pieces:  edit:filetype:script
+
+    my ($request, $filetype, $script) = split(":", $request);
+
+    #  Check the pre-coditions for success:
+
+    if($request != "edit") {	# Something is amiss afoot alack.
+	return "error:edit request detected, but request != 'edit'\n";
+    }
+    if( ($filetype ne "hosts")  &&
+	($filetype ne "domain")) {
+	return "error:edit requested with invalid file specifier: $filetype \n";
+    }
+
+    #   Split the edit script and check it's validity.
 
+    #   Execute the edit operation.
+
+
+    return "ok\n";
+}
 #
 #  Convert an error return code from lcpasswd to a string value.
 #
@@ -1237,7 +1266,7 @@
                my($command, $filetype, $script) = split(/:/, $userinput);
                if (($filetype eq "hosts") || ($filetype eq "domain")) {
                   if($script ne "") {
-                     Reply($client,"ok\n",$userinput);       # DEBUG: Call EditFile here.
+		      Reply($client, EditFile($userinput));
                   } else {
                      Reply($client,"refused\n",$userinput);
                   }