Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found
Sélectionner une révision Git
Loading items

Cible

Sélectionner le projet cible
  • martin2018/lektor
1 résultat
Sélectionner une révision Git
Loading items
Afficher les modifications
Validations sur la source (6)
Affichage de avec 184 ajouts et 316 suppressions
...@@ -9,7 +9,6 @@ Prerequisites: ...@@ -9,7 +9,6 @@ Prerequisites:
- [meson](https://mesonbuild.com/) - [meson](https://mesonbuild.com/)
- a C compiler with C18 support (e.g. `gcc>8.1`, `clang>7.0`) - a C compiler with C18 support (e.g. `gcc>8.1`, `clang>7.0`)
- the [libpcre](http://www.pcre.org/) development library
- the [sqlite3](https://www.sqlite.org/) development library, version 3.31.0 or - the [sqlite3](https://www.sqlite.org/) development library, version 3.31.0 or
newer for [generated columns](https://www.sqlite.org/gencol.html) support newer for [generated columns](https://www.sqlite.org/gencol.html) support
- the [json-c](https://github.com/json-c/json-c) development library - the [json-c](https://github.com/json-c/json-c) development library
...@@ -25,16 +24,19 @@ configuration file: ...@@ -25,16 +24,19 @@ configuration file:
- mkvpropedit from [mkvtoolnix](https://gitlab.com/mbunkus/mkvtoolnix) - mkvpropedit from [mkvtoolnix](https://gitlab.com/mbunkus/mkvtoolnix)
- the bourn shell again: [bash](https://git.savannah.gnu.org/cgit/bash.git) - the bourn shell again: [bash](https://git.savannah.gnu.org/cgit/bash.git)
- the command line tool [sqlite](https://www.sqlite.org/) - the command line tool xxd, is distributed in the
[vim](https://www.archlinux.org/packages/extra/x86_64/vim/) and
[gvim](https://www.archlinux.org/packages/extra/x86_64/gvim/) packages on
archlinux, seems to be distributed in its own package on debian:
[xxd](https://packages.debian.org/sid/xxd)
The manual way of installing and setting up lektor: The manual way of installing and setting up lektor:
```sh ```sh
meson build sudo mkdir /home/kara && sudo chown USER:USER /home/kara
ninja -C build meson build && cd build
./build/lktadm init database # Create the database ninja && ninja install
./build/lktadm init metadata # Modify mkv, if the metadata ar already set do not do this sudo chown USER:USER /home/kara/kara.db
./build/lktadm init populate # Papulate the database with karas on the filesystem
``` ```
You may need to put the `lib_window_x11.so` in the right directory to have the You may need to put the `lib_window_x11.so` in the right directory to have the
...@@ -52,20 +54,14 @@ lektor can store it in its database. This information is to be directly ...@@ -52,20 +54,14 @@ lektor can store it in its database. This information is to be directly
written in the `.mkv` file. written in the `.mkv` file.
For that purpose, run the `karadata` from the command-line, with your kara as an For that purpose, run the `karadata` from the command-line, with your kara as an
argument, like: argument. For that, karas must be placed in a folder hierarchy like the following:
``` ```
./lktadm --file /path/to/my/kara.mkv /some/directory/$CAT/$LANG/$AUTH/$SOURCE - $TYPE$NUM - $TITLE.mkv
``` ```
or The ideal way of populating lektor is using *Kurisu*. The *update* and *rescan*
commands are here for that.
```
./lktadm --prompt-file /path/to/my/kara.mkv
```
A karamaker may use the `scripts/karafont.py` to set the right MIME type for
fonts (stored as attachments in the mkv).
## How to launch lektor ## How to launch lektor
...@@ -78,6 +74,8 @@ card with optimus (in almose every laptop), please use `optirun` or `primusrun`: ...@@ -78,6 +74,8 @@ card with optimus (in almose every laptop), please use `optirun` or `primusrun`:
optirun ./lektord optirun ./lektord
``` ```
The `x11` module may have some issues with `optirun` and `primusrun`.
## How to use lektor ## How to use lektor
Lektor is compatible with mpd, which means that you can use any client (only mpc is Lektor is compatible with mpd, which means that you can use any client (only mpc is
...@@ -94,7 +92,7 @@ done by the same INI file using diferent sections. ...@@ -94,7 +92,7 @@ done by the same INI file using diferent sections.
Lektor searches for the configuration file in that order: Lektor searches for the configuration file in that order:
- `$(pwd)/lektor.ini` - `$(pwd)/lektor.ini`
- if XDG_CONFIG_HOME defined then `$XDG_CONFIG_HOME/lektor/lektor.ini` else - if `XDG_CONFIG_HOME` defined then `$XDG_CONFIG_HOME/lektor/lektor.ini` else
`$HOME/.config/lektor/lektor.ini` `$HOME/.config/lektor/lektor.ini`
- `/opt/lektor/lektor.ini` - `/opt/lektor/lektor.ini`
- `/usr/local/etc/lektor.ini` - `/usr/local/etc/lektor.ini`
...@@ -103,7 +101,11 @@ Lektor searches for the configuration file in that order: ...@@ -103,7 +101,11 @@ Lektor searches for the configuration file in that order:
The first one to be found is picked up by lektor. Note that if the environment The first one to be found is picked up by lektor. Note that if the environment
variable `XDG_CONFIG_HOME` is not defined, it is replaced by `HOME/.config`. variable `XDG_CONFIG_HOME` is not defined, it is replaced by `HOME/.config`.
To get the default config file, you can use the `lktadm` command. To get the default config file, you can use the `lktadm` command. To see what
are the settings used by lektor, you can also use the `lktadm` command.
Be aware that if the home directory or the `XDG_CONFIG_HOME` are too long
they will be ignored.
## Modules ## Modules
...@@ -114,12 +116,14 @@ function named `module_set_function` which takes a `void *` and a ...@@ -114,12 +116,14 @@ function named `module_set_function` which takes a `void *` and a
The name of this function can be defined in the INI file. The name of this function can be defined in the INI file.
Module can be configured with the ini configuration file in a section named Module can be configured with the ini configuration file in a section named
`module_${name}`. `module_${name}`, this a convention but it can be anything as long as it
don't make collision with sections used by lektor (may be fine, but don't to
this!).
Like in the *player*, modules are loaded into slots and **must be** refered by Like in the *player*, modules are loaded into slots and **must be** refered by
their section name. The function used to load the `.so` file will be determied their section name. The function used to load the `.so` file will be determied
depending on the context in which the module is configured and will pass the by the `load_function` property. The path to the `.so` file is determined by
option corresponding on the section's name. the `path` property.
## MPD ## MPD
......
...@@ -36,6 +36,10 @@ Display the metadata of a kara specified by the its path ...@@ -36,6 +36,10 @@ Display the metadata of a kara specified by the its path
.TP .TP
\fBconf\fP \fBconf\fP
Prints the default configuration file to stdout Prints the default configuration file to stdout
.TP
\fBsource\fP
Prints the configuration that is red by lektor, this is the configuration that
will use \fBlektord\fP when launched. Usefull when debuging
.PP .PP
\fIINITIALISATION-COMMANDS\fP \fIINITIALISATION-COMMANDS\fP
......
#pragma once #pragma once
#include <common/define.h>
#include <common/macro.h> #include <common/macro.h>
#include <unistd.h>
#include <stdint.h>
#define not_implemented() __not_implemented(__func__,__FILE__,__LINE__) #define not_implemented() __not_implemented(__func__,__FILE__,__LINE__)
extern void __not_implemented(const char *func, char *file, int line); extern void __not_implemented(const char *func, char *file, int line);
...@@ -10,3 +11,26 @@ extern void __not_implemented(const char *func, char *file, int line); ...@@ -10,3 +11,26 @@ extern void __not_implemented(const char *func, char *file, int line);
void __unused(void *, ...); void __unused(void *, ...);
long get_mtime(const char *path); long get_mtime(const char *path);
void *safe_malloc(size_t size);
int is_utf8(const char *string);
/* Read `bytes` as the big endian representation of a 32-bit unsigned integer.
`n` is the number of bytes in `bytes`
Returns 0 if n is 0.
Restriction: n <= 4 */
uint32_t be_uint32_t(const uint8_t bytes[], size_t n);
/* Same as `be_uint32_t` but for 64-bit unsigned integers.
Restriction: n <= 8 */
uint64_t be_uint64_t(const uint8_t bytes[], size_t n);
/* Trim the string `str` of the char `c` from the right and the left.
The string may not be null terminated.
Returns a pointer to the the trimmed string
Restrictions: the len of the string must be `len`. */
char *trim(char *str, size_t len, char c);
/* Get a line from stdin safely. */
int get_stdin_line(const char *prompt, char *buf, size_t len);
#pragma once
/* Max value for any buffer, to not squash the stack. */
#define BUFFER_MAX 4096
#ifndef __GNUC__
#define inline
#endif
#pragma once #pragma once
#include <stdint.h>
#include <stdlib.h>
/* Max value for any buffer, to not squash the stack. */
#define BUFFER_MAX 4096
#ifndef __GNUC__
#define inline
#endif
/* Macros */
#define BRACKETS_THAT(that) (that) #define BRACKETS_THAT(that) (that)
#ifndef MAX #ifndef MAX
...@@ -51,3 +63,109 @@ ...@@ -51,3 +63,109 @@
#define LOG_WARN(format, ...) LOG_WARN_SCT("", format, __VA_ARGS__) #define LOG_WARN(format, ...) LOG_WARN_SCT("", format, __VA_ARGS__)
#define LOG_ERROR(format, ...) LOG_DEBUG_SCT("", format, __VA_ARGS__) #define LOG_ERROR(format, ...) LOG_DEBUG_SCT("", format, __VA_ARGS__)
#define LOG_DEBUG(format, ...) LOG_DEBUG_SCT("", format, __VA_ARGS__) #define LOG_DEBUG(format, ...) LOG_DEBUG_SCT("", format, __VA_ARGS__)
/* Defines for lektor */
#define INI_MAX_LINE_LEN 512
#define INI_MAX_SECTION_LEN 80
#define URL_MAX_LEN 1024
#define DEFAULT_URL "https://kurisu.iiens.net"
#define GET_ID_JSON DEFAULT_URL "/api_karas.php?id=%ld"
#define GET_ID_FILE DEFAULT_URL "/download.php?id=%ld"
#define SELF_EXECUTABLE_LINUX "/proc/self/exe"
#define SELF_EXECUTABLE_FREEBSD "/proc/curproc/file"
#define SELF_EXECUTABLE_SOLARIS "/proc/self/path/a.out"
#define LKT_MAX_SQLITE_STATEMENT 1024
#define PROTECTED_DATABASE "disk"
#define LKT_DATABASE_NAME_KID "id"
#define LKT_DATABASE_NAME_KNAME "source_name"
#define LKT_DATABASE_NAME_KTITLE "song_title"
#define LKT_DATABASE_NAME_KCAT "category"
#define LKT_DATABASE_NAME_KTYPE "song_type"
#define LKT_DATABASE_NAME_KAUTHOR "author_name"
#define LKT_DATABASE_NAME_KAUTHOR_YEAR "author_year"
#define LKT_DATABASE_NAME_KLANG "language"
#define LKT_DATABASE_KARA_COLUMNT_ANY "any_col"
#define LKT_DATABASE_KARA_ALL "string"
#define LEKTOR_TAG_MAX 256
#define LKT_MESSAGE_ARGS_MAX 32
#define LKT_MESSAGE_MAX 2048
#define LKT_DEFAULT_LIST_SIZE 10
typedef volatile enum {
MPD_IDLE_NONE = 0,
MPD_IDLE_DATABASE = ( 1 << 1 ),
MPD_IDLE_UPDATE = ( 1 << 2 ),
MPD_IDLE_STORED_PLAYLIST = ( 1 << 3 ),
MPD_IDLE_PLAYLIST = ( 1 << 4 ),
MPD_IDLE_PLAYER = ( 1 << 5 ),
MPD_IDLE_MIXER = ( 1 << 6 ),
MPD_IDLE_OUTPUT = ( 1 << 7 ),
MPD_IDLE_OPTIONS = ( 1 << 8 ),
MPD_IDLE_PARTITION = ( 1 << 9 ),
MPD_IDLE_STICKER = ( 1 << 10 ),
MPD_IDLE_SUBSCRIPTION = ( 1 << 11 ),
MPD_IDLE_MESSAGE = ( 1 << 12 ),
MPD_IDLE_ALL =
MPD_IDLE_DATABASE | MPD_IDLE_UPDATE | MPD_IDLE_STORED_PLAYLIST |
MPD_IDLE_PLAYLIST | MPD_IDLE_PLAYER | MPD_IDLE_MIXER |
MPD_IDLE_OUTPUT | MPD_IDLE_OPTIONS | MPD_IDLE_PARTITION |
MPD_IDLE_STICKER | MPD_IDLE_SUBSCRIPTION | MPD_IDLE_MESSAGE,
} mpd_idle_flag;
#define LKT_BACKLOG 32
#define COMMAND_LIST_MAX 64
#define BUFFER_OUT_MAX 16
#define MPD_VERSION "0.21.16"
/* Macros */
#define SQLITE_PREPARE(db, stmt, SQL, goto_label) \
if (sqlite3_prepare_v2((sqlite3 *) db, SQL, -1, &(stmt), 0) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to prepare statement: %s", \
sqlite3_errmsg((sqlite3 *) db)); \
goto goto_label; \
}
#define SQLITE_EXEC(db, SQL, goto_label) \
if (sqlite3_exec((sqlite3 *) db, SQL, NULL, NULL, NULL) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to exec statement: %s", \
sqlite3_errmsg((sqlite3 *) db)); \
goto goto_label; \
}
#define SQLITE_BIND_TEXT(db, stmt, pos, text, error) \
if (sqlite3_bind_text(stmt, pos, text, -1, 0) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to bind text %s at pos %d: %s", \
text, pos, sqlite3_errmsg((sqlite3 *) db)); \
goto error; \
}
#define SQLITE_BIND_INT(db, stmt, pos, integer, error) \
if (sqlite3_bind_int(stmt, pos, integer) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to bind int %d at pos %d: %s", \
integer, pos, sqlite3_errmsg((sqlite3 *) db)); \
goto error; \
}
#define SQLITE_STEP(db, stmt, code, error) \
if (sqlite3_step(stmt) != code) { \
LOG_ERROR_SCT("DB", "Failed to step: %s", \
sqlite3_errmsg((sqlite3 *) db)); \
goto error; \
}
#define SQLITE_STEP_ROW(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_ROW, error)
#define SQLITE_STEP_DONE(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_DONE, error)
#define SQLITE_STEP_OK(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_OK, error)
#define SQLITE_DO_ROLLBACK(db) \
sqlite3_exec((sqlite3 *) db, "ROLLBACK TRANSACTION;\n", NULL, NULL, NULL);
/* inih -- simple .INI file parser
SPDX-License-Identifier: BSD-3-Clause
Copyright (C) 2009-2020, Ben Hoyt */
#ifndef __INI_H__
#define __INI_H__
/* Make this header file easier to include in C++ code */
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
/* Nonzero if ini_handler callback should accept lineno parameter. */
#ifndef INI_HANDLER_LINENO
#define INI_HANDLER_LINENO 0
#endif
/* Typedef for prototype of handler function. */
#if INI_HANDLER_LINENO
typedef int (*ini_handler)(void *user, const char *section,
const char *name, const char *value,
int lineno);
#else
typedef int (*ini_handler)(void *user, const char *section,
const char *name, const char *value);
#endif
/* Typedef for prototype of fgets-style reader function. */
typedef char *(*ini_reader)(char *str, int num, void *stream);
/* Parse given INI-style file. May have [section]s, name=value pairs
(whitespace stripped), and comments starting with ';' (semicolon). Section
is "" if name=value pair parsed before any section heading. name:value
pairs are also supported as a concession to Python's configparser.
For each name=value pair parsed, call handler function with given user
pointer as well as section, name, and value (data only valid for duration
of handler call). Handler should return nonzero on success, zero on error.
Returns 0 on success, line number of first error on parse error (doesn't
stop on first error), -1 on file open error, or -2 on memory allocation
error (only when INI_USE_STACK is zero).
*/
int ini_parse(const char *filename, ini_handler handler, void *user);
/* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
close the file when it's finished -- the caller must do that. */
int ini_parse_file(FILE *file, ini_handler handler, void *user);
/* Same as ini_parse(), but takes an ini_reader function pointer instead of
filename. Used for implementing custom or string-based I/O (see also
ini_parse_string). */
int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
void *user);
/* Same as ini_parse(), but takes a zero-terminated string with the INI data
instead of a file. Useful for parsing INI data from a network socket or
already in memory. */
int ini_parse_string(const char *string, ini_handler handler, void *user);
/* Nonzero to allow multi-line value parsing, in the style of Python's
configparser. If allowed, ini_parse() will call the handler with the same
name for each subsequent line parsed. */
#ifndef INI_ALLOW_MULTILINE
#define INI_ALLOW_MULTILINE 1
#endif
/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
the file. See https://github.com/benhoyt/inih/issues/21 */
#ifndef INI_ALLOW_BOM
#define INI_ALLOW_BOM 1
#endif
/* Chars that begin a start-of-line comment. Per Python configparser, allow
both ; and # comments at the start of a line by default. */
#ifndef INI_START_COMMENT_PREFIXES
#define INI_START_COMMENT_PREFIXES ";#"
#endif
/* Nonzero to allow inline comments (with valid inline comment characters
specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match
Python 3.2+ configparser behaviour. */
#ifndef INI_ALLOW_INLINE_COMMENTS
#define INI_ALLOW_INLINE_COMMENTS 1
#endif
#ifndef INI_INLINE_COMMENT_PREFIXES
#define INI_INLINE_COMMENT_PREFIXES ";"
#endif
/* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */
#ifndef INI_USE_STACK
#define INI_USE_STACK 1
#endif
/* Maximum line length for any line in INI file (stack or heap). Note that
this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */
#ifndef INI_MAX_LINE
#define INI_MAX_LINE 200
#endif
/* Nonzero to allow heap line buffer to grow via realloc(), zero for a
fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is
zero. */
#ifndef INI_ALLOW_REALLOC
#define INI_ALLOW_REALLOC 0
#endif
/* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK
is zero. */
#ifndef INI_INITIAL_ALLOC
#define INI_INITIAL_ALLOC 200
#endif
/* Stop parsing on first error (default is to keep parsing). */
#ifndef INI_STOP_ON_FIRST_ERROR
#define INI_STOP_ON_FIRST_ERROR 0
#endif
/* Nonzero to call the handler at the start of each new section (with
name and value NULL). Default is to only call the handler on
each name=value pair. */
#ifndef INI_CALL_HANDLER_ON_NEW_SECTION
#define INI_CALL_HANDLER_ON_NEW_SECTION 0
#endif
/* Nonzero to allow a name without a value (no '=' or ':' on the line) and
call the handler with value NULL in this case. Default is to treat
no-value lines as an error. */
#ifndef INI_ALLOW_NO_VALUE
#define INI_ALLOW_NO_VALUE 0
#endif
#ifdef __cplusplus
}
#endif
#endif /* __INI_H__ */
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#pragma once #pragma once
#include <lektor/common.h> #include <common/common.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
......
#pragma once #pragma once
#include <lektor/common.h> #include <common/common.h>
#include <lektor/net.h> #include <lektor/net.h>
#include <lektor/window.h> #include <lektor/window.h>
......
#pragma once
#include <common/macro.h>
#include <common/define.h>
#include <stdint.h>
#include <stdlib.h>
/* Defines */
#define URL_MAX_LEN 1024
#define DEFAULT_URL "https://kurisu.iiens.net"
#define GET_ID_JSON DEFAULT_URL "/api_karas.php?id=%ld"
#define GET_ID_FILE DEFAULT_URL "/download.php?id=%ld"
#define SELF_EXECUTABLE_LINUX "/proc/self/exe"
#define SELF_EXECUTABLE_FREEBSD "/proc/curproc/file"
#define SELF_EXECUTABLE_SOLARIS "/proc/self/path/a.out"
#define LKT_MAX_SQLITE_STATEMENT 1024
#define PROTECTED_DATABASE "disk"
#define LKT_DATABASE_NAME_KID "id"
#define LKT_DATABASE_NAME_KNAME "source_name"
#define LKT_DATABASE_NAME_KTITLE "song_title"
#define LKT_DATABASE_NAME_KCAT "category"
#define LKT_DATABASE_NAME_KTYPE "song_type"
#define LKT_DATABASE_NAME_KAUTHOR "author_name"
#define LKT_DATABASE_NAME_KAUTHOR_YEAR "author_year"
#define LKT_DATABASE_NAME_KLANG "language"
#define LKT_DATABASE_KARA_COLUMNT_ANY "any_col"
#define LKT_DATABASE_KARA_ALL "string"
#define LEKTOR_TAG_MAX 256
#define LKT_MESSAGE_ARGS_MAX 32
#define LKT_MESSAGE_MAX 2048
#define LKT_DEFAULT_LIST_SIZE 10
typedef volatile enum {
MPD_IDLE_NONE = 0,
MPD_IDLE_DATABASE = ( 1 << 1 ),
MPD_IDLE_UPDATE = ( 1 << 2 ),
MPD_IDLE_STORED_PLAYLIST = ( 1 << 3 ),
MPD_IDLE_PLAYLIST = ( 1 << 4 ),
MPD_IDLE_PLAYER = ( 1 << 5 ),
MPD_IDLE_MIXER = ( 1 << 6 ),
MPD_IDLE_OUTPUT = ( 1 << 7 ),
MPD_IDLE_OPTIONS = ( 1 << 8 ),
MPD_IDLE_PARTITION = ( 1 << 9 ),
MPD_IDLE_STICKER = ( 1 << 10 ),
MPD_IDLE_SUBSCRIPTION = ( 1 << 11 ),
MPD_IDLE_MESSAGE = ( 1 << 12 ),
MPD_IDLE_ALL =
MPD_IDLE_DATABASE | MPD_IDLE_UPDATE | MPD_IDLE_STORED_PLAYLIST |
MPD_IDLE_PLAYLIST | MPD_IDLE_PLAYER | MPD_IDLE_MIXER |
MPD_IDLE_OUTPUT | MPD_IDLE_OPTIONS | MPD_IDLE_PARTITION |
MPD_IDLE_STICKER | MPD_IDLE_SUBSCRIPTION | MPD_IDLE_MESSAGE,
} mpd_idle_flag;
#define LKT_BACKLOG 32
#define COMMAND_LIST_MAX 64
#define BUFFER_OUT_MAX 16
#define MPD_VERSION "0.21.16"
/* Macros */
#define SQLITE_PREPARE(db, stmt, SQL, goto_label) \
if (sqlite3_prepare_v2((sqlite3 *) db, SQL, -1, &(stmt), 0) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to prepare statement: %s", \
sqlite3_errmsg((sqlite3 *) db)); \
goto goto_label; \
}
#define SQLITE_EXEC(db, SQL, goto_label) \
if (sqlite3_exec((sqlite3 *) db, SQL, NULL, NULL, NULL) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to exec statement: %s", \
sqlite3_errmsg((sqlite3 *) db)); \
goto goto_label; \
}
#define SQLITE_BIND_TEXT(db, stmt, pos, text, error) \
if (sqlite3_bind_text(stmt, pos, text, -1, 0) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to bind text %s at pos %d: %s", \
text, pos, sqlite3_errmsg((sqlite3 *) db)); \
goto error; \
}
#define SQLITE_BIND_INT(db, stmt, pos, integer, error) \
if (sqlite3_bind_int(stmt, pos, integer) != SQLITE_OK) { \
LOG_ERROR_SCT("DB", "Failed to bind int %d at pos %d: %s", \
integer, pos, sqlite3_errmsg((sqlite3 *) db)); \
goto error; \
}
#define SQLITE_STEP(db, stmt, code, error) \
if (sqlite3_step(stmt) != code) { \
LOG_ERROR_SCT("DB", "Failed to step: %s", \
sqlite3_errmsg((sqlite3 *) db)); \
goto error; \
}
#define SQLITE_STEP_ROW(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_ROW, error)
#define SQLITE_STEP_DONE(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_DONE, error)
#define SQLITE_STEP_OK(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_OK, error)
#define SQLITE_DO_ROLLBACK(db) \
sqlite3_exec((sqlite3 *) db, "ROLLBACK TRANSACTION;\n", NULL, NULL, NULL);
/* Random things */
/* Read `bytes` as the big endian representation of a 32-bit unsigned integer.
`n` is the number of bytes in `bytes`
Returns 0 if n is 0.
Restriction: n <= 4 */
uint32_t be_uint32_t(const uint8_t bytes[], size_t n);
/* Same as `be_uint32_t` but for 64-bit unsigned integers.
Restriction: n <= 8 */
uint64_t be_uint64_t(const uint8_t bytes[], size_t n);
/* Trim the string `str` of the char `c` from the right and the left.
The string may not be null terminated.
Returns a pointer to the the trimmed string
Restrictions: the len of the string must be `len`. */
char *trim(char *str, size_t len, char c);
/* Get a line from stdin safely. */
int get_stdin_line(const char *prompt, char *buf, size_t len);
#pragma once #pragma once
#include <lektor/common.h> #include <common/common.h>
#include <stddef.h> #include <stddef.h>
#include <sqlite3.h> #include <sqlite3.h>
...@@ -30,7 +30,7 @@ static const char *const lkt_default_config_file = ...@@ -30,7 +30,7 @@ static const char *const lkt_default_config_file =
"; can be seen.\n" "; can be seen.\n"
"[player]\n" "[player]\n"
"autoclear = true ; Clear the queue when starting\n" "autoclear = true ; Clear the queue when starting\n"
"module = module_winx11 ; Default module for the window\n" "module = module_x11 ; Default module for the window\n"
"def_random = false ; Play at random per default\n" "def_random = false ; Play at random per default\n"
"def_consume = false ; Consume per default\n" "def_consume = false ; Consume per default\n"
"def_single = false ; Single per default\n" "def_single = false ; Single per default\n"
......
#pragma once #pragma once
#include <lektor/common.h> #include <common/common.h>
#include <lektor/mkv.h> #include <lektor/mkv.h>
#include <lektor/uri.h> #include <lektor/uri.h>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
*/ */
#pragma once #pragma once
#include <lektor/common.h> #include <common/common.h>
#include <linux/limits.h> #include <linux/limits.h>
#include <stddef.h> #include <stddef.h>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <sqlite3.h> #include <sqlite3.h>
#include <mpv/client.h> #include <mpv/client.h>
#include <lektor/net.h> #include <lektor/net.h>
#include <lektor/common.h> #include <common/common.h>
void lmpv_free(mpv_handle **ctx); void lmpv_free(mpv_handle **ctx);
mpv_handle *lmpv_new(unsigned long int wid); mpv_handle *lmpv_new(unsigned long int wid);
......
#pragma once #pragma once
#include <common/common.h>
#include <lektor/mkv.h> #include <lektor/mkv.h>
#include <lektor/common.h>
#include <lektor/config.h> #include <lektor/config.h>
#include <lektor/window.h> #include <lektor/window.h>
#include <lektor/thread.h> #include <lektor/thread.h>
......
#pragma once #pragma once
#include <lektor/common.h> #include <common/common.h>
#include <pthread.h> #include <pthread.h>
#include <sys/types.h> #include <sys/types.h>
......
#pragma once #pragma once
#include <lektor/common.h>
#include <stddef.h> #include <stddef.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
......
#pragma once #pragma once
#include <lektor/common.h> #include <common/common.h>
#include <stdbool.h> #include <stdbool.h>
#include <sqlite3.h> #include <sqlite3.h>
......
...@@ -60,8 +60,6 @@ void mthread_spinlock_lock (mthread_tst_t *atomic); ...@@ -60,8 +60,6 @@ void mthread_spinlock_lock (mthread_tst_t *atomic);
void mthread_spinlock_unlock(mthread_tst_t *atomic); void mthread_spinlock_unlock(mthread_tst_t *atomic);
int mthread_get_vp_rank(); int mthread_get_vp_rank();
void *safe_malloc(size_t size);
void mthread_insert_first(struct mthread_s *item, mthread_list_t *list); void mthread_insert_first(struct mthread_s *item, mthread_list_t *list);
void mthread_insert_last (struct mthread_s *item, mthread_list_t *list); void mthread_insert_last (struct mthread_s *item, mthread_list_t *list);
int mthread_list_test (struct mthread_s *item, mthread_list_t *list); int mthread_list_test (struct mthread_s *item, mthread_list_t *list);
......
...@@ -31,7 +31,6 @@ add_global_arguments('-D_REENTRANT', language: 'c') ...@@ -31,7 +31,6 @@ add_global_arguments('-D_REENTRANT', language: 'c')
## Sources for mthread ## Sources for mthread
mthread_sources = [ 'src/mthread/mthread.c' mthread_sources = [ 'src/mthread/mthread.c'
, 'src/mthread/mthread_cond.c' , 'src/mthread/mthread_cond.c'
, 'src/mthread/mthread_debug.c'
, 'src/mthread/mthread_key.c' , 'src/mthread/mthread_key.c'
, 'src/mthread/mthread_mutex.c' , 'src/mthread/mthread_mutex.c'
, 'src/mthread/mthread_once.c' , 'src/mthread/mthread_once.c'
...@@ -58,7 +57,6 @@ core_sources = [ 'src/mkv/bufferfd.c' ...@@ -58,7 +57,6 @@ core_sources = [ 'src/mkv/bufferfd.c'
, 'src/net/downloader.c' , 'src/net/downloader.c'
, 'src/config.c' , 'src/config.c'
, 'src/uri.c' , 'src/uri.c'
, 'src/ini/ini.c'
, 'src/thread.c' , 'src/thread.c'
] ]
......
...@@ -15,4 +15,5 @@ type $LKTADM &>/dev/null ...@@ -15,4 +15,5 @@ type $LKTADM &>/dev/null
$LKTADM conf > $LKT_INI || die $LKTADM conf > $LKT_INI || die
sed "s+LKT_PREFIX+$MESON_INSTALL_PREFIX+g" $LKT_INI || die sed "s+LKT_PREFIX+$MESON_INSTALL_PREFIX+g" $LKT_INI || die
mkdir /home/kara >&/dev/null || echo '/home/kara already exists' mkdir /home/kara >&/dev/null || echo '/home/kara already exists'
$LKTADM source || die
$LKTADM init database || die $LKTADM init database || die