mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-09-27 14:39:01 +00:00
structering the core some more
This commit is contained in:
parent
138eeb350f
commit
b3212c0786
@ -15,7 +15,8 @@ set( LSYNCD_SRC
|
|||||||
core/core.c
|
core/core.c
|
||||||
core/log.c
|
core/log.c
|
||||||
core/pipe.c
|
core/pipe.c
|
||||||
core/smem.c
|
core/mem.c
|
||||||
|
core/util.c
|
||||||
mantle.c
|
mantle.c
|
||||||
default.c
|
default.c
|
||||||
)
|
)
|
||||||
|
79
core/core.c
79
core/core.c
@ -38,7 +38,8 @@
|
|||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "smem.h"
|
#include "mem.h"
|
||||||
|
#include "util.h"
|
||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
|
|
||||||
#ifdef WITH_INOTIFY
|
#ifdef WITH_INOTIFY
|
||||||
@ -164,30 +165,6 @@ sig_handler( int sig )
|
|||||||
#endif
|
#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
|
:: Helper Routines
|
||||||
'::::::::::::::::::::*/
|
'::::::::::::::::::::*/
|
||||||
@ -212,58 +189,6 @@ static int mci = 0;
|
|||||||
static int callError;
|
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
|
:: Observances
|
||||||
':::::::::::::::::*/
|
':::::::::::::::::*/
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
|
||||||
#include "smem.h"
|
#include "mem.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "inotify.h"
|
#include "inotify.h"
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "smem.h"
|
#include "mem.h"
|
||||||
#include "lsyncd.h"
|
#include "lsyncd.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
| smem.c from Lsyncd - Live (Mirror) Syncing Demon
|
| mem.c from Lsyncd - Live (Mirror) Syncing Demon
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
| Simple "secured" memory management.
|
| Simple "secured" memory management.
|
||||||
@ -19,7 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "lsyncd.h"
|
#include "lsyncd.h"
|
||||||
#include "smem.h"
|
#include "mem.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
/*
|
/*
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
| smem.h from Lsyncd - Live (Mirror) Syncing Demon
|
| mem.h from Lsyncd - Live (Mirror) Syncing Demon
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
| Simple "secured" memory management.
|
| Simple "secured" memory management.
|
||||||
@ -9,8 +9,8 @@
|
|||||||
| Authors: Axel Kittenberger <axkibe@gmail.com>
|
| Authors: Axel Kittenberger <axkibe@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LSYNCD_SMEM_H
|
#ifndef LSYNCD_MEM_H
|
||||||
#define LSYNCD_SMEM_H
|
#define LSYNCD_MEM_H
|
||||||
|
|
||||||
extern void * s_calloc( size_t nmemb, size_t size );
|
extern void * s_calloc( size_t nmemb, size_t size );
|
||||||
extern void * s_malloc( size_t size );
|
extern void * s_malloc( size_t size );
|
@ -20,7 +20,7 @@
|
|||||||
//#include <lauxlib.h>
|
//#include <lauxlib.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "smem.h"
|
#include "mem.h"
|
||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user