Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 1f580a8898f837914361f6d9f1ea00af09352799
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon May 6 14:12:34 2024 -0700

    Fixed Darwin build errors

commit 93a58aee023502c37d1f8662df45b759ad3c17d7
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon May 6 13:50:45 2024 -0700

    Clipboard on Linux working

commit 950eb9b0ce3b70862d31c33ea9313ad2817cec62
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Sat May 4 15:43:48 2024 -0700

    Need to fix issue with snapshot name_len being incorrect

commit a35a478b949eec913cd0ca5b85ef6083b8cac4e9
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Fri May 3 16:55:54 2024 -0700

    Updates to snapshots

commit 05c48b56329148c694979039c1c6bb8fc853b836
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Fri May 3 00:14:33 2024 -0700

    Updated directory snapshots on Windows

commit c3bfb34105cf8cd01c622bee28faf8125f181882
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu May 2 22:49:24 2024 -0700

    Clipboard on Linux builds

commit a447209724d3db0fcb999ff204df8cb71edea17e
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu May 2 18:54:17 2024 -0700

    Adding file system snapshots

commit c86016814f533b6b4fb6873d4988d222ae57ff7c
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu May 2 16:32:50 2024 -0700

    Updated file system watching on mac

commit 569e2a0d5f3bddb3f655102cb1b29a0305ec24f4
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu May 2 14:09:04 2024 -0700

    More progress on Linux clipboard

commit bd59beb45ee383bee498d40c503d106c11c36764
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Wed May 1 21:25:45 2024 -0700

    Further progress on xcb clipboard

commit f128e3f195d6b52b8454c283db6f1ad08b2690a5
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Wed May 1 02:14:05 2024 -0700

    Updates to pipes on Windows

commit f2e6bd69ec7076516aa42f560e04ba8d21525a2a
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Tue Apr 30 18:05:36 2024 -0700

    Implementing clipboard on Linux with xcb

commit d6670e0ecc06d83ea1617248ff1ca5f492c3964c
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Tue Apr 30 15:59:43 2024 -0700

    Fixed file watching build errors on Linux

commit 6fe7bb3
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Tue Apr 30 19:16:49 2024 -0700

    Changes to pipes

commit 7c8300d
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon Apr 29 03:50:32 2024 -0700

    Changing semantics of process creation

commit b2296cd
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon Apr 29 01:09:56 2024 -0700

    Directory watching fixes on Windows

commit 3dca89f
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Fri Apr 26 15:58:31 2024 -0700

    Fixed file system watching on Linux

commit 1af172c
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Fri Apr 26 02:45:37 2024 -0700

    Changed locks

commit d151089
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu Apr 25 20:12:23 2024 -0700

    Abstracting away locks further

commit b0e951c
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu Apr 25 18:49:28 2024 -0700

    Updates to pasteboard and file watching on Mac

commit c6ae47f
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu Apr 25 14:23:54 2024 -0700

    Fixes to Windows file system watching

commit bde96f5
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu Apr 25 02:00:37 2024 -0700

    Updates to file system watching on Windows

commit 9a2a148
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Wed Apr 24 19:40:30 2024 -0700

    Changed semantics of some sysinfo functions

commit e706d61
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Wed Apr 24 17:51:53 2024 -0700

    Updates to pasteboard on Mac

commit 1b2d7d5
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Wed Apr 24 17:02:23 2024 -0700

    Added performance monitoring on Mac

commit eb86a6d
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Wed Apr 24 04:09:24 2024 -0700

    Change semantics of locks and condition variables

commit 5d9635f
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Wed Apr 24 03:15:28 2024 -0700

    Added aio for Linux

commit 52bb489
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Tue Apr 23 01:45:26 2024 -0700

    More robust error reporting on Windows

commit ac74f8e
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon Apr 22 21:22:47 2024 -0700

    Added error checking on Linux

