Appease the LSP server (#73)

* newline conversions

* formatting changes and lsp appeasement
This commit is contained in:
Levi Neely 2024-11-26 18:36:49 +00:00 committed by GitHub
parent 53f785ac1f
commit ca80afd658
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 988 additions and 969 deletions

View File

@ -39,6 +39,8 @@ Dependencies:
extern "C" { extern "C" {
#endif #endif
#include <stddef.h>
typedef enum _pCloud_FileState { typedef enum _pCloud_FileState {
FileStateInSync = 0, FileStateInSync = 0,
FileStateNoSync, FileStateNoSync,

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,6 @@
#ifndef _PSYNC_COMPAT_H #ifndef _PSYNC_COMPAT_H
#define _PSYNC_COMPAT_H #define _PSYNC_COMPAT_H
#include "pcompiler.h"
#define P_OS_LINUX #define P_OS_LINUX
#define P_OS_ID 7 // linux #define P_OS_ID 7 // linux
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
@ -72,6 +70,8 @@ typedef unsigned long psync_uint_t;
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include "pcompiler.h"
#define P_PRI_U64 PRIu64 #define P_PRI_U64 PRIu64
#define P_PRI_D64 PRId64 #define P_PRI_D64 PRId64

View File

@ -32,9 +32,10 @@
#ifndef _PSYNC_DATABASE_H #ifndef _PSYNC_DATABASE_H
#define _PSYNC_DATABASE_H #define _PSYNC_DATABASE_H
#include "pcompat.h"
#include <sqlite3.h> #include <sqlite3.h>
#include "pcompat.h"
#if defined(SQLITE_VERSION_NUMBER) && SQLITE_VERSION_NUMBER >= 3008002 #if defined(SQLITE_VERSION_NUMBER) && SQLITE_VERSION_NUMBER >= 3008002
#define P_SQL_WOWROWID "WITHOUT ROWID" #define P_SQL_WOWROWID "WITHOUT ROWID"
#else #else

View File

@ -1,127 +1,127 @@
/* /*
Copyright (c) 2013-2014 Anton Titov. Copyright (c) 2013-2014 Anton Titov.
Copyright (c) 2013-2014 pCloud Ltd. All rights reserved. Copyright (c) 2013-2014 pCloud Ltd. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: Redistributions of source code must retain the above are met: Redistributions of source code must retain the above
copyright notice, this list of conditions and the following copyright notice, this list of conditions and the following
disclaimer. Redistributions in binary form must reproduce the disclaimer. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the following above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided disclaimer in the documentation and/or other materials provided
with the distribution. Neither the name of pCloud Ltd nor the with the distribution. Neither the name of pCloud Ltd nor the
names of its contributors may be used to endorse or promote names of its contributors may be used to endorse or promote
products derived from this software without specific prior written products derived from this software without specific prior written
permission. permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL pCloud FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL pCloud
Ltd BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Ltd BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
*/ */
#include <libudev.h>
#include "plibs.h" #include <locale.h>
#include "psynclib.h" #include <stdio.h>
#include <stdlib.h>
#include "pdevice_monitor.h" #include <unistd.h>
#include "plocalscan.h"
#include "ptimer.h" #include "plibs.h"
#include <libudev.h> #include "psynclib.h"
#include <locale.h>
#include <stdio.h> #include "pdevice_monitor.h"
#include <stdlib.h> #include "plocalscan.h"
#include <unistd.h> #include "ptimer.h"
#define DEV_MONITOR_ACTIVITY_TIMER_INT 20 #define DEV_MONITOR_ACTIVITY_TIMER_INT 20
static pthread_mutex_t devmon_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t devmon_mutex = PTHREAD_MUTEX_INITIALIZER;
static psync_timer_t devmon_activity_timer = NULL; static psync_timer_t devmon_activity_timer = NULL;
void devmon_activity_timer_action() { void devmon_activity_timer_action() {
psync_timer_stop(devmon_activity_timer); psync_timer_stop(devmon_activity_timer);
pthread_mutex_lock(&devmon_mutex); pthread_mutex_lock(&devmon_mutex);
devmon_activity_timer = NULL; devmon_activity_timer = NULL;
pthread_mutex_unlock(&devmon_mutex); pthread_mutex_unlock(&devmon_mutex);
psync_restat_sync_folders(); psync_restat_sync_folders();
} }
void devmon_activity_timer_start() { void devmon_activity_timer_start() {
pthread_mutex_lock(&devmon_mutex); pthread_mutex_lock(&devmon_mutex);
if (!devmon_activity_timer) if (!devmon_activity_timer)
devmon_activity_timer = psync_timer_register( devmon_activity_timer = psync_timer_register(
devmon_activity_timer_action, DEV_MONITOR_ACTIVITY_TIMER_INT, NULL); devmon_activity_timer_action, DEV_MONITOR_ACTIVITY_TIMER_INT, NULL);
pthread_mutex_unlock(&devmon_mutex); pthread_mutex_unlock(&devmon_mutex);
} }
void enumerate_devices(struct udev *udev, device_event event) { void enumerate_devices(struct udev *udev, device_event event) {
devmon_activity_timer_start(); devmon_activity_timer_start();
} }
void monitor_usb_dev() { void monitor_usb_dev() {
struct udev *udev; struct udev *udev;
struct udev_device *dev; struct udev_device *dev;
struct udev_monitor *mon; struct udev_monitor *mon;
int fd; int fd;
udev = udev_new(); udev = udev_new();
if (!udev) { if (!udev) {
debug(D_WARNING, "Can't create udev\n"); debug(D_WARNING, "Can't create udev\n");
return; return;
} }
mon = udev_monitor_new_from_netlink(udev, "udev"); mon = udev_monitor_new_from_netlink(udev, "udev");
udev_monitor_filter_add_match_subsystem_devtype(mon, "usb", NULL); udev_monitor_filter_add_match_subsystem_devtype(mon, "usb", NULL);
udev_monitor_enable_receiving(mon); udev_monitor_enable_receiving(mon);
/* Get the file descriptor (fd) for the monitor. /* Get the file descriptor (fd) for the monitor.
This fd will get passed to select() */ This fd will get passed to select() */
fd = udev_monitor_get_fd(mon); fd = udev_monitor_get_fd(mon);
while (1) { while (1) {
/* Set up the call to select(). In this case, select() will /* Set up the call to select(). In this case, select() will
only operate on a single file descriptor, the one only operate on a single file descriptor, the one
associated with our udev_monitor. Note that the timeval associated with our udev_monitor. Note that the timeval
object is set to 0, which will cause select() to not object is set to 0, which will cause select() to not
block. */ block. */
fd_set fds; fd_set fds;
struct timeval tv; struct timeval tv;
int ret; int ret;
FD_ZERO(&fds); FD_ZERO(&fds);
FD_SET(fd, &fds); FD_SET(fd, &fds);
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
ret = select(fd + 1, &fds, NULL, NULL, &tv); ret = select(fd + 1, &fds, NULL, NULL, &tv);
/* Check if our file descriptor has received data. */ /* Check if our file descriptor has received data. */
if (ret > 0 && FD_ISSET(fd, &fds)) { if (ret > 0 && FD_ISSET(fd, &fds)) {
/* Make the call to receive the device. /* Make the call to receive the device.
select() ensured that this will not block. */ select() ensured that this will not block. */
dev = udev_monitor_receive_device(mon); dev = udev_monitor_receive_device(mon);
if (dev) { if (dev) {
enumerate_devices(udev, Dev_Event_arrival); enumerate_devices(udev, Dev_Event_arrival);
} else { } else {
// printf("No Device from receive_device(). An error occured.\n"); // printf("No Device from receive_device(). An error occured.\n");
} }
} }
usleep(250 * 1000); usleep(250 * 1000);
fflush(stdout); fflush(stdout);
} }
udev_unref(udev); udev_unref(udev);
return; return;
} }
void device_monitor_thread() { void device_monitor_thread() {
debug(D_NOTICE, "Waiting for USB devices connect/disconnect events"); debug(D_NOTICE, "Waiting for USB devices connect/disconnect events");
monitor_usb_dev(); monitor_usb_dev();
} }
void psync_devmon_init() { void psync_devmon_init() {
psync_run_thread("libusb handle events completed thread", psync_run_thread("libusb handle events completed thread",
device_monitor_thread); device_monitor_thread);
} }

View File

@ -1,45 +1,45 @@
/* /*
Copyright (c) 2013-2014 Anton Titov. Copyright (c) 2013-2014 Anton Titov.
Copyright (c) 2013-2014 pCloud Ltd. All rights reserved. Copyright (c) 2013-2014 pCloud Ltd. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: Redistributions of source code must retain the above are met: Redistributions of source code must retain the above
copyright notice, this list of conditions and the following copyright notice, this list of conditions and the following
disclaimer. Redistributions in binary form must reproduce the disclaimer. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the following above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided disclaimer in the documentation and/or other materials provided
with the distribution. Neither the name of pCloud Ltd nor the with the distribution. Neither the name of pCloud Ltd nor the
names of its contributors may be used to endorse or promote names of its contributors may be used to endorse or promote
products derived from this software without specific prior written products derived from this software without specific prior written
permission. permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL pCloud FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL pCloud
Ltd BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Ltd BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
*/ */
#pragma once #pragma once
#ifndef _PDEVICE_MONITOR #ifndef _PDEVICE_MONITOR
#define _PDEVICE_MONITOR #define _PDEVICE_MONITOR
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void psync_devmon_init(); void psync_devmon_init();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif //_PDEVICE_MONITOR #endif //_PDEVICE_MONITOR

View File

@ -37,7 +37,7 @@
#include "psettings.h" #include "psettings.h"
#include "psynclib.h" #include "psynclib.h"
#define PSYNC_INVALID_FOLDERID ((psync_folderid_t)-1) #define PSYNC_INVALID_FOLDERID ((psync_folderid_t) - 1)
#define PSYNC_INVALID_PATH NULL #define PSYNC_INVALID_PATH NULL
static inline uint64_t psync_get_permissions(const binresult *meta) { static inline uint64_t psync_get_permissions(const binresult *meta) {

View File

@ -35,7 +35,7 @@
#include "pcompiler.h" #include "pcompiler.h"
#include "psynclib.h" #include "psynclib.h"
#define PSYNC_INVALID_FOLDERID ((psync_folderid_t)-1) #define PSYNC_INVALID_FOLDERID ((psync_folderid_t) - 1)
#define PSYNC_INVALID_PATH NULL #define PSYNC_INVALID_PATH NULL
#define PSYNC_FOLDER_FLAG_ENCRYPTED 1 #define PSYNC_FOLDER_FLAG_ENCRYPTED 1

View File

@ -32,6 +32,8 @@
#ifndef _PSYNC_FS_H #ifndef _PSYNC_FS_H
#define _PSYNC_FS_H #define _PSYNC_FS_H
#include <pthread.h>
#include "papi.h" #include "papi.h"
#include "pcompat.h" #include "pcompat.h"
#include "pcrc32c.h" #include "pcrc32c.h"
@ -44,7 +46,6 @@
#include "psynclib.h" #include "psynclib.h"
#include "ptimer.h" #include "ptimer.h"
#include "ptree.h" #include "ptree.h"
#include <pthread.h>
#define psync_fs_need_per_folder_refresh() psync_fs_need_per_folder_refresh_f() #define psync_fs_need_per_folder_refresh() psync_fs_need_per_folder_refresh_f()
#define psync_fs_need_per_folder_refresh_const() 1 #define psync_fs_need_per_folder_refresh_const() 1

View File

@ -32,13 +32,14 @@
#ifndef _PSYNC_FSTASKS_H #ifndef _PSYNC_FSTASKS_H
#define _PSYNC_FSTASKS_H #define _PSYNC_FSTASKS_H
#include <stddef.h>
#include <string.h>
#include <time.h>
#include "pfsfolder.h" #include "pfsfolder.h"
#include "plibs.h" #include "plibs.h"
#include "psynclib.h" #include "psynclib.h"
#include "ptree.h" #include "ptree.h"
#include <stddef.h>
#include <string.h>
#include <time.h>
#define PSYNC_FS_TASK_MKDIR 1 #define PSYNC_FS_TASK_MKDIR 1
#define PSYNC_FS_TASK_RMDIR 2 #define PSYNC_FS_TASK_RMDIR 2

View File

@ -42,6 +42,7 @@
#endif #endif
#include "psynclib.h" #include "psynclib.h"
#include "poverlay_protocol.h"
extern int overlays_running; extern int overlays_running;
extern int callbacks_running; extern int callbacks_running;

View File

@ -1,9 +1,16 @@
// defines the messaging protocol for pclsync // defines the messaging protocol for pclsync
#ifndef __POVERLAY_PROTOCOL_H
#define __POVERLAY_PROTOCOL_H
#include <stddef.h>
#include <stdint.h>
#ifndef POVERLAY_SOCK_PATH #ifndef POVERLAY_SOCK_PATH
#define POVERLAY_SOCK_PATH "/tmp/pcloud_unix_soc.sock" #define POVERLAY_SOCK_PATH "/tmp/pcloud_unix_soc.sock"
#endif #endif
typedef struct _message { typedef struct _message {
uint32_t type; uint32_t type;
uint64_t length; uint64_t length;
@ -20,3 +27,5 @@ typedef struct {
size_t payloadsz; // size of payload size_t payloadsz; // size of payload
message *msg; // API response message message *msg; // API response message
} response_message; } response_message;
#endif

View File

@ -29,6 +29,8 @@
DAMAGE. DAMAGE.
*/ */
#include <stdint.h>
#define PSYNC_SCAN_EXTENSIONS_CNT 166 #define PSYNC_SCAN_EXTENSIONS_CNT 166
#define PSYNC_SCAN_TYPES_CNT 5 #define PSYNC_SCAN_TYPES_CNT 5

View File

@ -29,20 +29,18 @@
DAMAGE. DAMAGE.
*/ */
/*
Dependencies:
- pcompat.h
- pcompiler.h
- <mbedtls/aes.h>
- <mbedtls/rsa.h>
- <mbedtls/mbedtls_sha1.h>
- <mbedtls/mbedtls_sha256.h>
- <mbedtls/mbedtls_sha512.h>
*/
#ifndef _PSYNC_SSL_H #ifndef _PSYNC_SSL_H
#define _PSYNC_SSL_H #define _PSYNC_SSL_H
#include <mbedtls/aes.h>
#include <mbedtls/rsa.h>
#include <mbedtls/sha1.h>
#include <mbedtls/sha256.h>
#include <mbedtls/sha512.h>
#include "pcompat.h"
#include "pcompiler.h"
#define PSYNC_AES256_BLOCK_SIZE 16 #define PSYNC_AES256_BLOCK_SIZE 16
#define PSYNC_AES256_KEY_SIZE 32 #define PSYNC_AES256_KEY_SIZE 32

View File

@ -37,12 +37,13 @@
* success and -1 for failure. * success and -1 for failure.
*/ */
#include "paccountevents.h"
#include "ptools.h"
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "paccountevents.h"
#include "ptools.h"
typedef uint64_t psync_folderid_t; typedef uint64_t psync_folderid_t;
typedef uint64_t psync_fileid_t; typedef uint64_t psync_fileid_t;
typedef uint64_t psync_fileorfolderid_t; typedef uint64_t psync_fileorfolderid_t;

View File

@ -32,11 +32,12 @@
#ifndef _PSYNC_TIMER_H #ifndef _PSYNC_TIMER_H
#define _PSYNC_TIMER_H #define _PSYNC_TIMER_H
#include "plist.h"
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "plist.h"
#define PSYNC_INVALID_TIMER NULL #define PSYNC_INVALID_TIMER NULL
extern time_t psync_current_time; extern time_t psync_current_time;

View File

@ -29,7 +29,9 @@
#ifndef _PSYNC_TYPES_H #ifndef _PSYNC_TYPES_H
#define _PSYNC_TYPES_H #define _PSYNC_TYPES_H
#include "papi.h" #include "papi.h"
typedef void (*result_visitor)(int i, const binresult *result, void *param); typedef void (*result_visitor)(int i, const binresult *result, void *param);
#endif #endif