mirror of
https://github.com/kingk85/uFTP.git
synced 2025-07-17 09:16:11 +03:00
Some refactoring
This commit is contained in:
@ -36,8 +36,8 @@ start:
|
||||
end:
|
||||
@echo Build process end
|
||||
|
||||
uFTP: uFTP.c fileManagement.o configRead.o logFunctions.o ftpCommandElaborate.o ftpData.o ftpServer.o daemon.o
|
||||
@$(CC) uFTP.c $(LIBPATH)dynamicVectors.o $(LIBPATH)fileManagement.o $(LIBPATH)configRead.o $(LIBPATH)logFunctions.o $(LIBPATH)ftpCommandElaborate.o $(LIBPATH)ftpData.o $(LIBPATH)ftpServer.o $(LIBPATH)daemon.o -o $(OUTPATH)uFTP -lpthread
|
||||
uFTP: uFTP.c fileManagement.o configRead.o logFunctions.o ftpCommandElaborate.o ftpData.o ftpServer.o daemon.o signals.o
|
||||
@$(CC) uFTP.c $(LIBPATH)dynamicVectors.o $(LIBPATH)fileManagement.o $(LIBPATH)configRead.o $(LIBPATH)logFunctions.o $(LIBPATH)ftpCommandElaborate.o $(LIBPATH)ftpData.o $(LIBPATH)ftpServer.o $(LIBPATH)daemon.o $(LIBPATH)signals.o -o $(OUTPATH)uFTP -lpthread
|
||||
|
||||
daemon.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)daemon.c -o $(LIBPATH)daemon.o
|
||||
@ -51,6 +51,9 @@ configRead.o: dynamicVectors.o fileManagement.o
|
||||
fileManagement.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)fileManagement.c -o $(LIBPATH)fileManagement.o
|
||||
|
||||
signals.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)signals.c -o $(LIBPATH)signals.o
|
||||
|
||||
logFunctions.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)logFunctions.c -o $(LIBPATH)logFunctions.o
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@ build/Debug/GNU-Linux/ftpServer.o: ftpServer.c library/dynamicVectors.h \
|
||||
library/fileManagement.h library/dynamicVectors.h ftpServer.h ftpData.h \
|
||||
library/dynamicVectors.h library/configRead.h library/dynamicVectors.h \
|
||||
ftpCommandsElaborate.h library/fileManagement.h library/logFunctions.h \
|
||||
library/daemon.h
|
||||
library/daemon.h library/signals.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
@ -27,3 +27,5 @@ library/fileManagement.h:
|
||||
library/logFunctions.h:
|
||||
|
||||
library/daemon.h:
|
||||
|
||||
library/signals.h:
|
||||
|
Binary file not shown.
BIN
build/Debug/GNU-Linux/library/signals.o
Normal file
BIN
build/Debug/GNU-Linux/library/signals.o
Normal file
Binary file not shown.
11
build/Debug/GNU-Linux/library/signals.o.d
Normal file
11
build/Debug/GNU-Linux/library/signals.o.d
Normal file
@ -0,0 +1,11 @@
|
||||
build/Debug/GNU-Linux/library/signals.o: library/signals.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/../ftpServer.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpServer.h:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/modules/signals.o
Normal file
BIN
build/modules/signals.o
Normal file
Binary file not shown.
BIN
build/uFTP
Executable file
BIN
build/uFTP
Executable file
Binary file not shown.
1
dist/Debug/GNU-Linux/config.cfg
vendored
1
dist/Debug/GNU-Linux/config.cfg
vendored
@ -1 +0,0 @@
|
||||
../../../config.cfg
|
BIN
dist/Debug/GNU-Linux/uftp
vendored
BIN
dist/Debug/GNU-Linux/uftp
vendored
Binary file not shown.
1
dist/Debug/GNU-Linux/uftpd.cfg
vendored
Symbolic link
1
dist/Debug/GNU-Linux/uftpd.cfg
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../../../uftpd.cfg
|
15
ftpServer.c
15
ftpServer.c
@ -29,6 +29,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -47,12 +48,8 @@
|
||||
#include "library/logFunctions.h"
|
||||
#include "library/configRead.h"
|
||||
#include "library/daemon.h"
|
||||
#include "library/signals.h"
|
||||
|
||||
/* Catch Signal Handler functio */
|
||||
void signal_callback_handler(int signum){
|
||||
|
||||
printf("Caught signal SIGPIPE %d\n",signum);
|
||||
}
|
||||
|
||||
static ftpDataType ftpData;
|
||||
|
||||
@ -366,14 +363,12 @@ void *connectionWorkerHandle(void * socketId)
|
||||
|
||||
void runFtpServer(void)
|
||||
{
|
||||
DYNV_VectorGenericDataType configParameters;
|
||||
fd_set rset, wset, eset, rsetAll, wsetAll, esetAll;
|
||||
static int processingSock = 0;
|
||||
static int maxSocketFD = 0;
|
||||
|
||||
DYNV_VectorGeneric_Init(&configParameters);
|
||||
readConfigurationFile("./config.cfg", &configParameters);
|
||||
parseConfigurationFile(&ftpData.ftpParameters, &configParameters);
|
||||
/*Read the configuration file */
|
||||
configurationRead(&ftpData.ftpParameters);
|
||||
|
||||
if (ftpData.ftpParameters.singleInstanceModeOn == 1)
|
||||
{
|
||||
@ -385,13 +380,13 @@ void runFtpServer(void)
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fork the process daemon mode */
|
||||
if (ftpData.ftpParameters.daemonModeOn == 1)
|
||||
{
|
||||
daemonize("uFTP");
|
||||
}
|
||||
|
||||
signalHandlerInstall();
|
||||
initFtpData();
|
||||
|
||||
//Socket main creator
|
||||
|
@ -22,8 +22,6 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -34,9 +32,58 @@
|
||||
|
||||
#define PARAMETER_SIZE_LIMIT 1024
|
||||
|
||||
int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVector)
|
||||
{
|
||||
|
||||
/* Public Functions */
|
||||
int searchUser(char *name, DYNV_VectorGenericDataType *usersVector)
|
||||
{
|
||||
int returnCode = -1;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i <usersVector->Size; i++)
|
||||
{
|
||||
if (strcmp(name, ((usersParameters_DataType *) usersVector->Data[i])->name) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
void configurationRead(ftpParameters_DataType *ftpParameters)
|
||||
{
|
||||
int returnCode = 0;
|
||||
DYNV_VectorGenericDataType configParameters;
|
||||
DYNV_VectorGeneric_Init(&configParameters);
|
||||
|
||||
if (FILE_IsFile(LOCAL_CONFIGURATION_FILENAME) == 1)
|
||||
{
|
||||
printf("\nReading configuration from \n -> %s", LOCAL_CONFIGURATION_FILENAME);
|
||||
returnCode = readConfigurationFile(LOCAL_CONFIGURATION_FILENAME, &configParameters);
|
||||
}
|
||||
else if (FILE_IsFile(DEFAULT_CONFIGURATION_FILENAME) == 1)
|
||||
{
|
||||
printf("\nReading configuration from \n -> %s", DEFAULT_CONFIGURATION_FILENAME);
|
||||
returnCode = readConfigurationFile(DEFAULT_CONFIGURATION_FILENAME, &configParameters);
|
||||
}
|
||||
|
||||
if (returnCode == 1)
|
||||
{
|
||||
parseConfigurationFile(ftpParameters, &configParameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nError: could not read the configuration file located at: \n -> %s or at \n -> %s", DEFAULT_CONFIGURATION_FILENAME, LOCAL_CONFIGURATION_FILENAME);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*Private functions*/
|
||||
static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVector)
|
||||
{
|
||||
#define STATE_START 0
|
||||
#define STATE_NAME 1
|
||||
#define STATE_VALUE 2
|
||||
@ -146,7 +193,9 @@ int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVect
|
||||
{
|
||||
/* Value stored proceed to save */
|
||||
if (valueIndex > 0)
|
||||
{
|
||||
state = STATE_STORE;
|
||||
}
|
||||
else if (valueIndex == 0) /* No void value allowed*/
|
||||
{
|
||||
memset(name, 0, PARAMETER_SIZE_LIMIT);
|
||||
@ -191,21 +240,36 @@ int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVect
|
||||
nameIndex = 0;
|
||||
valueIndex = 0;
|
||||
state = STATE_START;
|
||||
printf("\nParameter read: %s = %s", parameter.name, parameter.value);
|
||||
//printf("\nParameter read: %s = %s", parameter.name, parameter.value);
|
||||
parametersVector->PushBack(parametersVector, ¶meter, sizeof(parameter_DataType));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* che if there is a value to store */
|
||||
if (state == STATE_VALUE &&
|
||||
valueIndex > 0)
|
||||
{
|
||||
parameter_DataType parameter;
|
||||
parameter.name = malloc(nameIndex+1);
|
||||
parameter.value = malloc(valueIndex+1);
|
||||
strcpy(parameter.name, name);
|
||||
strcpy(parameter.value, value);
|
||||
parameter.name[nameIndex] = '\0';
|
||||
parameter.value[valueIndex] = '\0';
|
||||
memset(name, 0, PARAMETER_SIZE_LIMIT);
|
||||
memset(value, 0, PARAMETER_SIZE_LIMIT);
|
||||
nameIndex = 0;
|
||||
valueIndex = 0;
|
||||
//printf("\nParameter read: %s = %s", parameter.name, parameter.value);
|
||||
parametersVector->PushBack(parametersVector, ¶meter, sizeof(parameter_DataType));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
int searchParameter(char *name, DYNV_VectorGenericDataType *parametersVector)
|
||||
static int searchParameter(char *name, DYNV_VectorGenericDataType *parametersVector)
|
||||
{
|
||||
int returnCode = -1;
|
||||
int i = 0;
|
||||
@ -221,48 +285,39 @@ int searchParameter(char *name, DYNV_VectorGenericDataType *parametersVector)
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
int searchUser(char *name, DYNV_VectorGenericDataType *usersVector)
|
||||
static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGenericDataType *parametersVector)
|
||||
{
|
||||
int returnCode = -1;
|
||||
int i = 0;
|
||||
int searchIndex, userIndex;
|
||||
|
||||
for (i = 0; i <usersVector->Size; i++)
|
||||
{
|
||||
if (strcmp(name, ((usersParameters_DataType *) usersVector->Data[i])->name) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
char userX[PARAMETER_SIZE_LIMIT],
|
||||
passwordX[PARAMETER_SIZE_LIMIT],
|
||||
homeX[PARAMETER_SIZE_LIMIT];
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGenericDataType *parametersVector)
|
||||
{
|
||||
int searchIndex;
|
||||
int userIndex;
|
||||
char userX[PARAMETER_SIZE_LIMIT], passwordX[PARAMETER_SIZE_LIMIT], homeX[PARAMETER_SIZE_LIMIT];
|
||||
printf("\nReading configuration settings..");
|
||||
|
||||
searchIndex = searchParameter("MAXIMUM_ALLOWED_FTP_CONNECTION", parametersVector);
|
||||
if (searchIndex != -1)
|
||||
{
|
||||
ftpParameters->maxClients = atoi(((parameter_DataType *) parametersVector->Data[searchIndex])->value);
|
||||
printf("\nFtp maximum allowed clients: %d", ftpParameters->maxClients);
|
||||
printf("\nMAXIMUM_ALLOWED_FTP_CONNECTION: %d", ftpParameters->maxClients);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpParameters->maxClients = 10;
|
||||
printf("\nMAXIMUM_ALLOWED_FTP_CONNECTION parameter not found in the configuration file, using the default value: %d", ftpParameters->maxClients);
|
||||
}
|
||||
|
||||
searchIndex = searchParameter("FTP_PORT", parametersVector);
|
||||
if (searchIndex != -1)
|
||||
{
|
||||
ftpParameters->port = atoi(((parameter_DataType *) parametersVector->Data[searchIndex])->value);
|
||||
printf("\nFtp port: %d", ftpParameters->port);
|
||||
printf("\nFTP_PORT: %d", ftpParameters->port);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpParameters->port = 21;
|
||||
printf("\nFTP_PORT parameter not found in the configuration file, using the default value: %d", ftpParameters->maxClients);
|
||||
}
|
||||
|
||||
|
||||
@ -275,6 +330,12 @@ int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGen
|
||||
|
||||
if(strcmp(((parameter_DataType *) parametersVector->Data[searchIndex])->value, "TRUE") == 0)
|
||||
ftpParameters->daemonModeOn = 1;
|
||||
|
||||
printf("\nDAEMON_MODE value: %d", ftpParameters->daemonModeOn);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nDAEMON_MODE parameter not found in the configuration file, using the default value: %d", ftpParameters->daemonModeOn);
|
||||
}
|
||||
|
||||
ftpParameters->singleInstanceModeOn = 0;
|
||||
@ -287,21 +348,22 @@ int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGen
|
||||
if(strcmp(((parameter_DataType *) parametersVector->Data[searchIndex])->value, "TRUE") == 0)
|
||||
ftpParameters->singleInstanceModeOn = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nSINGLE_INSTANCE parameter not found in the configuration file, using the default value: %d", ftpParameters->singleInstanceModeOn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ftpParameters->maximumIdleInactivity = 0;
|
||||
ftpParameters->maximumIdleInactivity = 3600;
|
||||
searchIndex = searchParameter("IDLE_MAX_TIMEOUT", parametersVector);
|
||||
if (searchIndex != -1)
|
||||
{
|
||||
ftpParameters->maximumIdleInactivity = atoi(((parameter_DataType *) parametersVector->Data[searchIndex])->value);
|
||||
printf("\nIDLE_MAX_TIMEOUT value: %d", ftpParameters->maximumIdleInactivity);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nIDLE_MAX_TIMEOUT parameter not found in the configuration file, using the default value: %d", ftpParameters->maximumIdleInactivity);
|
||||
}
|
||||
printf("\nftpParameters->maximumIdleInactivity: %d", ftpParameters->maximumIdleInactivity);
|
||||
|
||||
|
||||
printf("\nFtp singleInstanceModeOn: %d", ftpParameters->singleInstanceModeOn);
|
||||
printf("\nFtp daemonModeOn: %d", ftpParameters->daemonModeOn);
|
||||
|
||||
|
||||
searchIndex = searchParameter("FTP_SERVER_IP", parametersVector);
|
||||
if (searchIndex != -1)
|
||||
@ -310,7 +372,7 @@ int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGen
|
||||
&ftpParameters->ftpIpAddress[1],
|
||||
&ftpParameters->ftpIpAddress[2],
|
||||
&ftpParameters->ftpIpAddress[3]);
|
||||
printf("\nFtp ip address: %d.%d.%d.%d", ftpParameters->ftpIpAddress[0],
|
||||
printf("\nFTP_SERVER_IP value: %d.%d.%d.%d", ftpParameters->ftpIpAddress[0],
|
||||
ftpParameters->ftpIpAddress[1],
|
||||
ftpParameters->ftpIpAddress[2],
|
||||
ftpParameters->ftpIpAddress[3]);
|
||||
@ -321,21 +383,18 @@ int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGen
|
||||
ftpParameters->ftpIpAddress[1] = 0;
|
||||
ftpParameters->ftpIpAddress[2] = 0;
|
||||
ftpParameters->ftpIpAddress[3] = 1;
|
||||
printf("\nFTP_SERVER_IP parameter not found in the configuration file, listening on all available networks");
|
||||
}
|
||||
|
||||
printf("\nFtp port wait start: %d", ftpParameters->port);
|
||||
/* USER SETTINGS */
|
||||
userIndex = 0;
|
||||
|
||||
memset(userX, 0, PARAMETER_SIZE_LIMIT);
|
||||
memset(passwordX, 0, PARAMETER_SIZE_LIMIT);
|
||||
memset(homeX, 0, PARAMETER_SIZE_LIMIT);
|
||||
|
||||
DYNV_VectorGeneric_Init(&ftpParameters->usersVector);
|
||||
printf("\nFtp port xxx: %d", ftpParameters->port);
|
||||
while(1)
|
||||
{
|
||||
printf("\nFtp port start: %d", ftpParameters->port);
|
||||
int searchUserIndex, searchPasswordIndex, searchHomeIndex;
|
||||
usersParameters_DataType userData;
|
||||
|
||||
@ -368,17 +427,13 @@ int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGen
|
||||
userData.password[strlen(((parameter_DataType *) parametersVector->Data[searchPasswordIndex])->value)] = '\0';
|
||||
userData.homePath[strlen(((parameter_DataType *) parametersVector->Data[searchHomeIndex])->value)] = '\0';
|
||||
|
||||
printf("\n\nAdding user");
|
||||
printf("\nUser parameter found");
|
||||
printf("\nName: %s", userData.name);
|
||||
printf("\nPassword: %s", userData.password);
|
||||
printf("\nHomePath: %s", userData.homePath);
|
||||
|
||||
ftpParameters->usersVector.PushBack(&ftpParameters->usersVector, &userData, sizeof(usersParameters_DataType));
|
||||
printf("\nFtp port end: %d", ftpParameters->port);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
@ -31,6 +31,11 @@ extern "C" {
|
||||
|
||||
#include "dynamicVectors.h"
|
||||
|
||||
#define DEFAULT_CONFIGURATION_FILENAME "/etc/uftpd.cfg"
|
||||
#define LOCAL_CONFIGURATION_FILENAME "./uftpd.cfg"
|
||||
|
||||
|
||||
/* Data structures */
|
||||
struct parameter
|
||||
{
|
||||
char* name;
|
||||
@ -55,10 +60,15 @@ struct ftpParameters
|
||||
int maximumIdleInactivity;
|
||||
} typedef ftpParameters_DataType;
|
||||
|
||||
int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVector);
|
||||
int searchParameter(char *name, DYNV_VectorGenericDataType *parametersVector);
|
||||
|
||||
/*Public functions */
|
||||
int searchUser(char *name, DYNV_VectorGenericDataType *usersVector);
|
||||
int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGenericDataType *parametersVector);
|
||||
void configurationRead(ftpParameters_DataType *ftpParameters);
|
||||
|
||||
/* Private Functions */
|
||||
static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_VectorGenericDataType *parametersVector);
|
||||
static int searchParameter(char *name, DYNV_VectorGenericDataType *parametersVector);
|
||||
static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVector);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
38
library/signals.c
Normal file
38
library/signals.c
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2018 Ugo Cirmignani
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include "../ftpServer.h"
|
||||
|
||||
|
||||
/* Catch Signal Handler functio */
|
||||
void signal_callback_handler(int signum){
|
||||
|
||||
printf("Caught signal SIGPIPE %d\n",signum);
|
||||
}
|
||||
|
||||
void signalHandlerInstall(void)
|
||||
{
|
||||
signal(SIGPIPE, signal_callback_handler);
|
||||
}
|
47
library/signals.h
Normal file
47
library/signals.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2018 Ugo Cirmignani
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: signals.h
|
||||
* Author: ugo
|
||||
*
|
||||
* Created on 24 febbraio 2018, 19.15
|
||||
*/
|
||||
|
||||
#ifndef SIGNALS_H
|
||||
#define SIGNALS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void signalHandlerInstall(void);
|
||||
void signal_callback_handler(int signum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SIGNALS_H */
|
||||
|
@ -43,6 +43,7 @@ OBJECTFILES= \
|
||||
${OBJECTDIR}/library/dynamicVectors.o \
|
||||
${OBJECTDIR}/library/fileManagement.o \
|
||||
${OBJECTDIR}/library/logFunctions.o \
|
||||
${OBJECTDIR}/library/signals.o \
|
||||
${OBJECTDIR}/uFTP.o
|
||||
|
||||
|
||||
@ -110,6 +111,11 @@ ${OBJECTDIR}/library/logFunctions.o: library/logFunctions.c
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
|
||||
|
||||
${OBJECTDIR}/library/signals.o: library/signals.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/signals.o library/signals.c
|
||||
|
||||
${OBJECTDIR}/uFTP.o: uFTP.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
|
@ -43,6 +43,7 @@ OBJECTFILES= \
|
||||
${OBJECTDIR}/library/dynamicVectors.o \
|
||||
${OBJECTDIR}/library/fileManagement.o \
|
||||
${OBJECTDIR}/library/logFunctions.o \
|
||||
${OBJECTDIR}/library/signals.o \
|
||||
${OBJECTDIR}/uFTP.o
|
||||
|
||||
|
||||
@ -110,6 +111,11 @@ ${OBJECTDIR}/library/logFunctions.o: library/logFunctions.c
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
|
||||
|
||||
${OBJECTDIR}/library/signals.o: library/signals.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/signals.o library/signals.c
|
||||
|
||||
${OBJECTDIR}/uFTP.o: uFTP.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
|
@ -9,6 +9,7 @@
|
||||
<itemPath>library/dynamicVectors.h</itemPath>
|
||||
<itemPath>library/fileManagement.h</itemPath>
|
||||
<itemPath>library/logFunctions.h</itemPath>
|
||||
<itemPath>library/signals.h</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>library/daemon.h</itemPath>
|
||||
<itemPath>ftpCommandsElaborate.h</itemPath>
|
||||
@ -29,14 +30,15 @@
|
||||
<itemPath>library/dynamicVectors.c</itemPath>
|
||||
<itemPath>library/fileManagement.c</itemPath>
|
||||
<itemPath>library/logFunctions.c</itemPath>
|
||||
<itemPath>library/signals.c</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>MakeFileGeneric</itemPath>
|
||||
<itemPath>config.cfg</itemPath>
|
||||
<itemPath>ftpCommandElaborate.c</itemPath>
|
||||
<itemPath>ftpData.c</itemPath>
|
||||
<itemPath>ftpServer.c</itemPath>
|
||||
<itemPath>todo.txt</itemPath>
|
||||
<itemPath>uFTP.c</itemPath>
|
||||
<itemPath>uftpd.cfg</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="TestFiles"
|
||||
displayName="Test Files"
|
||||
@ -76,8 +78,6 @@
|
||||
</compileType>
|
||||
<item path="MakeFileGeneric" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="config.cfg" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandElaborate.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandsElaborate.h" ex="false" tool="3" flavor2="0">
|
||||
@ -112,10 +112,16 @@
|
||||
</item>
|
||||
<item path="library/logFunctions.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="todo.txt" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="uFTP.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="uftpd.cfg" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
</conf>
|
||||
<conf name="Release" type="1">
|
||||
<toolsSet>
|
||||
@ -139,8 +145,6 @@
|
||||
</compileType>
|
||||
<item path="MakeFileGeneric" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="config.cfg" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandElaborate.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandsElaborate.h" ex="false" tool="3" flavor2="0">
|
||||
@ -175,10 +179,16 @@
|
||||
</item>
|
||||
<item path="library/logFunctions.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="todo.txt" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="uFTP.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="uftpd.cfg" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
||||
|
@ -7,7 +7,14 @@
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/configRead.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpData.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/signals.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/signals.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpServer.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/uFTP.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/MakeFileGeneric</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpData.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/configRead.c</file>
|
||||
</group>
|
||||
</open-files>
|
||||
|
3
uFTP.c
3
uFTP.c
@ -26,13 +26,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "ftpServer.h"
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGPIPE, signal_callback_handler);
|
||||
|
||||
runFtpServer();
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
Reference in New Issue
Block a user