commit de20818
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon Apr 22 18:30:59 2024 -0700

    Added heavy error reporting on Windows

commit 7c6d8a6
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon Apr 22 03:00:45 2024 -0700

    Various functional and documentation improvements

commit 376b34c
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Mon Apr 22 00:23:38 2024 -0700

    Updates to performance monitoring

commit fdae9c0
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Sun Apr 21 20:44:49 2024 -0700

    Updates to asynchronous I/O

commit bc483b4
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Sat Apr 20 15:27:43 2024 -0700

    Adding asynchronous IO

commit 18b5122
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Sat Apr 20 01:37:27 2024 -0700

    Error checking and user functions on Windows

commit 9f58132
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu Apr 18 18:14:13 2024 -0700

    Added querying common user directories

commit 7e2966a
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu Apr 18 16:01:19 2024 -0700

    Fixed errors on Linux

commit b8043c1
Author: Ethan Vrhel <ethanvrhel@gmail.com>
Date:   Thu Apr 18 15:35:26 2024 -0700

    Getting rid of global data
  • Loading branch information
evrhel committed May 6, 2024
1 parent 64a139b commit cb3c022
Show file tree
Hide file tree
Showing 49 changed files with 8,171 additions and 2,797 deletions.
24 changes: 21 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.14)

project(lysys VERSION 1.0)

Expand All @@ -10,6 +10,7 @@ set(LYSYS_SOURCES
${src}/ls_core.c
${src}/ls_event.c
${src}/ls_file.c
${src}/ls_ioutils.c
${src}/ls_handle.c
${src}/ls_memory.c
${src}/ls_mmap.c
Expand All @@ -18,23 +19,40 @@ set(LYSYS_SOURCES
${src}/ls_shell.c
${src}/ls_stat.c
${src}/ls_sync.c
${src}/ls_sync_util.c
${src}/ls_sysinfo.c
${src}/ls_thread.c
${src}/ls_time.c
${src}/ls_user.c
${src}/ls_util.c
${src}/ls_watch.c)

if (APPLE)
list(APPEND LYSYS_SOURCES
${src}/ls_pasteboard.m
${src}/ls_watch_darwin.m)
${src}/ls_pasteboard.m)
elseif (UNIX)
include(${CMAKE_ROOT}/Modules/FindX11.cmake)
list(APPEND LYSYS_SOURCES
${src}/ls_clipboard_x11.c)
endif()

add_library(liblysys STATIC ${LYSYS_SOURCES})

set_property(TARGET liblysys PROPERTY C_STANDARD 99)

if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OSX version")
endif()

if (WIN32)
target_link_libraries(liblysys PRIVATE shlwapi)
target_link_libraries(liblysys PRIVATE userenv)
target_link_libraries(liblysys PRIVATE Pdh)
elseif(APPLE)
find_library(COCOA_LIBRARY Cocoa)
target_link_libraries(liblysys PUBLIC ${COCOA_LIBRARY})
elseif(UNIX)
target_link_libraries(liblysys PRIVATE xcb)
endif()

