removed macosx code
This commit is contained in:
parent
02278e3f8f
commit
ed56ef3bc7
|
|
@ -18,27 +18,19 @@ CFLAGS=-Wall -Wpointer-arith -Wunused-function -Wunused-but-set-parameter -Wunus
|
|||
LIB_A=psynclib.a
|
||||
UNAME_S := $(shell uname -s)
|
||||
UNAME_V := $(shell uname -v)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
CFLAGS += -DP_OS_LINUX -D_FILE_OFFSET_BITS=64
|
||||
ifneq (,$(findstring Debian,$(UNAME_V)))
|
||||
CFLAGS += -DP_OS_DEBIAN
|
||||
endif
|
||||
LAGS += -lssl -lcrypto -lfuse -lpthread -lsqlite3 -lzlib
|
||||
CFLAGS += -DP_OS_LINUX -D_FILE_OFFSET_BITS=64
|
||||
# XXX: remove, debian is not special
|
||||
ifneq (,$(findstring Debian,$(UNAME_V)))
|
||||
CFLAGS += -DP_OS_DEBIAN
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
CFLAGS += -DP_OS_MACOSX -I/usr/local/ssl/include/
|
||||
CFLAGS += -DP_OS_MACOSX -I/usr/local/include/osxfuse/
|
||||
LDFLAGS += -lssl -lcrypto -losxfuse -lsqlite3 -framework Cocoa -L/usr/local/ssl/lib
|
||||
endif
|
||||
|
||||
LDFLAGS += -lssl -lcrypto -lfuse -lpthread -lsqlite3 -lzlib
|
||||
|
||||
OBJ=pcompat.o psynclib.o plocks.o plibs.o pcallbacks.o pdiff.o pstatus.o papi.o ptimer.o\
|
||||
pupload.o pdownload.o pfolder.o psyncer.o ptasks.o psettings.o pnetlibs.o pcache.o\
|
||||
pscanner.o plist.o plocalscan.o plocalnotify.o pp2p.o pcrypto.o pssl.o pfileops.o\
|
||||
ptree.o ppassword.o prunratelimit.o pmemlock.o pnotifications.o pexternalstatus.o\
|
||||
publiclinks.o pbusinessaccount.o pcontacts.o poverlay.o poverlay_lin.o poverlay_mac.o\
|
||||
pcompression.o pasyncnet.o ppathstatus.o pdevice_monitor.o ptools.o
|
||||
publiclinks.o pbusinessaccount.o pcontacts.o poverlay.o poverlay_lin.o pcompression.o\
|
||||
pasyncnet.o ppathstatus.o pdevice_monitor.o ptools.o
|
||||
|
||||
OBJFS=pfs.o ppagecache.o pfsfolder.o pfstasks.o pfsupload.o pintervaltree.o pfsxattr.o\
|
||||
pcloudcrypto.o pfscrypto.o pcrc32c.o pfsstatic.o plocks.o
|
||||
|
|
|
|||
|
|
@ -44,12 +44,6 @@
|
|||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/attr.h>
|
||||
#include <SystemConfiguration/SystemConfiguration.h>
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_POSIX)
|
||||
|
||||
#include <sys/types.h>
|
||||
|
|
@ -118,7 +112,6 @@ PSYNC_THREAD const char *psync_thread_name="no name";
|
|||
static pthread_mutex_t socket_mutex=PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
const unsigned char psync_invalid_filename_chars[256]={
|
||||
#if defined(P_OS_LINUX)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||
|
|
@ -135,61 +128,11 @@ const unsigned char psync_invalid_filename_chars[256]={
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
#elif defined(P_OS_MACOSX)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
#else
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
#endif
|
||||
};
|
||||
|
||||
int psync_user_is_admin(){
|
||||
#if defined(P_OS_MACOSX)
|
||||
struct group *ag;
|
||||
int i;
|
||||
if (psync_uid==0)
|
||||
return 1;
|
||||
else if (psync_gids_cnt==0)
|
||||
return 0;
|
||||
ag=getgrnam("admin");
|
||||
if (!ag)
|
||||
return 0;
|
||||
for (i=0; i<psync_gids_cnt; i++)
|
||||
if (ag->gr_gid==psync_gids[i])
|
||||
return 1;
|
||||
int
|
||||
psync_user_is_admin(){
|
||||
return 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -459,11 +402,7 @@ psync_milisleep(uint64_t millisec){
|
|||
|
||||
time_t
|
||||
psync_time(){
|
||||
#if defined(P_OS_MACOSX)
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return tv.tv_sec;
|
||||
#elif defined(_POSIX_TIMERS) && _POSIX_TIMERS>0
|
||||
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS>0
|
||||
struct timespec ts;
|
||||
if (likely_log(clock_gettime(CLOCK_REALTIME, &ts)==0))
|
||||
return ts.tv_sec;
|
||||
|
|
@ -948,22 +887,6 @@ resolve_callback(void *h, void *ptr){
|
|||
psync_task_complete(h, res);
|
||||
}
|
||||
|
||||
#if defined(P_OS_MACOSX) && 0
|
||||
|
||||
#define PSYNC_HAS_PROXY_CODE
|
||||
|
||||
const void *
|
||||
get_value_cstr(CFDictionaryRef dict, const char *key) {
|
||||
CFStringRef str;
|
||||
const void *ret;
|
||||
str=CFStringCreateWithCString(NULL, key, kCFStringEncodingUTF8);
|
||||
ret=CFDictionaryGetValue(dict, str);
|
||||
CFRelease(str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(PSYNC_HAS_PROXY_CODE)
|
||||
static int
|
||||
recent_detect(){
|
||||
|
|
@ -1041,9 +964,6 @@ connect_socket_direct(const char *host, const char *port){
|
|||
#if defined(P_OS_LINUX)
|
||||
setsockopt(sock, SOL_TCP, TCP_NODELAY, (char *)&sock_opt, sizeof(sock_opt));
|
||||
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&sock_opt, sizeof(sock_opt));
|
||||
#elif defined(P_OS_MACOSX) || defined(P_OS_BSD)
|
||||
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&sock_opt, sizeof(sock_opt));
|
||||
setsockopt(sock, IPPROTO_TCP, TCP_KEEPALIVE, (char*)&sock_opt, sizeof(sock_opt));
|
||||
#endif
|
||||
#if defined(SOL_TCP)
|
||||
#if defined(TCP_KEEPCNT)
|
||||
|
|
@ -2127,10 +2047,6 @@ psync_list_dir(const char *path, psync_list_dir_callback callback, void *ptr){
|
|||
if (de->d_name[0]!='.' || (de->d_name[1]!=0 && (de->d_name[1]!='.' || de->d_name[2]!=0))){
|
||||
psync_strlcpy(cpath+pl, de->d_name, namelen+1);
|
||||
if (likely_log(!lstat(cpath, &pst.stat)) && (S_ISREG(pst.stat.st_mode) || S_ISDIR(pst.stat.st_mode))){
|
||||
#if defined(P_OS_MACOSX)
|
||||
if (pst.stat.st_flags&(UF_HIDDEN|UF_IMMUTABLE|SF_IMMUTABLE))
|
||||
continue;
|
||||
#endif
|
||||
pst.name=de->d_name;
|
||||
callback(ptr, &pst);
|
||||
}
|
||||
|
|
@ -2146,9 +2062,6 @@ err1:
|
|||
|
||||
int
|
||||
psync_list_dir_fast(const char *path, psync_list_dir_callback_fast callback, void *ptr){
|
||||
#if defined(P_OS_MACOSX)
|
||||
return psync_list_dir(path, callback, ptr);
|
||||
#elif defined(P_OS_POSIX)
|
||||
psync_pstat_fast pst;
|
||||
struct stat st;
|
||||
DIR *dh;
|
||||
|
|
@ -2204,7 +2117,6 @@ psync_list_dir_fast(const char *path, psync_list_dir_callback_fast callback, voi
|
|||
err1:
|
||||
psync_error=PERROR_LOCAL_FOLDER_NOT_FOUND;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t
|
||||
|
|
@ -2361,44 +2273,12 @@ psync_file_dup(psync_file_t fd){
|
|||
|
||||
int
|
||||
psync_file_set_creation(psync_file_t fd, time_t ctime){
|
||||
#if defined(P_OS_MACOSX)
|
||||
struct attrlist attr;
|
||||
struct timespec crtime;
|
||||
memset(&attr, 0, sizeof(attr));
|
||||
attr.bitmapcount=ATTR_BIT_MAP_COUNT;
|
||||
attr.commonattr=ATTR_CMN_CRTIME;
|
||||
crtime.tv_sec=ctime;
|
||||
crtime.tv_nsec=0;
|
||||
return fsetattrlist(fd, &attr, &crtime, sizeof(struct timespec), FSOPT_NOFOLLOW);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
psync_set_crtime_mtime(const char *path, time_t crtime, time_t mtime){
|
||||
#if defined(P_OS_MACOSX)
|
||||
if (crtime){
|
||||
struct attrlist attr;
|
||||
struct timespec crtimes;
|
||||
memset(&attr, 0, sizeof(attr));
|
||||
attr.bitmapcount=ATTR_BIT_MAP_COUNT;
|
||||
attr.commonattr=ATTR_CMN_CRTIME;
|
||||
crtimes.tv_sec=crtime;
|
||||
crtimes.tv_nsec=0;
|
||||
if (setattrlist(path, &attr, &crtimes, sizeof(struct timespec), FSOPT_NOFOLLOW))
|
||||
return -1;
|
||||
}
|
||||
if (mtime){
|
||||
struct timeval tm[2];
|
||||
tm[0].tv_sec=mtime;
|
||||
tm[0].tv_usec=0;
|
||||
tm[1].tv_sec=mtime;
|
||||
tm[1].tv_usec=0;
|
||||
return utimes(path, tm);
|
||||
}
|
||||
return 0;
|
||||
#elif defined(P_OS_POSIX)
|
||||
#if defined(P_OS_POSIX)
|
||||
if (mtime){
|
||||
struct timeval tm[2];
|
||||
tm[0].tv_sec=mtime;
|
||||
|
|
@ -2421,28 +2301,7 @@ psync_set_crtime_mtime(const char *path, time_t crtime, time_t mtime){
|
|||
|
||||
int
|
||||
psync_set_crtime_mtime_by_fd(psync_file_t fd, const char *path, time_t crtime, time_t mtime){
|
||||
#if defined(P_OS_MACOSX)
|
||||
if (crtime){
|
||||
struct attrlist attr;
|
||||
struct timespec crtimes;
|
||||
memset(&attr, 0, sizeof(attr));
|
||||
attr.bitmapcount=ATTR_BIT_MAP_COUNT;
|
||||
attr.commonattr=ATTR_CMN_CRTIME;
|
||||
crtimes.tv_sec=crtime;
|
||||
crtimes.tv_nsec=0;
|
||||
if (fsetattrlist(fd, &attr, &crtimes, sizeof(struct timespec), FSOPT_NOFOLLOW))
|
||||
return -1;
|
||||
}
|
||||
if (mtime){
|
||||
struct timeval tm[2];
|
||||
tm[0].tv_sec=mtime;
|
||||
tm[0].tv_usec=0;
|
||||
tm[1].tv_sec=mtime;
|
||||
tm[1].tv_usec=0;
|
||||
return futimes(fd, tm);
|
||||
}
|
||||
return 0;
|
||||
#elif defined(_BSD_SOURCE) || defined(P_OS_BSD)
|
||||
#if defined(_BSD_SOURCE) || defined(P_OS_BSD)
|
||||
if (mtime){
|
||||
struct timeval tm[2];
|
||||
tm[0].tv_sec=mtime;
|
||||
|
|
@ -2650,33 +2509,7 @@ psync_appname(){
|
|||
char *
|
||||
psync_deviceid(){
|
||||
char *device;
|
||||
#if defined(P_OS_MACOSX)
|
||||
struct utsname un;
|
||||
const char *ver;
|
||||
size_t len;
|
||||
char versbuff[64], modelname[256];
|
||||
int v;
|
||||
if (uname(&un))
|
||||
ver="Mac OS X";
|
||||
else{
|
||||
v=atoi(un.release);
|
||||
switch (v){
|
||||
case 16: ver="macOS 10.12 Sierra"; break;
|
||||
case 15: ver="OS X 10.11 El Capitan"; break;
|
||||
case 14: ver="OS X 10.10 Yosemite"; break;
|
||||
case 13: ver="OS X 10.9 Mavericks"; break;
|
||||
case 12: ver="OS X 10.8 Mountain Lion"; break;
|
||||
case 11: ver="OS X 10.7 Lion"; break;
|
||||
case 10: ver="OS X 10.6 Snow Leopard"; break;
|
||||
default: psync_slprintf(versbuff, sizeof(versbuff), "Mac/Darwin %s", un.release); ver=versbuff;
|
||||
}
|
||||
}
|
||||
len=sizeof(modelname);
|
||||
if (sysctlbyname("hw.model", modelname, &len, NULL, 0))
|
||||
psync_strlcpy(modelname, "Mac", sizeof(modelname));
|
||||
versbuff[sizeof(versbuff)-1]=0;
|
||||
device=psync_strcat(modelname, ", ", ver, NULL);
|
||||
#elif defined(P_OS_LINUX)
|
||||
#if defined(P_OS_LINUX)
|
||||
DIR *dh;
|
||||
struct dirent entry, *de;
|
||||
const char *hardware;
|
||||
|
|
@ -2709,18 +2542,11 @@ psync_deviceid(){
|
|||
return device;
|
||||
}
|
||||
|
||||
#define PSYNC_RUN_CMD "xdg-open" // XXX: verify this...
|
||||
|
||||
int
|
||||
psync_run_update_file(const char *path){
|
||||
#if defined(P_OS_LINUX) || defined(P_OS_MACOSX)
|
||||
#if defined(P_OS_LINUX)
|
||||
#if defined(P_OS_DEBIAN)
|
||||
#define PSYNC_RUN_CMD "/usr/lib/psyncgui/debinstall.sh"
|
||||
#else
|
||||
#define PSYNC_RUN_CMD "qapt-deb-installer"
|
||||
#endif
|
||||
#else
|
||||
#define PSYNC_RUN_CMD "open"
|
||||
#endif
|
||||
pid_t pid;
|
||||
debug(D_NOTICE, "running %s with "PSYNC_RUN_CMD, path);
|
||||
pid=fork();
|
||||
|
|
@ -2765,22 +2591,6 @@ psync_invalidate_os_cache_needed(){
|
|||
|
||||
extern int overlays_running;
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
|
||||
void
|
||||
psync_rebuild_icons(){
|
||||
int ret = 0;
|
||||
|
||||
if (!overlays_running)
|
||||
return;
|
||||
|
||||
debug(D_NOTICE, "Stopping finder plugin to refresh all icons.");
|
||||
ret = system("/bin/sh -c \"pluginkit -e ignore -i com.pcloud.pcloud.macos.pCloudFinderExt;sleep 0.5;pluginkit -e use -i com.pcloud.pcloud.macos.pCloudFinderExt;\"");
|
||||
debug(D_ERROR, "Reseting Finder Ext");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
psync_rebuild_icons(){
|
||||
if (!overlays_running)
|
||||
|
|
@ -2788,69 +2598,9 @@ psync_rebuild_icons(){
|
|||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
psync_invalidate_os_cache(const char *path){
|
||||
#if defined(P_OS_MACOSX)
|
||||
int pfds[2];
|
||||
pid_t pid;
|
||||
debug(D_NOTICE, "running osascript to refresh finder");
|
||||
if (unlikely(pipe(pfds))){
|
||||
debug(D_ERROR, "pipe failed");
|
||||
return -1;
|
||||
}
|
||||
pid=fork();
|
||||
if (unlikely(pid==-1)){
|
||||
close(pfds[0]);
|
||||
close(pfds[1]);
|
||||
debug(D_ERROR, "fork failed");
|
||||
return -1;
|
||||
}
|
||||
else if (pid){
|
||||
const char *cmd="tell application \"Finder\"\n\
|
||||
repeat with i from 1 to count of Finder windows\n\
|
||||
tell window i\n\
|
||||
try\n\
|
||||
update every item in every folder with necessity\n\
|
||||
end try\n\
|
||||
end tell\n\
|
||||
end repeat\n\
|
||||
end tell\n";
|
||||
int status;
|
||||
close(pfds[0]);
|
||||
status=strlen(cmd);
|
||||
if (write(pfds[1], cmd, status)!=status || close(pfds[1])!=0){
|
||||
debug(D_ERROR, "write to pipe failed");
|
||||
kill(pid, SIGKILL);
|
||||
waitpid(pid, &status, 0);
|
||||
return -1;
|
||||
}
|
||||
if (waitpid(pid, &status, 0)==0 && WIFEXITED(status) && WEXITSTATUS(status)==0){
|
||||
debug(D_NOTICE, "execution of osascript succeded");
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
debug(D_ERROR, "execution of osascript failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
int fd;
|
||||
close(pfds[1]);
|
||||
dup2(pfds[0], STDIN_FILENO);
|
||||
close(pfds[0]);
|
||||
fd=open("/dev/null", O_RDWR);
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
dup2(fd, STDERR_FILENO);
|
||||
close(fd);
|
||||
execl("/bin/sh", "/bin/sh", "-c", "osascript", NULL);
|
||||
debug(D_ERROR, "exec of \"/bin/sh -c osascript\" failed");
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
|
|||
|
|
@ -34,15 +34,8 @@
|
|||
|
||||
#include "pcompiler.h"
|
||||
|
||||
#if !defined(P_OS_LINUX) && !defined(P_OS_MACOSX) && !defined(P_OS_BSD) && !defined(P_OS_POSIX)
|
||||
#if defined(__ANDROID__)
|
||||
#define P_OS_LINUX
|
||||
#define P_OS_POSIX
|
||||
#elif defined(__APPLE__)
|
||||
#define P_OS_MACOSX
|
||||
#define P_OS_BSD
|
||||
#define P_OS_POSIX
|
||||
#elif defined(__CYGWIN__)
|
||||
#if !defined(P_OS_LINUX) && !defined(P_OS_BSD) && !defined(P_OS_POSIX)
|
||||
#if defined(__CYGWIN__)
|
||||
#define P_OS_POSIX
|
||||
#elif defined(__linux__)
|
||||
#define P_OS_LINUX
|
||||
|
|
@ -66,22 +59,16 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(P_OS_LINUX) || defined(P_OS_MACOSX) || defined(P_OS_BSD)) && !defined(P_OS_POSIX)
|
||||
#if (defined(P_OS_LINUX) || defined(P_OS_BSD)) && !defined(P_OS_POSIX)
|
||||
#define P_OS_POSIX
|
||||
#endif
|
||||
|
||||
#if !defined(P_OS_LINUX) && !defined(P_OS_MACOSX) && !defined(P_OS_POSIX)
|
||||
#if !defined(P_OS_LINUX) && !defined(P_OS_POSIX)
|
||||
#warning "You OS may not be supported, trying to build POSIX compatible source"
|
||||
#define P_OS_POSIX
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
|
||||
#define P_OS_ID 6
|
||||
|
||||
#define _DARWIN_USE_64_BIT_INODE
|
||||
|
||||
#elif defined(P_OS_LINUX)
|
||||
#if defined(P_OS_LINUX)
|
||||
|
||||
#define P_OS_ID 7
|
||||
|
||||
|
|
@ -168,17 +155,9 @@ typedef unsigned long psync_uint_t;
|
|||
#endif
|
||||
|
||||
#define psync_stat_inode(s) ((s)->st_ino)
|
||||
#if defined(P_OS_MACOSX)
|
||||
#define psync_stat_device(s) ((s)->st_dev>>24)
|
||||
#else
|
||||
#define psync_stat_device(s) ((s)->st_dev)
|
||||
#endif
|
||||
#define psync_stat_device_full(s) ((s)->st_dev)
|
||||
#if defined(P_OS_MACOSX)
|
||||
#define psync_deviceid_short(deviceid) (deviceid>>24)
|
||||
#else
|
||||
#define psync_deviceid_short(deviceid) (deviceid)
|
||||
#endif
|
||||
|
||||
typedef struct stat psync_stat_t;
|
||||
|
||||
|
|
@ -264,16 +243,11 @@ typedef struct {
|
|||
psync_stat_t stat;
|
||||
} psync_pstat;
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
typedef psync_pstat psync_pstat_fast;
|
||||
#define psync_stat_fast_isfolder(a) psync_stat_isfolder(&(a)->stat)
|
||||
#else
|
||||
typedef struct {
|
||||
const char *name;
|
||||
uint8_t isfolder;
|
||||
} psync_pstat_fast;
|
||||
#define psync_stat_fast_isfolder(a) ((a)->isfolder)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
struct sockaddr_storage address;
|
||||
|
|
|
|||
|
|
@ -162,146 +162,12 @@ void devmon_activity_timer_start(){
|
|||
// print_device_info(pDevExtInfo);
|
||||
//}
|
||||
|
||||
#ifdef P_OS_MACOSX
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOMessage.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
#include <IOKit/usb/IOUSBLib.h>
|
||||
|
||||
typedef struct MyPrivateData {
|
||||
io_object_t notification;
|
||||
const char* systempath;
|
||||
} MyPrivateData;
|
||||
|
||||
static IONotificationPortRef gNotifyPort;
|
||||
static io_iterator_t gAddedIter;
|
||||
static CFRunLoopRef gRunLoop;
|
||||
|
||||
void DeviceNotification(void *refCon, io_service_t service, natural_t messageType, void *messageArgument)
|
||||
{
|
||||
kern_return_t kr;
|
||||
MyPrivateData *privateDataRef = (MyPrivateData *) refCon;
|
||||
|
||||
if (messageType == kIOMessageServiceIsTerminated) {
|
||||
// remove_device(privateDataRef->systempath);
|
||||
// debug(D_NOTICE, "Device removed. Mountpoint: %s\n", privateDataRef->systempath);
|
||||
free(privateDataRef->systempath);
|
||||
kr = IOObjectRelease(privateDataRef->notification);
|
||||
free(privateDataRef);
|
||||
devmon_activity_timer_start();
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceAdded(void *refCon, io_iterator_t iterator)
|
||||
{
|
||||
kern_return_t kr;
|
||||
io_service_t usbDevice;
|
||||
CFStringRef deviceNameAsCFString;
|
||||
static int first_call=1;
|
||||
|
||||
while ((usbDevice = IOIteratorNext(iterator))) {
|
||||
io_name_t deviceName;
|
||||
MyPrivateData *privateDataRef = NULL;
|
||||
privateDataRef = malloc(sizeof(MyPrivateData));
|
||||
bzero(privateDataRef, sizeof(MyPrivateData));
|
||||
// Ought to work now, regardless of version of OSX being ran.
|
||||
CFStringRef usbSerial = (CFStringRef) IORegistryEntrySearchCFProperty(
|
||||
usbDevice,
|
||||
kIOServicePlane,
|
||||
CFSTR("USB Serial Number"),
|
||||
kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively
|
||||
);
|
||||
// if (!usbSerial) continue;
|
||||
// Ought to work now, regardless of version of OSX being ran.
|
||||
CFStringRef usbVendor = (CFStringRef) IORegistryEntrySearchCFProperty(
|
||||
usbDevice,
|
||||
kIOServicePlane,
|
||||
CFSTR("USB Vendor Name"),
|
||||
kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively
|
||||
);
|
||||
// if (!usbVendor) continue;
|
||||
// Get the USB device's name.
|
||||
kr = IORegistryEntryGetName(usbDevice, deviceName);
|
||||
if (KERN_SUCCESS != kr) {
|
||||
deviceName[0] = '\0';
|
||||
}
|
||||
deviceNameAsCFString = CFStringCreateWithCString(kCFAllocatorDefault, deviceName,
|
||||
kCFStringEncodingASCII);
|
||||
// if (!deviceNameAsCFString) continue;
|
||||
if (!first_call){
|
||||
debug(D_NOTICE, "start deviceactivity timer");
|
||||
devmon_activity_timer_start();
|
||||
}
|
||||
// Register for an interest notification of this device being removed. Use a reference to our
|
||||
// private data as the refCon which will be passed to the notification callback.
|
||||
kr = IOServiceAddInterestNotification(gNotifyPort, // notifyPort
|
||||
usbDevice, // service
|
||||
kIOGeneralInterest, // interestType
|
||||
DeviceNotification, // callback
|
||||
privateDataRef, // refCon
|
||||
&(privateDataRef->notification) // notification
|
||||
);
|
||||
if (KERN_SUCCESS != kr) {
|
||||
debug(D_NOTICE, "IOServiceAddInterestNotification returned 0x%08x.\n", kr);
|
||||
}
|
||||
// Done with this USB device; release the reference added by IOIteratorNext
|
||||
kr = IOObjectRelease(usbDevice);
|
||||
}
|
||||
first_call=0;
|
||||
}
|
||||
|
||||
void device_monitor_thread() {
|
||||
CFMutableDictionaryRef matchingDict;
|
||||
CFRunLoopSourceRef runLoopSource;
|
||||
// CFNumberRef numberRef;
|
||||
kern_return_t kr;
|
||||
matchingDict = IOServiceMatching(kIOUSBDeviceClassName); // Interested in instances of class
|
||||
// IOUSBDevice and its subclasses
|
||||
if (matchingDict == NULL) {
|
||||
debug(D_NOTICE, "IOServiceMatching returned NULL.\n");
|
||||
return;
|
||||
}
|
||||
gNotifyPort = IONotificationPortCreate(kIOMasterPortDefault);
|
||||
runLoopSource = IONotificationPortGetRunLoopSource(gNotifyPort);
|
||||
gRunLoop = CFRunLoopGetCurrent();
|
||||
CFRunLoopAddSource(gRunLoop, runLoopSource, kCFRunLoopDefaultMode);
|
||||
// Now set up a notification to be called when a device is first matched by I/O Kit.
|
||||
kr = IOServiceAddMatchingNotification(gNotifyPort, // notifyPort
|
||||
kIOFirstMatchNotification, // notificationType
|
||||
matchingDict, // matching
|
||||
DeviceAdded, // callback
|
||||
NULL, // refCon
|
||||
&gAddedIter // notification
|
||||
);
|
||||
// Iterate once to get already-present devices and arm the notification
|
||||
DeviceAdded(NULL, gAddedIter);
|
||||
// Start the run loop. Now we'll receive notifications.
|
||||
debug(D_NOTICE, "Starting run loop.\n\n");
|
||||
CFRunLoopRun();
|
||||
// We should never get here
|
||||
debug(D_NOTICE, "Unexpectedly back from CFRunLoopRun()!");
|
||||
return;
|
||||
}
|
||||
|
||||
void psync_devmon_init(){
|
||||
psync_run_thread("Device monitor main thread", device_monitor_thread);
|
||||
}
|
||||
#endif //P_OS_MACOSX
|
||||
|
||||
#ifdef P_OS_LINUX
|
||||
#include <libudev.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
void enumerate_devices (struct udev *udev,device_event event) {
|
||||
devmon_activity_timer_start();
|
||||
}
|
||||
|
|
@ -365,4 +231,3 @@ void device_monitor_thread(){
|
|||
void psync_devmon_init(){
|
||||
psync_run_thread("libusb handle events completed thread", device_monitor_thread);
|
||||
}
|
||||
#endif //P_OS_LINUX
|
||||
|
|
|
|||
|
|
@ -69,11 +69,6 @@ typedef off_t fuse_off_t;
|
|||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
#include <sys/mount.h>
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_LINUX)
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
|
@ -90,16 +85,6 @@ typedef off_t fuse_off_t;
|
|||
#define FS_BLOCK_SIZE 4096
|
||||
#define FS_MAX_WRITE 16*1024*1024
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
#define FS_MAX_ACCEPTABLE_FILENAME_LEN 255
|
||||
#define FUSE_HAS_SETCRTIME 1
|
||||
|
||||
#if defined(_DARWIN_FEATURE_64_BIT_INODE)
|
||||
#define FUSE_STAT_HAS_BIRTHTIME
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_LINUX)
|
||||
#define PSYNC_FS_ERR_CRYPTO_EXPIRED EROFS
|
||||
#define PSYNC_FS_ERR_MOVE_ACROSS_CRYPTO EXDEV
|
||||
|
|
@ -3221,11 +3206,6 @@ static void psync_fs_do_stop(void){
|
|||
debug(D_NOTICE, "stopping");
|
||||
pthread_mutex_lock(&start_mutex);
|
||||
if (started==1){
|
||||
#if defined(P_OS_MACOSX)
|
||||
debug(D_NOTICE, "running unmount");
|
||||
unmount(psync_current_mountpoint, MNT_FORCE);
|
||||
debug(D_NOTICE, "unmount exited");
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_LINUX)
|
||||
char *mp;
|
||||
|
|
@ -3331,11 +3311,6 @@ static void psync_fuse_thread(){
|
|||
pthread_mutex_lock(&start_mutex);
|
||||
fuse_destroy(psync_fuse);
|
||||
debug(D_NOTICE, "fuse_destroy exited");
|
||||
/*#if defined(P_OS_MACOSX)
|
||||
debug(D_NOTICE, "calling unmount");
|
||||
unmount(psync_current_mountpoint, MNT_FORCE);
|
||||
debug(D_NOTICE, "unmount exited");
|
||||
#endif*/
|
||||
psync_free(psync_current_mountpoint);
|
||||
started=0;
|
||||
pthread_cond_broadcast(&start_cond);
|
||||
|
|
@ -3385,17 +3360,6 @@ static int psync_fs_do_start(){
|
|||
// fuse_opt_add_arg(&args, "-d");
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
fuse_opt_add_arg(&args, "argv");
|
||||
fuse_opt_add_arg(&args, "-ovolname="DEFAULT_FUSE_VOLUME_NAME);
|
||||
fuse_opt_add_arg(&args, "-ofsname="DEFAULT_FUSE_MOUNT_POINT".fs");
|
||||
//fuse_opt_add_arg(&args, "-olocal");
|
||||
if (psync_user_is_admin())
|
||||
fuse_opt_add_arg(&args, "-oallow_root");
|
||||
fuse_opt_add_arg(&args, "-onolocalcaches");
|
||||
fuse_opt_add_arg(&args, "-ohard_remove");
|
||||
#endif
|
||||
|
||||
memset(&psync_oper, 0, sizeof(psync_oper));
|
||||
|
||||
psync_oper.init = psync_fs_init;
|
||||
|
|
@ -3443,10 +3407,6 @@ static int psync_fs_do_start(){
|
|||
goto err00;
|
||||
mp=psync_fuse_get_mountpoint();
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
unmount(mp, MNT_FORCE);
|
||||
#endif
|
||||
|
||||
psync_fuse_channel=fuse_mount(mp, &args);
|
||||
if (unlikely_log(!psync_fuse_channel))
|
||||
goto err0;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1918,9 +1918,7 @@ void psync_fstask_add_banned_folder(psync_fsfolderid_t folderid, const char *nam
|
|||
}
|
||||
|
||||
void psync_fstask_add_banned_folders(){
|
||||
#if defined(P_OS_MACOSX)
|
||||
psync_fstask_add_banned_folder(0, ".TemporaryItems");
|
||||
#endif
|
||||
// noop
|
||||
}
|
||||
|
||||
void psync_fstask_init(){
|
||||
|
|
|
|||
|
|
@ -35,11 +35,7 @@
|
|||
#include "pcompat.h"
|
||||
#include "psynclib.h"
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
#define PFS_XATTR_IGN , uint32_t ign
|
||||
#else
|
||||
#define PFS_XATTR_IGN
|
||||
#endif
|
||||
|
||||
int psync_fs_setxattr(const char *path, const char *name, const char *value, size_t size, int flags PFS_XATTR_IGN);
|
||||
int psync_fs_getxattr(const char *path, const char *name, char *value, size_t size PFS_XATTR_IGN);
|
||||
|
|
|
|||
|
|
@ -312,105 +312,6 @@ void psync_localnotify_del_sync(psync_syncid_t syncid){
|
|||
debug(D_ERROR, "write to pipe failed");
|
||||
}
|
||||
|
||||
#elif defined(P_OS_MACOSX)
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
static CFRunLoopRef runloop=NULL;
|
||||
static FSEventStreamEventId lastevent;
|
||||
|
||||
static void stream_callback(ConstFSEventStreamRef streamRef,
|
||||
void *clientCallBackInfo,
|
||||
size_t numEvents,
|
||||
void *eventPaths,
|
||||
const FSEventStreamEventFlags eventFlags[],
|
||||
const FSEventStreamEventId eventIds[]){
|
||||
size_t i;
|
||||
for (i=0; i<numEvents; i++)
|
||||
if (eventIds[i]>lastevent)
|
||||
lastevent=eventIds[i];
|
||||
psync_wake_localscan();
|
||||
}
|
||||
|
||||
static void timer_callback(CFRunLoopTimerRef timer, void *info){
|
||||
}
|
||||
|
||||
static CFRunLoopTimerRef get_timer(){
|
||||
CFRunLoopTimerRef timer;
|
||||
CFRunLoopTimerContext context={0, NULL, NULL, NULL, NULL};
|
||||
timer=CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), 3600, 0, 0, timer_callback, &context);
|
||||
return timer;
|
||||
}
|
||||
|
||||
static void psync_localnotify_thread(){
|
||||
psync_sql_res *res;
|
||||
psync_str_row row;
|
||||
CFMutableArrayRef dirs;
|
||||
CFStringRef dir;
|
||||
FSEventStreamRef stream;
|
||||
CFAbsoluteTime latency;
|
||||
CFRunLoopTimerRef timer;
|
||||
struct stat st;
|
||||
psync_uint_t cnt;
|
||||
latency=0.2;
|
||||
lastevent=kFSEventStreamEventIdSinceNow;
|
||||
runloop=CFRunLoopGetCurrent();
|
||||
/* the timer is needed only for cases with no directories to monitor, because loops do not like to run empty */
|
||||
timer=get_timer();
|
||||
CFRunLoopAddTimer(runloop, timer, kCFRunLoopCommonModes);
|
||||
while (psync_do_run){
|
||||
dirs=CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
|
||||
cnt=0;
|
||||
res=psync_sql_query("SELECT localpath FROM syncfolder WHERE synctype&"NTO_STR(PSYNC_UPLOAD_ONLY)"="NTO_STR(PSYNC_UPLOAD_ONLY));
|
||||
while ((row=psync_sql_fetch_rowstr(res))){
|
||||
if (stat(row[0], &st) || !S_ISDIR(st.st_mode))
|
||||
continue;
|
||||
dir=CFStringCreateWithBytes(kCFAllocatorDefault, (const unsigned char *)row[0], strlen(row[0]), kCFStringEncodingUTF8, false);
|
||||
CFArrayAppendValue(dirs, dir);
|
||||
CFRelease(dir);
|
||||
cnt++;
|
||||
}
|
||||
psync_sql_free_result(res);
|
||||
if (likely(cnt)){
|
||||
stream=FSEventStreamCreate(kCFAllocatorDefault, stream_callback, NULL, dirs, lastevent, latency, kFSEventStreamCreateFlagNone);
|
||||
FSEventStreamScheduleWithRunLoop(stream, runloop, kCFRunLoopDefaultMode);
|
||||
FSEventStreamStart(stream);
|
||||
}
|
||||
CFRelease(dirs);
|
||||
CFRunLoopRun();
|
||||
if (likely(cnt)){
|
||||
FSEventStreamStop(stream);
|
||||
FSEventStreamInvalidate(stream);
|
||||
FSEventStreamRelease(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int psync_localnotify_init(){
|
||||
psync_run_thread("localnotify", psync_localnotify_thread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wake_loop(){
|
||||
if (unlikely(!runloop)){
|
||||
unsigned int tries=0;
|
||||
while (!runloop && tries++<1000)
|
||||
psync_milisleep(2);
|
||||
if (!runloop)
|
||||
return;
|
||||
}
|
||||
CFRunLoopStop(runloop);
|
||||
}
|
||||
|
||||
void psync_localnotify_add_sync(psync_syncid_t syncid){
|
||||
wake_loop();
|
||||
}
|
||||
|
||||
void psync_localnotify_del_sync(psync_syncid_t syncid){
|
||||
wake_loop();
|
||||
}
|
||||
|
||||
#elif defined(P_OS_BSD)
|
||||
|
||||
/* this implementation only monitors folder changes - it does not catch
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ int callbacks_running = 1;
|
|||
|
||||
#if defined(P_OS_LINUX)
|
||||
#include "poverlay_lin.c"
|
||||
#elif defined(P_OS_MACOSX)
|
||||
#include "poverlay_mac.c"
|
||||
#else
|
||||
void overlay_main_loop(VOID){}
|
||||
void instance_thread(LPVOID){}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include "pcompat.h"
|
||||
#include "plibs.h"
|
||||
|
||||
#if defined(P_OS_LINUX) || defined(P_OS_MACOSX) || defined(P_OS_BSD)
|
||||
#if defined(P_OS_LINUX) || defined(P_OS_BSD)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
|
|
@ -133,4 +133,4 @@ void instance_thread(void* lpvParam)
|
|||
return;
|
||||
};
|
||||
|
||||
#endif //defined(P_OS_LINUX) || definef(P_OS_MACOSX) || defined(P_OS_BSD)
|
||||
#endif //defined(P_OS_LINUX) || defined(P_OS_BSD)
|
||||
|
|
|
|||
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2013-2015 pCloud Ltd. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met: Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer. Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided with
|
||||
the distribution. Neither the name of pCloud Ltd nor the names of
|
||||
its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL pCloud
|
||||
Ltd BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
*/
|
||||
|
||||
#include "pcompat.h"
|
||||
#include "plibs.h"
|
||||
|
||||
#if defined(P_OS_LINUX) || defined(P_OS_MACOSX) || defined(P_OS_BSD)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#define POVERLAY_BUFSIZE 512
|
||||
|
||||
#include "poverlay.h"
|
||||
|
||||
uint32_t myport = 8989;
|
||||
|
||||
void overlay_main_loop()
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
int fd,cl;
|
||||
const int enable = 1;
|
||||
|
||||
if ( (fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||
//debug(D_NOTICE, "TCP/IP socket error failed to create socket on port %u", (unsigned int)myport);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
addr.sin_port = htons(myport);
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) {
|
||||
debug(D_ERROR,"setsockopt(SO_REUSEADDR) failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
debug(D_ERROR,"TCP/IP socket bind error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (listen(fd, 5) == -1) {
|
||||
debug(D_ERROR,"TCP/IP socket listen error");
|
||||
return;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if ( (cl = accept(fd, NULL, NULL)) == -1) {
|
||||
debug(D_ERROR,"TCP/IP socket accept error");
|
||||
continue;
|
||||
}
|
||||
psync_run_thread1(
|
||||
"Pipe request handle routine",
|
||||
instance_thread, // thread proc
|
||||
(LPVOID)&cl // thread parameter
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void instance_thread(void* lpvParam)
|
||||
{
|
||||
int *cl, rc;
|
||||
char chbuf[POVERLAY_BUFSIZE];
|
||||
message* request = NULL;
|
||||
char * curbuf = &chbuf[0];
|
||||
int bytes_read = 0;
|
||||
message* reply = (message*)psync_malloc(POVERLAY_BUFSIZE);
|
||||
|
||||
memset(reply, 0, POVERLAY_BUFSIZE);
|
||||
memset(chbuf, 0, POVERLAY_BUFSIZE);
|
||||
|
||||
cl = (int *)lpvParam;
|
||||
|
||||
while ( (rc=read(*cl,curbuf,(POVERLAY_BUFSIZE - bytes_read))) > 0) {
|
||||
bytes_read += rc;
|
||||
//debug(D_NOTICE, "Read %u bytes: %u %s", bytes_read, rc, curbuf );
|
||||
curbuf = curbuf + rc;
|
||||
if (bytes_read > 12){
|
||||
request = (message *)chbuf;
|
||||
if(request->length == bytes_read)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rc == -1) {
|
||||
debug(D_ERROR,"TCP/IP socket read");
|
||||
close(*cl);
|
||||
return;
|
||||
}
|
||||
else if (rc == 0) {
|
||||
//debug(D_NOTICE,"Message received");
|
||||
close(*cl);
|
||||
}
|
||||
request = (message *)chbuf;
|
||||
if (request) {
|
||||
get_answer_to_request(request, reply);
|
||||
if (reply ) {
|
||||
rc = write(*cl,reply,reply->length);
|
||||
if (rc != reply->length)
|
||||
debug(D_ERROR,"TCP/IP socket reply not sent.");
|
||||
}
|
||||
}
|
||||
if (cl) {
|
||||
close(*cl);
|
||||
}
|
||||
//debug(D_NOTICE, "InstanceThread exitting.\n");
|
||||
return;
|
||||
};
|
||||
|
||||
#endif //defined(P_OS_LINUX) || definef(P_OS_MACOSX) || defined(P_OS_BSD)
|
||||
|
|
@ -148,11 +148,7 @@
|
|||
#define PSYNC_DEFAULT_CACHE_FOLDER "Cache"
|
||||
#define PSYNC_DEFAULT_READ_CACHE_FILE "cached"
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
#define PSYNC_DEFAULT_FS_FOLDER "pCloud Drive"
|
||||
#else
|
||||
#define PSYNC_DEFAULT_FS_FOLDER "pCloudDrive"
|
||||
#endif
|
||||
|
||||
#define PSYNC_DEFAULT_POSIX_FOLDER_MODE 0755
|
||||
#define PSYNC_DEFAULT_POSIX_FILE_MODE 0644
|
||||
|
|
@ -273,10 +269,7 @@ $RECYCLE.BIN;\
|
|||
*.part;\
|
||||
.pcloud;"
|
||||
|
||||
#if defined (P_OS_MACOSX)
|
||||
#define PSYNC_IGNORE_PATHS_DEFAULT "/Applications;/Library;/private;/System;/bin;/etc;/sbin;/usr;"
|
||||
#endif
|
||||
|
||||
// XXX: wtf??
|
||||
#if defined (P_OS_LINUX)
|
||||
#define PSYNC_IGNORE_PATHS_DEFAULT "/Applications;/Library;/private;/System;/bin;/dev;/etc;/net;/sbin;/usr;/Developer;"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,11 +46,6 @@
|
|||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/*************************************************************/
|
||||
char* getMACaddr() {
|
||||
char buffer[128];
|
||||
|
|
@ -78,17 +73,6 @@ char* getMACaddr() {
|
|||
buffer[12] = 0;
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
int byteRead = 0;
|
||||
FILE* stream = popen("ifconfig en0 | grep ether | cut -c 8-24", "r");
|
||||
|
||||
while (!feof(stream) && !ferror(stream)) {
|
||||
byteRead = fread(buffer, 1, 128, stream);
|
||||
}
|
||||
|
||||
buffer[byteRead] = 0;
|
||||
#endif
|
||||
|
||||
if (buffer[0] == 0) {
|
||||
return psync_strdup("GENERIC_MAC");
|
||||
|
||||
|
|
@ -362,27 +346,12 @@ char* get_machine_name() {
|
|||
gethostname(pcName, nameSize);
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
int byteRead;
|
||||
FILE* stream = popen("system_profiler SPSoftwareDataType | grep \"Computer Name\" | cut -d: -f2", "r");
|
||||
|
||||
while (!feof(stream) && !ferror(stream)) {
|
||||
byteRead = fread(pcName, 1, 128, stream);
|
||||
}
|
||||
if(byteRead > 0) {
|
||||
pcName[byteRead-1] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pcName[0] == 0) {
|
||||
|
||||
#if defined(P_OS_LINUX)
|
||||
strcpy(pcName, "LinuxMachine");
|
||||
#endif
|
||||
|
||||
#if defined(P_OS_MACOSX)
|
||||
strcpy(pcName, "MacMachine");
|
||||
#endif
|
||||
}
|
||||
|
||||
return psync_strdup(pcName);
|
||||
|
|
|
|||
|
|
@ -7,20 +7,8 @@ CFLAGS=-Wall -Wpointer-arith -O2 -g -fno-stack-protector -fomit-frame-pointer -m
|
|||
|
||||
UNAME_S := $(shell uname -s)
|
||||
UNAME_V := $(shell uname -v)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
CFLAGS += -DP_OS_LINUX
|
||||
ifneq (,$(findstring Debian,$(UNAME_V)))
|
||||
CFLAGS += -DP_OS_DEBIAN
|
||||
endif
|
||||
LAGS += -lssl -lcrypto -lpthread
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
CFLAGS += -DP_OS_MACOSX -I/usr/local/ssl/include/
|
||||
CFLAGS += -DP_OS_MACOSX -I/usr/local/include/osxfuse/
|
||||
LDFLAGS += -lssl -lcrypto -lpthread -L/usr/local/ssl/lib
|
||||
#USESSL=securetransport
|
||||
endif
|
||||
|
||||
CFLAGS += -DP_OS_LINUX
|
||||
LDFLAGS += -lssl -lcrypto -lpthread
|
||||
|
||||
OBJ=overlay_client.o debug.o
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue