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" {
#endif
#include <stddef.h>
typedef enum _pCloud_FileState {
FileStateInSync = 0,
FileStateNoSync,

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -1,127 +1,127 @@
/*
Copyright (c) 2013-2014 Anton Titov.
Copyright (c) 2013-2014 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 "plibs.h"
#include "psynclib.h"
#include "pdevice_monitor.h"
#include "plocalscan.h"
#include "ptimer.h"
#include <libudev.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define DEV_MONITOR_ACTIVITY_TIMER_INT 20
static pthread_mutex_t devmon_mutex = PTHREAD_MUTEX_INITIALIZER;
static psync_timer_t devmon_activity_timer = NULL;
void devmon_activity_timer_action() {
psync_timer_stop(devmon_activity_timer);
pthread_mutex_lock(&devmon_mutex);
devmon_activity_timer = NULL;
pthread_mutex_unlock(&devmon_mutex);
psync_restat_sync_folders();
}
void devmon_activity_timer_start() {
pthread_mutex_lock(&devmon_mutex);
if (!devmon_activity_timer)
devmon_activity_timer = psync_timer_register(
devmon_activity_timer_action, DEV_MONITOR_ACTIVITY_TIMER_INT, NULL);
pthread_mutex_unlock(&devmon_mutex);
}
void enumerate_devices(struct udev *udev, device_event event) {
devmon_activity_timer_start();
}
void monitor_usb_dev() {
struct udev *udev;
struct udev_device *dev;
struct udev_monitor *mon;
int fd;
udev = udev_new();
if (!udev) {
debug(D_WARNING, "Can't create udev\n");
return;
}
mon = udev_monitor_new_from_netlink(udev, "udev");
udev_monitor_filter_add_match_subsystem_devtype(mon, "usb", NULL);
udev_monitor_enable_receiving(mon);
/* Get the file descriptor (fd) for the monitor.
This fd will get passed to select() */
fd = udev_monitor_get_fd(mon);
while (1) {
/* Set up the call to select(). In this case, select() will
only operate on a single file descriptor, the one
associated with our udev_monitor. Note that the timeval
object is set to 0, which will cause select() to not
block. */
fd_set fds;
struct timeval tv;
int ret;
FD_ZERO(&fds);
FD_SET(fd, &fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
ret = select(fd + 1, &fds, NULL, NULL, &tv);
/* Check if our file descriptor has received data. */
if (ret > 0 && FD_ISSET(fd, &fds)) {
/* Make the call to receive the device.
select() ensured that this will not block. */
dev = udev_monitor_receive_device(mon);
if (dev) {
enumerate_devices(udev, Dev_Event_arrival);
} else {
// printf("No Device from receive_device(). An error occured.\n");
}
}
usleep(250 * 1000);
fflush(stdout);
}
udev_unref(udev);
return;
}
void device_monitor_thread() {
debug(D_NOTICE, "Waiting for USB devices connect/disconnect events");
monitor_usb_dev();
}
void psync_devmon_init() {
psync_run_thread("libusb handle events completed thread",
device_monitor_thread);
}
/*
Copyright (c) 2013-2014 Anton Titov.
Copyright (c) 2013-2014 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 <libudev.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "plibs.h"
#include "psynclib.h"
#include "pdevice_monitor.h"
#include "plocalscan.h"
#include "ptimer.h"
#define DEV_MONITOR_ACTIVITY_TIMER_INT 20
static pthread_mutex_t devmon_mutex = PTHREAD_MUTEX_INITIALIZER;
static psync_timer_t devmon_activity_timer = NULL;
void devmon_activity_timer_action() {
psync_timer_stop(devmon_activity_timer);
pthread_mutex_lock(&devmon_mutex);
devmon_activity_timer = NULL;
pthread_mutex_unlock(&devmon_mutex);
psync_restat_sync_folders();
}
void devmon_activity_timer_start() {
pthread_mutex_lock(&devmon_mutex);
if (!devmon_activity_timer)
devmon_activity_timer = psync_timer_register(
devmon_activity_timer_action, DEV_MONITOR_ACTIVITY_TIMER_INT, NULL);
pthread_mutex_unlock(&devmon_mutex);
}
void enumerate_devices(struct udev *udev, device_event event) {
devmon_activity_timer_start();
}
void monitor_usb_dev() {
struct udev *udev;
struct udev_device *dev;
struct udev_monitor *mon;
int fd;
udev = udev_new();
if (!udev) {
debug(D_WARNING, "Can't create udev\n");
return;
}
mon = udev_monitor_new_from_netlink(udev, "udev");
udev_monitor_filter_add_match_subsystem_devtype(mon, "usb", NULL);
udev_monitor_enable_receiving(mon);
/* Get the file descriptor (fd) for the monitor.
This fd will get passed to select() */
fd = udev_monitor_get_fd(mon);
while (1) {
/* Set up the call to select(). In this case, select() will
only operate on a single file descriptor, the one
associated with our udev_monitor. Note that the timeval
object is set to 0, which will cause select() to not
block. */
fd_set fds;
struct timeval tv;
int ret;
FD_ZERO(&fds);
FD_SET(fd, &fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
ret = select(fd + 1, &fds, NULL, NULL, &tv);
/* Check if our file descriptor has received data. */
if (ret > 0 && FD_ISSET(fd, &fds)) {
/* Make the call to receive the device.
select() ensured that this will not block. */
dev = udev_monitor_receive_device(mon);
if (dev) {
enumerate_devices(udev, Dev_Event_arrival);
} else {
// printf("No Device from receive_device(). An error occured.\n");
}
}
usleep(250 * 1000);
fflush(stdout);
}
udev_unref(udev);
return;
}
void device_monitor_thread() {
debug(D_NOTICE, "Waiting for USB devices connect/disconnect events");
monitor_usb_dev();
}
void psync_devmon_init() {
psync_run_thread("libusb handle events completed thread",
device_monitor_thread);
}

View File

@ -1,45 +1,45 @@
/*
Copyright (c) 2013-2014 Anton Titov.
Copyright (c) 2013-2014 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.
*/
#pragma once
#ifndef _PDEVICE_MONITOR
#define _PDEVICE_MONITOR
#ifdef __cplusplus
extern "C" {
#endif
void psync_devmon_init();
#ifdef __cplusplus
}
#endif
#endif //_PDEVICE_MONITOR
/*
Copyright (c) 2013-2014 Anton Titov.
Copyright (c) 2013-2014 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.
*/
#pragma once
#ifndef _PDEVICE_MONITOR
#define _PDEVICE_MONITOR
#ifdef __cplusplus
extern "C" {
#endif
void psync_devmon_init();
#ifdef __cplusplus
}
#endif
#endif //_PDEVICE_MONITOR

View File

@ -37,7 +37,7 @@
#include "psettings.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
static inline uint64_t psync_get_permissions(const binresult *meta) {

View File

@ -35,7 +35,7 @@
#include "pcompiler.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_FOLDER_FLAG_ENCRYPTED 1

View File

@ -32,6 +32,8 @@
#ifndef _PSYNC_FS_H
#define _PSYNC_FS_H
#include <pthread.h>
#include "papi.h"
#include "pcompat.h"
#include "pcrc32c.h"
@ -44,7 +46,6 @@
#include "psynclib.h"
#include "ptimer.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_const() 1

View File

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

View File

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

View File

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

View File

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

View File

@ -29,20 +29,18 @@
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
#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_KEY_SIZE 32

View File

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

View File

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

View File

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