target_include_directories(liblysys PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
51 changes: 22 additions & 29 deletions include/lysys/ls_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@

#define LS_INFINITE ((unsigned long)-1)

typedef void (*ls_exit_hook_t)(int);

struct ls_allocator
{
void *(*malloc)(size_t size);
void *(*calloc)(size_t nmemb, size_t size);
void *(*realloc)(void *ptr, size_t size);
void (*free)(void *ptr);
};

int ls_init(const struct ls_allocator *allocator);

void ls_shutdown(void);

int ls_add_exit_hook(ls_exit_hook_t hook);

//! \brief Exit the program.
//!
//! Exits the program with the specified status code. This function
//! will call any registered exit hooks before the program exits.
//!
//! \param [in] status The status code to exit with.
void ls_exit(int status);

//! \brief Wait for a handle to become signaled.
//!
//! Waits for the specified handle to become signaled. If the handle
Expand Down Expand Up @@ -76,16 +52,33 @@ void ls_close(ls_handle h);
//! \return The last error code or 0 if no error occurred.
int ls_errno(void);

void *ls_malloc(size_t size);
void ls_perror(const char *msg);

void *ls_calloc(size_t nmemb, size_t size);
const char *ls_strerror(int err);

void *ls_realloc(void *ptr, size_t size);
//! \brief Extract a substring.
//!
//! Extracts n characters from the string s and copies them to the
//! buffer buf. The buffer must be large enough to store the substring,
//! including the null terminator (i.e. buf must be at least n + 1
//! bytes long). The substring is copied to the buffer and the buffer
//! is null-terminated. If n is greater than the length of s, the entire
//! string is copied to the buffer. The length of the substring copied
//! to the buffer is returned, excluding the null terminator.
//!
//! \param s The string to extract from.
//! \param n The number of characters to extract.
//! \param buf The buffer to copy the substring to.
//!
//! \return The length of the substring copied to the buffer, excluding
//! the null terminator. If an error occurs, -1 is returned.
size_t ls_substr(const char *s, size_t n, char *buf);

void *ls_malloc(size_t size);
void *ls_calloc(size_t count, size_t size);
void *ls_realloc(void *ptr, size_t size);
void ls_free(void *ptr);

char *ls_strdup(const char *s);

size_t ls_substr(const char *s, size_t n, char *buf, size_t size);

#endif // _LYSYS_H_
103 changes: 103 additions & 0 deletions include/lysys/ls_error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#ifndef _LS_ERROR_H_
#define _LS_ERROR_H_

// Success
#define LS_SUCCESS 0

// Unknown error
#define LS_UNKNOWN_ERROR 1

// A handle is invalid
#define LS_INVALID_HANDLE 2

// There is insufficient memory to complete the operation
#define LS_OUT_OF_MEMORY 3

// One or more arguments are invalid
#define LS_INVALID_ARGUMENT 4

// An invalid state was detected
#define LS_INVALID_STATE 5

// The object is not waitable
#define LS_NOT_WAITABLE 6

// Access denied
#define LS_ACCESS_DENIED 7

// File not found
#define LS_FILE_NOT_FOUND 8

// Buffer too small, retry with a larger buffer
#define LS_BUFFER_TOO_SMALL 9

// Invalid character encoding
#define LS_INVALID_ENCODING 10

// File sharing violation
#define LS_SHARING_VIOLATION 11

// A value is out of range
#define LS_OUT_OF_RANGE 12

// The operation is not supported
#define LS_NOT_SUPPORTED 13

// The path was not found
#define LS_PATH_NOT_FOUND 14

// The end of the file has been reached
#define LS_END_OF_FILE 15

// The object already exists
#define LS_ALREADY_EXISTS 16

// The object was not found
#define LS_NOT_FOUND 17

// The pipe is broken
#define LS_BAD_PIPE 18

// No more files
#define LS_NO_MORE_FILES 19

// No data is available
#define LS_NO_DATA 20

// The device is not ready to perform the operation
#define LS_NOT_READY 21

// A deadlock was detected
#define LS_DEADLOCK 22

// The operation was interrupted
#define LS_INTERRUPTED 23

// An I/O error occurred
#define LS_IO_ERROR 24

// The disk is full
#define LS_DISK_FULL 25

// The device is busy
#define LS_BUSY 26

// The operation timed out
#define LS_TIMEDOUT 27

// The path is invalid
#define LS_INVALID_PATH 28

// An invalid image was detected
#define LS_INVALID_IMAGE 29

// An operation was canceled
#define LS_CANCELED 30

// An internal error occurred
#define LS_INTERNAL_ERROR 31

// The function is not implemented
#define LS_NOT_IMPLEMENTED 100

#endif // _LS_ERROR_H_
Loading

0 comments on commit cb3c022

Please sign in to comment.