structering the core some more

This commit is contained in:
Axel Kittenberger 2018-03-27 09:09:07 +02:00
parent 138eeb350f
commit b3212c0786
7 changed files with 12 additions and 86 deletions

View File

@ -15,7 +15,8 @@ set( LSYNCD_SRC
core/core.c
core/log.c
core/pipe.c
core/smem.c
core/mem.c
core/util.c
mantle.c
default.c
)

View File

@ -38,7 +38,8 @@
#include <lauxlib.h>
#include "log.h"
#include "smem.h"
#include "mem.h"
#include "util.h"
#include "pipe.h"
#ifdef WITH_INOTIFY
@ -164,30 +165,6 @@ sig_handler( int sig )
#endif
/*
| Returns the absolute path of a path.
|
| This is a wrapper to various C-Library differences.
*/
char *
get_realpath( const char * rpath )
{
// uses c-library to get the absolute path
#ifdef __GLIBC__
// in case of GLIBC the task is easy.
return realpath( rpath, NULL );
#else
# warning having to use old style realpath()
// otherwise less so and requires PATH_MAX limit
char buf[ PATH_MAX] ;
char *asw = realpath( rpath, buf );
if( !asw ) return NULL;
return s_strdup( asw );
#endif
}
/*:::::::::::::::::::.
:: Helper Routines
'::::::::::::::::::::*/
@ -212,58 +189,6 @@ static int mci = 0;
static int callError;
/*
| Sets the close-on-exit flag of a file descriptor.
*/
extern void
close_exec_fd( int fd )
{
int flags;
flags = fcntl( fd, F_GETFD );
if( flags == -1 )
{
logstring( "Error", "cannot get descriptor flags!" );
exit( -1 );
}
flags |= FD_CLOEXEC;
if( fcntl( fd, F_SETFD, flags ) == -1 )
{
logstring( "Error", "cannot set descripptor flags!" );
exit( -1 );
}
}
/*
| Sets the non-blocking flag of a file descriptor.
*/
extern void
non_block_fd( int fd )
{
int flags;
flags = fcntl( fd, F_GETFL );
if( flags == -1 )
{
logstring( "Error", "cannot get status flags!" );
exit( -1 );
}
flags |= O_NONBLOCK;
if( fcntl( fd, F_SETFL, flags ) == -1 )
{
logstring( "Error", "cannot set status flags!" );
exit( -1 );
}
}
/*::::::::::::::::.
:: Observances
':::::::::::::::::*/

View File

@ -36,7 +36,7 @@
#include <lualib.h>
#include <lauxlib.h>
#include "smem.h"
#include "mem.h"
#include "log.h"
#include "inotify.h"

View File

@ -27,7 +27,7 @@
#include <lauxlib.h>
#include "log.h"
#include "smem.h"
#include "mem.h"
#include "lsyncd.h"

View File

@ -1,5 +1,5 @@
/*
| smem.c from Lsyncd - Live (Mirror) Syncing Demon
| mem.c from Lsyncd - Live (Mirror) Syncing Demon
|
|
| Simple "secured" memory management.
@ -19,7 +19,7 @@
#include <string.h>
#include "lsyncd.h"
#include "smem.h"
#include "mem.h"
#include "log.h"
/*

View File

@ -1,5 +1,5 @@
/*
| smem.h from Lsyncd - Live (Mirror) Syncing Demon
| mem.h from Lsyncd - Live (Mirror) Syncing Demon
|
|
| Simple "secured" memory management.
@ -9,8 +9,8 @@
| Authors: Axel Kittenberger <axkibe@gmail.com>
*/
#ifndef LSYNCD_SMEM_H
#define LSYNCD_SMEM_H
#ifndef LSYNCD_MEM_H
#define LSYNCD_MEM_H
extern void * s_calloc( size_t nmemb, size_t size );
extern void * s_malloc( size_t size );

View File

@ -20,7 +20,7 @@
//#include <lauxlib.h>
#include "log.h"
#include "smem.h"
#include "mem.h"
#include "pipe.h"