diff --git a/build/Debug/GNU-Linux/ftpCommandElaborate.o b/build/Debug/GNU-Linux/ftpCommandElaborate.o
index d20347e..c703aa2 100644
Binary files a/build/Debug/GNU-Linux/ftpCommandElaborate.o and b/build/Debug/GNU-Linux/ftpCommandElaborate.o differ
diff --git a/build/Debug/GNU-Linux/ftpData.o b/build/Debug/GNU-Linux/ftpData.o
index 9b146b2..773138c 100644
Binary files a/build/Debug/GNU-Linux/ftpData.o and b/build/Debug/GNU-Linux/ftpData.o differ
diff --git a/build/Debug/GNU-Linux/ftpServer.o b/build/Debug/GNU-Linux/ftpServer.o
index 4de529e..a41a1f9 100644
Binary files a/build/Debug/GNU-Linux/ftpServer.o and b/build/Debug/GNU-Linux/ftpServer.o differ
diff --git a/dist/Debug/GNU-Linux/uftp b/dist/Debug/GNU-Linux/uftp
index 7ea5827..8abb718 100755
Binary files a/dist/Debug/GNU-Linux/uftp and b/dist/Debug/GNU-Linux/uftp differ
diff --git a/ftpCommandElaborate.c b/ftpCommandElaborate.c
index b0ea5f6..0ac986a 100644
--- a/ftpCommandElaborate.c
+++ b/ftpCommandElaborate.c
@@ -425,6 +425,87 @@ int parseCommandRest(clientDataType *theClientData)
return 1;
}
+int parseCommandMkd(clientDataType *theClientData)
+{
+ int returnStatus = 0;
+ char *theDirectoryFilename;
+ dynamicStringDataType theResponse;
+ dynamicStringDataType mkdFileName;
+
+ theDirectoryFilename = getFtpCommandArg("MKD", theClientData->theCommandReceived);
+
+
+ cleanDynamicStringDataType(&theResponse, 1);
+ cleanDynamicStringDataType(&mkdFileName, 1);
+
+ if (theDirectoryFilename[0] == '/')
+ {
+ setDynamicStringDataType(&mkdFileName, theDirectoryFilename, strlen(theDirectoryFilename));
+ }
+ else
+ {
+ setDynamicStringDataType(&mkdFileName, theClientData->login.absolutePath.text, theClientData->login.absolutePath.textLen);
+ appendToDynamicStringDataType(&mkdFileName, "/", 1);
+ appendToDynamicStringDataType(&mkdFileName, theDirectoryFilename, strlen(theDirectoryFilename));
+ }
+
+ if (strlen(theDirectoryFilename) > 0)
+ {
+ printf("\nThe directory to make is: %s", mkdFileName.text);
+ returnStatus = mkdir(mkdFileName.text, S_IRWXU | S_IRWXG | S_IRWXO);
+ }
+
+ setDynamicStringDataType(&theResponse, "257 \"", strlen("257 \""));
+ appendToDynamicStringDataType(&theResponse, theDirectoryFilename, strlen(theDirectoryFilename));
+ appendToDynamicStringDataType(&theResponse, "\" : The directory was successfully created\r\n", strlen("\" : The directory was successfully created\r\n"));
+
+ write(theClientData->socketDescriptor, theResponse.text, theResponse.textLen);
+
+ cleanDynamicStringDataType(&theResponse, 0);
+ cleanDynamicStringDataType(&mkdFileName, 0);
+
+ return 1;
+}
+
+
+int parseCommandRmd(clientDataType *theClientData)
+{
+ int returnStatus = 0;
+ char *theDirectoryFilename;
+ dynamicStringDataType theResponse;
+ dynamicStringDataType mkdFileName;
+
+ theDirectoryFilename = getFtpCommandArg("RMD", theClientData->theCommandReceived);
+
+ cleanDynamicStringDataType(&theResponse, 1);
+ cleanDynamicStringDataType(&mkdFileName, 1);
+
+ if (theDirectoryFilename[0] == '/')
+ {
+ setDynamicStringDataType(&mkdFileName, theDirectoryFilename, strlen(theDirectoryFilename));
+ }
+ else
+ {
+ setDynamicStringDataType(&mkdFileName, theClientData->login.absolutePath.text, theClientData->login.absolutePath.textLen);
+ appendToDynamicStringDataType(&mkdFileName, "/", 1);
+ appendToDynamicStringDataType(&mkdFileName, theDirectoryFilename, strlen(theDirectoryFilename));
+ }
+
+ if (strlen(theDirectoryFilename) > 0)
+ {
+ printf("\nThe directory to make is: %s", mkdFileName.text);
+ returnStatus = rmdir(mkdFileName.text);
+ }
+
+ setDynamicStringDataType(&theResponse, "250 The directory was successfully removed\r\n", strlen("250 The directory was successfully removed\r\n"));
+ write(theClientData->socketDescriptor, theResponse.text, theResponse.textLen);
+
+ cleanDynamicStringDataType(&theResponse, 0);
+ cleanDynamicStringDataType(&mkdFileName, 0);
+
+ return 1;
+}
+
int parseCommandCdup(clientDataType *theClientData)
{
int i;
@@ -500,5 +581,18 @@ int writeRetrFile(char * theFilename, int thePasvSocketConnection, int startFrom
printf("\n Bytes written: %d", toReturn);
fclose(retrFP);
+ return toReturn;
+}
+
+
+char *getFtpCommandArg(char * theCommand, char *theCommandString)
+{
+ char *toReturn = theCommandString + strlen(theCommand);
+
+ while (toReturn[0] == ' ')
+ {
+ toReturn += 1;
+ }
+
return toReturn;
}
\ No newline at end of file
diff --git a/ftpCommandsElaborate.h b/ftpCommandsElaborate.h
index 2eb4578..451c95d 100644
--- a/ftpCommandsElaborate.h
+++ b/ftpCommandsElaborate.h
@@ -33,10 +33,14 @@ int parseCommandTypeI(clientDataType *theClientData);
int parseCommandPasv(ftpDataType * data, int socketId);
int parseCommandList(ftpDataType * data, int socketId);
int parseCommandRetr(ftpDataType * data, int socketId);
+int parseCommandMkd(clientDataType *theClientData);
+int parseCommandRmd(clientDataType *theClientData);
int parseCommandStor(ftpDataType * data, int socketId);
int parseCommandCwd(clientDataType *theClientData);
int parseCommandCdup(clientDataType *theClientData);
+
int writeRetrFile(char * theFilename, int thePasvSocketConnection, int startFrom);
+char *getFtpCommandArg(char * theCommand, char *theCommandString);
#ifdef __cplusplus
}
diff --git a/ftpData.c b/ftpData.c
index d5625ee..ad75218 100644
--- a/ftpData.c
+++ b/ftpData.c
@@ -65,7 +65,6 @@ void setDynamicStringDataType(dynamicStringDataType *dynamicString, char *theStr
}
}
-
void appendToDynamicStringDataType(dynamicStringDataType *dynamicString, char *theString, int stringLen)
{
printf("\n Appending in %s --> %s", dynamicString->text, theString);
diff --git a/ftpServer.c b/ftpServer.c
index baf639f..0973ba8 100644
--- a/ftpServer.c
+++ b/ftpServer.c
@@ -329,7 +329,7 @@ void runFtpServer(void)
FD_ZERO(&rset);
FD_ZERO(&wset);
FD_ZERO(&eset);
-
+
FD_ZERO(&rsetTemp);
FD_ZERO(&wsetTemp);
FD_ZERO(&esetTemp);
@@ -668,7 +668,84 @@ static int processCommand(int processingElement)
printf("\nSTOR COMMAND RECEIVED");
toReturn = parseCommandStor(&ftpData, processingElement);
}
-
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "MKD", strlen("MKD")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "mkd", strlen("mkd")) == 0)
+ {
+ printf("\nMKD command received");
+ toReturn = parseCommandMkd(&ftpData.clients[processingElement]);
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "ABOR", strlen("ABOR")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "abor", strlen("abor")) == 0)
+ {
+ printf("\nABOR command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "DELE", strlen("DELE")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "dele", strlen("dele")) == 0)
+ {
+ printf("\nDELE command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "MTDM", strlen("MTDM")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "mtdm", strlen("mtdm")) == 0)
+ {
+ printf("\nMTDM command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "NLST", strlen("NLST")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "nlst", strlen("nlst")) == 0)
+ {
+ printf("\nNLST command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "PORT", strlen("PORT")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "port", strlen("port")) == 0)
+ {
+ printf("\nPORT command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "QUIT", strlen("QUIT")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "quit", strlen("quit")) == 0)
+ {
+ printf("\nQUIT command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "RMD", strlen("RMD")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "rmd", strlen("rmd")) == 0)
+ {
+ printf("\nRMD command received");
+ toReturn = parseCommandRmd(&ftpData.clients[processingElement]);
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "RNFR", strlen("RNFR")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "rnfr", strlen("rnfr")) == 0)
+ {
+ printf("\nRNFR command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "RNTO", strlen("RNTO")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "rnto", strlen("rnto")) == 0)
+ {
+ printf("\nRNTO command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "SIZE", strlen("SIZE")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "size", strlen("size")) == 0)
+ {
+ printf("\nSIZE command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "APPE", strlen("APPE")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "appe", strlen("appe")) == 0)
+ {
+ printf("\nAPPE command received");
+ //To implement
+ }
+ else if(strncmp(ftpData.clients[processingElement].theCommandReceived, "NOOP", strlen("NOOP")) == 0 ||
+ strncmp(ftpData.clients[processingElement].theCommandReceived, "noop", strlen("noop")) == 0)
+ {
+ printf("\nNOOP command received");
+ //To implement
+ }
//REST COMMAND
//REST 0
//350 Restarting at 0
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
index aef7ea3..029e357 100644
--- a/nbproject/private/private.xml
+++ b/nbproject/private/private.xml
@@ -6,6 +6,8 @@
-
+
+ file:/home/ugo/NetBeansProjects/uFTP/ftpCommandsElaborate.h
+